Commit e6598e9d authored by Maciej Suminski's avatar Maciej Suminski

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().
parent a42a83a3
...@@ -204,6 +204,14 @@ VECTOR2D VIEW::ToWorld( const VECTOR2D& aCoord, bool aAbsolute ) const ...@@ -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 VECTOR2D VIEW::ToScreen( const VECTOR2D& aCoord, bool aAbsolute ) const
{ {
const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix(); const MATRIX3x3D& matrix = m_gal->GetWorldScreenMatrix();
......
...@@ -189,7 +189,7 @@ public: ...@@ -189,7 +189,7 @@ public:
m_scope( aScope ), m_scope( aScope ),
m_mouseButtons( 0 ) m_mouseButtons( 0 )
{ {
if( aCategory == TC_COMMAND ) if( aCategory == TC_COMMAND || aCategory == TC_MESSAGE )
m_commandStr = aExtraParam; m_commandStr = aExtraParam;
} }
...@@ -317,7 +317,7 @@ public: ...@@ -317,7 +317,7 @@ public:
if( !( m_actions & aEvent.m_actions ) ) if( !( m_actions & aEvent.m_actions ) )
return false; return false;
if( m_category == TC_COMMAND ) if( m_category == TC_COMMAND || m_category == TC_MESSAGE )
{ {
if( m_commandStr && aEvent.m_commandStr ) if( m_commandStr && aEvent.m_commandStr )
return *m_commandStr == *aEvent.m_commandStr; return *m_commandStr == *aEvent.m_commandStr;
......
...@@ -232,6 +232,14 @@ public: ...@@ -232,6 +232,14 @@ public:
*/ */
VECTOR2D ToWorld( const VECTOR2D& aCoord, bool aAbsolute = true ) const; 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() * Function ToScreen()
* Converts a world space point/vector to a point/vector in screen space coordinates. * Converts a world space point/vector to a point/vector in screen space coordinates.
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <PolyLine.h> #include <PolyLine.h>
#include <math_for_graphics.h> #include <math_for_graphics.h>
#include <trigo.h> #include <trigo.h>
#include <common.h>
class LINE_READER; class LINE_READER;
......
...@@ -101,7 +101,7 @@ private: ...@@ -101,7 +101,7 @@ private:
///> Removes and frees a single BOARD_ITEM. ///> Removes and frees a single BOARD_ITEM.
void remove( BOARD_ITEM* aItem ); void remove( BOARD_ITEM* aItem );
///> Sets up handlers for various events ///> Sets up handlers for various events.
void setTransitions(); void setTransitions();
///> The required update flag for modified items ///> The required update flag for modified items
......
...@@ -133,7 +133,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) ...@@ -133,7 +133,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
else else
{ {
// Check if dragging has started within any of selected items bounding box // 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 // Yes -> run the move tool and wait till it finishes
m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" ); m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
...@@ -566,7 +566,7 @@ void SELECTION_TOOL::deselectVisually( BOARD_ITEM* aItem ) const ...@@ -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; const unsigned GRIP_MARGIN = 20;
VECTOR2D margin = getView()->ToWorld( VECTOR2D( GRIP_MARGIN, GRIP_MARGIN ), false ); VECTOR2D margin = getView()->ToWorld( VECTOR2D( GRIP_MARGIN, GRIP_MARGIN ), false );
......
...@@ -207,7 +207,7 @@ private: ...@@ -207,7 +207,7 @@ private:
* *
* @return True if the given point is contained in any of selected items' bouding box. * @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 /// Visual representation of selection box
SELECTION_AREA* m_selArea; SELECTION_AREA* m_selArea;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment