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

Multiple item selection event handler

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

Item unselection event handler.

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

Multiple item unselection event handler

More...
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
void zoomFitSelection (void)
 

Zooms the screen to center and fit the current selection.

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

Static Public Attributes

static const TOOL_EVENT SelectedEvent
 

Event sent after an item is selected.

More...
 
static const TOOL_EVENT UnselectedEvent
 

Event sent after an item is unselected.

More...
 
static const TOOL_EVENT ClearedEvent
 

Event sent after selection is cleared.

More...
 

Protected Types

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

Protected Member Functions

void doInteractiveItemPlacement (INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () 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...
 
int updateSelection (const TOOL_EVENT &aEvent)
 Event handler to update the selection VIEW_ITEM. 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_subtractive
 Flag saying if items should be removed from the current selection. More...
 
bool m_multiple
 Flag saying if multiple selection mode is active. More...
 
bool m_locked
 Can other tools modify locked items. More...
 
TOOL_MENU m_menu
 Menu model displayed by the tool. More...
 
std::unique_ptr< PRIVm_priv
 

Detailed Description

Class SELECTION_TOOL.

Our sample selection tool: currently supports:

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

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

Member Enumeration Documentation

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

Definition at line 98 of file pcb_tool.h.

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 80 of file tool_base.h.

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

Constructor & Destructor Documentation

SELECTION_TOOL::SELECTION_TOOL ( )

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

176  :
177  PCB_TOOL( "pcbnew.InteractiveSelection" ),
178  m_frame( NULL ), m_additive( false ), m_subtractive( false ),
179  m_multiple( false ),
180  m_locked( true ), m_menu( *this ),
181  m_priv( std::make_unique<PRIV>() )
182 {
183 
184 }
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:65
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
TOOL_MENU m_menu
Menu model displayed by the tool.
bool m_subtractive
Flag saying if items should be removed from the current selection.
bool m_locked
Can other tools modify locked items.
SELECTION_TOOL::~SELECTION_TOOL ( )

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

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

188 {
189  getView()->Remove( &m_selection );
190 }
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
SELECTION m_selection
Current state of selection.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

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

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

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

Function attachManager()

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

Definition at line 59 of file tool_base.cpp.

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

Referenced by TOOL_MANAGER::RegisterTool().

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

Definition at line 126 of file pcb_tool.h.

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

126 { return getModel<BOARD>(); }
SELECTION_LOCK_FLAGS SELECTION_TOOL::CheckLock ( )

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

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

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

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

624 {
625  if( !m_locked || m_editModules )
626  return SELECTION_UNLOCKED;
627 
628  bool containsLocked = false;
629 
630  // Check if the selection contains locked items
631  for( const auto& item : m_selection )
632  {
633  switch( item->Type() )
634  {
635  case PCB_MODULE_T:
636  if( static_cast<MODULE*>( item )->IsLocked() )
637  containsLocked = true;
638  break;
639 
640  case PCB_MODULE_EDGE_T:
641  case PCB_MODULE_TEXT_T:
642  if( static_cast<MODULE*>( item->GetParent() )->IsLocked() )
643  containsLocked = true;
644  break;
645 
646  default: // suppress warnings
647  break;
648  }
649  }
650 
651  if( containsLocked )
652  {
653  if( IsOK( m_frame, _( "Selection contains locked items. Do you want to continue?" ) ) )
654  {
655  m_locked = false;
657  }
658  else
659  return SELECTION_LOCKED;
660  }
661 
662  return SELECTION_UNLOCKED;
663 }
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:129
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:129
int SELECTION_TOOL::ClearSelection ( const TOOL_EVENT aEvent)

Clear current selection event handler.

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

References clearSelection().

Referenced by setTransitions().

689 {
690  clearSelection();
691 
692  return 0;
693 }
void clearSelection()
Function clearSelection() Clears the current selection.
void SELECTION_TOOL::clearSelection ( )
private

Function clearSelection() Clears the current selection.

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

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

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

1257 {
1258  if( m_selection.Empty() )
1259  return;
1260 
1261  for( auto item : m_selection )
1262  unselectVisually( static_cast<BOARD_ITEM*>( item ) );
1263 
1264  m_selection.Clear();
1265  m_selection.SetIsHover( false );
1266  m_selection.ClearReferencePoint();
1267 
1268  m_frame->SetCurItem( NULL );
1269  m_locked = true;
1270 
1271  // Inform other potentially interested tools
1273 }
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
void unselectVisually(BOARD_ITEM *aItem)
Function unselectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.
static const TOOL_EVENT ClearedEvent
Event sent after selection is cleared.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
bool m_locked
Can other tools modify locked items.
int SELECTION_TOOL::CursorSelection ( const TOOL_EVENT aEvent)

Select a single item under cursor event handler.

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

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

Referenced by setTransitions().

667 {
668  bool sanitize = (bool) aEvent.Parameter<intptr_t>();
669 
670  if( m_selection.Empty() ) // Try to find an item that could be modified
671  {
672  selectCursor( true );
673 
674  if( CheckLock() == SELECTION_LOCKED )
675  {
676  clearSelection();
677  return 0;
678  }
679  }
680 
681  if( sanitize )
683 
684  return 0;
685 }
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 1276 of file pcbnew/tools/selection_tool.cpp.

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

Referenced by selectPoint().

1277 {
1278  BOARD_ITEM* current = NULL;
1279  KIGFX::VIEW_GROUP highlightGroup;
1280  CONTEXT_MENU menu;
1281 
1282  highlightGroup.SetLayer( LAYER_GP_OVERLAY );
1283  getView()->Add( &highlightGroup );
1284 
1285  int limit = std::min( 9, aCollector->GetCount() );
1286 
1287  for( int i = 0; i < limit; ++i )
1288  {
1289  wxString text;
1290  BOARD_ITEM* item = ( *aCollector )[i];
1291  text = item->GetSelectMenuText();
1292 
1293  wxString menuText = wxString::Format("&%d. %s", i + 1, text );
1294  menu.Add( menuText, i + 1 );
1295  }
1296 
1297  menu.SetTitle( _( "Clarify selection" ) );
1298  menu.DisplayTitle( true );
1299  SetContextMenu( &menu, CMENU_NOW );
1300 
1301  while( OPT_TOOL_EVENT evt = Wait() )
1302  {
1303  if( evt->Action() == TA_CONTEXT_MENU_UPDATE )
1304  {
1305  if( current )
1306  {
1307  current->ClearBrightened();
1308  getView()->Hide( current, false );
1309  highlightGroup.Remove( current );
1311  }
1312 
1313  int id = *evt->GetCommandId();
1314 
1315  // User has pointed an item, so show it in a different way
1316  if( id > 0 && id <= limit )
1317  {
1318  current = ( *aCollector )[id - 1];
1319  current->SetBrightened();
1320  getView()->Hide( current, true );
1321  highlightGroup.Add( current );
1323  }
1324  else
1325  {
1326  current = NULL;
1327  }
1328  }
1329  else if( evt->Action() == TA_CONTEXT_MENU_CHOICE )
1330  {
1331  boost::optional<int> id = evt->GetCommandId();
1332 
1333  // User has selected an item, so this one will be returned
1334  if( id && ( *id > 0 ) )
1335  current = ( *aCollector )[*id - 1];
1336  else
1337  current = NULL;
1338 
1339  break;
1340  }
1341  }
1342 
1343  if( current && current->IsBrightened() )
1344  {
1345  current->ClearBrightened();
1346  getView()->Hide( current, false );
1348  }
1349 
1350  getView()->Remove( &highlightGroup );
1351 
1352 
1353  return current;
1354 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1352
bool IsBrightened() const
Definition: base_struct.h:238
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:342
void SetBrightened()
Definition: base_struct.h:243
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:247
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:568
void SetContextMenu(CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
Items that may change while the view stays the same (noncached)
Definition: definitions.h:43
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
general purpose overlay
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetLayer(int aLayer)
Function SetLayer() Sets layer used to draw the group.
Definition: view_group.h:115
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
void SetTitle(const wxString &aTitle) override
Function SetTitle() Sets title for the context menu.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
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
void PCB_TOOL::doInteractiveItemPlacement ( INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

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

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

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

Definition at line 38 of file pcb_tool.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), PCB_TOOL::board(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), BOARD_COMMIT::Push(), KIGFX::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(), DRAWING_TOOL::DrawVia(), and MODULE_EDITOR_TOOLS::PlacePad().

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

Definition at line 91 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

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

92  {
93  return m_editModules;
94  }
bool m_editModules
Definition: pcb_tool.h:129
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 1221 of file pcbnew/tools/selection_tool.cpp.

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

Referenced by setTransitions().

1222 {
1223  auto& opts = m_priv->m_filterOpts;
1224  DIALOG_BLOCK_OPTIONS dlg( m_frame, opts, false, _( "Filter selection" ) );
1225 
1226  const int cmd = dlg.ShowModal();
1227 
1228  if( cmd != wxID_OK )
1229  return 0;
1230 
1231  const auto& board = *getModel<BOARD>();
1232  const auto layerMask = getFilteredLayerSet( opts );
1233 
1234  // copy current selection
1235  auto selection = m_selection.GetItems();
1236 
1237  // clear current selection
1238  clearSelection();
1239 
1240  // copy selection items from the saved selection
1241  // according to the dialog options
1242  for( auto i : selection )
1243  {
1244  auto item = static_cast<BOARD_ITEM*>( i );
1245  bool include = itemIsIncludedByFilter( *item, board, layerMask, opts );
1246 
1247  if( include )
1248  {
1249  select( item );
1250  }
1251  }
1252  return 0;
1253 }
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:126
int SELECTION_TOOL::find ( const TOOL_EVENT aEvent)
private

Find an item.

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

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

Referenced by setTransitions().

1090 {
1091  DIALOG_FIND dlg( m_frame );
1092  dlg.EnableWarp( false );
1093  dlg.SetCallback( std::bind( &SELECTION_TOOL::findCallback, this, _1 ) );
1094  dlg.ShowModal();
1095 
1096  return 0;
1097 }
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 1070 of file pcbnew/tools/selection_tool.cpp.

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

Referenced by find().

1071 {
1072  clearSelection();
1073 
1074  if( aItem )
1075  {
1076  select( aItem );
1077  EDA_RECT bbox = aItem->GetBoundingBox();
1078  BOX2D viewport( VECTOR2D( bbox.GetOrigin() ), VECTOR2D( bbox.GetSize() ) );
1079  getView()->SetViewport( viewport );
1080 
1081  // Inform other potentially interested tools
1083  }
1084 
1086 }
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:514
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec.
Definition: box2.h:41
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
const wxPoint & GetOrigin() const
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
Class EDA_RECT handles the component boundary box.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:870
const wxSize & GetSize() const
int SELECTION_TOOL::findMove ( const TOOL_EVENT aEvent)
private

Find an item and start moving.

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

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

Referenced by setTransitions().

1101 {
1103 
1104  if( module )
1105  {
1106  KIGFX::VIEW_CONTROLS* viewCtrls = getViewControls();
1107  clearSelection();
1108  toggleSelection( module );
1109 
1110  auto cursorPosition = viewCtrls->GetCursorPosition( false );
1111 
1112  // Place event on module origin first, so the generic anchor snap
1113  // doesn't just choose the closest pin for us
1114  viewCtrls->ForceCursorPosition( true, module->GetPosition() );
1115 
1116  // pick the component up and start moving
1117  m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
1118 
1119  // restore the previous cursor position
1120  viewCtrls->SetCursorPosition( cursorPosition, false );
1121  }
1122 
1123  return 0;
1124 }
const wxPoint & GetPosition() const override
Definition: class_module.h:155
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true)=0
Moves cursor to the requested position expressed in world coordinates.
void toggleSelection(BOARD_ITEM *aItem)
Function toggleSelection() Changes selection status of a given item.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
MODULE * module() const
Definition: pcb_tool.h:127
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
MODULE * GetFootprintFromBoardByReference()
Function GetFootprintFromBoardByReference.
Definition: modules.cpp:62
PCB_EDIT_FRAME* PCB_TOOL::frame ( ) const
inlineprotectedinherited

Definition at line 125 of file pcb_tool.h.

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

125 { return getEditFrame<PCB_EDIT_FRAME>(); }
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

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

Definition at line 188 of file tool_base.h.

References TOOL_BASE::getEditFrameInt().

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

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47
TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

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:210
TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 144 of file tool_base.h.

References TOOL_BASE::m_toolMgr.

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

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

200  {
201  EDA_ITEM* m = getModelInt();
202 
203  return static_cast<T*>( m );
204  }
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:165
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

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

Definition at line 77 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

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

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

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

References m_menu.

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

97  {
98  return m_menu;
99  }
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::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), and TOOL_MANAGER::runTool().

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

Function getView()

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

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

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

Referenced by PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), disambiguationMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), guessSelectionCandidates(), PCBNEW_CONTROL::HighContrastMode(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), GERBVIEW_SELECTION_TOOL::MeasureTool(), 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(), PNS::TOOL_BASE::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), PCBNEW_CONTROL::TrackDisplayMode(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), POINT_EDITOR::updateEditedPoint(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and ~SELECTION_TOOL().

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

Function getViewControls()

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 41 of file tool_base.cpp.

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

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

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

Function Go()

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

Definition at line 135 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

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

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

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

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

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

References COLLECTOR::Append(), B_SilkS, calcArea(), calcCommonArea(), calcMaxArea(), calcRatio(), COLLECTOR::CountType(), COLLECTOR::Empty(), F_SilkS, PCB_BASE_FRAME::GetActiveLayer(), COLLECTOR::GetCount(), BOARD_ITEM::GetLayer(), BOX2< Vec >::GetPosition(), BOX2< Vec >::GetSize(), TOOL_BASE::getView(), KIGFX::VIEW::GetViewport(), 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().

1714 {
1715  std::set<BOARD_ITEM*> rejected;
1716 
1717  const double footprintAreaRatio = 0.2;
1718  const double modulePadMinCoverRatio = 0.45;
1719  const double padViaAreaRatio = 0.5;
1720  const double trackViaLengthRatio = 2.0;
1721  const double trackTrackLengthRatio = 0.3;
1722  const double textToFeatureMinRatio = 0.2;
1723  const double textToFootprintMinRatio = 0.4;
1724  // If the common area of two compared items is above the following threshold, they cannot
1725  // be rejected (it means they overlap and it might be hard to pick one by selecting
1726  // its unique area).
1727  const double commonAreaRatio = 0.6;
1728 
1729  PCB_LAYER_ID actLayer = m_frame->GetActiveLayer();
1730 
1731  LSET silkLayers( 2, B_SilkS, F_SilkS );
1732 
1733  if( silkLayers[actLayer] )
1734  {
1735  std::set<BOARD_ITEM*> preferred;
1736 
1737  for( int i = 0; i < aCollector.GetCount(); ++i )
1738  {
1739  BOARD_ITEM* item = aCollector[i];
1740  KICAD_T type = item->Type();
1741 
1742  if( ( type == PCB_MODULE_TEXT_T || type == PCB_TEXT_T || type == PCB_LINE_T )
1743  && silkLayers[item->GetLayer()] )
1744  {
1745  preferred.insert( item );
1746  }
1747  }
1748 
1749  if( preferred.size() != 0 )
1750  {
1751  aCollector.Empty();
1752 
1753  for( BOARD_ITEM* item : preferred )
1754  aCollector.Append( item );
1755  return;
1756  }
1757  }
1758 
1759  if( aCollector.CountType( PCB_MODULE_TEXT_T ) > 0 )
1760  {
1761  for( int i = 0; i < aCollector.GetCount(); ++i )
1762  {
1763  if( TEXTE_MODULE* txt = dyn_cast<TEXTE_MODULE*>( aCollector[i] ) )
1764  {
1765  double textArea = calcArea( txt );
1766 
1767  for( int j = 0; j < aCollector.GetCount(); ++j )
1768  {
1769  if( i == j )
1770  continue;
1771 
1772  BOARD_ITEM* item = aCollector[j];
1773  double itemArea = calcArea( item );
1774  double areaRatio = calcRatio( textArea, itemArea );
1775  double commonArea = calcCommonArea( txt, item );
1776  double itemCommonRatio = calcRatio( commonArea, itemArea );
1777  double txtCommonRatio = calcRatio( commonArea, textArea );
1778 
1779  if( item->Type() == PCB_MODULE_T && areaRatio < textToFootprintMinRatio &&
1780  itemCommonRatio < commonAreaRatio )
1781  rejected.insert( item );
1782 
1783  switch( item->Type() )
1784  {
1785  case PCB_TRACE_T:
1786  case PCB_PAD_T:
1787  case PCB_LINE_T:
1788  case PCB_VIA_T:
1789  case PCB_MODULE_T:
1790  if( areaRatio > textToFeatureMinRatio && txtCommonRatio < commonAreaRatio )
1791  rejected.insert( txt );
1792  break;
1793  default:
1794  break;
1795  }
1796  }
1797  }
1798  }
1799  }
1800 
1801  if( aCollector.CountType( PCB_MODULE_T ) > 0 )
1802  {
1803  double maxArea = calcMaxArea( aCollector, PCB_MODULE_T );
1804  BOX2D viewportD = getView()->GetViewport();
1805  BOX2I viewport( VECTOR2I( viewportD.GetPosition() ), VECTOR2I( viewportD.GetSize() ) );
1806 
1807  for( int i = 0; i < aCollector.GetCount(); ++i )
1808  {
1809  if( MODULE* mod = dyn_cast<MODULE*>( aCollector[i] ) )
1810  {
1811  double normalizedArea = calcRatio( calcArea( mod ), maxArea );
1812 
1813  if( normalizedArea > footprintAreaRatio
1814  // filter out components larger than the viewport
1815  || mod->ViewBBox().Contains( viewport ) )
1816  {
1817  rejected.insert( mod );
1818  }
1819  }
1820  }
1821  }
1822 
1823  if( aCollector.CountType( PCB_PAD_T ) > 0 )
1824  {
1825  for( int i = 0; i < aCollector.GetCount(); ++i )
1826  {
1827  if( D_PAD* pad = dyn_cast<D_PAD*>( aCollector[i] ) )
1828  {
1829  double ratio = pad->GetParent()->PadCoverageRatio();
1830 
1831  if( ratio < modulePadMinCoverRatio )
1832  rejected.insert( pad->GetParent() );
1833  }
1834  }
1835  }
1836 
1837  if( aCollector.CountType( PCB_VIA_T ) > 0 )
1838  {
1839  for( int i = 0; i < aCollector.GetCount(); ++i )
1840  {
1841  if( VIA* via = dyn_cast<VIA*>( aCollector[i] ) )
1842  {
1843  double viaArea = calcArea( via );
1844 
1845  for( int j = 0; j < aCollector.GetCount(); ++j )
1846  {
1847  if( i == j )
1848  continue;
1849 
1850  BOARD_ITEM* item = aCollector[j];
1851  double areaRatio = calcRatio( viaArea, calcArea( item ) );
1852 
1853  if( item->Type() == PCB_MODULE_T && areaRatio < modulePadMinCoverRatio )
1854  rejected.insert( item );
1855 
1856  if( item->Type() == PCB_PAD_T && areaRatio < padViaAreaRatio )
1857  rejected.insert( item );
1858 
1859  if( TRACK* track = dyn_cast<TRACK*>( item ) )
1860  {
1861  if( track->GetNetCode() != via->GetNetCode() )
1862  continue;
1863 
1864  double lenRatio = (double) ( track->GetLength() + track->GetWidth() ) /
1865  (double) via->GetWidth();
1866 
1867  if( lenRatio > trackViaLengthRatio )
1868  rejected.insert( track );
1869  }
1870  }
1871  }
1872  }
1873  }
1874 
1875  int nTracks = aCollector.CountType( PCB_TRACE_T );
1876 
1877  if( nTracks > 0 )
1878  {
1879  double maxLength = 0.0;
1880  double minLength = std::numeric_limits<double>::max();
1881  double maxArea = 0.0;
1882  const TRACK* maxTrack = nullptr;
1883 
1884  for( int i = 0; i < aCollector.GetCount(); ++i )
1885  {
1886  if( TRACK* track = dyn_cast<TRACK*>( aCollector[i] ) )
1887  {
1888  maxLength = std::max( track->GetLength(), maxLength );
1889  maxLength = std::max( (double) track->GetWidth(), maxLength );
1890 
1891  minLength = std::min( std::max( track->GetLength(), (double) track->GetWidth() ), minLength );
1892 
1893  double area = track->GetLength() * track->GetWidth();
1894 
1895  if( area > maxArea )
1896  {
1897  maxArea = area;
1898  maxTrack = track;
1899  }
1900  }
1901  }
1902 
1903  if( maxLength > 0.0 && minLength / maxLength < trackTrackLengthRatio && nTracks > 1 )
1904  {
1905  for( int i = 0; i < aCollector.GetCount(); ++i )
1906  {
1907  if( TRACK* track = dyn_cast<TRACK*>( aCollector[i] ) )
1908  {
1909  double ratio = std::max( (double) track->GetWidth(), track->GetLength() ) / maxLength;
1910 
1911  if( ratio > trackTrackLengthRatio )
1912  rejected.insert( track );
1913  }
1914  }
1915  }
1916 
1917  for( int j = 0; j < aCollector.GetCount(); ++j )
1918  {
1919  if( MODULE* mod = dyn_cast<MODULE*>( aCollector[j] ) )
1920  {
1921  double ratio = calcRatio( maxArea, mod->GetFootprintRect().GetArea() );
1922 
1923  if( ratio < modulePadMinCoverRatio && calcCommonArea( maxTrack, mod ) < commonAreaRatio )
1924  rejected.insert( mod );
1925  }
1926  }
1927  }
1928 
1929  if( (unsigned) aCollector.GetCount() > rejected.size() ) // do not remove everything
1930  {
1931  for( BOARD_ITEM* item : rejected )
1932  {
1933  aCollector.Remove( item );
1934  }
1935  }
1936 }
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:212
static double calcMaxArea(GENERAL_COLLECTOR &aCollector, KICAD_T aType)
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:104
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
const Vec & GetSize() const
Definition: box2.h:177
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590
int CountType(KICAD_T aType)
Function CountType counts the number of items matching aType.
Class BOX2 handles a 2-D bounding box, built on top of an origin point and size vector, both of templated class Vec.
Definition: box2.h:41
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
static double calcCommonArea(const BOARD_ITEM *aItem, const BOARD_ITEM *aOther)
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h: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
PCB_LAYER_ID
A quick note on layer IDs:
Class LSET is a set of PCB_LAYER_IDs.
BOX2D GetViewport() const
Function GetViewport() Returns the current viewport visible area rectangle.
Definition: view.cpp:502
const Vec & GetPosition() const
Definition: box2.h:182
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
#define max(a, b)
Definition: auxiliary.h:86
double calcRatio(double a, double b)
static double calcArea(const BOARD_ITEM *aItem)
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
#define mod(a, n)
Definition: greymap.cpp:24
#define min(a, b)
Definition: auxiliary.h:85
bool SELECTION_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from TOOL_BASE.

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

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

194 {
195  auto selectMenu = std::make_shared<SELECT_MENU>();
196  selectMenu->SetTool( this );
197  m_menu.AddSubMenu( selectMenu );
198 
199  auto& menu = m_menu.GetMenu();
200 
201  menu.AddMenu( selectMenu.get(), false, SELECTION_CONDITIONS::NotEmpty );
202  // only show separator if there is a Select menu to show above it
203  menu.AddSeparator( SELECTION_CONDITIONS::NotEmpty, 1000 );
204 
205  m_menu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
206 
207  return true;
208 }
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()
bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

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

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

Function Main()

The main loop.

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

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

Referenced by setTransitions().

235 {
236  // Main loop: keep receiving events
237  while( OPT_TOOL_EVENT evt = Wait() )
238  {
239  // Should selected items be added to the current selection or
240  // become the new selection (discarding previously selected items)
241  m_additive = evt->Modifier( MD_SHIFT );
242 
243  // Should selected items be REMOVED from the current selection?
244  // This will be ignored if the SHIFT modifier is pressed
245  m_subtractive = !m_additive && evt->Modifier( MD_CTRL );
246 
247  // Single click? Select single object
248  if( evt->IsClick( BUT_LEFT ) )
249  {
250  if( evt->Modifier( MD_CTRL ) && !m_editModules )
251  {
253  }
254  else
255  {
256  // If no modifier keys are pressed, clear the selection
257  if( !m_additive )
258  {
259  clearSelection();
260  }
261 
262  selectPoint( evt->Position() );
263  }
264  }
265 
266  // right click? if there is any object - show the context menu
267  else if( evt->IsClick( BUT_RIGHT ) )
268  {
269  if( m_selection.Empty() )
270  {
271  selectPoint( evt->Position() );
272  m_selection.SetIsHover( true );
273  }
274 
276  }
277 
278  // double click? Display the properties window
279  else if( evt->IsDblClick( BUT_LEFT ) )
280  {
281  if( m_selection.Empty() )
282  selectPoint( evt->Position() );
283 
285  }
286 
287  // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them
288  else if( evt->IsDrag( BUT_LEFT ) )
289  {
290  if( m_additive || m_subtractive )
291  {
292  selectMultiple();
293  }
294  else if( m_selection.Empty() )
295  {
296  // There is nothing selected, so try to select something
297  if( !selectCursor() )
298  {
299  // If nothings has been selected or user wants to select more
300  // draw the selection box
301  selectMultiple();
302  }
303  else
304  {
305  m_selection.SetIsHover( true );
306  m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
307  }
308  }
309 
310  else
311  {
312  // Check if dragging has started within any of selected items bounding box
313  if( selectionContains( evt->Position() ) )
314  {
315  // Yes -> run the move tool and wait till it finishes
316  m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
317  }
318  else
319  {
320  // No -> clear the selection list
321  clearSelection();
322  }
323  }
324  }
325 
326  else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
327  {
328  clearSelection();
329  }
330 
331  else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )
332  {
333  m_menu.CloseContextMenu( evt );
334  }
335  }
336 
337  // This tool is supposed to be active forever
338  assert( false );
339 
340  return 0;
341 }
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:215
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:105
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
void SetIsHover(bool aIsHover)
Definition: selection.h:61
bool 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:129
bool m_subtractive
Flag saying if items should be removed from the current selection.
void CloseContextMenu(OPT_TOOL_EVENT &evt)
Function CloseContextMenu.
Definition: tool_menu.cpp:82
static TOOL_ACTION highlightNet
Definition: pcb_actions.h:372
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 1357 of file pcbnew/tools/selection_tool.cpp.

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

1358 {
1359  int count = aCollector->GetPrimaryCount(); // try to use preferred layer
1360 
1361  if( 0 == count )
1362  count = aCollector->GetCount();
1363 
1364  for( int i = 0; i < count; ++i )
1365  {
1366  if( ( *aCollector )[i]->Type() != PCB_MODULE_T )
1367  return NULL;
1368  }
1369 
1370  // All are modules, now find smallest MODULE
1371  int minDim = 0x7FFFFFFF;
1372  int minNdx = 0;
1373 
1374  for( int i = 0; i < count; ++i )
1375  {
1376  MODULE* module = (MODULE*) ( *aCollector )[i];
1377 
1378  int lx = module->GetBoundingBox().GetWidth();
1379  int ly = module->GetBoundingBox().GetHeight();
1380 
1381  int lmin = std::min( lx, ly );
1382 
1383  if( lmin < minDim )
1384  {
1385  minDim = lmin;
1386  minNdx = i;
1387  }
1388  }
1389 
1390  return (*aCollector)[minNdx];
1391 }
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...
MODULE * module() const
Definition: pcb_tool.h:127
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 350 of file pcbnew/tools/selection_tool.cpp.

References SELECTION::ClearReferencePoint(), 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::copyToClipboard(), EDIT_TOOL::CreateArray(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::ExchangeFootprints(), EDIT_TOOL::Flip(), EDIT_TOOL::Main(), EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), EDIT_TOOL::Rotate(), and EDIT_TOOL::uniqueSelected().

351 {
352  if( m_selection.Empty() )
353  {
355  m_selection.SetIsHover( true );
357  }
358 
359  // Be careful with iterators: items can be removed from list
360  // that invalidate iterators.
361  for( unsigned ii = 0; ii < m_selection.GetSize(); ii++ )
362  {
363  EDA_ITEM* item = m_selection[ii];
364 
365  if( ( aFlags & SELECTION_EDITABLE ) && item->Type() == PCB_MARKER_T )
366  {
367  unselect( static_cast<BOARD_ITEM *>( item ) );
368  }
369  }
370 
371  if( aFlags & SELECTION_SANITIZE_PADS )
373 
374  return m_selection;
375 }
void ClearReferencePoint()
Definition: selection.h:188
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void SetIsHover(bool aIsHover)
Definition: selection.h:61
SELECTION m_selection
Current state of selection.
virtual unsigned int GetSize() const override
Function GetSize() Returns the number of stored items.
Definition: selection.h:86
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h: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:165
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 211 of file pcbnew/tools/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().

212 {
213  m_frame = getEditFrame<PCB_BASE_FRAME>();
214  m_locked = true;
215 
216  if( aReason == TOOL_BASE::MODEL_RELOAD )
217  {
218  // Remove pointers to the selected items from containers
219  // without changing their properties (as they are already deleted
220  // while a new board is loaded)
221  m_selection.Clear();
222  getView()->GetPainter()->GetSettings()->SetHighlight( false );
223  }
224  else
225  // Restore previous properties of selected items and remove them from containers
226  clearSelection();
227 
228  // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
229  getView()->Remove( &m_selection );
230  getView()->Add( &m_selection );
231 }
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:342
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
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:312
void SetHighlight(bool aEnabled, int aNetcode=-1)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specifie...
Definition: painter.h:140
void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 85 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

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

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

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

Definition at line 1947 of file pcbnew/tools/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(), RequestSelection(), and selectPRitem().

1948 {
1949  std::set<BOARD_ITEM*> rejected;
1950  std::set<BOARD_ITEM*> added;
1951 
1952  if( !m_editModules )
1953  {
1954  for( auto i : m_selection )
1955  {
1956  auto item = static_cast<BOARD_ITEM*>( i );
1957  if( item->Type() == PCB_PAD_T )
1958  {
1959  MODULE* mod = static_cast<MODULE*>( item->GetParent() );
1960 
1961  // case 1: module (or its pads) are locked
1962  if( mod && ( mod->PadsLocked() || mod->IsLocked() ) )
1963  {
1964  rejected.insert( item );
1965 
1966  if( !mod->IsLocked() && !mod->IsSelected() )
1967  added.insert( mod );
1968  }
1969 
1970  // case 2: multi-item selection contains both the module and its pads - remove the pads
1971  if( mod && m_selection.Contains( mod ) )
1972  rejected.insert( item );
1973  }
1974  }
1975  }
1976 
1977  if( !rejected.empty() )
1978  {
1979  for( BOARD_ITEM* item : rejected )
1980  unselect( item );
1981 
1982  // Inform other potentially interested tools
1984  }
1985 
1986  if( !added.empty() )
1987  {
1988  for( BOARD_ITEM* item : added )
1989  select( item );
1990 
1991  // Inform other potentially interested tools
1993  }
1994 
1995  return true;
1996 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool IsSelected() const
Definition: base_struct.h:235
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:272
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SELECTION m_selection
Current state of selection.
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:236
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
bool m_editModules
Definition: pcb_tool.h:129
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
#define mod(a, n)
Definition: greymap.cpp:24
void SELECTION_TOOL::select ( BOARD_ITEM aItem)
private

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

Parameters
aItemis an item to be selected.

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

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

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

1525 {
1526  if( aItem->IsSelected() )
1527  {
1528  return;
1529  }
1530 
1531  if( aItem->Type() == PCB_PAD_T )
1532  {
1533  MODULE* module = static_cast<MODULE*>( aItem->GetParent() );
1534 
1535  if( m_selection.Contains( module ) )
1536  return;
1537  }
1538 
1539  m_selection.Add( aItem );
1540  selectVisually( aItem );
1541 
1542 
1543  if( m_selection.Size() == 1 )
1544  {
1545  // Set as the current item, so the information about selection is displayed
1546  m_frame->SetCurItem( aItem, true );
1547  }
1548  else if( m_selection.Size() == 2 ) // Check only for 2, so it will not be
1549  { // called for every next selected item
1550  // If multiple items are selected, do not show the information about the selected item
1551  m_frame->SetCurItem( NULL, true );
1552  }
1553 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
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:235
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.
MODULE * module() const
Definition: pcb_tool.h:127
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 1394 of file pcbnew/tools/selection_tool.cpp.

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

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

1395 {
1396  // Is high contrast mode enabled?
1397  bool highContrast = getView()->GetPainter()->GetSettings()->GetHighContrast();
1398 
1399  int layers[KIGFX::VIEW::VIEW_MAX_LAYERS], layers_count;
1400 
1401  // Filter out items that do not belong to active layers
1402  const std::set<unsigned int>& activeLayers = getView()->GetPainter()->
1403  GetSettings()->GetActiveLayers();
1404 
1405  aItem->ViewGetLayers( layers, layers_count );
1406 
1407  if( highContrast )
1408  {
1409  bool onActive = false; // Is the item on any of active layers?
1410 
1411  for( int i = 0; i < layers_count; ++i )
1412  {
1413  if( activeLayers.count( layers[i] ) > 0 ) // Item is on at least one of the active layers
1414  {
1415  onActive = true;
1416  break;
1417  }
1418  }
1419 
1420  if( !onActive ) // We do not want to select items that are in the background
1421  {
1422  return false;
1423  }
1424  }
1425 
1426  switch( aItem->Type() )
1427  {
1428  case PCB_ZONE_AREA_T:
1429  // Keepout zones can exist on multiple layers!
1430  {
1431  auto* zone = static_cast<const ZONE_CONTAINER*>( aItem );
1432 
1433  if( zone && zone->GetIsKeepout() )
1434  {
1435  auto zoneLayers = zone->GetLayerSet().Seq();
1436 
1437  for( unsigned int i = 0; i < zoneLayers.size(); i++ )
1438  {
1439  if( board()->IsLayerVisible( zoneLayers[i] ) )
1440  {
1441  return true;
1442  }
1443  }
1444 
1445  // No active layers selected!
1446  return false;
1447  }
1448  }
1449  break;
1450  case PCB_VIA_T:
1451  {
1452  // For vias it is enough if only one of layers is visible
1453  PCB_LAYER_ID top, bottom;
1454 
1455  static_cast<const VIA*>( aItem )->LayerPair( &top, &bottom );
1456 
1457  return board()->IsLayerVisible( top ) || board()->IsLayerVisible( bottom );
1458  }
1459  break;
1460 
1461  case PCB_MODULE_T:
1462 
1463  // In the module editor, we do not want to select the module itself
1464  // rather, the module sub-components should be selected individually
1465  if( m_editModules )
1466  {
1467  return false;
1468  }
1469 
1470  if( aItem->IsOnLayer( F_Cu ) && board()->IsElementVisible( LAYER_MOD_FR ) )
1471  return !m_editModules;
1472 
1473  if( aItem->IsOnLayer( B_Cu ) && board()->IsElementVisible( LAYER_MOD_BK ) )
1474  return !m_editModules;
1475 
1476  return false;
1477 
1478  break;
1479 
1480  case PCB_MODULE_TEXT_T:
1481  if( m_multiple && !m_editModules )
1482  return false;
1483 
1484  return view()->IsVisible( aItem ) && board()->IsLayerVisible( aItem->GetLayer() );
1485 
1486  case PCB_MODULE_EDGE_T:
1487  case PCB_PAD_T:
1488  {
1489  // Multiple selection is only allowed in modedit mode
1490  // In pcbnew, you have to select subparts of modules
1491  // one-by-one, rather than with a drag selection.
1492  // This is so you can pick up items under an (unlocked)
1493  // module without also moving the module's sub-parts.
1494  if( m_multiple && !m_editModules )
1495  return false;
1496 
1497  // When editing modules, it's allowed to select them, even when
1498  // locked, since you already have to explicitly activate the
1499  // module editor to get to this stage
1500  if ( !m_editModules )
1501  {
1502  MODULE* mod = static_cast<const D_PAD*>( aItem )->GetParent();
1503  if( mod && mod->IsLocked() )
1504  return false;
1505  }
1506 
1507  break;
1508  }
1509 
1510  // These are not selectable
1511  case NOT_USED:
1512  case TYPE_NOT_INIT:
1513  return false;
1514 
1515  default: // Suppress warnings
1516  break;
1517  }
1518 
1519  // All other items are selected only if the layer on which they exist is visible
1520  return board()->IsLayerVisible( aItem->GetLayer() );
1521 }
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
bool GetHighContrast() const
Function GetHighContrast Returns information about high contrast display mode.
Definition: painter.h:161
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Function IsOnLayer tests to see if this object is on the given layer.
bool m_multiple
Flag saying if multiple selection mode is active.
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
the 3d code uses this value
Definition: typeinfo.h:92
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on...
show modules on back
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
show modules on front
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Function Seq returns an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:337
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
Definition: class_zone.cpp:237
class MODULE, a footprint
Definition: typeinfo.h:101
PCB_LAYER_ID
A quick note on layer IDs:
static const int VIEW_MAX_LAYERS
maximum number of layers that may be shown
Definition: view.h:652
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
TOOL_SETTINGS & GetSettings()
Definition: tool_base.cpp:77
bool IsLocked() const override
Function IsLocked.
Definition: class_module.h:236
bool m_editModules
Definition: pcb_tool.h:129
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Function IsElementVisible tests whether a given element category is visible.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
bool IsVisible(const VIEW_ITEM *aItem) const
Returns information if the item is visible (or not).
Definition: view.cpp:1371
#define mod(a, n)
Definition: greymap.cpp:24
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:451
BOARD * board() const
Definition: pcb_tool.h:126
void SELECTION_TOOL::selectAllItemsConnectedToItem ( BOARD_CONNECTED_ITEM aSourceItem)
private

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

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

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

Referenced by selectCopper().

840 {
841  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
842  auto connectivity = board()->GetConnectivity();
843 
844  std::list<BOARD_CONNECTED_ITEM*> items;
845  items = connectivity->GetConnectedItems( &aSourceItem, types );
846 
847  for( auto item : connectivity->GetConnectedItems( &aSourceItem, types ) )
848  select( item );
849 }
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
search types array terminator (End Of Types)
Definition: typeinfo.h:94
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
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
BOARD * board() const
Definition: pcb_tool.h:126
void SELECTION_TOOL::selectAllItemsConnectedToTrack ( TRACK aSourceTrack)
private

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

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

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

Referenced by selectAllItemsOnSheet(), and selectConnection().

826 {
827  int segmentCount;
828  TRACK* trackList = board()->MarkTrace( &aSourceTrack, &segmentCount,
829  nullptr, nullptr, true );
830 
831  for( int i = 0; i < segmentCount; ++i )
832  {
833  select( trackList );
834  trackList = trackList->Next();
835  }
836 }
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:98
BOARD * board() const
Definition: pcb_tool.h:126
void SELECTION_TOOL::selectAllItemsOnNet ( int  aNetCode)
private

Selects all items with the given net code.

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

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

Referenced by selectNet().

853 {
854  constexpr KICAD_T types[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
855  auto connectivity = board()->GetConnectivity();
856 
857  for( auto item : connectivity->GetNetItems( aNetCode, types ) )
858  select( item );
859 }
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
search types array terminator (End Of Types)
Definition: typeinfo.h:94
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
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Function GetConnectivity() returns list of missing connections between components/tracks.
Definition: class_board.h:290
BOARD * board() const
Definition: pcb_tool.h:126
void SELECTION_TOOL::selectAllItemsOnSheet ( wxString &  aSheetpath)
private

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

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

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

Referenced by selectOnSheetFromEeschema(), and selectSameSheet().

892 {
893  auto modules = board()->m_Modules.GetFirst();
894  std::list<MODULE*> modList;
895 
896  // store all modules that are on that sheet
897  for( MODULE* mitem = modules; mitem; mitem = mitem->Next() )
898  {
899  if( mitem != NULL && mitem->GetPath().Contains( aSheetpath ) )
900  {
901  modList.push_back( mitem );
902  }
903  }
904 
905  //Generate a list of all pads, and of all nets they belong to.
906  std::list<int> netcodeList;
907  std::list<BOARD_CONNECTED_ITEM*> padList;
908  for( MODULE* mmod : modList )
909  {
910  for( auto pad : mmod->Pads() )
911  {
912  if( pad->IsConnected() )
913  {
914  netcodeList.push_back( pad->GetNetCode() );
915  padList.push_back( pad );
916  }
917  }
918  }
919  // remove all duplicates
920  netcodeList.sort();
921  netcodeList.unique();
922 
923  // auto select trivial connections segments which are launched from the pads
924  std::list<TRACK*> launchTracks;
925 
926  for( auto pad : padList )
927  {
928  launchTracks = board()->GetTracksByPosition( pad->GetPosition() );
929 
930  for( auto track : launchTracks )
931  {
933  }
934  }
935 
936  // now we need to find all modules that are connected to each of these nets
937  // then we need to determine if these modules are in the list of modules
938  // belonging to this sheet ( modList )
939  std::list<int> removeCodeList;
940  constexpr KICAD_T padType[] = { PCB_PAD_T, EOT };
941 
942  for( int netCode : netcodeList )
943  {
944  for( BOARD_CONNECTED_ITEM* mitem : board()->GetConnectivity()->GetNetItems( netCode, padType ) )
945  {
946  if( mitem->Type() == PCB_PAD_T)
947  {
948  bool found = ( std::find( modList.begin(), modList.end(),
949  mitem->GetParent() ) != modList.end() );
950 
951  if( !found )
952  {
953  // if we cannot find the module of the pad in the modList
954  // then we can assume that that module is not located in the same
955  // schematic, therefore invalidate this netcode.
956  removeCodeList.push_back( netCode );
957  break;
958  }
959  }
960  }
961  }
962 
963  // remove all duplicates
964  removeCodeList.sort();
965  removeCodeList.unique();
966 
967  for( int removeCode : removeCodeList )
968  {
969  netcodeList.remove( removeCode );
970  }
971 
972  std::list<BOARD_CONNECTED_ITEM*> localConnectionList;
973  constexpr KICAD_T trackViaType[] = { PCB_TRACE_T, PCB_VIA_T, EOT };
974 
975  for( int netCode : netcodeList )
976  {
977  for( BOARD_CONNECTED_ITEM* item : board()->GetConnectivity()->GetNetItems( netCode, trackViaType ) )
978  {
979  localConnectionList.push_back( item );
980  }
981  }
982 
983  for( BOARD_ITEM* i : modList )
984  {
985  if( i != NULL )
986  select( i );
987  }
988 
989  for( BOARD_CONNECTED_ITEM* i : localConnectionList )
990  {
991  if( i != NULL )
992  select( i );
993  }
994 }
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:100
std::list< TRACK * > GetTracksByPosition(const wxPoint &aPosition, PCB_LAYER_ID aLayer=PCB_LAYER_ID(-1)) const
Function GetTracksByPosition finds the list of tracks that starts or ends at aPosition on aLayer...
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
search types array terminator (End Of Types)
Definition: typeinfo.h:94
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
T * GetFirst() const
Function GetFirst returns the first T* in the list without removing it, or NULL if the list is empty...
Definition: dlist.h:163
void selectAllItemsConnectedToTrack(TRACK &aSourceTrack)
Selects all items connected by copper tracks to the given TRACK.
DLIST< MODULE > m_Modules
Definition: class_board.h:245
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
BOARD * board() const
Definition: pcb_tool.h:126
int SELECTION_TOOL::selectConnection ( const TOOL_EVENT aEvent)
private

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

Definition at line 770 of file pcbnew/tools/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().

771 {
772  if( !selectCursor() )
773  return 0;
774 
775  // copy the selection, since we're going to iterate and modify
776  auto selection = m_selection.GetItems();
777 
778  for( auto item : selection )
779  {
780  // only TRACK items can be checked for trivial connections
781  if( item->Type() == PCB_TRACE_T || item->Type() == PCB_VIA_T )
782  {
783  TRACK& trackItem = static_cast<TRACK&>( *item );
784  selectAllItemsConnectedToTrack( trackItem );
785  }
786  }
787 
788  // Inform other potentially interested tools
789  if( m_selection.Size() > 0 )
791 
792  return 0;
793 }
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:215
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
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SELECTION m_selection
Current state of selection.
static const TOOL_EVENT 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
int SELECTION_TOOL::selectCopper ( const TOOL_EVENT aEvent)
private

Selects items with a continuous copper connection to items in selection

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

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

Referenced by setTransitions().

797 {
798  if( !selectCursor() )
799  return 0;
800 
801  // copy the selection, since we're going to iterate and modify
802  auto selection = m_selection.GetItems();
803 
804  for( auto i : selection )
805  {
806  auto item = static_cast<BOARD_ITEM*>( i );
807 
808  // only connected items can be traversed in the ratsnest
809  if( item->IsConnected() )
810  {
811  auto& connItem = static_cast<BOARD_CONNECTED_ITEM&>( *item );
812 
813  selectAllItemsConnectedToItem( connItem );
814  }
815  }
816 
817  // Inform other potentially interested tools
818  if( m_selection.Size() > 0 )
820 
821  return 0;
822 }
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:215
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
const std::set< EDA_ITEM * > GetItems() const
Definition: selection.h:117
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
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 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 476 of file pcbnew/tools/selection_tool.cpp.

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

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

477 {
478  if( aSelectAlways || m_selection.Empty() )
479  {
480  clearSelection();
481  selectPoint( getViewControls()->GetCursorPosition( false ) );
482  }
483 
484  return !m_selection.Empty();
485 }
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:41
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 1618 of file pcbnew/tools/selection_tool.cpp.

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

Referenced by Main().

1619 {
1620  const unsigned GRIP_MARGIN = 20;
1621  VECTOR2D margin = getView()->ToWorld( VECTOR2D( GRIP_MARGIN, GRIP_MARGIN ), false );
1622 
1623  // Check if the point is located within any of the currently selected items bounding boxes
1624  for( auto item : m_selection )
1625  {
1626  BOX2I itemBox = item->ViewBBox();
1627  itemBox.Inflate( margin.x, margin.y ); // Give some margin for gripping an item
1628 
1629  if( itemBox.Contains( aPoint ) )
1630  return true;
1631  }
1632 
1633  return false;
1634 }
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:441
VECTOR2< double > VECTOR2D
Definition: vector2d.h:589
SELECTION m_selection
Current state of selection.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:266
int SELECTION_TOOL::SelectItem ( const TOOL_EVENT aEvent)

Item selection event handler.

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

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

Referenced by setTransitions().

717 {
718  // Check if there is an item to be selected
719  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
720 
721  if( item )
722  {
723  select( item );
724 
725  // Inform other potentially interested tools
727  }
728 
729  return 0;
730 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
int SELECTION_TOOL::SelectItems ( const TOOL_EVENT aEvent)

Multiple item selection event handler

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

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

Referenced by setTransitions().

697 {
698  std::vector<BOARD_ITEM*>* items = aEvent.Parameter<std::vector<BOARD_ITEM*>*>();
699 
700  if( items )
701  {
702  // Perform individual selection of each item
703  // before processing the event.
704  for( auto item : *items )
705  {
706  select( item );
707  }
708 
710  }
711 
712  return 0;
713 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
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 488 of file pcbnew/tools/selection_tool.cpp.

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

Referenced by Main().

489 {
490  bool cancelled = false; // Was the tool cancelled while it was running?
491  m_multiple = true; // Multiple selection mode is active
492  KIGFX::VIEW* view = getView();
493  getViewControls()->SetAutoPan( true );
494 
496  view->Add( &area );
497 
498  while( OPT_TOOL_EVENT evt = Wait() )
499  {
500  if( evt->IsCancel() )
501  {
502  cancelled = true;
503  break;
504  }
505 
506  if( evt->IsDrag( BUT_LEFT ) )
507  {
508 
509  // Start drawing a selection box
510  area.SetOrigin( evt->DragOrigin() );
511  area.SetEnd( evt->Position() );
512  area.SetAdditive( m_additive );
514 
515  view->SetVisible( &area, true );
516  view->Update( &area );
517  }
518 
519  if( evt->IsMouseUp( BUT_LEFT ) )
520  {
521  // End drawing the selection box
522  view->SetVisible( &area, false );
523 
524  // Mark items within the selection box as selected
525  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
526 
527  // Filter the view items based on the selection box
528  BOX2I selectionBox = area.ViewBBox();
529  view->Query( selectionBox, selectedItems ); // Get the list of selected items
530 
531  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR>::iterator it, it_end;
532 
533  int width = area.GetEnd().x - area.GetOrigin().x;
534  int height = area.GetEnd().y - area.GetOrigin().y;
535 
536  // Construct an EDA_RECT to determine BOARD_ITEM selection
537  EDA_RECT selectionRect( wxPoint( area.GetOrigin().x, area.GetOrigin().y ),
538  wxSize( width, height ) );
539 
540  selectionRect.Normalize();
541 
542  for( it = selectedItems.begin(), it_end = selectedItems.end(); it != it_end; ++it )
543  {
544  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first );
545 
546  if( !item || !selectable( item ) )
547  continue;
548 
549  /* Selection mode depends on direction of drag-selection:
550  * Left > Right : Select objects that are fully enclosed by selection
551  * Right > Left : Select objects that are crossed by selection
552  */
553 
554  if( width >= 0 )
555  {
556  if( selectionBox.Contains( item->ViewBBox() ) )
557  {
558  if( m_subtractive )
559  unselect( item );
560  else
561  select( item );
562  }
563  }
564  else
565  {
566  if( item->HitTest( selectionRect, false ) )
567  {
568  if( m_subtractive )
569  unselect( item );
570  else
571  select( item );
572  }
573 
574  }
575  }
576 
577  if( m_selection.Size() == 1 )
578  m_frame->SetCurItem( static_cast<BOARD_ITEM*>( m_selection.Front() ) );
579  else
580  m_frame->SetCurItem( NULL );
581 
582  // Inform other potentially interested tools
583  if( !m_selection.Empty() )
585 
586  break; // Stop waiting for events
587  }
588  }
589 
590  // Stop drawing the selection box
591  view->Remove( &area );
592  m_multiple = false; // Multiple selection mode is inactive
593  getViewControls()->SetAutoPan( false );
594 
595  if( !cancelled )
597 
598  return cancelled;
599 }
void ClearReferencePoint()
Definition: selection.h:188
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:106
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
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:418
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
bool m_multiple
Flag saying if multiple selection mode is active.
void SetOrigin(VECTOR2I aOrigin)
Set the origin of the rectange (the fixed corner)
bool m_additive
Flag saying if items should be added to the current selection or rather replace it.
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:139
EDA_ITEM * Front() const
Definition: selection.h:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
void SetCurItem(BOARD_ITEM *aItem, bool aDisplayInfo=true)
Function SetCurItem sets the currently selected item and displays it in the MsgPanel.
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
bool selectable(const BOARD_ITEM *aItem) const
Function selectable() Checks conditions for an item to be selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers. ...
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void Normalize()
Function Normalize ensures that the height ant width are positive.
bool m_subtractive
Flag saying if items should be removed from the current selection.
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
void SetSubtractive(bool aSubtractive)
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
Class EDA_RECT handles the component boundary box.
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Sets the item visibility.
Definition: view.cpp:1331
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:312
Class VIEW.
Definition: view.h:58
virtual const BOX2I ViewBBox() const override
Function ViewBBox() returns the bounding box of the item covering all its layers. ...
void SetAdditive(bool aAdditive)
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 862 of file pcbnew/tools/selection_tool.cpp.

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

Referenced by setTransitions().

863 {
864  if( !selectCursor() )
865  return 0;
866 
867  // copy the selection, since we're going to iterate and modify
868  auto selection = m_selection.GetItems();
869 
870  for( auto i : selection )
871  {
872  auto item = static_cast<BOARD_ITEM*>( i );
873 
874  // only connected items get a net code
875  if( item->IsConnected() )
876  {
877  auto& connItem = static_cast<BOARD_CONNECTED_ITEM&>( *item );
878 
879  selectAllItemsOnNet( connItem.GetNetCode() );
880  }
881  }
882 
883  // Inform other potentially interested tools
884  if( m_selection.Size() > 0 )
886 
887  return 0;
888 }
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:215
Class BOARD_CONNECTED_ITEM is a base class derived from BOARD_ITEM for items that can be connected an...
const std::set< EDA_ITEM * > GetItems() const
Definition: selection.h:117
void selectAllItemsOnNet(int aNetCode)
Selects all items with the given net code.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
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
int SELECTION_TOOL::selectOnSheetFromEeschema ( const TOOL_EVENT aEvent)
private

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

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

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

Referenced by setTransitions().

1021 {
1022  clearSelection();
1023  wxString* sheetpath = aEvent.Parameter<wxString*>();
1024 
1025  selectAllItemsOnSheet( *sheetpath );
1026 
1027  zoomFitSelection();
1028 
1029  if( m_selection.Size() > 0 )
1031 
1032  return 0;
1033 }
void zoomFitSelection(void)
Zooms the screen to center and fit the current selection.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void selectAllItemsOnSheet(wxString &aSheetpath)
Selects all items with the given sheet timestamp name (the sheet path)
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
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 406 of file pcbnew/tools/selection_tool.cpp.

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

Referenced by Main(), and selectCursor().

407 {
408  BOARD_ITEM* item;
410  GENERAL_COLLECTOR collector;
411 
412  collector.Collect( board(),
414  wxPoint( aWhere.x, aWhere.y ), guide );
415 
416  bool anyCollected = collector.GetCount() != 0;
417 
418  // Remove unselectable items
419  for( int i = collector.GetCount() - 1; i >= 0; --i )
420  {
421  if( !selectable( collector[i] ) || ( aOnDrag && collector[i]->IsLocked() ) )
422  collector.Remove( i );
423  }
424 
426 
427  switch( collector.GetCount() )
428  {
429  case 0:
430  if( !m_additive && anyCollected )
431  {
432  clearSelection();
433  }
434 
435  return false;
436 
437  case 1:
438  toggleSelection( collector[0] );
439 
440  return true;
441 
442  default:
443  // Apply some ugly heuristics to avoid disambiguation menus whenever possible
444  guessSelectionCandidates( collector );
445 
446  // Let's see if there is still disambiguation in selection..
447  if( collector.GetCount() == 1 )
448  {
449  toggleSelection( collector[0] );
450 
451  return true;
452  }
453  else if( collector.GetCount() > 1 )
454  {
455  if( aOnDrag )
456  {
458  }
459 
460  item = disambiguationMenu( &collector );
461 
462  if( item )
463  {
464  toggleSelection( item );
465 
466  return true;
467  }
468  }
469  break;
470  }
471 
472  return false;
473 }
int GetCount() const
Function GetCount returns the number of objects in the list.
void ClearReferencePoint()
Definition: selection.h:188
static const KICAD_T AllBoardItems[]
A scan list for all editable board items, like PcbGeneralLocateAndDisplay()
Definition: collectors.h:239
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection. ...
Definition: collectors.cpp:435
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 ...
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.
bool m_editModules
Definition: pcb_tool.h:129
static const KICAD_T ModuleItems[]
A scan list for primary module items.
Definition: collectors.h:280
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:212
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:351
BOARD * board() const
Definition: pcb_tool.h:126
int SELECTION_TOOL::selectSameSheet ( const TOOL_EVENT aEvent)
private

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

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

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

Referenced by setTransitions().

1037 {
1038  if( !selectCursor( true ) )
1039  return 0;
1040 
1041  // this function currently only supports modules since they are only
1042  // on one sheet.
1043  auto item = m_selection.Front();
1044 
1045  if( !item )
1046  return 0;
1047 
1048  if( item->Type() != PCB_MODULE_T )
1049  return 0;
1050 
1051  auto mod = dynamic_cast<MODULE*>( item );
1052 
1053  clearSelection();
1054 
1055  // get the lowest subsheet name for this.
1056  wxString sheetPath = mod->GetPath();
1057  sheetPath = sheetPath.BeforeLast( '/' );
1058  sheetPath = sheetPath.AfterLast( '/' );
1059 
1060  selectAllItemsOnSheet( sheetPath );
1061 
1062  // Inform other potentially interested tools
1063  if( m_selection.Size() > 0 )
1065 
1066  return 0;
1067 }
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:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
class MODULE, a footprint
Definition: typeinfo.h:101
void selectAllItemsOnSheet(wxString &aSheetpath)
Selects all items with the given sheet timestamp name (the sheet path)
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
SELECTION m_selection
Current state of selection.
void clearSelection()
Function clearSelection() Clears the current selection.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
#define mod(a, n)
Definition: greymap.cpp:24
void SELECTION_TOOL::selectVisually ( BOARD_ITEM aItem)
private

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

Parameters
aItemis an item to be be marked.

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

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

Referenced by select().

1573 {
1574  // Hide the original item, so it is shown only on overlay
1575  aItem->SetSelected();
1576  view()->Hide( aItem, true );
1577 
1578  // Modules are treated in a special way - when they are selected, we have to
1579  // unselect all the parts that make the module, not the module itself
1580 
1581  if( aItem->Type() == PCB_MODULE_T )
1582  {
1583  static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* item )
1584  {
1585  item->SetSelected();
1586  view()->Hide( item, true );
1587  });
1588  }
1589 
1590  view()->Update( &m_selection );
1591 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1352
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
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:241
SELECTION m_selection
Current state of selection.
void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

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

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

Definition at line 74 of file tool_interactive.cpp.

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

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

75 {
76  if( aMenu )
77  aMenu->SetTool( this );
78  else
79  aTrigger = CMENU_OFF;
80 
81  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
82 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool'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 86 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

87  {
88  m_editModules = aEnabled;
89  }
bool m_editModules
Definition: pcb_tool.h:129
void SELECTION_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 602 of file pcbnew/tools/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::selectionModified, PCB_ACTIONS::selectItem, SelectItem(), PCB_ACTIONS::selectItems, SelectItems(), PCB_ACTIONS::selectNet, selectNet(), PCB_ACTIONS::selectOnSheetFromEeschema, selectOnSheetFromEeschema(), PCB_ACTIONS::selectSameSheet, selectSameSheet(), PCB_ACTIONS::unselectItem, UnselectItem(), PCB_ACTIONS::unselectItems, UnselectItems(), and updateSelection().

603 {
611  Go( &SELECTION_TOOL::find, PCB_ACTIONS::find.MakeEvent() );
620 }
static TOOL_ACTION selectItems
Selects a list of items (specified as the event parameter)
Definition: pcb_actions.h:59
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: pcb_actions.h:47
int UnselectItem(const TOOL_EVENT &aEvent)
Item unselection event handler.
int Main(const TOOL_EVENT &aEvent)
Function Main()
int selectSameSheet(const TOOL_EVENT &aEvent)
Selects all modules belonging to same hierarchical sheet as the selected footprint.
static TOOL_ACTION unselectItem
Unselects an item (specified as the event parameter).
Definition: pcb_actions.h:62
static TOOL_ACTION selectNet
Selects all connections belonging to a single net.
Definition: pcb_actions.h:74
static TOOL_ACTION unselectItems
Unselects a list of items (specified as the event parameter)
Definition: pcb_actions.h:65
int find(const TOOL_EVENT &aEvent)
Find an item.
int findMove(const TOOL_EVENT &aEvent)
Find an item and start moving.
int UnselectItems(const TOOL_EVENT &aEvent)
Multiple item unselection event handler
static TOOL_ACTION selectConnection
Selects a connection between junctions.
Definition: pcb_actions.h:68
int selectConnection(const TOOL_EVENT &aEvent)
Selects a trivial connection (between two junctions) of items in selection
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION selectionModified
Modified selection notification.
Definition: pcb_actions.h:108
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:382
int updateSelection(const TOOL_EVENT &aEvent)
Event handler to update the selection VIEW_ITEM.
int ClearSelection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
int selectOnSheetFromEeschema(const TOOL_EVENT &aEvent)
Selects all modules belonging to same sheet, from Eeschema, using crossprobing
static TOOL_ACTION selectCopper
Selects whole copper connection.
Definition: pcb_actions.h:71
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:83
static TOOL_ACTION selectOnSheetFromEeschema
Selects all components on sheet from Eeschema crossprobing.
Definition: pcb_actions.h:77
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
int SelectItems(const TOOL_EVENT &aEvent)
Multiple item selection event handler
static TOOL_ACTION findMove
Find an item and start moving.
Definition: pcb_actions.h:385
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:80
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 378 of file pcbnew/tools/selection_tool.cpp.

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

Referenced by findMove(), and selectPoint().

379 {
380  if( aItem->IsSelected() )
381  {
382  unselect( aItem );
383 
384  // Inform other potentially interested tools
386  }
387  else
388  {
389  if( !m_additive )
390  clearSelection();
391 
392  // Prevent selection of invisible or inactive items
393  if( selectable( aItem ) )
394  {
395  select( aItem );
396 
397  // Inform other potentially interested tools
399  }
400  }
401 
403 }
void ForceRefresh()
Function ForceRefresh() Forces a redraw.
bool m_additive
Flag saying if items should be added to the current selection or rather replace it.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool IsSelected() const
Definition: base_struct.h:235
void select(BOARD_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
bool selectable(const BOARD_ITEM *aItem) const
Function selectable() Checks conditions for an item to be selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
void clearSelection()
Function clearSelection() Clears the current selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
static const TOOL_EVENT SelectedEvent
Event sent after an item is selected.
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:870
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 1556 of file pcbnew/tools/selection_tool.cpp.

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

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

1557 {
1558  if( !aItem->IsSelected() )
1559  return;
1560 
1561  m_selection.Remove( aItem );
1562  unselectVisually( aItem );
1563 
1564  if( m_selection.Empty() )
1565  {
1566  m_frame->SetCurItem( NULL );
1567  m_locked = true;
1568  }
1569 }
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:235
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 753 of file pcbnew/tools/selection_tool.cpp.

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

Referenced by setTransitions().

754 {
755  // Check if there is an item to be selected
756  BOARD_ITEM* item = aEvent.Parameter<BOARD_ITEM*>();
757 
758  if( item )
759  {
760  unselect( item );
761 
762  // Inform other potentially interested tools
764  }
765 
766  return 0;
767 }
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
int SELECTION_TOOL::UnselectItems ( const TOOL_EVENT aEvent)

Multiple item unselection event handler

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

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

Referenced by setTransitions().

734 {
735  std::vector<BOARD_ITEM*>* items = aEvent.Parameter<std::vector<BOARD_ITEM*>*>();
736 
737  if( items )
738  {
739  // Perform individual unselection of each item
740  // before processing the event
741  for( auto item : *items )
742  {
743  unselect( item );
744  }
745 
747  }
748 
749  return 0;
750 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
static const TOOL_EVENT UnselectedEvent
Event sent after an item is unselected.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:373
void unselect(BOARD_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
void SELECTION_TOOL::unselectVisually ( BOARD_ITEM aItem)
private

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

Parameters
aItemis an item to be be marked.

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

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

1595 {
1596  // Restore original item visibility
1597  aItem->ClearSelected();
1598  view()->Hide( aItem, false );
1599  view()->Update( aItem );
1600 
1601  // Modules are treated in a special way - when they are selected, we have to
1602  // unselect all the parts that make the module, not the module itself
1603 
1604  if( aItem->Type() == PCB_MODULE_T )
1605  {
1606  static_cast<MODULE*>( aItem )->RunOnChildren( [&] ( BOARD_ITEM* item )
1607  {
1608  item->ClearSelected();
1609  view()->Hide( item, false );
1610  view()->Update( item );
1611  });
1612  }
1613 
1614  view()->Update( &m_selection );
1615 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1352
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
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:245
class MODULE, a footprint
Definition: typeinfo.h:101
SELECTION m_selection
Current state of selection.
void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
int SELECTION_TOOL::updateSelection ( const TOOL_EVENT aEvent)
private

Event handler to update the selection VIEW_ITEM.

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

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

Referenced by setTransitions().

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

Function Wait()

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

Definition at line 55 of file tool_interactive.cpp.

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

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

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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 997 of file pcbnew/tools/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().

998 {
999  //Should recalculate the view to zoom in on the selection
1000  auto selectionBox = m_selection.ViewBBox();
1001  auto canvas = m_frame->GetGalCanvas();
1002  auto view = getView();
1003 
1004  VECTOR2D screenSize = view->ToWorld( canvas->GetClientSize(), false );
1005 
1006  if( !( selectionBox.GetWidth() == 0 ) || !( selectionBox.GetHeight() == 0 ) )
1007  {
1008  VECTOR2D vsize = selectionBox.GetSize();
1009  double scale = view->GetScale() / std::max( fabs( vsize.x / screenSize.x ),
1010  fabs( vsize.y / screenSize.y ) );
1011  view->SetScale( scale );
1012  view->SetCenter( selectionBox.Centre() );
1013  view->Add( &m_selection );
1014  }
1015 
1017 }
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
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:441
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:565
SELECTION m_selection
Current state of selection.
PCB_BASE_FRAME * m_frame
Pointer to the parent frame.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
const int scale
#define max(a, b)
Definition: auxiliary.h:86
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:870
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312

Member Data Documentation

const TOOL_EVENT SELECTION_TOOL::ClearedEvent
static

Event sent after selection is cleared.

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

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

bool SELECTION_TOOL::m_additive
private

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

Definition at line 330 of file pcbnew/tools/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 339 of file pcbnew/tools/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 342 of file pcbnew/tools/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 336 of file pcbnew/tools/selection_tool.h.

Referenced by selectable(), and selectMultiple().

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

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

Referenced by filterSelection().

bool SELECTION_TOOL::m_subtractive
private

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

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

Referenced by Main(), and selectMultiple().

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 210 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

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

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 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 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

const TOOL_EVENT SELECTION_TOOL::UnselectedEvent
static

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