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
35721397
Commit
35721397
authored
Sep 27, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved common actions to a separate file.
parent
6b74b577
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
118 additions
and
46 deletions
+118
-46
action_manager.cpp
common/tool/action_manager.cpp
+1
-1
CMakeLists.txt
pcbnew/CMakeLists.txt
+1
-0
common_actions.cpp
pcbnew/tools/common_actions.cpp
+44
-0
common_actions.h
pcbnew/tools/common_actions.h
+49
-0
move_tool.cpp
pcbnew/tools/move_tool.cpp
+8
-18
move_tool.h
pcbnew/tools/move_tool.h
+0
-9
pcb_tools.cpp
pcbnew/tools/pcb_tools.cpp
+12
-0
selection_tool.cpp
pcbnew/tools/selection_tool.cpp
+3
-11
selection_tool.h
pcbnew/tools/selection_tool.h
+0
-7
No files found.
common/tool/action_manager.cpp
View file @
35721397
...
@@ -66,7 +66,7 @@ void ACTION_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
...
@@ -66,7 +66,7 @@ void ACTION_MANAGER::UnregisterAction( TOOL_ACTION* aAction )
int
ACTION_MANAGER
::
MakeActionId
(
const
std
::
string
&
aActionName
)
int
ACTION_MANAGER
::
MakeActionId
(
const
std
::
string
&
aActionName
)
{
{
static
int
currentActionId
=
0
;
static
int
currentActionId
=
1
;
return
currentActionId
++
;
return
currentActionId
++
;
}
}
...
...
pcbnew/CMakeLists.txt
View file @
35721397
...
@@ -228,6 +228,7 @@ set( PCBNEW_CLASS_SRCS
...
@@ -228,6 +228,7 @@ set( PCBNEW_CLASS_SRCS
tools/bright_box.cpp
tools/bright_box.cpp
tools/move_tool.cpp
tools/move_tool.cpp
tools/pcb_tools.cpp
tools/pcb_tools.cpp
tools/common_actions.cpp
)
)
set
(
PCBNEW_SRCS
${
PCBNEW_AUTOROUTER_SRCS
}
${
PCBNEW_CLASS_SRCS
}
${
PCBNEW_DIALOGS
}
)
set
(
PCBNEW_SRCS
${
PCBNEW_AUTOROUTER_SRCS
}
${
PCBNEW_CLASS_SRCS
}
${
PCBNEW_DIALOGS
}
)
...
...
pcbnew/tools/common_actions.cpp
0 → 100644
View file @
35721397
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "common_actions.h"
#include <tool/action_manager.h>
// Selection tool actions
TOOL_ACTION
COMMON_ACTIONS
::
selectionActivate
(
"pcbnew.InteractiveSelection"
,
AS_GLOBAL
,
'S'
,
"Selection tool"
,
"Allows to select items"
);
// Move tool actions
TOOL_ACTION
COMMON_ACTIONS
::
moveActivate
(
"pcbnew.InteractiveMove"
,
AS_GLOBAL
,
'M'
,
"Move"
,
"Moves the selected item(s)"
);
TOOL_ACTION
COMMON_ACTIONS
::
rotate
(
"pcbnew.InteractiveMove.rotate"
,
AS_CONTEXT
,
' '
,
"Rotate"
,
"Rotates selected item(s)"
);
TOOL_ACTION
COMMON_ACTIONS
::
flip
(
"pcbnew.InteractiveMove.flip"
,
AS_CONTEXT
,
'F'
,
"Flip"
,
"Flips selected item(s)"
);
pcbnew/tools/common_actions.h
0 → 100644
View file @
35721397
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <tool/tool_action.h>
class
ACTION_MANAGER
;
/**
* Class COMMON_ACTIONS
*
* Gathers all the actions that are shared by tools. The instance of COMMON_ACTIOSN is created
* inside of ACTION_MANAGER object and registers them.
*/
class
COMMON_ACTIONS
{
public
:
/// Activation of the move tool
static
TOOL_ACTION
moveActivate
;
/// Activation of the selection tool
static
TOOL_ACTION
selectionActivate
;
/// Rotation of selected objects
static
TOOL_ACTION
rotate
;
/// Flipping of selected objects
static
TOOL_ACTION
flip
;
};
pcbnew/tools/move_tool.cpp
View file @
35721397
...
@@ -25,9 +25,9 @@
...
@@ -25,9 +25,9 @@
#include <class_board.h>
#include <class_board.h>
#include <class_module.h>
#include <class_module.h>
#include <tool/tool_manager.h>
#include <tool/tool_manager.h>
#include <tool/tool_action.h>
#include <view/view_controls.h>
#include <view/view_controls.h>
#include "common_actions.h"
#include "selection_tool.h"
#include "selection_tool.h"
#include "move_tool.h"
#include "move_tool.h"
...
@@ -35,12 +35,7 @@ using namespace KiGfx;
...
@@ -35,12 +35,7 @@ using namespace KiGfx;
using
boost
::
optional
;
using
boost
::
optional
;
MOVE_TOOL
::
MOVE_TOOL
()
:
MOVE_TOOL
::
MOVE_TOOL
()
:
TOOL_INTERACTIVE
(
"pcbnew.InteractiveMove"
),
m_selectionTool
(
NULL
),
TOOL_INTERACTIVE
(
"pcbnew.InteractiveMove"
),
m_selectionTool
(
NULL
)
// Available actions:
m_activate
(
m_toolName
,
AS_GLOBAL
,
'M'
,
"Move"
,
"Moves the selected item(s)"
),
m_rotate
(
m_toolName
+
".rotate"
,
AS_CONTEXT
,
' '
,
"Rotate"
,
"Rotates selected item(s)"
),
m_flip
(
m_toolName
+
".flip"
,
AS_CONTEXT
,
'F'
,
"Flip"
,
"Flips selected item(s)"
)
{
{
}
}
...
@@ -53,7 +48,7 @@ MOVE_TOOL::~MOVE_TOOL()
...
@@ -53,7 +48,7 @@ MOVE_TOOL::~MOVE_TOOL()
void
MOVE_TOOL
::
Reset
()
void
MOVE_TOOL
::
Reset
()
{
{
// The tool launches upon reception of action event ("pcbnew.InteractiveMove")
// The tool launches upon reception of action event ("pcbnew.InteractiveMove")
Go
(
&
MOVE_TOOL
::
Main
,
m_a
ctivate
.
MakeEvent
()
);
Go
(
&
MOVE_TOOL
::
Main
,
COMMON_ACTIONS
::
moveA
ctivate
.
MakeEvent
()
);
}
}
...
@@ -66,15 +61,10 @@ bool MOVE_TOOL::Init()
...
@@ -66,15 +61,10 @@ bool MOVE_TOOL::Init()
{
{
m_selectionTool
=
static_cast
<
SELECTION_TOOL
*>
(
selectionTool
);
m_selectionTool
=
static_cast
<
SELECTION_TOOL
*>
(
selectionTool
);
// Activate hot keys
m_toolMgr
->
RegisterAction
(
&
m_activate
);
m_toolMgr
->
RegisterAction
(
&
m_rotate
);
m_toolMgr
->
RegisterAction
(
&
m_flip
);
// Add context menu entries that are displayed when selection tool is active
// Add context menu entries that are displayed when selection tool is active
m_selectionTool
->
AddMenuItem
(
m_a
ctivate
);
m_selectionTool
->
AddMenuItem
(
COMMON_ACTIONS
::
moveA
ctivate
);
m_selectionTool
->
AddMenuItem
(
m_
rotate
);
m_selectionTool
->
AddMenuItem
(
COMMON_ACTIONS
::
rotate
);
m_selectionTool
->
AddMenuItem
(
m_
flip
);
m_selectionTool
->
AddMenuItem
(
COMMON_ACTIONS
::
flip
);
}
}
else
else
{
{
...
@@ -115,12 +105,12 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
...
@@ -115,12 +105,12 @@ int MOVE_TOOL::Main( TOOL_EVENT& aEvent )
{
{
VECTOR2D
cursorPos
=
getView
()
->
ToWorld
(
getViewControls
()
->
GetCursorPosition
()
);
VECTOR2D
cursorPos
=
getView
()
->
ToWorld
(
getViewControls
()
->
GetCursorPosition
()
);
if
(
evt
->
IsAction
(
&
m_
rotate
)
)
// got rotation event?
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
rotate
)
)
// got rotation event?
{
{
m_state
.
Rotate
(
cursorPos
,
900.0
);
m_state
.
Rotate
(
cursorPos
,
900.0
);
m_items
.
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
m_items
.
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
}
}
else
if
(
evt
->
IsAction
(
&
m_
flip
)
)
// got flip event?
else
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
flip
)
)
// got flip event?
{
{
m_state
.
Flip
(
cursorPos
);
m_state
.
Flip
(
cursorPos
);
m_items
.
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
m_items
.
ViewUpdate
(
VIEW_ITEM
::
GEOMETRY
);
...
...
pcbnew/tools/move_tool.h
View file @
35721397
...
@@ -85,15 +85,6 @@ private:
...
@@ -85,15 +85,6 @@ private:
/// VIEW_GROUP that helds currently moved items
/// VIEW_GROUP that helds currently moved items
KiGfx
::
VIEW_GROUP
m_items
;
KiGfx
::
VIEW_GROUP
m_items
;
/// Register hotkey for activation of the move tool
TOOL_ACTION
m_activate
;
/// Register hotkey for rotation of selected objects
TOOL_ACTION
m_rotate
;
/// Register hotkey for flipping of selected objects
TOOL_ACTION
m_flip
;
};
};
#endif
#endif
pcbnew/tools/pcb_tools.cpp
View file @
35721397
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include "selection_tool.h"
#include "selection_tool.h"
#include "move_tool.h"
#include "move_tool.h"
#include "common_actions.h"
#include <router/router_tool.h>
#include <router/router_tool.h>
void
PCB_EDIT_FRAME
::
setupTools
()
void
PCB_EDIT_FRAME
::
setupTools
()
...
@@ -45,6 +46,12 @@ void PCB_EDIT_FRAME::setupTools()
...
@@ -45,6 +46,12 @@ void PCB_EDIT_FRAME::setupTools()
m_toolDispatcher
=
new
TOOL_DISPATCHER
(
m_toolManager
,
this
);
m_toolDispatcher
=
new
TOOL_DISPATCHER
(
m_toolManager
,
this
);
m_galCanvas
->
SetEventDispatcher
(
m_toolDispatcher
);
m_galCanvas
->
SetEventDispatcher
(
m_toolDispatcher
);
// Register tool actions
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
moveActivate
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
selectionActivate
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
rotate
);
m_toolManager
->
RegisterAction
(
&
COMMON_ACTIONS
::
flip
);
// Register tools
// Register tools
m_toolManager
->
RegisterTool
(
new
SELECTION_TOOL
);
m_toolManager
->
RegisterTool
(
new
SELECTION_TOOL
);
m_toolManager
->
RegisterTool
(
new
ROUTER_TOOL
);
m_toolManager
->
RegisterTool
(
new
ROUTER_TOOL
);
...
@@ -54,6 +61,11 @@ void PCB_EDIT_FRAME::setupTools()
...
@@ -54,6 +61,11 @@ void PCB_EDIT_FRAME::setupTools()
void
PCB_EDIT_FRAME
::
destroyTools
()
void
PCB_EDIT_FRAME
::
destroyTools
()
{
{
m_toolManager
->
UnregisterAction
(
&
COMMON_ACTIONS
::
moveActivate
);
m_toolManager
->
UnregisterAction
(
&
COMMON_ACTIONS
::
selectionActivate
);
m_toolManager
->
UnregisterAction
(
&
COMMON_ACTIONS
::
rotate
);
m_toolManager
->
UnregisterAction
(
&
COMMON_ACTIONS
::
flip
);
delete
m_toolDispatcher
;
delete
m_toolDispatcher
;
delete
m_toolManager
;
delete
m_toolManager
;
}
}
...
...
pcbnew/tools/selection_tool.cpp
View file @
35721397
...
@@ -44,13 +44,13 @@
...
@@ -44,13 +44,13 @@
#include "selection_tool.h"
#include "selection_tool.h"
#include "selection_area.h"
#include "selection_area.h"
#include "bright_box.h"
#include "bright_box.h"
#include "common_actions.h"
using
namespace
KiGfx
;
using
namespace
KiGfx
;
using
boost
::
optional
;
using
boost
::
optional
;
SELECTION_TOOL
::
SELECTION_TOOL
()
:
SELECTION_TOOL
::
SELECTION_TOOL
()
:
TOOL_INTERACTIVE
(
"pcbnew.InteractiveSelection"
),
m_multiple
(
false
),
TOOL_INTERACTIVE
(
"pcbnew.InteractiveSelection"
),
m_multiple
(
false
)
m_activate
(
m_toolName
,
AS_GLOBAL
,
'S'
,
"Selection tool"
,
"Allows to select items"
)
{
{
m_selArea
=
new
SELECTION_AREA
;
m_selArea
=
new
SELECTION_AREA
;
}
}
...
@@ -68,15 +68,7 @@ void SELECTION_TOOL::Reset()
...
@@ -68,15 +68,7 @@ void SELECTION_TOOL::Reset()
m_selectedItems
.
clear
();
m_selectedItems
.
clear
();
// The tool launches upon reception of action event ("pcbnew.InteractiveSelection")
// The tool launches upon reception of action event ("pcbnew.InteractiveSelection")
Go
(
&
SELECTION_TOOL
::
Main
,
m_activate
.
MakeEvent
()
);
Go
(
&
SELECTION_TOOL
::
Main
,
COMMON_ACTIONS
::
selectionActivate
.
MakeEvent
()
);
}
bool
SELECTION_TOOL
::
Init
()
{
m_toolMgr
->
RegisterAction
(
&
m_activate
);
return
true
;
}
}
...
...
pcbnew/tools/selection_tool.h
View file @
35721397
...
@@ -30,7 +30,6 @@
...
@@ -30,7 +30,6 @@
#include <math/vector2d.h>
#include <math/vector2d.h>
#include <tool/tool_interactive.h>
#include <tool/tool_interactive.h>
#include <tool/tool_action.h>
#include <tool/context_menu.h>
#include <tool/context_menu.h>
class
SELECTION_AREA
;
class
SELECTION_AREA
;
...
@@ -58,9 +57,6 @@ public:
...
@@ -58,9 +57,6 @@ public:
/// @copydoc TOOL_INTERACTIVE::Reset()
/// @copydoc TOOL_INTERACTIVE::Reset()
void
Reset
();
void
Reset
();
/// @copydoc TOOL_INTERACTIVE::Init()
bool
Init
();
/**
/**
* Function Main()
* Function Main()
*
*
...
@@ -194,9 +190,6 @@ private:
...
@@ -194,9 +190,6 @@ private:
/// Flag saying if multiple selection mode is active
/// Flag saying if multiple selection mode is active
bool
m_multiple
;
bool
m_multiple
;
/// Register hotkey fot activation of the selection tool
TOOL_ACTION
m_activate
;
/// Right click popup menu
/// Right click popup menu
CONTEXT_MENU
m_menu
;
CONTEXT_MENU
m_menu
;
};
};
...
...
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