KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 (C) 2022-2024 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
38
39// Some probable wxWidgets bugs encountered when writing this class:
40// 1. There are rendering problems with wxPropertyGrid on Linux, GTK, Xorg when
41// wxPG_NATIVE_DOUBLE_BUFFERING flag is not set.
42// 2. wxPropertyGridManager->ShowHeader() segfaults when called from this dialog's constructor.
43
44template <typename T>
46{
47public:
49 {
55 END_
56 };
57
59 {
60 SYMBOL = 0,
61 MODEL
62 };
63
64 DIALOG_SIM_MODEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame, T& aSymbol,
65 std::vector<SCH_FIELD>& aFields );
66
68
69private:
70 bool TransferDataToWindow() override;
71 bool TransferDataFromWindow() override;
72
73 void updateWidgets();
74 void updateIbisWidgets( SIM_MODEL* aModel );
76 void updateModelParamsTab( SIM_MODEL* aModel );
77 void updateModelCodeTab( SIM_MODEL* aModel );
78 void updatePinAssignments( SIM_MODEL* aModel, bool aForceUpdatePins );
79
81
82 bool loadLibrary( const wxString& aLibraryPath, REPORTER& aReporter,
83 bool aForceReload = false );
84
85 void addParamPropertyIfRelevant( SIM_MODEL* aModel, int aParamIndex );
86 wxPGProperty* newParamProperty( SIM_MODEL* aModel, int aParamIndex ) const;
87
88 int findSymbolPinRow( const wxString& aSymbolPinNumber ) const;
89
90 SIM_MODEL& curModel() const;
91 const SIM_LIBRARY* library() const;
92
93 wxString getSymbolPinString( int aSymbolPinNumber ) const;
94 wxString getModelPinString( SIM_MODEL* aModel, int aModelPinIndex ) const;
95 int getModelPinIndex( const wxString& aModelPinString ) const;
96
97 void onRadioButton( wxCommandEvent& aEvent ) override;
98 void onLibraryPathText( wxCommandEvent& aEvent ) override;
99 void onLibraryPathTextEnter( wxCommandEvent& aEvent ) override;
100 void onLibraryPathTextKillFocus( wxFocusEvent& aEvent ) override;
101 void onBrowseButtonClick( wxCommandEvent& aEvent ) override;
102 void onFilterCharHook( wxKeyEvent& aKeyStroke ) override;
103 void onModelFilter( wxCommandEvent& aEvent ) override;
104 void onModelNameChoice( wxCommandEvent& aEvent ) override;
105 void onPinCombobox( wxCommandEvent& event ) override;
106 void onPinComboboxTextEnter( wxCommandEvent& event ) override;
107 void onPinModelCombobox( wxCommandEvent& event ) override;
108 void onPinModelComboboxTextEnter( wxCommandEvent& event ) override;
109 void onDeviceTypeChoice( wxCommandEvent& aEvent ) override;
110 void onWaveformChoice( wxCommandEvent& aEvent ) override;
111 void onTypeChoice( wxCommandEvent& aEvent ) override;
112 void onPageChanging( wxNotebookEvent& event ) override;
113 void onPinAssignmentsGridCellChange( wxGridEvent& aEvent ) override;
114 void onPinAssignmentsGridSize( wxSizeEvent& aEvent ) override;
115 void onDifferentialCheckbox( wxCommandEvent& event ) override;
116 void onSizeParamGrid( wxSizeEvent& event ) override;
117
118 void onParamGridSetFocus( wxFocusEvent& aEvent );
119 void onParamGridSelectionChange( wxPropertyGridEvent& aEvent );
120 void onUpdateUI( wxUpdateUIEvent& aEvent );
121
122 void adjustParamGridColumns( int aWidth, bool aForce );
123
124 bool isIbisLoaded() { return dynamic_cast<const SIM_LIBRARY_IBIS*>( library() ); }
125
126private:
129 std::vector<SCH_FIELD>& m_fields;
130
135
136 std::map<wxString, int> m_modelListBoxEntryToLibraryIdx;
137
138 std::vector<SCH_PIN*> m_sortedPartPins; //< Pins of the current part.
139 std::map<SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType;
140 SIM_MODEL::TYPE m_curModelType;
141
144
145 wxPGProperty* m_firstCategory; // Used to add principal parameters to root.
147
149};
150
151#endif /* DIALOG_SIM_MODEL_H */
Class DIALOG_SIM_MODEL_BASE.
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)
void adjustParamGridColumns(int aWidth, bool aForce)
std::vector< SCH_FIELD > & m_fields
std::vector< SCH_PIN * > m_sortedPartPins
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:72
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:34