diff --git a/pcb_calculator/pcb_calculator.h b/pcb_calculator/pcb_calculator.h index d11c424334..742ae5a754 100644 --- a/pcb_calculator/pcb_calculator.h +++ b/pcb_calculator/pcb_calculator.h @@ -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 diff --git a/pcb_calculator/pcb_calculator_frame.cpp b/pcb_calculator/pcb_calculator_frame.cpp index e0f530603c..039f15df02 100644 --- a/pcb_calculator/pcb_calculator_frame.cpp +++ b/pcb_calculator/pcb_calculator_frame.cpp @@ -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 #include #include +#include // 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( aCfg ); + PCB_CALCULATOR_SETTINGS* cfg = static_cast( aCfg ); m_currTransLineType = static_cast( 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( 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(); diff --git a/pcb_calculator/pcb_calculator_settings.cpp b/pcb_calculator/pcb_calculator_settings.cpp index 4069b2b47c..79a728c028 100644 --- a/pcb_calculator/pcb_calculator_settings.cpp +++ b/pcb_calculator/pcb_calculator_settings.cpp @@ -47,6 +47,8 @@ PCB_CALCULATOR_SETTINGS::PCB_CALCULATOR_SETTINGS() : m_params.emplace_back( new PARAM( "last_page", &m_LastPage, 0 ) ); + m_params.emplace_back( new PARAM( "translines.type", &m_TransLine.type, 0 ) ); + m_params.emplace_back( new PARAM( "attenuators.type", &m_Attenuators.type, 0 ) ); const std::array att_names = { "att_pi", "att_tee", diff --git a/pcb_calculator/regulators_funct.cpp b/pcb_calculator/regulators_funct.cpp index f35d1a8042..55632aa398 100644 --- a/pcb_calculator/regulators_funct.cpp +++ b/pcb_calculator/regulators_funct.cpp @@ -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 #include #include +#include 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; + } + } + +} diff --git a/pcb_calculator/transline_dlg_funct.cpp b/pcb_calculator/transline_dlg_funct.cpp index 8405a7bc28..4908ef5fb8 100644 --- a/pcb_calculator/transline_dlg_funct.cpp +++ b/pcb_calculator/transline_dlg_funct.cpp @@ -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 ); }