2020-03-10 18:46:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 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 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 <sch_edit_frame.h>
|
|
|
|
#include <kiface_i.h>
|
|
|
|
#include <dialog_sch_import_settings.h>
|
|
|
|
#include <panel_setup_severities.h>
|
|
|
|
#include <panel_setup_formatting.h>
|
2020-03-11 21:43:02 +00:00
|
|
|
#include <panel_setup_pinmap.h>
|
2020-03-13 09:53:44 +00:00
|
|
|
#include <eeschema_config.h>
|
2020-03-16 11:05:01 +00:00
|
|
|
#include <erc_item.h>
|
2020-03-26 11:02:59 +00:00
|
|
|
#include <panel_text_variables.h>
|
2020-03-10 18:46:57 +00:00
|
|
|
#include "dialog_schematic_setup.h"
|
|
|
|
#include "panel_eeschema_template_fieldnames.h"
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_SCHEMATIC_SETUP::DIALOG_SCHEMATIC_SETUP( SCH_EDIT_FRAME* aFrame ) :
|
|
|
|
PAGED_DIALOG( aFrame, _( "Schematic Setup" ),
|
|
|
|
_( "Import Settings from Another Project..." ) ),
|
|
|
|
m_frame( aFrame ),
|
|
|
|
m_severities( nullptr )
|
|
|
|
{
|
|
|
|
m_formatting = new PANEL_SETUP_FORMATTING( this, aFrame );
|
|
|
|
m_fieldNameTemplates = new PANEL_EESCHEMA_TEMPLATE_FIELDNAMES( aFrame, this, false );
|
2020-03-11 21:43:02 +00:00
|
|
|
m_pinMap = new PANEL_SETUP_PINMAP( this, aFrame );
|
2020-03-16 11:05:01 +00:00
|
|
|
|
|
|
|
ERC_ITEM dummyItem;
|
|
|
|
m_severities = new PANEL_SETUP_SEVERITIES( this, dummyItem, g_ErcSettings->m_Severities,
|
2020-03-10 18:46:57 +00:00
|
|
|
ERCE_FIRST, ERCE_LAST );
|
2020-03-26 11:02:59 +00:00
|
|
|
|
|
|
|
m_textVars = new PANEL_TEXT_VARIABLES( this, &Prj() );
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
/*
|
|
|
|
* WARNING: If you change page names you MUST update calls to DoShowSchematicSetupDialog().
|
|
|
|
*/
|
|
|
|
|
|
|
|
m_treebook->AddPage( new wxPanel( this ), _( "General" ) );
|
|
|
|
m_treebook->AddSubPage( m_formatting, _( "Formatting" ) );
|
|
|
|
m_treebook->AddSubPage( m_fieldNameTemplates, _( "Field Name Templates" ) );
|
|
|
|
|
|
|
|
m_treebook->AddPage( new wxPanel( this ), _( "Electrical Rules" ) );
|
2020-03-11 21:43:02 +00:00
|
|
|
m_treebook->AddSubPage( m_pinMap, _( "Pin Map" ) );
|
2020-03-10 18:46:57 +00:00
|
|
|
m_treebook->AddSubPage( m_severities, _( "Violation Severity" ) );
|
|
|
|
|
2020-03-26 11:02:59 +00:00
|
|
|
m_treebook->AddPage( new wxPanel( this ), _( "Project" ) );
|
|
|
|
m_treebook->AddSubPage( m_textVars, _( "Text Variables" ) );
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
// Connect Events
|
|
|
|
m_treebook->Connect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
|
|
|
wxBookCtrlEventHandler( DIALOG_SCHEMATIC_SETUP::OnPageChange ), NULL, this );
|
|
|
|
|
|
|
|
FinishDialogSettings();
|
2020-03-26 11:02:59 +00:00
|
|
|
|
2020-04-03 17:01:01 +00:00
|
|
|
for( size_t i = 0; i < m_treebook->GetPageCount(); ++i )
|
2020-03-26 11:02:59 +00:00
|
|
|
m_macHack.push_back( true );
|
2020-03-10 18:46:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG_SCHEMATIC_SETUP::~DIALOG_SCHEMATIC_SETUP()
|
|
|
|
{
|
|
|
|
m_treebook->Disconnect( wxEVT_TREEBOOK_PAGE_CHANGED,
|
|
|
|
wxBookCtrlEventHandler( DIALOG_SCHEMATIC_SETUP::OnPageChange ), NULL, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DIALOG_SCHEMATIC_SETUP::OnPageChange( wxBookCtrlEvent& event )
|
|
|
|
{
|
|
|
|
#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();
|
2020-03-10 18:46:57 +00:00
|
|
|
|
2020-03-26 11:02:59 +00:00
|
|
|
if( m_macHack[ page ] )
|
|
|
|
{
|
|
|
|
wxSize pageSize = m_treebook->GetPage( page )->GetSize();
|
|
|
|
pageSize.x -= 1;
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Run Import Settings... action
|
|
|
|
void DIALOG_SCHEMATIC_SETUP::OnAuxiliaryAction( wxCommandEvent& event )
|
|
|
|
{
|
|
|
|
DIALOG_SCH_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 );
|
|
|
|
|
2020-03-13 09:53:44 +00:00
|
|
|
if( importDlg.m_formattingOpt->GetValue() )
|
|
|
|
{
|
|
|
|
std::vector<PARAM_CFG*> params;
|
|
|
|
m_frame->AddFormattingParameters( params );
|
|
|
|
|
|
|
|
wxConfigLoadParams( cfg, params, GROUP_SCH_EDIT );
|
|
|
|
m_formatting->TransferDataToWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
if( importDlg.m_fieldNameTemplatesOpt->GetValue() )
|
|
|
|
{
|
|
|
|
TEMPLATES templateMgr;
|
|
|
|
PARAM_CFG_FIELDNAMES param( &templateMgr );
|
|
|
|
param.ReadParam( cfg );
|
|
|
|
|
|
|
|
m_fieldNameTemplates->ImportSettingsFrom( &templateMgr );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( importDlg.m_pinMapOpt->GetValue() )
|
|
|
|
{
|
|
|
|
// JEY TODO
|
|
|
|
}
|
|
|
|
|
2020-03-10 18:46:57 +00:00
|
|
|
if( importDlg.m_SeveritiesOpt->GetValue() )
|
|
|
|
{
|
|
|
|
ERC_SETTINGS settings;
|
|
|
|
settings.LoadDefaults();
|
2020-03-13 09:53:44 +00:00
|
|
|
wxConfigLoadParams( cfg, settings.GetProjectFileParameters(), GROUP_SCH_EDIT );
|
2020-03-10 18:46:57 +00:00
|
|
|
|
|
|
|
m_severities->ImportSettingsFrom( settings.m_Severities );
|
|
|
|
}
|
|
|
|
|
|
|
|
delete cfg;
|
|
|
|
}
|