KiCad PCB EDA Suite
EE_SELECTION_TOOL Class Reference

#include <ee_selection_tool.h>

Inheritance diagram for EE_SELECTION_TOOL:
TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 EE_SELECTION_TOOL ()
 
 ~EE_SELECTION_TOOL ()
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
int UpdateMenu (const TOOL_EVENT &aEvent)
 
int Main (const TOOL_EVENT &aEvent)
 The main loop. More...
 
void OnIdle (wxIdleEvent &aEvent)
 
EE_SELECTIONGetSelection ()
 Return the set of currently selected items. More...
 
EE_SELECTIONRequestSelection (const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
 Return either an existing selection (filtered), or the selection at the current cursor if the existing selection is empty. More...
 
bool SelectPoint (const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
 This overload of SelectPoint will create an EE_COLLECTOR and collect hits at location aWhere before calling the primary SelectPoint method. More...
 
int AddItemToSel (const TOOL_EVENT &aEvent)
 
void AddItemToSel (EDA_ITEM *aItem, bool aQuietMode=false)
 
int AddItemsToSel (const TOOL_EVENT &aEvent)
 
void AddItemsToSel (EDA_ITEMS *aList, bool aQuietMode=false)
 
int RemoveItemFromSel (const TOOL_EVENT &aEvent)
 
void RemoveItemFromSel (EDA_ITEM *aItem, bool aQuietMode=false)
 
int RemoveItemsFromSel (const TOOL_EVENT &aEvent)
 
void RemoveItemsFromSel (EDA_ITEMS *aList, bool aQuietMode=false)
 
void RemoveItemsFromSel (std::vector< KIID > *aList, bool aQuietMode=false)
 A safer version of RemoveItemsFromSel( EDA_ITEMS ) which doesn't require the items to still exist. More...
 
void BrightenItem (EDA_ITEM *aItem)
 
void UnbrightenItem (EDA_ITEM *aItem)
 
void SelectHighlightItem (EDA_ITEM *aItem)
 Find (but don't select) node under cursor. More...
 
EDA_ITEMGetNode (VECTOR2I aPosition)
 Select node under cursor. More...
 
int SelectNode (const TOOL_EVENT &aEvent)
 If node selected then expand to connection, otherwise select connection under cursor. More...
 
int SelectConnection (const TOOL_EVENT &aEvent)
 Clear current selection event handler. More...
 
int ClearSelection (const TOOL_EVENT &aEvent)
 Select all visible items in sheet. More...
 
int SelectAll (const TOOL_EVENT &aEvent)
 
void ClearSelection ()
 
bool Selectable (const EDA_ITEM *aItem, bool checkVisibilityOnly=false) const
 Check conditions for an item to be selected. More...
 
void GuessSelectionCandidates (EE_COLLECTOR &collector, const VECTOR2I &aPos)
 Apply heuristics to try and determine a single object when multiple are found under the cursor. More...
 
int SelectionMenu (const TOOL_EVENT &aEvent)
 Show a popup menu to trim the COLLECTOR passed as aEvent's parameter down to a single item. More...
 
void RebuildSelection ()
 Rebuild the selection from the EDA_ITEMs' selection flags. More...
 
bool CollectHits (EE_COLLECTOR &aCollector, const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
 Select one or more items at the location given by parameter aWhere. More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Protected Member Functions

void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

TOOL_MENU m_menu
 The functions below are not yet implemented - their interface may change. More...
 
TOOL_TYPE m_type
 Unique identifier for the tool, assigned by a TOOL_MANAGER instance. More...
 
TOOL_ID m_toolId
 Name of the tool. More...
 
std::string m_toolName
 
TOOL_MANAGERm_toolMgr
 

Private Member Functions

void narrowSelection (EE_COLLECTOR &collector, const VECTOR2I &aWhere, bool aCheckLocked)
 Apply rules to narrow the collection down to selectable objects, and then heuristics to try and narrow it to a single object. More...
 
bool selectPoint (EE_COLLECTOR &aCollector, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
 This is the primary SelectPoint method that will prompt the user with a menu to disambiguate multiple selections and then finish by adding, subtracting or toggling the item(s) to the actual selection group. More...
 
bool selectMultiple ()
 Handle drawing a selection box that allows one to select many items at the same time. More...
 
bool doSelectionMenu (EE_COLLECTOR *aItems)
 Allow the selection of a single item from a list via pop-up menu. More...
 
void select (EDA_ITEM *aItem)
 Take necessary action mark an item as selected. More...
 
void unselect (EDA_ITEM *aItem)
 Take necessary action mark an item as unselected. More...
 
void highlight (EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
 Highlight the item visually. More...
 
void unhighlight (EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
 Unhighlight the item visually. More...
 
void updateReferencePoint ()
 Set the reference point to the anchor of the top-left item. More...
 
bool selectionContains (const VECTOR2I &aPoint) const
 Set up handlers for various events. More...
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
void setModifiersState (bool aShiftState, bool aCtrlState, bool aAltState)
 Set the configuration of m_additive, m_subtractive, m_exclusive_or, m_skip_heuristics from the state of modifier keys SHIFT, CTRL, ALT and depending on the OS. More...
 

Private Attributes

SCH_BASE_FRAMEm_frame
 
EE_SELECTION m_selection
 
bool m_additive
 
bool m_subtractive
 
bool m_exclusive_or
 
bool m_multiple
 
bool m_skip_heuristics
 
KICURSOR m_nonModifiedCursor
 
bool m_isSymbolEditor
 
bool m_isSymbolViewer
 
int m_unit
 
int m_convert
 

Detailed Description

Definition at line 55 of file ee_selection_tool.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

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

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

Constructor & Destructor Documentation

◆ EE_SELECTION_TOOL()

EE_SELECTION_TOOL::EE_SELECTION_TOOL ( )

Definition at line 107 of file ee_selection_tool.cpp.

107  :
108  TOOL_INTERACTIVE( "eeschema.InteractiveSelection" ),
109  m_frame( nullptr ),
110  m_additive( false ),
111  m_subtractive( false ),
112  m_exclusive_or( false ),
113  m_multiple( false ),
114  m_skip_heuristics( false ),
116  m_isSymbolEditor( false ),
117  m_isSymbolViewer( false ),
118  m_unit( 0 ),
119  m_convert( 0 )
120 {
121  m_selection.Clear();
122 }
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:82
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Create a tool with given id & name.
SCH_BASE_FRAME * m_frame
EE_SELECTION m_selection

References ARROW, SELECTION::Clear(), and m_selection.

◆ ~EE_SELECTION_TOOL()

EE_SELECTION_TOOL::~EE_SELECTION_TOOL ( )

Definition at line 125 of file ee_selection_tool.cpp.

126 {
127  getView()->Remove( &m_selection );
128 }
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:352
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
EE_SELECTION m_selection

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

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

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

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

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

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ AddItemsToSel() [1/2]

int EE_SELECTION_TOOL::AddItemsToSel ( const TOOL_EVENT aEvent)

Definition at line 1410 of file ee_selection_tool.cpp.

1411 {
1412  AddItemsToSel( aEvent.Parameter<EDA_ITEMS*>(), false );
1413  m_selection.SetIsHover( false );
1414  return 0;
1415 }
int AddItemsToSel(const TOOL_EVENT &aEvent)
void SetIsHover(bool aIsHover)
Definition: selection.h:68
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:507
EE_SELECTION m_selection

References m_selection, TOOL_EVENT::Parameter(), and SELECTION::SetIsHover().

Referenced by setTransitions().

◆ AddItemsToSel() [2/2]

void EE_SELECTION_TOOL::AddItemsToSel ( EDA_ITEMS aList,
bool  aQuietMode = false 
)

Definition at line 1418 of file ee_selection_tool.cpp.

1419 {
1420  if( aList )
1421  {
1422  for( EDA_ITEM* item : *aList )
1423  select( item );
1424 
1425  // Inform other potentially interested tools
1426  if( !aQuietMode )
1428  }
1429 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:199
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void select(EDA_ITEM *aItem)
Take necessary action mark an item as selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100

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

◆ AddItemToSel() [1/2]

◆ AddItemToSel() [2/2]

void EE_SELECTION_TOOL::AddItemToSel ( EDA_ITEM aItem,
bool  aQuietMode = false 
)

Definition at line 1397 of file ee_selection_tool.cpp.

1398 {
1399  if( aItem )
1400  {
1401  select( aItem );
1402 
1403  // Inform other potentially interested tools
1404  if( !aQuietMode )
1406  }
1407 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:199
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void select(EDA_ITEM *aItem)
Take necessary action mark an item as selected.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).

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

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ BrightenItem()

void EE_SELECTION_TOOL::BrightenItem ( EDA_ITEM aItem)

Definition at line 1489 of file ee_selection_tool.cpp.

1490 {
1491  highlight( aItem, BRIGHTENED );
1492 }
void highlight(EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
Highlight the item visually.
#define BRIGHTENED
item is drawn with a bright contour

References BRIGHTENED, and highlight().

Referenced by SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), and SCH_EDITOR_CONTROL::UpdateFind().

◆ ClearSelection() [1/2]

int EE_SELECTION_TOOL::ClearSelection ( const TOOL_EVENT aEvent)

◆ ClearSelection() [2/2]

void EE_SELECTION_TOOL::ClearSelection ( )

Definition at line 1769 of file ee_selection_tool.cpp.

1770 {
1771  if( m_selection.Empty() )
1772  return;
1773 
1774  while( m_selection.GetSize() )
1776 
1777  getView()->Update( &m_selection );
1778 
1779  m_selection.SetIsHover( false );
1781 
1782  // Inform other potentially interested tools
1784 }
void ClearReferencePoint()
Definition: selection.h:191
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void SetIsHover(bool aIsHover)
Definition: selection.h:68
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
Definition: actions.h:201
#define SELECTED
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:87
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
EE_SELECTION m_selection
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
Unhighlight the item visually.
EDA_ITEM * Front() const
Definition: selection.h:144
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1504

References EVENTS::ClearedEvent, SELECTION::ClearReferencePoint(), SELECTION::Empty(), SELECTION::Front(), SELECTION::GetSize(), TOOL_BASE::getView(), m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), SELECTED, SELECTION::SetIsHover(), unhighlight(), and KIGFX::VIEW::Update().

Referenced by ClearSelection(), Main(), RequestSelection(), Reset(), selectMultiple(), selectPoint(), and setTransitions().

◆ CollectHits()

bool EE_SELECTION_TOOL::CollectHits ( EE_COLLECTOR aCollector,
const VECTOR2I aWhere,
const KICAD_T aFilterList = EE_COLLECTOR::AllItems 
)

Select one or more items at the location given by parameter aWhere.

This method does not attempt to disambiguate multiple items and is simply "collecting"

Parameters
aCollectoris the collector object that will store found item(s)
aWhereis the place where the item should be selected.
aFilterListis a list of items that are acceptable for collection
aCheckLockedindicates if locked items should be excluded.

Definition at line 772 of file ee_selection_tool.cpp.

774 {
775  aCollector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
776 
777  if( m_isSymbolEditor )
778  {
779  LIB_SYMBOL* symbol = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
780 
781  if( !symbol )
782  return false;
783 
784  aCollector.Collect( symbol->GetDrawItems(), aFilterList, (wxPoint) aWhere, m_unit,
785  m_convert );
786  }
787  else
788  {
789  aCollector.Collect( m_frame->GetScreen(), aFilterList, (wxPoint) aWhere, m_unit,
790  m_convert );
791  }
792 
793  return aCollector.GetCount() > 0;
794 }
int m_Threshold
Definition: collector.h:248
void Collect(SCH_SCREEN *aScreen, const KICAD_T aFilterList[], const wxPoint &aPos, int aUnit=0, int aConvert=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
#define HITTEST_THRESHOLD_PIXELS
Define a library symbol object.
Definition: lib_symbol.h:96
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:473
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
SCH_BASE_FRAME * m_frame
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:70

References EE_COLLECTOR::Collect(), COLLECTOR::GetCount(), LIB_SYMBOL::GetDrawItems(), SCH_BASE_FRAME::GetScreen(), TOOL_BASE::getView(), HITTEST_THRESHOLD_PIXELS, KiROUND(), m_convert, m_frame, m_isSymbolEditor, COLLECTOR::m_Threshold, and m_unit.

Referenced by SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), Main(), and SelectPoint().

◆ doSelectionMenu()

bool EE_SELECTION_TOOL::doSelectionMenu ( EE_COLLECTOR aItems)
private

Allow the selection of a single item from a list via pop-up menu.

The items are highlighted on the canvas when hovered in the menu. The collector is trimmed to the picked item.

Returns
true if an item was picked

The user has requested the full, non-limited list of selection items

Definition at line 1562 of file ee_selection_tool.cpp.

1563 {
1564  EDA_ITEM* current = nullptr;
1565  bool selectAll = false;
1566  bool expandSelection = false;
1567 
1568  do
1569  {
1571  if( expandSelection )
1572  aCollector->Combine();
1573 
1574  expandSelection = false;
1575 
1576  int limit = std::min( 9, aCollector->GetCount() );
1577  ACTION_MENU menu( true );
1578 
1579  for( int i = 0; i < limit; ++i )
1580  {
1581  wxString text;
1582  EDA_ITEM* item = ( *aCollector )[i];
1584 
1585  wxString menuText = wxString::Format( "&%d. %s\t%d", i + 1, text, i + 1 );
1586  menu.Add( menuText, i + 1, item->GetMenuImage() );
1587  }
1588 
1589  menu.AppendSeparator();
1590  menu.Add( _( "Select &All\tA" ), limit + 1, BITMAPS::INVALID_BITMAP );
1591 
1592  if( !expandSelection && aCollector->HasAdditionalItems() )
1593  menu.Add( _( "&Expand Selection\tE" ), limit + 2, BITMAPS::INVALID_BITMAP );
1594 
1595  if( aCollector->m_MenuTitle.Length() )
1596  {
1597  menu.SetTitle( aCollector->m_MenuTitle );
1598  menu.SetIcon( BITMAPS::info );
1599  menu.DisplayTitle( true );
1600  }
1601  else
1602  {
1603  menu.DisplayTitle( false );
1604  }
1605 
1606  SetContextMenu( &menu, CMENU_NOW );
1607 
1608  while( TOOL_EVENT* evt = Wait() )
1609  {
1610  if( evt->Action() == TA_CHOICE_MENU_UPDATE )
1611  {
1612  if( selectAll )
1613  {
1614  for( int i = 0; i < aCollector->GetCount(); ++i )
1615  unhighlight( ( *aCollector )[i], BRIGHTENED );
1616  }
1617  else if( current )
1618  {
1619  unhighlight( current, BRIGHTENED );
1620  }
1621 
1622  int id = *evt->GetCommandId();
1623 
1624  // User has pointed an item, so show it in a different way
1625  if( id > 0 && id <= limit )
1626  {
1627  current = ( *aCollector )[id - 1];
1628  highlight( current, BRIGHTENED );
1629  }
1630  else
1631  {
1632  current = nullptr;
1633  }
1634 
1635  // User has pointed on the "Select All" option
1636  if( id == limit + 1 )
1637  {
1638  for( int i = 0; i < aCollector->GetCount(); ++i )
1639  highlight( ( *aCollector )[i], BRIGHTENED );
1640  selectAll = true;
1641  }
1642  else
1643  {
1644  selectAll = false;
1645  }
1646  }
1647  else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
1648  {
1649  if( selectAll )
1650  {
1651  for( int i = 0; i < aCollector->GetCount(); ++i )
1652  unhighlight( ( *aCollector )[i], BRIGHTENED );
1653  }
1654  else if( current )
1655  unhighlight( current, BRIGHTENED );
1656 
1657  OPT<int> id = evt->GetCommandId();
1658 
1659  // User has selected the "Select All" option
1660  if( id == limit + 1 )
1661  {
1662  selectAll = true;
1663  current = nullptr;
1664  }
1665  else if( id == limit + 2 )
1666  {
1667  selectAll = false;
1668  current = nullptr;
1669  expandSelection = true;
1670  }
1671  // User has selected an item, so this one will be returned
1672  else if( id && ( *id > 0 ) && ( *id <= limit ) )
1673  {
1674  selectAll = false;
1675  current = ( *aCollector )[*id - 1];
1676  }
1677  // User has cancelled the menu (either by <esc> or clicking out of it)
1678  else
1679  {
1680  selectAll = false;
1681  current = nullptr;
1682  }
1683  }
1684  else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
1685  {
1686  break;
1687  }
1688 
1689  getView()->UpdateItems();
1690  m_frame->GetCanvas()->Refresh();
1691  }
1692  } while( expandSelection );
1693 
1694  if( selectAll )
1695  return true;
1696  else if( current )
1697  {
1698  unhighlight( current, BRIGHTENED );
1699 
1700  getView()->UpdateItems();
1701  m_frame->GetCanvas()->Refresh();
1702 
1703  aCollector->Empty();
1704  aCollector->Append( current );
1705  return true;
1706  }
1707 
1708  return false;
1709 }
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:48
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Assign a context menu and tells when it should be activated.
void highlight(EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
Highlight the item visually.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
#define _(s)
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
Definition: view.cpp:1398
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
SCH_BASE_FRAME * m_frame
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: eda_item.cpp:109
virtual BITMAPS GetMenuImage() const
Return a pointer to an image to be used in menus.
Definition: eda_item.cpp:208
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
boost::optional< T > OPT
Definition: optional.h:7
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
Unhighlight the item visually.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
#define BRIGHTENED
item is drawn with a bright contour

References _, COLLECTOR::Append(), BRIGHTENED, CMENU_NOW, COLLECTOR::Combine(), COLLECTOR::Empty(), Format(), SCH_BASE_FRAME::GetCanvas(), COLLECTOR::GetCount(), EDA_ITEM::GetMenuImage(), EDA_ITEM::GetSelectMenuText(), EDA_BASE_FRAME::GetUserUnits(), TOOL_BASE::getView(), COLLECTOR::HasAdditionalItems(), highlight(), info, INVALID_BITMAP, m_frame, COLLECTOR::m_MenuTitle, EDA_DRAW_PANEL_GAL::Refresh(), TOOL_INTERACTIVE::SetContextMenu(), TA_CHOICE_MENU_CHOICE, TA_CHOICE_MENU_CLOSED, TA_CHOICE_MENU_UPDATE, text, unhighlight(), KIGFX::VIEW::UpdateItems(), and TOOL_INTERACTIVE::Wait().

Referenced by SelectionMenu().

◆ getEditFrame()

template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

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

Definition at line 184 of file tool_base.h.

185  {
186 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
187  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
188 #endif
189  return static_cast<T*>( getToolHolderInt() );
190  }
TOOLS_HOLDER * getToolHolderInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 120 of file tool_base.h.

121  {
122  return m_toolId;
123  }
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Return the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER or NULL if there is no associated tool manager.

Definition at line 143 of file tool_base.h.

144  {
145  return m_toolMgr;
146  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), LIB_TREE::onContextMenu(), ZONE_CREATE_HELPER::OnFirstPoint(), ACTION_MENU::OnMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ GetName()

const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Return 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.

134  {
135  return m_toolName;
136  }
std::string m_toolName
Definition: tool_base.h:213

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), TOOL_MANAGER::RegisterTool(), and TOOL_MANAGER::runTool().

◆ GetNode()

EDA_ITEM * EE_SELECTION_TOOL::GetNode ( VECTOR2I  aPosition)

Select node under cursor.

Definition at line 1333 of file ee_selection_tool.cpp.

1334 {
1335  EE_COLLECTOR collector;
1336 
1337  //TODO(snh): Reimplement after exposing KNN interface
1338  int thresholdMax = KiROUND(
1340 
1341  for( int threshold : { 0, thresholdMax/2, thresholdMax } )
1342  {
1343  collector.m_Threshold = threshold;
1344  collector.Collect( m_frame->GetScreen(), nodeTypes, (wxPoint) aPosition );
1345 
1346  if( collector.GetCount() > 0 )
1347  break;
1348  }
1349 
1350  return collector.GetCount() ? collector[ 0 ] : nullptr;
1351 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
int m_Threshold
Definition: collector.h:248
void Collect(SCH_SCREEN *aScreen, const KICAD_T aFilterList[], const wxPoint &aPos, int aUnit=0, int aConvert=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
EE_COLLECTOR.
Definition: ee_collectors.h:42
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
Definition: view.h:189
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
const VECTOR2D & GetGridSize() const
Return the grid size.
static KICAD_T nodeTypes[]
SCH_BASE_FRAME * m_frame
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:70
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
Definition: vector2d.h:293

References EE_COLLECTOR::Collect(), VECTOR2< T >::EuclideanNorm(), COLLECTOR::GetCount(), KIGFX::VIEW::GetGAL(), KIGFX::GAL::GetGridSize(), SCH_BASE_FRAME::GetScreen(), TOOL_MANAGER::GetView(), KiROUND(), m_frame, COLLECTOR::m_Threshold, TOOL_BASE::m_toolMgr, and nodeTypes.

◆ GetSelection()

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

109  {
110  return m_type;
111  }
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:206

References TOOL_BASE::m_type.

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

◆ getView()

KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Returns the instance of #VIEW object used in the application.

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

37 {
38  return m_toolMgr->GetView();
39 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:283
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), PL_SELECTION_TOOL::ClearSelection(), ClearSelection(), CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), ROUTER_TOOL::handleCommonEvents(), PL_SELECTION_TOOL::highlight(), highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), BOARD_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), Reset(), PCB_SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::SelectAll(), SelectAll(), PL_SELECTION_TOOL::selectionContains(), selectionContains(), PL_SELECTION_TOOL::selectMultiple(), selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_DRAWING_TOOLS::TwoClickPlace(), PL_SELECTION_TOOL::unhighlight(), unhighlight(), PCB_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updateParentItem(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), PCB_SELECTION_TOOL::zoomFitSelection(), ~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ getViewControls()

KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited

Return 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 42 of file tool_base.cpp.

43 {
44  return m_toolMgr->GetViewControls();
45 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:285

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

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), SCH_DRAWING_TOOLS::createSheetPin(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_DRAWING_TOOLS::GetCanvasFreeAreaPixels(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), PCB_SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Define which state (aStateFunc) to go when a certain event arrives (aConditions).

No conditions means any event.

Definition at line 128 of file tool_interactive.h.

130 {
131  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
132 
133  goInternal( sptr, aConditions );
134 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by AUTOPLACE_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PCB_PICKER_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), SCRIPTING_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), COMMON_CONTROL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), PAD_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), PCB_CONTROL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), DRC_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), and setTransitions().

◆ GuessSelectionCandidates()

void EE_SELECTION_TOOL::GuessSelectionCandidates ( EE_COLLECTOR collector,
const VECTOR2I aPos 
)

Apply heuristics to try and determine a single object when multiple are found under the cursor.

Definition at line 962 of file ee_selection_tool.cpp.

963 {
964  // There are certain parent/child and enclosure combinations that can be handled
965  // automatically.
966 
967  // Prefer exact hits to sloppy ones
968  int exactHits = 0;
969 
970  for( int i = collector.GetCount() - 1; i >= 0; --i )
971  {
972  EDA_ITEM* item = collector[ i ];
973 
974  if( item->HitTest( (wxPoint) aPos, 0 ) )
975  exactHits++;
976  }
977 
978  if( exactHits > 0 && exactHits < collector.GetCount() )
979  {
980  for( int i = collector.GetCount() - 1; i >= 0; --i )
981  {
982  EDA_ITEM* item = collector[ i ];
983 
984  if( !item->HitTest( (wxPoint) aPos, 0 ) )
985  collector.Transfer( item );
986  }
987  }
988 
989  // Prefer a non-sheet to a sheet
990  for( int i = 0; collector.GetCount() == 2 && i < 2; ++i )
991  {
992  EDA_ITEM* item = collector[ i ];
993  EDA_ITEM* other = collector[ ( i + 1 ) % 2 ];
994 
995  if( item->Type() != SCH_SHEET_T && other->Type() == SCH_SHEET_T )
996  collector.Transfer( other );
997  }
998 
999  // Prefer a symbol to a pin or the opposite, when both a symbol and a pin are selected
1000  // We need to be able to select only a pin:
1001  // - to display its characteristics (especially if an ERC is attached to the pin)
1002  // - for cross probing, to select the corresponding pad.
1003  // Note also the case happens only in schematic editor. In symbol editor, the symbol
1004  // itself is never selected
1005  for( int i = 0; collector.GetCount() == 2 && i < 2; ++i )
1006  {
1007  SCH_ITEM* item = collector[i];
1008  SCH_ITEM* other = collector[( i + 1 ) % 2];
1009 
1010  if( item->Type() == SCH_SYMBOL_T && other->Type() == SCH_PIN_T )
1011  {
1012  // Make sure we aren't clicking on the pin anchor itself, only the rest of the
1013  // pin should select the symbol with this setting
1014  // To avoid conflict with the auto-start wires option
1016  wxPoint cursorPos = wxPoint( grid.BestSnapAnchor( aPos, LAYER_CONNECTABLE,
1017  nullptr ) );
1018 
1019  if( !m_isSymbolEditor
1021  && !other->IsPointClickableAnchor( cursorPos ) )
1022  {
1023  collector.Transfer( other );
1024  }
1025  else
1026  {
1027  collector.Transfer( item );
1028  }
1029  }
1030  }
1031 
1032  // Prefer things that are generally smaller than a symbol to a symbol
1033  const std::set<KICAD_T> preferred =
1034  {
1035  SCH_FIELD_T,
1036  SCH_LINE_T,
1040  SCH_MARKER_T
1041  };
1042 
1043  for( int i = 0; collector.GetCount() == 2 && i < 2; ++i )
1044  {
1045  EDA_ITEM* item = collector[ i ];
1046  EDA_ITEM* other = collector[ ( i + 1 ) % 2 ];
1047 
1048  if( preferred.count( item->Type() ) && other->Type() == SCH_SYMBOL_T )
1049  collector.Transfer( other );
1050  }
1051 
1052  // No need for multiple wires at a single point; if there's a junction select that;
1053  // otherwise any of the wires will do
1054  bool junction = false;
1055  bool wiresOnly = true;
1056 
1057  for( EDA_ITEM* item : collector )
1058  {
1059  if( item->Type() == SCH_JUNCTION_T )
1060  junction = true;
1061  else if( item->Type() != SCH_LINE_T )
1062  wiresOnly = false;
1063  }
1064 
1065  if( wiresOnly )
1066  {
1067  for( int j = collector.GetCount() - 1; j >= 0; --j )
1068  {
1069  if( junction && collector[ j ]->Type() != SCH_JUNCTION_T )
1070  collector.Transfer( j );
1071  else if( !junction && j > 0 )
1072  collector.Transfer( j );
1073  }
1074  }
1075 
1076  // Construct a tight box (1/2 height and width) around the center of the closest item.
1077  // All items which exist at least partly outside this box have sufficient other areas
1078  // for selection and can be dropped.
1079  EDA_ITEM* closest = nullptr;
1080  int closestDist = INT_MAX;
1081 
1082  for( EDA_ITEM* item : collector )
1083  {
1084  int dist = EuclideanNorm( item->GetBoundingBox().GetCenter() - (wxPoint) aPos );
1085 
1086  if( dist < closestDist )
1087  {
1088  closestDist = dist;
1089  closest = item;
1090  }
1091  }
1092 
1093  if( closest ) // Don't try and get a tight bbox if nothing is near the mouse pointer
1094  {
1095  EDA_RECT tightBox = closest->GetBoundingBox();
1096  tightBox.Inflate( -tightBox.GetWidth() / 4, -tightBox.GetHeight() / 4 );
1097 
1098  for( int i = collector.GetCount() - 1; i >= 0; --i )
1099  {
1100  EDA_ITEM* item = collector[i];
1101 
1102  if( item == closest )
1103  continue;
1104 
1105  if( !item->HitTest( tightBox, true ) )
1106  collector.Transfer( item );
1107  }
1108  }
1109 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
int GetWidth() const
Definition: eda_rect.h:109
EESCHEMA_SETTINGS * eeconfig() const
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const
Test if aPosition is contained within or on the bounding box of an item.
Definition: eda_item.h:225
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
void Transfer(int aIndex)
Move the item at aIndex (first position is 0) to the backup list.
Definition: collector.h:159
int GetHeight() const
Definition: eda_rect.h:110
virtual bool IsPointClickableAnchor(const wxPoint &aPos) const
Definition: sch_item.h:368
SCH_BASE_FRAME * m_frame
Handle the component boundary box.
Definition: eda_rect.h:42
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
virtual const EDA_RECT GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:75
const wxPoint GetCenter() const
Definition: eda_rect.h:104
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References SCH_BASE_FRAME::eeconfig(), EuclideanNorm(), EDA_ITEM::GetBoundingBox(), COLLECTOR::GetCount(), EDA_RECT::GetHeight(), EDA_RECT::GetWidth(), grid, EDA_ITEM::HitTest(), EDA_RECT::Inflate(), SCH_ITEM::IsPointClickableAnchor(), LAYER_CONNECTABLE, m_frame, m_isSymbolEditor, EESCHEMA_SETTINGS::m_Selection, TOOL_BASE::m_toolMgr, SCH_BUS_WIRE_ENTRY_T, SCH_FIELD_T, SCH_JUNCTION_T, SCH_LINE_T, SCH_MARKER_T, SCH_NO_CONNECT_T, SCH_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, EESCHEMA_SETTINGS::SELECTION::select_pin_selects_symbol, COLLECTOR::Transfer(), and EDA_ITEM::Type().

Referenced by SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), and narrowSelection().

◆ highlight()

void EE_SELECTION_TOOL::highlight ( EDA_ITEM aItem,
int  aHighlightMode,
EE_SELECTION aGroup = nullptr 
)
private

Highlight the item visually.

Parameters
aItemis an item to be be highlighted.
aHighlightModeshould be either SELECTED or BRIGHTENED
aGroupis the group to add the item to in the BRIGHTENED mode.

Definition at line 1799 of file ee_selection_tool.cpp.

1800 {
1801  KICAD_T itemType = aItem->Type();
1802 
1803  if( aMode == SELECTED )
1804  aItem->SetSelected();
1805  else if( aMode == BRIGHTENED )
1806  aItem->SetBrightened();
1807 
1808  if( aGroup )
1809  aGroup->Add( aItem );
1810 
1811  // Highlight pins and fields. (All the other symbol children are currently only
1812  // represented in the LIB_SYMBOL and will inherit the settings of the parent symbol.)
1813  if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
1814  {
1815  sch_item->RunOnChildren(
1816  [&]( SCH_ITEM* aChild )
1817  {
1818  if( aMode == SELECTED )
1819  aChild->SetSelected();
1820  else if( aMode == BRIGHTENED )
1821  aChild->SetBrightened();
1822  } );
1823  }
1824 
1825  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
1826  getView()->Update( aItem->GetParent() );
1827  else
1828  getView()->Update( aItem );
1829 }
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:31
void SetBrightened()
Definition: eda_item.h:130
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
void SetSelected()
Definition: eda_item.h:129
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
#define SELECTED
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1504
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
#define BRIGHTENED
item is drawn with a bright contour

References SELECTION::Add(), BRIGHTENED, EDA_ITEM::GetParent(), TOOL_BASE::getView(), SCH_FIELD_T, SCH_PIN_T, SCH_SHEET_PIN_T, SELECTED, EDA_ITEM::SetBrightened(), EDA_ITEM::SetSelected(), EDA_ITEM::Type(), and KIGFX::VIEW::Update().

Referenced by BrightenItem(), doSelectionMenu(), select(), and SelectHighlightItem().

◆ Init()

bool EE_SELECTION_TOOL::Init ( )
overridevirtual

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 134 of file ee_selection_tool.cpp.

135 {
136  m_frame = getEditFrame<SCH_BASE_FRAME>();
137 
138  SYMBOL_VIEWER_FRAME* symbolViewerFrame = dynamic_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
139  SYMBOL_EDIT_FRAME* symbolEditorFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
140 
141  if( symbolEditorFrame )
142  {
143  m_isSymbolEditor = true;
144  m_unit = symbolEditorFrame->GetUnit();
145  m_convert = symbolEditorFrame->GetConvert();
146  }
147  else
148  {
149  m_isSymbolViewer = symbolViewerFrame != nullptr;
150  }
151 
152  static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
153  static KICAD_T connectedTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T,
156 
157  auto wireSelection = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_WIRE_T );
158  auto busSelection = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_BUS_T );
159  auto wireOrBusSelection = E_C::MoreThan( 0 ) && E_C::OnlyTypes( wireOrBusTypes );
160  auto connectedSelection = E_C::MoreThan( 0 ) && E_C::OnlyTypes( connectedTypes );
161  auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
162 
163  auto schEditSheetPageNumberCondition =
164  [&] ( const SELECTION& aSel )
165  {
167  return false;
168 
169  return E_C::LessThan( 2 )( aSel ) && E_C::OnlyType( SCH_SHEET_T )( aSel );
170  };
171 
172  auto schEditCondition =
173  [this] ( const SELECTION& aSel )
174  {
176  };
177 
178  auto belowRootSheetCondition =
179  [&]( const SELECTION& aSel )
180  {
181  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
182 
183  return editFrame
184  && editFrame->GetCurrentSheet().Last() != &editFrame->Schematic().Root();
185  };
186 
187  auto haveSymbolCondition =
188  [&]( const SELECTION& sel )
189  {
190  return m_isSymbolEditor &&
191  static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
192  };
193 
194  auto& menu = m_menu.GetMenu();
195 
196  menu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 1 );
197  menu.AddItem( EE_ACTIONS::explicitCrossProbe, sheetSelection && EE_CONDITIONS::Idle, 1 );
198  menu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 1 );
199 
200  menu.AddSeparator( 100 );
201  menu.AddItem( EE_ACTIONS::drawWire, schEditCondition && EE_CONDITIONS::Empty, 100 );
202  menu.AddItem( EE_ACTIONS::drawBus, schEditCondition && EE_CONDITIONS::Empty, 100 );
203 
204  menu.AddSeparator( 100 );
206 
207  menu.AddSeparator( 100 );
209 
210  menu.AddSeparator( 200 );
211  menu.AddItem( EE_ACTIONS::selectConnection, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
212  menu.AddItem( EE_ACTIONS::placeJunction, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
213  menu.AddItem( EE_ACTIONS::placeLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
214  menu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
215  menu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
216  menu.AddItem( EE_ACTIONS::breakWire, wireSelection && EE_CONDITIONS::Idle, 250 );
217  menu.AddItem( EE_ACTIONS::breakBus, busSelection && EE_CONDITIONS::Idle, 250 );
218  menu.AddItem( EE_ACTIONS::importSingleSheetPin, sheetSelection && EE_CONDITIONS::Idle, 250 );
219  menu.AddItem( EE_ACTIONS::assignNetclass, connectedSelection && EE_CONDITIONS::Idle, 250 );
220  menu.AddItem( EE_ACTIONS::editPageNumber, schEditSheetPageNumberCondition, 250 );
221 
222  menu.AddSeparator( 400 );
223  menu.AddItem( EE_ACTIONS::symbolProperties,
224  haveSymbolCondition && EE_CONDITIONS::Empty, 400 );
225  menu.AddItem( EE_ACTIONS::pinTable,
226  haveSymbolCondition && EE_CONDITIONS::Empty, 400 );
227 
228  menu.AddSeparator( 1000 );
230 
231  return true;
232 }
static TOOL_ACTION editPageNumber
Definition: ee_actions.h:151
static TOOL_ACTION pinTable
Definition: ee_actions.h:142
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
static bool IsDrawingWire(const SELECTION &aSelection)
static TOOL_ACTION breakBus
Definition: ee_actions.h:131
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
static bool Idle(const SELECTION &aSelection)
Test if there no items selected or being edited.
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:84
static TOOL_ACTION placeJunction
Definition: ee_actions.h:80
static TOOL_ACTION selectConnection
If current selection is a wire or bus, expand to entire connection.
Definition: ee_actions.h:50
Symbol library viewer main window.
Schematic editor (Eeschema) main window.
static TOOL_ACTION importSingleSheetPin
Definition: ee_actions.h:184
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
static TOOL_ACTION breakWire
Definition: ee_actions.h:130
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:181
static TOOL_ACTION drawWire
Definition: ee_actions.h:76
static SELECTION_CONDITION LessThan(int aNumber)
Create a functor that tests if the number of selected items is smaller than the value given as parame...
static TOOL_ACTION explicitCrossProbe
Definition: ee_actions.h:195
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:141
SCHEMATIC & Schematic() const
static bool IsDrawingBus(const SELECTION &aSelection)
static TOOL_ACTION drawBus
Definition: ee_actions.h:77
static TOOL_ACTION placeLabel
Definition: ee_actions.h:82
SCH_SHEET & Root() const
Definition: schematic.h:92
SCH_BASE_FRAME * m_frame
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:148
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
static bool Empty(const SELECTION &aSelection)
Test if there are no items selected.
static TOOL_ACTION enterSheet
Definition: ee_actions.h:180
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:83
static TOOL_ACTION finishBus
Definition: ee_actions.h:92
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.
static TOOL_ACTION finishWire
Definition: ee_actions.h:91
The symbol library editor main window.

References CONDITIONAL_MENU::AddItem(), EDA_DRAW_FRAME::AddStandardSubMenus(), EE_ACTIONS::assignNetclass, EE_ACTIONS::breakBus, EE_ACTIONS::breakWire, SELECTION_CONDITIONS::Count(), EE_ACTIONS::drawBus, EE_ACTIONS::drawWire, EE_ACTIONS::editPageNumber, SELECTION_CONDITIONS::Empty(), EE_ACTIONS::enterSheet, EOT, EE_ACTIONS::explicitCrossProbe, EE_ACTIONS::finishBus, EE_ACTIONS::finishWire, SYMBOL_EDIT_FRAME::GetConvert(), SCH_EDIT_FRAME::GetCurrentSheet(), TOOL_MENU::GetMenu(), SYMBOL_EDIT_FRAME::GetUnit(), SELECTION_CONDITIONS::Idle(), EE_ACTIONS::importSingleSheetPin, SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), SCH_SHEET_PATH::Last(), EE_ACTIONS::leaveSheet, SELECTION_CONDITIONS::LessThan(), m_convert, m_frame, m_isSymbolEditor, m_isSymbolViewer, TOOL_INTERACTIVE::m_menu, m_unit, SELECTION_CONDITIONS::MoreThan(), SELECTION_CONDITIONS::OnlyType(), SELECTION_CONDITIONS::OnlyTypes(), EE_ACTIONS::pinTable, EE_ACTIONS::placeGlobalLabel, EE_ACTIONS::placeHierLabel, EE_ACTIONS::placeJunction, EE_ACTIONS::placeLabel, SCHEMATIC::Root(), SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_LINE_LOCATE_BUS_T, SCH_LINE_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_PIN_T, SCH_SHEET_T, SCH_EDIT_FRAME::Schematic(), EE_ACTIONS::selectConnection, and EE_ACTIONS::symbolProperties.

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

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

Referenced by ROUTER_TOOL::handleLayerSwitch(), EDIT_TOOL::isRouterActive(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ Main()

int EE_SELECTION_TOOL::Main ( const TOOL_EVENT aEvent)

The main loop.

Definition at line 367 of file ee_selection_tool.cpp.

368 {
370 
371  KIID lastRolloverItem = niluuid;
372 
373  // Main loop: keep receiving events
374  while( TOOL_EVENT* evt = Wait() )
375  {
376  bool displayWireCursor = false;
377  bool displayBusCursor = false;
378  bool displayLineCursor = false;
379  KIID rolloverItem = lastRolloverItem;
380 
381  // on left click, a selection is made, depending on modifiers ALT, SHIFT, CTRL:
382  setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ),
383  evt->Modifier( MD_ALT ) );
384 
385  bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or;
386 
387  MOUSE_DRAG_ACTION drag_action = m_frame->GetDragAction();
389 
390  // Single click? Select single object
391  if( evt->IsClick( BUT_LEFT ) )
392  {
393  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
394  schframe->FocusOnItem( nullptr );
395 
396  EE_COLLECTOR collector;
397  bool continueSelect = true;
398 
399  // Collect items at the clicked location (doesn't select them yet)
400  if( CollectHits( collector, evt->Position()) )
401  {
402  narrowSelection( collector, evt->Position(), false );
403 
404  if( collector.GetCount() == 1 && !m_isSymbolEditor && !modifier_enabled )
405  {
406  // Check if we want to auto start wires
407  VECTOR2I snappedCursorPos = grid.BestSnapAnchor( evt->Position(),
408  LAYER_CONNECTABLE, nullptr );
409 
411  && collector[0]->IsPointClickableAnchor( (wxPoint) snappedCursorPos ) )
412  {
413  OPT_TOOL_EVENT newEvt;
414  SCH_CONNECTION* connection = collector[0]->Connection();
415 
416  if( ( connection && ( connection->IsNet() || connection->IsUnconnected() ) )
417  || collector[0]->Type() == SCH_SYMBOL_T )
418  {
419  newEvt = EE_ACTIONS::drawWire.MakeEvent();
420  }
421  else if( connection && connection->IsBus() )
422  {
423  newEvt = EE_ACTIONS::drawBus.MakeEvent();
424  }
425  else if( collector[0]->Type() == SCH_LINE_T
426  && static_cast<SCH_LINE*>( collector[0] )->IsGraphicLine() )
427  {
428  newEvt = EE_ACTIONS::drawLines.MakeEvent();
429  }
430 
431  auto* params = newEvt->Parameter<DRAW_SEGMENT_EVENT_PARAMS*>();
432  auto* newParams = new DRAW_SEGMENT_EVENT_PARAMS();
433 
434  *newParams= *params;
435  newParams->quitOnDraw = true;
436  newEvt->SetParameter( newParams );
437 
438  getViewControls()->ForceCursorPosition( true, snappedCursorPos );
439  newEvt->SetMousePosition( snappedCursorPos );
440  newEvt->SetHasPosition( true );
441  newEvt->SetForceImmediate( true );
442  m_toolMgr->ProcessEvent( *newEvt );
443 
444  continueSelect = false;
445  }
446  else if( collector[0]->IsHypertext() )
447  {
448  collector[0]->DoHypertextMenu( m_frame );
449  continueSelect = false;
450  }
451  }
452  }
453 
454  if( continueSelect )
455  {
456  // If we didn't click on an anchor, we perform a normal select, pass in the
457  // items we previously collected
458  selectPoint( collector, nullptr, nullptr, m_additive, m_subtractive,
459  m_exclusive_or );
460  }
461  }
462  else if( evt->IsClick( BUT_RIGHT ) )
463  {
464  // right click? if there is any object - show the context menu
465  bool selectionCancelled = false;
466 
467  if( m_selection.Empty() )
468  {
469  ClearSelection();
470  SelectPoint( evt->Position(), EE_COLLECTOR::AllItems, nullptr,
471  &selectionCancelled );
472  m_selection.SetIsHover( true );
473  }
474  // If the cursor has moved off the bounding box of the selection by more than
475  // a grid square, check to see if there is another item available for selection
476  // under the cursor. If there is, the user likely meant to get the context menu
477  // for that item. If there is no new item, then keep the original selection and
478  // show the context menu for it.
479  else if( !m_selection.GetBoundingBox().Inflate(
480  grid.GetGrid().x, grid.GetGrid().y ).Contains(
481  (wxPoint) evt->Position() ) )
482  {
483  EE_SELECTION saved_selection = m_selection;
484 
485  for( const auto& item : saved_selection )
486  RemoveItemFromSel( item, true );
487 
488  SelectPoint( evt->Position(), EE_COLLECTOR::AllItems, nullptr,
489  &selectionCancelled );
490 
491  if( m_selection.Empty() )
492  {
493  m_selection.SetIsHover( false );
494 
495  for( const auto& item : saved_selection )
496  AddItemToSel( item, true);
497  }
498  else
499  {
500  m_selection.SetIsHover( true );
501  }
502  }
503 
504  if( !selectionCancelled )
506  }
507  else if( evt->IsDblClick( BUT_LEFT ) )
508  {
509  // double click? Display the properties window
510  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
511  schframe->FocusOnItem( nullptr );
512 
513  if( m_selection.Empty() )
514  SelectPoint( evt->Position() );
515 
516  EDA_ITEM* item = m_selection.Front();
517 
518  if( item && item->Type() == SCH_SHEET_T )
520  else
522  }
523  else if( evt->IsDblClick( BUT_MIDDLE ) )
524  {
525  // Middle double click? Do zoom to fit or zoom to objects
526  if( evt->Modifier( MD_CTRL ) ) // Is CTRL key down?
528  else
530  }
531  else if( evt->IsDrag( BUT_LEFT ) )
532  {
533  // Is another tool already moving a new object? Don't allow a drag start
534  if( !m_selection.Empty() && m_selection[0]->HasFlag( IS_NEW | IS_MOVING ) )
535  {
536  evt->SetPassEvent();
537  continue;
538  }
539 
540  // drag with LMB? Select multiple objects (or at least draw a selection box) or
541  // drag them
542  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
543  schframe->FocusOnItem( nullptr );
544 
545  if( modifier_enabled || drag_action == MOUSE_DRAG_ACTION::SELECT )
546  {
547  selectMultiple();
548  }
549  else if( m_selection.Empty() && drag_action != MOUSE_DRAG_ACTION::DRAG_ANY )
550  {
551  selectMultiple();
552  }
553  else
554  {
555  // selection is empty? try to start dragging the item under the point where drag
556  // started
559  else if( m_selection.Empty() )
561 
562  // Check if dragging has started within any of selected items bounding box
563  if( selectionContains( evt->Position() ) )
564  {
565  // Yes -> run the move tool and wait till it finishes
566  if( m_isSymbolEditor )
567  {
568  SYMBOL_EDIT_FRAME* libFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
569 
570  // Cannot move any derived symbol elements for now.
571  if( libFrame && libFrame->GetCurSymbol()
572  && libFrame->GetCurSymbol()->IsRoot() )
573  m_toolMgr->InvokeTool( "eeschema.SymbolMoveTool" );
574  }
575  else
576  {
577  m_toolMgr->InvokeTool( "eeschema.InteractiveMove" );
578  }
579  }
580  else
581  {
582  // No -> drag a selection box
583  selectMultiple();
584  }
585  }
586  }
587  else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
588  {
589  // context sub-menu selection? Handle unit selection or bus unfolding
590  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
591  && evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
592  {
593  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_selection.Front() );
594  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
595 
596  if( symbol )
597  static_cast<SCH_EDIT_FRAME*>( m_frame )->SelectUnit( symbol, unit );
598  }
599  else if( evt->GetCommandId().get() >= ID_POPUP_SCH_UNFOLD_BUS
600  && evt->GetCommandId().get() <= ID_POPUP_SCH_UNFOLD_BUS_END )
601  {
602  wxString* net = new wxString( *evt->Parameter<wxString*>() );
604  }
605 
606  }
607  else if( evt->IsCancelInteractive() )
608  {
609  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
610  schframe->FocusOnItem( nullptr );
611 
612  ClearSelection();
613  }
614  else if( evt->Action() == TA_UNDO_REDO_PRE )
615  {
616  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
617  schframe->FocusOnItem( nullptr );
618 
619  ClearSelection();
620  }
621  else if( evt->IsMotion() && !m_isSymbolEditor && m_frame->ToolStackIsEmpty() )
622  {
623  rolloverItem = niluuid;
624  EE_COLLECTOR collector;
625 
626  // We are checking if we should display a pencil when hovering over anchors
627  // for "auto starting" wires when clicked
628  if( CollectHits( collector, evt->Position()) )
629  {
630  narrowSelection( collector, evt->Position(), false );
631 
632  if( collector.GetCount() == 1 && !modifier_enabled )
633  {
634  VECTOR2I snappedCursorPos = grid.BestSnapAnchor( evt->Position(),
635  LAYER_CONNECTABLE, nullptr );
636 
638  && collector[0]->IsPointClickableAnchor( (wxPoint) snappedCursorPos ) )
639  {
640  SCH_CONNECTION* connection = collector[0]->Connection();
641 
642  if( ( connection && ( connection->IsNet() || connection->IsUnconnected() ) )
643  || collector[0]->Type() == SCH_SYMBOL_T )
644  {
645  displayWireCursor = true;
646  }
647  else if( connection && connection->IsBus() )
648  {
649  displayBusCursor = true;
650  }
651  else if( collector[0]->Type() == SCH_LINE_T
652  && static_cast<SCH_LINE*>( collector[0] )->IsGraphicLine() )
653  {
654  displayLineCursor = true;
655  }
656 
657  getViewControls()->ForceCursorPosition( true, snappedCursorPos );
658  }
659  else if( collector[0]->IsHypertext()
660  && !collector[0]->IsSelected()
662  {
663  rolloverItem = collector[0]->m_Uuid;
664  }
665  }
666  }
667  else
668  {
670  }
671  }
672  else
673  {
674  evt->SetPassEvent();
675  }
676 
677  if( rolloverItem != lastRolloverItem )
678  {
679  EDA_ITEM* item = m_frame->GetItem( lastRolloverItem );
680 
681  if( item )
682  {
683  item->ClearFlags( IS_ROLLOVER );
684  lastRolloverItem = niluuid;
685 
686  if( item->Type() == SCH_FIELD_T )
687  m_frame->GetCanvas()->GetView()->Update( item->GetParent() );
688  else
689  m_frame->GetCanvas()->GetView()->Update( item );
690  }
691 
692  item = m_frame->GetItem( rolloverItem );
693 
694  if( item )
695  {
696  item->SetFlags( IS_ROLLOVER );
697  lastRolloverItem = rolloverItem;
698 
699  if( item->Type() == SCH_FIELD_T )
700  m_frame->GetCanvas()->GetView()->Update( item->GetParent() );
701  else
702  m_frame->GetCanvas()->GetView()->Update( item );
703  }
704  }
705 
706  if( m_frame->ToolStackIsEmpty() )
707  {
708  if( displayWireCursor )
709  {
711  }
712  else if( displayBusCursor )
713  {
715  }
716  else if( displayLineCursor )
717  {
719  }
720  else if( rolloverItem != niluuid )
721  {
723  }
724  else if( !m_selection.Empty()
725  && drag_action == MOUSE_DRAG_ACTION::DRAG_SELECTED
726  && evt->HasPosition()
727  && selectionContains( evt->Position() ) ) //move/drag option prediction
728  {
730  }
731  else
732  {
734  }
735  }
736  }
737 
738  // Shutting down; clear the selection
739  m_selection.Clear();
740 
741  return 0;
742 }
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
static TOOL_ACTION properties
Definition: ee_actions.h:117
TOOL_MENU m_menu
The functions below are not yet implemented - their interface may change.
bool selectionContains(const VECTOR2I &aPoint) const
Set up handlers for various events.
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:82
KIID niluuid(0)
bool IsUnconnected() const
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
#define IS_NEW
New item, just created.
EDA_RECT GetBoundingBox() const override
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool selectMultiple()
Handle drawing a selection box that allows one to select many items at the same time.
static TOOL_ACTION unfoldBus
Definition: ee_actions.h:78
static TOOL_ACTION zoomFitScreen
Definition: actions.h:96
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
EE_COLLECTOR.
Definition: ee_collectors.h:42
Schematic editor (Eeschema) main window.
static TOOL_ACTION zoomFitObjects
Definition: actions.h:97
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
void SetIsHover(bool aIsHover)
Definition: selection.h:68
const KICAD_T movableSymbolItems[]
void setModifiersState(bool aShiftState, bool aCtrlState, bool aAltState)
Set the configuration of m_additive, m_subtractive, m_exclusive_or, m_skip_heuristics from the state ...
EESCHEMA_SETTINGS * eeconfig() const
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
Definition: kiid.h:44
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
MOUSE_DRAG_ACTION
bool selectPoint(EE_COLLECTOR &aCollector, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
This is the primary SelectPoint method that will prompt the user with a menu to disambiguate multiple...
void narrowSelection(EE_COLLECTOR &collector, const VECTOR2I &aWhere, bool aCheckLocked)
Apply rules to narrow the collection down to selectable objects, and then heuristics to try and narro...
MOUSE_DRAG_ACTION GetDragAction() const
Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects.
Definition: tools_holder.h:133
#define IS_MOVING
Item being moved.
static TOOL_ACTION drawWire
Definition: ee_actions.h:76
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
bool ToolStackIsEmpty()
Definition: tools_holder.h:116
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:154
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
bool CollectHits(EE_COLLECTOR &aCollector, const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Select one or more items at the location given by parameter aWhere.
virtual EDA_ITEM * GetItem(const KIID &aId) const
Fetch an item by KIID.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
static TOOL_ACTION drawBus
Definition: ee_actions.h:77
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
bool IsNet() const
Schematic symbol object.
Definition: sch_symbol.h:78
int AddItemToSel(const TOOL_EVENT &aEvent)
bool SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
This overload of SelectPoint will create an EE_COLLECTOR and collect hits at location aWhere before c...
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
#define IS_ROLLOVER
Rollover active. Used for hyperlink highlighting.
SCH_BASE_FRAME * m_frame
static const KICAD_T AllItems[]
Definition: ee_collectors.h:45
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.cpp:72
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
static TOOL_ACTION enterSheet
Definition: ee_actions.h:180
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:171
static TOOL_ACTION drawLines
Definition: ee_actions.h:88
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
bool IsBus() const
EE_SELECTION m_selection
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:59
EDA_ITEM * Front() const
Definition: selection.h:144
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:364
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1504
const KICAD_T movableSchematicItems[]
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:543
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
The symbol library editor main window.

References AddItemToSel(), EE_COLLECTOR::AllItems, ARROW, EESCHEMA_SETTINGS::DRAWING::auto_start_wires, BUT_LEFT, BUT_MIDDLE, BUT_RIGHT, SELECTION::Clear(), EDA_ITEM::ClearFlags(), ClearSelection(), CollectHits(), DRAG_ANY, DRAG_SELECTED, EE_ACTIONS::drawBus, EE_ACTIONS::drawLines, EE_ACTIONS::drawWire, SCH_BASE_FRAME::eeconfig(), SELECTION::Empty(), EE_ACTIONS::enterSheet, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SELECTION::Front(), EE_SELECTION::GetBoundingBox(), SCH_BASE_FRAME::GetCanvas(), COLLECTOR::GetCount(), SYMBOL_EDIT_FRAME::GetCurSymbol(), TOOLS_HOLDER::GetDragAction(), EDA_DRAW_FRAME::GetItem(), EDA_ITEM::GetParent(), SCH_DRAW_PANEL::GetView(), TOOL_BASE::getViewControls(), grid, HAND, ID_POPUP_SCH_SELECT_UNIT_CMP, ID_POPUP_SCH_SELECT_UNIT_SYM_MAX, ID_POPUP_SCH_UNFOLD_BUS, ID_POPUP_SCH_UNFOLD_BUS_END, EDA_RECT::Inflate(), TOOL_MANAGER::InvokeTool(), IS_MOVING, IS_NEW, IS_ROLLOVER, SCH_CONNECTION::IsBus(), SCH_CONNECTION::IsNet(), LIB_SYMBOL::IsRoot(), SCH_CONNECTION::IsUnconnected(), LAYER_CONNECTABLE, LINE_BUS, LINE_GRAPHIC, LINE_WIRE_ADD, m_additive, EESCHEMA_SETTINGS::m_Drawing, m_exclusive_or, m_frame, m_isSymbolEditor, TOOL_INTERACTIVE::m_menu, m_nonModifiedCursor, m_selection, m_subtractive, TOOL_BASE::m_toolMgr, TOOL_ACTION::MakeEvent(), MD_ALT, MD_CTRL, MD_SHIFT, movableSchematicItems, movableSymbolItems, MOVING, narrowSelection(), niluuid, TOOL_EVENT::Parameter(), TOOL_MANAGER::ProcessEvent(), EE_ACTIONS::properties, DRAW_SEGMENT_EVENT_PARAMS::quitOnDraw, RemoveItemFromSel(), RequestSelection(), TOOL_MANAGER::RunAction(), SCH_FIELD_T, SCH_LINE_T, SCH_SHEET_T, SCH_SYMBOL_T, SELECT, selectionContains(), selectMultiple(), SelectPoint(), selectPoint(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), EDA_ITEM::SetFlags(), SELECTION::SetIsHover(), setModifiersState(), TOOL_MENU::ShowContextMenu(), TA_CHOICE_MENU_CHOICE, TA_UNDO_REDO_PRE, TC_COMMAND, TOOLS_HOLDER::ToolStackIsEmpty(), EDA_ITEM::Type(), EE_ACTIONS::unfoldBus, KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), ACTIONS::zoomFitObjects, and ACTIONS::zoomFitScreen.

Referenced by setTransitions().

◆ narrowSelection()

void EE_SELECTION_TOOL::narrowSelection ( EE_COLLECTOR collector,
const VECTOR2I aWhere,
bool  aCheckLocked 
)
private

Apply rules to narrow the collection down to selectable objects, and then heuristics to try and narrow it to a single object.

Definition at line 797 of file ee_selection_tool.cpp.

799 {
800  for( int i = collector.GetCount() - 1; i >= 0; --i )
801  {
802  if( !Selectable( collector[i] ) )
803  {
804  collector.Remove( i );
805  continue;
806  }
807 
808  if( aCheckLocked && collector[i]->IsLocked() )
809  {
810  collector.Remove( i );
811  continue;
812  }
813 
814  // SelectPoint, unlike other selection routines, can select line ends
815  if( collector[i]->Type() == SCH_LINE_T )
816  {
817  SCH_LINE* line = (SCH_LINE*) collector[i];
818  line->ClearFlags( STARTPOINT | ENDPOINT );
819 
820  if( HitTestPoints( line->GetStartPoint(), (wxPoint) aWhere, collector.m_Threshold ) )
821  line->SetFlags( STARTPOINT );
822  else if( HitTestPoints( line->GetEndPoint(), (wxPoint) aWhere, collector.m_Threshold ) )
823  line->SetFlags( ENDPOINT );
824  else
825  line->SetFlags( STARTPOINT | ENDPOINT );
826  }
827  }
828 
829  // Apply some ugly heuristics to avoid disambiguation menus whenever possible
830  if( collector.GetCount() > 1 && !m_skip_heuristics )
831  {
832  GuessSelectionCandidates( collector, aWhere );
833  }
834 }
int m_Threshold
Definition: collector.h:248
#define STARTPOINT
When a line is selected, these flags indicate which.
wxPoint GetStartPoint() const
Definition: sch_line.h:90
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
bool Selectable(const EDA_ITEM *aItem, bool checkVisibilityOnly=false) const
Check conditions for an item to be selected.
#define ENDPOINT
ends. (Used to support dragging.)
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:154
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
bool HitTestPoints(const wxPoint &pointA, const wxPoint &pointB, double threshold)
Test, if two points are near each other.
Definition: trigo.h:186
wxPoint GetEndPoint() const
Definition: sch_line.h:93

References EDA_ITEM::ClearFlags(), ENDPOINT, COLLECTOR::GetCount(), SCH_LINE::GetEndPoint(), SCH_LINE::GetStartPoint(), GuessSelectionCandidates(), HitTestPoints(), m_skip_heuristics, COLLECTOR::m_Threshold, COLLECTOR::Remove(), SCH_LINE_T, Selectable(), EDA_ITEM::SetFlags(), and STARTPOINT.

Referenced by Main(), and SelectPoint().

◆ OnIdle()

void EE_SELECTION_TOOL::OnIdle ( wxIdleEvent &  aEvent)

Definition at line 745 of file ee_selection_tool.cpp.

746 {
747  if( m_frame->ToolStackIsEmpty() && !m_multiple )
748  {
749  wxMouseState keyboardState = wxGetMouseState();
750 
751  setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(),
752  keyboardState.AltDown() );
753 
754  if( m_additive )
756  else if( m_subtractive )
758  else if( m_exclusive_or )
760  else
762  }
763 }
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
void setModifiersState(bool aShiftState, bool aCtrlState, bool aAltState)
Set the configuration of m_additive, m_subtractive, m_exclusive_or, m_skip_heuristics from the state ...
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool ToolStackIsEmpty()
Definition: tools_holder.h:116
SCH_BASE_FRAME * m_frame

References ADD, SCH_BASE_FRAME::GetCanvas(), m_additive, m_exclusive_or, m_frame, m_multiple, m_nonModifiedCursor, m_subtractive, EDA_DRAW_PANEL_GAL::SetCurrentCursor(), setModifiersState(), SUBTRACT, TOOLS_HOLDER::ToolStackIsEmpty(), and XOR.

Referenced by SCH_BASE_FRAME::SCH_BASE_FRAME().

◆ RebuildSelection()

void EE_SELECTION_TOOL::RebuildSelection ( )

Rebuild the selection from the EDA_ITEMs' selection flags.

Commonly called after rolling back an undo state to make sure there aren't any stale pointers.

Definition at line 1509 of file ee_selection_tool.cpp.

1510 {
1511  m_selection.Clear();
1512 
1513  if( m_isSymbolEditor )
1514  {
1515  LIB_SYMBOL* start = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
1516 
1517  for( LIB_ITEM& item : start->GetDrawItems() )
1518  {
1519  if( item.IsSelected() )
1520  select( static_cast<EDA_ITEM*>( &item ) );
1521  }
1522  }
1523  else
1524  {
1525  for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
1526  {
1527  // If the field and symbol are selected, only use the symbol
1528  if( item->IsSelected() )
1529  {
1530  select( item );
1531  }
1532  else
1533  {
1534  item->RunOnChildren(
1535  [&]( SCH_ITEM* aChild )
1536  {
1537  if( aChild->IsSelected() )
1538  select( aChild );
1539  } );
1540  }
1541  }
1542  }
1543 
1545 
1546  // Inform other potentially interested tools
1548 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:199
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:82
bool IsSelected() const
Definition: eda_item.h:123
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void select(EDA_ITEM *aItem)
Take necessary action mark an item as selected.
Define a library symbol object.
Definition: lib_symbol.h:96
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
void updateReferencePoint()
Set the reference point to the anchor of the top-left item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:473
SCH_BASE_FRAME * m_frame
EE_RTREE & Items()
Definition: sch_screen.h:102
EE_SELECTION m_selection
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197

References SELECTION::Clear(), LIB_SYMBOL::GetDrawItems(), SCH_BASE_FRAME::GetScreen(), EDA_ITEM::IsSelected(), SCH_SCREEN::Items(), m_frame, m_isSymbolEditor, m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), select(), EVENTS::SelectedEvent, and updateReferencePoint().

Referenced by SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), and SYMBOL_EDITOR_EDIT_TOOL::Undo().

◆ RemoveItemFromSel() [1/2]

int EE_SELECTION_TOOL::RemoveItemFromSel ( const TOOL_EVENT aEvent)

Definition at line 1432 of file ee_selection_tool.cpp.

1433 {
1434  RemoveItemFromSel( aEvent.Parameter<EDA_ITEM*>() );
1435  m_selection.SetIsHover( false );
1436  return 0;
1437 }
void SetIsHover(bool aIsHover)
Definition: selection.h:68
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
EE_SELECTION m_selection

References m_selection, TOOL_EVENT::Parameter(), and SELECTION::SetIsHover().

Referenced by SCH_EDIT_FRAME::DeleteJunction(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), Main(), SCH_EDIT_FRAME::SchematicCleanUp(), and setTransitions().

◆ RemoveItemFromSel() [2/2]

void EE_SELECTION_TOOL::RemoveItemFromSel ( EDA_ITEM aItem,
bool  aQuietMode = false 
)

Definition at line 1440 of file ee_selection_tool.cpp.

1441 {
1442  if( aItem )
1443  {
1444  unselect( aItem );
1445 
1446  // Inform other potentially interested tools
1447  if( !aQuietMode )
1449  }
1450 }
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:200
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void unselect(EDA_ITEM *aItem)
Take necessary action mark an item as unselected.

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

◆ RemoveItemsFromSel() [1/3]

int EE_SELECTION_TOOL::RemoveItemsFromSel ( const TOOL_EVENT aEvent)

Definition at line 1453 of file ee_selection_tool.cpp.

1454 {
1455  RemoveItemsFromSel( aEvent.Parameter<EDA_ITEMS*>(), false );
1456  m_selection.SetIsHover( false );
1457  return 0;
1458 }
void SetIsHover(bool aIsHover)
Definition: selection.h:68
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:507
int RemoveItemsFromSel(const TOOL_EVENT &aEvent)
EE_SELECTION m_selection

References m_selection, TOOL_EVENT::Parameter(), and SELECTION::SetIsHover().

Referenced by SCH_MOVE_TOOL::Main(), RemoveItemsFromSel(), and setTransitions().

◆ RemoveItemsFromSel() [2/3]

void EE_SELECTION_TOOL::RemoveItemsFromSel ( EDA_ITEMS aList,
bool  aQuietMode = false 
)

Definition at line 1461 of file ee_selection_tool.cpp.

1462 {
1463  if( aList )
1464  {
1465  for( EDA_ITEM* item : *aList )
1466  unselect( item );
1467 
1468  // Inform other potentially interested tools
1469  if( !aQuietMode )
1471  }
1472 }
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:200
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void unselect(EDA_ITEM *aItem)
Take necessary action mark an item as unselected.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100

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

◆ RemoveItemsFromSel() [3/3]

void EE_SELECTION_TOOL::RemoveItemsFromSel ( std::vector< KIID > *  aList,
bool  aQuietMode = false 
)

A safer version of RemoveItemsFromSel( EDA_ITEMS ) which doesn't require the items to still exist.

Definition at line 1475 of file ee_selection_tool.cpp.

1476 {
1477  EDA_ITEMS removeItems;
1478 
1479  for( EDA_ITEM* item : m_selection )
1480  {
1481  if( alg::contains( *aList, item->m_Uuid ) )
1482  removeItems.push_back( item );
1483  }
1484 
1485  RemoveItemsFromSel( &removeItems, aQuietMode );
1486 }
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:507
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:81
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
int RemoveItemsFromSel(const TOOL_EVENT &aEvent)
EE_SELECTION m_selection

References alg::contains(), m_selection, and RemoveItemsFromSel().

◆ RequestSelection()

EE_SELECTION & EE_SELECTION_TOOL::RequestSelection ( const KICAD_T aFilterList = EE_COLLECTOR::AllItems)

Return either an existing selection (filtered), or the selection at the current cursor if the existing selection is empty.

Definition at line 1112 of file ee_selection_tool.cpp.

1113 {
1114  if( m_selection.Empty() )
1115  {
1116  VECTOR2D cursorPos = getViewControls()->GetCursorPosition( true );
1117 
1118  ClearSelection();
1119  SelectPoint( cursorPos, aFilterList );
1120  m_selection.SetIsHover( true );
1122  }
1123  else // Trim an existing selection by aFilterList
1124  {
1125  for( int i = (int) m_selection.GetSize() - 1; i >= 0; --i )
1126  {
1127  EDA_ITEM* item = (EDA_ITEM*) m_selection.GetItem( i );
1128 
1129  if( !item->IsType( aFilterList ) )
1130  {
1131  unselect( item );
1133  }
1134  }
1135  }
1136 
1138 
1139  return m_selection;
1140 }
void ClearReferencePoint()
Definition: selection.h:191
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:200
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void SetIsHover(bool aIsHover)
Definition: selection.h:68
void updateReferencePoint()
Set the reference point to the anchor of the top-left item.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:183
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:87
void unselect(EDA_ITEM *aItem)
Take necessary action mark an item as unselected.
bool SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
This overload of SelectPoint will create an EE_COLLECTOR and collect hits at location aWhere before c...
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:52
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
EE_SELECTION m_selection
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

References SELECTION::ClearReferencePoint(), ClearSelection(), SELECTION::Empty(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), SELECTION::GetItem(), SELECTION::GetSize(), TOOL_BASE::getViewControls(), EDA_ITEM::IsType(), m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), SelectPoint(), SELECTION::SetIsHover(), unselect(), EVENTS::UnselectedEvent, and updateReferencePoint().

Referenced by SCH_MOVE_TOOL::AlignElements(), SCH_EDIT_FRAME::AnnotateSymbols(), SCH_EDIT_TOOL::AutoplaceFields(), SCH_EDIT_TOOL::BreakWire(), SCH_EDIT_TOOL::ChangeSymbols(), SCH_EDIT_TOOL::ChangeTextType(), SCH_EDIT_FRAME::CheckAnnotate(), SCH_EDIT_TOOL::CleanupSheetPins(), SCH_EDIT_TOOL::ConvertDeMorgan(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), SCH_EDIT_FRAME::DeleteAnnotation(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::EditPageNumber(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::EnterSheet(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), Main(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), SCH_EDIT_FRAME::SaveSymbolToSchematic(), SelectConnection(), EE_INSPECTION_TOOL::ShowDatasheet(), and BUS_UNFOLD_MENU::update().

◆ Reset()

void EE_SELECTION_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Bring 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 235 of file ee_selection_tool.cpp.

236 {
237  m_frame = getEditFrame<SCH_BASE_FRAME>();
238 
239  if( aReason == TOOL_BASE::MODEL_RELOAD )
240  {
241  // Remove pointers to the selected items from containers without changing their
242  // properties (as they are already deleted while a new sheet is loaded)
243  m_selection.Clear();
244  getView()->GetPainter()->GetSettings()->SetHighlight( false );
245 
246  SYMBOL_EDIT_FRAME* symbolEditFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
247  SYMBOL_VIEWER_FRAME* symbolViewerFrame = dynamic_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
248 
249  if( symbolEditFrame )
250  {
251  m_isSymbolEditor = true;
252  m_unit = symbolEditFrame->GetUnit();
253  m_convert = symbolEditFrame->GetConvert();
254  }
255  else
256  m_isSymbolViewer = symbolViewerFrame != nullptr;
257  }
258  else
259  // Restore previous properties of selected items and remove them from containers
260  ClearSelection();
261 
262  // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
263  getView()->Remove( &m_selection );
264  getView()->Add( &m_selection );
265 }
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:82
Model changes (required full reload)
Definition: tool_base.h:80
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:352
Symbol library viewer main window.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:207
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual RENDER_SETTINGS * GetSettings()=0
Return a pointer to current settings that are going to be used when drawing items.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Turns on/off highlighting.
SCH_BASE_FRAME * m_frame
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:322
EE_SELECTION m_selection
The symbol library editor main window.

References KIGFX::VIEW::Add(), SELECTION::Clear(), ClearSelection(), SYMBOL_EDIT_FRAME::GetConvert(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), SYMBOL_EDIT_FRAME::GetUnit(), TOOL_BASE::getView(), m_convert, m_frame, m_isSymbolEditor, m_isSymbolViewer, m_selection, m_unit, TOOL_BASE::MODEL_RELOAD, KIGFX::VIEW::Remove(), and KIGFX::RENDER_SETTINGS::SetHighlight().

◆ RunMainStack()

void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Call a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

88 {
89  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
90 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

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

Referenced by DRAWING_TOOL::PlaceText().

◆ select()

void EE_SELECTION_TOOL::select ( EDA_ITEM aItem)
private

Take necessary action mark an item as selected.

Parameters
aItemis an item to be selected.

Definition at line 1787 of file ee_selection_tool.cpp.

1788 {
1789  highlight( aItem, SELECTED, &m_selection );
1790 }
void highlight(EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
Highlight the item visually.
#define SELECTED
EE_SELECTION m_selection

References highlight(), m_selection, and SELECTED.

Referenced by AddItemsToSel(), AddItemToSel(), RebuildSelection(), SelectAll(), SelectConnection(), selectMultiple(), and selectPoint().

◆ Selectable()

bool EE_SELECTION_TOOL::Selectable ( const EDA_ITEM aItem,
bool  checkVisibilityOnly = false 
) const

Check conditions for an item to be selected.

Returns
True if the item fulfills conditions to be selected.

Definition at line 1712 of file ee_selection_tool.cpp.

1713 {
1714  // NOTE: in the future this is where Eeschema layer/itemtype visibility will be handled
1715 
1716  SYMBOL_EDIT_FRAME* symEditFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
1717 
1718  // Do not allow selection of anything except fields when the current symbol in the symbol
1719  // editor is a derived symbol.
1720  if( symEditFrame && symEditFrame->IsSymbolAlias() && aItem->Type() != LIB_FIELD_T )
1721  return false;
1722 
1723  switch( aItem->Type() )
1724  {
1725  case SCH_PIN_T:
1726  if( !static_cast<const SCH_PIN*>( aItem )->IsVisible() && !m_frame->GetShowAllPins() )
1727  return false;
1728  break;
1729 
1730  case LIB_SYMBOL_T: // In symbol_editor we do not want to select the symbol itself.
1731  return false;
1732 
1733  case LIB_FIELD_T: // LIB_FIELD object can always be edited.
1734  break;
1735 
1736  case LIB_ARC_T:
1737  case LIB_CIRCLE_T:
1738  case LIB_TEXT_T:
1739  case LIB_RECTANGLE_T:
1740  case LIB_POLYLINE_T:
1741  case LIB_BEZIER_T:
1742  case LIB_PIN_T:
1743  {
1744  if( symEditFrame )
1745  {
1746  LIB_ITEM* lib_item = (LIB_ITEM*) aItem;
1747 
1748  if( lib_item->GetUnit() && lib_item->GetUnit() != symEditFrame->GetUnit() )
1749  return false;
1750 
1751  if( lib_item->GetConvert() && lib_item->GetConvert() != symEditFrame->GetConvert() )
1752  return false;
1753  }
1754 
1755  break;
1756  }
1757 
1758  case SCH_MARKER_T: // Always selectable
1759  return true;
1760 
1761  default: // Suppress warnings
1762  break;
1763  }
1764 
1765  return true;
1766 }
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
int GetUnit() const
Definition: lib_item.h:259
bool IsSymbolAlias() const
Restore the empty editor screen, without any symbol or library selected.
int GetConvert() const
Definition: lib_item.h:262
virtual bool GetShowAllPins() const
Allow some frames to show/hide hidden pins.
SCH_BASE_FRAME * m_frame
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
The symbol library editor main window.

References SYMBOL_EDIT_FRAME::GetConvert(), LIB_ITEM::GetConvert(), SCH_BASE_FRAME::GetShowAllPins(), SYMBOL_EDIT_FRAME::GetUnit(), LIB_ITEM::GetUnit(), SYMBOL_EDIT_FRAME::IsSymbolAlias(), LIB_ARC_T, LIB_BEZIER_T, LIB_CIRCLE_T, LIB_FIELD_T, LIB_PIN_T, LIB_POLYLINE_T, LIB_RECTANGLE_T, LIB_SYMBOL_T, LIB_TEXT_T, m_frame, SCH_MARKER_T, SCH_PIN_T, and EDA_ITEM::Type().

Referenced by SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), narrowSelection(), SelectAll(), and selectMultiple().

◆ SelectAll()

int EE_SELECTION_TOOL::SelectAll ( const TOOL_EVENT aEvent)

Definition at line 916 of file ee_selection_tool.cpp.

917 {
918  m_multiple = true; // Multiple selection mode is active
919  KIGFX::VIEW* view = getView();
920 
921  // hold all visible items
922  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
923  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> sheetPins;
924 
925  // Filter the view items based on the selection box
926  BOX2I selectionBox;
927 
928  selectionBox.SetMaximum();
929  view->Query( selectionBox, selectedItems ); // Get the list of selected items
930 
931  // Sheet pins aren't in the view; add them by hand
932  for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems )
933  {
934  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( pair.first );
935 
936  if( sheet )
937  {
938  int layer = pair.second;
939 
940  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
941  sheetPins.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( pin, layer ) );
942  }
943  }
944 
945  selectedItems.insert( selectedItems.end(), sheetPins.begin(), sheetPins.end() );
946 
947  for( const std::pair<KIGFX::VIEW_ITEM*, int>& item_pair : selectedItems )
948  {
949  if( EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( item_pair.first ) )
950  {
951  if( Selectable( item ) )
952  select( item );
953  }
954  }
955 
956  m_multiple = false;
957 
958  return 0;
959 }
bool Selectable(const EDA_ITEM *aItem, bool checkVisibilityOnly=false) const
Check conditions for an item to be selected.
void select(EDA_ITEM *aItem)
Take necessary action mark an item as selected.
void SetMaximum()
Definition: box2.h:63
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:184
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
Definition: view.h:72
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
Definition: view.cpp:428
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67

References SCH_SHEET::GetPins(), TOOL_BASE::getView(), m_multiple, pin, KIGFX::VIEW::Query(), select(), Selectable(), and BOX2< Vec >::SetMaximum().

Referenced by setTransitions().

◆ SelectConnection()

int EE_SELECTION_TOOL::SelectConnection ( const TOOL_EVENT aEvent)

Clear current selection event handler.

Definition at line 1364 of file ee_selection_tool.cpp.

1365 {
1366  static KICAD_T wiresAndBuses[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
1367 
1368  RequestSelection( wiresAndBuses );
1369 
1370  if( m_selection.Empty() )
1371  return 0;
1372 
1373  SCH_LINE* line = (SCH_LINE*) m_selection.Front();
1374  EDA_ITEMS items;
1375 
1377  std::set<SCH_ITEM*> conns = m_frame->GetScreen()->MarkConnections( line );
1378 
1379  for( SCH_ITEM* item : conns )
1380  select( item );
1381 
1382  if( m_selection.GetSize() > 1 )
1384 
1385  return 0;
1386 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:199
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void select(EDA_ITEM *aItem)
Take necessary action mark an item as selected.
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
EE_SELECTION & RequestSelection(const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Return either an existing selection (filtered), or the selection at the current cursor if the existin...
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:507
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:97
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:87
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
SCH_BASE_FRAME * m_frame
void ClearDrawingState()
Clear the state flags of all the items in the screen.
Definition: sch_screen.cpp:825
EE_SELECTION m_selection
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
EDA_ITEM * Front() const
Definition: selection.h:144
std::set< SCH_ITEM * > MarkConnections(SCH_LINE *aSegment)
Return all wires and junctions connected to aSegment which are not connected any symbol pin.
Definition: sch_screen.cpp:345

References SCH_SCREEN::ClearDrawingState(), SELECTION::Empty(), EOT, SELECTION::Front(), SCH_BASE_FRAME::GetScreen(), SELECTION::GetSize(), m_frame, m_selection, TOOL_BASE::m_toolMgr, SCH_SCREEN::MarkConnections(), TOOL_MANAGER::ProcessEvent(), RequestSelection(), SCH_LINE_LOCATE_BUS_T, SCH_LINE_LOCATE_WIRE_T, select(), and EVENTS::SelectedEvent.

Referenced by setTransitions().

◆ SelectHighlightItem()

void EE_SELECTION_TOOL::SelectHighlightItem ( EDA_ITEM aItem)
inline

Find (but don't select) node under cursor.

Definition at line 126 of file ee_selection_tool.h.

References highlight(), and SELECTED.

Referenced by SCH_EDIT_FRAME::SaveSymbolToSchematic().

◆ selectionContains()

bool EE_SELECTION_TOOL::selectionContains ( const VECTOR2I aPoint) const
private

Set up handlers for various events.

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

Definition at line 1865 of file ee_selection_tool.cpp.

1866 {
1867  const unsigned GRIP_MARGIN = 20;
1868  VECTOR2I margin = getView()->ToWorld( VECTOR2I( GRIP_MARGIN, GRIP_MARGIN ), false );
1869 
1870  // Check if the point is located within any of the currently selected items bounding boxes
1871  for( EDA_ITEM* item : m_selection )
1872  {
1873  BOX2I itemBox = item->ViewBBox();
1874  itemBox.Inflate( margin.x, margin.y ); // Give some margin for gripping an item
1875 
1876  if( itemBox.Contains( aPoint ) )
1877  return true;
1878  }
1879 
1880  return false;
1881 }
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
Definition: view.cpp:451
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:141
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Function Inflate inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:292
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
EE_SELECTION m_selection

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

◆ SelectionMenu()

int EE_SELECTION_TOOL::SelectionMenu ( const TOOL_EVENT aEvent)

Show a popup menu to trim the COLLECTOR passed as aEvent's parameter down to a single item.

Note
This routine does not modify the selection.

Definition at line 1551 of file ee_selection_tool.cpp.

1552 {
1553  EE_COLLECTOR* collector = aEvent.Parameter<EE_COLLECTOR*>();
1554 
1555  if( !doSelectionMenu( collector ) )
1556  collector->m_MenuCancelled = true;
1557 
1558  return 0;
1559 }
EE_COLLECTOR.
Definition: ee_collectors.h:42
bool m_MenuCancelled
Definition: collector.h:251
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
bool doSelectionMenu(EE_COLLECTOR *aItems)
Allow the selection of a single item from a list via pop-up menu.

References doSelectionMenu(), COLLECTOR::m_MenuCancelled, and TOOL_EVENT::Parameter().

Referenced by setTransitions().

◆ selectMultiple()

bool EE_SELECTION_TOOL::selectMultiple ( )
private

Handle drawing a selection box that allows one to select many items at the same time.

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

Definition at line 1159 of file ee_selection_tool.cpp.

1160 {
1161  bool cancelled = false; // Was the tool canceled while it was running?
1162  m_multiple = true; // Multiple selection mode is active
1163  KIGFX::VIEW* view = getView();
1164 
1166  view->Add( &area );
1167 
1168  while( TOOL_EVENT* evt = Wait() )
1169  {
1170  int width = area.GetEnd().x - area.GetOrigin().x;
1171 
1172  /* Selection mode depends on direction of drag-selection:
1173  * Left > Right : Select objects that are fully enclosed by selection
1174  * Right > Left : Select objects that are crossed by selection
1175  */
1176  bool windowSelection = width >= 0;
1177 
1178  if( view->IsMirroredX() )
1179  windowSelection = !windowSelection;
1180 
1183 
1184  if( evt->IsCancelInteractive() || evt->IsActivate() )
1185  {
1186  cancelled = true;
1187  break;
1188  }
1189 
1190  if( evt->IsDrag( BUT_LEFT ) )
1191  {
1192  if( !m_additive && !m_subtractive && !m_exclusive_or )
1193  ClearSelection();
1194 
1195  // Start drawing a selection box
1196  area.SetOrigin( evt->DragOrigin() );
1197  area.SetEnd( evt->Position() );
1198  area.SetAdditive( m_additive );
1199  area.SetSubtractive( m_subtractive );
1201 
1202  view->SetVisible( &area, true );
1203  view->Update( &area );
1204  getViewControls()->SetAutoPan( true );
1205  }
1206 
1207  if( evt->IsMouseUp( BUT_LEFT ) )
1208  {
1209  getViewControls()->SetAutoPan( false );
1210 
1211  // End drawing the selection box
1212  view->SetVisible( &area, false );
1213 
1214  // Mark items within the selection box as selected
1215  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
1216  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> children;
1217 
1218  // Filter the view items based on the selection box
1219  BOX2I selectionBox = area.ViewBBox();
1220  view->Query( selectionBox, selectedItems ); // Get the list of selected items
1221 
1222  // Some children aren't in the view; add them by hand.
1223  // DO NOT add them directly to selectedItems. If we add enough to cause the vector
1224  // to grow it will re-allocate and invalidate the top-level for-loop iterator.
1225  for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems )
1226  {
1227  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( pair.first );
1228 
1229  if( sheet )
1230  {
1231  int layer = pair.second;
1232 
1233  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1234  children.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( pin, layer ) );
1235  }
1236 
1237  SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( pair.first );
1238 
1239  if( symbol )
1240  {
1241  int layer = pair.second;
1242 
1243  for( SCH_FIELD& field : symbol->GetFields() )
1244  children.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( &field, layer ) );
1245  }
1246 
1247  SCH_GLOBALLABEL* gLabel = dynamic_cast<SCH_GLOBALLABEL*>( pair.first );
1248 
1249  if( gLabel )
1250  {
1251  int layer = pair.second;
1252  SCH_FIELD* intersheetRef = gLabel->GetIntersheetRefs();
1253 
1254  children.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( intersheetRef, layer ) );
1255  }
1256  }
1257 
1258  selectedItems.insert( selectedItems.end(), children.begin(), children.end() );
1259 
1260  int height = area.GetEnd().y - area.GetOrigin().y;
1261 
1262  bool anyAdded = false;
1263  bool anySubtracted = false;
1264 
1265  // Construct an EDA_RECT to determine EDA_ITEM selection
1266  EDA_RECT selectionRect( (wxPoint) area.GetOrigin(), wxSize( width, height ) );
1267 
1268  selectionRect.Normalize();
1269 
1270  for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems )
1271  {
1272  EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( pair.first );
1273 
1274  if( item && Selectable( item ) && item->HitTest( selectionRect, windowSelection ) )
1275  {
1276  if( m_subtractive || ( m_exclusive_or && item->IsSelected() ) )
1277  {
1278  unselect( item );
1279  anySubtracted = true;
1280  }
1281  else
1282  {
1283  select( item );
1284  item->SetFlags( STARTPOINT | ENDPOINT );
1285  anyAdded = true;
1286  }
1287  }
1288  }
1289 
1290  m_selection.SetIsHover( false );
1291 
1292  // Inform other potentially interested tools
1293  if( anyAdded )
1295 
1296  if( anySubtracted )
1298 
1299  break; // Stop waiting for events
1300  }
1301  }
1302 
1303  getViewControls()->SetAutoPan( false );
1304 
1305  // Stop drawing the selection box
1306  view->Remove( &area );
1307  m_multiple = false; // Multiple selection mode is inactive
1308 
1309  if( !cancelled )
1311 
1312  return cancelled;
1313 }
void ClearReferencePoint()
Definition: selection.h:191
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:49
static const TOOL_EVENT SelectedEvent
Definition: actions.h:199
void SetEnd(VECTOR2I aEnd)
Set the current end of the rectangle (the corner that moves with the cursor.
#define STARTPOINT
When a line is selected, these flags indicate which.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
bool IsSelected() const
Definition: eda_item.h:123
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:200
void SetOrigin(VECTOR2I aOrigin)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:352
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:701
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:153
void SetExclusiveOr(bool aExclusiveOr)
bool Selectable(const EDA_ITEM *aItem, bool checkVisibilityOnly=false) const
Check conditions for an item to be selected.
void select(EDA_ITEM *aItem)
Take necessary action mark an item as selected.
#define ENDPOINT
ends. (Used to support dragging.)
void SetIsHover(bool aIsHover)
Definition: selection.h:68
void SetAdditive(bool aAdditive)
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const
Test if aPosition is contained within or on the bounding box of an item.
Definition: eda_item.h:225
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Generic, UI-independent tool event.
Definition: tool_event.h:152
const BOX2I ViewBBox() const override
Set the origin of the rectangle (the fixed corner)
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:54
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:237
void SetSubtractive(bool aSubtractive)
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:184
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
SCH_FIELD * GetIntersheetRefs()
Definition: sch_text.h:403
void unselect(EDA_ITEM *aItem)
Take necessary action mark an item as unselected.
Schematic symbol object.
Definition: sch_symbol.h:78
SCH_BASE_FRAME * m_frame
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
Definition: view.h:72
Handle the component boundary box.
Definition: eda_rect.h:42
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1450
Represent a selection area (currently a rectangle) in a VIEW, drawn corner-to-corner between two poin...
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:322
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Find all visible items that touch or are within the rectangle aRect.
Definition: view.cpp:428
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
EE_SELECTION m_selection
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1504

References KIGFX::VIEW::Add(), BUT_LEFT, SELECTION::ClearReferencePoint(), ClearSelection(), ENDPOINT, SCH_BASE_FRAME::GetCanvas(), KIGFX::PREVIEW::SELECTION_AREA::GetEnd(), SCH_SYMBOL::GetFields(), SCH_GLOBALLABEL::GetIntersheetRefs(), KIGFX::PREVIEW::SELECTION_AREA::GetOrigin(), SCH_SHEET::GetPins(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), EDA_ITEM::HitTest(), KIGFX::VIEW::IsMirroredX(), EDA_ITEM::IsSelected(), m_additive, m_exclusive_or, m_frame, m_multiple, m_selection, m_subtractive, TOOL_BASE::m_toolMgr, EDA_RECT::Normalize(), pin, TOOL_MANAGER::ProcessEvent(), KIGFX::VIEW::Query(), KIGFX::VIEW::Remove(), select(), SELECT_LASSO, SELECT_WINDOW, Selectable(), EVENTS::SelectedEvent, KIGFX::PREVIEW::SELECTION_AREA::SetAdditive(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::PREVIEW::SELECTION_AREA::SetEnd(), KIGFX::PREVIEW::SELECTION_AREA::SetExclusiveOr(), EDA_ITEM::SetFlags(), SELECTION::SetIsHover(), KIGFX::PREVIEW::SELECTION_AREA::SetOrigin(), KIGFX::PREVIEW::SELECTION_AREA::SetSubtractive(), KIGFX::VIEW::SetVisible(), STARTPOINT, unselect(), EVENTS::UnselectedEvent, KIGFX::VIEW::Update(), KIGFX::PREVIEW::SELECTION_AREA::ViewBBox(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Main().

◆ SelectNode()

int EE_SELECTION_TOOL::SelectNode ( const TOOL_EVENT aEvent)

If node selected then expand to connection, otherwise select connection under cursor.

Definition at line 1354 of file ee_selection_tool.cpp.

1355 {
1356  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( false );
1357 
1358  SelectPoint( cursorPos, nodeTypes );
1359 
1360  return 0;
1361 }
static KICAD_T nodeTypes[]
bool SelectPoint(const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
This overload of SelectPoint will create an EE_COLLECTOR and collect hits at location aWhere before c...
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.

References KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_BASE::getViewControls(), nodeTypes, and SelectPoint().

Referenced by setTransitions().

◆ SelectPoint()

bool EE_SELECTION_TOOL::SelectPoint ( const VECTOR2I aWhere,
const KICAD_T aFilterList = EE_COLLECTOR::AllItems,
EDA_ITEM **  aItem = nullptr,
bool *  aSelectionCancelledFlag = nullptr,
bool  aCheckLocked = false,
bool  aAdd = false,
bool  aSubtract = false,
bool  aExclusiveOr = false 
)

This overload of SelectPoint will create an EE_COLLECTOR and collect hits at location aWhere before calling the primary SelectPoint method.

Parameters
aWhereis the location where the item(s) should be collected
aItemis set to the newly selected item if only one was selected, otherwise is unchanged.
aSelectionCancelledFlagallows the function to inform its caller that a selection was canceled (for instance, by clicking outside of the disambiguation menu).
aCheckLockedindicates if locked items should be excluded.
aAddindicates if found item(s) should be added to the selection
aSubtractindicates if found item(s) should be subtracted from the selection
aExclusiveOrindicates if found item(s) should be toggle in the selection

Definition at line 900 of file ee_selection_tool.cpp.

904 {
905  EE_COLLECTOR collector;
906 
907  if( !CollectHits( collector, aWhere, aFilterList ) )
908  return false;
909 
910  narrowSelection( collector, aWhere, aCheckLocked );
911 
912  return selectPoint( collector, aItem, aSelectionCancelledFlag, aAdd, aSubtract, aExclusiveOr );
913 }
EE_COLLECTOR.
Definition: ee_collectors.h:42
bool selectPoint(EE_COLLECTOR &aCollector, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
This is the primary SelectPoint method that will prompt the user with a menu to disambiguate multiple...
void narrowSelection(EE_COLLECTOR &collector, const VECTOR2I &aWhere, bool aCheckLocked)
Apply rules to narrow the collection down to selectable objects, and then heuristics to try and narro...
bool CollectHits(EE_COLLECTOR &aCollector, const VECTOR2I &aWhere, const KICAD_T *aFilterList=EE_COLLECTOR::AllItems)
Select one or more items at the location given by parameter aWhere.

References CollectHits(), narrowSelection(), and selectPoint().

Referenced by Main(), RequestSelection(), SelectNode(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ selectPoint()

bool EE_SELECTION_TOOL::selectPoint ( EE_COLLECTOR aCollector,
EDA_ITEM **  aItem = nullptr,
bool *  aSelectionCancelledFlag = nullptr,
bool  aAdd = false,
bool  aSubtract = false,
bool  aExclusiveOr = false 
)
private

This is the primary SelectPoint method that will prompt the user with a menu to disambiguate multiple selections and then finish by adding, subtracting or toggling the item(s) to the actual selection group.

Parameters
aCollectoris an EE_COLLECTOR that already has collected items
aItemis set to the newly selected item if only one was selected, otherwise is unchanged.
aSelectionCancelledFlagallows the function to inform its caller that a selection was canceled (for instance, by clicking outside of the disambiguation menu).
aAddindicates if found item(s) should be added to the selection
aSubtractindicates if found item(s) should be subtracted from the selection
aExclusiveOrindicates if found item(s) should be toggle in the selection

Definition at line 837 of file ee_selection_tool.cpp.

840 {
842 
843  // If still more than one item we're going to have to ask the user.
844  if( aCollector.GetCount() > 1 )
845  {
846  // Must call selectionMenu via RunAction() to avoid event-loop contention
847  m_toolMgr->RunAction( EE_ACTIONS::selectionMenu, true, &aCollector );
848 
849  if( aCollector.m_MenuCancelled )
850  {
851  if( aSelectionCancelledFlag )
852  *aSelectionCancelledFlag = true;
853 
854  return false;
855  }
856  }
857 
858  if( !aAdd && !aSubtract && !aExclusiveOr )
859  ClearSelection();
860 
861  bool anyAdded = false;
862  bool anySubtracted = false;
863 
864  if( aCollector.GetCount() > 0 )
865  {
866  for( int i = 0; i < aCollector.GetCount(); ++i )
867  {
868  if( aSubtract || ( aExclusiveOr && aCollector[i]->IsSelected() ) )
869  {
870  unselect( aCollector[i] );
871  anySubtracted = true;
872  }
873  else
874  {
875  select( aCollector[i] );
876  anyAdded = true;
877  }
878  }
879  }
880 
881  if( anyAdded )
882  {
884 
885  if( aItem && aCollector.GetCount() == 1 )
886  *aItem = aCollector[0];
887 
888  return true;
889  }
890  else if( anySubtracted )
891  {
893  return true;
894  }
895 
896  return false;
897 }
void ClearReferencePoint()
Definition: selection.h:191
static const TOOL_EVENT SelectedEvent
Definition: actions.h:199
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:200
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:143
void select(EDA_ITEM *aItem)
Take necessary action mark an item as selected.
bool m_MenuCancelled
Definition: collector.h:251
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void unselect(EDA_ITEM *aItem)
Take necessary action mark an item as unselected.
static TOOL_ACTION selectionMenu
Runs a selection menu to select from a list of items.
Definition: ee_actions.h:64
EE_SELECTION m_selection

References SELECTION::ClearReferencePoint(), ClearSelection(), COLLECTOR::GetCount(), COLLECTOR::m_MenuCancelled, m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), TOOL_MANAGER::RunAction(), select(), EVENTS::SelectedEvent, EE_ACTIONS::selectionMenu, unselect(), and EVENTS::UnselectedEvent.

Referenced by Main(), and SelectPoint().

◆ SetContextMenu()

void TOOL_INTERACTIVE::SetContextMenu ( ACTION_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Assign 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 76 of file tool_interactive.cpp.

77 {
78  if( aMenu )
79  aMenu->SetTool( this );
80  else
81  aTrigger = CMENU_OFF;
82 
83  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
84 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
void SetTool(TOOL_INTERACTIVE *aTool)
Set a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Set behavior of the tool's context popup menu.

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setModifiersState()

void EE_SELECTION_TOOL::setModifiersState ( bool  aShiftState,
bool  aCtrlState,
bool  aAltState 
)
private

Set the configuration of m_additive, m_subtractive, m_exclusive_or, m_skip_heuristics from the state of modifier keys SHIFT, CTRL, ALT and depending on the OS.

Definition at line 318 of file ee_selection_tool.cpp.

319 {
320  // Set the configuration of m_additive, m_subtractive, m_exclusive_or
321  // from the state of modifier keys SHIFT, CTRL, ALT and the OS
322 
323  // on left click, a selection is made, depending on modifiers ALT, SHIFT, CTRL:
324  // Due to the fact ALT key modifier cannot be used freely on Windows and Linux,
325  // actions are different on OSX and others OS
326  // Especially, ALT key cannot be used to force showing the full selection choice
327  // context menu (the menu is immediately closed on Windows )
328  //
329  // No modifier = select items and deselect previous selection
330  // ALT (on OSX) = skip heuristic and show full selection choice
331  // ALT (on others) = exclusive OR of selected items (inverse selection)
332  //
333  // CTRL/CMD (on OSX) = exclusive OR of selected items (inverse selection)
334  // CTRL (on others) = skip heuristic and show full selection choice
335  //
336  // SHIFT = add selected items to the current selection
337  //
338  // CTRL/CMD+SHIFT (on OSX) = remove selected items to the current selection
339  // CTRL+SHIFT (on others) = unused (can be used for a new action)
340  //
341  // CTRL/CMT+ALT (on OSX) = unused (can be used for a new action)
342  // CTRL+ALT (on others) = do nothing (same as no modifier)
343  //
344  // SHIFT+ALT (on OSX) = do nothing (same as no modifier)
345  // SHIFT+ALT (on others) = remove selected items to the current selection
346 
347 #ifdef __WXOSX_MAC__
348  m_subtractive = aCtrlState && aShiftState && !aAltState;
349  m_additive = aShiftState && !aCtrlState && !aAltState;
350  m_exclusive_or = aCtrlState && !aShiftState && !aAltState;
351  m_skip_heuristics = aAltState && !aShiftState && !aCtrlState;
352 
353 #else
354  m_subtractive = aShiftState && !aCtrlState && aAltState;
355  m_additive = aShiftState && !aCtrlState && !aAltState;
356  m_exclusive_or = !aShiftState && !aCtrlState && aAltState;
357 
358  // Is the user requesting that the selection list include all possible
359  // items without removing less likely selection candidates
360  // Cannot use the Alt key on windows or the disambiguation context menu is immediately
361  // dismissed rendering it useless.
362  m_skip_heuristics = aCtrlState && !aShiftState && !aAltState;
363 #endif
364 }

References m_additive, m_exclusive_or, m_skip_heuristics, and m_subtractive.

Referenced by Main(), and OnIdle().

◆ setTransitions()

void EE_SELECTION_TOOL::setTransitions ( )
overrideprivatevirtual

This method is meant to be overridden in order to specify handlers for events.

It is called every time tool is reset or finished.

Implements TOOL_INTERACTIVE.

Definition at line 1884 of file ee_selection_tool.cpp.

1885 {
1887 
1892 
1898 
1900 }
int UpdateMenu(const TOOL_EVENT &aEvent)
int SelectAll(const TOOL_EVENT &aEvent)
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:60
static TOOL_ACTION selectConnection
If current selection is a wire or bus, expand to entire connection.
Definition: ee_actions.h:50
int AddItemsToSel(const TOOL_EVENT &aEvent)
static TOOL_ACTION removeItemsFromSel
Definition: ee_actions.h:61
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
static TOOL_ACTION removeItemFromSel
Definition: ee_actions.h:57
int SelectNode(const TOOL_EVENT &aEvent)
If node selected then expand to connection, otherwise select connection under cursor.
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:56
int SelectConnection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:43
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:53
static TOOL_ACTION updateMenu
Definition: actions.h:167
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
int AddItemToSel(const TOOL_EVENT &aEvent)
int SelectionMenu(const TOOL_EVENT &aEvent)
Show a popup menu to trim the COLLECTOR passed as aEvent's parameter down to a single item.
static TOOL_ACTION selectionMenu
Runs a selection menu to select from a list of items.
Definition: ee_actions.h:64
static TOOL_ACTION selectNode
Select the junction, wire or bus segment under the cursor.
Definition: ee_actions.h:46
int RemoveItemsFromSel(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectAll
Definition: actions.h:70
int Main(const TOOL_EVENT &aEvent)
The main loop.

References EE_ACTIONS::addItemsToSel, AddItemsToSel(), EE_ACTIONS::addItemToSel, AddItemToSel(), EE_ACTIONS::clearSelection, ClearSelection(), TOOL_INTERACTIVE::Go(), Main(), EE_ACTIONS::removeItemFromSel, RemoveItemFromSel(), EE_ACTIONS::removeItemsFromSel, RemoveItemsFromSel(), ACTIONS::selectAll, SelectAll(), EE_ACTIONS::selectConnection, SelectConnection(), EE_ACTIONS::selectionActivate, EE_ACTIONS::selectionMenu, SelectionMenu(), EE_ACTIONS::selectNode, SelectNode(), UpdateMenu(), and ACTIONS::updateMenu.

◆ UnbrightenItem()

void EE_SELECTION_TOOL::UnbrightenItem ( EDA_ITEM aItem)

Definition at line 1495 of file ee_selection_tool.cpp.

1496 {
1497  unhighlight( aItem, BRIGHTENED );
1498 }
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
Unhighlight the item visually.
#define BRIGHTENED
item is drawn with a bright contour

References BRIGHTENED, and unhighlight().

Referenced by SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), and SCH_EDITOR_CONTROL::UpdateFind().

◆ unhighlight()

void EE_SELECTION_TOOL::unhighlight ( EDA_ITEM aItem,
int  aHighlightMode,
EE_SELECTION aGroup = nullptr 
)
private

Unhighlight the item visually.

Parameters
aItemis an item to be be highlighted.
aHighlightModeshould be either SELECTED or BRIGHTENED
aGroupis the group to remove the item from.

Definition at line 1832 of file ee_selection_tool.cpp.

1833 {
1834  KICAD_T itemType = aItem->Type();
1835 
1836  if( aMode == SELECTED )
1837  aItem->ClearSelected();
1838  else if( aMode == BRIGHTENED )
1839  aItem->ClearBrightened();
1840 
1841  if( aGroup )
1842  aGroup->Remove( aItem );
1843 
1844  // Unhighlight pins and fields. (All the other symbol children are currently only
1845  // represented in the LIB_SYMBOL.)
1846  if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
1847  {
1848  sch_item->RunOnChildren(
1849  [&]( SCH_ITEM* aChild )
1850  {
1851  if( aMode == SELECTED )
1852  aChild->ClearSelected();
1853  else if( aMode == BRIGHTENED )
1854  aChild->ClearBrightened();
1855  } );
1856  }
1857 
1858  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
1859  getView()->Update( aItem->GetParent() );
1860  else
1861  getView()->Update( aItem );
1862 }
void ClearSelected()
Definition: eda_item.h:132
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
void ClearBrightened()
Definition: eda_item.h:133
EDA_ITEM * GetParent() const
Definition: eda_item.h:115
#define SELECTED
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.cpp:43
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:197
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
Definition: view.cpp:1504
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
#define BRIGHTENED
item is drawn with a bright contour

References BRIGHTENED, EDA_ITEM::ClearBrightened(), EDA_ITEM::ClearSelected(), EDA_ITEM::GetParent(), TOOL_BASE::getView(), SELECTION::Remove(), SCH_FIELD_T, SCH_PIN_T, SCH_SHEET_PIN_T, SELECTED, EDA_ITEM::Type(), and KIGFX::VIEW::Update().

Referenced by ClearSelection(), doSelectionMenu(), UnbrightenItem(), and unselect().

◆ unselect()

void EE_SELECTION_TOOL::unselect ( EDA_ITEM aItem)
private

Take necessary action mark an item as unselected.

Parameters
aItemis an item to be unselected.

Definition at line 1793 of file ee_selection_tool.cpp.

1794 {
1795  unhighlight( aItem, SELECTED, &m_selection );
1796 }
#define SELECTED
EE_SELECTION m_selection
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
Unhighlight the item visually.

References m_selection, SELECTED, and unhighlight().

Referenced by RemoveItemFromSel(), RemoveItemsFromSel(), RequestSelection(), selectMultiple(), and selectPoint().

◆ UpdateMenu()

int EE_SELECTION_TOOL::UpdateMenu ( const TOOL_EVENT aEvent)

Definition at line 268 of file ee_selection_tool.cpp.

269 {
270  ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
271  CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
272 
273  if( conditionalMenu )
274  conditionalMenu->Evaluate( m_selection );
275 
276  if( actionMenu )
277  actionMenu->UpdateAll();
278 
279  return 0;
280 }
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:48
void UpdateAll()
Run update handlers for the menu and its submenus.
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:427
EE_SELECTION m_selection

References m_selection, TOOL_EVENT::Parameter(), and ACTION_MENU::UpdateAll().

Referenced by setTransitions().

◆ updateReferencePoint()

void EE_SELECTION_TOOL::updateReferencePoint ( )
private

Set the reference point to the anchor of the top-left item.

Definition at line 1143 of file ee_selection_tool.cpp.

1144 {
1145  VECTOR2I refP( 0, 0 );
1146 
1147  if( m_selection.Size() > 0 )
1148  {
1149  if( m_isSymbolEditor )
1150  refP = static_cast<LIB_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
1151  else
1152  refP = static_cast<SCH_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
1153  }
1154 
1156 }
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:186
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
int Size() const
Returns the number of selected parts.
Definition: selection.h:103
EE_SELECTION m_selection

References EE_SELECTION::GetTopLeftItem(), m_isSymbolEditor, m_selection, SELECTION::SetReferencePoint(), and SELECTION::Size().

Referenced by RebuildSelection(), and RequestSelection().

◆ Wait()

TOOL_EVENT * TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Suspend execution of the tool until an event specified in aEventList arrives.

No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

58 {
59  return m_toolMgr->ScheduleWait( this, aEventList );
60 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pause execution of a given tool until one or more events matching aConditions arrives.

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), ZOOM_TOOL::Main(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), PL_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), GERBVIEW_SELECTION_TOOL::Main(), Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PL_SELECTION_TOOL::selectMultiple(), selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_additive

bool EE_SELECTION_TOOL::m_additive
private

Definition at line 284 of file ee_selection_tool.h.

Referenced by Main(), OnIdle(), selectMultiple(), and setModifiersState().

◆ m_convert

int EE_SELECTION_TOOL::m_convert
private

Definition at line 297 of file ee_selection_tool.h.

Referenced by CollectHits(), Init(), and Reset().

◆ m_exclusive_or

bool EE_SELECTION_TOOL::m_exclusive_or
private

Definition at line 286 of file ee_selection_tool.h.

Referenced by Main(), OnIdle(), selectMultiple(), and setModifiersState().

◆ m_frame

◆ m_isSymbolEditor

bool EE_SELECTION_TOOL::m_isSymbolEditor
private

◆ m_isSymbolViewer

bool EE_SELECTION_TOOL::m_isSymbolViewer
private

Definition at line 295 of file ee_selection_tool.h.

Referenced by Init(), and Reset().

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

The functions below are not yet implemented - their interface may change.

Definition at line 106 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), ROUTER_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), PL_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_DRAWING_TOOLS::Init(), SYMBOL_EDITOR_CONTROL::Init(), PCB_VIEWER_TOOLS::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PL_SELECTION_TOOL::Init(), SCH_DRAWING_TOOLS::Init(), BOARD_EDITOR_CONTROL::Init(), GERBVIEW_SELECTION_TOOL::Init(), EDA_3D_CONTROLLER::Init(), DRAWING_TOOL::Init(), Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), PCB_SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), PCB_TOOL_BASE::Init(), PICKER_TOOL::Init(), DRAWING_TOOL::InteractivePlaceWithPreview(), PCB_PICKER_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), GERBVIEW_SELECTION_TOOL::Main(), Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_multiple

bool EE_SELECTION_TOOL::m_multiple
private

Definition at line 287 of file ee_selection_tool.h.

Referenced by OnIdle(), SelectAll(), and selectMultiple().

◆ m_nonModifiedCursor

KICURSOR EE_SELECTION_TOOL::m_nonModifiedCursor
private

Definition at line 292 of file ee_selection_tool.h.

Referenced by Main(), and OnIdle().

◆ m_selection

◆ m_skip_heuristics

bool EE_SELECTION_TOOL::m_skip_heuristics
private

Definition at line 288 of file ee_selection_tool.h.

Referenced by narrowSelection(), and setModifiersState().

◆ m_subtractive

bool EE_SELECTION_TOOL::m_subtractive
private

Definition at line 285 of file ee_selection_tool.h.

Referenced by Main(), OnIdle(), selectMultiple(), and setModifiersState().

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName (eg. pcbnew.InteractiveSelection).

Definition at line 209 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 214 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), PCB_SELECTION_TOOL::AddItemToSel(), AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), SCH_EDIT_TOOL::BreakWire(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), BOARD_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), PL_SELECTION_TOOL::ClearSelection(), PCB_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), PL_EDIT_TOOL::Copy(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), SYMBOL_EDITOR_EDIT_TOOL::editGraphicProperties(), PAD_TOOL::EditPad(), SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), GetNode(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCB_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), GuessSelectionCandidates(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PL_EDIT_TOOL::ImportDrawingSheetContent(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_REANNOTATE_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), CONVERT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), GLOBAL_EDIT_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), PL_POINT_EDITOR::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), PCB_POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), BOARD_INSPECTION_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), SCH_NAVIGATE_TOOL::LeaveSheet(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), CVPCB_CONTROL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), Main(), PCB_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), SYMBOL_EDITOR_CONTROL::OnDeMorgan(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performRouting(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_EDIT_TOOL::PinTable(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_CONTROL::Print(), GERBVIEW_CONTROL::Print(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), RebuildSelection(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), PL_SELECTION_TOOL::RemoveItemFromSel(), RemoveItemFromSel(), PCB_SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem(), RequestSelection(), PCB_SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), PCB_SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_SELECTION_TOOL::selectSameSheet(), PCB_SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), EDA_3D_CONTROLLER::SetMaterial(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GROUP_TOOL::Ungroup(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), PCB_SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), PNS::TOOL_BASE::updateStartItem(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), and BOARD_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Definition at line 213 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

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

Definition at line 206 of file tool_base.h.

Referenced by TOOL_BASE::GetType(), and BOARD_COMMIT::Push().

◆ m_unit

int EE_SELECTION_TOOL::m_unit
private

Definition at line 296 of file ee_selection_tool.h.

Referenced by CollectHits(), Init(), and Reset().


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