diff --git a/pcbnew/dialogs/panel_edit_options.cpp b/pcbnew/dialogs/panel_edit_options.cpp index 80f4b30615..a942738b8a 100644 --- a/pcbnew/dialogs/panel_edit_options.cpp +++ b/pcbnew/dialogs/panel_edit_options.cpp @@ -75,14 +75,15 @@ bool PANEL_EDIT_OPTIONS::TransferDataToWindow() m_flipLeftRight->SetValue( general_opts.m_FlipLeftRight ); m_autoLockPads->SetValue( !general_opts.m_AddUnlockedPads ); - m_Show_Page_Limits->SetValue( m_frame->ShowPageLimits() ); - switch( general_opts.m_TrackDragAction ) { case TRACK_DRAG_ACTION::MOVE: m_rbTrackDragMove->SetValue( true ); break; case TRACK_DRAG_ACTION::DRAG: m_rbTrackDrag45->SetValue( true ); break; case TRACK_DRAG_ACTION::DRAG_FREE_ANGLE: m_rbTrackDragFree->SetValue( true ); break; } + + m_Show_Page_Limits->SetValue( m_frame->ShowPageLimits() ); + m_Auto_Refill_Zones->SetValue( general_opts.m_AutoRefillZones ); } else if( dynamic_cast( m_frame ) ) { @@ -119,6 +120,7 @@ bool PANEL_EDIT_OPTIONS::TransferDataFromWindow() m_frame->Settings().m_FlipLeftRight = m_flipLeftRight->GetValue(); m_frame->SetShowPageLimits( m_Show_Page_Limits->GetValue() ); m_frame->Settings().m_AddUnlockedPads = !m_autoLockPads->GetValue(); + m_frame->Settings().m_AutoRefillZones = m_Auto_Refill_Zones->GetValue(); if( m_rbTrackDragMove->GetValue() ) pcbnewSettings.m_TrackDragAction = TRACK_DRAG_ACTION::MOVE; diff --git a/pcbnew/dialogs/panel_edit_options_base.cpp b/pcbnew/dialogs/panel_edit_options_base.cpp index f30349b462..2b8cce9084 100644 --- a/pcbnew/dialogs/panel_edit_options_base.cpp +++ b/pcbnew/dialogs/panel_edit_options_base.cpp @@ -323,16 +323,6 @@ PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID i pcbOptionsSizer->Add( sbSizer3, 0, wxEXPAND|wxTOP, 5 ); - wxStaticBoxSizer* sbSizer4; - sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( pcbPage, wxID_ANY, _("Annotations") ), wxVERTICAL ); - - m_Show_Page_Limits = new wxCheckBox( sbSizer4->GetStaticBox(), wxID_ANY, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 0 ); - m_Show_Page_Limits->SetValue(true); - sbSizer4->Add( m_Show_Page_Limits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - - - pcbOptionsSizer->Add( sbSizer4, 1, wxEXPAND|wxTOP, 5 ); - wxStaticBoxSizer* sbSizer41; sbSizer41 = new wxStaticBoxSizer( new wxStaticBox( pcbPage, wxID_ANY, _("Track Editing") ), wxVERTICAL ); @@ -366,6 +356,24 @@ PANEL_EDIT_OPTIONS_BASE::PANEL_EDIT_OPTIONS_BASE( wxWindow* parent, wxWindowID i pcbOptionsSizer->Add( sbSizer41, 0, wxEXPAND|wxTOP, 5 ); + wxStaticBoxSizer* sbSizer4; + sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( pcbPage, wxID_ANY, _("Miscellaneous") ), wxVERTICAL ); + + m_Show_Page_Limits = new wxCheckBox( sbSizer4->GetStaticBox(), wxID_ANY, _("Show page limits"), wxDefaultPosition, wxDefaultSize, 0 ); + m_Show_Page_Limits->SetValue(true); + m_Show_Page_Limits->SetToolTip( _("Draw gray line that outlines the sheet size.") ); + + sbSizer4->Add( m_Show_Page_Limits, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_Auto_Refill_Zones = new wxCheckBox( sbSizer4->GetStaticBox(), wxID_ANY, _("Refill zones after Zone Properties dialog"), wxDefaultPosition, wxDefaultSize, 0 ); + m_Auto_Refill_Zones->SetValue(true); + m_Auto_Refill_Zones->SetToolTip( _("If checked, zones will be re-filled after editing the properties of the zone using the Zone Properties dialog") ); + + sbSizer4->Add( m_Auto_Refill_Zones, 0, wxALL, 5 ); + + + pcbOptionsSizer->Add( sbSizer4, 1, wxEXPAND|wxTOP, 5 ); + pcbPage->SetSizer( pcbOptionsSizer ); pcbPage->Layout(); diff --git a/pcbnew/dialogs/panel_edit_options_base.fbp b/pcbnew/dialogs/panel_edit_options_base.fbp index 1e739387f8..b27f7820ba 100644 --- a/pcbnew/dialogs/panel_edit_options_base.fbp +++ b/pcbnew/dialogs/panel_edit_options_base.fbp @@ -2520,11 +2520,11 @@ pcbOptionsSizer wxVERTICAL none - + 5 wxEXPAND 0 - + wxID_ANY Magnetic Points @@ -2532,11 +2532,11 @@ wxVERTICAL 1 none - + 5 wxEXPAND|wxBOTTOM 1 - + 2 wxBOTH @@ -2927,11 +2927,11 @@ - + 5 wxEXPAND|wxTOP 0 - + wxID_ANY Ratsnest @@ -3069,89 +3069,11 @@ - - 5 - wxEXPAND|wxTOP - 1 - - wxID_ANY - Annotations - - sbSizer4 - wxVERTICAL - 1 - none - - 5 - wxBOTTOM|wxRIGHT|wxLEFT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Show page limits - - 0 - - - 0 - - 1 - m_Show_Page_Limits - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - + 5 wxEXPAND|wxTOP 0 - + wxID_ANY Track Editing @@ -3425,6 +3347,148 @@ + + 5 + wxEXPAND|wxTOP + 1 + + wxID_ANY + Miscellaneous + + sbSizer4 + wxVERTICAL + 1 + none + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Show page limits + + 0 + + + 0 + + 1 + m_Show_Page_Limits + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + Draw gray line that outlines the sheet size. + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Refill zones after Zone Properties dialog + + 0 + + + 0 + + 1 + m_Auto_Refill_Zones + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + If checked, zones will be re-filled after editing the properties of the zone using the Zone Properties dialog + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + diff --git a/pcbnew/dialogs/panel_edit_options_base.h b/pcbnew/dialogs/panel_edit_options_base.h index 881d6cefdb..6241f9d988 100644 --- a/pcbnew/dialogs/panel_edit_options_base.h +++ b/pcbnew/dialogs/panel_edit_options_base.h @@ -61,11 +61,12 @@ class PANEL_EDIT_OPTIONS_BASE : public wxPanel wxChoice* m_magneticGraphicsChoice; wxCheckBox* m_showSelectedRatsnest; wxCheckBox* m_OptDisplayCurvedRatsnestLines; - wxCheckBox* m_Show_Page_Limits; wxStaticText* m_staticText5; wxRadioButton* m_rbTrackDragMove; wxRadioButton* m_rbTrackDrag45; wxRadioButton* m_rbTrackDragFree; + wxCheckBox* m_Show_Page_Limits; + wxCheckBox* m_Auto_Refill_Zones; public: diff --git a/pcbnew/edit_zone_helpers.cpp b/pcbnew/edit_zone_helpers.cpp index ba68f1d508..7364657426 100644 --- a/pcbnew/edit_zone_helpers.cpp +++ b/pcbnew/edit_zone_helpers.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -105,38 +106,42 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE* aZone ) UpdateCopyOfZonesList( pickedList, deletedList, GetBoard() ); - // refill zones with the new properties applied - std::vector zones_to_refill; - - for( unsigned i = 0; i < pickedList.GetCount(); ++i ) + if( Settings().m_AutoRefillZones ) { - ZONE* zone = dyn_cast( pickedList.GetPickedItem( i ) ); + // refill zones with the new properties applied + std::vector zones_to_refill; - if( zone == nullptr ) + for( unsigned i = 0; i < pickedList.GetCount(); ++i ) { - wxASSERT_MSG( false, "Expected a zone after zone properties edit" ); - continue; + ZONE* zone = dyn_cast( pickedList.GetPickedItem( i ) ); + + if( zone == nullptr ) + { + wxASSERT_MSG( false, "Expected a zone after zone properties edit" ); + continue; + } + + // aZone won't be filled if the layer set was modified, but it needs to be updated + if( zone->IsFilled() || zone == aZone ) + zones_to_refill.push_back( zone ); } - // aZone won't be filled if the layer set was modified, but it needs to be updated - if( zone->IsFilled() || zone == aZone ) - zones_to_refill.push_back( zone ); - } + commit.Stage( pickedList ); - commit.Stage( pickedList ); + std::lock_guard lock( GetBoard()->GetConnectivity()->GetLock() ); - std::lock_guard lock( GetBoard()->GetConnectivity()->GetLock() ); - - if( zones_to_refill.size() ) - { - ZONE_FILLER filler( GetBoard(), &commit ); - wxString title = wxString::Format( _( "Refill %d Zones" ), (int) zones_to_refill.size() ); - filler.InstallNewProgressReporter( this, title, 4 ); - - if( !filler.Fill( zones_to_refill ) ) + if( zones_to_refill.size() ) { - // User has already OK'ed dialog so we're going to go ahead and commit even if the - // fill was cancelled. + ZONE_FILLER filler( GetBoard(), &commit ); + wxString title = + wxString::Format( _( "Refill %d Zones" ), (int) zones_to_refill.size() ); + filler.InstallNewProgressReporter( this, title, 4 ); + + if( !filler.Fill( zones_to_refill ) ) + { + // User has already OK'ed dialog so we're going to go ahead and commit even if the + // fill was cancelled. + } } } diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index 5384bff8a0..d6ed975967 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -71,6 +71,7 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_PolarCoords( false ), m_RotationAngle( 900 ), m_ShowPageLimits( true ), + m_AutoRefillZones( true ), m_PnsSettings( nullptr ), m_FootprintViewerAutoZoom( false ), m_FootprintViewerZoom( 1.0 ) @@ -127,6 +128,9 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() m_params.emplace_back( new PARAM( "editing.use_45_degree_graphic_segments", &m_Use45DegreeGraphicSegments, false ) ); + m_params.emplace_back( new PARAM( "editing.auto_fill_zones", + &m_AutoRefillZones, true ) ); + m_params.emplace_back( new PARAM( "pcb_display.graphic_items_fill", &m_Display.m_DisplayGraphicsFill, true ) ); diff --git a/pcbnew/pcbnew_settings.h b/pcbnew/pcbnew_settings.h index edf4ae037c..ff2ffb1477 100644 --- a/pcbnew/pcbnew_settings.h +++ b/pcbnew/pcbnew_settings.h @@ -290,6 +290,9 @@ public: bool m_ShowPageLimits; + ///<@todo Implement real auto zone filling (not just after zone properties are edited) + bool m_AutoRefillZones; // Fill zones after editing the zone using the Zone Properties dialog + wxString m_FootprintTextShownColumns; std::unique_ptr m_PnsSettings; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 3dabfb8aa7..8ca3af61ad 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1738,17 +1738,20 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent ) m_commit->Modify( zone ); zone->RemoveCutout( outlineIdx, holeIdx ); - std::vector toFill; - toFill.emplace_back( zone ); - - // Fill the modified zone - ZONE_FILLER filler( board(), m_commit.get() ); - filler.InstallNewProgressReporter( frame(), _( "Fill Zone" ), 4 ); - - if( !filler.Fill( toFill ) ) + // Re-fill the zone if it was filled before the edit + if( zone->IsFilled() || frame()->Settings().m_AutoRefillZones ) { - m_commit->Revert(); - return 1; + std::vector toFill; + toFill.emplace_back( zone ); + + ZONE_FILLER filler( board(), m_commit.get() ); + filler.InstallNewProgressReporter( frame(), _( "Fill Zone" ), 4 ); + + if( !filler.Fill( toFill ) ) + { + m_commit->Revert(); + return 1; + } } // Update the display diff --git a/pcbnew/tools/zone_create_helper.cpp b/pcbnew/tools/zone_create_helper.cpp index bd535f0387..d2d00e6e21 100644 --- a/pcbnew/tools/zone_create_helper.cpp +++ b/pcbnew/tools/zone_create_helper.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -137,6 +138,7 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE& aZone, const ZONE& aCutout ) BOARD_COMMIT commit( &m_tool ); BOARD* board = m_tool.getModel(); std::vector newZones; + bool wereZonesFilled = aZone.IsFilled() || aCutout.IsFilled(); // Clear the selection before removing the old zone auto toolMgr = m_tool.GetManager(); @@ -168,14 +170,18 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE& aZone, const ZONE& aCutout ) commit.Remove( &aZone ); - ZONE_FILLER filler( board, &commit ); - - std::lock_guard lock( board->GetConnectivity()->GetLock() ); - - if( !filler.Fill( newZones ) ) + // Refill zone depending on settings or if one of the zones was filled + if( wereZonesFilled || m_tool.frame()->Settings().m_AutoRefillZones ) { - commit.Revert(); - return; + ZONE_FILLER filler( board, &commit ); + + std::lock_guard lock( board->GetConnectivity()->GetLock() ); + + if( !filler.Fill( newZones ) ) + { + commit.Revert(); + return; + } } commit.Push( _( "Add a zone cutout" ) ); @@ -214,7 +220,13 @@ void ZONE_CREATE_HELPER::commitZone( std::unique_ptr aZone ) std::lock_guard lock( board->GetConnectivity()->GetLock() ); - if( !m_params.m_keepout ) + // Only refill based on settings or if the zone we are copying was filled + bool refill = m_tool.frame()->Settings().m_AutoRefillZones; + + if( m_params.m_mode == ZONE_MODE::SIMILAR && aZone->IsFilled() ) + refill = true; + + if( !m_params.m_keepout && refill ) { ZONE_FILLER filler( board, &commit ); std::vector toFill = { aZone.get() };