diff --git a/pcbnew/board_stackup_manager/panel_board_finish.cpp b/pcbnew/board_stackup_manager/panel_board_finish.cpp index 6df058bf62..19edf749e3 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-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2021 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,16 +22,19 @@ * 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( wxWindow* aParentWindow, - PCB_EDIT_FRAME* aFrame ) : - PANEL_SETUP_BOARD_FINISH_BASE( aParentWindow ) + +PANEL_SETUP_BOARD_FINISH::PANEL_SETUP_BOARD_FINISH( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) : + PANEL_SETUP_BOARD_FINISH_BASE( aParent->GetTreebook() ) { + 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 3ef757a843..7bcfe2c6ee 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-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009-2021 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( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame ); + PANEL_SETUP_BOARD_FINISH( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ); ~PANEL_SETUP_BOARD_FINISH(); void ImportSettingsFrom( BOARD* aBoard ); @@ -48,6 +48,7 @@ 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 666060fc7c..f18f10fbbb 100644 --- a/pcbnew/board_stackup_manager/panel_board_stackup.cpp +++ b/pcbnew/board_stackup_manager/panel_board_stackup.cpp @@ -32,16 +32,19 @@ #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 @@ -71,14 +74,14 @@ static wxColor pasteColor( 200, 200, 200 ); static void drawBitmap( wxBitmap& aBitmap, wxColor aColor ); -PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( wxWindow* aParentWindow, - PCB_EDIT_FRAME* aFrame, +PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame, PANEL_SETUP_LAYERS* aPanelLayers ): - PANEL_SETUP_BOARD_STACKUP_BASE( aParentWindow ), + PANEL_SETUP_BOARD_STACKUP_BASE( aParent->GetTreebook() ), 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(); @@ -91,17 +94,18 @@ PANEL_SETUP_BOARD_STACKUP::PANEL_SETUP_BOARD_STACKUP( wxWindow* aParentWindow, m_enabledLayers = m_board->GetEnabledLayers() & BOARD_STACKUP::StackupAllowedBrdLayers(); // Calculates a good size for color swatches (icons) in this dialog - m_colorSwatchesSize = GetTextExtent( wxT( "XX" ) ); - m_colorIconsSize = GetTextExtent( wxT( "XXXX" ) ); + wxClientDC dc( this ); + m_colorSwatchesSize = dc.GetTextExtent( wxT( "XX" ) ); + m_colorIconsSize = dc.GetTextExtent( wxT( "XXXX" ) ); // Calculates a good size for wxTextCtrl to enter Epsilon R and Loss tan // ("0.0000000" + margins) - m_numericFieldsSize = GetTextExtent( wxT( "X.XXXXXXX" ) ); + m_numericFieldsSize = dc.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 = GetTextExtent( wxT( "XXX.XXXXXXX mils" ) ); + m_numericTextCtrlSize = dc.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 @@ -199,9 +203,13 @@ 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(); } @@ -282,9 +290,8 @@ void PANEL_SETUP_BOARD_STACKUP::onAddDielectricLayer( wxCommandEvent& event ) } } - 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 */ ); + 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 */); dlg.SetListLabel( _( "Select layer to add:" ) ); dlg.HideFilter(); @@ -340,9 +347,8 @@ void PANEL_SETUP_BOARD_STACKUP::onRemoveDielectricLayer( wxCommandEvent& event ) } } - 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 */ ); + 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 */ ); dlg.SetListLabel( _( "Select layer to remove:" ) ); dlg.HideFilter(); @@ -407,7 +413,9 @@ 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 ); - int idx = choice ? choice->GetSelection() : 0; + wxASSERT( choice ); + + int idx = choice ? choice->GetSelection() : 0; if( IsCustomColorIdx( item->GetType(), idx ) ) return m_rowUiItemsList[aRow].m_UserColor.ToColour(); @@ -461,13 +469,10 @@ 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() ); @@ -476,9 +481,8 @@ 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 7851969a74..ff3df48c08 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-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009-2022 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( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame, + PANEL_SETUP_BOARD_STACKUP( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame, PANEL_SETUP_LAYERS* aPanelLayers ); ~PANEL_SETUP_BOARD_STACKUP(); @@ -112,6 +112,8 @@ 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; @@ -228,38 +230,42 @@ 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 this doesn't - // match the enabled layers in PANEL_SETUP_LAYERS the - // stackup is not up to date.) + 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; - 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; + PAGED_DIALOG* m_parentDialog; + BOARD* m_board; BOARD_DESIGN_SETTINGS* m_brdSettings; - 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) + 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. - std::vector m_controlItemsList; // List of ctrls (wxChoice, wxTextCtrl, etc.) - // with added event handlers + // 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; }; #endif // #ifndef PANEL_SETUP_BOARD_STACKUP_H diff --git a/pcbnew/dialogs/dialog_board_setup.cpp b/pcbnew/dialogs/dialog_board_setup.cpp index 4c1efa5597..3e70972daf 100644 --- a/pcbnew/dialogs/dialog_board_setup.cpp +++ b/pcbnew/dialogs/dialog_board_setup.cpp @@ -47,16 +47,17 @@ 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_layers( nullptr ), - m_physicalStackup( nullptr ) + m_frame( aFrame ) { 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; /* @@ -71,27 +72,11 @@ 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_layersPage = m_treebook->GetPageCount(); - m_treebook->AddLazySubPage( - [this]( wxWindow* aParent ) -> wxWindow* - { - return new PANEL_SETUP_LAYERS( aParent, m_frame ); - }, _( "Board Editor Layers" ) ); + m_treebook->AddSubPage( m_layers, _( "Board Editor Layers" ) ); m_physicalStackupPage = m_treebook->GetPageCount(); - 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_treebook->AddSubPage( m_physicalStackup, _( "Physical Stackup" ) ); + m_treebook->AddSubPage( m_boardFinish, _( "Board Finish" ) ); m_maskAndPagePage = m_treebook->GetPageCount(); m_treebook->AddLazySubPage( @@ -198,12 +183,6 @@ 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() ); @@ -239,9 +218,6 @@ 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; @@ -249,7 +225,8 @@ 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 { @@ -302,55 +279,49 @@ void DIALOG_BOARD_SETUP::onAuxiliaryAction( wxCommandEvent& aEvent ) { m_physicalStackup->ImportSettingsFrom( otherBoard ); m_layers->ImportSettingsFrom( otherBoard ); - - RESOLVE_PAGE( PANEL_SETUP_BOARD_FINISH, - m_boardFinishPage )->ImportSettingsFrom( otherBoard ); + m_boardFinish->ImportSettingsFrom( otherBoard ); } if( importDlg.m_TextAndGraphicsOpt->GetValue() ) { - RESOLVE_PAGE( PANEL_SETUP_TEXT_AND_GRAPHICS, - m_textAndGraphicsPage )->ImportSettingsFrom( otherBoard ); + static_cast( m_treebook->ResolvePage( m_textAndGraphicsPage ) ) + ->ImportSettingsFrom( otherBoard ); } if( importDlg.m_FormattingOpt->GetValue() ) { - RESOLVE_PAGE( PANEL_SETUP_FORMATTING, - m_formattingPage )->ImportSettingsFrom( otherBoard ); + static_cast( m_treebook->ResolvePage( m_formattingPage ) ) + ->ImportSettingsFrom( otherBoard ); } if( importDlg.m_ConstraintsOpt->GetValue() ) { - RESOLVE_PAGE( PANEL_SETUP_CONSTRAINTS, - m_constraintsPage )->ImportSettingsFrom( otherBoard ); + static_cast( m_treebook->ResolvePage( m_constraintsPage ) ) + ->ImportSettingsFrom( otherBoard ); } if( importDlg.m_NetclassesOpt->GetValue() ) { - PROJECT_FILE& otherProjectFile = otherPrj->GetProjectFile(); - - RESOLVE_PAGE( PANEL_SETUP_NETCLASSES, - m_netclassesPage )->ImportSettingsFrom( otherProjectFile.m_NetSettings ); + static_cast( m_treebook->ResolvePage( m_netclassesPage ) ) + ->ImportSettingsFrom( otherPrj->GetProjectFile().m_NetSettings ); } if( importDlg.m_TracksAndViasOpt->GetValue() ) { - RESOLVE_PAGE( PANEL_SETUP_TRACKS_AND_VIAS, - m_tracksAndViasPage )->ImportSettingsFrom( otherBoard ); + static_cast( m_treebook->ResolvePage( m_tracksAndViasPage ) ) + ->ImportSettingsFrom( otherBoard ); } if( importDlg.m_MaskAndPasteOpt->GetValue() ) { - RESOLVE_PAGE( PANEL_SETUP_MASK_AND_PASTE, - m_maskAndPagePage )->ImportSettingsFrom( otherBoard ); + static_cast( m_treebook->ResolvePage( m_maskAndPagePage ) ) + ->ImportSettingsFrom( otherBoard ); } if( importDlg.m_SeveritiesOpt->GetValue() ) { - BOARD_DESIGN_SETTINGS& otherSettings = otherBoard->GetDesignSettings(); - - RESOLVE_PAGE( PANEL_SETUP_SEVERITIES, - m_severitiesPage )->ImportSettingsFrom( otherSettings.m_DRCSeverities ); + static_cast( m_treebook->ResolvePage( m_severitiesPage ) ) + ->ImportSettingsFrom( otherBoard->GetDesignSettings().m_DRCSeverities ); } if( otherPrj != &m_frame->Prj() ) diff --git a/pcbnew/dialogs/dialog_board_setup.h b/pcbnew/dialogs/dialog_board_setup.h index c9b669e442..c5621c4e6b 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; + PCB_EDIT_FRAME* m_frame; + + PANEL_SETUP_LAYERS* m_layers; + PANEL_SETUP_BOARD_STACKUP* m_physicalStackup; + PANEL_SETUP_BOARD_FINISH* m_boardFinish; public: static std::mutex g_Mutex; // Mutex to prevent multiple windows opening private: size_t m_currentPage; // the current page index - 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_formattingPage; + size_t m_physicalStackupPage; 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 ceb49bd691..11248fa51a 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-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2009-2021 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,6 +38,7 @@ #include #include +#include #include @@ -123,8 +124,9 @@ static LSEQ dlg_layers() } -PANEL_SETUP_LAYERS::PANEL_SETUP_LAYERS( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame ) : - PANEL_SETUP_LAYERS_BASE( aParentWindow ), +PANEL_SETUP_LAYERS::PANEL_SETUP_LAYERS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ) : + PANEL_SETUP_LAYERS_BASE( aParent->GetTreebook() ), + m_parentDialog( aParent ), m_frame( aFrame ), m_physicalStackup( nullptr ), m_initialized( false ) @@ -445,9 +447,10 @@ bool PANEL_SETUP_LAYERS::TransferDataFromWindow() if( !testLayerNames() ) return false; + wxASSERT( m_physicalStackup ); + // Make sure we have the latest copper layer count - if( m_physicalStackup ) - SyncCopperLayers( m_physicalStackup->GetCopperLayerCount() ); + SyncCopperLayers( m_physicalStackup->GetCopperLayerCount() ); wxString msg; bool modified = false; @@ -668,21 +671,20 @@ bool PANEL_SETUP_LAYERS::testLayerNames() if( !name ) { - PAGED_DIALOG::GetDialog( this )->SetError( _( "Layer must have a name." ), this, ctl ); + m_parentDialog->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 ); - PAGED_DIALOG::GetDialog( this )->SetError( msg, this, ctl ); + m_parentDialog->SetError( msg, this, ctl ); return false; } if( name == wxT( "signal" ) ) { - PAGED_DIALOG::GetDialog( this )->SetError( _( "Layer name \"signal\" is reserved." ), - this, ctl ); + m_parentDialog->SetError( _( "Layer name \"signal\" is reserved." ), this, ctl ); return false; } @@ -691,7 +693,7 @@ bool PANEL_SETUP_LAYERS::testLayerNames() if( name == existingName ) { wxString msg = wxString::Format(_( "Layer name '%s' already in use." ), name ); - PAGED_DIALOG::GetDialog( this )->SetError( msg, this, ctl ); + m_parentDialog->SetError( msg, this, ctl ); return false; } } @@ -831,13 +833,12 @@ void PANEL_SETUP_LAYERS::addUserDefinedLayer( wxCommandEvent& aEvent ) if( list.empty() ) { - DisplayErrorMessage( PAGED_DIALOG::GetDialog( this ), + DisplayErrorMessage( m_parentDialog, _( "All user-defined layers have already been added." ) ); return; } - EDA_LIST_DIALOG dlg( PAGED_DIALOG::GetDialog( this ), _( "Add User-defined Layer" ), - headers, list ); + EDA_LIST_DIALOG dlg( m_parentDialog, _( "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 5be4f5d066..b60f597d9e 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-2023 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2018-2021 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( wxWindow* aParentWindow, PCB_EDIT_FRAME* aFrame ); + PANEL_SETUP_LAYERS( PAGED_DIALOG* aParent, PCB_EDIT_FRAME* aFrame ); void ImportSettingsFrom( BOARD* aBoard ); @@ -94,6 +94,7 @@ public: bool IsInitialized() const { return m_initialized; } private: + void setLayerCheckBox( int layer, bool isChecked ); void setCopperLayerCheckBoxes( int copperCount ); void setMandatoryLayerCheckBoxes(); @@ -128,7 +129,7 @@ private: wxCheckBox* getCheckBox( int aLayer ); wxChoice* getChoice( int aLayer ); -private: + PAGED_DIALOG* m_parentDialog; PCB_EDIT_FRAME* m_frame; PANEL_SETUP_BOARD_STACKUP* m_physicalStackup; BOARD* m_pcb;