Browse Source

Fixed SELECTION_TOOL::selectCursor()

In the previous version the method did not work correctly
when an action was invoked from context menu. In such case,
the cursor position was obtained in the moment of selecting
the action, instead of using the right click location.
pull/7/merge
Maciej Suminski 8 years ago
parent
commit
08c4a0bc7b
  1. 4
      common/view/wx_view_controls.cpp
  2. 16
      include/view/view_controls.h
  3. 4
      include/view/wx_view_controls.h
  4. 2
      pcbnew/tools/selection_tool.cpp

4
common/view/wx_view_controls.cpp

@ -362,7 +362,7 @@ VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
}
VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition() const
VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition( bool aEnableSnapping ) const
{
if( m_settings.m_forceCursorPosition )
{
@ -372,7 +372,7 @@ VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition() const
{
VECTOR2D mousePosition = GetMousePosition();
if( m_settings.m_snappingEnabled )
if( aEnableSnapping )
return m_view->GetGAL()->GetGridPoint( mousePosition );
else
return mousePosition;

16
include/view/view_controls.h

@ -166,14 +166,26 @@ public:
virtual VECTOR2D GetMousePosition( bool aWorldCoordinates = true ) const = 0;
/**
* Function GetCursorPosition()
* Returns the current cursor position in world coordinates. Note, that it may be
* different from the mouse pointer position if snapping is enabled or cursor position
* is forced to a specific point.
*
* @return The current cursor position in world coordinates.
*/
virtual VECTOR2D GetCursorPosition() const = 0;
VECTOR2D GetCursorPosition() const
{
return GetCursorPosition( m_settings.m_snappingEnabled );
}
/**
* Returns the current cursor position in world coordinates. Note, that it may be
* different from the mouse pointer position if snapping is enabled or cursor position
* is forced to a specific point.
*
* @param aEnableSnapping selects whether cursor position should be snapped to the grid.
* @return The current cursor position in world coordinates.
*/
virtual VECTOR2D GetCursorPosition( bool aEnableSnapping ) const = 0;
/**
* Function ForceCursorPosition()

4
include/view/wx_view_controls.h

@ -73,8 +73,10 @@ public:
/// @copydoc VIEW_CONTROLS::GetMousePosition()
VECTOR2D GetMousePosition( bool aWorldCoordinates = true ) const override;
using VIEW_CONTROLS::GetCursorPosition;
/// @copydoc VIEW_CONTROLS::GetCursorPosition()
VECTOR2D GetCursorPosition() const override;
VECTOR2D GetCursorPosition( bool aSnappingEnabled ) const override;
/// @copydoc VIEW_CONTROLS::CursorWarp()
void WarpCursor( const VECTOR2D& aPosition, bool aWorldCoordinates = false,

2
pcbnew/tools/selection_tool.cpp

@ -472,7 +472,7 @@ bool SELECTION_TOOL::selectCursor( bool aSelectAlways )
if( aSelectAlways || m_selection.Empty() )
{
clearSelection();
selectPoint( getViewControls()->GetMousePosition() );
selectPoint( getViewControls()->GetCursorPosition( false ) );
}
return !m_selection.Empty();

Loading…
Cancel
Save