From cd25e620528a66b1c7147c1dcc3a62a2e9436a15 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 11 Aug 2016 14:41:24 +0200 Subject: [PATCH] CURSOR does not take mpWindow* in constructor --- eeschema/sim/sim_plot_panel.cpp | 5 ++++- eeschema/sim/sim_plot_panel.h | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/eeschema/sim/sim_plot_panel.cpp b/eeschema/sim/sim_plot_panel.cpp index 180cf043fc..a2d02e025b 100644 --- a/eeschema/sim/sim_plot_panel.cpp +++ b/eeschema/sim/sim_plot_panel.cpp @@ -31,6 +31,9 @@ void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow ) { + if( !m_window ) + m_window = &aWindow; + if( !m_visible ) return; @@ -80,7 +83,7 @@ void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow ) const int horLen = aWindow.GetScrX(); const int verLen = aWindow.GetScrY(); - const wxPoint cursorPos( m_window->x2p( m_coords.x ), m_window->y2p( m_coords.y ) ); + const wxPoint cursorPos( aWindow.x2p( m_coords.x ), aWindow.y2p( m_coords.y ) ); aDC.SetPen( wxPen( *wxBLACK, 1, m_continuous ? wxSOLID : wxLONG_DASH ) ); diff --git a/eeschema/sim/sim_plot_panel.h b/eeschema/sim/sim_plot_panel.h index 2e55336792..d25896d755 100644 --- a/eeschema/sim/sim_plot_panel.h +++ b/eeschema/sim/sim_plot_panel.h @@ -61,9 +61,9 @@ private: class CURSOR : public mpInfoLayer { public: - CURSOR( const TRACE* aTrace, mpWindow* aWindow ) + CURSOR( const TRACE* aTrace ) : mpInfoLayer( wxRect( 0, 0, DRAG_MARGIN, DRAG_MARGIN ), wxTRANSPARENT_BRUSH ), - m_trace( aTrace ), m_moved( false ), m_coords( 0.0, 0.0 ), m_window( aWindow ) + m_trace( aTrace ), m_moved( false ), m_coords( 0.0, 0.0 ), m_window( nullptr ) { } @@ -71,6 +71,9 @@ public: bool Inside( wxPoint& aPoint ) { + if( !m_window ) + return false; + return ( std::abs( aPoint.x - m_window->x2p( m_coords.x ) ) <= DRAG_MARGIN ) && ( std::abs( aPoint.y - m_window->y2p( m_coords.y ) ) <= DRAG_MARGIN ); } @@ -83,6 +86,9 @@ public: void UpdateReference() { + if( !m_window ) + return; + m_reference.x = m_window->x2p( m_coords.x ); m_reference.y = m_window->y2p( m_coords.y ); }