KiCad PCB EDA Suite
dialog_board_setup.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #include <pcb_edit_frame.h>
20 #include <panel_setup_layers.h>
23 #include <panel_setup_netclasses.h>
26 #include <../board_stackup_manager/panel_board_stackup.h>
27 #include <kiface_i.h>
28 #include "dialog_import_settings.h"
29 
30 #include "dialog_board_setup.h"
31 
33  PAGED_DIALOG( aFrame, _( "Board Setup" ), _( "Import Settings from Another Project..." ) ),
34  m_frame( aFrame )
35 {
36  m_layers = new PANEL_SETUP_LAYERS( this, aFrame );
38  m_constraints = new PANEL_SETUP_FEATURE_CONSTRAINTS( this, aFrame );
39  m_netclasses = new PANEL_SETUP_NETCLASSES( this, aFrame, m_constraints );
41  m_maskAndPaste = new PANEL_SETUP_MASK_AND_PASTE( this, aFrame );
43 
44  /*
45  * WARNING: If you change page names you MUST update calls to DoShowBoardSetupDialog().
46  */
47 
48  m_treebook->AddPage( new wxPanel( this ), _( "Board Stackup" ) );
49  m_treebook->AddSubPage( m_layers, _( "Board Editor Layers" ) );
50  m_treebook->AddSubPage( m_physicalStackup, _( "Physical Stackup" ) );
51  // Change this value if m_physicalStackup is not the page 2 of m_treebook
52  m_physicalStackupPage = 2; // The page number (from 0) to select the m_physicalStackup panel
53 
54  m_treebook->AddPage( new wxPanel( this ), _( "Defaults" ) );
55  m_treebook->AddSubPage( m_textAndGraphics, _( "Text & Graphics" ) );
56  m_treebook->AddSubPage( m_tracksAndVias, _( "Tracks & Vias" ) );
57  m_treebook->AddSubPage( m_maskAndPaste, _( "Solder Mask/Paste" ) );
58 
59  m_treebook->AddPage( new wxPanel( this ), _( "Design Rules" ) );
60  m_treebook->AddSubPage( m_constraints, _( "Constraints" ) );
61  m_treebook->AddSubPage( m_netclasses, _( "Net Classes" ) );
62 
63  // Connect Events
64  m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
65  wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this );
66 }
67 
68 
70 {
71  m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
72  wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this );
73 }
74 
75 
76 void DIALOG_BOARD_SETUP::OnPageChange( wxBookCtrlEvent& event )
77 {
78  if( event.GetSelection() == m_physicalStackupPage )
80 }
81 
82 
83 // Run Import Settings... action
84 void DIALOG_BOARD_SETUP::OnAuxiliaryAction( wxCommandEvent& event )
85 {
86  DIALOG_IMPORT_SETTINGS importDlg( this, m_frame );
87 
88  if( importDlg.ShowModal() == wxID_CANCEL )
89  return;
90 
91  wxConfigBase* cfg = new wxFileConfig( wxEmptyString, wxEmptyString, importDlg.GetFilePath() );
92 
93  // We do not want expansion of env var values when reading our project config file
94  cfg->SetExpandEnvVars( false );
95  cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
96 
97  BOARD* dummyBoard = new BOARD();
98  PARAM_CFG_ARRAY designSettingsConfig;
99 
100  dummyBoard->GetDesignSettings().AppendConfigs( dummyBoard, &designSettingsConfig );
101  wxConfigLoadParams( cfg, designSettingsConfig, GROUP_PCB );
102 
103  if( importDlg.m_LayersOpt->GetValue() )
104  m_layers->ImportSettingsFrom( dummyBoard );
105  if( importDlg.m_TextAndGraphicsOpt->GetValue() )
106  m_textAndGraphics->ImportSettingsFrom( dummyBoard );
107  if( importDlg.m_ConstraintsOpt->GetValue() )
108  m_constraints->ImportSettingsFrom( dummyBoard );
109  if( importDlg.m_NetclassesOpt->GetValue() )
110  m_netclasses->ImportSettingsFrom( dummyBoard );
111  if( importDlg.m_TracksAndViasOpt->GetValue() )
112  m_tracksAndVias->ImportSettingsFrom( dummyBoard );
113  if( importDlg.m_MaskAndPasteOpt->GetValue() )
114  m_maskAndPaste->ImportSettingsFrom( dummyBoard );
115 
116  // If layers options are imported, import also the stackup
117  // layers options and stackup are linked, so they cannot be imported
118  // separately, and stackup can be imported only after layers options
119  //
120  // Note also currently only the list of enabled layers can be imported, because
121  // we import settings from a .pro project file, not the settings inside
122  // a board, and info only living in the board is not imported.
123  if( importDlg.m_LayersOpt->GetValue() )
124  m_physicalStackup->ImportSettingsFrom( dummyBoard );
125 
126  delete dummyBoard;
127  delete cfg;
128 }
A list of parameters type.
PANEL_SETUP_NETCLASSES * m_netclasses
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:540
PCB_EDIT_FRAME * m_frame
void wxConfigLoadParams(wxConfigBase *aCfg, const PARAM_CFG_ARRAY &aList, const wxString &aGroup)
Function wxConfigLoadParams uses aList of PARAM_CFG_ARRAY elements to load configuration values from ...
PANEL_SETUP_BOARD_STACKUP * m_physicalStackup
void OnAuxiliaryAction(wxCommandEvent &event) override
void OnLayersOptionsChanged(LSET aNewLayerSet)
Must be called if the copper layers count has changed or solder mask, solder paste or silkscreen laye...
void ImportSettingsFrom(BOARD *aBoard)
void ImportSettingsFrom(BOARD *aBoard)
wxTreebook * m_treebook
Definition: paged_dialog.h:59
#define _(s)
void AppendConfigs(BOARD *aBoard, PARAM_CFG_ARRAY *aResult)
Function AppendConfigs appends to aResult the configuration setting accessors which will later allow ...
void ImportSettingsFrom(BOARD *aBoard)
DIALOG_BOARD_SETUP(PCB_EDIT_FRAME *aFrame)
PANEL_SETUP_TRACKS_AND_VIAS * m_tracksAndVias
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:161
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
PANEL_SETUP_TEXT_AND_GRAPHICS * m_textAndGraphics
PANEL_SETUP_MASK_AND_PASTE * m_maskAndPaste
PANEL_SETUP_LAYERS * m_layers
void OnPageChange(wxBookCtrlEvent &event)
#define GROUP_PCB
Names of sub sections where to store project info in *.pro project config files.
Definition: config_params.h:43
PANEL_SETUP_FEATURE_CONSTRAINTS * m_constraints