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-2023 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_symbol, typename T_field>
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_symbol& aSymbol,
65 std::vector<T_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:
125 T_symbol& m_symbol;
126 std::vector<T_field>& m_fields;
127
132
133 std::vector<LIB_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.
void onTypeChoice(wxCommandEvent &aEvent) override
SIM_LIB_MGR m_libraryModelsMgr
void onRadioButton(wxCommandEvent &aEvent) override
void updateBuiltinModelWidgets(SIM_MODEL *aModel)
std::vector< LIB_PIN * > m_sortedPartPins
void updatePinAssignments(SIM_MODEL *aModel, bool aForceUpdatePins)
bool loadLibrary(const wxString &aLibraryPath, bool aForceReload=false)
void onLibrarayPathText(wxCommandEvent &aEvent) override
wxString getModelPinString(SIM_MODEL *aModel, int aModelPinIndex) const
void removeOrphanedPinAssignments(SIM_MODEL *aModel)
void onWaveformChoice(wxCommandEvent &aEvent) override
void onPinAssignmentsGridCellChange(wxGridEvent &aEvent) override
SIM_MODEL::TYPE m_curModelType
void onPageChanging(wxNotebookEvent &event) override
void onParamGridSelectionChange(wxPropertyGridEvent &aEvent)
void onUpdateUI(wxUpdateUIEvent &aEvent)
int findSymbolPinRow(const wxString &aSymbolPinNumber) const
void adjustParamGridColumns(int aWidth, bool aForce)
void updateIbisWidgets(SIM_MODEL *aModel)
void onDeviceTypeChoice(wxCommandEvent &aEvent) override
SCINTILLA_TRICKS * m_scintillaTricksSubckt
EDA_BASE_FRAME * m_frame
const SIM_LIBRARY * library() const
SIM_MODEL & curModel() const
int getModelPinIndex(const wxString &aModelPinString) const
void onSizeParamGrid(wxSizeEvent &event) override
SIM_LIB_MGR m_builtinModelsMgr
wxPGProperty * m_firstCategory
void updateModelCodeTab(SIM_MODEL *aModel)
bool TransferDataToWindow() override
void onLibraryPathTextEnter(wxCommandEvent &aEvent) override
void onBrowseButtonClick(wxCommandEvent &aEvent) override
void addParamPropertyIfRelevant(SIM_MODEL *aModel, int aParamIndex)
std::map< SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE > m_curModelTypeOfDeviceType
wxString getSymbolPinString(int aSymbolPinNumber) const
std::vector< T_field > & m_fields
const SIM_MODEL * m_prevModel
void onPinCombobox(wxCommandEvent &event) override
wxPGProperty * newParamProperty(SIM_MODEL *aModel, int aParamIndex) const
void onPinComboboxTextEnter(wxCommandEvent &event) override
bool TransferDataFromWindow() override
void onDifferentialCheckbox(wxCommandEvent &event) override
wxPGProperty * m_prevParamGridSelection
void onPinModelComboboxTextEnter(wxCommandEvent &event) override
void onLibraryPathTextKillFocus(wxFocusEvent &aEvent) override
void onModelNameChoice(wxCommandEvent &aEvent) override
void updateModelParamsTab(SIM_MODEL *aModel)
SCINTILLA_TRICKS * m_scintillaTricksCode
void onParamGridSetFocus(wxFocusEvent &aEvent)
void onPinAssignmentsGridSize(wxSizeEvent &aEvent) override
void onPinModelCombobox(wxCommandEvent &event) 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