29 #include <wx/tokenzr.h> 38 static bool empty(
const wxTextEntryBase* aCtrl )
40 return aCtrl->GetValue().IsEmpty();
85 wxTextCtrl* aDcStop, wxTextCtrl* aDcIncr )
87 wxString dcSource = aDcSource->GetString( aDcSource->GetSelection() );
88 wxWindow* ctrlWithError =
nullptr;
90 if( dcSource.IsEmpty() )
93 ctrlWithError = aDcSource;
97 else if( !aDcStart->Validate() )
98 ctrlWithError = aDcStart;
99 else if( !aDcStop->Validate() )
100 ctrlWithError = aDcStop;
101 else if( !aDcIncr->Validate() )
102 ctrlWithError = aDcIncr;
106 ctrlWithError->SetFocus();
107 return wxEmptyString;
113 if( dcSource.Cmp(
"TEMP" ) )
117 SPICE_VALUE( aDcStart->GetValue() ).ToSpiceString(),
118 SPICE_VALUE( aDcStop->GetValue() ).ToSpiceString(),
119 SPICE_VALUE( aDcIncr->GetValue() ).ToSpiceString() );
121 catch( std::exception& e )
124 return wxEmptyString;
129 return wxEmptyString;
133 return wxEmptyString;
140 if( !wxDialog::TransferDataFromWindow() )
143 wxWindow* page =
m_simPages->GetCurrentPage();
162 wxString simCmd = wxString(
".dc " );
176 simCmd +=
" " + src2;
180 DisplayError(
this,
_(
"Source 1 and Source 2 must be different" ) );
204 if( noiseSource[0] !=
'v' && noiseSource[0] !=
'V' )
205 noiseSource +=
'v' + noiseSource;
274 std::map<wxComboBox*, wxString> cmbNet = {
279 for(
auto c : cmbNet )
284 for(
auto c : cmbNet )
285 c.first->Append( net.first );
289 for(
auto c : cmbNet )
291 int idx = c.first->FindString( c.second );
293 if( idx != wxNOT_FOUND )
294 c.first->SetSelection( idx );
297 return DIALOG_SIM_SETTINGS_BASE::ShowModal();
302 wxString prevSelection = aSource->GetString( aSource->GetSelection() );
303 std::vector<wxString> sourcesList;
304 bool enableSrcSelection =
true;
310 if( item.m_primitive == aType )
312 sourcesList.push_back( item.m_refName );
316 std::sort( sourcesList.begin(), sourcesList.end(),
317 [](wxString& a, wxString& b) ->
bool 319 return a.Len() < b.Len() || b.Cmp( a ) > 0;
323 enableSrcSelection =
false;
327 prevSelection = wxT(
"TEMP" );
328 sourcesList.push_back( prevSelection );
329 enableSrcSelection =
false;
332 aSource->Enable( enableSrcSelection );
335 for(
auto& src : sourcesList )
336 aSource->Append( src );
339 int idx = aSource->FindString( prevSelection );
341 if( idx != wxNOT_FOUND )
342 aSource->SetSelection( idx );
348 if( aCommand.IsEmpty() )
351 wxStringTokenizer tokenizer( aCommand,
" " );
352 wxString tkn = tokenizer.GetNextToken().Lower();
359 tkn = tokenizer.GetNextToken().Lower();
376 else if( tkn ==
".dc" )
385 if( !src1.
m_source.IsSameAs( wxT(
"TEMP" ),
false ) == 0 )
399 if( !src2.
m_source.IsSameAs( wxT(
"TEMP" ),
false ) == 0 )
417 else if( tkn ==
".tran" )
426 tkn = tokenizer.GetNextToken();
432 else if( tkn ==
".op" )
459 for(
auto& couple : textCtrl )
461 wxString tmp = couple.first->GetValue();
462 couple.first->SetValue( couple.second->GetValue() );
463 couple.second->SetValue( tmp );
495 m_dcSource2->Enable( is2ndSrcEnabled && type !=
'T' );
503 wxStaticText* aStartValUnit, wxStaticText* aEndValUnit,
504 wxStaticText* aStepUnit )
510 case 'V': unit =
_(
"Volts" );
break;
511 case 'I': unit =
_(
"Amperes" );
break;
512 case 'R': unit =
_(
"Ohms" );
break;
513 case 'T': unit = wxT(
"\u00B0C" );
break;
515 aStartValUnit->SetLabel( unit );
516 aEndValUnit->SetLabel( unit );
517 aStepUnit->SetLabel( unit );
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
wxTextCtrl * m_acFreqStart
wxString ToSpiceString() const
Return string value in Spice format (e.g.
wxTextCtrl * m_noiseFreqStart
const SPICE_ITEM_LIST & GetSpiceItems() const
Return list of items representing schematic components in the Spice world.
wxTextCtrl * m_acPointsNumber
wxRadioBox * m_dcSourceType1
This file is part of the common library.
wxRadioBox * m_dcSourceType2
SPICE_VALIDATOR m_spiceEmptyValidator
wxString evaluateDCControls(wxChoice *aDcSource, wxTextCtrl *aDcStart, wxTextCtrl *aDcStop, wxTextCtrl *aDcIncr)
Reads values from one DC sweep source to form a part of sim command.
wxTextCtrl * m_transFinal
static wxString scaleToString(int aOption)
Class DIALOG_SIM_SETTINGS_BASE.
wxStaticText * m_src2DCStartValUnit
wxPanel * m_pgTransferFunction
wxCheckBox * m_fixPassiveVals
wxStaticText * m_src1DCStepUnit
void onSwapDCSources(wxCommandEvent &event) override
wxTextCtrl * m_acFreqStop
SPICE_VALIDATOR m_spiceValidator
wxString GetSheetSimCommand()
Return simulation command directives placed in schematic sheets (if any).
void updateDCSources(wxChar aType, wxChoice *aSource)
Updates DC sweep source with components from schematic.
< Helper class to handle Spice way of expressing values (e.g. 10.5 Meg) Helper class to recognize Spi...
bool parseCommand(const wxString &aCommand)
Parses a Spice directive.
const NET_INDEX_MAP & GetNetIndexMap() const
Return a map of circuit nodes to net names.
wxStaticText * m_src2DCStepUnit
std::map< wxString, int > NET_INDEX_MAP
bool ParseDCCommand(const wxString &aCmd, SPICE_DC_PARAMS *aSource1, SPICE_DC_PARAMS *aSource2)
Parse a two-source .dc command directive into its components.
wxStaticText * m_src2DCEndValUnit
bool TransferDataFromWindow() override
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
wxCheckBox * m_fixIncludePaths
const wxString What() const
NETLIST_EXPORTER_PSPICE_SIM * m_exporter
wxStaticText * m_src1DCEndValUnit
DIALOG_SIM_SETTINGS(wxWindow *aParent)
bool TransferDataToWindow() override
wxIntegerValidator< int > m_posIntValidator
wxRadioBox * m_noiseScale
static bool empty(const wxTextEntryBase *aCtrl)
void updateDCUnits(wxChar aType, wxChoice *aSource, wxStaticText *aStartValUnit, wxStaticText *aEndValUnit, wxStaticText *aStepUnit)
Updates units on labels depending on selected source.
wxString GetSpiceDevice(const wxString &aComponent) const
Return name of Spice device corresponding to a schematic component.
void refreshUIControls()
!> Generates events to update UI state
wxTextCtrl * m_noiseFreqStop
wxStaticText * m_src1DCStartValUnit
wxTextCtrl * m_noisePointsNumber
wxTextCtrl * m_transInitial
void onDCEnableSecondSource(wxCommandEvent &event) override
Hold a translatable error message and may be used when throwing exceptions containing a translated er...
wxPanel * m_pgSensitivity