From e452992a6ce3374ff849c0aef5e3460cca2effb7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 11 Aug 2016 14:42:14 +0200 Subject: [PATCH] Cursor centering fix --- eeschema/sim/sim_plot_panel.cpp | 10 ++++++++-- eeschema/sim/sim_plot_panel.h | 12 ++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/eeschema/sim/sim_plot_panel.cpp b/eeschema/sim/sim_plot_panel.cpp index 75fab4a0e6..9245a5e2c6 100644 --- a/eeschema/sim/sim_plot_panel.cpp +++ b/eeschema/sim/sim_plot_panel.cpp @@ -298,8 +298,14 @@ void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow ) wxQueueEvent( aWindow.GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) ); } else + { + m_updateRef = true; + } + + if( m_updateRef ) { UpdateReference(); + m_updateRef = false; } // Line length in horizontal and vertical dimensions @@ -548,8 +554,8 @@ void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable ) if( aEnable ) { CURSOR* c = new CURSOR( t ); - //int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2; - //c->Move( wxPoint( plotCenter, 0 ) ); + int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2; + c->SetX( plotCenter ); t->SetCursor( c ); AddLayer( c ); } diff --git a/eeschema/sim/sim_plot_panel.h b/eeschema/sim/sim_plot_panel.h index c88589abcd..bd337ab0ec 100644 --- a/eeschema/sim/sim_plot_panel.h +++ b/eeschema/sim/sim_plot_panel.h @@ -37,13 +37,21 @@ class CURSOR : public mpInfoLayer public: CURSOR( const TRACE* aTrace ) : mpInfoLayer( wxRect( 0, 0, DRAG_MARGIN, DRAG_MARGIN ), wxTRANSPARENT_BRUSH ), - m_trace( aTrace ), m_updateRequired( true ), m_coords( 0.0, 0.0 ), m_window( nullptr ) + m_trace( aTrace ), m_updateRequired( true ), m_updateRef( false ), + m_coords( 0.0, 0.0 ), m_window( nullptr ) { SetDrawOutsideMargins( false ); } void Plot( wxDC& aDC, mpWindow& aWindow ) override; + void SetX( int aX ) + { + m_reference.x = 0; + m_updateRef = true; + Move( wxPoint( aX, 0 ) ); + } + void Update() { m_updateRequired = true; @@ -66,7 +74,7 @@ public: private: const TRACE* m_trace; - bool m_updateRequired; + bool m_updateRequired, m_updateRef; wxRealPoint m_coords; mpWindow* m_window;