Fixes: lp:1624659 (fix some issues in countries which are not using a point as decimal separator)
https://bugs.launchpad.net/kicad/+bug/1624659 Small enhancement in dialog_spice_model_base.cpp: add comments about spice values notation.
This commit is contained in:
parent
e5064231f9
commit
0719f8d214
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Jul 31 2016)
|
||||
// C++ code generated with wxFormBuilder (version Sep 8 2016)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -18,6 +18,9 @@ DIALOG_SPICE_MODEL_BASE::DIALOG_SPICE_MODEL_BASE( wxWindow* parent, wxWindowID i
|
|||
|
||||
m_notebook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_passive = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxBoxSizer* bSizer41;
|
||||
bSizer41 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
wxFlexGridSizer* fgSizer1;
|
||||
fgSizer1 = new wxFlexGridSizer( 0, 2, 0, 0 );
|
||||
fgSizer1->AddGrowableCol( 1 );
|
||||
|
@ -28,10 +31,11 @@ DIALOG_SPICE_MODEL_BASE::DIALOG_SPICE_MODEL_BASE( wxWindow* parent, wxWindowID i
|
|||
m_staticText2->Wrap( -1 );
|
||||
fgSizer1->Add( m_staticText2, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
|
||||
|
||||
m_pasType = new wxComboBox( m_passive, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
|
||||
m_pasType = new wxComboBox( m_passive, wxID_ANY, _("Resistor"), wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_READONLY );
|
||||
m_pasType->Append( _("Resistor") );
|
||||
m_pasType->Append( _("Capacitor") );
|
||||
m_pasType->Append( _("Inductor") );
|
||||
m_pasType->SetSelection( 0 );
|
||||
fgSizer1->Add( m_pasType, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
m_staticText3 = new wxStaticText( m_passive, wxID_ANY, _("Value"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
|
@ -44,10 +48,34 @@ DIALOG_SPICE_MODEL_BASE::DIALOG_SPICE_MODEL_BASE( wxWindow* parent, wxWindowID i
|
|||
fgSizer1->Add( m_pasValue, 0, wxALL|wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_passive->SetSizer( fgSizer1 );
|
||||
bSizer41->Add( fgSizer1, 0, wxEXPAND|wxALL, 5 );
|
||||
|
||||
m_staticline1 = new wxStaticLine( m_passive, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
|
||||
bSizer41->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
|
||||
|
||||
wxBoxSizer* bSizer5;
|
||||
bSizer5 = new wxBoxSizer( wxVERTICAL );
|
||||
|
||||
m_staticText32 = new wxStaticText( m_passive, wxID_ANY, _("In Spice values,the decimal separator is the point.\nValues can use Spice unit symbols."), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText32->Wrap( -1 );
|
||||
bSizer5->Add( m_staticText32, 0, wxALL, 5 );
|
||||
|
||||
m_staticText321 = new wxStaticText( m_passive, wxID_ANY, _("Spice unit symbols in values (case insensitive):"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticText321->Wrap( -1 );
|
||||
bSizer5->Add( m_staticText321, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
|
||||
|
||||
m_staticTextUnitsSymbolsInfo = new wxStaticText( m_passive, wxID_ANY, _("f = FEMTO\np = PICO\nn = NANO\nu = MICRO\nm = MILI\nk = KILO\nmeg = MEGA\ng = GIGA\nt = TERA"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||
m_staticTextUnitsSymbolsInfo->Wrap( -1 );
|
||||
bSizer5->Add( m_staticTextUnitsSymbolsInfo, 0, wxALL, 5 );
|
||||
|
||||
|
||||
bSizer41->Add( bSizer5, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
|
||||
|
||||
|
||||
m_passive->SetSizer( bSizer41 );
|
||||
m_passive->Layout();
|
||||
fgSizer1->Fit( m_passive );
|
||||
m_notebook->AddPage( m_passive, _("Passive"), false );
|
||||
bSizer41->Fit( m_passive );
|
||||
m_notebook->AddPage( m_passive, _("Passive"), true );
|
||||
m_semiconductor = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
|
||||
wxFlexGridSizer* fgSizer3;
|
||||
fgSizer3 = new wxFlexGridSizer( 0, 3, 0, 0 );
|
||||
|
@ -441,7 +469,7 @@ DIALOG_SPICE_MODEL_BASE::DIALOG_SPICE_MODEL_BASE( wxWindow* parent, wxWindowID i
|
|||
m_power->SetSizer( bSizer4 );
|
||||
m_power->Layout();
|
||||
bSizer4->Fit( m_power );
|
||||
m_notebook->AddPage( m_power, _("Source"), true );
|
||||
m_notebook->AddPage( m_power, _("Source"), false );
|
||||
|
||||
bSizer1->Add( m_notebook, 1, wxEXPAND | wxALL, 5 );
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
///////////////////////////////////////////////////////////////////////////
|
||||
// C++ code generated with wxFormBuilder (version Jul 31 2016)
|
||||
// C++ code generated with wxFormBuilder (version Sep 8 2016)
|
||||
// http://www.wxformbuilder.org/
|
||||
//
|
||||
// PLEASE DO "NOT" EDIT THIS FILE!
|
||||
|
@ -23,6 +23,7 @@ class DIALOG_SHIM;
|
|||
#include <wx/combobox.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statline.h>
|
||||
#include <wx/panel.h>
|
||||
#include <wx/bitmap.h>
|
||||
#include <wx/image.h>
|
||||
|
@ -44,7 +45,7 @@ class DIALOG_SHIM;
|
|||
class DIALOG_SPICE_MODEL_BASE : public DIALOG_SHIM
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
protected:
|
||||
wxNotebook* m_notebook;
|
||||
wxPanel* m_passive;
|
||||
|
@ -52,6 +53,10 @@ class DIALOG_SPICE_MODEL_BASE : public DIALOG_SHIM
|
|||
wxComboBox* m_pasType;
|
||||
wxStaticText* m_staticText3;
|
||||
wxTextCtrl* m_pasValue;
|
||||
wxStaticLine* m_staticline1;
|
||||
wxStaticText* m_staticText32;
|
||||
wxStaticText* m_staticText321;
|
||||
wxStaticText* m_staticTextUnitsSymbolsInfo;
|
||||
wxPanel* m_semiconductor;
|
||||
wxStaticText* m_staticText4;
|
||||
wxComboBox* m_semiType;
|
||||
|
@ -133,20 +138,20 @@ class DIALOG_SPICE_MODEL_BASE : public DIALOG_SHIM
|
|||
wxStdDialogButtonSizer* m_sdbSizer;
|
||||
wxButton* m_sdbSizerOK;
|
||||
wxButton* m_sdbSizerCancel;
|
||||
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void onInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
|
||||
virtual void onSemiSelectLib( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onSelectIcLib( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onPwlAdd( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void onPwlRemove( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
DIALOG_SPICE_MODEL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 640,582 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
|
||||
DIALOG_SPICE_MODEL_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 640,582 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
|
||||
~DIALOG_SPICE_MODEL_BASE();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif //__DIALOG_SPICE_MODEL_BASE_H__
|
||||
|
|
|
@ -28,7 +28,9 @@
|
|||
#include <cmath>
|
||||
|
||||
#include <wx/textentry.h>
|
||||
#include <wx/numformatter.h>
|
||||
#include <confirm.h>
|
||||
#include <common.h>
|
||||
|
||||
SPICE_VALUE::SPICE_VALUE( const wxString& aString )
|
||||
{
|
||||
|
@ -37,6 +39,8 @@ SPICE_VALUE::SPICE_VALUE( const wxString& aString )
|
|||
if( aString.IsEmpty() )
|
||||
throw std::invalid_argument( "Spice value cannot be empty" );
|
||||
|
||||
LOCALE_IO dummy; // All numeric values should be in "C" locale(decimal separator = .)
|
||||
|
||||
if( sscanf( (const char*) aString.c_str(), "%lf%7s", &m_base, buf ) == 0 )
|
||||
throw std::invalid_argument( "Invalid Spice value string" );
|
||||
|
||||
|
@ -244,22 +248,32 @@ bool SPICE_VALIDATOR::Validate( wxWindow* aParent )
|
|||
if( m_emptyAllowed )
|
||||
return true;
|
||||
|
||||
DisplayError( aParent, wxString::Format( wxT( "Fill required fields" ) ) );
|
||||
DisplayError( aParent, wxString::Format( _( "Please, fill required fields" ) ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
wxString svalue = text->GetValue();
|
||||
|
||||
// In countries where the decimal separator is not a point, if the user
|
||||
// has not used a point, replace the decimal separator by the point, as needed
|
||||
// by spice simulator which uses the "C" decimal separator
|
||||
svalue.Replace(",", "." );
|
||||
|
||||
try
|
||||
{
|
||||
// If SPICE_VALUE can be constructed, then it is a valid Spice value
|
||||
SPICE_VALUE val( text->GetValue() );
|
||||
SPICE_VALUE val( svalue );
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
DisplayError( aParent,
|
||||
wxString::Format( wxT( "'%s' is not a valid Spice value" ), text->GetValue() ) );
|
||||
wxString::Format( _( "'%s' is not a valid Spice value" ), text->GetValue() ) );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if( svalue != text->GetValue() )
|
||||
text->SetValue( svalue );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue