Save cursor positions in sim workbook.
This commit is contained in:
parent
83dd06e5d1
commit
1e756dbdd8
|
@ -33,7 +33,6 @@
|
||||||
|
|
||||||
#include <widgets/mathplot.h>
|
#include <widgets/mathplot.h>
|
||||||
#include <wx/graphics.h>
|
#include <wx/graphics.h>
|
||||||
#include <wx/module.h>
|
|
||||||
#include <wx/image.h>
|
#include <wx/image.h>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
@ -1717,11 +1716,8 @@ mpWindow::~mpWindow()
|
||||||
// Free all the layers:
|
// Free all the layers:
|
||||||
DelAllLayers( true, false );
|
DelAllLayers( true, false );
|
||||||
|
|
||||||
if( m_buff_bmp )
|
delete m_buff_bmp;
|
||||||
{
|
m_buff_bmp = nullptr;
|
||||||
delete m_buff_bmp;
|
|
||||||
m_buff_bmp = NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2189,8 +2185,8 @@ void mpWindow::ZoomOut( const wxPoint& centerPoint, double zoomFactor )
|
||||||
m_desiredYmax = m_posY;
|
m_desiredYmax = m_posY;
|
||||||
m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
|
m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
|
||||||
|
|
||||||
if( !CheckXLimits( m_desiredXmax,
|
if( !CheckXLimits( m_desiredXmax, m_desiredXmin )
|
||||||
m_desiredXmin ) || !CheckYLimits( m_desiredYmax, m_desiredYmin ) )
|
|| !CheckYLimits( m_desiredYmax, m_desiredYmin ) )
|
||||||
{
|
{
|
||||||
Fit();
|
Fit();
|
||||||
}
|
}
|
||||||
|
@ -2286,7 +2282,7 @@ void mpWindow::OnSize( wxSizeEvent& WXUNUSED( event ) )
|
||||||
|
|
||||||
bool mpWindow::AddLayer( mpLayer* layer, bool refreshDisplay )
|
bool mpWindow::AddLayer( mpLayer* layer, bool refreshDisplay )
|
||||||
{
|
{
|
||||||
if( layer != NULL )
|
if( layer )
|
||||||
{
|
{
|
||||||
m_layers.push_back( layer );
|
m_layers.push_back( layer );
|
||||||
|
|
||||||
|
@ -2296,14 +2292,11 @@ bool mpWindow::AddLayer( mpLayer* layer, bool refreshDisplay )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool mpWindow::DelLayer( mpLayer* layer,
|
bool mpWindow::DelLayer( mpLayer* layer, bool alsoDeleteObject, bool refreshDisplay )
|
||||||
bool alsoDeleteObject,
|
|
||||||
bool refreshDisplay )
|
|
||||||
{
|
{
|
||||||
wxLayerList::iterator layIt;
|
wxLayerList::iterator layIt;
|
||||||
|
|
||||||
|
@ -2358,9 +2351,7 @@ void mpWindow::OnPaint( wxPaintEvent& WXUNUSED( event ) )
|
||||||
{
|
{
|
||||||
if( m_last_lx != m_scrX || m_last_ly != m_scrY )
|
if( m_last_lx != m_scrX || m_last_ly != m_scrY )
|
||||||
{
|
{
|
||||||
if( m_buff_bmp )
|
delete m_buff_bmp;
|
||||||
delete m_buff_bmp;
|
|
||||||
|
|
||||||
m_buff_bmp = new wxBitmap( m_scrX, m_scrY );
|
m_buff_bmp = new wxBitmap( m_scrX, m_scrY );
|
||||||
m_buff_dc.SelectObject( *m_buff_bmp );
|
m_buff_dc.SelectObject( *m_buff_bmp );
|
||||||
m_last_lx = m_scrX;
|
m_last_lx = m_scrX;
|
||||||
|
|
|
@ -506,8 +506,7 @@ void SIM_PLOT_FRAME::ShowChangedLanguage()
|
||||||
m_cursorsGrid->SetColLabelValue( COL_CURSOR_SIGNAL, _( "Signal" ) );
|
m_cursorsGrid->SetColLabelValue( COL_CURSOR_SIGNAL, _( "Signal" ) );
|
||||||
m_cursorsGrid->SetColLabelValue( COL_CURSOR_X, _( "Time" ) );
|
m_cursorsGrid->SetColLabelValue( COL_CURSOR_X, _( "Time" ) );
|
||||||
m_cursorsGrid->SetColLabelValue( COL_CURSOR_Y, _( "Value" ) );
|
m_cursorsGrid->SetColLabelValue( COL_CURSOR_Y, _( "Value" ) );
|
||||||
wxCommandEvent dummy;
|
updateCursors();
|
||||||
onCursorUpdate( dummy );
|
|
||||||
|
|
||||||
for( TUNER_SLIDER* tuner : m_tuners )
|
for( TUNER_SLIDER* tuner : m_tuners )
|
||||||
tuner->ShowChangedLanguage();
|
tuner->ShowChangedLanguage();
|
||||||
|
@ -1048,8 +1047,8 @@ void SIM_PLOT_FRAME::onCursorsGridCellChanged( wxGridEvent& aEvent )
|
||||||
else if( cursorName == _( "Diff" ) && cursor1 && cursor2 )
|
else if( cursorName == _( "Diff" ) && cursor1 && cursor2 )
|
||||||
cursor2->SetCoordX( cursor1->GetCoords().x + value );
|
cursor2->SetCoordX( cursor1->GetCoords().x + value );
|
||||||
|
|
||||||
wxCommandEvent dummy;
|
updateCursors();
|
||||||
onCursorUpdate( dummy );
|
m_workbookModified = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1342,8 +1341,7 @@ void SIM_PLOT_FRAME::removeTrace( const wxString& aSignalName )
|
||||||
plotPanel->GetPlotWin()->Fit();
|
plotPanel->GetPlotWin()->Fit();
|
||||||
|
|
||||||
updateSignalsGrid();
|
updateSignalsGrid();
|
||||||
wxCommandEvent dummy;
|
updateCursors();
|
||||||
onCursorUpdate( dummy );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1712,7 +1710,8 @@ bool SIM_PLOT_FRAME::LoadWorkbook( const wxString& aPath )
|
||||||
|
|
||||||
addTrace( name, (SIM_TRACE_TYPE) traceType );
|
addTrace( name, (SIM_TRACE_TYPE) traceType );
|
||||||
|
|
||||||
TRACE* trace = GetCurrentPlot() ? GetCurrentPlot()->GetTrace( name ) : nullptr;
|
SIM_PLOT_PANEL* plotPanel = GetCurrentPlot();
|
||||||
|
TRACE* trace = plotPanel ? plotPanel->GetTrace( name ) : nullptr;
|
||||||
|
|
||||||
if( version >= 4 && trace )
|
if( version >= 4 && trace )
|
||||||
{
|
{
|
||||||
|
@ -1725,6 +1724,20 @@ bool SIM_PLOT_FRAME::LoadWorkbook( const wxString& aPath )
|
||||||
format->Range = text.Right( text.Length() - 1 );
|
format->Range = text.Right( text.Length() - 1 );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
auto addCursor =
|
||||||
|
[]( int aCursorId, SIM_PLOT_PANEL* aPlotPanel, TRACE* aTrace, double x )
|
||||||
|
{
|
||||||
|
CURSOR* cursor = new CURSOR( aTrace, aPlotPanel );
|
||||||
|
mpWindow* win = aPlotPanel->GetPlotWin();
|
||||||
|
|
||||||
|
cursor->SetName( aTrace->GetName() );
|
||||||
|
cursor->SetPen( wxPen( aTrace->GetTraceColour() ) );
|
||||||
|
cursor->SetCoordX( x );
|
||||||
|
|
||||||
|
aTrace->SetCursor( aCursorId, cursor );
|
||||||
|
win->AddLayer( cursor );
|
||||||
|
};
|
||||||
|
|
||||||
wxArrayString items = wxSplit( param, '|' );
|
wxArrayString items = wxSplit( param, '|' );
|
||||||
|
|
||||||
for( const wxString& item : items )
|
for( const wxString& item : items )
|
||||||
|
@ -1737,29 +1750,33 @@ bool SIM_PLOT_FRAME::LoadWorkbook( const wxString& aPath )
|
||||||
}
|
}
|
||||||
else if( item.StartsWith( wxS( "cursor1" ) ) )
|
else if( item.StartsWith( wxS( "cursor1" ) ) )
|
||||||
{
|
{
|
||||||
wxArrayString parts = wxSplit( item, '.' );
|
wxArrayString parts = wxSplit( item, ':' );
|
||||||
|
double val;
|
||||||
|
|
||||||
if( parts.size() == 3 )
|
if( parts.size() == 3 )
|
||||||
{
|
{
|
||||||
|
parts[0].AfterFirst( '=' ).ToDouble( &val );
|
||||||
readFormat( &m_cursorFormats[0][0], parts[1] );
|
readFormat( &m_cursorFormats[0][0], parts[1] );
|
||||||
readFormat( &m_cursorFormats[0][1], parts[2] );
|
readFormat( &m_cursorFormats[0][1], parts[2] );
|
||||||
GetCurrentPlot()->EnableCursor( name, 1, true );
|
addCursor( 1, plotPanel, trace, val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( item.StartsWith( wxS( "cursor2" ) ) )
|
else if( item.StartsWith( wxS( "cursor2" ) ) )
|
||||||
{
|
{
|
||||||
wxArrayString parts = wxSplit( item, '.' );
|
wxArrayString parts = wxSplit( item, ':' );
|
||||||
|
double val;
|
||||||
|
|
||||||
if( parts.size() == 3 )
|
if( parts.size() == 3 )
|
||||||
{
|
{
|
||||||
|
parts[0].AfterFirst( '=' ).ToDouble( &val );
|
||||||
readFormat( &m_cursorFormats[1][0], parts[1] );
|
readFormat( &m_cursorFormats[1][0], parts[1] );
|
||||||
readFormat( &m_cursorFormats[1][1], parts[2] );
|
readFormat( &m_cursorFormats[1][1], parts[2] );
|
||||||
GetCurrentPlot()->EnableCursor( name, 2, true );
|
addCursor( 2, plotPanel, trace, val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( item.StartsWith( wxS( "cursorD" ) ) )
|
else if( item.StartsWith( wxS( "cursorD" ) ) )
|
||||||
{
|
{
|
||||||
wxArrayString parts = wxSplit( item, '.' );
|
wxArrayString parts = wxSplit( item, ':' );
|
||||||
|
|
||||||
if( parts.size() == 3 )
|
if( parts.size() == 3 )
|
||||||
{
|
{
|
||||||
|
@ -1768,6 +1785,8 @@ bool SIM_PLOT_FRAME::LoadWorkbook( const wxString& aPath )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plotPanel->UpdatePlotColors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1777,9 +1796,7 @@ bool SIM_PLOT_FRAME::LoadWorkbook( const wxString& aPath )
|
||||||
rebuildSignalsList();
|
rebuildSignalsList();
|
||||||
rebuildSignalsGrid( m_filter->GetValue() );
|
rebuildSignalsGrid( m_filter->GetValue() );
|
||||||
updateSignalsGrid();
|
updateSignalsGrid();
|
||||||
|
updateCursors();
|
||||||
wxCommandEvent dummy;
|
|
||||||
onCursorUpdate( dummy );
|
|
||||||
|
|
||||||
file.Close();
|
file.Close();
|
||||||
|
|
||||||
|
@ -1866,18 +1883,20 @@ bool SIM_PLOT_FRAME::SaveWorkbook( const wxString& aPath )
|
||||||
|
|
||||||
wxString msg = COLOR4D( trace->GetTraceColour() ).ToCSSString();
|
wxString msg = COLOR4D( trace->GetTraceColour() ).ToCSSString();
|
||||||
|
|
||||||
if( trace->GetCursor( 1 ) )
|
if( CURSOR* cursor = trace->GetCursor( 1 ) )
|
||||||
{
|
{
|
||||||
msg += wxString::Format( wxS( "|cursor1.%d%s.%d%s" ),
|
msg += wxString::Format( wxS( "|cursor1=%E:%d%s:%d%s" ),
|
||||||
|
cursor->GetCoords().x,
|
||||||
m_cursorFormats[0][0].Precision,
|
m_cursorFormats[0][0].Precision,
|
||||||
m_cursorFormats[0][0].Range,
|
m_cursorFormats[0][0].Range,
|
||||||
m_cursorFormats[0][1].Precision,
|
m_cursorFormats[0][1].Precision,
|
||||||
m_cursorFormats[0][1].Range );
|
m_cursorFormats[0][1].Range );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( trace->GetCursor( 2 ) )
|
if( CURSOR* cursor = trace->GetCursor( 2 ) )
|
||||||
{
|
{
|
||||||
msg += wxString::Format( wxS( "|cursor2.%d%s.%d%s" ),
|
msg += wxString::Format( wxS( "|cursor2=%E:%d%s:%d%s" ),
|
||||||
|
cursor->GetCoords().x,
|
||||||
m_cursorFormats[1][0].Precision,
|
m_cursorFormats[1][0].Precision,
|
||||||
m_cursorFormats[1][0].Range,
|
m_cursorFormats[1][0].Range,
|
||||||
m_cursorFormats[1][1].Precision,
|
m_cursorFormats[1][1].Precision,
|
||||||
|
@ -1886,7 +1905,7 @@ bool SIM_PLOT_FRAME::SaveWorkbook( const wxString& aPath )
|
||||||
|
|
||||||
if( trace->GetCursor( 1 ) || trace->GetCursor( 2 ) )
|
if( trace->GetCursor( 1 ) || trace->GetCursor( 2 ) )
|
||||||
{
|
{
|
||||||
msg += wxString::Format( wxS( "|cursorD.%d%s.%d%s" ),
|
msg += wxString::Format( wxS( "|cursorD:%d%s:%d%s" ),
|
||||||
m_cursorFormats[2][0].Precision,
|
m_cursorFormats[2][0].Precision,
|
||||||
m_cursorFormats[2][0].Range,
|
m_cursorFormats[2][0].Range,
|
||||||
m_cursorFormats[2][1].Precision,
|
m_cursorFormats[2][1].Precision,
|
||||||
|
@ -1960,17 +1979,14 @@ void SIM_PLOT_FRAME::onPlotClosed( wxAuiNotebookEvent& event )
|
||||||
{
|
{
|
||||||
m_signals.clear();
|
m_signals.clear();
|
||||||
rebuildSignalsGrid( m_filter->GetValue() );
|
rebuildSignalsGrid( m_filter->GetValue() );
|
||||||
|
updateCursors();
|
||||||
wxCommandEvent dummy;
|
|
||||||
onCursorUpdate( dummy );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_PLOT_FRAME::onPlotChanged( wxAuiNotebookEvent& event )
|
void SIM_PLOT_FRAME::onPlotChanged( wxAuiNotebookEvent& event )
|
||||||
{
|
{
|
||||||
rebuildSignalsGrid( m_filter->GetValue() );
|
rebuildSignalsGrid( m_filter->GetValue() );
|
||||||
wxCommandEvent dummy;
|
updateCursors();
|
||||||
onCursorUpdate( dummy );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2101,7 +2117,7 @@ void SIM_PLOT_FRAME::doCloseWindow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_PLOT_FRAME::onCursorUpdate( wxCommandEvent& event )
|
void SIM_PLOT_FRAME::updateCursors()
|
||||||
{
|
{
|
||||||
m_cursorsGrid->ClearRows();
|
m_cursorsGrid->ClearRows();
|
||||||
|
|
||||||
|
@ -2225,7 +2241,13 @@ void SIM_PLOT_FRAME::onCursorUpdate( wxCommandEvent& event )
|
||||||
valColName = cursor1Name;
|
valColName = cursor1Name;
|
||||||
|
|
||||||
m_cursorsGrid->SetColLabelValue( COL_CURSOR_Y, valColName );
|
m_cursorsGrid->SetColLabelValue( COL_CURSOR_Y, valColName );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_PLOT_FRAME::onCursorUpdate( wxCommandEvent& aEvent )
|
||||||
|
{
|
||||||
|
updateCursors();
|
||||||
|
m_workbookModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -292,6 +292,11 @@ private:
|
||||||
*/
|
*/
|
||||||
void updateSignalsGrid();
|
void updateSignalsGrid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the cursor values (in the grid) and graphics (in the plot window).
|
||||||
|
*/
|
||||||
|
void updateCursors();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a measurement in the measurements grid.
|
* Update a measurement in the measurements grid.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -754,6 +754,12 @@ void SIM_PLOT_PANEL::SetTraceData( TRACE* trace, unsigned int aPoints, const dou
|
||||||
else
|
else
|
||||||
trace->SetScale( m_axis_x, m_axis_y1 );
|
trace->SetScale( m_axis_x, m_axis_y1 );
|
||||||
|
|
||||||
|
for( auto& [ cursorId, cursor ] : trace->GetCursors() )
|
||||||
|
{
|
||||||
|
if( cursor )
|
||||||
|
cursor->SetCoordX( cursor->GetCoords().x );
|
||||||
|
}
|
||||||
|
|
||||||
m_plotWin->UpdateAll();
|
m_plotWin->UpdateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue