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
7d5a4563
Commit
7d5a4563
authored
Aug 06, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code reformatting.
parent
f193e389
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
277 additions
and
213 deletions
+277
-213
tool_dispatcher.cpp
common/tool/tool_dispatcher.cpp
+93
-63
tool_manager.cpp
common/tool/tool_manager.cpp
+74
-44
graphics_abstraction_layer.h
include/gal/graphics_abstraction_layer.h
+6
-1
tool_dispatcher.h
include/tool/tool_dispatcher.h
+33
-34
tool_manager.h
include/tool/tool_manager.h
+25
-23
pcb_tools.cpp
pcbnew/tools/pcb_tools.cpp
+5
-5
selection_area.cpp
pcbnew/tools/selection_area.cpp
+8
-4
selection_area.h
pcbnew/tools/selection_area.h
+20
-23
selection_tool.cpp
pcbnew/tools/selection_tool.cpp
+8
-11
selection_tool.h
pcbnew/tools/selection_tool.h
+5
-5
No files found.
common/tool/tool_dispatcher.cpp
View file @
7d5a4563
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@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 <wx/wx.h>
#include <wx/wx.h>
#include <wx/event.h>
#include <wx/event.h>
...
@@ -19,12 +43,12 @@ using boost::optional;
...
@@ -19,12 +43,12 @@ using boost::optional;
struct
TOOL_DISPATCHER
::
ButtonState
struct
TOOL_DISPATCHER
::
ButtonState
{
{
ButtonState
(
TOOL_MouseButtons
aButton
,
const
wxEventType
&
aDownEvent
,
ButtonState
(
TOOL_MouseButtons
aButton
,
const
wxEventType
&
aDownEvent
,
const
wxEventType
&
aUpEvent
,
bool
aTriggerMenu
=
false
)
:
const
wxEventType
&
aUpEvent
,
bool
aTriggerMenu
=
false
)
:
button
(
aButton
),
button
(
aButton
),
downEvent
(
aDownEvent
),
downEvent
(
aDownEvent
),
upEvent
(
aUpEvent
),
upEvent
(
aUpEvent
),
triggerContextMenu
(
aTriggerMenu
)
triggerContextMenu
(
aTriggerMenu
)
{};
{};
bool
dragging
;
bool
dragging
;
...
@@ -47,119 +71,123 @@ struct TOOL_DISPATCHER::ButtonState
...
@@ -47,119 +71,123 @@ struct TOOL_DISPATCHER::ButtonState
}
}
};
};
TOOL_DISPATCHER
::
TOOL_DISPATCHER
(
TOOL_MANAGER
*
aToolMgr
,
PCB_BASE_FRAME
*
aEditFrame
)
:
m_toolMgr
(
aToolMgr
),
m_editFrame
(
aEditFrame
)
{
m_buttons
.
push_back
(
new
ButtonState
(
MB_Left
,
wxEVT_LEFT_DOWN
,
wxEVT_LEFT_UP
));
TOOL_DISPATCHER
::
TOOL_DISPATCHER
(
TOOL_MANAGER
*
aToolMgr
,
PCB_BASE_FRAME
*
aEditFrame
)
:
m_buttons
.
push_back
(
new
ButtonState
(
MB_Right
,
wxEVT_RIGHT_DOWN
,
wxEVT_RIGHT_UP
,
true
));
m_toolMgr
(
aToolMgr
),
m_editFrame
(
aEditFrame
)
m_buttons
.
push_back
(
new
ButtonState
(
MB_Middle
,
wxEVT_MIDDLE_DOWN
,
wxEVT_MIDDLE_UP
));
{
m_buttons
.
push_back
(
new
ButtonState
(
MB_Left
,
wxEVT_LEFT_DOWN
,
wxEVT_LEFT_UP
)
);
m_buttons
.
push_back
(
new
ButtonState
(
MB_Right
,
wxEVT_RIGHT_DOWN
,
wxEVT_RIGHT_UP
,
true
)
);
m_buttons
.
push_back
(
new
ButtonState
(
MB_Middle
,
wxEVT_MIDDLE_DOWN
,
wxEVT_MIDDLE_UP
)
);
ResetState
();
ResetState
();
};
}
TOOL_DISPATCHER
::~
TOOL_DISPATCHER
()
TOOL_DISPATCHER
::~
TOOL_DISPATCHER
()
{
{
BOOST_FOREACH
(
ButtonState
*
st
,
m_buttons
)
BOOST_FOREACH
(
ButtonState
*
st
,
m_buttons
)
delete
st
;
delete
st
;
}
}
void
TOOL_DISPATCHER
::
ResetState
()
void
TOOL_DISPATCHER
::
ResetState
()
{
{
BOOST_FOREACH
(
ButtonState
*
st
,
m_buttons
)
BOOST_FOREACH
(
ButtonState
*
st
,
m_buttons
)
st
->
Reset
();
st
->
Reset
();
}
}
KiGfx
::
VIEW
*
TOOL_DISPATCHER
::
getView
()
KiGfx
::
VIEW
*
TOOL_DISPATCHER
::
getView
()
{
{
return
m_editFrame
->
GetGalCanvas
()
->
GetView
();
return
m_editFrame
->
GetGalCanvas
()
->
GetView
();
}
}
int
TOOL_DISPATCHER
::
decodeModifiers
(
wxEvent
&
aEvent
)
int
TOOL_DISPATCHER
::
decodeModifiers
(
wxEvent
&
aEvent
)
{
{
wxMouseEvent
*
me
=
static_cast
<
wxMouseEvent
*>
(
&
aEvent
);
wxMouseEvent
*
me
=
static_cast
<
wxMouseEvent
*>
(
&
aEvent
);
int
mods
=
0
;
int
mods
=
0
;
if
(
me
->
ControlDown
()
)
if
(
me
->
ControlDown
()
)
mods
|=
MB_ModCtrl
;
mods
|=
MB_ModCtrl
;
if
(
me
->
AltDown
()
)
if
(
me
->
AltDown
()
)
mods
|=
MB_ModAlt
;
mods
|=
MB_ModAlt
;
if
(
me
->
ShiftDown
()
)
if
(
me
->
ShiftDown
()
)
mods
|=
MB_ModShift
;
mods
|=
MB_ModShift
;
return
mods
;
return
mods
;
}
}
bool
TOOL_DISPATCHER
::
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
)
bool
TOOL_DISPATCHER
::
handleMouseButton
(
wxEvent
&
aEvent
,
int
aIndex
,
bool
aMotion
)
{
{
ButtonState
*
st
=
m_buttons
[
aIndex
];
ButtonState
*
st
=
m_buttons
[
aIndex
];
wxEventType
type
=
aEvent
.
GetEventType
();
wxEventType
type
=
aEvent
.
GetEventType
();
optional
<
TOOL_EVENT
>
evt
;
optional
<
TOOL_EVENT
>
evt
;
bool
up
=
type
==
st
->
upEvent
;
bool
up
=
type
==
st
->
upEvent
;
bool
down
=
type
==
st
->
downEvent
;
bool
down
=
type
==
st
->
downEvent
;
int
mods
=
decodeModifiers
(
aEvent
);
int
mods
=
decodeModifiers
(
aEvent
);
int
args
=
st
->
button
|
mods
;
int
args
=
st
->
button
|
mods
;
if
(
down
)
if
(
down
)
{
{
st
->
downTimestamp
=
wxGetLocalTimeMillis
();
st
->
downTimestamp
=
wxGetLocalTimeMillis
();
st
->
dragOrigin
=
m_lastMousePos
;
st
->
dragOrigin
=
m_lastMousePos
;
st
->
dragMaxDelta
=
0
;
st
->
dragMaxDelta
=
0
;
st
->
pressed
=
true
;
st
->
pressed
=
true
;
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseDown
,
args
);
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseDown
,
args
);
}
else
if
(
up
)
}
else
if
(
up
)
{
{
bool
isClick
=
false
;
bool
isClick
=
false
;
st
->
pressed
=
false
;
st
->
pressed
=
false
;
if
(
st
->
dragging
)
if
(
st
->
dragging
)
{
{
wxLongLong
t
=
wxGetLocalTimeMillis
();
wxLongLong
t
=
wxGetLocalTimeMillis
();
if
(
t
-
st
->
downTimestamp
<
DragTimeThreshold
&&
st
->
dragMaxDelta
<
DragDistanceThreshold
)
if
(
t
-
st
->
downTimestamp
<
DragTimeThreshold
&&
st
->
dragMaxDelta
<
DragDistanceThreshold
)
isClick
=
true
;
isClick
=
true
;
else
else
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseUp
,
args
);
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseUp
,
args
);
}
else
}
else
isClick
=
true
;
isClick
=
true
;
if
(
isClick
)
if
(
isClick
)
{
{
if
(
st
->
triggerContextMenu
&&
!
mods
)
if
(
st
->
triggerContextMenu
&&
!
mods
)
{}
{}
// evt = TOOL_EVENT
(
TC_Command, TA_ContextMenu );
// evt = TOOL_EVENT
(
TC_Command, TA_ContextMenu );
else
else
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseClick
,
args
);
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseClick
,
args
);
}
}
st
->
dragging
=
false
;
st
->
dragging
=
false
;
}
}
if
(
st
->
pressed
&&
aMotion
)
if
(
st
->
pressed
&&
aMotion
)
{
{
st
->
dragging
=
true
;
st
->
dragging
=
true
;
double
dragPixelDistance
=
getView
()
->
ToScreen
(
m_lastMousePos
-
st
->
dragOrigin
,
false
).
EuclideanNorm
();
double
dragPixelDistance
=
getView
()
->
ToScreen
(
m_lastMousePos
-
st
->
dragOrigin
,
false
).
EuclideanNorm
();
st
->
dragMaxDelta
=
std
::
max
(
st
->
dragMaxDelta
,
dragPixelDistance
);
st
->
dragMaxDelta
=
std
::
max
(
st
->
dragMaxDelta
,
dragPixelDistance
);
wxLongLong
t
=
wxGetLocalTimeMillis
();
wxLongLong
t
=
wxGetLocalTimeMillis
();
if
(
t
-
st
->
downTimestamp
>
DragTimeThreshold
||
st
->
dragMaxDelta
>
DragDistanceThreshold
)
if
(
t
-
st
->
downTimestamp
>
DragTimeThreshold
||
st
->
dragMaxDelta
>
DragDistanceThreshold
)
{
{
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseDrag
,
args
);
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseDrag
,
args
);
evt
->
SetMouseDragOrigin
(
st
->
dragOrigin
);
evt
->
SetMouseDragOrigin
(
st
->
dragOrigin
);
evt
->
SetMouseDelta
(
m_lastMousePos
-
st
->
dragOrigin
);
evt
->
SetMouseDelta
(
m_lastMousePos
-
st
->
dragOrigin
);
}
}
}
}
if
(
evt
)
if
(
evt
)
{
{
evt
->
SetMousePosition
(
m_lastMousePos
);
evt
->
SetMousePosition
(
m_lastMousePos
);
m_toolMgr
->
ProcessEvent
(
*
evt
);
m_toolMgr
->
ProcessEvent
(
*
evt
);
return
true
;
return
true
;
...
@@ -168,7 +196,8 @@ bool TOOL_DISPATCHER::handleMouseButton ( wxEvent& aEvent, int aIndex, bool aMot
...
@@ -168,7 +196,8 @@ bool TOOL_DISPATCHER::handleMouseButton ( wxEvent& aEvent, int aIndex, bool aMot
return
false
;
return
false
;
}
}
void
TOOL_DISPATCHER
::
DispatchWxEvent
(
wxEvent
&
aEvent
)
void
TOOL_DISPATCHER
::
DispatchWxEvent
(
wxEvent
&
aEvent
)
{
{
bool
motion
=
false
,
buttonEvents
=
false
;
bool
motion
=
false
,
buttonEvents
=
false
;
VECTOR2D
pos
;
VECTOR2D
pos
;
...
@@ -178,37 +207,38 @@ void TOOL_DISPATCHER::DispatchWxEvent(wxEvent &aEvent)
...
@@ -178,37 +207,38 @@ void TOOL_DISPATCHER::DispatchWxEvent(wxEvent &aEvent)
if
(
type
==
wxEVT_MOTION
)
if
(
type
==
wxEVT_MOTION
)
{
{
wxMouseEvent
*
me
=
static_cast
<
wxMouseEvent
*>
(
&
aEvent
);
wxMouseEvent
*
me
=
static_cast
<
wxMouseEvent
*>
(
&
aEvent
);
pos
=
getView
()
->
ToWorld
(
VECTOR2D
(
me
->
GetX
(),
me
->
GetY
()
)
);
pos
=
getView
()
->
ToWorld
(
VECTOR2D
(
me
->
GetX
(),
me
->
GetY
()
)
);
if
(
pos
!=
m_lastMousePos
)
if
(
pos
!=
m_lastMousePos
)
{
{
motion
=
true
;
motion
=
true
;
m_lastMousePos
=
pos
;
m_lastMousePos
=
pos
;
}
}
}
}
for
(
unsigned
int
i
=
0
;
i
<
m_buttons
.
size
();
i
++
)
for
(
unsigned
int
i
=
0
;
i
<
m_buttons
.
size
();
i
++
)
buttonEvents
|=
handleMouseButton
(
aEvent
,
i
,
motion
);
buttonEvents
|=
handleMouseButton
(
aEvent
,
i
,
motion
);
if
(
!
buttonEvents
&&
motion
)
if
(
!
buttonEvents
&&
motion
)
{
{
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseMotion
);
evt
=
TOOL_EVENT
(
TC_Mouse
,
TA_MouseMotion
);
evt
->
SetMousePosition
(
pos
);
evt
->
SetMousePosition
(
pos
);
}
}
if
(
evt
)
if
(
evt
)
m_toolMgr
->
ProcessEvent
(
*
evt
);
m_toolMgr
->
ProcessEvent
(
*
evt
);
aEvent
.
Skip
();
aEvent
.
Skip
();
}
}
void
TOOL_DISPATCHER
::
DispatchWxCommand
(
wxCommandEvent
&
aEvent
)
void
TOOL_DISPATCHER
::
DispatchWxCommand
(
wxCommandEvent
&
aEvent
)
{
{
bool
activateTool
=
false
;
bool
activateTool
=
false
;
std
::
string
toolName
;
std
::
string
toolName
;
switch
(
aEvent
.
GetId
()
)
switch
(
aEvent
.
GetId
()
)
{
{
case
ID_SELECTION_TOOL
:
case
ID_SELECTION_TOOL
:
toolName
=
"pcbnew.InteractiveSelection"
;
toolName
=
"pcbnew.InteractiveSelection"
;
...
@@ -216,9 +246,9 @@ void TOOL_DISPATCHER::DispatchWxCommand(wxCommandEvent &aEvent)
...
@@ -216,9 +246,9 @@ void TOOL_DISPATCHER::DispatchWxCommand(wxCommandEvent &aEvent)
break
;
break
;
}
}
if
(
activateTool
)
if
(
activateTool
)
{
{
TOOL_EVENT
evt
(
TC_Command
,
TA_ActivateTool
,
toolName
);
TOOL_EVENT
evt
(
TC_Command
,
TA_ActivateTool
,
toolName
);
m_toolMgr
->
ProcessEvent
(
evt
);
m_toolMgr
->
ProcessEvent
(
evt
);
}
}
}
}
common/tool/tool_manager.cpp
View file @
7d5a4563
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013 CERN
* @author Tomasz Wlostowski <tomasz.wlostowski@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 <map>
#include <map>
#include <deque>
#include <deque>
#include <boost/foreach.hpp>
#include <boost/foreach.hpp>
#include <boost/optional.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptor/map.hpp>
#include <boost/range/adaptor/map.hpp>
...
@@ -24,33 +47,30 @@ using namespace std;
...
@@ -24,33 +47,30 @@ using namespace std;
struct
TOOL_MANAGER
::
ToolState
struct
TOOL_MANAGER
::
ToolState
{
{
TOOL_BASE
*
theTool
;
TOOL_BASE
*
theTool
;
bool
idle
;
bool
idle
;
bool
pendingWait
;
bool
pendingWait
;
bool
pendingContextMenu
;
bool
pendingContextMenu
;
CONTEXT_MENU
*
contextMenu
;
CONTEXT_MENU
*
contextMenu
;
TOOL_ContextMenuTrigger
contextMenuTrigger
;
TOOL_ContextMenuTrigger
contextMenuTrigger
;
COROUTINE
<
int
,
TOOL_EVENT
&>
*
cofunc
;
COROUTINE
<
int
,
TOOL_EVENT
&>
*
cofunc
;
TOOL_EVENT
wakeupEvent
;
TOOL_EVENT
wakeupEvent
;
TOOL_EVENT_LIST
waitEvents
;
TOOL_EVENT_LIST
waitEvents
;
std
::
vector
<
Transition
>
transitions
;
std
::
vector
<
Transition
>
transitions
;
};
};
TOOL_MANAGER
::
TOOL_MANAGER
()
TOOL_MANAGER
::
TOOL_MANAGER
()
{
{
}
}
void
TOOL_MANAGER
::
RegisterTool
(
TOOL_BASE
*
aTool
)
void
TOOL_MANAGER
::
RegisterTool
(
TOOL_BASE
*
aTool
)
{
{
ToolState
*
st
=
new
ToolState
;
ToolState
*
st
=
new
ToolState
;
st
->
theTool
=
aTool
;
st
->
theTool
=
aTool
;
st
->
idle
=
true
;
st
->
idle
=
true
;
...
@@ -59,25 +79,29 @@ void TOOL_MANAGER::RegisterTool ( TOOL_BASE *aTool )
...
@@ -59,25 +79,29 @@ void TOOL_MANAGER::RegisterTool ( TOOL_BASE *aTool )
st
->
cofunc
=
NULL
;
st
->
cofunc
=
NULL
;
st
->
contextMenuTrigger
=
CMENU_OFF
;
st
->
contextMenuTrigger
=
CMENU_OFF
;
m_toolState
[
aTool
]
=
st
;
m_toolState
[
aTool
]
=
st
;
m_toolNameIndex
[
aTool
->
GetName
()
]
=
st
;
m_toolNameIndex
[
aTool
->
GetName
()
]
=
st
;
m_toolIdIndex
[
aTool
->
GetId
()
]
=
st
;
m_toolIdIndex
[
aTool
->
GetId
()
]
=
st
;
aTool
->
m_toolMgr
=
this
;
aTool
->
m_toolMgr
=
this
;
if
(
aTool
->
GetType
()
==
TOOL_Interactive
)
if
(
aTool
->
GetType
()
==
TOOL_Interactive
)
static_cast
<
TOOL_INTERACTIVE
*>
(
aTool
)
->
Reset
();
static_cast
<
TOOL_INTERACTIVE
*>
(
aTool
)
->
Reset
();
}
}
void
TOOL_MANAGER
::
ScheduleNextState
(
TOOL_BASE
*
aTool
,
TOOL_STATE_FUNC
&
aHandler
,
const
TOOL_EVENT_LIST
&
aConditions
)
void
TOOL_MANAGER
::
ScheduleNextState
(
TOOL_BASE
*
aTool
,
TOOL_STATE_FUNC
&
aHandler
,
const
TOOL_EVENT_LIST
&
aConditions
)
{
{
ToolState
*
st
=
m_toolState
[
aTool
];
ToolState
*
st
=
m_toolState
[
aTool
];
st
->
transitions
.
push_back
(
Transition
(
aConditions
,
aHandler
)
);
st
->
transitions
.
push_back
(
Transition
(
aConditions
,
aHandler
)
);
}
}
optional
<
TOOL_EVENT
>
TOOL_MANAGER
::
ScheduleWait
(
TOOL_BASE
*
aTool
,
const
TOOL_EVENT_LIST
&
aConditions
)
optional
<
TOOL_EVENT
>
TOOL_MANAGER
::
ScheduleWait
(
TOOL_BASE
*
aTool
,
const
TOOL_EVENT_LIST
&
aConditions
)
{
{
ToolState
*
st
=
m_toolState
[
aTool
];
ToolState
*
st
=
m_toolState
[
aTool
];
st
->
pendingWait
=
true
;
st
->
pendingWait
=
true
;
st
->
waitEvents
=
aConditions
;
st
->
waitEvents
=
aConditions
;
...
@@ -86,34 +110,36 @@ optional<TOOL_EVENT> TOOL_MANAGER::ScheduleWait( TOOL_BASE *aTool, const TOOL_EV
...
@@ -86,34 +110,36 @@ optional<TOOL_EVENT> TOOL_MANAGER::ScheduleWait( TOOL_BASE *aTool, const TOOL_EV
return
st
->
wakeupEvent
;
return
st
->
wakeupEvent
;
}
}
void
TOOL_MANAGER
::
dispatchInternal
(
TOOL_EVENT
&
aEvent
)
void
TOOL_MANAGER
::
dispatchInternal
(
TOOL_EVENT
&
aEvent
)
{
{
// iterate over all registered tools
// iterate over all registered tools
BOOST_FOREACH
(
ToolState
*
st
,
m_toolState
|
boost
::
adaptors
::
map_values
)
BOOST_FOREACH
(
ToolState
*
st
,
m_toolState
|
boost
::
adaptors
::
map_values
)
{
{
// the tool state handler is waiting for events (i.e. called Wait() method)
// the tool state handler is waiting for events (i.e. called Wait() method)
if
(
st
->
pendingWait
)
if
(
st
->
pendingWait
)
{
{
if
(
st
->
waitEvents
.
Matches
(
aEvent
)
)
if
(
st
->
waitEvents
.
Matches
(
aEvent
)
)
{
{
// got matching event? clear wait list and wake up the coroutine
// got matching event? clear wait list and wake up the coroutine
st
->
wakeupEvent
=
aEvent
;
st
->
wakeupEvent
=
aEvent
;
st
->
pendingWait
=
false
;
st
->
pendingWait
=
false
;
st
->
waitEvents
.
clear
();
st
->
waitEvents
.
clear
();
st
->
cofunc
->
Resume
();
st
->
cofunc
->
Resume
();
if
(
!
st
->
cofunc
->
Running
()
)
if
(
!
st
->
cofunc
->
Running
()
)
delete
st
->
cofunc
;
delete
st
->
cofunc
;
}
}
}
else
{
}
else
{
// no state handler in progress - check if there are any transitions (defined by
// no state handler in progress - check if there are any transitions (defined by
// Go() method that match the event.
// Go() method that match the event.
if
(
st
->
transitions
.
size
())
{
if
(
st
->
transitions
.
size
()
)
BOOST_FOREACH
(
Transition
tr
,
st
->
transitions
)
{
BOOST_FOREACH
(
Transition
tr
,
st
->
transitions
)
{
{
if
(
tr
.
first
.
Matches
(
aEvent
)
)
if
(
tr
.
first
.
Matches
(
aEvent
)
)
{
{
st
->
transitions
.
clear
();
st
->
transitions
.
clear
();
...
@@ -123,9 +149,9 @@ void TOOL_MANAGER::dispatchInternal ( TOOL_EVENT& aEvent )
...
@@ -123,9 +149,9 @@ void TOOL_MANAGER::dispatchInternal ( TOOL_EVENT& aEvent )
st
->
cofunc
->
SetEntry
(
tr
.
second
);
st
->
cofunc
->
SetEntry
(
tr
.
second
);
// got match? Run the handler.
// got match? Run the handler.
st
->
cofunc
->
Call
(
aEvent
);
st
->
cofunc
->
Call
(
aEvent
);
if
(
!
st
->
cofunc
->
Running
()
)
if
(
!
st
->
cofunc
->
Running
()
)
delete
st
->
cofunc
;
delete
st
->
cofunc
;
}
}
}
}
...
@@ -134,16 +160,16 @@ void TOOL_MANAGER::dispatchInternal ( TOOL_EVENT& aEvent )
...
@@ -134,16 +160,16 @@ void TOOL_MANAGER::dispatchInternal ( TOOL_EVENT& aEvent )
}
}
}
}
bool
TOOL_MANAGER
::
ProcessEvent
(
TOOL_EVENT
&
aEvent
)
{
printf
(
"process: %s
\n
"
,
aEvent
.
Format
().
c_str
());
dispatchInternal
(
aEvent
);
bool
TOOL_MANAGER
::
ProcessEvent
(
TOOL_EVENT
&
aEvent
)
{
printf
(
"process: %s
\n
"
,
aEvent
.
Format
().
c_str
()
);
dispatchInternal
(
aEvent
);
BOOST_FOREACH
(
ToolState
*
st
,
m_toolState
|
boost
::
adaptors
::
map_values
)
BOOST_FOREACH
(
ToolState
*
st
,
m_toolState
|
boost
::
adaptors
::
map_values
)
{
{
if
(
st
->
contextMenuTrigger
==
CMENU_NOW
)
if
(
st
->
contextMenuTrigger
==
CMENU_NOW
)
{
{
st
->
pendingWait
=
true
;
st
->
pendingWait
=
true
;
st
->
waitEvents
=
TOOL_EVENT
(
TC_Any
,
TA_Any
);
st
->
waitEvents
=
TOOL_EVENT
(
TC_Any
,
TA_Any
);
...
@@ -157,33 +183,37 @@ bool TOOL_MANAGER::ProcessEvent (TOOL_EVENT& aEvent)
...
@@ -157,33 +183,37 @@ bool TOOL_MANAGER::ProcessEvent (TOOL_EVENT& aEvent)
}
}
}
}
if
(
m_view
->
IsDirty
()
)
if
(
m_view
->
IsDirty
()
)
{
{
PCB_EDIT_FRAME
*
f
=
static_cast
<
PCB_EDIT_FRAME
*>
(
GetEditFrame
()
);
PCB_EDIT_FRAME
*
f
=
static_cast
<
PCB_EDIT_FRAME
*>
(
GetEditFrame
()
);
f
->
GetGalCanvas
()
->
Refresh
();
// fixme: ugly hack, provide a method in TOOL_DISPATCHER.
f
->
GetGalCanvas
()
->
Refresh
();
// fixme: ugly hack, provide a method in TOOL_DISPATCHER.
}
}
return
false
;
return
false
;
}
}
void
TOOL_MANAGER
::
ScheduleContextMenu
(
TOOL_BASE
*
aTool
,
CONTEXT_MENU
*
aMenu
,
TOOL_ContextMenuTrigger
aTrigger
)
void
TOOL_MANAGER
::
ScheduleContextMenu
(
TOOL_BASE
*
aTool
,
CONTEXT_MENU
*
aMenu
,
TOOL_ContextMenuTrigger
aTrigger
)
{
{
ToolState
*
st
=
m_toolState
[
aTool
];
ToolState
*
st
=
m_toolState
[
aTool
];
st
->
contextMenu
=
aMenu
;
st
->
contextMenu
=
aMenu
;
st
->
contextMenuTrigger
=
aTrigger
;
st
->
contextMenuTrigger
=
aTrigger
;
if
(
aTrigger
==
CMENU_NOW
)
if
(
aTrigger
==
CMENU_NOW
)
st
->
cofunc
->
Yield
();
st
->
cofunc
->
Yield
();
}
}
TOOL_ID
TOOL_MANAGER
::
MakeToolId
(
const
std
::
string
&
aToolName
)
TOOL_ID
TOOL_MANAGER
::
MakeToolId
(
const
std
::
string
&
aToolName
)
{
{
static
int
currentId
;
static
int
currentId
;
return
currentId
++
;
return
currentId
++
;
}
}
void
TOOL_MANAGER
::
SetEnvironment
(
EDA_ITEM
*
aModel
,
KiGfx
::
VIEW
*
aView
,
KiGfx
::
VIEW_CONTROLS
*
aViewControls
,
wxWindow
*
aFrame
)
void
TOOL_MANAGER
::
SetEnvironment
(
EDA_ITEM
*
aModel
,
KiGfx
::
VIEW
*
aView
,
KiGfx
::
VIEW_CONTROLS
*
aViewControls
,
wxWindow
*
aFrame
)
{
{
m_model
=
aModel
;
m_model
=
aModel
;
m_view
=
aView
;
m_view
=
aView
;
...
...
include/gal/graphics_abstraction_layer.h
View file @
7d5a4563
...
@@ -29,6 +29,7 @@
...
@@ -29,6 +29,7 @@
#include <deque>
#include <deque>
#include <stack>
#include <stack>
#include <limits>
#include <wx/event.h>
#include <wx/event.h>
...
@@ -717,9 +718,13 @@ public:
...
@@ -717,9 +718,13 @@ public:
*/
*/
virtual
void
DrawCursor
(
VECTOR2D
aCursorPosition
)
=
0
;
virtual
void
DrawCursor
(
VECTOR2D
aCursorPosition
)
=
0
;
/**
* @brief Changes the current depth to deeper, so it is possible to draw objects right beneath
* other.
*/
inline
void
AdvanceDepth
()
inline
void
AdvanceDepth
()
{
{
layerDepth
-=
0
.
1
;
// fixme: there should be a minimum step
layerDepth
-=
std
::
numeric_limits
<
double
>::
epsilon
();
}
}
/**
/**
...
...
include/tool/tool_dispatcher.h
View file @
7d5a4563
...
@@ -50,22 +50,21 @@ namespace KiGfx {
...
@@ -50,22 +50,21 @@ namespace KiGfx {
class
TOOL_DISPATCHER
class
TOOL_DISPATCHER
{
{
public
:
public
:
/**
/**
* Constructor
* Constructor
*
*
* @param aToolMgr: tool manager instance the events will be sent to
* @param aToolMgr: tool manager instance the events will be sent to
* @param aEditFrame: the frame wx events come from
* @param aEditFrame: the frame wx events come from
*/
*/
TOOL_DISPATCHER
(
TOOL_MANAGER
*
aToolMgr
,
PCB_BASE_FRAME
*
aEditFrame
);
TOOL_DISPATCHER
(
TOOL_MANAGER
*
aToolMgr
,
PCB_BASE_FRAME
*
aEditFrame
);
~
TOOL_DISPATCHER
();
virtual
~
TOOL_DISPATCHER
();
virtual
void
ResetState
();
virtual
void
ResetState
();
virtual
void
DispatchWxEvent
(
wxEvent
&
aEvent
);
virtual
void
DispatchWxEvent
(
wxEvent
&
aEvent
);
virtual
void
DispatchWxCommand
(
wxCommandEvent
&
aEvent
);
virtual
void
DispatchWxCommand
(
wxCommandEvent
&
aEvent
);
private
:
private
:
static
const
int
MouseButtonCount
=
3
;
static
const
int
MouseButtonCount
=
3
;
static
const
int
DragTimeThreshold
=
300
;
static
const
int
DragTimeThreshold
=
300
;
static
const
int
DragDistanceThreshold
=
8
;
static
const
int
DragDistanceThreshold
=
8
;
...
@@ -76,12 +75,12 @@ class TOOL_DISPATCHER
...
@@ -76,12 +75,12 @@ class TOOL_DISPATCHER
int
decodeModifiers
(
wxEvent
&
aEvent
);
int
decodeModifiers
(
wxEvent
&
aEvent
);
KiGfx
::
VIEW
*
getView
();
KiGfx
::
VIEW
*
getView
();
struct
ButtonState
;
struct
ButtonState
;
TOOL_MANAGER
*
m_toolMgr
;
TOOL_MANAGER
*
m_toolMgr
;
PCB_BASE_FRAME
*
m_editFrame
;
PCB_BASE_FRAME
*
m_editFrame
;
VECTOR2D
m_lastMousePos
;
VECTOR2D
m_lastMousePos
;
std
::
vector
<
ButtonState
*>
m_buttons
;
std
::
vector
<
ButtonState
*>
m_buttons
;
...
...
include/tool/tool_manager.h
View file @
7d5a4563
...
@@ -58,7 +58,7 @@ class TOOL_MANAGER
...
@@ -58,7 +58,7 @@ class TOOL_MANAGER
/**
/**
* Generates an unique ID from for a tool with given name.
* Generates an unique ID from for a tool with given name.
*/
*/
static
TOOL_ID
MakeToolId
(
const
std
::
string
&
aToolName
);
static
TOOL_ID
MakeToolId
(
const
std
::
string
&
aToolName
);
/**
/**
* Function RegisterTool()
* Function RegisterTool()
...
@@ -66,46 +66,46 @@ class TOOL_MANAGER
...
@@ -66,46 +66,46 @@ class TOOL_MANAGER
* each tool during application initialization.
* each tool during application initialization.
* @param aTool: tool to be added. Ownership is transferred.
* @param aTool: tool to be added. Ownership is transferred.
*/
*/
void
RegisterTool
(
TOOL_BASE
*
aTool
);
void
RegisterTool
(
TOOL_BASE
*
aTool
);
/**
/**
* Function InvokeTool()
* Function InvokeTool()
* Calls a tool by sending a tool activation event to tool of given ID or name.
* Calls a tool by sending a tool activation event to tool of given ID or name.
* An user-defined parameter object can be also passed
* An user-defined parameter object can be also passed
*/
*/
void
InvokeTool
(
TOOL_ID
aToolId
);
void
InvokeTool
(
TOOL_ID
aToolId
);
void
InvokeTool
(
const
std
::
string
&
name
);
void
InvokeTool
(
const
std
::
string
&
name
);
template
<
class
Parameters
>
template
<
class
Parameters
>
void
InvokeTool
(
const
std
::
string
&
name
,
const
Parameters
&
aToolParams
);
void
InvokeTool
(
const
std
::
string
&
name
,
const
Parameters
&
aToolParams
);
/**
/**
* Function FindTool()
* Function FindTool()
* Searches for a tool with given name or ID
* Searches for a tool with given name or ID
*/
*/
TOOL_BASE
*
FindTool
(
int
aId
);
TOOL_BASE
*
FindTool
(
int
aId
);
TOOL_BASE
*
FindTool
(
const
std
::
string
&
aName
);
TOOL_BASE
*
FindTool
(
const
std
::
string
&
aName
);
/**
/**
* Resets the state of a given tool by clearing its wait and
* Resets the state of a given tool by clearing its wait and
* transition lists and calling tool's internal Reset() method.
* transition lists and calling tool's internal Reset() method.
*/
*/
void
ResetTool
(
TOOL_BASE
*
aTool
);
void
ResetTool
(
TOOL_BASE
*
aTool
);
/**
/**
* Takes an event from the TOOL_DISPATCHER and propagates it to
* Takes an event from the TOOL_DISPATCHER and propagates it to
* tools that requested events of matching type(s)
* tools that requested events of matching type(s)
*/
*/
bool
ProcessEvent
(
TOOL_EVENT
&
aEvent
);
bool
ProcessEvent
(
TOOL_EVENT
&
aEvent
);
/**
/**
* Sets the work environment (model, view, view controls and the parent window).
* Sets the work environment (model, view, view controls and the parent window).
* These are made available to the tool. Called by the parent frame (PCB_EDIT_FRAME)
* These are made available to the tool. Called by the parent frame (PCB_EDIT_FRAME)
* when the board is set up
* when the board is set up
*/
*/
void
SetEnvironment
(
EDA_ITEM
*
aModel
,
KiGfx
::
VIEW
*
aView
,
KiGfx
::
VIEW_CONTROLS
*
aViewControls
,
wxWindow
*
aFrame
);
void
SetEnvironment
(
EDA_ITEM
*
aModel
,
KiGfx
::
VIEW
*
aView
,
KiGfx
::
VIEW_CONTROLS
*
aViewControls
,
wxWindow
*
aFrame
);
/* Accessors for the environment objects (view, model, etc.) */
/* Accessors for the environment objects (view, model, etc.) */
KiGfx
::
VIEW
*
GetView
()
KiGfx
::
VIEW
*
GetView
()
...
@@ -132,13 +132,16 @@ class TOOL_MANAGER
...
@@ -132,13 +132,16 @@ class TOOL_MANAGER
* Defines a state transition - the events that cause a given handler method in the tool
* Defines a state transition - the events that cause a given handler method in the tool
* to be called. Called by TOOL_INTERACTIVE::Go(). May be called from a coroutine context.
* to be called. Called by TOOL_INTERACTIVE::Go(). May be called from a coroutine context.
*/
*/
void
ScheduleNextState
(
TOOL_BASE
*
aTool
,
TOOL_STATE_FUNC
&
aHandler
,
const
TOOL_EVENT_LIST
&
aConditions
);
void
ScheduleNextState
(
TOOL_BASE
*
aTool
,
TOOL_STATE_FUNC
&
aHandler
,
const
TOOL_EVENT_LIST
&
aConditions
);
/**
/**
* Pauses execution of a given tool until one or more events matching aConditions arrives. The pause/resume
* Pauses execution of a given tool until one or more events matching aConditions arrives.
* operation is done through COROUTINE object. Called only from coroutines.
* The pause/resume operation is done through COROUTINE object.
* Called only from coroutines.
*/
*/
boost
::
optional
<
TOOL_EVENT
>
ScheduleWait
(
TOOL_BASE
*
aTool
,
const
TOOL_EVENT_LIST
&
aConditions
);
boost
::
optional
<
TOOL_EVENT
>
ScheduleWait
(
TOOL_BASE
*
aTool
,
const
TOOL_EVENT_LIST
&
aConditions
);
/**
/**
* Sets behaviour of the tool's context popup menu.
* Sets behaviour of the tool's context popup menu.
...
@@ -149,10 +152,10 @@ class TOOL_MANAGER
...
@@ -149,10 +152,10 @@ class TOOL_MANAGER
* CMENU_OFF: menu is disabled.
* CMENU_OFF: menu is disabled.
* May be called from a coroutine context.
* May be called from a coroutine context.
*/
*/
void
ScheduleContextMenu
(
TOOL_BASE
*
aTool
,
CONTEXT_MENU
*
aMenu
,
TOOL_ContextMenuTrigger
aTrigger
);
void
ScheduleContextMenu
(
TOOL_BASE
*
aTool
,
CONTEXT_MENU
*
aMenu
,
TOOL_ContextMenuTrigger
aTrigger
);
private
:
private
:
void
dispatchInternal
(
TOOL_EVENT
&
aEvent
);
void
dispatchInternal
(
TOOL_EVENT
&
aEvent
);
struct
ToolState
;
struct
ToolState
;
...
@@ -162,13 +165,12 @@ class TOOL_MANAGER
...
@@ -162,13 +165,12 @@ class TOOL_MANAGER
std
::
map
<
std
::
string
,
ToolState
*>
m_toolNameIndex
;
std
::
map
<
std
::
string
,
ToolState
*>
m_toolNameIndex
;
std
::
map
<
TOOL_ID
,
ToolState
*>
m_toolIdIndex
;
std
::
map
<
TOOL_ID
,
ToolState
*>
m_toolIdIndex
;
EDA_ITEM
*
m_model
;
EDA_ITEM
*
m_model
;
KiGfx
::
VIEW
*
m_view
;
KiGfx
::
VIEW
*
m_view
;
KiGfx
::
VIEW_CONTROLS
*
m_viewControls
;
KiGfx
::
VIEW_CONTROLS
*
m_viewControls
;
wxWindow
*
m_editFrame
;
wxWindow
*
m_editFrame
;
ToolState
*
m_currentTool
;
ToolState
*
m_currentTool
;
};
};
#endif
#endif
pcbnew/tools/pcb_tools.cpp
View file @
7d5a4563
...
@@ -41,15 +41,15 @@ void PCB_EDIT_FRAME::setupTools()
...
@@ -41,15 +41,15 @@ void PCB_EDIT_FRAME::setupTools()
// create the manager and dispatcher. Route draw panel events to the dispatcher.
// create the manager and dispatcher. Route draw panel events to the dispatcher.
m_toolManager
=
new
TOOL_MANAGER
;
m_toolManager
=
new
TOOL_MANAGER
;
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 our selection tool.
// register our selection tool.
m_toolManager
->
RegisterTool
(
new
SELECTION_TOOL
);
m_toolManager
->
RegisterTool
(
new
SELECTION_TOOL
);
}
}
void
PCB_EDIT_FRAME
::
onGenericCommand
(
wxCommandEvent
&
aEvent
)
void
PCB_EDIT_FRAME
::
onGenericCommand
(
wxCommandEvent
&
aEvent
)
{
{
m_toolDispatcher
->
DispatchWxCommand
(
aEvent
);
m_toolDispatcher
->
DispatchWxCommand
(
aEvent
);
}
}
pcbnew/tools/selection_area.cpp
View file @
7d5a4563
...
@@ -39,15 +39,17 @@ const BOX2I SELECTION_AREA::ViewBBox() const
...
@@ -39,15 +39,17 @@ const BOX2I SELECTION_AREA::ViewBBox() const
return
tmp
;
return
tmp
;
}
}
void
SELECTION_AREA
::
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
void
SELECTION_AREA
::
ViewGetLayers
(
int
aLayers
[],
int
&
aCount
)
const
{
{
aLayers
[
0
]
=
SelectionLayer
;
aLayers
[
0
]
=
SelectionLayer
;
aCount
=
1
;
aCount
=
1
;
}
}
void
SELECTION_AREA
::
ViewDraw
(
int
aLayer
,
GAL
*
aGal
,
const
BOX2I
&
aVisibleArea
)
const
void
SELECTION_AREA
::
ViewDraw
(
int
aLayer
,
GAL
*
aGal
,
const
BOX2I
&
aVisibleArea
)
const
{
{
VECTOR2D
width
=
m_view
->
ToWorld
(
VECTOR2D
(
1.0
,
1.0
),
false
);
// fixme: pixel-sized stroke width setting?
VECTOR2D
width
=
m_view
->
ToWorld
(
VECTOR2D
(
1.0
,
1.0
),
false
);
// fixme: pixel-sized stroke width setting?
aGal
->
SetLineWidth
(
width
.
x
);
aGal
->
SetLineWidth
(
width
.
x
);
aGal
->
SetStrokeColor
(
COLOR4D
(
1.0
,
1.0
,
0.4
,
1.0
));
aGal
->
SetStrokeColor
(
COLOR4D
(
1.0
,
1.0
,
0.4
,
1.0
));
aGal
->
SetFillColor
(
COLOR4D
(
0.3
,
0.3
,
0.5
,
0.3
));
aGal
->
SetFillColor
(
COLOR4D
(
0.3
,
0.3
,
0.5
,
0.3
));
...
@@ -57,6 +59,8 @@ void SELECTION_AREA::ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea
...
@@ -57,6 +59,8 @@ void SELECTION_AREA::ViewDraw( int aLayer, GAL* aGal, const BOX2I& aVisibleArea
aGal
->
DrawRectangle
(
m_origin
,
m_end
);
aGal
->
DrawRectangle
(
m_origin
,
m_end
);
}
}
SELECTION_AREA
::
SELECTION_AREA
()
:
EDA_ITEM
(
NOT_USED
)
// this item is never added to a BOARD so it needs no type.
SELECTION_AREA
::
SELECTION_AREA
()
:
{}
EDA_ITEM
(
NOT_USED
)
// this item is never added to a BOARD so it needs no type.
\ No newline at end of file
{
}
pcbnew/tools/selection_area.h
View file @
7d5a4563
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
*/
*/
class
SELECTION_AREA
:
public
EDA_ITEM
class
SELECTION_AREA
:
public
EDA_ITEM
{
{
public
:
public
:
static
const
int
SelectionLayer
=
126
;
// fixme: define globally
static
const
int
SelectionLayer
=
126
;
// fixme: define globally
SELECTION_AREA
();
SELECTION_AREA
();
...
@@ -64,12 +64,9 @@ class SELECTION_AREA : public EDA_ITEM
...
@@ -64,12 +64,9 @@ class SELECTION_AREA : public EDA_ITEM
void
Show
(
int
x
,
std
::
ostream
&
st
)
const
void
Show
(
int
x
,
std
::
ostream
&
st
)
const
{
{
}
}
private
:
private
:
VECTOR2I
m_origin
,
m_end
;
VECTOR2I
m_origin
,
m_end
;
};
};
...
...
pcbnew/tools/selection_tool.cpp
View file @
7d5a4563
...
@@ -64,11 +64,9 @@ void SELECTION_TOOL::Reset()
...
@@ -64,11 +64,9 @@ void SELECTION_TOOL::Reset()
int
SELECTION_TOOL
::
Main
(
TOOL_EVENT
&
aEvent
)
int
SELECTION_TOOL
::
Main
(
TOOL_EVENT
&
aEvent
)
{
{
// Main loop: keep receiving events
// Main loop: keep receiving events
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
while
(
OPT_TOOL_EVENT
evt
=
Wait
()
)
{
{
if
(
evt
->
IsCancel
()
)
if
(
evt
->
IsCancel
()
)
return
0
;
return
0
;
...
@@ -87,7 +85,6 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
...
@@ -87,7 +85,6 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
void
SELECTION_TOOL
::
toggleSelection
(
BOARD_ITEM
*
aItem
,
bool
aAdditive
)
void
SELECTION_TOOL
::
toggleSelection
(
BOARD_ITEM
*
aItem
,
bool
aAdditive
)
{
{
if
(
m_selectedItems
.
find
(
aItem
)
!=
m_selectedItems
.
end
()
)
if
(
m_selectedItems
.
find
(
aItem
)
!=
m_selectedItems
.
end
()
)
{
{
aItem
->
ClearSelected
();
aItem
->
ClearSelected
();
...
@@ -104,7 +101,7 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem, bool aAdditive )
...
@@ -104,7 +101,7 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem, bool aAdditive )
void
SELECTION_TOOL
::
clearSelection
()
void
SELECTION_TOOL
::
clearSelection
()
{
{
BOOST_FOREACH
(
BOARD_ITEM
*
item
,
m_selectedItems
)
BOOST_FOREACH
(
BOARD_ITEM
*
item
,
m_selectedItems
)
{
{
item
->
ClearSelected
();
item
->
ClearSelected
();
}
}
...
@@ -113,17 +110,17 @@ void SELECTION_TOOL::clearSelection()
...
@@ -113,17 +110,17 @@ void SELECTION_TOOL::clearSelection()
}
}
void
SELECTION_TOOL
::
selectSingle
(
const
VECTOR2I
&
aWhere
,
bool
aAdditive
)
void
SELECTION_TOOL
::
selectSingle
(
const
VECTOR2I
&
aWhere
,
bool
aAdditive
)
{
{
BOARD
*
pcb
=
getModel
<
BOARD
>
(
PCB_T
);
BOARD
*
pcb
=
getModel
<
BOARD
>
(
PCB_T
);
BOARD_ITEM
*
item
;
BOARD_ITEM
*
item
;
GENERAL_COLLECTORS_GUIDE
guide
=
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
GetCollectorsGuide
();
GENERAL_COLLECTORS_GUIDE
guide
=
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
GetCollectorsGuide
();
GENERAL_COLLECTOR
collector
;
GENERAL_COLLECTOR
collector
;
collector
.
Collect
(
pcb
,
GENERAL_COLLECTOR
::
AllBoardItems
,
wxPoint
(
aWhere
.
x
,
aWhere
.
y
),
collector
.
Collect
(
pcb
,
GENERAL_COLLECTOR
::
AllBoardItems
,
wxPoint
(
aWhere
.
x
,
aWhere
.
y
),
guide
);
guide
);
switch
(
collector
.
GetCount
()
)
switch
(
collector
.
GetCount
()
)
{
{
case
0
:
case
0
:
if
(
!
aAdditive
)
if
(
!
aAdditive
)
...
@@ -161,7 +158,7 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
...
@@ -161,7 +158,7 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
for
(
int
i
=
0
;
i
<
count
;
++
i
)
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
{
MODULE
*
module
=
(
MODULE
*
)
(
*
aCollector
)[
i
];
MODULE
*
module
=
(
MODULE
*
)(
*
aCollector
)[
i
];
int
lx
=
module
->
GetBoundingBox
().
GetWidth
();
int
lx
=
module
->
GetBoundingBox
().
GetWidth
();
int
ly
=
module
->
GetBoundingBox
().
GetHeight
();
int
ly
=
module
->
GetBoundingBox
().
GetHeight
();
...
@@ -175,7 +172,7 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
...
@@ -175,7 +172,7 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
}
}
}
}
return
(
*
aCollector
)[
minNdx
];
return
(
*
aCollector
)[
minNdx
];
}
}
...
@@ -219,7 +216,7 @@ void SELECTION_TOOL::selectMultiple()
...
@@ -219,7 +216,7 @@ void SELECTION_TOOL::selectMultiple()
}
}
BOARD_ITEM
*
SELECTION_TOOL
::
disambiguationMenu
(
GENERAL_COLLECTOR
*
aCollector
)
BOARD_ITEM
*
SELECTION_TOOL
::
disambiguationMenu
(
GENERAL_COLLECTOR
*
aCollector
)
{
{
CONTEXT_MENU
cmenu
;
CONTEXT_MENU
cmenu
;
OPT_TOOL_EVENT
evt
;
OPT_TOOL_EVENT
evt
;
...
...
pcbnew/tools/selection_tool.h
View file @
7d5a4563
...
@@ -56,13 +56,13 @@ public:
...
@@ -56,13 +56,13 @@ public:
int
Main
(
TOOL_EVENT
&
aEvent
);
int
Main
(
TOOL_EVENT
&
aEvent
);
private
:
private
:
void
selectSingle
(
const
VECTOR2I
&
aWhere
,
bool
aAdditive
);
void
selectSingle
(
const
VECTOR2I
&
aWhere
,
bool
aAdditive
);
void
selectMultiple
();
void
selectMultiple
();
void
handleHighlight
(
const
VECTOR2D
&
aP
);
void
handleHighlight
(
const
VECTOR2D
&
aP
);
BOARD_ITEM
*
disambiguationMenu
(
GENERAL_COLLECTOR
*
aItems
);
BOARD_ITEM
*
disambiguationMenu
(
GENERAL_COLLECTOR
*
aItems
);
BOARD_ITEM
*
pickSmallestComponent
(
GENERAL_COLLECTOR
*
aCollector
);
BOARD_ITEM
*
pickSmallestComponent
(
GENERAL_COLLECTOR
*
aCollector
);
void
toggleSelection
(
BOARD_ITEM
*
aItem
,
bool
aAdditive
);
void
toggleSelection
(
BOARD_ITEM
*
aItem
,
bool
aAdditive
);
void
clearSelection
();
void
clearSelection
();
std
::
set
<
BOARD_ITEM
*>
m_selectedItems
;
std
::
set
<
BOARD_ITEM
*>
m_selectedItems
;
SELECTION_AREA
*
m_selArea
;
SELECTION_AREA
*
m_selArea
;
...
...
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