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
34fbde42
Commit
34fbde42
authored
Jul 09, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved way of translating wxEvent commands to TOOL_ACTIONs.
parent
f8f6fd41
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
128 deletions
+97
-128
tool_dispatcher.cpp
common/tool/tool_dispatcher.cpp
+3
-20
edit.cpp
pcbnew/edit.cpp
+67
-93
common_actions.cpp
pcbnew/tools/common_actions.cpp
+23
-14
common_actions.h
pcbnew/tools/common_actions.h
+4
-1
No files found.
common/tool/tool_dispatcher.cpp
View file @
34fbde42
...
...
@@ -288,27 +288,10 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
void
TOOL_DISPATCHER
::
DispatchWxCommand
(
wxCommandEvent
&
aEvent
)
{
boost
::
optional
<
TOOL_EVENT
>
evt
;
switch
(
aEvent
.
GetId
()
)
{
case
ID_ZOOM_IN
:
// toolbar button "Zoom In"
evt
=
COMMON_ACTIONS
::
zoomInCenter
.
MakeEvent
();
break
;
case
ID_ZOOM_OUT
:
// toolbar button "Zoom In"
evt
=
COMMON_ACTIONS
::
zoomOutCenter
.
MakeEvent
();
break
;
case
ID_ZOOM_PAGE
:
// toolbar button "Fit on Screen"
evt
=
COMMON_ACTIONS
::
zoomFitScreen
.
MakeEvent
();
break
;
default
:
aEvent
.
Skip
();
break
;
}
boost
::
optional
<
TOOL_EVENT
>
evt
=
COMMON_ACTIONS
::
TranslateLegacyId
(
aEvent
.
GetId
()
);
if
(
evt
)
m_toolMgr
->
ProcessEvent
(
*
evt
);
else
aEvent
.
Skip
();
}
pcbnew/edit.cpp
View file @
34fbde42
...
...
@@ -1385,31 +1385,6 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
if
(
GetToolId
()
==
id
)
return
;
if
(
IsGalCanvasActive
()
)
{
std
::
string
actionName
=
COMMON_ACTIONS
::
TranslateLegacyId
(
id
);
if
(
!
actionName
.
empty
()
||
id
==
ID_NO_TOOL_SELECTED
)
{
const
int
MAX_TRIALS
=
10
;
int
trials
=
0
;
// Cancel the current tool
// TODO while sending a lot of cancel events works for sure, it is not the most
// elegant way to cancel a tool, this should be probably done another way
while
(
m_toolManager
->
GetCurrentTool
()
->
GetName
()
!=
"pcbnew.InteractiveSelection"
&&
trials
++
<
MAX_TRIALS
)
{
TOOL_EVENT
cancel
(
TC_ANY
,
TA_CANCEL_TOOL
);
m_toolManager
->
ProcessEvent
(
cancel
);
}
if
(
!
actionName
.
empty
()
)
m_toolManager
->
RunAction
(
actionName
);
}
}
else
{
INSTALL_UNBUFFERED_DC
(
dc
,
m_canvas
);
// Stop the current command and deselect the current tool.
...
...
@@ -1505,5 +1480,4 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
break
;
}
}
}
pcbnew/tools/common_actions.cpp
View file @
34fbde42
...
...
@@ -269,46 +269,55 @@ TOOL_ACTION COMMON_ACTIONS::showHelp( "pcbnew.Control.showHelp",
""
,
""
);
std
::
string
COMMON_ACTIONS
::
TranslateLegacyId
(
int
aId
)
boost
::
optional
<
TOOL_EVENT
>
COMMON_ACTIONS
::
TranslateLegacyId
(
int
aId
)
{
switch
(
aId
)
{
case
ID_PCB_MODULE_BUTT
:
return
COMMON_ACTIONS
::
placeModule
.
GetName
();
return
COMMON_ACTIONS
::
placeModule
.
MakeEvent
();
case
ID_TRACK_BUTT
:
return
COMMON_ACTIONS
::
routerActivate
.
GetName
();
return
COMMON_ACTIONS
::
routerActivate
.
MakeEvent
();
case
ID_PCB_ZONES_BUTT
:
return
COMMON_ACTIONS
::
drawZone
.
GetName
();
return
COMMON_ACTIONS
::
drawZone
.
MakeEvent
();
case
ID_PCB_KEEPOUT_AREA_BUTT
:
return
COMMON_ACTIONS
::
drawKeepout
.
GetName
();
return
COMMON_ACTIONS
::
drawKeepout
.
MakeEvent
();
case
ID_PCB_ADD_LINE_BUTT
:
return
COMMON_ACTIONS
::
drawLine
.
GetName
();
return
COMMON_ACTIONS
::
drawLine
.
MakeEvent
();
case
ID_PCB_CIRCLE_BUTT
:
return
COMMON_ACTIONS
::
drawCircle
.
GetName
();
return
COMMON_ACTIONS
::
drawCircle
.
MakeEvent
();
case
ID_PCB_ARC_BUTT
:
return
COMMON_ACTIONS
::
drawArc
.
GetName
();
return
COMMON_ACTIONS
::
drawArc
.
MakeEvent
();
case
ID_PCB_ADD_TEXT_BUTT
:
return
COMMON_ACTIONS
::
placeTextPcb
.
GetName
();
return
COMMON_ACTIONS
::
placeTextPcb
.
MakeEvent
();
case
ID_MODEDIT_TEXT_TOOL
:
return
COMMON_ACTIONS
::
placeTextModule
.
GetName
();
return
COMMON_ACTIONS
::
placeTextModule
.
MakeEvent
();
case
ID_PCB_DIMENSION_BUTT
:
return
COMMON_ACTIONS
::
drawDimension
.
GetName
();
return
COMMON_ACTIONS
::
drawDimension
.
MakeEvent
();
case
ID_PCB_MIRE_BUTT
:
return
COMMON_ACTIONS
::
placeTarget
.
GetName
();
return
COMMON_ACTIONS
::
placeTarget
.
MakeEvent
();
case
ID_PCB_PLACE_GRID_COORD_BUTT
:
return
COMMON_ACTIONS
::
gridSetOrigin
.
GetName
();
return
COMMON_ACTIONS
::
gridSetOrigin
.
MakeEvent
();
case
ID_ZOOM_IN
:
// toolbar button "Zoom In"
return
COMMON_ACTIONS
::
zoomInCenter
.
MakeEvent
();
case
ID_ZOOM_OUT
:
// toolbar button "Zoom In"
return
COMMON_ACTIONS
::
zoomOutCenter
.
MakeEvent
();
case
ID_ZOOM_PAGE
:
// toolbar button "Fit on Screen"
return
COMMON_ACTIONS
::
zoomFitScreen
.
MakeEvent
();
}
return
""
;
return
boost
::
optional
<
TOOL_EVENT
>
()
;
}
pcbnew/tools/common_actions.h
View file @
34fbde42
...
...
@@ -23,6 +23,9 @@
*/
#include <tool/tool_action.h>
#include <boost/optional.hpp>
class
TOOL_EVENT
;
/**
* Class COMMON_ACTIONS
...
...
@@ -153,5 +156,5 @@ public:
* @return std::string is name of the corresponding TOOL_ACTION. It may be empty, if there is
* no corresponding TOOL_ACTION.
*/
static
std
::
string
TranslateLegacyId
(
int
aId
);
static
boost
::
optional
<
TOOL_EVENT
>
TranslateLegacyId
(
int
aId
);
};
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