KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sim_property.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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
21#ifndef SIM_PROPERTY_H
22#define SIM_PROPERTY_H
23
24#include <wx/notebook.h>
25#include <wx/propgrid/propgrid.h>
26#include <wx/propgrid/manager.h>
27#include <wx/propgrid/props.h>
28
29#include <sim/sim_model.h>
31
32
38
39
40class SIM_VALIDATOR : public wxValidator
41{
42private:
43 bool Validate( wxWindow* aParent ) override { return true; }
44 bool TransferToWindow() override { return true; }
45 bool TransferFromWindow() override { return true; }
46};
47
48
50{
51public:
52 SIM_PROPERTY( SIM_MODEL& aModel, int aParamIndex );
53
54 void Disable();
55
56 const SIM_MODEL::PARAM& GetParam() const { return m_model.GetParam( m_paramIndex ); }
57
58protected:
61
64
66};
67
68
69class SIM_BOOL_PROPERTY : public wxBoolProperty, public SIM_PROPERTY
70{
71public:
72 SIM_BOOL_PROPERTY( const wxString& aLabel, const wxString& aName,
73 SIM_MODEL& aModel,
74 int aParamIndex );
75
76 wxValidator* DoGetValidator() const override;
77
78 void OnSetValue() override;
79};
80
81
82class SIM_STRING_PROPERTY : public wxStringProperty, public SIM_PROPERTY
83{
84public:
85 // We pass shared_ptrs because we need to make sure they are destroyed only after the last time
86 // SIM_PROPERTY uses them.
87 SIM_STRING_PROPERTY( const wxString& aLabel, const wxString& aName,
88 SIM_MODEL& aModel,
89 int aParamIndex,
92
93 wxValidator* DoGetValidator() const override;
94
95#if wxCHECK_VERSION( 3, 3, 0 )
96 bool StringToValue( wxVariant& aVariant, const wxString& aText,
97 wxPGPropValFormatFlags aArgFlags = wxPGPropValFormatFlags::Null ) const override;
98#else
99 bool StringToValue( wxVariant& aVariant, const wxString& aText, int aArgFlags = 0 ) const override;
100#endif
101
102 bool OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event ) override;
103
104protected:
105 bool allowEval() const;
106
107protected:
109};
110
111
112class SIM_ENUM_PROPERTY : public wxEnumProperty, public SIM_PROPERTY
113{
114public:
115 SIM_ENUM_PROPERTY( const wxString& aLabel, const wxString& aName, SIM_MODEL& aModel,
116 int aParamIndex, const wxArrayString& aValues );
117
118#if wxCHECK_VERSION( 3, 3, 0 )
119 bool IntToValue( wxVariant& aVariant, int aNumber,
120 wxPGPropValFormatFlags aArgFlags = wxPGPropValFormatFlags::Null ) const override;
121#else
122 bool IntToValue( wxVariant& aVariant, int aNumber, int aArgFlags = 0 ) const override;
123#endif
124};
125
126#endif // SIM_PROPERTY_H
SIM_BOOL_PROPERTY(const wxString &aLabel, const wxString &aName, SIM_MODEL &aModel, int aParamIndex)
void OnSetValue() override
wxValidator * DoGetValidator() const override
SIM_ENUM_PROPERTY(const wxString &aLabel, const wxString &aName, SIM_MODEL &aModel, int aParamIndex, const wxArrayString &aValues)
bool IntToValue(wxVariant &aVariant, int aNumber, int aArgFlags=0) const override
const SIM_MODEL::PARAM & GetParam() const
SIM_PROPERTY(SIM_MODEL &aModel, int aParamIndex)
wxPropertyGrid property specializations for simulator.
SIM_MODEL & m_model
bool m_disabled
If true, never access the models.
NUMERIC_EVALUATOR m_eval
wxValidator * DoGetValidator() const override
SIM_STRING_PROPERTY(const wxString &aLabel, const wxString &aName, SIM_MODEL &aModel, int aParamIndex, SIM_VALUE::TYPE aValueType=SIM_VALUE::TYPE_FLOAT, SIM_VALUE_GRAMMAR::NOTATION aNotation=SIM_VALUE_GRAMMAR::NOTATION::SI)
SIM_VALUE::TYPE m_valueType
bool OnEvent(wxPropertyGrid *propgrid, wxWindow *wnd_primary, wxEvent &event) override
bool StringToValue(wxVariant &aVariant, const wxString &aText, int aArgFlags=0) const override
wxPropertyGrid property specializations for simulator.
bool Validate(wxWindow *aParent) override
bool TransferToWindow() override
bool TransferFromWindow() override