21#include <wx/choicdlg.h>
22#include <wx/filedlg.h>
38 const wxSize& size,
long style,
const wxString&
name ) :
40 m_RegulatorListChanged( false )
53 GetSizer()->SetSizeHints(
this );
105 m_RegulFormula->SetLabel( wxT(
"Vout = Vref * (R1 + R2) / R1 + Iadj * R2" ) );
110 GetSizer()->Layout();
137 value.Printf( wxT(
"%g" ), item->
m_Vref );
139 value.Printf( wxT(
"%g" ), item->
m_Iadj );
154 wildcard.Printf(
_(
"PCB Calculator data file" ) + wxT(
" (*.%s)|*.%s" ),
157 wxFileDialog dlg(
this,
_(
"Select PCB Calculator Data File" ), wxEmptyString, fullfilename,
158 wildcard, wxFD_OPEN );
160 if( dlg.ShowModal() == wxID_CANCEL )
163 fullfilename = dlg.GetPath();
172 if( wxMessageBox(
_(
"Do you want to load this file and replace current regulator list?" ) )
189 msg.Printf(
_(
"Unable to read data file '%s'." ), fullfilename );
199 if( dlg.ShowModal() != wxID_OK )
217 wxMessageBox(
_(
"This regulator is already in list. Aborted" ) );
228 if( item ==
nullptr )
235 if( dlg.ShowModal() != wxID_OK )
249 wxString
name = wxGetSingleChoice(
_(
"Remove Regulator" ), wxEmptyString,
284 wxCommandEvent event;
307 wxMessageBox( wxT(
"Selection error" ) );
311 double r1, r2, vref, vout;
332 if( vout < vref &&
id != 2 )
344 if( ( r1 < 0 &&
id != 0 ) || ( r2 <= 0 &&
id != 1 ) )
363 r1 = vref * r2 / ( vout - vref - ( r2 * iadj ) );
367 r2 = ( vout - vref ) / ( iadj + ( vref / r1 ) );
371 vout = vref * ( r1 + r2 ) / r1;
380 case 0: r1 = ( vout / vref - 1 ) * r2;
break;
381 case 1: r2 = r1 / ( vout / vref - 1 );
break;
382 case 2: vout = vref * ( r1 + r2 ) / r2;
break;
387 txt.Printf( wxT(
"%g" ), r1 / r1scale );
389 txt.Printf( wxT(
"%g" ), r2 / r2scale );
391 txt.Printf( wxT(
"%g" ), vref );
393 txt.Printf( wxT(
"%g" ), vout );
412 for(
int ii = 0; ii < 3; ii++ )
414 if( regprms[ii]->GetValue() )
438 for(
int ii = 0; ii < 3; ii++ )
457 for(
int ii = 0; ii < 3; ii++ )
459 if( regprms[ii]->GetValue() )
471 return wxEmptyString;
475 return fn.GetFullPath();
481 if( aFilename.IsEmpty() )
487 wxFileName fn( aFilename );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Class PANEL_REGULATOR_BASE.
wxStaticText * m_RegulFormula
wxButton * m_buttonEditItem
wxStaticText * m_RegulMessage
wxButton * m_buttonRemoveItem
wxTextCtrl * m_RegulR2Value
wxStaticText * m_IadjUnitLabel
wxTextCtrl * m_RegulVrefValue
wxChoice * m_choiceRegType
wxTextCtrl * m_RegulVoutValue
wxTextCtrl * m_regulators_fileNameCtrl
wxRadioButton * m_rbRegulVout
wxStaticBitmap * m_bitmapRegul4pins
wxChoice * m_choiceRegulatorSelector
wxStaticBitmap * m_bitmapRegul3pins
wxTextCtrl * m_RegulR1Value
wxRadioButton * m_rbRegulR2
wxTextCtrl * m_RegulIadjValue
wxRadioButton * m_rbRegulR1
void OnEditRegulator(wxCommandEvent &event) override
bool m_RegulatorListChanged
void OnRegulatorSelection(wxCommandEvent &event) override
void OnRegulatorResetButtonClick(wxCommandEvent &event) override
REGULATOR_LIST m_RegulatorList
void ThemeChanged() override
Update UI elements of the panel when the theme changes to ensure the images and fonts/colors are appr...
void Regulators_WriteConfig(PCB_CALCULATOR_SETTINGS *aCfg)
Write regulators parameters in configuration.
const wxString GetDataFilename()
void OnRegulatorCalcButtonClick(wxCommandEvent &event) override
void OnDataFileSelection(wxCommandEvent &event) override
void SetDataFilename(const wxString &aFilename)
Initialize the full filename of the selected pcb_calculator data file force the standard extension of...
void SelectLastSelectedRegulator()
If m_lastSelectedRegulatorName is empty, just calls RegulatorPageUpdate()
void OnRegulTypeSelection(wxCommandEvent &event) override
void SaveSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Save the settings from the panel.
void OnRemoveRegulator(wxCommandEvent &event) override
wxString m_lastSelectedRegulatorName
void OnAddRegulator(wxCommandEvent &event) override
PANEL_REGULATOR(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
void LoadSettings(PCB_CALCULATOR_SETTINGS *aCfg) override
Load the settings into the panel.
void RegulatorPageUpdate()
Update the regulator page dialog display.
void Remove(const wxString &aRegName)
wxArrayString GetRegList() const
void Replace(REGULATOR_DATA *aItem)
Replace an old REGULATOR_DATA by a new one The old one is deleted the 2 items must have the same name...
void Add(REGULATOR_DATA *aItem)
REGULATOR_DATA * GetReg(const wxString &aName)
std::vector< REGULATOR_DATA * > m_List
Contains structures for storage of regulator data.
double DoubleFromString(const wxString &TextValue)
double DoubleFromString(const wxString &TextValue)
const wxString DataFileNameExt
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
wxString selected_regulator