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, 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 SIM_PROPERTY_H
26#define SIM_PROPERTY_H
27
28#include <wx/notebook.h>
29#include <wx/propgrid/propgrid.h>
30#include <wx/propgrid/manager.h>
31#include <wx/propgrid/props.h>
32
33#include <sim/sim_model.h>
35
36
42
43
44class SIM_VALIDATOR : public wxValidator
45{
46private:
47 bool Validate( wxWindow* aParent ) override { return true; }
48 bool TransferToWindow() override { return true; }
49 bool TransferFromWindow() override { return true; }
50};
51
52
54{
55public:
56 SIM_PROPERTY( SIM_MODEL& aModel, int aParamIndex );
57
58 void Disable();
59
60 const SIM_MODEL::PARAM& GetParam() const { return m_model.GetParam( m_paramIndex ); }
61
62protected:
65
68
70};
71
72
73class SIM_BOOL_PROPERTY : public wxBoolProperty, public SIM_PROPERTY
74{
75public:
76 SIM_BOOL_PROPERTY( const wxString& aLabel, const wxString& aName,
77 SIM_MODEL& aModel,
78 int aParamIndex );
79
80 wxValidator* DoGetValidator() const override;
81
82 void OnSetValue() override;
83};
84
85
86class SIM_STRING_PROPERTY : public wxStringProperty, public SIM_PROPERTY
87{
88public:
89 // We pass shared_ptrs because we need to make sure they are destroyed only after the last time
90 // SIM_PROPERTY uses them.
91 SIM_STRING_PROPERTY( const wxString& aLabel, const wxString& aName,
92 SIM_MODEL& aModel,
93 int aParamIndex,
96
97 wxValidator* DoGetValidator() const override;
98
99 bool StringToValue( wxVariant& aVariant, const wxString& aText, int aArgFlags = 0 )
100 const override;
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