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
Hide 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,125 +1385,99 @@ void PCB_EDIT_FRAME::OnSelectTool( wxCommandEvent& aEvent )
if
(
GetToolId
()
==
id
)
return
;
if
(
IsGalCanvasActive
()
)
{
std
::
string
actionName
=
COMMON_ACTIONS
::
TranslateLegacyId
(
id
);
INSTALL_UNBUFFERED_DC
(
dc
,
m_canvas
);
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
);
}
// Stop the current command and deselect the current tool.
m_canvas
->
EndMouseCapture
(
ID_NO_TOOL_SELECTED
,
m_canvas
->
GetDefaultCursor
()
);
if
(
!
actionName
.
empty
()
)
m_toolManager
->
RunAction
(
actionName
);
}
}
else
switch
(
id
)
{
INSTALL_UNBUFFERED_DC
(
dc
,
m_canvas
);
case
ID_NO_TOOL_SELECTED
:
SetToolID
(
id
,
m_canvas
->
GetDefaultCursor
(),
wxEmptyString
);
break
;
// Stop the current command and deselect the current tool.
m_canvas
->
EndMouseCapture
(
ID_NO_TOOL_SELECTED
,
m_canvas
->
GetDefaultCursor
()
);
case
ID_TRACK_BUTT
:
if
(
g_Drc_On
)
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add tracks"
)
);
else
SetToolID
(
id
,
wxCURSOR_QUESTION_ARROW
,
_
(
"Add tracks"
)
);
switch
(
id
)
if
(
(
GetBoard
()
->
m_Status_Pcb
&
LISTE_RATSNEST_ITEM_OK
)
==
0
)
{
case
ID_NO_TOOL_SELECTED
:
SetToolID
(
id
,
m_canvas
->
GetDefaultCursor
(),
wxEmptyString
);
break
;
case
ID_TRACK_BUTT
:
if
(
g_Drc_On
)
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add tracks"
)
);
else
SetToolID
(
id
,
wxCURSOR_QUESTION_ARROW
,
_
(
"Add tracks"
)
);
if
(
(
GetBoard
()
->
m_Status_Pcb
&
LISTE_RATSNEST_ITEM_OK
)
==
0
)
{
Compile_Ratsnest
(
&
dc
,
true
);
}
Compile_Ratsnest
(
&
dc
,
true
);
}
break
;
break
;
case
ID_PCB_MODULE_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add module"
)
);
break
;
case
ID_PCB_MODULE_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add module"
)
);
break
;
case
ID_PCB_ZONES_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add zones"
)
);
case
ID_PCB_ZONES_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add zones"
)
);
if
(
DisplayOpt
.
DisplayZonesMode
!=
0
)
DisplayInfoMessage
(
this
,
_
(
"Warning: zone display is OFF!!!"
)
);
if
(
DisplayOpt
.
DisplayZonesMode
!=
0
)
DisplayInfoMessage
(
this
,
_
(
"Warning: zone display is OFF!!!"
)
);
if
(
!
GetBoard
()
->
IsHighLightNetON
()
&&
(
GetBoard
()
->
GetHighLightNetCode
()
>
0
)
)
HighLight
(
&
dc
);
if
(
!
GetBoard
()
->
IsHighLightNetON
()
&&
(
GetBoard
()
->
GetHighLightNetCode
()
>
0
)
)
HighLight
(
&
dc
);
break
;
break
;
case
ID_PCB_KEEPOUT_AREA_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add keepout"
)
);
break
;
case
ID_PCB_KEEPOUT_AREA_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add keepout"
)
);
break
;
case
ID_PCB_MIRE_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add layer alignment target"
)
);
break
;
case
ID_PCB_MIRE_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add layer alignment target"
)
);
break
;
case
ID_PCB_PLACE_OFFSET_COORD_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Adjust zero"
)
);
break
;
case
ID_PCB_PLACE_OFFSET_COORD_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Adjust zero"
)
);
break
;
case
ID_PCB_PLACE_GRID_COORD_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Adjust grid origin"
)
);
break
;
case
ID_PCB_PLACE_GRID_COORD_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Adjust grid origin"
)
);
break
;
case
ID_PCB_ADD_LINE_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add graphic line"
)
);
break
;
case
ID_PCB_ADD_LINE_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add graphic line"
)
);
break
;
case
ID_PCB_ARC_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add graphic arc"
)
);
break
;
case
ID_PCB_ARC_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add graphic arc"
)
);
break
;
case
ID_PCB_CIRCLE_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add graphic circle"
)
);
break
;
case
ID_PCB_CIRCLE_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add graphic circle"
)
);
break
;
case
ID_PCB_ADD_TEXT_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add text"
)
);
break
;
case
ID_PCB_ADD_TEXT_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add text"
)
);
break
;
case
ID_COMPONENT_BUTT
:
SetToolID
(
id
,
wxCURSOR_HAND
,
_
(
"Add module"
)
);
break
;
case
ID_COMPONENT_BUTT
:
SetToolID
(
id
,
wxCURSOR_HAND
,
_
(
"Add module"
)
);
break
;
case
ID_PCB_DIMENSION_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add dimension"
)
);
break
;
case
ID_PCB_DIMENSION_BUTT
:
SetToolID
(
id
,
wxCURSOR_PENCIL
,
_
(
"Add dimension"
)
);
break
;
case
ID_PCB_DELETE_ITEM_BUTT
:
SetToolID
(
id
,
wxCURSOR_BULLSEYE
,
_
(
"Delete item"
)
);
break
;
case
ID_PCB_DELETE_ITEM_BUTT
:
SetToolID
(
id
,
wxCURSOR_BULLSEYE
,
_
(
"Delete item"
)
);
break
;
case
ID_PCB_HIGHLIGHT_BUTT
:
SetToolID
(
id
,
wxCURSOR_HAND
,
_
(
"Highlight net"
)
);
break
;
case
ID_PCB_HIGHLIGHT_BUTT
:
SetToolID
(
id
,
wxCURSOR_HAND
,
_
(
"Highlight net"
)
);
break
;
case
ID_PCB_SHOW_1_RATSNEST_BUTT
:
SetToolID
(
id
,
wxCURSOR_HAND
,
_
(
"Select rats nest"
)
);
case
ID_PCB_SHOW_1_RATSNEST_BUTT
:
SetToolID
(
id
,
wxCURSOR_HAND
,
_
(
"Select rats nest"
)
);
if
(
(
GetBoard
()
->
m_Status_Pcb
&
LISTE_RATSNEST_ITEM_OK
)
==
0
)
Compile_Ratsnest
(
&
dc
,
true
);
if
(
(
GetBoard
()
->
m_Status_Pcb
&
LISTE_RATSNEST_ITEM_OK
)
==
0
)
Compile_Ratsnest
(
&
dc
,
true
);
break
;
}
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