40#include <wx/filedlg.h>
41#include <fmt/format.h>
47#include <wx/filedlg.h>
52#define FORCE_REFRESH_FROM_MODEL true
55bool equivalent( SIM_MODEL::DEVICE_T a, SIM_MODEL::DEVICE_T b )
66 std::vector<SCH_FIELD>& aFields ) :
85 if constexpr (std::is_same_v<T, SCH_SYMBOL>)
91 if(
EMBEDDED_FILES* symbolEmbeddedFiles = aSymbol.GetEmbeddedFiles() )
93 m_filesStack.push_back( symbolEmbeddedFiles );
95 if constexpr (std::is_same_v<T, SCH_SYMBOL>)
97 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( &aSymbol );
98 symbol->GetLibSymbolRef()->AppendParentEmbeddedFiles( m_filesStack );
100 else if constexpr (std::is_same_v<T, LIB_SYMBOL>)
107 m_libraryModelsMgr.SetFilesStack( m_filesStack );
108 m_builtinModelsMgr.SetFilesStack( m_filesStack );
113 if( !pin->GetParentSymbol()->IsMultiBodyStyle() || pin->GetBodyStyle() < 2 )
114 m_sortedPartPins.push_back( pin );
117 std::sort( m_sortedPartPins.begin(), m_sortedPartPins.end(),
121 return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0;
124 m_waveformChoice->Clear();
125 m_deviceChoice->Clear();
126 m_deviceSubtypeChoice->Clear();
128 m_scintillaTricksCode =
new SCINTILLA_TRICKS( m_codePreview, wxT(
"{}" ),
false );
129 m_scintillaTricksSubckt =
new SCINTILLA_TRICKS( m_subckt, wxT(
"()" ),
false );
133 wxPropertyGrid*
grid = m_paramGrid->GetGrid();
134 grid->SetCellDisabledTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
138 grid->DedicateKey( WXK_RETURN );
139 grid->DedicateKey( WXK_NUMPAD_ENTER );
140 grid->DedicateKey( WXK_UP );
141 grid->DedicateKey( WXK_DOWN );
143#if wxCHECK_VERSION( 3, 3, 0 )
144 grid->AddActionTrigger( wxPGKeyboardAction::Edit, WXK_RETURN );
145 grid->AddActionTrigger( wxPGKeyboardAction::NextProperty, WXK_RETURN );
146 grid->AddActionTrigger( wxPGKeyboardAction::Edit, WXK_NUMPAD_ENTER );
147 grid->AddActionTrigger( wxPGKeyboardAction::NextProperty, WXK_NUMPAD_ENTER );
149 grid->AddActionTrigger( wxPG_ACTION_EDIT, WXK_RETURN );
150 grid->AddActionTrigger( wxPG_ACTION_NEXT_PROPERTY, WXK_RETURN );
151 grid->AddActionTrigger( wxPG_ACTION_EDIT, WXK_NUMPAD_ENTER );
152 grid->AddActionTrigger( wxPG_ACTION_NEXT_PROPERTY, WXK_NUMPAD_ENTER );
155 m_pinAssignmentsGrid->ClearRows();
156 m_pinAssignmentsGrid->PushEventHandler(
new GRID_TRICKS( m_pinAssignmentsGrid ) );
159 finishDialogSettings();
168 for( wxPropertyGridIterator it =
m_paramGrid->GetIterator(); !it.AtEnd(); ++it )
185 wxCommandEvent dummyEvent;
188 wxString modelParams;
190 bool storeInValue =
false;
196 &deviceType, &modelType, &modelParams, &pinMap ) )
200 if( !modelType.IsEmpty() )
215 valueField->
SetText( wxT(
"${SIM.PARAMS}" ) );
219 wxFileName tmp( libraryFilename );
221 if( !tmp.GetFullName().IsEmpty() )
246 if( modelIdx == wxNOT_FOUND )
248 m_infoBar->ShowMessage( wxString::Format(
_(
"No model named '%s' in library." ), modelName ) );
279 for(
const std::pair<std::string, std::string>& strs : ibismodel->
GetIbisPins() )
285 ibismodel->
ChangePin( *ibisLibrary, strs.first );
292 if( i <
static_cast<int>( ibismodel->
GetIbisPins().size() ) )
319 if( ibisLibrary && !pinNum.empty() && !modelNm.empty() )
320 ibismodel->
SetIbisModel( *ibisLibrary, pinNum, modelNm );
337 for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
347 + wxT(
"\n\n" ) +
reporter.GetMessages() );
362 curModel().SetIsStoredInValue(
true );
369 return DIALOG_SIM_MODEL_BASE::TransferDataToWindow();
379 if( !
m_paramGrid->GetGrid()->CommitChangesFromEditor() )
382 if( !DIALOG_SIM_MODEL_BASE::TransferDataFromWindow() )
392 wxFileName fn(
path );
395 && !fn.GetFullPath().StartsWith(
".." ) )
397 path = fn.GetFullPath();
424 std::string differential;
427 pins = ibismodel->GetIbisPins().at(
m_pinCombobox->GetSelection() ).first;
438 if(
model.GetType() == SIM_MODEL::TYPE::RAWSPICE )
443 wxString code =
m_codePreview->GetText().Trim(
true ).Trim(
false );
444 model.SetParamValue(
"model", std::string( code.ToUTF8() ) );
455 std::string( symbolPinName.ToUTF8() ) );
463 model.IsStoredInValue() );
475 wxStringTokenizer sharedTokens(
m_sharedPinsText->GetValue(), wxS(
", \t" ),
478 while( sharedTokens.HasMoreTokens() )
479 decomposition.
sharedModelPins.push_back( sharedTokens.GetNextToken() );
493 const wxString& aOriginalValue,
bool aOverwritten,
494 bool aStoredInValue )
496 if( !aOverwritten || aStoredInValue )
500 valueField->SetText( aOriginalValue );
507 bool multiUnit =
m_symbol.GetUnitCount() > 1;
527 if( !shared.IsEmpty() )
528 shared += wxS(
", " );
599 SendSizeEvent( wxSEND_EVENT_POST );
623 for( SIM_MODEL::TYPE type : { SIM_MODEL::TYPE::KIBIS_DEVICE,
624 SIM_MODEL::TYPE::KIBIS_DRIVER_DC,
625 SIM_MODEL::TYPE::KIBIS_DRIVER_RECT,
626 SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS } )
636 if( type == aModel->
GetType() )
659 for( SIM_MODEL::DEVICE_T deviceType : SIM_MODEL::DEVICE_T_ITERATOR() )
670 for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
672 if( type == SIM_MODEL::TYPE::KIBIS_DEVICE
673 || type == SIM_MODEL::TYPE::KIBIS_DRIVER_DC
674 || type == SIM_MODEL::TYPE::KIBIS_DRIVER_RECT
675 || type == SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS )
688 if( type == aModel->
GetType() )
745 m_paramGrid->Append(
new wxPropertyCategory(
"AC" ) );
748 m_paramGrid->Append(
new wxPropertyCategory(
"DC" ) );
751 m_paramGrid->Append(
new wxPropertyCategory(
"S-Parameters" ) );
754 m_paramGrid->Append(
new wxPropertyCategory(
"Capacitance" ) );
757 m_paramGrid->Append(
new wxPropertyCategory(
"Temperature" ) );
760 m_paramGrid->Append(
new wxPropertyCategory(
"Noise" ) );
763 m_paramGrid->Append(
new wxPropertyCategory(
"Distributed Quantities" ) );
764 m_paramGrid->HideProperty(
"Distributed Quantities" );
766 m_paramGrid->Append(
new wxPropertyCategory(
"Waveform" ) );
769 m_paramGrid->Append(
new wxPropertyCategory(
"Limiting Values" ) );
772 m_paramGrid->Append(
new wxPropertyCategory(
"Advanced" ) );
775 m_paramGrid->Append(
new wxPropertyCategory(
"Flags" ) );
792 for( wxPropertyGridIterator it =
m_paramGrid->GetIterator(); !it.AtEnd(); ++it )
794 wxColour bgCol =
m_paramGrid->GetGrid()->GetPropertyDefaultCell().GetBgCol();
795 wxColour fgCol =
m_paramGrid->GetGrid()->GetPropertyDefaultCell().GetFgCol();
799 ( *it )->GetCell( col ).SetBgCol( bgCol );
800 ( *it )->GetCell( col ).SetFgCol( fgCol );
814 ( *it )->SetValueFromString( param.
value );
857 aForceRefreshFromModel =
true;
860 if( aForceRefreshFromModel )
867 for(
int modelPinIndex = 0; modelPinIndex < aModel->
GetPinCount(); ++modelPinIndex )
871 if( symbolPinNumber ==
"" )
876 if( symbolPinRow == -1 )
887 std::vector<BITMAPS> modelPinIcons;
888 wxArrayString modelPinChoices;
890 for(
int jj = 0; jj < aModel->
GetPinCount(); ++jj )
901 modelPinChoices.Add(
_(
"Not Connected" ) );
910 if( modelPinIndex >= 0 )
916 if( aModel->
GetType() == SIM_MODEL::TYPE::SUBCKT )
962 wxArrayString emptyArray;
977 for(
const auto& [baseModelName, baseModel] :
library()->GetModels() )
979 if( baseModelName == modelName )
987 wxArrayString modelNames;
989 bool modelNameExists =
false;
992 modelNames.Add(
name );
995 if( wxString(
name ).IsSameAs( modelName,
false ) )
996 modelNameExists =
true;
1004 if( !modelNameExists )
1006 m_infoBar->ShowMessage( wxString::Format(
_(
"No model named '%s' in '%s'." ),
1014 wxArrayString emptyArray;
1026 wxCommandEvent
dummy;
1037template <
typename T>
1055 case CATEGORY::S_PARAM:
1056 m_paramGrid->HideProperty(
"S-Parameters",
false );
1060 case CATEGORY::CAPACITANCE:
1061 m_paramGrid->HideProperty(
"Capacitance",
false );
1065 case CATEGORY::TEMPERATURE:
1066 m_paramGrid->HideProperty(
"Temperature",
false );
1070 case CATEGORY::NOISE:
1075 case CATEGORY::DISTRIBUTED_QUANTITIES:
1076 m_paramGrid->HideProperty(
"Distributed Quantities",
false );
1080 case CATEGORY::WAVEFORM:
1085 case CATEGORY::GEOMETRY:
1090 case CATEGORY::LIMITING_VALUES:
1091 m_paramGrid->HideProperty(
"Limiting Values",
false );
1095 case CATEGORY::ADVANCED:
1100 case CATEGORY::FLAGS:
1109 case CATEGORY::INITIAL_CONDITIONS:
1110 case CATEGORY::SUPERFLUOUS:
1116template <
typename T>
1120 wxString paramDescription;
1123 paramDescription = wxString::Format(
"%s", param.
info.
name );
1127 wxPGProperty* prop =
nullptr;
1133 prop->SetAttribute( wxPG_BOOL_USE_CHECKBOX,
true );
1155 wxArrayString inductors;
1166 if( item.model->GetDeviceType() == SIM_MODEL::DEVICE_T::L )
1167 inductors.push_back( item.refName );
1171 [](
const wxString& a,
const wxString& b ) ->
int
1177 if( inductors.empty() )
1195 wxArrayString values;
1198 values.Add(
string );
1206 prop =
new wxStringProperty( paramDescription, param.
info.
name );
1210 prop->SetAttribute( wxPG_ATTR_UNITS, wxString::FromUTF8( param.
info.
unit.c_str() ) );
1236template <
typename T>
1239 for(
int row = 0; row < static_cast<int>(
m_sortedPartPins.size() ); ++row )
1243 if(
pin->GetNumber() == aSymbolPinNumber )
1251template <
typename T>
1276template <
typename T>
1286template <
typename T>
1295 pinNumber =
pin->GetShownNumber();
1296 pinName =
pin->GetShownName();
1299 if( !pinName.IsEmpty() && pinName != pinNumber )
1300 pinNumber += wxString::Format( wxT(
" (\"%s\")" ), pinName );
1306template <
typename T>
1309 wxString modelPinName;
1311 if( aModelPinIndex >= 0 && aModelPinIndex < aModel->GetPinCount() )
1314 wxString modelPinNumber = wxString::Format(
"%d", aModelPinIndex + 1 );
1316 if( !modelPinName.IsEmpty() && modelPinName != modelPinNumber )
1317 modelPinNumber += wxString::Format( wxT(
" (\"%s\")" ), modelPinName );
1319 return modelPinNumber;
1323template <
typename T>
1326 if( aModelPinString ==
"Not Connected" )
1329 int length = aModelPinString.Find(
" " );
1331 if( length == wxNOT_FOUND )
1332 length =
static_cast<int>( aModelPinString.Length() );
1335 aModelPinString.Mid( 0, length ).ToCLong( &
result );
1337 return static_cast<int>(
result - 1 );
1341template <
typename T>
1349template <
typename T>
1356template <
typename T>
1373template <
typename T>
1383 wxCommandEvent
dummy;
1391template <
typename T>
1394 static wxString s_mruPath;
1397 wxFileDialog dlg(
this,
_(
"Browse Models" ),
path );
1400 dlg.SetCustomizeHook( customize );
1404 if( dlg.ShowModal() == wxID_CANCEL )
1409 path = dlg.GetPath();
1410 wxFileName fn(
path );
1411 s_mruPath = fn.GetPath();
1418 else if( fn.MakeRelativeTo(
Prj().GetProjectPath() ) && !fn.GetFullPath().StartsWith( wxS(
".." ) ) )
1420 path = fn.GetFullPath();
1434template <
typename T>
1447 switch( aKeyStroke.GetKeyCode() )
1450 if( sel == wxNOT_FOUND )
1453 sel = std::max( sel - 1, 0 );
1458 if( sel == wxNOT_FOUND )
1461 sel = std::min( sel + 1, count - 1 );
1466 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
1475 wxCommandEvent
dummy;
1480template <
typename T>
1486 wxArrayString modelNames;
1492 wxString wx_name(
name );
1494 if( wx_name.Matches(
filter ) )
1495 modelNames.Add( wx_name );
1508 wxCommandEvent
dummy;
1515template <
typename T>
1520 wxArrayString pinLabels;
1523 wxCHECK2( modelkibis,
return );
1525 for( std::pair<wxString, wxString> strs : modelkibis->
GetIbisPins() )
1526 pinLabels.Add( strs.first + wxT(
" - " ) + strs.second );
1530 wxArrayString emptyArray;
1539 wxArrayString lines = wxSplit( fallback->GetSpiceCode(),
'\n' );
1542 for(
const wxString& line : lines )
1544 if( !line.StartsWith(
'*' ) )
1546 if( !code.IsEmpty() )
1553 m_infoBar->ShowMessage( wxString::Format(
_(
"Failed to parse:\n\n"
1555 "Using generic SPICE model." ),
1567template <
typename T>
1570 wxArrayString modelLabels;
1574 std::vector<std::pair<std::string, std::string>> strs = ibisModel.
GetIbisPins();
1575 std::string pinNumber = strs.at(
m_pinCombobox->GetSelection() ).first;
1579 ibisModel.
ChangePin( *ibisLibrary, pinNumber );
1584 modelLabels.Add( modelName );
1597template <
typename T>
1606template <
typename T>
1618 std::string pinNumber = ibismodel->GetIbisPins()
1623 ibismodel->SetIbisModel( *ibisLibrary, pinNumber, modelName );
1631template <
typename T>
1638template <
typename T>
1644 modelibis->SwitchSingleEndedDiff( diff );
1651template <
typename T>
1656 for( SIM_MODEL::DEVICE_T deviceType : SIM_MODEL::DEVICE_T_ITERATOR() )
1669template <
typename T>
1672 SIM_MODEL::DEVICE_T deviceType =
curModel().GetDeviceType();
1675 for( SIM_MODEL::TYPE type : { SIM_MODEL::TYPE::KIBIS_DEVICE,
1676 SIM_MODEL::TYPE::KIBIS_DRIVER_DC,
1677 SIM_MODEL::TYPE::KIBIS_DRIVER_RECT,
1678 SIM_MODEL::TYPE::KIBIS_DRIVER_PRBS } )
1691 m_libraryModelsMgr.SetModel( idx, std::make_unique<SIM_MODEL_IBIS>( type, baseModel ) );
1713template <
typename T>
1716 SIM_MODEL::DEVICE_T deviceType =
curModel().GetDeviceType();
1719 for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
1734template <
typename T>
1741template <
typename T>
1744 int symbolPinIndex = aEvent.GetRow();
1745 wxString oldModelPinName = aEvent.GetString();
1746 wxString modelPinName =
m_pinAssignmentsGrid->GetCellValue( aEvent.GetRow(), aEvent.GetCol() );
1752 curModel().AssignSymbolPinNumberToModelPin( oldModelPinIndex,
"" );
1767template <
typename T>
1780template <
typename T>
1787 wxPGProperty* selected =
grid->GetSelection();
1790 selected =
grid->wxPropertyGridInterface::GetFirst();
1792#if wxCHECK_VERSION( 3, 3, 0 )
1794 grid->DoSelectProperty( selected, wxPGSelectPropertyFlags::Focus );
1797 grid->DoSelectProperty( selected, wxPG_SEL_FOCUS );
1804template <
typename T>
1810 if(
grid->GetSelection() &&
grid->GetSelection()->IsCategory() )
1812 wxPGProperty* selection =
grid->GetSelection();
1817 wxPropertyGridIterator it =
grid->GetIterator( wxPG_ITERATE_VISIBLE, selection );
1820 wxKeyEvent* keyEvent =
new wxKeyEvent( wxEVT_KEY_DOWN );
1824 if( !selection->IsExpanded() )
1826 grid->Expand( selection );
1827 keyEvent->m_keyCode = WXK_DOWN;
1828 wxQueueEvent(
grid, keyEvent );
1836 keyEvent->m_keyCode = WXK_UP;
1837 wxQueueEvent(
grid, keyEvent );
1842 if( !selection->IsExpanded() )
1843 grid->Expand( selection );
1845 keyEvent->m_keyCode = WXK_DOWN;
1846 wxQueueEvent(
grid, keyEvent );
1853 wxWindow* editorControl =
grid->GetEditorControl();
1855 if( !editorControl )
1862 editorControl->SetFocus();
1867template <
typename T>
1879 wxTextCtrl* ctrl =
grid->GetEditorTextCtrl();
1883 wxRect ctrlRect = ctrl->GetScreenRect();
1884 wxRect gridRect =
grid->GetScreenRect();
1886 if( ctrlRect.GetTop() < gridRect.GetTop() || ctrlRect.GetBottom() > gridRect.GetBottom() )
1887 grid->ClearSelection();
1893template <
typename T>
1906 std::vector<int> colWidths;
1908 for(
size_t ii = 0; ii <
grid->GetColumnCount(); ii++ )
1911 colWidths.push_back(
grid->GetState()->GetColumnWidth( ii ) + margin + indent );
1913 colWidths.push_back( std::max( 72,
grid->GetState()->GetColumnWidth( ii ) ) + margin );
1915 colWidths.push_back( 60 + margin );
1917 aWidth -= colWidths[ ii ];
1920 for(
size_t ii = 0; ii <
grid->GetColumnCount(); ii++ )
1921 grid->SetColumnProportion( ii, colWidths[ ii ] );
1923 grid->ResetColumnSizes();
1924 grid->RefreshEditor();
1929template <
typename T>
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
wxNotebook * m_modelNotebook
wxStaticText * m_subcktLabel
wxStaticText * m_sharedPinsLabel
wxStaticText * m_modelNameLabel
wxPropertyGridManager * m_paramGridMgr
wxStaticText * m_pathLabel
wxRadioButton * m_rbBuiltinModel
wxListBox * m_modelListBox
wxComboBox * m_pinCombobox
DIALOG_SIM_MODEL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Simulation Model Editor"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxChoice * m_deviceSubtypeChoice
wxSearchCtrl * m_modelFilter
wxStaticText * m_waveformLabel
wxTextCtrl * m_libraryPathText
wxStaticText * m_pinLabel
wxChoice * m_deviceChoice
wxComboBox * m_pinModelCombobox
wxRadioButton * m_rbLibraryModel
wxChoice * m_decompositionChoice
wxChoice * m_waveformChoice
wxStaticText * m_deviceLabel
wxStaticText * m_decompositionLabel
WX_GRID * m_pinAssignmentsGrid
wxStaticText * m_pinModelLabel
wxPanel * m_parametersPanel
wxStaticText * m_deviceSubtypeLabel
wxTextCtrl * m_sharedPinsText
wxCheckBox * m_saveInValueCheckbox
STD_BITMAP_BUTTON * m_browseButton
wxStyledTextCtrl * m_subckt
wxPropertyGridPage * m_paramGrid
wxPanel * m_pinAssignmentsPanel
wxCheckBox * m_differentialCheckbox
wxStyledTextCtrl * m_codePreview
const SIM_MODEL * m_prevModel
void onTypeChoice(wxCommandEvent &aEvent) override
void onLibraryPathTextKillFocus(wxFocusEvent &aEvent) override
wxString getSymbolPinString(int aSymbolPinNumber) const
void updateBuiltinModelWidgets(SIM_MODEL *aModel)
void onPinAssignmentsGridCellChange(wxGridEvent &aEvent) override
void onFilterCharHook(wxKeyEvent &aKeyStroke) override
int findSymbolPinRow(const wxString &aSymbolPinNumber) const
void onModelNameChoice(wxCommandEvent &aEvent) override
void onRadioButton(wxCommandEvent &aEvent) override
SCINTILLA_TRICKS * m_scintillaTricksSubckt
bool loadLibrary(const wxString &aLibraryPath, REPORTER &aReporter, bool aForceReload=false)
SIM_LIB_MGR m_builtinModelsMgr
int getModelPinIndex(const wxString &aModelPinString) const
void onModelFilter(wxCommandEvent &aEvent) override
void onLibraryPathText(wxCommandEvent &aEvent) override
void onDifferentialCheckbox(wxCommandEvent &event) override
void onParamGridSelectionChange(wxPropertyGridEvent &aEvent)
void removeOrphanedPinAssignments(SIM_MODEL *aModel)
bool m_inferredValueOverwritten
void adjustParamGridColumns(int aWidth, bool aForce)
std::vector< SCH_FIELD > & m_fields
std::vector< SCH_PIN * > m_sortedPartPins
Pins of the current part.
wxPGProperty * newParamProperty(SIM_MODEL *aModel, int aParamIndex) const
void onDecompositionModeChoice(wxCommandEvent &aEvent) override
wxPGProperty * m_prevParamGridSelection
void onPinModelCombobox(wxCommandEvent &event) override
const SIM_LIBRARY * library() const
SIM_MODEL & curModel() const
SIM_LIB_MGR m_libraryModelsMgr
void onBrowseButtonClick(wxCommandEvent &aEvent) override
void onPinComboboxTextEnter(wxCommandEvent &event) override
void onPinCombobox(wxCommandEvent &event) override
wxPGProperty * m_firstCategory
SCINTILLA_TRICKS * m_scintillaTricksCode
wxString m_inferredValueRestore
std::map< wxString, int > m_modelListBoxEntryToLibraryIdx
void updatePinAssignments(SIM_MODEL *aModel, bool aForceUpdatePins)
void onUpdateUI(wxUpdateUIEvent &aEvent)
DIALOG_SIM_MODEL(wxWindow *aParent, EDA_BASE_FRAME *aFrame, T &aSymbol, std::vector< SCH_FIELD > &aFields)
wxString getModelPinString(SIM_MODEL *aModel, int aModelPinIndex) const
void onPinAssignmentsGridSize(wxSizeEvent &aEvent) override
void updateIbisWidgets(SIM_MODEL *aModel)
void onParamGridSetFocus(wxFocusEvent &aEvent)
void updateModelParamsTab(SIM_MODEL *aModel)
bool TransferDataFromWindow() override
SIM_MODEL::TYPE m_curModelType
void updateModelCodeTab(SIM_MODEL *aModel)
void onSizeParamGrid(wxSizeEvent &event) override
void onPageChanging(wxNotebookEvent &event) override
std::vector< EMBEDDED_FILES * > m_filesStack
void updateDecompositionControls()
Show/populate the decomposition controls (multi-unit only) and sync their enabled state.
void onWaveformChoice(wxCommandEvent &aEvent) override
std::map< SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE > m_curModelTypeOfDeviceType
void onPinModelComboboxTextEnter(wxCommandEvent &event) override
void onLibraryPathTextEnter(wxCommandEvent &aEvent) override
static void RestoreInferredValue(std::vector< SCH_FIELD > &aFields, const wxString &aOriginalValue, bool aOverwritten, bool aStoredInValue)
Restore an inferred passive's Value field after WriteFields().
void onDeviceTypeChoice(wxCommandEvent &aEvent) override
bool TransferDataToWindow() override
void addParamPropertyIfRelevant(SIM_MODEL *aModel, int aParamIndex)
The base frame for deriving all KiCad main window classes.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Define a library symbol object.
void AppendParentEmbeddedFiles(std::vector< EMBEDDED_FILES * > &aStack) const
virtual bool ReadSchematicAndLibraries(unsigned aNetlistOptions, REPORTER &aReporter)
Process the schematic and Spice libraries to create net mapping and a list of SPICE_ITEMs.
const std::list< SPICE_ITEM > & GetItems() const
Return the list of items representing schematic symbols in the Spice world.
A singleton reporter that reports to nowhere.
virtual const wxString GetProjectPath() const
Return the full path of the project.
A pure virtual class used to derive REPORTER objects from.
virtual bool HasMessageOfSeverity(int aSeverityMask) const
Returns true if the reporter has one or more messages matching the specified severity mask.
EMBEDDED_FILES * GetEmbeddedFiles() override
Schematic editor (Eeschema) main window.
virtual const wxString & GetText() const override
Return the string associated with the text object.
void SetText(const wxString &aText) override
SCHEMATIC * Schematic() const
Search the item hierarchy to find a SCHEMATIC.
const wxString & GetShownNumber() const
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
static constexpr auto MODEL_FIELD
static constexpr auto PIN_FIELD
static constexpr auto DIFF_FIELD
bool isPinDiff(const std::string &aComp, const std::string &aPinNumber) const
static constexpr auto LIBRARY_FIELD
static constexpr auto NAME_FIELD
bool SetIbisModel(const SIM_LIBRARY_IBIS &aLib, const std::string &aPinNumber, const std::string &aModelName)
Bind to a KIBIS model, set IO mode from its type, manage sw_state.
std::vector< std::pair< std::string, std::string > > GetIbisPins() const
void SwitchSingleEndedDiff(bool aDiff) override
bool CanDifferential() const
std::vector< std::string > GetIbisModels() const
bool ChangePin(const SIM_LIBRARY_IBIS &aLib, const std::string &aPinNumber)
update the list of available models based on the pin number.
std::string GetComponentName() const
static INFO TypeInfo(TYPE aType)
static bool InferSimModel(const wxString &aPrefix, std::span< const wxString > aPins, std::vector< SCH_FIELD > *aFields, bool aResolve, int aDepth, SIM_VALUE_GRAMMAR::NOTATION aNotation, wxString *aDeviceType, wxString *aModelType, wxString *aModelParams, wxString *aPinMap)
aPins follows lexical symbol-pin number order, including duplicate numbers.
const SPICE_GENERATOR & SpiceGenerator() const
virtual const PARAM & GetParam(unsigned aParamIndex) const
static TYPE ReadTypeFromFields(const std::vector< SCH_FIELD > &aFields, bool aResolve, int aDepth, REPORTER &aReporter)
int GetParamCount() const
void AssignSymbolPinNumberToModelPin(int aPinIndex, const wxString &aSymbolPinNumber)
DEVICE_INFO GetDeviceInfo() const
DEVICE_T GetDeviceType() const
static DEVICE_INFO DeviceInfo(DEVICE_T aDeviceType)
virtual bool HasAutofill() const
const SIM_MODEL_PIN & GetPin(unsigned aIndex) const
virtual bool HasPrimaryValue() const
static std::vector< wxString > PinNumbers(std::span< const SCH_PIN *const > aPins)
const SIM_MODEL::PARAM & GetParam() const
Special netlist exporter flavor that allows one to override simulation commands.
virtual std::string Preview(const SPICE_ITEM &aItem) const
A wrapper for reporting to a wxString object.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
static bool empty(const wxTextEntryBase *aCtrl)
bool equivalent(SIM_MODEL::DEVICE_T a, SIM_MODEL::DEVICE_T b)
#define FORCE_REFRESH_FROM_MODEL
SIM_MODEL::PARAM::CATEGORY CATEGORY
static const std::string KiCadUriPrefix
static bool loadLibrary(SYMBOL_LIBRARY_ADAPTER &aAdapter, const wxString &aNickname, std::vector< KI_ERROR > &aErrors)
KICOMMON_API wxFont GetStatusFont(wxWindow *aWindow)
BITMAPS PinShapeGetBitmap(GRAPHIC_PINSHAPE shape)
void SetFieldValue(std::vector< SCH_FIELD > &aFields, const wxString &aFieldName, const std::string &aValue, bool aIsVisible=true, const SCH_SHEET_PATH *aSheetPath=nullptr, const wxString &aVariantName=wxEmptyString)
wxString GetFieldValue(const std::vector< SCH_FIELD > *aFields, FIELD_T aFieldType)
const SCH_FIELD * FindField(const std::vector< SCH_FIELD > &aFields, FIELD_T aFieldId)
#define SIM_REFERENCE_FIELD
#define SIM_DECOMPOSITION_FIELD
#define SIM_DEVICE_SUBTYPE_FIELD
std::vector< FAB_LAYER_COLOR > dummy
int StrNumCmp(const wxString &aString1, const wxString &aString2, bool aIgnoreCase)
Compare two strings with alphanumerical content.
Per-component decomposition descriptor stored in the Sim.Decomposition field.
static SIM_DECOMPOSITION Parse(const wxString &aField)
std::vector< wxString > sharedModelPins
std::vector< std::string > enumValues
static constexpr auto NOT_CONNECTED
const std::string modelPinName
@ REFERENCE
Field Reference of part, i.e. "IC21".
@ VALUE
Field Value of part, i.e. "3.3K".
IbisParser parser & reporter
wxString result
Test unit parsing edge cases and error handling.