KiCad PCB EDA Suite
dialog_sim_settings.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_SIM_SETTINGS_BASE_H
26 #define DIALOG_SIM_SETTINGS_BASE_H
27 
29 #include <sim/spice_value.h>
30 
31 #include <wx/valnum.h>
32 
34 
36 {
37 public:
38  DIALOG_SIM_SETTINGS( wxWindow* aParent );
39 
40  const wxString& GetSimCommand() const
41  {
42  return m_simCommand;
43  }
44 
45  bool SetSimCommand( const wxString& aCommand )
46  {
47  bool res = parseCommand( aCommand );
48 
49  if( res )
50  m_simCommand = aCommand;
51 
52  return res;
53  }
54 
55  int GetNetlistOptions() const
56  {
57  return m_netlistOpts;
58  }
59 
61  {
62  m_exporter = aExporter;
63  }
64 
65  bool TransferDataFromWindow() override;
66  bool TransferDataToWindow() override;
67 
68  // The default dialog Validate() calls the validators of all widgets.
69  // This is not what we want; We want only validators of the selected page
70  // of the notbooks. So disable the wxDialog::Validate(), and let our
71  // TransferDataFromWindow doing the job.
72  virtual bool Validate() override
73  {
74  return true;
75  }
76 
77  int ShowModal() override;
78 
79 private:
81  {
85  };
86 
87  virtual void onInitDlg( wxInitDialogEvent& event ) override
88  {
89  // Call the default wxDialog handler of a wxInitDialogEvent
91 
92  // Now all widgets have the size fixed, call FinishDialogSettings
94  }
95 
101  bool parseCommand( const wxString& aCommand );
102 
103  void onLoadDirectives( wxCommandEvent& event ) override
104  {
105  loadDirectives();
106  }
107 
108  static wxString scaleToString( int aOption )
109  {
110  switch( aOption )
111  {
112  case DECADE:
113  return wxString( "dec" );
114 
115  case OCTAVE:
116  return wxString( "oct" );
117 
118  case LINEAR:
119  return wxString( "lin" );
120  }
121 
122  wxASSERT_MSG( false, "Unhandled scale type" );
123 
124  return wxEmptyString;
125  }
126 
127  void loadDirectives();
128  void updateNetlistOpts();
129 
130  wxString m_simCommand;
133 
136  wxIntegerValidator<int> m_posIntValidator;
137 };
138 
139 #endif /* DIALOG_SIM_SETTINGS_BASE_H */
bool SetSimCommand(const wxString &aCommand)
SPICE_VALIDATOR m_spiceEmptyValidator
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
static wxString scaleToString(int aOption)
Class DIALOG_SIM_SETTINGS_BASE.
int GetNetlistOptions() const
SPICE_VALIDATOR m_spiceValidator
Helper class to recognize Spice formatted values
Definition: spice_value.h:146
bool parseCommand(const wxString &aCommand)
Parses a Spice directive.
void SetNetlistExporter(NETLIST_EXPORTER_PSPICE_SIM *aExporter)
bool TransferDataFromWindow() override
const wxString & GetSimCommand() const
void onLoadDirectives(wxCommandEvent &event) override
virtual bool Validate() override
NETLIST_EXPORTER_PSPICE_SIM * m_exporter
DIALOG_SIM_SETTINGS(wxWindow *aParent)
bool TransferDataToWindow() override
wxIntegerValidator< int > m_posIntValidator
virtual void onInitDlg(wxInitDialogEvent &event) override
Special netlist exporter flavor that allows to override simulation commands.