Commit 70cf1891 authored by jean-pierre charras's avatar jean-pierre charras

pcb_calculator: fixes and enhancements (not finished)

parent 7ce97878
...@@ -127,6 +127,8 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow ...@@ -127,6 +127,8 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
m_labelVRef = new wxStaticText( m_panelRegulators, wxID_ANY, _("Vref"), wxDefaultPosition, wxDefaultSize, 0 ); m_labelVRef = new wxStaticText( m_panelRegulators, wxID_ANY, _("Vref"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelVRef->Wrap( -1 ); m_labelVRef->Wrap( -1 );
m_labelVRef->SetToolTip( _("The internal reference voltage of the regulator.\nShould not be 0.") );
fgSizerRegParams->Add( m_labelVRef, 0, wxALL, 5 ); fgSizerRegParams->Add( m_labelVRef, 0, wxALL, 5 );
m_RegulVrefValue = new wxTextCtrl( m_panelRegulators, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_RegulVrefValue = new wxTextCtrl( m_panelRegulators, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
...@@ -141,6 +143,8 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow ...@@ -141,6 +143,8 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
m_RegulIadjTitle = new wxStaticText( m_panelRegulators, wxID_ANY, _("Iadj"), wxDefaultPosition, wxDefaultSize, 0 ); m_RegulIadjTitle = new wxStaticText( m_panelRegulators, wxID_ANY, _("Iadj"), wxDefaultPosition, wxDefaultSize, 0 );
m_RegulIadjTitle->Wrap( -1 ); m_RegulIadjTitle->Wrap( -1 );
m_RegulIadjTitle->SetToolTip( _("For 3 terminal regulators only, the Adjust pin current.") );
fgSizerRegParams->Add( m_RegulIadjTitle, 0, wxALL, 5 ); fgSizerRegParams->Add( m_RegulIadjTitle, 0, wxALL, 5 );
m_RegulIadjValue = new wxTextCtrl( m_panelRegulators, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_RegulIadjValue = new wxTextCtrl( m_panelRegulators, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
...@@ -155,6 +159,8 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow ...@@ -155,6 +159,8 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
m_staticTextRegType = new wxStaticText( m_panelRegulators, wxID_ANY, _("Type"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextRegType = new wxStaticText( m_panelRegulators, wxID_ANY, _("Type"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRegType->Wrap( -1 ); m_staticTextRegType->Wrap( -1 );
m_staticTextRegType->SetToolTip( _("Type of the regulator.\nThere are 2 types:\n- regulators which have a dedicted sense pin for the voltage regulation.\n- 3 terminal pins.") );
fgSizerRegParams->Add( m_staticTextRegType, 0, wxALL, 5 ); fgSizerRegParams->Add( m_staticTextRegType, 0, wxALL, 5 );
wxString m_choiceRegTypeChoices[] = { _("Standard Type"), _("3 Terminal Type") }; wxString m_choiceRegTypeChoices[] = { _("Standard Type"), _("3 Terminal Type") };
...@@ -182,26 +188,28 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow ...@@ -182,26 +188,28 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
m_staticTextRegFile = new wxStaticText( m_panelRegulators, wxID_ANY, _("Regulators data file:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextRegFile = new wxStaticText( m_panelRegulators, wxID_ANY, _("Regulators data file:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextRegFile->Wrap( -1 ); m_staticTextRegFile->Wrap( -1 );
m_staticTextRegFile->SetToolTip( _("The name of the data file which stores known regulators parameters.") );
sbSizerRegulatorsChooser->Add( m_staticTextRegFile, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); sbSizerRegulatorsChooser->Add( m_staticTextRegFile, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_regulators_filePicker = new wxFilePickerCtrl( m_panelRegulators, wxID_ANY, wxEmptyString, _("Select a file"), wxT("*.pcbcalc"), wxDefaultPosition, wxDefaultSize, wxFLP_SAVE|wxFLP_USE_TEXTCTRL ); m_regulators_filePicker = new wxFilePickerCtrl( m_panelRegulators, wxID_ANY, wxEmptyString, _("Select a Pcb Calculator data file"), wxT("*.pcbcalc"), wxDefaultPosition, wxDefaultSize, wxFLP_SAVE|wxFLP_USE_TEXTCTRL );
sbSizerRegulatorsChooser->Add( m_regulators_filePicker, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); sbSizerRegulatorsChooser->Add( m_regulators_filePicker, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bSizerReulBtn; wxBoxSizer* bSizerReulBtn;
bSizerReulBtn = new wxBoxSizer( wxHORIZONTAL ); bSizerReulBtn = new wxBoxSizer( wxHORIZONTAL );
m_buttonEditItem = new wxButton( m_panelRegulators, wxID_ANY, _("Edit Regulator"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonEditItem = new wxButton( m_panelRegulators, wxID_ANY, _("Edit Regulator"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonEditItem->SetToolTip( _("Enter a new item in the current list of availlable regulators") ); m_buttonEditItem->SetToolTip( _("Edit the current selected regulator.") );
bSizerReulBtn->Add( m_buttonEditItem, 0, wxALL, 5 ); bSizerReulBtn->Add( m_buttonEditItem, 0, wxALL, 5 );
m_buttonAddItem = new wxButton( m_panelRegulators, wxID_ANY, _("Add Regulator"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonAddItem = new wxButton( m_panelRegulators, wxID_ANY, _("Add Regulator"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonAddItem->SetToolTip( _("Enter a new item in the current list of availlable regulators") ); m_buttonAddItem->SetToolTip( _("Enter a new item to the current list of available regulators") );
bSizerReulBtn->Add( m_buttonAddItem, 1, wxALL, 5 ); bSizerReulBtn->Add( m_buttonAddItem, 1, wxALL, 5 );
m_buttonRemoveItem = new wxButton( m_panelRegulators, wxID_ANY, _("Remove Regulator"), wxDefaultPosition, wxDefaultSize, 0 ); m_buttonRemoveItem = new wxButton( m_panelRegulators, wxID_ANY, _("Remove Regulator"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonRemoveItem->SetToolTip( _("Remove an item in the current list of availlable regulators") ); m_buttonRemoveItem->SetToolTip( _("Remove an item from the current list of available regulators") );
bSizerReulBtn->Add( m_buttonRemoveItem, 1, wxALL, 5 ); bSizerReulBtn->Add( m_buttonRemoveItem, 1, wxALL, 5 );
...@@ -1241,6 +1249,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow ...@@ -1241,6 +1249,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
this->Centre( wxBOTH ); this->Centre( wxBOTH );
// Connect Events // Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PCB_CALCULATOR_FRAME_BASE::OnClosePcbCalc ) );
m_choiceRegType->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulTypeSelection ), NULL, this ); m_choiceRegType->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulTypeSelection ), NULL, this );
m_buttonCalculate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulatorCalcButtonClick ), NULL, this ); m_buttonCalculate->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulatorCalcButtonClick ), NULL, this );
m_choiceRegulatorSelector->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulatorSelection ), NULL, this ); m_choiceRegulatorSelector->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulatorSelection ), NULL, this );
...@@ -1269,6 +1278,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow ...@@ -1269,6 +1278,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
PCB_CALCULATOR_FRAME_BASE::~PCB_CALCULATOR_FRAME_BASE() PCB_CALCULATOR_FRAME_BASE::~PCB_CALCULATOR_FRAME_BASE()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PCB_CALCULATOR_FRAME_BASE::OnClosePcbCalc ) );
m_choiceRegType->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulTypeSelection ), NULL, this ); m_choiceRegType->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulTypeSelection ), NULL, this );
m_buttonCalculate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulatorCalcButtonClick ), NULL, this ); m_buttonCalculate->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulatorCalcButtonClick ), NULL, this );
m_choiceRegulatorSelector->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulatorSelection ), NULL, this ); m_choiceRegulatorSelector->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( PCB_CALCULATOR_FRAME_BASE::OnRegulatorSelection ), NULL, this );
......
...@@ -259,6 +259,7 @@ class PCB_CALCULATOR_FRAME_BASE : public wxFrame ...@@ -259,6 +259,7 @@ class PCB_CALCULATOR_FRAME_BASE : public wxFrame
wxPanel* m_panelShowClassPrms; wxPanel* m_panelShowClassPrms;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnClosePcbCalc( wxCloseEvent& event ) { event.Skip(); }
virtual void OnRegulTypeSelection( wxCommandEvent& event ) { event.Skip(); } virtual void OnRegulTypeSelection( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRegulatorCalcButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnRegulatorCalcButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRegulatorSelection( wxCommandEvent& event ) { event.Skip(); } virtual void OnRegulatorSelection( wxCommandEvent& event ) { event.Skip(); }
......
...@@ -57,7 +57,7 @@ IMPLEMENT_APP( EDA_APP ) ...@@ -57,7 +57,7 @@ IMPLEMENT_APP( EDA_APP )
bool EDA_APP::OnInit() bool EDA_APP::OnInit()
{ {
InitEDA_Appl( wxT( "PCBcalc" ) ); InitEDA_Appl( wxT( "pcb_calculator" ) );
wxFrame* frame = new PCB_CALCULATOR_FRAME( NULL ); wxFrame* frame = new PCB_CALCULATOR_FRAME( NULL );
SetTopWindow( frame ); SetTopWindow( frame );
......
...@@ -46,6 +46,8 @@ public: ...@@ -46,6 +46,8 @@ public:
private: private:
// Event handlers // Event handlers
void OnClosePcbCalc( wxCloseEvent& event );
// These 3 functions are called by the OnPaint event, to draw // These 3 functions are called by the OnPaint event, to draw
// icons that show the current item on the specific panels // icons that show the current item on the specific panels
void OnPaintTranslinePanel( wxPaintEvent& event ); void OnPaintTranslinePanel( wxPaintEvent& event );
...@@ -64,6 +66,11 @@ private: ...@@ -64,6 +66,11 @@ private:
return m_regulators_filePicker->GetPath(); return m_regulators_filePicker->GetPath();
} }
void SetDataFilename( const wxString & aFilename)
{
m_regulators_filePicker->SetPath( aFilename );
}
// tracks width versus current functions: // tracks width versus current functions:
/** /**
* Function OnTWCalculateButt * Function OnTWCalculateButt
......
...@@ -44,10 +44,10 @@ ...@@ -44,10 +44,10 @@
#define KEYWORD_REGUL_R2 wxT( "RegulR2" ) #define KEYWORD_REGUL_R2 wxT( "RegulR2" )
#define KEYWORD_REGUL_VREF wxT( "RegulVREF" ) #define KEYWORD_REGUL_VREF wxT( "RegulVREF" )
#define KEYWORD_REGUL_VOUT wxT( "RegulVOUT" ) #define KEYWORD_REGUL_VOUT wxT( "RegulVOUT" )
#define KEYWORD_REGUL_FILENAME wxT( "RegulListFilename" )
#define KEYWORD_REGUL_SELECTED wxT( "RegulName" ) #define KEYWORD_REGUL_SELECTED wxT( "RegulName" )
#define KEYWORD_REGUL_TYPE wxT( "RegulType" ) #define KEYWORD_REGUL_TYPE wxT( "RegulType" )
#define KEYWORD_REGUL_LAST_PARAM wxT( "RegulLastParam" ) #define KEYWORD_REGUL_LAST_PARAM wxT( "RegulLastParam" )
#define KEYWORD_DATAFILE_FILENAME wxT( "DataFilename" )
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( wxWindow* parent ) : PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( wxWindow* parent ) :
PCB_CALCULATOR_FRAME_BASE( parent ) PCB_CALCULATOR_FRAME_BASE( parent )
...@@ -116,10 +116,6 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME() ...@@ -116,10 +116,6 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
{ {
WriteConfig(); WriteConfig();
if( m_RegulatorListChanged )
WriteDataFile();
for( unsigned ii = 0; ii < m_transline_list.size(); ii++ ) for( unsigned ii = 0; ii < m_transline_list.size(); ii++ )
delete m_transline_list[ii]; delete m_transline_list[ii];
...@@ -134,6 +130,37 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME() ...@@ -134,6 +130,37 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
this->Freeze(); this->Freeze();
} }
void PCB_CALCULATOR_FRAME::OnClosePcbCalc( wxCloseEvent& event )
{
if( m_RegulatorListChanged )
{
if( GetDataFilename().IsEmpty() )
{
int opt = wxMessageBox( _("Data modified, and no data filename to save modifications\n"\
"Do you want to exit and abandon your change?"),
_("Regulator list change"),
wxYES_NO | wxICON_QUESTION );
if( opt == wxNO )
return;
}
else
{
if( !WriteDataFile() )
{
wxString msg;
msg.Printf( _("Unable to write file<%s>\n"\
"Do you want to exit and abandon your change?"), GetDataFilename() );
int opt = wxMessageBox( msg, _("Write Data File Errror"),
wxYES_NO | wxICON_QUESTION );
if( opt == wxNO )
return;
}
}
}
Destroy();
}
void PCB_CALCULATOR_FRAME::ReadConfig() void PCB_CALCULATOR_FRAME::ReadConfig()
{ {
...@@ -166,8 +193,8 @@ void PCB_CALCULATOR_FRAME::ReadConfig() ...@@ -166,8 +193,8 @@ void PCB_CALCULATOR_FRAME::ReadConfig()
m_RegulVrefValue->SetValue( msg ); m_RegulVrefValue->SetValue( msg );
m_Config->Read( KEYWORD_REGUL_VOUT, &msg, wxT( "12" ) ); m_Config->Read( KEYWORD_REGUL_VOUT, &msg, wxT( "12" ) );
m_RegulVoutValue->SetValue( msg ); m_RegulVoutValue->SetValue( msg );
m_Config->Read( KEYWORD_REGUL_FILENAME, &msg, wxT( "" ) ); m_Config->Read( KEYWORD_DATAFILE_FILENAME, &msg, wxT( "" ) );
m_regulators_filePicker->SetPath( msg ); SetDataFilename( msg );
m_Config->Read( KEYWORD_REGUL_SELECTED, &msg, wxT( "" ) ); m_Config->Read( KEYWORD_REGUL_SELECTED, &msg, wxT( "" ) );
m_lastSelectedRegulatorName = msg; m_lastSelectedRegulatorName = msg;
m_Config->Read( KEYWORD_REGUL_TYPE, &ltmp, 0 ); m_Config->Read( KEYWORD_REGUL_TYPE, &ltmp, 0 );
...@@ -221,7 +248,7 @@ void PCB_CALCULATOR_FRAME::WriteConfig() ...@@ -221,7 +248,7 @@ void PCB_CALCULATOR_FRAME::WriteConfig()
m_Config->Write( KEYWORD_REGUL_R2, m_RegulR2Value->GetValue() ); m_Config->Write( KEYWORD_REGUL_R2, m_RegulR2Value->GetValue() );
m_Config->Write( KEYWORD_REGUL_VREF, m_RegulVrefValue->GetValue() ); m_Config->Write( KEYWORD_REGUL_VREF, m_RegulVrefValue->GetValue() );
m_Config->Write( KEYWORD_REGUL_VOUT, m_RegulVoutValue->GetValue() ); m_Config->Write( KEYWORD_REGUL_VOUT, m_RegulVoutValue->GetValue() );
m_Config->Write( KEYWORD_REGUL_FILENAME, m_regulators_filePicker->GetPath() ); m_Config->Write( KEYWORD_DATAFILE_FILENAME, GetDataFilename() );
m_Config->Write( KEYWORD_REGUL_SELECTED, m_lastSelectedRegulatorName ); m_Config->Write( KEYWORD_REGUL_SELECTED, m_lastSelectedRegulatorName );
m_Config->Write( KEYWORD_REGUL_TYPE, m_Config->Write( KEYWORD_REGUL_TYPE,
m_choiceRegType->GetSelection() ); m_choiceRegType->GetSelection() );
......
...@@ -47,6 +47,15 @@ public: ...@@ -47,6 +47,15 @@ public:
~DIALOG_EDITOR_DATA() {}; ~DIALOG_EDITOR_DATA() {};
// Event called functions:
void OnOKClick( wxCommandEvent& event );
/**
* Function IsOK()
* @return true if regulator parameters are acceptable
*/
bool IsOK();
/** /**
* Function CopyRegulatorDataToDialog * Function CopyRegulatorDataToDialog
* Transfert data from dialog to aItem * Transfert data from dialog to aItem
...@@ -83,6 +92,33 @@ public: ...@@ -83,6 +92,33 @@ public:
}; };
void DIALOG_EDITOR_DATA::OnOKClick( wxCommandEvent& event )
{
if( !IsOK() )
{
wxMessageBox( _("Bad or missing parameters!") );
return;
}
EndModal( wxID_OK );
}
bool DIALOG_EDITOR_DATA::IsOK()
{
bool ok = true;
if( m_textCtrlName->GetValue().IsEmpty() )
ok = false;
if( m_textCtrlVref->GetValue().IsEmpty() )
ok = false;
if( m_choiceRegType->GetSelection() == 1 )
{
if( m_RegulIadjValue->GetValue().IsEmpty() )
ok = false;
}
return ok;
}
void DIALOG_EDITOR_DATA::CopyRegulatorDataToDialog( REGULATOR_DATA * aItem ) void DIALOG_EDITOR_DATA::CopyRegulatorDataToDialog( REGULATOR_DATA * aItem )
{ {
m_textCtrlName->SetValue( aItem->m_Name ); m_textCtrlName->SetValue( aItem->m_Name );
...@@ -137,6 +173,12 @@ void PCB_CALCULATOR_FRAME::RegulatorPageUpdate() ...@@ -137,6 +173,12 @@ void PCB_CALCULATOR_FRAME::RegulatorPageUpdate()
} }
// The new icon size must be taken in account // The new icon size must be taken in account
m_panelRegulators->GetSizer()->Layout(); m_panelRegulators->GetSizer()->Layout();
// Enable/disable buttons:
bool enbl = m_choiceRegulatorSelector->GetCount() > 0;
m_buttonEditItem->Enable( enbl );
m_buttonRemoveItem->Enable( enbl );
m_panelRegulators->Refresh(); m_panelRegulators->Refresh();
} }
...@@ -158,9 +200,11 @@ void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event ) ...@@ -158,9 +200,11 @@ void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event )
m_RegulVrefValue->SetValue( value ); m_RegulVrefValue->SetValue( value );
value.Printf( wxT("%g"), item->m_Iadj ); value.Printf( wxT("%g"), item->m_Iadj );
m_RegulIadjValue->SetValue( value ); m_RegulIadjValue->SetValue( value );
}
// Call RegulatorPageUpdate to enable/sisable tools,
// even if no item selected
RegulatorPageUpdate(); RegulatorPageUpdate();
}
} }
void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxFileDirPickerEvent& event ) void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxFileDirPickerEvent& event )
...@@ -172,6 +216,11 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event ) ...@@ -172,6 +216,11 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event )
DIALOG_EDITOR_DATA dlg( this, wxEmptyString ); DIALOG_EDITOR_DATA dlg( this, wxEmptyString );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return; return;
if( !dlg.IsOK() )
{
wxMessageBox( _("Bad or missing parameters!") );
return;
}
REGULATOR_DATA * new_item = dlg.BuildRegulatorFromData(); REGULATOR_DATA * new_item = dlg.BuildRegulatorFromData();
...@@ -183,6 +232,7 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event ) ...@@ -183,6 +232,7 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event )
m_RegulatorListChanged = true; m_RegulatorListChanged = true;
m_choiceRegulatorSelector->Clear(); m_choiceRegulatorSelector->Clear();
m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() ); m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() );
m_lastSelectedRegulatorName = new_item->m_Name;
SelectLastSelectedRegulator(); SelectLastSelectedRegulator();
} }
else else
...@@ -196,7 +246,11 @@ void PCB_CALCULATOR_FRAME::OnEditRegulator( wxCommandEvent& event ) ...@@ -196,7 +246,11 @@ void PCB_CALCULATOR_FRAME::OnEditRegulator( wxCommandEvent& event )
{ {
wxString name = m_choiceRegulatorSelector->GetStringSelection(); wxString name = m_choiceRegulatorSelector->GetStringSelection();
REGULATOR_DATA * item = m_RegulatorList.GetReg( name ); REGULATOR_DATA * item = m_RegulatorList.GetReg( name );
if( item == NULL )
return;
DIALOG_EDITOR_DATA dlg( this, name ); DIALOG_EDITOR_DATA dlg( this, name );
dlg.CopyRegulatorDataToDialog( item ); dlg.CopyRegulatorDataToDialog( item );
if( dlg.ShowModal() != wxID_OK ) if( dlg.ShowModal() != wxID_OK )
return; return;
...@@ -305,7 +359,8 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve() ...@@ -305,7 +359,8 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve()
// Calculate // Calculate
if( m_choiceRegType->GetSelection() == 1) if( m_choiceRegType->GetSelection() == 1)
{ // 3 terminal regulator {
// 3 terminal regulator
txt = m_RegulIadjValue->GetValue(); txt = m_RegulIadjValue->GetValue();
double iadj = ReturnDoubleFromString(txt); double iadj = ReturnDoubleFromString(txt);
// iadj is given in micro amp, so convert it in amp. // iadj is given in micro amp, so convert it in amp.
...@@ -318,7 +373,6 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve() ...@@ -318,7 +373,6 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve()
break; break;
case 1: case 1:
// to do
r2 = ( vout - vref ) / ( iadj + (vref/r1) ); r2 = ( vout - vref ) / ( iadj + (vref/r1) );
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment