diff --git a/gerbview/export_to_pcbnew.cpp b/gerbview/export_to_pcbnew.cpp index 876c1662ed..466bd4c8c5 100644 --- a/gerbview/export_to_pcbnew.cpp +++ b/gerbview/export_to_pcbnew.cpp @@ -200,8 +200,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( const GERBER_DRAW_ITEM* aGbrIt Double2Str( MapToPcbUnits(seg_end.x) ).c_str(), Double2Str( MapToPcbUnits(seg_end.y) ).c_str(), TO_UTF8( GetPCBDefaultLayerName( aLayer ) ), - Double2Str( MapToPcbUnits( aGbrItem->m_Size.x ) ).c_str() - ); + Double2Str( MapToPcbUnits( aGbrItem->m_Size.x ) ).c_str() ); } else { @@ -212,8 +211,7 @@ void GBR_TO_PCB_EXPORTER::export_non_copper_item( const GERBER_DRAW_ITEM* aGbrIt Double2Str( MapToPcbUnits(seg_end.y) ).c_str(), Double2Str( angle ).c_str(), TO_UTF8( GetPCBDefaultLayerName( aLayer ) ), - Double2Str( MapToPcbUnits( aGbrItem->m_Size.x ) ).c_str() - ); + Double2Str( MapToPcbUnits( aGbrItem->m_Size.x ) ).c_str() ); } } break; @@ -265,14 +263,14 @@ void GBR_TO_PCB_EXPORTER::export_via( const EXPORT_VIA& aVia ) // Layers are Front to Back fprintf( m_fp, " (via (at %s %s) (size %s) (drill %s)", - Double2Str( MapToPcbUnits( via_pos.x ) ).c_str(), - Double2Str( MapToPcbUnits( via_pos.y ) ).c_str(), - Double2Str( MapToPcbUnits( aVia.m_Size ) ).c_str(), - Double2Str( MapToPcbUnits( aVia.m_Drill ) ).c_str() ); + Double2Str( MapToPcbUnits( via_pos.x ) ).c_str(), + Double2Str( MapToPcbUnits( via_pos.y ) ).c_str(), + Double2Str( MapToPcbUnits( aVia.m_Size ) ).c_str(), + Double2Str( MapToPcbUnits( aVia.m_Drill ) ).c_str() ); fprintf( m_fp, " (layers %s %s))\n", - TO_UTF8( GetPCBDefaultLayerName( F_Cu ) ), - TO_UTF8( GetPCBDefaultLayerName( B_Cu ) ) ); + TO_UTF8( GetPCBDefaultLayerName( F_Cu ) ), + TO_UTF8( GetPCBDefaultLayerName( B_Cu ) ) ); } @@ -329,12 +327,12 @@ void GBR_TO_PCB_EXPORTER::writeCopperLineItem( const wxPoint& aStart, const wxPo int aWidth, int aLayer ) { fprintf( m_fp, "(segment (start %s %s) (end %s %s) (width %s) (layer %s) (net 0))\n", - Double2Str( MapToPcbUnits(aStart.x) ).c_str(), - Double2Str( MapToPcbUnits(aStart.y) ).c_str(), - Double2Str( MapToPcbUnits(aEnd.x) ).c_str(), - Double2Str( MapToPcbUnits(aEnd.y) ).c_str(), - Double2Str( MapToPcbUnits( aWidth ) ).c_str(), - TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) ); + Double2Str( MapToPcbUnits(aStart.x) ).c_str(), + Double2Str( MapToPcbUnits(aStart.y) ).c_str(), + Double2Str( MapToPcbUnits(aEnd.x) ).c_str(), + Double2Str( MapToPcbUnits(aEnd.y) ).c_str(), + Double2Str( MapToPcbUnits( aWidth ) ).c_str(), + TO_UTF8( GetPCBDefaultLayerName( aLayer ) ) ); } @@ -369,8 +367,7 @@ void GBR_TO_PCB_EXPORTER::export_segarc_copper_item( const GERBER_DRAW_ITEM* aGb { seg_start = curr_start; wxPoint curr_end = start; - RotatePoint( &curr_end, aGbrItem->m_ArcCentre, - -RAD2DECIDEG( DELTA_ANGLE * ii ) ); + RotatePoint( &curr_end, aGbrItem->m_ArcCentre, -RAD2DECIDEG( DELTA_ANGLE * ii ) ); seg_end = curr_end; // Reverse Y axis: diff --git a/gerbview/gerber_draw_item.cpp b/gerbview/gerber_draw_item.cpp index c7795a496b..9c4973675b 100644 --- a/gerbview/gerber_draw_item.cpp +++ b/gerbview/gerber_draw_item.cpp @@ -66,9 +66,11 @@ void GERBER_DRAW_ITEM::SetNetAttributes( const GBR_NETLIST_METADATA& aNetAttribu { m_netAttributes = aNetAttributes; - if( ( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_CMP ) || - ( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_PAD ) ) + if( ( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_CMP ) + || ( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_PAD ) ) + { m_GerberImageFile->m_ComponentsList.insert( std::make_pair( m_netAttributes.m_Cmpref, 0 ) ); + } if( ( m_netAttributes.m_NetAttribType & GBR_NETLIST_METADATA::GBR_NETINFO_NET ) ) m_GerberImageFile->m_NetnamesList.insert( std::make_pair( m_netAttributes.m_Netname, 0 ) ); @@ -90,13 +92,9 @@ bool GERBER_DRAW_ITEM::GetTextD_CodePrms( int& aSize, wxPoint& aPos, double& aOr return false; // No D_Code for this item if( m_Flashed || m_Shape == GBR_ARC ) - { aPos = m_Start; - } else // it is a line: - { aPos = ( m_Start + m_End) / 2; - } aPos = GetABPosition( aPos ); @@ -227,29 +225,14 @@ wxString GERBER_DRAW_ITEM::ShowGBRShape() const { switch( m_Shape ) { - case GBR_SEGMENT: - return _( "Line" ); - - case GBR_ARC: - return _( "Arc" ); - - case GBR_CIRCLE: - return _( "Circle" ); - - case GBR_SPOT_OVAL: - return wxT( "spot_oval" ); - - case GBR_SPOT_CIRCLE: - return wxT( "spot_circle" ); - - case GBR_SPOT_RECT: - return wxT( "spot_rect" ); - - case GBR_SPOT_POLY: - return wxT( "spot_poly" ); - - case GBR_POLYGON: - return wxT( "polygon" ); + case GBR_SEGMENT: return _( "Line" ); + case GBR_ARC: return _( "Arc" ); + case GBR_CIRCLE: return _( "Circle" ); + case GBR_SPOT_OVAL: return wxT( "spot_oval" ); + case GBR_SPOT_CIRCLE: return wxT( "spot_circle" ); + case GBR_SPOT_RECT: return wxT( "spot_rect" ); + case GBR_SPOT_POLY: return wxT( "spot_poly" ); + case GBR_POLYGON: return wxT( "polygon" ); case GBR_SPOT_MACRO: { @@ -262,8 +245,7 @@ wxString GERBER_DRAW_ITEM::ShowGBRShape() const return name; } - default: - return wxT( "??" ); + default: return wxT( "??" ); } } @@ -760,14 +742,18 @@ void GERBER_DRAW_ITEM::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vectorGetLayer() != m_GraphicLayer ) continue; + if( item->HasNegativeItems() ) { m_hasNegativeItems = 1; @@ -252,6 +247,7 @@ bool GERBER_FILE_IMAGE::HasNegativeItems() } } } + return m_hasNegativeItems == 1; } @@ -262,8 +258,11 @@ int GERBER_FILE_IMAGE::GetDcodesCount() for( unsigned ii = 0; ii < arrayDim( m_Aperture_List ); ii++ ) { if( m_Aperture_List[ii] ) + { if( m_Aperture_List[ii]->m_InUse || m_Aperture_List[ii]->m_Defined ) ++count; + } + } return count; @@ -295,8 +294,7 @@ void GERBER_FILE_IMAGE::InitToolTable() */ void GERBER_FILE_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem ) { - if( GetLayerParams().m_XRepeatCount < 2 && - GetLayerParams().m_YRepeatCount < 2 ) + if( GetLayerParams().m_XRepeatCount < 2 && GetLayerParams().m_YRepeatCount < 2 ) return; // Nothing to repeat // Duplicate item: @@ -312,9 +310,9 @@ void GERBER_FILE_IMAGE::StepAndRepeatItem( const GERBER_DRAW_ITEM& aItem ) GERBER_DRAW_ITEM* dupItem = new GERBER_DRAW_ITEM( aItem ); wxPoint move_vector; move_vector.x = scaletoIU( ii * GetLayerParams().m_StepForRepeat.x, - GetLayerParams().m_StepForRepeatMetric ); + GetLayerParams().m_StepForRepeatMetric ); move_vector.y = scaletoIU( jj * GetLayerParams().m_StepForRepeat.y, - GetLayerParams().m_StepForRepeatMetric ); + GetLayerParams().m_StepForRepeatMetric ); dupItem->MoveXY( move_vector ); AddItemToList( dupItem ); } diff --git a/gerbview/gerbview_frame.cpp b/gerbview/gerbview_frame.cpp index 069c911c00..e1c8b87bdb 100644 --- a/gerbview/gerbview_frame.cpp +++ b/gerbview/gerbview_frame.cpp @@ -20,18 +20,14 @@ #include #include -#include -#include #include #include -#include #include #include #include #include #include #include -#include #include #include #include @@ -50,7 +46,6 @@ #include #include #include -#include #include #include "widgets/gbr_layer_box_selector.h" @@ -412,7 +407,7 @@ void GERBVIEW_FRAME::SetElementVisibility( int aLayerID, bool aNewState ) view->UpdateAllItemsConditionally( KIGFX::REPAINT, []( KIGFX::VIEW_ITEM* aItem ) { - auto item = dynamic_cast( aItem ); + GERBER_DRAW_ITEM* item = dynamic_cast( aItem ); // GetLayerPolarity() returns true for negative items return ( item && item->GetLayerPolarity() ); @@ -513,11 +508,10 @@ void GERBVIEW_FRAME::SortLayersByX2Attributes() std::unordered_map view_remapping; - for( auto it : remapping ) + for( const std::pair& entry : remapping ) { - view_remapping[ GERBER_DRAW_LAYER( it.first) ] = GERBER_DRAW_LAYER( it.second ); - view_remapping[ GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.first) ) ] = - GERBER_DCODE_LAYER( GERBER_DRAW_LAYER( it.second ) ); + view_remapping[ entry.first ] = GERBER_DRAW_LAYER( entry.second ); + view_remapping[ GERBER_DCODE_LAYER( entry.first ) ] = GERBER_DCODE_LAYER( entry.second ); } GetCanvas()->GetView()->ReorderLayerData( view_remapping ); @@ -530,7 +524,7 @@ void GERBVIEW_FRAME::UpdateDiffLayers() auto target = GetCanvas()->GetBackend() == GERBVIEW_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ? KIGFX::TARGET_CACHED : KIGFX::TARGET_NONCACHED; - auto view = GetCanvas()->GetView(); + KIGFX::VIEW* view = GetCanvas()->GetView(); int lastVisibleLayer = -1; diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index 636c6f0f8b..3860d86221 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -660,13 +660,10 @@ void DRC_ENGINE::RunTests( EDA_UNITS aUnits, bool aReportAllTrackErrors, bool aT for( DRC_TEST_PROVIDER* provider : m_testProviders ) { - if( provider->IsEnabled() ) - { - ReportAux( wxString::Format( "Run DRC provider: '%s'", provider->GetName() ) ); + ReportAux( wxString::Format( "Run DRC provider: '%s'", provider->GetName() ) ); - if( !provider->Run() ) - break; - } + if( !provider->Run() ) + break; } } diff --git a/pcbnew/drc/drc_test_provider.h b/pcbnew/drc/drc_test_provider.h index 2c0aa2173e..c029a01543 100644 --- a/pcbnew/drc/drc_test_provider.h +++ b/pcbnew/drc/drc_test_provider.h @@ -89,16 +89,6 @@ public: virtual const wxString GetName() const; virtual const wxString GetDescription() const; - bool IsEnabled() const - { - return m_enabled; - } - - void Enable( bool aEnable ) - { - m_enabled = aEnable; - } - protected: int forEachGeometryItem( const std::vector& aTypes, LSET aLayers, const std::function& aFunc ); @@ -122,7 +112,6 @@ protected: DRC_ENGINE* m_drcEngine; std::unordered_map m_stats; bool m_isRuleDriven = true; - bool m_enabled = true; wxString m_msg; // Allocating strings gets expensive enough to want to avoid it }; diff --git a/pcbnew/drc/drc_test_provider_misc.cpp b/pcbnew/drc/drc_test_provider_misc.cpp index f9e94bdf4c..d6d358645c 100644 --- a/pcbnew/drc/drc_test_provider_misc.cpp +++ b/pcbnew/drc/drc_test_provider_misc.cpp @@ -38,9 +38,6 @@ - DRCE_DISABLED_LAYER_ITEM, ///< item on a disabled layer - DRCE_INVALID_OUTLINE, ///< invalid board outline - DRCE_UNRESOLVED_VARIABLE, - - TODO: - - if grows too big, split into separate providers */ class DRC_TEST_PROVIDER_MISC : public DRC_TEST_PROVIDER diff --git a/pcbnew/tools/drc_tool.cpp b/pcbnew/tools/drc_tool.cpp index 30b05fb89f..287a6f9c91 100644 --- a/pcbnew/tools/drc_tool.cpp +++ b/pcbnew/tools/drc_tool.cpp @@ -22,7 +22,6 @@ */ #include -#include #include #include #include diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 4c443edd1e..c86e0c16a0 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -90,10 +90,10 @@ SPECIAL_TOOLS_CONTEXT_MENU::SPECIAL_TOOLS_CONTEXT_MENU( TOOL_INTERACTIVE* aTool SetIcon( BITMAPS::special_tools ); SetTitle( _( "Special Tools" ) ); - AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::ShowAlways ); + AddItem( PCB_ACTIONS::moveExact, SELECTION_CONDITIONS::ShowAlways ); AddItem( PCB_ACTIONS::moveWithReference, SELECTION_CONDITIONS::ShowAlways ); - AddItem( PCB_ACTIONS::positionRelative, SELECTION_CONDITIONS::ShowAlways ); - AddItem( PCB_ACTIONS::createArray, SELECTION_CONDITIONS::ShowAlways ); + AddItem( PCB_ACTIONS::positionRelative, SELECTION_CONDITIONS::ShowAlways ); + AddItem( PCB_ACTIONS::createArray, SELECTION_CONDITIONS::ShowAlways ); } @@ -593,43 +593,43 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) // Ensure we only do one commit operation on each object auto processTrack = - [&]( PCB_TRACK* aTrack, PCB_TRACK* aTrackCopy, int aMaxLengthIU ) -> bool - { - if( aTrack->IsNew() ) + [&]( PCB_TRACK* aTrack, PCB_TRACK* aTrackCopy, int aMaxLengthIU ) -> bool { - getView()->Remove( aTrack ); - - if( aTrack->GetLength() <= aMaxLengthIU ) + if( aTrack->IsNew() ) { - delete aTrack; + getView()->Remove( aTrack ); + + if( aTrack->GetLength() <= aMaxLengthIU ) + { + delete aTrack; + delete aTrackCopy; + aTrack = nullptr; + aTrackCopy = nullptr; + return false; + } + else + { + m_commit->Add( aTrack ); + delete aTrackCopy; + aTrackCopy = nullptr; + return true; + } + } + else if( aTrack->GetLength() <= aMaxLengthIU ) + { + aTrack->SwapData( aTrackCopy ); //restore the original before notifying COMMIT + m_commit->Remove( aTrack ); delete aTrackCopy; - aTrack = nullptr; aTrackCopy = nullptr; return false; } else { - m_commit->Add( aTrack ); - delete aTrackCopy; - aTrackCopy = nullptr; - return true; + m_commit->Modified( aTrack, aTrackCopy ); } - } - else if( aTrack->GetLength() <= aMaxLengthIU ) - { - aTrack->SwapData( aTrackCopy ); //restore the original before notifying COMMIT - m_commit->Remove( aTrack ); - delete aTrackCopy; - aTrackCopy = nullptr; - return false; - } - else - { - m_commit->Modified( aTrack, aTrackCopy ); - } - return true; - }; + return true; + }; // Amend the end points of the arc if we delete the joining tracks wxPoint newStart = trackOnStart->GetStart(); @@ -1361,8 +1361,8 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent ) // Tracks & vias are treated in a special way: if( ( SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Tracks ) )( selection ) ) { - DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit ); - dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR + DIALOG_TRACK_VIA_PROPERTIES dlg( editFrame, selection, *m_commit ); + dlg.ShowQuasiModal(); // QuasiModal required for NET_SELECTOR } else if( selection.Size() == 1 ) { @@ -1473,11 +1473,10 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) // If rotating a group, record position of all the descendants for undo if( item->Type() == PCB_GROUP_T ) { - static_cast( item )->RunOnDescendants( - [&]( BOARD_ITEM* bItem ) - { - m_commit->Modify( bItem ); - }); + static_cast( item )->RunOnDescendants( [&]( BOARD_ITEM* bItem ) + { + m_commit->Modify( bItem ); + }); } } @@ -2204,12 +2203,12 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent ) } // Be sure that there is at least one item that we can modify - const auto& selection = m_selectionTool->RequestSelection( - []( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool ) - { - sTool->FilterCollectorForMarkers( aCollector ); - sTool->FilterCollectorForHierarchy( aCollector, true ); - } ); + const PCB_SELECTION& selection = m_selectionTool->RequestSelection( + []( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool ) + { + sTool->FilterCollectorForMarkers( aCollector ); + sTool->FilterCollectorForHierarchy( aCollector, true ); + } ); if( selection.Empty() ) return 0;