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
2889a7a1
Commit
2889a7a1
authored
Mar 06, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Undo/redo support for POINT_EDITOR.
parent
f72aec25
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
5 deletions
+34
-5
point_editor.cpp
pcbnew/tools/point_editor.cpp
+34
-5
No files found.
pcbnew/tools/point_editor.cpp
View file @
2889a7a1
...
@@ -47,9 +47,9 @@ class EDIT_POINTS_FACTORY
...
@@ -47,9 +47,9 @@ class EDIT_POINTS_FACTORY
public
:
public
:
static
boost
::
shared_ptr
<
EDIT_POINTS
>
Make
(
EDA_ITEM
*
aItem
)
static
boost
::
shared_ptr
<
EDIT_POINTS
>
Make
(
EDA_ITEM
*
aItem
)
{
{
// TODO generate list of points basing on the type
boost
::
shared_ptr
<
EDIT_POINTS
>
points
=
boost
::
make_shared
<
EDIT_POINTS
>
(
aItem
);
boost
::
shared_ptr
<
EDIT_POINTS
>
points
=
boost
::
make_shared
<
EDIT_POINTS
>
(
aItem
);
// Generate list of edit points basing on the item type
switch
(
aItem
->
Type
()
)
switch
(
aItem
->
Type
()
)
{
{
case
PCB_LINE_T
:
case
PCB_LINE_T
:
...
@@ -140,20 +140,22 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
...
@@ -140,20 +140,22 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
{
{
const
SELECTION_TOOL
::
SELECTION
&
selection
=
m_selectionTool
->
GetSelection
();
const
SELECTION_TOOL
::
SELECTION
&
selection
=
m_selectionTool
->
GetSelection
();
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
m_dragPoint
=
NULL
;
if
(
selection
.
Size
()
==
1
)
if
(
selection
.
Size
()
==
1
)
{
{
Activate
();
PCB_EDIT_FRAME
*
editFrame
=
getEditFrame
<
PCB_EDIT_FRAME
>
();
EDA_ITEM
*
item
=
selection
.
items
.
GetPickedItem
(
0
);
EDA_ITEM
*
item
=
selection
.
items
.
GetPickedItem
(
0
);
m_editPoints
=
EDIT_POINTS_FACTORY
::
Make
(
item
);
m_editPoints
=
EDIT_POINTS_FACTORY
::
Make
(
item
);
m_toolMgr
->
GetView
()
->
Add
(
m_editPoints
.
get
()
);
m_toolMgr
->
GetView
()
->
Add
(
m_editPoints
.
get
()
);
m_dragPoint
=
NULL
;
bool
modified
=
false
;
Activate
();
// Main loop: keep receiving events
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
{
if
(
!
m_editPoints
||
evt
->
IsCancel
()
||
if
(
!
m_editPoints
||
evt
->
Matches
(
m_selectionTool
->
ClearedEvent
)
||
evt
->
Matches
(
m_selectionTool
->
ClearedEvent
)
||
evt
->
Matches
(
m_selectionTool
->
DeselectedEvent
)
||
evt
->
Matches
(
m_selectionTool
->
DeselectedEvent
)
||
evt
->
Matches
(
m_selectionTool
->
SelectedEvent
)
)
evt
->
Matches
(
m_selectionTool
->
SelectedEvent
)
)
...
@@ -186,6 +188,14 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
...
@@ -186,6 +188,14 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
else
if
(
evt
->
IsDrag
(
BUT_LEFT
)
&&
m_dragPoint
)
else
if
(
evt
->
IsDrag
(
BUT_LEFT
)
&&
m_dragPoint
)
{
{
if
(
!
modified
)
{
// Save items, so changes can be undone
editFrame
->
OnModify
();
editFrame
->
SaveCopyInUndoList
(
selection
.
items
,
UR_CHANGED
);
modified
=
true
;
}
m_dragPoint
->
SetPosition
(
controls
->
GetCursorPosition
()
);
m_dragPoint
->
SetPosition
(
controls
->
GetCursorPosition
()
);
m_dragPoint
->
ApplyConstraint
();
m_dragPoint
->
ApplyConstraint
();
updateItem
();
updateItem
();
...
@@ -199,6 +209,25 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
...
@@ -199,6 +209,25 @@ int POINT_EDITOR::OnSelectionChange( TOOL_EVENT& aEvent )
updatePoints
();
updatePoints
();
}
}
else
if
(
evt
->
IsMouseUp
(
BUT_LEFT
)
)
{
modified
=
false
;
}
else
if
(
evt
->
IsCancel
()
)
{
if
(
modified
)
// Restore the last change
{
wxCommandEvent
dummy
;
editFrame
->
GetBoardFromUndoList
(
dummy
);
updatePoints
();
modified
=
false
;
}
break
;
}
else
else
{
{
m_toolMgr
->
PassEvent
();
m_toolMgr
->
PassEvent
();
...
...
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