KiCad PCB EDA Suite
dialog_sim_model.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2022 Mikolaj Wielgus
5 * Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 3
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * https://www.gnu.org/licenses/gpl-3.0.html
20 * or you may search the http://www.gnu.org website for the version 3 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <dialog_sim_model.h>
26#include <sim/sim_property.h>
29#include <sim/sim_model_kibis.h>
31#include <widgets/wx_grid.h>
32#include <kiplatform/ui.h>
33#include <confirm.h>
34#include <string_utils.h>
35#include <locale_io.h>
36#include <wx/filedlg.h>
37#include <wx/textfile.h>
38
40
41
42template <typename T>
44 std::vector<T>& aFields )
45 : DIALOG_SIM_MODEL_BASE( aParent ),
46 m_symbol( aSymbol ),
47 m_fields( aFields ),
48 m_library( std::make_shared<SIM_LIBRARY_SPICE>() ),
49 m_prevModel( nullptr ),
50 m_firstCategory( nullptr ),
51 m_prevParamGridSelection( nullptr ),
52 m_wasCodePreviewUpdated( true )
53{
56
58 std::sort( m_sortedSymbolPins.begin(), m_sortedSymbolPins.end(),
59 []( const LIB_PIN* lhs, const LIB_PIN* rhs )
60 {
61 // We sort by StrNumCmp because SIM_MODEL_BASE sorts with it too.
62 return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0;
63 } );
64
65 for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
66 {
67 m_models.push_back( SIM_MODEL::Create( type, m_sortedSymbolPins.size() ) );
68
69 SIM_MODEL::DEVICE_TYPE_ deviceType = SIM_MODEL::TypeInfo( type ).deviceType;
70
71 if( !m_curModelTypeOfDeviceType.count( deviceType ) )
72 m_curModelTypeOfDeviceType[deviceType] = type;
73 }
74
75
76 m_typeChoice->Clear();
77
78 for( SIM_MODEL::DEVICE_TYPE_ deviceType : SIM_MODEL::DEVICE_TYPE__ITERATOR() )
79 m_deviceTypeChoice->Append( SIM_MODEL::DeviceTypeInfo( deviceType ).description );
80
81 m_scintillaTricks = std::make_unique<SCINTILLA_TRICKS>( m_codePreview, wxT( "{}" ), false );
82
83 m_paramGridMgr->Bind( wxEVT_PG_SELECTED, &DIALOG_SIM_MODEL::onParamGridSelectionChange, this );
84
85 m_paramGrid->SetValidationFailureBehavior( wxPG_VFB_STAY_IN_PROPERTY
86 | wxPG_VFB_BEEP
87 | wxPG_VFB_MARK_CELL );
88
89 m_paramGrid->SetColumnProportion( static_cast<int>( PARAM_COLUMN::DESCRIPTION ), 50 );
90 m_paramGrid->SetColumnProportion( static_cast<int>( PARAM_COLUMN::VALUE ), 18 );
91 m_paramGrid->SetColumnProportion( static_cast<int>( PARAM_COLUMN::UNIT ), 10 );
92 m_paramGrid->SetColumnProportion( static_cast<int>( PARAM_COLUMN::DEFAULT ), 12 );
93 m_paramGrid->SetColumnProportion( static_cast<int>( PARAM_COLUMN::TYPE ), 10 );
94
95 if( wxPropertyGrid* grid = m_paramGrid->GetGrid() )
96 {
97 //grid->SetCellBackgroundColour( grid->GetPropertyDefaultCell().GetBgCol() );
98 //grid->SetCellTextColour( grid->GetPropertyDefaultCell().GetFgCol();
99
100 // In wx 3.0 the color will be wrong sometimes.
101 grid->SetCellDisabledTextColour( wxSystemSettings::GetColour( wxSYS_COLOUR_GRAYTEXT ) );
102
103 grid->Bind( wxEVT_SET_FOCUS, &DIALOG_SIM_MODEL::onParamGridSetFocus, this );
104
105 grid->AddActionTrigger( wxPG_ACTION_EDIT, WXK_RETURN );
106 grid->DedicateKey( WXK_RETURN );
107 grid->AddActionTrigger( wxPG_ACTION_NEXT_PROPERTY, WXK_RETURN );
108
109 grid->DedicateKey( WXK_UP );
110 grid->DedicateKey( WXK_DOWN );
111 }
112 else
113 wxFAIL;
114
115 // Now all widgets have the size fixed, call FinishDialogSettings
118}
119
120
121template <typename T>
123{
124 wxString libraryFilename = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::LIBRARY_FIELD );
125
126 if( libraryFilename != "" )
127 {
128 // The model is sourced from a library, optionally with instance overrides.
129 loadLibrary( libraryFilename );
130
131 bool ibisMode = IsIbisLoaded();
132 setIbisMode( ibisMode );
133
134 // Must be set before curModel() is used since the latter checks the combobox value.
135 m_modelNameCombobox->SetStringSelection(
137
138 if( ibisMode && ( m_modelNameCombobox->GetSelection() >= 0 ) )
139 {
140 std::shared_ptr<SIM_MODEL_KIBIS> kibismodel =
141 std::dynamic_pointer_cast<SIM_MODEL_KIBIS>(
142 m_libraryModels.at( m_modelNameCombobox->GetSelection() ) );
143
144 if( kibismodel )
145 {
146 wxCommandEvent dummyEvent;
147 onModelNameCombobox( dummyEvent ); // refresh list of pins
148
149 long unsigned int i = 0;
150
151 for( std::pair<std::string, std::string> strs : kibismodel->GetIbisPins() )
152 {
153 if( strs.first
155 {
156 kibismodel->ChangePin(
157 *( std::dynamic_pointer_cast<SIM_LIBRARY_KIBIS>( m_library ) ),
158 strs.first );
159 m_ibisPinCombobox->SetSelection( i );
160 break;
161 }
162 i++;
163 }
164
165 if( i < kibismodel->GetIbisPins().size() )
166 {
167 onIbisPinCombobox( dummyEvent ); // refresh list of models
168
169 m_ibisModelCombobox->SetStringSelection(
171 }
172 }
173 }
174
175 m_excludeSymbolCheckbox->SetValue( !curModel().IsEnabled() );
176 }
177 else
178 {
179 // The model is sourced from the instance.
181
182 try
183 {
184 m_models.at( static_cast<int>( SIM_MODEL::ReadTypeFromFields( m_fields ) ) ) =
185 SIM_MODEL::Create( m_sortedSymbolPins.size(), m_fields );
186 }
187 catch( const IO_ERROR& e )
188 {
189 DisplayErrorMessage( this, e.What() );
190 return DIALOG_SIM_MODEL_BASE::TransferDataToWindow();
191 }
192
193 m_curModelType = type;
194 }
195
196 m_overrideCheckbox->SetValue( curModel().HasNonInstanceOverrides() );
197
198 updateWidgets();
199
200 return DIALOG_SIM_MODEL_BASE::TransferDataToWindow();
201}
202
203
204template <typename T>
206{
207 m_pinAssignmentsGrid->CommitPendingChanges();
208
209 if( !DIALOG_SIM_MODEL_BASE::TransferDataFromWindow() )
210 return false;
211
212 std::string modelName;
213
214 modelName = m_modelNameCombobox->GetValue();
215
217
218 std::string path;
219
220 if( m_useLibraryModelRadioButton->GetValue() || IsIbisLoaded() )
221 {
222 path = m_library->GetFilePath();
223 wxFileName fn( path );
224
225 if( fn.MakeRelativeTo( Prj().GetProjectPath() ) && !fn.GetFullPath().StartsWith( ".." ) )
226 path = fn.GetFullPath();
227 }
228
230
231 if( IsIbisLoaded() )
232 {
233 std::shared_ptr<SIM_MODEL_KIBIS> kibismodel = std::dynamic_pointer_cast<SIM_MODEL_KIBIS>(
234 m_libraryModels.at( m_modelNameCombobox->GetSelection() ) );
235
236 if( kibismodel )
237
238 {
241 kibismodel->GetIbisPins().at( m_ibisPinCombobox->GetSelection() ).first );
243 std::string( m_ibisModelCombobox->GetValue().c_str() ) );
244 }
245 }
246
247 curModel().WriteFields( m_fields );
248
249 return true;
250}
251
252
253template <typename T>
255{
256 updateModelParamsTab();
257 updateModelCodeTab();
258 updatePinAssignments();
259
260 m_prevModel = &curModel();
261}
262
263
264template <typename T>
266{
267 if( ( &curModel() != m_prevModel ) || curModel().RequiresUIUpdate() )
268 {
269 SIM_MODEL::DEVICE_TYPE_ deviceType = SIM_MODEL::TypeInfo( curModel().GetType() ).deviceType;
270
271 // Change the Type choice to match the current device type.
272 if( !m_prevModel || deviceType != m_prevModel->GetDeviceType()
273 || curModel().RequiresUIUpdate() )
274 {
275 curModel().UIUpdated();
276 m_deviceTypeChoice->SetSelection( static_cast<int>( deviceType ) );
277
278 m_typeChoice->Clear();
279
280 for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
281 {
282 if( SIM_MODEL::TypeInfo( type ).deviceType == deviceType )
283 {
284 wxString description = SIM_MODEL::TypeInfo( type ).description;
285
286 if( !description.IsEmpty() )
287 m_typeChoice->Append( description );
288
289 if( type == curModel().GetType() )
290 m_typeChoice->SetSelection( m_typeChoice->GetCount() - 1 );
291 }
292 }
293 }
294
295 // This wxPropertyGridManager column and header stuff has to be here because it segfaults in
296 // the constructor.
297
298 m_paramGridMgr->SetColumnCount( static_cast<int>( PARAM_COLUMN::END_ ) );
299
300 m_paramGridMgr->SetColumnTitle( static_cast<int>( PARAM_COLUMN::UNIT ), "Unit" );
301 m_paramGridMgr->SetColumnTitle( static_cast<int>( PARAM_COLUMN::DEFAULT ), "Default" );
302 m_paramGridMgr->SetColumnTitle( static_cast<int>( PARAM_COLUMN::TYPE ), "Type" );
303
304 m_paramGridMgr->ShowHeader();
305
306
307 m_paramGrid->Clear();
308
309 m_firstCategory = m_paramGrid->Append( new wxPropertyCategory( "Geometry" ) );
310 m_paramGrid->HideProperty( "Geometry" );
311
312 m_paramGrid->Append( new wxPropertyCategory( "AC" ) );
313 m_paramGrid->HideProperty( "AC" );
314
315 m_paramGrid->Append( new wxPropertyCategory( "DC" ) );
316 m_paramGrid->HideProperty( "DC" );
317
318 m_paramGrid->Append( new wxPropertyCategory( "Capacitance" ) );
319 m_paramGrid->HideProperty( "Capacitance" );
320
321 m_paramGrid->Append( new wxPropertyCategory( "Temperature" ) );
322 m_paramGrid->HideProperty( "Temperature" );
323
324 m_paramGrid->Append( new wxPropertyCategory( "Noise" ) );
325 m_paramGrid->HideProperty( "Noise" );
326
327 m_paramGrid->Append( new wxPropertyCategory( "Distributed Quantities" ) );
328 m_paramGrid->HideProperty( "Distributed Quantities" );
329
330 m_paramGrid->Append( new wxPropertyCategory( "Waveform" ) );
331 m_paramGrid->HideProperty( "Waveform" );
332
333 m_paramGrid->Append( new wxPropertyCategory( "Limiting Values" ) );
334 m_paramGrid->HideProperty( "Limiting Values" );
335
336 m_paramGrid->Append( new wxPropertyCategory( "Advanced" ) );
337 m_paramGrid->HideProperty( "Advanced" );
338
339 m_paramGrid->Append( new wxPropertyCategory( "Flags" ) );
340 m_paramGrid->HideProperty( "Flags" );
341
342 m_paramGrid->CollapseAll();
343
344 for( int i = 0; i < curModel().GetParamCount(); ++i )
345 addParamPropertyIfRelevant( i );
346
347 m_paramGrid->CollapseAll();
348 m_paramGrid->Expand( "AC" );
349 m_paramGrid->Expand( "Waveform" );
350 }
351
352 // Either enable all properties or disable all except the principal ones.
353 // Set all properties to default colors.
354 for( wxPropertyGridIterator it = m_paramGrid->GetIterator(); !it.AtEnd(); ++it )
355 {
356 SIM_PROPERTY* prop = dynamic_cast<SIM_PROPERTY*>( *it );
357
358 if( !prop )
359 continue;
360
361 wxColour bgCol = m_paramGrid->GetGrid()->GetPropertyDefaultCell().GetBgCol();
362 wxColour fgCol = m_paramGrid->GetGrid()->GetPropertyDefaultCell().GetFgCol();
363
364 for( int col = 0; col < m_paramGridMgr->GetColumnCount(); ++col )
365 {
366 ( *it )->GetCell( col ).SetBgCol( bgCol );
367 ( *it )->GetCell( col ).SetFgCol( fgCol );
368 }
369
370 // Model values other than the currently edited value may have changed. Update them.
371 // This feature is called "autofill" and present only in certain models. Don't do it for
372 // models that don't have it for performance reasons.
373 if( curModel().HasAutofill() )
374 ( *it )->SetValueFromString( prop->GetParam().value->ToString() );
375
376 // Most of the values are disabled when the override checkbox is unchecked.
377 ( *it )->Enable(
378 ( IsIbisLoaded() ) || m_useInstanceModelRadioButton->GetValue()
379 || ( prop->GetParam().info.isInstanceParam
381 || m_overrideCheckbox->GetValue() );
382 }
383}
384
385
386template <typename T>
388{
389 wxString modelName = m_modelNameCombobox->GetStringSelection();
390
391 if( m_useInstanceModelRadioButton->GetValue() || modelName.IsEmpty() )
392 modelName = m_fields.at( REFERENCE_FIELD ).GetText();
393
394 m_codePreview->SetEditable( true ); // ???
395
396 if( dynamic_cast<SIM_MODEL_RAW_SPICE*>( &curModel() ) )
397 {
398 // For raw Spice models display the whole file instead.
399
400 wxString path = curModel().FindParam( "lib" )->value->ToString();
401 wxString absolutePath = Prj().AbsolutePath( path );
402 wxTextFile file;
403 wxString text;
404
405 text << curModel().SpiceGenerator().Preview( std::string( modelName.ToUTF8() ) );
406 text << "\n";
407 text << "--- FILE SOURCE (" << path << ") ---\n";
408 text << "\n";
409
410 if( wxFileExists( absolutePath ) && file.Open( absolutePath ) )
411 {
412 for( text << file.GetFirstLine() << "\n";
413 !file.Eof();
414 text << file.GetNextLine() << "\n" )
415 {
416 }
417
418 file.Close();
419 m_codePreview->SetText( text );
420 }
421 }
422 else
423 m_codePreview->SetText( curModel().SpiceGenerator().Preview( std::string( modelName.ToUTF8() ) ) );
424
425 m_codePreview->SetEditable( false ); // ???
426 m_wasCodePreviewUpdated = true;
427}
428
429
430template <typename T>
432{
433 removeOrphanedPinAssignments();
434
435 // Reset the grid.
436
437 m_pinAssignmentsGrid->ClearRows();
438 m_pinAssignmentsGrid->AppendRows( static_cast<int>( m_sortedSymbolPins.size() ) );
439
440 for( int row = 0; row < m_pinAssignmentsGrid->GetNumberRows(); ++row )
441 {
442 m_pinAssignmentsGrid->SetCellValue( row, static_cast<int>( PIN_COLUMN::MODEL ),
443 "Not Connected" );
444 }
445
446 // Now set up the grid values in the Model column.
447 for( int modelPinIndex = 0; modelPinIndex < curModel().GetPinCount(); ++modelPinIndex )
448 {
449 wxString symbolPinNumber = curModel().GetPin( modelPinIndex ).symbolPinNumber;
450
451 if( symbolPinNumber == "" )
452 continue;
453
454 wxString modelPinString = getModelPinString( modelPinIndex );
455 m_pinAssignmentsGrid->SetCellValue( findSymbolPinRow( symbolPinNumber ),
456 static_cast<int>( PIN_COLUMN::MODEL ),
457 modelPinString );
458 }
459
460 wxArrayString modelPinChoices = getModelPinChoices();
461
462 // Set up the Symbol column grid values and Model column cell editors with dropdown options.
463 for( int i = 0; i < m_pinAssignmentsGrid->GetNumberRows(); ++i )
464 {
465 wxString symbolPinString = getSymbolPinString( i );
466
467 m_pinAssignmentsGrid->SetReadOnly( i, static_cast<int>( PIN_COLUMN::SYMBOL ) );
468 m_pinAssignmentsGrid->SetCellValue( i, static_cast<int>( PIN_COLUMN::SYMBOL ),
469 symbolPinString );
470
471 wxString curModelPinString = m_pinAssignmentsGrid->GetCellValue(
472 i, static_cast<int>( PIN_COLUMN::MODEL ) );
473
474 wxArrayString actualModelPinChoices( modelPinChoices );
475
476 if( curModelPinString != _( "Not Connected" ) )
477 actualModelPinChoices.Insert( curModelPinString, 0 );
478
479 // Using `new` here shouldn't cause a memory leak because `SetCellEditor()` calls
480 // `DecRef()` on its last editor.
481 m_pinAssignmentsGrid->SetCellEditor( i, static_cast<int>( PIN_COLUMN::MODEL ),
482 new wxGridCellChoiceEditor( actualModelPinChoices ) );
483 }
484
485 // TODO: Show a preview of the symbol with the pin numbers shown.
486 // TODO: Maybe show a preview of the code for subcircuits and code models.
487}
488
489
490template <typename T>
492{
493 for( int i = 0; i < curModel().GetPinCount(); ++i )
494 {
495 const SIM_MODEL::PIN& modelPin = curModel().GetPin( i );
496 bool isOrphaned = true;
497
498 for( const LIB_PIN* symbolPin : m_sortedSymbolPins )
499 {
500 if( modelPin.symbolPinNumber == symbolPin->GetNumber() )
501 {
502 isOrphaned = false;
503 break;
504 }
505 }
506
507 if( isOrphaned )
508 curModel().SetPinSymbolPinNumber( i, "" );
509 }
510}
511
512
513template <typename T>
514void DIALOG_SIM_MODEL<T>::loadLibrary( const wxString& aFilePath )
515{
516 const wxString absolutePath = Prj().AbsolutePath( aFilePath );
517
518 if( absolutePath.EndsWith( ".ibs" ) )
519 m_library = std::make_shared<SIM_LIBRARY_KIBIS>();
520 else
521 m_library = std::make_shared<SIM_LIBRARY_SPICE>();
522
523 setIbisMode( IsIbisLoaded() );
524
525 try
526 {
527 if( IsIbisLoaded() )
528 {
529 wxString ibisTypeString = SIM_MODEL::GetFieldValue( &m_fields, SIM_MODEL::TYPE_FIELD );
530
531 SIM_MODEL::TYPE ibisType = SIM_MODEL::TYPE::KIBIS_DEVICE;
532
533 if( ibisTypeString == "IBISDRIVER" )
534 ibisType = SIM_MODEL::TYPE::KIBIS_DRIVER;
535 else if( ibisTypeString == "IBISDIFFDRIVER" )
536 ibisType = SIM_MODEL::TYPE::KIBIS_DIFFDRIVER;
537 else if( ibisTypeString == "IBISDIFFDEVICE" )
538 ibisType = SIM_MODEL::TYPE::KIBIS_DIFFDEVICE;
539
540 std::dynamic_pointer_cast<SIM_LIBRARY_KIBIS>( m_library )
541 ->ReadFile( std::string( absolutePath.ToUTF8() ), ibisType );
542 }
543 else
544 {
545 m_library->ReadFile( std::string( absolutePath.ToUTF8() ) );
546 }
547 }
548 catch( const IO_ERROR& e )
549 {
550 DisplayErrorMessage( this, wxString::Format( _( "Failed reading model library '%s'." ),
551 absolutePath ),
552 e.What() );
553 return;
554 }
555
556 m_tclibraryPathName->ChangeValue( aFilePath );
557
558 m_libraryModels.clear();
559
560 try
561 {
562 for( unsigned i = 0; i < m_library->GetModels().size(); ++i )
563 {
564 const SIM_MODEL& baseModel = m_library->GetModels().at( i );
565 wxString baseModelName = m_library->GetModelNames().at( i );
566 wxString expectedModelName;
567
568 expectedModelName =
570
571 // Only the current model is initialized from fields. Others have default
572 // initialization.
573 if( baseModelName == expectedModelName )
574 {
575 //TODO: it's not cur model.
576
577 m_libraryModels.push_back(
578 SIM_MODEL::Create( baseModel, m_sortedSymbolPins.size(), m_fields ) );
579 }
580 else
581 {
582 m_libraryModels.push_back( SIM_MODEL::Create( baseModel, m_sortedSymbolPins.size() ) );
583 }
584 }
585 }
586 catch( const IO_ERROR& e )
587 {
588 DisplayErrorMessage( this, e.What() );
589 }
590
591 wxArrayString modelNames;
592 for( const std::string& name : m_library->GetModelNames() )
593 modelNames.Add( name );
594
595 auto validator = dynamic_cast<MODEL_NAME_VALIDATOR*>( m_modelNameCombobox->GetValidator() );
596
597 if( validator )
598 validator->SetIncludes( modelNames );
599
600 m_modelNameCombobox->Set( modelNames );
601
602 m_useLibraryModelRadioButton->SetValue( true );
603}
604
605
606template <typename T>
608{
609 if( curModel().GetParam( aParamIndex ).info.dir == SIM_MODEL::PARAM::DIR_OUT )
610 return;
611
612 switch( curModel().GetParam( aParamIndex ).info.category )
613 {
614 case CATEGORY::AC:
615 m_paramGrid->HideProperty( "AC", false );
616 m_paramGrid->AppendIn( "AC", newParamProperty( aParamIndex ) );
617 break;
618
619 case CATEGORY::DC:
620 m_paramGrid->HideProperty( "DC", false );
621 m_paramGrid->AppendIn( "DC", newParamProperty( aParamIndex ) );
622 break;
623
625 m_paramGrid->HideProperty( "Capacitance", false );
626 m_paramGrid->AppendIn( "Capacitance", newParamProperty( aParamIndex ) );
627 break;
628
630 m_paramGrid->HideProperty( "Temperature", false );
631 m_paramGrid->AppendIn( "Temperature", newParamProperty( aParamIndex ) );
632 break;
633
634 case CATEGORY::NOISE:
635 m_paramGrid->HideProperty( "Noise", false );
636 m_paramGrid->AppendIn( "Noise", newParamProperty( aParamIndex ) );
637 break;
638
640 m_paramGrid->HideProperty( "Distributed Quantities", false );
641 m_paramGrid->AppendIn( "Distributed Quantities", newParamProperty( aParamIndex ) );
642 break;
643
645 m_paramGrid->HideProperty( "Waveform", false );
646 m_paramGrid->AppendIn( "Waveform", newParamProperty( aParamIndex ) );
647 break;
648
650 m_paramGrid->HideProperty( "Geometry", false );
651 m_paramGrid->AppendIn( "Geometry", newParamProperty( aParamIndex ) );
652 break;
653
655 m_paramGrid->HideProperty( "Limiting Values", false );
656 m_paramGrid->AppendIn( "Limiting Values", newParamProperty( aParamIndex ) );
657 break;
658
660 m_paramGrid->HideProperty( "Advanced", false );
661 m_paramGrid->AppendIn( "Advanced", newParamProperty( aParamIndex ) );
662 break;
663
664 case CATEGORY::FLAGS:
665 m_paramGrid->HideProperty( "Flags", false );
666 m_paramGrid->AppendIn( "Flags", newParamProperty( aParamIndex ) );
667 break;
668
669 default:
670 m_paramGrid->Insert( m_firstCategory, newParamProperty( aParamIndex ) );
671 break;
672
675 return;
676 }
677}
678
679template <typename T>
680wxPGProperty* DIALOG_SIM_MODEL<T>::newParamProperty( int aParamIndex ) const
681{
682 const SIM_MODEL::PARAM& param = curModel().GetParam( aParamIndex );
683 wxString paramDescription;
684
685 if( param.info.description == "" )
686 paramDescription = wxString::Format( "%s", param.info.name );
687 else
688 paramDescription = wxString::Format( "%s (%s)", param.info.description, param.info.name );
689
690 wxPGProperty* prop = nullptr;
691
692 switch( param.info.type )
693 {
695 // TODO.
696 prop = new SIM_BOOL_PROPERTY( paramDescription, param.info.name, m_library,
697 curModelSharedPtr(), aParamIndex );
698 prop->SetAttribute( wxPG_BOOL_USE_CHECKBOX, true );
699 break;
700
702 prop = new SIM_STRING_PROPERTY( paramDescription, param.info.name, m_library,
703 curModelSharedPtr(), aParamIndex, SIM_VALUE::TYPE_INT );
704 break;
705
707 prop = new SIM_STRING_PROPERTY( paramDescription, param.info.name, m_library,
708 curModelSharedPtr(), aParamIndex, SIM_VALUE::TYPE_FLOAT );
709 break;
710
711 //case TYPE_COMPLEX:
712 // break;
713
715 if( param.info.enumValues.empty() )
716 {
717 prop = new SIM_STRING_PROPERTY( paramDescription, param.info.name, m_library,
718 curModelSharedPtr(), aParamIndex, SIM_VALUE::TYPE_STRING );
719 }
720 else
721 {
722 prop = new SIM_ENUM_PROPERTY( paramDescription, param.info.name, m_library,
723 curModelSharedPtr(), aParamIndex, SIM_VALUE::TYPE_STRING );
724 }
725 break;
726
727 default:
728 prop = new wxStringProperty( paramDescription, param.info.name );
729 break;
730 }
731
732 prop->SetAttribute( wxPG_ATTR_UNITS, param.info.unit );
733
734 // Legacy due to the way we extracted the parameters from Ngspice.
735 if( param.isOtherVariant )
736 prop->SetCell( 3, wxString( param.info.defaultValueOfOtherVariant ) );
737 else
738 prop->SetCell( 3, wxString( param.info.defaultValue ) );
739
740 wxString typeStr;
741
742 switch( param.info.type )
743 {
744 case SIM_VALUE::TYPE_BOOL: typeStr = wxString( "Bool" ); break;
745 case SIM_VALUE::TYPE_INT: typeStr = wxString( "Int" ); break;
746 case SIM_VALUE::TYPE_FLOAT: typeStr = wxString( "Float" ); break;
747 case SIM_VALUE::TYPE_COMPLEX: typeStr = wxString( "Complex" ); break;
748 case SIM_VALUE::TYPE_STRING: typeStr = wxString( "String" ); break;
749 case SIM_VALUE::TYPE_BOOL_VECTOR: typeStr = wxString( "Bool Vector" ); break;
750 case SIM_VALUE::TYPE_INT_VECTOR: typeStr = wxString( "Int Vector" ); break;
751 case SIM_VALUE::TYPE_FLOAT_VECTOR: typeStr = wxString( "Float Vector" ); break;
752 case SIM_VALUE::TYPE_COMPLEX_VECTOR: typeStr = wxString( "Complex Vector" ); break;
753 }
754
755 prop->SetCell( static_cast<int>( PARAM_COLUMN::TYPE ), typeStr );
756
757 if( m_useLibraryModelRadioButton->GetValue()
758 && !m_overrideCheckbox->GetValue()
759 && !param.info.isInstanceParam )
760 {
761 prop->Enable( false );
762 }
763
764 return prop;
765}
766
767
768template <typename T>
769int DIALOG_SIM_MODEL<T>::findSymbolPinRow( const wxString& aSymbolPinNumber ) const
770{
771 for( int row = 0; row < static_cast<int>( m_sortedSymbolPins.size() ); ++row )
772 {
773 LIB_PIN* pin = m_sortedSymbolPins[row];
774
775 if( pin->GetNumber() == aSymbolPinNumber )
776 return row;
777 }
778
779 return -1;
780}
781
782
783template <typename T>
785{
786 return *curModelSharedPtr();
787}
788
789
790template <typename T>
791std::shared_ptr<SIM_MODEL> DIALOG_SIM_MODEL<T>::curModelSharedPtr() const
792{
793 if( m_useLibraryModelRadioButton->GetValue()
794 && m_modelNameCombobox->GetSelection() != wxNOT_FOUND )
795 return m_libraryModels.at( m_modelNameCombobox->GetSelection() );
796 else
797 return m_models.at( static_cast<int>( m_curModelType ) );
798}
799
800
801template <typename T>
802wxString DIALOG_SIM_MODEL<T>::getSymbolPinString( int symbolPinIndex ) const
803{
804 LIB_PIN* pin = m_sortedSymbolPins.at( symbolPinIndex );
805 wxString number;
806 wxString name;
807
808 if( pin )
809 {
810 number = pin->GetShownNumber();
811 name = pin->GetShownName();
812 }
813
814 LOCALE_IO toggle;
815
816 if( name == "" )
817 return wxString::Format( "%s", number );
818 else
819 return wxString::Format( "%s (%s)", number, name );
820}
821
822
823template <typename T>
824wxString DIALOG_SIM_MODEL<T>::getModelPinString( int aModelPinIndex ) const
825{
826 const wxString& pinName = curModel().GetPin( aModelPinIndex ).name;
827
828 LOCALE_IO toggle;
829
830 if( pinName == "" )
831 return wxString::Format( "%d", aModelPinIndex + 1, pinName );
832 else
833 return wxString::Format( "%d (%s)", aModelPinIndex + 1, pinName );
834}
835
836
837template <typename T>
838int DIALOG_SIM_MODEL<T>::getModelPinIndex( const wxString& aModelPinString ) const
839{
840 if( aModelPinString == "Not Connected" )
842
843 int length = aModelPinString.Find( " " );
844
845 if( length == wxNOT_FOUND )
846 length = static_cast<int>( aModelPinString.Length() );
847
848 long result = 0;
849 aModelPinString.Mid( 0, length ).ToCLong( &result );
850
851 return static_cast<int>( result - 1 );
852}
853
854
855template <typename T>
857{
858 wxArrayString modelPinChoices;
859
860 for( int i = 0; i < curModel().GetPinCount(); ++i )
861 {
862 const SIM_MODEL::PIN& modelPin = curModel().GetPin( i );
863
864 if( modelPin.symbolPinNumber != "" )
865 continue;
866
867 modelPinChoices.Add( getModelPinString( i ) );
868 }
869
870 modelPinChoices.Add( _( "Not Connected" ) );
871 return modelPinChoices;
872}
873
874
875template <typename T>
876void DIALOG_SIM_MODEL<T>::onRadioButton( wxCommandEvent& aEvent )
877{
878 updateWidgets();
879}
880
881
882template <typename T>
883void DIALOG_SIM_MODEL<T>::onBrowseButtonClick( wxCommandEvent& aEvent )
884{
885 wxFileDialog dlg( this, _( "Browse Models" ), Prj().GetProjectPath() );
886
887 if( dlg.ShowModal() == wxID_CANCEL )
888 return;
889
890 wxString path = dlg.GetPath();
891 wxFileName fn( path );
892
893 if( fn.MakeRelativeTo( Prj().GetProjectPath() ) && !fn.GetFullPath().StartsWith( ".." ) )
894 path = fn.GetFullPath();
895
896 loadLibrary( path );
897}
898
899
900template <typename T>
901void DIALOG_SIM_MODEL<T>::onModelNameCombobox( wxCommandEvent& aEvent )
902{
903 if( IsIbisLoaded() )
904 {
905 wxArrayString pinLabels;
906 SIM_MODEL_KIBIS* modelkibis = dynamic_cast<SIM_MODEL_KIBIS*>( &curModel() );
907
908 if( !modelkibis )
909 {
910 wxFAIL;
911 return;
912 }
913
914 for( std::pair<wxString, wxString> strs : modelkibis->GetIbisPins() )
915 {
916 pinLabels.Add( strs.first + " - " + strs.second );
917 }
918
919 m_ibisPinCombobox->Set( pinLabels );
920
921 wxArrayString emptyArray;
922 m_ibisModelCombobox->Set( emptyArray );
923 }
924 updateWidgets();
925}
926
927
928template <typename T>
930{
931 m_modelNameCombobox->SetSelection(
932 m_modelNameCombobox->FindString( m_modelNameCombobox->GetValue() ) );
933 updateWidgets();
934}
935
936
937template <typename T>
939{
940 m_modelNameCombobox->SetSelection(
941 m_modelNameCombobox->FindString( m_modelNameCombobox->GetValue() ) );
942 onModelNameCombobox( aEvent );
943}
944
945
946template <typename T>
947void DIALOG_SIM_MODEL<T>::onIbisPinCombobox( wxCommandEvent& aEvent )
948{
949 if( IsIbisLoaded() )
950 {
951 wxArrayString modelLabels;
952
953 SIM_MODEL_KIBIS* modelkibis = dynamic_cast<SIM_MODEL_KIBIS*>( &curModel() );
954
955 if( !modelkibis )
956 {
957 wxFAIL;
958 return;
959 }
960
961 std::vector<std::pair<std::string, std::string>> strs = modelkibis->GetIbisPins();
962 modelkibis->ChangePin( *std::dynamic_pointer_cast<SIM_LIBRARY_KIBIS>( m_library ),
963 strs.at( m_ibisPinCombobox->GetSelection() ).first );
964
965 for( wxString modelName : modelkibis->GetIbisModels() )
966 modelLabels.Add( modelName );
967
968 m_ibisModelCombobox->Set( modelLabels );
969 }
970 updateWidgets();
971}
972
973
974template <typename T>
976{
977 m_ibisPinCombobox->SetSelection(
978 m_ibisPinCombobox->FindString( m_ibisPinCombobox->GetValue() ) );
979
980 onIbisPinCombobox( aEvent );
981}
982
983
984template <typename T>
985void DIALOG_SIM_MODEL<T>::onIbisModelCombobox( wxCommandEvent& aEvent )
986{
987 updateWidgets();
988}
989
990
991template <typename T>
993{
994 m_ibisModelCombobox->SetSelection(
995 m_ibisModelCombobox->FindString( m_ibisModelCombobox->GetValue() ) );
996
997 onIbisPinCombobox( aEvent );
998}
999
1000template <typename T>
1001void DIALOG_SIM_MODEL<T>::onOverrideCheckbox( wxCommandEvent& aEvent )
1002{
1003 updateWidgets();
1004}
1005
1006
1007template <typename T>
1008void DIALOG_SIM_MODEL<T>::onDeviceTypeChoice( wxCommandEvent& aEvent )
1009{
1010 SIM_MODEL::DEVICE_TYPE_ deviceType =
1011 static_cast<SIM_MODEL::DEVICE_TYPE_>( m_deviceTypeChoice->GetSelection() );
1012
1013 m_curModelType = m_curModelTypeOfDeviceType.at( deviceType );
1014
1015 updateWidgets();
1016}
1017
1018
1019template <typename T>
1020void DIALOG_SIM_MODEL<T>::onTypeChoice( wxCommandEvent& aEvent )
1021{
1022 SIM_MODEL::DEVICE_TYPE_ deviceType =
1023 static_cast<SIM_MODEL::DEVICE_TYPE_>( m_deviceTypeChoice->GetSelection() );
1024 wxString typeDescription = m_typeChoice->GetString( m_typeChoice->GetSelection() );
1025
1026 for( SIM_MODEL::TYPE type : SIM_MODEL::TYPE_ITERATOR() )
1027 {
1028 if( deviceType == SIM_MODEL::TypeInfo( type ).deviceType
1029 && typeDescription == SIM_MODEL::TypeInfo( type ).description )
1030 {
1031 if( IsIbisLoaded()
1032 && ( type == SIM_MODEL::TYPE::KIBIS_DEVICE || type == SIM_MODEL::TYPE::KIBIS_DRIVER
1033 || type == SIM_MODEL::TYPE::KIBIS_DIFFDRIVER
1034 || type == SIM_MODEL::TYPE::KIBIS_DIFFDEVICE ) )
1035 {
1036 std::shared_ptr<SIM_MODEL_KIBIS> kibismodel =
1037 std::dynamic_pointer_cast<SIM_MODEL_KIBIS>(
1038 m_libraryModels.at( m_modelNameCombobox->GetSelection() ) );
1039
1040 m_libraryModels.at( m_modelNameCombobox->GetSelection() ) =
1041 std::shared_ptr<SIM_MODEL>( dynamic_cast<SIM_MODEL*>(
1042 new SIM_MODEL_KIBIS( type, *kibismodel, m_fields ) ) );
1043
1044 wxCommandEvent dummyEvent;
1045 onIbisPinCombobox( dummyEvent );
1046
1047 kibismodel = std::dynamic_pointer_cast<SIM_MODEL_KIBIS>(
1048 m_libraryModels.at( m_modelNameCombobox->GetSelection() ) );
1049 }
1050
1051 m_curModelType = type;
1052 break;
1053 }
1054 }
1055
1056 m_curModelTypeOfDeviceType.at( deviceType ) = m_curModelType;
1057 updateWidgets();
1058}
1059
1060
1061template <typename T>
1062void DIALOG_SIM_MODEL<T>::onParamGridChanged( wxPropertyGridEvent& aEvent )
1063{
1064 if( IsIbisLoaded() )
1065 {
1066 wxString propValue = "";
1067 wxString propName = aEvent.GetPropertyName();
1068 wxPGProperty* property = aEvent.GetProperty();
1069
1070 if( property && propName == "wftype" )
1071 {
1072 wxVariant variant = aEvent.GetPropertyValue();
1073 propValue = property->ValueToString( variant );
1074
1075 std::shared_ptr<SIM_MODEL_KIBIS> kibismodel =
1076 std::dynamic_pointer_cast<SIM_MODEL_KIBIS>(
1077 m_libraryModels.at( m_modelNameCombobox->GetSelection() ) );
1078
1079 kibismodel->SetParameters( std::string( propValue.c_str() ) );
1080 kibismodel->SetParamValue( "wftype", std::string( propValue.c_str() ) );
1081 }
1082 }
1083 updateWidgets();
1084}
1085
1086
1087template <typename T>
1089{
1090 // For some reason all text gets selected for me -Mikolaj
1091 if( m_wasCodePreviewUpdated )
1092 m_codePreview->SelectNone();
1093
1094 m_wasCodePreviewUpdated = false;
1095}
1096
1097
1098template <typename T>
1100{
1101 int symbolPinIndex = aEvent.GetRow();
1102 int oldModelPinIndex = getModelPinIndex( aEvent.GetString() );
1103 int modelPinIndex = getModelPinIndex(
1104 m_pinAssignmentsGrid->GetCellValue( aEvent.GetRow(), aEvent.GetCol() ) );
1105
1106 if( oldModelPinIndex != SIM_MODEL::PIN::NOT_CONNECTED )
1107 curModel().SetPinSymbolPinNumber( oldModelPinIndex, "" );
1108
1109 if( modelPinIndex != SIM_MODEL::PIN::NOT_CONNECTED )
1110 {
1111 curModel().SetPinSymbolPinNumber( modelPinIndex,
1112 std::string( m_sortedSymbolPins.at( symbolPinIndex )->GetShownNumber().ToUTF8() ) );
1113 }
1114
1115 updatePinAssignments();
1116
1117 aEvent.Skip();
1118}
1119
1120
1121template <typename T>
1123{
1124 wxGridUpdateLocker deferRepaintsTillLeavingScope( m_pinAssignmentsGrid );
1125
1126 int gridWidth = KIPLATFORM::UI::GetUnobscuredSize( m_pinAssignmentsGrid ).x;
1127 m_pinAssignmentsGrid->SetColSize( static_cast<int>( PIN_COLUMN::MODEL ), gridWidth / 2 );
1128 m_pinAssignmentsGrid->SetColSize( static_cast<int>( PIN_COLUMN::SYMBOL ), gridWidth / 2 );
1129
1130 aEvent.Skip();
1131}
1132
1133
1134template <typename T>
1136{
1137 curModel().SetIsEnabled( !m_excludeSymbolCheckbox->GetValue() );
1138}
1139
1140
1141template <typename T>
1142void DIALOG_SIM_MODEL<T>::onLibraryPathUpdate( wxUpdateUIEvent& aEvent )
1143{
1144 aEvent.Enable( m_useLibraryModelRadioButton->GetValue() );
1145}
1146
1147
1148template <typename T>
1149void DIALOG_SIM_MODEL<T>::onBrowseButtonUpdate( wxUpdateUIEvent& aEvent )
1150{
1151 aEvent.Enable( m_useLibraryModelRadioButton->GetValue() );
1152}
1153
1154
1155template <typename T>
1157{
1158 aEvent.Enable( m_useLibraryModelRadioButton->GetValue() );
1159}
1160
1161
1162template <typename T>
1164{
1165 aEvent.Enable( m_useLibraryModelRadioButton->GetValue() );
1166}
1167
1168
1169template <typename T>
1171{
1172 aEvent.Enable( m_useInstanceModelRadioButton->GetValue() );
1173}
1174
1175
1176template <typename T>
1177void DIALOG_SIM_MODEL<T>::onTypeChoiceUpdate( wxUpdateUIEvent& aEvent )
1178{
1179 aEvent.Enable( m_useInstanceModelRadioButton->GetValue() || ( IsIbisLoaded() ) );
1180}
1181
1182
1183template <typename T>
1185{
1186 // By default, when a property grid is focused, the textbox is not immediately focused until
1187 // Tab key is pressed. This is inconvenient, so we fix that here.
1188
1189 wxPropertyGrid* grid = m_paramGrid->GetGrid();
1190 if( !grid )
1191 {
1192 wxFAIL;
1193 return;
1194 }
1195
1196 wxPGProperty* selected = grid->GetSelection();
1197
1198 if( !selected )
1199 selected = grid->wxPropertyGridInterface::GetFirst();
1200
1201 if( selected )
1202 grid->DoSelectProperty( selected, wxPG_SEL_FOCUS );
1203
1204 aEvent.Skip();
1205}
1206
1207
1208template <typename T>
1209void DIALOG_SIM_MODEL<T>::onParamGridSelectionChange( wxPropertyGridEvent& aEvent )
1210{
1211 wxPropertyGrid* grid = m_paramGrid->GetGrid();
1212 if( !grid )
1213 {
1214 wxFAIL;
1215 return;
1216 }
1217
1218 // Jump over categories.
1219 if( grid->GetSelection() && grid->GetSelection()->IsCategory() )
1220 {
1221 wxPGProperty* selection = grid->GetSelection();
1222
1223 // If the new selection is immediately above the previous selection, we jump up. Otherwise
1224 // we jump down. We do this by simulating up or down arrow keys.
1225
1226 wxPropertyGridIterator it = grid->GetIterator( wxPG_ITERATE_VISIBLE, selection );
1227 it.Next();
1228
1229 wxKeyEvent* keyEvent = new wxKeyEvent( wxEVT_KEY_DOWN );
1230
1231 if( *it == m_prevParamGridSelection )
1232 {
1233 if( !selection->IsExpanded() )
1234 {
1235 grid->Expand( selection );
1236 keyEvent->m_keyCode = WXK_DOWN;
1237 wxQueueEvent( grid, keyEvent );
1238
1239 // Does not work for some reason.
1240 /*m_paramGrid->DoSelectProperty( selection->Item( selection->GetChildCount() - 1 ),
1241 wxPG_SEL_FOCUS );*/
1242 }
1243 else
1244 {
1245 keyEvent->m_keyCode = WXK_UP;
1246 wxQueueEvent( grid, keyEvent );
1247 }
1248 }
1249 else
1250 {
1251 if( !selection->IsExpanded() )
1252 grid->Expand( selection );
1253
1254 keyEvent->m_keyCode = WXK_DOWN;
1255 wxQueueEvent( grid, keyEvent );
1256 }
1257
1258 m_prevParamGridSelection = grid->GetSelection();
1259 return;
1260 }
1261
1262 wxWindow* editorControl = grid->GetEditorControl();
1263 if( !editorControl )
1264 {
1265 m_prevParamGridSelection = grid->GetSelection();
1266 return;
1267 }
1268
1269 // Without this the user had to press tab before they could edit the field.
1270 editorControl->SetFocus();
1271 m_prevParamGridSelection = grid->GetSelection();
1272}
1273
1274template <typename T>
1276{
1277 m_ibisModelCombobox->Show( aIbisMode );
1278 m_ibisPinCombobox->Show( aIbisMode );
1279 m_ibisModelLabel->Show( aIbisMode );
1280 m_ibisPinLabel->Show( aIbisMode );
1281 m_overrideCheckbox->Show( !aIbisMode );
1282
1283 m_modelNameLabel->SetLabel( aIbisMode ? "Component:" : "Model:" );
1284 this->Fit();
1285 this->Refresh();
1286 this->Update();
1287}
1288
1289template class DIALOG_SIM_MODEL<SCH_FIELD>;
1290template class DIALOG_SIM_MODEL<LIB_FIELD>;
const char * name
Definition: DXF_plotter.cpp:56
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ small_folder
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_SIM_MODEL_BASE.
wxPropertyGridManager * m_paramGridMgr
wxPropertyGridPage * m_paramGrid
wxBitmapButton * m_browseButton
wxStyledTextCtrl * m_codePreview
void onDeviceTypeChoiceUpdate(wxUpdateUIEvent &aEvent) override
void onTypeChoice(wxCommandEvent &aEvent) override
void onExcludeSymbolCheckbox(wxCommandEvent &aEvent) override
void onTypeChoiceUpdate(wxUpdateUIEvent &aEvent) override
std::map< SIM_MODEL::DEVICE_TYPE_, SIM_MODEL::TYPE > m_curModelTypeOfDeviceType
void onParamGridChanged(wxPropertyGridEvent &aEvent) override
std::vector< LIB_PIN * > m_sortedSymbolPins
wxString getSymbolPinString(int aSymbolPinNumber) const
void onPinAssignmentsGridCellChange(wxGridEvent &aEvent) override
void loadLibrary(const wxString &aFilePath)
wxPGProperty * newParamProperty(int aParamIndex) const
void onIbisModelComboboxTextEnter(wxCommandEvent &event) override
void removeOrphanedPinAssignments()
int findSymbolPinRow(const wxString &aSymbolPinNumber) const
void onRadioButton(wxCommandEvent &aEvent) override
int getModelPinIndex(const wxString &aModelPinString) const
MODEL_NAME_VALIDATOR m_modelNameValidator
void addParamPropertyIfRelevant(int aParamIndex)
SCH_SYMBOL & m_symbol
wxArrayString getModelPinChoices() const
void onBrowseButtonUpdate(wxUpdateUIEvent &aEvent) override
void onParamGridSelectionChange(wxPropertyGridEvent &aEvent)
std::unique_ptr< SCINTILLA_TRICKS > m_scintillaTricks
void onIbisPinComboboxTextEnter(wxCommandEvent &event) override
void onModelNameCombobox(wxCommandEvent &aEvent) override
std::shared_ptr< SIM_MODEL > curModelSharedPtr() const
void onModelNameComboboxKillFocus(wxFocusEvent &event) override
void onModelNameComboboxTextEnter(wxCommandEvent &event) override
void onModelNameComboboxUpdate(wxUpdateUIEvent &aEvent) override
SIM_MODEL & curModel() const
void onBrowseButtonClick(wxCommandEvent &aEvent) override
void onOverrideCheckbox(wxCommandEvent &aEvent) override
wxString getModelPinString(int aModelPinIndex) const
void onIbisPinCombobox(wxCommandEvent &event) override
std::vector< std::shared_ptr< SIM_MODEL > > m_models
void onPinAssignmentsGridSize(wxSizeEvent &aEvent) override
void onParamGridSetFocus(wxFocusEvent &aEvent)
bool TransferDataFromWindow() override
DIALOG_SIM_MODEL(wxWindow *aParent, SCH_SYMBOL &aSymbol, std::vector< T > &aSchFields)
void setIbisMode(bool aIbisMode)
void onOverrideCheckboxUpdate(wxUpdateUIEvent &aEvent) override
void onLibraryPathUpdate(wxUpdateUIEvent &aEvent) override
void onIbisModelCombobox(wxCommandEvent &event) override
void onCodePreviewSetFocus(wxFocusEvent &aEvent) override
void onDeviceTypeChoice(wxCommandEvent &aEvent) override
bool TransferDataToWindow() override
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:41
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
Definition: project.cpp:304
Schematic symbol object.
Definition: sch_symbol.h:79
void GetLibPins(std::vector< LIB_PIN * > &aPinsList) const
Populate a vector with all the pins from the library object.
Definition: sch_symbol.cpp:949
static constexpr auto MODEL_FIELD
static constexpr auto PIN_FIELD
static constexpr auto LIBRARY_FIELD
Definition: sim_library.h:34
static constexpr auto NAME_FIELD
Definition: sim_library.h:35
std::vector< std::string > GetIbisModels() const
bool ChangePin(SIM_LIBRARY_KIBIS &aLib, std::string aPinNumber)
update the list of available models based on the pin number.
std::vector< std::pair< std::string, std::string > > GetIbisPins() const
static std::unique_ptr< SIM_MODEL > Create(TYPE aType, unsigned aSymbolPinCount)
Definition: sim_model.cpp:616
static void SetFieldValue(std::vector< T > &aFields, const std::string &aFieldName, const std::string &aValue)
Definition: sim_model.cpp:703
static INFO TypeInfo(TYPE aType)
Definition: sim_model.cpp:114
static TYPE ReadTypeFromFields(const std::vector< T > &aFields)
Definition: sim_model.cpp:390
static constexpr auto TYPE_FIELD
Definition: sim_model.h:111
static DEVICE_INFO DeviceTypeInfo(DEVICE_TYPE_ aDeviceType)
Definition: sim_model.cpp:75
static std::string GetFieldValue(const std::vector< T > *aFields, const std::string &aFieldName)
Definition: sim_model.cpp:674
const SIM_MODEL::PARAM & GetParam() const
Definition: sim_property.h:96
@ TYPE_BOOL
Definition: sim_value.h:56
@ TYPE_FLOAT_VECTOR
Definition: sim_value.h:64
@ TYPE_BOOL_VECTOR
Definition: sim_value.h:62
@ TYPE_INT
Definition: sim_value.h:57
@ TYPE_FLOAT
Definition: sim_value.h:58
@ TYPE_INT_VECTOR
Definition: sim_value.h:63
@ TYPE_COMPLEX_VECTOR
Definition: sim_value.h:65
@ TYPE_STRING
Definition: sim_value.h:60
@ TYPE_COMPLEX
Definition: sim_value.h:59
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:299
This file is part of the common library.
#define _(s)
PROJECT & Prj()
Definition: kicad.cpp:403
wxSize GetUnobscuredSize(const wxWindow *aWindow)
Tries to determine the size of the viewport of a scrollable widget (wxDataViewCtrl,...
Definition: gtk/ui.cpp:126
Definition: bitmap.cpp:64
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
SIM_MODEL::TYPE TYPE
Definition: sim_model.cpp:51
std::vector< std::string > enumValues
Definition: sim_model.h:384
SIM_VALUE::TYPE type
Definition: sim_model.h:373
std::string defaultValue
Definition: sim_model.h:377
std::string defaultValueOfOtherVariant
Definition: sim_model.h:378
std::string description
Definition: sim_model.h:379
std::shared_ptr< SIM_VALUE > value
Definition: sim_model.h:421
const INFO & info
Definition: sim_model.h:422
std::string symbolPinNumber
Definition: sim_model.h:332
static constexpr auto NOT_CONNECTED
Definition: sim_model.h:334
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".