kicad/eeschema/dialogs/dialog_spice_model.h

87 lines
3.3 KiB
C
Raw Normal View History

2016-08-11 12:41:40 +00:00
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mikolaj Wielgus
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
2016-08-11 12:41:40 +00:00
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 3
2016-08-11 12:41:40 +00: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:
* 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 12:41:40 +00:00
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef DIALOG_SPICE_MODEL_H
#define DIALOG_SPICE_MODEL_H
#include <dialog_spice_model_base.h>
#include <netlist_exporter_pspice.h>
#include <scintilla_tricks.h>
2016-08-11 12:41:56 +00:00
#include <sim/sim_model.h>
#include <sch_symbol.h>
2016-08-11 12:41:56 +00: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.
template <typename T>
2016-08-11 12:41:40 +00:00
class DIALOG_SPICE_MODEL : public DIALOG_SPICE_MODEL_BASE
{
public:
enum class PARAM_COLUMN : int { DESCRIPTION, VALUE, UNIT, DEFAULT, TYPE, END_ };
enum class PIN_COLUMN : int { SYMBOL, MODEL };
DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_SYMBOL& aSymbol, std::vector<T>& aSchFields );
2016-08-11 12:41:40 +00:00
private:
bool TransferDataFromWindow() override;
bool TransferDataToWindow() override;
2016-08-11 12:41:40 +00:00
void updateWidgets();
void updateModelParamsTab();
void updateModelCodeTab();
void updatePinAssignmentsTab();
void updatePinAssignmentsGridEditors();
void addParamPropertyIfRelevant( const SIM_MODEL::PARAM& aParam );
wxPGProperty* newParamProperty( const SIM_MODEL::PARAM& aParam ) const;
2016-08-11 12:41:40 +00:00
SIM_MODEL& getCurModel() const;
wxString getSymbolPinString( int aSymbolPinNumber ) const;
wxString getModelPinString( int aModelPinNumber ) const;
int getModelPinNumber( const wxString& aModelPinString ) const;
void onDeviceTypeChoice( wxCommandEvent& aEvent ) override;
void onTypeChoice( wxCommandEvent& aEvent ) override;
void onPinAssignmentsGridCellChange( wxGridEvent& aEvent ) override;
void onPinAssignmentsGridSize( wxSizeEvent& aEvent ) override;
virtual void onSelectionChange( wxPropertyGridEvent& aEvent );
//void onPropertyChanged( wxPropertyGridEvent& aEvent ) override;
2021-06-10 14:10:55 +00:00
SCH_SYMBOL& m_symbol;
std::vector<T>& m_fields;
2016-08-11 12:41:40 +00:00
std::vector<std::unique_ptr<SIM_MODEL>> m_models;
std::map<SIM_MODEL::DEVICE_TYPE, SIM_MODEL::TYPE> m_curModelTypeOfDeviceType;
SIM_MODEL::TYPE m_curModelType = SIM_MODEL::TYPE::NONE;
wxPGProperty* m_firstCategory; // Used to add principal parameters to root (any better ideas?)
std::unique_ptr<SCINTILLA_TRICKS> m_scintillaTricks;
2016-08-11 12:41:40 +00:00
};
#endif /* DIALOG_SPICE_MODEL_H */