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)
 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 UnselectItem (const TOOL_EVENT &aEvent)
 

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 ()
 

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

using ITEM_CREATOR = std::function< std::unique_ptr< BOARD_ITEM >(const TOOL_EVENT &aEvt) >
 Callable that returns a new board item. More...
 

Protected Member Functions

void doInteractiveItemPlacement (ITEM_CREATOR aItemCreator, const wxString &aCommitMessage)
 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::VIEWview () const
 
PCB_EDIT_FRAMEframe () const
 
BOARDboard () const
 
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)
 Function selectPoint() Selects an item pointed by the parameter aWhere. More...
 
bool selectCursor (bool aSelectAlways=false)
 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 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...
 

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_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 60 of file selection_tool.h.

Member Typedef Documentation

using PCB_TOOL::ITEM_CREATOR = std::function< std::unique_ptr< BOARD_ITEM >( const TOOL_EVENT& aEvt ) >
protectedinherited

Callable that returns a new board item.

The event that triggered it is provided, so you can check modifier keys, position, etc, if required

Definition at line 91 of file pcb_tool.h.

Member Enumeration Documentation

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 166 of file selection_tool.cpp.

166  :
167  PCB_TOOL( "pcbnew.InteractiveSelection" ),
168  m_frame( NULL ), m_additive( false ), m_multiple( false ),
169  m_locked( true ), m_menu( *this ),
170  m_priv( std::make_unique<PRIV>() )
171 {
172 
173 }
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:52
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
TOOL_MENU m_menu
Menu model displayed by the tool.
bool m_locked
Can other tools modify locked items.
SELECTION_TOOL::~SELECTION_TOOL ( )

Definition at line 176 of file selection_tool.cpp.

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

177 {
178  getView()->Remove( &m_selection );
179 }
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
SELECTION m_selection
Current state of selection.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30

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 MODULE_EDITOR_TOOLS::CopyItems(), 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(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), and ROUTER_TOOL::SettingsDialog().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
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...
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 54 of file tool_base.cpp.

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

Referenced by TOOL_MANAGER::RegisterTool().

55 {
56  m_toolMgr = aManager;
57  m_toolSettings = TOOL_SETTINGS( this );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
friend class TOOL_SETTINGS
Definition: tool_base.h:160
SELECTION_LOCK_FLAGS SELECTION_TOOL::CheckLock ( )

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

Definition at line 559 of file 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(), EDIT_TOOL::Remove(), and EDIT_TOOL::Rotate().

560 {
561  if( !m_locked || m_editModules )
562  return SELECTION_UNLOCKED;
563 
564  bool containsLocked = false;
565 
566  // Check if the selection contains locked items
567  for( const auto& item : m_selection )
568  {
569  switch( item->Type() )
570  {
571  case PCB_MODULE_T:
572  if( static_cast<MODULE*>( item )->IsLocked() )
573  containsLocked = true;
574  break;
575 
576  case PCB_MODULE_EDGE_T:
577  case PCB_MODULE_TEXT_T:
578  if( static_cast<MODULE*>( item->GetParent() )->IsLocked() )
579  containsLocked = true;
580  break;
581 
582  default: // suppress warnings
583  break;
584  }
585  }
586 
587  if( containsLocked )
588  {
589  if( IsOK( m_frame, _( "Selection contains locked items. Do you want to continue?" ) ) )
590  {
591  m_locked = false;
593  }
594  else
595  return SELECTION_LOCKED;
596  }
597 
598  m_locked = false;
599 
600  return SELECTION_UNLOCKED;
601 }
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
class MODULE, a footprint
Definition: typeinfo.h:101
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
bool m_editModules
Definition: pcb_tool.h:112
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
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:111
int SELECTION_TOOL::ClearSelection ( const TOOL_EVENT aEvent)

Clear current selection event handler.

Definition at line 626 of file selection_tool.cpp.

References clearSelection().

Referenced by SetTransitions().

627 {
628  clearSelection();
629 
630  return 0;
631 }
void clearSelection()
Function clearSelection() Clears the current selection.
void SELECTION_TOOL::clearSelection ( )
private

Function clearSelection() Clears the current selection.

Definition at line 1123 of file 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(), selectMultiple(), selectOnSheetFromEeschema(), selectPoint(), selectSameSheet(), and toggleSelection().

1124 {
1125  if( m_selection.Empty() )
1126  return;
1127 
1128  for( auto item : m_selection )
1129  unselectVisually( static_cast<BOARD_ITEM*>( item ) );
1130 
1131  m_selection.Clear();
1132 
1133  m_frame->SetCurItem( NULL );
1134  m_locked = true;
1135 
1136  // Inform other potentially interested tools
1138 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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.
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.
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
int SELECTION_TOOL::CursorSelection ( const TOOL_EVENT aEvent)

Select a single item under cursor event handler.

Definition at line 604 of file selection_tool.cpp.

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

Referenced by SetTransitions().

605 {
606  bool sanitize = (bool) aEvent.Parameter<intptr_t>();
607 
608  if( m_selection.Empty() ) // Try to find an item that could be modified
609  {
610  selectCursor( true );
611 
612  if( CheckLock() == SELECTION_LOCKED )
613  {
614  clearSelection();
615  return 0;
616  }
617  }
618 
619  if( sanitize )
621 
622  return 0;
623 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
bool selectCursor(bool aSelectAlways=false)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
SELECTION_LOCK_FLAGS CheckLock()
Checks if the user has agreed to modify locked items for the given selection.
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:373
bool SanitizeSelection()
Makes sure a group selection does not contain items that would cause conflicts when moving/rotating t...
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 1141 of file selection_tool.cpp.

References KIGFX::VIEW::Add(), CONTEXT_MENU::Add(), EDA_ITEM::ClearBrightened(), CMENU_NOW, CONTEXT_MENU::DisplayTitle(), KIGFX::GEOMETRY, COLLECTOR::GetCount(), EDA_ITEM::GetSelectMenuText(), TOOL_BASE::getView(), EDA_ITEM::IsBrightened(), KIGFX::VIEW::MarkTargetDirty(), min, KIGFX::VIEW::Remove(), EDA_ITEM::SetBrightened(), TOOL_INTERACTIVE::SetContextMenu(), BRIGHT_BOX::SetItem(), CONTEXT_MENU::SetTitle(), KIGFX::VIEW::SetVisible(), TA_CONTEXT_MENU_CHOICE, TA_CONTEXT_MENU_UPDATE, KIGFX::TARGET_OVERLAY, KIGFX::VIEW::Update(), and TOOL_INTERACTIVE::Wait().

Referenced by selectPoint().

1142 {
1143  BOARD_ITEM* current = NULL;
1144  PCB_BRIGHT_BOX brightBox;
1145  CONTEXT_MENU menu;
1146 
1147  getView()->Add( &brightBox );
1148 
1149  int limit = std::min( 10, aCollector->GetCount() );
1150 
1151  for( int i = 0; i < limit; ++i )
1152  {
1153  wxString text;
1154  BOARD_ITEM* item = ( *aCollector )[i];
1155  text = item->GetSelectMenuText();
1156  menu.Add( text, i + 1 );
1157  }
1158 
1159  menu.SetTitle( _( "Clarify selection" ) );
1160  menu.DisplayTitle( true );
1161  SetContextMenu( &menu, CMENU_NOW );
1162 
1163  while( OPT_TOOL_EVENT evt = Wait() )
1164  {
1165  if( evt->Action() == TA_CONTEXT_MENU_UPDATE )
1166  {
1167  if( current )
1168  current->ClearBrightened();
1169 
1170  int id = *evt->GetCommandId();
1171 
1172  // User has pointed an item, so show it in a different way
1173  if( id > 0 && id <= limit )
1174  {
1175  current = ( *aCollector )[id - 1];
1176  current->SetBrightened();
1177  }
1178  else
1179  {
1180  current = NULL;
1181  }
1182  }
1183  else if( evt->Action() == TA_CONTEXT_MENU_CHOICE )
1184  {
1185  boost::optional<int> id = evt->GetCommandId();
1186 
1187  // User has selected an item, so this one will be returned
1188  if( id && ( *id > 0 ) )
1189  current = ( *aCollector )[*id - 1];
1190  else
1191  current = NULL;
1192 
1193  break;
1194  }
1195 
1196  // Draw a mark to show which item is available to be selected
1197  if( current && current->IsBrightened() )
1198  {
1199  brightBox.SetItem( current );
1200  getView()->SetVisible( &brightBox, true );
1201 // getView()->Hide( &brightBox, false );
1202  getView()->Update( &brightBox, KIGFX::GEOMETRY );
1204  }
1205  }
1206 
1207  getView()->Remove( &brightBox );
1208 
1209 
1210  return current;
1211 }
bool IsBrightened() const
Definition: base_struct.h:224
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
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
void SetBrightened()
Definition: base_struct.h:229
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:233
void SetItem(EDA_ITEM *aItem)
Definition: bright_box.cpp:61
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:575
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
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
Class PCB_BRIGHT_BOX.
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the context menu.
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Function SetVisible() Sets the item visibility.
Definition: view.cpp:1330
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
void DisplayTitle(bool aDisplay=true)
Function DisplayTitle() Decides whether a title for a pop up menu should be displayed.
#define min(a, b)
Definition: auxiliary.h:85
Color has changed.
Definition: view_item.h:57
void PCB_TOOL::doInteractiveItemPlacement ( ITEM_CREATOR  aItemCreator,
const wxString &  aCommitMessage 
)
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::VIEW_GROUP::Add(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), PCB_MODULE_T, BOARD_COMMIT::Push(), KIGFX::VIEW_GROUP::Remove(), SELECTION::Remove(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, KIGFX::VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint().

41 {
42  using namespace std::placeholders;
43 
44  KIGFX::VIEW& view = *getView();
46  auto& frame = *getEditFrame<PCB_EDIT_FRAME>();
47 
48  std::unique_ptr<BOARD_ITEM> newItem;
49 
50  Activate();
51 
52  BOARD_COMMIT commit( &frame );
53 
55 
56  // do not capture or auto-pan until we start placing an item
57  controls.ShowCursor( true );
58  controls.SetSnapping( true );
59 
60  // Add a VIEW_GROUP that serves as a preview for the new item
61  SELECTION preview;
62  view.Add( &preview );
63 
64  // Main loop: keep receiving events
65  while( OPT_TOOL_EVENT evt = Wait() )
66  {
67  VECTOR2I cursorPos = controls.GetCursorPosition();
68 
70  {
71  if( newItem )
72  {
73  // Delete the old item and have another try
74  newItem = nullptr;
75 
76  preview.Clear();
77 
78  controls.SetAutoPan( false );
79  controls.CaptureCursor( false );
80  controls.ShowCursor( true );
81  }
82  else
83  {
84  break;
85  }
86 
87  if( evt->IsActivate() ) // now finish unconditionally
88  break;
89  }
90 
91  else if( evt->IsClick( BUT_LEFT ) )
92  {
93  if( !newItem )
94  {
95  // create the item if possible
96  newItem = aItemCreator( *evt );
97 
98  // no item created, so wait for another click
99  if( !newItem )
100  continue;
101 
102  controls.CaptureCursor( true );
103  controls.SetAutoPan( true );
104 
105  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
106 
107  preview.Add( newItem.get() );
108 
109  if( newItem->Type() == PCB_MODULE_T )
110  {
111  auto module = dyn_cast<MODULE*>( newItem.get() );
112 
113  // modules have more drawable parts
114  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
115  }
116  }
117  else
118  {
119  newItem->ClearFlags();
120  preview.Remove( newItem.get() );
121 
122  if( newItem->Type() == PCB_MODULE_T )
123  {
124  auto module = dyn_cast<MODULE*>( newItem.get() );
125  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
126  }
127 
128  commit.Add( newItem.release() );
129  commit.Push( aCommitMessage );
130 
131  controls.CaptureCursor( false );
132  controls.SetAutoPan( false );
133  controls.ShowCursor( true );
134  }
135  }
136 
137  else if( newItem && evt->Category() == TC_COMMAND )
138  {
139  /*
140  * Handle any events that can affect the item as we move
141  * it around, eg rotate and flip
142  */
143 
144  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
145  {
146  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
147  frame, *evt );
148  newItem->Rotate( newItem->GetPosition(), rotationAngle );
149  view.Update( &preview );
150  }
151  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
152  {
153  newItem->Flip( newItem->GetPosition() );
154  view.Update( &preview );
155  }
156  }
157 
158  else if( newItem && evt->IsMotion() )
159  {
160  // track the cursor
161  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
162 
163  // Show a preview of the item
164  view.Update( &preview );
165  }
166  }
167 
168  view.Remove( &preview );
169 }
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.
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
void RunOnChildren(std::function< void(BOARD_ITEM *)> aFunction)
Function RunOnChildren.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
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
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
class MODULE, a footprint
Definition: typeinfo.h:101
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:109
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
Definition: view_controls.h:94
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
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
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:36
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:90
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.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
Class VIEW.
Definition: view.h:58
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 78 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

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

79  {
80  return m_editModules;
81  }
bool m_editModules
Definition: pcb_tool.h:112
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::filterSelection ( const TOOL_EVENT aEvent)
private

Invoke filter dialog and modify current selection

Definition at line 1088 of file selection_tool.cpp.

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

Referenced by SetTransitions().

1089 {
1090  auto& opts = m_priv->m_filterOpts;
1091  DIALOG_BLOCK_OPTIONS dlg( m_frame, opts, false, _( "Filter selection" ) );
1092 
1093  const int cmd = dlg.ShowModal();
1094 
1095  if( cmd != wxID_OK )
1096  return 0;
1097 
1098  const auto& board = *getModel<BOARD>();
1099  const auto layerMask = getFilteredLayerSet( opts );
1100 
1101  // copy current selection
1102  auto selection = m_selection.GetItems();
1103 
1104  // clear current selection
1105  clearSelection();
1106 
1107  // copy selection items from the saved selection
1108  // according to the dialog options
1109  for( auto i : selection )
1110  {
1111  auto item = static_cast<BOARD_ITEM*>( i );
1112  bool include = itemIsIncludedByFilter( *item, board, layerMask, opts );
1113 
1114  if( include )
1115  {
1116  select( item );
1117  }
1118  }
1119  return 0;
1120 }
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.
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:110
int SELECTION_TOOL::find ( const TOOL_EVENT aEvent)
private

Find an item.

Definition at line 960 of file selection_tool.cpp.

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

Referenced by SetTransitions().

961 {
962  DIALOG_FIND dlg( m_frame );
963  dlg.EnableWarp( false );
964  dlg.SetCallback( std::bind( &SELECTION_TOOL::findCallback, this, _1 ) );
965  dlg.ShowModal();
966 
967  return 0;
968 }
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 941 of file 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().

942 {
943  clearSelection();
944 
945  if( aItem )
946  {
947  select( aItem );
948  EDA_RECT bbox = aItem->GetBoundingBox();
949  BOX2D viewport( VECTOR2D( bbox.GetOrigin() ), VECTOR2D( bbox.GetSize() ) );
950  getView()->SetViewport( viewport );
951 
952  // Inform other potentially interested tools
954  }
955 
957 }
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:512
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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.
const wxPoint & GetOrigin() const
VECTOR2< double > VECTOR2D
Definition: vector2d.h:579
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:30
Class EDA_RECT handles the component boundary box.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:803
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
const wxSize & GetSize() const
int SELECTION_TOOL::findMove ( const TOOL_EVENT aEvent)
private

Find an item and start moving.

Definition at line 971 of file selection_tool.cpp.

References clearSelection(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_BASE_FRAME::GetFootprintFromBoardByReference(), MODULE::GetPosition(), TOOL_BASE::getViewControls(), TOOL_MANAGER::InvokeTool(), m_frame, TOOL_BASE::m_toolMgr, and toggleSelection().

Referenced by SetTransitions().

972 {
974 
975  if( module )
976  {
977  clearSelection();
978  toggleSelection( module );
979 
980  // Place event on module origin first, so the generic anchor snap
981  // doesn't just choose the closest pin for us
982  // Don't warp the view - we want the component to
983  // "teleport" to cursor, not move to the components position
984  getViewControls()->ForceCursorPosition( true, module->GetPosition() );
985 
986  // pick the component up and start moving
987  m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
988  }
989 
990  return 0;
991 }
const wxPoint & GetPosition() const override
Definition: class_module.h:143
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
void toggleSelection(BOARD_ITEM *aItem)
Function toggleSelection() Changes selection status of a given item.
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
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:36
MODULE * GetFootprintFromBoardByReference()
Function GetFootprintFromBoardByReference.
Definition: modules.cpp:60
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

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

Definition at line 193 of file tool_base.h.

References TOOL_BASE::getEditFrameInt().

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

194  {
195  return static_cast<T*>( getEditFrameInt() );
196  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:42
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.

References TOOL_BASE::m_toolId.

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

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:215
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.

References TOOL_BASE::m_toolMgr.

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

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 204 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

205  {
206  EDA_ITEM* m = getModelInt();
207 
208  return static_cast<T*>( m );
209  }
T
enum T contains all this lexer's tokens.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:48
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.

References TOOL_BASE::m_toolName.

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:219
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 72 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

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

73 {
74  return m_toolSettings;
75 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
TOOL_MENU& SELECTION_TOOL::GetToolMenu ( )
inline

Definition at line 95 of file selection_tool.h.

References m_menu.

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

96  {
97  return m_menu;
98  }
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.

References TOOL_BASE::m_type.

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

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:212
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 30 of file tool_base.cpp.

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

Referenced by PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), PCBNEW_CONTROL::HighContrastMode(), PNS::TOOL_BASE::highlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EDIT_TOOL::Main(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), MODULE_EDITOR_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), Reset(), selectable(), selectionContains(), selectMultiple(), ZOOM_TOOL::selectRegion(), PCBNEW_CONTROL::TrackDisplayMode(), POINT_EDITOR::updateEditedPoint(), PNS::TOOL_BASE::updateEndItem(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneUnfill(), PCB_EDITOR_CONTROL::ZoneUnfillAll(), COMMON_TOOLS::ZoomFitScreen(), zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), and ~SELECTION_TOOL().

31 {
32  return m_toolMgr->GetView();
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:243
KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited
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 122 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::Reset(), ZOOM_TOOL::SetTransitions(), LENGTH_TUNER_TOOL::SetTransitions(), ROUTER_TOOL::SetTransitions(), PAD_TOOL::SetTransitions(), MICROWAVE_TOOL::SetTransitions(), POINT_EDITOR::SetTransitions(), COMMON_TOOLS::SetTransitions(), PLACEMENT_TOOL::SetTransitions(), PCBNEW_CONTROL::SetTransitions(), MODULE_EDITOR_TOOLS::SetTransitions(), PICKER_TOOL::SetTransitions(), PCB_EDITOR_CONTROL::SetTransitions(), SetTransitions(), EDIT_TOOL::SetTransitions(), and DRAWING_TOOL::SetTransitions().

124 {
125  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
126 
127  goInternal( sptr, aConditions );
128 }
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 1537 of file selection_tool.cpp.

References COLLECTOR::Append(), B_SilkS, calcArea(), calcCommonArea(), calcMaxArea(), calcMinArea(), calcRatio(), COLLECTOR::CountType(), COLLECTOR::Empty(), F_SilkS, PCB_BASE_FRAME::GetActiveLayer(), COLLECTOR::GetCount(), BOARD_ITEM::GetLayer(), m_frame, 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(), and EDA_ITEM::Type().

Referenced by selectPoint().

1538 {
1539  std::set<BOARD_ITEM*> rejected;
1540 
1541  const double footprintAreaRatio = 0.2;
1542  const double modulePadMinCoverRatio = 0.45;
1543  const double padViaAreaRatio = 0.5;
1544  const double trackViaLengthRatio = 2.0;
1545  const double trackTrackLengthRatio = 0.3;
1546  const double textToFeatureMinRatio = 0.2;
1547  const double textToFootprintMinRatio = 0.4;
1548  // If the common area of two compared items is above the following threshold, they cannot
1549  // be rejected (it means they overlap and it might be hard to pick one by selecting
1550  // its unique area).
1551  const double commonAreaRatio = 0.6;
1552 
1553  LAYER_ID actLayer = m_frame->GetActiveLayer();
1554 
1555  LSET silkLayers( 2, B_SilkS, F_SilkS );
1556 
1557  if( silkLayers[actLayer] )
1558  {
1559  std::set<BOARD_ITEM*> preferred;
1560 
1561  for( int i = 0; i < aCollector.GetCount(); ++i )
1562  {
1563  BOARD_ITEM* item = aCollector[i];
1564  KICAD_T type = item->Type();
1565 
1566  if( ( type == PCB_MODULE_TEXT_T || type == PCB_TEXT_T || type == PCB_LINE_T )
1567  && silkLayers[item->GetLayer()] )
1568  {
1569  preferred.insert( item );
1570  }
1571  }
1572 
1573  if( preferred.size() != 0 )
1574  {
1575  aCollector.Empty();
1576 
1577  for( BOARD_ITEM* item : preferred )
1578  aCollector.Append( item );
1579  return;
1580  }
1581  }
1582 
1583  if( aCollector.CountType( PCB_MODULE_TEXT_T ) > 0 )
1584  {
1585  for( int i = 0; i < aCollector.GetCount(); ++i )
1586  {
1587  if( TEXTE_MODULE* txt = dyn_cast<TEXTE_MODULE*>( aCollector[i] ) )
1588  {
1589  double textArea = calcArea( txt );
1590 
1591  for( int j = 0; j < aCollector.GetCount(); ++j )
1592  {
1593  if( i == j )
1594  continue;
1595 
1596  BOARD_ITEM* item = aCollector[j];
1597  double itemArea = calcArea( item );
1598  double areaRatio = calcRatio( textArea, itemArea );
1599  double commonArea = calcCommonArea( txt, item );
1600  double itemCommonRatio = calcRatio( commonArea, itemArea );
1601  double txtCommonRatio = calcRatio( commonArea, textArea );
1602 
1603  if( item->Type() == PCB_MODULE_T && areaRatio < textToFootprintMinRatio &&
1604  itemCommonRatio < commonAreaRatio )
1605  rejected.insert( item );
1606 
1607  switch( item->Type() )
1608  {
1609  case PCB_TRACE_T:
1610  case PCB_PAD_T:
1611  case PCB_LINE_T:
1612  case PCB_VIA_T:
1613  case PCB_MODULE_T:
1614  if( areaRatio > textToFeatureMinRatio && txtCommonRatio < commonAreaRatio )
1615  rejected.insert( txt );
1616  break;
1617  default:
1618  break;
1619  }
1620  }
1621  }
1622  }
1623  }
1624 
1625  if( aCollector.CountType( PCB_MODULE_T ) > 0 )
1626  {
1627  double minArea = calcMinArea( aCollector, PCB_MODULE_T );
1628  double maxArea = calcMaxArea( aCollector, PCB_MODULE_T );
1629 
1630  if( calcRatio( minArea, maxArea ) <= footprintAreaRatio )
1631  {
1632  for( int i = 0; i < aCollector.GetCount(); ++i )
1633  {
1634  if( MODULE* mod = dyn_cast<MODULE*>( aCollector[i] ) )
1635  {
1636  double normalizedArea = calcRatio( calcArea( mod ), maxArea );
1637 
1638  if( normalizedArea > footprintAreaRatio )
1639  rejected.insert( mod );
1640  }
1641  }
1642  }
1643  }
1644 
1645  if( aCollector.CountType( PCB_PAD_T ) > 0 )
1646  {
1647  for( int i = 0; i < aCollector.GetCount(); ++i )
1648  {
1649  if( D_PAD* pad = dyn_cast<D_PAD*>( aCollector[i] ) )
1650  {
1651  double ratio = pad->GetParent()->PadCoverageRatio();
1652 
1653  if( ratio < modulePadMinCoverRatio )
1654  rejected.insert( pad->GetParent() );
1655  }
1656  }
1657  }
1658 
1659  if( aCollector.CountType( PCB_VIA_T ) > 0 )
1660  {
1661  for( int i = 0; i < aCollector.GetCount(); ++i )
1662  {
1663  if( VIA* via = dyn_cast<VIA*>( aCollector[i] ) )
1664  {
1665  double viaArea = calcArea( via );
1666 
1667  for( int j = 0; j < aCollector.GetCount(); ++j )
1668  {
1669  if( i == j )
1670  continue;
1671 
1672  BOARD_ITEM* item = aCollector[j];
1673  double areaRatio = calcRatio( viaArea, calcArea( item ) );
1674 
1675  if( item->Type() == PCB_MODULE_T && areaRatio < modulePadMinCoverRatio )
1676  rejected.insert( item );
1677 
1678  if( item->Type() == PCB_PAD_T && areaRatio < padViaAreaRatio )
1679  rejected.insert( item );
1680 
1681  if( TRACK* track = dyn_cast<TRACK*>( item ) )
1682  {
1683  if( track->GetNetCode() != via->GetNetCode() )
1684  continue;
1685 
1686  double lenRatio = (double) ( track->GetLength() + track->GetWidth() ) /
1687  (double) via->GetWidth();
1688 
1689  if( lenRatio > trackViaLengthRatio )
1690  rejected.insert( track );
1691  }
1692  }
1693  }
1694  }
1695  }
1696 
1697  int nTracks = aCollector.CountType( PCB_TRACE_T );
1698 
1699  if( nTracks > 0 )
1700  {
1701  double maxLength = 0.0;
1702  double minLength = std::numeric_limits<double>::max();
1703  double maxArea = 0.0;
1704  const TRACK* maxTrack = nullptr;
1705 
1706  for( int i = 0; i < aCollector.GetCount(); ++i )
1707  {
1708  if( TRACK* track = dyn_cast<TRACK*>( aCollector[i] ) )
1709  {
1710  maxLength = std::max( track->GetLength(), maxLength );
1711  maxLength = std::max( (double) track->GetWidth(), maxLength );
1712 
1713  minLength = std::min( std::max( track->GetLength(), (double) track->GetWidth() ), minLength );
1714 
1715  double area = track->GetLength() * track->GetWidth();
1716 
1717  if( area > maxArea )
1718  {
1719  maxArea = area;
1720  maxTrack = track;
1721  }
1722  }
1723  }
1724 
1725  if( maxLength > 0.0 && minLength / maxLength < trackTrackLengthRatio && nTracks > 1 )
1726  {
1727  for( int i = 0; i < aCollector.GetCount(); ++i )
1728  {
1729  if( TRACK* track = dyn_cast<TRACK*>( aCollector[i] ) )
1730  {
1731  double ratio = std::max( (double) track->GetWidth(), track->GetLength() ) / maxLength;
1732 
1733  if( ratio > trackTrackLengthRatio )
1734  rejected.insert( track );
1735  }
1736  }
1737  }
1738 
1739  for( int j = 0; j < aCollector.GetCount(); ++j )
1740  {
1741  if( MODULE* mod = dyn_cast<MODULE*>( aCollector[j] ) )
1742  {
1743  double ratio = calcRatio( maxArea, mod->GetFootprintRect().GetArea() );
1744 
1745  if( ratio < modulePadMinCoverRatio && calcCommonArea( maxTrack, mod ) < commonAreaRatio )
1746  rejected.insert( mod );
1747  }
1748  }
1749  }
1750 
1751  if( (unsigned) aCollector.GetCount() > rejected.size() ) // do not remove everything
1752  {
1753  for( BOARD_ITEM* item : rejected )
1754  {
1755  aCollector.Remove( item );
1756  }
1757  }
1758 }
void Empty()
Function Empty sets the list to empty.
int GetCount() const
Function GetCount returns the number of objects in the list.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
static double calcCommonArea(const BOARD_ITEM *aItem, const BOARD_ITEM *aOther)
virtual LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:104
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
int CountType(KICAD_T aType)
Function CountType counts the number of items matching aType.
static double calcArea(const BOARD_ITEM *aItem)
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
class MODULE, a footprint
Definition: typeinfo.h:101
Class LSET is a set of LAYER_IDs.
static double calcMaxArea(GENERAL_COLLECTOR &aCollector, KICAD_T aType)
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
#define max(a, b)
Definition: auxiliary.h:86
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
double calcRatio(double a, double b)
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
#define mod(a, n)
Definition: greymap.cpp:24
#define min(a, b)
Definition: auxiliary.h:85
static double calcMinArea(GENERAL_COLLECTOR &aCollector, KICAD_T aType)
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 182 of file selection_tool.cpp.

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

183 {
184  auto selectMenu = std::make_shared<SELECT_MENU>();
185  selectMenu->SetTool( this );
186  m_menu.AddSubMenu( selectMenu );
187 
188  auto& menu = m_menu.GetMenu();
189 
190  menu.AddMenu( selectMenu.get(), false, SELECTION_CONDITIONS::NotEmpty );
191  // only show separator if there is a Select menu to show above it
192  menu.AddSeparator( SELECTION_CONDITIONS::NotEmpty, 1000 );
193 
194  m_menu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
195 
196  return true;
197 }
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
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()
int SELECTION_TOOL::Main ( const TOOL_EVENT aEvent)

Function Main()

The main loop.

Definition at line 223 of file 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, TOOL_BASE::m_toolMgr, MD_CTRL, MD_SHIFT, PCB_ACTIONS::properties, TOOL_MANAGER::RunAction(), selectCursor(), selectionContains(), selectMultiple(), selectPoint(), TOOL_MENU::ShowContextMenu(), TA_CONTEXT_MENU_CLOSED, TA_UNDO_REDO_PRE, and TOOL_INTERACTIVE::Wait().

Referenced by SetTransitions().

224 {
225  // Main loop: keep receiving events
226  while( OPT_TOOL_EVENT evt = Wait() )
227  {
228  // Should selected items be added to the current selection or
229  // become the new selection (discarding previously selected items)
230  m_additive = evt->Modifier( MD_SHIFT );
231 
232  // single click? Select single object
233  if( evt->IsClick( BUT_LEFT ) )
234  {
235  if( evt->Modifier( MD_CTRL ) && !m_editModules )
236  {
238  }
239  else
240  {
241  if( !m_additive )
242  clearSelection();
243 
244  selectPoint( evt->Position() );
245  }
246  }
247 
248  // right click? if there is any object - show the context menu
249  else if( evt->IsClick( BUT_RIGHT ) )
250  {
251  bool emptySelection = m_selection.Empty();
252 
253  if( emptySelection )
254  selectPoint( evt->Position() );
255 
257  }
258 
259  // double click? Display the properties window
260  else if( evt->IsDblClick( BUT_LEFT ) )
261  {
262  if( m_selection.Empty() )
263  selectPoint( evt->Position() );
264 
266  }
267 
268  // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them
269  else if( evt->IsDrag( BUT_LEFT ) )
270  {
271  if( m_additive )
272  {
273  selectMultiple();
274  }
275  else if( m_selection.Empty() )
276  {
277  // There is nothing selected, so try to select something
278  if( !selectCursor() )
279  {
280  // If nothings has been selected or user wants to select more
281  // draw the selection box
282  selectMultiple();
283  }
284  else
285  {
286  m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
287  }
288  }
289 
290  else
291  {
292  // Check if dragging has started within any of selected items bounding box
293  if( selectionContains( evt->Position() ) )
294  {
295  // Yes -> run the move tool and wait till it finishes
296  m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
297  }
298  else
299  {
300  // No -> clear the selection list
301  clearSelection();
302  }
303  }
304  }
305 
306  else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
307  {
308  clearSelection();
309  }
310 
311  else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )
312  {
313  m_menu.CloseContextMenu( evt );
314  }
315  }
316 
317  // This tool is supposed to be active forever
318  assert( false );
319 
320  return 0;
321 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
bool selectCursor(bool aSelectAlways=false)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
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:220
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:96
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...
bool selectMultiple()
Function selectMultiple() Handles drawing a selection box that allows to select many items at the sam...
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 selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
bool m_editModules
Definition: pcb_tool.h:112
void CloseContextMenu(OPT_TOOL_EVENT &evt)
Function CloseContextMenu.
Definition: tool_menu.cpp:82
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:342
bool selectionContains(const VECTOR2I &aPoint) const
Function selectionContains() Checks if the given point is placed within any of selected items' boundi...
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
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 1214 of file selection_tool.cpp.

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

1215 {
1216  int count = aCollector->GetPrimaryCount(); // try to use preferred layer
1217 
1218  if( 0 == count )
1219  count = aCollector->GetCount();
1220 
1221  for( int i = 0; i < count; ++i )
1222  {
1223  if( ( *aCollector )[i]->Type() != PCB_MODULE_T )
1224  return NULL;
1225  }
1226 
1227  // All are modules, now find smallest MODULE
1228  int minDim = 0x7FFFFFFF;
1229  int minNdx = 0;
1230 
1231  for( int i = 0; i < count; ++i )
1232  {
1233  MODULE* module = (MODULE*) ( *aCollector )[i];
1234 
1235  int lx = module->GetBoundingBox().GetWidth();
1236  int ly = module->GetBoundingBox().GetHeight();
1237 
1238  int lmin = std::min( lx, ly );
1239 
1240  if( lmin < minDim )
1241  {
1242  minDim = lmin;
1243  minNdx = i;
1244  }
1245  }
1246 
1247  return (*aCollector)[minNdx];
1248 }
int GetCount() const
Function GetCount returns the number of objects in the list.
int GetHeight() const
class MODULE, a footprint
Definition: typeinfo.h:101
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
int GetPrimaryCount()
Function GetPrimaryCount.
Definition: collectors.h:344
int GetWidth() const
#define min(a, b)
Definition: auxiliary.h:85
SELECTION & SELECTION_TOOL::RequestSelection ( int  aFlags = SELECTION_DEFAULT)

Function RequestSelection()

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

Definition at line 330 of file selection_tool.cpp.

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

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

331 {
332  if ( m_selection.Empty() )
333  {
335  m_selection.SetIsHover( true );
336  }
337  else
338  {
339  m_selection.SetIsHover( false );
340  }
341 
342  // Be careful with iterators: items can be removed from list
343  // that invalidate iterators.
344  for( unsigned ii = 0; ii < m_selection.GetSize(); ii++ )
345  {
346  EDA_ITEM* item = m_selection[ii];
347 
348  if( ( aFlags & SELECTION_EDITABLE ) && item->Type() == PCB_MARKER_T )
349  {
350  unselect( static_cast<BOARD_ITEM *>( item ) );
351  }
352  }
353 
354  if ( aFlags & SELECTION_SANITIZE_PADS )
356 
357  return m_selection;
358 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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:111
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:151
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.

Implements TOOL_BASE.

Definition at line 200 of file selection_tool.cpp.

References KIGFX::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::VIEW::Remove(), and KIGFX::RENDER_SETTINGS::SetHighlight().

201 {
202  m_frame = getEditFrame<PCB_BASE_FRAME>();
203  m_locked = true;
204 
205  if( aReason == TOOL_BASE::MODEL_RELOAD )
206  {
207  // Remove pointers to the selected items from containers
208  // without changing their properties (as they are already deleted
209  // while a new board is loaded)
210  m_selection.Clear();
211  getView()->GetPainter()->GetSettings()->SetHighlight( false );
212  }
213  else
214  // Restore previous properties of selected items and remove them from containers
215  clearSelection();
216 
217  // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
218  getView()->Remove( &m_selection );
219  getView()->Add( &m_selection );
220 }
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
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
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:30
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
bool m_locked
Can other tools modify locked items.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
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:139
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 78 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

79 {
80  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
81 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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 1761 of file selection_tool.cpp.

References 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, unselect(), and UnselectedEvent.

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

1762 {
1763  std::set<BOARD_ITEM*> rejected;
1764  std::set<BOARD_ITEM*> added;
1765 
1766  if( !m_editModules )
1767  {
1768  for( auto i : m_selection )
1769  {
1770  auto item = static_cast<BOARD_ITEM*>( i );
1771  if( item->Type() == PCB_PAD_T )
1772  {
1773  MODULE* mod = static_cast<MODULE*>( item->GetParent() );
1774 
1775  // case 1: module (or its pads) are locked
1776  if( mod && ( mod->PadsLocked() || mod->IsLocked() ) )
1777  {
1778  rejected.insert( item );
1779 
1780  if( !mod->IsLocked() && !mod->IsSelected() )
1781  added.insert( mod );
1782  }
1783 
1784  // case 2: multi-item selection contains both the module and its pads - remove the pads
1785  if( mod && m_selection.Contains( mod ) )
1786  rejected.insert( item );
1787  }
1788  }
1789  }
1790 
1791  if( !rejected.empty() )
1792  {
1793  for( BOARD_ITEM* item : rejected )
1794  unselect( item );
1795 
1796  // Inform other potentially interested tools
1798  }
1799 
1800  if( !added.empty() )
1801  {
1802  for( BOARD_ITEM* item : added )
1803  select( item );
1804 
1805  // Inform other potentially interested tools
1807  }
1808 
1809  return true;
1810 }
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:220
bool IsSelected() const
Definition: base_struct.h:221
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
bool PadsLocked() const
Definition: class_module.h:259
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:223
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
bool m_editModules
Definition: pcb_tool.h:112
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
#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 1346 of file selection_tool.cpp.

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

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

1347 {
1348  if( aItem->IsSelected() )
1349  {
1350  return;
1351  }
1352 
1353  if( aItem->Type() == PCB_PAD_T )
1354  {
1355  MODULE* module = static_cast<MODULE*>( aItem->GetParent() );
1356 
1357  if( m_selection.Contains( module ) )
1358  return;
1359  }
1360 
1361  m_selection.Add( aItem );
1362  selectVisually( aItem );
1363 
1364 
1365  if( m_selection.Size() == 1 )
1366  {
1367  // Set as the current item, so the information about selection is displayed
1368  m_frame->SetCurItem( aItem, true );
1369  }
1370  else if( m_selection.Size() == 2 ) // Check only for 2, so it will not be
1371  { // called for every next selected item
1372  // If multiple items are selected, do not show the information about the selected item
1373  m_frame->SetCurItem( NULL, true );
1374  }
1375 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
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:221
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
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.
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 1251 of file selection_tool.cpp.

References B_Cu, PCB_TOOL::board(), F_Cu, KIGFX::RENDER_SETTINGS::GetHighContrast(), BOARD_ITEM::GetLayer(), KIGFX::VIEW::GetPainter(), TOOL_BASE::GetSettings(), KIGFX::PAINTER::GetSettings(), TOOL_BASE::getView(), BOARD::IsElementVisible(), BOARD::IsLayerVisible(), MODULE::IsLocked(), BOARD_ITEM::IsOnLayer(), KIGFX::VIEW::IsVisible(), PCB_TOOL::m_editModules, m_multiple, mod, MOD_BK_VISIBLE, MOD_FR_VISIBLE, NOT_USED, PCB_MODULE_EDGE_T, PCB_MODULE_T, PCB_MODULE_TEXT_T, PCB_PAD_T, PCB_VIA_T, EDA_ITEM::Type(), TYPE_NOT_INIT, PCB_TOOL::view(), KIGFX::VIEW::VIEW_MAX_LAYERS, and BOARD_ITEM::ViewGetLayers().

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

1252 {
1253  // Is high contrast mode enabled?
1254  bool highContrast = getView()->GetPainter()->GetSettings()->GetHighContrast();
1255 
1256  if( highContrast )
1257  {
1258  bool onActive = false; // Is the item on any of active layers?
1259  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS], layers_count;
1260 
1261  // Filter out items that do not belong to active layers
1262  const std::set<unsigned int>& activeLayers = getView()->GetPainter()->
1263  GetSettings()->GetActiveLayers();
1264  aItem->ViewGetLayers( layers, layers_count );
1265 
1266  for( int i = 0; i < layers_count; ++i )
1267  {
1268  if( activeLayers.count( layers[i] ) > 0 ) // Item is on at least one of the active layers
1269  {
1270  onActive = true;
1271  break;
1272  }
1273  }
1274 
1275  if( !onActive ) // We do not want to select items that are in the background
1276  return false;
1277  }
1278 
1279  switch( aItem->Type() )
1280  {
1281  case PCB_VIA_T:
1282  {
1283  // For vias it is enough if only one of layers is visible
1284  LAYER_ID top, bottom;
1285 
1286  static_cast<const VIA*>( aItem )->LayerPair( &top, &bottom );
1287 
1288  return board()->IsLayerVisible( top ) || board()->IsLayerVisible( bottom );
1289  }
1290  break;
1291 
1292  case PCB_MODULE_T:
1293  if( aItem->IsOnLayer( F_Cu ) && board()->IsElementVisible( MOD_FR_VISIBLE ) )
1294  return !m_editModules;
1295 
1296  if( aItem->IsOnLayer( B_Cu ) && board()->IsElementVisible( MOD_BK_VISIBLE ) )
1297  return !m_editModules;
1298 
1299  return false;
1300 
1301  break;
1302 
1303  case PCB_MODULE_TEXT_T:
1304  if( m_multiple && !m_editModules )
1305  return false;
1306 
1307  return view()->IsVisible( aItem ) && board()->IsLayerVisible( aItem->GetLayer() );
1308 
1309  case PCB_MODULE_EDGE_T:
1310  case PCB_PAD_T:
1311  {
1312  // Multiple selection is only allowed in modedit mode
1313  // In pcbnew, you have to select subparts of modules
1314  // one-by-one, rather than with a drag selection.
1315  // This is so you can pick up items under an (unlocked)
1316  // module without also moving the module's sub-parts.
1317  if( m_multiple && !m_editModules )
1318  return false;
1319 
1320  // When editing modules, it's allowed to select them, even when
1321  // locked, since you already have to explicitly activate the
1322  // module editor to get to this stage
1323  if ( !m_editModules )
1324  {
1325  MODULE* mod = static_cast<const D_PAD*>( aItem )->GetParent();
1326  if( mod && mod->IsLocked() )
1327  return false;
1328  }
1329 
1330  break;
1331  }
1332 
1333  // These are not selectable
1334  case NOT_USED:
1335  case TYPE_NOT_INIT:
1336  return false;
1337 
1338  default: // Suppress warnings
1339  break;
1340  }
1341 
1342  // All other items are selected only if the layer on which they exist is visible
1343  return board()->IsLayerVisible( aItem->GetLayer() );
1344 }
show modules on front
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
bool GetHighContrast() const
Function GetHighContrast Returns information about high contrast display mode.
Definition: painter.h:160
bool m_multiple
Flag saying if multiple selection mode is active.
the 3d code uses this value
Definition: typeinfo.h:92
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
virtual bool IsOnLayer(LAYER_ID aLayer) const
Function IsOnLayer tests to see if this object is on the given layer.
class MODULE, a footprint
Definition: typeinfo.h:101
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:640
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:72
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:223
bool m_editModules
Definition: pcb_tool.h:112
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
bool IsLayerVisible(LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:440
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
bool IsElementVisible(int aPCB_VISIBLE) const
Function IsElementVisible tests whether a given element category is visible.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
bool IsVisible(const VIEW_ITEM *aItem) const
Function IsVisible() Returns information if the item is visible (or not).
Definition: view.cpp:1370
#define mod(a, n)
Definition: greymap.cpp:24
BOARD * board() const
Definition: pcb_tool.h:110
void SELECTION_TOOL::selectAllItemsConnectedToItem ( BOARD_CONNECTED_ITEM aSourceItem)
private

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

Definition at line 735 of file selection_tool.cpp.

References RN_DATA::GetConnectedItems(), RN_TRACKS, RN_VIAS, and select().

Referenced by selectCopper().

736 {
737  RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
738  std::list<BOARD_CONNECTED_ITEM*> itemsList;
739  ratsnest->GetConnectedItems( &aSourceItem, itemsList, (RN_ITEM_TYPE)( RN_TRACKS | RN_VIAS ) );
740 
741  for( BOARD_CONNECTED_ITEM* i : itemsList )
742  select( i );
743 }
Class RN_DATA.
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.
RN_ITEM_TYPE
Types of items that are handled by the class
Definition: ratsnest_data.h:53
void GetConnectedItems(const BOARD_CONNECTED_ITEM *aItem, std::list< BOARD_CONNECTED_ITEM * > &aOutput, RN_ITEM_TYPE aTypes=RN_ALL) const
Function GetConnectedItems() Adds items that are connected together to a list.
void SELECTION_TOOL::selectAllItemsConnectedToTrack ( TRACK aSourceTrack)
private

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

Definition at line 721 of file selection_tool.cpp.

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

Referenced by selectConnection().

722 {
723  int segmentCount;
724  TRACK* trackList = board()->MarkTrace( &aSourceTrack, &segmentCount,
725  nullptr, nullptr, true );
726 
727  for( int i = 0; i < segmentCount; ++i )
728  {
729  select( trackList );
730  trackList = trackList->Next();
731  }
732 }
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:97
BOARD * board() const
Definition: pcb_tool.h:110
void SELECTION_TOOL::selectAllItemsOnNet ( int  aNetCode)
private

Selects all items with the given net code.

Definition at line 746 of file selection_tool.cpp.

References RN_DATA::GetNetItems(), RN_TRACKS, RN_VIAS, and select().

Referenced by selectNet().

747 {
748  RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
749  std::list<BOARD_CONNECTED_ITEM*> itemsList;
750 
751  ratsnest->GetNetItems( aNetCode, itemsList, (RN_ITEM_TYPE)( RN_TRACKS | RN_VIAS ) );
752 
753  for( BOARD_CONNECTED_ITEM* i : itemsList )
754  select( i );
755 }
Class RN_DATA.
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.
void GetNetItems(int aNetCode, std::list< BOARD_CONNECTED_ITEM * > &aOutput, RN_ITEM_TYPE aTypes=RN_ALL) const
Function GetNetItems() Adds all items that belong to a certain net to a list.
RN_ITEM_TYPE
Types of items that are handled by the class
Definition: ratsnest_data.h:53
void SELECTION_TOOL::selectAllItemsOnSheet ( wxString &  aSheetpath)
private

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

Definition at line 786 of file selection_tool.cpp.

References PCB_TOOL::board(), DLIST< T >::GetFirst(), RN_DATA::GetNetItems(), BOARD::m_Modules, MODULE::Next(), D_PAD::Next(), RN_PADS, RN_TRACKS, RN_VIAS, and select().

Referenced by selectOnSheetFromEeschema(), and selectSameSheet().

787 {
788  auto modules = board()->m_Modules.GetFirst();
789  std::list<MODULE*> modList;
790 
791  // store all modules that are on that sheet
792  for( MODULE* mitem = modules; mitem; mitem = mitem->Next() )
793  {
794  if( mitem != NULL && mitem->GetPath().Contains( aSheetpath ) )
795  {
796  modList.push_back( mitem );
797  }
798  }
799 
800  //Generate a list of all pads, and of all nets they belong to.
801  std::list<int> netcodeList;
802  for( MODULE* mmod : modList )
803  {
804  for( D_PAD* pad = mmod->Pads().GetFirst(); pad; pad = pad->Next() )
805  {
806  if( pad->IsConnected() )
807  {
808  netcodeList.push_back( pad->GetNetCode() );
809  }
810  }
811  }
812 
813  // remove all duplicates
814  netcodeList.sort();
815  netcodeList.unique();
816 
817  // now we need to find all modules that are connected to each of these nets
818  // then we need to determine if these modules are in the list of modules
819  // belonging to this sheet ( modList )
820  RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
821  std::list<int> removeCodeList;
822  for( int netCode : netcodeList )
823  {
824  std::list<BOARD_CONNECTED_ITEM*> netPads;
825  ratsnest->GetNetItems( netCode, netPads, (RN_ITEM_TYPE)( RN_PADS ) );
826  for( BOARD_CONNECTED_ITEM* mitem : netPads )
827  {
828  bool found = ( std::find( modList.begin(), modList.end(), mitem->GetParent() ) != modList.end() );
829  if( !found )
830  {
831  // if we cannot find the module of the pad in the modList
832  // then we can assume that that module is not located in the same
833  // schematic, therefore invalidate this netcode.
834  removeCodeList.push_back( netCode );
835  break;
836  }
837  }
838  }
839 
840  // remove all duplicates
841  removeCodeList.sort();
842  removeCodeList.unique();
843 
844  for( int removeCode : removeCodeList )
845  {
846  netcodeList.remove( removeCode );
847  }
848 
849  std::list<BOARD_CONNECTED_ITEM*> localConnectionList;
850  for( int netCode : netcodeList )
851  {
852  ratsnest->GetNetItems( netCode, localConnectionList, (RN_ITEM_TYPE)( RN_TRACKS | RN_VIAS ) );
853  }
854 
855  for( BOARD_ITEM* i : modList )
856  {
857  if( i != NULL )
858  select( i );
859  }
860  for( BOARD_CONNECTED_ITEM* i : localConnectionList )
861  {
862  if( i != NULL )
863  select( i );
864  }
865 }
Class RN_DATA.
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:99
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.
void GetNetItems(int aNetCode, std::list< BOARD_CONNECTED_ITEM * > &aOutput, RN_ITEM_TYPE aTypes=RN_ALL) const
Function GetNetItems() Adds all items that belong to a certain net to a list.
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
D_PAD * Next() const
Definition: class_pad.h:106
RN_ITEM_TYPE
Types of items that are handled by the class
Definition: ratsnest_data.h:53
DLIST< MODULE > m_Modules
Definition: class_board.h:243
BOARD * board() const
Definition: pcb_tool.h:110
int SELECTION_TOOL::selectConnection ( const TOOL_EVENT aEvent)
private

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

Definition at line 667 of file selection_tool.cpp.

References SELECTION::GetItems(), m_selection, TOOL_BASE::m_toolMgr, PCB_TRACE_T, PCB_VIA_T, TOOL_MANAGER::ProcessEvent(), selectAllItemsConnectedToTrack(), selectCursor(), SelectedEvent, and SELECTION::Size().

Referenced by SetTransitions().

668 {
669  if( !selectCursor() )
670  return 0;
671 
672  // copy the selection, since we're going to iterate and modify
673  auto selection = m_selection.GetItems();
674 
675  for( auto item : selection )
676  {
677  // only TRACK items can be checked for trivial connections
678  if( item->Type() == PCB_TRACE_T || item->Type() == PCB_VIA_T )
679  {
680  TRACK& trackItem = static_cast<TRACK&>( *item );
681  selectAllItemsConnectedToTrack( trackItem );
682  }
683  }
684 
685  // Inform other potentially interested tools
686  if( m_selection.Size() > 0 )
688 
689  return 0;
690 }
bool selectCursor(bool aSelectAlways=false)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
const std::set< EDA_ITEM * > GetItems() const
Definition: selection.h:117
SELECTION m_selection
Current state of selection.
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.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
int SELECTION_TOOL::selectCopper ( const TOOL_EVENT aEvent)
private

Selects items with a continuous copper connection to items in selection

Definition at line 693 of file selection_tool.cpp.

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

Referenced by SetTransitions().

694 {
695  if( !selectCursor() )
696  return 0;
697 
698  // copy the selection, since we're going to iterate and modify
699  auto selection = m_selection.GetItems();
700 
701  for( auto i : selection )
702  {
703  auto item = static_cast<BOARD_ITEM*>( i );
704  // only connected items can be traversed in the ratsnest
705  if( item->IsConnected() )
706  {
707  auto& connItem = static_cast<BOARD_CONNECTED_ITEM&>( *item );
708 
709  selectAllItemsConnectedToItem( connItem );
710  }
711  }
712 
713  // Inform other potentially interested tools
714  if( m_selection.Size() > 0 )
716 
717  return 0;
718 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
bool selectCursor(bool aSelectAlways=false)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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
SELECTION m_selection
Current state of 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
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
void selectAllItemsConnectedToItem(BOARD_CONNECTED_ITEM &aSourceItem)
Selects all items connected (by copper) to the given item.
bool SELECTION_TOOL::selectCursor ( bool  aSelectAlways = false)
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.
Returns
true if eventually there is an item selected, false otherwise.

Definition at line 453 of file selection_tool.cpp.

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

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

454 {
455  if( aSelectAlways || m_selection.Empty() )
456  {
457  clearSelection();
458  selectPoint( getViewControls()->GetCursorPosition() );
459  }
460 
461  return !m_selection.Empty();
462 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
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:36
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
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 1442 of file 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().

1443 {
1444  const unsigned GRIP_MARGIN = 20;
1445  VECTOR2D margin = getView()->ToWorld( VECTOR2D( GRIP_MARGIN, GRIP_MARGIN ), false );
1446 
1447  // Check if the point is located within any of the currently selected items bounding boxes
1448  for( auto item : m_selection )
1449  {
1450  BOX2I itemBox = item->ViewBBox();
1451  itemBox.Inflate( margin.x, margin.y ); // Give some margin for gripping an item
1452 
1453  if( itemBox.Contains( aPoint ) )
1454  return true;
1455  }
1456 
1457  return false;
1458 }
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:439
VECTOR2< double > VECTOR2D
Definition: vector2d.h:579
SELECTION m_selection
Current state of selection.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
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 633 of file selection_tool.cpp.

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

Referenced by SetTransitions().

634 {
635  // Check if there is an item to be selected
636  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
637 
638  if( item )
639  {
640  select( item );
641 
642  // Inform other potentially interested tools
644  }
645 
646  return 0;
647 }
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:220
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
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:373
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
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 465 of file selection_tool.cpp.

References KIGFX::VIEW::Add(), BUT_LEFT, clearSelection(), BOX2< Vec >::Contains(), SELECTION::Empty(), SELECTION::Front(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), EDA_ITEM::IsSelected(), m_additive, m_frame, m_multiple, m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), KIGFX::VIEW::Query(), KIGFX::VIEW::Remove(), select(), selectable(), SelectedEvent, KIGFX::VIEW_CONTROLS::SetAutoPan(), PCB_BASE_FRAME::SetCurItem(), KIGFX::PREVIEW::SELECTION_AREA::SetEnd(), KIGFX::PREVIEW::SELECTION_AREA::SetOrigin(), KIGFX::VIEW::SetVisible(), SELECTION::Size(), KIGFX::VIEW::Update(), PCB_TOOL::view(), KIGFX::PREVIEW::SELECTION_AREA::ViewBBox(), EDA_ITEM::ViewBBox(), and TOOL_INTERACTIVE::Wait().

Referenced by Main().

466 {
467  bool cancelled = false; // Was the tool cancelled while it was running?
468  m_multiple = true; // Multiple selection mode is active
469  KIGFX::VIEW* view = getView();
470  getViewControls()->SetAutoPan( true );
471 
473  view->Add( &area );
474 
475  while( OPT_TOOL_EVENT evt = Wait() )
476  {
477  if( evt->IsCancel() )
478  {
479  cancelled = true;
480  break;
481  }
482 
483  if( evt->IsDrag( BUT_LEFT ) )
484  {
485  if( !m_additive )
486  clearSelection();
487 
488  // Start drawing a selection box
489  area.SetOrigin( evt->DragOrigin() );
490  area.SetEnd( evt->Position() );
491  view->SetVisible( &area, true );
492  view->Update( &area );
493  }
494 
495  if( evt->IsMouseUp( BUT_LEFT ) )
496  {
497  // End drawing the selection box
498  view->SetVisible( &area, false );
499 
500  // Mark items within the selection box as selected
501  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
502  BOX2I selectionBox = area.ViewBBox();
503  view->Query( selectionBox, selectedItems ); // Get the list of selected items
504 
505  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR>::iterator it, it_end;
506 
507  for( it = selectedItems.begin(), it_end = selectedItems.end(); it != it_end; ++it )
508  {
509  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first );
510 
511  // Add only those items that are visible and fully within the selection box
512  if( !item->IsSelected() && selectable( item ) &&
513  selectionBox.Contains( item->ViewBBox() ) )
514  {
515  select( item );
516  }
517  }
518 
519  if( m_selection.Size() == 1 )
520  m_frame->SetCurItem( static_cast<BOARD_ITEM*>( m_selection.Front() ) );
521  else
522  m_frame->SetCurItem( NULL );
523 
524  // Inform other potentially interested tools
525  if( !m_selection.Empty() )
527 
528  break; // Stop waiting for events
529  }
530  }
531 
532  // Stop drawing the selection box
533  view->Remove( &area );
534  m_multiple = false; // Multiple selection mode is inactive
535  getViewControls()->SetAutoPan( false );
536 
537  return cancelled;
538 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
void SetEnd(VECTOR2I aEnd)
Set the current end of the rectangle (the corner that moves with the cursor.
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:416
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:137
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
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()
bool IsSelected() const
Definition: base_struct.h:221
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.
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.
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
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:36
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Function SetVisible() Sets the item visibility.
Definition: view.cpp:1330
Class SELECTION_AREA.
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
Class VIEW.
Definition: view.h:58
virtual const BOX2I ViewBBox() const override
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 758 of file selection_tool.cpp.

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

Referenced by SetTransitions().

759 {
760  if( !selectCursor() )
761  return 0;
762 
763  // copy the selection, since we're going to iterate and modify
764  auto selection = m_selection.GetItems();
765 
766  for( auto i : selection )
767  {
768  auto item = static_cast<BOARD_ITEM*>( i );
769  // only connected items get a net code
770  if( item->IsConnected() )
771  {
772  auto& connItem = static_cast<BOARD_CONNECTED_ITEM&>( *item );
773 
774  selectAllItemsOnNet( connItem.GetNetCode() );
775  }
776  }
777 
778  // Inform other potentially interested tools
779  if( m_selection.Size() > 0 )
781 
782  return 0;
783 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
bool selectCursor(bool aSelectAlways=false)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
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.
SELECTION m_selection
Current state of 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
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
int SELECTION_TOOL::selectOnSheetFromEeschema ( const TOOL_EVENT aEvent)
private

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

Definition at line 890 of file 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().

891 {
892  clearSelection();
893  wxString* sheetpath = aEvent.Parameter<wxString*>();
894 
895  selectAllItemsOnSheet( *sheetpath );
896 
898 
899  if( m_selection.Size() > 0 )
901 
902 
903  return 0;
904 }
void zoomFitSelection(void)
Zooms the screen to center and fit the current selection.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void selectAllItemsOnSheet(wxString &aSheetpath)
Selects all items with the given sheet timestamp name (the sheet path)
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:373
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
bool SELECTION_TOOL::selectPoint ( const VECTOR2I aWhere,
bool  aOnDrag = false 
)
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.
aAllowDisambiguationdecides what to do in case of disambiguation. If true, then a menu is shown, otherise function finishes without selecting anything.
Returns
True if an item was selected, false otherwise.

Definition at line 389 of file selection_tool.cpp.

References GENERAL_COLLECTOR::AllBoardItems, PCB_TOOL::board(), BUT_LEFT, clearSelection(), GENERAL_COLLECTOR::Collect(), disambiguationMenu(), PCB_BASE_FRAME::GetCollectorsGuide(), COLLECTOR::GetCount(), guessSelectionCandidates(), m_additive, PCB_TOOL::m_editModules, m_frame, 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().

390 {
391  BOARD_ITEM* item;
393  GENERAL_COLLECTOR collector;
394 
395  collector.Collect( board(),
397  wxPoint( aWhere.x, aWhere.y ), guide );
398 
399  bool anyCollected = collector.GetCount() != 0;
400 
401  // Remove unselectable items
402  for( int i = collector.GetCount() - 1; i >= 0; --i )
403  {
404  if( !selectable( collector[i] ) || ( aOnDrag && collector[i]->IsLocked() ) )
405  collector.Remove( i );
406  }
407 
408  switch( collector.GetCount() )
409  {
410  case 0:
411  if( !m_additive && anyCollected )
412  clearSelection();
413 
414  return false;
415 
416  case 1:
417  toggleSelection( collector[0] );
418 
419  return true;
420 
421  default:
422  // Apply some ugly heuristics to avoid disambiguation menus whenever possible
423  guessSelectionCandidates( collector );
424 
425  // Let's see if there is still disambiguation in selection..
426  if( collector.GetCount() == 1 )
427  {
428  toggleSelection( collector[0] );
429 
430  return true;
431  }
432  else if( collector.GetCount() > 1 )
433  {
434  if( aOnDrag )
436 
437  item = disambiguationMenu( &collector );
438 
439  if( item )
440  {
441  toggleSelection( item );
442 
443  return true;
444  }
445  }
446  break;
447  }
448 
449  return false;
450 }
int GetCount() const
Function GetCount returns the number of objects in the list.
static const KICAD_T AllBoardItems[]
A scan list for all editable board items, like PcbGeneralLocateAndDisplay()
Definition: collectors.h:241
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)
Function Collect scans a BOARD_ITEM using this class's Inspector method, which does the collection...
Definition: collectors.cpp:447
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);.
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
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 ...
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
bool m_editModules
Definition: pcb_tool.h:112
static const KICAD_T ModuleItems[]
A scan list for primary module items.
Definition: collectors.h:288
Class GENERAL_COLLECTOR is intended for use when the right click button is pressed, or when the plain "arrow" tool is in effect.
Definition: collectors.h:211
Class GENERAL_COLLECTORS_GUIDE is a general implementation of a COLLECTORS_GUIDE. ...
Definition: collectors.h:378
BOARD * board() const
Definition: pcb_tool.h:110
int SELECTION_TOOL::selectSameSheet ( const TOOL_EVENT aEvent)
private

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

Definition at line 907 of file 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().

908 {
909  if( !selectCursor( true ) )
910  return 0;
911 
912  // this function currently only supports modules since they are only
913  // on one sheet.
914  auto item = m_selection.Front();
915 
916  if( !item )
917  return 0;
918 
919  if( item->Type() != PCB_MODULE_T )
920  return 0;
921 
922  auto mod = dynamic_cast<MODULE*>( item );
923 
924  clearSelection();
925 
926  // get the lowest subsheet name for this.
927  wxString sheetPath = mod->GetPath();
928  sheetPath = sheetPath.BeforeLast( '/' );
929  sheetPath = sheetPath.AfterLast( '/' );
930 
931  selectAllItemsOnSheet( sheetPath );
932 
933  // Inform other potentially interested tools
934  if( m_selection.Size() > 0 )
936 
937  return 0;
938 }
bool selectCursor(bool aSelectAlways=false)
Function selectCursor() Selects an item under the cursor unless there is something already selected o...
EDA_ITEM * Front() const
Definition: selection.h:137
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
class MODULE, a footprint
Definition: typeinfo.h:101
void selectAllItemsOnSheet(wxString &aSheetpath)
Selects all items with the given sheet timestamp name (the sheet path)
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
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
#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 1394 of file selection_tool.cpp.

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

Referenced by select().

1395 {
1396  // Hide the original item, so it is shown only on overlay
1397  aItem->SetSelected();
1398  view()->Hide( aItem, true );
1399  view()->Update( aItem, KIGFX::GEOMETRY );
1400 
1401  // Modules are treated in a special way - when they are selected, we have to
1402  // unselect all the parts that make the module, not the module itself
1403 
1404  if( aItem->Type() == PCB_MODULE_T )
1405  {
1406  static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* item )
1407  {
1408  item->SetSelected();
1409  view()->Hide( item, true );
1410  view()->Update( item, KIGFX::GEOMETRY );
1411  } );
1412  }
1413 
1414  view()->Update( &m_selection );
1415 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Function Hide() Temporarily hides the item in the view (e.g.
Definition: view.cpp:1351
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
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:101
void SetSelected()
Definition: base_struct.h:227
SELECTION m_selection
Current state of selection.
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
Color has changed.
Definition: view_item.h:57
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 67 of file tool_interactive.cpp.

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

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

68 {
69  if( aMenu )
70  aMenu->SetTool( this );
71  else
72  aTrigger = CMENU_OFF;
73 
74  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
75 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool'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 73 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

74  {
75  m_editModules = aEnabled;
76  }
bool m_editModules
Definition: pcb_tool.h:112
void SELECTION_TOOL::SetTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from TOOL_BASE.

Definition at line 541 of file selection_tool.cpp.

References ClearSelection(), CursorSelection(), 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::selectItem, SelectItem(), PCB_ACTIONS::selectNet, selectNet(), PCB_ACTIONS::selectOnSheetFromEeschema, selectOnSheetFromEeschema(), PCB_ACTIONS::selectSameSheet, selectSameSheet(), PCB_ACTIONS::unselectItem, and UnselectItem().

542 {
548  Go( &SELECTION_TOOL::find, PCB_ACTIONS::find.MakeEvent() );
556 }
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:59
static TOOL_ACTION selectNet
Selects all connections belonging to a single net.
Definition: pcb_actions.h:68
int find(const TOOL_EVENT &aEvent)
Find an item.
int findMove(const TOOL_EVENT &aEvent)
Find an item and start moving.
static TOOL_ACTION selectConnection
Selects a connection between junctions.
Definition: pcb_actions.h:62
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()
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
static TOOL_ACTION find
Find an item.
Definition: pcb_actions.h:351
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:65
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 filterSelection
Filters the items in the current selection (invokes dialog)
Definition: pcb_actions.h:77
static TOOL_ACTION selectOnSheetFromEeschema
Selects all components on sheet from Eeschema crossprobing.
Definition: pcb_actions.h:71
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
static TOOL_ACTION findMove
Find an item and start moving.
Definition: pcb_actions.h:354
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:74
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 361 of file 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().

362 {
363  if( aItem->IsSelected() )
364  {
365  unselect( aItem );
366 
367  // Inform other potentially interested tools
369  }
370  else
371  {
372  if( !m_additive )
373  clearSelection();
374 
375  // Prevent selection of invisible or inactive items
376  if( selectable( aItem ) )
377  {
378  select( aItem );
379 
380  // Inform other potentially interested tools
382  }
383  }
384 
386 }
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:220
bool IsSelected() const
Definition: base_struct.h:221
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.
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:803
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
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 1378 of file 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(), toggleSelection(), and UnselectItem().

1379 {
1380  if( !aItem->IsSelected() )
1381  return;
1382 
1383  m_selection.Remove( aItem );
1384  unselectVisually( aItem );
1385 
1386  if( m_selection.Empty() )
1387  {
1388  m_frame->SetCurItem( NULL );
1389  m_locked = true;
1390  }
1391 }
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:221
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 650 of file selection_tool.cpp.

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

Referenced by SetTransitions().

651 {
652  // Check if there is an item to be selected
653  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
654 
655  if( item )
656  {
657  unselect( item );
658 
659  // Inform other potentially interested tools
661  }
662 
663  return 0;
664 }
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:220
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:373
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
void ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
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 1418 of file selection_tool.cpp.

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

Referenced by clearSelection(), and unselect().

1419 {
1420  // Restore original item visibility
1421  aItem->ClearSelected();
1422  view()->Hide( aItem, false );
1423  view()->Update( aItem, KIGFX::ALL );
1424 
1425  // Modules are treated in a special way - when they are selected, we have to
1426  // unselect all the parts that make the module, not the module itself
1427 
1428  if( aItem->Type() == PCB_MODULE_T )
1429  {
1430  static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* item )
1431  {
1432  item->ClearSelected();
1433  view()->Hide( item, false );
1434  view()->Update( item, KIGFX::ALL );
1435  });
1436  }
1437 
1438  view()->Update( &m_selection );
1439 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Function Hide() Temporarily hides the item in the view (e.g.
Definition: view.cpp:1351
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
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:231
Layers have changed.
Definition: view_item.h:59
class MODULE, a footprint
Definition: typeinfo.h:101
SELECTION m_selection
Current state of selection.
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
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 MODULE_EDITOR_TOOLS::CopyItems(), PCBNEW_CONTROL::DeleteItemCursor(), 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(), Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), selectMultiple(), selectPoint(), ZOOM_TOOL::selectRegion(), and DRAWING_TOOL::SetAnchor().

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
boost::optional< 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 867 of file selection_tool.cpp.

References KIGFX::VIEW::Add(), 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().

868 {
869  //Should recalculate the view to zoom in on the selection
870  auto selectionBox = m_selection.ViewBBox();
871  auto canvas = m_frame->GetGalCanvas();
872  auto view = getView();
873 
874  VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
875 
876  if( !( selectionBox.GetWidth() == 0 ) || !( selectionBox.GetHeight() == 0 ) )
877  {
878  VECTOR2D vsize = selectionBox.GetSize();
879  double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
880  fabs( vsize.y / screenSize.y ) );
881  view->SetScale( scale );
882  view->SetCenter( selectionBox.Centre() );
883  view->Add( &m_selection );
884  }
885 
887 }
KIGFX::VIEW * view() const
Definition: pcb_tool.h:108
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:439
void SetScale(double aScale)
Function SetScale() Sets the scaling factor.
Definition: view.h:247
const BOX2I ViewBBox() const override
Function ViewBBox() Returns the bounding box for all stored items covering all its layers...
void SetCenter(const VECTOR2D &aCenter)
Function SetCenter() Sets the center point of the VIEW (i.e.
Definition: view.cpp:563
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:30
const int scale
#define max(a, b)
Definition: auxiliary.h:86
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:803
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310

Member Data Documentation

const TOOL_EVENT SELECTION_TOOL::ClearedEvent
static

Event sent after selection is cleared.

Definition at line 126 of file selection_tool.h.

Referenced by clearSelection(), and POINT_EDITOR::OnSelectionChange().

bool SELECTION_TOOL::m_additive
private

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

Definition at line 318 of file selection_tool.h.

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

bool SELECTION_TOOL::m_locked
private

Can other tools modify locked items.

Definition at line 324 of file selection_tool.h.

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

TOOL_MENU SELECTION_TOOL::m_menu
private

Menu model displayed by the tool.

Definition at line 327 of file selection_tool.h.

Referenced by GetToolMenu(), Init(), and Main().

bool SELECTION_TOOL::m_multiple
private

Flag saying if multiple selection mode is active.

Definition at line 321 of file selection_tool.h.

Referenced by selectable(), and selectMultiple().

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

Definition at line 330 of file selection_tool.h.

Referenced by filterSelection().

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::GetId(), and EDIT_TOOL::getModificationPoint().

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 220 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PCBNEW_CONTROL::AppendBoard(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), clearSelection(), MODULE_EDITOR_TOOLS::CopyItems(), PAD_TOOL::copyPadSettings(), 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(), findCallback(), findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), EDIT_TOOL::getModificationPoint(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::Init(), PLACEMENT_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), 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(), MODULE_EDITOR_TOOLS::PasteItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Remove(), RequestSelection(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SanitizeSelection(), selectConnection(), selectCopper(), SelectItem(), selectMultiple(), selectNet(), selectOnSheetFromEeschema(), selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), UnselectItem(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and PCB_EDITOR_CONTROL::ZoneUnfill().

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 219 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 221 of file tool_base.h.

Referenced by TOOL_BASE::attachManager(), and TOOL_BASE::GetSettings().

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 212 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

const TOOL_EVENT SELECTION_TOOL::UnselectedEvent
static

Event sent after an item is unselected.

Definition at line 123 of file selection_tool.h.

Referenced by POINT_EDITOR::OnSelectionChange(), SanitizeSelection(), POINT_EDITOR::SetTransitions(), toggleSelection(), and UnselectItem().


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