diff --git a/pcbnew/class_board.h b/pcbnew/class_board.h index 914313f43d..b2f5cabaee 100644 --- a/pcbnew/class_board.h +++ b/pcbnew/class_board.h @@ -61,7 +61,6 @@ class MARKER_PCB; class MSG_PANEL_ITEM; class NETLIST; class REPORTER; -class RN_DATA; class SHAPE_POLY_SET; class CONNECTIVITY_DATA; @@ -292,9 +291,8 @@ public: /** * Function GetConnectivity() * returns list of missing connections between components/tracks. - * @return RATSNEST* is an object that contains informations about missing connections. + * @return an object that contains informations about missing connections. */ - std::shared_ptr GetConnectivity() const { return m_connectivity; diff --git a/pcbnew/clean.cpp b/pcbnew/clean.cpp index 35d07f9384..9a2ef7b42e 100644 --- a/pcbnew/clean.cpp +++ b/pcbnew/clean.cpp @@ -177,7 +177,7 @@ void TRACKS_CLEANER::buildTrackConnectionInfo() //RebuildTrackChain ( m_brd ); -// clear flags and variables used in cleanup + // clear flags and variables used in cleanup for( auto track : m_brd->Tracks() ) { track->SetState( START_ON_PAD | END_ON_PAD | BUSY, false ); @@ -320,7 +320,6 @@ bool TRACKS_CLEANER::cleanupVias() for( VIA* via = GetFirstVia( m_brd->m_Track ); via != NULL; via = GetFirstVia( via->Next() ) ) { - if( via->GetFlags() & TRACK_LOCKED ) continue; @@ -367,7 +366,7 @@ bool TRACKS_CLEANER::testTrackEndpointDangling( TRACK* aTrack, ENDPOINT_T aEndPo auto connectivity = m_brd->GetConnectivity(); VECTOR2I endpoint ; - if ( aTrack->Type() == PCB_TRACE_T ) + if( aTrack->Type() == PCB_TRACE_T ) endpoint = aTrack->GetEndPoint( aEndPoint ); else endpoint = aTrack->GetStart( ); @@ -381,9 +380,9 @@ bool TRACKS_CLEANER::testTrackEndpointDangling( TRACK* aTrack, ENDPOINT_T aEndPo auto anchors = citem->Anchors(); - for ( auto anchor : anchors ) + for( auto anchor : anchors ) { - if ( anchor->Pos() == endpoint && anchor->IsDangling() ) + if( anchor->Pos() == endpoint && anchor->IsDangling() ) return true; } @@ -451,7 +450,7 @@ bool TRACKS_CLEANER::deleteNullSegments() for( auto segment : m_brd->Tracks() ) { - if ( segment->IsNull() ) // Length segment = 0; delete it + if( segment->IsNull() ) // Length segment = 0; delete it toRemove.insert( segment ); } @@ -467,7 +466,7 @@ void TRACKS_CLEANER::removeDuplicatesOfTrack( const TRACK *aTrack, std::setGetNetCode() != other->GetNetCode() ) continue; - if ( aTrack == other ) + if( aTrack == other ) continue; // Must be of the same type, on the same layer and the endpoints @@ -554,7 +553,7 @@ bool TRACKS_CLEANER::cleanupSegments() // Delete redundant segments, i.e. segments having the same end points and layers // (can happens when blocks are copied on themselve) - for ( auto segment : m_brd->Tracks() ) + for( auto segment : m_brd->Tracks() ) removeDuplicatesOfTrack( segment, toRemove ); modified |= removeItems( toRemove ); @@ -663,7 +662,7 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* return aCandidate; // Weed out non-parallel tracks - if ( !parallelismTest( aTrackRef->GetEnd().x - aTrackRef->GetStart().x, + if( !parallelismTest( aTrackRef->GetEnd().x - aTrackRef->GetStart().x, aTrackRef->GetEnd().y - aTrackRef->GetStart().y, aCandidate->GetEnd().x - aCandidate->GetStart().x, aCandidate->GetEnd().y - aCandidate->GetStart().y ) ) @@ -675,15 +674,12 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* * and if this point is not on a pad, it can be removed and the 2 segments will be merged */ - auto connectivity=m_brd->GetConnectivity(); - updateConn(aTrackRef, connectivity); - updateConn(aCandidate, connectivity); #if 0 - if (aTrackRef->GetNetCode() == 47) + 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", @@ -712,11 +708,14 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* #endif + auto connectivity = m_brd->GetConnectivity(); + updateConn( aTrackRef, connectivity ); + updateConn( aCandidate, connectivity ); if( aEndType == ENDPOINT_START ) { - // We do not have a pad, which is a always terminal point for a track + // We do not have a pad, which is a always terminal point for a track if( aTrackRef->GetState( START_ON_PAD ) ) return NULL; @@ -741,8 +740,6 @@ TRACK* TRACKS_CLEANER::mergeCollinearSegmentIfPossible( TRACK* aTrackRef, TRACK* } else // aEndType == END { - - // We do not have a pad, which is a always terminal point for a track if( aTrackRef->GetState( END_ON_PAD ) ) return NULL; diff --git a/pcbnew/connectivity.cpp b/pcbnew/connectivity.cpp index c94ebcc0b1..41cd2ea442 100644 --- a/pcbnew/connectivity.cpp +++ b/pcbnew/connectivity.cpp @@ -59,13 +59,6 @@ bool CONNECTIVITY_DATA::Remove( BOARD_ITEM* aItem ) } -/** - * Function Update() - * Updates the connectivity data for an item. - * @param aItem is an item to be updated. - * @return True if operation succeeded. The item will not be updated if it was not previously - * added to the ratsnest. - */ bool CONNECTIVITY_DATA::Update( BOARD_ITEM* aItem ) { m_connAlgo->Remove( aItem ); @@ -105,9 +98,9 @@ void CONNECTIVITY_DATA::updateRatsnest() int i; #ifdef USE_OPENMP - #pragma omp parallel shared(lastNet) private(i) + #pragma omp parallel shared(lastNet) private(i) { - #pragma omp for schedule(guided, 1) + #pragma omp for schedule(guided, 1) #else /* USE_OPENMP */ { #endif @@ -122,6 +115,7 @@ void CONNECTIVITY_DATA::updateRatsnest() } } } /* end of parallel section */ + #ifdef PROFILE rnUpdate.Show(); #endif /* PROFILE */ @@ -339,13 +333,13 @@ const std::list CONNECTIVITY_DATA::GetConnectedItems( aTypes, aItem->GetNetCode() ); for( auto cl : clusters ) + { if( cl->Contains( aItem ) ) { for( const auto item : *cl ) rv.push_back( item->Parent() ); } - - + } return rv; } @@ -354,13 +348,13 @@ const std::list CONNECTIVITY_DATA::GetConnectedItems( const std::list CONNECTIVITY_DATA::GetNetItems( int aNetCode, const KICAD_T aTypes[] ) const { - std::set items; - std::list rv; + std::set items; + std::list rv; // fixme: apply aTypes - m_connAlgo->ForEachItem( [&items, aNetCode] ( CN_ITEM* aItem) { - if ( aItem->Net() == aNetCode ) + m_connAlgo->ForEachItem( [&items, aNetCode] ( CN_ITEM* aItem ) { + if( aItem->Net() == aNetCode ) items.insert( aItem->Parent() ); } ); @@ -395,7 +389,7 @@ bool CONNECTIVITY_DATA::CheckConnectivity( std::vector& a } -const std::vector CONNECTIVITY_DATA::GetConnectedTracks( const BOARD_CONNECTED_ITEM* aItem ) +const std::vector CONNECTIVITY_DATA::GetConnectedTracks( const BOARD_CONNECTED_ITEM* aItem ) const { auto& entry = m_connAlgo->ItemEntry( aItem ); @@ -417,7 +411,7 @@ const } -const std::vector CONNECTIVITY_DATA::GetConnectedPads( const BOARD_CONNECTED_ITEM* aItem ) +const std::vector CONNECTIVITY_DATA::GetConnectedPads( const BOARD_CONNECTED_ITEM* aItem ) const { auto& entry = m_connAlgo->ItemEntry( aItem ); @@ -464,10 +458,11 @@ unsigned int CONNECTIVITY_DATA::GetPadCount( int aNet ) const { int n = 0; - for ( auto pad : m_connAlgo->PadList() ) + for( auto pad : m_connAlgo->PadList() ) { auto dpad = static_cast( pad->Parent() ); - if ( aNet < 0 || aNet == dpad->GetNetCode() ) + + if( aNet < 0 || aNet == dpad->GetNetCode() ) { n++; } @@ -513,12 +508,12 @@ const std::vector CONNECTIVITY_DATA::NearestUnconnectedTargets( { if( item->Parent()->GetNetCode() == refNet && item->Parent()->Type() != PCB_ZONE_AREA_T ) + { for( auto anchor : item->Anchors() ) { anchors.insert( anchor->Pos() ); } - - + } } } } @@ -538,12 +533,12 @@ const std::vector CONNECTIVITY_DATA::NearestUnconnectedTargets( return rv; } + void CONNECTIVITY_DATA::GetUnconnectedEdges( std::vector& aEdges) const { - - for ( auto rnNet : m_nets ) + for( auto rnNet : m_nets ) { - if ( rnNet ) + if( rnNet ) { for( auto edge : rnNet->GetEdges() ) { @@ -553,7 +548,9 @@ void CONNECTIVITY_DATA::GetUnconnectedEdges( std::vector& aEdges) const } } -const std::vector CONNECTIVITY_DATA::GetConnectedItems( const BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aAnchor, KICAD_T aTypes[] ) + +const std::vector CONNECTIVITY_DATA::GetConnectedItems( + const BOARD_CONNECTED_ITEM* aItem, const VECTOR2I& aAnchor, KICAD_T aTypes[] ) { auto& entry = m_connAlgo->ItemEntry( aItem ); std::vector rv; @@ -562,11 +559,11 @@ const std::vector CONNECTIVITY_DATA::GetConnectedItems( c { for( auto anchor : cnItem->Anchors() ) { - if ( anchor->Pos() == aAnchor ) + if( anchor->Pos() == aAnchor ) { for( int i = 0; aTypes[i] > 0; i++ ) { - if ( cnItem->Parent()->Type() == aTypes[i] ) + if( cnItem->Parent()->Type() == aTypes[i] ) { rv.push_back( cnItem->Parent() ); break; diff --git a/pcbnew/connectivity.h b/pcbnew/connectivity.h index 9a1a3ac728..99baf0aaa0 100644 --- a/pcbnew/connectivity.h +++ b/pcbnew/connectivity.h @@ -184,7 +184,7 @@ public: * Calculates the temporary dynamic ratsnest (i.e. the ratsnest lines that) * for the set of items aItems. */ - void ComputeDynamicRatsnest( const std::vector& aItems ); + void ComputeDynamicRatsnest( const std::vector& aItems ); const std::vector& GetDynamicRatsnest() const; @@ -215,7 +215,7 @@ public: std::shared_ptr GetConnectivityAlgo() const { - return m_connAlgo; + return m_connAlgo; } private: diff --git a/pcbnew/connectivity_algo.cpp b/pcbnew/connectivity_algo.cpp index 3527c14ecb..f9c56102ac 100644 --- a/pcbnew/connectivity_algo.cpp +++ b/pcbnew/connectivity_algo.cpp @@ -28,6 +28,8 @@ #include #endif +using namespace std::placeholders; + bool operator<( const CN_ANCHOR_PTR a, const CN_ANCHOR_PTR b ) { if( a->Pos().x == b->Pos().x ) @@ -36,11 +38,13 @@ bool operator<( const CN_ANCHOR_PTR a, const CN_ANCHOR_PTR b ) return a->Pos().x < b->Pos().x; } + bool CN_ANCHOR::IsDirty() const { return m_item->Dirty(); } + CN_CLUSTER::CN_CLUSTER() { m_items.reserve( 64 ); @@ -49,11 +53,12 @@ CN_CLUSTER::CN_CLUSTER() m_conflicting = false; } + CN_CLUSTER::~CN_CLUSTER() { - } + wxString CN_CLUSTER::OriginNetName() const { if( !m_originPad ) @@ -62,6 +67,7 @@ wxString CN_CLUSTER::OriginNetName() const return m_originPad->Parent()->GetNetname(); } + bool CN_CLUSTER::Contains( const CN_ITEM* aItem ) { return std::find( m_items.begin(), m_items.end(), aItem ) != m_items.end(); @@ -71,21 +77,27 @@ bool CN_CLUSTER::Contains( const CN_ITEM* aItem ) bool CN_CLUSTER::Contains( const BOARD_CONNECTED_ITEM* aItem ) { for( auto item : m_items ) + { if( item->Parent() == aItem ) return true; + } + return false; } + void CN_ITEM::Dump() { printf(" valid: %d, connected: \n", !!Valid()); - for(auto i : m_connected ) + + for( auto i : m_connected ) { - TRACK *t = static_cast(i->Parent()); - printf(" - %p %d\n", t, t->Type() ); + TRACK* t = static_cast( i->Parent() ); + printf( " - %p %d\n", t, t->Type() ); } } + void CN_CLUSTER::Dump() { for( auto item : m_items ) @@ -95,16 +107,15 @@ void CN_CLUSTER::Dump() printf( "- item : %p bitem : %p type : %d inet %s\n", item, item->Parent(), item->Parent()->Type(), (const char*) item->Parent()->GetNetname().c_str() ); item->Dump(); - } } + void CN_CLUSTER::Add( CN_ITEM* item ) { - m_items.push_back( item ); - if ( m_originNet < 0 ) + if( m_originNet < 0 ) { m_originNet = item->Net(); } @@ -116,6 +127,7 @@ void CN_CLUSTER::Add( CN_ITEM* item ) m_originPad = item; m_originNet = item->Net(); } + if( m_originPad && item->Net() != m_originNet ) { m_conflicting = true; @@ -128,151 +140,156 @@ CN_CONNECTIVITY_ALGO::CN_CONNECTIVITY_ALGO() { } + CN_CONNECTIVITY_ALGO::~CN_CONNECTIVITY_ALGO() { Clear(); } + bool CN_CONNECTIVITY_ALGO::Remove( BOARD_ITEM* aItem ) { - markItemNetAsDirty ( aItem ); + markItemNetAsDirty( aItem ); switch( aItem->Type() ) { case PCB_MODULE_T: - for ( auto pad : static_cast (aItem ) -> Pads() ) + for( auto pad : static_cast( aItem ) -> Pads() ) { m_itemMap[ static_cast( pad ) ].MarkItemsAsInvalid(); - m_itemMap.erase ( static_cast( pad ) ); + m_itemMap.erase( static_cast( pad ) ); } - m_padList.SetDirty(true); + m_padList.SetDirty( true ); break; + case PCB_PAD_T: m_itemMap[ static_cast( aItem ) ].MarkItemsAsInvalid(); - m_itemMap.erase ( static_cast( aItem ) ); - m_padList.SetDirty(true); + m_itemMap.erase( static_cast( aItem ) ); + m_padList.SetDirty( true ); break; case PCB_TRACE_T: m_itemMap[ static_cast( aItem ) ].MarkItemsAsInvalid(); - m_itemMap.erase ( static_cast( aItem ) ); - m_trackList.SetDirty(true); + m_itemMap.erase( static_cast( aItem ) ); + m_trackList.SetDirty( true ); break; case PCB_VIA_T: m_itemMap[ static_cast( aItem ) ].MarkItemsAsInvalid(); - m_itemMap.erase ( static_cast( aItem ) ); - m_viaList.SetDirty(true); - + m_itemMap.erase( static_cast( aItem ) ); + m_viaList.SetDirty( true ); break; - case PCB_ZONE_AREA_T: case PCB_ZONE_T: { m_itemMap[ static_cast( aItem ) ].MarkItemsAsInvalid(); - m_itemMap.erase ( static_cast( aItem ) ); - m_zoneList.SetDirty(true); - + m_itemMap.erase ( static_cast( aItem ) ); + m_zoneList.SetDirty( true ); break; } + default: - return false; + return false; } return true; - } -void CN_CONNECTIVITY_ALGO::markItemNetAsDirty( const BOARD_ITEM *aItem ) + +void CN_CONNECTIVITY_ALGO::markItemNetAsDirty( const BOARD_ITEM* aItem ) { - if ( aItem->IsConnected () ) + if( aItem->IsConnected() ) { - auto citem = static_cast ( aItem ); - markNetAsDirty ( citem->GetNetCode() ); - } else { - if ( aItem->Type() == PCB_MODULE_T ) + auto citem = static_cast( aItem ); + markNetAsDirty( citem->GetNetCode() ); + } + else + { + if( aItem->Type() == PCB_MODULE_T ) { - auto mod = static_cast ( aItem ); + auto mod = static_cast ( aItem ); + for( D_PAD* pad = mod->PadsList(); pad; pad = pad->Next() ) - markNetAsDirty ( pad->GetNetCode() ); + markNetAsDirty( pad->GetNetCode() ); } } } bool CN_CONNECTIVITY_ALGO::Add( BOARD_ITEM* aItem ) +{ + markItemNetAsDirty ( aItem ); + + switch( aItem->Type() ) { - markItemNetAsDirty ( aItem ); - - switch( aItem->Type() ) + case PCB_MODULE_T: + for( auto pad : static_cast( aItem ) -> Pads() ) { - case PCB_MODULE_T: - for ( auto pad : static_cast (aItem ) -> Pads() ) - { - if ( m_itemMap.find ( pad ) != m_itemMap.end() ) - return false; - - add( m_padList, pad ); - } - - break; - - case PCB_PAD_T: - if ( m_itemMap.find ( static_cast ( aItem ) ) != m_itemMap.end() ) + if( m_itemMap.find( pad ) != m_itemMap.end() ) return false; - add( m_padList, static_cast ( aItem ) ); - - break; - - case PCB_TRACE_T: - { - if ( m_itemMap.find ( static_cast ( aItem ) ) != m_itemMap.end() ) - return false; - - add( m_trackList, static_cast ( aItem ) ); - - break; + add( m_padList, pad ); } - case PCB_VIA_T: - if ( m_itemMap.find ( static_cast ( aItem ) ) != m_itemMap.end() ) - return false; - add( m_viaList, static_cast (aItem )); + break; - break; - - - case PCB_ZONE_AREA_T: - case PCB_ZONE_T: - { - auto zone = static_cast ( aItem ); - - if ( m_itemMap.find ( static_cast ( aItem ) ) != m_itemMap.end() ) - return false; - - m_itemMap[zone] = ITEM_MAP_ENTRY(); - - for( auto zitem : m_zoneList.Add( zone ) ) - m_itemMap[zone].Link(zitem); - - break; - } - default: + case PCB_PAD_T: + if( m_itemMap.find ( static_cast( aItem ) ) != m_itemMap.end() ) return false; - } - return true; + add( m_padList, static_cast( aItem ) ); + + break; + + case PCB_TRACE_T: + { + if( m_itemMap.find( static_cast( aItem ) ) != m_itemMap.end() ) + return false; + + add( m_trackList, static_cast( aItem ) ); + + break; } + case PCB_VIA_T: + if( m_itemMap.find( static_cast( aItem ) ) != m_itemMap.end() ) + return false; + + add( m_viaList, static_cast( aItem ) ); + + break; + + case PCB_ZONE_AREA_T: + case PCB_ZONE_T: + { + auto zone = static_cast( aItem ); + + if( m_itemMap.find( static_cast( aItem ) ) != m_itemMap.end() ) + return false; + + m_itemMap[zone] = ITEM_MAP_ENTRY(); + + for( auto zitem : m_zoneList.Add( zone ) ) + m_itemMap[zone].Link(zitem); + + break; + } + + default: + return false; + } + + return true; +} + void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones ) { int totalDirtyCount = 0; - if ( m_lastSearchWithZones != aIncludeZones ) + if( m_lastSearchWithZones != aIncludeZones ) { m_padList.MarkAllAsDirty(); m_viaList.MarkAllAsDirty(); @@ -282,158 +299,157 @@ void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones ) m_lastSearchWithZones = aIncludeZones; - auto checkForConnection = [] ( const CN_ANCHOR_PTR point, CN_ITEM *aRefItem, int aMaxDist = 0) - { - const auto parent = aRefItem->Parent(); - - - assert ( point->Item() ); - assert ( point->Item()->Parent() ); - assert ( aRefItem->Parent() ); - - if ( !point->Item()->Valid() ) - return; - - if ( !aRefItem->Valid() ) - return; - - if( parent == point->Item()->Parent() ) - return; - - if( !( parent->GetLayerSet() & - point->Item()->Parent()->GetLayerSet() ).any() ) - return; - - switch ( parent->Type() ) - { - case PCB_PAD_T: - case PCB_VIA_T: - - if( parent->HitTest( wxPoint( point->Pos().x, point->Pos().y ) ) ) - CN_ITEM::Connect( aRefItem, point->Item() ); - - break; - case PCB_TRACE_T: - { - const auto track = static_cast ( parent ); - - const VECTOR2I d_start( VECTOR2I( track->GetStart() ) - point->Pos() ); - const VECTOR2I d_end( VECTOR2I( track->GetEnd() ) - point->Pos() ); - - if( d_start.EuclideanNorm() < aMaxDist - || d_end.EuclideanNorm() < aMaxDist ) - CN_ITEM::Connect( aRefItem, point->Item() ); - break; - - } - - case PCB_ZONE_T: - case PCB_ZONE_AREA_T: - { - const auto zone = static_cast ( parent ); - auto zoneItem = static_cast ( aRefItem ); - - if( point->Item()->Net() != parent->GetNetCode() ) - return; - - if( !( zone->GetLayerSet() & - point->Item()->Parent()->GetLayerSet() ).any() ) - return; - - if ( zoneItem->ContainsAnchor ( point ) ) - { - CN_ITEM::Connect( zoneItem, point->Item() ); - } - - break; - - } - default : - assert ( false ); - } - }; - - auto checkInterZoneConnection = [] ( CN_ZONE* testedZone, CN_ZONE *aRefZone ) + auto checkForConnection = [] ( const CN_ANCHOR_PTR point, CN_ITEM* aRefItem, int aMaxDist = 0 ) { - const auto parentZone = static_cast(aRefZone->Parent()); + const auto parent = aRefItem->Parent(); + + assert( point->Item() ); + assert( point->Item()->Parent() ); + assert( aRefItem->Parent() ); + + if( !point->Item()->Valid() ) + return; + + if( !aRefItem->Valid() ) + return; + + if( parent == point->Item()->Parent() ) + return; + + if( !( parent->GetLayerSet() & + point->Item()->Parent()->GetLayerSet() ).any() ) + return; + + switch( parent->Type() ) + { + case PCB_PAD_T: + case PCB_VIA_T: + + if( parent->HitTest( wxPoint( point->Pos().x, point->Pos().y ) ) ) + CN_ITEM::Connect( aRefItem, point->Item() ); + + break; + + case PCB_TRACE_T: + { + const auto track = static_cast ( parent ); + + const VECTOR2I d_start( VECTOR2I( track->GetStart() ) - point->Pos() ); + const VECTOR2I d_end( VECTOR2I( track->GetEnd() ) - point->Pos() ); + + if( d_start.EuclideanNorm() < aMaxDist + || d_end.EuclideanNorm() < aMaxDist ) + CN_ITEM::Connect( aRefItem, point->Item() ); + break; + } + + case PCB_ZONE_T: + case PCB_ZONE_AREA_T: + { + const auto zone = static_cast ( parent ); + auto zoneItem = static_cast ( aRefItem ); + + if( point->Item()->Net() != parent->GetNetCode() ) + return; + + if( !( zone->GetLayerSet() & + point->Item()->Parent()->GetLayerSet() ).any() ) + return; + + if( zoneItem->ContainsAnchor( point ) ) + { + CN_ITEM::Connect( zoneItem, point->Item() ); + } + + break; + + } + default : + assert( false ); + } + }; + + auto checkInterZoneConnection = [] ( CN_ZONE* testedZone, CN_ZONE* aRefZone ) + { + const auto parentZone = static_cast( aRefZone->Parent() ); if( testedZone->Parent()->Type () != PCB_ZONE_AREA_T ) return; - if (testedZone == aRefZone) + if( testedZone == aRefZone ) + return; + + if( testedZone->Parent() == aRefZone->Parent() ) return; - if (testedZone->Parent() == aRefZone->Parent()) - return; - - if( testedZone->Net() != parentZone->GetNetCode() ) return; // we only test zones belonging to the same net - if( !( testedZone->Parent()->GetLayerSet() & - parentZone->GetLayerSet() ).any() ) + if( !( testedZone->Parent()->GetLayerSet() & parentZone->GetLayerSet() ).any() ) return; // and on same layer const auto& outline = parentZone->GetFilledPolysList().COutline( aRefZone->SubpolyIndex() ); for( int i = 0; i < outline.PointCount(); i++ ) - if( testedZone ->ContainsPoint( outline.CPoint(i) ) ) + { + if( testedZone->ContainsPoint( outline.CPoint( i ) ) ) { - CN_ITEM::Connect ( aRefZone, testedZone ); + CN_ITEM::Connect( aRefZone, testedZone ); return; } + } - const auto testedZoneParent = static_cast(testedZone->Parent()); + const auto testedZoneParent = static_cast( testedZone->Parent() ); const auto& outline2 = testedZoneParent->GetFilledPolysList().COutline( testedZone->SubpolyIndex() ); for( int i = 0; i < outline2.PointCount(); i++ ) - if( aRefZone ->ContainsPoint( outline2.CPoint(i) ) ) + { + if( aRefZone->ContainsPoint( outline2.CPoint( i ) ) ) { - CN_ITEM::Connect ( aRefZone, testedZone ); + CN_ITEM::Connect( aRefZone, testedZone ); return; } - + } }; - #ifdef CONNECTIVITY_DEBUG printf("Search start\n"); #endif - std::vector garbage; - garbage.reserve(1024); + std::vector garbage; + garbage.reserve( 1024 ); - m_padList.RemoveInvalidItems(garbage); - m_viaList.RemoveInvalidItems(garbage); - m_trackList.RemoveInvalidItems(garbage); - m_zoneList.RemoveInvalidItems(garbage); + m_padList.RemoveInvalidItems( garbage ); + m_viaList.RemoveInvalidItems( garbage ); + m_trackList.RemoveInvalidItems( garbage ); + m_zoneList.RemoveInvalidItems( garbage ); - for ( auto item : garbage ) + for( auto item : garbage ) delete item; //auto all = allItemsInBoard(); #ifdef CONNECTIVITY_DEBUG - for ( auto item : m_padList ) - if ( all.find( item->Parent() ) == all.end() ) { printf("FAiling pad : %p\n", item->Parent() ); assert ( false ); } - for ( auto item : m_viaList ) - if ( all.find( item->Parent() ) == all.end() ) { printf("FAiling via : %p\n", item->Parent() ); assert ( false ); } - for ( auto item : m_trackList ) - if ( all.find( item->Parent() ) == all.end() ) { printf("FAiling track : %p\n", item->Parent() ); assert ( false ); } - for ( auto item : m_zoneList ) - if ( all.find( item->Parent() ) == all.end() ) { printf("FAiling zome : %p\n", item->Parent() ); assert ( false ); } + for( auto item : m_padList ) + if( all.find( item->Parent() ) == all.end() ) { printf("Failing pad : %p\n", item->Parent() ); assert ( false ); } + + for( auto item : m_viaList ) + if( all.find( item->Parent() ) == all.end() ) { printf("Failing via : %p\n", item->Parent() ); assert ( false ); } + + for( auto item : m_trackList ) + if( all.find( item->Parent() ) == all.end() ) { printf("Failing track : %p\n", item->Parent() ); assert ( false ); } + + for( auto item : m_zoneList ) + if( all.find( item->Parent() ) == all.end() ) { printf("Failing zome : %p\n", item->Parent() ); assert ( false ); } #endif - - using namespace std::placeholders; - #ifdef PROFILE PROF_COUNTER search_cnt( "search-connections" ); PROF_COUNTER search_basic( "search-basic" ); #endif - if ( m_padList.IsDirty() || m_trackList.IsDirty() || m_viaList.IsDirty() ) + if( m_padList.IsDirty() || m_trackList.IsDirty() || m_viaList.IsDirty() ) { totalDirtyCount++; @@ -486,11 +502,8 @@ void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones ) m_viaList.FindNearby( zoneItem->BBox(), searchZones ); m_trackList.FindNearby( zoneItem->BBox(), searchZones ); m_padList.FindNearby( zoneItem->BBox(), searchZones ); - m_zoneList.FindNearbyZones( zoneItem->BBox(), std::bind( checkInterZoneConnection, _1, zoneItem ) ); + m_zoneList.FindNearbyZones( zoneItem->BBox(), std::bind( checkInterZoneConnection, _1, zoneItem ) ); } - - - } m_zoneList.ClearDirtyFlags(); @@ -507,30 +520,30 @@ void CN_CONNECTIVITY_ALGO::searchConnections( bool aIncludeZones ) #ifdef PROFILE search_cnt.Show(); #endif - } + void CN_ITEM::RemoveInvalidRefs() { auto lastConn = std::remove_if(m_connected.begin(), m_connected.end(), [] ( CN_ITEM * item) { return !item->Valid(); - } ); m_connected.resize( lastConn - m_connected.begin() ); } -void CN_LIST::RemoveInvalidItems( std::vector& aGarbage ) -{ - auto lastAnchor = std::remove_if(m_anchors.begin(), m_anchors.end(), [] ( const CN_ANCHOR_PTR anchor) { - return !anchor->Valid(); - } ); +void CN_LIST::RemoveInvalidItems( std::vector& aGarbage ) +{ + auto lastAnchor = std::remove_if(m_anchors.begin(), m_anchors.end(), + [] ( const CN_ANCHOR_PTR anchor ) { + return !anchor->Valid(); + } ); m_anchors.resize( lastAnchor - m_anchors.begin() ); - auto lastItem = std::remove_if(m_items.begin(), m_items.end(), [&aGarbage] ( CN_ITEM * item) { - if ( !item->Valid() ) + auto lastItem = std::remove_if(m_items.begin(), m_items.end(), [&aGarbage] ( CN_ITEM* item ) { + if( !item->Valid() ) { aGarbage.push_back ( item ); return true; @@ -543,23 +556,26 @@ void CN_LIST::RemoveInvalidItems( std::vector& aGarbage ) // fixme: mem leaks - for ( auto item : m_items ) + for( auto item : m_items ) item->RemoveInvalidRefs(); } bool CN_CONNECTIVITY_ALGO::isDirty() const { - return m_viaList.IsDirty() || m_trackList.IsDirty() || m_zoneList.IsDirty() || m_padList.IsDirty(); + return m_viaList.IsDirty() || m_trackList.IsDirty() || m_zoneList.IsDirty() || m_padList.IsDirty(); } + const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUSTER_SEARCH_MODE aMode ) { constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_PAD_T, PCB_VIA_T, PCB_ZONE_AREA_T, PCB_MODULE_T, EOT }; - return SearchClusters ( aMode, types, -1 ); + return SearchClusters( aMode, types, -1 ); } -const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUSTER_SEARCH_MODE aMode, const KICAD_T aTypes[], int aSingleNet ) + +const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUSTER_SEARCH_MODE aMode, + const KICAD_T aTypes[], int aSingleNet ) { bool includeZones = ( aMode != CSM_PROPAGATE ); bool withinAnyNet = ( aMode != CSM_PROPAGATE ); @@ -568,36 +584,38 @@ const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUST CN_ITEM* head = nullptr; CLUSTERS clusters; - if ( isDirty() ) + if( isDirty() ) searchConnections( includeZones ); auto addToSearchList = [&head, withinAnyNet, aSingleNet, aTypes] ( CN_ITEM *aItem ) { - if ( withinAnyNet && aItem->Net() <= 0 ) + if( withinAnyNet && aItem->Net() <= 0 ) return; if( !aItem->Valid() ) return; - if ( aSingleNet >=0 && aItem->Net() != aSingleNet ) + if( aSingleNet >=0 && aItem->Net() != aSingleNet ) return; bool found = false; - for ( int i = 0; aTypes[i] != EOT; i++ ) - if ( aItem->Parent()->Type() == aTypes[i] ) + for( int i = 0; aTypes[i] != EOT; i++ ) + { + if( aItem->Parent()->Type() == aTypes[i] ) { found = true; break; } + } - if (!found) + if( !found ) return; aItem->ListClear(); aItem->SetVisited( false ); - if ( !head ) + if( !head ) head = aItem; else head->ListInsert( aItem ); @@ -607,7 +625,7 @@ const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUST std::for_each( m_trackList.begin(), m_trackList.end(), addToSearchList ); std::for_each( m_viaList.begin(), m_viaList.end(), addToSearchList ); - if (includeZones) + if( includeZones ) { std::for_each( m_zoneList.begin(), m_zoneList.end(), addToSearchList ); } @@ -634,7 +652,7 @@ const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUST for( auto n : current->ConnectedItems() ) { - if ( withinAnyNet && n->Net() != root->Net() ) + if( withinAnyNet && n->Net() != root->Net() ) continue; if( !n->Visited() && n->Valid() ) @@ -656,9 +674,10 @@ const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUST #ifdef CONNECTIVITY_DEBUG printf("Active clusters: %d\n"); - for (auto cl:clusters) + + for( auto cl : clusters ) { - printf("Net %d\n", cl->OriginNet()); + printf( "Net %d\n", cl->OriginNet() ); cl->Dump(); } #endif @@ -666,6 +685,7 @@ const CN_CONNECTIVITY_ALGO::CLUSTERS CN_CONNECTIVITY_ALGO::SearchClusters( CLUST return clusters; } + void CN_CONNECTIVITY_ALGO::Build( BOARD* aBoard ) { for( int i = 0; iGetAreaCount(); i++ ) @@ -678,17 +698,20 @@ void CN_CONNECTIVITY_ALGO::Build( BOARD* aBoard ) Add( tv ); for( auto mod : aBoard->Modules() ) + { for( auto pad : mod->Pads() ) Add( pad ); + } /*wxLogTrace( "CN", "zones : %lu, pads : %lu vias : %lu tracks : %lu\n", m_zoneList.Size(), m_padList.Size(), m_viaList.Size(), m_trackList.Size() );*/ } -void CN_CONNECTIVITY_ALGO::Build( const std::vector &aItems ) + +void CN_CONNECTIVITY_ALGO::Build( const std::vector& aItems ) { - for ( auto item : aItems ) + for( auto item : aItems ) { switch( item->Type() ) { @@ -701,7 +724,7 @@ void CN_CONNECTIVITY_ALGO::Build( const std::vector &aItems ) case PCB_MODULE_T: { - for( auto pad : static_cast(item)->Pads() ) + for( auto pad : static_cast( item )->Pads() ) { Add( pad ); } @@ -715,6 +738,7 @@ void CN_CONNECTIVITY_ALGO::Build( const std::vector &aItems ) } } + void CN_CONNECTIVITY_ALGO::propagateConnections() { for( auto cluster : m_connClusters ) @@ -764,10 +788,10 @@ void CN_CONNECTIVITY_ALGO::PropagateNets() propagateConnections(); } + void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( ZONE_CONTAINER* aZone, std::vector& aIslands ) { - - if ( aZone->GetFilledPolysList().IsEmpty() ) + if( aZone->GetFilledPolysList().IsEmpty() ) return; aIslands.clear(); @@ -778,6 +802,7 @@ void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( ZONE_CONTAINER* aZone, std m_connClusters = SearchClusters( CSM_CONNECTIVITY_CHECK ); for( auto cluster : m_connClusters ) + { if( cluster->Contains( aZone ) && cluster->IsOrphaned() ) { for( auto z : *cluster ) @@ -788,80 +813,89 @@ void CN_CONNECTIVITY_ALGO::FindIsolatedCopperIslands( ZONE_CONTAINER* aZone, std } } } + } wxLogTrace( "CN", "Found %llu isolated islands\n", aIslands.size() ); } + const CN_CONNECTIVITY_ALGO::CLUSTERS& CN_CONNECTIVITY_ALGO::GetClusters() { m_ratsnestClusters = SearchClusters( CSM_RATSNEST ); return m_ratsnestClusters; -}; +} -void CN_CONNECTIVITY_ALGO::markNetAsDirty ( int aNet ) + +void CN_CONNECTIVITY_ALGO::markNetAsDirty( int aNet ) { - if(aNet <= 0) + if( aNet <= 0 ) return; if(m_dirtyNets.size() <= aNet ) - m_dirtyNets.resize(aNet + 1); - m_dirtyNets[ aNet ] = true; + m_dirtyNets.resize( aNet + 1 ); + + m_dirtyNets[aNet] = true; } + int CN_ITEM::AnchorCount() const { return m_parent->Type() == PCB_TRACE_T ? 2 : 1; } + const VECTOR2I CN_ITEM::GetAnchor( int n ) const { - switch ( m_parent->Type() ) + switch( m_parent->Type() ) { case PCB_PAD_T: - return static_cast(m_parent)->ShapePos(); + return static_cast( m_parent )->ShapePos(); break; case PCB_TRACE_T: { - auto tr = static_cast(m_parent); - return (n == 0 ? tr->GetStart() : tr->GetEnd() ); + auto tr = static_cast( m_parent ); + return ( n == 0 ? tr->GetStart() : tr->GetEnd() ); break; } case PCB_VIA_T: - return static_cast(m_parent)->GetStart(); + return static_cast( m_parent )->GetStart(); default: - assert(false); + assert( false ); return VECTOR2I(); } } + int CN_ZONE::AnchorCount() const { - const auto zone = static_cast ( Parent() ); + const auto zone = static_cast( Parent() ); const auto& outline = zone->GetFilledPolysList().COutline( m_subpolyIndex ); return outline.PointCount() ? 1 : 0; } -const VECTOR2I CN_ZONE::GetAnchor(int n ) const + +const VECTOR2I CN_ZONE::GetAnchor( int n ) const { const auto zone = static_cast ( Parent() ); const auto& outline = zone->GetFilledPolysList().COutline( m_subpolyIndex ); - return outline.CPoint(0); + return outline.CPoint( 0 ); } + /*const std::vector CN_CLUSTER::GetAnchors() { std::vector anchors; - for ( auto item : m_items ) + for( auto item : m_items ) { int cnt = item->AnchorCount(); - for (int i = 0 ; i < cnt; i++) + for(int i = 0 ; i < cnt; i++) { anchors.push_back( item->GetAnchor(i) ); } @@ -870,15 +904,17 @@ const VECTOR2I CN_ZONE::GetAnchor(int n ) const return anchors; }*/ + int CN_ITEM::Net() const { - if (!m_parent) + if( !m_parent ) return -1; + return m_parent->GetNetCode(); } -BOARD_CONNECTED_ITEM *CN_ANCHOR::Parent() const +BOARD_CONNECTED_ITEM* CN_ANCHOR::Parent() const { return m_item->Parent(); } @@ -888,9 +924,11 @@ bool CN_ANCHOR::Valid() const { if( !m_item ) return false; + return m_item->Valid(); } + void CN_CONNECTIVITY_ALGO::Clear() { m_ratsnestClusters.clear(); @@ -903,30 +941,39 @@ void CN_CONNECTIVITY_ALGO::Clear() } -void CN_CONNECTIVITY_ALGO::ForEachItem( std::function aFunc ) + +void CN_CONNECTIVITY_ALGO::ForEachItem( std::function aFunc ) { - for ( auto item : m_padList ) + for( auto item : m_padList ) aFunc( item ); - for ( auto item : m_viaList ) + + for( auto item : m_viaList ) aFunc( item ); - for ( auto item : m_trackList ) + + for( auto item : m_trackList ) aFunc( item ); - for ( auto item : m_zoneList ) + + for( auto item : m_zoneList ) aFunc( item ); } -void CN_CONNECTIVITY_ALGO::ForEachAnchor( std::function aFunc ) + +void CN_CONNECTIVITY_ALGO::ForEachAnchor( std::function aFunc ) { - for ( auto anchor : m_padList.Anchors() ) + for( auto anchor : m_padList.Anchors() ) aFunc( anchor ); - for ( auto anchor : m_viaList.Anchors() ) + + for( auto anchor : m_viaList.Anchors() ) aFunc( anchor ); - for ( auto anchor : m_trackList.Anchors() ) + + for( auto anchor : m_trackList.Anchors() ) aFunc( anchor ); - for ( auto anchor : m_zoneList.Anchors() ) + + for( auto anchor : m_zoneList.Anchors() ) aFunc( anchor ); } + bool CN_ANCHOR::IsDangling() const { if( !m_cluster ) @@ -935,8 +982,10 @@ bool CN_ANCHOR::IsDangling() const int validCount = 0; for( auto item : *m_cluster ) - if ( item->Valid() ) + { + if( item->Valid() ) validCount++; + } return validCount <= 1; } diff --git a/pcbnew/connectivity_algo.h b/pcbnew/connectivity_algo.h index 4f67eabc28..7baf4918fa 100644 --- a/pcbnew/connectivity_algo.h +++ b/pcbnew/connectivity_algo.h @@ -145,6 +145,7 @@ private: typedef std::shared_ptr CN_ANCHOR_PTR; typedef std::vector CN_ANCHORS; + class CN_EDGE { public: @@ -189,6 +190,7 @@ private: bool m_visible = true; }; + class CN_CLUSTER { private: @@ -248,6 +250,7 @@ public: typedef std::shared_ptr CN_CLUSTER_PTR; + // a lightweight intrusive list container template class INTRUSIVE_LIST @@ -320,6 +323,7 @@ private: T* m_root; }; + // basic connectivity item class CN_ITEM : public INTRUSIVE_LIST { @@ -328,21 +332,21 @@ private: using CONNECTED_ITEMS = std::vector; -// list of items physically connected (touching) + ///> list of items physically connected (touching) CONNECTED_ITEMS m_connected; CN_ANCHORS m_anchors; -// visited flag for the BFS scan + ///> visited flag for the BFS scan bool m_visited; -// can the net propagator modify the netcode? + ///> can the net propagator modify the netcode? bool m_canChangeNet; -// valid flag, used to identify garbage items (we use lazy removal) + ///> valid flag, used to identify garbage items (we use lazy removal) bool m_valid; -// dirty flag, used to identify recently added item not yet scanned into the connectivity search + ///> dirty flag, used to identify recently added item not yet scanned into the connectivity search bool m_dirty; public: @@ -362,7 +366,7 @@ public: CN_ANCHOR_PTR AddAnchor( const VECTOR2I& aPos ) { - m_anchors.emplace_back( std::make_shared ( aPos, this ) ); + m_anchors.emplace_back( std::make_shared( aPos, this ) ); //printf("%p add %d\n", this, m_anchors.size() ); return m_anchors.back(); } @@ -461,6 +465,7 @@ public: typedef std::shared_ptr CN_ITEM_PTR; + class CN_LIST { private: @@ -491,7 +496,7 @@ public: CN_LIST() { m_dirty = false; - }; + } void Clear() { @@ -558,7 +563,6 @@ public: class CN_PAD_LIST : public CN_LIST { public: - CN_ITEM* Add( D_PAD* pad ) { auto item = new CN_ITEM( pad, false, 2 ); @@ -568,9 +572,10 @@ public: SetDirty(); return item; - }; + } }; + class CN_TRACK_LIST : public CN_LIST { public: @@ -585,9 +590,10 @@ public: SetDirty(); return item; - }; + } }; + class CN_VIA_LIST : public CN_LIST { public: @@ -599,9 +605,10 @@ public: addAnchor( via->GetStart(), item ); SetDirty(); return item; - }; + } }; + class CN_ZONE : public CN_ITEM { public: @@ -674,22 +681,23 @@ public: } return rv; - }; + } template void FindNearbyZones( BOX2I aBBox, T aFunc, bool aDirtyOnly = false ); }; + template void CN_LIST::FindNearby( BOX2I aBBox, T aFunc, bool aDirtyOnly ) { for( auto p : m_anchors ) { if( p->Valid() && aBBox.Contains( p->Pos() ) ) + { if( !aDirtyOnly || p->IsDirty() ) aFunc( p ); - - + } } } @@ -699,7 +707,7 @@ void CN_ZONE_LIST::FindNearbyZones( BOX2I aBBox, T aFunc, bool aDirtyOnly ) { for( auto item : m_items ) { - auto zone = static_cast ( item ); + auto zone = static_cast( item ); if( aBBox.Intersects( zone->BBox() ) ) { @@ -735,7 +743,7 @@ void CN_LIST::FindNearby( VECTOR2I aPosition, int aDistMax, T aFunc, bool aDirty { // Calculate half size of remaining interval to test. // Ensure the computed value is not truncated (too small) - if( (delta & 1) && ( delta > 1 ) ) + if( ( delta & 1 ) && ( delta > 1 ) ) delta++; delta /= 2; @@ -787,12 +795,10 @@ void CN_LIST::FindNearby( VECTOR2I aPosition, int aDistMax, T aFunc, bool aDirty if( p->Valid() ) if( !aDirtyOnly || p->IsDirty() ) aFunc( p ); - - } // search previous candidates in list - for( int ii = idx - 1; ii >=0; ii-- ) + for( int ii = idx - 1; ii >=0; ii-- ) { auto& p = m_anchors[ii]; diff = p->Pos() - aPosition; @@ -805,10 +811,10 @@ void CN_LIST::FindNearby( VECTOR2I aPosition, int aDistMax, T aFunc, bool aDirty // We have here a good candidate:add it if( p->Valid() ) + { if( !aDirtyOnly || p->IsDirty() ) aFunc( p ); - - + } } } @@ -873,7 +879,7 @@ public: CLUSTERS m_ratsnestClusters; std::vector m_dirtyNets; - void searchConnections( bool aIncludeZones = false ); + void searchConnections( bool aIncludeZones = false ); void update(); void propagateConnections(); @@ -889,8 +895,8 @@ public: bool addConnectedItem( BOARD_CONNECTED_ITEM* aItem ); bool isDirty() const; - void markNetAsDirty( int aNet ); - void markItemNetAsDirty( const BOARD_ITEM* aItem ); + void markNetAsDirty( int aNet ); + void markItemNetAsDirty( const BOARD_ITEM* aItem ); public: diff --git a/pcbnew/dragsegm.cpp b/pcbnew/dragsegm.cpp index 37a6be91ae..12ea5a931c 100644 --- a/pcbnew/dragsegm.cpp +++ b/pcbnew/dragsegm.cpp @@ -156,7 +156,7 @@ void DRAG_LIST::BuildDragListe( MODULE* aModule ) std::vector padList; - for ( auto pad : aModule->Pads() ) + for( auto pad : aModule->Pads() ) padList.push_back( pad ); sort( padList.begin(), padList.end(), sortPadsByXthenYCoord ); @@ -192,7 +192,7 @@ void DRAG_LIST::fillList( std::vector& aList ) auto connectedTracks = m_Brd->GetConnectivity()->GetConnectedTracks( pad ); // store track connected to the pad - for ( auto track : connectedTracks ) + for( auto track : connectedTracks ) { track->start = NULL; track->end = NULL; @@ -206,9 +206,8 @@ void DRAG_LIST::fillList( std::vector& aList ) auto connectedTracks = m_Brd->GetConnectivity()->GetConnectedTracks( pad ); // store track connected to the pad - for ( auto track : connectedTracks ) + for( auto track : connectedTracks ) { - if( pad->HitTest( track->GetStart() ) ) { track->start = pad; diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index d4c4c8dbfc..35c893141c 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -1740,14 +1740,15 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals ) via->SetDrill( drillz ); -// make sure the via diameter respects the restring rules + // make sure the via diameter respects the restring rules if( !v.diam || via->GetWidth() <= via->GetDrill() ) { - double annulus = Clamp( m_rules->rlMinViaOuter, (double) (via->GetWidth() / 2 - via->GetDrill()), m_rules->rlMaxViaOuter ); + double annulus = Clamp( m_rules->rlMinViaOuter, + (double)( via->GetWidth() / 2 - via->GetDrill() ), m_rules->rlMaxViaOuter ); via->SetWidth( drillz + 2 * annulus ); } - + if( kidiam < m_min_via ) m_min_via = kidiam; @@ -1770,6 +1771,7 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals ) via->SetNetCode( netCode ); } + m_xpath->pop(); } diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 7edfeb6636..91a7819c1a 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -160,6 +160,7 @@ TRACK* PCB_EDIT_FRAME::Begin_Route( TRACK* aTrack, wxDC* aDC ) DBG( g_CurrentTrackList.VerifyListIntegrity() ); int net = -1; + if( lockPoint ) net = lockPoint->GetNetCode(); @@ -798,7 +799,7 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo // If the starting point is on a pad, add current track length+ length die if( g_FirstTrackSegment->GetState( BEGIN_ONPAD ) ) { - D_PAD * pad = (D_PAD *) g_FirstTrackSegment->start; + D_PAD* pad = (D_PAD*) g_FirstTrackSegment->start; lenPadToDie = (double) pad->GetPadToDieLength(); } diff --git a/pcbnew/exporters/export_d356.cpp b/pcbnew/exporters/export_d356.cpp index d899061cf0..23c0ca7d5c 100644 --- a/pcbnew/exporters/export_d356.cpp +++ b/pcbnew/exporters/export_d356.cpp @@ -116,10 +116,10 @@ static void build_pad_testpoints( BOARD *aPcb, { wxPoint origin = aPcb->GetAuxOrigin(); - for( MODULE *module = aPcb->m_Modules; + for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) { - for( D_PAD *pad = module->PadsList(); pad; pad = pad->Next() ) + for( D_PAD* pad = module->PadsList(); pad; pad = pad->Next() ) { D356_RECORD rk; rk.access = compute_pad_access_code( aPcb, pad->GetLayerSet() ); diff --git a/pcbnew/exporters/gendrill_file_writer_base.cpp b/pcbnew/exporters/gendrill_file_writer_base.cpp index e9afdc1474..aaa7b9a598 100644 --- a/pcbnew/exporters/gendrill_file_writer_base.cpp +++ b/pcbnew/exporters/gendrill_file_writer_base.cpp @@ -117,7 +117,7 @@ void GENDRILL_WRITER_BASE::buildHolesList( DRILL_LAYER_PAIR aLayerPair, // add holes for thru hole pads for( MODULE* module = m_pcb->m_Modules; module; module = module->Next() ) { - for( auto &pad : module->Pads() ) + for( auto& pad : module->Pads() ) { if( !m_merge_PTH_NPTH ) { diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 67763ff156..c763168099 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -65,6 +65,7 @@ static const wxString traceFootprintLibrary( wxT( "KicadFootprintLib" ) ); void filterNetClass( const BOARD& aBoard, NETCLASS& aNetClass ) { auto connectivity = aBoard.GetConnectivity(); + for( NETCLASS::iterator it = aNetClass.begin(); it != aNetClass.end(); ) { NETINFO_ITEM* netinfo = aBoard.FindNet( *it ); @@ -74,7 +75,6 @@ void filterNetClass( const BOARD& aBoard, NETCLASS& aNetClass ) else ++it; } - } /** diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index e2598dc6e0..227c01b655 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -91,7 +91,7 @@ void PlotSilkScreen( BOARD *aBoard, PLOTTER* aPlotter, LSET aLayerMask, { aPlotter->StartBlock( NULL ); - for( D_PAD * pad = Module->PadsList(); pad; pad = pad->Next() ) + for( D_PAD* pad = Module->PadsList(); pad; pad = pad->Next() ) { // See if the pad is on this layer LSET masklayer = pad->GetLayerSet(); diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 8d8e1d687f..6f53c7b222 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -238,7 +238,7 @@ bool BRDITEMS_PLOTTER::PlotAllTextsModule( MODULE* aModule ) PlotTextModule( &aModule->Value(), GetValueColor() ); } - for( BOARD_ITEM *item = aModule->GraphicalItemsList().GetFirst(); item; item = item->Next() ) + for( BOARD_ITEM* item = aModule->GraphicalItemsList().GetFirst(); item; item = item->Next() ) { textModule = dyn_cast( item ); @@ -810,7 +810,7 @@ void BRDITEMS_PLOTTER::PlotDrillMarks() if( GetPlotMode() == FILLED ) m_plotter->SetColor( WHITE ); - for( TRACK *pts = m_board->m_Track; pts != NULL; pts = pts->Next() ) + for( TRACK* pts = m_board->m_Track; pts != NULL; pts = pts->Next() ) { const VIA* via = dyn_cast( pts ); @@ -820,9 +820,9 @@ void BRDITEMS_PLOTTER::PlotDrillMarks() wxSize( via->GetWidth(), 0 ), 0, small_drill ); } - for( MODULE *Module = m_board->m_Modules; Module != NULL; Module = Module->Next() ) + for( MODULE* Module = m_board->m_Modules; Module != NULL; Module = Module->Next() ) { - for( D_PAD *pad = Module->PadsList(); pad != NULL; pad = pad->Next() ) + for( D_PAD* pad = Module->PadsList(); pad != NULL; pad = pad->Next() ) { if( pad->GetDrillSize().x == 0 ) continue; diff --git a/pcbnew/ratsnest.cpp b/pcbnew/ratsnest.cpp index aca7eee00e..c17812c0f7 100644 --- a/pcbnew/ratsnest.cpp +++ b/pcbnew/ratsnest.cpp @@ -60,7 +60,7 @@ void PCB_BASE_FRAME::Compile_Ratsnest( wxDC* aDC, bool aDisplayStatus ) GetBoard()->m_Status_Pcb = 0; // we want a full ratsnest computation, from the scratch - if( GetBoard()->IsElementVisible(LAYER_RATSNEST) && aDC ) + if( GetBoard()->IsElementVisible( LAYER_RATSNEST ) && aDC ) DrawGeneralRatsnest( aDC, 0 ); wxString msg; diff --git a/pcbnew/ratsnest_data.cpp b/pcbnew/ratsnest_data.cpp index 1915e4dc43..18e44ad7e6 100644 --- a/pcbnew/ratsnest_data.cpp +++ b/pcbnew/ratsnest_data.cpp @@ -54,6 +54,7 @@ static uint64_t getDistance( const CN_ANCHOR_PTR& aNode1, const CN_ANCHOR_PTR& a return sqrt( dx * dx + dy * dy ); } + static bool sortWeight( const CN_EDGE& aEdge1, const CN_EDGE& aEdge2 ) { return aEdge1.GetWeight() < aEdge2.GetWeight(); @@ -181,6 +182,7 @@ static const std::vector kruskalMST( std::list& aEdges, return mst; } + class RN_NET::TRIANGULATOR_STATE { private: @@ -209,7 +211,7 @@ public: std::vector anchorChains; triNodes.reserve( m_allNodes.size() ); - anchorChains.reserve ( m_allNodes.size() ); + anchorChains.reserve( m_allNodes.size() ); std::sort( m_allNodes.begin(), m_allNodes.end(), [] ( const CN_ANCHOR_PTR& aNode1, const CN_ANCHOR_PTR& aNode2 ) @@ -297,16 +299,15 @@ public: } }; -#include RN_NET::RN_NET() : m_dirty( true ) { m_triangulator.reset( new TRIANGULATOR_STATE ); } + void RN_NET::compute() { - // Special cases do not need complicated algorithms (actually, it does not work well with // the Delaunay triangulator) //printf("compute nodes : %d\n", m_nodes.size() ); @@ -333,7 +334,6 @@ void RN_NET::compute() node->SetTag( 0 ); } - return; } @@ -647,13 +647,13 @@ void RN_NET::AddCluster( CN_CLUSTER_PTR aCluster ) auto& anchors = item->Anchors(); int nAnchors = isZone ? 1 : anchors.size(); - if ( nAnchors > anchors.size() ) + if( nAnchors > anchors.size() ) nAnchors = anchors.size(); //printf("item %p anchors : %d\n", item, anchors.size() ); //printf("add item %p anchors : %d net : %d\n", item, item->Anchors().size(), item->Parent()->GetNetCode() ); - for ( int i = 0; i < nAnchors; i++ ) + for( int i = 0; i < nAnchors; i++ ) { // printf("add anchor %p\n", anchors[i].get() ); @@ -675,6 +675,7 @@ void RN_NET::AddCluster( CN_CLUSTER_PTR aCluster ) } } + bool RN_NET::NearestBicoloredPair( const RN_NET& aOtherNet, CN_ANCHOR_PTR& aNode1, CN_ANCHOR_PTR& aNode2 ) const { @@ -710,8 +711,9 @@ unsigned int RN_NET::GetNodeCount() const return m_nodes.size(); } + void RN_NET::SetVisible( bool aEnabled ) { - for ( auto& edge : m_rnEdges ) - edge.SetVisible ( aEnabled ); + for( auto& edge : m_rnEdges ) + edge.SetVisible( aEnabled ); } diff --git a/pcbnew/ratsnest_data.h b/pcbnew/ratsnest_data.h index bcebd52836..2d150d4e59 100644 --- a/pcbnew/ratsnest_data.h +++ b/pcbnew/ratsnest_data.h @@ -69,7 +69,7 @@ public: * false otherwise. */ void SetVisible( bool aEnabled ); - + /** * Function MarkDirty() * Marks ratsnest for given net as 'dirty', i.e. requiring recomputation. @@ -109,7 +109,6 @@ public: void AddCluster( std::shared_ptr aCluster ); - unsigned int GetNodeCount() const; /** @@ -176,7 +175,7 @@ public: protected: - ///> Recomputes ratsnset from scratch. + ///> Recomputes ratsnest from scratch. void compute(); ///> Vector of nodes @@ -196,5 +195,4 @@ protected: std::shared_ptr m_triangulator; }; - #endif /* RATSNEST_DATA_H */ diff --git a/pcbnew/ratsnest_viewitem.h b/pcbnew/ratsnest_viewitem.h index 22729a03e5..a6551c801a 100644 --- a/pcbnew/ratsnest_viewitem.h +++ b/pcbnew/ratsnest_viewitem.h @@ -70,7 +70,7 @@ public: protected: ///> Object containing ratsnest data. - std::shared_ptr m_data; + std::shared_ptr m_data; }; } // namespace KIGFX diff --git a/pcbnew/tools/common_actions.cpp b/pcbnew/tools/common_actions.cpp deleted file mode 100644 index eee78402c8..0000000000 --- a/pcbnew/tools/common_actions.cpp +++ /dev/null @@ -1,804 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2013-2016 CERN - * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. - * @author Maciej Suminski - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, you may find one here: - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html - * or you may search the http://www.gnu.org website for the version 2 license, - * or you may write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - */ - -#include "common_actions.h" -#include -#include -#include -#include -#include -#include - -// These members are static in class COMMON_ACTIONS: Build them here: - -// Selection tool actions -TOOL_ACTION COMMON_ACTIONS::selectionActivate( "pcbnew.InteractiveSelection", - AS_GLOBAL, 0, - "", "", NULL, AF_ACTIVATE ); // No description, it is not supposed to be shown anywhere - -TOOL_ACTION COMMON_ACTIONS::selectionCursor( "pcbnew.InteractiveSelection.Cursor", - AS_GLOBAL, 0, - "", "" ); // No description, it is not supposed to be shown anywhere - -TOOL_ACTION COMMON_ACTIONS::selectItem( "pcbnew.InteractiveSelection.SelectItem", - AS_GLOBAL, 0, - "", "" ); // No description, it is not supposed to be shown anywhere - -TOOL_ACTION COMMON_ACTIONS::unselectItem( "pcbnew.InteractiveSelection.UnselectItem", - AS_GLOBAL, 0, - "", "" ); // No description, it is not supposed to be shown anywhere - -TOOL_ACTION COMMON_ACTIONS::selectionClear( "pcbnew.InteractiveSelection.Clear", - AS_GLOBAL, 0, - "", "" ); // No description, it is not supposed to be shown anywhere - -TOOL_ACTION COMMON_ACTIONS::selectConnection( "pcbnew.InteractiveSelection.SelectConnection", - AS_GLOBAL, 'U', - _( "Trivial Connection" ), _( "Selects a connection between two junctions." ) ); - -TOOL_ACTION COMMON_ACTIONS::selectCopper( "pcbnew.InteractiveSelection.SelectCopper", - AS_GLOBAL, 'I', - _( "Copper Connection" ), _( "Selects whole copper connection." ) ); - -TOOL_ACTION COMMON_ACTIONS::selectNet( "pcbnew.InteractiveSelection.SelectNet", - AS_GLOBAL, 0, - _( "Whole Net" ), _( "Selects all tracks & vias belonging to the same net." ) ); - -TOOL_ACTION COMMON_ACTIONS::selectSameSheet( "pcbnew.InteractiveSelection.SelectSameSheet", - AS_GLOBAL, 'P', - _( "Same Sheet" ), _( "Selects all modules and tracks in the same schematic sheet" ) ); - -TOOL_ACTION COMMON_ACTIONS::find( "pcbnew.InteractiveSelection.Find", - AS_GLOBAL, 0, //TOOL_ACTION::LegacyHotKey( HK_FIND_ITEM ), // handled by wxWidgets - _( "Find Item" ), _( "Searches the document for an item" ), find_xpm ); - -TOOL_ACTION COMMON_ACTIONS::findMove( "pcbnew.InteractiveSelection.FindMove", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GET_AND_MOVE_FOOTPRINT ) ); - - -// Edit tool actions -TOOL_ACTION COMMON_ACTIONS::editFootprintInFpEditor( "pcbnew.InteractiveEdit.editFootprintInFpEditor", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_MODULE_WITH_MODEDIT ), - _( "Open in Footprint Editor" ), - _( "Opens the selected footprint in the Footprint Editor" ), - module_editor_xpm ); - -TOOL_ACTION COMMON_ACTIONS::copyPadToSettings( "pcbnew.InteractiveEdit.copyPadToSettings", - AS_GLOBAL, 0, - _( "Copy Pad Settings to Current Settings" ), - _( "Copies the properties of selected pad to the current template pad settings." ) ); - -TOOL_ACTION COMMON_ACTIONS::copySettingsToPads( "pcbnew.InteractiveEdit.copySettingsToPads", - AS_GLOBAL, 0, - _( "Copy Current Settings to Pads" ), - _( "Copies the current template pad settings to the selected pad(s)." ) ); - -TOOL_ACTION COMMON_ACTIONS::globalEditPads( "pcbnew.InteractiveEdit.globalPadEdit", - AS_GLOBAL, 0, - _( "Global Pad Edition" ), - _( "Changes pad properties globally." ), push_pad_settings_xpm ); - -TOOL_ACTION COMMON_ACTIONS::editActivate( "pcbnew.InteractiveEdit", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE_ITEM ), - _( "Move" ), _( "Moves the selected item(s)" ), move_xpm, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::drag( "pcbnew.InteractiveEdit.dragItem", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DRAG_TRACK_KEEP_SLOPE ), - _( "Drag" ), _( "Drags the selected item(s)" ), drag_track_segment_xpm ); - -TOOL_ACTION COMMON_ACTIONS::duplicate( "pcbnew.InteractiveEdit.duplicate", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE_ITEM ), - _( "Duplicate" ), _( "Duplicates the selected item(s)" ), duplicate_module_xpm ); - -TOOL_ACTION COMMON_ACTIONS::duplicateIncrement( "pcbnew.InteractiveEdit.duplicateIncrementPads", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DUPLICATE_ITEM_AND_INCREMENT ), - _( "Duplicate" ), _( "Duplicates the selected item(s), incrementing pad numbers" ) ); - -TOOL_ACTION COMMON_ACTIONS::moveExact( "pcbnew.InteractiveEdit.moveExact", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_MOVE_ITEM_EXACT ), - _( "Move Exactly..." ), _( "Moves the selected item(s) by an exact amount" ), - move_module_xpm ); - -TOOL_ACTION COMMON_ACTIONS::createArray( "pcbnew.InteractiveEdit.createArray", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_CREATE_ARRAY ), - _( "Create Array" ), _( "Create array" ), array_module_xpm, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::rotateCw( "pcbnew.InteractiveEdit.rotateCw", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ROTATE_ITEM ), - _( "Rotate Clockwise" ), _( "Rotates selected item(s) clockwise" ), - rotate_cw_xpm, AF_NONE, (void*) 1 ); - -TOOL_ACTION COMMON_ACTIONS::rotateCcw( "pcbnew.InteractiveEdit.rotateCcw", - AS_GLOBAL, MD_SHIFT + 'R', - _( "Rotate Counter-clockwise" ), _( "Rotates selected item(s) counter-clockwise" ), - rotate_ccw_xpm, AF_NONE, (void*) -1 ); - -TOOL_ACTION COMMON_ACTIONS::flip( "pcbnew.InteractiveEdit.flip", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_FLIP_ITEM ), - _( "Flip" ), _( "Flips selected item(s)" ), swap_layer_xpm ); - -TOOL_ACTION COMMON_ACTIONS::mirror( "pcbnew.InteractiveEdit.mirror", - AS_GLOBAL, 0, - _( "Mirror" ), _( "Mirrors selected item" ), mirror_h_xpm ); - -TOOL_ACTION COMMON_ACTIONS::remove( "pcbnew.InteractiveEdit.remove", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_BACK_SPACE ), - _( "Remove" ), _( "Deletes selected item(s)" ), delete_xpm, - AF_NONE, (void*) REMOVE_FLAGS::NORMAL ); - -TOOL_ACTION COMMON_ACTIONS::removeAlt( "pcbnew.InteractiveEdit.removeAlt", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DELETE ), - _( "Remove (Alternative)" ), _( "Deletes selected item(s)" ), delete_xpm, - AF_NONE, (void*) REMOVE_FLAGS::ALT ); - -TOOL_ACTION COMMON_ACTIONS::exchangeFootprints( "pcbnew.InteractiveEdit.ExchangeFootprints", - AS_GLOBAL, 0, - _( "Exchange Footprint(s)" ), _( "Change the footprint used for modules" ), - import_module_xpm ); - - -TOOL_ACTION COMMON_ACTIONS::properties( "pcbnew.InteractiveEdit.properties", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_ITEM ), - _( "Properties..." ), _( "Displays item properties dialog" ), editor_xpm ); - -TOOL_ACTION COMMON_ACTIONS::editModifiedSelection( "pcbnew.InteractiveEdit.ModifiedSelection", - AS_GLOBAL, 0, - "", "" ); - - -// Drawing tool actions -TOOL_ACTION COMMON_ACTIONS::drawLine( "pcbnew.InteractiveDrawing.line", - AS_GLOBAL, 0, - _( "Draw Line" ), _( "Draw a line" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::drawCircle( "pcbnew.InteractiveDrawing.circle", - AS_GLOBAL, 0, - _( "Draw Circle" ), _( "Draw a circle" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::drawArc( "pcbnew.InteractiveDrawing.arc", - AS_GLOBAL, 0, - _( "Draw Arc" ), _( "Draw an arc" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::placeText( "pcbnew.InteractiveDrawing.text", - AS_GLOBAL, 0, - _( "Add Text" ), _( "Add a text" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::drawDimension( "pcbnew.InteractiveDrawing.dimension", - AS_GLOBAL, 0, - _( "Add Dimension" ), _( "Add a dimension" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::drawZone( "pcbnew.InteractiveDrawing.zone", - AS_GLOBAL, 0, - _( "Add Filled Zone" ), _( "Add a filled zone" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::drawKeepout( "pcbnew.InteractiveDrawing.keepout", - AS_GLOBAL, 0, - _( "Add Keepout Area" ), _( "Add a keepout area" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::drawZoneCutout( "pcbnew.InteractiveDrawing.zoneCutout", - AS_GLOBAL, 0, - _( "Add a Zone Cutout" ), _( "Add a cutout area of an existing zone" ), - add_zone_cutout_xpm, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::drawSimilarZone( "pcbnew.InteractiveDrawing.similarZone", - AS_GLOBAL, 0, - _( "Add a Similar Zone" ), _( "Add a zone with the same settings as an existing zone" ), - add_zone_xpm, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::placeDXF( "pcbnew.InteractiveDrawing.placeDXF", - AS_GLOBAL, 0, - "Place DXF", "", NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::setAnchor( "pcbnew.InteractiveDrawing.setAnchor", - AS_GLOBAL, 0, - _( "Place the Footprint Anchor" ), _( "Place the footprint anchor" ), - NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::incWidth( "pcbnew.InteractiveDrawing.incWidth", - AS_CONTEXT, '+', - _( "Increase Line Width" ), _( "Increase the line width" ) ); - -TOOL_ACTION COMMON_ACTIONS::decWidth( "pcbnew.InteractiveDrawing.decWidth", - AS_CONTEXT, '-', - _( "Decrease Line Width" ), _( "Decrease the line width" ) ); - -TOOL_ACTION COMMON_ACTIONS::arcPosture( "pcbnew.InteractiveDrawing.arcPosture", - AS_CONTEXT, TOOL_ACTION::LegacyHotKey( HK_SWITCH_TRACK_POSTURE ), - _( "Switch Arc Posture" ), _( "Switch the arc posture" ) ); - - -// View Controls -TOOL_ACTION COMMON_ACTIONS::zoomIn( "common.Control.zoomIn", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_IN ), - _( "Zoom In" ), "", zoom_in_xpm ); - -TOOL_ACTION COMMON_ACTIONS::zoomOut( "common.Control.zoomOut", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_OUT ), - _( "Zoom Out" ), "", zoom_out_xpm ); - -TOOL_ACTION COMMON_ACTIONS::zoomInCenter( "common.Control.zoomInCenter", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::zoomOutCenter( "common.Control.zoomOutCenter", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::zoomCenter( "common.Control.zoomCenter", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_CENTER ), - _( "Center" ), "", zoom_center_on_screen_xpm ); - -TOOL_ACTION COMMON_ACTIONS::zoomFitScreen( "common.Control.zoomFitScreen", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_AUTO ), - _( "Zoom Auto" ), "", zoom_fit_in_page_xpm ); - -TOOL_ACTION COMMON_ACTIONS::zoomPreset( "common.Control.zoomPreset", - AS_GLOBAL, 0, - "", "" ); - - -// Display modes -TOOL_ACTION COMMON_ACTIONS::trackDisplayMode( "pcbnew.Control.trackDisplayMode", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_TRACK_DISPLAY_MODE ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::padDisplayMode( "pcbnew.Control.padDisplayMode", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::viaDisplayMode( "pcbnew.Control.viaDisplayMode", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::zoneDisplayEnable( "pcbnew.Control.zoneDisplayEnable", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::zoneDisplayDisable( "pcbnew.Control.zoneDisplayDisable", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::zoneDisplayOutlines( "pcbnew.Control.zoneDisplayOutlines", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::highContrastMode( "pcbnew.Control.highContrastMode", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_HIGHCONTRAST_MODE ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::highContrastInc( "pcbnew.Control.highContrastInc", - AS_GLOBAL, '>', - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::highContrastDec( "pcbnew.Control.highContrastDec", - AS_GLOBAL, '<', - "", "" ); - - -// Layer control -TOOL_ACTION COMMON_ACTIONS::layerTop( "pcbnew.Control.layerTop", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_COMPONENT ), - "", "", NULL, AF_NONE, (void*) F_Cu ); - -TOOL_ACTION COMMON_ACTIONS::layerInner1( "pcbnew.Control.layerInner1", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER1 ), - "", "", NULL, AF_NONE, (void*) In1_Cu ); - -TOOL_ACTION COMMON_ACTIONS::layerInner2( "pcbnew.Control.layerInner2", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER2 ), - "", "", NULL, AF_NONE, (void*) In2_Cu ); - -TOOL_ACTION COMMON_ACTIONS::layerInner3( "pcbnew.Control.layerInner3", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER3 ), - "", "", NULL, AF_NONE, (void*) In3_Cu ); - -TOOL_ACTION COMMON_ACTIONS::layerInner4( "pcbnew.Control.layerInner4", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER4 ), - "", "", NULL, AF_NONE, (void*) In4_Cu ); - -TOOL_ACTION COMMON_ACTIONS::layerInner5( "pcbnew.Control.layerInner5", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER5 ), - "", "", NULL, AF_NONE, (void*) In5_Cu ); - -TOOL_ACTION COMMON_ACTIONS::layerInner6( "pcbnew.Control.layerInner6", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_INNER6 ), - "", "", NULL, AF_NONE, (void*) In6_Cu ); - -TOOL_ACTION COMMON_ACTIONS::layerBottom( "pcbnew.Control.layerBottom", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_COPPER ), - "", "", NULL, AF_NONE, (void*) B_Cu ); - -TOOL_ACTION COMMON_ACTIONS::layerNext( "pcbnew.Control.layerNext", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_NEXT ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::layerPrev( "pcbnew.Control.layerPrev", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_LAYER_TO_PREVIOUS ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::layerToggle( "pcbnew.Control.layerToggle", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_THROUGH_VIA ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::layerAlphaInc( "pcbnew.Control.layerAlphaInc", - AS_GLOBAL, '}', - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::layerAlphaDec( "pcbnew.Control.layerAlphaDec", - AS_GLOBAL, '{', - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::layerChanged( "pcbnew.Control.layerChanged", - AS_GLOBAL, 0, - "", "", NULL, AF_NOTIFY ); - - -// Grid control -TOOL_ACTION COMMON_ACTIONS::gridFast1( "common.Control.gridFast1", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_FASTGRID1 ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::gridFast2( "common.Control.gridFast2", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_FASTGRID2 ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::gridNext( "common.Control.gridNext", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_NEXT ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::gridPrev( "common.Control.gridPrev", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_GRID_TO_PREVIOUS ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::gridSetOrigin( "common.Control.gridSetOrigin", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SET_GRID_ORIGIN ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::gridResetOrigin( "common.Control.gridResetOrigin", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_RESET_GRID_ORIGIN ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::gridPreset( "common.Control.gridPreset", - AS_GLOBAL, 0, - "", "" ); - -// Track & via size control -TOOL_ACTION COMMON_ACTIONS::trackWidthInc( "pcbnew.EditorControl.trackWidthInc", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_TRACK_WIDTH_TO_NEXT ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::trackWidthDec( "pcbnew.EditorControl.trackWidthDec", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_TRACK_WIDTH_TO_PREVIOUS ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::viaSizeInc( "pcbnew.EditorControl.viaSizeInc", - AS_GLOBAL, '\'', - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::viaSizeDec( "pcbnew.EditorControl.viaSizeDec", - AS_GLOBAL, '\\', - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::trackViaSizeChanged( "pcbnew.EditorControl.trackViaSizeChanged", - AS_GLOBAL, 0, - "", "", NULL, AF_NOTIFY ); - - -// Zone actions -TOOL_ACTION COMMON_ACTIONS::zoneFill( "pcbnew.EditorControl.zoneFill", - AS_GLOBAL, 0, - _( "Fill" ), _( "Fill zone(s)" ), fill_zone_xpm ); - -TOOL_ACTION COMMON_ACTIONS::zoneFillAll( "pcbnew.EditorControl.zoneFillAll", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZONE_FILL_OR_REFILL ), - _( "Fill All" ), _( "Fill all zones" ) ); - -TOOL_ACTION COMMON_ACTIONS::zoneUnfill( "pcbnew.EditorControl.zoneUnfill", - AS_GLOBAL, 0, - _( "Unfill" ), _( "Unfill zone(s)" ), zone_unfill_xpm ); - -TOOL_ACTION COMMON_ACTIONS::zoneUnfillAll( "pcbnew.EditorControl.zoneUnfillAll", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZONE_REMOVE_FILLED ), - _( "Unfill All" ), _( "Unfill all zones" ) ); - -TOOL_ACTION COMMON_ACTIONS::zoneMerge( "pcbnew.EditorControl.zoneMerge", - AS_GLOBAL, 0, - _( "Merge Zones" ), _( "Merge zones" ) ); - -TOOL_ACTION COMMON_ACTIONS::zoneDuplicate( "pcbnew.EditorControl.zoneDuplicate", - AS_GLOBAL, 0, - _( "Duplicate Zone onto Layer" ), _( "Duplicate zone outline onto a different layer" ), - zone_duplicate_xpm ); - - -TOOL_ACTION COMMON_ACTIONS::placeTarget( "pcbnew.EditorControl.placeTarget", - AS_GLOBAL, 0, - _( "Add Layer Alignment Target" ), _( "Add a layer alignment target" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::placeModule( "pcbnew.EditorControl.placeModule", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_MODULE ), - _( "Add Footprint" ), _( "Add a footprint" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::drillOrigin( "pcbnew.EditorControl.drillOrigin", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::crossProbeSchToPcb( "pcbnew.EditorControl.crossProbSchToPcb", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::toggleLock( "pcbnew.EditorControl.toggleLock", - AS_GLOBAL, 'L', - "Toggle Lock", "" ); - -TOOL_ACTION COMMON_ACTIONS::lock( "pcbnew.EditorControl.lock", - AS_GLOBAL, 0, - _( "Lock" ), "" ); - -TOOL_ACTION COMMON_ACTIONS::unlock( "pcbnew.EditorControl.unlock", - AS_GLOBAL, 0, - _( "Unlock" ), "" ); - -TOOL_ACTION COMMON_ACTIONS::appendBoard( "pcbnew.EditorControl.appendBoard", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::highlightNet( "pcbnew.EditorControl.highlightNet", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::highlightNetCursor( "pcbnew.EditorControl.highlightNetCursor", - AS_GLOBAL, 0, - "", "" ); - - -// Module editor tools -TOOL_ACTION COMMON_ACTIONS::placePad( "pcbnew.ModuleEditor.placePad", - AS_GLOBAL, 0, - _( "Add Pad" ), _( "Add a pad" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::enumeratePads( "pcbnew.ModuleEditor.enumeratePads", - AS_GLOBAL, 0, - _( "Enumerate Pads" ), _( "Enumerate pads" ), pad_enumerate_xpm, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::copyItems( "pcbnew.ModuleEditor.copyItems", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_COPY_ITEM ), - _( "Copy" ), _( "Copy items" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::pasteItems( "pcbnew.ModuleEditor.pasteItems", - AS_GLOBAL, MD_CTRL + int( 'V' ), - _( "Paste" ), _( "Paste items" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::moduleEdgeOutlines( "pcbnew.ModuleEditor.graphicOutlines", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::moduleTextOutlines( "pcbnew.ModuleEditor.textOutlines", - AS_GLOBAL, 0, - "", "" ); - -// Pad tools -TOOL_ACTION COMMON_ACTIONS::copyPadSettings( - "pcbnew.PadTool.CopyPadSettings", - AS_GLOBAL, 0, - _( "Copy Pad Settings" ), _( "Copy current pad's settings to the board design settings" ), - copy_pad_settings_xpm ); - -TOOL_ACTION COMMON_ACTIONS::applyPadSettings( - "pcbnew.PadTool.ApplyPadSettings", - AS_GLOBAL, 0, - _( "Apply Pad Settings" ), _( "Copy the board design settings pad properties to the current pad" ), - apply_pad_settings_xpm ); - -TOOL_ACTION COMMON_ACTIONS::pushPadSettings( - "pcbnew.PadTool.PushPadSettings", - AS_GLOBAL, 0, - _( "Push Pad Settings" ), _( "Copy the current pad settings to other pads" ), - push_pad_settings_xpm ); - -// Cursor control -TOOL_ACTION COMMON_ACTIONS::cursorUp( "pcbnew.Control.cursorUp", - AS_GLOBAL, WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP ); -TOOL_ACTION COMMON_ACTIONS::cursorDown( "pcbnew.Control.cursorDown", - AS_GLOBAL, WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN ); -TOOL_ACTION COMMON_ACTIONS::cursorLeft( "pcbnew.Control.cursorLeft", - AS_GLOBAL, WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT ); -TOOL_ACTION COMMON_ACTIONS::cursorRight( "pcbnew.Control.cursorRight", - AS_GLOBAL, WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT ); - -TOOL_ACTION COMMON_ACTIONS::cursorUpFast( "pcbnew.Control.cursorUpFast", - AS_GLOBAL, MD_CTRL + WXK_UP, "", "", NULL, AF_NONE, (void*) ( CURSOR_UP | CURSOR_FAST_MOVE ) ); -TOOL_ACTION COMMON_ACTIONS::cursorDownFast( "pcbnew.Control.cursorDownFast", - AS_GLOBAL, MD_CTRL + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) ( CURSOR_DOWN | CURSOR_FAST_MOVE ) ); -TOOL_ACTION COMMON_ACTIONS::cursorLeftFast( "pcbnew.Control.cursorLeftFast", - AS_GLOBAL, MD_CTRL + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_LEFT | CURSOR_FAST_MOVE ) ); -TOOL_ACTION COMMON_ACTIONS::cursorRightFast( "pcbnew.Control.cursorRightFast", - AS_GLOBAL, MD_CTRL + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) ( CURSOR_RIGHT | CURSOR_FAST_MOVE ) ); - -TOOL_ACTION COMMON_ACTIONS::cursorClick( "pcbnew.Control.cursorClick", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_CLICK ), - "", "", NULL, AF_NONE, (void*) CURSOR_CLICK ); -TOOL_ACTION COMMON_ACTIONS::cursorDblClick( "pcbnew.Control.cursorDblClick", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_LEFT_DCLICK ), - "", "", NULL, AF_NONE, (void*) CURSOR_DBL_CLICK ); - -TOOL_ACTION COMMON_ACTIONS::panUp( "pcbnew.Control.panUp", - AS_GLOBAL, MD_SHIFT + WXK_UP, "", "", NULL, AF_NONE, (void*) CURSOR_UP ); -TOOL_ACTION COMMON_ACTIONS::panDown( "pcbnew.Control.panDown", - AS_GLOBAL, MD_SHIFT + WXK_DOWN, "", "" , NULL, AF_NONE, (void*) CURSOR_DOWN ); -TOOL_ACTION COMMON_ACTIONS::panLeft( "pcbnew.Control.panLeft", - AS_GLOBAL, MD_SHIFT + WXK_LEFT, "", "" , NULL, AF_NONE, (void*) CURSOR_LEFT ); -TOOL_ACTION COMMON_ACTIONS::panRight( "pcbnew.Control.panRight", - AS_GLOBAL, MD_SHIFT + WXK_RIGHT, "", "" , NULL, AF_NONE, (void*) CURSOR_RIGHT ); - -// Miscellaneous -TOOL_ACTION COMMON_ACTIONS::selectionTool( "pcbnew.Control.selectionTool", - AS_GLOBAL, 0, - "", "", NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::zoomTool( "pcbnew.Control.zoomTool", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ZOOM_SELECTION ), - _( "Zoom to Selection" ), "", NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::pickerTool( "pcbnew.Picker", AS_GLOBAL, 0, "", "", NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::resetCoords( "pcbnew.Control.resetCoords", - AS_GLOBAL, ' ', - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::switchCursor( "pcbnew.Control.switchCursor", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::switchUnits( "pcbnew.Control.switchUnits", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_SWITCH_UNITS ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::deleteItemCursor( "pcbnew.Control.deleteItemCursor", - AS_GLOBAL, 0, - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::showHelp( "pcbnew.Control.showHelp", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_HELP ), - "", "" ); - -TOOL_ACTION COMMON_ACTIONS::toBeDone( "pcbnew.Control.toBeDone", - AS_GLOBAL, 0, // dialog saying it is not implemented yet - "", "" ); // so users are aware of that - -TOOL_ACTION COMMON_ACTIONS::routerActivateSingle( "pcbnew.InteractiveRouter.SingleTrack", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_ADD_NEW_TRACK ), - _( "Interactive Router (Single Tracks)" ), - _( "Run push & shove router (single tracks)" ), ps_router_xpm, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::routerActivateDiffPair( "pcbnew.InteractiveRouter.DiffPair", - AS_GLOBAL, '6', - _( "Interactive Router (Differential Pairs)" ), - _( "Run push & shove router (differential pairs)" ), ps_diff_pair_xpm, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::routerActivateSettingsDialog( "pcbnew.InteractiveRouter.SettingsDialog", - AS_GLOBAL, 0, - _( "Interactive Router Settings" ), - _( "Open Interactive Router settings" ), NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::routerActivateDpDimensionsDialog( "pcbnew.InteractiveRouter.DpDimensionsDialog", - AS_GLOBAL, 0, - _( "Differential Pair Dimension settings" ), - _( "Open Differential Pair Dimension settings" ), ps_diff_pair_gap_xpm, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::routerActivateTuneSingleTrace( "pcbnew.LengthTuner.TuneSingleTrack", - AS_GLOBAL, '7', - _( "Tune length of a single track" ), "", ps_tune_length_xpm, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::routerActivateTuneDiffPair( "pcbnew.LengthTuner.TuneDiffPair", - AS_GLOBAL, '8', - _( "Tune length of a differential pair" ), "", NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::routerActivateTuneDiffPairSkew( "pcbnew.LengthTuner.TuneDiffPairSkew", - AS_GLOBAL, '9', - _( "Tune skew of a differential pair" ), "", NULL, AF_ACTIVATE ); - -TOOL_ACTION COMMON_ACTIONS::routerInlineDrag( "pcbnew.InteractiveRouter.InlineDrag", - AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_DRAG_TRACK_KEEP_SLOPE ), - _( "Drag Track/Via" ), _( "Drags tracks and vias without breaking connections" ), - drag_track_segment_xpm ); - -// Point editor -TOOL_ACTION COMMON_ACTIONS::pointEditorAddCorner( "pcbnew.PointEditor.addCorner", - AS_GLOBAL, 0, - _( "Create Corner" ), _( "Create a corner" ), add_corner_xpm ); - -TOOL_ACTION COMMON_ACTIONS::pointEditorRemoveCorner( "pcbnew.PointEditor.removeCorner", - AS_GLOBAL, 0, - _( "Remove Corner" ), _( "Remove corner" ), delete_xpm ); - -// Placement tool -TOOL_ACTION COMMON_ACTIONS::alignTop( "pcbnew.Place.alignTop", - AS_GLOBAL, 0, - _( "Align to Top" ), - _( "Aligns selected items to the top edge" ), up_xpm ); - -TOOL_ACTION COMMON_ACTIONS::alignBottom( "pcbnew.Place.alignBottom", - AS_GLOBAL, 0, - _( "Align to Bottom" ), - _( "Aligns selected items to the bottom edge" ), down_xpm ); - -TOOL_ACTION COMMON_ACTIONS::alignLeft( "pcbnew.Place.alignLeft", - AS_GLOBAL, 0, - _( "Align to Left" ), - _( "Aligns selected items to the left edge" ), left_xpm ); - -TOOL_ACTION COMMON_ACTIONS::alignRight( "pcbnew.Place.alignRight", - AS_GLOBAL, 0, - _( "Align to Right" ), - _( "Aligns selected items to the right edge" ), right_xpm ); - -TOOL_ACTION COMMON_ACTIONS::distributeHorizontally( "pcbnew.Place.distributeHorizontally", - AS_GLOBAL, 0, - _( "Distribute Horizontally" ), - _( "Distributes selected items along the horizontal axis" ), distribute_horizontal_xpm ); - -TOOL_ACTION COMMON_ACTIONS::distributeVertically( "pcbnew.Place.distributeVertically", - AS_GLOBAL, 0, - _( "Distribute Vertically" ), - _( "Distributes selected items along the vertical axis" ), distribute_vertical_xpm ); - - -boost::optional COMMON_ACTIONS::TranslateLegacyId( int aId ) -{ - switch( aId ) - { - case ID_PCB_MODULE_BUTT: - return COMMON_ACTIONS::placeModule.MakeEvent(); - - case ID_TRACK_BUTT: - return COMMON_ACTIONS::routerActivateSingle.MakeEvent(); - - case ID_DIFF_PAIR_BUTT: - return COMMON_ACTIONS::routerActivateDiffPair.MakeEvent(); - - case ID_TUNE_SINGLE_TRACK_LEN_BUTT: - return COMMON_ACTIONS::routerActivateTuneSingleTrace.MakeEvent(); - - case ID_TUNE_DIFF_PAIR_LEN_BUTT: - return COMMON_ACTIONS::routerActivateTuneDiffPair.MakeEvent(); - - case ID_TUNE_DIFF_PAIR_SKEW_BUTT: - return COMMON_ACTIONS::routerActivateTuneDiffPairSkew.MakeEvent(); - - case ID_MENU_INTERACTIVE_ROUTER_SETTINGS: - return COMMON_ACTIONS::routerActivateSettingsDialog.MakeEvent(); - - case ID_MENU_DIFF_PAIR_DIMENSIONS: - return COMMON_ACTIONS::routerActivateDpDimensionsDialog.MakeEvent(); - - case ID_PCB_ZONES_BUTT: - return COMMON_ACTIONS::drawZone.MakeEvent(); - - case ID_PCB_KEEPOUT_AREA_BUTT: - return COMMON_ACTIONS::drawKeepout.MakeEvent(); - - case ID_PCB_ADD_LINE_BUTT: - case ID_MODEDIT_LINE_TOOL: - return COMMON_ACTIONS::drawLine.MakeEvent(); - - case ID_PCB_CIRCLE_BUTT: - case ID_MODEDIT_CIRCLE_TOOL: - return COMMON_ACTIONS::drawCircle.MakeEvent(); - - case ID_PCB_ARC_BUTT: - case ID_MODEDIT_ARC_TOOL: - return COMMON_ACTIONS::drawArc.MakeEvent(); - - case ID_PCB_ADD_TEXT_BUTT: - case ID_MODEDIT_TEXT_TOOL: - return COMMON_ACTIONS::placeText.MakeEvent(); - - case ID_PCB_DIMENSION_BUTT: - return COMMON_ACTIONS::drawDimension.MakeEvent(); - - case ID_PCB_MIRE_BUTT: - return COMMON_ACTIONS::placeTarget.MakeEvent(); - - case ID_MODEDIT_PAD_TOOL: - return COMMON_ACTIONS::placePad.MakeEvent(); - - case ID_GEN_IMPORT_DXF_FILE: - return COMMON_ACTIONS::placeDXF.MakeEvent(); - - case ID_MODEDIT_ANCHOR_TOOL: - return COMMON_ACTIONS::setAnchor.MakeEvent(); - - case ID_PCB_PLACE_GRID_COORD_BUTT: - case ID_MODEDIT_PLACE_GRID_COORD: - return COMMON_ACTIONS::gridSetOrigin.MakeEvent(); - - case ID_ZOOM_IN: // toolbar button "Zoom In" - return COMMON_ACTIONS::zoomInCenter.MakeEvent(); - - case ID_ZOOM_OUT: // toolbar button "Zoom In" - return COMMON_ACTIONS::zoomOutCenter.MakeEvent(); - - case ID_ZOOM_PAGE: // toolbar button "Fit on Screen" - return COMMON_ACTIONS::zoomFitScreen.MakeEvent(); - - case ID_TB_OPTIONS_SHOW_TRACKS_SKETCH: - return COMMON_ACTIONS::trackDisplayMode.MakeEvent(); - - case ID_TB_OPTIONS_SHOW_PADS_SKETCH: - return COMMON_ACTIONS::padDisplayMode.MakeEvent(); - - case ID_TB_OPTIONS_SHOW_VIAS_SKETCH: - return COMMON_ACTIONS::viaDisplayMode.MakeEvent(); - - case ID_TB_OPTIONS_SHOW_ZONES: - return COMMON_ACTIONS::zoneDisplayEnable.MakeEvent(); - - case ID_TB_OPTIONS_SHOW_ZONES_DISABLE: - return COMMON_ACTIONS::zoneDisplayDisable.MakeEvent(); - - case ID_TB_OPTIONS_SHOW_ZONES_OUTLINES_ONLY: - return COMMON_ACTIONS::zoneDisplayOutlines.MakeEvent(); - - case ID_TB_OPTIONS_SHOW_MODULE_EDGE_SKETCH: - return COMMON_ACTIONS::moduleEdgeOutlines.MakeEvent(); - - case ID_TB_OPTIONS_SHOW_MODULE_TEXT_SKETCH: - return COMMON_ACTIONS::moduleTextOutlines.MakeEvent(); - - case ID_TB_OPTIONS_SHOW_HIGH_CONTRAST_MODE: - return COMMON_ACTIONS::highContrastMode.MakeEvent(); - - case ID_FIND_ITEMS: - return COMMON_ACTIONS::find.MakeEvent(); - - case ID_POPUP_PCB_GET_AND_MOVE_MODULE_REQUEST: - return COMMON_ACTIONS::findMove.MakeEvent(); - - case ID_NO_TOOL_SELECTED: - return COMMON_ACTIONS::selectionTool.MakeEvent(); - - case ID_ZOOM_SELECTION: - return COMMON_ACTIONS::zoomTool.MakeEvent(); - - case ID_PCB_DELETE_ITEM_BUTT: - case ID_MODEDIT_DELETE_TOOL: - return COMMON_ACTIONS::deleteItemCursor.MakeEvent(); - - case ID_PCB_PLACE_OFFSET_COORD_BUTT: - return COMMON_ACTIONS::drillOrigin.MakeEvent(); - - case ID_PCB_HIGHLIGHT_BUTT: - return COMMON_ACTIONS::highlightNetCursor.MakeEvent(); - - case ID_APPEND_FILE: - return COMMON_ACTIONS::appendBoard.MakeEvent(); - - case ID_PCB_SHOW_1_RATSNEST_BUTT: - return COMMON_ACTIONS::showLocalRatsnest.MakeEvent(); - } - - return boost::optional(); -} diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 88da9590cc..e9d7708d05 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1389,19 +1389,19 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent ) const auto lset = aVia->GetLayerSet(); for( auto tv : m_board->Tracks() ) // fixme: move to BOARD class? - if( tv->HitTest( pos ) && (tv->GetLayerSet() & - lset ).any() ) + { + if( tv->HitTest( pos ) && ( tv->GetLayerSet() & lset ).any() ) return -1; - - + } for( auto mod : m_board->Modules() ) + { for( auto pad : mod->Pads() ) - if( pad->HitTest( pos ) && (pad->GetLayerSet() & - lset ).any() ) + { + if( pad->HitTest( pos ) && ( pad->GetLayerSet() & lset ).any() ) return -1; - - + } + } std::vector foundZones; @@ -1511,7 +1511,6 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent ) break; } - return std::unique_ptr( via ); } }; @@ -1520,8 +1519,7 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent ) frame()->SetToolID( ID_PCB_DRAW_VIA_BUTT, wxCURSOR_PENCIL, _( "Add vias" ) ); - doInteractiveItemPlacement( &placer, _( - "Place via" ), + doInteractiveItemPlacement( &placer, _( "Place via" ), IPO_REPEAT | IPO_SINGLE_CLICK | IPO_ROTATE | IPO_FLIP | IPO_PROPERTIES ); frame()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 4a00d4a5b9..2ead0240fe 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -532,6 +532,7 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) return 0; } + /*! * Mirror a point about the vertical axis passing through another point */ @@ -1149,6 +1150,7 @@ void EDIT_TOOL::SetTransitions() Go( &EDIT_TOOL::MeasureTool, PCB_ACTIONS::measureTool.MakeEvent() ); } + void EDIT_TOOL::updateRatsnest( bool aRedraw ) { auto& selection = m_selectionTool->GetSelection(); @@ -1161,6 +1163,7 @@ void EDIT_TOOL::updateRatsnest( bool aRedraw ) connectivity->ComputeDynamicRatsnest( items ); } + wxPoint EDIT_TOOL::getModificationPoint( const SELECTION& aSelection ) { if( aSelection.Size() == 1 ) @@ -1178,6 +1181,7 @@ wxPoint EDIT_TOOL::getModificationPoint( const SELECTION& aSelection ) } } + int EDIT_TOOL::editFootprintInFpEditor( const TOOL_EVENT& aEvent ) { const auto& selection = m_selectionTool->RequestSelection(); @@ -1214,6 +1218,7 @@ int EDIT_TOOL::editFootprintInFpEditor( const TOOL_EVENT& aEvent ) return 0; } + template T* EDIT_TOOL::uniqueSelected() { diff --git a/pcbnew/tools/edit_tool.h b/pcbnew/tools/edit_tool.h index 821dd0788b..71ff819fe2 100644 --- a/pcbnew/tools/edit_tool.h +++ b/pcbnew/tools/edit_tool.h @@ -145,8 +145,6 @@ private: ///> of edit reference point). VECTOR2I m_cursor; - std::unique_ptr m_dynamicConnectivity; - ///> Updates ratsnest for selected items. ///> @param aRedraw says if selected items should be drawn using the simple mode (e.g. one line ///> per item). diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index e44209a7f8..d3bd9b644a 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -485,12 +485,12 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) } } - controls->ShowCursor( false ); + controls->ShowCursor( false ); controls->SetSnapping( false ); controls->SetAutoPan( false ); controls->CaptureCursor( false ); - view->Remove( &preview ); + view->Remove( &preview ); m_frame->SetNoToolSelected(); return 0; @@ -836,23 +836,23 @@ int PCB_EDITOR_CONTROL::ZoneMerge( const TOOL_EVENT& aEvent ) if( firstZone ) { - if( firstZone->GetNetCode() != netcode ) - continue; + if( firstZone->GetNetCode() != netcode ) + continue; - if( curr_area->GetPriority() != firstZone->GetPriority() ) - continue; + if( curr_area->GetPriority() != firstZone->GetPriority() ) + continue; - if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() ) - continue; + if( curr_area->GetIsKeepout() != firstZone->GetIsKeepout() ) + continue; - if( curr_area->GetLayer() != firstZone->GetLayer() ) - continue; + if( curr_area->GetLayer() != firstZone->GetLayer() ) + continue; - if( !board->TestAreaIntersection( curr_area, firstZone ) ) - continue; + if( !board->TestAreaIntersection( curr_area, firstZone ) ) + continue; - toMerge.push_back( curr_area ); - } + toMerge.push_back( curr_area ); + } else { toMerge.push_back( curr_area ); @@ -1088,6 +1088,7 @@ int PCB_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent ) return 0; } + static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition ) { auto selectionTool = aToolMgr->GetTool(); @@ -1100,11 +1101,11 @@ static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition if( selection.Empty() ) return true; - for ( auto item : selection ) + for( auto item : selection ) { - if ( item->Type() == PCB_MODULE_T ) + if( item->Type() == PCB_MODULE_T ) { - for ( auto pad : static_cast (item)->Pads() ) + for( auto pad : static_cast (item)->Pads() ) { pad->SetLocalRatsnestVisible( true ); } @@ -1114,6 +1115,7 @@ static bool showLocalRatsnest( TOOL_MANAGER* aToolMgr, const VECTOR2D& aPosition return true; } + int PCB_EDITOR_CONTROL::ShowLocalRatsnest( const TOOL_EVENT& aEvent ) { Activate(); @@ -1130,6 +1132,7 @@ int PCB_EDITOR_CONTROL::ShowLocalRatsnest( const TOOL_EVENT& aEvent ) return 0; } + int PCB_EDITOR_CONTROL::UpdateSelectionRatsnest( const TOOL_EVENT& aEvent ) { return 0; @@ -1179,7 +1182,7 @@ void PCB_EDITOR_CONTROL::SetTransitions() Go( &PCB_EDITOR_CONTROL::DrillOrigin, PCB_ACTIONS::drillOrigin.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::HighlightNet, PCB_ACTIONS::highlightNet.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::HighlightNetCursor, PCB_ACTIONS::highlightNetCursor.MakeEvent() ); - Go( &PCB_EDITOR_CONTROL::ShowLocalRatsnest, PCB_ACTIONS::showLocalRatsnest.MakeEvent() ); + Go( &PCB_EDITOR_CONTROL::ShowLocalRatsnest, PCB_ACTIONS::showLocalRatsnest.MakeEvent() ); Go( &PCB_EDITOR_CONTROL::UpdateSelectionRatsnest, PCB_ACTIONS::selectionModified.MakeEvent() ); } diff --git a/pcbnew/tools/pcb_tool.cpp b/pcbnew/tools/pcb_tool.cpp index 4651b51a6f..3e64deb100 100644 --- a/pcbnew/tools/pcb_tool.cpp +++ b/pcbnew/tools/pcb_tool.cpp @@ -35,7 +35,7 @@ #include "pcb_actions.h" #include "tool_event_utils.h" -void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE *aPlacer, +void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE* aPlacer, const wxString& aCommitMessage, int aOptions ) { @@ -59,7 +59,7 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE *aPlacer, aPlacer->m_board = board(); aPlacer->m_frame = frame(); - if ( aOptions & IPO_SINGLE_CLICK ) + if( aOptions & IPO_SINGLE_CLICK ) { VECTOR2I cursorPos = controls()->GetCursorPosition(); @@ -83,7 +83,7 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE *aPlacer, preview.Clear(); - if ( aOptions & IPO_SINGLE_CLICK ) + if( aOptions & IPO_SINGLE_CLICK ) break; controls()->SetAutoPan( false ); @@ -144,10 +144,11 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE *aPlacer, controls()->CaptureCursor( false ); controls()->SetAutoPan( false ); controls()->ShowCursor( true ); - if (! ( aOptions & IPO_REPEAT ) ) + + if( !( aOptions & IPO_REPEAT ) ) break; - if ( aOptions & IPO_SINGLE_CLICK ) + if( aOptions & IPO_SINGLE_CLICK ) { VECTOR2I pos = controls()->GetCursorPosition(); @@ -156,7 +157,6 @@ void PCB_TOOL::doInteractiveItemPlacement( INTERACTIVE_PLACER_BASE *aPlacer, preview.Add( newItem.get() ); } - } } diff --git a/pcbnew/tools/pcb_tool.h b/pcbnew/tools/pcb_tool.h index de6b62a3a3..2c83ff9d4b 100644 --- a/pcbnew/tools/pcb_tool.h +++ b/pcbnew/tools/pcb_tool.h @@ -50,8 +50,8 @@ struct INTERACTIVE_PLACER_BASE virtual std::unique_ptr CreateItem() = 0; virtual bool PlaceItem( BOARD_ITEM *aItem ) { return false; } - PCB_EDIT_FRAME *m_frame; - BOARD *m_board; + PCB_EDIT_FRAME* m_frame; + BOARD* m_board; }; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 16083a5524..3260cab1cd 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -830,7 +830,7 @@ void SELECTION_TOOL::selectAllItemsConnectedToTrack( TRACK& aSourceTrack ) void SELECTION_TOOL::selectAllItemsConnectedToItem( BOARD_CONNECTED_ITEM& aSourceItem ) { - constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT }; + constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT }; auto connectivity = board()->GetConnectivity(); std::list items; diff --git a/pcbnew/tr_modif.cpp b/pcbnew/tr_modif.cpp index da40c0ef3d..07318493a8 100644 --- a/pcbnew/tr_modif.cpp +++ b/pcbnew/tr_modif.cpp @@ -268,13 +268,13 @@ int PCB_EDIT_FRAME::EraseRedundantTrack( wxDC* aDC, pt_del->UnLink(); pt_del->SetStatus( 0 ); pt_del->ClearFlags(); - GetBoard()->GetConnectivity()->Remove ( pt_del ); + GetBoard()->GetConnectivity()->Remove( pt_del ); ITEM_PICKER picker( pt_del, UR_DELETED ); aItemsListPicker->PushItem( picker ); } else { - GetBoard()->GetConnectivity()->Remove ( pt_del ); + GetBoard()->GetConnectivity()->Remove( pt_del ); pt_del->DeleteStructure(); } } diff --git a/pcbnew/zones_by_polygon_fill_functions.cpp b/pcbnew/zones_by_polygon_fill_functions.cpp index e6a75c0704..32a4458017 100644 --- a/pcbnew/zones_by_polygon_fill_functions.cpp +++ b/pcbnew/zones_by_polygon_fill_functions.cpp @@ -117,10 +117,10 @@ int PCB_EDIT_FRAME::Fill_Zone( ZONE_CONTAINER* aZone ) wxBusyCursor dummy; // Shows an hourglass cursor (removed by its destructor) - BOARD_COMMIT commit ( this ); + BOARD_COMMIT commit( this ); commit.Modify( aZone ); aZone->BuildFilledSolidAreasPolygons( GetBoard() ); - commit.Push ( _("Fill Zone"), false ); + commit.Push( _( "Fill Zone" ), false ); //GetGalCanvas()->GetView()->Update( aZone, KIGFX::ALL ); //GetBoard()->GetConnectivity()->Update( aZone ); @@ -189,7 +189,9 @@ int PCB_EDIT_FRAME::Fill_All_Zones( wxWindow * aActiveWindow, bool aVerbose ) // Recalculate the active ratsnest, i.e. the unconnected links //TestForActiveLinksInRatsnest( 0 ); + if( progressDialog ) progressDialog->Destroy(); + return errorLevel; }