KiCad PCB EDA Suite
DIALOG_SPICE_MODEL Class Reference

#include <dialog_spice_model.h>

Inheritance diagram for DIALOG_SPICE_MODEL:
DIALOG_SPICE_MODEL_BASE DIALOG_SHIM KIWAY_HOLDER

Public Member Functions

 DIALOG_SPICE_MODEL (wxWindow *aParent, SCH_COMPONENT &aComponent, SCH_FIELDS &aSchFields)
 
int ShowQuasiModal ()
 
void EndQuasiModal (int retCode)
 
bool IsQuasiModal ()
 
bool Show (bool show) override
 
bool Enable (bool enable) override
 
KIWAYKiway () const
 Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in. More...
 
PROJECTPrj () const
 Function Prj returns a reference to the PROJECT "associated with" this KIWAY. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 Function SetKiway. More...
 

Protected Member Functions

void FinishDialogSettings ()
 In all dialogs, we must call the same functions to fix minimal dlg size, the default position and perhaps some others to fix a few issues depending on Windows Managers this helper function does these calls. More...
 
void FixOSXCancelButtonIssue ()
 A ugly hack to fix an issue on OSX: when typing ctrl+c in a wxTextCtrl inside a dialog, it is closed instead of copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer, when the dlg is created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority to copy text standard accelerator, and the dlg is closed when trying to copy text this function do nothing on other platforms. More...
 

Protected Attributes

wxNotebook * m_notebook
 
wxPanel * m_passive
 
wxStaticText * m_staticText2
 
wxComboBox * m_pasType
 
wxStaticText * m_staticText62
 
wxStaticText * m_staticText3
 
wxTextCtrl * m_pasValue
 
wxStaticText * m_staticText63
 
wxStaticLine * m_staticline1
 
wxStaticText * m_staticText32
 
wxStaticText * m_staticText321
 
wxStaticText * m_staticText341
 
wxStaticText * m_staticText351
 
wxStaticText * m_staticText36
 
wxStaticText * m_staticText37
 
wxStaticText * m_staticText38
 
wxStaticText * m_staticText39
 
wxStaticText * m_staticText40
 
wxStaticText * m_staticText41
 
wxStaticText * m_staticText42
 
wxStaticText * m_staticText43
 
wxStaticText * m_staticText44
 
wxStaticText * m_staticText46
 
wxStaticText * m_staticText47
 
wxStaticText * m_staticText48
 
wxStaticText * m_staticText45
 
wxStaticText * m_staticText49
 
wxStaticText * m_staticText50
 
wxStaticText * m_staticText51
 
wxStaticText * m_staticText52
 
wxStaticText * m_staticText53
 
wxStaticText * m_staticText54
 
wxStaticText * m_staticText55
 
wxStaticText * m_staticText56
 
wxStaticText * m_staticText57
 
wxStaticText * m_staticText58
 
wxStaticText * m_staticText59
 
wxStaticText * m_staticText60
 
wxPanel * m_semiconductor
 
wxStaticText * m_staticText4
 
wxComboBox * m_semiType
 
wxStaticText * m_staticText5
 
wxComboBox * m_semiModel
 
wxStaticText * m_staticText7
 
wxTextCtrl * m_semiLib
 
wxButton * m_semiSelectLib
 
wxPanel * m_ic
 
wxStaticText * m_staticText8
 
wxComboBox * m_icModel
 
wxStaticText * m_staticText9
 
wxTextCtrl * m_icLib
 
wxButton * m_icSelectLib
 
wxPanel * m_power
 
wxStaticText * m_staticText10
 
wxTextCtrl * m_genDc
 
wxStaticText * m_staticText11
 
wxTextCtrl * m_genAcMag
 
wxStaticText * m_staticText12
 
wxTextCtrl * m_genAcPhase
 
wxNotebook * m_powerNotebook
 
wxPanel * m_pwrPulse
 
wxStaticText * m_staticText13
 
wxTextCtrl * m_pulseInit
 
wxStaticText * m_staticText14
 
wxTextCtrl * m_pulseNominal
 
wxStaticText * m_staticText15
 
wxTextCtrl * m_pulseDelay
 
wxStaticText * m_staticText16
 
wxTextCtrl * m_pulseRise
 
wxStaticText * m_staticText17
 
wxTextCtrl * m_pulseFall
 
wxStaticText * m_staticText18
 
wxTextCtrl * m_pulseWidth
 
wxStaticText * m_staticText20
 
wxTextCtrl * m_pulsePeriod
 
wxPanel * m_pwrSin
 
wxStaticText * m_staticText21
 
wxTextCtrl * m_sinOffset
 
wxStaticText * m_staticText22
 
wxTextCtrl * m_sinAmplitude
 
wxStaticText * m_staticText23
 
wxTextCtrl * m_sinFreq
 
wxStaticText * m_staticText24
 
wxTextCtrl * m_sinDelay
 
wxStaticText * m_staticText25
 
wxTextCtrl * m_sinDampFactor
 
wxPanel * m_pwrExp
 
wxStaticText * m_staticText26
 
wxTextCtrl * m_expInit
 
wxStaticText * m_staticText27
 
wxTextCtrl * m_expPulsed
 
wxStaticText * m_staticText28
 
wxTextCtrl * m_expRiseDelay
 
wxStaticText * m_staticText29
 
wxTextCtrl * m_expRiseConst
 
wxStaticText * m_staticText30
 
wxTextCtrl * m_expFallDelay
 
wxStaticText * m_staticText31
 
wxTextCtrl * m_expFallConst
 
wxPanel * m_pwrPwl
 
wxStaticText * m_staticText34
 
wxTextCtrl * m_pwlTime
 
wxStaticText * m_staticText35
 
wxTextCtrl * m_pwlValue
 
wxButton * m_pwlAddButton
 
wxListCtrl * m_pwlValList
 
wxButton * m_pwlRemoveBtn
 
wxPanel * m_pwrFm
 
wxPanel * m_pwrAm
 
wxPanel * m_pwrTransNoise
 
wxPanel * m_pwrRandom
 
wxPanel * m_pwrExtData
 
wxRadioBox * m_pwrType
 
wxStaticLine * m_staticline2
 
wxCheckBox * m_disabled
 
wxCheckBox * m_nodeSeqCheck
 
wxTextCtrl * m_nodeSeqVal
 
wxStaticLine * m_staticline3
 
wxStdDialogButtonSizer * m_sdbSizer
 
wxButton * m_sdbSizerOK
 
wxButton * m_sdbSizerCancel
 
std::string m_hash_key
 
EVENT_LOOPm_qmodal_loop
 
bool m_qmodal_showing
 
WDO_ENABLE_DISABLEm_qmodal_parent_disabler
 

Private Member Functions

bool parsePowerSource (const wxString &aModel)
 Parse a string describing a power source, so appropriate settings are checked in the dialog. More...
 
bool generatePowerSource (wxString &aTarget) const
 Generates a string to describe power source parameters, basing on the current selection. More...
 
void updateFromFile (wxComboBox *aComboBox, const wxString &aFilePath, const wxString &aKeyword)
 Loads a list of components from a file and adds them to a combo box. More...
 
SCH_FIELDgetField (int aFieldType)
 Returns or creates a field in the edited schematic fields vector. More...
 
bool addPwlValue (const wxString &aTime, const wxString &aValue)
 Adds a value to the PWL values list. More...
 
virtual bool TransferDataFromWindow () override
 
virtual bool TransferDataToWindow () override
 
virtual bool Validate () override
 
virtual void onInitDlg (wxInitDialogEvent &event) override
 
void onSemiSelectLib (wxCommandEvent &event) override
 
void onSelectIcLib (wxCommandEvent &event) override
 
void onPwlAdd (wxCommandEvent &event) override
 
void onPwlRemove (wxCommandEvent &event) override
 

Private Attributes

SCH_COMPONENTm_component
 

Edited component

More...
 
SCH_FIELDSm_fields
 

Fields from the component properties dialog

More...
 
std::map< int, wxString > m_fieldsTmp
 

Temporary field values

More...
 
long m_pwlTimeCol
 

Column identifiers for PWL power source value list

More...
 
long m_pwlValueCol
 
SPICE_VALIDATOR m_spiceValidator
 
SPICE_VALIDATOR m_spiceEmptyValidator
 
wxTextValidator m_notEmptyValidator
 

Detailed Description

Definition at line 35 of file dialog_spice_model.h.

Constructor & Destructor Documentation

DIALOG_SPICE_MODEL::DIALOG_SPICE_MODEL ( wxWindow *  aParent,
SCH_COMPONENT aComponent,
SCH_FIELDS aSchFields 
)

Definition at line 57 of file dialog_spice_model.cpp.

References DIALOG_SPICE_MODEL_BASE::m_expFallConst, DIALOG_SPICE_MODEL_BASE::m_expFallDelay, DIALOG_SPICE_MODEL_BASE::m_expInit, DIALOG_SPICE_MODEL_BASE::m_expPulsed, DIALOG_SPICE_MODEL_BASE::m_expRiseConst, DIALOG_SPICE_MODEL_BASE::m_expRiseDelay, DIALOG_SPICE_MODEL_BASE::m_genAcMag, DIALOG_SPICE_MODEL_BASE::m_genAcPhase, DIALOG_SPICE_MODEL_BASE::m_genDc, DIALOG_SPICE_MODEL_BASE::m_icModel, m_notEmptyValidator, DIALOG_SPICE_MODEL_BASE::m_pasValue, DIALOG_SPICE_MODEL_BASE::m_pulseDelay, DIALOG_SPICE_MODEL_BASE::m_pulseFall, DIALOG_SPICE_MODEL_BASE::m_pulseInit, DIALOG_SPICE_MODEL_BASE::m_pulseNominal, DIALOG_SPICE_MODEL_BASE::m_pulsePeriod, DIALOG_SPICE_MODEL_BASE::m_pulseRise, DIALOG_SPICE_MODEL_BASE::m_pulseWidth, m_pwlTimeCol, DIALOG_SPICE_MODEL_BASE::m_pwlValList, m_pwlValueCol, DIALOG_SPICE_MODEL_BASE::m_sdbSizerOK, DIALOG_SPICE_MODEL_BASE::m_semiModel, DIALOG_SPICE_MODEL_BASE::m_semiType, DIALOG_SPICE_MODEL_BASE::m_sinAmplitude, DIALOG_SPICE_MODEL_BASE::m_sinDampFactor, DIALOG_SPICE_MODEL_BASE::m_sinDelay, DIALOG_SPICE_MODEL_BASE::m_sinFreq, DIALOG_SPICE_MODEL_BASE::m_sinOffset, m_spiceEmptyValidator, and m_spiceValidator.

58  : DIALOG_SPICE_MODEL_BASE( aParent ), m_component( aComponent ), m_fields( aFields ),
59  m_spiceEmptyValidator( true ), m_notEmptyValidator( wxFILTER_EMPTY )
60 {
61  m_pasValue->SetValidator( m_spiceValidator );
62 
63  m_semiType->SetValidator( m_notEmptyValidator );
64  m_semiModel->SetValidator( m_notEmptyValidator );
65 
66  m_icModel->SetValidator( m_notEmptyValidator );
67 
68  m_genDc->SetValidator( m_spiceEmptyValidator );
69  m_genAcMag->SetValidator( m_spiceEmptyValidator );
70  m_genAcPhase->SetValidator( m_spiceEmptyValidator );
71 
72  m_pulseInit->SetValidator( m_spiceEmptyValidator );
73  m_pulseNominal->SetValidator( m_spiceEmptyValidator );
74  m_pulseDelay->SetValidator( m_spiceEmptyValidator );
75  m_pulseRise->SetValidator( m_spiceEmptyValidator );
76  m_pulseFall->SetValidator( m_spiceEmptyValidator );
77  m_pulseWidth->SetValidator( m_spiceEmptyValidator );
78  m_pulsePeriod->SetValidator( m_spiceEmptyValidator );
79 
80  m_sinOffset->SetValidator( m_spiceEmptyValidator );
81  m_sinAmplitude->SetValidator( m_spiceEmptyValidator );
82  m_sinFreq->SetValidator( m_spiceEmptyValidator );
83  m_sinDelay->SetValidator( m_spiceEmptyValidator );
84  m_sinDampFactor->SetValidator( m_spiceEmptyValidator );
85 
86  m_expInit->SetValidator( m_spiceEmptyValidator );
87  m_expPulsed->SetValidator( m_spiceEmptyValidator );
88  m_expRiseDelay->SetValidator( m_spiceEmptyValidator );
89  m_expRiseConst->SetValidator( m_spiceEmptyValidator );
90  m_expFallDelay->SetValidator( m_spiceEmptyValidator );
91  m_expFallConst->SetValidator( m_spiceEmptyValidator );
92 
93  m_pwlTimeCol = m_pwlValList->AppendColumn( "Time [s]", wxLIST_FORMAT_LEFT, 100 );
94  m_pwlValueCol = m_pwlValList->AppendColumn( "Value [V/A]", wxLIST_FORMAT_LEFT, 100 );
95 
96  m_sdbSizerOK->SetDefault();
97 
98 }
SCH_COMPONENT & m_component
Edited component
SPICE_VALIDATOR m_spiceValidator
long m_pwlTimeCol
Column identifiers for PWL power source value list
DIALOG_SPICE_MODEL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(640, 582), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxTextValidator m_notEmptyValidator
SCH_FIELDS & m_fields
Fields from the component properties dialog
SPICE_VALIDATOR m_spiceEmptyValidator

Member Function Documentation

bool DIALOG_SPICE_MODEL::addPwlValue ( const wxString &  aTime,
const wxString &  aValue 
)
private

Adds a value to the PWL values list.

Parameters
aTimeis the time value.
aValueis the source value at the given time.
Returns
True if request has completed successfully, false if the data is invalid.

Definition at line 683 of file dialog_spice_model.cpp.

References comparePwlValues(), DIALOG_SPICE_MODEL_BASE::m_pwlTime, m_pwlTimeCol, DIALOG_SPICE_MODEL_BASE::m_pwlValList, and m_pwlValueCol.

Referenced by onPwlAdd(), and parsePowerSource().

684 {
685  // TODO execute validators
686  if( aTime.IsEmpty() || aValue.IsEmpty() )
687  return false;
688 
689  long idx = m_pwlValList->InsertItem( m_pwlTimeCol, aTime );
690  m_pwlValList->SetItem( idx, m_pwlValueCol, aValue );
691 
692  // There is no wxString::ToFloat, but we need to guarantee it fits in 4 bytes
693  double timeD;
694  float timeF;
695  m_pwlTime->GetValue().ToDouble( &timeD );
696  timeF = timeD;
697 
698  // Store the time value, so the entries can be sorted
699  m_pwlValList->SetItemData( idx, *reinterpret_cast<long*>( &timeF ) );
700 
701  // Sort items by timestamp
702  m_pwlValList->SortItems( comparePwlValues, -1 );
703 
704  return true;
705 }
long m_pwlTimeCol
Column identifiers for PWL power source value list
static int wxCALLBACK comparePwlValues(wxIntPtr aItem1, wxIntPtr aItem2, wxIntPtr WXUNUSED(aSortData))
bool DIALOG_SHIM::Enable ( bool  enable)
overrideinherited

Definition at line 181 of file dialog_shim.cpp.

Referenced by DIALOG_PRINT_USING_PRINTER::InitValues().

182 {
183  // so we can do logging of this state change:
184 
185 #if defined(DEBUG)
186  const char* type_id = typeid( *this ).name();
187  printf( "wxDialog %s: %s\n", type_id, enable ? "enabled" : "disabled" );
188 #endif
189 
190  return wxDialog::Enable( enable );
191 }
void DIALOG_SHIM::EndQuasiModal ( int  retCode)
inherited

Definition at line 539 of file dialog_shim.cpp.

References DIALOG_SHIM::IsQuasiModal(), DIALOG_SHIM::m_qmodal_loop, DIALOG_SHIM::m_qmodal_parent_disabler, DIALOG_SHIM::m_qmodal_showing, and DIALOG_SHIM::Show().

Referenced by HK_PROMPT_DIALOG::EndFlexible(), DIALOG_SHIM::OnButton(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnCancelButtonClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCancelButtonClick(), DIALOG_EDIT_ONE_FIELD::OnCancelClick(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnCloseDialog(), DIALOG_EDIT_ONE_FIELD::OnCloseDialog(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnCloseDialog(), DIALOG_CHOOSE_COMPONENT::OnCloseTimer(), DIALOG_SHIM::OnCloseWindow(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnOKButtonClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), DIALOG_EDIT_ONE_FIELD::OnOkClick(), DIALOG_EXCHANGE_MODULE::OnQuit(), DIALOG_CHOOSE_COMPONENT::OnSchViewDClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp(), and DIALOG_SHIM::~DIALOG_SHIM().

540 {
541  // Hook up validator and transfer data from controls handling so quasi-modal dialogs
542  // handle validation in the same way as other dialogs.
543  if( ( retCode == wxID_OK ) && ( !Validate() || !TransferDataFromWindow() ) )
544  return;
545 
546  SetReturnCode( retCode );
547 
548  if( !IsQuasiModal() )
549  {
550  wxFAIL_MSG( wxT( "either DIALOG_SHIM::EndQuasiModal called twice or ShowQuasiModal wasn't called" ) );
551  return;
552  }
553 
554  m_qmodal_showing = false;
555 
556  if( m_qmodal_loop )
557  {
558  if( m_qmodal_loop->IsRunning() )
559  m_qmodal_loop->Exit( 0 );
560  else
561  m_qmodal_loop->ScheduleExit( 0 );
562 
563  m_qmodal_loop = NULL;
564  }
565 
568 
569  Show( false );
570 }
bool m_qmodal_showing
Definition: dialog_shim.h:132
EVENT_LOOP * m_qmodal_loop
Definition: dialog_shim.h:131
bool IsQuasiModal()
Definition: dialog_shim.h:93
bool Show(bool show) override
WDO_ENABLE_DISABLE * m_qmodal_parent_disabler
Definition: dialog_shim.h:133
void DIALOG_SHIM::FinishDialogSettings ( )
protectedinherited

In all dialogs, we must call the same functions to fix minimal dlg size, the default position and perhaps some others to fix a few issues depending on Windows Managers this helper function does these calls.

FinishDialogSettings must be called from derived classes, when all widgets are initialized, and therefore their size fixed. If TransferDataToWindow() is used to initialize widgets, at end of TransferDataToWindow, or better at end of a wxInitDialogEvent handler

In any case, the best way is to call it in a wxInitDialogEvent handler after calling TransfertDataToWindow(), which is the default wxInitDialogEvent handler wxDialog

Definition at line 103 of file dialog_shim.cpp.

References PCAD2KICAD::Center.

Referenced by DIALOG_BOM::DIALOG_BOM(), DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE(), DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES(), DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR(), DIALOG_DISPLAY_OPTIONS::DIALOG_DISPLAY_OPTIONS(), DIALOG_DRC_CONTROL::DIALOG_DRC_CONTROL(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::DIALOG_EDIT_COMPONENT_IN_LIBRARY(), DIALOG_EESCHEMA_OPTIONS::DIALOG_EESCHEMA_OPTIONS(), DIALOG_ENUM_PADS::DIALOG_ENUM_PADS(), DIALOG_EXPORT_3DFILE::DIALOG_EXPORT_3DFILE(), DIALOG_EXPORT_IDF3::DIALOG_EXPORT_IDF3(), DIALOG_EXPORT_STEP::DIALOG_EXPORT_STEP(), DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST(), DIALOG_KEEPOUT_AREA_PROPERTIES::DIALOG_KEEPOUT_AREA_PROPERTIES(), DIALOG_LABEL_EDITOR::DIALOG_LABEL_EDITOR(), DIALOG_LIB_EDIT_DRAW_ITEM::DIALOG_LIB_EDIT_DRAW_ITEM(), DIALOG_LIB_EDIT_TEXT::DIALOG_LIB_EDIT_TEXT(), DIALOG_LIB_NEW_COMPONENT::DIALOG_LIB_NEW_COMPONENT(), DIALOG_LIBEDIT_OPTIONS::DIALOG_LIBEDIT_OPTIONS(), DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES(), DIALOG_PLOT_SCHEMATIC::DIALOG_PLOT_SCHEMATIC(), DIALOG_SCH_EDIT_SHEET_PIN::DIALOG_SCH_EDIT_SHEET_PIN(), DIALOG_SCH_SHEET_PROPS::DIALOG_SCH_SHEET_PROPS(), DIALOG_SELECT_PRETTY_LIB::DIALOG_SELECT_PRETTY_LIB(), DIALOG_TRACK_VIA_SIZE::DIALOG_TRACK_VIA_SIZE(), DIALOG_EDIT_ONE_FIELD::init(), NETLIST_DIALOG::NETLIST_DIALOG(), DIALOG_LIB_EDIT_PIN::OnInitDialog(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::OnInitDialog(), DIALOG_TRACK_VIA_PROPERTIES::OnInitDlg(), DIALOG_GRAPHIC_ITEMS_OPTIONS::OnInitDlg(), DialogEditModuleText::OnInitDlg(), DIALOG_SET_GRID::OnInitDlg(), DIALOG_PCB_TEXT_PROPERTIES::OnInitDlg(), DIALOG_PRINT_FOR_MODEDIT::OnInitDlg(), DIALOG_GRAPHIC_ITEM_PROPERTIES::OnInitDlg(), DIALOG_MODULE_MODULE_EDITOR::OnInitDlg(), DIALOG_SIM_SETTINGS::onInitDlg(), onInitDlg(), DIALOG_MODULE_BOARD_EDITOR::OnInitDlg(), DIALOG_PRINT_USING_PRINTER::OnInitDlg(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnInitDlg(), TARGET_PROPERTIES_DIALOG_EDITOR::TARGET_PROPERTIES_DIALOG_EDITOR(), and DIALOG_SIGNAL_LIST::TransferDataToWindow().

104 {
105  // must be called from the constructor of derived classes,
106  // when all widgets are initialized, and therefore their size fixed
107 
108  // SetSizeHints fixes the minimal size of sizers in the dialog
109  // (SetSizeHints calls Fit(), so no need to call it)
110  GetSizer()->SetSizeHints( this );
111 
112  // the default position, when calling the first time the dlg
113  Center();
114 }
void DIALOG_SHIM::FixOSXCancelButtonIssue ( )
protectedinherited

A ugly hack to fix an issue on OSX: when typing ctrl+c in a wxTextCtrl inside a dialog, it is closed instead of copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer, when the dlg is created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority to copy text standard accelerator, and the dlg is closed when trying to copy text this function do nothing on other platforms.

Definition at line 116 of file dialog_shim.cpp.

Referenced by DIALOG_SHIM::Show().

117 {
118 #ifdef __WXMAC__
119  // A ugly hack to fix an issue on OSX: ctrl+c closes the dialog instead of
120  // copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer
121  // created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority
122  // to copy text standard accelerator, and the dlg is closed when trying to copy text
123  wxButton* button = dynamic_cast< wxButton* > ( wxWindow::FindWindowById( wxID_CANCEL, this ) );
124 
125  if( button )
126  button->SetLabel( _( "Cancel" ) );
127 #endif
128 }
bool DIALOG_SPICE_MODEL::generatePowerSource ( wxString &  aTarget) const
private

Generates a string to describe power source parameters, basing on the current selection.

If there are missing fields, it will not modify the target string.

Parameters
aTargetis the destination for the generated string.
Returns
True if the string was saved successfully.

DC / AC section

Transient section

Definition at line 465 of file dialog_spice_model.cpp.

References DisplayError(), empty(), Format(), DIALOG_SPICE_MODEL_BASE::m_expFallConst, DIALOG_SPICE_MODEL_BASE::m_expFallDelay, DIALOG_SPICE_MODEL_BASE::m_expInit, DIALOG_SPICE_MODEL_BASE::m_expPulsed, DIALOG_SPICE_MODEL_BASE::m_expRiseConst, DIALOG_SPICE_MODEL_BASE::m_expRiseDelay, DIALOG_SPICE_MODEL_BASE::m_genAcMag, DIALOG_SPICE_MODEL_BASE::m_genAcPhase, DIALOG_SPICE_MODEL_BASE::m_genDc, DIALOG_SPICE_MODEL_BASE::m_powerNotebook, DIALOG_SPICE_MODEL_BASE::m_pulseDelay, DIALOG_SPICE_MODEL_BASE::m_pulseFall, DIALOG_SPICE_MODEL_BASE::m_pulseInit, DIALOG_SPICE_MODEL_BASE::m_pulseNominal, DIALOG_SPICE_MODEL_BASE::m_pulsePeriod, DIALOG_SPICE_MODEL_BASE::m_pulseRise, DIALOG_SPICE_MODEL_BASE::m_pulseWidth, m_pwlTimeCol, DIALOG_SPICE_MODEL_BASE::m_pwlValList, m_pwlValueCol, DIALOG_SPICE_MODEL_BASE::m_pwrExp, DIALOG_SPICE_MODEL_BASE::m_pwrPulse, DIALOG_SPICE_MODEL_BASE::m_pwrPwl, DIALOG_SPICE_MODEL_BASE::m_pwrSin, DIALOG_SPICE_MODEL_BASE::m_sinAmplitude, DIALOG_SPICE_MODEL_BASE::m_sinDampFactor, DIALOG_SPICE_MODEL_BASE::m_sinDelay, DIALOG_SPICE_MODEL_BASE::m_sinFreq, and DIALOG_SPICE_MODEL_BASE::m_sinOffset.

Referenced by TransferDataFromWindow().

466 {
467  wxString acdc, trans;
468  wxWindow* page = m_powerNotebook->GetCurrentPage();
469  bool useTrans = true; // shall we use the transient command part?
470 
471  // Variables for generic processing
472  bool genericProcessing = false;
473  unsigned int genericReqParamsCount = 0;
474  std::vector<wxTextCtrl*> genericControls;
475 
477  // If SPICE_VALUE can be properly constructed, then it is a valid value
478  try
479  {
480  if( !empty( m_genDc ) )
481  acdc += wxString::Format( "dc %s ", SPICE_VALUE( m_genDc->GetValue() ).ToSpiceString() );
482  }
483  catch( ... )
484  {
485  DisplayError( NULL, wxT( "Invalid DC value" ) );
486  return false;
487  }
488 
489  try
490  {
491  if( !empty( m_genAcMag ) )
492  {
493  acdc += wxString::Format( "ac %s ", SPICE_VALUE( m_genAcMag->GetValue() ).ToSpiceString() );
494 
495  if( !empty( m_genAcPhase ) )
496  acdc += wxString::Format( "%s ", SPICE_VALUE( m_genAcPhase->GetValue() ).ToSpiceString() );
497  }
498  }
499  catch( ... )
500  {
501  DisplayError( NULL, wxT( "Invalid AC magnitude or phase" ) );
502  return false;
503  }
504 
506  if( page == m_pwrPulse )
507  {
508  if( !m_pwrPulse->Validate() )
509  return false;
510 
511  genericProcessing = true;
512  trans += "pulse";
513  genericReqParamsCount = 2;
514  genericControls = { m_pulseInit, m_pulseNominal, m_pulseDelay,
516  }
517 
518 
519  else if( page == m_pwrSin )
520  {
521  if( !m_pwrSin->Validate() )
522  return false;
523 
524  genericProcessing = true;
525  trans += "sin";
526  genericReqParamsCount = 2;
528  }
529 
530 
531  else if( page == m_pwrExp )
532  {
533  if( !m_pwrExp->Validate() )
534  return false;
535 
536  genericProcessing = true;
537  trans += "exp";
538  genericReqParamsCount = 2;
539  genericControls = { m_expInit, m_expPulsed,
541  }
542 
543 
544  else if( page == m_pwrPwl )
545  {
546  if( m_pwlValList->GetItemCount() > 0 )
547  {
548  trans += "pwl(";
549 
550  for( int i = 0; i < m_pwlValList->GetItemCount(); ++i )
551  {
552  trans += wxString::Format( "%s %s ", m_pwlValList->GetItemText( i, m_pwlTimeCol ),
553  m_pwlValList->GetItemText( i, m_pwlValueCol ) );
554  }
555 
556  trans.Trim();
557  trans += ")";
558  }
559  }
560 
561  if( genericProcessing )
562  {
563  bool finished = false;
564  unsigned int paramCounter = 0;
565 
566  trans += "(";
567 
568  for( auto textCtrl : genericControls )
569  {
570  if( empty( textCtrl ) )
571  {
572  finished = true;
573 
574  if( paramCounter < genericReqParamsCount )
575  {
576  if( paramCounter == 0 )
577  {
578  // It is fine, no parameters were entered
579  useTrans = false;
580  break;
581  }
582 
583  DisplayError( NULL,
584  wxString::Format( wxT( "You need to specify at least the "
585  "first %d parameters for the transient source" ),
586  genericReqParamsCount ) );
587 
588  return false;
589  }
590  }
591  else if( finished )
592  {
593  DisplayError( NULL, wxT( "You cannot leave interleaved blank "
594  "spaces for the transient source" ) );
595  return false;
596  }
597 
598  trans += wxString::Format( "%s ", textCtrl->GetValue() );
599  ++paramCounter;
600  }
601 
602  trans.Trim();
603  trans += ")";
604  }
605 
606  aTarget = acdc;
607 
608  if( useTrans )
609  aTarget += trans;
610 
611  aTarget.Trim( false );
612  aTarget.Trim( true );
613 
614  return true;
615 }
long m_pwlTimeCol
Column identifiers for PWL power source value list
static bool empty(const wxTextCtrl *aCtrl)
Helper class to handle Spice way of expressing values (e.g. 10.5 Meg)
Definition: spice_value.h:32
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
Definition: confirm.cpp:69
SCH_FIELD & DIALOG_SPICE_MODEL::getField ( int  aFieldType)
private

Returns or creates a field in the edited schematic fields vector.

Parameters
aFieldTypeis an SPICE_FIELD enum value.
Returns
Requested field.

Definition at line 665 of file dialog_spice_model.cpp.

References NETLIST_EXPORTER_PSPICE::GetSpiceFieldName(), m_component, and m_fields.

Referenced by TransferDataFromWindow().

666 {
667  const wxString& spiceField = NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD) aFieldType );
668 
669  auto fieldIt = std::find_if( m_fields.begin(), m_fields.end(), [&]( const SCH_FIELD& f ) {
670  return f.GetName() == spiceField;
671  } );
672 
673  // Found one, so return it
674  if( fieldIt != m_fields.end() )
675  return *fieldIt;
676 
677  // Create a new field with requested name
678  m_fields.emplace_back( wxPoint(), m_fields.size(), &m_component, spiceField );
679  return m_fields.back();
680 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
SCH_COMPONENT & m_component
Edited component
static const wxString & GetSpiceFieldName(SPICE_FIELD aField)
Returns a string used for a particular component field related to Spice simulation.
SCH_FIELDS & m_fields
Fields from the component properties dialog
KIWAY& KIWAY_HOLDER::Kiway ( ) const
inlineinherited

Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in.

A KIWAY_HOLDER is not necessarily a KIWAY_PLAYER.

Definition at line 60 of file kiway_player.h.

References KIWAY_HOLDER::m_kiway.

Referenced by SCH_EDIT_FRAME::AppendOneEEProject(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), DIALOG_CHOOSE_COMPONENT::ConstructRightPanel(), CVPCB_MAINFRAME::CreateScreenCmp(), CVPCB_MAINFRAME::CVPCB_MAINFRAME(), DIALOG_SHIM::DIALOG_SHIM(), EDIT_TOOL::editFootprintInFpEditor(), SCH_EDIT_FRAME::EditSheet(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_EDIT_FRAME::GetPlotSettings(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::initBuffers(), LIB_EDIT_FRAME::InstallConfigFrame(), PCB_EDIT_FRAME::InstallModuleOptionsFrame(), KIWAY_PLAYER::language_change(), SCH_SHEET::Load(), CVPCB_MAINFRAME::LoadFootprintFiles(), KIWAY_PLAYER::OnChangeIconsOptions(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), SCH_EDIT_FRAME::OnLeftClick(), SCH_BASE_FRAME::OnOpenLibraryViewer(), SCH_EDIT_FRAME::OnSimulate(), DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick(), FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateReplaceModuleInBoard(), SCH_EDIT_FRAME::OpenProjectFiles(), KIWAY_HOLDER::Prj(), PCB_EDIT_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), CVPCB_MAINFRAME::ReadNetListAndLinkFiles(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), LIB_EDIT_FRAME::refreshSchematic(), SCH_EDIT_FRAME::SaveEEFile(), CVPCB_MAINFRAME::SaveFootprintAssociation(), SCH_BASE_FRAME::SelectComponentFromLibBrowser(), CVPCB_MAINFRAME::SendMessageToEESCHEMA(), PCB_EDIT_FRAME::SendMessageToEESCHEMA(), SCH_EDIT_FRAME::SendMessageToPCBNEW(), SCH_EDIT_FRAME::sendNetlist(), FOOTPRINT_EDIT_FRAME::SetPlotSettings(), DISPLAY_FOOTPRINTS_FRAME::Show3D_Frame(), FOOTPRINT_VIEWER_FRAME::Show3D_Frame(), FOOTPRINT_EDIT_FRAME::Show3D_Frame(), FOOTPRINT_WIZARD_FRAME::Show3D_Frame(), DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::showButtonHandler(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::showButtonHandler(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), and DIALOG_EXCHANGE_MODULE::ViewAndSelectFootprint().

61  {
62  wxASSERT( m_kiway ); // smoke out bugs in Debug build, then Release runs fine.
63  return *m_kiway;
64  }
KIWAY * m_kiway
Definition: kiway_player.h:85
virtual void DIALOG_SPICE_MODEL::onInitDlg ( wxInitDialogEvent &  event)
inlineoverrideprivatevirtual

Reimplemented from DIALOG_SPICE_MODEL_BASE.

Definition at line 91 of file dialog_spice_model.h.

References DIALOG_SHIM::FinishDialogSettings(), and TransferDataToWindow().

92  {
93  // Call the default wxDialog handler of a wxInitDialogEvent
95 
96  // Now all widgets have the size fixed, call FinishDialogSettings
98  }
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
virtual bool TransferDataToWindow() override
void DIALOG_SPICE_MODEL::onPwlAdd ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_SPICE_MODEL_BASE.

Definition at line 762 of file dialog_spice_model.cpp.

References addPwlValue(), DIALOG_SPICE_MODEL_BASE::m_pwlTime, and DIALOG_SPICE_MODEL_BASE::m_pwlValue.

763 {
764  addPwlValue( m_pwlTime->GetValue(), m_pwlValue->GetValue() );
765 }
bool addPwlValue(const wxString &aTime, const wxString &aValue)
Adds a value to the PWL values list.
void DIALOG_SPICE_MODEL::onPwlRemove ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_SPICE_MODEL_BASE.

Definition at line 768 of file dialog_spice_model.cpp.

References DIALOG_SPICE_MODEL_BASE::m_pwlValList.

769 {
770  long idx = m_pwlValList->GetNextItem( -1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
771  m_pwlValList->DeleteItem( idx );
772 }
void DIALOG_SPICE_MODEL::onSelectIcLib ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_SPICE_MODEL_BASE.

Definition at line 735 of file dialog_spice_model.cpp.

References PROJECT::GetProjectPath(), DIALOG_SPICE_MODEL_BASE::m_icLib, DIALOG_SPICE_MODEL_BASE::m_icModel, KIWAY_HOLDER::Prj(), and updateFromFile().

736 {
737  wxString searchPath = wxFileName( m_icLib->GetValue() ).GetPath();
738 
739  if( searchPath.IsEmpty() )
740  searchPath = Prj().GetProjectPath();
741 
742  wxFileDialog openDlg( this, wxT( "Select library" ), searchPath, "",
743  "Spice library file (*.lib)|*.lib;*.LIB|Any file|*",
744  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
745 
746  if( openDlg.ShowModal() == wxID_CANCEL )
747  return;
748 
749  wxFileName libPath( openDlg.GetPath() );
750 
751  // Try to convert the path to relative to project
752  if( libPath.MakeRelativeTo( Prj().GetProjectPath() ) && !libPath.GetFullPath().StartsWith( ".." ) )
753  m_icLib->SetValue( libPath.GetFullPath() );
754  else
755  m_icLib->SetValue( openDlg.GetPath() );
756 
757  updateFromFile( m_icModel, openDlg.GetPath(), ".subckt" );
758  m_icModel->Popup();
759 }
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void updateFromFile(wxComboBox *aComboBox, const wxString &aFilePath, const wxString &aKeyword)
Loads a list of components from a file and adds them to a combo box.
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
void DIALOG_SPICE_MODEL::onSemiSelectLib ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from DIALOG_SPICE_MODEL_BASE.

Definition at line 708 of file dialog_spice_model.cpp.

References PROJECT::GetProjectPath(), DIALOG_SPICE_MODEL_BASE::m_semiLib, DIALOG_SPICE_MODEL_BASE::m_semiModel, KIWAY_HOLDER::Prj(), and updateFromFile().

709 {
710  wxString searchPath = wxFileName( m_semiLib->GetValue() ).GetPath();
711 
712  if( searchPath.IsEmpty() )
713  searchPath = Prj().GetProjectPath();
714 
715  wxFileDialog openDlg( this, wxT( "Select library" ), searchPath, "",
716  "Spice library file (*.lib)|*.lib;*.LIB|Any file|*",
717  wxFD_OPEN | wxFD_FILE_MUST_EXIST );
718 
719  if( openDlg.ShowModal() == wxID_CANCEL )
720  return;
721 
722  wxFileName libPath( openDlg.GetPath() );
723 
724  // Try to convert the path to relative to project
725  if( libPath.MakeRelativeTo( Prj().GetProjectPath() ) && !libPath.GetFullPath().StartsWith( ".." ) )
726  m_semiLib->SetValue( libPath.GetFullPath() );
727  else
728  m_semiLib->SetValue( openDlg.GetPath() );
729 
730  updateFromFile( m_semiModel, openDlg.GetPath(), ".model" );
731  m_semiModel->Popup();
732 }
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void updateFromFile(wxComboBox *aComboBox, const wxString &aFilePath, const wxString &aKeyword)
Loads a list of components from a file and adds them to a combo box.
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
bool DIALOG_SPICE_MODEL::parsePowerSource ( const wxString &  aModel)
private

Parse a string describing a power source, so appropriate settings are checked in the dialog.

Parameters
aModelcontains the string to be parse (e.g. sin(0 1 10k))
Returns
True if the input string was parsed without errors.

Definition at line 313 of file dialog_spice_model.cpp.

References addPwlValue(), DIALOG_SPICE_MODEL_BASE::m_expFallConst, DIALOG_SPICE_MODEL_BASE::m_expFallDelay, DIALOG_SPICE_MODEL_BASE::m_expInit, DIALOG_SPICE_MODEL_BASE::m_expPulsed, DIALOG_SPICE_MODEL_BASE::m_expRiseConst, DIALOG_SPICE_MODEL_BASE::m_expRiseDelay, DIALOG_SPICE_MODEL_BASE::m_genAcMag, DIALOG_SPICE_MODEL_BASE::m_genAcPhase, DIALOG_SPICE_MODEL_BASE::m_genDc, DIALOG_SPICE_MODEL_BASE::m_powerNotebook, DIALOG_SPICE_MODEL_BASE::m_pulseDelay, DIALOG_SPICE_MODEL_BASE::m_pulseFall, DIALOG_SPICE_MODEL_BASE::m_pulseInit, DIALOG_SPICE_MODEL_BASE::m_pulseNominal, DIALOG_SPICE_MODEL_BASE::m_pulsePeriod, DIALOG_SPICE_MODEL_BASE::m_pulseRise, DIALOG_SPICE_MODEL_BASE::m_pulseWidth, DIALOG_SPICE_MODEL_BASE::m_pwrExp, DIALOG_SPICE_MODEL_BASE::m_pwrPulse, DIALOG_SPICE_MODEL_BASE::m_pwrPwl, DIALOG_SPICE_MODEL_BASE::m_pwrSin, DIALOG_SPICE_MODEL_BASE::m_sinAmplitude, DIALOG_SPICE_MODEL_BASE::m_sinDampFactor, DIALOG_SPICE_MODEL_BASE::m_sinDelay, DIALOG_SPICE_MODEL_BASE::m_sinFreq, DIALOG_SPICE_MODEL_BASE::m_sinOffset, and SPICE_VALUE::ToSpiceString().

Referenced by TransferDataToWindow().

314 {
315  if( aModel.IsEmpty() )
316  return false;
317 
318  wxStringTokenizer tokenizer( aModel, " ()" );
319  wxString tkn = tokenizer.GetNextToken().Lower();
320 
321  while( tokenizer.HasMoreTokens() )
322  {
323  // Variables used for generic values processing (filling out wxTextCtrls in sequence)
324  bool genericProcessing = false;
325  unsigned int genericReqParamsCount = 0;
326  std::vector<wxTextCtrl*> genericControls;
327 
328  if( tkn == "dc" )
329  {
330  // There might be an optional "dc" or "trans" directive, skip it
331  if( tkn == "dc" || tkn == "trans" )
332  tkn = tokenizer.GetNextToken().Lower();
333 
334  // DC value
335  try
336  {
337  m_genDc->SetValue( SPICE_VALUE( tkn ).ToSpiceString() );
338  }
339  catch( ... )
340  {
341  return false;
342  }
343  }
344 
345 
346  else if( tkn == "ac" )
347  {
348  // AC magnitude
349  try
350  {
351  tkn = tokenizer.GetNextToken().Lower();
352  m_genAcMag->SetValue( SPICE_VALUE( tkn ).ToSpiceString() );
353  }
354  catch( ... )
355  {
356  return false;
357  }
358 
359  // AC phase (optional)
360  try
361  {
362  tkn = tokenizer.GetNextToken().Lower();
363  m_genAcPhase->SetValue( SPICE_VALUE( tkn ).ToSpiceString() );
364  }
365  catch( ... )
366  {
367  continue; // perhaps another directive
368  }
369  }
370 
371 
372  else if( tkn == "pulse" )
373  {
374  m_powerNotebook->SetSelection( m_powerNotebook->FindPage( m_pwrPulse ) );
375 
376  genericProcessing = true;
377  genericReqParamsCount = 2;
378  genericControls = { m_pulseInit, m_pulseNominal, m_pulseDelay,
380  }
381 
382 
383  else if( tkn == "sin" )
384  {
385  m_powerNotebook->SetSelection( m_powerNotebook->FindPage( m_pwrSin ) );
386 
387  genericProcessing = true;
388  genericReqParamsCount = 2;
390  }
391 
392 
393  else if( tkn == "exp" )
394  {
395  m_powerNotebook->SetSelection( m_powerNotebook->FindPage( m_pwrExp ) );
396 
397  genericProcessing = true;
398  genericReqParamsCount = 2;
399  genericControls = { m_expInit, m_expPulsed,
401  }
402 
403 
404  else if( tkn == "pwl" )
405  {
406  m_powerNotebook->SetSelection( m_powerNotebook->FindPage( m_pwrPwl ) );
407 
408  try
409  {
410  while( tokenizer.HasMoreTokens() )
411  {
412  tkn = tokenizer.GetNextToken();
413  SPICE_VALUE time( tkn );
414 
415  tkn = tokenizer.GetNextToken();
416  SPICE_VALUE value( tkn );
417 
418  addPwlValue( time.ToSpiceString(), value.ToSpiceString() );
419  }
420  }
421  catch( ... )
422  {
423  return false;
424  }
425  }
426 
427 
428  else
429  {
430  // Unhandled power source type
431  wxASSERT_MSG( false, "Unhandled power source type" );
432  return false;
433  }
434 
435 
436  if( genericProcessing )
437  {
438  try
439  {
440  for( unsigned int i = 0; i < genericControls.size(); ++i )
441  {
442  // If there are no more tokens, let's check if we got at least required fields
443  if( !tokenizer.HasMoreTokens() )
444  return ( i >= genericReqParamsCount );
445 
446  tkn = tokenizer.GetNextToken().Lower();
447  genericControls[i]->SetValue( SPICE_VALUE( tkn ).ToSpiceString() );
448  }
449  }
450  catch( ... )
451  {
452  return false;
453  }
454  }
455 
456  // Get the next token now, so if any of the branches catches an expection, try to
457  // process it in another branch
458  tkn = tokenizer.GetNextToken().Lower();
459  }
460 
461  return true;
462 }
bool addPwlValue(const wxString &aTime, const wxString &aValue)
Adds a value to the PWL values list.
Helper class to handle Spice way of expressing values (e.g. 10.5 Meg)
Definition: spice_value.h:32
PROJECT & KIWAY_HOLDER::Prj ( ) const
inherited

Function Prj returns a reference to the PROJECT "associated with" this KIWAY.

Definition at line 34 of file kiway_holder.cpp.

References KIWAY_HOLDER::Kiway(), and KIWAY::Prj().

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), SCH_EDIT_FRAME::AppendOneEEProject(), PCB_EDIT_FRAME::ArchiveModulesOnBoard(), LIB_VIEW_FRAME::BestZoom(), DIALOG_MODULE_MODULE_EDITOR::BrowseAndAdd3DShapeFile(), DIALOG_MODULE_BOARD_EDITOR::BrowseAndAdd3DShapeFile(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::BrowseAndSelectDocFile(), DIALOG_EXCHANGE_MODULE::BrowseAndSelectFootprint(), CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX(), DIALOG_MODULE_MODULE_EDITOR::Cfg3DPath(), DIALOG_MODULE_BOARD_EDITOR::Cfg3DPath(), SCH_EDIT_FRAME::CheckAnnotate(), SCH_SCREEN::CheckComponentsToPartsLinks(), SCH_EDIT_FRAME::ConvertPart(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copyPanelToOptions(), SCH_EDIT_FRAME::CreateArchiveLibrary(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), DIALOG_PLOT_SCHEMATIC::createPlotFileName(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary(), LIB_EDIT_FRAME::DeleteOnePart(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_EESCHEMA_CONFIG::DIALOG_EESCHEMA_CONFIG(), DIALOG_FP_LIB_TABLE::DIALOG_FP_LIB_TABLE(), DIALOG_MODULE_MODULE_EDITOR::DIALOG_MODULE_MODULE_EDITOR(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), DIALOG_SCH_EDIT_ONE_FIELD::DIALOG_SCH_EDIT_ONE_FIELD(), LIB_VIEW_FRAME::DisplayLibInfos(), SCH_BASE_FRAME::DisplayListComponentsInLib(), PCB_EDIT_FRAME::doAutoSave(), DIALOG_MODULE_MODULE_EDITOR::Edit3DShapeFileName(), DIALOG_MODULE_BOARD_EDITOR::Edit3DShapeFileName(), SCH_EDIT_FRAME::EditComponentFieldText(), SCH_EDIT_FRAME::EditSheet(), PCB_EDIT_FRAME::Export_IDF3(), PCB_EDIT_FRAME::ExportToGenCAD(), PCB_EDIT_FRAME::ExportVRML_File(), PCB_EDIT_FRAME::Files_io_from_id(), PCB_EDIT_FRAME::GenD356File(), DIALOG_GENDRILL::GenDrillAndMapFiles(), NETLIST_DIALOG::GenNetlist(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), LIB_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), LIB_EDIT_FRAME::GetCurPart(), FOOTPRINT_EDIT_FRAME::GetCurrentLib(), FOOTPRINT_EDIT_FRAME::getLibPath(), DIALOG_BOM::getPluginFileName(), LIB_VIEW_FRAME::getSelectedAlias(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::InitBuffers(), DIALOG_MODULE_MODULE_EDITOR::initModeditProperties(), DIALOG_MODULE_BOARD_EDITOR::InitModeditProperties(), LIB_EDIT_FRAME::InstallConfigFrame(), SCH_EDIT_FRAME::InstallConfigFrame(), PCB_EDIT_FRAME::InstallNetlistFrame(), SCH_EDIT_FRAME::IsSearchCacheObsolete(), SCH_EDIT_FRAME::Load_Component(), SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile(), CVPCB_MAINFRAME::LoadFootprintFiles(), SCH_EDIT_FRAME::LoadOneEEFile(), LIB_EDIT_FRAME::LoadOneLibraryPart(), LIB_EDIT_FRAME::LoadOneSymbol(), CVPCB_MAINFRAME::LoadProjectFile(), SCH_EDIT_FRAME::LoadProjectFile(), PCB_EDIT_FRAME::LoadProjectSettings(), DIALOG_DRC_CONTROL::makeValidFileNameReport(), FOOTPRINT_VIEWER_FRAME::OnActivate(), DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick(), DIALOG_EESCHEMA_CONFIG::OnAddOrInsertPath(), DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick(), LIB_EDIT_FRAME::OnCloseWindow(), CVPCB_MAINFRAME::OnEditFootprintLibraryTable(), DIALOG_GENDRILL::OnGenReportFile(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), PCB_EDIT_FRAME::OnLeftClick(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnOKButtonClick(), DIALOG_NETLIST::OnOpenNetlistClick(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_SVG_PRINT::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), DIALOG_GEN_MODULE_POSITION::OnOutputDirectoryBrowseClicked(), LIB_EDIT_FRAME::OnPlotCurrentComponent(), SCH_EDIT_FRAME::OnRightClick(), DIALOG_BOM::OnRunPlugin(), DIALOG_NETLIST::OnSaveMessagesToFile(), SCH_EDIT_FRAME::OnSaveProject(), onSelectIcLib(), LIB_VIEW_FRAME::OnSelectSymbol(), SCH_EDIT_FRAME::OnSelectUnit(), onSemiSelectLib(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnTestChipName(), FOOTPRINT_EDIT_FRAME::OnUpdateSelectCurrentLib(), LIB_EDIT_FRAME::OnViewEntryDoc(), LIB_VIEW_FRAME::onViewSymbolDocument(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), SCH_EDIT_FRAME::PasteListOfItems(), PCB_EDITOR_CONTROL::PlaceModule(), SCH_EDIT_FRAME::prepareForNetlist(), SCH_EDIT_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Config(), SCH_EDIT_FRAME::Process_Special_Functions(), SCH_EDIT_FRAME::ProcessCmpToFootprintLinkFile(), FP_LOADER_THREAD::ProcessEntry(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), CVPCB_MAINFRAME::ReadNetListAndLinkFiles(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), LIB_VIEW_FRAME::ReCreateHToolbar(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), LIB_VIEW_FRAME::ReCreateListCmp(), LIB_VIEW_FRAME::ReCreateListLib(), LIB_VIEW_FRAME::RedrawActiveWindow(), EDA_3D_VIEWER::ReloadRequest(), SCH_EDIT_FRAME::RescueProject(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), SCH_SCREEN::Save(), LIB_EDIT_FRAME::SaveActiveLibrary(), SCH_EDIT_FRAME::SaveEEFile(), FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary(), LIB_EDIT_FRAME::SaveOneSymbol(), CVPCB_MAINFRAME::SaveProjectFile(), SCH_EDIT_FRAME::SaveProjectSettings(), PCB_EDIT_FRAME::SaveProjectSettings(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), SCH_BASE_FRAME::SelectComponentFromLibrary(), FOOTPRINT_VIEWER_FRAME::SelectCurrentFootprint(), PCB_BASE_FRAME::SelectLibrary(), SCH_BASE_FRAME::SelectLibraryFromList(), SCH_EDIT_FRAME::sendNetlist(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), LIB_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), LIB_EDIT_FRAME::SetCurPart(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::SetInitCmp(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), EDA_3D_VIEWER::takeScreenshot(), DIALOG_ERC::TestErc(), updateFromFile(), SIM_PLOT_FRAME::updateNetlistExporter(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), CVPCB_MAINFRAME::UpdateTitle(), FOOTPRINT_EDIT_FRAME::updateTitle(), SCH_EDIT_FRAME::WriteNetListFile(), DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR(), and DIALOG_MODULE_MODULE_EDITOR::~DIALOG_MODULE_MODULE_EDITOR().

35 {
36  return Kiway().Prj();
37 }
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_player.h:60
VTBL_ENTRY PROJECT & Prj() const
Function Prj returns the PROJECT associated with this KIWAY.
Definition: kiway.cpp:144
void KIWAY_HOLDER::SetKiway ( wxWindow *  aDest,
KIWAY aKiway 
)
inherited

Function SetKiway.

Parameters
aDestis the recipient of aKiway pointer. It is only used for debugging, since "this" is not a wxWindow*. "this" is a KIWAY_HOLDER mix-in.
aKiwayis often from a parent window, or from KIFACE::CreateWindow().

Definition at line 41 of file kiway_holder.cpp.

References KIWAY_HOLDER::m_kiway.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), and SIM_PLOT_FRAME::SIM_PLOT_FRAME().

42 {
43 #if defined(DEBUG)
44  // offer a trap point for debugging most any window
45  wxASSERT( aDest );
46  if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
47  {
48  int breakhere=1;
49  (void) breakhere;
50  }
51 #endif
52 
53  (void) aDest;
54 
55  m_kiway = aKiway;
56 }
KIWAY * m_kiway
Definition: kiway_player.h:85
bool DIALOG_SHIM::Show ( bool  show)
overrideinherited

Definition at line 138 of file dialog_shim.cpp.

References class_map, DIALOG_SHIM::FixOSXCancelButtonIssue(), EDA_RECT::GetPosition(), EDA_RECT::GetSize(), DIALOG_SHIM::m_hash_key, wxPoint::x, and wxPoint::y.

Referenced by DisplayHotkeyList(), DIALOG_SHIM::EndQuasiModal(), InvokeDialogERC(), DIALOG_SCH_FIND::OnCancel(), DIALOG_DRC_CONTROL::OnLeftDClickClearance(), DIALOG_DRC_CONTROL::OnLeftDClickUnconnected(), DIALOG_DRC_CONTROL::OnPopupMenu(), DIALOG_EXCHANGE_MODULE::OnQuit(), CVPCB_MAINFRAME::ReadNetListAndLinkFiles(), DRC::ShowDRCDialog(), and DIALOG_SHIM::ShowQuasiModal().

139 {
140  bool ret;
141  const char* hash_key;
142 
143  if( m_hash_key.size() )
144  {
145  // a special case like EDA_LIST_DIALOG, which has multiple uses.
146  hash_key = m_hash_key.c_str();
147  }
148  else
149  {
150  hash_key = typeid(*this).name();
151  }
152 
153  // Show or hide the window. If hiding, save current position and size.
154  // If showing, use previous position and size.
155  if( show )
156  {
157  wxDialog::Raise(); // Needed on OS X and some other window managers (i.e. Unity)
158  ret = wxDialog::Show( show );
159 
160  // classname is key, returns a zeroed out default EDA_RECT if none existed before.
161  EDA_RECT r = class_map[ hash_key ];
162 
163  if( r.GetSize().x != 0 && r.GetSize().y != 0 )
164  SetSize( r.GetPosition().x, r.GetPosition().y, r.GetSize().x, r.GetSize().y, 0 );
165  }
166  else
167  {
168  // Save the dialog's position & size before hiding, using classname as key
169  EDA_RECT r( wxDialog::GetPosition(), wxDialog::GetSize() );
170  class_map[ hash_key ] = r;
171 
172  ret = wxDialog::Show( show );
173  }
174 
176 
177  return ret;
178 }
std::string m_hash_key
Definition: dialog_shim.h:128
void FixOSXCancelButtonIssue()
A ugly hack to fix an issue on OSX: when typing ctrl+c in a wxTextCtrl inside a dialog, it is closed instead of copying a text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer, when the dlg is created by wxFormBuilder: the label is &Cancel, and this accelerator key has priority to copy text standard accelerator, and the dlg is closed when trying to copy text this function do nothing on other platforms.
static RECT_MAP class_map
const wxPoint & GetPosition() const
Class EDA_RECT handles the component boundary box.
const wxSize & GetSize() const
int DIALOG_SHIM::ShowQuasiModal ( )
inherited

Definition at line 494 of file dialog_shim.cpp.

References DBG, DIALOG_SHIM::m_qmodal_loop, DIALOG_SHIM::m_qmodal_parent_disabler, DIALOG_SHIM::m_qmodal_showing, and DIALOG_SHIM::Show().

Referenced by LIB_EDIT_FRAME::DeleteOnePart(), SCH_EDIT_FRAME::EditComponent(), SCH_EDIT_FRAME::EditComponentFieldText(), LIB_EDIT_FRAME::EditField(), EDIT_TOOL::ExchangeFootprints(), PCB_EDIT_FRAME::InstallExchangeModuleFrame(), LIB_EDIT_FRAME::InstallFieldsEditorDialog(), LIB_VIEW_FRAME::OnSelectSymbol(), and SCH_BASE_FRAME::SelectComponentFromLibrary().

495 {
496  // This is an exception safe way to zero a pointer before returning.
497  // Yes, even though DismissModal() clears this first normally, this is
498  // here in case there's an exception before the dialog is dismissed.
499  struct NULLER
500  {
501  void*& m_what;
502  NULLER( void*& aPtr ) : m_what( aPtr ) {}
503  ~NULLER() { m_what = 0; } // indeed, set it to NULL on destruction
504  } clear_this( (void*&) m_qmodal_loop );
505 
506  // release the mouse if it's currently captured as the window having it
507  // will be disabled when this dialog is shown -- but will still keep the
508  // capture making it impossible to do anything in the modal dialog itself
509  wxWindow* win = wxWindow::GetCapture();
510  if( win )
511  win->ReleaseMouse();
512 
513  // Get the optimal parent
514  wxWindow* parent = GetParentForModalDialog( GetParent(), GetWindowStyle() );
515 
516  // Show the optimal parent
517  DBG( if( parent ) printf( "%s: optimal parent: %s\n", __func__, typeid(*parent).name() );)
518 
519  wxASSERT_MSG( !m_qmodal_parent_disabler,
520  wxT( "Caller using ShowQuasiModal() twice on same window?" ) );
521 
522  // quasi-modal: disable only my "optimal" parent
524 
525  Show( true );
526 
527  m_qmodal_showing = true;
528 
529  EVENT_LOOP event_loop;
530 
531  m_qmodal_loop = &event_loop;
532 
533  event_loop.Run();
534 
535  return GetReturnCode();
536 }
bool m_qmodal_showing
Definition: dialog_shim.h:132
EVENT_LOOP * m_qmodal_loop
Definition: dialog_shim.h:131
bool Show(bool show) override
WDO_ENABLE_DISABLE * m_qmodal_parent_disabler
Definition: dialog_shim.h:133
Toggle a window's "enable" status to disabled, then enabled on destruction.
Definition: dialog_shim.cpp:33
#define DBG(x)
Definition: fctsys.h:33
bool DIALOG_SPICE_MODEL::TransferDataFromWindow ( )
overrideprivatevirtual

Definition at line 101 of file dialog_spice_model.cpp.

References empty(), generatePowerSource(), getField(), NETLIST_EXPORTER_PSPICE::GetSpiceFieldName(), DIALOG_SPICE_MODEL_BASE::m_disabled, m_fields, m_fieldsTmp, DIALOG_SPICE_MODEL_BASE::m_ic, DIALOG_SPICE_MODEL_BASE::m_icLib, DIALOG_SPICE_MODEL_BASE::m_icModel, DIALOG_SPICE_MODEL_BASE::m_nodeSeqCheck, DIALOG_SPICE_MODEL_BASE::m_nodeSeqVal, DIALOG_SPICE_MODEL_BASE::m_notebook, DIALOG_SPICE_MODEL_BASE::m_passive, DIALOG_SPICE_MODEL_BASE::m_pasType, DIALOG_SPICE_MODEL_BASE::m_pasValue, DIALOG_SPICE_MODEL_BASE::m_power, DIALOG_SPICE_MODEL_BASE::m_pwrType, DIALOG_SPICE_MODEL_BASE::m_semiconductor, DIALOG_SPICE_MODEL_BASE::m_semiLib, DIALOG_SPICE_MODEL_BASE::m_semiModel, DIALOG_SPICE_MODEL_BASE::m_semiType, EDA_TEXT::SetText(), SF_ENABLED, SF_END, SF_LIB_FILE, SF_MODEL, SF_NODE_SEQUENCE, SF_PRIMITIVE, SP_BJT, SP_CAPACITOR, SP_DIODE, SP_INDUCTOR, SP_ISOURCE, SP_MOSFET, SP_RESISTOR, SP_SUBCKT, and SP_VSOURCE.

102 {
103  if( !DIALOG_SPICE_MODEL_BASE::TransferDataFromWindow() )
104  return false;
105 
106  wxWindow* page = m_notebook->GetCurrentPage();
107 
108  // Passive
109  if( page == m_passive )
110  {
111  if( !m_passive->Validate() )
112  return false;
113 
114  switch( m_pasType->GetSelection() )
115  {
116  case 0: m_fieldsTmp[SF_PRIMITIVE] = (char) SP_RESISTOR; break;
117  case 1: m_fieldsTmp[SF_PRIMITIVE] = (char) SP_CAPACITOR; break;
118  case 2: m_fieldsTmp[SF_PRIMITIVE] = (char) SP_INDUCTOR; break;
119 
120  default:
121  wxASSERT_MSG( false, "Unhandled passive type" );
122  return false;
123  break;
124  }
125 
126  m_fieldsTmp[SF_MODEL] = m_pasValue->GetValue();
127  }
128 
129 
130  // Semiconductor
131  else if( page == m_semiconductor )
132  {
133  if( !m_semiconductor->Validate() )
134  return false;
135 
136  switch( m_semiType->GetSelection() )
137  {
138  case 0: m_fieldsTmp[SF_PRIMITIVE] = (char) SP_DIODE; break;
139  case 1: m_fieldsTmp[SF_PRIMITIVE] = (char) SP_BJT; break;
140  case 2: m_fieldsTmp[SF_PRIMITIVE] = (char) SP_MOSFET; break;
141 
142  default:
143  wxASSERT_MSG( false, "Unhandled semiconductor type" );
144  return false;
145  break;
146  }
147 
148  m_fieldsTmp[SF_MODEL] = m_semiModel->GetValue();
149 
150  if( !empty( m_semiLib ) )
151  m_fieldsTmp[SF_LIB_FILE] = m_semiLib->GetValue();
152  }
153 
154 
155  // Integrated circuit
156  else if( page == m_ic )
157  {
158  if( !m_ic->Validate() )
159  return false;
160 
162  m_fieldsTmp[SF_MODEL] = m_icModel->GetValue();
163 
164  if( !empty( m_icLib ) )
165  m_fieldsTmp[SF_LIB_FILE] = m_icLib->GetValue();
166  }
167 
168 
169  // Power source
170  else if( page == m_power )
171  {
172  wxString model;
173 
174  if( !generatePowerSource( model ) )
175  return false;
176 
177  m_fieldsTmp[SF_PRIMITIVE] = (char)( m_pwrType->GetSelection() ? SP_ISOURCE : SP_VSOURCE );
178  m_fieldsTmp[SF_MODEL] = model;
179  }
180 
181 
182  else
183  {
184  wxASSERT_MSG( false, "Unhandled model type" );
185  return false;
186  }
187 
188  m_fieldsTmp[SF_ENABLED] = !m_disabled->GetValue() ? "Y" : "N"; // note bool inversion
189  m_fieldsTmp[SF_NODE_SEQUENCE] = m_nodeSeqCheck->IsChecked() ? m_nodeSeqVal->GetValue() : "";
190 
191  // Apply the settings
192  for( int i = 0; i < SF_END; ++i )
193  {
194  if( m_fieldsTmp.count( (SPICE_FIELD) i ) > 0 && !m_fieldsTmp.at( i ).IsEmpty() )
195  {
196  getField( i ).SetText( m_fieldsTmp[i] );
197  }
198  else
199  {
200  // Erase empty fields (having empty fields causes a warning in the properties dialog)
201  const wxString& spiceField = NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( (SPICE_FIELD) i );
202 
203  auto fieldIt = std::find_if( m_fields.begin(), m_fields.end(), [&]( const SCH_FIELD& f ) {
204  return f.GetName() == spiceField;
205  } );
206 
207  if( fieldIt != m_fields.end() )
208  m_fields.erase( fieldIt );
209  }
210  }
211 
212  return true;
213 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
SCH_FIELD & getField(int aFieldType)
Returns or creates a field in the edited schematic fields vector.
static const wxString & GetSpiceFieldName(SPICE_FIELD aField)
Returns a string used for a particular component field related to Spice simulation.
bool generatePowerSource(wxString &aTarget) const
Generates a string to describe power source parameters, basing on the current selection.
static bool empty(const wxTextCtrl *aCtrl)
std::map< int, wxString > m_fieldsTmp
Temporary field values
SCH_FIELDS & m_fields
Fields from the component properties dialog
virtual void SetText(const wxString &aText)
Definition: eda_text.h:141
bool DIALOG_SPICE_MODEL::TransferDataToWindow ( )
overrideprivatevirtual

Definition at line 216 of file dialog_spice_model.cpp.

References empty(), NETLIST_EXPORTER_PSPICE::GetSpiceFieldDefVal(), NETLIST_EXPORTER_PSPICE::GetSpiceFields(), m_component, DIALOG_SPICE_MODEL_BASE::m_disabled, m_fields, m_fieldsTmp, DIALOG_SPICE_MODEL_BASE::m_ic, DIALOG_SPICE_MODEL_BASE::m_icLib, DIALOG_SPICE_MODEL_BASE::m_icModel, DIALOG_SPICE_MODEL_BASE::m_nodeSeqCheck, DIALOG_SPICE_MODEL_BASE::m_nodeSeqVal, DIALOG_SPICE_MODEL_BASE::m_notebook, DIALOG_SPICE_MODEL_BASE::m_passive, DIALOG_SPICE_MODEL_BASE::m_pasType, DIALOG_SPICE_MODEL_BASE::m_pasValue, DIALOG_SPICE_MODEL_BASE::m_power, DIALOG_SPICE_MODEL_BASE::m_pwrType, DIALOG_SPICE_MODEL_BASE::m_semiconductor, DIALOG_SPICE_MODEL_BASE::m_semiLib, DIALOG_SPICE_MODEL_BASE::m_semiModel, DIALOG_SPICE_MODEL_BASE::m_semiType, NET_ADJUST_INCLUDE_PATHS, NET_ADJUST_PASSIVE_VALS, parsePowerSource(), SF_ENABLED, SF_LIB_FILE, SF_MODEL, SF_NODE_SEQUENCE, SF_PRIMITIVE, SP_BJT, SP_CAPACITOR, SP_DIODE, SP_INDUCTOR, SP_ISOURCE, SP_MOSFET, SP_RESISTOR, SP_SUBCKT, SP_VSOURCE, NETLIST_EXPORTER_PSPICE::StringToBool(), and updateFromFile().

Referenced by onInitDlg().

217 {
218  const auto& spiceFields = NETLIST_EXPORTER_PSPICE::GetSpiceFields();
219 
220  // Fill out the working buffer
221  for( unsigned int idx = 0; idx < spiceFields.size(); ++idx )
222  {
223  const wxString& spiceField = spiceFields[idx];
224 
225  auto fieldIt = std::find_if( m_fields.begin(), m_fields.end(), [&]( const SCH_FIELD& f ) {
226  return f.GetName() == spiceField;
227  } );
228 
229  // Do not modify the existing value, just add missing fields with default values
230  if( fieldIt != m_fields.end() && !fieldIt->GetText().IsEmpty() )
231  m_fieldsTmp[idx] = fieldIt->GetText();
232  else
235  }
236 
237  // Analyze the component fields to fill out the dialog
238  char primitive = toupper( m_fieldsTmp[SF_PRIMITIVE][0] );
239 
240  switch( primitive )
241  {
242  case SP_RESISTOR:
243  case SP_CAPACITOR:
244  case SP_INDUCTOR:
245  m_notebook->SetSelection( m_notebook->FindPage( m_passive ) );
246  m_pasType->SetSelection( primitive == SP_RESISTOR ? 0
247  : primitive == SP_CAPACITOR ? 1
248  : primitive == SP_INDUCTOR ? 2
249  : -1 );
250  m_pasValue->SetValue( m_fieldsTmp[SF_MODEL] );
251  break;
252 
253  case SP_DIODE:
254  case SP_BJT:
255  case SP_MOSFET:
256  m_notebook->SetSelection( m_notebook->FindPage( m_semiconductor ) );
257  m_semiType->SetSelection( primitive == SP_DIODE ? 0
258  : primitive == SP_BJT ? 1
259  : primitive == SP_MOSFET ? 2
260  : -1 );
261  m_semiModel->SetValue( m_fieldsTmp[SF_MODEL] );
262  m_semiLib->SetValue( m_fieldsTmp[SF_LIB_FILE] );
263 
264  if( !empty( m_semiLib ) )
265  {
266  const wxString& libFile = m_semiLib->GetValue();
267  m_fieldsTmp[SF_LIB_FILE] = libFile;
268  updateFromFile( m_semiModel, libFile, ".model" );
269  }
270  break;
271 
272  case SP_SUBCKT:
273  m_notebook->SetSelection( m_notebook->FindPage( m_ic ) );
274  m_icModel->SetValue( m_fieldsTmp[SF_MODEL] );
275  m_icLib->SetValue( m_fieldsTmp[SF_LIB_FILE] );
276 
277  if( !empty( m_icLib ) )
278  {
279  const wxString& libFile = m_icLib->GetValue();
280  m_fieldsTmp[SF_LIB_FILE] = libFile;
281  updateFromFile( m_icModel, libFile, ".subckt" );
282  }
283  break;
284 
285  case SP_VSOURCE:
286  case SP_ISOURCE:
287  if( !parsePowerSource( m_fieldsTmp[SF_MODEL] ) )
288  return false;
289 
290  m_notebook->SetSelection( m_notebook->FindPage( m_power ) );
291  m_pwrType->SetSelection( primitive == SP_ISOURCE ? 1 : 0 );
292  break;
293 
294  default:
295  //wxASSERT_MSG( false, "Unhandled Spice primitive type" );
296  break;
297  }
298 
300 
301  // Check if node sequence is different than the default one
304  {
305  m_nodeSeqCheck->SetValue( true );
307  }
308 
309  return DIALOG_SPICE_MODEL_BASE::TransferDataToWindow();
310 }
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
SCH_COMPONENT & m_component
Edited component
static bool StringToBool(const wxString &aStr)
Convertes typical boolean string values (no/yes, true/false, 1/0) to a boolean value.
bool parsePowerSource(const wxString &aModel)
Parse a string describing a power source, so appropriate settings are checked in the dialog...
static wxString GetSpiceFieldDefVal(SPICE_FIELD aField, SCH_COMPONENT *aComponent, unsigned aCtl)
Retrieves the default value for a given field.
static bool empty(const wxTextCtrl *aCtrl)
std::map< int, wxString > m_fieldsTmp
Temporary field values
SCH_FIELDS & m_fields
Fields from the component properties dialog
void updateFromFile(wxComboBox *aComboBox, const wxString &aFilePath, const wxString &aKeyword)
Loads a list of components from a file and adds them to a combo box.
static const std::vector< wxString > & GetSpiceFields()
Returns a vector of component field names related to Spice simulation.
void DIALOG_SPICE_MODEL::updateFromFile ( wxComboBox *  aComboBox,
const wxString &  aFilePath,
const wxString &  aKeyword 
)
private

Loads a list of components from a file and adds them to a combo box.

Parameters
aComboBoxis the target combo box
aFilePathis the file to be processed
aKeywordis the keyword to select the type of components (e.g. "subckt" or "model")

Definition at line 618 of file dialog_spice_model.cpp.

References KIWAY_HOLDER::Prj().

Referenced by onSelectIcLib(), onSemiSelectLib(), and TransferDataToWindow().

620 {
621  wxString curValue = aComboBox->GetValue();
622  const wxString keyword( aKeyword.Lower() );
623  wxFileName filePath( aFilePath );
624 
625  if( !filePath.Exists() )
626  {
627  // Look for the file in the project path
628  filePath.SetPath( Prj().GetProjectPath() + filePath.GetPath() );
629  }
630 
631  wxTextFile file;
632 
633  if( !file.Open( filePath.GetFullPath() ) )
634  return;
635 
636  aComboBox->Clear();
637 
638  // Process the file, looking for components
639  for( wxString line = file.GetFirstLine().Lower(); !file.Eof(); line = file.GetNextLine() )
640  {
641  wxStringTokenizer tokenizer( line, " " );
642 
643  while( tokenizer.HasMoreTokens() )
644  {
645  wxString token = tokenizer.GetNextToken().Lower();
646 
647  if( token == keyword )
648  {
649  token = tokenizer.GetNextToken();
650 
651  if( !token.IsEmpty() )
652  aComboBox->Append( token );
653  }
654  }
655  }
656 
657  // Restore the previous value or if there is none - pick the first one from the loaded library
658  if( !curValue.IsEmpty() )
659  aComboBox->SetValue( curValue );
660  else if( aComboBox->GetCount() > 0 )
661  aComboBox->SetSelection( 0 );
662 }
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
virtual bool DIALOG_SPICE_MODEL::Validate ( )
inlineoverrideprivatevirtual

Definition at line 86 of file dialog_spice_model.h.

87  {
88  return true;
89  }

Member Data Documentation

SCH_COMPONENT& DIALOG_SPICE_MODEL::m_component
private

Edited component

Definition at line 107 of file dialog_spice_model.h.

Referenced by getField(), and TransferDataToWindow().

wxCheckBox* DIALOG_SPICE_MODEL_BASE::m_disabled
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_expFallConst
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_expFallDelay
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_expInit
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_expPulsed
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_expRiseConst
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_expRiseDelay
protectedinherited
SCH_FIELDS& DIALOG_SPICE_MODEL::m_fields
private

Fields from the component properties dialog

Definition at line 110 of file dialog_spice_model.h.

Referenced by getField(), TransferDataFromWindow(), and TransferDataToWindow().

std::map<int, wxString> DIALOG_SPICE_MODEL::m_fieldsTmp
private

Temporary field values

Definition at line 113 of file dialog_spice_model.h.

Referenced by TransferDataFromWindow(), and TransferDataToWindow().

wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_genAcMag
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_genAcPhase
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_genDc
protectedinherited
std::string DIALOG_SHIM::m_hash_key
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_ic
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_icLib
protectedinherited
wxComboBox* DIALOG_SPICE_MODEL_BASE::m_icModel
protectedinherited
wxButton* DIALOG_SPICE_MODEL_BASE::m_icSelectLib
protectedinherited
wxCheckBox* DIALOG_SPICE_MODEL_BASE::m_nodeSeqCheck
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_nodeSeqVal
protectedinherited
wxNotebook* DIALOG_SPICE_MODEL_BASE::m_notebook
protectedinherited
wxTextValidator DIALOG_SPICE_MODEL::m_notEmptyValidator
private

Definition at line 120 of file dialog_spice_model.h.

Referenced by DIALOG_SPICE_MODEL().

wxPanel* DIALOG_SPICE_MODEL_BASE::m_passive
protectedinherited
wxComboBox* DIALOG_SPICE_MODEL_BASE::m_pasType
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_pasValue
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_power
protectedinherited
wxNotebook* DIALOG_SPICE_MODEL_BASE::m_powerNotebook
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_pulseDelay
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_pulseFall
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_pulseInit
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_pulseNominal
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_pulsePeriod
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_pulseRise
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_pulseWidth
protectedinherited
wxButton* DIALOG_SPICE_MODEL_BASE::m_pwlAddButton
protectedinherited
wxButton* DIALOG_SPICE_MODEL_BASE::m_pwlRemoveBtn
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_pwlTime
protectedinherited
long DIALOG_SPICE_MODEL::m_pwlTimeCol
private

Column identifiers for PWL power source value list

Definition at line 116 of file dialog_spice_model.h.

Referenced by addPwlValue(), DIALOG_SPICE_MODEL(), and generatePowerSource().

wxListCtrl* DIALOG_SPICE_MODEL_BASE::m_pwlValList
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_pwlValue
protectedinherited
long DIALOG_SPICE_MODEL::m_pwlValueCol
private

Definition at line 116 of file dialog_spice_model.h.

Referenced by addPwlValue(), DIALOG_SPICE_MODEL(), and generatePowerSource().

wxPanel* DIALOG_SPICE_MODEL_BASE::m_pwrAm
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_pwrExp
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_pwrExtData
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_pwrFm
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_pwrPulse
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_pwrPwl
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_pwrRandom
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_pwrSin
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_pwrTransNoise
protectedinherited
wxRadioBox* DIALOG_SPICE_MODEL_BASE::m_pwrType
protectedinherited
EVENT_LOOP* DIALOG_SHIM::m_qmodal_loop
protectedinherited

Definition at line 131 of file dialog_shim.h.

Referenced by DIALOG_SHIM::EndQuasiModal(), and DIALOG_SHIM::ShowQuasiModal().

WDO_ENABLE_DISABLE* DIALOG_SHIM::m_qmodal_parent_disabler
protectedinherited
bool DIALOG_SHIM::m_qmodal_showing
protectedinherited
wxStdDialogButtonSizer* DIALOG_SPICE_MODEL_BASE::m_sdbSizer
protectedinherited
wxButton* DIALOG_SPICE_MODEL_BASE::m_sdbSizerCancel
protectedinherited
wxButton* DIALOG_SPICE_MODEL_BASE::m_sdbSizerOK
protectedinherited
wxPanel* DIALOG_SPICE_MODEL_BASE::m_semiconductor
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_semiLib
protectedinherited
wxComboBox* DIALOG_SPICE_MODEL_BASE::m_semiModel
protectedinherited
wxButton* DIALOG_SPICE_MODEL_BASE::m_semiSelectLib
protectedinherited
wxComboBox* DIALOG_SPICE_MODEL_BASE::m_semiType
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_sinAmplitude
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_sinDampFactor
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_sinDelay
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_sinFreq
protectedinherited
wxTextCtrl* DIALOG_SPICE_MODEL_BASE::m_sinOffset
protectedinherited
SPICE_VALIDATOR DIALOG_SPICE_MODEL::m_spiceEmptyValidator
private

Definition at line 119 of file dialog_spice_model.h.

Referenced by DIALOG_SPICE_MODEL().

SPICE_VALIDATOR DIALOG_SPICE_MODEL::m_spiceValidator
private

Definition at line 118 of file dialog_spice_model.h.

Referenced by DIALOG_SPICE_MODEL().

wxStaticLine* DIALOG_SPICE_MODEL_BASE::m_staticline1
protectedinherited
wxStaticLine* DIALOG_SPICE_MODEL_BASE::m_staticline2
protectedinherited
wxStaticLine* DIALOG_SPICE_MODEL_BASE::m_staticline3
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText10
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText11
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText12
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText13
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText14
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText15
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText16
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText17
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText18
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText2
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText20
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText21
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText22
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText23
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText24
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText25
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText26
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText27
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText28
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText29
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText3
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText30
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText31
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText32
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText321
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText34
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText341
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText35
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText351
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText36
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText37
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText38
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText39
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText4
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText40
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText41
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText42
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText43
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText44
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText45
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText46
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText47
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText48
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText49
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText5
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText50
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText51
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText52
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText53
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText54
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText55
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText56
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText57
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText58
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText59
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText60
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText62
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText63
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText7
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText8
protectedinherited
wxStaticText* DIALOG_SPICE_MODEL_BASE::m_staticText9
protectedinherited

The documentation for this class was generated from the following files: