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
m_labelVRef = new wxStaticText( m_panelRegulators, wxID_ANY, _("Vref"), wxDefaultPosition, wxDefaultSize, 0 );
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 );
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
m_RegulIadjTitle = new wxStaticText( m_panelRegulators, wxID_ANY, _("Iadj"), wxDefaultPosition, wxDefaultSize, 0 );
m_RegulIadjTitle->Wrap( -1 );
m_RegulIadjTitle->SetToolTip( _("For 3 terminal regulators only, the Adjust pin current.") );
fgSizerRegParams->Add( m_RegulIadjTitle, 0, wxALL, 5 );
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
m_staticTextRegType = new wxStaticText( m_panelRegulators, wxID_ANY, _("Type"), wxDefaultPosition, wxDefaultSize, 0 );
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 );
wxString m_choiceRegTypeChoices[] = { _("Standard Type"), _("3 Terminal Type") };
......@@ -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->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 );
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 );
wxBoxSizer* bSizerReulBtn;
bSizerReulBtn = new wxBoxSizer( wxHORIZONTAL );
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 );
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 );
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 );
......@@ -1241,6 +1249,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
this->Centre( wxBOTH );
// 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_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 );
......@@ -1269,6 +1278,7 @@ PCB_CALCULATOR_FRAME_BASE::PCB_CALCULATOR_FRAME_BASE( wxWindow* parent, wxWindow
PCB_CALCULATOR_FRAME_BASE::~PCB_CALCULATOR_FRAME_BASE()
{
// 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_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 );
......
......@@ -94,7 +94,7 @@
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnClose">OnClosePcbCalc</event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
......@@ -1920,7 +1920,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">The internal reference voltage of the regulator.&#x0A;Should not be 0.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
......@@ -2195,7 +2195,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">For 3 terminal regulators only, the Adjust pin current.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
......@@ -2470,7 +2470,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">Type of the regulator.&#x0A;There are 2 types:&#x0A;- regulators which have a dedicted sense pin for the voltage regulation.&#x0A;- 3 terminal pins.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
......@@ -2845,7 +2845,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">The name of the data file which stores known regulators parameters.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
......@@ -2914,7 +2914,7 @@
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="message">Select a file</property>
<property name="message">Select a Pcb Calculator data file</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
......@@ -3031,7 +3031,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Enter a new item in the current list of availlable regulators</property>
<property name="tooltip">Edit the current selected regulator.</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
......@@ -3119,7 +3119,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Enter a new item in the current list of availlable regulators</property>
<property name="tooltip">Enter a new item to the current list of available regulators</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
......@@ -3207,7 +3207,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Remove an item in the current list of availlable regulators</property>
<property name="tooltip">Remove an item from the current list of available regulators</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
......@@ -7515,7 +7515,7 @@
<property name="bitmap"></property>
<property name="label">Electrical Spacing</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -7593,25 +7593,25 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizerElectricalClearance</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bLeftSizerElectricalClearance</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxChoice" expanded="1">
<object class="wxChoice" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -7695,11 +7695,11 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<object class="wxStaticLine" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -7780,11 +7780,11 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -7867,11 +7867,11 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -7958,11 +7958,11 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<object class="wxButton" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -8048,20 +8048,20 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bElectricalSpacingSizerRight</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -8144,11 +8144,11 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxGrid" expanded="1">
<object class="wxGrid" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -8291,11 +8291,11 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<object class="wxStaticText" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -14968,7 +14968,7 @@
<property name="bitmap"></property>
<property name="label">RF Attenuators</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -15046,7 +15046,7 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxStaticBoxSizer" expanded="1">
<object class="wxStaticBoxSizer" expanded="0">
<property name="id">wxID_ANY</property>
<property name="label">label</property>
<property name="minimum_size"></property>
......@@ -17266,7 +17266,7 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
......@@ -259,6 +259,7 @@ class PCB_CALCULATOR_FRAME_BASE : public wxFrame
wxPanel* m_panelShowClassPrms;
// 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 OnRegulatorCalcButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRegulatorSelection( wxCommandEvent& event ) { event.Skip(); }
......
......@@ -57,7 +57,7 @@ IMPLEMENT_APP( EDA_APP )
bool EDA_APP::OnInit()
{
InitEDA_Appl( wxT( "PCBcalc" ) );
InitEDA_Appl( wxT( "pcb_calculator" ) );
wxFrame* frame = new PCB_CALCULATOR_FRAME( NULL );
SetTopWindow( frame );
......
......@@ -46,6 +46,8 @@ public:
private:
// Event handlers
void OnClosePcbCalc( wxCloseEvent& event );
// These 3 functions are called by the OnPaint event, to draw
// icons that show the current item on the specific panels
void OnPaintTranslinePanel( wxPaintEvent& event );
......@@ -64,6 +66,11 @@ private:
return m_regulators_filePicker->GetPath();
}
void SetDataFilename( const wxString & aFilename)
{
m_regulators_filePicker->SetPath( aFilename );
}
// tracks width versus current functions:
/**
* Function OnTWCalculateButt
......
......@@ -44,10 +44,10 @@
#define KEYWORD_REGUL_R2 wxT( "RegulR2" )
#define KEYWORD_REGUL_VREF wxT( "RegulVREF" )
#define KEYWORD_REGUL_VOUT wxT( "RegulVOUT" )
#define KEYWORD_REGUL_FILENAME wxT( "RegulListFilename" )
#define KEYWORD_REGUL_SELECTED wxT( "RegulName" )
#define KEYWORD_REGUL_TYPE wxT( "RegulType" )
#define KEYWORD_REGUL_LAST_PARAM wxT( "RegulLastParam" )
#define KEYWORD_DATAFILE_FILENAME wxT( "DataFilename" )
PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( wxWindow* parent ) :
PCB_CALCULATOR_FRAME_BASE( parent )
......@@ -116,10 +116,6 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
{
WriteConfig();
if( m_RegulatorListChanged )
WriteDataFile();
for( unsigned ii = 0; ii < m_transline_list.size(); ii++ )
delete m_transline_list[ii];
......@@ -134,6 +130,37 @@ PCB_CALCULATOR_FRAME::~PCB_CALCULATOR_FRAME()
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()
{
......@@ -166,8 +193,8 @@ void PCB_CALCULATOR_FRAME::ReadConfig()
m_RegulVrefValue->SetValue( msg );
m_Config->Read( KEYWORD_REGUL_VOUT, &msg, wxT( "12" ) );
m_RegulVoutValue->SetValue( msg );
m_Config->Read( KEYWORD_REGUL_FILENAME, &msg, wxT( "" ) );
m_regulators_filePicker->SetPath( msg );
m_Config->Read( KEYWORD_DATAFILE_FILENAME, &msg, wxT( "" ) );
SetDataFilename( msg );
m_Config->Read( KEYWORD_REGUL_SELECTED, &msg, wxT( "" ) );
m_lastSelectedRegulatorName = msg;
m_Config->Read( KEYWORD_REGUL_TYPE, &ltmp, 0 );
......@@ -221,7 +248,7 @@ void PCB_CALCULATOR_FRAME::WriteConfig()
m_Config->Write( KEYWORD_REGUL_R2, m_RegulR2Value->GetValue() );
m_Config->Write( KEYWORD_REGUL_VREF, m_RegulVrefValue->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_TYPE,
m_choiceRegType->GetSelection() );
......
......@@ -47,6 +47,15 @@ public:
~DIALOG_EDITOR_DATA() {};
// Event called functions:
void OnOKClick( wxCommandEvent& event );
/**
* Function IsOK()
* @return true if regulator parameters are acceptable
*/
bool IsOK();
/**
* Function CopyRegulatorDataToDialog
* Transfert data from dialog to aItem
......@@ -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 )
{
m_textCtrlName->SetValue( aItem->m_Name );
......@@ -137,6 +173,12 @@ void PCB_CALCULATOR_FRAME::RegulatorPageUpdate()
}
// The new icon size must be taken in account
m_panelRegulators->GetSizer()->Layout();
// Enable/disable buttons:
bool enbl = m_choiceRegulatorSelector->GetCount() > 0;
m_buttonEditItem->Enable( enbl );
m_buttonRemoveItem->Enable( enbl );
m_panelRegulators->Refresh();
}
......@@ -158,9 +200,11 @@ void PCB_CALCULATOR_FRAME::OnRegulatorSelection( wxCommandEvent& event )
m_RegulVrefValue->SetValue( value );
value.Printf( wxT("%g"), item->m_Iadj );
m_RegulIadjValue->SetValue( value );
}
// Call RegulatorPageUpdate to enable/sisable tools,
// even if no item selected
RegulatorPageUpdate();
}
}
void PCB_CALCULATOR_FRAME::OnDataFileSelection( wxFileDirPickerEvent& event )
......@@ -172,6 +216,11 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event )
DIALOG_EDITOR_DATA dlg( this, wxEmptyString );
if( dlg.ShowModal() != wxID_OK )
return;
if( !dlg.IsOK() )
{
wxMessageBox( _("Bad or missing parameters!") );
return;
}
REGULATOR_DATA * new_item = dlg.BuildRegulatorFromData();
......@@ -183,6 +232,7 @@ void PCB_CALCULATOR_FRAME::OnAddRegulator( wxCommandEvent& event )
m_RegulatorListChanged = true;
m_choiceRegulatorSelector->Clear();
m_choiceRegulatorSelector->Append( m_RegulatorList.GetRegList() );
m_lastSelectedRegulatorName = new_item->m_Name;
SelectLastSelectedRegulator();
}
else
......@@ -196,7 +246,11 @@ void PCB_CALCULATOR_FRAME::OnEditRegulator( wxCommandEvent& event )
{
wxString name = m_choiceRegulatorSelector->GetStringSelection();
REGULATOR_DATA * item = m_RegulatorList.GetReg( name );
if( item == NULL )
return;
DIALOG_EDITOR_DATA dlg( this, name );
dlg.CopyRegulatorDataToDialog( item );
if( dlg.ShowModal() != wxID_OK )
return;
......@@ -305,7 +359,8 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve()
// Calculate
if( m_choiceRegType->GetSelection() == 1)
{ // 3 terminal regulator
{
// 3 terminal regulator
txt = m_RegulIadjValue->GetValue();
double iadj = ReturnDoubleFromString(txt);
// iadj is given in micro amp, so convert it in amp.
......@@ -318,7 +373,6 @@ void PCB_CALCULATOR_FRAME::RegulatorsSolve()
break;
case 1:
// to do
r2 = ( vout - vref ) / ( iadj + (vref/r1) );
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