2016-08-11 12:41:29 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 CERN
|
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2016-08-11 12:41:43 +00:00
|
|
|
* as published by the Free Software Foundation; either version 3
|
2016-08-11 12:41:29 +00:00
|
|
|
* 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:
|
2016-08-11 12:41:43 +00:00
|
|
|
* https://www.gnu.org/licenses/gpl-3.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 3 license,
|
2016-08-11 12:41:29 +00:00
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DIALOG_SIM_SETTINGS_BASE_H
|
|
|
|
#define DIALOG_SIM_SETTINGS_BASE_H
|
|
|
|
|
|
|
|
#include "dialog_sim_settings_base.h"
|
2016-08-11 12:41:54 +00:00
|
|
|
#include <sim/spice_value.h>
|
|
|
|
|
2016-08-11 12:41:29 +00:00
|
|
|
#include <wx/valnum.h>
|
|
|
|
|
|
|
|
class NETLIST_EXPORTER_PSPICE_SIM;
|
|
|
|
|
|
|
|
class DIALOG_SIM_SETTINGS : public DIALOG_SIM_SETTINGS_BASE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DIALOG_SIM_SETTINGS( wxWindow* aParent );
|
|
|
|
|
|
|
|
const wxString& GetSimCommand() const
|
|
|
|
{
|
|
|
|
return m_simCommand;
|
|
|
|
}
|
|
|
|
|
2016-08-11 12:42:08 +00:00
|
|
|
bool SetSimCommand( const wxString& aCommand )
|
|
|
|
{
|
|
|
|
bool res = parseCommand( aCommand );
|
|
|
|
|
|
|
|
if( res )
|
|
|
|
m_simCommand = aCommand;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2016-08-11 12:41:36 +00:00
|
|
|
int GetNetlistOptions() const
|
|
|
|
{
|
|
|
|
return m_netlistOpts;
|
|
|
|
}
|
|
|
|
|
2016-08-11 12:41:29 +00:00
|
|
|
void SetNetlistExporter( NETLIST_EXPORTER_PSPICE_SIM* aExporter )
|
|
|
|
{
|
|
|
|
m_exporter = aExporter;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TransferDataFromWindow() override;
|
|
|
|
bool TransferDataToWindow() override;
|
|
|
|
|
2016-09-17 12:38:34 +00:00
|
|
|
// The default dialog Validate() calls the validators of all widgets.
|
|
|
|
// This is not what we want; We want only validators of the selected page
|
|
|
|
// of the notbooks. So disable the wxDialog::Validate(), and let our
|
|
|
|
// TransferDataFromWindow doing the job.
|
|
|
|
virtual bool Validate() override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-08-11 12:41:30 +00:00
|
|
|
int ShowModal() override;
|
|
|
|
|
2016-08-11 12:41:29 +00:00
|
|
|
private:
|
|
|
|
enum SCALE_TYPE
|
|
|
|
{
|
|
|
|
DECADE,
|
|
|
|
OCTAVE,
|
|
|
|
LINEAR
|
|
|
|
};
|
|
|
|
|
2016-08-20 15:25:51 +00:00
|
|
|
virtual void onInitDlg( wxInitDialogEvent& event ) override
|
|
|
|
{
|
|
|
|
// Call the default wxDialog handler of a wxInitDialogEvent
|
|
|
|
TransferDataToWindow();
|
|
|
|
|
|
|
|
// Now all widgets have the size fixed, call FinishDialogSettings
|
2020-11-16 11:16:44 +00:00
|
|
|
finishDialogSettings();
|
2016-08-20 15:25:51 +00:00
|
|
|
}
|
|
|
|
|
2016-08-11 12:42:08 +00:00
|
|
|
/**
|
|
|
|
* @brief Parses a Spice directive.
|
|
|
|
* @param aCommand is the directive to be parsed (e.g. ".tran 10n 1000n").
|
|
|
|
* @return bool if the directive was parsed correctly.
|
|
|
|
*/
|
|
|
|
bool parseCommand( const wxString& aCommand );
|
|
|
|
|
2016-08-11 12:41:36 +00:00
|
|
|
void onLoadDirectives( wxCommandEvent& event ) override
|
|
|
|
{
|
|
|
|
loadDirectives();
|
|
|
|
}
|
2016-08-11 12:41:29 +00:00
|
|
|
|
|
|
|
static wxString scaleToString( int aOption )
|
|
|
|
{
|
|
|
|
switch( aOption )
|
|
|
|
{
|
|
|
|
case DECADE:
|
|
|
|
return wxString( "dec" );
|
|
|
|
|
|
|
|
case OCTAVE:
|
|
|
|
return wxString( "oct" );
|
|
|
|
|
|
|
|
case LINEAR:
|
|
|
|
return wxString( "lin" );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxASSERT_MSG( false, "Unhandled scale type" );
|
|
|
|
|
|
|
|
return wxEmptyString;
|
|
|
|
}
|
|
|
|
|
2016-08-11 12:41:36 +00:00
|
|
|
void loadDirectives();
|
2016-08-11 12:41:36 +00:00
|
|
|
void updateNetlistOpts();
|
|
|
|
|
2016-08-11 12:41:29 +00:00
|
|
|
wxString m_simCommand;
|
2016-08-11 12:41:36 +00:00
|
|
|
int m_netlistOpts;
|
2016-08-11 12:41:29 +00:00
|
|
|
NETLIST_EXPORTER_PSPICE_SIM* m_exporter;
|
|
|
|
|
2016-08-11 12:41:54 +00:00
|
|
|
SPICE_VALIDATOR m_spiceValidator;
|
|
|
|
SPICE_VALIDATOR m_spiceEmptyValidator;
|
2016-08-11 12:41:29 +00:00
|
|
|
wxIntegerValidator<int> m_posIntValidator;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DIALOG_SIM_SETTINGS_BASE_H */
|