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 (C) 2022 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
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
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
void OnSetValue() override
wxValidator * DoGetValidator() const override
bool IntToValue(wxVariant &aVariant, int aNumber, int aArgFlags=0) const override
virtual const PARAM & GetParam(unsigned aParamIndex) const
Definition: sim_model.cpp:789
const SIM_MODEL::PARAM & GetParam() const
Definition: sim_property.h:60
SIM_MODEL & m_model
Definition: sim_property.h:63
bool m_disabled
If true, never access the models.
Definition: sim_property.h:69
bool m_needsEval
Definition: sim_property.h:66
NUMERIC_EVALUATOR m_eval
Definition: sim_property.h:67
wxValidator * DoGetValidator() const override
bool allowEval() const
SIM_VALUE::TYPE m_valueType
Definition: sim_property.h:108
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.
Definition: sim_property.h:45
bool Validate(wxWindow *aParent) override
Definition: sim_property.h:47
bool TransferToWindow() override
Definition: sim_property.h:48
bool TransferFromWindow() override
Definition: sim_property.h:49
@ TYPE_FLOAT
Definition: sim_value.h:69