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
f7a32e83
Commit
f7a32e83
authored
Feb 19, 2015
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved UndoInhibit related functions from TOOL_MANAGER to EDIT_TOOL.
parent
aafdfd01
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
62 deletions
+47
-62
tool_manager.cpp
common/tool/tool_manager.cpp
+2
-23
tool_manager.h
include/tool/tool_manager.h
+0
-28
edit_tool.cpp
pcbnew/tools/edit_tool.cpp
+8
-11
edit_tool.h
pcbnew/tools/edit_tool.h
+37
-0
No files found.
common/tool/tool_manager.cpp
View file @
f7a32e83
...
...
@@ -195,8 +195,7 @@ private:
TOOL_MANAGER
::
TOOL_MANAGER
()
:
m_model
(
NULL
),
m_view
(
NULL
),
m_viewControls
(
NULL
),
m_editFrame
(
NULL
),
m_undoInhibit
(
false
)
m_model
(
NULL
),
m_view
(
NULL
),
m_viewControls
(
NULL
),
m_editFrame
(
NULL
)
{
m_actionMgr
=
new
ACTION_MANAGER
(
this
);
...
...
@@ -635,7 +634,7 @@ bool TOOL_MANAGER::ProcessEvent( const TOOL_EVENT& aEvent )
if
(
m_view
->
IsDirty
()
)
{
PCB_EDIT_FRAME
*
f
=
static_cast
<
PCB_EDIT
_FRAME
*>
(
GetEditFrame
()
);
EDA_DRAW_FRAME
*
f
=
static_cast
<
EDA_DRAW
_FRAME
*>
(
GetEditFrame
()
);
f
->
GetGalCanvas
()
->
Refresh
();
// fixme: ugly hack, provide a method in TOOL_DISPATCHER.
}
...
...
@@ -714,23 +713,3 @@ bool TOOL_MANAGER::isActive( TOOL_BASE* aTool )
// Just check if the tool is on the active tools stack
return
std
::
find
(
m_activeTools
.
begin
(),
m_activeTools
.
end
(),
aTool
->
GetId
()
)
!=
m_activeTools
.
end
();
}
void
TOOL_MANAGER
::
IncUndoInhibit
()
{
m_undoInhibit
++
;
}
void
TOOL_MANAGER
::
DecUndoInhibit
()
{
m_undoInhibit
--
;
wxASSERT_MSG
(
m_undoInhibit
>=
0
,
wxT
(
"Undo inhibit count decremented past zero"
)
);
}
bool
TOOL_MANAGER
::
IsUndoInhibited
()
const
{
return
m_undoInhibit
>
0
;
}
include/tool/tool_manager.h
View file @
f7a32e83
...
...
@@ -30,8 +30,6 @@
#include <typeinfo>
#include <map>
#include <math/vector2d.h>
#include <tool/tool_base.h>
class
TOOL_BASE
;
...
...
@@ -301,29 +299,6 @@ public:
return
actionList
;
}
/**
* Increments the undo inhibit counter. This will indicate that tools
* should not create an undo point, as another tool is doing it already,
* and considers that its operation is atomic, even if it calls another one
* (for example a duplicate calls a move)
*/
void
IncUndoInhibit
();
/**
* Decrements the inhibit counter. An assert is raised if the counter drops
* below zero
*/
void
DecUndoInhibit
();
/**
* Report if the tool manager has been told at least once that undo
* points should not be created. This can be ignored if the undo point
* is still required.
*
* @return true if undo are inhibited
*/
bool
IsUndoInhibited
()
const
;
private
:
struct
TOOL_STATE
;
typedef
std
::
pair
<
TOOL_EVENT_LIST
,
TOOL_STATE_FUNC
>
TRANSITION
;
...
...
@@ -451,9 +426,6 @@ private:
/// Flag saying if the currently processed event should be passed to other tools.
bool
m_passEvent
;
/// Counter of undo inhibitions. When zero, undo is not inhibited
int
m_undoInhibit
;
};
#endif
pcbnew/tools/edit_tool.cpp
View file @
f7a32e83
...
...
@@ -123,9 +123,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
// cumulative translation
wxPoint
totalMovement
(
0
,
0
);
// make sure nothing is inhibiting undo points
bool
inhibitUndo
=
m_toolMgr
->
IsUndoInhibited
();
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
...
...
@@ -218,7 +215,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
break
;
// Save items, so changes can be undone
if
(
!
i
nhibitUndo
)
if
(
!
i
sUndoInhibited
()
)
{
editFrame
->
OnModify
();
editFrame
->
SaveCopyInUndoList
(
selection
.
items
,
UR_CHANGED
);
...
...
@@ -248,7 +245,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
controls
->
SetAutoPan
(
true
);
m_dragging
=
true
;
m_toolMgr
->
I
ncUndoInhibit
();
i
ncUndoInhibit
();
}
selection
.
group
->
ViewUpdate
(
KIGFX
::
VIEW_ITEM
::
GEOMETRY
);
...
...
@@ -260,7 +257,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
}
if
(
m_dragging
)
m_toolMgr
->
D
ecUndoInhibit
();
d
ecUndoInhibit
();
m_dragging
=
false
;
m_offset
.
x
=
0
;
...
...
@@ -382,7 +379,7 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
wxPoint
rotatePoint
=
getModificationPoint
(
selection
);
// If it is being dragged, then it is already saved with UR_CHANGED flag
if
(
!
m_toolMgr
->
I
sUndoInhibited
()
)
if
(
!
i
sUndoInhibited
()
)
{
editFrame
->
OnModify
();
editFrame
->
SaveCopyInUndoList
(
selection
.
items
,
UR_ROTATED
,
rotatePoint
);
...
...
@@ -436,7 +433,7 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
wxPoint
flipPoint
=
getModificationPoint
(
selection
);
if
(
!
m_toolMgr
->
I
sUndoInhibited
()
)
// If it is being dragged, then it is already saved with UR_CHANGED flag
if
(
!
i
sUndoInhibited
()
)
// If it is being dragged, then it is already saved with UR_CHANGED flag
{
editFrame
->
OnModify
();
editFrame
->
SaveCopyInUndoList
(
selection
.
items
,
UR_FLIPPED
,
flipPoint
);
...
...
@@ -614,7 +611,7 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
if
(
ret
==
DIALOG_MOVE_EXACT
::
MOVE_OK
)
{
if
(
!
m_toolMgr
->
I
sUndoInhibited
()
)
if
(
!
i
sUndoInhibited
()
)
{
editFrame
->
OnModify
();
// Record an action of move and rotate
...
...
@@ -676,7 +673,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
// prevent other tools making undo points while the duplicate is going on
// so that if you cancel, you don't get a duplicate object hiding over
// the original
m_toolMgr
->
I
ncUndoInhibit
();
i
ncUndoInhibit
();
std
::
vector
<
BOARD_ITEM
*>
old_items
;
...
...
@@ -731,7 +728,7 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
Main
(
evt
);
// and re-enable undos
m_toolMgr
->
D
ecUndoInhibit
();
d
ecUndoInhibit
();
setTransitions
();
...
...
pcbnew/tools/edit_tool.h
View file @
f7a32e83
...
...
@@ -142,6 +142,9 @@ private:
/// Edit module mode flag
bool
m_editModules
;
/// Counter of undo inhibitions. When zero, undo is not inhibited.
int
m_undoInhibit
;
///> Removes and frees a single BOARD_ITEM.
void
remove
(
BOARD_ITEM
*
aItem
);
...
...
@@ -173,6 +176,40 @@ private:
///> Updates view with the changes in the list.
void
processChanges
(
const
PICKED_ITEMS_LIST
*
aList
);
/**
* Increments the undo inhibit counter. This will indicate that tools
* should not create an undo point, as another tool is doing it already,
* and considers that its operation is atomic, even if it calls another one
* (for example a duplicate calls a move).
*/
inline
void
incUndoInhibit
()
{
m_undoInhibit
++
;
}
/**
* Decrements the inhibit counter. An assert is raised if the counter drops
* below zero.
*/
inline
void
decUndoInhibit
()
{
m_undoInhibit
--
;
wxASSERT_MSG
(
m_undoInhibit
>=
0
,
wxT
(
"Undo inhibit count decremented past zero"
)
);
}
/**
* Report if the tool manager has been told at least once that undo
* points should not be created. This can be ignored if the undo point
* is still required.
*
* @return true if undo are inhibited
*/
inline
bool
isUndoInhibited
()
const
{
return
m_undoInhibit
>
0
;
}
};
#endif
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