Save location of legend in worksheet.
Also provides a different cursor when over a legend (to make it clearer that you can drag it).
This commit is contained in:
parent
ec6d709929
commit
a14c017def
|
@ -1869,6 +1869,9 @@ void mpWindow::OnMouseMove( wxMouseEvent& event )
|
|||
{
|
||||
if( m_movingInfoLayer )
|
||||
{
|
||||
if( dynamic_cast<mpInfoLegend*>( m_movingInfoLayer ) )
|
||||
cursor = wxCURSOR_SIZING;
|
||||
else
|
||||
cursor = wxCURSOR_SIZEWE;
|
||||
|
||||
wxPoint moveVector( event.GetX() - m_mouseLClick.x, event.GetY() - m_mouseLClick.y );
|
||||
|
@ -1903,9 +1906,14 @@ void mpWindow::OnMouseMove( wxMouseEvent& event )
|
|||
mpInfoLayer* infoLayer = (mpInfoLayer*) layer;
|
||||
|
||||
if( infoLayer->Inside( event.GetPosition() ) )
|
||||
{
|
||||
if( dynamic_cast<mpInfoLegend*>( infoLayer ) )
|
||||
cursor = wxCURSOR_SIZING;
|
||||
else
|
||||
cursor = wxCURSOR_SIZEWE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if (m_coordTooltip) {
|
||||
* wxString toolTipContent;
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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 );
|
||||
|
@ -2154,6 +2150,24 @@ bool SIMULATOR_FRAME::LoadWorkbook( const wxString& aPath )
|
|||
for( const auto& [ plotPanel, traceInfoVector ] : traceInfo )
|
||||
{
|
||||
for( const auto& [ traceType, signalName, param ] : traceInfoVector )
|
||||
{
|
||||
if( traceType == SPT_UNKNOWN && signalName == wxS( "$LEGEND" ) )
|
||||
{
|
||||
wxArrayString coords = wxSplit( 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 );
|
||||
|
@ -2161,6 +2175,7 @@ bool SIMULATOR_FRAME::LoadWorkbook( const wxString& aPath )
|
|||
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() ) );
|
||||
|
|
Loading…
Reference in New Issue