From e6598e9d41434c2389da642eea5c0993ab00dd09 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 27 Feb 2014 16:13:27 +0100 Subject: [PATCH] Added VIEW::ToWorld( double ). TOOL_EVENT message is supposed to contain string as parameter. Added missing header for class_drawsegment.h (KiROUND). Renamed SELECTION_TOOL::containsSelected() to SELECTION_TOOL::selectionContains(). --- common/view/view.cpp | 8 ++++++++ include/tool/tool_event.h | 4 ++-- include/view/view.h | 8 ++++++++ pcbnew/class_drawsegment.h | 1 + pcbnew/tools/edit_tool.h | 2 +- pcbnew/tools/selection_tool.cpp | 4 ++-- pcbnew/tools/selection_tool.h | 2 +- 7 files changed, 23 insertions(+), 6 deletions(-) diff --git a/common/view/view.cpp b/common/view/view.cpp index 428dd7e594..1baa2599fc 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -204,6 +204,14 @@ VECTOR2D VIEW::ToWorld( const VECTOR2D& aCoord, bool aAbsolute ) const } +double VIEW::ToWorld( double aSize ) const +{ + const MATRIX3x3D& matrix = m_gal->GetScreenWorldMatrix(); + + return matrix.GetScale().x * aSize; +} + + VECTOR2D VIEW::ToScreen( const VECTOR2D& aCoord, bool aAbsolute ) const { const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix(); diff --git a/include/tool/tool_event.h b/include/tool/tool_event.h index 3f7971ed77..4571b5a9f8 100644 --- a/include/tool/tool_event.h +++ b/include/tool/tool_event.h @@ -189,7 +189,7 @@ public: m_scope( aScope ), m_mouseButtons( 0 ) { - if( aCategory == TC_COMMAND ) + if( aCategory == TC_COMMAND || aCategory == TC_MESSAGE ) m_commandStr = aExtraParam; } @@ -317,7 +317,7 @@ public: if( !( m_actions & aEvent.m_actions ) ) return false; - if( m_category == TC_COMMAND ) + if( m_category == TC_COMMAND || m_category == TC_MESSAGE ) { if( m_commandStr && aEvent.m_commandStr ) return *m_commandStr == *aEvent.m_commandStr; diff --git a/include/view/view.h b/include/view/view.h index 4a7965bb94..dbb82954a0 100644 --- a/include/view/view.h +++ b/include/view/view.h @@ -232,6 +232,14 @@ public: */ VECTOR2D ToWorld( const VECTOR2D& aCoord, bool aAbsolute = true ) const; + /** + * Function ToWorld() + * Converts a screen space one dimensional size to a one dimensional size in world + * space coordinates. + * @param aCoord: the size to be converted + */ + double ToWorld( double aSize ) const; + /** * Function ToScreen() * Converts a world space point/vector to a point/vector in screen space coordinates. diff --git a/pcbnew/class_drawsegment.h b/pcbnew/class_drawsegment.h index 635a3235d7..56862aa7db 100644 --- a/pcbnew/class_drawsegment.h +++ b/pcbnew/class_drawsegment.h @@ -34,6 +34,7 @@ #include #include #include +#include class LINE_READER; diff --git a/pcbnew/tools/edit_tool.h b/pcbnew/tools/edit_tool.h index 49fbe48450..b5f6f1fc0d 100644 --- a/pcbnew/tools/edit_tool.h +++ b/pcbnew/tools/edit_tool.h @@ -101,7 +101,7 @@ private: ///> Removes and frees a single BOARD_ITEM. void remove( BOARD_ITEM* aItem ); - ///> Sets up handlers for various events + ///> Sets up handlers for various events. void setTransitions(); ///> The required update flag for modified items diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 366c81659a..0e1a241868 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -133,7 +133,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) else { // Check if dragging has started within any of selected items bounding box - if( containsSelected( evt->Position() ) ) + if( selectionContains( evt->Position() ) ) { // Yes -> run the move tool and wait till it finishes m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" ); @@ -566,7 +566,7 @@ void SELECTION_TOOL::deselectVisually( BOARD_ITEM* aItem ) const } -bool SELECTION_TOOL::containsSelected( const VECTOR2I& aPoint ) const +bool SELECTION_TOOL::selectionContains( const VECTOR2I& aPoint ) const { const unsigned GRIP_MARGIN = 20; VECTOR2D margin = getView()->ToWorld( VECTOR2D( GRIP_MARGIN, GRIP_MARGIN ), false ); diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index 4c5e4b2d9a..ab320b1d5e 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -207,7 +207,7 @@ private: * * @return True if the given point is contained in any of selected items' bouding box. */ - bool containsSelected( const VECTOR2I& aPoint ) const; + bool selectionContains( const VECTOR2I& aPoint ) const; /// Visual representation of selection box SELECTION_AREA* m_selArea;