From 3a88992f8e512f3bc4b1909f92df5dacbda6d6bc Mon Sep 17 00:00:00 2001 From: Marek Roszko Date: Mon, 12 Oct 2020 21:17:40 -0400 Subject: [PATCH] Split out the regulator dialog into unique file and fix filenames --- pcb_calculator/CMakeLists.txt | 3 +- pcb_calculator/class_regulator_data.h | 17 +- pcb_calculator/colorcode.cpp | 4 +- .../dialogs/dialog_regulator_form.cpp | 96 ++++++++++++ .../dialogs/dialog_regulator_form.h | 93 +++++++++++ ...ase.cpp => dialog_regulator_form_base.cpp} | 16 +- ...ase.fbp => dialog_regulator_form_base.fbp} | 72 ++++----- ...ta_base.h => dialog_regulator_form_base.h} | 10 +- pcb_calculator/regulators_funct.cpp | 146 +++--------------- 9 files changed, 271 insertions(+), 186 deletions(-) create mode 100644 pcb_calculator/dialogs/dialog_regulator_form.cpp create mode 100644 pcb_calculator/dialogs/dialog_regulator_form.h rename pcb_calculator/dialogs/{dialog_regulator_data_base.cpp => dialog_regulator_form_base.cpp} (86%) rename pcb_calculator/dialogs/{dialog_regulator_data_base.fbp => dialog_regulator_form_base.fbp} (96%) rename pcb_calculator/dialogs/{dialog_regulator_data_base.h => dialog_regulator_form_base.h} (77%) diff --git a/pcb_calculator/CMakeLists.txt b/pcb_calculator/CMakeLists.txt index 544fe67bd4..8b13f0d76a 100644 --- a/pcb_calculator/CMakeLists.txt +++ b/pcb_calculator/CMakeLists.txt @@ -35,7 +35,8 @@ set( PCB_CALCULATOR_SRCS transline_dlg_funct.cpp attenuators/attenuator_classes.cpp dialogs/pcb_calculator_frame_base.cpp - dialogs/dialog_regulator_data_base.cpp + dialogs/dialog_regulator_form_base.cpp + dialogs/dialog_regulator_form.cpp ../common/env_vars.cpp # needed on MSW to avoid a link issue (a symbol not found) ) diff --git a/pcb_calculator/class_regulator_data.h b/pcb_calculator/class_regulator_data.h index 711ab337e7..88d5a8d0cf 100644 --- a/pcb_calculator/class_regulator_data.h +++ b/pcb_calculator/class_regulator_data.h @@ -1,15 +1,8 @@ -#ifndef CLASS_REGULATOR_DATA_H -#define CLASS_REGULATOR_DATA_H - - -/** - * @file class_regulator_data.h - */ /* * 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 change_log.txt for contributors. + * Copyright (C) 1992-2020 Kicad Developers, see change_log.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 @@ -29,6 +22,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ +/** + * @file class_regulator_data.h + * Contains structures for storage of regulator data + */ + +#ifndef CLASS_REGULATOR_DATA_H +#define CLASS_REGULATOR_DATA_H + #include #include diff --git a/pcb_calculator/colorcode.cpp b/pcb_calculator/colorcode.cpp index 6e7ece0bf3..b1192aefbd 100644 --- a/pcb_calculator/colorcode.cpp +++ b/pcb_calculator/colorcode.cpp @@ -28,6 +28,7 @@ void PCB_CALCULATOR_FRAME::OnToleranceSelection( wxCommandEvent& event ) ToleranceSelection( event.GetSelection() ); } + void PCB_CALCULATOR_FRAME::ToleranceSelection( int aSelection ) { /* For tolerance = 5 or 10 %, there are 3 bands for the value @@ -56,5 +57,4 @@ void PCB_CALCULATOR_FRAME::ToleranceSelection( int aSelection ) m_panelColorCode->GetSizer()->Layout(); m_panelColorCode->Refresh(); } -} - +} \ No newline at end of file diff --git a/pcb_calculator/dialogs/dialog_regulator_form.cpp b/pcb_calculator/dialogs/dialog_regulator_form.cpp new file mode 100644 index 0000000000..19700d1312 --- /dev/null +++ b/pcb_calculator/dialogs/dialog_regulator_form.cpp @@ -0,0 +1,96 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 1992-2011 jean-pierre.charras + * 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 + * 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 . + */ + +#include "class_regulator_data.h" +#include "pcb_calculator_frame.h" +#include "dialog_regulator_form.h" + + +extern double DoubleFromString( const wxString& TextValue ); + + +void DIALOG_REGULATOR_FORM::OnOKClick( wxCommandEvent& event ) +{ + if( !IsOK() ) + { + wxMessageBox( _( "Bad or missing parameters!" ) ); + return; + } + + EndModal( wxID_OK ); +} + + +bool DIALOG_REGULATOR_FORM::IsOK() +{ + bool success = true; + + if( m_textCtrlName->GetValue().IsEmpty() ) + success = false; + if( m_textCtrlVref->GetValue().IsEmpty() ) + success = false; + else + { + double vref = DoubleFromString( m_textCtrlVref->GetValue() ); + if( fabs( vref ) < 0.01 ) + success = false; + } + if( m_choiceRegType->GetSelection() == 1 ) + { + if( m_RegulIadjValue->GetValue().IsEmpty() ) + success = false; + } + + return success; +} + + +void DIALOG_REGULATOR_FORM::UpdateDialog() +{ + bool enbl = m_choiceRegType->GetSelection() == 1; + m_RegulIadjValue->Enable( enbl ); +} + + +void DIALOG_REGULATOR_FORM::CopyRegulatorDataToDialog( REGULATOR_DATA* aItem ) +{ + m_textCtrlName->SetValue( aItem->m_Name ); + wxString value; + value.Printf( wxT( "%g" ), aItem->m_Vref ); + m_textCtrlVref->SetValue( value ); + value.Printf( wxT( "%g" ), aItem->m_Iadj ); + m_RegulIadjValue->SetValue( value ); + m_choiceRegType->SetSelection( aItem->m_Type ); + UpdateDialog(); +} + + +REGULATOR_DATA* DIALOG_REGULATOR_FORM::BuildRegulatorFromData() +{ + double vref = DoubleFromString( m_textCtrlVref->GetValue() ); + double iadj = DoubleFromString( m_RegulIadjValue->GetValue() ); + int type = m_choiceRegType->GetSelection(); + + if( type != 1 ) + iadj = 0.0; + + REGULATOR_DATA* item = new REGULATOR_DATA( m_textCtrlName->GetValue(), vref, type, iadj ); + return item; +} \ No newline at end of file diff --git a/pcb_calculator/dialogs/dialog_regulator_form.h b/pcb_calculator/dialogs/dialog_regulator_form.h new file mode 100644 index 0000000000..92ec821282 --- /dev/null +++ b/pcb_calculator/dialogs/dialog_regulator_form.h @@ -0,0 +1,93 @@ +/* + * This program source code file is part of KICAD, a free EDA CAD application. + * + * Copyright (C) 1992-2011 jean-pierre.charras + * 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 + * 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 . + */ + +/** + * @file dialog_regulator_form.h + * Subclass of DIALOG_REGULATOR_FORM_BASE, which is generated by wxFormBuilder. + * + * This dialog is used to add / edit regulators to the list on the + * regulator tab of the pcb calculator + */ + +#ifndef DIALOG_REGULATOR_FORM_H +#define DIALOG_REGULATOR_FORM_H + +#include "dialog_regulator_form_base.h" + +class PCB_CALCULATOR_FRAME; +class REGULATOR_DATA; + +class DIALOG_REGULATOR_FORM : public DIALOG_REGULATOR_FORM_BASE +{ +public: + DIALOG_REGULATOR_FORM( PCB_CALCULATOR_FRAME* parent, const wxString& aRegName ) + : DIALOG_REGULATOR_FORM_BASE( parent ) + { + m_textCtrlName->SetValue( aRegName ); + m_textCtrlName->Enable( aRegName.IsEmpty() ); + UpdateDialog(); + + m_sdbSizerOK->SetDefault(); + + // Now all widgets have the size fixed, call FinishDialogSettings + FinishDialogSettings(); + } + + ~DIALOG_REGULATOR_FORM(){}; + + // Event called functions: + void OnOKClick( wxCommandEvent& event ) override; + + /** + * Function IsOK() + * @return true if regulator parameters are acceptable + */ + bool IsOK(); + + /** + * Function CopyRegulatorDataToDialog + * Transfert data from dialog to aItem + * @param aItem = a pointer to the REGULATOR_DATA + */ + void CopyRegulatorDataToDialog( REGULATOR_DATA* aItem ); + + /** + * Function BuildRegulatorFromData + * Creates a new REGULATOR_DATA from dialog + * @return a pointer to the new REGULATOR_DATA + */ + REGULATOR_DATA* BuildRegulatorFromData(); + + /** + * Enable/disable Iadj realted widgets, according to + * the regulator type + */ + void UpdateDialog(); + + /** + * called when the current regulator type is changed + */ + void OnRegTypeSelection( wxCommandEvent& event ) override + { + UpdateDialog(); + } +}; + +#endif // DIALOG_REGULATOR_FORM_H \ No newline at end of file diff --git a/pcb_calculator/dialogs/dialog_regulator_data_base.cpp b/pcb_calculator/dialogs/dialog_regulator_form_base.cpp similarity index 86% rename from pcb_calculator/dialogs/dialog_regulator_data_base.cpp rename to pcb_calculator/dialogs/dialog_regulator_form_base.cpp index 55a57e2ac0..bcbfe1ee2e 100644 --- a/pcb_calculator/dialogs/dialog_regulator_data_base.cpp +++ b/pcb_calculator/dialogs/dialog_regulator_form_base.cpp @@ -1,15 +1,15 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version v3.8.0) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "dialog_regulator_data_base.h" +#include "dialog_regulator_form_base.h" /////////////////////////////////////////////////////////////////////////// -DIALOG_EDITOR_DATA_BASE::DIALOG_EDITOR_DATA_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +DIALOG_REGULATOR_FORM_BASE::DIALOG_REGULATOR_FORM_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); @@ -95,14 +95,14 @@ DIALOG_EDITOR_DATA_BASE::DIALOG_EDITOR_DATA_BASE( wxWindow* parent, wxWindowID i this->Centre( wxBOTH ); // Connect Events - m_choiceRegType->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_EDITOR_DATA_BASE::OnRegTypeSelection ), NULL, this ); - m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDITOR_DATA_BASE::OnOKClick ), NULL, this ); + m_choiceRegType->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnRegTypeSelection ), NULL, this ); + m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnOKClick ), NULL, this ); } -DIALOG_EDITOR_DATA_BASE::~DIALOG_EDITOR_DATA_BASE() +DIALOG_REGULATOR_FORM_BASE::~DIALOG_REGULATOR_FORM_BASE() { // Disconnect Events - m_choiceRegType->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_EDITOR_DATA_BASE::OnRegTypeSelection ), NULL, this ); - m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EDITOR_DATA_BASE::OnOKClick ), NULL, this ); + m_choiceRegType->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnRegTypeSelection ), NULL, this ); + m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_REGULATOR_FORM_BASE::OnOKClick ), NULL, this ); } diff --git a/pcb_calculator/dialogs/dialog_regulator_data_base.fbp b/pcb_calculator/dialogs/dialog_regulator_form_base.fbp similarity index 96% rename from pcb_calculator/dialogs/dialog_regulator_data_base.fbp rename to pcb_calculator/dialogs/dialog_regulator_form_base.fbp index b9d4a978cc..8c8aeca576 100644 --- a/pcb_calculator/dialogs/dialog_regulator_data_base.fbp +++ b/pcb_calculator/dialogs/dialog_regulator_form_base.fbp @@ -11,12 +11,12 @@ res UTF-8 connect - dialog_regulator_data_base + dialog_regulator_form_base 1000 none 1 - dialog_regulator_data + dialog_regulator_form_base . @@ -43,7 +43,7 @@ wxID_ANY -1,-1 - DIALOG_EDITOR_DATA_BASE + DIALOG_REGULATOR_FORM_BASE -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER @@ -53,16 +53,16 @@ - + 300,-1 bSizerMain wxVERTICAL none - + 5 wxEXPAND 0 - + 3 wxHORIZONTAL 1 @@ -74,11 +74,11 @@ none 4 0 - + 5 wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -135,11 +135,11 @@ -1 - + 5 wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND 0 - + 1 1 1 @@ -199,21 +199,21 @@ - + 5 wxEXPAND 1 - + 0 protected 0 - + 5 wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -270,11 +270,11 @@ -1 - + 5 wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND 0 - + 1 1 1 @@ -334,11 +334,11 @@ - + 5 wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -395,11 +395,11 @@ -1 - + 5 wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -456,11 +456,11 @@ -1 - + 5 wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND 0 - + 1 1 1 @@ -521,21 +521,21 @@ OnRegTypeSelection - + 5 wxEXPAND 1 - + 0 protected 0 - + 5 wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -592,11 +592,11 @@ -1 - + 5 wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND 0 - + 1 1 1 @@ -656,11 +656,11 @@ - + 5 wxALIGN_CENTER_VERTICAL|wxALL 0 - + 1 1 1 @@ -719,21 +719,21 @@ - + 5 wxEXPAND 1 - + 0 protected 0 - + 5 wxEXPAND 0 - + 1 1 1 @@ -787,11 +787,11 @@ - + 5 wxALL|wxEXPAND 0 - + 0 1 0 diff --git a/pcb_calculator/dialogs/dialog_regulator_data_base.h b/pcb_calculator/dialogs/dialog_regulator_form_base.h similarity index 77% rename from pcb_calculator/dialogs/dialog_regulator_data_base.h rename to pcb_calculator/dialogs/dialog_regulator_form_base.h index 5ae12568cd..f4ad624639 100644 --- a/pcb_calculator/dialogs/dialog_regulator_data_base.h +++ b/pcb_calculator/dialogs/dialog_regulator_form_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version v3.8.0) +// C++ code generated with wxFormBuilder (version Oct 26 2018) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -28,9 +28,9 @@ /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_EDITOR_DATA_BASE +/// Class DIALOG_REGULATOR_FORM_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_EDITOR_DATA_BASE : public DIALOG_SHIM +class DIALOG_REGULATOR_FORM_BASE : public DIALOG_SHIM { private: @@ -57,8 +57,8 @@ class DIALOG_EDITOR_DATA_BASE : public DIALOG_SHIM public: - DIALOG_EDITOR_DATA_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Regulator Parameters"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); - ~DIALOG_EDITOR_DATA_BASE(); + DIALOG_REGULATOR_FORM_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Regulator Parameters"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); + ~DIALOG_REGULATOR_FORM_BASE(); }; diff --git a/pcb_calculator/regulators_funct.cpp b/pcb_calculator/regulators_funct.cpp index a84203253f..8c52ab25a2 100644 --- a/pcb_calculator/regulators_funct.cpp +++ b/pcb_calculator/regulators_funct.cpp @@ -1,6 +1,3 @@ -/** - * @file regulators_funct.cpp - */ /* * This program source code file is part of KICAD, a free EDA CAD application. * @@ -20,143 +17,31 @@ * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ + +/** + * @file regulators_funct.cpp + * Contains the partial functions of PCB_CALCULATOR_FRAME related to regulators + */ + #include #include #include "class_regulator_data.h" -#include "dialog_regulator_data_base.h" #include "pcb_calculator_frame.h" #include "pcb_calculator_settings.h" +#include "dialogs/dialog_regulator_form.h" + extern double DoubleFromString( const wxString& TextValue ); -class DIALOG_EDITOR_DATA: public DIALOG_EDITOR_DATA_BASE -{ -public: - DIALOG_EDITOR_DATA( PCB_CALCULATOR_FRAME * parent, const wxString & aRegName ) - : DIALOG_EDITOR_DATA_BASE( parent ) - { - m_textCtrlName->SetValue( aRegName ); - m_textCtrlName->Enable( aRegName.IsEmpty() ); - UpdateDialog(); - - m_sdbSizerOK->SetDefault(); - - // Now all widgets have the size fixed, call FinishDialogSettings - FinishDialogSettings(); - } - - ~DIALOG_EDITOR_DATA() {}; - - // Event called functions: - void OnOKClick( wxCommandEvent& event ) override; - - /** - * Function IsOK() - * @return true if regulator parameters are acceptable - */ - bool IsOK(); - - /** - * Function CopyRegulatorDataToDialog - * Transfert data from dialog to aItem - * @param aItem = a pointer to the REGULATOR_DATA - */ - void CopyRegulatorDataToDialog( REGULATOR_DATA * aItem ); - - /** - * Function BuildRegulatorFromData - * Creates a new REGULATOR_DATA from dialog - * @return a pointer to the new REGULATOR_DATA - */ - REGULATOR_DATA * BuildRegulatorFromData(); - - /** - * Enable/disable Iadj realted widgets, according to - * the regulator type - */ - void UpdateDialog() - { - bool enbl = m_choiceRegType->GetSelection() == 1; - m_RegulIadjValue->Enable( enbl ); - } - - /** - * called when the current regulator type is changed - */ - void OnRegTypeSelection( wxCommandEvent& event ) override - { - UpdateDialog(); - } -}; - - -void DIALOG_EDITOR_DATA::OnOKClick( wxCommandEvent& event ) -{ - if( !IsOK() ) - { - wxMessageBox( _("Bad or missing parameters!") ); - return; - } - - EndModal( wxID_OK ); -} - -bool DIALOG_EDITOR_DATA::IsOK() -{ - bool success = true; - - if( m_textCtrlName->GetValue().IsEmpty() ) - success = false; - if( m_textCtrlVref->GetValue().IsEmpty() ) - success = false; - else - { - double vref = DoubleFromString( m_textCtrlVref->GetValue() ); - if( fabs(vref) < 0.01 ) - success = false; - } - if( m_choiceRegType->GetSelection() == 1 ) - { - if( m_RegulIadjValue->GetValue().IsEmpty() ) - success = false; - } - - return success; -} - -void DIALOG_EDITOR_DATA::CopyRegulatorDataToDialog( REGULATOR_DATA * aItem ) -{ - m_textCtrlName->SetValue( aItem->m_Name ); - wxString value; - value.Printf( wxT("%g"), aItem->m_Vref ); - m_textCtrlVref->SetValue( value ); - value.Printf( wxT("%g"), aItem->m_Iadj ); - m_RegulIadjValue->SetValue( value ); - m_choiceRegType->SetSelection( aItem->m_Type ); - UpdateDialog(); -} - -REGULATOR_DATA * DIALOG_EDITOR_DATA::BuildRegulatorFromData() -{ - double vref = DoubleFromString( m_textCtrlVref->GetValue() ); - double iadj = DoubleFromString( m_RegulIadjValue->GetValue() ); - int type = m_choiceRegType->GetSelection(); - - if( type != 1 ) - iadj = 0.0; - - REGULATOR_DATA * item = new REGULATOR_DATA( m_textCtrlName->GetValue(), - vref, type, iadj ); - return item; -} void PCB_CALCULATOR_FRAME::OnRegulatorCalcButtonClick( wxCommandEvent& event ) { RegulatorsSolve(); } + void PCB_CALCULATOR_FRAME::OnRegulatorResetButtonClick( wxCommandEvent& event ) { m_RegulR1Value->SetValue( wxT( "10" ) ); @@ -170,6 +55,7 @@ void PCB_CALCULATOR_FRAME::OnRegulatorResetButtonClick( wxCommandEvent& event ) RegulatorPageUpdate(); } + void PCB_CALCULATOR_FRAME::RegulatorPageUpdate() { switch( m_choiceRegType->GetSelection() ) @@ -200,11 +86,13 @@ void PCB_CALCULATOR_FRAME::RegulatorPageUpdate() m_panelRegulators->Refresh(); } + void PCB_CALCULATOR_FRAME::OnRegulTypeSelection( wxCommandEvent& event ) { RegulatorPageUpdate(); } + void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event ) { wxString name = m_choiceRegulatorSelector->GetStringSelection(); @@ -225,6 +113,7 @@ void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event ) RegulatorPageUpdate(); } + /* * Called when ckicking on button Browse: * Select a new data file, and load it on request @@ -274,9 +163,10 @@ void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxCommandEvent& event ) } } + void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event ) { - DIALOG_EDITOR_DATA dlg( this, wxEmptyString ); + DIALOG_REGULATOR_FORM dlg( this, wxEmptyString ); if( dlg.ShowModal() != wxID_OK ) return; if( !dlg.IsOK() ) @@ -305,6 +195,7 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event ) } } + void PCB_CALCULATOR_FRAME::OnEditRegulator( wxCommandEvent& event ) { wxString name = m_choiceRegulatorSelector->GetStringSelection(); @@ -312,7 +203,7 @@ void PCB_CALCULATOR_FRAME::OnEditRegulator( wxCommandEvent& event ) if( item == NULL ) return; - DIALOG_EDITOR_DATA dlg( this, name ); + DIALOG_REGULATOR_FORM dlg( this, name ); dlg.CopyRegulatorDataToDialog( item ); if( dlg.ShowModal() != wxID_OK ) @@ -326,6 +217,7 @@ void PCB_CALCULATOR_FRAME::OnEditRegulator( wxCommandEvent& event ) SelectLastSelectedRegulator(); } + void PCB_CALCULATOR_FRAME::OnRemoveRegulator( wxCommandEvent& event ) { wxString name = wxGetSingleChoice( _("Remove Regulator"), wxEmptyString, @@ -343,6 +235,7 @@ void PCB_CALCULATOR_FRAME::OnRemoveRegulator( wxCommandEvent& event ) SelectLastSelectedRegulator(); } + void PCB_CALCULATOR_FRAME::SelectLastSelectedRegulator() { // Find last selected in regulator list: @@ -362,6 +255,7 @@ void PCB_CALCULATOR_FRAME::SelectLastSelectedRegulator() OnRegulatorSelection( event ); } + // Calculate a value from the 3 other values // Vref is given by the regulator properties, so // we can calculate only R1, R2 or Vout