2018-04-28 15:22:25 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2019-07-27 19:09:43 +00:00
|
|
|
* Copyright (C) 2017-2019 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-04-28 15:22:25 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include <pcb_edit_frame.h>
|
|
|
|
#include <panel_setup_layers.h>
|
|
|
|
#include <panel_setup_text_and_graphics.h>
|
|
|
|
#include <panel_setup_feature_constraints.h>
|
|
|
|
#include <panel_setup_netclasses.h>
|
2018-07-17 06:52:33 +00:00
|
|
|
#include <panel_setup_tracks_and_vias.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
#include <panel_setup_mask_and_paste.h>
|
2019-07-27 19:09:43 +00:00
|
|
|
#include <../board_stackup_manager/panel_board_stackup.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
#include <kiface_i.h>
|
2020-03-10 18:46:57 +00:00
|
|
|
#include <drc/drc.h>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <drc/drc_item.h>
|
2020-03-10 18:46:57 +00:00
|
|
|
#include <dialog_import_settings.h>
|
|
|
|
#include <panel_setup_severities.h>
|
2020-03-26 11:02:59 +00:00
|
|
|
#include <panel_text_variables.h>
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
#include "dialog_board_setup.h"
|
2020-03-10 18:46:57 +00:00
|
|
|
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
|
2019-04-26 13:59:12 +00:00
|
|
|
PAGED_DIALOG( aFrame, _( "Board Setup" ), _( "Import Settings from Another Project..." ) ),
|
2018-04-28 15:22:25 +00:00
|
|
|
m_frame( aFrame )
|
|
|
|
{
|
|
|
|
m_layers = new PANEL_SETUP_LAYERS( this, aFrame );
|
|
|
|
m_textAndGraphics = new PANEL_SETUP_TEXT_AND_GRAPHICS( this, aFrame );
|
|
|
|
m_constraints = new PANEL_SETUP_FEATURE_CONSTRAINTS( this, aFrame );
|
|
|
|
m_netclasses = new PANEL_SETUP_NETCLASSES( this, aFrame, m_constraints );
|
2018-07-17 06:52:33 +00:00
|
|
|
m_tracksAndVias = new PANEL_SETUP_TRACKS_AND_VIAS( this, aFrame, m_constraints );
|
2018-04-28 15:22:25 +00:00
|
|
|
m_maskAndPaste = new PANEL_SETUP_MASK_AND_PASTE( this, aFrame );
|
2019-07-27 19:09:43 +00:00
|
|
|
m_physicalStackup = new PANEL_SETUP_BOARD_STACKUP( this, aFrame, m_layers );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
2020-04-24 13:36:10 +00:00
|
|
|
DRC_ITEM dummyItem( 0 );
|
2020-03-16 11:05:01 +00:00
|
|
|
BOARD_DESIGN_SETTINGS& bds = aFrame->GetDesignSettings();
|
|
|
|
m_severities = new PANEL_SETUP_SEVERITIES( this, dummyItem, bds.m_DRCSeverities,
|
2020-03-10 18:46:57 +00:00
|
|
|
DRCE_FIRST, DRCE_LAST );
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2020-03-26 11:02:59 +00:00
|
|
|
m_textVars = new PANEL_TEXT_VARIABLES( this, &Prj() );
|
|
|
|
|
2018-11-17 00:33:20 +00:00
|
|
|
/*
|
2019-08-19 16:46:25 +00:00
|
|
|
* WARNING: If you change page names you MUST update calls to DoShowBoardSetupDialog().
|
2018-11-17 00:33:20 +00:00
|
|
|
*/
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
m_treebook->AddPage( new wxPanel( this ), _( "Board Stackup" ) );
|
|
|
|
m_treebook->AddSubPage( m_layers, _( "Board Editor Layers" ) );
|
|
|
|
m_treebook->AddSubPage( m_physicalStackup, _( "Physical Stackup" ) );
|
|
|
|
// Change this value if m_physicalStackup is not the page 2 of m_treebook
|
|
|
|
m_physicalStackupPage = 2; // The page number (from 0) to select the m_physicalStackup panel
|
2018-04-28 15:22:25 +00:00
|
|
|
|
2019-08-19 16:46:25 +00:00
|
|
|
m_treebook->AddPage( new wxPanel( this ), _( "Defaults" ) );
|
|
|
|
m_treebook->AddSubPage( m_textAndGraphics, _( "Text & Graphics" ) );
|
2018-07-17 06:52:33 +00:00
|
|
|
m_treebook->AddSubPage( m_tracksAndVias, _( "Tracks & Vias" ) );
|
2018-07-15 23:15:48 +00:00
|
|
|
m_treebook->AddSubPage( m_maskAndPaste, _( "Solder Mask/Paste" ) );
|
2019-08-19 16:46:25 +00:00
|
|
|
|
|
|
|
m_treebook->AddPage( new wxPanel( this ), _( "Design Rules" ) );
|
|
|
|
m_treebook->AddSubPage( m_constraints, _( "Constraints" ) );
|
|
|
|
m_treebook->AddSubPage( m_netclasses, _( "Net Classes" ) );
|
2020-03-10 18:46:57 +00:00
|
|
|
m_treebook->AddSubPage( m_severities, _( "Violation Severity" ) );
|
2019-07-27 19:09:43 +00:00
|
|
|
|
2020-03-26 11:02:59 +00:00
|
|
|
m_treebook->AddPage( new wxPanel( this ), _( "Project" ) );
|
|
|
|
m_treebook->AddSubPage( m_textVars, _( "Text Variables" ) );
|
|
|
|
|
2020-04-10 15:01:11 +00:00
|
|
|
for( size_t i = 0; i < m_treebook->GetPageCount(); ++i )
|
|
|
|
m_macHack.push_back( true );
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
// Connect Events
|
|
|
|
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
|
|
|
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
|
|
|
FinishDialogSettings();
|
2019-07-27 19:09:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_BOARD_SETUP::~DIALOG_BOARD_SETUP()
|
|
|
|
{
|
|
|
|
m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
|
|
|
wxBookCtrlEventHandler( DIALOG_BOARD_SETUP::OnPageChange ), NULL, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_BOARD_SETUP::OnPageChange( wxBookCtrlEvent& event )
|
|
|
|
{
|
|
|
|
if( event.GetSelection() == m_physicalStackupPage )
|
|
|
|
m_physicalStackup->OnLayersOptionsChanged( m_layers->GetUILayerMask() );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
|
|
|
#ifdef __WXMAC__
|
2020-03-26 11:02:59 +00:00
|
|
|
// Work around an OSX bug where the wxGrid children don't get placed correctly until
|
|
|
|
// the first resize event
|
|
|
|
int page = event.GetSelection();
|
|
|
|
|
|
|
|
if( m_macHack[ page ] )
|
2020-03-10 18:46:57 +00:00
|
|
|
{
|
2020-03-26 11:02:59 +00:00
|
|
|
wxSize pageSize = m_treebook->GetPage( page )->GetSize();
|
|
|
|
pageSize.x -= 1;
|
|
|
|
pageSize.y += 2;
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-03-26 11:02:59 +00:00
|
|
|
m_treebook->GetPage( page )->SetSize( pageSize );
|
|
|
|
m_macHack[ page ] = false;
|
2020-03-10 18:46:57 +00:00
|
|
|
}
|
|
|
|
#endif
|
2018-04-28 15:22:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Run Import Settings... action
|
|
|
|
void DIALOG_BOARD_SETUP::OnAuxiliaryAction( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
DIALOG_IMPORT_SETTINGS importDlg( this, m_frame );
|
|
|
|
|
|
|
|
if( importDlg.ShowModal() == wxID_CANCEL )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxConfigBase* cfg = new wxFileConfig( wxEmptyString, wxEmptyString, importDlg.GetFilePath() );
|
|
|
|
|
|
|
|
// We do not want expansion of env var values when reading our project config file
|
|
|
|
cfg->SetExpandEnvVars( false );
|
|
|
|
cfg->SetPath( wxCONFIG_PATH_SEPARATOR );
|
|
|
|
|
|
|
|
BOARD* dummyBoard = new BOARD();
|
2020-01-12 18:40:50 +00:00
|
|
|
std::vector<PARAM_CFG*> designSettingsConfig;
|
2018-04-28 15:22:25 +00:00
|
|
|
|
|
|
|
dummyBoard->GetDesignSettings().AppendConfigs( dummyBoard, &designSettingsConfig );
|
|
|
|
wxConfigLoadParams( cfg, designSettingsConfig, GROUP_PCB );
|
|
|
|
|
|
|
|
if( importDlg.m_LayersOpt->GetValue() )
|
|
|
|
m_layers->ImportSettingsFrom( dummyBoard );
|
|
|
|
if( importDlg.m_TextAndGraphicsOpt->GetValue() )
|
|
|
|
m_textAndGraphics->ImportSettingsFrom( dummyBoard );
|
|
|
|
if( importDlg.m_ConstraintsOpt->GetValue() )
|
|
|
|
m_constraints->ImportSettingsFrom( dummyBoard );
|
|
|
|
if( importDlg.m_NetclassesOpt->GetValue() )
|
|
|
|
m_netclasses->ImportSettingsFrom( dummyBoard );
|
2019-03-07 04:55:14 +00:00
|
|
|
if( importDlg.m_TracksAndViasOpt->GetValue() )
|
|
|
|
m_tracksAndVias->ImportSettingsFrom( dummyBoard );
|
2018-04-28 15:22:25 +00:00
|
|
|
if( importDlg.m_MaskAndPasteOpt->GetValue() )
|
|
|
|
m_maskAndPaste->ImportSettingsFrom( dummyBoard );
|
|
|
|
|
2019-07-27 19:09:43 +00:00
|
|
|
// If layers options are imported, import also the stackup
|
|
|
|
// layers options and stackup are linked, so they cannot be imported
|
|
|
|
// separately, and stackup can be imported only after layers options
|
|
|
|
//
|
|
|
|
// Note also currently only the list of enabled layers can be imported, because
|
|
|
|
// we import settings from a .pro project file, not the settings inside
|
|
|
|
// a board, and info only living in the board is not imported.
|
|
|
|
if( importDlg.m_LayersOpt->GetValue() )
|
|
|
|
m_physicalStackup->ImportSettingsFrom( dummyBoard );
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
if( importDlg.m_SeveritiesOpt->GetValue() )
|
|
|
|
m_severities->ImportSettingsFrom( dummyBoard->GetDesignSettings().m_DRCSeverities );
|
|
|
|
|
2018-04-28 15:22:25 +00:00
|
|
|
delete dummyBoard;
|
|
|
|
delete cfg;
|
|
|
|
}
|