KiCad PCB EDA Suite
SELECTION_TOOL Class Reference

Class SELECTION_TOOL. More...

#include <selection_tool.h>

Inheritance diagram for SELECTION_TOOL:
PCB_TOOL TOOL_INTERACTIVE TOOL_BASE

Classes

class  PRIV
 Private implementation of firewalled private data. More...
 

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 SELECTION_TOOL ()
 
 ~SELECTION_TOOL ()
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
int Main (const TOOL_EVENT &aEvent)
 Function Main() More...
 
SELECTIONGetSelection ()
 Function GetSelection() More...
 
SELECTIONRequestSelection (int aFlags=SELECTION_DEFAULT, CLIENT_SELECTION_FILTER aClientFilter=NULL)
 Function RequestSelection() More...
 
TOOL_MENUGetToolMenu ()
 
SELECTION_LOCK_FLAGS CheckLock ()
 

Checks if the user has agreed to modify locked items for the given selection.

More...
 
int CursorSelection (const TOOL_EVENT &aEvent)
 

Select a single item under cursor event handler.

More...
 
int ClearSelection (const TOOL_EVENT &aEvent)
 

Clear current selection event handler.

More...
 
bool SanitizeSelection ()
 

Makes sure a group selection does not contain items that would cause conflicts when moving/rotating together (e.g.

More...
 
int SelectItem (const TOOL_EVENT &aEvent)
 

Item selection event handler.

More...
 
int SelectItems (const TOOL_EVENT &aEvent)
 

Multiple item selection event handler

More...
 
int UnselectItem (const TOOL_EVENT &aEvent)
 

Item unselection event handler.

More...
 
int UnselectItems (const TOOL_EVENT &aEvent)
 

Multiple item unselection event handler

More...
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
void zoomFitSelection (void)
 

Zooms the screen to center and fit the current selection.

More...
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Static Public Attributes

static const TOOL_EVENT SelectedEvent
 

Event sent after an item is selected.

More...
 
static const TOOL_EVENT UnselectedEvent
 

Event sent after an item is unselected.

More...
 
static const TOOL_EVENT ClearedEvent
 

Event sent after selection is cleared.

More...
 

Protected Types

enum  INTERACTIVE_PLACEMENT_OPTIONS {
  IPO_ROTATE = 1, IPO_FLIP = 2, IPO_PROPERTIES = 4, IPO_SINGLE_CLICK = 8,
  IPO_REPEAT = 16
}
 

Protected Member Functions

void doInteractiveItemPlacement (INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const SELECTIONselection () const
 
SELECTIONselection ()
 
const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

bool m_editModules
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

bool selectPoint (const VECTOR2I &aWhere, bool aOnDrag=false, bool *aSelectionCancelledFlag=NULL, CLIENT_SELECTION_FILTER aClientFilter=NULL)
 Function selectPoint() Selects an item pointed by the parameter aWhere. More...
 
bool selectCursor (bool aSelectAlways=false, CLIENT_SELECTION_FILTER aClientFilter=NULL)
 Function selectCursor() Selects an item under the cursor unless there is something already selected or aSelectAlways is true. More...
 
bool selectMultiple ()
 Function selectMultiple() Handles drawing a selection box that allows to select many items at the same time. More...
 
int selectConnection (const TOOL_EVENT &aEvent)
 

Selects a trivial connection (between two junctions) of items in selection

More...
 
int expandSelectedConnection (const TOOL_EVENT &aEvent)
 

Expands the current selection to select a connection between two junctions

More...
 
int selectCopper (const TOOL_EVENT &aEvent)
 

Selects items with a continuous copper connection to items in selection

More...
 
int selectNet (const TOOL_EVENT &aEvent)
 Selects all copper connections belonging to the same net(s) as the items in the selection. More...
 
void selectAllItemsConnectedToTrack (TRACK &aSourceTrack)
 Selects all items connected by copper tracks to the given TRACK. More...
 
void selectAllItemsConnectedToItem (BOARD_CONNECTED_ITEM &aSourceItem)
 Selects all items connected (by copper) to the given item. More...
 
void selectAllItemsOnNet (int aNetCode)
 Selects all items with the given net code. More...
 
void selectAllItemsOnSheet (wxString &aSheetpath)
 Selects all items with the given sheet timestamp name (the sheet path) More...
 
int selectOnSheetFromEeschema (const TOOL_EVENT &aEvent)
 

Selects all modules belonging to same sheet, from Eeschema, using crossprobing

More...
 
int selectSameSheet (const TOOL_EVENT &aEvent)
 

Selects all modules belonging to same hierarchical sheet as the selected footprint.

More...
 
void findCallback (BOARD_ITEM *aItem)
 

Find dialog callback.

More...
 
int find (const TOOL_EVENT &aEvent)
 

Find an item.

More...
 
int findMove (const TOOL_EVENT &aEvent)
 

Find an item and start moving.

More...
 
int filterSelection (const TOOL_EVENT &aEvent)
 

Invoke filter dialog and modify current selection

More...
 
void clearSelection ()
 Function clearSelection() Clears the current selection. More...
 
BOARD_ITEMdisambiguationMenu (GENERAL_COLLECTOR *aItems)
 Function disambiguationMenu() Handles the menu that allows to select one of many items in case there is more than one item at the selected point (. More...
 
BOARD_ITEMpickSmallestComponent (GENERAL_COLLECTOR *aCollector)
 Function pickSmallestComponent() Allows to find the smallest (in terms of bounding box area) item from the list. More...
 
void toggleSelection (BOARD_ITEM *aItem)
 Function toggleSelection() Changes selection status of a given item. More...
 
bool selectable (const BOARD_ITEM *aItem) const
 Function selectable() Checks conditions for an item to be selected. More...
 
bool modifiable (const BOARD_ITEM *aItem) const
 Function modifiable() Checks if an item might be modified. More...
 
void select (BOARD_ITEM *aItem)
 Function select() Takes necessary action mark an item as selected. More...
 
void unselect (BOARD_ITEM *aItem)
 Function unselect() Takes necessary action mark an item as unselected. More...
 
void selectVisually (BOARD_ITEM *aItem)
 Function selectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST. More...
 
void unselectVisually (BOARD_ITEM *aItem)
 Function unselectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST. More...
 
bool selectionContains (const VECTOR2I &aPoint) const
 Function selectionContains() Checks if the given point is placed within any of selected items' bounding box. More...
 
void guessSelectionCandidates (GENERAL_COLLECTOR &aCollector) const
 Function guessSelectionCandidates() Tries to guess best selection candidates in case multiple items are clicked, by doing some braindead heuristics. More...
 
int updateSelection (const TOOL_EVENT &aEvent)
 Event handler to update the selection VIEW_ITEM. More...
 
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide () const
 

Private Attributes

PCB_BASE_FRAMEm_frame
 Pointer to the parent frame. More...
 
SELECTION m_selection
 Current state of selection. More...
 
bool m_additive
 Flag saying if items should be added to the current selection or rather replace it. More...
 
bool m_subtractive
 Flag saying if items should be removed from the current selection. More...
 
bool m_multiple
 Flag saying if multiple selection mode is active. More...
 
bool m_locked
 Can other tools modify locked items. More...
 
TOOL_MENU m_menu
 Menu model displayed by the tool. More...
 
std::unique_ptr< PRIVm_priv
 

Detailed Description

Class SELECTION_TOOL.

Our sample selection tool: currently supports:

  • pick single objects (click LMB)
  • add objects to existing selection (Shift+LMB)
  • draw selection box (drag LMB)
  • handles MODULEs properly (i.e. selects either MODULE or its PADs, TEXTs, etc.)
  • takes into account high-contrast & layer visibility settings
  • invokes InteractiveEdit tool when user starts to drag selected items

Definition at line 63 of file pcbnew/tools/selection_tool.h.

Member Enumeration Documentation

enum PCB_TOOL::INTERACTIVE_PLACEMENT_OPTIONS
protectedinherited
Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_PROPERTIES 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 104 of file pcb_tool.h.

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 80 of file tool_base.h.

81  {
82  RUN,
83  MODEL_RELOAD,
84  GAL_SWITCH
85  };
Model changes (required full reload)
Definition: tool_base.h:83
Tool is invoked after being inactive.
Definition: tool_base.h:82
Rendering engine changes.
Definition: tool_base.h:84

Constructor & Destructor Documentation

SELECTION_TOOL::SELECTION_TOOL ( )

Definition at line 185 of file pcbnew/tools/selection_tool.cpp.

185  :
186  PCB_TOOL( "pcbnew.InteractiveSelection" ),
187  m_frame( NULL ),
188  m_additive( false ),
189  m_subtractive( false ),
190  m_multiple( false ),
191  m_locked( true ),
192  m_menu( *this ),
193  m_priv( std::make_unique<PRIV>() )
194 {
195 
196 }
std::unique_ptr< PRIV > m_priv
bool m_multiple
Flag saying if multiple selection mode is active.
bool m_additive
Flag saying if items should be added to the current selection or rather replace it.
PCB_TOOL(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool.h:69
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
TOOL_MENU m_menu
Menu model displayed by the tool.
bool m_subtractive
Flag saying if items should be removed from the current selection.
bool m_locked
Can other tools modify locked items.
SELECTION_TOOL::~SELECTION_TOOL ( )

Definition at line 199 of file pcbnew/tools/selection_tool.cpp.

References TOOL_BASE::getView(), m_selection, and KIGFX::VIEW::Remove().

200 {
201  getView()->Remove( &m_selection );
202 }
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:339
SELECTION m_selection
Current state of selection.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

After activation, the tool starts receiving events until it is finished.

Definition at line 49 of file tool_interactive.cpp.

References TOOL_MANAGER::InvokeTool(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

Referenced by EDIT_TOOL::copyToClipboard(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), ROUTER_TOOL::SettingsDialog(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

Sets the TOOL_MANAGER the tool will belong to. Called by TOOL_MANAGER::RegisterTool()

Definition at line 59 of file tool_base.cpp.

References TOOL_BASE::m_toolMgr, TOOL_BASE::m_toolSettings, and TOOL_BASE::TOOL_SETTINGS.

Referenced by TOOL_MANAGER::RegisterTool().

60 {
61  m_toolMgr = aManager;
62  m_toolSettings = TOOL_SETTINGS( this );
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
friend class TOOL_SETTINGS
Definition: tool_base.h:155
BOARD* PCB_TOOL::board ( ) const
inlineprotectedinherited

Definition at line 135 of file pcb_tool.h.

Referenced by PCBNEW_CONTROL::AppendBoard(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), EDIT_TOOL::changeTrackWidthOnClick(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::doInteractiveItemPlacement(), MODULE_EDITOR_TOOLS::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), filterSelection(), POINT_EDITOR::finishItem(), getCollectorsGuide(), ROUTER_TOOL::getNetclassDimensions(), PCBNEW_CONTROL::GraphicDisplayMode(), PAD_TOOL::haveFootprints(), highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), ROUTER_TOOL::mainLoop(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PCBNEW_CONTROL::placeBoardItems(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), selectable(), selectAllItemsConnectedToItem(), selectAllItemsConnectedToTrack(), selectAllItemsOnNet(), selectAllItemsOnSheet(), selectPoint(), PCBNEW_CONTROL::TrackDisplayMode(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

135 { return getModel<BOARD>(); }
PCB_DRAW_PANEL_GAL * PCB_TOOL::canvas ( ) const
protectedinherited

Definition at line 213 of file pcb_tool.cpp.

References PCB_TOOL::frame(), and EDA_DRAW_FRAME::GetGalCanvas().

Referenced by PCBNEW_CONTROL::GraphicDisplayMode(), PCBNEW_CONTROL::HighContrastMode(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::TrackDisplayMode(), PCBNEW_CONTROL::ViaDisplayMode(), PCBNEW_CONTROL::ZoneDisplayMode(), and zoomFitSelection().

214 {
215  return static_cast<PCB_DRAW_PANEL_GAL*>( frame()->GetGalCanvas() );
216 }
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
SELECTION_LOCK_FLAGS SELECTION_TOOL::CheckLock ( )

Checks if the user has agreed to modify locked items for the given selection.

Definition at line 679 of file pcbnew/tools/selection_tool.cpp.

References IsOK(), PCB_TOOL::m_editModules, m_frame, m_locked, m_selection, PCB_MODULE_EDGE_T, PCB_MODULE_T, PCB_MODULE_TEXT_T, SELECTION_LOCK_OVERRIDE, SELECTION_LOCKED, and SELECTION_UNLOCKED.

Referenced by CursorSelection(), EDIT_TOOL::Flip(), EDIT_TOOL::Main(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Remove(), and EDIT_TOOL::Rotate().

680 {
681  if( !m_locked || m_editModules )
682  return SELECTION_UNLOCKED;
683 
684  bool containsLocked = false;
685 
686  // Check if the selection contains locked items
687  for( const auto& item : m_selection )
688  {
689  switch( item->Type() )
690  {
691  case PCB_MODULE_T:
692  if( static_cast<MODULE*>( item )->IsLocked() )
693  containsLocked = true;
694  break;
695 
696  case PCB_MODULE_EDGE_T:
697  case PCB_MODULE_TEXT_T:
698  if( static_cast<MODULE*>( item->GetParent() )->IsLocked() )
699  containsLocked = true;
700  break;
701 
702  default: // suppress warnings
703  break;
704  }
705  }
706 
707  if( containsLocked )
708  {
709  if( IsOK( m_frame, _( "Selection contains locked items. Do you want to continue?" ) ) )
710  {
711  m_locked = false;
713  }
714  else
715  return SELECTION_LOCKED;
716  }
717 
718  return SELECTION_UNLOCKED;
719 }
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
class MODULE, a footprint
Definition: typeinfo.h:89
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
bool m_editModules
Definition: pcb_tool.h:142
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
bool m_locked
Can other tools modify locked items.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:289
int SELECTION_TOOL::ClearSelection ( const TOOL_EVENT aEvent)

Clear current selection event handler.

Definition at line 741 of file pcbnew/tools/selection_tool.cpp.

References clearSelection().

Referenced by setTransitions().

742 {
743  clearSelection();
744 
745  return 0;
746 }
void clearSelection()
Function clearSelection() Clears the current selection.
void SELECTION_TOOL::clearSelection ( )
private

Function clearSelection() Clears the current selection.

Definition at line 1347 of file pcbnew/tools/selection_tool.cpp.

References ClearedEvent, SELECTION::Empty(), m_frame, m_locked, m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), PCB_BASE_FRAME::SetCurItem(), and unselectVisually().

Referenced by ClearSelection(), CursorSelection(), filterSelection(), findCallback(), findMove(), Main(), Reset(), selectCursor(), selectOnSheetFromEeschema(), selectPoint(), selectSameSheet(), and toggleSelection().

1348 {
1349  if( m_selection.Empty() )
1350  return;
1351 
1352  for( auto item : m_selection )
1353  unselectVisually( static_cast<BOARD_ITEM*>( item ) );
1354 
1355  m_selection.Clear();
1356  m_selection.SetIsHover( false );
1357  m_selection.ClearReferencePoint();
1358 
1359  if( m_frame )
1360  {
1361  m_frame->SetCurItem( NULL );
1362  }
1363 
1364  m_locked = true;
1365 
1366  // Inform other potentially interested tools
1368 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
void unselectVisually(BOARD_ITEM *aItem)
Function unselectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
bool m_locked
Can other tools modify locked items.
int SELECTION_TOOL::CursorSelection ( const TOOL_EVENT aEvent)

Select a single item under cursor event handler.

Definition at line 722 of file pcbnew/tools/selection_tool.cpp.

References CheckLock(), clearSelection(), SELECTION::Empty(), m_selection, TOOL_EVENT::Parameter(), selectCursor(), and SELECTION_LOCKED.

Referenced by setTransitions().

723 {
725 
726  if( m_selection.Empty() ) // Try to find an item that could be modified
727  {
728  selectCursor( true, aClientFilter );
729 
730  if( CheckLock() == SELECTION_LOCKED )
731  {
732  clearSelection();
733  return 0;
734  }
735  }
736 
737  return 0;
738 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
SELECTION_LOCK_FLAGS CheckLock()
Checks if the user has agreed to modify locked items for the given selection.
void(* CLIENT_SELECTION_FILTER)(const VECTOR2I &, GENERAL_COLLECTOR &)
bool selectCursor(bool aSelectAlways=false, CLIENT_SELECTION_FILTER aClientFilter=NULL)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
BOARD_ITEM * SELECTION_TOOL::disambiguationMenu ( GENERAL_COLLECTOR aItems)
private

Function disambiguationMenu() Handles the menu that allows to select one of many items in case there is more than one item at the selected point (.

See also
selectCursor()).
Parameters
aItemscontains list of items that are displayed to the user.

Definition at line 1371 of file pcbnew/tools/selection_tool.cpp.

References KIGFX::VIEW_GROUP::Add(), CONTEXT_MENU::Add(), KIGFX::VIEW::Add(), EDA_ITEM::ClearBrightened(), CMENU_NOW, CONTEXT_MENU::DisplayTitle(), Format(), COLLECTOR::GetCount(), EDA_ITEM::GetMenuImage(), EDA_ITEM::GetSelectMenuText(), TOOL_BASE::getView(), KIGFX::VIEW::Hide(), LAYER_GP_OVERLAY, KIGFX::VIEW::MarkTargetDirty(), min, KIGFX::VIEW_GROUP::Remove(), KIGFX::VIEW::Remove(), EDA_ITEM::SetBrightened(), TOOL_INTERACTIVE::SetContextMenu(), CONTEXT_MENU::SetIcon(), KIGFX::VIEW_GROUP::SetLayer(), CONTEXT_MENU::SetTitle(), TA_CONTEXT_MENU_CHOICE, TA_CONTEXT_MENU_UPDATE, KIGFX::TARGET_OVERLAY, and TOOL_INTERACTIVE::Wait().

Referenced by selectPoint().

1372 {
1373  BOARD_ITEM* current = NULL;
1374  KIGFX::VIEW_GROUP highlightGroup;
1375  CONTEXT_MENU menu;
1376 
1377  highlightGroup.SetLayer( LAYER_GP_OVERLAY );
1378  getView()->Add( &highlightGroup );
1379 
1380  int limit = std::min( 9, aCollector->GetCount() );
1381 
1382  for( int i = 0; i < limit; ++i )
1383  {
1384  wxString text;
1385  BOARD_ITEM* item = ( *aCollector )[i];
1386  text = item->GetSelectMenuText();
1387 
1388  wxString menuText = wxString::Format("&%d. %s", i + 1, text );
1389  menu.Add( menuText, i + 1, item->GetMenuImage() );
1390  }
1391 
1392  menu.SetTitle( _( "Clarify Selection" ) );
1393  menu.SetIcon( info_xpm );
1394  menu.DisplayTitle( true );
1395  SetContextMenu( &menu, CMENU_NOW );
1396 
1397  while( OPT_TOOL_EVENT evt = Wait() )
1398  {
1399  if( evt->Action() == TA_CONTEXT_MENU_UPDATE )
1400  {
1401  if( current )
1402  {
1403  current->ClearBrightened();
1404  getView()->Hide( current, false );
1405  highlightGroup.Remove( current );
1407  }
1408 
1409  int id = *evt->GetCommandId();
1410 
1411  // User has pointed an item, so show it in a different way
1412  if( id > 0 && id <= limit )
1413  {
1414  current = ( *aCollector )[id - 1];
1415  current->SetBrightened();
1416  getView()->Hide( current, true );
1417  highlightGroup.Add( current );
1419  }
1420  else
1421  {
1422  current = NULL;
1423  }
1424  }
1425  else if( evt->Action() == TA_CONTEXT_MENU_CHOICE )
1426  {
1427  if( current )
1428  {
1429  current->ClearBrightened();
1430  getView()->Hide( current, false );
1431  highlightGroup.Remove( current );
1433  }
1434 
1435  OPT<int> id = evt->GetCommandId();
1436 
1437  // User has selected an item, so this one will be returned
1438  if( id && ( *id > 0 ) )
1439  current = ( *aCollector )[*id - 1];
1440  else
1441  current = NULL;
1442 
1443  break;
1444  }
1445  }
1446  getView()->Remove( &highlightGroup );
1447 
1448 
1449  return current;
1450 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1349
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
Class CONTEXT_MENU.
Definition: context_menu.h:44
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:339
void SetBrightened()
Definition: base_struct.h:258
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual wxString GetSelectMenuText() const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
wxMenuItem * Add(const wxString &aLabel, int aId, const BITMAP_OPAQUE *aIcon=NULL)
Function Add() Adds an entry to the menu.
void ClearBrightened()
Definition: base_struct.h:262
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target &#39;dirty&#39; flag.
Definition: view.h:568
void SetContextMenu(CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
Items that may change while the view stays the same (noncached)
Definition: definitions.h:43
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
general purpose overlay
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetLayer(int aLayer)
Function SetLayer() Sets layer used to draw the group.
Definition: view_group.h:115
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void SetIcon(const BITMAP_OPAQUE *aIcon)
Function SetIcon() Assigns an icon for the entry.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the context menu.
boost::optional< T > OPT
Definition: optional.h:7
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:309
void DisplayTitle(bool aDisplay=true)
Function DisplayTitle() Decides whether a title for a pop up menu should be displayed.
virtual BITMAP_DEF GetMenuImage() const
Function GetMenuImage returns a pointer to an image to be used in menus.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:465
#define min(a, b)
Definition: auxiliary.h:85
PCB_DISPLAY_OPTIONS * PCB_TOOL::displayOptions ( ) const
protectedinherited

Definition at line 208 of file pcb_tool.cpp.

References PCB_TOOL::frame(), and PCB_BASE_FRAME::GetDisplayOptions().

Referenced by PCBNEW_CONTROL::GraphicDisplayMode(), PCBNEW_CONTROL::HighContrastMode(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), PCBNEW_CONTROL::PadDisplayMode(), PNS::TOOL_BASE::pickSingleItem(), PCBNEW_CONTROL::TrackDisplayMode(), PCBNEW_CONTROL::ViaDisplayMode(), and PCBNEW_CONTROL::ZoneDisplayMode().

209 {
210  return static_cast<PCB_DISPLAY_OPTIONS*>( frame()->GetDisplayOptions() );
211 }
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
void PCB_TOOL::doInteractiveItemPlacement ( INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc.

More complex interactive processes are not supported here, you should implement a customised event loop for those.

Parameters
aItemCreatorthe callable that will attempt to create the item
aCommitMessagethe message used on a successful commit

Definition at line 39 of file pcb_tool.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), COMMIT::Add(), PCB_TOOL::board(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), BOARD_COMMIT::Push(), KIGFX::PCB_VIEW::Remove(), KIGFX::VIEW_GROUP::Remove(), SELECTION::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), DRAWING_TOOL::DrawVia(), and MODULE_EDITOR_TOOLS::PlacePad().

42 {
43  using namespace std::placeholders;
44  std::unique_ptr<BOARD_ITEM> newItem;
45 
46  Activate();
47 
48  BOARD_COMMIT commit( frame() );
49 
51 
52  // do not capture or auto-pan until we start placing an item
53  controls()->ShowCursor( true );
54  controls()->SetSnapping( true );
55 
56  // Add a VIEW_GROUP that serves as a preview for the new item
57  SELECTION preview;
58  view()->Add( &preview );
59 
60  aPlacer->m_board = board();
61  aPlacer->m_frame = frame();
62 
63  if( aOptions & IPO_SINGLE_CLICK )
64  {
65  VECTOR2I cursorPos = controls()->GetCursorPosition();
66 
67  newItem = aPlacer->CreateItem();
68  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
69 
70  preview.Add( newItem.get() );
71  }
72 
73  // Main loop: keep receiving events
74  while( OPT_TOOL_EVENT evt = Wait() )
75  {
76  VECTOR2I cursorPos = controls()->GetCursorPosition();
77 
79  {
80  if( newItem )
81  {
82  // Delete the old item and have another try
83  newItem = nullptr;
84 
85  preview.Clear();
86 
87  if( aOptions & IPO_SINGLE_CLICK )
88  break;
89 
90  controls()->SetAutoPan( false );
91  controls()->CaptureCursor( false );
92  controls()->ShowCursor( true );
93  }
94  else
95  {
96  break;
97  }
98 
99  if( evt->IsActivate() ) // now finish unconditionally
100  break;
101  }
102 
103  else if( evt->IsClick( BUT_LEFT ) )
104  {
105  if( !newItem )
106  {
107  // create the item if possible
108  newItem = aPlacer->CreateItem();
109 
110  // no item created, so wait for another click
111  if( !newItem )
112  continue;
113 
114  controls()->CaptureCursor( true );
115  controls()->SetAutoPan( true );
116 
117  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
118 
119  preview.Add( newItem.get() );
120 
121  if( newItem->Type() == PCB_MODULE_T )
122  {
123  auto module = dyn_cast<MODULE*>( newItem.get() );
124 
125  // modules have more drawable parts
126  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
127  }
128  }
129  else
130  {
131  newItem->ClearFlags();
132  preview.Remove( newItem.get() );
133 
134  aPlacer->PlaceItem( newItem.get() );
135 
136  if( newItem->Type() == PCB_MODULE_T )
137  {
138  auto module = dyn_cast<MODULE*>( newItem.get() );
139  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
140  }
141 
142  commit.Add( newItem.release() );
143  commit.Push( aCommitMessage );
144 
145  controls()->CaptureCursor( false );
146  controls()->SetAutoPan( false );
147  controls()->ShowCursor( true );
148 
149  if( !( aOptions & IPO_REPEAT ) )
150  break;
151 
152  if( aOptions & IPO_SINGLE_CLICK )
153  {
155 
156  newItem = aPlacer->CreateItem();
157  newItem->SetPosition( wxPoint( pos.x, pos.y ) );
158 
159  preview.Add( newItem.get() );
160  }
161  }
162  }
163 
164  else if( newItem && evt->Category() == TC_COMMAND )
165  {
166  /*
167  * Handle any events that can affect the item as we move
168  * it around, eg rotate and flip
169  */
170 
171  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
172  {
173  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
174  *frame(), *evt );
175  newItem->Rotate( newItem->GetPosition(), rotationAngle );
176  view()->Update( &preview );
177  }
178  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
179  {
180  newItem->Flip( newItem->GetPosition() );
181  view()->Update( &preview );
182  }
183  }
184 
185  else if( newItem && evt->IsMotion() )
186  {
187  // track the cursor
188  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
189 
190  // Show a preview of the item
191  view()->Update( &preview );
192  }
193  }
194 
195  view()->Remove( &preview );
196 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
virtual bool PlaceItem(BOARD_ITEM *aItem)
Definition: pcb_tool.h:55
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:81
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
PCB_EDIT_FRAME * m_frame
Definition: pcb_tool.h:57
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:61
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:64
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:133
class MODULE, a footprint
Definition: typeinfo.h:89
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
MODULE * module() const
Definition: pcb_tool.h:136
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:102
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool...
Definition: tool_base.h:144
void Activate()
Function Activate() Runs the tool.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:48
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:465
BOARD * board() const
Definition: pcb_tool.h:135
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 97 of file pcb_tool.h.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PAD_TOOL::Init(), and EDIT_TOOL::MeasureTool().

98  {
99  return m_editModules;
100  }
bool m_editModules
Definition: pcb_tool.h:142
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
int SELECTION_TOOL::expandSelectedConnection ( const TOOL_EVENT aEvent)
private

Expands the current selection to select a connection between two junctions

Definition at line 847 of file pcbnew/tools/selection_tool.cpp.

References SELECTION::GetItems(), m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), selectAllItemsConnectedToTrack(), SelectedEvent, PCB_TOOL::selection(), and SELECTION::Size().

Referenced by selectConnection(), and setTransitions().

848 {
849  // copy the selection, since we're going to iterate and modify
850  auto selection = m_selection.GetItems();
851 
852  for( auto item : selection )
853  {
854  TRACK* trackItem = dynamic_cast<TRACK*>( item );
855 
856  if( trackItem )
857  selectAllItemsConnectedToTrack( *trackItem );
858  }
859 
860  // Inform other potentially interested tools
861  if( m_selection.Size() > 0 )
863 
864  return 0;
865 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const std::set< EDA_ITEM * > GetItems() const
Definition: selection.h:117
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SELECTION m_selection
Current state of selection.
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
void selectAllItemsConnectedToTrack(TRACK &aSourceTrack)
Selects all items connected by copper tracks to the given TRACK.
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
int SELECTION_TOOL::filterSelection ( const TOOL_EVENT aEvent)
private

Invoke filter dialog and modify current selection

Definition at line 1312 of file pcbnew/tools/selection_tool.cpp.

References PCB_TOOL::board(), clearSelection(), getFilteredLayerSet(), SELECTION::GetItems(), itemIsIncludedByFilter(), m_frame, m_priv, m_selection, select(), and PCB_TOOL::selection().

Referenced by setTransitions().

1313 {
1314  auto& opts = m_priv->m_filterOpts;
1315  DIALOG_BLOCK_OPTIONS dlg( m_frame, opts, false, _( "Filter selection" ) );
1316 
1317  const int cmd = dlg.ShowModal();
1318 
1319  if( cmd != wxID_OK )
1320  return 0;
1321 
1322  const auto& board = *getModel<BOARD>();
1323  const auto layerMask = getFilteredLayerSet( opts );
1324 
1325  // copy current selection
1326  auto selection = m_selection.GetItems();
1327 
1328  // clear current selection
1329  clearSelection();
1330 
1331  // copy selection items from the saved selection
1332  // according to the dialog options
1333  for( auto i : selection )
1334  {
1335  auto item = static_cast<BOARD_ITEM*>( i );
1336  bool include = itemIsIncludedByFilter( *item, board, layerMask, opts );
1337 
1338  if( include )
1339  {
1340  select( item );
1341  }
1342  }
1343  return 0;
1344 }
std::unique_ptr< PRIV > m_priv
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
const std::set< EDA_ITEM * > GetItems() const
Definition: selection.h:117
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
static bool itemIsIncludedByFilter(const BOARD_ITEM &aItem, const BOARD &aBoard, const LSET &aTechnlLayerMask, const DIALOG_BLOCK_OPTIONS::OPTIONS &aBlockOpts)
Function itemIsIncludedByFilter()
static LSET getFilteredLayerSet(const DIALOG_BLOCK_OPTIONS::OPTIONS &blockOpts)
Gets the technical layers that are part of the given selection opts.
BOARD * board() const
Definition: pcb_tool.h:135
int SELECTION_TOOL::find ( const TOOL_EVENT aEvent)
private

Find an item.

Definition at line 1176 of file pcbnew/tools/selection_tool.cpp.

References DIALOG_FIND::EnableWarp(), findCallback(), m_frame, and DIALOG_FIND::SetCallback().

Referenced by setTransitions().

1177 {
1178  DIALOG_FIND dlg( m_frame );
1179  dlg.EnableWarp( false );
1180  dlg.SetCallback( std::bind( &SELECTION_TOOL::findCallback, this, _1 ) );
1181  dlg.ShowModal();
1182 
1183  return 0;
1184 }
void findCallback(BOARD_ITEM *aItem)
Find dialog callback.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
void SELECTION_TOOL::findCallback ( BOARD_ITEM aItem)
private

Find dialog callback.

Definition at line 1157 of file pcbnew/tools/selection_tool.cpp.

References clearSelection(), EDA_DRAW_PANEL_GAL::ForceRefresh(), EDA_ITEM::GetBoundingBox(), EDA_DRAW_FRAME::GetGalCanvas(), EDA_RECT::GetOrigin(), EDA_RECT::GetSize(), TOOL_BASE::getView(), m_frame, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), select(), SelectedEvent, and KIGFX::VIEW::SetViewport().

Referenced by find().

1158 {
1159  clearSelection();
1160 
1161  if( aItem )
1162  {
1163  select( aItem );
1164  EDA_RECT bbox = aItem->GetBoundingBox();
1165  BOX2D viewport( VECTOR2D( bbox.GetOrigin() ), VECTOR2D( bbox.GetSize() ) );
1166  getView()->SetViewport( viewport );
1167 
1168  // Inform other potentially interested tools
1170  }
1171 
1173 }
virtual const EDA_RECT GetBoundingBox() const
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
void SetViewport(const BOX2D &aViewport)
Function SetViewport() Sets the visible area of the VIEW.
Definition: view.cpp:511
const wxPoint GetOrigin() const
Definition: eda_rect.h:112
const wxSize GetSize() const
Definition: eda_rect.h:101
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec.
Definition: box2.h:41
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
VECTOR2< double > VECTOR2D
Definition: vector2d.h:588
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
int SELECTION_TOOL::findMove ( const TOOL_EVENT aEvent)
private

Find an item and start moving.

Definition at line 1187 of file pcbnew/tools/selection_tool.cpp.

References clearSelection(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetFootprintFromBoardByReference(), MODULE::GetPosition(), TOOL_BASE::getViewControls(), TOOL_MANAGER::InvokeTool(), m_frame, m_selection, TOOL_BASE::m_toolMgr, PCB_TOOL::module(), KIGFX::VIEW_CONTROLS::SetCursorPosition(), SELECTION::SetReferencePoint(), and toggleSelection().

Referenced by setTransitions().

1188 {
1190 
1191  if( module )
1192  {
1193  KIGFX::VIEW_CONTROLS* viewCtrls = getViewControls();
1194  clearSelection();
1195  toggleSelection( module );
1196 
1197  auto cursorPosition = viewCtrls->GetCursorPosition( false );
1198 
1199  // Set a reference point so InteractiveEdit will move it to the
1200  // cursor before waiting for mouse move events
1202 
1203  // Place event on module origin first, so the generic anchor snap
1204  // doesn't just choose the closest pin for us
1205  viewCtrls->ForceCursorPosition( true, module->GetPosition() );
1206 
1207  // pick the component up and start moving
1208  m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
1209 
1210  // restore the previous cursor position
1211  viewCtrls->SetCursorPosition( cursorPosition, false );
1212  }
1213 
1214  return 0;
1215 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves cursor to the requested position expressed in world coordinates.
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:200
void toggleSelection(BOARD_ITEM *aItem)
Function toggleSelection() Changes selection status of a given item.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
SELECTION m_selection
Current state of selection.
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
MODULE * module() const
Definition: pcb_tool.h:136
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
MODULE * GetFootprintFromBoardByReference()
Function GetFootprintFromBoardByReference.
const wxPoint GetPosition() const override
Definition: class_module.h:182
PCB_EDIT_FRAME* PCB_TOOL::frame ( ) const
inlineprotectedinherited

Definition at line 134 of file pcb_tool.h.

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), PAD_TOOL::applyPadSettings(), PCB_TOOL::canvas(), EDIT_TOOL::changeTrackWidthOnClick(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::displayOptions(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::DrawVia(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ROUTER_TOOL::finishInteractive(), getMicrowaveItemCreator(), highlightNet(), PICKER_TOOL::Init(), PAD_TOOL::Init(), EDIT_TOOL::Init(), Init(), ROUTER_TOOL::InlineDrag(), PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PasteItemsFromClipboard(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), MODULE_EDITOR_TOOLS::PlacePad(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::RouteDiffPair(), ROUTER_TOOL::RouteSingleTrace(), ROUTER_TOOL::SettingsDialog(), ROUTER_TOOL::switchLayerOnViaPlacement(), LENGTH_TUNER_TOOL::TuneDiffPair(), LENGTH_TUNER_TOOL::TuneDiffPairSkew(), LENGTH_TUNER_TOOL::TuneSingleTrace(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

134 { return getEditFrame<PCB_EDIT_FRAME>(); }
const GENERAL_COLLECTORS_GUIDE SELECTION_TOOL::getCollectorsGuide ( ) const
private

Definition at line 429 of file pcbnew/tools/selection_tool.cpp.

References PCB_TOOL::board(), LAYER_MOD_BK, LAYER_MOD_FR, LAYER_MOD_REFERENCES, LAYER_MOD_TEXT_BK, LAYER_MOD_TEXT_FR, LAYER_MOD_TEXT_INVISIBLE, LAYER_MOD_VALUES, LAYER_PAD_BK, LAYER_PAD_FR, LAYER_TRACKS, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_THROUGH, GENERAL_COLLECTORS_GUIDE::SetIgnoreBlindBuriedVias(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMicroVias(), GENERAL_COLLECTORS_GUIDE::SetIgnoreModulesOnBack(), GENERAL_COLLECTORS_GUIDE::SetIgnoreModulesOnFront(), GENERAL_COLLECTORS_GUIDE::SetIgnoreModulesRefs(), GENERAL_COLLECTORS_GUIDE::SetIgnoreModulesVals(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMTextsMarkedNoShow(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMTextsOnBack(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMTextsOnFront(), GENERAL_COLLECTORS_GUIDE::SetIgnorePadsOnBack(), GENERAL_COLLECTORS_GUIDE::SetIgnorePadsOnFront(), GENERAL_COLLECTORS_GUIDE::SetIgnoreThroughVias(), GENERAL_COLLECTORS_GUIDE::SetIgnoreTracks(), and PCB_TOOL::view().

Referenced by selectPoint().

430 {
431  GENERAL_COLLECTORS_GUIDE guide( board()->GetVisibleLayers(),
432  (PCB_LAYER_ID) view()->GetTopLayer() );
433 
434  // account for the globals
435  guide.SetIgnoreMTextsMarkedNoShow( ! board()->IsElementVisible( LAYER_MOD_TEXT_INVISIBLE ) );
436  guide.SetIgnoreMTextsOnBack( ! board()->IsElementVisible( LAYER_MOD_TEXT_BK ) );
437  guide.SetIgnoreMTextsOnFront( ! board()->IsElementVisible( LAYER_MOD_TEXT_FR ) );
438  guide.SetIgnoreModulesOnBack( ! board()->IsElementVisible( LAYER_MOD_BK ) );
439  guide.SetIgnoreModulesOnFront( ! board()->IsElementVisible( LAYER_MOD_FR ) );
440  guide.SetIgnorePadsOnBack( ! board()->IsElementVisible( LAYER_PAD_BK ) );
441  guide.SetIgnorePadsOnFront( ! board()->IsElementVisible( LAYER_PAD_FR ) );
442  guide.SetIgnoreModulesVals( ! board()->IsElementVisible( LAYER_MOD_VALUES ) );
443  guide.SetIgnoreModulesRefs( ! board()->IsElementVisible( LAYER_MOD_REFERENCES ) );
444  guide.SetIgnoreThroughVias( ! board()->IsElementVisible( LAYER_VIA_THROUGH ) );
445  guide.SetIgnoreBlindBuriedVias( ! board()->IsElementVisible( LAYER_VIA_BBLIND ) );
446  guide.SetIgnoreMicroVias( ! board()->IsElementVisible( LAYER_VIA_MICROVIA ) );
447  guide.SetIgnoreTracks( ! board()->IsElementVisible( LAYER_TRACKS ) );
448 
449  return guide;
450 }
to draw blind/buried vias
show modules on back
show modules values (when texts are visibles)
smd pads, back layer
show modules on front
PCB_LAYER_ID
A quick note on layer IDs:
to draw usual through hole vias
smd pads, front layer
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:371
show modules references (when texts are visibles)
BOARD * board() const
Definition: pcb_tool.h:135
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

Returns the application window object, casted to requested user type.

Definition at line 188 of file tool_base.h.

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), and TOOL_SETTINGS::getConfigBase().

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47
TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Function GetId() Returns the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::saveViewControls().

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER. If there is no TOOL_MANAGER associated, it returns NULL.

Definition at line 144 of file tool_base.h.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PCB_TOOL::doInteractiveItemPlacement(), CONTEXT_MENU::getToolManager(), EDIT_TOOL::MeasureTool(), and CONTEXT_MENU::onMenuEvent().

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

Referenced by ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), ZONE_CREATE_HELPER::createZoneFromExisting(), and ZONE_CREATE_HELPER::performZoneCutout().

200  {
201  EDA_ITEM* m = getModelInt();
202 
203  return static_cast<T*>( m );
204  }
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:180
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

Referenced by TOOL_SETTINGS::getKeyName(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), and TOOL_MANAGER::RegisterTool().

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:214
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

Referenced by GERBVIEW_CONTROL::HighlightControl(), ROUTER_TOOL::Init(), selectable(), and ROUTER_TOOL::~ROUTER_TOOL().

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
TOOL_MENU& SELECTION_TOOL::GetToolMenu ( )
inline

Definition at line 100 of file pcbnew/tools/selection_tool.h.

Referenced by PICKER_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), and EDIT_TOOL::Init().

101  {
102  return m_menu;
103  }
TOOL_MENU m_menu
Menu model displayed by the tool.
TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), and TOOL_MANAGER::runTool().

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:207
KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Function getView()

Returns the instance of VIEW object used in the application. It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

References TOOL_MANAGER::GetView(), and TOOL_BASE::m_toolMgr.

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), disambiguationMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), guessSelectionCandidates(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), POINT_EDITOR::updateEditedPoint(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), updateSelection(), PNS::TOOL_BASE::updateStartItem(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and ~SELECTION_TOOL().

36 {
37  return m_toolMgr->GetView();
38 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Function getViewControls()

Returns the instance of VIEW_CONTROLS object used in the application. It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.)

Returns
The instance of VIEW_CONTROLS.

Definition at line 41 of file tool_base.cpp.

References TOOL_MANAGER::GetViewControls(), and TOOL_BASE::m_toolMgr.

Referenced by POINT_EDITOR::addCorner(), PCBNEW_CONTROL::CursorControl(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawZone(), MODULE_EDITOR_TOOLS::EnumeratePads(), findMove(), PCB_EDITOR_CONTROL::HighlightNet(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), PCBNEW_CONTROL::ResetCoords(), DRAWING_TOOL::runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectCursor(), selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), selectMultiple(), ZOOM_TOOL::selectRegion(), PICKER_TOOL::setControls(), POINT_EDITOR::setEditedPoint(), EDIT_TOOL::updateModificationPoint(), COMMON_TOOLS::ZoomCenter(), and COMMON_TOOLS::ZoomInOut().

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257
template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Function Go()

Defines which state (aStateFunc) to go when a certain event arrives (aConditions). No conditions means any event.

Definition at line 135 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), POINT_EDITOR::setTransitions(), COMMON_TOOLS::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), setTransitions(), EDIT_TOOL::setTransitions(), and DRAWING_TOOL::setTransitions().

137 {
138  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
139 
140  goInternal( sptr, aConditions );
141 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
void SELECTION_TOOL::guessSelectionCandidates ( GENERAL_COLLECTOR aCollector) const
private

Function guessSelectionCandidates() Tries to guess best selection candidates in case multiple items are clicked, by doing some braindead heuristics.

Parameters
aCollectoris the collector that has a list of items to be queried.

Definition at line 1853 of file pcbnew/tools/selection_tool.cpp.

References COLLECTOR::Append(), B_SilkS, calcArea(), calcCommonArea(), calcMaxArea(), calcRatio(), COLLECTOR::CountType(), COLLECTOR::Empty(), F_SilkS, COLLECTOR::GetCount(), BOARD_ITEM::GetLayer(), BOARD_ITEM::GetParent(), BOX2< Vec >::GetPosition(), BOX2< Vec >::GetSize(), KIGFX::VIEW::GetTopLayer(), TOOL_BASE::getView(), KIGFX::VIEW::GetViewport(), max, min, mod, PCB_LINE_T, PCB_MODULE_T, PCB_MODULE_TEXT_T, PCB_PAD_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, COLLECTOR::Remove(), EDA_ITEM::Type(), and PCB_TOOL::view().

Referenced by selectPoint().

1854 {
1855  std::set<BOARD_ITEM*> rejected;
1856  std::set<BOARD_ITEM*> forced;
1857 
1858  // footprints which are below this percentage of the largest footprint will be considered
1859  // for selection; all others will not
1860  constexpr double footprintToFootprintMinRatio = 0.20;
1861  // pads which are below this percentage of their parent's area will exclude their parent
1862  constexpr double padToFootprintMinRatio = 0.45;
1863  // footprints containing items with items-to-footprint area ratio higher than this will be
1864  // forced to stay on the list
1865  constexpr double footprintMaxCoverRatio = 0.80;
1866  constexpr double viaToPadMinRatio = 0.50;
1867  constexpr double trackViaLengthRatio = 2.0;
1868  constexpr double trackTrackLengthRatio = 0.3;
1869  constexpr double textToFeatureMinRatio = 0.2;
1870  constexpr double textToFootprintMinRatio = 0.4;
1871  // If the common area of two compared items is above the following threshold, they cannot
1872  // be rejected (it means they overlap and it might be hard to pick one by selecting
1873  // its unique area).
1874  constexpr double commonAreaRatio = 0.6;
1875 
1876  PCB_LAYER_ID actLayer = (PCB_LAYER_ID) view()->GetTopLayer();
1877 
1878  LSET silkLayers( 2, B_SilkS, F_SilkS );
1879 
1880  if( silkLayers[actLayer] )
1881  {
1882  std::set<BOARD_ITEM*> preferred;
1883 
1884  for( int i = 0; i < aCollector.GetCount(); ++i )
1885  {
1886  BOARD_ITEM* item = aCollector[i];
1887  KICAD_T type = item->Type();
1888 
1889  if( ( type == PCB_MODULE_TEXT_T || type == PCB_TEXT_T || type == PCB_LINE_T )
1890  && silkLayers[item->GetLayer()] )
1891  {
1892  preferred.insert( item );
1893  }
1894  }
1895 
1896  if( preferred.size() != 0 )
1897  {
1898  aCollector.Empty();
1899 
1900  for( BOARD_ITEM* item : preferred )
1901  aCollector.Append( item );
1902  return;
1903  }
1904  }
1905 
1906  if( aCollector.CountType( PCB_MODULE_TEXT_T ) > 0 )
1907  {
1908  for( int i = 0; i < aCollector.GetCount(); ++i )
1909  {
1910  if( TEXTE_MODULE* txt = dyn_cast<TEXTE_MODULE*>( aCollector[i] ) )
1911  {
1912  double textArea = calcArea( txt );
1913 
1914  for( int j = 0; j < aCollector.GetCount(); ++j )
1915  {
1916  if( i == j )
1917  continue;
1918 
1919  BOARD_ITEM* item = aCollector[j];
1920  double itemArea = calcArea( item );
1921  double areaRatio = calcRatio( textArea, itemArea );
1922  double commonArea = calcCommonArea( txt, item );
1923  double itemCommonRatio = calcRatio( commonArea, itemArea );
1924  double txtCommonRatio = calcRatio( commonArea, textArea );
1925 
1926  if( item->Type() == PCB_MODULE_T )
1927  {
1928  // when text area is small compared to an overlapping footprint,
1929  // then it's a clear sign the text is the selection target
1930  if( areaRatio < textToFootprintMinRatio && itemCommonRatio < commonAreaRatio )
1931  rejected.insert( item );
1932  }
1933 
1934  switch( item->Type() )
1935  {
1936  case PCB_TRACE_T:
1937  case PCB_PAD_T:
1938  case PCB_LINE_T:
1939  case PCB_VIA_T:
1940  case PCB_MODULE_T:
1941  if( areaRatio > textToFeatureMinRatio && txtCommonRatio < commonAreaRatio )
1942  rejected.insert( txt );
1943  break;
1944  default:
1945  break;
1946  }
1947  }
1948  }
1949  }
1950  }
1951 
1952  if( aCollector.CountType( PCB_PAD_T ) > 0 )
1953  {
1954  for( int i = 0; i < aCollector.GetCount(); ++i )
1955  {
1956  if( D_PAD* pad = dyn_cast<D_PAD*>( aCollector[i] ) )
1957  {
1958  MODULE* parent = pad->GetParent();
1959  double ratio = calcRatio( calcArea( pad ), calcArea( parent ) );
1960 
1961  // when pad area is small compared to the parent footprint,
1962  // then it is a clear sign the pad is the selection target
1963  if( ratio < padToFootprintMinRatio )
1964  rejected.insert( pad->GetParent() );
1965  }
1966  }
1967  }
1968 
1969  int moduleCount = aCollector.CountType( PCB_MODULE_T );
1970 
1971  if( moduleCount > 0 )
1972  {
1973  double maxArea = calcMaxArea( aCollector, PCB_MODULE_T );
1974  BOX2D viewportD = getView()->GetViewport();
1975  BOX2I viewport( VECTOR2I( viewportD.GetPosition() ), VECTOR2I( viewportD.GetSize() ) );
1976 
1977  for( int i = 0; i < aCollector.GetCount(); ++i )
1978  {
1979  if( MODULE* mod = dyn_cast<MODULE*>( aCollector[i] ) )
1980  {
1981  // filter out components larger than the viewport
1982  if( mod->ViewBBox().Contains( viewport ) )
1983  rejected.insert( mod );
1984  // footprints completely covered with other features have no other
1985  // means of selection, so must be kept
1986  else if( mod->CoverageRatio( aCollector ) > footprintMaxCoverRatio )
1987  rejected.erase( mod );
1988  // if a footprint is much smaller than the largest overlapping
1989  // footprint then it should be considered for selection
1990  else if( calcRatio( calcArea( mod ), maxArea ) <= footprintToFootprintMinRatio )
1991  continue;
1992  // reject ALL OTHER footprints (whether there are one or more of
1993  // them); the other items in the list should have precedence
1994  else
1995  rejected.insert( mod );
1996  }
1997  }
1998  }
1999 
2000  if( aCollector.CountType( PCB_VIA_T ) > 0 )
2001  {
2002  for( int i = 0; i < aCollector.GetCount(); ++i )
2003  {
2004  if( VIA* via = dyn_cast<VIA*>( aCollector[i] ) )
2005  {
2006  double viaArea = calcArea( via );
2007 
2008  for( int j = 0; j < aCollector.GetCount(); ++j )
2009  {
2010  if( i == j )
2011  continue;
2012 
2013  BOARD_ITEM* item = aCollector[j];
2014  double areaRatio = calcRatio( viaArea, calcArea( item ) );
2015 
2016  if( item->Type() == PCB_MODULE_T && areaRatio < padToFootprintMinRatio )
2017  rejected.insert( item );
2018 
2019  if( item->Type() == PCB_PAD_T && areaRatio < viaToPadMinRatio )
2020  rejected.insert( item );
2021 
2022  if( TRACK* track = dyn_cast<TRACK*>( item ) )
2023  {
2024  if( track->GetNetCode() != via->GetNetCode() )
2025  continue;
2026 
2027  double lenRatio = (double) ( track->GetLength() + track->GetWidth() ) /
2028  (double) via->GetWidth();
2029 
2030  if( lenRatio > trackViaLengthRatio )
2031  rejected.insert( track );
2032  }
2033  }
2034  }
2035  }
2036  }
2037 
2038  int nTracks = aCollector.CountType( PCB_TRACE_T );
2039 
2040  if( nTracks > 0 )
2041  {
2042  double maxLength = 0.0;
2043  double minLength = std::numeric_limits<double>::max();
2044  double maxArea = 0.0;
2045  const TRACK* maxTrack = nullptr;
2046 
2047  for( int i = 0; i < aCollector.GetCount(); ++i )
2048  {
2049  if( TRACK* track = dyn_cast<TRACK*>( aCollector[i] ) )
2050  {
2051  maxLength = std::max( track->GetLength(), maxLength );
2052  maxLength = std::max( (double) track->GetWidth(), maxLength );
2053 
2054  minLength = std::min( std::max( track->GetLength(), (double) track->GetWidth() ), minLength );
2055 
2056  double area = track->GetLength() * track->GetWidth();
2057 
2058  if( area > maxArea )
2059  {
2060  maxArea = area;
2061  maxTrack = track;
2062  }
2063  }
2064  }
2065 
2066  if( maxLength > 0.0 && minLength / maxLength < trackTrackLengthRatio && nTracks > 1 )
2067  {
2068  for( int i = 0; i < aCollector.GetCount(); ++i )
2069  {
2070  if( TRACK* track = dyn_cast<TRACK*>( aCollector[i] ) )
2071  {
2072  double ratio = std::max( (double) track->GetWidth(), track->GetLength() ) / maxLength;
2073 
2074  if( ratio > trackTrackLengthRatio )
2075  rejected.insert( track );
2076  }
2077  }
2078  }
2079 
2080  for( int j = 0; j < aCollector.GetCount(); ++j )
2081  {
2082  if( MODULE* mod = dyn_cast<MODULE*>( aCollector[j] ) )
2083  {
2084  double ratio = calcRatio( maxArea, mod->GetFootprintRect().GetArea() );
2085 
2086  if( ratio < padToFootprintMinRatio && calcCommonArea( maxTrack, mod ) < commonAreaRatio )
2087  rejected.insert( mod );
2088  }
2089  }
2090  }
2091 
2092  if( (unsigned) aCollector.GetCount() > rejected.size() ) // do not remove everything
2093  {
2094  for( BOARD_ITEM* item : rejected )
2095  {
2096  aCollector.Remove( item );
2097  }
2098  }
2099 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:116
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:107
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
BOARD_ITEM_CONTAINER * GetParent() const
static double calcMaxArea(GENERAL_COLLECTOR &aCollector, KICAD_T aType)
virtual int GetTopLayer() const
Definition: view.cpp:718
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
const Vec & GetSize() const
Definition: box2.h:177
VECTOR2< int > VECTOR2I
Definition: vector2d.h:589
int CountType(KICAD_T aType)
Function CountType counts the number of items matching aType.
Definition: collector.h:258
Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec.
Definition: box2.h:41
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:136
static double calcCommonArea(const BOARD_ITEM *aItem, const BOARD_ITEM *aOther)
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:126
class MODULE, a footprint
Definition: typeinfo.h:89
PCB_LAYER_ID
A quick note on layer IDs:
Class LSET is a set of PCB_LAYER_IDs.
BOX2D GetViewport() const
Function GetViewport() Returns the current viewport visible area rectangle.
Definition: view.cpp:499
const Vec & GetPosition() const
Definition: box2.h:182
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
#define max(a, b)
Definition: auxiliary.h:86
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
double calcRatio(double a, double b)
static double calcArea(const BOARD_ITEM *aItem)
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
#define mod(a, n)
Definition: greymap.cpp:24
#define min(a, b)
Definition: auxiliary.h:85
bool SELECTION_TOOL::Init ( )
overridevirtual

Function Init() Init() is called once upon a registration of the tool.

Returns
True if the initialization went fine, false - otherwise.

Reimplemented from TOOL_BASE.

Definition at line 205 of file pcbnew/tools/selection_tool.cpp.

References CONDITIONAL_MENU::AddMenu(), TOOL_MENU::AddStandardSubMenus(), TOOL_MENU::AddSubMenu(), PCB_TOOL::frame(), TOOL_MENU::GetMenu(), m_menu, and SELECTION_CONDITIONS::NotEmpty().

206 {
207  auto selectMenu = std::make_shared<SELECT_MENU>();
208  selectMenu->SetTool( this );
209  m_menu.AddSubMenu( selectMenu );
210 
211  auto& menu = m_menu.GetMenu();
212 
213  menu.AddMenu( selectMenu.get(), false, SELECTION_CONDITIONS::NotEmpty );
214  menu.AddSeparator( SELECTION_CONDITIONS::NotEmpty, 1000 );
215 
216  auto frame = getEditFrame<PCB_BASE_FRAME>();
217 
218  if( frame )
219  {
221  }
222 
223  return true;
224 }
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
void AddSubMenu(std::shared_ptr< CONTEXT_MENU > aSubMenu)
Function CreateSubMenu.
Definition: tool_menu.cpp:55
static bool NotEmpty(const SELECTION &aSelection)
Function NotEmpty Tests if there are any items selected.
void AddStandardSubMenus(EDA_DRAW_FRAME &aFrame)
Function CreateBasicMenu.
Definition: tool_menu.cpp:95
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:134
TOOL_MENU m_menu
Menu model displayed by the tool.
void AddMenu(CONTEXT_MENU *aMenu, bool aExpand=false, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

References TOOL_MANAGER::IsToolActive(), TOOL_BASE::m_toolId, and TOOL_BASE::m_toolMgr.

31 {
32  return m_toolMgr->IsToolActive( m_toolId );
33 }
bool IsToolActive(TOOL_ID aId) const
Function IsToolActive() Returns true if a tool with given id is active (executing) ...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
int SELECTION_TOOL::Main ( const TOOL_EVENT aEvent)

Function Main()

The main loop.

Definition at line 250 of file pcbnew/tools/selection_tool.cpp.

References BUT_LEFT, BUT_RIGHT, clearSelection(), TOOL_MENU::CloseContextMenu(), SELECTION::Empty(), PCB_ACTIONS::highlightNet, TOOL_MANAGER::InvokeTool(), m_additive, PCB_TOOL::m_editModules, m_menu, m_selection, m_subtractive, TOOL_BASE::m_toolMgr, MD_CTRL, MD_SHIFT, PCB_ACTIONS::properties, TOOL_MANAGER::RunAction(), selectCursor(), selectionContains(), selectMultiple(), selectPoint(), SELECTION::SetIsHover(), TOOL_MENU::ShowContextMenu(), TA_CONTEXT_MENU_CLOSED, TA_UNDO_REDO_PRE, and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

251 {
252  // Main loop: keep receiving events
253  while( OPT_TOOL_EVENT evt = Wait() )
254  {
255  // Should selected items be added to the current selection or
256  // become the new selection (discarding previously selected items)
257  m_additive = evt->Modifier( MD_SHIFT );
258 
259  // Should selected items be REMOVED from the current selection?
260  // This will be ignored if the SHIFT modifier is pressed
261  m_subtractive = !m_additive && evt->Modifier( MD_CTRL );
262 
263  // Single click? Select single object
264  if( evt->IsClick( BUT_LEFT ) )
265  {
266  if( evt->Modifier( MD_CTRL ) && !m_editModules )
267  {
269  }
270  else
271  {
272  // If no modifier keys are pressed, clear the selection
273  if( !m_additive )
274  {
275  clearSelection();
276  }
277 
278  selectPoint( evt->Position() );
279  }
280  }
281 
282  // right click? if there is any object - show the context menu
283  else if( evt->IsClick( BUT_RIGHT ) )
284  {
285  bool selectionCancelled = false;
286 
287  if( m_selection.Empty() )
288  {
289  selectPoint( evt->Position(), false, &selectionCancelled );
290  m_selection.SetIsHover( true );
291  }
292 
293  if( !selectionCancelled )
295  }
296 
297  // double click? Display the properties window
298  else if( evt->IsDblClick( BUT_LEFT ) )
299  {
300  if( m_selection.Empty() )
301  selectPoint( evt->Position() );
302 
304  }
305 
306  // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them
307  else if( evt->IsDrag( BUT_LEFT ) )
308  {
309  if( m_additive || m_subtractive )
310  {
311  selectMultiple();
312  }
313  else if( m_selection.Empty() )
314  {
315  // There is nothing selected, so try to select something
316  if( !selectCursor() )
317  {
318  // If nothings has been selected or user wants to select more
319  // draw the selection box
320  selectMultiple();
321  }
322  else
323  {
324  m_selection.SetIsHover( true );
325  m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
326  }
327  }
328 
329  else
330  {
331  // Check if dragging has started within any of selected items bounding box
332  if( selectionContains( evt->Position() ) )
333  {
334  // Yes -> run the move tool and wait till it finishes
335  m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
336  }
337  else
338  {
339  // No -> clear the selection list
340  clearSelection();
341  }
342  }
343  }
344 
345  else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
346  {
347  clearSelection();
348  }
349 
350  else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )
351  {
352  m_menu.CloseContextMenu( evt );
353  }
354  }
355 
356  // This tool is supposed to be active forever
357  assert( false );
358 
359  return 0;
360 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
bool m_additive
Flag saying if items should be added to the current selection or rather replace it.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:108
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
void SetIsHover(bool aIsHover)
Definition: selection.h:61
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false, bool *aSelectionCancelledFlag=NULL, CLIENT_SELECTION_FILTER aClientFilter=NULL)
Function selectPoint() Selects an item pointed by the parameter aWhere.
bool selectMultiple()
Function selectMultiple() Handles drawing a selection box that allows to select many items at the sam...
bool selectCursor(bool aSelectAlways=false, CLIENT_SELECTION_FILTER aClientFilter=NULL)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
TOOL_MENU m_menu
Menu model displayed by the tool.
bool m_editModules
Definition: pcb_tool.h:142
bool m_subtractive
Flag saying if items should be removed from the current selection.
void CloseContextMenu(OPT_TOOL_EVENT &evt)
Function CloseContextMenu.
Definition: tool_menu.cpp:82
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:385
bool selectionContains(const VECTOR2I &aPoint) const
Function selectionContains() Checks if the given point is placed within any of selected items&#39; boundi...
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:465
bool SELECTION_TOOL::modifiable ( const BOARD_ITEM aItem) const
private

Function modifiable() Checks if an item might be modified.

This function is used to filter out items from the selection when it is passed to other tools.

Returns
True if the item fulfills conditions to be modified.
BOARD_ITEM * SELECTION_TOOL::pickSmallestComponent ( GENERAL_COLLECTOR aCollector)
private

Function pickSmallestComponent() Allows to find the smallest (in terms of bounding box area) item from the list.

Parameters
aCollectorcontaines the list of items.

Definition at line 1453 of file pcbnew/tools/selection_tool.cpp.

References MODULE::GetBoundingBox(), COLLECTOR::GetCount(), EDA_RECT::GetHeight(), GENERAL_COLLECTOR::GetPrimaryCount(), EDA_RECT::GetWidth(), min, PCB_TOOL::module(), and PCB_MODULE_T.

1454 {
1455  int count = aCollector->GetPrimaryCount(); // try to use preferred layer
1456 
1457  if( 0 == count )
1458  count = aCollector->GetCount();
1459 
1460  for( int i = 0; i < count; ++i )
1461  {
1462  if( ( *aCollector )[i]->Type() != PCB_MODULE_T )
1463  return NULL;
1464  }
1465 
1466  // All are modules, now find smallest MODULE
1467  int minDim = 0x7FFFFFFF;
1468  int minNdx = 0;
1469 
1470  for( int i = 0; i < count; ++i )
1471  {
1472  MODULE* module = (MODULE*) ( *aCollector )[i];
1473 
1474  int lx = module->GetBoundingBox().GetWidth();
1475  int ly = module->GetBoundingBox().GetHeight();
1476 
1477  int lmin = std::min( lx, ly );
1478 
1479  if( lmin < minDim )
1480  {
1481  minDim = lmin;
1482  minNdx = i;
1483  }
1484  }
1485 
1486  return (*aCollector)[minNdx];
1487 }
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:107
int GetHeight() const
Definition: eda_rect.h:118
class MODULE, a footprint
Definition: typeinfo.h:89
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
MODULE * module() const
Definition: pcb_tool.h:136
int GetWidth() const
Definition: eda_rect.h:117
#define min(a, b)
Definition: auxiliary.h:85
SELECTION & SELECTION_TOOL::RequestSelection ( int  aFlags = SELECTION_DEFAULT,
CLIENT_SELECTION_FILTER  aClientFilter = NULL 
)

Function RequestSelection()

Returns the current selection set, filtered according to aFlags and aClientFilter. If the set is empty, performs the legacy-style hover selection.

Definition at line 369 of file pcbnew/tools/selection_tool.cpp.

References SELECTION::ClearReferencePoint(), SELECTION::Empty(), SELECTION::GetSize(), m_locked, m_selection, TOOL_BASE::m_toolMgr, PCB_MARKER_T, TOOL_MANAGER::RunAction(), SanitizeSelection(), SELECTION_EDITABLE, SELECTION_FORCE_UNLOCK, SELECTION_SANITIZE_PADS, PCB_ACTIONS::selectionCursor, SELECTION::SetIsHover(), EDA_ITEM::Type(), and unselect().

Referenced by EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::Flip(), EDIT_TOOL::Main(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), and EDIT_TOOL::Rotate().

370 {
371  if( m_selection.Empty() )
372  {
373  if( aFlags & SELECTION_FORCE_UNLOCK )
374  m_locked = false;
375  m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true, aClientFilter );
376  m_selection.SetIsHover( true );
378  }
379 
380  // Be careful with iterators: items can be removed from list
381  // that invalidate iterators.
382  for( unsigned ii = 0; ii < m_selection.GetSize(); ii++ )
383  {
384  EDA_ITEM* item = m_selection[ii];
385 
386  if( ( aFlags & SELECTION_EDITABLE ) && item->Type() == PCB_MARKER_T )
387  {
388  unselect( static_cast<BOARD_ITEM *>( item ) );
389  }
390  }
391 
392  if( aFlags & SELECTION_SANITIZE_PADS )
394 
395  return m_selection;
396 }
void ClearReferencePoint()
Definition: selection.h:205
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void SetIsHover(bool aIsHover)
Definition: selection.h:61
SELECTION m_selection
Current state of selection.
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:86
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:180
bool m_locked
Can other tools modify locked items.
bool SanitizeSelection()
Makes sure a group selection does not contain items that would cause conflicts when moving/rotating t...
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:50
void SELECTION_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Function Reset() Brings the tool to a known, initial state.

If the tool claimed anything from the model or the view, it must release it when its reset.

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PCB_TOOL.

Definition at line 227 of file pcbnew/tools/selection_tool.cpp.

References KIGFX::PCB_VIEW::Add(), SELECTION::Clear(), clearSelection(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_BASE::getView(), m_frame, m_locked, m_selection, TOOL_BASE::MODEL_RELOAD, KIGFX::PCB_VIEW::Remove(), KIGFX::RENDER_SETTINGS::SetHighlight(), and PCB_TOOL::view().

228 {
229  m_frame = getEditFrame<PCB_BASE_FRAME>();
230  m_locked = true;
231 
232  if( aReason == TOOL_BASE::MODEL_RELOAD )
233  {
234  // Remove pointers to the selected items from containers
235  // without changing their properties (as they are already deleted
236  // while a new board is loaded)
237  m_selection.Clear();
238  getView()->GetPainter()->GetSettings()->SetHighlight( false );
239  }
240  else
241  // Restore previous properties of selected items and remove them from containers
242  clearSelection();
243 
244  // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
245  view()->Remove( &m_selection );
246  view()->Add( &m_selection );
247 }
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
Model changes (required full reload)
Definition: tool_base.h:83
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:64
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
bool m_locked
Can other tools modify locked items.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:48
void SetHighlight(bool aEnabled, int aNetcode=-1)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specifie...
Definition: painter.h:140
void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 85 of file tool_interactive.cpp.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::RunMainStack().

Referenced by DRAWING_TOOL::PlaceText().

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
bool SELECTION_TOOL::SanitizeSelection ( )

Makes sure a group selection does not contain items that would cause conflicts when moving/rotating together (e.g.

a footprint and one of the same footprint's pads)

Definition at line 2110 of file pcbnew/tools/selection_tool.cpp.

References ClearedEvent, MODULE::IsLocked(), EDA_ITEM::IsSelected(), PCB_TOOL::m_editModules, m_selection, TOOL_BASE::m_toolMgr, mod, MODULE::PadsLocked(), PCB_PAD_T, TOOL_MANAGER::ProcessEvent(), select(), SelectedEvent, TA_ACTION, TC_MESSAGE, unselect(), and UnselectedEvent.

Referenced by deleteItem(), RequestSelection(), and selectPRitem().

2111 {
2112  std::set<BOARD_ITEM*> rejected;
2113  std::set<BOARD_ITEM*> added;
2114 
2115  if( !m_editModules )
2116  {
2117  for( auto i : m_selection )
2118  {
2119  auto item = static_cast<BOARD_ITEM*>( i );
2120  if( item->Type() == PCB_PAD_T )
2121  {
2122  MODULE* mod = static_cast<MODULE*>( item->GetParent() );
2123 
2124  // case 1: module (or its pads) are locked
2125  if( mod && ( mod->PadsLocked() || mod->IsLocked() ) )
2126  {
2127  rejected.insert( item );
2128 
2129  if( !mod->IsLocked() && !mod->IsSelected() )
2130  added.insert( mod );
2131  }
2132 
2133  // case 2: multi-item selection contains both the module and its pads - remove the pads
2134  if( mod && m_selection.Contains( mod ) )
2135  rejected.insert( item );
2136  }
2137  }
2138  }
2139 
2140  if( !rejected.empty() )
2141  {
2142  for( BOARD_ITEM* item : rejected )
2143  unselect( item );
2144 
2145  // Inform other potentially interested tools
2147  }
2148 
2149  if( !added.empty() )
2150  {
2151  for( BOARD_ITEM* item : added )
2152  select( item );
2153 
2154  // Inform other potentially interested tools
2156  }
2157 
2158  return true;
2159 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool IsSelected() const
Definition: base_struct.h:250
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
bool PadsLocked() const
Definition: class_module.h:299
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SELECTION m_selection
Current state of selection.
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:263
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
bool m_editModules
Definition: pcb_tool.h:142
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
#define mod(a, n)
Definition: greymap.cpp:24
void SELECTION_TOOL::select ( BOARD_ITEM aItem)
private

Function select() Takes necessary action mark an item as selected.

Parameters
aItemis an item to be selected.

Definition at line 1659 of file pcbnew/tools/selection_tool.cpp.

References SELECTION::Add(), SELECTION::Contains(), BOARD_ITEM::GetParent(), EDA_ITEM::IsSelected(), m_frame, m_selection, PCB_TOOL::module(), PCB_PAD_T, selectVisually(), PCB_BASE_FRAME::SetCurItem(), SELECTION::Size(), and EDA_ITEM::Type().

Referenced by filterSelection(), findCallback(), SanitizeSelection(), selectAllItemsConnectedToItem(), selectAllItemsConnectedToTrack(), selectAllItemsOnNet(), selectAllItemsOnSheet(), SelectItem(), SelectItems(), selectMultiple(), and toggleSelection().

1660 {
1661  if( aItem->IsSelected() )
1662  {
1663  return;
1664  }
1665 
1666  if( aItem->Type() == PCB_PAD_T )
1667  {
1668  MODULE* module = static_cast<MODULE*>( aItem->GetParent() );
1669 
1670  if( m_selection.Contains( module ) )
1671  return;
1672  }
1673 
1674  m_selection.Add( aItem );
1675  selectVisually( aItem );
1676 
1677  if( m_frame )
1678  {
1679  if( m_selection.Size() == 1 )
1680  {
1681  // Set as the current item, so the information about selection is displayed
1682  m_frame->SetCurItem( aItem, true );
1683  }
1684  else if( m_selection.Size() == 2 ) // Check only for 2, so it will not be
1685  { // called for every next selected item
1686  // If multiple items are selected, do not show the information about the selected item
1687  m_frame->SetCurItem( NULL, true );
1688  }
1689  }
1690 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
BOARD_ITEM_CONTAINER * GetParent() const
bool Contains(EDA_ITEM *aItem) const
Definition: selection.h:100
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
bool IsSelected() const
Definition: base_struct.h:250
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
MODULE * module() const
Definition: pcb_tool.h:136
void selectVisually(BOARD_ITEM *aItem)
Function selectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
bool SELECTION_TOOL::selectable ( const BOARD_ITEM aItem) const
private

Function selectable() Checks conditions for an item to be selected.

Returns
True if the item fulfills conditions to be selected.

Definition at line 1490 of file pcbnew/tools/selection_tool.cpp.

References B_Cu, PCB_TOOL::board(), F_Cu, BOX2< Vec >::GetArea(), KIGFX::RENDER_SETTINGS::GetHighContrast(), BOARD_ITEM::GetLayer(), ZONE_CONTAINER::GetLayerSet(), KIGFX::VIEW::GetPainter(), TOOL_BASE::GetSettings(), KIGFX::PAINTER::GetSettings(), VIA::GetViaType(), TOOL_BASE::getView(), KIGFX::VIEW::GetViewport(), BOARD::IsElementVisible(), BOARD::IsLayerVisible(), MODULE::IsLocked(), BOARD_ITEM::IsOnLayer(), KIGFX::VIEW::IsVisible(), LAYER_MOD_BK, LAYER_MOD_FR, LAYER_TRACKS, LAYER_VIA_BBLIND, LAYER_VIA_MICROVIA, LAYER_VIA_THROUGH, VIA::LayerPair(), PCB_TOOL::m_editModules, m_multiple, mod, NOT_USED, PCB_MODULE_EDGE_T, PCB_MODULE_T, PCB_MODULE_TEXT_T, PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, LSET::Seq(), EDA_ITEM::Type(), TYPE_NOT_INIT, VIA_BLIND_BURIED, VIA_MICROVIA, VIA_THROUGH, PCB_TOOL::view(), KIGFX::VIEW::VIEW_MAX_LAYERS, EDA_ITEM::ViewBBox(), and BOARD_ITEM::ViewGetLayers().

Referenced by selectMultiple(), selectPoint(), and toggleSelection().

1491 {
1492  // Is high contrast mode enabled?
1493  bool highContrast = getView()->GetPainter()->GetSettings()->GetHighContrast();
1494 
1495  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS], layers_count;
1496 
1497  // Filter out items that do not belong to active layers
1498  const std::set<unsigned int>& activeLayers = getView()->GetPainter()->
1499  GetSettings()->GetActiveLayers();
1500 
1501  aItem->ViewGetLayers( layers, layers_count );
1502 
1503  if( highContrast )
1504  {
1505  bool onActive = false; // Is the item on any of active layers?
1506 
1507  for( int i = 0; i < layers_count; ++i )
1508  {
1509  if( activeLayers.count( layers[i] ) > 0 ) // Item is on at least one of the active layers
1510  {
1511  onActive = true;
1512  break;
1513  }
1514  }
1515 
1516  if( !onActive ) // We do not want to select items that are in the background
1517  {
1518  return false;
1519  }
1520  }
1521 
1522  switch( aItem->Type() )
1523  {
1524  case PCB_ZONE_AREA_T:
1525  // Keepout zones can exist on multiple layers!
1526  {
1527  auto* zone = static_cast<const ZONE_CONTAINER*>( aItem );
1528 
1529  if( zone && zone->GetIsKeepout() )
1530  {
1531  auto zoneLayers = zone->GetLayerSet().Seq();
1532 
1533  for( unsigned int i = 0; i < zoneLayers.size(); i++ )
1534  {
1535  if( board()->IsLayerVisible( zoneLayers[i] ) )
1536  {
1537  return true;
1538  }
1539  }
1540 
1541  // No active layers selected!
1542  return false;
1543  }
1544  }
1545  break;
1546 
1547  case PCB_TRACE_T:
1548  {
1549  if( !board()->IsElementVisible( LAYER_TRACKS ) )
1550  return false;
1551  }
1552  break;
1553 
1554  case PCB_VIA_T:
1555  {
1556  const VIA* via = static_cast<const VIA*>( aItem );
1557 
1558  // Check if appropriate element layer is visible
1559  switch( via->GetViaType() )
1560  {
1561  case VIA_THROUGH:
1563  return false;
1564  break;
1565 
1566  case VIA_BLIND_BURIED:
1568  return false;
1569  break;
1570 
1571  case VIA_MICROVIA:
1573  return false;
1574  break;
1575 
1576  default:
1577  wxFAIL;
1578  return false;
1579  }
1580 
1581  // For vias it is enough if only one of its layers is visible
1582  PCB_LAYER_ID top, bottom;
1583  via->LayerPair( &top, &bottom );
1584 
1585  return board()->IsLayerVisible( top ) || board()->IsLayerVisible( bottom );
1586  }
1587  break;
1588 
1589  case PCB_MODULE_T:
1590  {
1591  // In the module editor, we do not want to select the module itself
1592  // rather, the module sub-components should be selected individually
1593  if( m_editModules )
1594  return false;
1595 
1596  float viewArea = getView()->GetViewport().GetArea();
1597  float modArea = aItem->ViewBBox().GetArea();
1598 
1599  // Do not select modules that cover more than 90% of the view area
1600  // (most likely footprints representing shield connectors)
1601  if( viewArea > 0.0 && modArea / viewArea > 0.9 )
1602  return false;
1603 
1604  if( aItem->IsOnLayer( F_Cu ) && board()->IsElementVisible( LAYER_MOD_FR ) )
1605  return !m_editModules;
1606 
1607  if( aItem->IsOnLayer( B_Cu ) && board()->IsElementVisible( LAYER_MOD_BK ) )
1608  return !m_editModules;
1609 
1610  return false;
1611 
1612  break;
1613  }
1614 
1615  case PCB_MODULE_TEXT_T:
1616  if( m_multiple && !m_editModules )
1617  return false;
1618 
1619  return view()->IsVisible( aItem ) && board()->IsLayerVisible( aItem->GetLayer() );
1620 
1621  case PCB_MODULE_EDGE_T:
1622  case PCB_PAD_T:
1623  {
1624  // Multiple selection is only allowed in modedit mode
1625  // In pcbnew, you have to select subparts of modules
1626  // one-by-one, rather than with a drag selection.
1627  // This is so you can pick up items under an (unlocked)
1628  // module without also moving the module's sub-parts.
1629  if( m_multiple && !m_editModules )
1630  return false;
1631 
1632  // When editing modules, it's allowed to select them, even when
1633  // locked, since you already have to explicitly activate the
1634  // module editor to get to this stage
1635  if ( !m_editModules )
1636  {
1637  MODULE* mod = static_cast<const D_PAD*>( aItem )->GetParent();
1638  if( mod && mod->IsLocked() )
1639  return false;
1640  }
1641 
1642  break;
1643  }
1644 
1645  // These are not selectable
1646  case NOT_USED:
1647  case TYPE_NOT_INIT:
1648  return false;
1649 
1650  default: // Suppress warnings
1651  break;
1652  }
1653 
1654  // All other items are selected only if the layer on which they exist is visible
1655  return board()->IsLayerVisible( aItem->GetLayer() );
1656 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
to draw blind/buried vias
bool GetHighContrast() const
Function GetHighContrast Returns information about high contrast display mode.
Definition: painter.h:161
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Function IsOnLayer tests to see if this object is on the given layer.
bool m_multiple
Flag saying if multiple selection mode is active.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
the 3d code uses this value
Definition: typeinfo.h:80
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on...
show modules on back
ecoord_type GetArea() const
Function GetArea returns the area of the rectangle.
Definition: box2.h:391
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
show modules on front
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:364
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:226
class MODULE, a footprint
Definition: typeinfo.h:89
PCB_LAYER_ID
A quick note on layer IDs:
BOX2D GetViewport() const
Function GetViewport() Returns the current viewport visible area rectangle.
Definition: view.cpp:499
VIATYPE_T GetViaType() const
Definition: class_track.h:455
to draw usual through hole vias
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:652
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
TOOL_SETTINGS & GetSettings()
Definition: tool_base.cpp:77
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:263
void LayerPair(PCB_LAYER_ID *top_layer, PCB_LAYER_ID *bottom_layer) const
Function LayerPair Return the 2 layers used by the via (the via actually uses all layers between thes...
bool m_editModules
Definition: pcb_tool.h:142
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1368
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers. ...
#define mod(a, n)
Definition: greymap.cpp:24
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:451
BOARD * board() const
Definition: pcb_tool.h:135
void SELECTION_TOOL::selectAllItemsConnectedToItem ( BOARD_CONNECTED_ITEM aSourceItem)
private

Selects all items connected (by copper) to the given item.

Definition at line 926 of file pcbnew/tools/selection_tool.cpp.

References PCB_TOOL::board(), EOT, BOARD::GetConnectivity(), PCB_TRACE_T, PCB_VIA_T, and select().

Referenced by selectCopper().

927 {
928  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
929  auto connectivity = board()->GetConnectivity();
930 
931  std::vector<BOARD_CONNECTED_ITEM*> items;
932  items = connectivity->GetConnectedItems( &aSourceItem, types );
933 
934  for( auto item : connectivity->GetConnectedItems( &aSourceItem, types ) )
935  select( item );
936 }
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
BOARD * board() const
Definition: pcb_tool.h:135
void SELECTION_TOOL::selectAllItemsConnectedToTrack ( TRACK aSourceTrack)
private

Selects all items connected by copper tracks to the given TRACK.

Definition at line 912 of file pcbnew/tools/selection_tool.cpp.

References PCB_TOOL::board(), BOARD::MarkTrace(), TRACK::Next(), and select().

Referenced by expandSelectedConnection(), and selectAllItemsOnSheet().

913 {
914  int segmentCount;
915  TRACK* trackList = board()->MarkTrace( &aSourceTrack, &segmentCount,
916  nullptr, nullptr, true );
917 
918  for( int i = 0; i < segmentCount; ++i )
919  {
920  select( trackList );
921  trackList = trackList->Next();
922  }
923 }
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
TRACK * MarkTrace(TRACK *aTrace, int *aCount, double *aTraceLength, double *aInPackageLength, bool aReorder)
Function MarkTrace marks a chain of trace segments, connected to aTrace.
TRACK * Next() const
Definition: class_track.h:99
BOARD * board() const
Definition: pcb_tool.h:135
void SELECTION_TOOL::selectAllItemsOnNet ( int  aNetCode)
private

Selects all items with the given net code.

Definition at line 939 of file pcbnew/tools/selection_tool.cpp.

References PCB_TOOL::board(), EOT, BOARD::GetConnectivity(), PCB_TRACE_T, PCB_VIA_T, and select().

Referenced by selectNet().

940 {
941  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
942  auto connectivity = board()->GetConnectivity();
943 
944  for( auto item : connectivity->GetNetItems( aNetCode, types ) )
945  select( item );
946 }
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
BOARD * board() const
Definition: pcb_tool.h:135
void SELECTION_TOOL::selectAllItemsOnSheet ( wxString &  aSheetpath)
private

Selects all items with the given sheet timestamp name (the sheet path)

Definition at line 978 of file pcbnew/tools/selection_tool.cpp.

References PCB_TOOL::board(), EOT, DLIST< T >::GetFirst(), BOARD::GetTracksByPosition(), BOARD::m_Modules, MODULE::Next(), PCB_PAD_T, PCB_TRACE_T, PCB_VIA_T, select(), and selectAllItemsConnectedToTrack().

Referenced by selectOnSheetFromEeschema(), and selectSameSheet().

979 {
980  auto modules = board()->m_Modules.GetFirst();
981  std::list<MODULE*> modList;
982 
983  // store all modules that are on that sheet
984  for( MODULE* mitem = modules; mitem; mitem = mitem->Next() )
985  {
986  if( mitem != NULL && mitem->GetPath().Contains( aSheetpath ) )
987  {
988  modList.push_back( mitem );
989  }
990  }
991 
992  //Generate a list of all pads, and of all nets they belong to.
993  std::list<int> netcodeList;
994  std::list<BOARD_CONNECTED_ITEM*> padList;
995  for( MODULE* mmod : modList )
996  {
997  for( auto pad : mmod->Pads() )
998  {
999  if( pad->IsConnected() )
1000  {
1001  netcodeList.push_back( pad->GetNetCode() );
1002  padList.push_back( pad );
1003  }
1004  }
1005  }
1006  // remove all duplicates
1007  netcodeList.sort();
1008  netcodeList.unique();
1009 
1010  // auto select trivial connections segments which are launched from the pads
1011  std::list<TRACK*> launchTracks;
1012 
1013  for( auto pad : padList )
1014  {
1015  launchTracks = board()->GetTracksByPosition( pad->GetPosition() );
1016 
1017  for( auto track : launchTracks )
1018  {
1020  }
1021  }
1022 
1023  // now we need to find all modules that are connected to each of these nets
1024  // then we need to determine if these modules are in the list of modules
1025  // belonging to this sheet ( modList )
1026  std::list<int> removeCodeList;
1027  constexpr KICAD_T padType[] = { PCB_PAD_T, EOT };
1028 
1029  for( int netCode : netcodeList )
1030  {
1031  for( BOARD_CONNECTED_ITEM* mitem : board()->GetConnectivity()->GetNetItems( netCode, padType ) )
1032  {
1033  if( mitem->Type() == PCB_PAD_T)
1034  {
1035  bool found = ( std::find( modList.begin(), modList.end(),
1036  mitem->GetParent() ) != modList.end() );
1037 
1038  if( !found )
1039  {
1040  // if we cannot find the module of the pad in the modList
1041  // then we can assume that that module is not located in the same
1042  // schematic, therefore invalidate this netcode.
1043  removeCodeList.push_back( netCode );
1044  break;
1045  }
1046  }
1047  }
1048  }
1049 
1050  // remove all duplicates
1051  removeCodeList.sort();
1052  removeCodeList.unique();
1053 
1054  for( int removeCode : removeCodeList )
1055  {
1056  netcodeList.remove( removeCode );
1057  }
1058 
1059  std::list<BOARD_CONNECTED_ITEM*> localConnectionList;
1060  constexpr KICAD_T trackViaType[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
1061 
1062  for( int netCode : netcodeList )
1063  {
1064  for( BOARD_CONNECTED_ITEM* item : board()->GetConnectivity()->GetNetItems( netCode, trackViaType ) )
1065  {
1066  localConnectionList.push_back( item );
1067  }
1068  }
1069 
1070  for( BOARD_ITEM* i : modList )
1071  {
1072  if( i != NULL )
1073  select( i );
1074  }
1075 
1076  for( BOARD_CONNECTED_ITEM* i : localConnectionList )
1077  {
1078  if( i != NULL )
1079  select( i );
1080  }
1081 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
MODULE * Next() const
Definition: class_module.h:121
std::list< TRACK * > GetTracksByPosition(const wxPoint &aPosition, PCB_LAYER_ID aLayer=PCB_LAYER_ID(-1)) const
Function GetTracksByPosition finds the list of tracks that starts or ends at aPosition on aLayer...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
T * GetFirst() const
Function GetFirst returns the first T* in the list without removing it, or NULL if the list is empty...
Definition: dlist.h:163
void selectAllItemsConnectedToTrack(TRACK &aSourceTrack)
Selects all items connected by copper tracks to the given TRACK.
DLIST< MODULE > m_Modules
Definition: class_board.h:245
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
BOARD * board() const
Definition: pcb_tool.h:135
int SELECTION_TOOL::selectConnection ( const TOOL_EVENT aEvent)
private

Selects a trivial connection (between two junctions) of items in selection

Definition at line 838 of file pcbnew/tools/selection_tool.cpp.

References connectedTrackFilter(), expandSelectedConnection(), and selectCursor().

Referenced by setTransitions().

839 {
840  if( !selectCursor( true, connectedTrackFilter ) )
841  return 0;
842 
843  return expandSelectedConnection( aEvent );
844 }
void connectedTrackFilter(const VECTOR2I &aPt, GENERAL_COLLECTOR &aCollector)
int expandSelectedConnection(const TOOL_EVENT &aEvent)
Expands the current selection to select a connection between two junctions
bool selectCursor(bool aSelectAlways=false, CLIENT_SELECTION_FILTER aClientFilter=NULL)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
int SELECTION_TOOL::selectCopper ( const TOOL_EVENT aEvent)
private

Selects items with a continuous copper connection to items in selection

Definition at line 888 of file pcbnew/tools/selection_tool.cpp.

References connectedItemFilter(), SELECTION::GetItems(), m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), selectAllItemsConnectedToItem(), selectCursor(), SelectedEvent, PCB_TOOL::selection(), and SELECTION::Size().

Referenced by setTransitions().

889 {
890  if( !selectCursor( true, connectedItemFilter ) )
891  return 0;
892 
893  // copy the selection, since we're going to iterate and modify
894  auto selection = m_selection.GetItems();
895 
896  for( auto item : selection )
897  {
898  BOARD_CONNECTED_ITEM* connItem = dynamic_cast<BOARD_CONNECTED_ITEM*>( item );
899 
900  if( connItem )
901  selectAllItemsConnectedToItem( *connItem );
902  }
903 
904  // Inform other potentially interested tools
905  if( m_selection.Size() > 0 )
907 
908  return 0;
909 }
void connectedItemFilter(const VECTOR2I &, GENERAL_COLLECTOR &aCollector)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
const std::set< EDA_ITEM * > GetItems() const
Definition: selection.h:117
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
bool selectCursor(bool aSelectAlways=false, CLIENT_SELECTION_FILTER aClientFilter=NULL)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
SELECTION m_selection
Current state of selection.
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
void selectAllItemsConnectedToItem(BOARD_CONNECTED_ITEM &aSourceItem)
Selects all items connected (by copper) to the given item.
bool SELECTION_TOOL::selectCursor ( bool  aSelectAlways = false,
CLIENT_SELECTION_FILTER  aClientFilter = NULL 
)
private

Function selectCursor() Selects an item under the cursor unless there is something already selected or aSelectAlways is true.

Parameters
aSelectAlwaysforces to select an item even if there is an item already selected.
aClientFilterallows the client to perform tool- or action-specific filtering.
Returns
true if eventually there is an item selected, false otherwise.

Definition at line 529 of file pcbnew/tools/selection_tool.cpp.

References clearSelection(), SELECTION::Empty(), TOOL_BASE::getViewControls(), m_selection, and selectPoint().

Referenced by CursorSelection(), Main(), selectConnection(), selectCopper(), selectNet(), and selectSameSheet().

530 {
531  if( aSelectAlways || m_selection.Empty() )
532  {
533  clearSelection();
534  selectPoint( getViewControls()->GetCursorPosition( false ), false, NULL, aClientFilter );
535  }
536 
537  return !m_selection.Empty();
538 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false, bool *aSelectionCancelledFlag=NULL, CLIENT_SELECTION_FILTER aClientFilter=NULL)
Function selectPoint() Selects an item pointed by the parameter aWhere.
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
const SELECTION & PCB_TOOL::selection ( ) const
protectedinherited

Definition at line 218 of file pcb_tool.cpp.

References TOOL_MANAGER::GetTool(), and TOOL_BASE::m_toolMgr.

Referenced by PAD_TOOL::applyPadSettings(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), deleteItem(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::ExchangeFootprints(), expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), filterSelection(), EDIT_TOOL::Flip(), DRAWING_TOOL::getSourceZoneForAction(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Remove(), EDIT_TOOL::Rotate(), selectCopper(), PCB_TOOL::selection(), selectNet(), selectPRitem(), showLocalRatsnest(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

219 {
220  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
221  const auto& selection = selTool->GetSelection();
222  return selection;
223 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
SELECTION & PCB_TOOL::selection ( )
protectedinherited

Definition at line 225 of file pcb_tool.cpp.

References TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, and PCB_TOOL::selection().

226 {
227  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
228  auto& selection = selTool->GetSelection();
229  return selection;
230 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
bool SELECTION_TOOL::selectionContains ( const VECTOR2I aPoint) const
private

Function selectionContains() Checks if the given point is placed within any of selected items' bounding box.

Returns
True if the given point is contained in any of selected items' bouding box.

Definition at line 1758 of file pcbnew/tools/selection_tool.cpp.

References BOX2< Vec >::Contains(), TOOL_BASE::getView(), BOX2< Vec >::Inflate(), m_selection, KIGFX::VIEW::ToWorld(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Main().

1759 {
1760  const unsigned GRIP_MARGIN = 20;
1761  VECTOR2D margin = getView()->ToWorld( VECTOR2D( GRIP_MARGIN, GRIP_MARGIN ), false );
1762 
1763  // Check if the point is located within any of the currently selected items bounding boxes
1764  for( auto item : m_selection )
1765  {
1766  BOX2I itemBox = item->ViewBBox();
1767  itemBox.Inflate( margin.x, margin.y ); // Give some margin for gripping an item
1768 
1769  if( itemBox.Contains( aPoint ) )
1770  return true;
1771  }
1772 
1773  return false;
1774 }
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:139
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates...
Definition: view.cpp:438
VECTOR2< double > VECTOR2D
Definition: vector2d.h:588
SELECTION m_selection
Current state of selection.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:266
int SELECTION_TOOL::SelectItem ( const TOOL_EVENT aEvent)

Item selection event handler.

Definition at line 769 of file pcbnew/tools/selection_tool.cpp.

References TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), TOOL_MANAGER::ProcessEvent(), select(), and SelectedEvent.

Referenced by setTransitions().

770 {
771  // Check if there is an item to be selected
772  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
773 
774  if( item )
775  {
776  select( item );
777 
778  // Inform other potentially interested tools
780  }
781 
782  return 0;
783 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
int SELECTION_TOOL::SelectItems ( const TOOL_EVENT aEvent)

Multiple item selection event handler

Definition at line 749 of file pcbnew/tools/selection_tool.cpp.

References TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), TOOL_MANAGER::ProcessEvent(), select(), and SelectedEvent.

Referenced by setTransitions().

750 {
751  std::vector<BOARD_ITEM*>* items = aEvent.Parameter<std::vector<BOARD_ITEM*>*>();
752 
753  if( items )
754  {
755  // Perform individual selection of each item
756  // before processing the event.
757  for( auto item : *items )
758  {
759  select( item );
760  }
761 
763  }
764 
765  return 0;
766 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
bool SELECTION_TOOL::selectMultiple ( )
private

Function selectMultiple() Handles drawing a selection box that allows to select many items at the same time.

Returns
true if the function was cancelled (i.e. CancelEvent was received).

Definition at line 541 of file pcbnew/tools/selection_tool.cpp.

References KIGFX::VIEW::Add(), BUT_LEFT, SELECTION::ClearReferencePoint(), BOX2< Vec >::Contains(), SELECTION::Empty(), SELECTION::Front(), KIGFX::PREVIEW::SELECTION_AREA::GetEnd(), KIGFX::PREVIEW::SELECTION_AREA::GetOrigin(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), BOARD_ITEM::HitTest(), TOOL_EVT_UTILS::IsCancelInteractive(), m_additive, m_frame, m_multiple, m_selection, m_subtractive, TOOL_BASE::m_toolMgr, EDA_RECT::Normalize(), TOOL_MANAGER::ProcessEvent(), KIGFX::VIEW::Query(), KIGFX::VIEW::Remove(), select(), selectable(), SelectedEvent, KIGFX::PREVIEW::SELECTION_AREA::SetAdditive(), KIGFX::VIEW_CONTROLS::SetAutoPan(), PCB_BASE_FRAME::SetCurItem(), KIGFX::PREVIEW::SELECTION_AREA::SetEnd(), KIGFX::PREVIEW::SELECTION_AREA::SetOrigin(), KIGFX::PREVIEW::SELECTION_AREA::SetSubtractive(), KIGFX::VIEW::SetVisible(), SELECTION::Size(), unselect(), KIGFX::VIEW::Update(), PCB_TOOL::view(), KIGFX::PREVIEW::SELECTION_AREA::ViewBBox(), EDA_ITEM::ViewBBox(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Main().

542 {
543  bool cancelled = false; // Was the tool cancelled while it was running?
544  m_multiple = true; // Multiple selection mode is active
545  KIGFX::VIEW* view = getView();
546 
548  view->Add( &area );
549 
550  while( OPT_TOOL_EVENT evt = Wait() )
551  {
553  {
554  cancelled = true;
555  break;
556  }
557 
558  if( evt->IsDrag( BUT_LEFT ) )
559  {
560  // Start drawing a selection box
561  area.SetOrigin( evt->DragOrigin() );
562  area.SetEnd( evt->Position() );
563  area.SetAdditive( m_additive );
565 
566  view->SetVisible( &area, true );
567  view->Update( &area );
568  getViewControls()->SetAutoPan( true );
569  }
570 
571  if( evt->IsMouseUp( BUT_LEFT ) )
572  {
573  getViewControls()->SetAutoPan( false );
574 
575  // End drawing the selection box
576  view->SetVisible( &area, false );
577 
578  // Mark items within the selection box as selected
579  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
580 
581  // Filter the view items based on the selection box
582  BOX2I selectionBox = area.ViewBBox();
583  view->Query( selectionBox, selectedItems ); // Get the list of selected items
584 
585  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR>::iterator it, it_end;
586 
587  int width = area.GetEnd().x - area.GetOrigin().x;
588  int height = area.GetEnd().y - area.GetOrigin().y;
589 
590  // Construct an EDA_RECT to determine BOARD_ITEM selection
591  EDA_RECT selectionRect( wxPoint( area.GetOrigin().x, area.GetOrigin().y ),
592  wxSize( width, height ) );
593 
594  selectionRect.Normalize();
595 
596  for( it = selectedItems.begin(), it_end = selectedItems.end(); it != it_end; ++it )
597  {
598  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first );
599 
600  if( !item || !selectable( item ) )
601  continue;
602 
603  /* Selection mode depends on direction of drag-selection:
604  * Left > Right : Select objects that are fully enclosed by selection
605  * Right > Left : Select objects that are crossed by selection
606  */
607 
608  if( width >= 0 )
609  {
610  if( selectionBox.Contains( item->ViewBBox() ) )
611  {
612  if( m_subtractive )
613  unselect( item );
614  else
615  select( item );
616  }
617  }
618  else
619  {
620  if( item->HitTest( selectionRect, false ) )
621  {
622  if( m_subtractive )
623  unselect( item );
624  else
625  select( item );
626  }
627  }
628  }
629 
630  if( m_frame )
631  {
632  if( m_selection.Size() == 1 )
633  m_frame->SetCurItem( static_cast<BOARD_ITEM*>( m_selection.Front() ) );
634  else
635  m_frame->SetCurItem( NULL );
636  }
637 
638  // Inform other potentially interested tools
639  if( !m_selection.Empty() )
641 
642  break; // Stop waiting for events
643  }
644  }
645 
646  // Stop drawing the selection box
647  view->Remove( &area );
648  m_multiple = false; // Multiple selection mode is inactive
649 
650  if( !cancelled )
652 
653  return cancelled;
654 }
void ClearReferencePoint()
Definition: selection.h:205
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
void SetEnd(VECTOR2I aEnd)
Set the current end of the rectangle (the corner that moves with the cursor.
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Function Query() Finds all visible items that touch or are within the rectangle aRect.
Definition: view.cpp:415
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
bool m_multiple
Flag saying if multiple selection mode is active.
void SetOrigin(VECTOR2I aOrigin)
Set the origin of the rectange (the fixed corner)
bool m_additive
Flag saying if items should be added to the current selection or rather replace it.
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:139
EDA_ITEM * Front() const
Definition: selection.h:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:339
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
bool selectable(const BOARD_ITEM *aItem) const
Function selectable() Checks conditions for an item to be selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers. ...
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1382
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void Normalize()
Function Normalize ensures that the height ant width are positive.
bool m_subtractive
Flag saying if items should be removed from the current selection.
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
void SetSubtractive(bool aSubtractive)
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1328
Class SELECTION_AREA.
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:309
Class VIEW.
Definition: view.h:58
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers. ...
void SetAdditive(bool aAdditive)
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:465
int SELECTION_TOOL::selectNet ( const TOOL_EVENT aEvent)
private

Selects all copper connections belonging to the same net(s) as the items in the selection.

Definition at line 949 of file pcbnew/tools/selection_tool.cpp.

References SELECTION::GetItems(), m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), selectAllItemsOnNet(), selectCursor(), SelectedEvent, PCB_TOOL::selection(), and SELECTION::Size().

Referenced by setTransitions().

950 {
951  if( !selectCursor() )
952  return 0;
953 
954  // copy the selection, since we're going to iterate and modify
955  auto selection = m_selection.GetItems();
956 
957  for( auto i : selection )
958  {
959  auto item = static_cast<BOARD_ITEM*>( i );
960 
961  // only connected items get a net code
962  if( item->IsConnected() )
963  {
964  auto& connItem = static_cast<BOARD_CONNECTED_ITEM&>( *item );
965 
966  selectAllItemsOnNet( connItem.GetNetCode() );
967  }
968  }
969 
970  // Inform other potentially interested tools
971  if( m_selection.Size() > 0 )
973 
974  return 0;
975 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
const std::set< EDA_ITEM * > GetItems() const
Definition: selection.h:117
void selectAllItemsOnNet(int aNetCode)
Selects all items with the given net code.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
bool selectCursor(bool aSelectAlways=false, CLIENT_SELECTION_FILTER aClientFilter=NULL)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
SELECTION m_selection
Current state of selection.
const SELECTION & selection() const
Definition: pcb_tool.cpp:218
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
int SELECTION_TOOL::selectOnSheetFromEeschema ( const TOOL_EVENT aEvent)
private

Selects all modules belonging to same sheet, from Eeschema, using crossprobing

Definition at line 1107 of file pcbnew/tools/selection_tool.cpp.

References clearSelection(), m_selection, TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), TOOL_MANAGER::ProcessEvent(), selectAllItemsOnSheet(), SelectedEvent, SELECTION::Size(), and zoomFitSelection().

Referenced by setTransitions().

1108 {
1109  clearSelection();
1110  wxString* sheetpath = aEvent.Parameter<wxString*>();
1111 
1112  selectAllItemsOnSheet( *sheetpath );
1113 
1114  zoomFitSelection();
1115 
1116  if( m_selection.Size() > 0 )
1118 
1119  return 0;
1120 }
void zoomFitSelection(void)
Zooms the screen to center and fit the current selection.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void selectAllItemsOnSheet(wxString &aSheetpath)
Selects all items with the given sheet timestamp name (the sheet path)
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
bool SELECTION_TOOL::selectPoint ( const VECTOR2I aWhere,
bool  aOnDrag = false,
bool *  aSelectionCancelledFlag = NULL,
CLIENT_SELECTION_FILTER  aClientFilter = NULL 
)
private

Function selectPoint() Selects an item pointed by the parameter aWhere.

If there is more than one item at that place, there is a menu displayed that allows to choose the item.

Parameters
aWhereis the place where the item should be selected.
aOnDragindicates whether a drag operation is being performed.
aSelectionCancelledFlagallows the function to inform its caller that a selection was cancelled (for instance, by clicking outside of the disambiguation menu).
aClientFilterallows the client to perform tool- or action-specific filtering.
Returns
True if an item was selected, false otherwise.

Definition at line 453 of file pcbnew/tools/selection_tool.cpp.

References GENERAL_COLLECTOR::AllBoardItems, PCB_TOOL::board(), BUT_LEFT, SELECTION::ClearReferencePoint(), clearSelection(), GENERAL_COLLECTOR::Collect(), disambiguationMenu(), getCollectorsGuide(), COLLECTOR::GetCount(), guessSelectionCandidates(), m_additive, PCB_TOOL::m_editModules, m_selection, GENERAL_COLLECTOR::ModuleItems, COLLECTOR::Remove(), selectable(), TA_MOUSE_UP, TC_ANY, toggleSelection(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Main(), and selectCursor().

456 {
457  auto guide = getCollectorsGuide();
458  GENERAL_COLLECTOR collector;
459 
460  collector.Collect( board(),
462  wxPoint( aWhere.x, aWhere.y ), guide );
463 
464  bool anyCollected = collector.GetCount() != 0;
465 
466  // Remove unselectable items
467  for( int i = collector.GetCount() - 1; i >= 0; --i )
468  {
469  if( !selectable( collector[i] ) || ( aOnDrag && collector[i]->IsLocked() ) )
470  collector.Remove( i );
471  }
472 
474 
475  // Allow the client to do tool- or action-specific filtering to see if we
476  // can get down to a single item
477  if( aClientFilter )
478  aClientFilter( aWhere, collector );
479 
480  if( collector.GetCount() == 0 )
481  {
482  if( !m_additive && anyCollected )
483  {
484  clearSelection();
485  }
486  return false;
487  }
488 
489  if( collector.GetCount() == 1 )
490  {
491  toggleSelection( collector[0] );
492  return true;
493  }
494 
495  // Apply some ugly heuristics to avoid disambiguation menus whenever possible
496  guessSelectionCandidates( collector );
497 
498  if( collector.GetCount() == 1 )
499  {
500  toggleSelection( collector[0] );
501  return true;
502  }
503 
504  // Still more than one item. We're going to have to ask the user.
505  if( aOnDrag )
506  {
508  }
509 
510  BOARD_ITEM* item = disambiguationMenu( &collector );
511 
512  if( item )
513  {
514  toggleSelection( item );
515  return true;
516  }
517  else
518  {
519  if( aSelectionCancelledFlag )
520  *aSelectionCancelledFlag = true;
521 
522  return false;
523  }
524 
525  return false;
526 }
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:107
void ClearReferencePoint()
Definition: selection.h:205
static const KICAD_T AllBoardItems[]
A scan list for all editable board items, like PcbGeneralLocateAndDisplay()
Definition: collectors.h:259
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class&#39;s Inspector method, which does the collection. ...
Definition: collectors.cpp:450
void guessSelectionCandidates(GENERAL_COLLECTOR &aCollector) const
Function guessSelectionCandidates() Tries to guess best selection candidates in case multiple items a...
bool m_additive
Flag saying if items should be added to the current selection or rather replace it.
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:136
bool selectable(const BOARD_ITEM *aItem) const
Function selectable() Checks conditions for an item to be selected.
void toggleSelection(BOARD_ITEM *aItem)
Function toggleSelection() Changes selection status of a given item.
Class TOOL_EVENT.
Definition: tool_event.h:162
BOARD_ITEM * disambiguationMenu(GENERAL_COLLECTOR *aItems)
Function disambiguationMenu() Handles the menu that allows to select one of many items in case there ...
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
bool m_editModules
Definition: pcb_tool.h:142
static const KICAD_T ModuleItems[]
A scan list for primary module items.
Definition: collectors.h:300
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:232
const GENERAL_COLLECTORS_GUIDE getCollectorsGuide() const
BOARD * board() const
Definition: pcb_tool.h:135
int SELECTION_TOOL::selectSameSheet ( const TOOL_EVENT aEvent)
private

Selects all modules belonging to same hierarchical sheet as the selected footprint.

Definition at line 1123 of file pcbnew/tools/selection_tool.cpp.

References clearSelection(), SELECTION::Front(), m_selection, TOOL_BASE::m_toolMgr, mod, PCB_MODULE_T, TOOL_MANAGER::ProcessEvent(), selectAllItemsOnSheet(), selectCursor(), SelectedEvent, and SELECTION::Size().

Referenced by setTransitions().

1124 {
1125  if( !selectCursor( true ) )
1126  return 0;
1127 
1128  // this function currently only supports modules since they are only
1129  // on one sheet.
1130  auto item = m_selection.Front();
1131 
1132  if( !item )
1133  return 0;
1134 
1135  if( item->Type() != PCB_MODULE_T )
1136  return 0;
1137 
1138  auto mod = dynamic_cast<MODULE*>( item );
1139 
1140  clearSelection();
1141 
1142  // get the lowest subsheet name for this.
1143  wxString sheetPath = mod->GetPath();
1144  sheetPath = sheetPath.BeforeLast( '/' );
1145  sheetPath = sheetPath.AfterLast( '/' );
1146 
1147  selectAllItemsOnSheet( sheetPath );
1148 
1149  // Inform other potentially interested tools
1150  if( m_selection.Size() > 0 )
1152 
1153  return 0;
1154 }
EDA_ITEM * Front() const
Definition: selection.h:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
class MODULE, a footprint
Definition: typeinfo.h:89
void selectAllItemsOnSheet(wxString &aSheetpath)
Selects all items with the given sheet timestamp name (the sheet path)
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
bool selectCursor(bool aSelectAlways=false, CLIENT_SELECTION_FILTER aClientFilter=NULL)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
#define mod(a, n)
Definition: greymap.cpp:24
void SELECTION_TOOL::selectVisually ( BOARD_ITEM aItem)
private

Function selectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.

Parameters
aItemis an item to be be marked.

Definition at line 1712 of file pcbnew/tools/selection_tool.cpp.

References KIGFX::VIEW::Hide(), m_selection, PCB_MODULE_T, EDA_ITEM::SetSelected(), EDA_ITEM::Type(), KIGFX::PCB_VIEW::Update(), and PCB_TOOL::view().

Referenced by select().

1713 {
1714  // Hide the original item, so it is shown only on overlay
1715  aItem->SetSelected();
1716  view()->Hide( aItem, true );
1717 
1718  // Modules are treated in a special way - when they are selected, we have to
1719  // unselect all the parts that make the module, not the module itself
1720 
1721  if( aItem->Type() == PCB_MODULE_T )
1722  {
1723  static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* item )
1724  {
1725  item->SetSelected();
1726  view()->Hide( item, true );
1727  });
1728  }
1729 
1730  view()->Update( &m_selection );
1731 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1349
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:81
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
class MODULE, a footprint
Definition: typeinfo.h:89
void SetSelected()
Definition: base_struct.h:256
SELECTION m_selection
Current state of selection.
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

Assigns a context menu and tells when it should be activated.

Parameters
aMenuis the menu to be assigned.
aTriggerdetermines conditions upon which the context menu is activated.

Definition at line 74 of file tool_interactive.cpp.

References CMENU_OFF, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ScheduleContextMenu(), and CONTEXT_MENU::SetTool().

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), disambiguationMenu(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), and TOOL_MENU::ShowContextMenu().

75 {
76  if( aMenu )
77  aMenu->SetTool( this );
78  else
79  aTrigger = CMENU_OFF;
80 
81  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
82 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool&#39;s context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void PCB_TOOL::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

Toggles edit module mode. When enabled, one may select parts of modules individually (graphics, pads, etc.), so they can be modified.

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 92 of file pcb_tool.h.

93  {
94  m_editModules = aEnabled;
95  }
bool m_editModules
Definition: pcb_tool.h:142
void SELECTION_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL.

Definition at line 657 of file pcbnew/tools/selection_tool.cpp.

References ClearSelection(), CursorSelection(), PCB_ACTIONS::expandSelectedConnection, expandSelectedConnection(), PCB_ACTIONS::filterSelection, filterSelection(), find(), PCB_ACTIONS::find, findMove(), PCB_ACTIONS::findMove, TOOL_INTERACTIVE::Go(), Main(), PCB_ACTIONS::selectConnection, selectConnection(), PCB_ACTIONS::selectCopper, selectCopper(), PCB_ACTIONS::selectionActivate, PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionCursor, PCB_ACTIONS::selectionModified, PCB_ACTIONS::selectItem, SelectItem(), PCB_ACTIONS::selectItems, SelectItems(), PCB_ACTIONS::selectNet, selectNet(), PCB_ACTIONS::selectOnSheetFromEeschema, selectOnSheetFromEeschema(), PCB_ACTIONS::selectSameSheet, selectSameSheet(), PCB_ACTIONS::unselectItem, UnselectItem(), PCB_ACTIONS::unselectItems, UnselectItems(), and updateSelection().

658 {
666  Go( &SELECTION_TOOL::find, PCB_ACTIONS::find.MakeEvent() );
676 }
static TOOL_ACTION selectItems
Selects a list of items (specified as the event parameter)
Definition: pcb_actions.h:59
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: pcb_actions.h:47
int UnselectItem(const TOOL_EVENT &aEvent)
Item unselection event handler.
int Main(const TOOL_EVENT &aEvent)
Function Main()
int selectSameSheet(const TOOL_EVENT &aEvent)
Selects all modules belonging to same hierarchical sheet as the selected footprint.
static TOOL_ACTION unselectItem
Unselects an item (specified as the event parameter).
Definition: pcb_actions.h:62
static TOOL_ACTION selectNet
Selects all connections belonging to a single net.
Definition: pcb_actions.h:77
static TOOL_ACTION unselectItems
Unselects a list of items (specified as the event parameter)
Definition: pcb_actions.h:65
int find(const TOOL_EVENT &aEvent)
Find an item.
int findMove(const TOOL_EVENT &aEvent)
Find an item and start moving.
int UnselectItems(const TOOL_EVENT &aEvent)
Multiple item unselection event handler
static TOOL_ACTION selectConnection
Selects a connection between junctions.
Definition: pcb_actions.h:68
int selectConnection(const TOOL_EVENT &aEvent)
Selects a trivial connection (between two junctions) of items in selection
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:111
int selectCopper(const TOOL_EVENT &aEvent)
Selects items with a continuous copper connection to items in selection
int filterSelection(const TOOL_EVENT &aEvent)
Invoke filter dialog and modify current selection
int expandSelectedConnection(const TOOL_EVENT &aEvent)
Expands the current selection to select a connection between two junctions
static TOOL_ACTION find
Find an item.
Definition: pcb_actions.h:395
int updateSelection(const TOOL_EVENT &aEvent)
Event handler to update the selection VIEW_ITEM.
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
int selectOnSheetFromEeschema(const TOOL_EVENT &aEvent)
Selects all modules belonging to same sheet, from Eeschema, using crossprobing
static TOOL_ACTION selectCopper
Selects whole copper connection.
Definition: pcb_actions.h:74
int SelectItem(const TOOL_EVENT &aEvent)
Item selection event handler.
int selectNet(const TOOL_EVENT &aEvent)
Selects all copper connections belonging to the same net(s) as the items in the selection.
static TOOL_ACTION expandSelectedConnection
Expands the current selection to select a connection between two junctions.
Definition: pcb_actions.h:71
static TOOL_ACTION filterSelection
Filters the items in the current selection (invokes dialog)
Definition: pcb_actions.h:86
static TOOL_ACTION selectOnSheetFromEeschema
Selects all components on sheet from Eeschema crossprobing.
Definition: pcb_actions.h:80
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
int SelectItems(const TOOL_EVENT &aEvent)
Multiple item selection event handler
static TOOL_ACTION findMove
Find an item and start moving.
Definition: pcb_actions.h:398
int CursorSelection(const TOOL_EVENT &aEvent)
Select a single item under cursor event handler.
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:50
static TOOL_ACTION selectSameSheet
Selects all components on the same sheet as the selected footprint.
Definition: pcb_actions.h:83
void SELECTION_TOOL::toggleSelection ( BOARD_ITEM aItem)
private

Function toggleSelection() Changes selection status of a given item.

Parameters
aItemis the item to have selection status changed.

Definition at line 399 of file pcbnew/tools/selection_tool.cpp.

References clearSelection(), EDA_DRAW_PANEL_GAL::ForceRefresh(), EDA_DRAW_FRAME::GetGalCanvas(), EDA_ITEM::IsSelected(), m_additive, m_frame, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), select(), selectable(), SelectedEvent, unselect(), and UnselectedEvent.

Referenced by findMove(), and selectPoint().

400 {
401  if( aItem->IsSelected() )
402  {
403  unselect( aItem );
404 
405  // Inform other potentially interested tools
407  }
408  else
409  {
410  if( !m_additive )
411  clearSelection();
412 
413  // Prevent selection of invisible or inactive items
414  if( selectable( aItem ) )
415  {
416  select( aItem );
417 
418  // Inform other potentially interested tools
420  }
421  }
422 
423  if( m_frame )
424  {
426  }
427 }
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
bool m_additive
Flag saying if items should be added to the current selection or rather replace it.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool IsSelected() const
Definition: base_struct.h:250
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
bool selectable(const BOARD_ITEM *aItem) const
Function selectable() Checks conditions for an item to be selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
void SELECTION_TOOL::unselect ( BOARD_ITEM aItem)
private

Function unselect() Takes necessary action mark an item as unselected.

Parameters
aItemis an item to be unselected.

Definition at line 1693 of file pcbnew/tools/selection_tool.cpp.

References SELECTION::Empty(), EDA_ITEM::IsSelected(), m_frame, m_locked, m_selection, SELECTION::Remove(), PCB_BASE_FRAME::SetCurItem(), and unselectVisually().

Referenced by RequestSelection(), SanitizeSelection(), selectMultiple(), toggleSelection(), UnselectItem(), and UnselectItems().

1694 {
1695  if( !aItem->IsSelected() )
1696  return;
1697 
1698  m_selection.Remove( aItem );
1699  unselectVisually( aItem );
1700 
1701  if( m_selection.Empty() )
1702  {
1703  if( m_frame )
1704  {
1705  m_frame->SetCurItem( NULL );
1706  }
1707  m_locked = true;
1708  }
1709 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
bool IsSelected() const
Definition: base_struct.h:250
void unselectVisually(BOARD_ITEM *aItem)
Function unselectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
bool m_locked
Can other tools modify locked items.
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
int SELECTION_TOOL::UnselectItem ( const TOOL_EVENT aEvent)

Item unselection event handler.

Definition at line 806 of file pcbnew/tools/selection_tool.cpp.

References TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), TOOL_MANAGER::ProcessEvent(), unselect(), and UnselectedEvent.

Referenced by setTransitions().

807 {
808  // Check if there is an item to be selected
809  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
810 
811  if( item )
812  {
813  unselect( item );
814 
815  // Inform other potentially interested tools
817  }
818 
819  return 0;
820 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
int SELECTION_TOOL::UnselectItems ( const TOOL_EVENT aEvent)

Multiple item unselection event handler

Definition at line 786 of file pcbnew/tools/selection_tool.cpp.

References TOOL_BASE::m_toolMgr, TOOL_EVENT::Parameter(), TOOL_MANAGER::ProcessEvent(), unselect(), and UnselectedEvent.

Referenced by setTransitions().

787 {
788  std::vector<BOARD_ITEM*>* items = aEvent.Parameter<std::vector<BOARD_ITEM*>*>();
789 
790  if( items )
791  {
792  // Perform individual unselection of each item
793  // before processing the event
794  for( auto item : *items )
795  {
796  unselect( item );
797  }
798 
800  }
801 
802  return 0;
803 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:378
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
void SELECTION_TOOL::unselectVisually ( BOARD_ITEM aItem)
private

Function unselectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.

Parameters
aItemis an item to be be marked.

Definition at line 1734 of file pcbnew/tools/selection_tool.cpp.

References EDA_ITEM::ClearSelected(), KIGFX::VIEW::Hide(), m_selection, PCB_MODULE_T, EDA_ITEM::Type(), KIGFX::PCB_VIEW::Update(), and PCB_TOOL::view().

Referenced by clearSelection(), and unselect().

1735 {
1736  // Restore original item visibility
1737  aItem->ClearSelected();
1738  view()->Hide( aItem, false );
1739  view()->Update( aItem );
1740 
1741  // Modules are treated in a special way - when they are selected, we have to
1742  // unselect all the parts that make the module, not the module itself
1743 
1744  if( aItem->Type() == PCB_MODULE_T )
1745  {
1746  static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* item )
1747  {
1748  item->ClearSelected();
1749  view()->Hide( item, false );
1750  view()->Update( item );
1751  });
1752  }
1753 
1754  view()->Update( &m_selection );
1755 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1349
KICAD_T Type() const
Function Type()
Definition: base_struct.h:227
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:81
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void ClearSelected()
Definition: base_struct.h:260
class MODULE, a footprint
Definition: typeinfo.h:89
SELECTION m_selection
Current state of selection.
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
int SELECTION_TOOL::updateSelection ( const TOOL_EVENT aEvent)
private

Event handler to update the selection VIEW_ITEM.

Definition at line 2102 of file pcbnew/tools/selection_tool.cpp.

References TOOL_BASE::getView(), m_selection, and KIGFX::VIEW::Update().

Referenced by setTransitions().

2103 {
2104  getView()->Update( &m_selection );
2105 
2106  return 0;
2107 }
SELECTION m_selection
Current state of selection.
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1382
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

Suspends execution of the tool until an event specified in aEventList arrives. No parameters means waiting for any event.

Definition at line 55 of file tool_interactive.cpp.

References TOOL_BASE::m_toolMgr, and TOOL_MANAGER::ScheduleWait().

Referenced by PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectMultiple(), selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT< TOOL_EVENT > ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses execution of a given tool until one or more events matching aConditions arrives.
void SELECTION_TOOL::zoomFitSelection ( void  )

Zooms the screen to center and fit the current selection.

Definition at line 1084 of file pcbnew/tools/selection_tool.cpp.

References KIGFX::PCB_VIEW::Add(), PCB_TOOL::canvas(), EDA_DRAW_PANEL_GAL::ForceRefresh(), EDA_DRAW_FRAME::GetGalCanvas(), KIGFX::VIEW::GetScale(), TOOL_BASE::getView(), m_frame, m_selection, max, scale, KIGFX::VIEW::SetCenter(), KIGFX::VIEW::SetScale(), KIGFX::VIEW::ToWorld(), PCB_TOOL::view(), SELECTION::ViewBBox(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by selectOnSheetFromEeschema().

1085 {
1086  //Should recalculate the view to zoom in on the selection
1087  auto selectionBox = m_selection.ViewBBox();
1088  auto canvas = m_frame->GetGalCanvas();
1089  auto view = getView();
1090 
1091  VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
1092 
1093  if( !( selectionBox.GetWidth() == 0 ) || !( selectionBox.GetHeight() == 0 ) )
1094  {
1095  VECTOR2D vsize = selectionBox.GetSize();
1096  double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
1097  fabs( vsize.y / screenSize.y ) );
1098  view->SetScale( scale );
1099  view->SetCenter( selectionBox.Centre() );
1100  view->Add( &m_selection );
1101  }
1102 
1104 }
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Function ToWorld() Converts a screen space point/vector to a point/vector in world space coordinates...
Definition: view.cpp:438
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:247
PCB_DRAW_PANEL_GAL * canvas() const
Definition: pcb_tool.cpp:213
const BOX2I ViewBBox() const override
Function ViewBBox() Returns the bounding box for all stored items covering all its layers...
Definition: selection.cpp:132
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:562
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
const int scale
#define max(a, b)
Definition: auxiliary.h:86
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:132
double GetScale() const
Function GetScale()
Definition: view.h:265
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:882
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:48

Member Data Documentation

const TOOL_EVENT SELECTION_TOOL::ClearedEvent
static

Event sent after selection is cleared.

Definition at line 137 of file pcbnew/tools/selection_tool.h.

Referenced by clearSelection(), POINT_EDITOR::OnSelectionChange(), SanitizeSelection(), and PCB_EDITOR_CONTROL::setTransitions().

bool SELECTION_TOOL::m_additive
private

Flag saying if items should be added to the current selection or rather replace it.

Definition at line 345 of file pcbnew/tools/selection_tool.h.

Referenced by Main(), selectMultiple(), selectPoint(), and toggleSelection().

PCB_BASE_FRAME* SELECTION_TOOL::m_frame
private
bool SELECTION_TOOL::m_locked
private

Can other tools modify locked items.

Definition at line 354 of file pcbnew/tools/selection_tool.h.

Referenced by CheckLock(), clearSelection(), RequestSelection(), Reset(), and unselect().

TOOL_MENU SELECTION_TOOL::m_menu
private

Menu model displayed by the tool.

Definition at line 357 of file pcbnew/tools/selection_tool.h.

Referenced by Init(), and Main().

bool SELECTION_TOOL::m_multiple
private

Flag saying if multiple selection mode is active.

Definition at line 351 of file pcbnew/tools/selection_tool.h.

Referenced by selectable(), and selectMultiple().

std::unique_ptr<PRIV> SELECTION_TOOL::m_priv
private

Definition at line 360 of file pcbnew/tools/selection_tool.h.

Referenced by filterSelection().

bool SELECTION_TOOL::m_subtractive
private

Flag saying if items should be removed from the current selection.

Definition at line 348 of file pcbnew/tools/selection_tool.h.

Referenced by Main(), and selectMultiple().

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Unique identifier for the tool, assigned by a TOOL_MANAGER instance.

Definition at line 210 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::IsToolActive(), and EDIT_TOOL::updateModificationPoint().

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), GERBVIEW_SELECTION_TOOL::clearSelection(), clearSelection(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), findCallback(), findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), PICKER_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), GERBVIEW_SELECTION_TOOL::RequestSelection(), RequestSelection(), TOOL_INTERACTIVE::resetTransitions(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SanitizeSelection(), selectCopper(), PCB_TOOL::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), selectMultiple(), selectNet(), selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), GERBVIEW_SELECTION_TOOL::toggleSelection(), toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GERBVIEW_SELECTION_TOOL::UnselectItem(), UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), UnselectItems(), EDIT_TOOL::updateModificationPoint(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName

(eg. pcbnew.InteractiveSelection).

Definition at line 214 of file tool_base.h.

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

Referenced by TOOL_BASE::attachManager().

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.

const TOOL_EVENT SELECTION_TOOL::UnselectedEvent
static

The documentation for this class was generated from the following files: