VIEW_CONTROLS::GetMousePosition() returns the mouse position in world coordinates.
This commit is contained in:
parent
ad48cd435d
commit
dcc803ecb1
|
@ -264,8 +264,7 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
|||
wxMouseEvent* me = static_cast<wxMouseEvent*>( &aEvent );
|
||||
int mods = decodeModifiers( me );
|
||||
|
||||
VECTOR2D screenPos = m_toolMgr->GetViewControls()->GetMousePosition();
|
||||
VECTOR2D pos = getView()->ToWorld( screenPos );
|
||||
VECTOR2D pos = m_toolMgr->GetViewControls()->GetMousePosition();
|
||||
|
||||
if( pos != m_lastMousePos )
|
||||
{
|
||||
|
|
|
@ -352,12 +352,13 @@ void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
|
|||
}
|
||||
|
||||
|
||||
VECTOR2I WX_VIEW_CONTROLS::GetMousePosition() const
|
||||
VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
|
||||
{
|
||||
wxPoint msp = wxGetMousePosition();
|
||||
wxPoint winp = m_parentPanel->GetScreenPosition();
|
||||
VECTOR2D screenPos( msp.x - winp.x, msp.y - winp.y );
|
||||
|
||||
return VECTOR2I( msp.x - winp.x, msp.y - winp.y );
|
||||
return aWorldCoordinates ? m_view->ToWorld( screenPos ) : screenPos;
|
||||
}
|
||||
|
||||
|
||||
|
@ -372,9 +373,9 @@ VECTOR2D WX_VIEW_CONTROLS::GetCursorPosition() const
|
|||
VECTOR2D mousePosition = GetMousePosition();
|
||||
|
||||
if( m_settings.m_snappingEnabled )
|
||||
return m_view->GetGAL()->GetGridPoint( m_view->ToWorld( mousePosition ) );
|
||||
return m_view->GetGAL()->GetGridPoint( mousePosition );
|
||||
else
|
||||
return m_view->ToWorld( mousePosition );
|
||||
return mousePosition;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -413,7 +414,7 @@ void WX_VIEW_CONTROLS::CenterOnCursor() const
|
|||
const VECTOR2I& screenSize = m_view->GetGAL()->GetScreenPixelSize();
|
||||
VECTOR2I screenCenter( screenSize / 2 );
|
||||
|
||||
if( GetMousePosition() != screenCenter )
|
||||
if( GetMousePosition( false ) != screenCenter )
|
||||
{
|
||||
m_view->SetCenter( GetCursorPosition() );
|
||||
m_parentPanel->WarpPointer( KiROUND( screenSize.x / 2 ), KiROUND( screenSize.y / 2 ) );
|
||||
|
|
|
@ -156,18 +156,20 @@ public:
|
|||
|
||||
/**
|
||||
* Function GetMousePosition()
|
||||
* Returns the current mouse pointer position in screen coordinates. Note, that it may be
|
||||
* Returns the current mouse pointer position. Note, that it may be
|
||||
* different from the cursor position if snapping is enabled (@see GetCursorPosition()).
|
||||
*
|
||||
* @return The current mouse pointer position in the screen coordinates.
|
||||
* @param aWorldCoordinates if true, the result is given in world coordinates, otherwise
|
||||
* it is given in screen coordinates.
|
||||
* @return The current mouse pointer position in either world or screen coordinates.
|
||||
*/
|
||||
virtual VECTOR2I GetMousePosition() const = 0;
|
||||
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 specific point.
|
||||
* is forced to a specific point.
|
||||
*
|
||||
* @return The current cursor position in world coordinates.
|
||||
*/
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
*/
|
||||
|
||||
/// @copydoc VIEW_CONTROLS::GetMousePosition()
|
||||
VECTOR2I GetMousePosition() const override;
|
||||
VECTOR2D GetMousePosition( bool aWorldCoordinates = true ) const override;
|
||||
|
||||
/// @copydoc VIEW_CONTROLS::GetCursorPosition()
|
||||
VECTOR2D GetCursorPosition() const override;
|
||||
|
|
|
@ -238,8 +238,7 @@ void TOOL_BASE::updateStartItem( TOOL_EVENT& aEvent )
|
|||
|
||||
void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
VECTOR2I mp = m_ctls->GetMousePosition();
|
||||
VECTOR2I p = getView()->ToWorld( mp );
|
||||
VECTOR2I p = m_ctls->GetMousePosition();
|
||||
int layer;
|
||||
bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
|
||||
|
||||
|
|
|
@ -1032,7 +1032,7 @@ int PCB_EDITOR_CONTROL::HighlightNet( const TOOL_EVENT& aEvent )
|
|||
else
|
||||
{
|
||||
// No net code specified, pick the net code belonging to the item under the cursor
|
||||
highlightNet( m_toolMgr, getView()->ToWorld( getViewControls()->GetMousePosition() ) );
|
||||
highlightNet( m_toolMgr, getViewControls()->GetMousePosition() );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue