KiCad PCB EDA Suite
dialog_spice_model.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) 2016 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
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 DIALOG_SPICE_MODEL_H
26 #define DIALOG_SPICE_MODEL_H
27 
29 
30 #include <sim/spice_value.h>
31 #include <sch_component.h>
32 
33 #include <wx/valnum.h>
34 
36 {
37 public:
38  DIALOG_SPICE_MODEL( wxWindow* aParent, SCH_COMPONENT& aComponent, SCH_FIELDS& aSchFields );
39 
40 private:
46  bool parsePowerSource( const wxString& aModel );
47 
54  bool generatePowerSource( wxString& aTarget ) const;
55 
62  void updateFromFile( wxComboBox* aComboBox, const wxString& aFilePath, const wxString& aKeyword );
63 
69  SCH_FIELD& getField( int aFieldType );
70 
77  bool addPwlValue( const wxString& aTime, const wxString& aValue );
78 
79  virtual bool TransferDataFromWindow() override;
80  virtual bool TransferDataToWindow() override;
81 
82  // The default dialog Validate() calls the validators of all widgets.
83  // This is not what we want; We want only validators of the selected page
84  // of the notbooks. So disable the wxDialog::Validate(), and let our
85  // TransferDataFromWindow doing the job.
86  virtual bool Validate() override
87  {
88  return true;
89  }
90 
91  virtual void onInitDlg( wxInitDialogEvent& event ) override
92  {
93  // Call the default wxDialog handler of a wxInitDialogEvent
95 
96  // Now all widgets have the size fixed, call FinishDialogSettings
98  }
99 
100  // Event handlers
101  void onSemiSelectLib( wxCommandEvent& event ) override;
102  void onSelectIcLib( wxCommandEvent& event ) override;
103  void onPwlAdd( wxCommandEvent& event ) override;
104  void onPwlRemove( wxCommandEvent& event ) override;
105 
108 
111 
113  std::map<int, wxString> m_fieldsTmp;
114 
117 
120  wxTextValidator m_notEmptyValidator;
121 };
122 
123 #endif /* DIALOG_SPICE_MODEL_H */
Class SCH_FIELD instances are attached to a component and provide a place for the component's value...
Definition: sch_field.h:56
SCH_COMPONENT & m_component
Edited component
SPICE_VALIDATOR m_spiceValidator
SCH_FIELD & getField(int aFieldType)
Returns or creates a field in the edited schematic fields vector.
virtual bool TransferDataFromWindow() override
void onSelectIcLib(wxCommandEvent &event) override
bool addPwlValue(const wxString &aTime, const wxString &aValue)
Adds a value to the PWL values list.
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
long m_pwlTimeCol
Column identifiers for PWL power source value list
void onSemiSelectLib(wxCommandEvent &event) override
bool generatePowerSource(wxString &aTarget) const
Generates a string to describe power source parameters, basing on the current selection.
bool parsePowerSource(const wxString &aModel)
Parse a string describing a power source, so appropriate settings are checked in the dialog...
virtual bool Validate() override
std::vector< SCH_FIELD > SCH_FIELDS
A container for several SCH_FIELD items.
Definition: sch_component.h:52
Helper class to recognize Spice formatted values
Definition: spice_value.h:146
DIALOG_SPICE_MODEL(wxWindow *aParent, SCH_COMPONENT &aComponent, SCH_FIELDS &aSchFields)
wxTextValidator m_notEmptyValidator
std::map< int, wxString > m_fieldsTmp
Temporary field values
void onPwlRemove(wxCommandEvent &event) override
SCH_FIELDS & m_fields
Fields from the component properties dialog
void onPwlAdd(wxCommandEvent &event) override
Definition the SCH_COMPONENT class for Eeschema.
Class DIALOG_SPICE_MODEL_BASE.
void updateFromFile(wxComboBox *aComboBox, const wxString &aFilePath, const wxString &aKeyword)
Loads a list of components from a file and adds them to a combo box.
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:68
virtual void onInitDlg(wxInitDialogEvent &event) override
SPICE_VALIDATOR m_spiceEmptyValidator
virtual bool TransferDataToWindow() override