2016-08-11 14:41:40 +02:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2022-02-09 01:45:04 +01:00
|
|
|
* Copyright (C) 2022 Mikolaj Wielgus
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2016-08-11 14:41:40 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2016-08-11 14:41:43 +02:00
|
|
|
* as published by the Free Software Foundation; either version 3
|
2016-08-11 14:41:40 +02:00
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
2016-08-11 14:41:43 +02:00
|
|
|
* https://www.gnu.org/licenses/gpl-3.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 3 license,
|
2016-08-11 14:41:40 +02:00
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2022-06-21 04:22:52 +02:00
|
|
|
#ifndef DIALOG_SIM_MODEL_H
|
|
|
|
#define DIALOG_SIM_MODEL_H
|
2022-10-25 09:45:40 +00:00
|
|
|
#include <sim/kibis/kibis.h>
|
2016-08-11 14:41:40 +02:00
|
|
|
|
2022-04-12 16:37:06 +02:00
|
|
|
#include <dialog_sim_model_base.h>
|
|
|
|
#include <netlist_exporter_spice.h>
|
2021-12-03 03:41:02 +01:00
|
|
|
#include <scintilla_tricks.h>
|
2016-08-11 14:41:56 +02:00
|
|
|
|
2022-02-21 04:58:31 +01:00
|
|
|
#include <sim/sim_model.h>
|
2022-04-01 06:30:50 +02:00
|
|
|
#include <sim/sim_library.h>
|
2024-06-10 20:16:30 +01:00
|
|
|
#include <sim/sim_library_ibis.h>
|
2021-02-24 08:48:02 -05:00
|
|
|
#include <sch_symbol.h>
|
2016-08-11 14:41:56 +02:00
|
|
|
|
2025-02-22 13:33:22 -08:00
|
|
|
class EMBEDDED_FILES;
|
2022-06-21 04:22:52 +02:00
|
|
|
|
2022-02-21 04:58:31 +01:00
|
|
|
// Some probable wxWidgets bugs encountered when writing this class:
|
|
|
|
// 1. There are rendering problems with wxPropertyGrid on Linux, GTK, Xorg when
|
|
|
|
// wxPG_NATIVE_DOUBLE_BUFFERING flag is not set.
|
|
|
|
// 2. wxPropertyGridManager->ShowHeader() segfaults when called from this dialog's constructor.
|
|
|
|
|
2024-04-12 22:00:41 +01:00
|
|
|
template <typename T>
|
2022-04-12 16:37:06 +02:00
|
|
|
class DIALOG_SIM_MODEL : public DIALOG_SIM_MODEL_BASE
|
2016-08-11 14:41:40 +02:00
|
|
|
{
|
|
|
|
public:
|
2022-10-28 12:43:00 +01:00
|
|
|
enum PARAM_COLUMN
|
|
|
|
{
|
|
|
|
DESCRIPTION = 0,
|
|
|
|
VALUE,
|
|
|
|
UNIT,
|
|
|
|
DEFAULT,
|
|
|
|
TYPE,
|
|
|
|
END_
|
|
|
|
};
|
|
|
|
|
|
|
|
enum PIN_COLUMN
|
|
|
|
{
|
|
|
|
SYMBOL = 0,
|
|
|
|
MODEL
|
|
|
|
};
|
2022-02-09 01:45:04 +01:00
|
|
|
|
2024-04-12 22:00:41 +01:00
|
|
|
DIALOG_SIM_MODEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame, T& aSymbol,
|
|
|
|
std::vector<SCH_FIELD>& aFields );
|
2016-08-11 14:41:40 +02:00
|
|
|
|
2022-10-28 00:33:31 +01:00
|
|
|
~DIALOG_SIM_MODEL();
|
|
|
|
|
2016-08-11 14:41:40 +02:00
|
|
|
private:
|
2022-02-09 01:45:04 +01:00
|
|
|
bool TransferDataToWindow() override;
|
2022-04-01 06:30:50 +02:00
|
|
|
bool TransferDataFromWindow() override;
|
2016-08-11 14:41:40 +02:00
|
|
|
|
2022-02-09 01:45:04 +01:00
|
|
|
void updateWidgets();
|
2023-02-15 00:26:01 +00:00
|
|
|
void updateIbisWidgets( SIM_MODEL* aModel );
|
2023-05-20 21:03:37 +01:00
|
|
|
void updateBuiltinModelWidgets( SIM_MODEL* aModel );
|
2023-02-15 00:26:01 +00:00
|
|
|
void updateModelParamsTab( SIM_MODEL* aModel );
|
|
|
|
void updateModelCodeTab( SIM_MODEL* aModel );
|
2024-02-26 19:00:38 +00:00
|
|
|
void updatePinAssignments( SIM_MODEL* aModel, bool aForceUpdatePins );
|
2022-08-28 14:51:03 +02:00
|
|
|
|
2023-02-15 00:26:01 +00:00
|
|
|
void removeOrphanedPinAssignments( SIM_MODEL* aModel );
|
2022-04-01 06:30:50 +02:00
|
|
|
|
2024-07-03 00:00:26 +01:00
|
|
|
bool loadLibrary( const wxString& aLibraryPath, REPORTER& aReporter,
|
|
|
|
bool aForceReload = false );
|
2022-09-28 11:09:35 +02:00
|
|
|
|
2023-02-15 00:26:01 +00:00
|
|
|
void addParamPropertyIfRelevant( SIM_MODEL* aModel, int aParamIndex );
|
|
|
|
wxPGProperty* newParamProperty( SIM_MODEL* aModel, int aParamIndex ) const;
|
2022-04-01 06:30:50 +02:00
|
|
|
|
2022-08-22 07:40:23 +02:00
|
|
|
int findSymbolPinRow( const wxString& aSymbolPinNumber ) const;
|
|
|
|
|
2022-04-01 06:30:50 +02:00
|
|
|
SIM_MODEL& curModel() const;
|
2023-01-12 16:29:51 +00:00
|
|
|
const SIM_LIBRARY* library() const;
|
2016-08-11 14:41:40 +02:00
|
|
|
|
2022-03-09 02:40:59 +01:00
|
|
|
wxString getSymbolPinString( int aSymbolPinNumber ) const;
|
2023-02-15 00:26:01 +00:00
|
|
|
wxString getModelPinString( SIM_MODEL* aModel, int aModelPinIndex ) const;
|
2022-08-22 07:40:23 +02:00
|
|
|
int getModelPinIndex( const wxString& aModelPinString ) const;
|
2022-03-09 02:40:59 +01:00
|
|
|
|
2022-04-01 06:30:50 +02:00
|
|
|
void onRadioButton( wxCommandEvent& aEvent ) override;
|
2024-06-22 10:22:22 +03:00
|
|
|
void onLibraryPathText( wxCommandEvent& aEvent ) override;
|
2022-11-26 03:47:41 +01:00
|
|
|
void onLibraryPathTextEnter( wxCommandEvent& aEvent ) override;
|
|
|
|
void onLibraryPathTextKillFocus( wxFocusEvent& aEvent ) override;
|
2022-04-01 06:30:50 +02:00
|
|
|
void onBrowseButtonClick( wxCommandEvent& aEvent ) override;
|
2024-08-30 20:50:18 +01:00
|
|
|
void onFilterCharHook( wxKeyEvent& aKeyStroke ) override;
|
|
|
|
void onModelFilter( wxCommandEvent& aEvent ) override;
|
2022-12-15 12:12:36 +00:00
|
|
|
void onModelNameChoice( wxCommandEvent& aEvent ) override;
|
2023-09-16 23:36:06 +01:00
|
|
|
void onPinCombobox( wxCommandEvent& event ) override;
|
|
|
|
void onPinComboboxTextEnter( wxCommandEvent& event ) override;
|
|
|
|
void onPinModelCombobox( wxCommandEvent& event ) override;
|
|
|
|
void onPinModelComboboxTextEnter( wxCommandEvent& event ) override;
|
2022-03-09 02:40:59 +01:00
|
|
|
void onDeviceTypeChoice( wxCommandEvent& aEvent ) override;
|
2023-09-16 23:36:06 +01:00
|
|
|
void onWaveformChoice( wxCommandEvent& aEvent ) override;
|
2022-03-09 02:40:59 +01:00
|
|
|
void onTypeChoice( wxCommandEvent& aEvent ) override;
|
2022-12-17 22:33:00 +00:00
|
|
|
void onPageChanging( wxNotebookEvent& event ) override;
|
2022-03-09 02:40:59 +01:00
|
|
|
void onPinAssignmentsGridCellChange( wxGridEvent& aEvent ) override;
|
|
|
|
void onPinAssignmentsGridSize( wxSizeEvent& aEvent ) override;
|
2022-10-25 09:45:40 +00:00
|
|
|
void onDifferentialCheckbox( wxCommandEvent& event ) override;
|
2022-12-08 14:40:01 +00:00
|
|
|
void onSizeParamGrid( wxSizeEvent& event ) override;
|
2022-04-01 06:30:50 +02:00
|
|
|
|
2022-06-12 05:39:13 +02:00
|
|
|
void onParamGridSetFocus( wxFocusEvent& aEvent );
|
|
|
|
void onParamGridSelectionChange( wxPropertyGridEvent& aEvent );
|
2023-02-24 12:43:41 +00:00
|
|
|
void onUpdateUI( wxUpdateUIEvent& aEvent );
|
2022-03-09 02:40:59 +01:00
|
|
|
|
2022-12-08 14:40:01 +00:00
|
|
|
void adjustParamGridColumns( int aWidth, bool aForce );
|
|
|
|
|
2024-06-10 20:16:30 +01:00
|
|
|
bool isIbisLoaded() { return dynamic_cast<const SIM_LIBRARY_IBIS*>( library() ); }
|
2022-04-01 06:30:50 +02:00
|
|
|
|
2022-10-28 12:43:00 +01:00
|
|
|
private:
|
2025-04-24 11:33:02 +01:00
|
|
|
EDA_BASE_FRAME* m_frame;
|
|
|
|
T& m_symbol;
|
|
|
|
std::vector<SCH_FIELD>& m_fields;
|
2016-08-11 14:41:40 +02:00
|
|
|
|
2025-04-24 11:33:02 +01:00
|
|
|
std::vector<EMBEDDED_FILES*> m_filesStack;
|
|
|
|
SIM_LIB_MGR m_libraryModelsMgr;
|
|
|
|
SIM_LIB_MGR m_builtinModelsMgr;
|
|
|
|
wxString m_prevLibrary;
|
|
|
|
const SIM_MODEL* m_prevModel;
|
2022-11-19 01:45:28 +01:00
|
|
|
|
2025-04-24 11:33:02 +01:00
|
|
|
std::map<wxString, int> m_modelListBoxEntryToLibraryIdx;
|
2024-12-21 14:27:23 +00:00
|
|
|
|
2025-01-18 10:32:42 -05:00
|
|
|
std::vector<SCH_PIN*> m_sortedPartPins; ///< Pins of the current part.
|
2022-12-06 14:59:49 +00:00
|
|
|
std::map<SIM_MODEL::DEVICE_T, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType;
|
|
|
|
SIM_MODEL::TYPE m_curModelType;
|
2021-12-03 03:41:02 +01:00
|
|
|
|
2024-04-12 22:00:41 +01:00
|
|
|
SCINTILLA_TRICKS* m_scintillaTricksCode;
|
|
|
|
SCINTILLA_TRICKS* m_scintillaTricksSubckt;
|
2022-06-12 05:39:13 +02:00
|
|
|
|
2024-04-12 22:00:41 +01:00
|
|
|
wxPGProperty* m_firstCategory; // Used to add principal parameters to root.
|
|
|
|
wxPGProperty* m_prevParamGridSelection;
|
2022-12-07 15:02:35 +00:00
|
|
|
|
2024-04-12 22:00:41 +01:00
|
|
|
int m_lastParamGridWidth;
|
2016-08-11 14:41:40 +02:00
|
|
|
};
|
|
|
|
|
2022-06-21 04:22:52 +02:00
|
|
|
#endif /* DIALOG_SIM_MODEL_H */
|