ADDED: Open Zone Manager... button to Zone Properties.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/22246
This commit is contained in:
Jeff Young
2025-11-11 15:49:44 +00:00
parent 18c9f87c2e
commit bf283c845e
15 changed files with 174 additions and 78 deletions
+73 -34
View File
@@ -35,66 +35,99 @@
#include <zone.h>
#include <zone_settings_bag.h>
#include <pad.h>
#include <board.h>
#include <grid_layer_box_helpers.h>
#include <tool/tool_manager.h>
#include <panel_zone_properties.h>
#include <dialog_copper_zones_base.h>
#include "panel_zone_properties.h"
#include <tools/pcb_actions.h>
class DIALOG_COPPER_ZONE : public DIALOG_COPPER_ZONE_BASE
{
public:
DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings, CONVERT_SETTINGS* aConvertSettings );
// The dialog can be closed for several reasons.
enum RETVAL
{
COPPER_ZONE_CANCEL,
COPPER_ZONE_OK,
COPPER_ZONE_OPEN_ZONE_MANAGER
};
DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE* aZone, ZONE_SETTINGS* aSettings,
CONVERT_SETTINGS* aConvertSettings );
~DIALOG_COPPER_ZONE() override;
private:
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
RETVAL GetReturnValue() { return m_returnValue; }
private:
void OnLayerSelection( wxDataViewEvent& event ) override;
void OnUpdateUI( wxUpdateUIEvent& ) override;
void onZoneManager( wxCommandEvent& event ) override;
private:
PCB_BASE_FRAME* m_Parent;
ZONE* m_zone;
ZONE_SETTINGS* m_ptr;
ZONE_SETTINGS_BAG m_zoneSettingsBag;
PANEL_ZONE_PROPERTIES* m_panelZoneProperties;
wxStaticText* m_gapLabel;
wxTextCtrl* m_gapCtrl;
wxStaticText* m_gapUnits;
UNIT_BINDER* m_gap;
ZONE_SETTINGS_BAG m_zoneSettingsBag; // Local storage of settings
CONVERT_SETTINGS* m_convertSettings;
wxRadioButton* m_rbCenterline;
wxRadioButton* m_rbEnvelope;
wxStaticText* m_gapLabel;
wxTextCtrl* m_gapCtrl;
wxStaticText* m_gapUnits;
UNIT_BINDER* m_gap;
wxCheckBox* m_cbDeleteOriginals;
PANEL_ZONE_PROPERTIES* m_panelZoneProperties;
RETVAL m_returnValue;
};
int InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings, CONVERT_SETTINGS* aConvertSettings )
int InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE* aZone, ZONE_SETTINGS* aSettings,
CONVERT_SETTINGS* aConvertSettings )
{
DIALOG_COPPER_ZONE dlg( aCaller, aSettings, aConvertSettings );
DIALOG_COPPER_ZONE dlg( aCaller, aZone, aSettings, aConvertSettings );
// TODO: why does this need QuasiModal?
return dlg.ShowQuasiModal();
dlg.ShowQuasiModal();
switch( dlg.GetReturnValue() )
{
case DIALOG_COPPER_ZONE::COPPER_ZONE_OK:
return wxID_OK;
case DIALOG_COPPER_ZONE::COPPER_ZONE_OPEN_ZONE_MANAGER:
aCaller->CallAfter(
[aCaller]()
{
aCaller->GetToolManager()->RunAction( PCB_ACTIONS::zonesManager );
} );
return wxID_OK;
default:
case DIALOG_COPPER_ZONE::COPPER_ZONE_CANCEL:
return wxID_CANCEL;
}
}
DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSettings,
DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE* aZone, ZONE_SETTINGS* aSettings,
CONVERT_SETTINGS* aConvertSettings ) :
DIALOG_COPPER_ZONE_BASE( aParent ),
m_zoneSettingsBag( aSettings ),
m_Parent( aParent ),
m_zone( aZone ),
m_zoneSettingsBag( aZone, aSettings ),
m_convertSettings( aConvertSettings ),
m_rbCenterline( nullptr ),
m_rbEnvelope( nullptr ),
m_cbDeleteOriginals( nullptr )
m_cbDeleteOriginals( nullptr ),
m_returnValue( COPPER_ZONE_CANCEL )
{
m_Parent = aParent;
m_ptr = aSettings;
aSettings->SetupLayersList( m_layers, m_Parent, LSET::AllCuMask( aParent->GetBoard()->GetCopperLayerCount() ) );
@@ -141,8 +174,12 @@ DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS*
m_gap = nullptr;
}
// A zone still in creation (ie: not yet in the document) can't be edited by the Zone Manager
if( !aZone )
m_openZoneManager->Hide();
m_panelZoneProperties = new PANEL_ZONE_PROPERTIES( this, aParent, m_zoneSettingsBag );
m_panelZoneProperties->SetZone( nullptr );
m_panelZoneProperties->SetZone( m_zone );
m_sizerRight->Add( m_panelZoneProperties, 1, wxEXPAND, 5 );
SetupStandardButtons();
@@ -183,16 +220,7 @@ void DIALOG_COPPER_ZONE::OnUpdateUI( wxUpdateUIEvent& )
bool DIALOG_COPPER_ZONE::TransferDataFromWindow()
{
// Get the layer selection for this zone
int layers = 0;
for( int ii = 0; ii < m_layers->GetItemCount(); ++ii )
{
if( m_layers->GetToggleValue( (unsigned) ii, 0 ) )
layers++;
}
if( layers == 0 )
if( m_zoneSettingsBag.GetZoneSettings( m_zone )->m_Layers.empty() )
{
DisplayError( this, _( "No layer selected." ) );
return false;
@@ -212,7 +240,8 @@ bool DIALOG_COPPER_ZONE::TransferDataFromWindow()
m_convertSettings->m_Gap = m_gap->GetIntValue();
}
*m_ptr = *m_zoneSettingsBag.GetZoneSettings( nullptr );
*m_ptr = *m_zoneSettingsBag.GetZoneSettings( m_zone );
m_returnValue = COPPER_ZONE_OK;
return true;
}
@@ -229,5 +258,15 @@ void DIALOG_COPPER_ZONE::OnLayerSelection( wxDataViewEvent& event )
wxVariant layerID;
m_layers->GetValue( layerID, row, 2 );
m_zoneSettingsBag.GetZoneSettings( nullptr )->m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), checked );
m_zoneSettingsBag.GetZoneSettings( m_zone )->m_Layers.set( ToLAYER_ID( layerID.GetInteger() ), checked );
}
void DIALOG_COPPER_ZONE::onZoneManager( wxCommandEvent& event )
{
if( TransferDataFromWindow() )
{
m_returnValue = COPPER_ZONE_OPEN_ZONE_MANAGER;
Close();
}
}
@@ -50,6 +50,9 @@ DIALOG_COPPER_ZONE_BASE::DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID i
wxBoxSizer* bSizerbottom;
bSizerbottom = new wxBoxSizer( wxHORIZONTAL );
m_openZoneManager = new wxButton( this, wxID_ANY, _("Open Zone Manager..."), wxDefaultPosition, wxDefaultSize, 0 );
bSizerbottom->Add( m_openZoneManager, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
m_sdbSizer->AddButton( m_sdbSizerOK );
@@ -71,6 +74,7 @@ DIALOG_COPPER_ZONE_BASE::DIALOG_COPPER_ZONE_BASE( wxWindow* parent, wxWindowID i
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_COPPER_ZONE_BASE::OnClose ) );
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_COPPER_ZONE_BASE::OnUpdateUI ) );
m_layers->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_COPPER_ZONE_BASE::OnLayerSelection ), NULL, this );
m_openZoneManager->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_ZONE_BASE::onZoneManager ), NULL, this );
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_ZONE_BASE::OnButtonCancelClick ), NULL, this );
}
@@ -80,6 +84,7 @@ DIALOG_COPPER_ZONE_BASE::~DIALOG_COPPER_ZONE_BASE()
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_COPPER_ZONE_BASE::OnClose ) );
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( DIALOG_COPPER_ZONE_BASE::OnUpdateUI ) );
m_layers->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_VALUE_CHANGED, wxDataViewEventHandler( DIALOG_COPPER_ZONE_BASE::OnLayerSelection ), NULL, this );
m_openZoneManager->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_ZONE_BASE::onZoneManager ), NULL, this );
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_COPPER_ZONE_BASE::OnButtonCancelClick ), NULL, this );
}
@@ -219,6 +219,81 @@
<property name="name">bSizerbottom</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="true">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="true">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer">0</property>
<property name="aui_name"></property>
<property name="aui_position">0</property>
<property name="aui_row">0</property>
<property name="auth_needed">0</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="bitmap"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="current"></property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="disabled"></property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="drag_accept_files">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="focus"></property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Open Zone Manager...</property>
<property name="margins"></property>
<property name="markup">0</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_openZoneManager</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="position"></property>
<property name="pressed"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</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>
<event name="OnButtonClick">onZoneManager</event>
</object>
</object>
<object class="sizeritem" expanded="false">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
@@ -20,6 +20,9 @@
#include <wx/dataview.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/bitmap.h>
#include <wx/image.h>
#include <wx/icon.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@@ -41,6 +44,7 @@ class DIALOG_COPPER_ZONE_BASE : public DIALOG_SHIM
wxStaticText* m_staticTextLayerSelection;
wxDataViewListCtrl* m_layers;
wxBoxSizer* m_sizerRight;
wxButton* m_openZoneManager;
wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK;
wxButton* m_sdbSizerCancel;
@@ -49,6 +53,7 @@ class DIALOG_COPPER_ZONE_BASE : public DIALOG_SHIM
virtual void OnClose( wxCloseEvent& event ) { event.Skip(); }
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void OnLayerSelection( wxDataViewEvent& event ) { event.Skip(); }
virtual void onZoneManager( wxCommandEvent& event ) { event.Skip(); }
virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); }
+1 -1
View File
@@ -54,7 +54,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE* aZone )
{
// edit a zone on a copper layer
zoneInfo << *aZone;
dialogResult = InvokeCopperZonesEditor( this, &zoneInfo );
dialogResult = InvokeCopperZonesEditor( this, aZone, &zoneInfo );
}
else
{
+1 -7
View File
@@ -229,17 +229,11 @@ void FOOTPRINT_EDIT_FRAME::OnEditItemRequest( BOARD_ITEM* aItem )
zoneSettings << *static_cast<ZONE*>( aItem );
if( zone->GetIsRuleArea() )
{
success = InvokeRuleAreaEditor( this, &zoneSettings ) == wxID_OK;
}
else if( zone->IsOnCopperLayer() )
{
success = InvokeCopperZonesEditor( this, &zoneSettings ) == wxID_OK;
}
success = InvokeCopperZonesEditor( this, zone, &zoneSettings ) == wxID_OK;
else
{
success = InvokeNonCopperZonesEditor( this, &zoneSettings ) == wxID_OK;
}
if( success )
{
+1 -1
View File
@@ -1587,7 +1587,7 @@ int BOARD_EDITOR_CONTROL::ZoneDuplicate( const TOOL_EVENT& aEvent )
if( oldZone->GetIsRuleArea() )
dialogResult = InvokeRuleAreaEditor( m_frame, &zoneSettings, board() );
else if( oldZone->IsOnCopperLayer() )
dialogResult = InvokeCopperZonesEditor( m_frame, &zoneSettings );
dialogResult = InvokeCopperZonesEditor( m_frame, nullptr, &zoneSettings );
else
dialogResult = InvokeNonCopperZonesEditor( m_frame, &zoneSettings );
+1 -1
View File
@@ -539,7 +539,7 @@ int CONVERT_TOOL::CreatePolys( const TOOL_EVENT& aEvent )
else
{
zoneInfo.SetIsRuleArea( false );
ret = InvokeCopperZonesEditor( frame, &zoneInfo, &m_userSettings );
ret = InvokeCopperZonesEditor( frame, nullptr, &zoneInfo, &m_userSettings );
}
if( ret == wxID_CANCEL )
+1 -5
View File
@@ -244,8 +244,7 @@ int GLOBAL_EDIT_TOOL::ZonesManager( const TOOL_EVENT& aEvent )
for( ZONE* zone : board->Zones() )
commit.Modify( zone );
ZONE_SETTINGS zoneInfo = board->GetDesignSettings().GetDefaultZoneSettings();
DIALOG_ZONE_MANAGER dlg( editFrame, &zoneInfo );
DIALOG_ZONE_MANAGER dlg( editFrame );
int dialogResult = dlg.ShowQuasiModal();
@@ -266,9 +265,6 @@ int GLOBAL_EDIT_TOOL::ZonesManager( const TOOL_EVENT& aEvent )
for( ZONE* zone : board->Zones() )
editFrame->GetCanvas()->GetView()->Update( zone );
zoneInfo.m_Netcode = NETINFO_LIST::ORPHANED;
board->GetDesignSettings().SetDefaultZoneSettings( zoneInfo );
commit.Push( _( "Modify zones properties with zone manager" ), SKIP_CONNECTIVITY );
editFrame->OnModify();
//rebuildConnectivity
+1 -1
View File
@@ -124,7 +124,7 @@ std::unique_ptr<ZONE> ZONE_CREATE_HELPER::createNewZone( bool aKeepout )
if( m_params.m_keepout )
dialogResult = InvokeRuleAreaEditor( frame, &zoneInfo, m_tool.board() );
else if( ( zoneInfo.m_Layers & LSET::AllCuMask() ).any() )
dialogResult = InvokeCopperZonesEditor( frame, &zoneInfo );
dialogResult = InvokeCopperZonesEditor( frame, nullptr, &zoneInfo );
else
dialogResult = InvokeNonCopperZonesEditor( frame, &zoneInfo );
+1 -9
View File
@@ -47,10 +47,9 @@
#include "dialog_zone_manager.h"
DIALOG_ZONE_MANAGER::DIALOG_ZONE_MANAGER( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aZoneInfo ) :
DIALOG_ZONE_MANAGER::DIALOG_ZONE_MANAGER( PCB_BASE_FRAME* aParent ) :
DIALOG_ZONE_MANAGER_BASE( aParent ),
m_pcbFrame( aParent ),
m_zoneInfo( aZoneInfo ),
m_zoneSettingsBag( aParent->GetBoard() ),
m_priorityDragIndex( {} ),
m_needZoomGAL( true ),
@@ -238,13 +237,6 @@ void DIALOG_ZONE_MANAGER::OnOk( wxCommandEvent& aEvt )
{
m_panelZoneProperties->TransferZoneSettingsFromWindow();
m_zoneSettingsBag.OnUserConfirmChange();
if( m_zoneInfo )
{
if( std::shared_ptr<ZONE_SETTINGS> zone = m_panelZoneProperties->GetZoneSettings() )
m_zoneInfo->CopyFrom( *zone, false );
}
aEvt.Skip();
}
+2 -11
View File
@@ -53,29 +53,21 @@ class COMMIT;
class ZONE_PREVIEW_CANVAS;
enum class ZONE_INDEX_MOVEMENT;
class DIALOG_ZONE_MANAGER : public DIALOG_ZONE_MANAGER_BASE
{
/*enum
{
ZONE_VIEWER = ID_DIALOG_COPPER_ZONE_BASE + 10,
};*/
public:
DIALOG_ZONE_MANAGER( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aZoneInfo );
DIALOG_ZONE_MANAGER( PCB_BASE_FRAME* aParent );
~DIALOG_ZONE_MANAGER() override;
bool GetRepourOnClose() { return m_checkRepour->GetValue(); }
protected:
void OnZoneSelectionChanged( ZONE* aZone );
void OnDataViewCtrlSelectionChanged( wxDataViewEvent& event ) override;
void SelectZoneTableItem( wxDataViewItem const& aItem );
void OnViewZonesOverviewOnLeftUp( wxMouseEvent& aEvent ) override;
void onDialogResize( wxSizeEvent& event ) override;
void OnOk( wxCommandEvent& aEvt ) override;
#if wxUSE_DRAG_AND_DROP
@@ -113,7 +105,6 @@ private:
private:
PCB_BASE_FRAME* m_pcbFrame;
ZONE_SETTINGS* m_zoneInfo;
ZONE_SETTINGS_BAG m_zoneSettingsBag;
PANEL_ZONE_PROPERTIES* m_panelZoneProperties;
wxObjectDataPtr<MODEL_ZONES_OVERVIEW> m_modelZonesOverview;
+2 -2
View File
@@ -61,9 +61,9 @@ ZONE_SETTINGS_BAG::ZONE_SETTINGS_BAG( BOARD* aBoard )
}
ZONE_SETTINGS_BAG::ZONE_SETTINGS_BAG( ZONE_SETTINGS* aSettings )
ZONE_SETTINGS_BAG::ZONE_SETTINGS_BAG( ZONE* aZone, ZONE_SETTINGS* aSettings )
{
m_zoneSettings[nullptr] = std::make_shared<ZONE_SETTINGS>( *aSettings );
m_zoneSettings[aZone] = std::make_shared<ZONE_SETTINGS>( *aSettings );
}
+1 -1
View File
@@ -39,7 +39,7 @@ class ZONE_SETTINGS_BAG
{
public:
ZONE_SETTINGS_BAG( BOARD* aBoard );
ZONE_SETTINGS_BAG( ZONE_SETTINGS* aSettings );
ZONE_SETTINGS_BAG( ZONE* aZone, ZONE_SETTINGS* aSettings );
ZONE_SETTINGS_BAG() = default;
+4 -5
View File
@@ -22,8 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef ZONES_H_
#define ZONES_H_
#pragma once
#include <wx/translation.h>
@@ -42,6 +41,7 @@ struct CONVERT_SETTINGS;
#define ZONE_MANAGER_REPOUR 1005 //Reported if repour option is checked while clicking OK
/// How pads are covered by copper in zone
enum class ZONE_CONNECTION
{
@@ -90,10 +90,11 @@ int InvokeNonCopperZonesEditor( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* aSetting
*
* @param aCaller is the PCB_BASE_FRAME calling parent window for the modal dialog,
* and it gives access to the BOARD through PCB_BASE_FRAME::GetBoard().
* @param aZone the zone being edited, or nullptr if a zone is being created.
* @param aSettings points to the ZONE_SETTINGS to edit.
* @return int - tells if user aborted, changed only one zone, or all of them.
*/
int InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings,
int InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE* aZone, ZONE_SETTINGS* aSettings,
CONVERT_SETTINGS* aConvertSettings = nullptr );
/**
@@ -107,5 +108,3 @@ int InvokeCopperZonesEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings,
*/
int InvokeRuleAreaEditor( PCB_BASE_FRAME* aCaller, ZONE_SETTINGS* aSettings,
BOARD* aBoard = nullptr, CONVERT_SETTINGS* aConvertSettings = nullptr );
#endif // ZONES_H_