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
1fa49ce7
Commit
1fa49ce7
authored
Apr 01, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed drifting for items dragged using EDIT_TOOL.
parent
39bca76d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
+14
-6
edit_tool.cpp
pcbnew/tools/edit_tool.cpp
+14
-6
No files found.
pcbnew/tools/edit_tool.cpp
View file @
1fa49ce7
...
@@ -81,13 +81,15 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
...
@@ -81,13 +81,15 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
if
(
!
makeSelection
(
selection
)
)
if
(
!
makeSelection
(
selection
)
)
return
0
;
return
0
;
VECTOR2I
dragPosition
;
// The last position of the cursor while dragging
m_dragging
=
false
;
// Are selected items being dragged?
m_dragging
=
false
;
// Are selected items being dragged?
bool
restore
=
false
;
// Should items' state be restored when finishing the tool?
bool
restore
=
false
;
// Should items' state be restored when finishing the tool?
// By default, modified items need to update their geometry
// By default, modified items need to update their geometry
m_updateFlag
=
KIGFX
::
VIEW_ITEM
::
GEOMETRY
;
m_updateFlag
=
KIGFX
::
VIEW_ITEM
::
GEOMETRY
;
// Offset from the dragged item's center (anchor)
wxPoint
offset
;
VIEW_CONTROLS
*
controls
=
getViewControls
();
VIEW_CONTROLS
*
controls
=
getViewControls
();
PCB_EDIT_FRAME
*
editFrame
=
static_cast
<
PCB_EDIT_FRAME
*>
(
m_toolMgr
->
GetEditFrame
()
);
PCB_EDIT_FRAME
*
editFrame
=
static_cast
<
PCB_EDIT_FRAME
*>
(
m_toolMgr
->
GetEditFrame
()
);
controls
->
ShowCursor
(
true
);
controls
->
ShowCursor
(
true
);
...
@@ -128,29 +130,34 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
...
@@ -128,29 +130,34 @@ int EDIT_TOOL::Main( TOOL_EVENT& aEvent )
else
if
(
evt
->
IsMotion
()
||
evt
->
IsDrag
(
BUT_LEFT
)
)
else
if
(
evt
->
IsMotion
()
||
evt
->
IsDrag
(
BUT_LEFT
)
)
{
{
VECTOR2I
cursor
(
controls
->
GetCursorPosition
()
);
if
(
m_dragging
)
if
(
m_dragging
)
{
{
wxPoint
movement
=
wxPoint
(
cursor
.
x
,
cursor
.
y
)
-
static_cast
<
BOARD_ITEM
*>
(
selection
.
items
.
GetPickedItem
(
0
)
)
->
GetPosition
();
// Drag items to the current cursor position
// Drag items to the current cursor position
VECTOR2I
movement
=
(
controls
->
GetCursorPosition
()
-
dragPosition
);
for
(
unsigned
int
i
=
0
;
i
<
selection
.
items
.
GetCount
();
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
selection
.
items
.
GetCount
();
++
i
)
{
{
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
selection
.
items
.
GetPickedItem
(
i
)
);
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
selection
.
items
.
GetPickedItem
(
i
)
);
item
->
Move
(
wxPoint
(
movement
.
x
,
movement
.
y
)
);
item
->
Move
(
movement
+
offset
);
}
}
updateRatsnest
(
true
);
updateRatsnest
(
true
);
}
}
else
else
// Prepare to start dragging
{
{
//
Prepare to drag - s
ave items, so changes can be undone
//
S
ave items, so changes can be undone
editFrame
->
OnModify
();
editFrame
->
OnModify
();
editFrame
->
SaveCopyInUndoList
(
selection
.
items
,
UR_CHANGED
);
editFrame
->
SaveCopyInUndoList
(
selection
.
items
,
UR_CHANGED
);
offset
=
static_cast
<
BOARD_ITEM
*>
(
selection
.
items
.
GetPickedItem
(
0
)
)
->
GetPosition
()
-
wxPoint
(
cursor
.
x
,
cursor
.
y
);
m_dragging
=
true
;
m_dragging
=
true
;
}
}
selection
.
group
->
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
selection
.
group
->
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
dragPosition
=
controls
->
GetCursorPosition
();
m_toolMgr
->
RunAction
(
COMMON_ACTIONS
::
pointEditorUpdate
);
m_toolMgr
->
RunAction
(
COMMON_ACTIONS
::
pointEditorUpdate
);
}
}
...
@@ -350,6 +357,7 @@ int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
...
@@ -350,6 +357,7 @@ int EDIT_TOOL::Remove( TOOL_EVENT& aEvent )
// Save them
// Save them
for
(
unsigned
int
i
=
0
;
i
<
selectedItems
.
GetCount
();
++
i
)
for
(
unsigned
int
i
=
0
;
i
<
selectedItems
.
GetCount
();
++
i
)
selectedItems
.
SetPickedItemStatus
(
UR_DELETED
,
i
);
selectedItems
.
SetPickedItemStatus
(
UR_DELETED
,
i
);
editFrame
->
OnModify
();
editFrame
->
OnModify
();
editFrame
->
SaveCopyInUndoList
(
selectedItems
,
UR_DELETED
);
editFrame
->
SaveCopyInUndoList
(
selectedItems
,
UR_DELETED
);
...
...
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