KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
dialog_sim_model.h
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 The 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#ifndef DIALOG_SIM_MODEL_H
26#define DIALOG_SIM_MODEL_H
27#include <sim/kibis/kibis.h>
28
31#include <scintilla_tricks.h>
32
33#include <sim/sim_model.h>
34#include <sim/sim_library.h>
36#include <sch_symbol.h>
37
38class EMBEDDED_FILES;
39
40// Some probable wxWidgets bugs encountered when writing this class:
41// 1. There are rendering problems with wxPropertyGrid on Linux, GTK, Xorg when
42// wxPG_NATIVE_DOUBLE_BUFFERING flag is not set.
43// 2. wxPropertyGridManager->ShowHeader() segfaults when called from this dialog's constructor.
44
45template <typename T>
47{
48public:
50 {
56 END_
57 };
58
60 {
61 SYMBOL = 0,
62 MODEL
63 };
64
65 DIALOG_SIM_MODEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame, T& aSymbol,
66 std::vector<SCH_FIELD>& aFields );
67
69
70private:
71 bool TransferDataToWindow() override;
72 bool TransferDataFromWindow() override;
73
74 void updateWidgets();
75 void updateIbisWidgets( SIM_MODEL* aModel );
77 void updateModelParamsTab( SIM_MODEL* aModel );
78 void updateModelCodeTab( SIM_MODEL* aModel );
79 void updatePinAssignments( SIM_MODEL* aModel, bool aForceUpdatePins );
80
82
83 bool loadLibrary( const wxString& aLibraryPath, REPORTER& aReporter,
84 bool aForceReload = false );
85
86 void addParamPropertyIfRelevant( SIM_MODEL* aModel, int aParamIndex );
87 wxPGProperty* newParamProperty( SIM_MODEL* aModel, int aParamIndex ) const;
88
89 int findSymbolPinRow( const wxString& aSymbolPinNumber ) const;
90
91 SIM_MODEL& curModel() const;
92 const SIM_LIBRARY* library() const;
93
94 wxString getSymbolPinString( int aSymbolPinNumber ) const;
95 wxString getModelPinString( SIM_MODEL* aModel, int aModelPinIndex ) const;
96 int getModelPinIndex( const wxString& aModelPinString ) const;
97
98 void onRadioButton( wxCommandEvent& aEvent ) override;
99 void onLibraryPathText( wxCommandEvent& aEvent ) override;
100 void onLibraryPathTextEnter( wxCommandEvent& aEvent ) override;
101 void onLibraryPathTextKillFocus( wxFocusEvent& aEvent ) override;
102 void onBrowseButtonClick( wxCommandEvent& aEvent ) override;
103 void onFilterCharHook( wxKeyEvent& aKeyStroke ) override;
104 void onModelFilter( wxCommandEvent& aEvent ) override;
105 void onModelNameChoice( wxCommandEvent& aEvent ) override;
106 void onPinCombobox( wxCommandEvent& event ) override;
107 void onPinComboboxTextEnter( wxCommandEvent& event ) override;
108 void onPinModelCombobox( wxCommandEvent& event ) override;
109 void onPinModelComboboxTextEnter( wxCommandEvent& event ) override;
110 void onDeviceTypeChoice( wxCommandEvent& aEvent ) override;
111 void onWaveformChoice( wxCommandEvent& aEvent ) override;
112 void onTypeChoice( wxCommandEvent& aEvent ) override;
113 void onPageChanging( wxNotebookEvent& event ) override;
114 void onPinAssignmentsGridCellChange( wxGridEvent& aEvent ) override;
115 void onPinAssignmentsGridSize( wxSizeEvent& aEvent ) override;
116 void onDifferentialCheckbox( wxCommandEvent& event ) override;
117 void onSizeParamGrid( wxSizeEvent& event ) override;
118
119 void onParamGridSetFocus( wxFocusEvent& aEvent );
120 void onParamGridSelectionChange( wxPropertyGridEvent& aEvent );
121 void onUpdateUI( wxUpdateUIEvent& aEvent );
122
123 void adjustParamGridColumns( int aWidth, bool aForce );
124
125 bool isIbisLoaded() { return dynamic_cast<const SIM_LIBRARY_IBIS*>( library() ); }
126
127private:
130 std::vector<SCH_FIELD>& m_fields;
131
137
138 std::map<wxString, int> m_modelListBoxEntryToLibraryIdx;
139
140 std::vector<SCH_PIN*> m_sortedPartPins;
141 std::map<SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType;
142 SIM_MODEL::TYPE m_curModelType;
143
146
147 wxPGProperty* m_firstCategory; // Used to add principal parameters to root.
149
151};
152
153#endif /* DIALOG_SIM_MODEL_H */
Class DIALOG_SIM_MODEL_BASE.
const SIM_MODEL * m_prevModel
EMBEDDED_FILES * m_files
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)
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
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
std::map< wxString, int > m_modelListBoxEntryToLibraryIdx
void updatePinAssignments(SIM_MODEL *aModel, bool aForceUpdatePins)
void onUpdateUI(wxUpdateUIEvent &aEvent)
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
void onWaveformChoice(wxCommandEvent &aEvent) override
std::map< SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE > m_curModelTypeOfDeviceType
void onPinModelComboboxTextEnter(wxCommandEvent &event) override
EDA_BASE_FRAME * m_frame
void onLibraryPathTextEnter(wxCommandEvent &aEvent) override
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.
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:73
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
A base class for LIB_SYMBOL and SCH_SYMBOL.
Definition: symbol.h:63