diff --git a/eeschema/dialogs/dialog_sim_format_value_base.cpp b/eeschema/dialogs/dialog_sim_format_value_base.cpp index 2e726aeb2e..535e4441a4 100644 --- a/eeschema/dialogs/dialog_sim_format_value_base.cpp +++ b/eeschema/dialogs/dialog_sim_format_value_base.cpp @@ -26,7 +26,7 @@ DIALOG_SIM_FORMAT_VALUE_BASE::DIALOG_SIM_FORMAT_VALUE_BASE( wxWindow* parent, wx m_precisionLabel->Wrap( -1 ); fgSizer->Add( m_precisionLabel, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); - m_precisionCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 10, 3 ); + m_precisionCtrl = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 1, 9, 3 ); fgSizer->Add( m_precisionCtrl, 0, wxALIGN_CENTER_VERTICAL|wxEXPAND|wxRIGHT|wxLEFT, 5 ); m_rangeLabel = new wxStaticText( this, wxID_ANY, _("Range:"), wxDefaultPosition, wxDefaultSize, 0 ); diff --git a/eeschema/dialogs/dialog_sim_format_value_base.fbp b/eeschema/dialogs/dialog_sim_format_value_base.fbp index 5b97d04412..f03f36629e 100644 --- a/eeschema/dialogs/dialog_sim_format_value_base.fbp +++ b/eeschema/dialogs/dialog_sim_format_value_base.fbp @@ -171,7 +171,7 @@ 0 wxID_ANY 3 - 10 + 9 0 diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 8e6d2b5c14..c0319033cf 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -1712,20 +1712,72 @@ bool SIM_PLOT_FRAME::LoadWorkbook( const wxString& aPath ) param = file.GetNextLine(); - #if 0 // no longer in use - if( param.IsEmpty() ) - { - DISPLAY_LOAD_ERROR( "Error loading workbook: Line %d is empty." ); - file.Close(); - - return false; - } - #endif - addTrace( name, (SIM_TRACE_TYPE) traceType ); + + TRACE* trace = GetCurrentPlot() ? GetCurrentPlot()->GetTrace( name ) : nullptr; + + if( version >= 4 && trace ) + { + auto readFormat = + []( SPICE_VALUE_FORMAT* format, const wxString& text ) + { + long val; + text.Left( 1 ).ToLong( &val ); + format->Precision = (int) val; + format->Range = text.Right( text.Length() - 1 ); + }; + + wxArrayString items = wxSplit( param, '|' ); + + for( const wxString& item : items ) + { + if( item.StartsWith( wxS( "rgb" ) ) ) + { + wxColour color; + color.Set( item ); + trace->SetTraceColour( color ); + } + else if( item.StartsWith( wxS( "cursor1" ) ) ) + { + wxArrayString parts = wxSplit( item, '.' ); + + if( parts.size() == 3 ) + { + readFormat( &m_cursorFormats[0][0], parts[1] ); + readFormat( &m_cursorFormats[0][1], parts[2] ); + GetCurrentPlot()->EnableCursor( name, 1, true ); + } + } + else if( item.StartsWith( wxS( "cursor2" ) ) ) + { + wxArrayString parts = wxSplit( item, '.' ); + + if( parts.size() == 3 ) + { + readFormat( &m_cursorFormats[1][0], parts[1] ); + readFormat( &m_cursorFormats[1][1], parts[2] ); + GetCurrentPlot()->EnableCursor( name, 2, true ); + } + } + else if( item.StartsWith( wxS( "cursorD" ) ) ) + { + wxArrayString parts = wxSplit( item, '.' ); + + if( parts.size() == 3 ) + { + readFormat( &m_cursorFormats[2][0], parts[1] ); + readFormat( &m_cursorFormats[2][1], parts[2] ); + } + } + } + } } } + updateSignalsGrid(); + wxCommandEvent dummy; + onCursorUpdate( dummy ); + file.Close(); wxFileName filename( aPath ); @@ -1759,7 +1811,7 @@ bool SIM_PLOT_FRAME::SaveWorkbook( const wxString& aPath ) file.Create(); } - file.AddLine( wxT( "version 3" ) ); + file.AddLine( wxT( "version 4" ) ); file.AddLine( wxString::Format( wxT( "%llu" ), m_workbook->GetPageCount() ) ); @@ -1806,7 +1858,37 @@ bool SIM_PLOT_FRAME::SaveWorkbook( const wxString& aPath ) { file.AddLine( wxString::Format( wxT( "%d" ), trace->GetType() ) ); file.AddLine( trace->GetName() ); - file.AddLine( trace->GetParam().IsEmpty() ? wxS( " " ) : trace->GetParam() ); + + wxString msg = COLOR4D( trace->GetTraceColour() ).ToCSSString(); + + if( trace->GetCursor( 1 ) ) + { + msg += wxString::Format( wxS( "|cursor1.%d%s.%d%s" ), + m_cursorFormats[0][0].Precision, + m_cursorFormats[0][0].Range, + m_cursorFormats[0][1].Precision, + m_cursorFormats[0][1].Range ); + } + + if( trace->GetCursor( 2 ) ) + { + msg += wxString::Format( wxS( "|cursor2.%d%s.%d%s" ), + m_cursorFormats[1][0].Precision, + m_cursorFormats[1][0].Range, + m_cursorFormats[1][1].Precision, + m_cursorFormats[1][1].Range ); + } + + if( trace->GetCursor( 1 ) || trace->GetCursor( 2 ) ) + { + msg += wxString::Format( wxS( "|cursorD.%d%s.%d%s" ), + m_cursorFormats[2][0].Precision, + m_cursorFormats[2][0].Range, + m_cursorFormats[2][1].Precision, + m_cursorFormats[2][1].Range ); + } + + file.AddLine( msg ); } } diff --git a/eeschema/sim/sim_plot_panel.h b/eeschema/sim/sim_plot_panel.h index 09af037d3e..efc847ce78 100644 --- a/eeschema/sim/sim_plot_panel.h +++ b/eeschema/sim/sim_plot_panel.h @@ -176,20 +176,10 @@ public: return m_traceColour; } - const wxString& GetParam() const - { - return m_param; - } - - protected: std::map m_cursors; // No ownership; the mpWindow owns the CURSORs SIM_TRACE_TYPE m_type; wxColour m_traceColour; - -private: - ///< Name of the signal parameter - wxString m_param; };