2022-03-09 01:40:59 +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.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* 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,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SIM_PROPERTY_H
|
|
|
|
#define SIM_PROPERTY_H
|
|
|
|
|
2022-06-12 03:39:13 +00:00
|
|
|
#include <wx/notebook.h>
|
|
|
|
#include <wx/propgrid/propgrid.h>
|
|
|
|
#include <wx/propgrid/manager.h>
|
2022-03-09 01:40:59 +00:00
|
|
|
#include <wx/propgrid/props.h>
|
|
|
|
|
2022-11-16 09:09:54 +00:00
|
|
|
#include <sim/sim_model.h>
|
2022-12-05 02:07:45 +00:00
|
|
|
#include "libeval/numeric_evaluator.h"
|
2022-11-16 09:09:54 +00:00
|
|
|
|
2022-03-09 01:40:59 +00:00
|
|
|
|
2023-03-03 22:36:07 +00:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* wxPropertyGrid property specializations for simulator.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2022-03-09 01:40:59 +00:00
|
|
|
class SIM_VALIDATOR : public wxValidator
|
|
|
|
{
|
2022-06-21 02:22:52 +00:00
|
|
|
private:
|
2022-12-05 02:07:45 +00:00
|
|
|
bool Validate( wxWindow* aParent ) override { return true; }
|
|
|
|
bool TransferToWindow() override { return true; }
|
|
|
|
bool TransferFromWindow() override { return true; }
|
2022-06-21 02:22:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-09-11 13:22:45 +00:00
|
|
|
class SIM_PROPERTY
|
|
|
|
{
|
|
|
|
public:
|
2022-11-12 02:09:26 +00:00
|
|
|
SIM_PROPERTY( SIM_MODEL& aModel, int aParamIndex );
|
2022-09-11 13:22:45 +00:00
|
|
|
|
2022-11-12 02:09:26 +00:00
|
|
|
void Disable();
|
|
|
|
|
|
|
|
const SIM_MODEL::PARAM& GetParam() const { return m_model.GetParam( m_paramIndex ); }
|
2022-09-11 13:22:45 +00:00
|
|
|
|
|
|
|
protected:
|
2022-11-12 02:09:26 +00:00
|
|
|
SIM_MODEL& m_model;
|
2022-09-11 13:22:45 +00:00
|
|
|
int m_paramIndex;
|
2022-12-05 02:07:45 +00:00
|
|
|
|
|
|
|
bool m_needsEval;
|
|
|
|
mutable NUMERIC_EVALUATOR m_eval;
|
|
|
|
|
|
|
|
bool m_disabled; ///< If true, never access the models.
|
2022-09-11 13:22:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class SIM_BOOL_PROPERTY : public wxBoolProperty, public SIM_PROPERTY
|
2022-06-21 02:22:52 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
SIM_BOOL_PROPERTY( const wxString& aLabel, const wxString& aName,
|
2022-11-12 02:09:26 +00:00
|
|
|
SIM_MODEL& aModel,
|
2022-06-21 02:22:52 +00:00
|
|
|
int aParamIndex );
|
|
|
|
|
|
|
|
wxValidator* DoGetValidator() const override;
|
2022-09-22 05:38:45 +00:00
|
|
|
|
2022-06-21 02:22:52 +00:00
|
|
|
void OnSetValue() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-09-11 13:22:45 +00:00
|
|
|
class SIM_STRING_PROPERTY : public wxStringProperty, public SIM_PROPERTY
|
2022-03-09 01:40:59 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-04-01 04:30:50 +00:00
|
|
|
// We pass shared_ptrs because we need to make sure they are destroyed only after the last time
|
|
|
|
// SIM_PROPERTY uses them.
|
2022-06-21 02:22:52 +00:00
|
|
|
SIM_STRING_PROPERTY( const wxString& aLabel, const wxString& aName,
|
2022-11-12 02:09:26 +00:00
|
|
|
SIM_MODEL& aModel,
|
2022-11-07 18:33:31 +00:00
|
|
|
int aParamIndex,
|
|
|
|
SIM_VALUE::TYPE aValueType = SIM_VALUE::TYPE_FLOAT,
|
|
|
|
SIM_VALUE_GRAMMAR::NOTATION aNotation = SIM_VALUE_GRAMMAR::NOTATION::SI );
|
2022-03-09 01:40:59 +00:00
|
|
|
|
|
|
|
wxValidator* DoGetValidator() const override;
|
|
|
|
|
|
|
|
bool StringToValue( wxVariant& aVariant, const wxString& aText, int aArgFlags = 0 )
|
|
|
|
const override;
|
2022-11-07 18:33:31 +00:00
|
|
|
|
2022-12-05 02:07:45 +00:00
|
|
|
bool OnEvent( wxPropertyGrid* propgrid, wxWindow* wnd_primary, wxEvent& event ) override;
|
|
|
|
|
2022-12-27 12:30:28 +00:00
|
|
|
protected:
|
|
|
|
bool allowEval() const;
|
|
|
|
|
2022-11-07 18:33:31 +00:00
|
|
|
protected:
|
2023-02-24 12:43:41 +00:00
|
|
|
SIM_VALUE::TYPE m_valueType;
|
2022-03-09 01:40:59 +00:00
|
|
|
};
|
|
|
|
|
2022-08-30 07:00:52 +00:00
|
|
|
|
2022-09-11 13:22:45 +00:00
|
|
|
class SIM_ENUM_PROPERTY : public wxEnumProperty, public SIM_PROPERTY
|
2022-08-30 07:00:52 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-12-05 02:07:45 +00:00
|
|
|
SIM_ENUM_PROPERTY( const wxString& aLabel, const wxString& aName, SIM_MODEL& aModel,
|
2024-01-25 15:29:29 +00:00
|
|
|
int aParamIndex, const wxArrayString& aValues );
|
2022-08-30 07:00:52 +00:00
|
|
|
|
2024-03-21 01:51:35 +00:00
|
|
|
#if wxCHECK_VERSION( 3, 3, 0 )
|
|
|
|
bool IntToValue( wxVariant& aVariant, int aNumber,
|
|
|
|
wxPGPropValFormatFlags aArgFlags = wxPGPropValFormatFlags::Null ) const override;
|
|
|
|
#else
|
2022-08-30 07:00:52 +00:00
|
|
|
bool IntToValue( wxVariant& aVariant, int aNumber, int aArgFlags = 0 ) const override;
|
2024-03-21 01:51:35 +00:00
|
|
|
#endif
|
2022-08-30 07:00:52 +00:00
|
|
|
};
|
|
|
|
|
2022-03-09 01:40:59 +00:00
|
|
|
#endif // SIM_PROPERTY_H
|