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_FIELD )->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  wxString savePath = aPath;
960 
961  if( !savePath.Lower().EndsWith(".wbk") )
962  savePath += ".wbk";
963 
964  wxTextFile file( savePath );
965 
966  if( file.Exists() )
967  {
968  if( !file.Open() )
969  return false;
970 
971  file.Clear();
972  }
973  else
974  {
975  file.Create();
976  }
977 
978  file.AddLine( wxString::Format( "%llu", m_plots.size() ) );
979 
980  for( const auto& plot : m_plots )
981  {
982  if( plot.first )
983  {
984  file.AddLine( wxString::Format( "%d", plot.first->GetType() ) );
985  file.AddLine( plot.second.m_simCommand );
986  file.AddLine( wxString::Format( "%llu", plot.second.m_traces.size() ) );
987 
988  for( const auto& trace : plot.second.m_traces )
989  {
990  file.AddLine( wxString::Format( "%d", trace.second.GetType() ) );
991  file.AddLine( trace.second.GetName() );
992  file.AddLine( trace.second.GetParam() );
993  }
994  }
995  }
996 
997  bool res = file.Write();
998  file.Close();
999 
1000  return res;
1001 }
1002 
1003 
1005 {
1006  switch( aType )
1007  {
1008  case ST_AC:
1009  return SPT_LIN_FREQUENCY;
1011 
1012  case ST_DC:
1013  return SPT_SWEEP;
1014 
1015  case ST_TRANSIENT:
1016  return SPT_TIME;
1017 
1018  default:
1019  wxASSERT_MSG( false, "Unhandled simulation type" );
1020  return (SIM_PLOT_TYPE) 0;
1021  }
1022 }
1023 
1024 
1025 void SIM_PLOT_FRAME::menuNewPlot( wxCommandEvent& aEvent )
1026 {
1027  SIM_TYPE type = m_exporter->GetSimType();
1028 
1029  if( SIM_PANEL_BASE::IsPlottable( type ) )
1030  {
1031  SIM_PLOT_PANEL* prevPlot = CurrentPlot();
1032  SIM_PLOT_PANEL* newPlot = dynamic_cast<SIM_PLOT_PANEL*>( NewPlotPanel( type ) );
1033 
1034  // If the previous plot had the same type, copy the simulation command
1035  if( prevPlot )
1036  m_plots[newPlot].m_simCommand = m_plots[prevPlot].m_simCommand;
1037  }
1038 }
1039 
1040 
1041 void SIM_PLOT_FRAME::menuOpenWorkbook( wxCommandEvent& event )
1042 {
1043  wxFileDialog openDlg( this, _( "Open simulation workbook" ), m_savedWorkbooksPath, "",
1044  WorkbookFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
1045 
1046  if( openDlg.ShowModal() == wxID_CANCEL )
1047  return;
1048 
1049  m_savedWorkbooksPath = openDlg.GetDirectory();
1050 
1051  if( !loadWorkbook( openDlg.GetPath() ) )
1052  DisplayError( this, _( "There was an error while opening the workbook file" ) );
1053 }
1054 
1055 
1056 void SIM_PLOT_FRAME::menuSaveWorkbook( wxCommandEvent& event )
1057 {
1058  if( !CurrentPlot() )
1059  return;
1060 
1061  wxFileDialog saveDlg( this, _( "Save Simulation Workbook" ), m_savedWorkbooksPath, "",
1062  WorkbookFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1063 
1064  if( saveDlg.ShowModal() == wxID_CANCEL )
1065  return;
1066 
1067  m_savedWorkbooksPath = saveDlg.GetDirectory();
1068 
1069  if( !saveWorkbook( saveDlg.GetPath() ) )
1070  DisplayError( this, _( "There was an error while saving the workbook file" ) );
1071 }
1072 
1073 
1074 void SIM_PLOT_FRAME::menuSaveImage( wxCommandEvent& event )
1075 {
1076  if( !CurrentPlot() )
1077  return;
1078 
1079  wxFileDialog saveDlg( this, _( "Save Plot as Image" ), "", "",
1080  PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1081 
1082  if( saveDlg.ShowModal() == wxID_CANCEL )
1083  return;
1084 
1085  CurrentPlot()->GetPlotWin()->SaveScreenshot( saveDlg.GetPath(), wxBITMAP_TYPE_PNG );
1086 }
1087 
1088 
1089 void SIM_PLOT_FRAME::menuSaveCsv( wxCommandEvent& event )
1090 {
1091  if( !CurrentPlot() )
1092  return;
1093 
1094  const wxChar SEPARATOR = ';';
1095 
1096  wxFileDialog saveDlg( this, _( "Save Plot Data" ), "", "",
1097  CsvFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
1098 
1099  if( saveDlg.ShowModal() == wxID_CANCEL )
1100  return;
1101 
1102  wxFile out( saveDlg.GetPath(), wxFile::write );
1103  bool timeWritten = false;
1104 
1105  for( const auto& t : CurrentPlot()->GetTraces() )
1106  {
1107  const TRACE* trace = t.second;
1108 
1109  if( !timeWritten )
1110  {
1111  out.Write( wxString::Format( "Time%c", SEPARATOR ) );
1112 
1113  for( double v : trace->GetDataX() )
1114  out.Write( wxString::Format( "%f%c", v, SEPARATOR ) );
1115 
1116  out.Write( "\r\n" );
1117  timeWritten = true;
1118  }
1119 
1120  out.Write( wxString::Format( "%s%c", t.first, SEPARATOR ) );
1121 
1122  for( double v : trace->GetDataY() )
1123  out.Write( wxString::Format( "%f%c", v, SEPARATOR ) );
1124 
1125  out.Write( "\r\n" );
1126  }
1127 
1128  out.Close();
1129 }
1130 
1131 
1132 void SIM_PLOT_FRAME::menuZoomIn( wxCommandEvent& event )
1133 {
1134  if( CurrentPlot() )
1135  CurrentPlot()->GetPlotWin()->ZoomIn();
1136 }
1137 
1138 
1139 void SIM_PLOT_FRAME::menuZoomOut( wxCommandEvent& event )
1140 {
1141  if( CurrentPlot() )
1142  CurrentPlot()->GetPlotWin()->ZoomOut();
1143 }
1144 
1145 
1146 void SIM_PLOT_FRAME::menuZoomFit( wxCommandEvent& event )
1147 {
1148  if( CurrentPlot() )
1149  CurrentPlot()->GetPlotWin()->Fit();
1150 }
1151 
1152 
1153 void SIM_PLOT_FRAME::menuShowGrid( wxCommandEvent& event )
1154 {
1155  SIM_PLOT_PANEL* plot = CurrentPlot();
1156 
1157  if( plot )
1158  plot->ShowGrid( !plot->IsGridShown() );
1159 }
1160 
1161 
1162 void SIM_PLOT_FRAME::menuShowGridUpdate( wxUpdateUIEvent& event )
1163 {
1164  SIM_PLOT_PANEL* plot = CurrentPlot();
1165 
1166  event.Check( plot ? plot->IsGridShown() : false );
1167 }
1168 
1169 
1170 void SIM_PLOT_FRAME::menuShowLegend( wxCommandEvent& event )
1171 {
1172  SIM_PLOT_PANEL* plot = CurrentPlot();
1173 
1174  if( plot )
1175  plot->ShowLegend( !plot->IsLegendShown() );
1176 }
1177 
1178 
1179 void SIM_PLOT_FRAME::menuShowLegendUpdate( wxUpdateUIEvent& event )
1180 {
1181  SIM_PLOT_PANEL* plot = CurrentPlot();
1182  event.Check( plot ? plot->IsLegendShown() : false );
1183 }
1184 
1185 
1186 void SIM_PLOT_FRAME::menuShowDotted( wxCommandEvent& event )
1187 {
1188  SIM_PLOT_PANEL* plot = CurrentPlot();
1189 
1190  if( plot )
1191  plot->SetDottedCurrentPhase( !plot->GetDottedCurrentPhase() );
1192 }
1193 
1194 
1195 void SIM_PLOT_FRAME::menuShowDottedUpdate( wxUpdateUIEvent& event )
1196 {
1197  SIM_PLOT_PANEL* plot = CurrentPlot();
1198 
1199  event.Check( plot ? plot->GetDottedCurrentPhase() : false );
1200 }
1201 
1202 
1203 void SIM_PLOT_FRAME::menuWhiteBackground( wxCommandEvent& event )
1204 {
1206 
1207  // Rebuild the color list to plot traces
1209 
1210  // Now send changes to all SIM_PLOT_PANEL
1211  for( size_t page = 0; page < m_plotNotebook->GetPageCount(); page++ )
1212  {
1213  wxWindow* curPage = m_plotNotebook->GetPage( page );
1214 
1215  if( curPage == m_welcomePanel )
1216  continue;
1217 
1218  static_cast<SIM_PLOT_PANEL*>( curPage )->UpdatePlotColors();
1219  }
1220 }
1221 
1222 
1223 void SIM_PLOT_FRAME::onPlotClose( wxAuiNotebookEvent& event )
1224 {
1225  int idx = event.GetSelection();
1226 
1227  if( idx == wxNOT_FOUND )
1228  return;
1229 
1230  SIM_PANEL_BASE* plotPanel =
1231  dynamic_cast<SIM_PANEL_BASE*>( m_plotNotebook->GetPage( idx ) );
1232 
1233  m_plots.erase( plotPanel );
1234  updateSignalList();
1235  wxCommandEvent dummy;
1236  onCursorUpdate( dummy );
1237 }
1238 
1239 
1240 void SIM_PLOT_FRAME::onPlotChanged( wxAuiNotebookEvent& event )
1241 {
1242  updateSignalList();
1243  wxCommandEvent dummy;
1244  onCursorUpdate( dummy );
1245 }
1246 
1247 
1248 void SIM_PLOT_FRAME::onSignalDblClick( wxMouseEvent& event )
1249 {
1250  // Remove signal from the plot panel when double clicked
1251  long idx = m_signals->GetFocusedItem();
1252 
1253  if( idx != wxNOT_FOUND )
1254  removePlot( m_signals->GetItemText( idx, 0 ) );
1255 }
1256 
1257 
1258 void SIM_PLOT_FRAME::onSignalRClick( wxListEvent& event )
1259 {
1260  int idx = event.GetIndex();
1261 
1262  if( idx != wxNOT_FOUND )
1263  m_signals->Select( idx );
1264 
1265  idx = m_signals->GetFirstSelected();
1266 
1267  if( idx != wxNOT_FOUND )
1268  {
1269  const wxString& netName = m_signals->GetItemText( idx, 0 );
1270  SIGNAL_CONTEXT_MENU ctxMenu( netName, this );
1271  m_signals->PopupMenu( &ctxMenu );
1272  }
1273 }
1274 
1275 
1276 void SIM_PLOT_FRAME::onSimulate( wxCommandEvent& event )
1277 {
1278  if( IsSimulationRunning() )
1279  StopSimulation();
1280  else
1281  StartSimulation();
1282 }
1283 
1284 
1285 void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
1286 {
1287  SIM_PANEL_BASE* plotPanelWindow = currentPlotWindow();
1288 
1289  // Initial processing is required to e.g. display a list of power sources
1291 
1292  if( !m_exporter->ProcessNetlist( NET_ALL_FLAGS ) )
1293  {
1294  DisplayError( this, _( "There were errors during netlist export, aborted." ) );
1295  return;
1296  }
1297 
1298  if( !m_settingsDlg )
1299  m_settingsDlg = new DIALOG_SIM_SETTINGS( this );
1300 
1301  if( plotPanelWindow != m_welcomePanel )
1302  m_settingsDlg->SetSimCommand( m_plots[plotPanelWindow].m_simCommand );
1303 
1305 
1306  if( m_settingsDlg->ShowModal() == wxID_OK )
1307  {
1308  wxString newCommand = m_settingsDlg->GetSimCommand();
1309  SIM_TYPE newSimType = NETLIST_EXPORTER_PSPICE_SIM::CommandToSimType( newCommand );
1310 
1311  // If it is a new simulation type, open a new plot
1312  if( !plotPanelWindow || ( plotPanelWindow && plotPanelWindow->GetType() != newSimType ) )
1313  {
1314  plotPanelWindow = NewPlotPanel( newSimType );
1315  }
1316 
1317  m_plots[plotPanelWindow].m_simCommand = newCommand;
1318  }
1319 }
1320 
1321 
1322 void SIM_PLOT_FRAME::onAddSignal( wxCommandEvent& event )
1323 {
1324  SIM_PLOT_PANEL* plotPanel = CurrentPlot();
1325 
1326  if( !plotPanel || !m_exporter || plotPanel->GetType() != m_exporter->GetSimType() )
1327  {
1328  DisplayInfoMessage( this, _( "You need to run plot-providing simulation first." ) );
1329  return;
1330  }
1331 
1332  DIALOG_SIGNAL_LIST dialog( this, m_exporter.get() );
1333  dialog.ShowModal();
1334 }
1335 
1336 
1337 void SIM_PLOT_FRAME::onProbe( wxCommandEvent& event )
1338 {
1339  if( m_schematicFrame == NULL )
1340  return;
1341 
1343  m_schematicFrame->Raise();
1344 }
1345 
1346 
1347 void SIM_PLOT_FRAME::onTune( wxCommandEvent& event )
1348 {
1349  if( m_schematicFrame == NULL )
1350  return;
1351 
1353  m_schematicFrame->Raise();
1354 }
1355 
1356 void SIM_PLOT_FRAME::onShowNetlist( wxCommandEvent& event )
1357 {
1358  class NETLIST_VIEW_DIALOG : public wxDialog
1359  {
1360  public:
1361  enum
1362  {
1363  MARGIN_LINE_NUMBERS
1364  };
1365 
1366  void onClose( wxCloseEvent& evt )
1367  {
1368  EndModal( GetReturnCode() );
1369  }
1370 
1371  NETLIST_VIEW_DIALOG(wxWindow* parent, wxString source) :
1372  wxDialog(parent, wxID_ANY, "SPICE Netlist",
1373  wxDefaultPosition, wxSize(1500,900),
1374  wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
1375  {
1376  wxStyledTextCtrl* text = new wxStyledTextCtrl( this, wxID_ANY );
1377 
1378  text->SetMarginWidth( MARGIN_LINE_NUMBERS, 50 );
1379  text->StyleSetForeground( wxSTC_STYLE_LINENUMBER, wxColour( 75, 75, 75 ) );
1380  text->StyleSetBackground( wxSTC_STYLE_LINENUMBER, wxColour( 220, 220, 220 ) );
1381  text->SetMarginType( MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER );
1382 
1383  text->SetWrapMode( wxSTC_WRAP_WORD );
1384 
1385  text->SetText( source );
1386 
1387  text->StyleClearAll();
1388  text->SetLexer( wxSTC_LEX_SPICE );
1389 
1390  wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
1391  sizer->Add( text, 1, wxEXPAND );
1392  SetSizer( sizer );
1393 
1394  Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( NETLIST_VIEW_DIALOG::onClose ), NULL,
1395  this );
1396  }
1397  };
1398 
1399  if( m_schematicFrame == NULL || m_simulator == NULL )
1400  return;
1401 
1402  NETLIST_VIEW_DIALOG dlg( this, m_simulator->GetNetlist() );
1403  dlg.ShowModal();
1404 }
1405 
1406 
1408 {
1409  SaveSettings( config() );
1410 
1411  if( IsSimulationRunning() )
1412  m_simulator->Stop();
1413 
1414  // Cancel a running simProbe or simTune tool
1416 
1417  Destroy();
1418 }
1419 
1420 
1421 void SIM_PLOT_FRAME::onCursorUpdate( wxCommandEvent& event )
1422 {
1423  wxSize size = m_cursors->GetClientSize();
1424  SIM_PLOT_PANEL* plotPanel = CurrentPlot();
1425  m_cursors->ClearAll();
1426 
1427  if( !plotPanel )
1428  return;
1429 
1431  m_cursors->SetImageList(m_signalsIconColorList, wxIMAGE_LIST_SMALL);
1432 
1433  // Fill the signals listctrl
1434  m_cursors->AppendColumn( _( "Signal" ), wxLIST_FORMAT_LEFT, size.x / 2 );
1435  const long X_COL = m_cursors->AppendColumn( plotPanel->GetLabelX(), wxLIST_FORMAT_LEFT, size.x / 4 );
1436 
1437  wxString labelY1 = plotPanel->GetLabelY1();
1438  wxString labelY2 = plotPanel->GetLabelY2();
1439  wxString labelY;
1440 
1441  if( !labelY2.IsEmpty() )
1442  labelY = labelY1 + " / " + labelY2;
1443  else
1444  labelY = labelY1;
1445 
1446  const long Y_COL = m_cursors->AppendColumn( labelY, wxLIST_FORMAT_LEFT, size.x / 4 );
1447 
1448  // Update cursor values
1449  int itemidx = 0;
1450 
1451  for( const auto& trace : plotPanel->GetTraces() )
1452  {
1453  if( CURSOR* cursor = trace.second->GetCursor() )
1454  {
1455  // Find the right icon color in list.
1456  // It is the icon used in m_signals list for the same trace
1457  long iconColor = m_signals->FindItem( -1, trace.first );
1458 
1459  const wxRealPoint coords = cursor->GetCoords();
1460  long idx = m_cursors->InsertItem( itemidx++, trace.first, iconColor );
1461  m_cursors->SetItem( idx, X_COL, SPICE_VALUE( coords.x ).ToSpiceString() );
1462  m_cursors->SetItem( idx, Y_COL, SPICE_VALUE( coords.y ).ToSpiceString() );
1463  }
1464  }
1465 }
1466 
1467 
1468 void SIM_PLOT_FRAME::onSimStarted( wxCommandEvent& aEvent )
1469 {
1470  m_toolBar->SetToolNormalBitmap( ID_SIM_RUN, KiBitmap( sim_stop_xpm ) );
1471  SetCursor( wxCURSOR_ARROWWAIT );
1472 }
1473 
1474 
1475 void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent )
1476 {
1477  m_toolBar->SetToolNormalBitmap( ID_SIM_RUN, KiBitmap( sim_run_xpm ) );
1478  SetCursor( wxCURSOR_ARROW );
1479 
1480  SIM_TYPE simType = m_exporter->GetSimType();
1481 
1482  if( simType == ST_UNKNOWN )
1483  return;
1484 
1485  SIM_PANEL_BASE* plotPanelWindow = currentPlotWindow();
1486 
1487  if( !plotPanelWindow || plotPanelWindow->GetType() != simType )
1488  plotPanelWindow = NewPlotPanel( simType );
1489 
1490  if( IsSimulationRunning() )
1491  return;
1492 
1493  // If there are any signals plotted, update them
1494  if( SIM_PANEL_BASE::IsPlottable( simType ) )
1495  {
1496  TRACE_MAP& traceMap = m_plots[plotPanelWindow].m_traces;
1497  SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( plotPanelWindow );
1498 
1499  wxCHECK_RET( plotPanel, "not a SIM_PLOT_PANEL" );
1500 
1501  for( auto it = traceMap.begin(); it != traceMap.end(); /* iteration occurs in the loop */)
1502  {
1503  if( !updatePlot( it->second, plotPanel ) )
1504  {
1505  removePlot( it->first, false );
1506  it = traceMap.erase( it ); // remove a plot that does not exist anymore
1507  }
1508  else
1509  {
1510  ++it;
1511  }
1512  }
1513 
1514  updateSignalList();
1515  plotPanel->GetPlotWin()->UpdateAll();
1516  plotPanel->ResetScales();
1517  }
1518  else if( simType == ST_OP )
1519  {
1520  m_simConsole->AppendText( _( "\n\nSimulation results:\n\n" ) );
1521  m_simConsole->SetInsertionPointEnd();
1522 
1523  for( const auto& vec : m_simulator->AllPlots() )
1524  {
1525  double val = m_simulator->GetRealPlot( vec, 1 ).at( 0 );
1526 
1527  wxString outLine, signal;
1528  SIM_PLOT_TYPE type = m_exporter->VectorToSignal( vec, signal );
1529 
1530  const size_t tab = 25; //characters
1531  size_t padding = ( signal.length() < tab ) ? ( tab - signal.length() ) : 1;
1532 
1533  outLine.Printf( wxT( "%s%s" ), ( signal + wxT( ":" ) ).Pad( padding, wxUniChar( ' ' ) ),
1534  SPICE_VALUE( val ).ToSpiceString() );
1535 
1536  outLine.Append( type == SPT_CURRENT ? "A\n" : "V\n" );
1537 
1538  m_simConsole->AppendText( outLine );
1539  m_simConsole->SetInsertionPointEnd();
1540 
1541  // @todo display calculated values on the schematic
1542  }
1543  }
1544 }
1545 
1546 
1547 void SIM_PLOT_FRAME::onSimUpdate( wxCommandEvent& aEvent )
1548 {
1549  if( IsSimulationRunning() )
1550  StopSimulation();
1551 
1552  if( CurrentPlot() != m_lastSimPlot )
1553  {
1554  // We need to rerun simulation, as the simulator currently stores
1555  // results for another plot
1556  StartSimulation();
1557  }
1558  else
1559  {
1560  // Incremental update
1561  m_simConsole->Clear();
1562  // Do not export netlist, it is already stored in the simulator
1563  applyTuners();
1564  m_simulator->Run();
1565  }
1566 }
1567 
1568 
1569 void SIM_PLOT_FRAME::onSimReport( wxCommandEvent& aEvent )
1570 {
1571  m_simConsole->AppendText( aEvent.GetString() + "\n" );
1572  m_simConsole->SetInsertionPointEnd();
1573 }
1574 
1575 
1577  SIM_PLOT_FRAME* aPlotFrame )
1578  : m_signal( aSignal ), m_plotFrame( aPlotFrame )
1579 {
1581 
1582  AddMenuItem( this, HIDE_SIGNAL, _( "Hide Signal" ),
1583  _( "Erase the signal from plot screen" ),
1584  KiBitmap( delete_xpm ) );
1585 
1586  TRACE* trace = plot->GetTrace( m_signal );
1587 
1588  if( trace->HasCursor() )
1589  AddMenuItem( this, HIDE_CURSOR, _( "Hide Cursor" ), KiBitmap( pcb_target_xpm ) );
1590  else
1591  AddMenuItem( this, SHOW_CURSOR, _( "Show Cursor" ), KiBitmap( pcb_target_xpm ) );
1592 
1593  Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( SIGNAL_CONTEXT_MENU::onMenuEvent ), NULL, this );
1594 }
1595 
1596 
1598 {
1599  SIM_PLOT_PANEL* plot = m_plotFrame->CurrentPlot();
1600 
1601  switch( aEvent.GetId() )
1602  {
1603  case HIDE_SIGNAL:
1604  m_plotFrame->removePlot( m_signal );
1605  break;
1606 
1607  case SHOW_CURSOR:
1608  plot->EnableCursor( m_signal, true );
1609  break;
1610 
1611  case HIDE_CURSOR:
1612  plot->EnableCursor( m_signal, false );
1613  break;
1614  }
1615 }
1616 
1617 wxDEFINE_EVENT( EVT_SIM_UPDATE, wxCommandEvent );
1618 wxDEFINE_EVENT( EVT_SIM_REPORT, wxCommandEvent );
1619 
1620 wxDEFINE_EVENT( EVT_SIM_STARTED, wxCommandEvent );
1621 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:240
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:2274
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.
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
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
const BITMAP_OPAQUE pcb_target_xpm[1]
SEVERITY
Definition: ui_common.h:81
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:234
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:24
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:141
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
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:102
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:122
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:2748
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:59
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:82
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:207
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:345
#define ID_MENU_SHOW_NETLIST
wxString GetLabelY2() const
static TOOL_ACTION simTune
Definition: ee_actions.h:212
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:2217
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:19
const BITMAP_OPAQUE export_xpm[1]
Definition: export.cpp:71
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:476
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)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
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:2012
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:59
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:79
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:211
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:76
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:2978
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:268
Field Reference of part, i.e. "IC21".
STRING_FORMATTER implements OUTPUTFORMATTER to a memory buffer.
Definition: richio.h:446
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:133
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:46
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:47