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
235da608
Commit
235da608
authored
Feb 27, 2014
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SELECTION_TOOL emits event notifying about selecting/deselecting/clearing selection.
parent
e6598e9d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
4 deletions
+42
-4
selection_tool.cpp
pcbnew/tools/selection_tool.cpp
+37
-4
selection_tool.h
pcbnew/tools/selection_tool.h
+5
-0
No files found.
pcbnew/tools/selection_tool.cpp
View file @
235da608
...
@@ -50,7 +50,11 @@
...
@@ -50,7 +50,11 @@
using
boost
::
optional
;
using
boost
::
optional
;
SELECTION_TOOL
::
SELECTION_TOOL
()
:
SELECTION_TOOL
::
SELECTION_TOOL
()
:
TOOL_INTERACTIVE
(
"pcbnew.InteractiveSelection"
),
m_additive
(
false
),
m_multiple
(
false
)
TOOL_INTERACTIVE
(
"pcbnew.InteractiveSelection"
),
SelectedEvent
(
TC_MESSAGE
,
TA_ACTION
,
"pcbnew.InteractiveSelection.selected"
),
DeselectedEvent
(
TC_MESSAGE
,
TA_ACTION
,
"pcbnew.InteractiveSelection.deselected"
),
ClearedEvent
(
TC_MESSAGE
,
TA_ACTION
,
"pcbnew.InteractiveSelection.cleared"
),
m_additive
(
false
),
m_multiple
(
false
)
{
{
m_selArea
=
new
SELECTION_AREA
;
m_selArea
=
new
SELECTION_AREA
;
m_selection
.
group
=
new
KIGFX
::
VIEW_GROUP
;
m_selection
.
group
=
new
KIGFX
::
VIEW_GROUP
;
...
@@ -94,6 +98,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
...
@@ -94,6 +98,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
selectionSingle
)
)
if
(
evt
->
IsAction
(
&
COMMON_ACTIONS
::
selectionSingle
)
)
{
{
// GetMousePosition() is used to be independent of snapping settings
selectSingle
(
getView
()
->
ToWorld
(
getViewControls
()
->
GetMousePosition
()
)
);
selectSingle
(
getView
()
->
ToWorld
(
getViewControls
()
->
GetMousePosition
()
)
);
}
}
...
@@ -167,6 +172,10 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
...
@@ -167,6 +172,10 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
if
(
aItem
->
IsSelected
()
)
if
(
aItem
->
IsSelected
()
)
{
{
deselect
(
aItem
);
deselect
(
aItem
);
// Inform other potentially interested tools
TOOL_EVENT
deselectEvent
(
DeselectedEvent
);
m_toolMgr
->
ProcessEvent
(
deselectEvent
);
}
}
else
else
{
{
...
@@ -175,7 +184,13 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
...
@@ -175,7 +184,13 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
// Prevent selection of invisible or inactive items
// Prevent selection of invisible or inactive items
if
(
selectable
(
aItem
)
)
if
(
selectable
(
aItem
)
)
{
select
(
aItem
);
select
(
aItem
);
// Inform other potentially interested tools
TOOL_EVENT
selectEvent
(
SelectedEvent
);
m_toolMgr
->
ProcessEvent
(
selectEvent
);
}
}
}
}
}
...
@@ -203,7 +218,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere )
...
@@ -203,7 +218,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere )
default
:
default
:
// Remove unselectable items
// Remove unselectable items
for
(
int
i
=
collector
.
GetCount
()
-
1
;
i
>=
0
;
--
i
)
for
(
int
i
=
collector
.
GetCount
()
-
1
;
i
>=
0
;
--
i
)
{
{
if
(
!
selectable
(
collector
[
i
]
)
)
if
(
!
selectable
(
collector
[
i
]
)
)
collector
.
Remove
(
i
);
collector
.
Remove
(
i
);
...
@@ -273,13 +288,21 @@ bool SELECTION_TOOL::selectMultiple()
...
@@ -273,13 +288,21 @@ bool SELECTION_TOOL::selectMultiple()
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
it
->
first
);
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
it
->
first
);
// Add only those items that are visible and fully within the selection box
// Add only those items that are visible and fully within the selection box
if
(
!
item
->
IsSelected
()
&&
selectable
(
item
)
&&
selectionBox
.
Contains
(
item
->
ViewBBox
()
)
)
if
(
!
item
->
IsSelected
()
&&
selectable
(
item
)
&&
selectionBox
.
Contains
(
item
->
ViewBBox
()
)
)
select
(
item
);
select
(
item
);
}
}
// Do not display information about selected item,as there is more than one
// Do not display information about selected item,as there is more than one
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
SetCurItem
(
NULL
);
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
SetCurItem
(
NULL
);
if
(
!
m_selection
.
Empty
()
)
{
// Inform other potentially interested tools
TOOL_EVENT
selectEvent
(
SelectedEvent
);
m_toolMgr
->
ProcessEvent
(
selectEvent
);
}
break
;
// Stop waiting for events
break
;
// Stop waiting for events
}
}
}
}
...
@@ -313,6 +336,10 @@ void SELECTION_TOOL::clearSelection()
...
@@ -313,6 +336,10 @@ void SELECTION_TOOL::clearSelection()
// Do not show the context menu when there is nothing selected
// Do not show the context menu when there is nothing selected
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
// Inform other potentially interested tools
TOOL_EVENT
clearEvent
(
ClearedEvent
);
m_toolMgr
->
ProcessEvent
(
clearEvent
);
}
}
...
@@ -351,7 +378,9 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
...
@@ -351,7 +378,9 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
current
->
SetBrightened
();
current
->
SetBrightened
();
}
}
else
else
{
current
=
NULL
;
current
=
NULL
;
}
}
}
else
if
(
evt
->
Action
()
==
TA_CONTEXT_MENU_CHOICE
)
else
if
(
evt
->
Action
()
==
TA_CONTEXT_MENU_CHOICE
)
{
{
...
@@ -412,7 +441,7 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
...
@@ -412,7 +441,7 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
}
}
}
}
return
(
*
aCollector
)[
minNdx
];
return
(
*
aCollector
)[
minNdx
];
}
}
...
@@ -543,6 +572,10 @@ void SELECTION_TOOL::deselect( BOARD_ITEM* aItem )
...
@@ -543,6 +572,10 @@ void SELECTION_TOOL::deselect( BOARD_ITEM* aItem )
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
SetCurItem
(
NULL
);
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
SetCurItem
(
NULL
);
}
}
// Inform other potentially interested tools
TOOL_EVENT
dupa
(
DeselectedEvent
);
m_toolMgr
->
ProcessEvent
(
dupa
);
}
}
...
...
pcbnew/tools/selection_tool.h
View file @
235da608
...
@@ -114,6 +114,11 @@ public:
...
@@ -114,6 +114,11 @@ public:
*/
*/
void
AddMenuItem
(
const
TOOL_ACTION
&
aAction
);
void
AddMenuItem
(
const
TOOL_ACTION
&
aAction
);
// TODO comments
const
TOOL_EVENT
SelectedEvent
;
const
TOOL_EVENT
DeselectedEvent
;
const
TOOL_EVENT
ClearedEvent
;
private
:
private
:
/**
/**
* Function selectSingle()
* Function selectSingle()
...
...
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