diff --git a/pcbnew/board_stackup_manager/panel_board_finish.cpp b/pcbnew/board_stackup_manager/panel_board_finish.cpp index 19edf749e3..6df058bf62 100644 --- a/pcbnew/board_stackup_manager/panel_board_finish.cpp +++ b/pcbnew/board_stackup_manager/panel_board_finish.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -22,19 +22,16 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include #include #include #include #include "panel_board_finish.h" -#include - -PANEL_SETUP_BOARD_FINISH::PANEL_SETUP_BOARD_FINISH( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) : - PANEL_SETUP_BOARD_FINISH_BASE( aParent->GetTreebook() ) +PANEL_SETUP_BOARD_FINISH::PANEL_SETUP_BOARD_FINISH( wxWindow* aParentWindow, + PCB_EDIT_FRAME* aFrame ) : + PANEL_SETUP_BOARD_FINISH_BASE( aParentWindow ) { - m_parentDialog = aParent; m_frame = aFrame; m_board = m_frame->GetBoard(); m_brdSettings = &m_board->GetDesignSettings(); diff --git a/pcbnew/board_stackup_manager/panel_board_finish.h b/pcbnew/board_stackup_manager/panel_board_finish.h index 7bcfe2c6ee..3ef757a843 100644 --- a/pcbnew/board_stackup_manager/panel_board_finish.h +++ b/pcbnew/board_stackup_manager/panel_board_finish.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2009-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -36,7 +36,7 @@ class PCB_EDIT_FRAME; class PANEL_SETUP_BOARD_FINISH : public PANEL_SETUP_BOARD_FINISH_BASE { public: - PANEL_SETUP_BOARD_FINISH( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ); + PANEL_SETUP_BOARD_FINISH( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame ); ~PANEL_SETUP_BOARD_FINISH(); void ImportSettingsFrom( BOARD* aBoard ); @@ -48,7 +48,6 @@ private: void synchronizeWithBoard(); private: - PAGED_DIALOG* m_parentDialog; PCB_EDIT_FRAME* m_frame; BOARD* m_board; BOARD_DESIGN_SETTINGS* m_brdSettings; diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.cpp b/pcbnew/board_stackup_manager/panel_board_stackup.cpp index f18f10fbbb..666060fc7c 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp @@ -32,19 +32,16 @@ #include #include #include +#include +#include +#include #include // for KiROUND #include "panel_board_stackup.h" #include #include "board_stackup_reporter.h" #include -#include -#include #include "dialog_dielectric_list_manager.h" -#include -#include -#include -#include #include #include @@ -74,14 +71,14 @@ static wxColor pasteColor( 200, 200, 200 ); static void drawBitmap( wxBitmap& aBitmap, wxColor aColor ); -PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame, +PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( wxWindow* aParentWindow, + PCB_EDIT_FRAME* aFrame, PANEL_SETUP_LAYERS* aPanelLayers ): - PANEL_SETUP_BOARD_STACKUP_BASE( aParent->GetTreebook() ), + PANEL_SETUP_BOARD_STACKUP_BASE( aParentWindow ), m_delectricMatList( DIELECTRIC_SUBSTRATE_LIST::DL_MATERIAL_DIELECTRIC ), m_solderMaskMatList( DIELECTRIC_SUBSTRATE_LIST::DL_MATERIAL_SOLDERMASK ), m_silkscreenMatList( DIELECTRIC_SUBSTRATE_LIST::DL_MATERIAL_SILKSCREEN ) { - m_parentDialog = aParent; m_frame = aFrame; m_panelLayers = aPanelLayers; m_board = m_frame->GetBoard(); @@ -94,18 +91,17 @@ PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB m_enabledLayers = m_board->GetEnabledLayers() & BOARD_STACKUP::StackupAllowedBrdLayers(); // Calculates a good size for color swatches (icons) in this dialog - wxClientDC dc( this ); - m_colorSwatchesSize = dc.GetTextExtent( wxT( "XX" ) ); - m_colorIconsSize = dc.GetTextExtent( wxT( "XXXX" ) ); + m_colorSwatchesSize = GetTextExtent( wxT( "XX" ) ); + m_colorIconsSize = GetTextExtent( wxT( "XXXX" ) ); // Calculates a good size for wxTextCtrl to enter Epsilon R and Loss tan // ("0.0000000" + margins) - m_numericFieldsSize = dc.GetTextExtent( wxT( "X.XXXXXXX" ) ); + m_numericFieldsSize = GetTextExtent( wxT( "X.XXXXXXX" ) ); m_numericFieldsSize.y = -1; // Use default for the vertical size // Calculates a minimal size for wxTextCtrl to enter a dim with units // ("000.0000000 mils" + margins) - m_numericTextCtrlSize = dc.GetTextExtent( wxT( "XXX.XXXXXXX mils" ) ); + m_numericTextCtrlSize = GetTextExtent( wxT( "XXX.XXXXXXX mils" ) ); m_numericTextCtrlSize.y = -1; // Use default for the vertical size // The grid column containing the lock checkbox is kept to a minimal @@ -203,13 +199,9 @@ void PANEL_SETUP_BOARD_STACKUP::onAdjustDielectricThickness( wxCommandEvent& eve // Now adjust not locked dielectric thickness layers: if( items_candidate.size() ) - { setDefaultLayerWidths( iu_thickness ); - } else - { wxMessageBox( _( "All dielectric thickness layers are locked" ) ); - } computeBoardThickness(); } @@ -290,8 +282,9 @@ void PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer( wxCommandEvent& event ) } } - EDA_LIST_DIALOG dlg( m_parentDialog, _( "Add Dielectric Layer" ), headers, d_list, - wxEmptyString, false /* do not sort the list: it is **expected** in stack order */); + EDA_LIST_DIALOG dlg( PAGED_DIALOG::GetDialog( this ), _( "Add Dielectric Layer" ), + headers, d_list, wxEmptyString, + false /* do not sort the list: it is **expected** in stackup order */ ); dlg.SetListLabel( _( "Select layer to add:" ) ); dlg.HideFilter(); @@ -347,8 +340,9 @@ void PANEL_SETUP_BOARD_STACKUP::onRemoveDielectricLayer( wxCommandEvent& event ) } } - EDA_LIST_DIALOG dlg( m_parentDialog, _( "Remove Dielectric Layer" ), headers, d_list, - wxEmptyString, false /* do not sort the list: it is **expected** in stack order */ ); + EDA_LIST_DIALOG dlg( PAGED_DIALOG::GetDialog( this ), _( "Remove Dielectric Layer" ), + headers, d_list, wxEmptyString, + false /* do not sort the list: it is **expected** in stackup order */ ); dlg.SetListLabel( _( "Select layer to remove:" ) ); dlg.HideFilter(); @@ -413,9 +407,7 @@ wxColor PANEL_SETUP_BOARD_STACKUP::GetSelectedColor( int aRow ) const const BOARD_STACKUP_ROW_UI_ITEM& row = m_rowUiItemsList[aRow]; const BOARD_STACKUP_ITEM* item = row.m_Item; const wxBitmapComboBox* choice = dynamic_cast( row.m_ColorCtrl ); - wxASSERT( choice ); - - int idx = choice ? choice->GetSelection() : 0; + int idx = choice ? choice->GetSelection() : 0; if( IsCustomColorIdx( item->GetType(), idx ) ) return m_rowUiItemsList[aRow].m_UserColor.ToColour(); @@ -469,10 +461,13 @@ void PANEL_SETUP_BOARD_STACKUP::setDefaultLayerWidths( int targetThickness ) wxCheckBox* cbLock = dynamic_cast( ui_item.m_ThicknessLockCtrl ); wxChoice* layerType = dynamic_cast( ui_item.m_LayerTypeCtrl ); - if( ( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && !layerType ) || item->GetType() == BS_ITEM_TYPE_SOLDERMASK - || item->GetType() == BS_ITEM_TYPE_COPPER || ( cbLock && cbLock->GetValue() ) ) + if( ( item->GetType() == BS_ITEM_TYPE_DIELECTRIC && !layerType ) + || item->GetType() == BS_ITEM_TYPE_SOLDERMASK + || item->GetType() == BS_ITEM_TYPE_COPPER + || ( cbLock && cbLock->GetValue() ) ) { - // secondary dielectric layers, mask and copper layers and locked layers will be counted as fixed width + // secondary dielectric layers, mask and copper layers and locked layers will be + // counted as fixed width wxTextCtrl* textCtrl = static_cast( ui_item.m_ThicknessCtrl ); int item_thickness = m_frame->ValueFromString( textCtrl->GetValue() ); @@ -481,8 +476,9 @@ void PANEL_SETUP_BOARD_STACKUP::setDefaultLayerWidths( int targetThickness ) } // Width that hasn't been allocated by fixed items - int remainingWidth = - targetThickness - totalWidthOfFixedItems - ( prePregDefaultThickness * prePregLayerCount ); + int remainingWidth = targetThickness + - totalWidthOfFixedItems + - ( prePregDefaultThickness * prePregLayerCount ); int prePregThickness = prePregDefaultThickness; int coreThickness = remainingWidth / coreLayerCount; diff --git a/pcbnew/board_stackup_manager/panel_board_stackup.h b/pcbnew/board_stackup_manager/panel_board_stackup.h index ff3df48c08..7851969a74 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.h +++ b/pcbnew/board_stackup_manager/panel_board_stackup.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2009-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -87,7 +87,7 @@ struct BOARD_STACKUP_ROW_UI_ITEM class PANEL_SETUP_BOARD_STACKUP : public PANEL_SETUP_BOARD_STACKUP_BASE { public: - PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame, + PANEL_SETUP_BOARD_STACKUP( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame, PANEL_SETUP_LAYERS* aPanelLayers ); ~PANEL_SETUP_BOARD_STACKUP(); @@ -112,8 +112,6 @@ public: /// Return the color currently selected for the row aRow wxColor GetSelectedColor( int aRow ) const; - BOARD_STACKUP& GetStackup() { return m_stackup; } - // Called by wxWidgets: transfer current settings stored in m_stackup to the board bool TransferDataFromWindow() override; @@ -230,42 +228,38 @@ private: wxBitmapComboBox* createColorBox( BOARD_STACKUP_ITEM* aStackupItem, int aRow ); /** - * disconnect event handlers connected to wxControl items - * found in list m_controlItemsList + * disconnect event handlers connected to wxControl items found in list m_controlItemsList */ void disconnectEvents(); private: BOARD_STACKUP m_stackup; - PANEL_SETUP_LAYERS* m_panelLayers; // The associated PANEL_SETUP_LAYERS, to know - // enabled layers and copper layer names - LSET m_enabledLayers; // the current enabled layers in this panel - // restricted to allowed layers in stackup. - // when do not match the enabled layers - // in PANEL_SETUP_LAYERS the stackup is not up to date - // a list of currently available dielectric materials - DIELECTRIC_SUBSTRATE_LIST m_delectricMatList; - // a list of currently available solder mask materials - DIELECTRIC_SUBSTRATE_LIST m_solderMaskMatList; - // a list of currently available solder mask materials - DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList; - // List of items in m_fgGridSizer - std::vector m_rowUiItemsList; + PANEL_SETUP_LAYERS* m_panelLayers; // The associated PANEL_SETUP_LAYERS, to know enabled + // layers and copper layer names + LSET m_enabledLayers; // The current enabled layers in this panel restricted + // to allowed layers in stackup. (When this doesn't + // match the enabled layers in PANEL_SETUP_LAYERS the + // stackup is not up to date.) - PAGED_DIALOG* m_parentDialog; - BOARD* m_board; + DIELECTRIC_SUBSTRATE_LIST m_delectricMatList; // List of currently available + // dielectric materials + DIELECTRIC_SUBSTRATE_LIST m_solderMaskMatList; // List of currently available + // solder mask materials + DIELECTRIC_SUBSTRATE_LIST m_silkscreenMatList; // List of currently available + // solder mask materials + std::vector m_rowUiItemsList; // List of items in m_fgGridSizer + + BOARD* m_board; BOARD_DESIGN_SETTINGS* m_brdSettings; - PCB_EDIT_FRAME* m_frame; - wxSize m_numericTextCtrlSize; // Best size to enter values with units in wxTextCtrl - wxSize m_numericFieldsSize; // Best size to enter double values in wxTextCtrl - wxArrayString m_core_prepreg_choice; // Used to display the option list in dialog - wxSize m_colorSwatchesSize; // the size of color swatches in the wxBitmapComboBox. - wxSize m_colorIconsSize; // the size of color swatches in grid, left column. + PCB_EDIT_FRAME* m_frame; + wxSize m_numericTextCtrlSize; // Best size for wxTextCtrls with units + wxSize m_numericFieldsSize; // Best size for wxTextCtrls without units + wxArrayString m_core_prepreg_choice; // Used to display the option list in dialog + wxSize m_colorSwatchesSize; // Size of swatches in the wxBitmapComboBox. + wxSize m_colorIconsSize; // Size of swatches in the grid (left column) - // The list of controls (wxChoice, wxBitmapComboBox, wxTextCtrl) added to the panel - // when building the BOARD_STACKUP_ITEM list editor and connected to command events - // Used to disconnect event handlers - std::vector m_controlItemsList; + std::vector m_controlItemsList; // List of ctrls (wxChoice, wxTextCtrl, etc.) + // with added event handlers }; #endif // #ifndef PANEL_SETUP_BOARD_STACKUP_H diff --git a/pcbnew/dialogs/dialog_board_setup.cpp b/pcbnew/dialogs/dialog_board_setup.cpp index 3e70972daf..4c1efa5597 100644 --- a/pcbnew/dialogs/dialog_board_setup.cpp +++ b/pcbnew/dialogs/dialog_board_setup.cpp @@ -47,17 +47,16 @@ std::mutex DIALOG_BOARD_SETUP::g_Mutex; +#define RESOLVE_PAGE( T, pageIndex ) static_cast( m_treebook->ResolvePage( pageIndex ) ) + DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) : PAGED_DIALOG( aFrame, _( "Board Setup" ), false, _( "Import Settings from Another Board..." ) ), - m_frame( aFrame ) + m_frame( aFrame ), + m_layers( nullptr ), + m_physicalStackup( nullptr ) { SetEvtHandlerEnabled( false ); - - m_layers = new PANEL_SETUP_LAYERS( this, m_frame ); - m_physicalStackup = new PANEL_SETUP_BOARD_STACKUP( this, m_frame, m_layers ); - m_boardFinish = new PANEL_SETUP_BOARD_FINISH( this, m_frame ); - m_currentPage = -1; /* @@ -72,11 +71,27 @@ DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) : * PANEL_SETUP_BOARD_STACKUP::TransferDataFromWindow and rework this logic if it is determined * that the order of these pages should be changed. */ - m_treebook->AddSubPage( m_layers, _( "Board Editor Layers" ) ); + m_layersPage = m_treebook->GetPageCount(); + m_treebook->AddLazySubPage( + [this]( wxWindow* aParent ) -> wxWindow* + { + return new PANEL_SETUP_LAYERS( aParent, m_frame ); + }, _( "Board Editor Layers" ) ); m_physicalStackupPage = m_treebook->GetPageCount(); - m_treebook->AddSubPage( m_physicalStackup, _( "Physical Stackup" ) ); - m_treebook->AddSubPage( m_boardFinish, _( "Board Finish" ) ); + m_treebook->AddLazySubPage( + [this]( wxWindow* aParent ) -> wxWindow* + { + m_layers = RESOLVE_PAGE( PANEL_SETUP_LAYERS, m_layersPage ); + return new PANEL_SETUP_BOARD_STACKUP( aParent, m_frame, m_layers ); + }, _( "Physical Stackup" ) ); + + m_boardFinishPage = m_treebook->GetPageCount(); + m_treebook->AddLazySubPage( + [this]( wxWindow* aParent ) -> wxWindow* + { + return new PANEL_SETUP_BOARD_FINISH( aParent, m_frame ); + }, _( "Board Finish" ) ); m_maskAndPagePage = m_treebook->GetPageCount(); m_treebook->AddLazySubPage( @@ -183,6 +198,12 @@ void DIALOG_BOARD_SETUP::onPageChanged( wxBookCtrlEvent& aEvent ) size_t page = aEvent.GetSelection(); + if( m_currentPage == m_physicalStackupPage || page == m_physicalStackupPage ) + { + m_layers = RESOLVE_PAGE( PANEL_SETUP_LAYERS, m_layersPage ); + m_physicalStackup = RESOLVE_PAGE( PANEL_SETUP_BOARD_STACKUP, m_physicalStackupPage ); + } + // Ensure layer page always gets updated even if we aren't moving towards it if( m_currentPage == m_physicalStackupPage ) m_layers->SyncCopperLayers( m_physicalStackup->GetCopperLayerCount() ); @@ -218,6 +239,9 @@ void DIALOG_BOARD_SETUP::onAuxiliaryAction( wxCommandEvent& aEvent ) return; } + m_layers = RESOLVE_PAGE( PANEL_SETUP_LAYERS, m_layersPage ); + m_physicalStackup = RESOLVE_PAGE( PANEL_SETUP_BOARD_STACKUP, m_physicalStackupPage ); + // Flag so user can stop work if it will result in deleted inner copper layers // and still clean up this function properly. bool okToProceed = true; @@ -225,8 +249,7 @@ void DIALOG_BOARD_SETUP::onAuxiliaryAction( wxCommandEvent& aEvent ) PROJECT* otherPrj = m_frame->GetSettingsManager()->GetProject( projectFn.GetFullPath() ); PLUGIN::RELEASER pi( IO_MGR::PluginFind( IO_MGR::KICAD_SEXP ) ); - - BOARD* otherBoard = nullptr; + BOARD* otherBoard = nullptr; try { @@ -279,49 +302,55 @@ void DIALOG_BOARD_SETUP::onAuxiliaryAction( wxCommandEvent& aEvent ) { m_physicalStackup->ImportSettingsFrom( otherBoard ); m_layers->ImportSettingsFrom( otherBoard ); - m_boardFinish->ImportSettingsFrom( otherBoard ); + + RESOLVE_PAGE( PANEL_SETUP_BOARD_FINISH, + m_boardFinishPage )->ImportSettingsFrom( otherBoard ); } if( importDlg.m_TextAndGraphicsOpt->GetValue() ) { - static_cast( m_treebook->ResolvePage( m_textAndGraphicsPage ) ) - ->ImportSettingsFrom( otherBoard ); + RESOLVE_PAGE( PANEL_SETUP_TEXT_AND_GRAPHICS, + m_textAndGraphicsPage )->ImportSettingsFrom( otherBoard ); } if( importDlg.m_FormattingOpt->GetValue() ) { - static_cast( m_treebook->ResolvePage( m_formattingPage ) ) - ->ImportSettingsFrom( otherBoard ); + RESOLVE_PAGE( PANEL_SETUP_FORMATTING, + m_formattingPage )->ImportSettingsFrom( otherBoard ); } if( importDlg.m_ConstraintsOpt->GetValue() ) { - static_cast( m_treebook->ResolvePage( m_constraintsPage ) ) - ->ImportSettingsFrom( otherBoard ); + RESOLVE_PAGE( PANEL_SETUP_CONSTRAINTS, + m_constraintsPage )->ImportSettingsFrom( otherBoard ); } if( importDlg.m_NetclassesOpt->GetValue() ) { - static_cast( m_treebook->ResolvePage( m_netclassesPage ) ) - ->ImportSettingsFrom( otherPrj->GetProjectFile().m_NetSettings ); + PROJECT_FILE& otherProjectFile = otherPrj->GetProjectFile(); + + RESOLVE_PAGE( PANEL_SETUP_NETCLASSES, + m_netclassesPage )->ImportSettingsFrom( otherProjectFile.m_NetSettings ); } if( importDlg.m_TracksAndViasOpt->GetValue() ) { - static_cast( m_treebook->ResolvePage( m_tracksAndViasPage ) ) - ->ImportSettingsFrom( otherBoard ); + RESOLVE_PAGE( PANEL_SETUP_TRACKS_AND_VIAS, + m_tracksAndViasPage )->ImportSettingsFrom( otherBoard ); } if( importDlg.m_MaskAndPasteOpt->GetValue() ) { - static_cast( m_treebook->ResolvePage( m_maskAndPagePage ) ) - ->ImportSettingsFrom( otherBoard ); + RESOLVE_PAGE( PANEL_SETUP_MASK_AND_PASTE, + m_maskAndPagePage )->ImportSettingsFrom( otherBoard ); } if( importDlg.m_SeveritiesOpt->GetValue() ) { - static_cast( m_treebook->ResolvePage( m_severitiesPage ) ) - ->ImportSettingsFrom( otherBoard->GetDesignSettings().m_DRCSeverities ); + BOARD_DESIGN_SETTINGS& otherSettings = otherBoard->GetDesignSettings(); + + RESOLVE_PAGE( PANEL_SETUP_SEVERITIES, + m_severitiesPage )->ImportSettingsFrom( otherSettings.m_DRCSeverities ); } if( otherPrj != &m_frame->Prj() ) diff --git a/pcbnew/dialogs/dialog_board_setup.h b/pcbnew/dialogs/dialog_board_setup.h index c5621c4e6b..c9b669e442 100644 --- a/pcbnew/dialogs/dialog_board_setup.h +++ b/pcbnew/dialogs/dialog_board_setup.h @@ -50,24 +50,24 @@ protected: void onPageChanged( wxBookCtrlEvent& aEvent ) override; void onAuxiliaryAction( wxCommandEvent& aEvent ) override; - PCB_EDIT_FRAME* m_frame; - - PANEL_SETUP_LAYERS* m_layers; - PANEL_SETUP_BOARD_STACKUP* m_physicalStackup; - PANEL_SETUP_BOARD_FINISH* m_boardFinish; + PCB_EDIT_FRAME* m_frame; + PANEL_SETUP_LAYERS* m_layers; + PANEL_SETUP_BOARD_STACKUP* m_physicalStackup; public: static std::mutex g_Mutex; // Mutex to prevent multiple windows opening private: size_t m_currentPage; // the current page index - size_t m_textAndGraphicsPage; - size_t m_constraintsPage; - size_t m_formattingPage; + size_t m_layersPage; size_t m_physicalStackupPage; + size_t m_boardFinishPage; + size_t m_textAndGraphicsPage; + size_t m_formattingPage; + size_t m_maskAndPagePage; + size_t m_constraintsPage; size_t m_tracksAndViasPage; size_t m_netclassesPage; - size_t m_maskAndPagePage; size_t m_severitiesPage; }; diff --git a/pcbnew/dialogs/panel_setup_layers.cpp b/pcbnew/dialogs/panel_setup_layers.cpp index 11248fa51a..ceb49bd691 100644 --- a/pcbnew/dialogs/panel_setup_layers.cpp +++ b/pcbnew/dialogs/panel_setup_layers.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2009 Isaac Marino Bavaresco, isaacbavaresco@yahoo.com.br * Copyright (C) 2009 SoftPLC Corporation, Dick Hollenbeck - * Copyright (C) 2009-2021 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -38,7 +38,6 @@ #include #include -#include #include @@ -124,9 +123,8 @@ static LSEQ dlg_layers() } -PANEL_SETUP_LAYERS::PANEL_SETUP_LAYERS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) : - PANEL_SETUP_LAYERS_BASE( aParent->GetTreebook() ), - m_parentDialog( aParent ), +PANEL_SETUP_LAYERS::PANEL_SETUP_LAYERS( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame ) : + PANEL_SETUP_LAYERS_BASE( aParentWindow ), m_frame( aFrame ), m_physicalStackup( nullptr ), m_initialized( false ) @@ -447,10 +445,9 @@ bool PANEL_SETUP_LAYERS::TransferDataFromWindow() if( !testLayerNames() ) return false; - wxASSERT( m_physicalStackup ); - // Make sure we have the latest copper layer count - SyncCopperLayers( m_physicalStackup->GetCopperLayerCount() ); + if( m_physicalStackup ) + SyncCopperLayers( m_physicalStackup->GetCopperLayerCount() ); wxString msg; bool modified = false; @@ -671,20 +668,21 @@ bool PANEL_SETUP_LAYERS::testLayerNames() if( !name ) { - m_parentDialog->SetError( _( "Layer must have a name." ), this, ctl ); + PAGED_DIALOG::GetDialog( this )->SetError( _( "Layer must have a name." ), this, ctl ); return false; } if( hasOneOf( name, badchars ) ) { wxString msg = wxString::Format(_( "%s are forbidden in layer names." ), badchars ); - m_parentDialog->SetError( msg, this, ctl ); + PAGED_DIALOG::GetDialog( this )->SetError( msg, this, ctl ); return false; } if( name == wxT( "signal" ) ) { - m_parentDialog->SetError( _( "Layer name \"signal\" is reserved." ), this, ctl ); + PAGED_DIALOG::GetDialog( this )->SetError( _( "Layer name \"signal\" is reserved." ), + this, ctl ); return false; } @@ -693,7 +691,7 @@ bool PANEL_SETUP_LAYERS::testLayerNames() if( name == existingName ) { wxString msg = wxString::Format(_( "Layer name '%s' already in use." ), name ); - m_parentDialog->SetError( msg, this, ctl ); + PAGED_DIALOG::GetDialog( this )->SetError( msg, this, ctl ); return false; } } @@ -833,12 +831,13 @@ void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent ) if( list.empty() ) { - DisplayErrorMessage( m_parentDialog, + DisplayErrorMessage( PAGED_DIALOG::GetDialog( this ), _( "All user-defined layers have already been added." ) ); return; } - EDA_LIST_DIALOG dlg( m_parentDialog, _( "Add User-defined Layer" ), headers, list ); + EDA_LIST_DIALOG dlg( PAGED_DIALOG::GetDialog( this ), _( "Add User-defined Layer" ), + headers, list ); dlg.SetListLabel( _( "Select layer to add:" ) ); dlg.HideFilter(); diff --git a/pcbnew/dialogs/panel_setup_layers.h b/pcbnew/dialogs/panel_setup_layers.h index b60f597d9e..5be4f5d066 100644 --- a/pcbnew/dialogs/panel_setup_layers.h +++ b/pcbnew/dialogs/panel_setup_layers.h @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2018-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2018-2023 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -56,7 +56,7 @@ struct PANEL_SETUP_LAYERS_CTLs class PANEL_SETUP_LAYERS : public PANEL_SETUP_LAYERS_BASE { public: - PANEL_SETUP_LAYERS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ); + PANEL_SETUP_LAYERS( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame ); void ImportSettingsFrom( BOARD* aBoard ); @@ -94,7 +94,6 @@ public: bool IsInitialized() const { return m_initialized; } private: - void setLayerCheckBox( int layer, bool isChecked ); void setCopperLayerCheckBoxes( int copperCount ); void setMandatoryLayerCheckBoxes(); @@ -129,7 +128,7 @@ private: wxCheckBox* getCheckBox( int aLayer ); wxChoice* getChoice( int aLayer ); - PAGED_DIALOG* m_parentDialog; +private: PCB_EDIT_FRAME* m_frame; PANEL_SETUP_BOARD_STACKUP* m_physicalStackup; BOARD* m_pcb;