ADDED Option to disable automatic zone filling in pcbnew

The new setting is stored as 'editing.auto_fill_zones' and controls
whether zones should be refilled after certain actions or not.
This commit is contained in:
Roberto Fernandez Bautista 2021-03-17 18:57:07 +00:00 committed by Jeff Young
parent a743e0c52b
commit f6c4677189
9 changed files with 243 additions and 141 deletions

View File

@ -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<FOOTPRINT_EDIT_FRAME*>( 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;

View File

@ -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();

View File

@ -2520,11 +2520,11 @@
<property name="name">pcbOptionsSizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="0">
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Magnetic Points</property>
<property name="minimum_size"></property>
@ -2532,11 +2532,11 @@
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM</property>
<property name="proportion">1</property>
<object class="wxFlexGridSizer" expanded="0">
<object class="wxFlexGridSizer" expanded="1">
<property name="cols">2</property>
<property name="flexible_direction">wxBOTH</property>
<property name="growablecols"></property>
@ -2927,11 +2927,11 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="0">
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Ratsnest</property>
<property name="minimum_size"></property>
@ -3069,89 +3069,11 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="0">
<property name="id">wxID_ANY</property>
<property name="label">Annotations</property>
<property name="minimum_size"></property>
<property name="name">sbSizer4</property>
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Show page limits</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_Show_Page_Limits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="0">
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Track Editing</property>
<property name="minimum_size"></property>
@ -3425,6 +3347,148 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Miscellaneous</property>
<property name="minimum_size"></property>
<property name="name">sbSizer4</property>
<property name="orient">wxVERTICAL</property>
<property name="parent">1</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Show page limits</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_Show_Page_Limits</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Draw gray line that outlines the sheet size.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Refill zones after Zone Properties dialog</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_Auto_Refill_Zones</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">If checked, zones will be re-filled after editing the properties of the zone using the Zone Properties dialog</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>
</object>
</object>

View File

@ -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:

View File

@ -27,6 +27,7 @@
#include <kiface_i.h>
#include <confirm.h>
#include <pcb_edit_frame.h>
#include <pcbnew_settings.h>
#include <board_commit.h>
#include <zone.h>
#include <zones.h>
@ -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<ZONE*> zones_to_refill;
for( unsigned i = 0; i < pickedList.GetCount(); ++i )
if( Settings().m_AutoRefillZones )
{
ZONE* zone = dyn_cast<ZONE*>( pickedList.GetPickedItem( i ) );
// refill zones with the new properties applied
std::vector<ZONE*> 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<ZONE*>( 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<KISPINLOCK> lock( GetBoard()->GetConnectivity()->GetLock() );
std::lock_guard<KISPINLOCK> 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.
}
}
}

View File

@ -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<bool>( "editing.use_45_degree_graphic_segments",
&m_Use45DegreeGraphicSegments, false ) );
m_params.emplace_back( new PARAM<bool>( "editing.auto_fill_zones",
&m_AutoRefillZones, true ) );
m_params.emplace_back( new PARAM<bool>( "pcb_display.graphic_items_fill",
&m_Display.m_DisplayGraphicsFill, true ) );

View File

@ -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<PNS::ROUTING_SETTINGS> m_PnsSettings;

View File

@ -1738,17 +1738,20 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
m_commit->Modify( zone );
zone->RemoveCutout( outlineIdx, holeIdx );
std::vector<ZONE*> 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<ZONE*> 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

View File

@ -30,6 +30,7 @@
#include <fp_shape.h>
#include <board_commit.h>
#include <pcb_painter.h>
#include <pcbnew_settings.h>
#include <tools/pcb_actions.h>
#include <tools/pcb_selection_tool.h>
#include <zone_filler.h>
@ -137,6 +138,7 @@ void ZONE_CREATE_HELPER::performZoneCutout( ZONE& aZone, const ZONE& aCutout )
BOARD_COMMIT commit( &m_tool );
BOARD* board = m_tool.getModel<BOARD>();
std::vector<ZONE*> 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<KISPINLOCK> 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<KISPINLOCK> 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<ZONE> aZone )
std::lock_guard<KISPINLOCK> 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<ZONE*> toFill = { aZone.get() };