KiCad PCB EDA Suite
sim_plot_frame.cpp
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  * Copyright (C) 2016-2018 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; either version 3
12  * of the License, or (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, you may find one here:
21  * https://www.gnu.org/licenses/gpl-3.0.html
22  * or you may search the http://www.gnu.org website for the version 3 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #include <wx/stc/stc.h>
28 
29 #include <sch_edit_frame.h>
30 #include <eeschema_id.h>
31 #include <kiway.h>
32 #include <confirm.h>
33 #include <bitmaps.h>
35 #include <widgets/tuner_slider.h>
38 #include <pgm_base.h>
39 #include "sim_plot_frame.h"
40 #include "sim_plot_panel.h"
41 #include "spice_simulator.h"
42 #include "spice_reporter.h"
43 #include <menus_helpers.h>
45 #include <tool/tool_manager.h>
46 #include <tools/ee_actions.h>
47 #include <eeschema_settings.h>
48 
50 {
51  int res = (int) aFirst | (int) aSecond;
52 
53  return (SIM_PLOT_TYPE) res;
54 }
55 
56 
58 {
59 public:
61  : m_parent( aParent )
62  {
63  }
64 
65  REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override
66  {
67  wxCommandEvent* event = new wxCommandEvent( EVT_SIM_REPORT );
68  event->SetString( aText );
69  wxQueueEvent( m_parent, event );
70  return *this;
71  }
72 
73  bool HasMessage() const override
74  {
75  return false; // Technically "indeterminate" rather than false.
76  }
77 
78  void OnSimStateChange( SPICE_SIMULATOR* aObject, SIM_STATE aNewState ) override
79  {
80  wxCommandEvent* event = NULL;
81 
82  switch( aNewState )
83  {
84  case SIM_IDLE:
85  event = new wxCommandEvent( EVT_SIM_FINISHED );
86  break;
87 
88  case SIM_RUNNING:
89  event = new wxCommandEvent( EVT_SIM_STARTED );
90  break;
91 
92  default:
93  wxFAIL;
94  return;
95  }
96 
97  wxQueueEvent( m_parent, event );
98  }
99 
100 private:
102 };
103 
104 
105 TRACE_DESC::TRACE_DESC( const NETLIST_EXPORTER_PSPICE_SIM& aExporter, const wxString& aName,
106  SIM_PLOT_TYPE aType, const wxString& aParam )
107  : m_name( aName ), m_type( aType ), m_param( aParam )
108 {
109  // Title generation
110  m_title = wxString::Format( "%s(%s)", aParam, aName );
111 
112  if( aType & SPT_AC_MAG )
113  m_title += " (mag)";
114  else if( aType & SPT_AC_PHASE )
115  m_title += " (phase)";
116 }
117 
118 // Store the path of saved workbooks during the session
120 
121 SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent )
122  : SIM_PLOT_FRAME_BASE( aParent ),
123  m_lastSimPlot( nullptr ),
124  m_welcomePanel( nullptr ),
125  m_plotNumber( 0 )
126 {
127  SetKiway( this, aKiway );
129 
131 
132  if( m_schematicFrame == NULL )
133  throw std::runtime_error( "There is no schematic window" );
134 
135  // Give an icon
136  wxIcon icon;
137  icon.CopyFromBitmap( KiBitmap( simulator_xpm ) );
138  SetIcon( icon );
139 
140  // Get the previous size and position of windows:
141  LoadSettings( config() );
142 
143  // Prepare the color list to plot traces
145 
146  // Give icons to menuitems
148 
150 
151  if( !m_simulator )
152  {
153  throw std::runtime_error( "Could not create simulator instance" );
154  return;
155  }
156 
157  m_simulator->Init();
158 
159  if( m_savedWorkbooksPath.IsEmpty() )
160  {
162  }
163 
164  m_reporter = new SIM_THREAD_REPORTER( this );
165  m_simulator->SetReporter( m_reporter );
166 
168 
169  Connect( EVT_SIM_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onSimUpdate ), NULL, this );
170  Connect( EVT_SIM_REPORT, wxCommandEventHandler( SIM_PLOT_FRAME::onSimReport ), NULL, this );
171  Connect( EVT_SIM_STARTED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimStarted ), NULL, this );
172  Connect( EVT_SIM_FINISHED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimFinished ), NULL, this );
173  Connect( EVT_SIM_CURSOR_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onCursorUpdate ), NULL, this );
174 
175  // Toolbar buttons
176  m_toolSimulate = m_toolBar->AddTool( ID_SIM_RUN, _( "Run/Stop Simulation" ),
177  KiBitmap( sim_run_xpm ), _( "Run Simulation" ), wxITEM_NORMAL );
178  m_toolAddSignals = m_toolBar->AddTool( ID_SIM_ADD_SIGNALS, _( "Add Signals" ),
179  KiBitmap( sim_add_signal_xpm ), _( "Add signals to plot" ), wxITEM_NORMAL );
180  m_toolProbe = m_toolBar->AddTool( ID_SIM_PROBE, _( "Probe" ),
181  KiBitmap( sim_probe_xpm ), _( "Probe signals on the schematic" ), wxITEM_NORMAL );
182  m_toolTune = m_toolBar->AddTool( ID_SIM_TUNE, _( "Tune" ),
183  KiBitmap( sim_tune_xpm ), _( "Tune component values" ), wxITEM_NORMAL );
184  m_toolSettings = m_toolBar->AddTool( wxID_ANY, _( "Settings" ),
185  KiBitmap( sim_settings_xpm ), _( "Simulation settings" ), wxITEM_NORMAL );
186 
187  Connect( m_toolSimulate->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
188  wxCommandEventHandler( SIM_PLOT_FRAME::onSimulate ), NULL, this );
189  Connect( m_toolAddSignals->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
190  wxCommandEventHandler( SIM_PLOT_FRAME::onAddSignal ), NULL, this );
191  Connect( m_toolProbe->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
192  wxCommandEventHandler( SIM_PLOT_FRAME::onProbe ), NULL, this );
193  Connect( m_toolTune->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
194  wxCommandEventHandler( SIM_PLOT_FRAME::onTune ), NULL, this );
195  Connect( m_toolSettings->GetId(), wxEVT_COMMAND_TOOL_CLICKED,
196  wxCommandEventHandler( SIM_PLOT_FRAME::onSettings ), NULL, this );
197 
198  // Bind toolbar buttons event to existing menu event handlers, so they behave the same
199  Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onSimulate, this, m_runSimulation->GetId() );
200  Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onAddSignal, this, m_addSignals->GetId() );
201  Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onProbe, this, m_probeSignals->GetId() );
202  Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onTune, this, m_tuneValue->GetId() );
203  Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onShowNetlist, this, m_showNetlist->GetId() );
204  Bind( wxEVT_COMMAND_MENU_SELECTED, &SIM_PLOT_FRAME::onSettings, this, m_settings->GetId() );
205 
206  m_toolBar->Realize();
207 
209  m_plotNotebook->AddPage( m_welcomePanel, _( "Welcome!" ), 1, true );
210 
211  // the settings dialog will be created later, on demand.
212  // if created in the ctor, for some obscure reason, there is an issue
213  // on Windows: when open it, the simulator frame is sent to the background.
214  // instead of being behind the dialog frame (as it does)
216 
217  // resize the subwindows size. At least on Windows, calling wxSafeYield before
218  // resizing the subwindows forces the wxSplitWindows size events automatically generated
219  // by wxWidgets to be executed before our resize code.
220  // Otherwise, the changes made by setSubWindowsSashSize are overwritten by one these
221  // events
222  wxSafeYield();
224 
225  // Ensure the window is on top
226  Raise();
227 }
228 
229 
231 {
232  m_simulator->SetReporter( nullptr );
233  delete m_reporter;
234  delete m_signalsIconColorList;
235 
236  if( m_settingsDlg )
237  m_settingsDlg->Destroy();
238 }
239 
240 
242 {
243  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
244  wxASSERT( cfg );
245 
246  if( cfg )
247  {
249 
250  cfg->m_Simulator.plot_panel_width = m_splitterLeftRight->GetSashPosition();
251  cfg->m_Simulator.plot_panel_height = m_splitterPlotAndConsole->GetSashPosition();
252  cfg->m_Simulator.signal_panel_height = m_splitterSignals->GetSashPosition();
253  cfg->m_Simulator.cursors_panel_height = m_splitterTuneValues->GetSashPosition();
254  cfg->m_Simulator.white_background = m_plotUseWhiteBg;
255  }
256 }
257 
258 
260 {
261  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
262  wxASSERT( cfg );
263 
264  if( cfg )
265  {
267 
268  // Read subwindows sizes (should be > 0 )
269  m_splitterLeftRightSashPosition = cfg->m_Simulator.plot_panel_width;
270  m_splitterPlotAndConsoleSashPosition = cfg->m_Simulator.plot_panel_height;
271  m_splitterSignalsSashPosition = cfg->m_Simulator.signal_panel_height;
272  m_splitterTuneValuesSashPosition = cfg->m_Simulator.cursors_panel_height;
273  m_plotUseWhiteBg = cfg->m_Simulator.white_background;
274  }
275 }
276 
277 
279 {
280  auto cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
281  wxASSERT( cfg );
282 
283  return cfg ? &cfg->m_Simulator.window : nullptr;
284 }
285 
286 
287 // A small helper struct to handle bitmaps initialisation in menus
289 {
290  int m_MenuId;
292 };
293 
294 
296 {
297  // Give icons to menuitems of the main menubar
298  BM_MENU_INIT_ITEM bm_list[]
299  {
300  // File menu:
301  { wxID_NEW, simulator_xpm },
302  { wxID_OPEN,directory_browser_xpm },
303  { wxID_SAVE, directory_xpm},
306  { wxID_CLOSE, exit_xpm},
307 
308  // simulator menu:
315 
316  // View menu
317  { wxID_ZOOM_IN, zoom_in_xpm},
318  { wxID_ZOOM_OUT, zoom_out_xpm},
319  { wxID_ZOOM_FIT, zoom_fit_in_page_xpm},
324 
325  { 0, nullptr } // Sentinel
326  };
327 
328  // wxMenuItems are already created and attached to the m_mainMenu wxMenuBar.
329  // A problem is the fact setting bitmaps in wxMenuItems after they are attached
330  // to a wxMenu do not work in all cases.
331  // So the trick is:
332  // Remove the wxMenuItem from its wxMenu
333  // Set the bitmap
334  // Insert the modified wxMenuItem to its previous place
335  for( int ii = 0; bm_list[ii].m_MenuId; ++ii )
336  {
337  wxMenuItem* item = m_mainMenu->FindItem( bm_list[ii].m_MenuId );
338 
339  if( !item || !bm_list[ii].m_Bitmap)
340  continue;
341 
342  wxMenu* menu = item->GetMenu();
343  // Calculate the initial index of item inside the wxMenu parent
344  wxMenuItemList& mlist = menu->GetMenuItems();
345  int mpos = mlist.IndexOf( item );
346 
347  if( mpos >= 0 ) // Should be always the case
348  {
349  // Modify the bitmap
350  menu->Remove( item );
351  AddBitmapToMenuItem( item, KiBitmap( bm_list[ii].m_Bitmap ) );
352  // Insert item to its the initial index
353  menu->Insert( mpos, item );
354  }
355  }
356 }
357 
358 
360 {
363 
366 
369 
372 }
373 
374 
375 wxColor SIM_PLOT_FRAME::GetPlotColor( int aColorId )
376 {
377  // return the wxColor selected in color list or BLACK is not in list
378  if( aColorId >= 0 && aColorId < (int)m_colorList.size() )
379  return m_colorList[aColorId];
380 
381  return wxColor( 0, 0, 0 );
382 }
383 
384 
386 {
387  m_colorList.clear();
388 
389  if( aWhiteBg )
390  {
391  m_colorList.emplace_back( 255, 255, 255 ); // Bg color
392  m_colorList.emplace_back( 0, 0, 0 ); // Fg color (texts)
393  m_colorList.emplace_back( 130, 130, 130 ); // Axis color
394  m_colorList.emplace_back( 0, 0, 0 ); // cursors color
395  }
396  else
397  {
398  m_colorList.emplace_back( 0, 0, 0 ); // Bg color
399  m_colorList.emplace_back( 255, 255, 255 ); // Fg color (texts)
400  m_colorList.emplace_back( 130, 130, 130 ); // Axis color
401  m_colorList.emplace_back( 255, 255, 255 ); // cursors color
402  }
403 
404  // Add a list of color for traces, starting at index SIM_TRACE_COLOR
405  m_colorList.emplace_back( 0xE4, 0x1A, 0x1C );
406  m_colorList.emplace_back( 0x37, 0x7E, 0xB8 );
407  m_colorList.emplace_back( 0x4D, 0xAF, 0x4A );
408  m_colorList.emplace_back( 0x98, 0x4E, 0xA3 );
409  m_colorList.emplace_back( 0xFF, 0x7F, 0x00 );
410  m_colorList.emplace_back( 0xFF, 0xFF, 0x33 );
411  m_colorList.emplace_back( 0xA6, 0x56, 0x28 );
412  m_colorList.emplace_back( 0xF7, 0x81, 0xBF );
413  m_colorList.emplace_back( 0x66, 0xC2, 0xA5 );
414  m_colorList.emplace_back( 0xFC, 0x8D, 0x62 );
415  m_colorList.emplace_back( 0x8D, 0xA0, 0xCB );
416  m_colorList.emplace_back( 0xE7, 0x8A, 0xC3 );
417  m_colorList.emplace_back( 0xA6, 0xD8, 0x54 );
418  m_colorList.emplace_back( 0xFF, 0xD9, 0x2F );
419  m_colorList.emplace_back( 0xE5, 0xC4, 0x94 );
420  m_colorList.emplace_back( 0xB3, 0xB3, 0xB3 );
421 
422 }
423 
424 
425 void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
426 {
427  STRING_FORMATTER formatter;
428 
429  if( !m_settingsDlg )
430  m_settingsDlg = new DIALOG_SIM_SETTINGS( this );
431 
432  m_simConsole->Clear();
434 
435  if( aSimCommand.IsEmpty() )
436  {
437  SIM_PANEL_BASE* plotPanel = currentPlotWindow();
438  if( plotPanel )
439  m_exporter->SetSimCommand( m_plots[plotPanel].m_simCommand );
440  }
441  else
442  {
443  m_exporter->SetSimCommand( aSimCommand );
444  }
445 
446  if( !m_exporter->Format( &formatter, m_settingsDlg->GetNetlistOptions() ) )
447  {
448  DisplayError( this, _( "There were errors during netlist export, aborted." ) );
449  return;
450  }
451 
452  if( m_exporter->GetSimType() == ST_UNKNOWN )
453  {
454  DisplayInfoMessage( this, _( "You need to select the simulation settings first." ) );
455  return;
456  }
457 
458  m_simulator->LoadNetlist( formatter.GetString() );
459  updateTuners();
460  applyTuners();
461  m_simulator->Run();
462 }
463 
464 
466 {
467  m_simulator->Stop();
468 }
469 
470 
472 {
473  return m_simulator ? m_simulator->IsRunning() : false;
474 }
475 
476 
478 {
479  SIM_PANEL_BASE* plotPanel;
480 
481  if( SIM_PANEL_BASE::IsPlottable( aSimType ) )
482  {
483  SIM_PLOT_PANEL* panel;
484  panel = new SIM_PLOT_PANEL( aSimType, m_plotNotebook, this, wxID_ANY );
485 
487  Pgm().GetCommonSettings()->m_Input.scroll_modifier_zoom != 0 );
488 
489  plotPanel = dynamic_cast<SIM_PANEL_BASE*>( panel );
490  }
491  else
492  {
493  SIM_NOPLOT_PANEL* panel;
494  panel = new SIM_NOPLOT_PANEL( aSimType, m_plotNotebook, wxID_ANY );
495  plotPanel = dynamic_cast<SIM_PANEL_BASE*>( panel );
496  }
497 
498  if( m_welcomePanel )
499  {
500  m_plotNotebook->DeletePage( 0 );
501  m_welcomePanel = nullptr;
502  }
503 
504  wxString pageTitle( m_simulator->TypeToName( aSimType, true ) );
505  pageTitle.Prepend( wxString::Format( _( "Plot%u - " ), (unsigned int) ++m_plotNumber ) );
506 
507  m_plotNotebook->AddPage( dynamic_cast<wxWindow*>( plotPanel ), pageTitle, true );
508  m_plots[plotPanel] = PLOT_INFO();
509 
510  return plotPanel;
511 }
512 
513 
514 void SIM_PLOT_FRAME::AddVoltagePlot( const wxString& aNetName )
515 {
516  addPlot( aNetName, SPT_VOLTAGE, "V" );
517 }
518 
519 
520 void SIM_PLOT_FRAME::AddCurrentPlot( const wxString& aDeviceName, const wxString& aParam )
521 {
522  addPlot( aDeviceName, SPT_CURRENT, aParam );
523 }
524 
525 
527 {
528  SIM_PANEL_BASE* plotPanel = currentPlotWindow();
529 
530  if( !plotPanel || plotPanel == m_welcomePanel )
531  return;
532 
533  // For now limit the tuner tool to RLC components
534  char primitiveType = NETLIST_EXPORTER_PSPICE::GetSpiceField( SF_PRIMITIVE, aComponent, 0 )[0];
535 
536  if( primitiveType != SP_RESISTOR && primitiveType != SP_CAPACITOR && primitiveType != SP_INDUCTOR )
537  return;
538 
539  const wxString componentName = aComponent->GetField( REFERENCE )->GetText();
540 
541  // Do not add multiple instances for the same component
542  auto tunerIt = std::find_if( m_tuners.begin(), m_tuners.end(), [&]( const TUNER_SLIDER* t )
543  {
544  return t->GetComponentName() == componentName;
545  }
546  );
547 
548  if( tunerIt != m_tuners.end() )
549  return; // We already have it
550 
551  try
552  {
553  TUNER_SLIDER* tuner = new TUNER_SLIDER( this, m_tunePanel, aComponent );
554  m_tuneSizer->Add( tuner );
555  m_tuners.push_back( tuner );
556  m_tunePanel->Layout();
557  }
558  catch( const KI_PARAM_ERROR& e )
559  {
560  // Sorry, no bonus
561  DisplayError( nullptr, e.What() );
562  }
563 }
564 
565 
566 void SIM_PLOT_FRAME::RemoveTuner( TUNER_SLIDER* aTuner, bool aErase )
567 {
568  if( aErase )
569  m_tuners.remove( aTuner );
570 
571  aTuner->Destroy();
572  m_tunePanel->Layout();
573 }
574 
575 
577 {
578  SIM_PANEL_BASE* curPage = currentPlotWindow();
579 
580  return ( ( !curPage || curPage->GetType() == ST_UNKNOWN ) ?
581  nullptr :
582  dynamic_cast<SIM_PLOT_PANEL*>( curPage ) );
583 }
584 
585 
587 {
588  return m_exporter.get();
589 }
590 
591 
592 void SIM_PLOT_FRAME::addPlot( const wxString& aName, SIM_PLOT_TYPE aType, const wxString& aParam )
593 {
594  SIM_TYPE simType = m_exporter->GetSimType();
595 
596  if( simType == ST_UNKNOWN )
597  {
598  m_simConsole->AppendText( _( "Error: simulation type not defined!\n" ) );
599  m_simConsole->SetInsertionPointEnd();
600  return;
601  }
602  else if( !SIM_PANEL_BASE::IsPlottable( simType ) )
603  {
604  m_simConsole->AppendText( _( "Error: simulation type doesn't support plotting!\n" ) );
605  m_simConsole->SetInsertionPointEnd();
606  return;
607  }
608 
609  // Create a new plot if the current one displays a different type
610  SIM_PLOT_PANEL* plotPanel = CurrentPlot();
611 
612  if( !plotPanel || plotPanel->GetType() != simType )
613  plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( NewPlotPanel( simType ) );
614 
615  wxASSERT( plotPanel );
616 
617  if( !plotPanel ) // Something is wrong
618  return;
619 
620  TRACE_DESC descriptor( *m_exporter, aName, aType, aParam );
621 
622  bool updated = false;
623  SIM_PLOT_TYPE xAxisType = GetXAxisType( simType );
624 
625  if( xAxisType == SPT_LIN_FREQUENCY || xAxisType == SPT_LOG_FREQUENCY )
626  {
627  int baseType = descriptor.GetType() & ~( SPT_AC_MAG | SPT_AC_PHASE );
628 
629  // Add two plots: magnitude & phase
630  TRACE_DESC mag_desc( *m_exporter, descriptor, (SIM_PLOT_TYPE)( baseType | SPT_AC_MAG ) );
631  TRACE_DESC phase_desc( *m_exporter, descriptor, (SIM_PLOT_TYPE)( baseType | SPT_AC_PHASE ) );
632 
633  updated |= updatePlot( mag_desc, plotPanel );
634  updated |= updatePlot( phase_desc, plotPanel );
635  }
636  else
637  {
638  updated = updatePlot( descriptor, plotPanel );
639  }
640 
641  if( updated )
642  {
644  }
645 }
646 
647 
648 void SIM_PLOT_FRAME::removePlot( const wxString& aPlotName, bool aErase )
649 {
650  SIM_PLOT_PANEL* plotPanel = CurrentPlot();
651 
652  if( !plotPanel )
653  return;
654 
655  if( aErase )
656  {
657  auto& traceMap = m_plots[plotPanel].m_traces;
658  auto traceIt = traceMap.find( aPlotName );
659  wxASSERT( traceIt != traceMap.end() );
660  traceMap.erase( traceIt );
661  }
662 
663  wxASSERT( plotPanel->TraceShown( aPlotName ) );
664  plotPanel->DeleteTrace( aPlotName );
665  plotPanel->GetPlotWin()->Fit();
666 
668  wxCommandEvent dummy;
670 }
671 
672 
674 {
676 }
677 
678 
679 bool SIM_PLOT_FRAME::updatePlot( const TRACE_DESC& aDescriptor, SIM_PLOT_PANEL* aPanel )
680 {
681  SIM_TYPE simType = m_exporter->GetSimType();
682  wxString spiceVector = m_exporter->ComponentToVector(
683  aDescriptor.GetName(), aDescriptor.GetType(), aDescriptor.GetParam() );
684 
685  if( !SIM_PANEL_BASE::IsPlottable( simType ) )
686  {
687  // There is no plot to be shown
688  m_simulator->Command( wxString::Format( "print %s", spiceVector ).ToStdString() );
689 
690  return false;
691  }
692 
693  // First, handle the x axis
694  wxString xAxisName( m_simulator->GetXAxis( simType ) );
695 
696  if( xAxisName.IsEmpty() )
697  return false;
698 
699  auto data_x = m_simulator->GetMagPlot( (const char*) xAxisName.c_str() );
700  unsigned int size = data_x.size();
701 
702  if( data_x.empty() )
703  return false;
704 
705  SIM_PLOT_TYPE plotType = aDescriptor.GetType();
706  std::vector<double> data_y;
707 
708  // Now, Y axis data
709  switch( m_exporter->GetSimType() )
710  {
711  case ST_AC:
712  {
713  wxASSERT_MSG( !( ( plotType & SPT_AC_MAG ) && ( plotType & SPT_AC_PHASE ) ),
714  "Cannot set both AC_PHASE and AC_MAG bits" );
715 
716  if( plotType & SPT_AC_MAG )
717  data_y = m_simulator->GetMagPlot( (const char*) spiceVector.c_str() );
718  else if( plotType & SPT_AC_PHASE )
719  data_y = m_simulator->GetPhasePlot( (const char*) spiceVector.c_str() );
720  else
721  wxASSERT_MSG( false, "Plot type missing AC_PHASE or AC_MAG bit" );
722  }
723  break;
724 
725  case ST_NOISE:
726  case ST_DC:
727  case ST_TRANSIENT:
728  {
729  data_y = m_simulator->GetMagPlot( (const char*) spiceVector.c_str() );
730  }
731  break;
732 
733  default:
734  wxASSERT_MSG( false, "Unhandled plot type" );
735  return false;
736  }
737 
738  if( data_y.size() != size )
739  return false;
740 
741  // If we did a two-source DC analysis, we need to split the resulting vector and add traces
742  // for each input step
743  SPICE_DC_PARAMS source1, source2;
744 
745  if( m_exporter->GetSimType() == ST_DC &&
746  m_exporter->ParseDCCommand( m_exporter->GetUsedSimCommand(), &source1, &source2 ) )
747  {
748  if( !source2.m_source.IsEmpty() )
749  {
750  // Source 1 is the inner loop, so lets add traces for each Source 2 (outer loop) step
751  SPICE_VALUE v = source2.m_vstart;
752  wxString name;
753 
754  size_t offset = 0;
755  size_t outer = ( size_t )( ( source2.m_vend - v ) / source2.m_vincrement ).ToDouble();
756  size_t inner = data_x.size() / ( outer + 1 );
757 
758  wxASSERT( data_x.size() % ( outer + 1 ) == 0 );
759 
760  for( size_t idx = 0; idx <= outer; idx++ )
761  {
762  name = wxString::Format( "%s (%s = %s V)", aDescriptor.GetTitle(),
763  source2.m_source, v.ToString() );
764 
765  std::vector<double> sub_x( data_x.begin() + offset,
766  data_x.begin() + offset + inner );
767  std::vector<double> sub_y( data_y.begin() + offset,
768  data_y.begin() + offset + inner );
769 
770  if( aPanel->AddTrace( name, inner,
771  sub_x.data(), sub_y.data(), aDescriptor.GetType() ) )
772  {
773  m_plots[aPanel].m_traces.insert( std::make_pair( name, aDescriptor ) );
774  }
775 
776  v = v + source2.m_vincrement;
777  offset += inner;
778  }
779 
780  return true;
781  }
782  }
783 
784  if( aPanel->AddTrace( aDescriptor.GetTitle(), size,
785  data_x.data(), data_y.data(), aDescriptor.GetType() ) )
786  {
787  m_plots[aPanel].m_traces.insert( std::make_pair( aDescriptor.GetTitle(), aDescriptor ) );
788  }
789 
790  return true;
791 }
792 
793 
795 {
796  m_signals->ClearAll();
797 
798  SIM_PLOT_PANEL* plotPanel = CurrentPlot();
799 
800  if( !plotPanel )
801  return;
802 
803  wxSize size = m_signals->GetClientSize();
804  m_signals->AppendColumn( _( "Signal" ), wxLIST_FORMAT_LEFT, size.x );
805 
806  // Build an image list, to show the color of the corresponding trace
807  // in the plot panel
808  // This image list is used for trace and cursor lists
809  wxMemoryDC bmDC;
810  const int isize = bmDC.GetCharHeight();
811 
813  m_signalsIconColorList = new wxImageList( isize, isize, false );
814  else
815  m_signalsIconColorList->RemoveAll();
816 
817  for( const auto& trace : CurrentPlot()->GetTraces() )
818  {
819  wxBitmap bitmap( isize, isize );
820  bmDC.SelectObject( bitmap );
821  wxColour tcolor = trace.second->GetTraceColour();
822 
823  wxColour bgColor = m_signals->wxWindow::GetBackgroundColour();
824  bmDC.SetPen( wxPen( bgColor ) );
825  bmDC.SetBrush( wxBrush( bgColor ) );
826  bmDC.DrawRectangle( 0, 0, isize, isize ); // because bmDC.Clear() does not work in wxGTK
827 
828  bmDC.SetPen( wxPen( tcolor ) );
829  bmDC.SetBrush( wxBrush( tcolor ) );
830  bmDC.DrawRectangle( 0, isize / 4 + 1, isize, isize / 2 );
831 
832  bmDC.SelectObject( wxNullBitmap ); // Needed to initialize bitmap
833 
834  bitmap.SetMask( new wxMask( bitmap, *wxBLACK ) );
835  m_signalsIconColorList->Add( bitmap );
836  }
837 
838  if( bmDC.IsOk() )
839  {
840  bmDC.SetBrush( wxNullBrush );
841  bmDC.SetPen( wxNullPen );
842  }
843 
844  m_signals->SetImageList( m_signalsIconColorList, wxIMAGE_LIST_SMALL );
845 
846  // Fill the signals listctrl. Keep the order of names and
847  // the order of icon color identical, because the icons
848  // are also used in cursor list, and the color index is
849  // calculated from the trace name index
850  int imgidx = 0;
851 
852  for( const auto& trace : m_plots[plotPanel].m_traces )
853  {
854  m_signals->InsertItem( imgidx, trace.first, imgidx );
855  imgidx++;
856  }
857 }
858 
859 
861 {
862  const auto& spiceItems = m_exporter->GetSpiceItems();
863 
864  for( auto it = m_tuners.begin(); it != m_tuners.end(); /* iteration inside the loop */ )
865  {
866  const wxString& ref = (*it)->GetComponentName();
867 
868  if( std::find_if( spiceItems.begin(), spiceItems.end(), [&]( const SPICE_ITEM& item )
869  {
870  return item.m_refName == ref;
871  }) == spiceItems.end() )
872  {
873  // The component does not exist anymore, remove the associated tuner
874  TUNER_SLIDER* tuner = *it;
875  it = m_tuners.erase( it );
876  RemoveTuner( tuner, false );
877  }
878  else
879  {
880  ++it;
881  }
882  }
883 }
884 
885 
887 {
888  for( auto& tuner : m_tuners )
889  {
891  std::string command( "alter @" + tuner->GetSpiceName()
892  + "=" + tuner->GetValue().ToSpiceString() );
893 
894  m_simulator->Command( command );
895  }
896 }
897 
898 
899 bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
900 {
901  m_plots.clear();
902  m_plotNotebook->DeleteAllPages();
903 
904  wxTextFile file( aPath );
905 
906  if( !file.Open() )
907  return false;
908 
909  long plotsCount;
910 
911  if( !file.GetFirstLine().ToLong( &plotsCount ) ) // GetFirstLine instead of GetNextLine
912  return false;
913 
914  for( long i = 0; i < plotsCount; ++i )
915  {
916  long plotType, tracesCount;
917 
918  if( !file.GetNextLine().ToLong( &plotType ) )
919  return false;
920 
921  SIM_PANEL_BASE* plotPanel = NewPlotPanel( (SIM_TYPE) plotType );
922  m_plots[plotPanel].m_simCommand = file.GetNextLine();
923  StartSimulation( m_plots[plotPanel].m_simCommand );
924 
925  // Perform simulation, so plots can be added with values
926  do
927  {
928  wxThread::This()->Sleep( 50 );
929  }
930  while( IsSimulationRunning() );
931 
932  if( !file.GetNextLine().ToLong( &tracesCount ) )
933  return false;
934 
935  for( long j = 0; j < tracesCount; ++j )
936  {
937  long traceType;
938  wxString name, param;
939 
940  if( !file.GetNextLine().ToLong( &traceType ) )
941  return false;
942 
943  name = file.GetNextLine();
944  param = file.GetNextLine();
945 
946  if( name.IsEmpty() || param.IsEmpty() )
947  return false;
948 
949  addPlot( name, (SIM_PLOT_TYPE) traceType, param );
950  }
951  }
952 
953  return true;
954 }
955 
956 
957 bool SIM_PLOT_FRAME::saveWorkbook( const wxString& aPath )
958 {
959 
960  wxString savePath = aPath;
961 
962  if( !savePath.Lower().EndsWith(".wbk"))
963  {
964  savePath += ".wbk";
965  };
966 
967 
968  wxTextFile file( savePath );
969 
970  if( file.Exists() )
971  {
972  if( !file.Open() )
973  return false;
974 
975  file.Clear();
976  }
977  else
978  {
979  file.Create();
980  }
981 
982  file.AddLine( wxString::Format( "%llu", m_plots.size() ) );
983 
984  for( const auto& plot : m_plots )
985  {
986  if( plot.first )
987  {
988  file.AddLine( wxString::Format( "%d", plot.first->GetType() ) );
989  file.AddLine( plot.second.m_simCommand );
990  file.AddLine( wxString::Format( "%llu", plot.second.m_traces.size() ) );
991 
992  for( const auto& trace : plot.second.m_traces )
993  {
994  file.AddLine( wxString::Format( "%d", trace.second.GetType() ) );
995  file.AddLine( trace.second.GetName() );
996  file.AddLine( trace.second.GetParam() );
997  }
998  }
999  }
1000 
1001  bool res = file.Write();
1002  file.Close();
1003 
1004  return res;
1005 }
1006 
1007 
1009 {
1010  switch( aType )
1011  {
1012  case ST_AC:
1013  return SPT_LIN_FREQUENCY;
1015 
1016  case ST_DC:
1017  return SPT_SWEEP;
1018 
1019  case ST_TRANSIENT:
1020  return SPT_TIME;
1021 
1022  default:
1023  wxASSERT_MSG( false, "Unhandled simulation type" );
1024  return (SIM_PLOT_TYPE) 0;
1025  }
1026 }
1027 
1028 
1029 void SIM_PLOT_FRAME::menuNewPlot( wxCommandEvent& aEvent )
1030 {
1031  SIM_TYPE type = m_exporter->GetSimType();
1032 
1033  if( SIM_PANEL_BASE::IsPlottable( type ) )
1034  {
1035  SIM_PLOT_PANEL* prevPlot = CurrentPlot();
1036  SIM_PLOT_PANEL* newPlot = dynamic_cast<SIM_PLOT_PANEL*>( NewPlotPanel( type ) );
1037 
1038  // If the previous plot had the same type, copy the simulation command
1039  if( prevPlot )
1040  m_plots[newPlot].m_simCommand = m_plots[prevPlot].m_simCommand;
1041  }
1042 }
1043 
1044 
1045 void SIM_PLOT_FRAME::menuOpenWorkbook( wxCommandEvent& event )
1046 {
1047  wxFileDialog openDlg( this, _( "Open simulation workbook" ), m_savedWorkbooksPath, "",
1048  WorkbookFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1049 
1050  if( openDlg.ShowModal() == wxID_CANCEL )
1051  return;
1052 
1053  m_savedWorkbooksPath = openDlg.GetDirectory();
1054 
1055  if( !loadWorkbook( openDlg.GetPath() ) )
1056  DisplayError( this, _( "There was an error while opening the workbook file" ) );
1057 }
1058 
1059 
1060 void SIM_PLOT_FRAME::menuSaveWorkbook( wxCommandEvent& event )
1061 {
1062  if( !CurrentPlot() )
1063  return;
1064 
1065  wxFileDialog saveDlg( this, _( "Save Simulation Workbook" ), m_savedWorkbooksPath, "",
1066  WorkbookFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1067 
1068  if( saveDlg.ShowModal() == wxID_CANCEL )
1069  return;
1070 
1071  m_savedWorkbooksPath = saveDlg.GetDirectory();
1072 
1073  if( !saveWorkbook( saveDlg.GetPath() ) )
1074  DisplayError( this, _( "There was an error while saving the workbook file" ) );
1075 }
1076 
1077 
1078 void SIM_PLOT_FRAME::menuSaveImage( wxCommandEvent& event )
1079 {
1080  if( !CurrentPlot() )
1081  return;
1082 
1083  wxFileDialog saveDlg( this, _( "Save Plot as Image" ), "", "",
1084  PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1085 
1086  if( saveDlg.ShowModal() == wxID_CANCEL )
1087  return;
1088 
1089  CurrentPlot()->GetPlotWin()->SaveScreenshot( saveDlg.GetPath(), wxBITMAP_TYPE_PNG );
1090 }
1091 
1092 
1093 void SIM_PLOT_FRAME::menuSaveCsv( wxCommandEvent& event )
1094 {
1095  if( !CurrentPlot() )
1096  return;
1097 
1098  const wxChar SEPARATOR = ';';
1099 
1100  wxFileDialog saveDlg( this, _( "Save Plot Data" ), "", "",
1101  CsvFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1102 
1103  if( saveDlg.ShowModal() == wxID_CANCEL )
1104  return;
1105 
1106  wxFile out( saveDlg.GetPath(), wxFile::write );
1107  bool timeWritten = false;
1108 
1109  for( const auto& t : CurrentPlot()->GetTraces() )
1110  {
1111  const TRACE* trace = t.second;
1112 
1113  if( !timeWritten )
1114  {
1115  out.Write( wxString::Format( "Time%c", SEPARATOR ) );
1116 
1117  for( double v : trace->GetDataX() )
1118  out.Write( wxString::Format( "%f%c", v, SEPARATOR ) );
1119 
1120  out.Write( "\r\n" );
1121  timeWritten = true;
1122  }
1123 
1124  out.Write( wxString::Format( "%s%c", t.first, SEPARATOR ) );
1125 
1126  for( double v : trace->GetDataY() )
1127  out.Write( wxString::Format( "%f%c", v, SEPARATOR ) );
1128 
1129  out.Write( "\r\n" );
1130  }
1131 
1132  out.Close();
1133 }
1134 
1135 
1136 void SIM_PLOT_FRAME::menuZoomIn( wxCommandEvent& event )
1137 {
1138  if( CurrentPlot() )
1139  CurrentPlot()->GetPlotWin()->ZoomIn();
1140 }
1141 
1142 
1143 void SIM_PLOT_FRAME::menuZoomOut( wxCommandEvent& event )
1144 {
1145  if( CurrentPlot() )
1146  CurrentPlot()->GetPlotWin()->ZoomOut();
1147 }
1148 
1149 
1150 void SIM_PLOT_FRAME::menuZoomFit( wxCommandEvent& event )
1151 {
1152  if( CurrentPlot() )
1153  CurrentPlot()->GetPlotWin()->Fit();
1154 }
1155 
1156 
1157 void SIM_PLOT_FRAME::menuShowGrid( wxCommandEvent& event )
1158 {
1159  SIM_PLOT_PANEL* plot = CurrentPlot();
1160 
1161  if( plot )
1162  plot->ShowGrid( !plot->IsGridShown() );
1163 }
1164 
1165 
1166 void SIM_PLOT_FRAME::menuShowGridUpdate( wxUpdateUIEvent& event )
1167 {
1168  SIM_PLOT_PANEL* plot = CurrentPlot();
1169 
1170  event.Check( plot ? plot->IsGridShown() : false );
1171 }
1172 
1173 
1174 void SIM_PLOT_FRAME::menuShowLegend( wxCommandEvent& event )
1175 {
1176  SIM_PLOT_PANEL* plot = CurrentPlot();
1177 
1178  if( plot )
1179  plot->ShowLegend( !plot->IsLegendShown() );
1180 }
1181 
1182 
1183 void SIM_PLOT_FRAME::menuShowLegendUpdate( wxUpdateUIEvent& event )
1184 {
1185  SIM_PLOT_PANEL* plot = CurrentPlot();
1186  event.Check( plot ? plot->IsLegendShown() : false );
1187 }
1188 
1189 
1190 void SIM_PLOT_FRAME::menuShowDotted( wxCommandEvent& event )
1191 {
1192  SIM_PLOT_PANEL* plot = CurrentPlot();
1193 
1194  if( plot )
1195  plot->SetDottedCurrentPhase( !plot->GetDottedCurrentPhase() );
1196 }
1197 
1198 
1199 void SIM_PLOT_FRAME::menuShowDottedUpdate( wxUpdateUIEvent& event )
1200 {
1201  SIM_PLOT_PANEL* plot = CurrentPlot();
1202 
1203  event.Check( plot ? plot->GetDottedCurrentPhase() : false );
1204 }
1205 
1206 
1207 void SIM_PLOT_FRAME::menuWhiteBackground( wxCommandEvent& event )
1208 {
1210 
1211  // Rebuild the color list to plot traces
1213 
1214  // Now send changes to all SIM_PLOT_PANEL
1215  for( size_t page = 0; page < m_plotNotebook->GetPageCount(); page++ )
1216  {
1217  wxWindow* curPage = m_plotNotebook->GetPage( page );
1218 
1219  if( curPage == m_welcomePanel )
1220  continue;
1221 
1222  static_cast<SIM_PLOT_PANEL*>( curPage )->UpdatePlotColors();
1223  }
1224 }
1225 
1226 
1227 void SIM_PLOT_FRAME::onPlotClose( wxAuiNotebookEvent& event )
1228 {
1229  int idx = event.GetSelection();
1230 
1231  if( idx == wxNOT_FOUND )
1232  return;
1233 
1234  SIM_PANEL_BASE* plotPanel =
1235  dynamic_cast<SIM_PANEL_BASE*>( m_plotNotebook->GetPage( idx ) );
1236 
1237  m_plots.erase( plotPanel );
1238  updateSignalList();
1239  wxCommandEvent dummy;
1240  onCursorUpdate( dummy );
1241 }
1242 
1243 
1244 void SIM_PLOT_FRAME::onPlotChanged( wxAuiNotebookEvent& event )
1245 {
1246  updateSignalList();
1247  wxCommandEvent dummy;
1248  onCursorUpdate( dummy );
1249 }
1250 
1251 
1252 void SIM_PLOT_FRAME::onSignalDblClick( wxMouseEvent& event )
1253 {
1254  // Remove signal from the plot panel when double clicked
1255  long idx = m_signals->GetFocusedItem();
1256 
1257  if( idx != wxNOT_FOUND )
1258  removePlot( m_signals->GetItemText( idx, 0 ) );
1259 }
1260 
1261 
1262 void SIM_PLOT_FRAME::onSignalRClick( wxListEvent& event )
1263 {
1264  int idx = event.GetIndex();
1265 
1266  if( idx != wxNOT_FOUND )
1267  m_signals->Select( idx );
1268 
1269  idx = m_signals->GetFirstSelected();
1270 
1271  if( idx != wxNOT_FOUND )
1272  {
1273  const wxString& netName = m_signals->GetItemText( idx, 0 );
1274  SIGNAL_CONTEXT_MENU ctxMenu( netName, this );
1275  m_signals->PopupMenu( &ctxMenu );
1276  }
1277 }
1278 
1279 
1280 void SIM_PLOT_FRAME::onSimulate( wxCommandEvent& event )
1281 {
1282  if( IsSimulationRunning() )
1283  StopSimulation();
1284  else
1285  StartSimulation();
1286 }
1287 
1288 
1289 void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
1290 {
1291  SIM_PANEL_BASE* plotPanelWindow = currentPlotWindow();
1292 
1293  // Initial processing is required to e.g. display a list of power sources
1295 
1296  if( !m_exporter->ProcessNetlist( NET_ALL_FLAGS ) )
1297  {
1298  DisplayError( this, _( "There were errors during netlist export, aborted." ) );
1299  return;
1300  }
1301 
1302  if( !m_settingsDlg )
1303  m_settingsDlg = new DIALOG_SIM_SETTINGS( this );
1304 
1305  if( plotPanelWindow != m_welcomePanel )
1306  m_settingsDlg->SetSimCommand( m_plots[plotPanelWindow].m_simCommand );
1307 
1309 
1310  if( m_settingsDlg->ShowModal() == wxID_OK )
1311  {
1312  wxString newCommand = m_settingsDlg->GetSimCommand();
1313  SIM_TYPE newSimType = NETLIST_EXPORTER_PSPICE_SIM::CommandToSimType( newCommand );
1314 
1315  // If it is a new simulation type, open a new plot
1316  if( !plotPanelWindow || ( plotPanelWindow && plotPanelWindow->GetType() != newSimType ) )
1317  {
1318  plotPanelWindow = NewPlotPanel( newSimType );
1319  }
1320 
1321  m_plots[plotPanelWindow].m_simCommand = newCommand;
1322  }
1323 }
1324 
1325 
1326 void SIM_PLOT_FRAME::onAddSignal( wxCommandEvent& event )
1327 {
1328  SIM_PLOT_PANEL* plotPanel = CurrentPlot();
1329 
1330  if( !plotPanel || !m_exporter || plotPanel->GetType() != m_exporter->GetSimType() )
1331  {
1332  DisplayInfoMessage( this, _( "You need to run plot-providing simulation first." ) );
1333  return;
1334  }
1335 
1336  DIALOG_SIGNAL_LIST dialog( this, m_exporter.get() );
1337  dialog.ShowModal();
1338 }
1339 
1340 
1341 void SIM_PLOT_FRAME::onProbe( wxCommandEvent& event )
1342 {
1343  if( m_schematicFrame == NULL )
1344  return;
1345 
1347  m_schematicFrame->Raise();
1348 }
1349 
1350 
1351 void SIM_PLOT_FRAME::onTune( wxCommandEvent& event )
1352 {
1353  if( m_schematicFrame == NULL )
1354  return;
1355 
1357  m_schematicFrame->Raise();
1358 }
1359 
1360 void SIM_PLOT_FRAME::onShowNetlist( wxCommandEvent& event )
1361 {
1362  class NETLIST_VIEW_DIALOG : public wxDialog
1363  {
1364  public:
1365  enum
1366  {
1367  MARGIN_LINE_NUMBERS
1368  };
1369 
1370  void onClose( wxCloseEvent& evt )
1371  {
1372  EndModal( GetReturnCode() );
1373  }
1374 
1375  NETLIST_VIEW_DIALOG(wxWindow* parent, wxString source) :
1376  wxDialog(parent, wxID_ANY, "SPICE Netlist",
1377  wxDefaultPosition, wxSize(1500,900),
1378  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
1379  {
1380  wxStyledTextCtrl* text = new wxStyledTextCtrl( this, wxID_ANY );
1381 
1382  text->SetMarginWidth( MARGIN_LINE_NUMBERS, 50 );
1383  text->StyleSetForeground( wxSTC_STYLE_LINENUMBER, wxColour( 75, 75, 75 ) );
1384  text->StyleSetBackground( wxSTC_STYLE_LINENUMBER, wxColour( 220, 220, 220 ) );
1385  text->SetMarginType( MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER );
1386 
1387  text->SetWrapMode( wxSTC_WRAP_WORD );
1388 
1389  text->SetText( source );
1390 
1391  text->StyleClearAll();
1392  text->SetLexer( wxSTC_LEX_SPICE );
1393 
1394  wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
1395  sizer->Add( text, 1, wxEXPAND );
1396  SetSizer( sizer );
1397 
1398  Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( NETLIST_VIEW_DIALOG::onClose ), NULL,
1399  this );
1400  }
1401  };
1402 
1403  if( m_schematicFrame == NULL || m_simulator == NULL )
1404  return;
1405 
1406  NETLIST_VIEW_DIALOG dlg( this, m_simulator->GetNetlist() );
1407  dlg.ShowModal();
1408 }
1409 
1410 
1412 {
1413  SaveSettings( config() );
1414 
1415  if( IsSimulationRunning() )
1416  m_simulator->Stop();
1417 
1418  // Cancel a running simProbe or simTune tool
1420 
1421  Destroy();
1422 }
1423 
1424 
1425 void SIM_PLOT_FRAME::onCursorUpdate( wxCommandEvent& event )
1426 {
1427  wxSize size = m_cursors->GetClientSize();
1428  SIM_PLOT_PANEL* plotPanel = CurrentPlot();
1429  m_cursors->ClearAll();
1430 
1431  if( !plotPanel )
1432  return;
1433 
1435  m_cursors->SetImageList(m_signalsIconColorList, wxIMAGE_LIST_SMALL);
1436 
1437  // Fill the signals listctrl
1438  m_cursors->AppendColumn( _( "Signal" ), wxLIST_FORMAT_LEFT, size.x / 2 );
1439  const long X_COL = m_cursors->AppendColumn( plotPanel->GetLabelX(), wxLIST_FORMAT_LEFT, size.x / 4 );
1440 
1441  wxString labelY1 = plotPanel->GetLabelY1();
1442  wxString labelY2 = plotPanel->GetLabelY2();
1443  wxString labelY;
1444 
1445  if( !labelY2.IsEmpty() )
1446  labelY = labelY1 + " / " + labelY2;
1447  else
1448  labelY = labelY1;
1449 
1450  const long Y_COL = m_cursors->AppendColumn( labelY, wxLIST_FORMAT_LEFT, size.x / 4 );
1451 
1452  // Update cursor values
1453  int itemidx = 0;
1454 
1455  for( const auto& trace : plotPanel->GetTraces() )
1456  {
1457  if( CURSOR* cursor = trace.second->GetCursor() )
1458  {
1459  // Find the right icon color in list.
1460  // It is the icon used in m_signals list for the same trace
1461  long iconColor = m_signals->FindItem( -1, trace.first );
1462 
1463  const wxRealPoint coords = cursor->GetCoords();
1464  long idx = m_cursors->InsertItem( itemidx++, trace.first, iconColor );
1465  m_cursors->SetItem( idx, X_COL, SPICE_VALUE( coords.x ).ToSpiceString() );
1466  m_cursors->SetItem( idx, Y_COL, SPICE_VALUE( coords.y ).ToSpiceString() );
1467  }
1468  }
1469 }
1470 
1471 
1472 void SIM_PLOT_FRAME::onSimStarted( wxCommandEvent& aEvent )
1473 {
1474  m_toolBar->SetToolNormalBitmap( ID_SIM_RUN, KiBitmap( sim_stop_xpm ) );
1475  SetCursor( wxCURSOR_ARROWWAIT );
1476 }
1477 
1478 
1479 void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent )
1480 {
1481  m_toolBar->SetToolNormalBitmap( ID_SIM_RUN, KiBitmap( sim_run_xpm ) );
1482  SetCursor( wxCURSOR_ARROW );
1483 
1484  SIM_TYPE simType = m_exporter->GetSimType();
1485 
1486  if( simType == ST_UNKNOWN )
1487  return;
1488 
1489  SIM_PANEL_BASE* plotPanelWindow = currentPlotWindow();
1490 
1491  if( !plotPanelWindow || plotPanelWindow->GetType() != simType )
1492  plotPanelWindow = NewPlotPanel( simType );
1493 
1494  if( IsSimulationRunning() )
1495  return;
1496 
1497  // If there are any signals plotted, update them
1498  if( SIM_PANEL_BASE::IsPlottable( simType ) )
1499  {
1500  TRACE_MAP& traceMap = m_plots[plotPanelWindow].m_traces;
1501  SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( plotPanelWindow );
1502 
1503  wxCHECK_RET( plotPanel, "not a SIM_PLOT_PANEL" );
1504 
1505  for( auto it = traceMap.begin(); it != traceMap.end(); /* iteration occurs in the loop */)
1506  {
1507  if( !updatePlot( it->second, plotPanel ) )
1508  {
1509  removePlot( it->first, false );
1510  it = traceMap.erase( it ); // remove a plot that does not exist anymore
1511  }
1512  else
1513  {
1514  ++it;
1515  }
1516  }
1517 
1518  updateSignalList();
1519  plotPanel->GetPlotWin()->UpdateAll();
1520  plotPanel->ResetScales();
1521  }
1522  else if( simType == ST_OP )
1523  {
1524  m_simConsole->AppendText( _( "\n\nSimulation results:\n\n" ) );
1525  m_simConsole->SetInsertionPointEnd();
1526 
1527  for( const auto& vec : m_simulator->AllPlots() )
1528  {
1529  double val = m_simulator->GetRealPlot( vec, 1 ).at( 0 );
1530 
1531  wxString outLine, signal;
1532  SIM_PLOT_TYPE type = m_exporter->VectorToSignal( vec, signal );
1533 
1534  const size_t tab = 25; //characters
1535  size_t padding = ( signal.length() < tab ) ? ( tab - signal.length() ) : 1;
1536 
1537  outLine.Printf( wxT( "%s%s" ), ( signal + wxT( ":" ) ).Pad( padding, wxUniChar( ' ' ) ),
1538  SPICE_VALUE( val ).ToSpiceString() );
1539 
1540  outLine.Append( type == SPT_CURRENT ? "A\n" : "V\n" );
1541 
1542  m_simConsole->AppendText( outLine );
1543  m_simConsole->SetInsertionPointEnd();
1544 
1545  // @todo display calculated values on the schematic
1546  }
1547  }
1548 }
1549 
1550 
1551 void SIM_PLOT_FRAME::onSimUpdate( wxCommandEvent& aEvent )
1552 {
1553  if( IsSimulationRunning() )
1554  StopSimulation();
1555 
1556  if( CurrentPlot() != m_lastSimPlot )
1557  {
1558  // We need to rerun simulation, as the simulator currently stores
1559  // results for another plot
1560  StartSimulation();
1561  }
1562  else
1563  {
1564  // Incremental update
1565  m_simConsole->Clear();
1566  // Do not export netlist, it is already stored in the simulator
1567  applyTuners();
1568  m_simulator->Run();
1569  }
1570 }
1571 
1572 
1573 void SIM_PLOT_FRAME::onSimReport( wxCommandEvent& aEvent )
1574 {
1575  m_simConsole->AppendText( aEvent.GetString() + "\n" );
1576  m_simConsole->SetInsertionPointEnd();
1577 }
1578 
1579 
1581  SIM_PLOT_FRAME* aPlotFrame )
1582  : m_signal( aSignal ), m_plotFrame( aPlotFrame )
1583 {
1585 
1586  AddMenuItem( this, HIDE_SIGNAL, _( "Hide Signal" ),
1587  _( "Erase the signal from plot screen" ),
1588  KiBitmap( delete_xpm ) );
1589 
1590  TRACE* trace = plot->GetTrace( m_signal );
1591 
1592  if( trace->HasCursor() )
1593  AddMenuItem( this, HIDE_CURSOR, _( "Hide Cursor" ), KiBitmap( pcb_target_xpm ) );
1594  else
1595  AddMenuItem( this, SHOW_CURSOR, _( "Show Cursor" ), KiBitmap( pcb_target_xpm ) );
1596 
1597  Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( SIGNAL_CONTEXT_MENU::onMenuEvent ), NULL, this );
1598 }
1599 
1600 
1602 {
1603  SIM_PLOT_PANEL* plot = m_plotFrame->CurrentPlot();
1604 
1605  switch( aEvent.GetId() )
1606  {
1607  case HIDE_SIGNAL:
1608  m_plotFrame->removePlot( m_signal );
1609  break;
1610 
1611  case SHOW_CURSOR:
1612  plot->EnableCursor( m_signal, true );
1613  break;
1614 
1615  case HIDE_CURSOR:
1616  plot->EnableCursor( m_signal, false );
1617  break;
1618  }
1619 }
1620 
1621 wxDEFINE_EVENT( EVT_SIM_UPDATE, wxCommandEvent );
1622 wxDEFINE_EVENT( EVT_SIM_REPORT, wxCommandEvent );
1623 
1624 wxDEFINE_EVENT( EVT_SIM_STARTED, wxCommandEvent );
1625 wxDEFINE_EVENT( EVT_SIM_FINISHED, wxCommandEvent );
const BITMAP_OPAQUE simulator_xpm[1]
Definition: simulator.cpp:52
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:239
void onAddSignal(wxCommandEvent &event)
#define ID_MENU_PROBE_SIGNALS
const BITMAP_OPAQUE swap_layer_xpm[1]
Definition: swap_layer.cpp:33
#define ID_SAVE_AS_IMAGE
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2239
bool IsLegendShown() const
bool saveWorkbook(const wxString &aPath)
Saves plot settings to a file.
wxString ToSpiceString() const
Returns string value in Spice format (e.g.
void SetKiway(wxWindow *aDest, KIWAY *aKiway)
Function SetKiway.
wxToolBarToolBase * m_toolProbe
void setIconsForMenuItems()
Give icons to menuitems of the main menubar.
void onSimStarted(wxCommandEvent &aEvent)
KIWAY & Kiway() const
Function Kiway returns a reference to the KIWAY that this object has an opportunity to participate in...
Definition: kiway_holder.h:56
void RemoveTuner(TUNER_SLIDER *aTuner, bool aErase=true)
Removes an existing tuner.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Function Report is a pure virtual function to override in the derived object.
bool GetPlotBgOpt() const
const BITMAP_OPAQUE pcb_target_xpm[1]
Definition: pcb_target.cpp:42
wxImageList * m_signalsIconColorList
imagelists uset to add a small coloured icon to signal names and cursors name, the same color as the ...
SIM_PLOT_TYPE operator|(SIM_PLOT_TYPE aFirst, SIM_PLOT_TYPE aSecond)
void onPlotChanged(wxAuiNotebookEvent &event) override
PNG memory record (file in memory).
Definition: bitmap_def.h:29
SIM_PLOT_FRAME * m_parent
const BITMAP_OPAQUE add_dashed_line_xpm[1]
void EnableMouseWheelPan(bool enabled)
Enable/disable trackpad friendly panning (2-axis scroll wheel)
Definition: mathplot.h:1217
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void menuWhiteBackground(wxCommandEvent &event) override
void onSignalDblClick(wxMouseEvent &event) override
bool SetSimCommand(const wxString &aCommand)
virtual void SaveSettings(APP_SETTINGS_BASE *aCfg)
Saves common frame parameters to a configuration data file.
mpWindow * GetPlotWin() const
Getter for math plot window
This file is part of the common library.
wxSplitterWindow * m_splitterSignals
const wxString & GetTitle() const
SIM_PANEL_BASE * NewPlotPanel(SIM_TYPE aSimType)
Creates a new plot panel for a given simulation type and adds it to the main notebook.
bool HasCursor() const
SEVERITY
Definition: ui_common.h:45
wxMenuItem * AddMenuItem(wxMenu *aMenu, int aId, const wxString &aText, const wxBitmap &aImage, wxItemKind aType=wxITEM_NORMAL)
Function AddMenuItem is an inline helper function to create and insert a menu item with an icon into ...
Definition: bitmap.cpp:232
void ShowLegend(bool aEnable)
int m_splitterPlotAndConsoleSashPosition
void menuZoomFit(wxCommandEvent &event) override
Structure to represent a schematic component in the Spice simulation.
const std::vector< double > & GetDataX() const
std::list< TUNER_SLIDER * > m_tuners
List of currently displayed tuners
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
void doCloseWindow() override
SIM_PLOT_TYPE GetType() const
wxString m_title
Title displayed in the signal list/plot legend
Class SIM_PLOT_FRAME_BASE.
const BITMAP_OPAQUE directory_browser_xpm[1]
const BITMAP_OPAQUE text_xpm[1]
Definition: text.cpp:27
bool IsGridShown() const
bool GetDottedCurrentPhase() const
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
WINDOW_SETTINGS * GetWindowSettings(APP_SETTINGS_BASE *aCfg) override
Returns a pointer to the window settings for this frame.
void menuNewPlot(wxCommandEvent &aEvent) override
void applyTuners()
Applies component values specified using tunder sliders to the current netlist.
const BITMAP_OPAQUE zoom_fit_in_page_xpm[1]
void AddVoltagePlot(const wxString &aNetName)
Adds a voltage plot for a given net name.
void AddCurrentPlot(const wxString &aDeviceName, const wxString &aParam)
Adds a current plot for a particular device.
#define ID_MENU_WHITE_BG
Trace descriptor class
Schematic editor (Eeschema) main window.
wxString CsvFileWildcard()
void onSimUpdate(wxCommandEvent &aEvent)
void menuOpenWorkbook(wxCommandEvent &event) override
void SetDottedCurrentPhase(bool aEnable)
void menuShowGrid(wxCommandEvent &event) override
void menuZoomIn(wxCommandEvent &event) override
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
std::map< SIM_PANEL_BASE *, PLOT_INFO > m_plots
Map of plot panels and associated data
void menuZoomOut(wxCommandEvent &event) override
SIM_THREAD_REPORTER * m_reporter
void OnSimStateChange(SPICE_SIMULATOR *aObject, SIM_STATE aNewState) override
std::shared_ptr< SPICE_SIMULATOR > m_simulator
bool updatePlot(const TRACE_DESC &aDescriptor, SIM_PLOT_PANEL *aPanel)
Updates plot in a particular SIM_PLOT_PANEL.
TRACE * GetTrace(const wxString &aName) const
SIM_PANEL_BASE * m_welcomePanel
Info panel
#define ID_SAVE_AS_CSV
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:124
Field Reference of part, i.e. "IC21".
wxString GetLabelY1() const
wxSplitterWindow * m_splitterTuneValues
static bool IsPlottable(SIM_TYPE aSimType)
static SIM_TYPE CommandToSimType(const wxString &aCmd)
Returns simulation type basing on a simulation command directive.
SIM_PLOT_TYPE GetXAxisType(SIM_TYPE aType) const
Returns X axis for a given simulation type.
void menuSaveCsv(wxCommandEvent &event) override
void onPlotClose(wxAuiNotebookEvent &event) override
void StartSimulation(const wxString &aSimCommand=wxEmptyString)
const wxString & GetParam() const
wxAuiNotebook * m_plotNotebook
SCH_EDIT_FRAME * m_schematicFrame
bool DeleteTrace(const wxString &aName)
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2713
void EnableCursor(const wxString &aName, bool aEnable)
Toggles cursor for a particular trace.
SIM_STATE
const wxString & GetSimCommand() const
void setSubWindowsSashSize()
const BITMAP_OPAQUE zoom_out_xpm[1]
Definition: zoom_out.cpp:58
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:80
Stores the common settings that are saved and loaded for each window / frame.
Definition: app_settings.h:81
wxString ToString() const
Returns string value as when converting double to string (e.g.
const BITMAP_OPAQUE sim_add_signal_xpm[1]
SIM_PLOT_PANEL * m_lastSimPlot
Panel that was used as the most recent one for simulations
wxString GetLabelX() const
void AddBitmapToMenuItem(wxMenuItem *aMenu, const wxBitmap &aImage)
Add a bitmap to a menuitem.
Definition: bitmap.cpp:205
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
Definition: app_settings.h:99
#define NULL
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:343
#define ID_MENU_SHOW_NETLIST
wxString GetLabelY2() const
static TOOL_ACTION simTune
Definition: ee_actions.h:211
Helper class to handle Spice way of expressing values (e.g. 10.5 Meg)
Definition: spice_value.h:32
wxColor GetPlotColor(int aColorId)
wxSplitterWindow * m_splitterLeftRight
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2182
wxMenuItem * m_runSimulation
#define ID_MENU_TUNE_SIGNALS
void onSimReport(wxCommandEvent &aEvent)
const BITMAP_OPAQUE exit_xpm[1]
Definition: exit.cpp:63
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
SIM_TYPE
Possible simulation types
Definition: sim_types.h:29
std::vector< wxColour > m_colorList
The color list to draw traces, bg, fg, axis...
void onSimFinished(wxCommandEvent &aEvent)
Interface to receive simulation updates from SPICE_SIMULATOR class.
void fillDefaultColorList(bool aWhiteBg)
Fills m_colorList by a default set of colors.
const BITMAP_OPAQUE grid_xpm[1]
Definition: grid.cpp:21
const BITMAP_OPAQUE export_xpm[1]
Definition: export.cpp:75
bool AddTrace(const wxString &aName, int aPoints, const double *aX, const double *aY, SIM_PLOT_TYPE aFlags)
SCHEMATIC & Schematic() const
Definition of file extensions used in Kicad.
void onShowNetlist(wxCommandEvent &event)
SIM_THREAD_REPORTER(SIM_PLOT_FRAME *aParent)
void menuShowLegendUpdate(wxUpdateUIEvent &event) override
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
wxToolBarToolBase * m_toolAddSignals
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
int m_splitterTuneValuesSashPosition
void SaveSettings(APP_SETTINGS_BASE *aCfg) override
Saves common frame parameters to a configuration data file.
static std::shared_ptr< SPICE_SIMULATOR > CreateInstance(const std::string &aName)
Creates a simulator instance of particular type (currently only ngspice is handled)
TRACE_DESC(const NETLIST_EXPORTER_PSPICE_SIM &aExporter, const wxString &aName, SIM_PLOT_TYPE aType, const wxString &aParam)
SIM_PANEL_BASE * currentPlotWindow() const
Returns the currently opened plot panel (or NULL if there is none).
const std::string & GetString()
Definition: richio.h:475
void onSignalRClick(wxListEvent &event) override
void ResetScales()
Resets scale ranges to fit the current traces
bool IsSimulationRunning()
#define ID_MENU_SHOW_LEGEND
void menuShowLegend(wxCommandEvent &event) override
void ShowGrid(bool aEnable)
void onTune(wxCommandEvent &event)
wxToolBarToolBase * m_toolSimulate
void menuSaveImage(wxCommandEvent &event) override
#define ID_MENU_SET_SIMUL
const BITMAP_OPAQUE directory_xpm[1]
Definition: directory.cpp:30
wxString PngFileWildcard()
Implementing SIM_PLOT_FRAME_BASE.
bool loadWorkbook(const wxString &aPath)
Loads plot settings from a file.
void SetNetlistExporter(NETLIST_EXPORTER_PSPICE_SIM *aExporter)
static wxString m_savedWorkbooksPath
A string to store the path of saved workbooks during a session
void onCursorUpdate(wxCommandEvent &aEvent)
SCH_FIELD * GetField(int aFieldNdx)
Returns a field in this symbol.
SIM_TYPE GetType() const
DIALOG_SIM_SETTINGS * m_settingsDlg
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1977
const wxString & GetName() const
const wxString What() const
Definition: ki_exception.h:58
const BITMAP_OPAQUE sim_probe_xpm[1]
Definition: sim_probe.cpp:52
#define ID_MENU_ADD_SIGNAL
const BITMAP_OPAQUE sim_stop_xpm[1]
Definition: sim_stop.cpp:20
std::unique_ptr< NETLIST_EXPORTER_PSPICE_SIM > m_exporter
void updateNetlistExporter()
Reloads the current schematic for the netlist exporter.
see class PGM_BASE
void onSimulate(wxCommandEvent &event)
const BITMAP_OPAQUE sim_tune_xpm[1]
Definition: sim_tune.cpp:39
const char * name
Definition: DXF_plotter.cpp:60
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:201
SIGNAL_CONTEXT_MENU(const wxString &aSignal, SIM_PLOT_FRAME *aPlotFrame)
void onProbe(wxCommandEvent &event)
#define ID_MENU_SHOW_GRID
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
#define _(s)
Definition: 3d_actions.cpp:33
void updateSignalList()
Updates the list of currently plotted signals.
#define ID_MENU_DOTTED
const BITMAP_OPAQUE netlist_xpm[1]
unsigned int m_plotNumber
static wxString GetSpiceField(SPICE_FIELD aField, SCH_COMPONENT *aComponent, unsigned aCtl)
Retrieves either the requested field value or the default value.
Schematic symbol object.
Definition: sch_component.h:80
int m_splitterSignalsSashPosition
const BITMAP_OPAQUE sim_run_xpm[1]
Definition: sim_run.cpp:35
SIM_PLOT_PANEL * CurrentPlot() const
Returns the currently opened plot panel (or NULL if there is none).
std::map< wxString, TRACE_DESC > TRACE_MAP
void menuShowDotted(wxCommandEvent &event) override
wxDEFINE_EVENT(EVT_SIM_UPDATE, wxCommandEvent)
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
const std::vector< double > & GetDataY() const
int m_splitterLeftRightSashPosition
void menuShowDottedUpdate(wxUpdateUIEvent &event) override
static TOOL_ACTION simProbe
Definition: ee_actions.h:210
const BITMAP_OPAQUE sim_settings_xpm[1]
const NETLIST_EXPORTER_PSPICE_SIM * GetExporter() const
Returns the netlist exporter object used for simulations.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:78
void removePlot(const wxString &aPlotName, bool aErase=true)
Removes a plot with a specific title.
Custom widget to handle quick component values modification and simulation on the fly.
Definition: tuner_slider.h:40
void AddTuner(SCH_COMPONENT *aComponent)
Adds a tuner for a component.
wxString WorkbookFileWildcard()
bool SaveScreenshot(const wxString &filename, wxBitmapType type=wxBITMAP_TYPE_BMP, wxSize imageSize=wxDefaultSize, bool fit=false)
Draw the window on a wxBitmap, then save it to a file.
Definition: mathplot.cpp:2943
const std::map< wxString, TRACE * > & GetTraces() const
wxSplitterWindow * m_splitterPlotAndConsole
void menuShowGridUpdate(wxUpdateUIEvent &event) override
bool HasMessage() const override
Function HasMessage Returns true if the reporter client is non-empty.
void menuSaveWorkbook(wxCommandEvent &event) override
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition: confirm.cpp:267
STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:445
SIM_PLOT_TYPE
Possible plot types
Definition: sim_types.h:44
#define ID_MENU_RUN_SIM
void addPlot(const wxString &aName, SIM_PLOT_TYPE aType, const wxString &aParam)
Adds a new plot to the current panel.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
void onSettings(wxCommandEvent &event)
void LoadSettings(APP_SETTINGS_BASE *aCfg) override
Load common frame parameters from a configuration file.
wxToolBarToolBase * m_toolTune
void onMenuEvent(wxMenuEvent &aEvent)
bool TraceShown(const wxString &aName) const
Cursor attached to a trace to follow its values:
virtual void LoadSettings(APP_SETTINGS_BASE *aCfg)
Load common frame parameters from a configuration file.
const BITMAP_OPAQUE delete_xpm[1]
Definition: delete.cpp:62
Special netlist exporter flavor that allows one to override simulation commands.
void updateTuners()
Filters out tuners for components that do not exist anymore.
KI_PARAM_ERROR is a class used to hold a translatable error message and may be used when throwing exc...
Definition: ki_exception.h:45
wxToolBarToolBase * m_toolSettings
SIM_PLOT_FRAME(KIWAY *aKiway, wxWindow *aParent)
Constructor.
const BITMAP_OPAQUE zoom_in_xpm[1]
Definition: zoom_in.cpp:59