Pcb_calculator: add missing code to store its full config.
This commit is contained in:
parent
3673c23696
commit
e3d9d5fa88
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2015 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-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
|
||||
|
@ -33,6 +33,8 @@
|
|||
|
||||
extern const wxString PcbCalcDataFileExt;
|
||||
|
||||
class PCB_CALCULATOR_SETTINGS;
|
||||
|
||||
/* Class PCB_CALCULATOR_FRAME_BASE
|
||||
This is the main frame for this application
|
||||
*/
|
||||
|
@ -109,7 +111,7 @@ private:
|
|||
|
||||
/**
|
||||
* Function TW_WriteConfig
|
||||
* Write Track width prameters in config
|
||||
* Write Track width parameters in config
|
||||
*/
|
||||
void TW_WriteConfig();
|
||||
|
||||
|
@ -187,7 +189,7 @@ private:
|
|||
|
||||
/**
|
||||
* Function VS_WriteConfig
|
||||
* Write Via Size prameters in config
|
||||
* Write Via Size parameters in config
|
||||
*/
|
||||
void VS_WriteConfig();
|
||||
|
||||
|
@ -339,6 +341,12 @@ private:
|
|||
|
||||
void RegulatorsSolve();
|
||||
|
||||
/**
|
||||
* Write regulators parameters in config
|
||||
* @param aCfg is the config settings
|
||||
*/
|
||||
void Regulators_WriteConfig( PCB_CALCULATOR_SETTINGS* aCfg );
|
||||
|
||||
public:
|
||||
// Read/write params values and results
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2015 jean-pierre.charras
|
||||
* Copyright (C) 1992-2015 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-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
|
||||
|
@ -25,6 +25,7 @@
|
|||
#include <UnitSelector.h>
|
||||
#include <bitmaps.h>
|
||||
#include <geometry/shape_poly_set.h>
|
||||
#include <kiface_i.h>
|
||||
|
||||
|
||||
// extension of pcb_calculator data filename:
|
||||
|
@ -135,7 +136,7 @@ void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event )
|
|||
wxString msg;
|
||||
msg.Printf( _("Unable to write file \"%s\"\n"\
|
||||
"Do you want to exit and abandon your change?"),
|
||||
GetDataFilename().c_str() );
|
||||
GetDataFilename() );
|
||||
|
||||
int opt = wxMessageBox( msg, _("Write Data File Error"),
|
||||
wxYES_NO | wxICON_ERROR );
|
||||
|
@ -156,7 +157,7 @@ void PCB_CALCULATOR_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|||
|
||||
EDA_BASE_FRAME::LoadSettings( aCfg );
|
||||
|
||||
auto cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( aCfg );
|
||||
PCB_CALCULATOR_SETTINGS* cfg = static_cast<PCB_CALCULATOR_SETTINGS*>( aCfg );
|
||||
|
||||
m_currTransLineType = static_cast<TRANSLINE_TYPE_ID>( cfg->m_TransLine.type );
|
||||
m_Notebook->ChangeSelection( cfg->m_LastPage );
|
||||
|
@ -200,39 +201,23 @@ void PCB_CALCULATOR_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
|||
|
||||
EDA_BASE_FRAME::SaveSettings( aCfg );
|
||||
|
||||
#if 0
|
||||
aCfg->Write( KEYWORD_TRANSLINE_SELECTION, (long) m_currTransLineType );
|
||||
aCfg->Write( KEYWORD_PAGE_SELECTION, m_Notebook->GetSelection() );
|
||||
aCfg->Write( KEYWORD_COLORCODE_SELECTION, m_rbToleranceSelection->GetSelection() );
|
||||
aCfg->Write( KEYWORD_ATTENUATORS_SELECTION, m_AttenuatorsSelection->GetSelection() );
|
||||
aCfg->Write( KEYWORD_BRDCLASS_SELECTION, m_BoardClassesUnitsSelector->GetSelection() );
|
||||
// Save current parameters values in config.
|
||||
auto cfg = dynamic_cast<PCB_CALCULATOR_SETTINGS*>( Kiface().KifaceSettings() );
|
||||
|
||||
aCfg->Write( KEYWORD_REGUL_R1, m_RegulR1Value->GetValue() );
|
||||
aCfg->Write( KEYWORD_REGUL_R2, m_RegulR2Value->GetValue() );
|
||||
aCfg->Write( KEYWORD_REGUL_VREF, m_RegulVrefValue->GetValue() );
|
||||
aCfg->Write( KEYWORD_REGUL_VOUT, m_RegulVoutValue->GetValue() );
|
||||
aCfg->Write( KEYWORD_DATAFILE_FILENAME, GetDataFilename() );
|
||||
aCfg->Write( KEYWORD_REGUL_SELECTED, m_lastSelectedRegulatorName );
|
||||
aCfg->Write( KEYWORD_REGUL_TYPE,
|
||||
m_choiceRegType->GetSelection() );
|
||||
wxRadioButton * regprms[3] =
|
||||
{ m_rbRegulR1, m_rbRegulR2, m_rbRegulVout
|
||||
};
|
||||
for( int ii = 0; ii < 3; ii++ )
|
||||
if( cfg )
|
||||
{
|
||||
if( regprms[ii]->GetValue() )
|
||||
{
|
||||
aCfg->Write( KEYWORD_REGUL_LAST_PARAM, ii );
|
||||
break;
|
||||
}
|
||||
cfg->m_LastPage = m_Notebook->GetSelection();
|
||||
cfg->m_TransLine.type = m_currTransLineType;
|
||||
cfg->m_Attenuators.type = m_AttenuatorsSelection->GetSelection();
|
||||
cfg->m_ColorCodeTolerance = m_rbToleranceSelection->GetSelection();
|
||||
cfg->m_BoardClassUnits = m_BoardClassesUnitsSelector->GetSelection();
|
||||
|
||||
cfg->m_Electrical.spacing_units = m_ElectricalSpacingUnitsSelector->GetSelection();
|
||||
cfg->m_Electrical.spacing_voltage = m_ElectricalSpacingVoltage->GetValue();
|
||||
|
||||
Regulators_WriteConfig( cfg );
|
||||
}
|
||||
|
||||
|
||||
aCfg->Write( KEYWORD_ELECTRICAL_SPACING_SELECTION,
|
||||
m_ElectricalSpacingUnitsSelector->GetSelection() );
|
||||
aCfg->Write( KEYWORD_ELECTRICAL_SPACING_VOLTAGE,
|
||||
m_ElectricalSpacingVoltage->GetValue() );
|
||||
#endif
|
||||
TW_WriteConfig();
|
||||
|
||||
VS_WriteConfig();
|
||||
|
|
|
@ -47,6 +47,8 @@ PCB_CALCULATOR_SETTINGS::PCB_CALCULATOR_SETTINGS() :
|
|||
|
||||
m_params.emplace_back( new PARAM<int>( "last_page", &m_LastPage, 0 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( "translines.type", &m_TransLine.type, 0 ) );
|
||||
|
||||
m_params.emplace_back( new PARAM<int>( "attenuators.type", &m_Attenuators.type, 0 ) );
|
||||
|
||||
const std::array<std::string, 4> att_names = { "att_pi", "att_tee",
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2011 jean-pierre.charras
|
||||
* Copyright (C) 1992-2011 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-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
|
||||
|
@ -26,6 +26,7 @@
|
|||
#include <pcb_calculator.h>
|
||||
#include <class_regulator_data.h>
|
||||
#include <dialog_regulator_data_base.h>
|
||||
#include <pcb_calculator_settings.h>
|
||||
|
||||
|
||||
extern double DoubleFromString( const wxString& TextValue );
|
||||
|
@ -473,3 +474,31 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve()
|
|||
|
||||
}
|
||||
|
||||
|
||||
void PCB_CALCULATOR_FRAME::Regulators_WriteConfig( PCB_CALCULATOR_SETTINGS* aCfg )
|
||||
{
|
||||
// Save current parameter values in config.
|
||||
aCfg->m_Regulators.r1 = m_RegulR1Value->GetValue();
|
||||
aCfg->m_Regulators.r2 = m_RegulR2Value->GetValue();
|
||||
aCfg->m_Regulators.vref = m_RegulVrefValue->GetValue();
|
||||
aCfg->m_Regulators.vout = m_RegulVoutValue->GetValue();
|
||||
aCfg->m_Regulators.data_file = GetDataFilename();
|
||||
aCfg->m_Regulators.selected_regulator = m_lastSelectedRegulatorName;
|
||||
aCfg->m_Regulators.type = m_choiceRegType->GetSelection();
|
||||
|
||||
// Store the parameter selection that was recently calculated (R1, R2 or Vout)
|
||||
wxRadioButton * regprms[3] =
|
||||
{
|
||||
m_rbRegulR1, m_rbRegulR2, m_rbRegulVout
|
||||
};
|
||||
|
||||
for( int ii = 0; ii < 3; ii++ )
|
||||
{
|
||||
if( regprms[ii]->GetValue() )
|
||||
{
|
||||
aCfg->m_Regulators.last_param = ii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -453,9 +453,6 @@ void PCB_CALCULATOR_FRAME::OnTranslineSelection( wxCommandEvent& event )
|
|||
m_Phys_prm1_Value->SetBackgroundColour( background );
|
||||
m_Phys_prm2_Value->SetBackgroundColour( background );
|
||||
m_Phys_prm3_Value->SetBackgroundColour( background );
|
||||
m_elec_prm1_label->SetBackgroundColour( background );
|
||||
m_elec_prm2_label->SetBackgroundColour( background );
|
||||
m_elec_prm3_label->SetBackgroundColour( background );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue