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-2018 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 <kiface_i.h>
27 #include "dialog_import_settings.h"
28 
29 #include "dialog_board_setup.h"
30 
32  PAGED_DIALOG( aFrame, _( "Board Setup" ), _( "Import Settings..." ) ),
33  m_frame( aFrame )
34 {
35  m_layers = new PANEL_SETUP_LAYERS( this, aFrame );
37  m_constraints = new PANEL_SETUP_FEATURE_CONSTRAINTS( this, aFrame );
38  m_netclasses = new PANEL_SETUP_NETCLASSES( this, aFrame, m_constraints );
40  m_maskAndPaste = new PANEL_SETUP_MASK_AND_PASTE( this, aFrame );
41 
42  /*
43  * WARNING: If you change page names you MUST update callers which specifiy a
44  * particular page to be in sync.
45  */
46 
47  m_treebook->AddPage( m_layers, _( "Layers" ) );
48  m_treebook->AddSubPage( m_textAndGraphics, _( "Text & Graphics" ) );
49 
50  m_treebook->AddPage( m_constraints, _( "Design Rules" ) );
51  m_treebook->AddSubPage( m_netclasses, _( "Net Classes" ) );
52  m_treebook->AddSubPage( m_tracksAndVias, _( "Tracks & Vias" ) );
53  m_treebook->AddSubPage( m_maskAndPaste, _( "Solder Mask/Paste" ) );
54 }
55 
56 
57 // Run Import Settings... action
58 void DIALOG_BOARD_SETUP::OnAuxiliaryAction( wxCommandEvent& event )
59 {
60  DIALOG_IMPORT_SETTINGS importDlg( this, m_frame );
61 
62  if( importDlg.ShowModal() == wxID_CANCEL )
63  return;
64 
65  wxConfigBase* cfg = new wxFileConfig( wxEmptyString, wxEmptyString, importDlg.GetFilePath() );
66 
67  // We do not want expansion of env var values when reading our project config file
68  cfg->SetExpandEnvVars( false );
69  cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
70 
71  BOARD* dummyBoard = new BOARD();
72  PARAM_CFG_ARRAY designSettingsConfig;
73 
74  dummyBoard->GetDesignSettings().AppendConfigs( dummyBoard, &designSettingsConfig );
75  wxConfigLoadParams( cfg, designSettingsConfig, GROUP_PCB );
76 
77  if( importDlg.m_LayersOpt->GetValue() )
78  m_layers->ImportSettingsFrom( dummyBoard );
79  if( importDlg.m_TextAndGraphicsOpt->GetValue() )
81  if( importDlg.m_ConstraintsOpt->GetValue() )
82  m_constraints->ImportSettingsFrom( dummyBoard );
83  if( importDlg.m_NetclassesOpt->GetValue() )
84  m_netclasses->ImportSettingsFrom( dummyBoard );
85  if( importDlg.m_MaskAndPasteOpt->GetValue() )
86  m_maskAndPaste->ImportSettingsFrom( dummyBoard );
87 
88  delete dummyBoard;
89  delete cfg;
90 }
A list of parameters type.
PANEL_SETUP_NETCLASSES * m_netclasses
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 ...
void OnAuxiliaryAction(wxCommandEvent &event) override
void ImportSettingsFrom(BOARD *aBoard)
wxTreebook * m_treebook
Definition: paged_dialog.h:59
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
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:170
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
#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