Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
ab21124b
Commit
ab21124b
authored
Sep 16, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reenabled snapping for tools.
parent
8e0674b7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
40 deletions
+29
-40
tool_dispatcher.cpp
common/tool/tool_dispatcher.cpp
+3
-11
wx_view_controls.cpp
common/view/wx_view_controls.cpp
+18
-5
tool_dispatcher.h
include/tool/tool_dispatcher.h
+0
-2
view_controls.h
include/view/view_controls.h
+2
-22
wx_view_controls.h
include/view/wx_view_controls.h
+6
-0
No files found.
common/tool/tool_dispatcher.cpp
View file @
ab21124b
...
...
@@ -31,6 +31,7 @@
#include <tool/tool_manager.h>
#include <tool/tool_dispatcher.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <class_drawpanel_gal.h>
...
...
@@ -122,15 +123,6 @@ int TOOL_DISPATCHER::decodeModifiers( const wxKeyboardState* aState ) const
}
wxPoint
TOOL_DISPATCHER
::
getCurrentMousePos
()
const
{
wxPoint
msp
=
wxGetMousePosition
();
wxPoint
winp
=
m_editFrame
->
GetGalCanvas
()
->
GetScreenPosition
();
return
wxPoint
(
msp
.
x
-
winp
.
x
,
msp
.
y
-
winp
.
y
);
}
bool
TOOL_DISPATCHER
::
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
)
{
ButtonState
*
st
=
m_buttons
[
aIndex
];
...
...
@@ -208,7 +200,6 @@ bool TOOL_DISPATCHER::handleMouseButton( wxEvent& aEvent, int aIndex, bool aMoti
void
TOOL_DISPATCHER
::
DispatchWxEvent
(
wxEvent
&
aEvent
)
{
bool
motion
=
false
,
buttonEvents
=
false
;
VECTOR2D
pos
;
optional
<
TOOL_EVENT
>
evt
;
int
type
=
aEvent
.
GetEventType
();
...
...
@@ -220,7 +211,8 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
type
==
wxEVT_RIGHT_DOWN
||
type
==
wxEVT_RIGHT_UP
||
type
==
EVT_REFRESH_MOUSE
)
{
pos
=
getView
()
->
ToWorld
(
getCurrentMousePos
()
);
VECTOR2D
screenPos
=
m_toolMgr
->
GetViewControls
()
->
GetCursorPosition
();
VECTOR2D
pos
=
getView
()
->
ToWorld
(
screenPos
);
if
(
pos
!=
m_lastMousePos
||
type
==
EVT_REFRESH_MOUSE
)
{
motion
=
true
;
...
...
common/view/wx_view_controls.cpp
View file @
ab21124b
...
...
@@ -65,11 +65,6 @@ void WX_VIEW_CONTROLS::onMotion( wxMouseEvent& aEvent )
m_mousePosition
.
x
=
aEvent
.
GetX
();
m_mousePosition
.
y
=
aEvent
.
GetY
();
if
(
m_snappingEnabled
)
m_cursorPosition
=
m_view
->
GetGAL
()
->
GetGridPoint
(
m_mousePosition
);
else
m_cursorPosition
=
m_mousePosition
;
bool
isAutoPanning
=
false
;
if
(
m_autoPanEnabled
)
...
...
@@ -222,6 +217,24 @@ void WX_VIEW_CONTROLS::SetGrabMouse( bool aEnabled )
}
const
VECTOR2D
WX_VIEW_CONTROLS
::
GetMousePosition
()
const
{
wxPoint
msp
=
wxGetMousePosition
();
wxPoint
winp
=
m_parentPanel
->
GetScreenPosition
();
return
VECTOR2D
(
msp
.
x
-
winp
.
x
,
msp
.
y
-
winp
.
y
);
}
const
VECTOR2D
WX_VIEW_CONTROLS
::
GetCursorPosition
()
const
{
if
(
m_snappingEnabled
)
return
m_view
->
GetGAL
()
->
GetGridPoint
(
GetMousePosition
()
);
else
return
GetMousePosition
();
}
bool
WX_VIEW_CONTROLS
::
handleAutoPanning
(
const
wxMouseEvent
&
aEvent
)
{
VECTOR2D
p
(
aEvent
.
GetX
(),
aEvent
.
GetY
()
);
...
...
include/tool/tool_dispatcher.h
View file @
ab21124b
...
...
@@ -76,8 +76,6 @@ private:
bool
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
);
bool
handlePopupMenu
(
wxEvent
&
aEvent
);
wxPoint
getCurrentMousePos
()
const
;
int
decodeModifiers
(
const
wxKeyboardState
*
aState
)
const
;
struct
ButtonState
;
...
...
include/view/view_controls.h
View file @
ab21124b
...
...
@@ -110,10 +110,7 @@ public:
*
* @return The current mouse pointer position.
*/
virtual
const
VECTOR2D
&
GetMousePosition
()
const
{
return
m_mousePosition
;
}
virtual
const
VECTOR2D
GetMousePosition
()
const
=
0
;
/**
* Function GetCursorPosition()
...
...
@@ -122,21 +119,7 @@ public:
*
* @return The current cursor position in screen coordinates.
*/
virtual
const
VECTOR2D
&
GetCursorPosition
()
const
{
return
m_cursorPosition
;
}
/**
* Function SetCursorPosition()
* Allows to move the cursor to a different location.
*
* @param aPosition is the new location expressed in screen coordinates.
*/
virtual
void
SetCursorPosition
(
const
VECTOR2D
&
aPosition
)
{
m_cursorPosition
=
aPosition
;
}
virtual
const
VECTOR2D
GetCursorPosition
()
const
=
0
;
protected
:
/// Pointer to controlled VIEW.
...
...
@@ -145,9 +128,6 @@ protected:
/// Current mouse position
VECTOR2D
m_mousePosition
;
/// Current cursor position
VECTOR2D
m_cursorPosition
;
/// Should the cursor snap to grid or move freely
bool
m_snappingEnabled
;
...
...
include/view/wx_view_controls.h
View file @
ab21124b
...
...
@@ -78,6 +78,12 @@ public:
m_state
=
IDLE
;
}
/// @copydoc VIEW_CONTROLS::GetMousePosition()
virtual
const
VECTOR2D
GetMousePosition
()
const
;
/// @copydoc VIEW_CONTROLS::GetCursorPosition()
virtual
const
VECTOR2D
GetCursorPosition
()
const
;
private
:
/// Possible states for WX_VIEW_CONTROLS
enum
State
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment