diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp index 9a2ef7b42e..5f89bd492b 100644 --- a/pcbnew/clean.cpp +++ b/pcbnew/clean.cpp @@ -167,7 +167,6 @@ void PCB_EDIT_FRAME::Clean_Pcb() m_canvas->Refresh( true ); } -extern void RebuildTrackChain ( BOARD *brd); void TRACKS_CLEANER::buildTrackConnectionInfo() { @@ -175,8 +174,6 @@ void TRACKS_CLEANER::buildTrackConnectionInfo() connectivity->Build(m_brd); - //RebuildTrackChain ( m_brd ); - // clear flags and variables used in cleanup for( auto track : m_brd->Tracks() ) { @@ -199,17 +196,6 @@ void TRACKS_CLEANER::buildTrackConnectionInfo() } } } - -#if 0 - printf("bci\n"); - for( TRACK* segment = m_brd->m_Track; segment; segment = segment->Next() ) - { - if( segment->Type() == PCB_TRACE_T ) - { - printf("s %d %d %d %d %d %x\n", segment->GetStart().x, segment->GetStart().y, segment->GetEnd().x, segment->GetEnd().y, segment->GetLayer(), segment->GetStatus() ); - } - } -#endif } @@ -668,46 +654,6 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* aCandidate->GetEnd().y - aCandidate->GetStart().y ) ) return NULL; - /* Here we have 2 aligned segments: - * We must change the pt_ref common point only if not on a pad - * (this function) is called when there is only 2 connected segments, - * and if this point is not on a pad, it can be removed and the 2 segments will be merged - */ - - - -#if 0 - - - if(aTrackRef->GetNetCode() == 47) - { - auto pads = m_brd->GetConnectivity()->GetConnectedPads( aTrackRef ); - printf("eps ref %d %d-%d %d pads-con %d eop %d sop %d\n", - aTrackRef->GetStart().x, - aTrackRef->GetStart().y, - aTrackRef->GetEnd().x, - aTrackRef->GetEnd().y, - pads.size(), - !!aTrackRef->GetState(END_ON_PAD), - !!aTrackRef->GetState(START_ON_PAD) - - ); - - pads = m_brd->GetConnectivity()->GetConnectedPads( aCandidate ); - printf("eps cand %d %d-%d %d pads-con %d eop %d sop %d\n", - aCandidate->GetStart().x, - aCandidate->GetStart().y, - aCandidate->GetEnd().x, - aCandidate->GetEnd().y, - pads.size(), - !!aCandidate->GetState(END_ON_PAD), - !!aCandidate->GetState(START_ON_PAD) - ); - - } - -#endif - auto connectivity = m_brd->GetConnectivity(); updateConn( aTrackRef, connectivity ); diff --git a/pcbnew/connectivity.cpp b/pcbnew/connectivity.cpp index 41cd2ea442..c1d779e7ac 100644 --- a/pcbnew/connectivity.cpp +++ b/pcbnew/connectivity.cpp @@ -440,13 +440,6 @@ unsigned int CONNECTIVITY_DATA::GetLinksCount() const } -unsigned int CONNECTIVITY_DATA::GetConnectedCount() const -{ - return 0; - assert( false ); -} - - unsigned int CONNECTIVITY_DATA::GetNodeCount( int aNet ) const { return 0; diff --git a/pcbnew/connectivity.h b/pcbnew/connectivity.h index 99baf0aaa0..61c38398ad 100644 --- a/pcbnew/connectivity.h +++ b/pcbnew/connectivity.h @@ -157,9 +157,6 @@ public: unsigned int GetLinksCount() const; - unsigned int GetConnectedCount() const; - - unsigned int GetNodeCount( int aNet = -1 ) const; unsigned int GetPadCount( int aNet = -1 ) const; diff --git a/pcbnew/connectivity_algo.cpp b/pcbnew/connectivity_algo.cpp index f9c56102ac..fafb1d99e1 100644 --- a/pcbnew/connectivity_algo.cpp +++ b/pcbnew/connectivity_algo.cpp @@ -888,23 +888,6 @@ const VECTOR2I CN_ZONE::GetAnchor( int n ) const } -/*const std::vector CN_CLUSTER::GetAnchors() -{ - std::vector anchors; - - for( auto item : m_items ) - { - int cnt = item->AnchorCount(); - for(int i = 0 ; i < cnt; i++) - { - anchors.push_back( item->GetAnchor(i) ); - } - } - - return anchors; -}*/ - - int CN_ITEM::Net() const { if( !m_parent ) diff --git a/pcbnew/ratsnest_data.cpp b/pcbnew/ratsnest_data.cpp index 18e44ad7e6..535b390d74 100644 --- a/pcbnew/ratsnest_data.cpp +++ b/pcbnew/ratsnest_data.cpp @@ -61,32 +61,6 @@ static bool sortWeight( const CN_EDGE& aEdge1, const CN_EDGE& aEdge2 ) } -/*bool operator==( const RN_NODE_PTR& aFirst, const RN_NODE_PTR& aSecond ) - * { - * return aFirst->GetX() == aSecond->GetX() && aFirst->GetY() == aSecond->GetY(); - * } - * - * bool operator!=( const RN_NODE_PTR& aFirst, const RN_NODE_PTR& aSecond ) - * { - * return aFirst->GetX() != aSecond->GetX() || aFirst->GetY() != aSecond->GetY(); - * } - * - * RN_NODE_AND_FILTER operator&&( const RN_NODE_FILTER& aFilter1, const RN_NODE_FILTER& aFilter2 ) - * { - * return RN_NODE_AND_FILTER( aFilter1, aFilter2 ); - * } - * - * RN_NODE_OR_FILTER operator||( const RN_NODE_FILTER& aFilter1, const RN_NODE_FILTER& aFilter2 ) - * { - * return RN_NODE_OR_FILTER( aFilter1, aFilter2 ); - * } - * - * static bool isEdgeConnectingNode( const RN_EDGE_PTR& aEdge, const RN_NODE_PTR& aNode ) - * { - * return aEdge->GetSourceNode() == aNode || aEdge->GetTargetNode() == aNode; - * } - */ - static const std::vector kruskalMST( std::list& aEdges, std::vector& aNodes ) { @@ -385,257 +359,6 @@ void RN_NET::Clear() m_dirty = true; } -#if 0 - -const RN_NODE_PTR RN_NET::GetClosestNode( const RN_NODE_PTR& aNode ) const -{ - /*const RN_LINKS::RN_NODE_SET& nodes = m_links.GetNodes(); - * RN_LINKS::RN_NODE_LISt::const_iterator it, itEnd; - * - * unsigned int minDistance = std::numeric_limits::max(); - * RN_NODE_PTR closest; - * - * for( it = nodes.begin(), itEnd = nodes.end(); it != itEnd; ++it ) - * { - * RN_NODE_PTR node = *it; - * - * // Obviously the distance between node and itself is the shortest, - * // that's why we have to skip it - * if( node != aNode ) - * { - * unsigned int distance = getDistance( node, aNode ); - * if( distance < minDistance ) - * { - * minDistance = distance; - * closest = node; - * } - * } - * } - * - * return closest;*/ -} - - -const RN_NODE_PTR RN_NET::GetClosestNode( const RN_NODE_PTR& aNode, - const RN_NODE_FILTER& aFilter ) const -{ - /*const RN_LINKS::RN_NODE_SET& nodes = m_links.GetNodes(); - * RN_LINKS::RN_NODE_SET::const_iterator it, itEnd; - * - * unsigned int minDistance = std::numeric_limits::max(); - * RN_NODE_PTR closest; - * - * for( it = nodes.begin(), itEnd = nodes.end(); it != itEnd; ++it ) - * { - * RN_NODE_PTR node = *it; - * - * // Obviously the distance between node and itself is the shortest, - * // that's why we have to skip it - * if( node != aNode && aFilter( node ) ) - * { - * unsigned int distance = getDistance( node, aNode ); - * - * if( distance < minDistance ) - * { - * minDistance = distance; - * closest = node; - * } - * } - * } - * - * return closest;*/ -} - - -std::list RN_NET::GetClosestNodes( const RN_NODE_PTR& aNode, int aNumber ) const -{ - /*std::list closest; - * const RN_LINKS::RN_NODE_SET& nodes = m_links.GetNodes(); - * - * // Copy nodes - * std::copy( nodes.begin(), nodes.end(), std::back_inserter( closest ) ); - * - * // Sort by the distance from aNode - * closest.sort( std::bind( sortDistance, std::cref( aNode ), _1, _2 ) ); - * - * // aNode should not be returned in the results - * closest.remove( aNode ); - * - * // Trim the result to the asked size - * if( aNumber > 0 ) - * closest.resize( std::min( (size_t)aNumber, nodes.size() ) ); - * return closest;*/ -} - - -std::list RN_NET::GetClosestNodes( const RN_NODE_PTR& aNode, - const RN_NODE_FILTER& aFilter, int aNumber ) const -{ - /*std::list closest; - * const RN_LINKS::RN_NODE_SET& nodes = m_links.GetNodes(); - * - * // Copy filtered nodes - * std::copy_if( nodes.begin(), nodes.end(), std::back_inserter( closest ), std::cref( aFilter ) ); - * - * // Sort by the distance from aNode - * closest.sort( std::bind( sortDistance, std::cref( aNode ), _1, _2 ) ); - * - * // aNode should not be returned in the results - * closest.remove( aNode ); - * - * // Trim the result to the asked size - * if( aNumber > 0 ) - * closest.resize( std::min( static_cast( aNumber ), nodes.size() ) ); - * return closest;*/ -} - - -std::list RN_NET::GetNodes( const BOARD_CONNECTED_ITEM* aItem ) const -{ - /*std::list nodes; - * - * switch( aItem->Type() ) - * { - * case PCB_PAD_T: - * { - * PAD_NODE_MAP::const_iterator it = m_pads.find( static_cast( aItem ) ); - * - * if( it != m_pads.end() ) - * nodes.push_back( it->second.m_Node ); - * } - * break; - * - * case PCB_VIA_T: - * { - * VIA_NODE_MAP::const_iterator it = m_vias.find( static_cast( aItem ) ); - * - * if( it != m_vias.end() ) - * nodes.push_back( it->second ); - * } - * break; - * - * case PCB_TRACE_T: - * { - * TRACK_EDGE_MAP::const_iterator it = m_tracks.find( static_cast( aItem ) ); - * - * if( it != m_tracks.end() ) - * { - * nodes.push_back( it->second->GetSourceNode() ); - * nodes.push_back( it->second->GetTargetNode() ); - * } - * } - * break; - * - * case PCB_ZONE_AREA_T: - * { - * ZONE_DATA_MAP::const_iterator itz = m_zones.find( static_cast( aItem ) ); - * - * if( itz != m_zones.end() ) - * { - * const std::deque& polys = itz->second.m_Polygons; - * - * for( std::deque::const_iterator it = polys.begin(); it != polys.end(); ++it ) - * nodes.push_back( it->GetNode() ); - * } - * } - * break; - * - * default: - * break; - * } - * - * return nodes;*/ -} - - -void RN_NET::GetAllItems( std::list& aOutput, const KICAD_T aTypes[] ) const -{ -/* if( aType & RN_PADS ) - * { - * for( auto it : m_pads ) - * aOutput.push_back( const_cast( it.first ) ); - * } - * - * if( aType & RN_VIAS ) - * { - * for( auto it : m_vias ) - * aOutput.push_back( const_cast( it.first ) ); - * } - * - * if( aType & RN_TRACKS ) - * { - * for( auto it : m_tracks ) - * aOutput.push_back( const_cast( it.first ) ); - * } - * - * if( aType & RN_ZONES ) - * { - * for( auto it : m_zones ) - * aOutput.push_back( const_cast( it.first ) ); - * }*/ -} - - -void RN_NET::GetConnectedItems( const BOARD_CONNECTED_ITEM* aItem, - std::list& aOutput, - const KICAD_T aTypes[] ) const -{ -/* std::list nodes = GetNodes( aItem ); - * assert( !nodes.empty() ); - * - * int tag = nodes.front()->GetTag(); - * assert( tag >= 0 ); - * - * if( aTypes & RN_PADS ) - * { - * for( PAD_NODE_MAP::const_iterator it = m_pads.begin(); it != m_pads.end(); ++it ) - * { - * if( it->second.m_Node->GetTag() == tag ) - * aOutput.push_back( const_cast( it->first ) ); - * } - * } - * - * if( aTypes & RN_VIAS ) - * { - * for( VIA_NODE_MAP::const_iterator it = m_vias.begin(); it != m_vias.end(); ++it ) - * { - * if( it->second->GetTag() == tag ) - * aOutput.push_back( const_cast( it->first ) ); - * } - * } - * - * if( aTypes & RN_TRACKS ) - * { - * for( TRACK_EDGE_MAP::const_iterator it = m_tracks.begin(); it != m_tracks.end(); ++it ) - * { - * if( it->second->GetTag() == tag ) - * aOutput.push_back( const_cast( it->first ) ); - * } - * } - * - * if( aTypes & RN_ZONES ) - * { - * for( ZONE_DATA_MAP::const_iterator it = m_zones.begin(); it != m_zones.end(); ++it ) - * { - * for( const RN_EDGE_MST_PTR& edge : it->second.m_Edges ) - * { - * if( edge->GetTag() == tag ) - * { - * aOutput.push_back( const_cast( it->first ) ); - * break; - * } - * } - * } - * }*/ -} - - -// const RN_NODE_PTR& RN_NET::AddNode( int aX, int aY ) -// { -// return m_links.AddNode( aX, aY ); -// } - -#endif void RN_NET::AddCluster( CN_CLUSTER_PTR aCluster ) { diff --git a/pcbnew/ratsnest_data.h b/pcbnew/ratsnest_data.h index 2d150d4e59..65061f6916 100644 --- a/pcbnew/ratsnest_data.h +++ b/pcbnew/ratsnest_data.h @@ -141,39 +141,6 @@ public: bool NearestBicoloredPair( const RN_NET& aOtherNet, CN_ANCHOR_PTR& aNode1, CN_ANCHOR_PTR& aNode2 ) const; - /** - * Function GetClosestNode() - * Returns a single node that lies in the shortest distance from a specific node and meets - * selected filter criterion. - * @param aNode is the node for which the closest node is searched. - * @param aFilter is a functor that filters nodes. - */ - /*const CN_ANCHOR_PTR GetClosestNode( const RN_NODE_PTR& aNode, - const RN_NODE_FILTER& aFilter ) const;*/ - - /** - * Function GetClosestNodes() - * Returns list of nodes sorted by the distance from a specific node. - * @param aNode is the node for which the closest nodes are searched. - * @param aNumber is asked number of returned nodes. If it is negative then all nodes that - * belong to the same net are returned. If asked number is greater than number of possible - * nodes then the size of list is limited to number of possible nodes. - */ - //std::list GetClosestNodes( const RN_NODE_PTR& aNode, int aNumber = -1 ) const; - - /** - * Function GetClosestNodes() - * Returns filtered list of nodes sorted by the distance from a specific node. - * @param aNode is the node for which the closest nodes are searched. - * @param aFilter is a functor that filters nodes. - * @param aNumber is asked number of returned nodes. If it is negative then all nodes that - * belong to the same net are returned. If asked number is greater than number of possible - * nodes then the size of list is limited to number of possible nodes. - */ - //std::list GetClosestNodes( const RN_NODE_PTR& aNode, - // const RN_NODE_FILTER& aFilter, int aNumber = -1 ) const; - - protected: ///> Recomputes ratsnest from scratch. void compute(); diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index d3bd9b644a..163cca5c50 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -1136,20 +1136,6 @@ int PCB_EDITOR_CONTROL::ShowLocalRatsnest( const TOOL_EVENT& aEvent ) int PCB_EDITOR_CONTROL::UpdateSelectionRatsnest( const TOOL_EVENT& aEvent ) { return 0; -/* SELECTION_TOOL* selTool = m_toolMgr->GetTool(); - const SELECTION& selection = selTool->GetSelection(); - RN_DATA* ratsnest = getModel()->GetRatsnest(); - - // Update "simple" ratsnest, computed for currently modified items - ratsnest->ClearSimple(); - - for( auto item : selection ) - { - ratsnest->Update( static_cast( item ) ); - ratsnest->AddSimple( static_cast( item ) ); - } - - return 0;*/ } diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 3260cab1cd..f054246701 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -797,6 +797,7 @@ int SELECTION_TOOL::selectCopper( const TOOL_EVENT& aEvent ) for( auto i : selection ) { auto item = static_cast( i ); + // only connected items can be traversed in the ratsnest if( item->IsConnected() ) { @@ -862,6 +863,7 @@ int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent ) for( auto i : selection ) { auto item = static_cast( i ); + // only connected items get a net code if( item->IsConnected() ) { @@ -1000,7 +1002,6 @@ int SELECTION_TOOL::selectOnSheetFromEeschema( const TOOL_EVENT& aEvent ) if( m_selection.Size() > 0 ) m_toolMgr->ProcessEvent( SelectedEvent ); - return 0; }