diff --git a/common/widgets/mathplot.cpp b/common/widgets/mathplot.cpp index 0526ee1065..c139d6df7e 100644 --- a/common/widgets/mathplot.cpp +++ b/common/widgets/mathplot.cpp @@ -1869,7 +1869,10 @@ void mpWindow::OnMouseMove( wxMouseEvent& event ) { if( m_movingInfoLayer ) { - cursor = wxCURSOR_SIZEWE; + if( dynamic_cast( m_movingInfoLayer ) ) + cursor = wxCURSOR_SIZING; + else + cursor = wxCURSOR_SIZEWE; wxPoint moveVector( event.GetX() - m_mouseLClick.x, event.GetY() - m_mouseLClick.y ); m_movingInfoLayer->Move( moveVector ); @@ -1903,7 +1906,12 @@ void mpWindow::OnMouseMove( wxMouseEvent& event ) mpInfoLayer* infoLayer = (mpInfoLayer*) layer; if( infoLayer->Inside( event.GetPosition() ) ) - cursor = wxCURSOR_SIZEWE; + { + if( dynamic_cast( infoLayer ) ) + cursor = wxCURSOR_SIZING; + else + cursor = wxCURSOR_SIZEWE; + } } } diff --git a/eeschema/sim/sim_plot_panel.h b/eeschema/sim/sim_plot_panel.h index 00f9f08939..ec03c23750 100644 --- a/eeschema/sim/sim_plot_panel.h +++ b/eeschema/sim/sim_plot_panel.h @@ -266,6 +266,17 @@ public: return m_legend->IsVisible(); } + wxPoint GetLegendPosition() const + { + return m_legend->GetPosition(); + } + + void SetLegendPosition( const wxPoint& aPosition ) + { + m_legend->Move( aPosition ); + m_legend->UpdateReference(); + } + /** * Draw secondary signal traces (current or phase) with dotted lines */ diff --git a/eeschema/sim/simulator_frame.cpp b/eeschema/sim/simulator_frame.cpp index b54af307d0..457365477c 100644 --- a/eeschema/sim/simulator_frame.cpp +++ b/eeschema/sim/simulator_frame.cpp @@ -1985,10 +1985,6 @@ void SIMULATOR_FRAME::parseTraceParams( SIM_PLOT_PANEL* aPlotPanel, TRACE* aTrac { aPlotPanel->SetDottedSecondary( true ); } - else if( item == wxS( "showLegend" ) ) - { - aPlotPanel->ShowLegend( true ); - } else if( item == wxS( "hideGrid" ) ) { aPlotPanel->ShowGrid( false ); @@ -2155,11 +2151,30 @@ bool SIMULATOR_FRAME::LoadWorkbook( const wxString& aPath ) { for( const auto& [ traceType, signalName, param ] : traceInfoVector ) { - wxString vectorName = vectorNameFromSignalName( signalName, nullptr ); - TRACE* trace = plotPanel->AddTrace( vectorName, (int) traceType ); + if( traceType == SPT_UNKNOWN && signalName == wxS( "$LEGEND" ) ) + { + wxArrayString coords = wxSplit( param, ' ' ); - if( version >= 4 && trace ) - parseTraceParams( plotPanel, trace, signalName, param ); + if( coords.size() >= 2 ) + { + long x = 0; + long y = 0; + + coords[0].ToLong( &x ); + coords[1].ToLong( &y ); + plotPanel->SetLegendPosition( wxPoint( (int) x, (int) y ) ); + } + + plotPanel->ShowLegend( true ); + } + else + { + wxString vectorName = vectorNameFromSignalName( signalName, nullptr ); + TRACE* trace = plotPanel->AddTrace( vectorName, (int) traceType ); + + if( version >= 4 && trace ) + parseTraceParams( plotPanel, trace, signalName, param ); + } } plotPanel->UpdatePlotColors(); @@ -2283,7 +2298,12 @@ bool SIMULATOR_FRAME::SaveWorkbook( const wxString& aPath ) continue; } - file.AddLine( wxString::Format( wxT( "%llu" ), plotPanel->GetTraces().size() ) ); + size_t traceCount = plotPanel->GetTraces().size(); + + if( plotPanel->IsLegendShown() ) + traceCount++; + + file.AddLine( wxString::Format( wxT( "%llu" ), traceCount ) ); auto findSignalName = [&]( const wxString& aVectorName ) -> wxString @@ -2330,14 +2350,20 @@ bool SIMULATOR_FRAME::SaveWorkbook( const wxString& aPath ) if( plotPanel->GetDottedSecondary() ) msg += wxS( "|dottedSecondary" ); - if( plotPanel->IsLegendShown() ) - msg += wxS( "|showLegend" ); - if( !plotPanel->IsGridShown() ) msg += wxS( "|hideGrid" ); file.AddLine( msg ); } + + if( plotPanel->IsLegendShown() ) + { + file.AddLine( wxString::Format( wxT( "%d" ), SPT_UNKNOWN ) ); + file.AddLine( wxT( "$LEGEND" ) ); + file.AddLine( wxString::Format( wxT( "%d %d" ), + plotPanel->GetLegendPosition().x, + plotPanel->GetLegendPosition().y - 40 ) ); + } } file.AddLine( wxString::Format( wxT( "%llu" ), m_userDefinedSignals.size() ) );