KiCad PCB EDA Suite
Loading...
Searching...
No Matches
simulator_control.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
21
22#define wxUSE_BASE64 1
23#include <wx/base64.h>
24
25#include <wx/ffile.h>
26#include <wx/filedlg.h>
27#include <wx_filename.h>
28#include <kiplatform/ui.h>
29#include <wx/stc/stc.h>
30
31#include <kiway.h>
32#include <confirm.h>
36#include <sch_edit_frame.h>
37#include <sim/simulator_frame.h>
38#include <sim/sim_plot_tab.h>
39#include <tool/tool_manager.h>
40#include <tools/sch_actions.h>
41#include <scintilla_tricks.h>
44#include <wx/clipbrd.h>
45#include <wx/dataobj.h>
46#include <wx/mstream.h>
47#include <richio.h>
48#include <string_utils.h>
49
50
52{
54 return true;
55}
56
57
59{
61
63 {
64 m_schematicFrame = m_simulatorFrame->GetSchematicFrame();
65 m_circuitModel = m_simulatorFrame->GetCircuitModel();
66 m_simulator = m_simulatorFrame->GetSimulator();
67 }
68}
69
70
72{
75
77
78 if( reporter.HasMessageOfSeverity( RPT_SEVERITY_UNDEFINED | RPT_SEVERITY_ERROR ) )
79 {
80 DisplayErrorMessage( m_simulatorFrame, _( "Errors during netlist generation." ), reporter.GetMessages() );
81 }
82 else if( reporter.HasMessageOfSeverity( RPT_SEVERITY_WARNING ) )
83 {
84 DisplayInfoMessage( m_simulatorFrame, _( "Warnings during netlist generation." ), reporter.GetMessages() );
85 }
86
87 dlg.SetSimCommand( wxS( "*" ) );
89
90 if( dlg.ShowModal() == wxID_OK )
91 {
92 SIM_TAB* tab = m_simulatorFrame->NewSimTab( dlg.GetSimCommand() );
93 dlg.ApplySettings( tab );
94 m_simulatorFrame->OnModify();
95 }
96
97 return 0;
98}
99
100
102{
103 wxFileDialog openDlg( m_simulatorFrame, _( "Open Simulation Workbook" ), getDefaultPath(), "",
104 FILEEXT::WorkbookFileWildcard(), wxFD_OPEN | wxFD_FILE_MUST_EXIST );
105
107
108 if( openDlg.ShowModal() == wxID_CANCEL )
109 return -1;
110
111 m_simulatorFrame->LoadWorkbook( openDlg.GetPath() );
112 return 0;
113}
114
115
117{
118 wxFileName filename = m_simulator->Settings()->GetWorkbookFilename();
119
120 if( filename.GetName().IsEmpty() )
121 {
122 if( m_simulatorFrame->Prj().GetProjectName().IsEmpty() )
123 {
124 filename.SetName( _( "noname" ) );
125 filename.SetExt( FILEEXT::WorkbookFileExtension );
126 }
127 else
128 {
129 filename.SetName( m_simulatorFrame->Prj().GetProjectName() );
130 filename.SetExt( FILEEXT::WorkbookFileExtension );
131 }
132 }
133
134 return filename.GetFullName();
135}
136
137
139{
140 wxFileName path = m_simulator->Settings()->GetWorkbookFilename();
141
142 path.Normalize( FN_NORMALIZE_FLAGS | wxPATH_NORM_ENV_VARS, m_simulatorFrame->Prj().GetProjectPath() );
143 return path.GetPath();
144}
145
146
148{
149 wxString filename;
150
151 if( aEvent.IsAction( &SCH_ACTIONS::saveWorkbook ) )
152 filename = m_simulator->Settings()->GetWorkbookFilename();
153
154 if( filename.IsEmpty() )
155 {
156 wxFileDialog saveAsDlg( m_simulatorFrame, _( "Save Simulation Workbook As" ), getDefaultPath(),
158 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
159
161
162 if( saveAsDlg.ShowModal() == wxID_CANCEL )
163 return -1;
164
165 filename = saveAsDlg.GetPath();
166 }
167
168 m_simulatorFrame->SaveWorkbook( m_simulatorFrame->Prj().AbsolutePath( filename ) );
169 return 0;
170}
171
172
174{
175 if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
176 {
177 wxFileDialog saveDlg( m_simulatorFrame, _( "Save Plot as Image" ), "", "", FILEEXT::PngFileWildcard(),
178 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
179
181
182 if( saveDlg.ShowModal() == wxID_CANCEL )
183 return -1;
184
185 wxImage screenImage;
186 plotTab->GetPlotWin()->SaveScreenshot( screenImage );
187 screenImage.SaveFile( saveDlg.GetPath(), wxBITMAP_TYPE_PNG );
188 }
189
190 return 0;
191}
192
193
195{
196 if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
197 {
198 wxImage screenImage;
199 plotTab->GetPlotWin()->SaveScreenshot( screenImage );
200
201 if( wxTheClipboard->Open() )
202 {
203 wxBitmap bm( screenImage );
204
205 wxTheClipboard->SetData( new wxBitmapDataObject( bm ) );
206 wxTheClipboard->Flush(); // Allow data to be available after closing KiCad
207 wxTheClipboard->Close();
208 }
209 }
210
211 return 0;
212}
213
214
216{
217 if( m_schematicFrame == nullptr )
218 return -1;
219
220 if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
221 {
222 wxWindow* blocking_dialog = m_schematicFrame->Kiway().GetBlockingDialog();
223
224 if( blocking_dialog )
225 blocking_dialog->Close( true );
226
227 wxImage screenImage;
228 plotTab->GetPlotWin()->SaveScreenshot( screenImage );
229
230 if( wxTheClipboard->Open() )
231 {
232 // Build a PNG bitmap:
233 wxMemoryOutputStream stream;
234 screenImage.SaveFile( stream, wxBITMAP_TYPE_PNG );
235 stream.Close();
236
237 // Create a SCH_BITMAP data string
238 wxString string;
239 string << "(image (at 0 0)\n";
240 string << " (data\n";
241
242 wxMemoryBuffer buff;
243 buff.GetWriteBuf( stream.GetLength() );
244 stream.CopyTo( buff.GetData(), stream.GetLength() );
245 buff.SetDataLen( stream.GetLength() );
246
247 wxString out;
248 out << wxBase64Encode( buff );
249
250#define MIME_BASE64_LENGTH 76
251 size_t first = 0;
252
253 while( first < out.Length() )
254 {
255 string << " \"" << TO_UTF8( out( first, MIME_BASE64_LENGTH ) );
256 string << "\"\n";
257 first += MIME_BASE64_LENGTH;
258 }
259 string << " )\n)\n";
260
261 wxTheClipboard->SetData( new wxTextDataObject( string ) );
262 wxTheClipboard->Close();
263
264 m_schematicFrame->GetToolManager()->PostAction( ACTIONS::paste );
265 m_schematicFrame->Raise();
266 }
267 }
268
269 return 0;
270}
271
272
274{
275 return m_simulatorFrame->GetCurrentSimTab();
276}
277
278
280{
281 if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
282 {
283 const wxChar SEPARATOR = ';';
284
285 wxFileDialog saveDlg( m_simulatorFrame, _( "Save Plot Data" ), "", "", FILEEXT::CsvFileWildcard(),
286 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
287
289
290 if( saveDlg.ShowModal() == wxID_CANCEL )
291 return -1;
292
293 wxFFile out( saveDlg.GetPath(), "wb" );
294
295 std::map<wxString, TRACE*> traces = plotTab->GetTraces();
296
297 if( traces.size() == 0 )
298 return -1;
299
300 SIM_TYPE simType = plotTab->GetSimType();
301
302 if( plotTab->IsSmithMode() )
303 {
304 // smith traces hold Re/Im of the reflection coefficient, frequency lives beside them
305 std::vector<SMITH_TRACE*> smithTraces;
306
307 for( const auto& [name, trace] : traces )
308 {
309 if( SMITH_TRACE* smithTrace = dynamic_cast<SMITH_TRACE*>( trace ) )
310 smithTraces.push_back( smithTrace );
311 }
312
313 if( smithTraces.empty() )
314 return -1;
315
316 const std::vector<double>& freqs = smithTraces[0]->GetFrequencies();
317
318 out.Write( wxString::Format( wxT( "%s%c" ), wxS( "frequency" ), SEPARATOR ) );
319
320 for( SMITH_TRACE* trace : smithTraces )
321 {
322 out.Write( wxString::Format( wxT( "%s Re%c%s Im%c" ), trace->GetDisplayName(), SEPARATOR,
323 trace->GetDisplayName(), SEPARATOR ) );
324 }
325
326 out.Write( wxS( "\r\n" ) );
327
328 for( std::size_t curRow = 0; curRow < freqs.size(); curRow++ )
329 {
330 out.Write( wxString::Format( wxT( "%g%c" ), freqs[curRow], SEPARATOR ) );
331
332 for( SMITH_TRACE* trace : smithTraces )
333 {
334 double re = curRow < trace->GetDataX().size() ? trace->GetDataX()[curRow] : 0.0;
335 double im = curRow < trace->GetDataY().size() ? trace->GetDataY()[curRow] : 0.0;
336
337 out.Write( wxString::Format( wxT( "%g%c%g%c" ), re, SEPARATOR, im, SEPARATOR ) );
338 }
339
340 out.Write( wxS( "\r\n" ) );
341 }
342
343 out.Close();
344 return 0;
345 }
346
347 std::size_t rowCount = traces.begin()->second->GetDataX().size();
348
349 // write column header names on the first row
350 wxString xAxisName( m_simulator->GetXAxis( simType ) );
351 out.Write( wxString::Format( wxT( "%s%c" ), xAxisName, SEPARATOR ) );
352
353 for( const auto& [name, trace] : traces )
354 out.Write( wxString::Format( wxT( "%s%c" ), trace->GetDisplayName(), SEPARATOR ) );
355
356 out.Write( wxS( "\r\n" ) );
357
358 // write each row's numerical value
359 for( std::size_t curRow = 0; curRow < rowCount; curRow++ )
360 {
361 double xAxisValue = traces.begin()->second->GetDataX().at( curRow );
362 out.Write( wxString::Format( wxT( "%g%c" ), xAxisValue, SEPARATOR ) );
363
364 for( const auto& [name, trace] : traces )
365 {
366 double yAxisValue = trace->GetDataY().at( curRow );
367 out.Write( wxString::Format( wxT( "%g%c" ), yAxisValue, SEPARATOR ) );
368 }
369
370 out.Write( wxS( "\r\n" ) );
371 }
372
373 out.Close();
374 }
375
376 return 0;
377}
378
379
381{
382 m_simulatorFrame->Close();
383 return 0;
384}
385
386
388{
389 if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
390 {
391 // The X axis is shared (kept in sync) across all of a tab's views, so horizontal zoom
392 // only needs to be applied to the default view -- its OnXViewChanged() propagates the new
393 // X range to the others. The Y axes are independent, so vertical zoom (and zoom-to-fit's
394 // Y component) must be applied to every view, or only the default view would rescale.
395 SIM_VIEW* defaultView = plotTab->GetDefaultView();
396 const std::vector<SIM_VIEW*>& views = plotTab->GetViews();
397
398 if( !defaultView )
399 return 0;
400
401 if( plotTab->IsSmithMode() )
402 {
403 // the chart is drawn from the Smith view, not the hidden axes
404 wxPoint center( defaultView->GetScrX() / 2, defaultView->GetScrY() / 2 );
405
406 if( aEvent.IsAction( &ACTIONS::zoomInCenter ) )
407 {
408 plotTab->SmithZoomAt( center, 1.5 );
409 }
410 else if( aEvent.IsAction( &ACTIONS::zoomOutCenter ) )
411 {
412 plotTab->SmithZoomAt( center, 1.0 / 1.5 );
413 }
414 else if( aEvent.IsAction( &ACTIONS::zoomFitScreen ) )
415 {
416 plotTab->ResetSmithView();
417 }
418
419 return 0;
420 }
421
422 if( aEvent.IsAction( &ACTIONS::zoomInCenter ) )
423 {
424 defaultView->ZoomIn(); // both axes on the default view; its X range syncs to the others
425
426 for( SIM_VIEW* view : views )
427 {
428 if( view != defaultView )
429 view->ZoomIn( wxDefaultPosition, mpWindow::zoomIncrementalFactor, wxVERTICAL );
430 }
431 }
432 else if( aEvent.IsAction( &ACTIONS::zoomOutCenter ) )
433 {
434 defaultView->ZoomOut();
435
436 for( SIM_VIEW* view : views )
437 {
438 if( view != defaultView )
439 view->ZoomOut( wxDefaultPosition, mpWindow::zoomIncrementalFactor, wxVERTICAL );
440 }
441 }
442 else if( aEvent.IsAction( &ACTIONS::zoomInHorizontally ) )
443 {
444 defaultView->ZoomIn( wxDefaultPosition, mpWindow::zoomIncrementalFactor, wxHORIZONTAL );
445 }
446 else if( aEvent.IsAction( &ACTIONS::zoomOutHorizontally ) )
447 {
448 defaultView->ZoomOut( wxDefaultPosition, mpWindow::zoomIncrementalFactor, wxHORIZONTAL );
449 }
450 else if( aEvent.IsAction( &ACTIONS::zoomInVertically ) )
451 {
452 for( SIM_VIEW* view : views )
453 view->ZoomIn( wxDefaultPosition, mpWindow::zoomIncrementalFactor, wxVERTICAL );
454 }
455 else if( aEvent.IsAction( &ACTIONS::zoomOutVertically ) )
456 {
457 for( SIM_VIEW* view : views )
458 view->ZoomOut( wxDefaultPosition, mpWindow::zoomIncrementalFactor, wxVERTICAL );
459 }
460 else if( aEvent.IsAction( &ACTIONS::zoomFitScreen ) )
461 {
462 wxCommandEvent dummy;
463
464 for( SIM_VIEW* view : views )
465 view->OnFit( dummy );
466 }
467 }
468
469 return 0;
470}
471
472
474{
475 if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
476 {
477 // the Smith view keeps no zoom history, and the hidden axes must not move
478 if( !plotTab->IsSmithMode() )
479 plotTab->GetPlotWin()->ZoomUndo();
480 }
481
482 return 0;
483}
484
485
487{
488 if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
489 {
490 if( !plotTab->IsSmithMode() )
491 plotTab->GetPlotWin()->ZoomRedo();
492 }
493
494 return 0;
495}
496
497
499{
500 if( m_simulatorFrame )
501 m_simulatorFrame->ToggleSimConsole();
502
503 return 0;
504}
505
506
508{
509 if( m_simulatorFrame )
510 m_simulatorFrame->ToggleSimSidePanel();
511
512 return 0;
513}
514
515
517{
518 if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
519 {
520 plotTab->ShowGrid( !plotTab->IsGridShown() );
521 m_simulatorFrame->OnModify();
522 }
523
524 return 0;
525}
526
527
529{
530 if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
531 {
532 plotTab->ShowLegend( !plotTab->IsLegendShown() );
533 m_simulatorFrame->OnModify();
534 }
535
536 return 0;
537}
538
539
541{
542 if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
543 {
544 plotTab->SetDottedSecondary( !plotTab->GetDottedSecondary() );
545 m_simulatorFrame->OnModify();
546 }
547
548 return 0;
549}
550
551
553{
554 m_simulatorFrame->ToggleSmithChart();
555 return 0;
556}
557
558
560{
561 m_simulatorFrame->ToggleDarkModePlots();
562 return 0;
563}
564
565
567{
568 m_simulatorFrame->EditAnalysis();
569 return 0;
570}
571
572
574{
575 if( m_simulator->IsRunning() )
576 {
577 m_simulator->Stop();
578 return 0;
579 }
580
581 if( !getCurrentSimTab() )
582 NewAnalysisTab( aEvent );
583
584 if( !getCurrentSimTab() )
585 return 0;
586
587 m_simulatorFrame->StartSimulation();
588
589 return 0;
590}
591
592
594{
595 if( m_schematicFrame == nullptr )
596 return -1;
597
598 wxWindow* blocking_dialog = m_schematicFrame->Kiway().GetBlockingDialog();
599
600 if( blocking_dialog )
601 blocking_dialog->Close( true );
602
603 m_schematicFrame->GetToolManager()->PostAction( SCH_ACTIONS::simProbe );
604 m_schematicFrame->Raise();
605
606 return 0;
607}
608
609
611{
612 if( m_schematicFrame == nullptr )
613 return -1;
614
615 wxWindow* blocking_dialog = m_schematicFrame->Kiway().GetBlockingDialog();
616
617 if( blocking_dialog )
618 blocking_dialog->Close( true );
619
620 m_schematicFrame->GetToolManager()->PostAction( SCH_ACTIONS::simTune );
621 m_schematicFrame->Raise();
622
623 return 0;
624}
625
626
628{
629public:
630 enum
631 {
633 };
634
635 void onClose( wxCloseEvent& evt )
636 {
637 wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
638 }
639
640 NETLIST_VIEW_DIALOG( wxWindow* parent ) :
641 DIALOG_SHIM( parent, wxID_ANY, _( "SPICE Netlist" ), wxDefaultPosition, wxSize( 800, 800 ),
642 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
643 m_textCtrl( nullptr ),
644 m_reporter( nullptr )
645 {
646 m_splitter = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
647 wxSP_LIVE_UPDATE | wxSP_NOBORDER | wxSP_3DSASH );
648
649 //Avoid the splitter window being assigned as the Parent to additional windows
650 m_splitter->SetExtraStyle( wxWS_EX_TRANSIENT );
651
652 m_textCtrl = new wxStyledTextCtrl( m_splitter, wxID_ANY );
653
654 m_textCtrl->SetMarginWidth( MARGIN_LINE_NUMBERS, 50 );
655 m_textCtrl->StyleSetForeground( wxSTC_STYLE_LINENUMBER, wxColour( 75, 75, 75 ) );
656 m_textCtrl->StyleSetBackground( wxSTC_STYLE_LINENUMBER, wxColour( 220, 220, 220 ) );
657 m_textCtrl->SetMarginType( MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER );
658
659 wxFont fixedFont = KIUI::GetMonospacedUIFont();
660
661 for( int i = 0; i < wxSTC_STYLE_MAX; ++i )
662 m_textCtrl->StyleSetFont( i, fixedFont );
663
664 m_textCtrl->StyleClearAll(); // Addresses a bug in wx3.0 where styles are not correctly set
665
666 m_textCtrl->SetWrapMode( wxSTC_WRAP_WORD );
667 m_textCtrl->SetLexer( wxSTC_LEX_SPICE );
668 m_textCtrl->SetMinSize( wxSize( 40, 40 ) );
669 m_textCtrl->SetSize( wxSize( 40, 40 ) );
670
671 m_reporter = new WX_HTML_REPORT_BOX( m_splitter, wxID_ANY );
672 m_reporter->SetMinSize( wxSize( 40, 40 ) );
673 m_reporter->SetSize( wxSize( 40, 40 ) );
674
675 m_splitter->SetMinimumPaneSize( 40 );
676 m_splitter->SetSashPosition( 760 );
677 m_splitter->SetSashGravity( 0.9 );
678 m_splitter->SplitHorizontally( m_textCtrl, m_reporter );
679
680 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
681 sizer->Add( m_splitter, 1, wxEXPAND | wxALL, 5 );
682 SetSizer( sizer );
683 Layout();
684
685 Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( NETLIST_VIEW_DIALOG::onClose ), nullptr, this );
686
687 m_scintillaTricks = std::make_unique<SCINTILLA_TRICKS>( m_textCtrl, wxT( "{}" ), false );
688
690 }
691
692 void SetNetlist( const wxString& aSource )
693 {
694 m_textCtrl->SetText( aSource );
695 m_textCtrl->SetEditable( false );
696
697 m_reporter->Flush();
698 }
699
701
702private:
703 wxSplitterWindow* m_splitter;
704 wxStyledTextCtrl* m_textCtrl;
706
707 std::unique_ptr<SCINTILLA_TRICKS> m_scintillaTricks;
708};
709
710
712{
713 std::map<int, wxString> userSignals = m_simulatorFrame->UserDefinedSignals();
714
716
717 // QuasiModal required for syntax help and Scintilla auto-complete
718 if( dlg.ShowQuasiModal() == wxID_OK )
719 m_simulatorFrame->SetUserDefinedSignals( userSignals );
720
721 return 0;
722}
723
724
726{
727 if( m_schematicFrame == nullptr || m_simulator == nullptr )
728 return -1;
729
730 STRING_FORMATTER formatter;
732
733 m_circuitModel->GetNetlist( m_simulatorFrame->GetCurrentSimCommand(), m_simulatorFrame->GetCurrentOptions(),
734 &formatter, *dlg.GetReporter() );
735
736 dlg.SetNetlist( wxString( formatter.GetString() ) );
737 dlg.ShowModal();
738
739 return 0;
740}
741
742
744{
745 // clang-format off
754
757
772
778
781 // clang-format on
782}
const char * name
static TOOL_ACTION toggleGrid
Definition actions.h:194
static TOOL_ACTION paste
Definition actions.h:76
static TOOL_ACTION zoomOutCenter
Definition actions.h:132
static TOOL_ACTION zoomRedo
Definition actions.h:144
static TOOL_ACTION zoomOutHorizontally
Definition actions.h:134
static TOOL_ACTION zoomOutVertically
Definition actions.h:136
static TOOL_ACTION zoomInHorizontally
Definition actions.h:133
static TOOL_ACTION zoomFitScreen
Definition actions.h:138
static TOOL_ACTION zoomInCenter
Definition actions.h:131
static TOOL_ACTION zoomInVertically
Definition actions.h:135
static TOOL_ACTION zoomUndo
Definition actions.h:143
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
DIALOG_SHIM(wxWindow *aParent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE|wxRESIZE_BORDER, const wxString &name=wxDialogNameStr)
int ShowModal() override
void SetSimCommand(const wxString &aCommand)
void ApplySettings(SIM_TAB *aTab)
void SetSimOptions(int aOptions)
const wxString & GetSimCommand() const
WX_HTML_REPORT_BOX * m_reporter
void SetNetlist(const wxString &aSource)
std::unique_ptr< SCINTILLA_TRICKS > m_scintillaTricks
void onClose(wxCloseEvent &evt)
wxStyledTextCtrl * m_textCtrl
NETLIST_VIEW_DIALOG(wxWindow *parent)
wxSplitterWindow * m_splitter
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
static TOOL_ACTION toggleSimConsole
static TOOL_ACTION exportPlotToClipboard
static TOOL_ACTION saveWorkbookAs
static TOOL_ACTION toggleSimSidePanel
static TOOL_ACTION exportPlotAsCSV
static TOOL_ACTION simAnalysisProperties
static TOOL_ACTION toggleSmithChart
static TOOL_ACTION toggleDottedSecondary
static TOOL_ACTION simTune
static TOOL_ACTION toggleDarkModePlots
static TOOL_ACTION exportPlotAsPNG
static TOOL_ACTION exportPlotToSchematic
static TOOL_ACTION runSimulation
static TOOL_ACTION editUserDefinedSignals
static TOOL_ACTION newAnalysisTab
static TOOL_ACTION simProbe
static TOOL_ACTION showNetlist
static TOOL_ACTION openWorkbook
static TOOL_ACTION saveWorkbook
static TOOL_ACTION toggleLegend
static TOOL_ACTION stopSimulation
int ExportPlotAsPNG(const TOOL_EVENT &aEvent)
wxString getDefaultPath()
Return the default path to be used in file browser dialog.
SCH_EDIT_FRAME * m_schematicFrame
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int ToggleLegend(const TOOL_EVENT &aEvent)
int RedoZoom(const TOOL_EVENT &aEvent)
int ShowNetlist(const TOOL_EVENT &aEvent)
int ExportPlotToClipboard(const TOOL_EVENT &aEvent)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
int ToggleDarkModePlots(const TOOL_EVENT &aEvent)
int Tune(const TOOL_EVENT &aEvent)
wxString getDefaultFilename()
Return the default filename (with extension) to be used in file browser dialog.
SIMULATOR_FRAME * m_simulatorFrame
bool Init() override
Init() is called once upon a registration of the tool.
int SaveWorkbook(const TOOL_EVENT &aEvent)
int RunSimulation(const TOOL_EVENT &aEvent)
SIM_TAB * getCurrentSimTab()
Set up handlers for various events.
int OpenWorkbook(const TOOL_EVENT &aEvent)
int ToggleSmithChart(const TOOL_EVENT &aEvent)
int EditUserDefinedSignals(const TOOL_EVENT &aEvent)
std::shared_ptr< SPICE_CIRCUIT_MODEL > m_circuitModel
int ToggleGrid(const TOOL_EVENT &aEvent)
int Zoom(const TOOL_EVENT &aEvent)
int EditAnalysisTab(const TOOL_EVENT &aEvent)
int ToggleSimConsolePanel(const TOOL_EVENT &aEvent)
int ToggleDottedSecondary(const TOOL_EVENT &aEvent)
std::shared_ptr< SPICE_SIMULATOR > m_simulator
int ExportPlotAsCSV(const TOOL_EVENT &aEvent)
int UndoZoom(const TOOL_EVENT &aEvent)
int ExportPlotToSchematic(const TOOL_EVENT &aEvent)
int Probe(const TOOL_EVENT &aEvent)
int ToggleSimSidePanel(const TOOL_EVENT &aEvent)
int NewAnalysisTab(const TOOL_EVENT &aEvent)
int Close(const TOOL_EVENT &aEvent)
A single stacked plot area within a SIM_PLOT_TAB.
Cursor that snaps along a Smith chart locus, keyed by frequency.
Implement an OUTPUTFORMATTER to a memory buffer.
Definition richio.h:430
const std::string & GetString()
Definition richio.h:453
T * getEditFrame() const
Return the application window object, casted to requested user type.
Definition tool_base.h:182
RESET_REASON
Determine the reason of reset for a tool.
Definition tool_base.h:74
@ MODEL_RELOAD
Model changes (the sheet for a schematic)
Definition tool_base.h:76
Generic, UI-independent tool event.
Definition tool_event.h:167
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
A slimmed down version of WX_HTML_REPORT_PANEL.
A wrapper for reporting to a wxString object.
Definition reporter.h:242
int GetScrX() const
Get current view's X dimension in device context units.
Definition mathplot.h:1074
int GetScrY() const
Get current view's Y dimension in device context units.
Definition mathplot.h:1083
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition mathplot.h:1238
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
Definition confirm.cpp:245
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition confirm.cpp:217
This file is part of the common library.
#define _(s)
void Reset() override
static const std::string WorkbookFileExtension
static wxString PngFileWildcard()
static wxString CsvFileWildcard()
static wxString WorkbookFileWildcard()
void AllowNetworkFileSystems(wxDialog *aDialog)
Configure a file dialog to show network and virtual file systems.
Definition wxgtk/ui.cpp:521
KICOMMON_API wxFont GetMonospacedUIFont(int aRelativeSize=0)
Definition ui_common.cpp:93
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_ERROR
@ RPT_SEVERITY_UNDEFINED
SIM_TYPE
< Possible simulation types
Definition sim_types.h:31
#define MIME_BASE64_LENGTH
std::vector< FAB_LAYER_COLOR > dummy
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
std::string path
IbisParser parser & reporter
VECTOR2I center
Definition of file extensions used in Kicad.
#define SEPARATOR
#define FN_NORMALIZE_FLAGS
Default flags to pass to wxFileName::Normalize().
Definition wx_filename.h:35