KiCad PCB EDA Suite
KIGFX::WX_VIEW_CONTROLS Class Reference

An implementation of class VIEW_CONTROLS for wxWidgets library. More...

#include <wx_view_controls.h>

Inheritance diagram for KIGFX::WX_VIEW_CONTROLS:
KIGFX::VIEW_CONTROLS

Public Member Functions

 WX_VIEW_CONTROLS (VIEW *aView, EDA_DRAW_PANEL_GAL *aParentPanel)
 
virtual ~WX_VIEW_CONTROLS ()
 
void onWheel (wxMouseEvent &aEvent)
 Handler functions. More...
 
void onMotion (wxMouseEvent &aEvent)
 
void onButton (wxMouseEvent &aEvent)
 
void onEnter (wxMouseEvent &WXUNUSED(aEvent))
 
void onLeave (wxMouseEvent &WXUNUSED(aEvent))
 
void onTimer (wxTimerEvent &WXUNUSED(aEvent))
 
void onScroll (wxScrollWinEvent &aEvent)
 
void onCaptureLost (wxMouseEvent &WXUNUSED(aEvent))
 
void CaptureCursor (bool aEnabled) override
 Force the cursor to stay within the drawing panel area. More...
 
VECTOR2D GetMousePosition (bool aWorldCoordinates=true) const override
 Return the current mouse pointer position. More...
 
VECTOR2D GetCursorPosition (bool aSnappingEnabled) const override
 < More...
 
VECTOR2D GetRawCursorPosition (bool aSnappingEnabled=true) const override
 Return the current cursor position in world coordinates ignoring the cursorUp position force mode. More...
 
void SetCursorPosition (const VECTOR2D &aPosition, bool warpView, bool aTriggeredByArrows, long aArrowCommand) override
 Move the graphic crosshair cursor to the requested position expressed in world coordinates. More...
 
void SetCrossHairCursorPosition (const VECTOR2D &aPosition, bool aWarpView) override
 
void WarpCursor (const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false) override
 Set the viewport center to the current cursor position and warps the cursor to the screen center. More...
 
void CenterOnCursor () const override
 Adjusts the scrollbars position to match the current viewport. More...
 
void UpdateScrollbars ()
 End any mouse drag action still in progress. More...
 
void CancelDrag ()
 
void ForceCursorPosition (bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0)) override
 Applies VIEW_CONTROLS settings from the program COMMON_SETTINGS. More...
 
void LoadSettings () override
 Event that forces mouse move event in the dispatcher (eg. More...
 
VECTOR2D GetCursorPosition () const
 Return the current cursor position in world coordinates. More...
 
virtual VECTOR2D GetCursorPosition (bool aEnableSnapping) const=0
 Return the current cursor position in world coordinates. More...
 
virtual void SetGrabMouse (bool aEnabled)
 Turn on/off mouse grabbing. More...
 
virtual void SetAutoPan (bool aEnabled)
 Turn on/off auto panning (this feature is used when there is a tool active (eg. More...
 
virtual void EnableAutoPan (bool aEnabled)
 Turn on/off auto panning (user setting to disable it entirely). More...
 
virtual void SetAutoPanSpeed (float aSpeed)
 Set the speed of autopanning. More...
 
virtual void SetAutoPanAcceleration (float aAcceleration)
 Set the speed of autopanning. More...
 
virtual void SetAutoPanMargin (float aMargin)
 Set the margin for autopanning (ie. More...
 
VECTOR2D GetCursorPosition () const
 Return the current cursor position in world coordinates. More...
 
virtual void ShowCursor (bool aEnabled)
 Enable or disables display of cursor. More...
 
bool IsCursorShown () const
 Return true when cursor is visible. More...
 
void EnableCursorWarping (bool aEnable)
 Enable or disable warping the cursor. More...
 
bool IsCursorWarpingEnabled () const
 
virtual void Reset ()
 Restore the default VIEW_CONTROLS settings. More...
 
const VC_SETTINGSGetSettings () const
 Apply VIEW_CONTROLS settings from an object. More...
 
void ApplySettings (const VC_SETTINGS &aSettings)
 Load new settings from program common settings. More...
 

Public Attributes

std::unique_ptr< PROF_COUNTERm_MotionEventCounter
 

Static Public Attributes

static const wxEventType EVT_REFRESH_MOUSE = wxNewEventType()
 

Protected Attributes

VIEWm_view
 < Pointer to controlled VIEW. More...
 
bool m_cursorWarped
 Current VIEW_CONTROLS settings. More...
 
VC_SETTINGS m_settings
 

Private Types

enum  STATE { IDLE = 1, DRAG_PANNING, AUTO_PANNING, DRAG_ZOOMING }
 < Possible states for WX_VIEW_CONTROLS. More...
 

Private Member Functions

bool handleAutoPanning (const wxMouseEvent &aEvent)
 Compute new viewport settings while in autopanning mode. More...
 
void handleCursorCapture (int x, int y)
 Limit the cursor position to within the canvas by warping it. More...
 
void refreshMouse ()
 Send an event to refresh mouse position. More...
 
wxPoint getMouseScreenPosition () const
 Get the cursor position in the screen coordinates. More...
 

Private Attributes

STATE m_state
 Panel that is affected by VIEW_CONTROLS. More...
 
EDA_DRAW_PANEL_GALm_parentPanel
 Store information about point where dragging has started. More...
 
VECTOR2D m_dragStartPoint
 Stores information about the center of viewport when dragging has started. More...
 
VECTOR2D m_lookStartPoint
 Current direction of panning (only autopanning mode). More...
 
VECTOR2D m_panDirection
 Timer responsible for handling autopanning. More...
 
wxTimer m_panTimer
 Ratio used for scaling world coordinates to scrollbar position. More...
 
VECTOR2D m_scrollScale
 Current scrollbar position. More...
 
VECTOR2I m_scrollPos
 The zoom scale when a drag zoom started. More...
 
double m_initialZoomScale
 The mouse position when a drag zoom started. More...
 
VECTOR2D m_zoomStartPoint
 Current cursor position (world coordinates). More...
 
VECTOR2D m_cursorPos
 Flag deciding whether the cursor position should be calculated using the mouse position. More...
 
bool m_updateCursor
 A #ZOOM_CONTROLLER that determines zoom steps. This is platform-specific. More...
 
std::unique_ptr< ZOOM_CONTROLLERm_zoomController
 

Detailed Description

An implementation of class VIEW_CONTROLS for wxWidgets library.

Definition at line 51 of file wx_view_controls.h.

Member Enumeration Documentation

◆ STATE

< Possible states for WX_VIEW_CONTROLS.

Enumerator
IDLE 

Nothing is happening.

DRAG_PANNING 

Panning with mouse button pressed.

AUTO_PANNING 

Panning on approaching borders of the frame.

DRAG_ZOOMING 

Zooming with mouse button pressed.

Definition at line 123 of file wx_view_controls.h.

124  {
125  IDLE = 1,
126  DRAG_PANNING,
127  AUTO_PANNING,
128  DRAG_ZOOMING,
129  };
Panning with mouse button pressed.
Zooming with mouse button pressed.
Panning on approaching borders of the frame.

Constructor & Destructor Documentation

◆ WX_VIEW_CONTROLS()

WX_VIEW_CONTROLS::WX_VIEW_CONTROLS ( VIEW aView,
EDA_DRAW_PANEL_GAL aParentPanel 
)

Definition at line 74 of file wx_view_controls.cpp.

74  :
75  VIEW_CONTROLS( aView ),
76  m_state( IDLE ),
77  m_parentPanel( aParentPanel ),
78  m_scrollScale( 1.0, 1.0 ),
79  m_initialZoomScale( 0.0 ),
80 #ifdef __WXGTK3__
81  m_lastTimestamp( 0 ),
82 #endif
83  m_cursorPos( 0, 0 ),
84  m_updateCursor( true )
85 {
86  LoadSettings();
87 
88  m_MotionEventCounter = std::make_unique<PROF_COUNTER>( "Mouse motion events" );
89 
90  m_parentPanel->Connect( wxEVT_MOTION,
91  wxMouseEventHandler( WX_VIEW_CONTROLS::onMotion ), nullptr, this );
92 #if wxCHECK_VERSION( 3, 1, 0 ) || defined( USE_OSX_MAGNIFY_EVENT )
93  m_parentPanel->Connect( wxEVT_MAGNIFY,
94  wxMouseEventHandler( WX_VIEW_CONTROLS::onMagnify ), nullptr, this );
95 #endif
96  m_parentPanel->Connect( wxEVT_MOUSEWHEEL,
97  wxMouseEventHandler( WX_VIEW_CONTROLS::onWheel ), nullptr, this );
98  m_parentPanel->Connect( wxEVT_MIDDLE_UP,
99  wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
100  m_parentPanel->Connect( wxEVT_MIDDLE_DOWN,
101  wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
102  m_parentPanel->Connect( wxEVT_LEFT_UP,
103  wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
104  m_parentPanel->Connect( wxEVT_LEFT_DOWN,
105  wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
106  m_parentPanel->Connect( wxEVT_RIGHT_UP,
107  wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
108  m_parentPanel->Connect( wxEVT_RIGHT_DOWN,
109  wxMouseEventHandler( WX_VIEW_CONTROLS::onButton ), nullptr, this );
110 #if defined __WXMSW__
111  m_parentPanel->Connect( wxEVT_ENTER_WINDOW,
112  wxMouseEventHandler( WX_VIEW_CONTROLS::onEnter ), nullptr, this );
113 #endif
114  m_parentPanel->Connect( wxEVT_LEAVE_WINDOW,
115  wxMouseEventHandler( WX_VIEW_CONTROLS::onLeave ), nullptr, this );
116  m_parentPanel->Connect( wxEVT_SCROLLWIN_THUMBTRACK,
117  wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
118  m_parentPanel->Connect( wxEVT_SCROLLWIN_PAGEUP,
119  wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
120  m_parentPanel->Connect( wxEVT_SCROLLWIN_PAGEDOWN,
121  wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
122 
123  m_parentPanel->Connect( wxEVT_SCROLLWIN_BOTTOM,
124  wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
125  m_parentPanel->Connect( wxEVT_SCROLLWIN_TOP,
126  wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
127  m_parentPanel->Connect( wxEVT_SCROLLWIN_LINEUP,
128  wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
129  m_parentPanel->Connect( wxEVT_SCROLLWIN_LINEDOWN,
130  wxScrollWinEventHandler( WX_VIEW_CONTROLS::onScroll ), nullptr, this );
131 #if defined USE_MOUSE_CAPTURE
132  m_parentPanel->Connect( wxEVT_MOUSE_CAPTURE_LOST,
133  wxMouseEventHandler( WX_VIEW_CONTROLS::onCaptureLost ), nullptr, this );
134 #endif
135 
136  m_cursorWarped = false;
137 
138  m_panTimer.SetOwner( this );
139  this->Connect( wxEVT_TIMER, wxTimerEventHandler( WX_VIEW_CONTROLS::onTimer ), nullptr, this );
140 
144 }
void LoadSettings() override
Event that forces mouse move event in the dispatcher (eg.
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
VIEW_CONTROLS(VIEW *aView)
void onButton(wxMouseEvent &aEvent)
VC_SETTINGS m_settings
VECTOR2D m_scrollScale
Current scrollbar position.
void onCaptureLost(wxMouseEvent &WXUNUSED(aEvent))
VECTOR2D m_lastKeyboardCursorPosition
void onWheel(wxMouseEvent &aEvent)
Handler functions.
bool m_cursorWarped
Current VIEW_CONTROLS settings.
void onMotion(wxMouseEvent &aEvent)
std::unique_ptr< PROF_COUNTER > m_MotionEventCounter
void onTimer(wxTimerEvent &WXUNUSED(aEvent))
long m_lastKeyboardCursorCommand
Position of the above event.
bool m_updateCursor
A #ZOOM_CONTROLLER that determines zoom steps. This is platform-specific.
bool m_lastKeyboardCursorPositionValid
ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
double m_initialZoomScale
The mouse position when a drag zoom started.
void onEnter(wxMouseEvent &WXUNUSED(aEvent))
STATE m_state
Panel that is affected by VIEW_CONTROLS.
void onScroll(wxScrollWinEvent &aEvent)
void onLeave(wxMouseEvent &WXUNUSED(aEvent))
VECTOR2D m_cursorPos
Flag deciding whether the cursor position should be calculated using the mouse position.
wxTimer m_panTimer
Ratio used for scaling world coordinates to scrollbar position.

References LoadSettings(), KIGFX::VIEW_CONTROLS::m_cursorWarped, KIGFX::VC_SETTINGS::m_lastKeyboardCursorCommand, KIGFX::VC_SETTINGS::m_lastKeyboardCursorPosition, KIGFX::VC_SETTINGS::m_lastKeyboardCursorPositionValid, m_MotionEventCounter, m_panTimer, m_parentPanel, KIGFX::VIEW_CONTROLS::m_settings, onButton(), onCaptureLost(), onEnter(), onLeave(), onMotion(), onScroll(), onTimer(), and onWheel().

◆ ~WX_VIEW_CONTROLS()

WX_VIEW_CONTROLS::~WX_VIEW_CONTROLS ( )
virtual

Definition at line 147 of file wx_view_controls.cpp.

148 {
149 #if defined USE_MOUSE_CAPTURE
150  if( m_parentPanel->HasCapture() )
151  m_parentPanel->ReleaseMouse();
152 #endif
153 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.

References m_parentPanel.

Member Function Documentation

◆ ApplySettings()

void VIEW_CONTROLS::ApplySettings ( const VC_SETTINGS aSettings)
inherited

Load new settings from program common settings.

Definition at line 87 of file view_controls.cpp.

88 {
89  ShowCursor( aSettings.m_showCursor );
90  CaptureCursor( aSettings.m_cursorCaptured );
91  SetGrabMouse( aSettings.m_grabMouse );
92  SetAutoPan( aSettings.m_autoPanEnabled );
93  SetAutoPanMargin( aSettings.m_autoPanMargin );
94  SetAutoPanSpeed( aSettings.m_autoPanSpeed );
96 }
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
virtual void SetAutoPanSpeed(float aSpeed)
Set the speed of autopanning.
float m_autoPanSpeed
How fast does panning accelerate when approaching the window boundary.
Definition: view_controls.h:79
bool m_grabMouse
Flag for turning on autopanning.
Definition: view_controls.h:67
VECTOR2D m_forcedPosition
Is the forced cursor position enabled.
Definition: view_controls.h:55
virtual void SetAutoPanMargin(float aMargin)
Set the margin for autopanning (ie.
bool m_forceCursorPosition
Should the cursor be locked within the parent window area.
Definition: view_controls.h:58
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
float m_autoPanMargin
How fast is panning when in auto mode.
Definition: view_controls.h:76
bool m_autoPanEnabled
Flag for turning on autopanning.
Definition: view_controls.h:70
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool m_showCursor
Forced cursor position (world coordinates).
Definition: view_controls.h:52
virtual void SetGrabMouse(bool aEnabled)
Turn on/off mouse grabbing.
bool m_cursorCaptured
Should the cursor snap to grid or move freely.
Definition: view_controls.h:61

References KIGFX::VIEW_CONTROLS::CaptureCursor(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), KIGFX::VC_SETTINGS::m_autoPanEnabled, KIGFX::VC_SETTINGS::m_autoPanMargin, KIGFX::VC_SETTINGS::m_autoPanSpeed, KIGFX::VC_SETTINGS::m_cursorCaptured, KIGFX::VC_SETTINGS::m_forceCursorPosition, KIGFX::VC_SETTINGS::m_forcedPosition, KIGFX::VC_SETTINGS::m_grabMouse, KIGFX::VC_SETTINGS::m_showCursor, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetAutoPanMargin(), KIGFX::VIEW_CONTROLS::SetAutoPanSpeed(), KIGFX::VIEW_CONTROLS::SetGrabMouse(), and KIGFX::VIEW_CONTROLS::ShowCursor().

Referenced by TOOL_MANAGER::applyViewControls(), DIALOG_PAD_PROPERTIES::prepareCanvas(), and KIGFX::VIEW_CONTROLS::Reset().

◆ CancelDrag()

void WX_VIEW_CONTROLS::CancelDrag ( )

Definition at line 634 of file wx_view_controls.cpp.

635 {
637  {
638  m_state = IDLE;
639 #if defined USE_MOUSE_CAPTURE
640  if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() )
641  m_parentPanel->ReleaseMouse();
642 #endif
643  }
644 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
Panning with mouse button pressed.
VC_SETTINGS m_settings
Zooming with mouse button pressed.
STATE m_state
Panel that is affected by VIEW_CONTROLS.
bool m_cursorCaptured
Should the cursor snap to grid or move freely.
Definition: view_controls.h:61

References DRAG_PANNING, DRAG_ZOOMING, IDLE, KIGFX::VC_SETTINGS::m_cursorCaptured, m_parentPanel, KIGFX::VIEW_CONTROLS::m_settings, and m_state.

Referenced by EDA_DRAW_PANEL_GAL::onLostFocus().

◆ CaptureCursor()

void WX_VIEW_CONTROLS::CaptureCursor ( bool  aEnabled)
overridevirtual

Force the cursor to stay within the drawing panel area.

Parameters
aEnableddetermines if the cursor should be captured.Return the current mouse pointer position.
Note
The position may be different from the cursor position if snapping is enabled (
See also
GetCursorPosition()).
Note
The position is clamped if outside of coordinates representation limits.
Parameters
aWorldCoordinatesif true, the result is given in world coordinates, otherwise it is given in screen coordinates.
Returns
The current mouse pointer position in either world or screen coordinates.

Reimplemented from KIGFX::VIEW_CONTROLS.

Definition at line 607 of file wx_view_controls.cpp.

608 {
609 #if defined USE_MOUSE_CAPTURE
610  // Note: for some reason, m_parentPanel->HasCapture() can be false even if CaptureMouse()
611  // was called (i.e. mouse was captured, so when need to test m_MouseCapturedLost to be
612  // sure a wxEVT_MOUSE_CAPTURE_LOST event was fired before. Otherwise wxMSW complains
613  if( aEnabled && !m_parentPanel->HasCapture() && m_parentPanel->m_MouseCapturedLost )
614  {
615  m_parentPanel->CaptureMouse();
616 
617  // Clear the flag to allow calling m_parentPanel->CaptureMouse()
618  // Calling it without calling ReleaseMouse() is not accepted by wxWidgets (MSW specific)
620  }
621  else if( !aEnabled && m_parentPanel->HasCapture()
623  {
624  m_parentPanel->ReleaseMouse();
625 
626  // Mouse is released, calling CaptureMouse() is allowed now:
628  }
629 #endif
630  VIEW_CONTROLS::CaptureCursor( aEnabled );
631 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
Panning with mouse button pressed.
Zooming with mouse button pressed.
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
bool m_MouseCapturedLost
used on wxMSW: true after a wxEVT_MOUSE_CAPTURE_LOST was received false after the mouse is recaptured...
STATE m_state
Panel that is affected by VIEW_CONTROLS.

References KIGFX::VIEW_CONTROLS::CaptureCursor(), DRAG_PANNING, DRAG_ZOOMING, EDA_DRAW_PANEL_GAL::m_MouseCapturedLost, m_parentPanel, and m_state.

◆ CenterOnCursor()

void WX_VIEW_CONTROLS::CenterOnCursor ( ) const
overridevirtual

Adjusts the scrollbars position to match the current viewport.

Implements KIGFX::VIEW_CONTROLS.

Definition at line 761 of file wx_view_controls.cpp.

762 {
763  const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
764  VECTOR2I screenCenter( screenSize / 2 );
765 
766  if( GetMousePosition( false ) != screenCenter )
767  {
769  m_parentPanel->WarpPointer( KiROUND( screenSize.x / 2 ), KiROUND( screenSize.y / 2 ) );
770  }
771 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const override
Return the current mouse pointer position.
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
VIEW * m_view
< Pointer to controlled VIEW.
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

References KIGFX::VIEW_CONTROLS::GetCursorPosition(), KIGFX::VIEW::GetGAL(), GetMousePosition(), KIGFX::GAL::GetScreenPixelSize(), KiROUND(), m_parentPanel, KIGFX::VIEW_CONTROLS::m_view, KIGFX::VIEW::SetCenter(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by onWheel().

◆ EnableAutoPan()

virtual void KIGFX::VIEW_CONTROLS::EnableAutoPan ( bool  aEnabled)
inlinevirtualinherited

Turn on/off auto panning (user setting to disable it entirely).

Parameters
aEnabledtells if the autopanning should be enabled.

Definition at line 166 of file view_controls.h.

167  {
169  }
VC_SETTINGS m_settings
bool m_autoPanSettingEnabled
Distance from cursor to VIEW edge when panning is active.
Definition: view_controls.h:73

References KIGFX::VC_SETTINGS::m_autoPanSettingEnabled, and KIGFX::VIEW_CONTROLS::m_settings.

◆ EnableCursorWarping()

void KIGFX::VIEW_CONTROLS::EnableCursorWarping ( bool  aEnable)
inlineinherited

Enable or disable warping the cursor.

Parameters
aEnableis true if the cursor is allowed to be warped.

Definition at line 335 of file view_controls.h.

336  {
337  m_settings.m_warpCursor = aEnable;
338  }
VC_SETTINGS m_settings
bool m_warpCursor
Enable horizontal panning with the horizontal scroll/trackpad input.
Definition: view_controls.h:85

References KIGFX::VIEW_CONTROLS::m_settings, and KIGFX::VC_SETTINGS::m_warpCursor.

◆ ForceCursorPosition()

void WX_VIEW_CONTROLS::ForceCursorPosition ( bool  aEnabled,
const VECTOR2D aPosition = VECTOR2D( 0, 0 ) 
)
overridevirtual

Applies VIEW_CONTROLS settings from the program COMMON_SETTINGS.

Reimplemented from KIGFX::VIEW_CONTROLS.

Definition at line 950 of file wx_view_controls.cpp.

951 {
952  VECTOR2D clampedPosition = GetClampedCoords( aPosition );
953 
955  m_settings.m_forcedPosition = clampedPosition;
956 }
Define a general 2D-vector/point.
Definition: vector2d.h:61
VC_SETTINGS m_settings
VECTOR2D m_forcedPosition
Is the forced cursor position enabled.
Definition: view_controls.h:55
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=0u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
bool m_forceCursorPosition
Should the cursor be locked within the parent window area.
Definition: view_controls.h:58

References GetClampedCoords(), KIGFX::VC_SETTINGS::m_forceCursorPosition, KIGFX::VC_SETTINGS::m_forcedPosition, and KIGFX::VIEW_CONTROLS::m_settings.

◆ GetCursorPosition() [1/4]

virtual VECTOR2D KIGFX::VIEW_CONTROLS::GetCursorPosition

Return the current cursor position in world coordinates.

Note
The position may be different from the mouse pointer position if snapping is enabled or cursor position is forced to a specific point.
The position is clamped if outside of coordinates representation limits.
Parameters
aEnableSnappingselects whether cursor position should be snapped to the grid.
Returns
The current cursor position in world coordinates.

◆ GetCursorPosition() [2/4]

VECTOR2D KIGFX::VIEW_CONTROLS::GetCursorPosition
inline

Return the current cursor position in world coordinates.

Note
The position may be different from the mouse pointer position if snapping is enabled or cursor position is forced to a specific point.
The position is clamped if outside of coordinates representation limits.
Returns
The current cursor position in world coordinates.

Definition at line 225 of file view_controls.h.

226  {
228  }
bool m_snappingEnabled
Flag for grabbing the mouse cursor.
Definition: view_controls.h:64
VC_SETTINGS m_settings
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

◆ GetCursorPosition() [3/4]

VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition ( bool  aSnappingEnabled) const
overridevirtual

<

Return the current cursor position in world coordinates.

Note
The position may be different from the mouse pointer position if snapping is enabled or cursor position is forced to a specific point.
The position is clamped if outside of coordinates representation limits.
Returns
The current cursor position in world coordinates. Return the current cursor position in world coordinates ignoring the cursorUp position force mode.
The current cursor position in world coordinates.

Implements KIGFX::VIEW_CONTROLS.

Definition at line 671 of file wx_view_controls.cpp.

672 {
674  {
676  }
677  else
678  {
679  return GetClampedCoords( GetRawCursorPosition( aEnableSnapping ) );
680  }
681 }
VC_SETTINGS m_settings
VECTOR2D m_forcedPosition
Is the forced cursor position enabled.
Definition: view_controls.h:55
VECTOR2D GetRawCursorPosition(bool aSnappingEnabled=true) const override
Return the current cursor position in world coordinates ignoring the cursorUp position force mode.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=0u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
bool m_forceCursorPosition
Should the cursor be locked within the parent window area.
Definition: view_controls.h:58

References GetClampedCoords(), GetRawCursorPosition(), KIGFX::VC_SETTINGS::m_forceCursorPosition, KIGFX::VC_SETTINGS::m_forcedPosition, and KIGFX::VIEW_CONTROLS::m_settings.

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ GetCursorPosition() [4/4]

VECTOR2D KIGFX::VIEW_CONTROLS::GetCursorPosition ( ) const
inlineinherited

Return the current cursor position in world coordinates.

Note
The position may be different from the mouse pointer position if snapping is enabled or cursor position is forced to a specific point.
The position is clamped if outside of coordinates representation limits.
Returns
The current cursor position in world coordinates.

Definition at line 225 of file view_controls.h.

226  {
228  }
bool m_snappingEnabled
Flag for grabbing the mouse cursor.
Definition: view_controls.h:64
VC_SETTINGS m_settings
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

References KIGFX::VIEW_CONTROLS::m_settings, and KIGFX::VC_SETTINGS::m_snappingEnabled.

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB(), SCH_EDIT_TOOL::BreakWire(), CenterOnCursor(), ZONE_CREATE_HELPER::createNewZone(), TOOL_MANAGER::DispatchContextMenu(), EDIT_TOOL::doMoveSelection(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), PAD_TOOL::EnumeratePads(), TOOL_MANAGER::GetCursorPosition(), SCH_EDITOR_CONTROL::HighlightNet(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), COMMON_TOOLS::OnGridChanged(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::ResetLocalCoords(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), EE_SELECTION_TOOL::SelectNode(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), PNS::TOOL_BASE::updateStartItem(), GERBVIEW_FRAME::UpdateStatusBar(), PL_EDITOR_FRAME::UpdateStatusBar(), SCH_BASE_FRAME::UpdateStatusBar(), and PCB_BASE_FRAME::UpdateStatusBar().

◆ GetMousePosition()

VECTOR2D WX_VIEW_CONTROLS::GetMousePosition ( bool  aWorldCoordinates = true) const
overridevirtual

Return the current mouse pointer position.

Note
The position may be different from the cursor position if snapping is enabled (
See also
GetCursorPosition()).
Note
The position is clamped if outside of coordinates representation limits.
Parameters
aWorldCoordinatesif true, the result is given in world coordinates, otherwise it is given in screen coordinates.
Returns
The current mouse pointer position in either world or screen coordinates.

Implements KIGFX::VIEW_CONTROLS.

Definition at line 647 of file wx_view_controls.cpp.

648 {
649  wxPoint msp = getMouseScreenPosition();
650  VECTOR2D screenPos( msp.x, msp.y );
651 
652  return aWorldCoordinates ? GetClampedCoords( m_view->ToWorld( screenPos ) ) : screenPos;
653 }
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:449
wxPoint getMouseScreenPosition() const
Get the cursor position in the screen coordinates.
Define a general 2D-vector/point.
Definition: vector2d.h:61
VIEW * m_view
< Pointer to controlled VIEW.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=0u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...

References GetClampedCoords(), getMouseScreenPosition(), KIGFX::VIEW_CONTROLS::m_view, and KIGFX::VIEW::ToWorld().

Referenced by CenterOnCursor().

◆ getMouseScreenPosition()

wxPoint WX_VIEW_CONTROLS::getMouseScreenPosition ( ) const
private

Get the cursor position in the screen coordinates.

Current state of VIEW_CONTROLS.

Definition at line 903 of file wx_view_controls.cpp.

904 {
905  wxPoint msp = wxGetMousePosition();
906  m_parentPanel->ScreenToClient( &msp.x, &msp.y );
907  return msp;
908 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.

References m_parentPanel.

Referenced by GetMousePosition(), and refreshMouse().

◆ GetRawCursorPosition()

VECTOR2D WX_VIEW_CONTROLS::GetRawCursorPosition ( bool  aSnappingEnabled = true) const
overridevirtual

Return the current cursor position in world coordinates ignoring the cursorUp position force mode.

Returns
The current cursor position in world coordinates.

Implements KIGFX::VIEW_CONTROLS.

Definition at line 656 of file wx_view_controls.cpp.

657 {
658  GAL* gal = m_view->GetGAL();
659 
660  if( aEnableSnapping && gal->GetGridSnapping() )
661  {
662  return gal->GetGridPoint( m_cursorPos );
663  }
664  else
665  {
666  return m_cursorPos;
667  }
668 }
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
VIEW * m_view
< Pointer to controlled VIEW.
VECTOR2D GetGridPoint(const VECTOR2D &aPoint) const
For a given point it returns the nearest point belonging to the grid in world coordinates.
bool GetGridSnapping() const
Abstract interface for drawing on a 2D-surface.
VECTOR2D m_cursorPos
Flag deciding whether the cursor position should be calculated using the mouse position.

References KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridPoint(), KIGFX::GAL::GetGridSnapping(), m_cursorPos, and KIGFX::VIEW_CONTROLS::m_view.

Referenced by GetCursorPosition().

◆ GetSettings()

const VC_SETTINGS& KIGFX::VIEW_CONTROLS::GetSettings ( ) const
inlineinherited

◆ handleAutoPanning()

bool WX_VIEW_CONTROLS::handleAutoPanning ( const wxMouseEvent &  aEvent)
private

Compute new viewport settings while in autopanning mode.

Parameters
aEventis an event to be processed and decide if autopanning should happen.
Returns
true if it is currently autopanning (ie. autopanning is active and mouse cursor is in the area that causes autopanning to happen).

Definition at line 774 of file wx_view_controls.cpp.

775 {
776  VECTOR2I p( aEvent.GetX(), aEvent.GetY() );
778 
780  {
781  // last cursor move event came from keyboard cursor control. If auto-panning is enabled
782  // and the next position is inside the autopan zone, check if it really came from a mouse
783  // event, otherwise disable autopan temporarily. Also temporarily disable autopan if the
784  // cursor is in the autopan zone because the application warped the cursor.
785 
786  m_cursorWarped = false;
787  return true;
788  }
789 
790  m_cursorWarped = false;
791 
792  // Compute areas where autopanning is active
793  int borderStart = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
795  borderStart = std::max( borderStart, 2 );
796  int borderEndX = m_view->GetScreenPixelSize().x - borderStart;
797  int borderEndY = m_view->GetScreenPixelSize().y - borderStart;
798 
799  if( p.x < borderStart )
800  m_panDirection.x = -( borderStart - p.x );
801  else if( p.x > borderEndX )
802  m_panDirection.x = ( p.x - borderEndX );
803  else
804  m_panDirection.x = 0;
805 
806  if( p.y < borderStart )
807  m_panDirection.y = -( borderStart - p.y );
808  else if( p.y > borderEndY )
809  m_panDirection.y = ( p.y - borderEndY );
810  else
811  m_panDirection.y = 0;
812 
813  bool borderHit = ( m_panDirection.x != 0 || m_panDirection.y != 0 );
814 
815  switch( m_state )
816  {
817  case AUTO_PANNING:
818  if( !borderHit )
819  {
820  m_panTimer.Stop();
821  m_state = IDLE;
822 
823  return false;
824  }
825 
826  return true;
827  break;
828 
829  case IDLE:
830  if( borderHit )
831  {
833  m_panTimer.Start( (int) ( 250.0 / 60.0 ) );
834 
835  return true;
836  }
837 
838  return false;
839  break;
840 
841  case DRAG_PANNING:
842  case DRAG_ZOOMING:
843  return false;
844  }
845 
846  wxCHECK_MSG( false, false, wxT( "This line should never be reached" ) );
847 }
Panning with mouse button pressed.
VC_SETTINGS m_settings
VIEW * m_view
< Pointer to controlled VIEW.
Zooming with mouse button pressed.
VECTOR2D m_lastKeyboardCursorPosition
Panning on approaching borders of the frame.
const VECTOR2I & GetScreenPixelSize() const
Return the size of the our rendering area in pixels.
Definition: view.cpp:1167
float m_autoPanMargin
How fast is panning when in auto mode.
Definition: view_controls.h:76
bool m_cursorWarped
Current VIEW_CONTROLS settings.
VECTOR2D ToScreen(const VECTOR2D &aCoord, bool aAbsolute=true) const
Convert a world space point/vector to a point/vector in screen space coordinates.
Definition: view.cpp:468
VECTOR2D m_panDirection
Timer responsible for handling autopanning.
bool m_lastKeyboardCursorPositionValid
ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
STATE m_state
Panel that is affected by VIEW_CONTROLS.
wxTimer m_panTimer
Ratio used for scaling world coordinates to scrollbar position.

References AUTO_PANNING, DRAG_PANNING, DRAG_ZOOMING, KIGFX::VIEW::GetScreenPixelSize(), IDLE, KIGFX::VC_SETTINGS::m_autoPanMargin, KIGFX::VIEW_CONTROLS::m_cursorWarped, KIGFX::VC_SETTINGS::m_lastKeyboardCursorPosition, KIGFX::VC_SETTINGS::m_lastKeyboardCursorPositionValid, m_panDirection, m_panTimer, KIGFX::VIEW_CONTROLS::m_settings, m_state, KIGFX::VIEW_CONTROLS::m_view, KIGFX::VIEW::ToScreen(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by onMotion().

◆ handleCursorCapture()

void WX_VIEW_CONTROLS::handleCursorCapture ( int  x,
int  y 
)
private

Limit the cursor position to within the canvas by warping it.

Parameters
xMouse position
yMouse position

Definition at line 850 of file wx_view_controls.cpp.

851 {
853  {
854  bool warp = false;
855  wxSize parentSize = m_parentPanel->GetClientSize();
856 
857  if( x < 0 )
858  {
859  x = 0;
860  warp = true;
861  }
862  else if( x >= parentSize.x )
863  {
864  x = parentSize.x - 1;
865  warp = true;
866  }
867 
868  if( y < 0 )
869  {
870  y = 0;
871  warp = true;
872  }
873  else if( y >= parentSize.y )
874  {
875  y = parentSize.y - 1;
876  warp = true;
877  }
878 
879  if( warp )
880  m_parentPanel->WarpPointer( x, y );
881  }
882 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
VC_SETTINGS m_settings
bool m_cursorCaptured
Should the cursor snap to grid or move freely.
Definition: view_controls.h:61

References KIGFX::VC_SETTINGS::m_cursorCaptured, m_parentPanel, and KIGFX::VIEW_CONTROLS::m_settings.

Referenced by onMotion().

◆ IsCursorShown()

bool VIEW_CONTROLS::IsCursorShown ( ) const
inherited

Return true when cursor is visible.

Returns
True if cursor is visible.

Definition at line 41 of file view_controls.cpp.

42 {
43  // this only says if the VIEW_CONTROLS say the cursor should be
44  // shown: m_view->GetGAL()->IsCursorEnabled() will say if the GAL is
45  // actually going to do show the cursor or not
46  return m_settings.m_showCursor;
47 }
VC_SETTINGS m_settings
bool m_showCursor
Forced cursor position (world coordinates).
Definition: view_controls.h:52

References KIGFX::VIEW_CONTROLS::m_settings, and KIGFX::VC_SETTINGS::m_showCursor.

◆ IsCursorWarpingEnabled()

bool KIGFX::VIEW_CONTROLS::IsCursorWarpingEnabled ( ) const
inlineinherited
Returns
the current setting for cursor warping.

Definition at line 343 of file view_controls.h.

344  {
345  return m_settings.m_warpCursor;
346  }
VC_SETTINGS m_settings
bool m_warpCursor
Enable horizontal panning with the horizontal scroll/trackpad input.
Definition: view_controls.h:85

References KIGFX::VIEW_CONTROLS::m_settings, and KIGFX::VC_SETTINGS::m_warpCursor.

Referenced by onWheel().

◆ LoadSettings()

void WX_VIEW_CONTROLS::LoadSettings ( )
overridevirtual

Event that forces mouse move event in the dispatcher (eg.

used in autopanning, when mouse cursor does not move in screen coordinates, but does in world coordinates)

Reimplemented from KIGFX::VIEW_CONTROLS.

Definition at line 156 of file wx_view_controls.cpp.

157 {
158  COMMON_SETTINGS* cfg = Pgm().GetCommonSettings();
159 
173 
174  m_zoomController.reset();
175 
176  if( cfg->m_Input.zoom_speed_auto )
177  {
179  }
180  else
181  {
182  if( cfg->m_Input.zoom_acceleration )
183  {
185  std::make_unique<ACCELERATING_ZOOM_CONTROLLER>( cfg->m_Input.zoom_speed );
186  }
187  else
188  {
190 
191  m_zoomController = std::make_unique<CONSTANT_ZOOM_CONTROLLER>( scale );
192  }
193  }
194 }
MOUSE_DRAG_ACTION m_dragRight
Is last cursor motion event coming from keyboard arrow cursor motion action.
MOUSE_DRAG_ACTION drag_left
std::unique_ptr< ZOOM_CONTROLLER > m_zoomController
VC_SETTINGS m_settings
static std::unique_ptr< ZOOM_CONTROLLER > GetZoomControllerForPlatform(bool aAcceleration)
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:106
MOUSE_DRAG_ACTION drag_right
int m_scrollModifierPanH
What modifier key to enable vertical with the (vertical) scroll wheel.
bool m_autoPanSettingEnabled
Distance from cursor to VIEW edge when panning is active.
Definition: view_controls.h:73
MOUSE_DRAG_ACTION m_dragLeft
MOUSE_DRAG_ACTION m_dragMiddle
bool m_zoomSpeedAuto
What modifier key to enable zoom with the (vertical) scroll wheel.
Definition: view_controls.h:97
int m_scrollModifierZoom
What modifier key to enable horizontal pan with the (vertical) scroll wheel.
float m_autoPanAcceleration
If the cursor is allowed to be warped.
Definition: view_controls.h:82
int m_zoomSpeed
When true, ignore zoom_speed and pick a platform-specific default.
Definition: view_controls.h:94
bool m_warpCursor
Enable horizontal panning with the horizontal scroll/trackpad input.
Definition: view_controls.h:85
bool m_horizontalPan
Enable the accelerating zoom controller.
Definition: view_controls.h:88
bool m_zoomAcceleration
Zoom speed for the non-accelerating zoom controller.
Definition: view_controls.h:91
const int scale
static constexpr double MANUAL_SCALE_FACTOR
MOUSE_DRAG_ACTION drag_middle

References COMMON_SETTINGS::INPUT::auto_pan, COMMON_SETTINGS::INPUT::auto_pan_acceleration, COMMON_SETTINGS::INPUT::center_on_zoom, COMMON_SETTINGS::INPUT::drag_left, COMMON_SETTINGS::INPUT::drag_middle, COMMON_SETTINGS::INPUT::drag_right, GetZoomControllerForPlatform(), COMMON_SETTINGS::INPUT::horizontal_pan, KIGFX::VC_SETTINGS::m_autoPanAcceleration, KIGFX::VC_SETTINGS::m_autoPanSettingEnabled, KIGFX::VC_SETTINGS::m_dragLeft, KIGFX::VC_SETTINGS::m_dragMiddle, KIGFX::VC_SETTINGS::m_dragRight, KIGFX::VC_SETTINGS::m_horizontalPan, COMMON_SETTINGS::m_Input, KIGFX::VC_SETTINGS::m_scrollModifierPanH, KIGFX::VC_SETTINGS::m_scrollModifierPanV, KIGFX::VC_SETTINGS::m_scrollModifierZoom, KIGFX::VIEW_CONTROLS::m_settings, KIGFX::VC_SETTINGS::m_warpCursor, KIGFX::VC_SETTINGS::m_zoomAcceleration, m_zoomController, KIGFX::VC_SETTINGS::m_zoomSpeed, KIGFX::VC_SETTINGS::m_zoomSpeedAuto, KIGFX::CONSTANT_ZOOM_CONTROLLER::MANUAL_SCALE_FACTOR, Pgm(), scale, COMMON_SETTINGS::INPUT::scroll_modifier_pan_h, COMMON_SETTINGS::INPUT::scroll_modifier_pan_v, COMMON_SETTINGS::INPUT::scroll_modifier_zoom, COMMON_SETTINGS::INPUT::zoom_acceleration, COMMON_SETTINGS::INPUT::zoom_speed, and COMMON_SETTINGS::INPUT::zoom_speed_auto.

Referenced by WX_VIEW_CONTROLS().

◆ onButton()

void WX_VIEW_CONTROLS::onButton ( wxMouseEvent &  aEvent)

Definition at line 396 of file wx_view_controls.cpp.

397 {
398  switch( m_state )
399  {
400  case IDLE:
401  case AUTO_PANNING:
402  if( ( aEvent.MiddleDown() && m_settings.m_dragMiddle == MOUSE_DRAG_ACTION::PAN ) ||
403  ( aEvent.RightDown() && m_settings.m_dragRight == MOUSE_DRAG_ACTION::PAN ) )
404  {
405  m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
408 
409 #if defined USE_MOUSE_CAPTURE
410  if( !m_parentPanel->HasCapture() )
411  m_parentPanel->CaptureMouse();
412 #endif
413  }
414  else if( ( aEvent.MiddleDown() && m_settings.m_dragMiddle == MOUSE_DRAG_ACTION::ZOOM ) ||
415  ( aEvent.RightDown() && m_settings.m_dragRight == MOUSE_DRAG_ACTION::ZOOM ) )
416  {
417  m_dragStartPoint = VECTOR2D( aEvent.GetX(), aEvent.GetY() );
421 
422 #if defined USE_MOUSE_CAPTURE
423  if( !m_parentPanel->HasCapture() )
424  m_parentPanel->CaptureMouse();
425 #endif
426  }
427 
428  if( aEvent.LeftUp() )
429  m_state = IDLE; // Stop autopanning when user release left mouse button
430 
431  break;
432 
433  case DRAG_ZOOMING:
434  case DRAG_PANNING:
435  if( aEvent.MiddleUp() || aEvent.LeftUp() || aEvent.RightUp() )
436  {
437  m_state = IDLE;
438 
439 #if defined USE_MOUSE_CAPTURE
440  if( !m_settings.m_cursorCaptured && m_parentPanel->HasCapture() )
441  m_parentPanel->ReleaseMouse();
442 #endif
443  }
444 
445  break;
446  }
447 
448  aEvent.Skip();
449 }
VECTOR2D m_lookStartPoint
Current direction of panning (only autopanning mode).
MOUSE_DRAG_ACTION m_dragRight
Is last cursor motion event coming from keyboard arrow cursor motion action.
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
Panning with mouse button pressed.
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
Definition: view.h:334
VC_SETTINGS m_settings
VIEW * m_view
< Pointer to controlled VIEW.
Zooming with mouse button pressed.
Panning on approaching borders of the frame.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
MOUSE_DRAG_ACTION m_dragMiddle
VECTOR2D m_zoomStartPoint
Current cursor position (world coordinates).
double m_initialZoomScale
The mouse position when a drag zoom started.
VECTOR2D m_dragStartPoint
Stores information about the center of viewport when dragging has started.
STATE m_state
Panel that is affected by VIEW_CONTROLS.
double GetScale() const
Definition: view.h:264
bool m_cursorCaptured
Should the cursor snap to grid or move freely.
Definition: view_controls.h:61

References AUTO_PANNING, DRAG_PANNING, DRAG_ZOOMING, KIGFX::VIEW::GetCenter(), KIGFX::VIEW::GetScale(), IDLE, KIGFX::VC_SETTINGS::m_cursorCaptured, KIGFX::VC_SETTINGS::m_dragMiddle, KIGFX::VC_SETTINGS::m_dragRight, m_dragStartPoint, m_initialZoomScale, m_lookStartPoint, m_parentPanel, KIGFX::VIEW_CONTROLS::m_settings, m_state, KIGFX::VIEW_CONTROLS::m_view, m_zoomStartPoint, PAN, and ZOOM.

Referenced by WX_VIEW_CONTROLS().

◆ onCaptureLost()

void WX_VIEW_CONTROLS::onCaptureLost ( wxMouseEvent &  WXUNUSEDaEvent)

Definition at line 487 of file wx_view_controls.cpp.

488 {
489  // This method must be present to suppress the capture-lost assertion
490 
491  // Set the flag to allow calling m_parentPanel->CaptureMouse()
492  // Note: One cannot call m_parentPanel->CaptureMouse() twice, this is not accepted
493  // by wxWidgets (MSW specific) so we need this guard
495 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
bool m_MouseCapturedLost
used on wxMSW: true after a wxEVT_MOUSE_CAPTURE_LOST was received false after the mouse is recaptured...

References EDA_DRAW_PANEL_GAL::m_MouseCapturedLost, and m_parentPanel.

Referenced by WX_VIEW_CONTROLS().

◆ onEnter()

void WX_VIEW_CONTROLS::onEnter ( wxMouseEvent &  WXUNUSEDaEvent)

Definition at line 452 of file wx_view_controls.cpp.

453 {
454  // Avoid stealing focus from text controls
455  // This is particularly important for users using On-Screen-Keyboards
456  // They may move the mouse over the canvas to reach the keyboard
458  {
459  return;
460  }
461 
462 #if defined( _WIN32 ) || defined( __WXGTK__ )
463  // Win32 and some *nix WMs transmit mouse move and wheel events to all controls below the mouse regardless
464  // of focus. Forcing the focus here will cause the EDA FRAMES to immediately become the
465  // top level active window.
466  if( m_parentPanel->GetParent() != nullptr )
467  {
468  // this assumes the parent panel's parent is the eda window
469  if( KIPLATFORM::UI::IsWindowActive( m_parentPanel->GetParent() ) )
470  {
472  }
473  }
474 #else
476 #endif
477 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
bool IsInputControlFocused(wxWindow *aFocus=nullptr)
Check if a input control has focus.
Definition: ui_common.cpp:220
bool IsWindowActive(wxWindow *aWindow)
Check to see if the given window is the currently active window (e.g.
Definition: gtk/ui.cpp:50
virtual void SetFocus() override

References KIUI::IsInputControlFocused(), KIPLATFORM::UI::IsWindowActive(), m_parentPanel, and EDA_DRAW_PANEL_GAL::SetFocus().

Referenced by WX_VIEW_CONTROLS().

◆ onLeave()

void WX_VIEW_CONTROLS::onLeave ( wxMouseEvent &  WXUNUSEDaEvent)

Definition at line 480 of file wx_view_controls.cpp.

481 {
482 #if !defined USE_MOUSE_CAPTURE
483  onMotion( aEvent );
484 #endif
485 }
void onMotion(wxMouseEvent &aEvent)

References onMotion().

Referenced by WX_VIEW_CONTROLS().

◆ onMotion()

void WX_VIEW_CONTROLS::onMotion ( wxMouseEvent &  aEvent)

Definition at line 197 of file wx_view_controls.cpp.

198 {
199  ( *m_MotionEventCounter )++;
200 
201  bool isAutoPanning = false;
202  int x = aEvent.GetX();
203  int y = aEvent.GetY();
204  VECTOR2D mousePos( x, y );
205 
207  handleCursorCapture( x, y );
208 
210  isAutoPanning = handleAutoPanning( aEvent );
211 
212  if( !isAutoPanning && aEvent.Dragging() )
213  {
214  if( m_state == DRAG_PANNING )
215  {
216  static bool justWarped = false;
217  int warpX = 0;
218  int warpY = 0;
219  wxSize parentSize = m_parentPanel->GetClientSize();
220 
221  if( x < 0 )
222  {
223  warpX = parentSize.x;
224  }
225  else if(x >= parentSize.x )
226  {
227  warpX = -parentSize.x;
228  }
229 
230  if( y < 0 )
231  {
232  warpY = parentSize.y;
233  }
234  else if( y >= parentSize.y )
235  {
236  warpY = -parentSize.y;
237  }
238 
239  if( !justWarped )
240  {
241  VECTOR2D d = m_dragStartPoint - mousePos;
242  VECTOR2D delta = m_view->ToWorld( d, false );
244  aEvent.StopPropagation();
245  }
246 
247  if( warpX || warpY )
248  {
249  if( !justWarped )
250  {
251  m_parentPanel->WarpPointer( x + warpX, y + warpY );
252  m_dragStartPoint += VECTOR2D( warpX, warpY );
253  justWarped = true;
254  }
255  else
256  justWarped = false;
257  }
258  else
259  justWarped = false;
260  }
261  else if( m_state == DRAG_ZOOMING )
262  {
263  static bool justWarped = false;
264  int warpY = 0;
265  wxSize parentSize = m_parentPanel->GetClientSize();
266 
267  if( y < 0 )
268  {
269  warpY = parentSize.y;
270  }
271  else if( y >= parentSize.y )
272  {
273  warpY = -parentSize.y;
274  }
275 
276  if( !justWarped )
277  {
278  VECTOR2D d = m_dragStartPoint - mousePos;
279  double scale = exp( d.y * m_settings.m_zoomSpeed * 0.001 );
280 
281  wxLogTrace( traceZoomScroll, wxString::Format( "dy: %f scale: %f", d.y, scale ) );
282 
284  aEvent.StopPropagation();
285  }
286 
287  if( warpY )
288  {
289  if( !justWarped )
290  {
291  m_parentPanel->WarpPointer( x, y + warpY );
292  m_dragStartPoint += VECTOR2D( 0, warpY );
293  justWarped = true;
294  }
295  else
296  justWarped = false;
297  }
298  else
299  justWarped = false;
300  }
301  }
302 
303  if( m_updateCursor ) // do not update the cursor position if it was explicitly set
304  m_cursorPos = GetClampedCoords( m_view->ToWorld( mousePos ) );
305  else
306  m_updateCursor = true;
307 
308  aEvent.Skip();
309 }
VECTOR2D m_lookStartPoint
Current direction of panning (only autopanning mode).
const wxChar *const traceZoomScroll
Flag to enable debug output of zoom-scrolling calculations in KIGFX::ZOOM_CONTROLLER and derivatives.
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
Panning with mouse button pressed.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:449
Define a general 2D-vector/point.
Definition: vector2d.h:61
VC_SETTINGS m_settings
VIEW * m_view
< Pointer to controlled VIEW.
Zooming with mouse button pressed.
bool m_autoPanSettingEnabled
Distance from cursor to VIEW edge when panning is active.
Definition: view_controls.h:73
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=0u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
int m_zoomSpeed
When true, ignore zoom_speed and pick a platform-specific default.
Definition: view_controls.h:94
bool m_autoPanEnabled
Flag for turning on autopanning.
Definition: view_controls.h:70
void handleCursorCapture(int x, int y)
Limit the cursor position to within the canvas by warping it.
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:552
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
VECTOR2D m_zoomStartPoint
Current cursor position (world coordinates).
const int scale
bool m_updateCursor
A #ZOOM_CONTROLLER that determines zoom steps. This is platform-specific.
double m_initialZoomScale
The mouse position when a drag zoom started.
bool handleAutoPanning(const wxMouseEvent &aEvent)
Compute new viewport settings while in autopanning mode.
VECTOR2D m_dragStartPoint
Stores information about the center of viewport when dragging has started.
constexpr int delta
STATE m_state
Panel that is affected by VIEW_CONTROLS.
VECTOR2D m_cursorPos
Flag deciding whether the cursor position should be calculated using the mouse position.

References delta, DRAG_PANNING, DRAG_ZOOMING, Format(), GetClampedCoords(), handleAutoPanning(), handleCursorCapture(), KIGFX::VC_SETTINGS::m_autoPanEnabled, KIGFX::VC_SETTINGS::m_autoPanSettingEnabled, m_cursorPos, m_dragStartPoint, m_initialZoomScale, m_lookStartPoint, m_parentPanel, KIGFX::VIEW_CONTROLS::m_settings, m_state, m_updateCursor, KIGFX::VIEW_CONTROLS::m_view, KIGFX::VC_SETTINGS::m_zoomSpeed, m_zoomStartPoint, scale, KIGFX::VIEW::SetCenter(), KIGFX::VIEW::SetScale(), KIGFX::VIEW::ToWorld(), traceZoomScroll, and VECTOR2< T >::y.

Referenced by onLeave(), and WX_VIEW_CONTROLS().

◆ onScroll()

void WX_VIEW_CONTROLS::onScroll ( wxScrollWinEvent &  aEvent)

Definition at line 548 of file wx_view_controls.cpp.

549 {
550  const double linePanDelta = 0.05;
551  const double pagePanDelta = 0.5;
552 
553  int type = aEvent.GetEventType();
554  int dir = aEvent.GetOrientation();
555 
556  if( type == wxEVT_SCROLLWIN_THUMBTRACK )
557  {
558  auto center = m_view->GetCenter();
559  const auto& boundary = m_view->GetBoundary();
560 
561  // Flip scroll direction in flipped view
562  const double xstart = ( m_view->IsMirroredX() ?
563  boundary.GetRight() : boundary.GetLeft() );
564  const double xdelta = ( m_view->IsMirroredX() ? -1 : 1 );
565 
566  if( dir == wxHORIZONTAL )
567  center.x = xstart + xdelta * ( aEvent.GetPosition() / m_scrollScale.x );
568  else
569  center.y = boundary.GetTop() + aEvent.GetPosition() / m_scrollScale.y;
570 
571  m_view->SetCenter( center );
572  }
573  else
574  {
575  double dist = 0;
576 
577  if( type == wxEVT_SCROLLWIN_PAGEUP )
578  dist = pagePanDelta;
579  else if( type == wxEVT_SCROLLWIN_PAGEDOWN )
580  dist = -pagePanDelta;
581  else if( type == wxEVT_SCROLLWIN_LINEUP )
582  dist = linePanDelta;
583  else if( type == wxEVT_SCROLLWIN_LINEDOWN )
584  dist = -linePanDelta;
585  else
586  wxCHECK_MSG( false, /* void */, wxT( "Unhandled event type" ) );
587 
588  VECTOR2D scroll = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) * dist;
589 
590  double scrollX = 0.0;
591  double scrollY = 0.0;
592 
593  if ( dir == wxHORIZONTAL )
594  scrollX = -scroll.x;
595  else
596  scrollY = -scroll.y;
597 
598  VECTOR2D delta( scrollX, scrollY );
599 
601  }
602 
604 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
const BOX2D & GetBoundary() const
Definition: view.h:293
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:449
coord_type GetTop() const
Definition: box2.h:187
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
Definition: view.h:334
Define a general 2D-vector/point.
Definition: vector2d.h:61
VIEW * m_view
< Pointer to controlled VIEW.
VECTOR2D m_scrollScale
Current scrollbar position.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
const VECTOR2I & GetScreenPixelSize() const
Return the size of the our rendering area in pixels.
Definition: view.cpp:1167
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:238
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
constexpr int delta

References delta, KIGFX::VIEW::GetBoundary(), KIGFX::VIEW::GetCenter(), KIGFX::VIEW::GetScreenPixelSize(), BOX2< Vec >::GetTop(), KIGFX::VIEW::IsMirroredX(), m_parentPanel, m_scrollScale, KIGFX::VIEW_CONTROLS::m_view, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::VIEW::SetCenter(), KIGFX::VIEW::ToWorld(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by WX_VIEW_CONTROLS().

◆ onTimer()

void WX_VIEW_CONTROLS::onTimer ( wxTimerEvent &  WXUNUSEDaEvent)

Definition at line 498 of file wx_view_controls.cpp.

499 {
500  switch( m_state )
501  {
502  case AUTO_PANNING:
503  {
505  {
506  m_state = IDLE;
507  return;
508  }
509 
510  if( !m_parentPanel->HasFocus() )
511  break;
512 
513  double borderSize = std::min( m_settings.m_autoPanMargin * m_view->GetScreenPixelSize().x,
515 
516  // When the mouse cursor is outside the area with no pan,
517  // m_panDirection is the dist to this area limit ( in pixels )
518  // It will be used also as pan value (the pan speed depends on this dist).
519  VECTOR2D dir( m_panDirection );
520 
521  // When the mouse cursor is outside the area with no pan, the pan value
522  // is accelerated depending on the dist between the area and the cursor
523  float accel = 0.5f + ( m_settings.m_autoPanAcceleration / 5.0f );
524 
525  // For a small mouse cursor dist to area, just use the distance.
526  // But for a dist > borderSize / 2, use an accelerated pan value
527 
528  if( dir.EuclideanNorm() >= borderSize ) // far from area limits
529  dir = dir.Resize( borderSize * accel );
530  else if( dir.EuclideanNorm() > borderSize / 2 ) // Near from area limits
531  dir = dir.Resize( borderSize );
532 
533  dir = m_view->ToWorld( dir, false );
534  m_view->SetCenter( m_view->GetCenter() + dir );
535 
536  refreshMouse();
537  }
538  break;
539 
540  case IDLE: // Just remove unnecessary warnings
541  case DRAG_PANNING:
542  case DRAG_ZOOMING:
543  break;
544  }
545 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
Panning with mouse button pressed.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:449
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
Definition: view.h:334
Define a general 2D-vector/point.
Definition: vector2d.h:61
VC_SETTINGS m_settings
VIEW * m_view
< Pointer to controlled VIEW.
Zooming with mouse button pressed.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
Panning on approaching borders of the frame.
float m_autoPanAcceleration
If the cursor is allowed to be warped.
Definition: view_controls.h:82
const VECTOR2I & GetScreenPixelSize() const
Return the size of the our rendering area in pixels.
Definition: view.cpp:1167
float m_autoPanMargin
How fast is panning when in auto mode.
Definition: view_controls.h:76
void refreshMouse()
Send an event to refresh mouse position.
bool m_autoPanEnabled
Flag for turning on autopanning.
Definition: view_controls.h:70
VECTOR2D m_panDirection
Timer responsible for handling autopanning.
STATE m_state
Panel that is affected by VIEW_CONTROLS.

References AUTO_PANNING, DRAG_PANNING, DRAG_ZOOMING, KIGFX::VIEW::GetCenter(), KIGFX::VIEW::GetScreenPixelSize(), IDLE, KIGFX::VC_SETTINGS::m_autoPanAcceleration, KIGFX::VC_SETTINGS::m_autoPanEnabled, KIGFX::VC_SETTINGS::m_autoPanMargin, m_panDirection, m_parentPanel, KIGFX::VIEW_CONTROLS::m_settings, m_state, KIGFX::VIEW_CONTROLS::m_view, refreshMouse(), KIGFX::VIEW::SetCenter(), KIGFX::VIEW::ToWorld(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by WX_VIEW_CONTROLS().

◆ onWheel()

void WX_VIEW_CONTROLS::onWheel ( wxMouseEvent &  aEvent)

Handler functions.

Definition at line 312 of file wx_view_controls.cpp.

313 {
314 #ifdef __WXGTK3__
315  if( aEvent.GetTimestamp() == m_lastTimestamp )
316  {
317  aEvent.Skip( false );
318  return;
319  }
320 
321  m_lastTimestamp = aEvent.GetTimestamp();
322 #endif
323 
324  const double wheelPanSpeed = 0.001;
325  const int axis = aEvent.GetWheelAxis();
326 
327  if( axis == wxMOUSE_WHEEL_HORIZONTAL && !m_settings.m_horizontalPan )
328  return;
329 
330  // Pick the modifier, if any. Shift beats control beats alt, we don't support more than one.
331  int modifiers =
332  aEvent.ShiftDown() ? WXK_SHIFT :
333  ( aEvent.ControlDown() ? WXK_CONTROL : ( aEvent.AltDown() ? WXK_ALT : 0 ) );
334 
335  // Restrict zoom handling to the vertical axis, otherwise horizontal
336  // scrolling events (e.g. touchpads and some mice) end up interpreted
337  // as vertical scroll events and confuse the user.
338  if( axis == wxMOUSE_WHEEL_VERTICAL && modifiers == m_settings.m_scrollModifierZoom )
339  {
340  const int rotation = aEvent.GetWheelRotation();
341  const double zoomScale = m_zoomController->GetScaleForRotation( rotation );
342 
343  if( IsCursorWarpingEnabled() )
344  {
345  CenterOnCursor();
346  m_view->SetScale( m_view->GetScale() * zoomScale );
347  }
348  else
349  {
350  const VECTOR2D anchor = m_view->ToWorld( VECTOR2D( aEvent.GetX(), aEvent.GetY() ) );
351  m_view->SetScale( m_view->GetScale() * zoomScale, anchor );
352  }
353 
354  // Refresh the zoom level and mouse position on message panel
355  // (mouse position has not changed, only the zoom level has changed):
356  refreshMouse();
357  }
358  else
359  {
360  // Scrolling
361  VECTOR2D scrollVec = m_view->ToWorld( m_view->GetScreenPixelSize(), false ) *
362  ( (double) aEvent.GetWheelRotation() * wheelPanSpeed );
363  double scrollX = 0.0;
364  double scrollY = 0.0;
365 
366  if( axis == wxMOUSE_WHEEL_HORIZONTAL || modifiers == m_settings.m_scrollModifierPanH )
367  scrollX = scrollVec.x;
368  else
369  scrollY = -scrollVec.y;
370 
371  VECTOR2D delta( scrollX, scrollY );
372 
374  refreshMouse();
375  }
376 
377  // Do not skip this event, otherwise wxWidgets will fire
378  // 3 wxEVT_SCROLLWIN_LINEUP or wxEVT_SCROLLWIN_LINEDOWN (normal wxWidgets behavior)
379  // and we do not want that.
381 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:449
const VECTOR2D & GetCenter() const
Return the center point of this VIEW (in world space coordinates).
Definition: view.h:334
std::unique_ptr< ZOOM_CONTROLLER > m_zoomController
Define a general 2D-vector/point.
Definition: vector2d.h:61
VC_SETTINGS m_settings
VIEW * m_view
< Pointer to controlled VIEW.
int m_scrollModifierPanH
What modifier key to enable vertical with the (vertical) scroll wheel.
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
VECTOR2< double > VECTOR2D
Definition: vector2d.h:621
int m_scrollModifierZoom
What modifier key to enable horizontal pan with the (vertical) scroll wheel.
const VECTOR2I & GetScreenPixelSize() const
Return the size of the our rendering area in pixels.
Definition: view.cpp:1167
bool IsCursorWarpingEnabled() const
bool m_horizontalPan
Enable the accelerating zoom controller.
Definition: view_controls.h:88
void refreshMouse()
Send an event to refresh mouse position.
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:552
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
constexpr int delta
double GetScale() const
Definition: view.h:264
void CenterOnCursor() const override
Adjusts the scrollbars position to match the current viewport.

References anchor, CenterOnCursor(), delta, KIGFX::VIEW::GetCenter(), KIGFX::VIEW::GetScale(), KIGFX::VIEW::GetScreenPixelSize(), KIGFX::VIEW_CONTROLS::IsCursorWarpingEnabled(), KIGFX::VC_SETTINGS::m_horizontalPan, m_parentPanel, KIGFX::VC_SETTINGS::m_scrollModifierPanH, KIGFX::VC_SETTINGS::m_scrollModifierZoom, KIGFX::VIEW_CONTROLS::m_settings, KIGFX::VIEW_CONTROLS::m_view, m_zoomController, EDA_DRAW_PANEL_GAL::Refresh(), refreshMouse(), KIGFX::VIEW::SetCenter(), KIGFX::VIEW::SetScale(), KIGFX::VIEW::ToWorld(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by WX_VIEW_CONTROLS().

◆ refreshMouse()

void WX_VIEW_CONTROLS::refreshMouse ( )
private

Send an event to refresh mouse position.

It is mostly used for notifying the tools that the cursor position in the world coordinates has changed, whereas the screen coordinates remained the same (e.g. frame edge autopanning).

Definition at line 885 of file wx_view_controls.cpp.

886 {
887  // Notify tools that the cursor position has changed in the world coordinates
888  wxMouseEvent moveEvent( EVT_REFRESH_MOUSE );
889  wxPoint msp = getMouseScreenPosition();
890  moveEvent.SetX( msp.x );
891  moveEvent.SetY( msp.y );
892 
893  // Set the modifiers state
894  moveEvent.SetControlDown( wxGetKeyState( WXK_CONTROL ) );
895  moveEvent.SetShiftDown( wxGetKeyState( WXK_SHIFT ) );
896  moveEvent.SetAltDown( wxGetKeyState( WXK_ALT ) );
897 
898  m_cursorPos = GetClampedCoords( m_view->ToWorld( VECTOR2D( msp.x, msp.y ) ) );
899  wxPostEvent( m_parentPanel, moveEvent );
900 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
static const wxEventType EVT_REFRESH_MOUSE
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:449
wxPoint getMouseScreenPosition() const
Get the cursor position in the screen coordinates.
Define a general 2D-vector/point.
Definition: vector2d.h:61
VIEW * m_view
< Pointer to controlled VIEW.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=0u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
VECTOR2D m_cursorPos
Flag deciding whether the cursor position should be calculated using the mouse position.

References EVT_REFRESH_MOUSE, GetClampedCoords(), getMouseScreenPosition(), m_cursorPos, m_parentPanel, KIGFX::VIEW_CONTROLS::m_view, and KIGFX::VIEW::ToWorld().

Referenced by onTimer(), onWheel(), UpdateScrollbars(), and WarpCursor().

◆ Reset()

void VIEW_CONTROLS::Reset ( )
virtualinherited

Restore the default VIEW_CONTROLS settings.

Return the current VIEW_CONTROLS settings.

Definition at line 50 of file view_controls.cpp.

51 {
52  // Get the default settings from the default constructor
55 }
void ApplySettings(const VC_SETTINGS &aSettings)
Load new settings from program common settings.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
Definition: view_controls.h:41
static LIB_SYMBOL * dummy()
Used when a LIB_SYMBOL is not found in library to draw a dummy shape.

References KIGFX::VIEW_CONTROLS::ApplySettings(), and KIGFX::dummy().

◆ SetAutoPan()

virtual void KIGFX::VIEW_CONTROLS::SetAutoPan ( bool  aEnabled)
inlinevirtualinherited

Turn on/off auto panning (this feature is used when there is a tool active (eg.

drawing a track) and user moves mouse to the VIEW edge - then the view can be translated or not).

Parameters
aEnabledtells if the autopanning should be active.

Definition at line 156 of file view_controls.h.

157  {
158  m_settings.m_autoPanEnabled = aEnabled;
159  }
VC_SETTINGS m_settings
bool m_autoPanEnabled
Flag for turning on autopanning.
Definition: view_controls.h:70

References KIGFX::VC_SETTINGS::m_autoPanEnabled, and KIGFX::VIEW_CONTROLS::m_settings.

Referenced by KIGFX::VIEW_CONTROLS::ApplySettings(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), ROUTER_TOOL::finishInteractive(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), ROUTER_TOOL::InlineDrag(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), PCB_POINT_EDITOR::Reset(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ SetAutoPanAcceleration()

virtual void KIGFX::VIEW_CONTROLS::SetAutoPanAcceleration ( float  aAcceleration)
inlinevirtualinherited

Set the speed of autopanning.

Parameters
aSpeedis a new speed for autopanning.

Definition at line 186 of file view_controls.h.

187  {
188  m_settings.m_autoPanAcceleration = aAcceleration;
189  }
VC_SETTINGS m_settings
float m_autoPanAcceleration
If the cursor is allowed to be warped.
Definition: view_controls.h:82

References KIGFX::VC_SETTINGS::m_autoPanAcceleration, and KIGFX::VIEW_CONTROLS::m_settings.

◆ SetAutoPanMargin()

virtual void KIGFX::VIEW_CONTROLS::SetAutoPanMargin ( float  aMargin)
inlinevirtualinherited

Set the margin for autopanning (ie.

the area when autopanning becomes active).

Parameters
aMarginis a new margin for autopanning.

Definition at line 196 of file view_controls.h.

197  {
198  m_settings.m_autoPanMargin = aMargin;
199  }
VC_SETTINGS m_settings
float m_autoPanMargin
How fast is panning when in auto mode.
Definition: view_controls.h:76

References KIGFX::VC_SETTINGS::m_autoPanMargin, and KIGFX::VIEW_CONTROLS::m_settings.

Referenced by KIGFX::VIEW_CONTROLS::ApplySettings().

◆ SetAutoPanSpeed()

virtual void KIGFX::VIEW_CONTROLS::SetAutoPanSpeed ( float  aSpeed)
inlinevirtualinherited

Set the speed of autopanning.

Parameters
aSpeedis a new speed for autopanning.

Definition at line 176 of file view_controls.h.

177  {
178  m_settings.m_autoPanSpeed = aSpeed;
179  }
float m_autoPanSpeed
How fast does panning accelerate when approaching the window boundary.
Definition: view_controls.h:79
VC_SETTINGS m_settings

References KIGFX::VC_SETTINGS::m_autoPanSpeed, and KIGFX::VIEW_CONTROLS::m_settings.

Referenced by KIGFX::VIEW_CONTROLS::ApplySettings().

◆ SetCrossHairCursorPosition()

void WX_VIEW_CONTROLS::SetCrossHairCursorPosition ( const VECTOR2D aPosition,
bool  aWarpView = true 
)
overridevirtual

Implements KIGFX::VIEW_CONTROLS.

Definition at line 711 of file wx_view_controls.cpp.

713 {
714  m_updateCursor = false;
715 
716  VECTOR2D clampedPosition = GetClampedCoords( aPosition );
717 
718  const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
719  BOX2I screen( VECTOR2I( 0, 0 ), screenSize );
720  VECTOR2D screenPos = m_view->ToScreen( clampedPosition );
721 
722  if( aWarpView && !screen.Contains( screenPos ) )
723  m_view->SetCenter( clampedPosition );
724 
725  m_cursorPos = clampedPosition;
726 }
Define a general 2D-vector/point.
Definition: vector2d.h:61
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
VIEW * m_view
< Pointer to controlled VIEW.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=0u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
VECTOR2D ToScreen(const VECTOR2D &aCoord, bool aAbsolute=true) const
Convert a world space point/vector to a point/vector in screen space coordinates.
Definition: view.cpp:468
bool m_updateCursor
A #ZOOM_CONTROLLER that determines zoom steps. This is platform-specific.
VECTOR2D m_cursorPos
Flag deciding whether the cursor position should be calculated using the mouse position.

References BOX2< Vec >::Contains(), GetClampedCoords(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetScreenPixelSize(), m_cursorPos, m_updateCursor, KIGFX::VIEW_CONTROLS::m_view, KIGFX::VIEW::SetCenter(), and KIGFX::VIEW::ToScreen().

◆ SetCursorPosition()

void WX_VIEW_CONTROLS::SetCursorPosition ( const VECTOR2D aPosition,
bool  warpView,
bool  aTriggeredByArrows,
long  aArrowCommand 
)
overridevirtual

Move the graphic crosshair cursor to the requested position expressed in world coordinates.

Note
The position is clamped if outside of coordinates representation limits.
Parameters
aPositionis the requested cursor position in the world coordinates.
aWarpViewenables/disables view warp if the cursor is outside the current viewport.

Implements KIGFX::VIEW_CONTROLS.

Definition at line 684 of file wx_view_controls.cpp.

686 {
687  m_updateCursor = false;
688 
689  VECTOR2D clampedPosition = GetClampedCoords( aPosition );
690 
691  if( aTriggeredByArrows )
692  {
694  m_settings.m_lastKeyboardCursorPosition = clampedPosition;
695  m_settings.m_lastKeyboardCursorCommand = aArrowCommand;
696  m_cursorWarped = false;
697  }
698  else
699  {
703  m_cursorWarped = true;
704  }
705 
706  WarpCursor( clampedPosition, true, aWarpView );
707  m_cursorPos = clampedPosition;
708 }
Define a general 2D-vector/point.
Definition: vector2d.h:61
VC_SETTINGS m_settings
VECTOR2D m_lastKeyboardCursorPosition
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=0u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
bool m_cursorWarped
Current VIEW_CONTROLS settings.
void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false) override
Set the viewport center to the current cursor position and warps the cursor to the screen center.
long m_lastKeyboardCursorCommand
Position of the above event.
bool m_updateCursor
A #ZOOM_CONTROLLER that determines zoom steps. This is platform-specific.
bool m_lastKeyboardCursorPositionValid
ACTIONS::CURSOR_UP, ACTIONS::CURSOR_DOWN, etc.
VECTOR2D m_cursorPos
Flag deciding whether the cursor position should be calculated using the mouse position.

References GetClampedCoords(), m_cursorPos, KIGFX::VIEW_CONTROLS::m_cursorWarped, KIGFX::VC_SETTINGS::m_lastKeyboardCursorCommand, KIGFX::VC_SETTINGS::m_lastKeyboardCursorPosition, KIGFX::VC_SETTINGS::m_lastKeyboardCursorPositionValid, KIGFX::VIEW_CONTROLS::m_settings, m_updateCursor, and WarpCursor().

◆ SetGrabMouse()

virtual void KIGFX::VIEW_CONTROLS::SetGrabMouse ( bool  aEnabled)
inlinevirtualinherited

Turn on/off mouse grabbing.

When the mouse is grabbed, it cannot go outside the VIEW.

Parameters
aEnabledtells if mouse should be grabbed or not.

Definition at line 145 of file view_controls.h.

146  {
147  m_settings.m_grabMouse = aEnabled;
148  }
bool m_grabMouse
Flag for turning on autopanning.
Definition: view_controls.h:67
VC_SETTINGS m_settings

References KIGFX::VC_SETTINGS::m_grabMouse, and KIGFX::VIEW_CONTROLS::m_settings.

Referenced by KIGFX::VIEW_CONTROLS::ApplySettings().

◆ ShowCursor()

void VIEW_CONTROLS::ShowCursor ( bool  aEnabled)
virtualinherited

Enable or disables display of cursor.

Parameters
aEnableddecides if the cursor should be shown.

Definition at line 34 of file view_controls.cpp.

35 {
36  m_settings.m_showCursor = aEnabled;
37  m_view->GetGAL()->SetCursorEnabled( aEnabled );
38 }
void SetCursorEnabled(bool aCursorEnabled)
Enable/disable cursor.
VC_SETTINGS m_settings
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
VIEW * m_view
< Pointer to controlled VIEW.
bool m_showCursor
Forced cursor position (world coordinates).
Definition: view_controls.h:52

References KIGFX::VIEW::GetGAL(), KIGFX::VIEW_CONTROLS::m_settings, KIGFX::VC_SETTINGS::m_showCursor, KIGFX::VIEW_CONTROLS::m_view, and KIGFX::GAL::SetCursorEnabled().

Referenced by KIGFX::VIEW_CONTROLS::ApplySettings(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), PL_POINT_EDITOR::setEditedPoint(), EE_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ UpdateScrollbars()

void WX_VIEW_CONTROLS::UpdateScrollbars ( )

End any mouse drag action still in progress.

Definition at line 911 of file wx_view_controls.cpp.

912 {
913  const BOX2D viewport = m_view->GetViewport();
914  const BOX2D& boundary = m_view->GetBoundary();
915 
916  m_scrollScale.x = 2e3 / viewport.GetWidth(); // TODO it does not have to be updated so often
917  m_scrollScale.y = 2e3 / viewport.GetHeight();
918  VECTOR2I newScroll( ( viewport.Centre().x - boundary.GetLeft() ) * m_scrollScale.x,
919  ( viewport.Centre().y - boundary.GetTop() ) * m_scrollScale.y );
920 
921  // We add the width of the scroll bar thumb to the range because the scroll range is given by
922  // the full bar while the position is given by the left/top position of the thumb
923  VECTOR2I newRange( m_scrollScale.x * boundary.GetWidth() +
924  m_parentPanel->GetScrollThumb( wxSB_HORIZONTAL ),
925  m_scrollScale.y * boundary.GetHeight() +
926  m_parentPanel->GetScrollThumb( wxSB_VERTICAL ) );
927 
928  // Flip scroll direction in flipped view
929  if( m_view->IsMirroredX() )
930  newScroll.x = ( boundary.GetRight() - viewport.Centre().x ) * m_scrollScale.x;
931 
932  // Adjust scrollbars only if it is needed. Otherwise there are cases when canvas is continuously
933  // refreshed (Windows)
934  if( m_scrollPos != newScroll || newRange.x != m_parentPanel->GetScrollRange( wxSB_HORIZONTAL )
935  || newRange.y != m_parentPanel->GetScrollRange( wxSB_VERTICAL ) )
936  {
937  m_parentPanel->SetScrollbars( 1, 1, newRange.x, newRange.y, newScroll.x, newScroll.y,
938  true );
939  m_scrollPos = newScroll;
940 
941 #if !defined( __APPLE__ ) && !defined( WIN32 )
942  // Trigger a mouse refresh to get the canvas update in GTK (re-draws the scrollbars).
943  // Note that this causes an infinite loop on OSX and Windows (in certain cases) as it
944  // generates a paint event.
945  refreshMouse();
946 #endif
947  }
948 }
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:512
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
const BOX2D & GetBoundary() const
Definition: view.h:293
coord_type GetTop() const
Definition: box2.h:187
coord_type GetRight() const
Definition: box2.h:182
VIEW * m_view
< Pointer to controlled VIEW.
VECTOR2D m_scrollScale
Current scrollbar position.
coord_type GetWidth() const
Definition: box2.h:180
void refreshMouse()
Send an event to refresh mouse position.
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:238
Vec Centre() const
Definition: box2.h:63
VECTOR2I m_scrollPos
The zoom scale when a drag zoom started.
coord_type GetHeight() const
Definition: box2.h:181
coord_type GetLeft() const
Definition: box2.h:186

References BOX2< Vec >::Centre(), KIGFX::VIEW::GetBoundary(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), KIGFX::VIEW::GetViewport(), BOX2< Vec >::GetWidth(), KIGFX::VIEW::IsMirroredX(), m_parentPanel, m_scrollPos, m_scrollScale, KIGFX::VIEW_CONTROLS::m_view, refreshMouse(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by EDA_DRAW_PANEL_GAL::DoRePaint().

◆ WarpCursor()

void WX_VIEW_CONTROLS::WarpCursor ( const VECTOR2D aPosition,
bool  aWorldCoordinates = false,
bool  aWarpView = false 
)
overridevirtual

Set the viewport center to the current cursor position and warps the cursor to the screen center.

Implements KIGFX::VIEW_CONTROLS.

Definition at line 729 of file wx_view_controls.cpp.

731 {
732  if( aWorldCoordinates )
733  {
734  const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
735  BOX2I screen( VECTOR2I( 0, 0 ), screenSize );
736  VECTOR2D clampedPosition = GetClampedCoords( aPosition );
737  VECTOR2D screenPos = m_view->ToScreen( clampedPosition );
738 
739  if( !screen.Contains( screenPos ) )
740  {
741  if( aWarpView )
742  {
743  m_view->SetCenter( clampedPosition );
744  m_parentPanel->WarpPointer( screenSize.x / 2, screenSize.y / 2 );
745  }
746  }
747  else
748  {
749  m_parentPanel->WarpPointer( screenPos.x, screenPos.y );
750  }
751  }
752  else
753  {
754  m_parentPanel->WarpPointer( aPosition.x, aPosition.y );
755  }
756 
757  refreshMouse();
758 }
EDA_DRAW_PANEL_GAL * m_parentPanel
Store information about point where dragging has started.
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:190
VIEW * m_view
< Pointer to controlled VIEW.
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
const VECTOR2I & GetScreenPixelSize() const
Return GAL canvas size in pixels.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=0u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
void SetCenter(const VECTOR2D &aCenter)
Set the center point of the VIEW (i.e.
Definition: view.cpp:578
void refreshMouse()
Send an event to refresh mouse position.
VECTOR2D ToScreen(const VECTOR2D &aCoord, bool aAbsolute=true) const
Convert a world space point/vector to a point/vector in screen space coordinates.
Definition: view.cpp:468

References BOX2< Vec >::Contains(), GetClampedCoords(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetScreenPixelSize(), m_parentPanel, KIGFX::VIEW_CONTROLS::m_view, refreshMouse(), KIGFX::VIEW::SetCenter(), KIGFX::VIEW::ToScreen(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SetCursorPosition().

Member Data Documentation

◆ EVT_REFRESH_MOUSE

const wxEventType WX_VIEW_CONTROLS::EVT_REFRESH_MOUSE = wxNewEventType()
static

◆ m_cursorPos

VECTOR2D KIGFX::WX_VIEW_CONTROLS::m_cursorPos
private

Flag deciding whether the cursor position should be calculated using the mouse position.

Definition at line 198 of file wx_view_controls.h.

Referenced by GetRawCursorPosition(), onMotion(), refreshMouse(), SetCrossHairCursorPosition(), and SetCursorPosition().

◆ m_cursorWarped

bool KIGFX::VIEW_CONTROLS::m_cursorWarped
protectedinherited

Current VIEW_CONTROLS settings.

Definition at line 376 of file view_controls.h.

Referenced by handleAutoPanning(), SetCursorPosition(), and WX_VIEW_CONTROLS().

◆ m_dragStartPoint

VECTOR2D KIGFX::WX_VIEW_CONTROLS::m_dragStartPoint
private

Stores information about the center of viewport when dragging has started.

Definition at line 169 of file wx_view_controls.h.

Referenced by onButton(), and onMotion().

◆ m_initialZoomScale

double KIGFX::WX_VIEW_CONTROLS::m_initialZoomScale
private

The mouse position when a drag zoom started.

Definition at line 187 of file wx_view_controls.h.

Referenced by onButton(), and onMotion().

◆ m_lookStartPoint

VECTOR2D KIGFX::WX_VIEW_CONTROLS::m_lookStartPoint
private

Current direction of panning (only autopanning mode).

Definition at line 172 of file wx_view_controls.h.

Referenced by onButton(), and onMotion().

◆ m_MotionEventCounter

std::unique_ptr<PROF_COUNTER> KIGFX::WX_VIEW_CONTROLS::m_MotionEventCounter

Definition at line 119 of file wx_view_controls.h.

Referenced by EVT_UPDATE_UI_RANGE(), and WX_VIEW_CONTROLS().

◆ m_panDirection

VECTOR2D KIGFX::WX_VIEW_CONTROLS::m_panDirection
private

Timer responsible for handling autopanning.

Definition at line 175 of file wx_view_controls.h.

Referenced by handleAutoPanning(), and onTimer().

◆ m_panTimer

wxTimer KIGFX::WX_VIEW_CONTROLS::m_panTimer
private

Ratio used for scaling world coordinates to scrollbar position.

Definition at line 178 of file wx_view_controls.h.

Referenced by handleAutoPanning(), and WX_VIEW_CONTROLS().

◆ m_parentPanel

EDA_DRAW_PANEL_GAL* KIGFX::WX_VIEW_CONTROLS::m_parentPanel
private

◆ m_scrollPos

VECTOR2I KIGFX::WX_VIEW_CONTROLS::m_scrollPos
private

The zoom scale when a drag zoom started.

Definition at line 184 of file wx_view_controls.h.

Referenced by UpdateScrollbars().

◆ m_scrollScale

VECTOR2D KIGFX::WX_VIEW_CONTROLS::m_scrollScale
private

Current scrollbar position.

Definition at line 181 of file wx_view_controls.h.

Referenced by onScroll(), and UpdateScrollbars().

◆ m_settings

◆ m_state

STATE KIGFX::WX_VIEW_CONTROLS::m_state
private

Panel that is affected by VIEW_CONTROLS.

Definition at line 163 of file wx_view_controls.h.

Referenced by CancelDrag(), CaptureCursor(), handleAutoPanning(), onButton(), onMotion(), and onTimer().

◆ m_updateCursor

bool KIGFX::WX_VIEW_CONTROLS::m_updateCursor
private

A #ZOOM_CONTROLLER that determines zoom steps. This is platform-specific.

Definition at line 201 of file wx_view_controls.h.

Referenced by onMotion(), SetCrossHairCursorPosition(), and SetCursorPosition().

◆ m_view

VIEW* KIGFX::VIEW_CONTROLS::m_view
protectedinherited

◆ m_zoomController

std::unique_ptr<ZOOM_CONTROLLER> KIGFX::WX_VIEW_CONTROLS::m_zoomController
private

Definition at line 204 of file wx_view_controls.h.

Referenced by LoadSettings(), and onWheel().

◆ m_zoomStartPoint

VECTOR2D KIGFX::WX_VIEW_CONTROLS::m_zoomStartPoint
private

Current cursor position (world coordinates).

Definition at line 190 of file wx_view_controls.h.

Referenced by onButton(), and onMotion().


The documentation for this class was generated from the following files: