sim: further locale hacks, fixed plot/welcome message sizing

This commit is contained in:
Tomasz Wlostowski 2016-08-11 14:42:02 +02:00 committed by Maciej Suminski
parent d0e1f2e412
commit 36297f84c3
6 changed files with 307 additions and 295 deletions

View File

@ -53,27 +53,29 @@ NGSPICE::NGSPICE()
m_ngSpice_AllVecs = (ngSpice_AllVecs) m_dll->GetSymbol( "ngSpice_AllVecs" );
m_ngSpice_Running = (ngSpice_Running) m_dll->GetSymbol( "ngSpice_running" );
setlocale( LC_ALL, "C" );
}
NGSPICE::~NGSPICE()
{
setlocale( LC_ALL, "" );
delete m_dll;
}
void NGSPICE::Init()
{
setlocale( LC_ALL, "C" );
m_ngSpice_Init( &cbSendChar, &cbSendStat, &cbControlledExit, NULL, NULL, &cbBGThreadRunning, this );
setlocale( LC_ALL, "" );
}
vector<COMPLEX> NGSPICE::GetPlot( const string& aName, int aMaxLen )
{
vector<COMPLEX> data;
setlocale( LC_ALL, "C" );
vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() );
setlocale( LC_ALL, "" );
if( vi )
{
@ -99,7 +101,9 @@ vector<COMPLEX> NGSPICE::GetPlot( const string& aName, int aMaxLen )
vector<double> NGSPICE::GetRealPlot( const string& aName, int aMaxLen )
{
vector<double> data;
setlocale( LC_ALL, "C" );
vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() );
setlocale( LC_ALL, "" );
if( vi )
{
@ -130,7 +134,10 @@ vector<double> NGSPICE::GetRealPlot( const string& aName, int aMaxLen )
vector<double> NGSPICE::GetImagPlot( const string& aName, int aMaxLen )
{
vector<double> data;
setlocale( LC_ALL, "C" );
vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() );
setlocale( LC_ALL, "" );
if( vi )
{
@ -153,7 +160,10 @@ vector<double> NGSPICE::GetImagPlot( const string& aName, int aMaxLen )
vector<double> NGSPICE::GetMagPlot( const string& aName, int aMaxLen )
{
vector<double> data;
setlocale( LC_ALL, "C" );
vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() );
setlocale( LC_ALL, "" );
if( vi )
{
@ -179,7 +189,10 @@ vector<double> NGSPICE::GetMagPlot( const string& aName, int aMaxLen )
vector<double> NGSPICE::GetPhasePlot( const string& aName, int aMaxLen )
{
vector<double> data;
setlocale( LC_ALL, "C" );
vector_info* vi = m_ngGet_Vec_Info( (char*) aName.c_str() );
setlocale( LC_ALL, "" );
if( vi )
{
@ -209,52 +222,58 @@ bool NGSPICE::LoadNetlist( const string& aNetlist )
stringstream ss( aNetlist );
int n = 0;
printf("***\n");
while( !ss.eof() && n < 16384 )
{
char line[1024];
ss.getline( line, sizeof(line) );
lines[n++] = strdup(line);
printf("%s\n", line);
}
printf("***\n");
lines[n] = NULL;
setlocale( LC_ALL, "C" );
m_ngSpice_Circ( lines );
setlocale( LC_ALL, "" );
for(int i = 0; i < n; i++)
delete lines[i];
printf("Netlist load complete!\n");
return true;
}
bool NGSPICE::Run()
{
return Command( "bg_run" );
setlocale( LC_ALL, "C" );
bool rv = Command( "bg_run" );
setlocale( LC_ALL, "" );
return rv;
}
bool NGSPICE::Stop()
{
return Command( "bg_halt" );
setlocale( LC_ALL, "C" );
bool rv = Command( "bg_halt" );
setlocale( LC_ALL, "" );
return rv;
}
bool NGSPICE::IsRunning()
{
return m_ngSpice_Running();
setlocale( LC_ALL, "C" );
bool rv = m_ngSpice_Running();
setlocale( LC_ALL, "" );
return rv;
}
bool NGSPICE::Command( const string& aCmd )
{
setlocale( LC_ALL, "C" );
m_ngSpice_Command( (char*) aCmd.c_str() );
setlocale( LC_ALL, "" );
return true;
}

View File

@ -133,16 +133,10 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent )
Connect( m_toolTune->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onTune ), NULL, this );
Connect( m_toolSettings->GetId(), wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( SIM_PLOT_FRAME::onSettings ), NULL, this );
int w, h;
GetSize( &w, &h );
m_toolBar->Realize();
m_plotNotebook->SetPageText(0, _("Welcome!") );
m_splitterConsole->SetSashPosition( w * 0.8 );
m_splitterPlot->SetSashPosition( h * 0.8 );
Layout();
//relayout();
}
@ -178,9 +172,11 @@ void SIM_PLOT_FRAME::StartSimulation()
m_simulator->LoadNetlist( formatter.GetString() );
m_simulator->Run();
m_welcomePanel->Show(false);
m_plotNotebook->Show(true);
m_plotNotebook->Fit();
if ( m_welcomePanel )
{
m_plotNotebook->DeletePage( 0 );
m_welcomePanel = nullptr;
}
Layout();
}
@ -253,9 +249,13 @@ void SIM_PLOT_FRAME::AddTuner( SCH_COMPONENT* aComponent )
TUNER_SLIDER* tuner = new TUNER_SLIDER( this, m_sidePanel, aComponent );
m_tuneSizer->Add( tuner , 0, wxALL, 5 );
tunerList.push_back( tuner );
m_sidePanel->Layout();
m_sideSizer->Fit( m_sidePanel );
m_splitterPlot->Layout();
//m_sidePanel->Layout();
//m_sideSizer->Fit( m_sidePanel );
//m_splitterPlot->Layout();
Layout();
Layout();
Layout();
Layout();
Layout();
}
catch( ... )
@ -275,6 +275,8 @@ void SIM_PLOT_FRAME::RemoveTuner( TUNER_SLIDER* aTuner )
m_plots[plotPanel].m_tuners.remove( aTuner );
aTuner->Destroy();
Layout();
Layout();
Layout();
}
@ -319,17 +321,9 @@ void SIM_PLOT_FRAME::addPlot( const wxString& aName, SIM_PLOT_TYPE aType, const
if( updated )
{
updateSignalList();
plotPanel->Layout();
plotPanel->Fit();
m_plotPanel->Layout();
//m_sideSizer->Fit( m_sidePanel );
m_splitterPlot->Layout();
Layout();
}
}
void SIM_PLOT_FRAME::removePlot( const wxString& aPlotName )
{
SIM_PLOT_PANEL* plotPanel = CurrentPlot();

View File

@ -136,6 +136,7 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE
SIM_PLOT_PANEL* CurrentPlot() const;
private:
void relayout();
/**
* @brief Adds a new plot to the current panel.
* @param aName is the device/net name.

View File

@ -101,43 +101,35 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
this->SetMenuBar( m_mainMenu );
wxBoxSizer* bSizer1;
bSizer1 = new wxBoxSizer( wxVERTICAL );
m_sizer1 = new wxBoxSizer( wxVERTICAL );
m_toolBar = new wxToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_FLAT|wxTB_HORIZONTAL|wxTB_TEXT );
m_toolBar->Realize();
bSizer1->Add( m_toolBar, 0, wxEXPAND, 5 );
m_sizer1->Add( m_toolBar, 0, wxEXPAND, 5 );
m_splitterPlot = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
m_splitterPlot->SetSashGravity( 0.8 );
m_splitterPlot->Connect( wxEVT_IDLE, wxIdleEventHandler( SIM_PLOT_FRAME_BASE::m_splitterPlotOnIdle ), NULL, this );
m_panel2 = new wxPanel( m_splitterPlot, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer11;
bSizer11 = new wxBoxSizer( wxVERTICAL );
m_sizer11 = new wxBoxSizer( wxVERTICAL );
m_splitterConsole = new wxSplitterWindow( m_panel2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D );
m_splitterConsole->SetSashGravity( 0.8 );
m_splitterConsole->Connect( wxEVT_IDLE, wxIdleEventHandler( SIM_PLOT_FRAME_BASE::m_splitterConsoleOnIdle ), NULL, this );
m_plotPanel = new wxPanel( m_splitterConsole, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer5;
bSizer5 = new wxBoxSizer( wxHORIZONTAL );
m_sizer5 = new wxBoxSizer( wxHORIZONTAL );
m_plotNotebook = new wxNotebook( m_plotPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
m_plotNotebook->Hide();
m_plotNotebook->SetMinSize( wxSize( 400,-1 ) );
bSizer5->Add( m_plotNotebook, 3, wxEXPAND | wxALL, 5 );
m_welcomePanel = new wxPanel( m_plotPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer8;
bSizer8 = new wxBoxSizer( wxVERTICAL );
m_welcomePanel = new wxPanel( m_plotNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_sizer8 = new wxBoxSizer( wxVERTICAL );
bSizer8->Add( 0, 0, 1, wxEXPAND, 5 );
m_sizer8->Add( 0, 0, 1, wxEXPAND, 5 );
wxBoxSizer* bSizer81;
bSizer81 = new wxBoxSizer( wxHORIZONTAL );
@ -156,41 +148,42 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
bSizer81->Add( 0, 0, 1, wxEXPAND, 5 );
bSizer8->Add( bSizer81, 0, wxEXPAND, 5 );
m_sizer8->Add( bSizer81, 0, wxEXPAND, 5 );
bSizer8->Add( 0, 0, 1, wxEXPAND, 5 );
m_sizer8->Add( 0, 0, 1, wxEXPAND, 5 );
m_welcomePanel->SetSizer( bSizer8 );
m_welcomePanel->SetSizer( m_sizer8 );
m_welcomePanel->Layout();
bSizer8->Fit( m_welcomePanel );
bSizer5->Add( m_welcomePanel, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_sizer8->Fit( m_welcomePanel );
m_plotNotebook->AddPage( m_welcomePanel, _("a page"), false );
m_sizer5->Add( m_plotNotebook, 3, wxEXPAND | wxALL, 5 );
m_plotPanel->SetSizer( bSizer5 );
m_plotPanel->SetSizer( m_sizer5 );
m_plotPanel->Layout();
bSizer5->Fit( m_plotPanel );
m_sizer5->Fit( m_plotPanel );
m_panel5 = new wxPanel( m_splitterConsole, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer13;
bSizer13 = new wxBoxSizer( wxVERTICAL );
m_sizer13 = new wxBoxSizer( wxVERTICAL );
m_simConsole = new wxTextCtrl( m_panel5, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_DONTWRAP|wxTE_MULTILINE|wxTE_READONLY );
m_simConsole->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) );
bSizer13->Add( m_simConsole, 1, wxALL|wxEXPAND, 5 );
m_sizer13->Add( m_simConsole, 1, wxALL|wxEXPAND, 5 );
m_panel5->SetSizer( bSizer13 );
m_panel5->SetSizer( m_sizer13 );
m_panel5->Layout();
bSizer13->Fit( m_panel5 );
m_sizer13->Fit( m_panel5 );
m_splitterConsole->SplitHorizontally( m_plotPanel, m_panel5, 0 );
bSizer11->Add( m_splitterConsole, 1, wxEXPAND, 5 );
m_sizer11->Add( m_splitterConsole, 1, wxEXPAND, 5 );
m_panel2->SetSizer( bSizer11 );
m_panel2->SetSizer( m_sizer11 );
m_panel2->Layout();
bSizer11->Fit( m_panel2 );
m_sizer11->Fit( m_panel2 );
m_sidePanel = new wxPanel( m_splitterPlot, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_sideSizer = new wxBoxSizer( wxVERTICAL );
@ -227,10 +220,10 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
m_sidePanel->Layout();
m_sideSizer->Fit( m_sidePanel );
m_splitterPlot->SplitVertically( m_panel2, m_sidePanel, 0 );
bSizer1->Add( m_splitterPlot, 1, wxEXPAND, 5 );
m_sizer1->Add( m_splitterPlot, 1, wxEXPAND, 5 );
this->SetSizer( bSizer1 );
this->SetSizer( m_sizer1 );
this->Layout();
this->Centre( wxBOTH );

View File

@ -415,9 +415,9 @@
</object>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer1</property>
<property name="name">m_sizer1</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
@ -668,14 +668,14 @@
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer11</property>
<property name="name">m_sizer11</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="wxSplitterWindow" expanded="0">
<object class="wxSplitterWindow" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -759,8 +759,8 @@
<event name="OnSplitterSashPosChanging"></event>
<event name="OnSplitterUnsplit"></event>
<event name="OnUpdateUI"></event>
<object class="splitteritem" expanded="0">
<object class="wxPanel" expanded="0">
<object class="splitteritem" expanded="1">
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -795,7 +795,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panel4</property>
<property name="name">m_plotPanel</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -834,11 +834,11 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer5</property>
<property name="name">m_sizer5</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
@ -870,7 +870,7 @@
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">1</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
@ -921,13 +921,11 @@
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxPanel" expanded="0">
<object class="notebookpage" expanded="1">
<property name="bitmap"></property>
<property name="label">a page</property>
<property name="select">0</property>
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -1003,9 +1001,9 @@
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizer8</property>
<property name="name">m_sizer8</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
@ -1146,6 +1144,8 @@
</object>
</object>
</object>
</object>
</object>
<object class="splitteritem" expanded="0">
<object class="wxPanel" expanded="0">
<property name="BottomDockable">1</property>
@ -1223,9 +1223,9 @@
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizer13</property>
<property name="name">m_sizer13</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<property name="permission">protected</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>

View File

@ -24,10 +24,10 @@ class KIWAY_PLAYER;
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/toolbar.h>
#include <wx/notebook.h>
#include <wx/stattext.h>
#include <wx/sizer.h>
#include <wx/panel.h>
#include <wx/notebook.h>
#include <wx/textctrl.h>
#include <wx/splitter.h>
#include <wx/listbox.h>
@ -50,15 +50,20 @@ class SIM_PLOT_FRAME_BASE : public KIWAY_PLAYER
wxMenu* m_fileMenu;
wxMenu* m_simulationMenu;
wxMenu* m_viewMenu;
wxBoxSizer* m_sizer1;
wxToolBar* m_toolBar;
wxSplitterWindow* m_splitterPlot;
wxPanel* m_panel2;
wxBoxSizer* m_sizer11;
wxSplitterWindow* m_splitterConsole;
wxPanel* m_plotPanel;
wxBoxSizer* m_sizer5;
wxNotebook* m_plotNotebook;
wxPanel* m_welcomePanel;
wxBoxSizer* m_sizer8;
wxStaticText* m_staticText2;
wxPanel* m_panel5;
wxBoxSizer* m_sizer13;
wxTextCtrl* m_simConsole;
wxPanel* m_sidePanel;
wxBoxSizer* m_sideSizer;