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
5c984aa0
Commit
5c984aa0
authored
Apr 30, 2015
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Parametrized TOOL_ACTIONs.
parent
89699a19
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
56 deletions
+46
-56
tool_manager.cpp
common/tool/tool_manager.cpp
+8
-2
tool_action.h
include/tool/tool_action.h
+11
-14
tool_event.h
include/tool/tool_event.h
+13
-10
common_actions.cpp
pcbnew/tools/common_actions.cpp
+10
-9
pcbnew_control.cpp
pcbnew/tools/pcbnew_control.cpp
+2
-19
selection_tool.cpp
pcbnew/tools/selection_tool.cpp
+2
-2
No files found.
common/tool/tool_manager.cpp
View file @
5c984aa0
...
...
@@ -303,7 +303,10 @@ bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow, void* a
if
(
action
)
{
TOOL_EVENT
event
=
action
->
MakeEvent
();
event
.
SetParameter
(
aParam
);
// Allow to override the action parameter
if
(
aParam
)
event
.
SetParameter
(
aParam
);
if
(
aNow
)
ProcessEvent
(
event
);
...
...
@@ -320,7 +323,10 @@ bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow, void* a
void
TOOL_MANAGER
::
RunAction
(
const
TOOL_ACTION
&
aAction
,
bool
aNow
,
void
*
aParam
)
{
TOOL_EVENT
event
=
aAction
.
MakeEvent
();
event
.
SetParameter
(
aParam
);
// Allow to override the action parameter
if
(
aParam
)
event
.
SetParameter
(
aParam
);
if
(
aNow
)
ProcessEvent
(
event
);
...
...
include/tool/tool_action.h
View file @
5c984aa0
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2013
-2015
CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
...
...
@@ -41,7 +41,7 @@ struct BITMAP_OPAQUE;
* - running the DRC from the menu
* and so on, and so forth....
* Action class groups all necessary properties of an action, including explanation,
* icons, hotkeys,
.
menu items, etc.
* icons, hotkeys,
menu items, etc.
*/
class
TOOL_ACTION
{
...
...
@@ -49,10 +49,10 @@ public:
TOOL_ACTION
(
const
std
::
string
&
aName
,
TOOL_ACTION_SCOPE
aScope
=
AS_CONTEXT
,
int
aDefaultHotKey
=
0
,
const
wxString
aMenuItem
=
wxEmptyString
,
const
wxString
&
aMenuDesc
=
wxEmptyString
,
const
BITMAP_OPAQUE
*
aIcon
=
NULL
,
TOOL_ACTION_FLAGS
aFlags
=
AF_NONE
)
:
TOOL_ACTION_FLAGS
aFlags
=
AF_NONE
,
void
*
aParam
=
NULL
)
:
m_name
(
aName
),
m_scope
(
aScope
),
m_defaultHotKey
(
aDefaultHotKey
),
m_currentHotKey
(
aDefaultHotKey
),
m_menuItem
(
aMenuItem
),
m_
menuDescription
(
aMenuDesc
),
m_icon
(
aIcon
),
m_id
(
-
1
),
m_flags
(
aFlags
)
m_currentHotKey
(
aDefaultHotKey
),
m_menuItem
(
aMenuItem
),
m_menuDescription
(
aMenuDesc
),
m_
icon
(
aIcon
),
m_id
(
-
1
),
m_flags
(
aFlags
),
m_param
(
aParam
)
{
TOOL_MANAGER
::
GetActionList
().
push_back
(
this
);
}
...
...
@@ -150,11 +150,11 @@ public:
TOOL_EVENT
MakeEvent
()
const
{
if
(
IsActivation
()
)
return
TOOL_EVENT
(
TC_COMMAND
,
TA_ACTIVATE
,
m_name
,
m_scope
);
return
TOOL_EVENT
(
TC_COMMAND
,
TA_ACTIVATE
,
m_name
,
m_scope
,
m_param
);
else
if
(
IsNotification
()
)
return
TOOL_EVENT
(
TC_MESSAGE
,
TA_NONE
,
m_name
,
m_scope
);
return
TOOL_EVENT
(
TC_MESSAGE
,
TA_NONE
,
m_name
,
m_scope
,
m_param
);
else
return
TOOL_EVENT
(
TC_COMMAND
,
TA_ACTION
,
m_name
,
m_scope
);
return
TOOL_EVENT
(
TC_COMMAND
,
TA_ACTION
,
m_name
,
m_scope
,
m_param
);
}
const
wxString
&
GetMenuItem
()
const
...
...
@@ -219,7 +219,7 @@ private:
/// Name of the action (convention is: app.[tool.]action.name)
std
::
string
m_name
;
/// Scope of the action
(i.e. the event that is issued after activation).
/// Scope of the action
TOOL_ACTION_SCOPE
m_scope
;
/// Default hot key that activates the action.
...
...
@@ -243,11 +243,8 @@ private:
/// Action flags
TOOL_ACTION_FLAGS
m_flags
;
/// Origin of the action
// const TOOL_BASE* m_origin;
/// Originating UI object
// wxWindow* m_uiOrigin;
/// Generic parameter
void
*
m_param
;
};
#endif
include/tool/tool_event.h
View file @
5c984aa0
...
...
@@ -159,24 +159,24 @@ public:
const
std
::
string
Format
()
const
;
TOOL_EVENT
(
TOOL_EVENT_CATEGORY
aCategory
=
TC_NONE
,
TOOL_ACTIONS
aAction
=
TA_NONE
,
TOOL_ACTION_SCOPE
aScope
=
AS_GLOBAL
)
:
TOOL_ACTION_SCOPE
aScope
=
AS_GLOBAL
,
void
*
aParameter
=
NULL
)
:
m_category
(
aCategory
),
m_actions
(
aAction
),
m_scope
(
aScope
),
m_mouseButtons
(
0
),
m_keyCode
(
0
),
m_modifiers
(
0
),
m_param
(
NULL
)
{}
m_param
(
aParameter
)
{}
TOOL_EVENT
(
TOOL_EVENT_CATEGORY
aCategory
,
TOOL_ACTIONS
aAction
,
int
aExtraParam
,
TOOL_ACTION_SCOPE
aScope
=
AS_GLOBAL
)
:
TOOL_ACTION_SCOPE
aScope
=
AS_GLOBAL
,
void
*
aParameter
=
NULL
)
:
m_category
(
aCategory
),
m_actions
(
aAction
),
m_scope
(
aScope
),
m_mouseButtons
(
0
),
m_keyCode
(
0
),
m_modifiers
(
0
),
m_param
(
NULL
)
m_param
(
aParameter
)
{
if
(
aCategory
==
TC_MOUSE
)
{
...
...
@@ -198,14 +198,15 @@ public:
}
TOOL_EVENT
(
TOOL_EVENT_CATEGORY
aCategory
,
TOOL_ACTIONS
aAction
,
const
std
::
string
&
aExtraParam
,
TOOL_ACTION_SCOPE
aScope
=
AS_GLOBAL
)
:
const
std
::
string
&
aExtraParam
,
TOOL_ACTION_SCOPE
aScope
=
AS_GLOBAL
,
void
*
aParameter
=
NULL
)
:
m_category
(
aCategory
),
m_actions
(
aAction
),
m_scope
(
aScope
),
m_mouseButtons
(
0
),
m_keyCode
(
0
),
m_modifiers
(
0
),
m_param
(
NULL
)
m_param
(
aParameter
)
{
if
(
aCategory
==
TC_COMMAND
||
aCategory
==
TC_MESSAGE
)
m_commandStr
=
aExtraParam
;
...
...
@@ -360,9 +361,10 @@ public:
* Returns a non-standard parameter assigned to the event. Its meaning depends on the
* target tool.
*/
void
*
Parameter
()
const
template
<
typename
T
>
inline
T
Parameter
()
const
{
return
m_param
;
return
reinterpret_cast
<
T
>
(
m_param
)
;
}
/**
...
...
@@ -371,9 +373,10 @@ public:
* target tool.
* @param aParam is the new parameter.
*/
void
SetParameter
(
void
*
aParam
)
template
<
typename
T
>
void
SetParameter
(
T
aParam
)
{
m_param
=
aParam
;
m_param
=
(
void
*
)
aParam
;
}
boost
::
optional
<
int
>
GetCommandId
()
const
...
...
pcbnew/tools/common_actions.cpp
View file @
5c984aa0
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* Copyright (C) 2013
-2015
CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
...
...
@@ -25,6 +25,7 @@
#include "common_actions.h"
#include <tool/action_manager.h>
#include <pcbnew_id.h>
#include <layers_id_colors_and_visibility.h>
#include <wx/defs.h>
// These members are static in class COMMON_ACTIONS: Build them here:
...
...
@@ -246,35 +247,35 @@ TOOL_ACTION COMMON_ACTIONS::highContrastDec( "pcbnew.Control.highContrastDec",
// Layer control
TOOL_ACTION
COMMON_ACTIONS
::
layerTop
(
"pcbnew.Control.layerTop"
,
AS_GLOBAL
,
WXK_PAGEUP
,
""
,
""
);
""
,
""
,
NULL
,
AF_NONE
,
(
void
*
)
F_Cu
);
TOOL_ACTION
COMMON_ACTIONS
::
layerInner1
(
"pcbnew.Control.layerInner1"
,
AS_GLOBAL
,
WXK_F5
,
""
,
""
);
""
,
""
,
NULL
,
AF_NONE
,
(
void
*
)
In1_Cu
);
TOOL_ACTION
COMMON_ACTIONS
::
layerInner2
(
"pcbnew.Control.layerInner2"
,
AS_GLOBAL
,
WXK_F6
,
""
,
""
);
""
,
""
,
NULL
,
AF_NONE
,
(
void
*
)
In2_Cu
);
TOOL_ACTION
COMMON_ACTIONS
::
layerInner3
(
"pcbnew.Control.layerInner3"
,
AS_GLOBAL
,
WXK_F7
,
""
,
""
);
""
,
""
,
NULL
,
AF_NONE
,
(
void
*
)
In3_Cu
);
TOOL_ACTION
COMMON_ACTIONS
::
layerInner4
(
"pcbnew.Control.layerInner4"
,
AS_GLOBAL
,
WXK_F8
,
""
,
""
);
""
,
""
,
NULL
,
AF_NONE
,
(
void
*
)
In4_Cu
);
TOOL_ACTION
COMMON_ACTIONS
::
layerInner5
(
"pcbnew.Control.layerInner5"
,
AS_GLOBAL
,
WXK_F9
,
""
,
""
);
""
,
""
,
NULL
,
AF_NONE
,
(
void
*
)
In5_Cu
);
TOOL_ACTION
COMMON_ACTIONS
::
layerInner6
(
"pcbnew.Control.layerInner6"
,
AS_GLOBAL
,
WXK_F10
,
""
,
""
);
""
,
""
,
NULL
,
AF_NONE
,
(
void
*
)
In6_Cu
);
TOOL_ACTION
COMMON_ACTIONS
::
layerBottom
(
"pcbnew.Control.layerBottom"
,
AS_GLOBAL
,
WXK_PAGEDOWN
,
""
,
""
);
""
,
""
,
NULL
,
AF_NONE
,
(
void
*
)
B_Cu
);
TOOL_ACTION
COMMON_ACTIONS
::
layerNext
(
"pcbnew.Control.layerNext"
,
AS_GLOBAL
,
'+'
,
...
...
pcbnew/tools/pcbnew_control.cpp
View file @
5c984aa0
...
...
@@ -285,23 +285,7 @@ int PCBNEW_CONTROL::HighContrastDec( const TOOL_EVENT& aEvent )
// Layer control
int
PCBNEW_CONTROL
::
LayerSwitch
(
const
TOOL_EVENT
&
aEvent
)
{
if
(
aEvent
.
IsAction
(
&
COMMON_ACTIONS
::
layerTop
)
)
m_frame
->
SwitchLayer
(
NULL
,
F_Cu
);
else
if
(
aEvent
.
IsAction
(
&
COMMON_ACTIONS
::
layerInner1
)
)
m_frame
->
SwitchLayer
(
NULL
,
In1_Cu
);
else
if
(
aEvent
.
IsAction
(
&
COMMON_ACTIONS
::
layerInner2
)
)
m_frame
->
SwitchLayer
(
NULL
,
In2_Cu
);
else
if
(
aEvent
.
IsAction
(
&
COMMON_ACTIONS
::
layerInner3
)
)
m_frame
->
SwitchLayer
(
NULL
,
In3_Cu
);
else
if
(
aEvent
.
IsAction
(
&
COMMON_ACTIONS
::
layerInner4
)
)
m_frame
->
SwitchLayer
(
NULL
,
In4_Cu
);
else
if
(
aEvent
.
IsAction
(
&
COMMON_ACTIONS
::
layerInner5
)
)
m_frame
->
SwitchLayer
(
NULL
,
In5_Cu
);
else
if
(
aEvent
.
IsAction
(
&
COMMON_ACTIONS
::
layerInner6
)
)
m_frame
->
SwitchLayer
(
NULL
,
In6_Cu
);
else
if
(
aEvent
.
IsAction
(
&
COMMON_ACTIONS
::
layerBottom
)
)
m_frame
->
SwitchLayer
(
NULL
,
B_Cu
);
m_frame
->
SwitchLayer
(
NULL
,
(
LAYER_ID
)
aEvent
.
Parameter
<
long
>
()
);
setTransitions
();
return
0
;
...
...
@@ -450,8 +434,7 @@ int PCBNEW_CONTROL::GridPrev( const TOOL_EVENT& aEvent )
int
PCBNEW_CONTROL
::
GridSetOrigin
(
const
TOOL_EVENT
&
aEvent
)
{
Activate
();
m_frame
->
SetToolID
(
ID_PCB_PLACE_GRID_COORD_BUTT
,
wxCURSOR_PENCIL
,
_
(
"Adjust grid origin"
)
);
m_frame
->
SetToolID
(
ID_PCB_PLACE_GRID_COORD_BUTT
,
wxCURSOR_PENCIL
,
_
(
"Adjust grid origin"
)
);
KIGFX
::
VIEW_CONTROLS
*
controls
=
getViewControls
();
controls
->
ShowCursor
(
true
);
...
...
pcbnew/tools/selection_tool.cpp
View file @
5c984aa0
...
...
@@ -509,7 +509,7 @@ int SELECTION_TOOL::ClearSelection( const TOOL_EVENT& aEvent )
int
SELECTION_TOOL
::
SelectItem
(
const
TOOL_EVENT
&
aEvent
)
{
// Check if there is an item to be selected
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
aEvent
.
Parameter
()
);
BOARD_ITEM
*
item
=
aEvent
.
Parameter
<
BOARD_ITEM
*>
(
);
if
(
item
)
{
...
...
@@ -527,7 +527,7 @@ int SELECTION_TOOL::SelectItem( const TOOL_EVENT& aEvent )
int
SELECTION_TOOL
::
UnselectItem
(
const
TOOL_EVENT
&
aEvent
)
{
// Check if there is an item to be selected
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
aEvent
.
Parameter
()
);
BOARD_ITEM
*
item
=
aEvent
.
Parameter
<
BOARD_ITEM
*>
(
);
if
(
item
)
{
...
...
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