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, bool aForceReload = false );
83
84 void addParamPropertyIfRelevant( SIM_MODEL* aModel, int aParamIndex );
85 wxPGProperty* newParamProperty( SIM_MODEL* aModel, int aParamIndex ) const;
86
87 int findSymbolPinRow( const wxString& aSymbolPinNumber ) const;
88
89 SIM_MODEL& curModel() const;
90 const SIM_LIBRARY* library() const;
91
92 wxString getSymbolPinString( int aSymbolPinNumber ) const;
93 wxString getModelPinString( SIM_MODEL* aModel, int aModelPinIndex ) const;
94 int getModelPinIndex( const wxString& aModelPinString ) const;
95
96 void onRadioButton( wxCommandEvent& aEvent ) override;
97 void onLibrarayPathText( wxCommandEvent& aEvent ) override;
98 void onLibraryPathTextEnter( wxCommandEvent& aEvent ) override;
99 void onLibraryPathTextKillFocus( wxFocusEvent& aEvent ) override;
100 void onBrowseButtonClick( wxCommandEvent& aEvent ) override;
101 void onModelNameChoice( wxCommandEvent& aEvent ) override;
102 void onPinCombobox( wxCommandEvent& event ) override;
103 void onPinComboboxTextEnter( wxCommandEvent& event ) override;
104 void onPinModelCombobox( wxCommandEvent& event ) override;
105 void onPinModelComboboxTextEnter( wxCommandEvent& event ) override;
106 void onDeviceTypeChoice( wxCommandEvent& aEvent ) override;
107 void onWaveformChoice( wxCommandEvent& aEvent ) override;
108 void onTypeChoice( wxCommandEvent& aEvent ) override;
109 void onPageChanging( wxNotebookEvent& event ) override;
110 void onPinAssignmentsGridCellChange( wxGridEvent& aEvent ) override;
111 void onPinAssignmentsGridSize( wxSizeEvent& aEvent ) override;
112 void onDifferentialCheckbox( wxCommandEvent& event ) override;
113 void onSizeParamGrid( wxSizeEvent& event ) override;
114
115 void onParamGridSetFocus( wxFocusEvent& aEvent );
116 void onParamGridSelectionChange( wxPropertyGridEvent& aEvent );
117 void onUpdateUI( wxUpdateUIEvent& aEvent );
118
119 void adjustParamGridColumns( int aWidth, bool aForce );
120
121 bool isIbisLoaded() { return dynamic_cast<const SIM_LIBRARY_KIBIS*>( library() ); }
122
123private:
126 std::vector<SCH_FIELD>& m_fields;
127
132
133 std::vector<SCH_PIN*> m_sortedPartPins; //< Pins of the current part.
134 std::map<SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType;
135 SIM_MODEL::TYPE m_curModelType;
136
139
140 wxPGProperty* m_firstCategory; // Used to add principal parameters to root.
142
145};
146
147#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
int findSymbolPinRow(const wxString &aSymbolPinNumber) const
void onModelNameChoice(wxCommandEvent &aEvent) override
void onRadioButton(wxCommandEvent &aEvent) override
SCINTILLA_TRICKS * m_scintillaTricksSubckt
SIM_LIB_MGR m_builtinModelsMgr
int getModelPinIndex(const wxString &aModelPinString) const
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
void updatePinAssignments(SIM_MODEL *aModel, bool aForceUpdatePins)
void onUpdateUI(wxUpdateUIEvent &aEvent)
wxString getModelPinString(SIM_MODEL *aModel, int aModelPinIndex) const
void onPinAssignmentsGridSize(wxSizeEvent &aEvent) override
bool loadLibrary(const wxString &aLibraryPath, bool aForceReload=false)
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)
void onLibrarayPathText(wxCommandEvent &aEvent) override
The base frame for deriving all KiCad main window classes.
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