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
27c7eb5d
Commit
27c7eb5d
authored
Dec 04, 2013
by
Maciej Suminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
The Selection Tool displays information about selected items. ClearSelection() made public.
parent
24a317ce
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
43 deletions
+64
-43
selection_tool.cpp
pcbnew/tools/selection_tool.cpp
+52
-40
selection_tool.h
pcbnew/tools/selection_tool.h
+12
-3
No files found.
pcbnew/tools/selection_tool.cpp
View file @
27c7eb5d
...
...
@@ -66,7 +66,7 @@ SELECTION_TOOL::~SELECTION_TOOL()
void
SELECTION_TOOL
::
Reset
()
{
c
learSelection
();
C
learSelection
();
// Reinsert the VIEW_GROUP, in case it was removed from the VIEW
getView
()
->
Remove
(
m_selection
.
group
);
...
...
@@ -89,7 +89,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
if
(
evt
->
IsCancel
()
)
{
if
(
!
m_selection
.
Empty
()
)
// Cancel event deselects items...
c
learSelection
();
C
learSelection
();
// This tool never exits
}
...
...
@@ -98,7 +98,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
else
if
(
evt
->
IsClick
(
BUT_LEFT
)
)
{
if
(
!
m_additive
&&
m_selection
.
Size
()
>
1
)
c
learSelection
();
C
learSelection
();
selectSingle
(
evt
->
Position
()
);
}
...
...
@@ -132,7 +132,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
else
{
// No -> clear the selection list
c
learSelection
();
C
learSelection
();
}
}
}
...
...
@@ -145,6 +145,28 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
}
void
SELECTION_TOOL
::
ClearSelection
()
{
KIGFX
::
VIEW_GROUP
::
const_iter
it
,
it_end
;
// Restore the initial properties
for
(
it
=
m_selection
.
group
->
Begin
(),
it_end
=
m_selection
.
group
->
End
();
it
!=
it_end
;
++
it
)
{
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
*
it
);
item
->
ViewSetVisible
(
true
);
item
->
ClearSelected
();
}
m_selection
.
Clear
();
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
SetCurItem
(
NULL
);
// Do not show the context menu when there is nothing selected
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
}
void
SELECTION_TOOL
::
AddMenuItem
(
const
TOOL_ACTION
&
aAction
)
{
assert
(
aAction
.
GetId
()
>
0
);
// Check if the action was registered before in ACTION_MANAGER
...
...
@@ -155,48 +177,25 @@ void SELECTION_TOOL::AddMenuItem( const TOOL_ACTION& aAction )
void
SELECTION_TOOL
::
toggleSelection
(
BOARD_ITEM
*
aItem
)
{
if
(
m_selection
.
items
.
find
(
aItem
)
!=
m_selection
.
items
.
end
(
)
)
if
(
isSelected
(
aItem
)
)
{
deselectItem
(
aItem
);
// If there is nothing selected, disable the context menu
if
(
m_selection
.
Empty
()
)
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
}
else
{
if
(
!
m_additive
)
c
learSelection
();
C
learSelection
();
// Prevent selection of invisible or inactive items
if
(
selectable
(
aItem
)
)
{
selectItem
(
aItem
);
// Now the context menu should be enabled
SetContextMenu
(
&
m_menu
,
CMENU_BUTTON
);
}
}
}
void
SELECTION_TOOL
::
clearSelection
()
bool
SELECTION_TOOL
::
isSelected
(
const
BOARD_ITEM
*
aItem
)
const
{
KIGFX
::
VIEW_GROUP
::
const_iter
it
,
it_end
;
// Restore the initial properties
for
(
it
=
m_selection
.
group
->
Begin
(),
it_end
=
m_selection
.
group
->
End
();
it
!=
it_end
;
++
it
)
{
BOARD_ITEM
*
item
=
static_cast
<
BOARD_ITEM
*>
(
*
it
);
item
->
ViewSetVisible
(
true
);
item
->
ClearSelected
();
}
m_selection
.
Clear
();
// Do not show the context menu when there is nothing selected
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
return
(
m_selection
.
items
.
find
(
const_cast
<
BOARD_ITEM
*>
(
aItem
)
)
!=
m_selection
.
items
.
end
()
);
}
...
...
@@ -214,7 +213,7 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere )
{
case
0
:
if
(
!
m_additive
)
c
learSelection
();
C
learSelection
();
break
;
...
...
@@ -308,7 +307,7 @@ bool SELECTION_TOOL::selectMultiple()
if
(
evt
->
IsDrag
(
BUT_LEFT
)
)
{
if
(
!
m_additive
)
c
learSelection
();
C
learSelection
();
// Start drawing a selection box
m_selArea
->
SetOrigin
(
evt
->
DragOrigin
()
);
...
...
@@ -338,11 +337,10 @@ bool SELECTION_TOOL::selectMultiple()
selectItem
(
item
);
}
// Now the context menu should be enabled
if
(
!
m_selection
.
Empty
()
)
SetContextMenu
(
&
m_menu
,
CMENU_BUTTON
);
// Do not display information about selected item,as there is more than one
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
SetCurItem
(
NULL
);
break
;
break
;
// Stop waiting for events
}
}
...
...
@@ -413,9 +411,6 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector )
// Removes possible brighten mark
getView
()
->
MarkTargetDirty
(
KIGFX
::
TARGET_OVERLAY
);
// Restore the original menu
SetContextMenu
(
&
m_menu
,
CMENU_BUTTON
);
return
current
;
}
...
...
@@ -542,6 +537,16 @@ void SELECTION_TOOL::selectItem( BOARD_ITEM* aItem )
// Add items to the VIEW_GROUP, so they will be displayed on the overlay
selectBase
(
aItem
);
m_selection
.
items
.
insert
(
aItem
);
// It is enough to do it only for the first selected item
if
(
m_selection
.
items
.
size
()
==
1
)
{
// Set as the current item, so the information about selection is displayed
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
SetCurItem
(
aItem
,
true
);
// Now the context menu should be enabled
SetContextMenu
(
&
m_menu
,
CMENU_BUTTON
);
}
}
...
...
@@ -584,6 +589,13 @@ void SELECTION_TOOL::deselectItem( BOARD_ITEM* aItem )
deselectBase
(
aItem
);
m_selection
.
items
.
erase
(
aItem
);
// If there is nothing selected, disable the context menu
if
(
m_selection
.
Empty
()
)
{
SetContextMenu
(
&
m_menu
,
CMENU_OFF
);
getEditFrame
<
PCB_EDIT_FRAME
>
()
->
SetCurItem
(
NULL
);
}
}
...
...
pcbnew/tools/selection_tool.h
View file @
27c7eb5d
...
...
@@ -104,6 +104,12 @@ public:
return
m_selection
;
}
/**
* Function ClearSelection()
* Clears the current selection.
*/
void
ClearSelection
();
/**
* Function AddAction()
*
...
...
@@ -156,10 +162,13 @@ private:
void
toggleSelection
(
BOARD_ITEM
*
aItem
);
/**
* Function clearSelection()
* Clears selections of currently selected items.
* Function isSelected()
* Tests if an item is currently selected.
*
* @param aItem is the item to be checked.
* @return True if the item is selected, false otherwise.
*/
void
clearSelection
()
;
bool
isSelected
(
const
BOARD_ITEM
*
aItem
)
const
;
/**
* Function selectable()
...
...
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