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

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

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

Constructor & Destructor Documentation

◆ EE_SELECTION_TOOL()

EE_SELECTION_TOOL::EE_SELECTION_TOOL ( )

Definition at line 106 of file ee_selection_tool.cpp.

106  :
107  TOOL_INTERACTIVE( "eeschema.InteractiveSelection" ),
108  m_frame( nullptr ),
109  m_additive( false ),
110  m_subtractive( false ),
111  m_exclusive_or( false ),
112  m_multiple( false ),
113  m_skip_heuristics( false ),
115  m_isSymbolEditor( false ),
116  m_isSymbolViewer( false ),
117  m_unit( 0 ),
118  m_convert( 0 )
119 {
120  m_selection.Clear();
121 }
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:96
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 124 of file ee_selection_tool.cpp.

125 {
126  getView()->Remove( &m_selection );
127 }
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:351
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:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
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(), BOARD_INSPECTION_TOOL::HighlightNetTool(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), 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(), 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(), SCH_DRAWING_TOOLS::PlaceComponent(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), 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 1421 of file ee_selection_tool.cpp.

1422 {
1423  AddItemsToSel( aEvent.Parameter<EDA_ITEMS*>(), false );
1424  m_selection.SetIsHover( false );
1425  return 0;
1426 }
int AddItemsToSel(const TOOL_EVENT &aEvent)
void SetIsHover(bool aIsHover)
Definition: selection.h:67
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:556
EE_SELECTION m_selection

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

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

◆ AddItemsToSel() [2/2]

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

Definition at line 1429 of file ee_selection_tool.cpp.

1430 {
1431  if( aList )
1432  {
1433  for( EDA_ITEM* item : *aList )
1434  select( item );
1435 
1436  // Inform other potentially interested tools
1437  if( !aQuietMode )
1439  }
1440 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:209
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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:149

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

1409 {
1410  if( aItem )
1411  {
1412  select( aItem );
1413 
1414  // Inform other potentially interested tools
1415  if( !aQuietMode )
1417  }
1418 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:209
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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:215

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ BrightenItem()

void EE_SELECTION_TOOL::BrightenItem ( EDA_ITEM aItem)

Definition at line 1486 of file ee_selection_tool.cpp.

1487 {
1488  highlight( aItem, BRIGHTENED );
1489 }
#define BRIGHTENED
item is drawn with a bright contour
Definition: eda_item.h:130
void highlight(EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
Highlight the item visually.

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

1767 {
1768  if( m_selection.Empty() )
1769  return;
1770 
1771  while( m_selection.GetSize() )
1773 
1774  getView()->Update( &m_selection );
1775 
1776  m_selection.SetIsHover( false );
1778 
1779  // Inform other potentially interested tools
1781 }
void ClearReferencePoint()
Definition: selection.h:269
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SetIsHover(bool aIsHover)
Definition: selection.h:67
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
#define SELECTED
Definition: eda_item.h:113
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
Definition: actions.h:211
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:122
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:101
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
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:203
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:1508

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

785 {
786  aCollector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
787 
788  if( m_isSymbolEditor )
789  {
790  LIB_PART* part = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurPart();
791 
792  if( !part )
793  return false;
794 
795  aCollector.Collect( part->GetDrawItems(), aFilterList, (wxPoint) aWhere, m_unit,
796  m_convert );
797  }
798  else
799  {
800  aCollector.Collect( m_frame->GetScreen(), aFilterList, (wxPoint) aWhere, m_unit,
801  m_convert );
802  }
803 
804  return aCollector.GetCount() > 0;
805 }
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)
Function Collect scans 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
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:467
Define a library symbol object.
Definition: lib_symbol.h:93
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:68

References EE_COLLECTOR::Collect(), COLLECTOR::GetCount(), LIB_PART::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 1559 of file ee_selection_tool.cpp.

1560 {
1561  EDA_ITEM* current = nullptr;
1562  bool selectAll = false;
1563  bool expandSelection = false;
1564 
1565  do
1566  {
1568  if( expandSelection )
1569  aCollector->Combine();
1570 
1571  expandSelection = false;
1572 
1573  int limit = std::min( 9, aCollector->GetCount() );
1574  ACTION_MENU menu( true );
1575 
1576  for( int i = 0; i < limit; ++i )
1577  {
1578  wxString text;
1579  EDA_ITEM* item = ( *aCollector )[i];
1580  text = item->GetSelectMenuText( m_frame->GetUserUnits() );
1581 
1582  wxString menuText = wxString::Format( "&%d. %s\t%d", i + 1, text, i + 1 );
1583  menu.Add( menuText, i + 1, item->GetMenuImage() );
1584  }
1585 
1586  menu.AppendSeparator();
1587  menu.Add( _( "Select &All\tA" ), limit + 1, nullptr );
1588 
1589  if( !expandSelection && aCollector->HasAdditionalItems() )
1590  menu.Add( _( "&Expand Selection\tE" ), limit + 2, nullptr );
1591 
1592  if( aCollector->m_MenuTitle.Length() )
1593  {
1594  menu.SetTitle( aCollector->m_MenuTitle );
1595  menu.SetIcon( info_xpm );
1596  menu.DisplayTitle( true );
1597  }
1598  else
1599  {
1600  menu.DisplayTitle( false );
1601  }
1602 
1603  SetContextMenu( &menu, CMENU_NOW );
1604 
1605  while( TOOL_EVENT* evt = Wait() )
1606  {
1607  if( evt->Action() == TA_CHOICE_MENU_UPDATE )
1608  {
1609  if( selectAll )
1610  {
1611  for( int i = 0; i < aCollector->GetCount(); ++i )
1612  unhighlight( ( *aCollector )[i], BRIGHTENED );
1613  }
1614  else if( current )
1615  {
1616  unhighlight( current, BRIGHTENED );
1617  }
1618 
1619  int id = *evt->GetCommandId();
1620 
1621  // User has pointed an item, so show it in a different way
1622  if( id > 0 && id <= limit )
1623  {
1624  current = ( *aCollector )[id - 1];
1625  highlight( current, BRIGHTENED );
1626  }
1627  else
1628  {
1629  current = nullptr;
1630  }
1631 
1632  // User has pointed on the "Select All" option
1633  if( id == limit + 1 )
1634  {
1635  for( int i = 0; i < aCollector->GetCount(); ++i )
1636  highlight( ( *aCollector )[i], BRIGHTENED );
1637  selectAll = true;
1638  }
1639  else
1640  {
1641  selectAll = false;
1642  }
1643  }
1644  else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
1645  {
1646  if( selectAll )
1647  {
1648  for( int i = 0; i < aCollector->GetCount(); ++i )
1649  unhighlight( ( *aCollector )[i], BRIGHTENED );
1650  }
1651  else if( current )
1652  unhighlight( current, BRIGHTENED );
1653 
1654  OPT<int> id = evt->GetCommandId();
1655 
1656  // User has selected the "Select All" option
1657  if( id == limit + 1 )
1658  {
1659  selectAll = true;
1660  current = nullptr;
1661  }
1662  else if( id == limit + 2 )
1663  {
1664  selectAll = false;
1665  current = nullptr;
1666  expandSelection = true;
1667  }
1668  // User has selected an item, so this one will be returned
1669  else if( id && ( *id > 0 ) && ( *id <= limit ) )
1670  {
1671  selectAll = false;
1672  current = ( *aCollector )[*id - 1];
1673  }
1674  // User has cancelled the menu (either by <esc> or clicking out of it)
1675  else
1676  {
1677  selectAll = false;
1678  current = nullptr;
1679  }
1680  }
1681  else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
1682  {
1683  break;
1684  }
1685 
1686  getView()->UpdateItems();
1687  m_frame->GetCanvas()->Refresh();
1688  }
1689  } while( expandSelection );
1690 
1691  if( selectAll )
1692  return true;
1693  else if( current )
1694  {
1695  unhighlight( current, BRIGHTENED );
1696 
1697  getView()->UpdateItems();
1698  m_frame->GetCanvas()->Refresh();
1699 
1700  aCollector->Empty();
1701  aCollector->Append( current );
1702  return true;
1703  }
1704 
1705  return false;
1706 }
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:45
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Assign a context menu and tells when it should be activated.
#define BRIGHTENED
item is drawn with a bright contour
Definition: eda_item.h:130
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:173
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
Definition: view.cpp:1389
const BITMAP_OPAQUE info_xpm[1]
Definition: info.cpp:36
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
#define _(s)
Definition: 3d_actions.cpp:33
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:123
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
boost::optional< T > OPT
Definition: optional.h:7
virtual BITMAP_DEF GetMenuImage() const
Return a pointer to an image to be used in menus.
Definition: eda_item.cpp:222
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.

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_xpm, 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, 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 185 of file tool_base.h.

186  {
187 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
188  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
189 #endif
190  return static_cast<T*>( getToolHolderInt() );
191  }
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 121 of file tool_base.h.

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

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

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

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

References TOOL_BASE::getModelInt().

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

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

135  {
136  return m_toolName;
137  }
std::string m_toolName
Definition: tool_base.h:214

References TOOL_BASE::m_toolName.

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

◆ GetNode()

EDA_ITEM * EE_SELECTION_TOOL::GetNode ( VECTOR2I  aPosition)

Select node under cursor.

Definition at line 1344 of file ee_selection_tool.cpp.

1345 {
1346  EE_COLLECTOR collector;
1347 
1348  //TODO(snh): Reimplement after exposing KNN interface
1349  int thresholdMax = KiROUND(
1351 
1352  for( int threshold : { 0, thresholdMax/2, thresholdMax } )
1353  {
1354  collector.m_Threshold = threshold;
1355  collector.Collect( m_frame->GetScreen(), nodeTypes, (wxPoint) aPosition );
1356 
1357  if( collector.GetCount() > 0 )
1358  break;
1359  }
1360 
1361  return collector.GetCount() ? collector[ 0 ] : nullptr;
1362 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:289
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)
Function Collect scans a EDA_ITEM using this class's Inspector method, which does the collection.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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:68
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 109 of file tool_base.h.

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

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:289
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

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::FindComponentAndItem(), 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(), 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(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), 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:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:291

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(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), 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(), SCH_DRAWING_TOOLS::PlaceComponent(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), 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(), 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:59
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(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), CONVERT_TOOL::setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_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_EDIT_TOOL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::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(), BOARD_INSPECTION_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::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 973 of file ee_selection_tool.cpp.

974 {
975  // There are certain parent/child and enclosure combinations that can be handled
976  // automatically.
977 
978  // Prefer exact hits to sloppy ones
979  int exactHits = 0;
980 
981  for( int i = collector.GetCount() - 1; i >= 0; --i )
982  {
983  EDA_ITEM* item = collector[ i ];
984 
985  if( item->HitTest( (wxPoint) aPos, 0 ) )
986  exactHits++;
987  }
988 
989  if( exactHits > 0 && exactHits < collector.GetCount() )
990  {
991  for( int i = collector.GetCount() - 1; i >= 0; --i )
992  {
993  EDA_ITEM* item = collector[ i ];
994 
995  if( !item->HitTest( (wxPoint) aPos, 0 ) )
996  collector.Transfer( item );
997  }
998  }
999 
1000  // Prefer a non-sheet to a sheet
1001  for( int i = 0; collector.GetCount() == 2 && i < 2; ++i )
1002  {
1003  EDA_ITEM* item = collector[ i ];
1004  EDA_ITEM* other = collector[ ( i + 1 ) % 2 ];
1005 
1006  if( item->Type() != SCH_SHEET_T && other->Type() == SCH_SHEET_T )
1007  collector.Transfer( other );
1008  }
1009 
1010  // Prefer a symbol to a pin or the opposite, when both a symbol and a pin are selected
1011  // We need to be able to select only a pin:
1012  // - to display its characteristics (especially if an ERC is attached to the pin)
1013  // - for cross probing, to select the corresponding pad.
1014  // Note also the case happens only in schematic editor. In symbol editor, the symbol
1015  // itself is never selected
1016  for( int i = 0; collector.GetCount() == 2 && i < 2; ++i )
1017  {
1018  SCH_ITEM* item = collector[i];
1019  SCH_ITEM* other = collector[( i + 1 ) % 2];
1020 
1021  if( item->Type() == SCH_COMPONENT_T && other->Type() == SCH_PIN_T )
1022  {
1023  // Make sure we aren't clicking on the pin anchor itself, only the rest of the
1024  // pin should select the symbol with this setting
1025  // To avoid conflict with the auto-start wires option
1026  EE_GRID_HELPER grid( m_toolMgr );
1027  wxPoint cursorPos = wxPoint( grid.BestSnapAnchor( aPos, LAYER_CONNECTABLE,
1028  nullptr ) );
1029 
1030  if( !m_isSymbolEditor
1032  && !other->IsPointClickableAnchor( cursorPos ) )
1033  {
1034  collector.Transfer( other );
1035  }
1036  else
1037  {
1038  collector.Transfer( item );
1039  }
1040  }
1041  }
1042 
1043  // Prefer things that are generally smaller than a symbol to a symbol
1044  const std::set<KICAD_T> preferred =
1045  {
1046  SCH_FIELD_T,
1047  SCH_LINE_T,
1051  SCH_MARKER_T
1052  };
1053 
1054  for( int i = 0; collector.GetCount() == 2 && i < 2; ++i )
1055  {
1056  EDA_ITEM* item = collector[ i ];
1057  EDA_ITEM* other = collector[ ( i + 1 ) % 2 ];
1058 
1059  if( preferred.count( item->Type() ) && other->Type() == SCH_COMPONENT_T )
1060  collector.Transfer( other );
1061  }
1062 
1063  // No need for multiple wires at a single point; if there's a junction select that;
1064  // otherwise any of the wires will do
1065  bool junction = false;
1066  bool wiresOnly = true;
1067 
1068  for( EDA_ITEM* item : collector )
1069  {
1070  if( item->Type() == SCH_JUNCTION_T )
1071  junction = true;
1072  else if( item->Type() != SCH_LINE_T )
1073  wiresOnly = false;
1074  }
1075 
1076  if( wiresOnly )
1077  {
1078  for( int j = collector.GetCount() - 1; j >= 0; --j )
1079  {
1080  if( junction && collector[ j ]->Type() != SCH_JUNCTION_T )
1081  collector.Transfer( j );
1082  else if( !junction && j > 0 )
1083  collector.Transfer( j );
1084  }
1085  }
1086 
1087  // Construct a tight box (1/2 height and width) around the center of the closest item.
1088  // All items which exist at least partly outside this box have sufficient other areas
1089  // for selection and can be dropped.
1090  EDA_ITEM* closest = nullptr;
1091  int closestDist = INT_MAX;
1092 
1093  for( EDA_ITEM* item : collector )
1094  {
1095  int dist = EuclideanNorm( item->GetBoundingBox().GetCenter() - (wxPoint) aPos );
1096 
1097  if( dist < closestDist )
1098  {
1099  closestDist = dist;
1100  closest = item;
1101  }
1102  }
1103 
1104  if( closest ) // Don't try and get a tight bbox if nothing is near the mouse pointer
1105  {
1106  EDA_RECT tightBox = closest->GetBoundingBox();
1107  tightBox.Inflate( -tightBox.GetWidth() / 4, -tightBox.GetHeight() / 4 );
1108 
1109  for( int i = collector.GetCount() - 1; i >= 0; --i )
1110  {
1111  EDA_ITEM* item = collector[i];
1112 
1113  if( item == closest )
1114  continue;
1115 
1116  if( !item->HitTest( tightBox, true ) )
1117  collector.Transfer( item );
1118  }
1119  }
1120 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
int GetWidth() const
Definition: eda_rect.h:114
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:274
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:115
virtual bool IsPointClickableAnchor(const wxPoint &aPos) const
Definition: sch_item.h:381
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:149
virtual const EDA_RECT GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:89
const wxPoint GetCenter() const
Definition: eda_rect.h:109
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:363
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162

References EE_GRID_HELPER::BestSnapAnchor(), SCH_BASE_FRAME::eeconfig(), EuclideanNorm(), EDA_ITEM::GetBoundingBox(), COLLECTOR::GetCount(), EDA_RECT::GetHeight(), EDA_RECT::GetWidth(), 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_COMPONENT_T, SCH_FIELD_T, SCH_JUNCTION_T, SCH_LINE_T, SCH_MARKER_T, SCH_NO_CONNECT_T, SCH_PIN_T, SCH_SHEET_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 1796 of file ee_selection_tool.cpp.

1797 {
1798  KICAD_T itemType = aItem->Type();
1799 
1800  if( aMode == SELECTED )
1801  aItem->SetSelected();
1802  else if( aMode == BRIGHTENED )
1803  aItem->SetBrightened();
1804 
1805  if( aGroup )
1806  aGroup->Add( aItem );
1807 
1808  // Highlight pins and fields. (All the other component children are currently only
1809  // represented in the LIB_PART and will inherit the settings of the parent component.)
1810  if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
1811  {
1812  sch_item->RunOnChildren(
1813  [&]( SCH_ITEM* aChild )
1814  {
1815  if( aMode == SELECTED )
1816  aChild->SetSelected();
1817  else if( aMode == BRIGHTENED )
1818  aChild->SetBrightened();
1819  } );
1820  }
1821 
1822  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
1823  getView()->Update( aItem->GetParent() );
1824  else
1825  getView()->Update( aItem );
1826 }
void SetBrightened()
Definition: eda_item.h:179
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:77
#define BRIGHTENED
item is drawn with a bright contour
Definition: eda_item.h:130
void SetSelected()
Definition: eda_item.h:178
#define SELECTED
Definition: eda_item.h:113
EDA_ITEM * GetParent() const
Definition: eda_item.h:164
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:196
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:1508
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162

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

134 {
135  m_frame = getEditFrame<SCH_BASE_FRAME>();
136 
137  SYMBOL_VIEWER_FRAME* symbolViewerFrame = dynamic_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
138  SYMBOL_EDIT_FRAME* symbolEditorFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
139 
140  if( symbolEditorFrame )
141  {
142  m_isSymbolEditor = true;
143  m_unit = symbolEditorFrame->GetUnit();
144  m_convert = symbolEditorFrame->GetConvert();
145  }
146  else
147  {
148  m_isSymbolViewer = symbolViewerFrame != nullptr;
149  }
150 
151  static KICAD_T wireOrBusTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
152  static KICAD_T connectedTypes[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T,
155 
156  auto wireSelection = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_WIRE_T );
157  auto busSelection = E_C::MoreThan( 0 ) && E_C::OnlyType( SCH_LINE_LOCATE_BUS_T );
158  auto wireOrBusSelection = E_C::MoreThan( 0 ) && E_C::OnlyTypes( wireOrBusTypes );
159  auto connectedSelection = E_C::MoreThan( 0 ) && E_C::OnlyTypes( connectedTypes );
160  auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyType( SCH_SHEET_T );
161 
162  auto schEditSheetPageNumberCondition =
163  [&] ( const SELECTION& aSel )
164  {
166  return false;
167 
168  return E_C::LessThan( 2 )( aSel ) && E_C::OnlyType( SCH_SHEET_T )( aSel );
169  };
170 
171  auto schEditCondition =
172  [this] ( const SELECTION& aSel )
173  {
175  };
176 
177  auto belowRootSheetCondition =
178  [&]( const SELECTION& aSel )
179  {
180  SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
181 
182  return editFrame
183  && editFrame->GetCurrentSheet().Last() != &editFrame->Schematic().Root();
184  };
185 
186  auto havePartCondition =
187  [&]( const SELECTION& sel )
188  {
189  return m_isSymbolEditor && static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurPart();
190  };
191 
192  auto& menu = m_menu.GetMenu();
193 
194  menu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 1 );
195  menu.AddItem( EE_ACTIONS::explicitCrossProbe, sheetSelection && EE_CONDITIONS::Idle, 1 );
196  menu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 1 );
197 
198  menu.AddSeparator( 100 );
199  menu.AddItem( EE_ACTIONS::drawWire, schEditCondition && EE_CONDITIONS::Empty, 100 );
200  menu.AddItem( EE_ACTIONS::drawBus, schEditCondition && EE_CONDITIONS::Empty, 100 );
201 
202  menu.AddSeparator( 100 );
204 
205  menu.AddSeparator( 100 );
207 
208  menu.AddSeparator( 200 );
209  menu.AddItem( EE_ACTIONS::selectConnection, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
210  menu.AddItem( EE_ACTIONS::placeJunction, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
211  menu.AddItem( EE_ACTIONS::placeLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
212  menu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
213  menu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
214  menu.AddItem( EE_ACTIONS::breakWire, wireSelection && EE_CONDITIONS::Idle, 250 );
215  menu.AddItem( EE_ACTIONS::breakBus, busSelection && EE_CONDITIONS::Idle, 250 );
216  menu.AddItem( EE_ACTIONS::importSingleSheetPin, sheetSelection && EE_CONDITIONS::Idle, 250 );
217  menu.AddItem( EE_ACTIONS::assignNetclass, connectedSelection && EE_CONDITIONS::Idle, 250 );
218  menu.AddItem( EE_ACTIONS::editPageNumber, schEditSheetPageNumberCondition, 250 );
219 
220  menu.AddSeparator( 400 );
221  menu.AddItem( EE_ACTIONS::symbolProperties, havePartCondition && EE_CONDITIONS::Empty, 400 );
222  menu.AddItem( EE_ACTIONS::pinTable, havePartCondition && EE_CONDITIONS::Empty, 400 );
223 
224  menu.AddSeparator( 1000 );
226 
227  return true;
228 }
static TOOL_ACTION editPageNumber
Definition: ee_actions.h:152
static TOOL_ACTION pinTable
Definition: ee_actions.h:143
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:132
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:85
static TOOL_ACTION placeJunction
Definition: ee_actions.h:81
static TOOL_ACTION selectConnection
If current selection is a wire or bus, expand to entire connection.
Definition: ee_actions.h:51
Symbol library viewer main window.
Schematic editor (Eeschema) main window.
static TOOL_ACTION importSingleSheetPin
Definition: ee_actions.h:185
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:131
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:182
static TOOL_ACTION drawWire
Definition: ee_actions.h:77
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:196
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:142
SCHEMATIC & Schematic() const
static bool IsDrawingBus(const SELECTION &aSelection)
static TOOL_ACTION drawBus
Definition: ee_actions.h:78
static TOOL_ACTION placeLabel
Definition: ee_actions.h:83
SCH_SHEET & Root() const
Definition: schematic.h:116
SCH_BASE_FRAME * m_frame
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:149
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:181
SCH_SHEET_PATH & GetCurrentSheet() const
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:84
static TOOL_ACTION finishBus
Definition: ee_actions.h:93
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:92
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:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
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 314 of file ee_selection_tool.cpp.

315 {
317 
318  KIID lastRolloverItem = niluuid;
319 
320  // Main loop: keep receiving events
321  while( TOOL_EVENT* evt = Wait() )
322  {
323  bool displayWireCursor = false;
324  bool displayBusCursor = false;
325  bool displayLineCursor = false;
326  KIID rolloverItem = lastRolloverItem;
327 
328  // on left click, a selection is made, depending on modifiers ALT, SHIFT, CTRL:
329  // Due to the fact ALT key modifier cannot be useed freely on Winows and Linux,
330  // actions are different on OSX and others OS
331  // Especially, ALT key cannot be used to force showing the full selection choice
332  // context menu (the menu is immediately closed on Windows )
333  //
334  // No modifier = select items and deselect previous selection
335  // ALT (on OSX) = skip heuristic and show full selection choice
336  // ALT (on others) = exclusive OR of selected items (inverse selection)
337  //
338  // CTRL/CMD (on OSX) = exclusive OR of selected items (inverse selection)
339  // CTRL (on others) = skip heuristic and show full selection choice
340  //
341  // SHIFT = add selected items to the current selection
342  //
343  // CTRL/CMD+SHIFT (on OSX) = remove selected items to the current selection
344  // CTRL+SHIFT (on others) = unused (can be used for a new action)
345  //
346  // CTRL/CMT+ALT (on OSX) = unused (can be used for a new action)
347  // CTRL+ALT (on others) = do nothing (same as no modifier)
348  //
349  // SHIFT+ALT (on OSX) = do nothing (same as no modifier)
350  // SHIFT+ALT (on others) = remove selected items to the current selection
351 
352 #ifdef __WXOSX_MAC__
353  m_subtractive = evt->Modifier( MD_CTRL ) &&
354  evt->Modifier( MD_SHIFT ) &&
355  !evt->Modifier( MD_ALT );
356 
357  m_additive = evt->Modifier( MD_SHIFT ) &&
358  !evt->Modifier( MD_CTRL ) &&
359  !evt->Modifier( MD_ALT );
360 
361  m_exclusive_or = evt->Modifier( MD_CTRL ) &&
362  !evt->Modifier( MD_SHIFT ) &&
363  !evt->Modifier( MD_ALT );
364 
365  m_skip_heuristics = evt->Modifier( MD_ALT ) &&
366  !evt->Modifier( MD_SHIFT ) &&
367  !evt->Modifier( MD_CTRL );
368 
369 #else
370  m_subtractive = evt->Modifier( MD_SHIFT )
371  && !evt->Modifier( MD_CTRL )
372  && evt->Modifier( MD_ALT );
373 
374  m_additive = evt->Modifier( MD_SHIFT )
375  && !evt->Modifier( MD_CTRL )
376  && !evt->Modifier( MD_ALT );
377 
378  m_exclusive_or = !evt->Modifier( MD_SHIFT )
379  && !evt->Modifier( MD_CTRL )
380  && evt->Modifier( MD_ALT );
381 
382  // Is the user requesting that the selection list include all possible
383  // items without removing less likely selection candidates
384  // Cannot use the Alt key on windows or the disambiguation context menu is immediately
385  // dismissed rendering it useless.
386  m_skip_heuristics = evt->Modifier( MD_CTRL )
387  && !evt->Modifier( MD_SHIFT )
388  && !evt->Modifier( MD_ALT );
389 #endif
390 
391  bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or;
392 
393  MOUSE_DRAG_ACTION drag_action = m_frame->GetDragAction();
394  EE_GRID_HELPER grid( m_toolMgr );
395 
396  // Single click? Select single object
397  if( evt->IsClick( BUT_LEFT ) )
398  {
399  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
400  schframe->FocusOnItem( nullptr );
401 
402  EE_COLLECTOR collector;
403  bool continueSelect = true;
404 
405  // Collect items at the clicked location (doesn't select them yet)
406  if( CollectHits( collector, evt->Position()) )
407  {
408  narrowSelection( collector, evt->Position(), false );
409 
410  if( collector.GetCount() == 1 && !m_isSymbolEditor && !modifier_enabled )
411  {
412  // Check if we want to auto start wires
413  VECTOR2I snappedCursorPos = grid.BestSnapAnchor( evt->Position(),
414  LAYER_CONNECTABLE, nullptr );
415 
417  && collector[0]->IsPointClickableAnchor( (wxPoint) snappedCursorPos ) )
418  {
419  OPT_TOOL_EVENT newEvt;
420  SCH_CONNECTION* connection = collector[0]->Connection();
421 
422  if( ( connection && ( connection->IsNet() || connection->IsUnconnected() ) )
423  || collector[0]->Type() == SCH_COMPONENT_T )
424  {
425  newEvt = EE_ACTIONS::drawWire.MakeEvent();
426  }
427  else if( connection && connection->IsBus() )
428  {
429  newEvt = EE_ACTIONS::drawBus.MakeEvent();
430  }
431  else if( collector[0]->Type() == SCH_LINE_T
432  && static_cast<SCH_LINE*>( collector[0] )->IsGraphicLine() )
433  {
434  newEvt = EE_ACTIONS::drawLines.MakeEvent();
435  }
436 
437  auto* params = newEvt->Parameter<DRAW_SEGMENT_EVENT_PARAMS*>();
438  auto* newParams = new DRAW_SEGMENT_EVENT_PARAMS();
439 
440  *newParams= *params;
441  newParams->quitOnDraw = true;
442  newEvt->SetParameter( newParams );
443 
444  getViewControls()->ForceCursorPosition( true, snappedCursorPos );
445  newEvt->SetMousePosition( snappedCursorPos );
446  newEvt->SetHasPosition( true );
447  newEvt->SetForceImmediate( true );
448  m_toolMgr->ProcessEvent( *newEvt );
449 
450  continueSelect = false;
451  }
452  else if( collector[0]->IsHypertext() )
453  {
454  collector[0]->DoHypertextMenu( m_frame );
455  continueSelect = false;
456  }
457  }
458  }
459 
460  if( continueSelect )
461  {
462  // If we didn't click on an anchor, we perform a normal select, pass in the
463  // items we previously collected
464  selectPoint( collector, nullptr, nullptr, m_additive, m_subtractive,
465  m_exclusive_or );
466  }
467  }
468  else if( evt->IsClick( BUT_RIGHT ) )
469  {
470  // right click? if there is any object - show the context menu
471  bool selectionCancelled = false;
472 
473  if( m_selection.Empty() )
474  {
475  ClearSelection();
476  SelectPoint( evt->Position(), EE_COLLECTOR::AllItems, nullptr,
477  &selectionCancelled );
478  m_selection.SetIsHover( true );
479  }
480  // If the cursor has moved off the bounding box of the selection by more than
481  // a grid square, check to see if there is another item available for selection
482  // under the cursor. If there is, the user likely meant to get the context menu
483  // for that item. If there is no new item, then keep the original selection and
484  // show the context menu for it.
485  else if( !m_selection.GetBoundingBox().Inflate(
486  grid.GetGrid().x, grid.GetGrid().y ).Contains(
487  (wxPoint) evt->Position() ) )
488  {
489  EE_SELECTION saved_selection = m_selection;
490 
491  for( auto item : m_selection )
492  RemoveItemFromSel( item, true );
493 
494  SelectPoint( evt->Position(), EE_COLLECTOR::AllItems, nullptr,
495  &selectionCancelled );
496 
497  if( m_selection.Empty() )
498  {
499  m_selection.SetIsHover( false );
500 
501  for( auto item : saved_selection )
502  AddItemToSel( item, true);
503  }
504  else
505  {
506  m_selection.SetIsHover( true );
507  }
508  }
509 
510  if( !selectionCancelled )
512  }
513  else if( evt->IsDblClick( BUT_LEFT ) )
514  {
515  // double click? Display the properties window
516  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
517  schframe->FocusOnItem( nullptr );
518 
519  if( m_selection.Empty() )
520  SelectPoint( evt->Position() );
521 
522  EDA_ITEM* item = m_selection.Front();
523 
524  if( item && item->Type() == SCH_SHEET_T )
526  else
528  }
529  else if( evt->IsDblClick( BUT_MIDDLE ) )
530  {
531  // Middle double click? Do zoom to fit or zoom to objects
532  if( evt->Modifier( MD_CTRL ) ) // Is CTRL key down?
534  else
536  }
537  else if( evt->IsDrag( BUT_LEFT ) )
538  {
539  // Is another tool already moving a new object? Don't allow a drag start
540  if( !m_selection.Empty() && m_selection[0]->HasFlag( IS_NEW | IS_MOVED ) )
541  {
542  evt->SetPassEvent();
543  continue;
544  }
545 
546  // drag with LMB? Select multiple objects (or at least draw a selection box) or
547  // drag them
548  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
549  schframe->FocusOnItem( nullptr );
550 
551  if( modifier_enabled || drag_action == MOUSE_DRAG_ACTION::SELECT )
552  {
553  selectMultiple();
554  }
555  else if( m_selection.Empty() && drag_action != MOUSE_DRAG_ACTION::DRAG_ANY )
556  {
557  selectMultiple();
558  }
559  else
560  {
561  // selection is empty? try to start dragging the item under the point where drag
562  // started
565  else if( m_selection.Empty() )
567 
568  // Check if dragging has started within any of selected items bounding box
569  if( selectionContains( evt->Position() ) )
570  {
571  // Yes -> run the move tool and wait till it finishes
572  if( m_isSymbolEditor )
573  {
574  SYMBOL_EDIT_FRAME* libFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
575 
576  // Cannot move any derived symbol elements for now.
577  if( libFrame && libFrame->GetCurPart() && libFrame->GetCurPart()->IsRoot() )
578  m_toolMgr->InvokeTool( "eeschema.SymbolMoveTool" );
579  }
580  else
581  {
582  m_toolMgr->InvokeTool( "eeschema.InteractiveMove" );
583  }
584  }
585  else
586  {
587  // No -> drag a selection box
588  selectMultiple();
589  }
590  }
591  }
592  else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
593  {
594  // context sub-menu selection? Handle unit selection or bus unfolding
595  if( evt->GetCommandId().get() >= ID_POPUP_SCH_SELECT_UNIT_CMP
596  && evt->GetCommandId().get() <= ID_POPUP_SCH_SELECT_UNIT_CMP_MAX )
597  {
598  SCH_COMPONENT* component = dynamic_cast<SCH_COMPONENT*>( m_selection.Front() );
599  int unit = evt->GetCommandId().get() - ID_POPUP_SCH_SELECT_UNIT_CMP;
600 
601  if( component )
602  static_cast<SCH_EDIT_FRAME*>( m_frame )->SelectUnit( component, unit );
603  }
604  else if( evt->GetCommandId().get() >= ID_POPUP_SCH_UNFOLD_BUS
605  && evt->GetCommandId().get() <= ID_POPUP_SCH_UNFOLD_BUS_END )
606  {
607  wxString* net = new wxString( *evt->Parameter<wxString*>() );
609  }
610 
611  }
612  else if( evt->IsCancelInteractive() )
613  {
614  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
615  schframe->FocusOnItem( nullptr );
616 
617  ClearSelection();
618  }
619  else if( evt->Action() == TA_UNDO_REDO_PRE )
620  {
621  if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
622  schframe->FocusOnItem( nullptr );
623 
624  ClearSelection();
625  }
626  else if( evt->IsMotion() && !m_isSymbolEditor && m_frame->ToolStackIsEmpty() )
627  {
628  rolloverItem = niluuid;
629  EE_COLLECTOR collector;
630 
631  // We are checking if we should display a pencil when hovering over anchors
632  // for "auto starting" wires when clicked
633  if( CollectHits( collector, evt->Position()) )
634  {
635  narrowSelection( collector, evt->Position(), false );
636 
637  if( collector.GetCount() == 1 && !modifier_enabled )
638  {
639  VECTOR2I snappedCursorPos = grid.BestSnapAnchor( evt->Position(),
640  LAYER_CONNECTABLE, nullptr );
641 
643  && collector[0]->IsPointClickableAnchor( (wxPoint) snappedCursorPos ) )
644  {
645  SCH_CONNECTION* connection = collector[0]->Connection();
646 
647  if( ( connection && ( connection->IsNet() || connection->IsUnconnected() ) )
648  || collector[0]->Type() == SCH_COMPONENT_T )
649  {
650  displayWireCursor = true;
651  }
652  else if( connection && connection->IsBus() )
653  {
654  displayBusCursor = true;
655  }
656  else if( collector[0]->Type() == SCH_LINE_T
657  && static_cast<SCH_LINE*>( collector[0] )->IsGraphicLine() )
658  {
659  displayLineCursor = true;
660  }
661 
662  getViewControls()->ForceCursorPosition( true, snappedCursorPos );
663  }
664  else if( collector[0]->IsHypertext()
665  && !collector[0]->IsSelected()
667  {
668  rolloverItem = collector[0]->m_Uuid;
669  }
670  }
671  }
672  else
673  {
675  }
676  }
677  else
678  {
679  evt->SetPassEvent();
680  }
681 
682  if( rolloverItem != lastRolloverItem )
683  {
684  EDA_ITEM* item = m_frame->GetItem( lastRolloverItem );
685 
686  if( item )
687  {
688  item->ClearFlags( IS_ROLLOVER );
689  lastRolloverItem = niluuid;
690 
691  if( item->Type() == SCH_FIELD_T )
692  m_frame->GetCanvas()->GetView()->Update( item->GetParent() );
693  else
694  m_frame->GetCanvas()->GetView()->Update( item );
695  }
696 
697  item = m_frame->GetItem( rolloverItem );
698 
699  if( item )
700  {
701  item->SetFlags( IS_ROLLOVER );
702  lastRolloverItem = rolloverItem;
703 
704  if( item->Type() == SCH_FIELD_T )
705  m_frame->GetCanvas()->GetView()->Update( item->GetParent() );
706  else
707  m_frame->GetCanvas()->GetView()->Update( item );
708  }
709  }
710 
711  if( m_frame->ToolStackIsEmpty() )
712  {
713  if( displayWireCursor )
714  {
716  }
717  else if( displayBusCursor )
718  {
720  }
721  else if( displayLineCursor )
722  {
724  }
725  else if( rolloverItem != niluuid )
726  {
728  }
729  else if( !m_selection.Empty()
730  && drag_action == MOUSE_DRAG_ACTION::DRAG_SELECTED
731  && evt->HasPosition()
732  && selectionContains( evt->Position() ) ) //move/drag option prediction
733  {
735  }
736  else
737  {
739  }
740  }
741  }
742 
743  // Shutting down; clear the selection
744  m_selection.Clear();
745 
746  return 0;
747 }
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:118
virtual EDA_ITEM * GetItem(const KIID &aId)
Fetch an item by KIID.
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:96
KIID niluuid(0)
bool IsUnconnected() const
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.
EDA_RECT GetBoundingBox() const override
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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:79
static TOOL_ACTION zoomFitScreen
Definition: actions.h:99
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
EE_COLLECTOR.
Definition: ee_collectors.h:42
Schematic editor (Eeschema) main window.
#define IS_ROLLOVER
Rollover active. Used for hyperlink highlighting.
Definition: eda_item.h:129
static TOOL_ACTION zoomFitObjects
Definition: actions.h:100
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
void SetIsHover(bool aIsHover)
Definition: selection.h:67
const KICAD_T movableSymbolItems[]
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
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:134
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:202
static TOOL_ACTION drawWire
Definition: ee_actions.h:77
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:443
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:173
bool ToolStackIsEmpty()
Definition: tools_holder.h:117
EDA_ITEM * GetParent() const
Definition: eda_item.h:164
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.
#define IS_MOVED
Item being moved.
Definition: eda_item.h:105
LIB_PART * GetCurPart()
Return the current part being edited or NULL if none selected.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
static TOOL_ACTION drawBus
Definition: ee_actions.h:78
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
bool IsNet() const
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).
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.h:123
Schematic symbol object.
Definition: sch_symbol.h:78
bool IsRoot() const override
For symbols derived from other symbols, IsRoot() indicates no derivation.
Definition: lib_symbol.h:167
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
static TOOL_ACTION enterSheet
Definition: ee_actions.h:181
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:203
static TOOL_ACTION drawLines
Definition: ee_actions.h:89
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
#define IS_NEW
New item, just created.
Definition: eda_item.h:106
EDA_ITEM * Front() const
Definition: selection.h:203
EDA_RECT & Inflate(wxCoord dx, wxCoord dy)
Inflate the rectangle horizontally by dx and vertically by dy.
Definition: eda_rect.cpp:363
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:1508
const KICAD_T movableSchematicItems[]
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:569
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
The symbol library editor main window.

References AddItemToSel(), EE_COLLECTOR::AllItems, ARROW, EESCHEMA_SETTINGS::DRAWING::auto_start_wires, EE_GRID_HELPER::BestSnapAnchor(), 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::GetCurPart(), TOOLS_HOLDER::GetDragAction(), GRID_HELPER::GetGrid(), EDA_DRAW_FRAME::GetItem(), EDA_ITEM::GetParent(), SCH_DRAW_PANEL::GetView(), TOOL_BASE::getViewControls(), HAND, ID_POPUP_SCH_SELECT_UNIT_CMP, ID_POPUP_SCH_SELECT_UNIT_CMP_MAX, ID_POPUP_SCH_UNFOLD_BUS, ID_POPUP_SCH_UNFOLD_BUS_END, EDA_RECT::Inflate(), TOOL_MANAGER::InvokeTool(), IS_MOVED, IS_NEW, IS_ROLLOVER, SCH_CONNECTION::IsBus(), SCH_CONNECTION::IsNet(), LIB_PART::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_skip_heuristics, 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_COMPONENT_T, SCH_FIELD_T, SCH_LINE_T, SCH_SHEET_T, SELECT, selectionContains(), selectMultiple(), SelectPoint(), selectPoint(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), EDA_ITEM::SetFlags(), SELECTION::SetIsHover(), 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(), VECTOR2< T >::x, VECTOR2< T >::y, 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 808 of file ee_selection_tool.cpp.

810 {
811  for( int i = collector.GetCount() - 1; i >= 0; --i )
812  {
813  if( !Selectable( collector[i] ) )
814  {
815  collector.Remove( i );
816  continue;
817  }
818 
819  if( aCheckLocked && collector[i]->IsLocked() )
820  {
821  collector.Remove( i );
822  continue;
823  }
824 
825  // SelectPoint, unlike other selection routines, can select line ends
826  if( collector[i]->Type() == SCH_LINE_T )
827  {
828  SCH_LINE* line = (SCH_LINE*) collector[i];
829  line->ClearFlags( STARTPOINT | ENDPOINT );
830 
831  if( HitTestPoints( line->GetStartPoint(), (wxPoint) aWhere, collector.m_Threshold ) )
832  line->SetFlags( STARTPOINT );
833  else if( HitTestPoints( line->GetEndPoint(), (wxPoint) aWhere, collector.m_Threshold ) )
834  line->SetFlags( ENDPOINT );
835  else
836  line->SetFlags( STARTPOINT | ENDPOINT );
837  }
838  }
839 
840  // Apply some ugly heuristics to avoid disambiguation menus whenever possible
841  if( collector.GetCount() > 1 && !m_skip_heuristics )
842  {
843  GuessSelectionCandidates( collector, aWhere );
844  }
845 }
int m_Threshold
Definition: collector.h:248
wxPoint GetStartPoint() const
Definition: sch_line.h:94
bool Selectable(const EDA_ITEM *aItem, bool checkVisibilityOnly=false) const
Check conditions for an item to be selected.
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 SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:202
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: eda_item.h:111
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
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:203
#define ENDPOINT
ends. (Used to support dragging.)
Definition: eda_item.h:112
wxPoint GetEndPoint() const
Definition: sch_line.h:97

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

751 {
752  if( m_frame->ToolStackIsEmpty() && !m_multiple )
753  {
754  wxMouseState keyboardState = wxGetMouseState();
755 
757 
758  if( keyboardState.ShiftDown() && keyboardState.ControlDown() )
759  m_subtractive = true;
760  else if( keyboardState.ShiftDown() )
761  m_additive = true;
762  else if( keyboardState.ControlDown() )
763  m_exclusive_or = true;
764 
765  if( m_additive )
767  else if( m_subtractive )
769  else if( m_exclusive_or )
771  else
773  }
774 }
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
bool ToolStackIsEmpty()
Definition: tools_holder.h:117
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(), 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 1506 of file ee_selection_tool.cpp.

1507 {
1508  m_selection.Clear();
1509 
1510  if( m_isSymbolEditor )
1511  {
1512  LIB_PART* start = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurPart();
1513 
1514  for( LIB_ITEM& item : start->GetDrawItems() )
1515  {
1516  if( item.IsSelected() )
1517  select( static_cast<EDA_ITEM*>( &item ) );
1518  }
1519  }
1520  else
1521  {
1522  for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
1523  {
1524  // If the field and component are selected, only use the component
1525  if( item->IsSelected() )
1526  {
1527  select( item );
1528  }
1529  else
1530  {
1531  item->RunOnChildren(
1532  [&]( SCH_ITEM* aChild )
1533  {
1534  if( aChild->IsSelected() )
1535  select( aChild );
1536  } );
1537  }
1538  }
1539  }
1540 
1542 
1543  // Inform other potentially interested tools
1545 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:209
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:96
bool IsSelected() const
Definition: eda_item.h:172
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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.
The base class for drawable items used by schematic library components.
Definition: lib_item.h:62
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:467
Define a library symbol object.
Definition: lib_symbol.h:93
SCH_BASE_FRAME * m_frame
EE_RTREE & Items()
Definition: sch_screen.h:162
EE_SELECTION m_selection
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196

References SELECTION::Clear(), LIB_PART::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(), SCH_EDIT_FRAME::PutDataInPreviousState(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), SYMBOL_EDIT_FRAME::RollbackSymbolFromUndo(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), and SCH_EDITOR_CONTROL::Undo().

◆ RemoveItemFromSel() [1/2]

int EE_SELECTION_TOOL::RemoveItemFromSel ( const TOOL_EVENT aEvent)

Definition at line 1443 of file ee_selection_tool.cpp.

1444 {
1445  RemoveItemFromSel( aEvent.Parameter<EDA_ITEM*>() );
1446  m_selection.SetIsHover( false );
1447  return 0;
1448 }
void SetIsHover(bool aIsHover)
Definition: selection.h:67
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
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:149
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 1451 of file ee_selection_tool.cpp.

1452 {
1453  if( aItem )
1454  {
1455  unselect( aItem );
1456 
1457  // Inform other potentially interested tools
1458  if( !aQuietMode )
1460  }
1461 }
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:210
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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/2]

int EE_SELECTION_TOOL::RemoveItemsFromSel ( const TOOL_EVENT aEvent)

Definition at line 1464 of file ee_selection_tool.cpp.

1465 {
1466  RemoveItemsFromSel( aEvent.Parameter<EDA_ITEMS*>(), false );
1467  m_selection.SetIsHover( false );
1468  return 0;
1469 }
void SetIsHover(bool aIsHover)
Definition: selection.h:67
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:443
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:556
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(), and setTransitions().

◆ RemoveItemsFromSel() [2/2]

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

Definition at line 1472 of file ee_selection_tool.cpp.

1473 {
1474  if( aList )
1475  {
1476  for( EDA_ITEM* item : *aList )
1477  unselect( item );
1478 
1479  // Inform other potentially interested tools
1480  if( !aQuietMode )
1482  }
1483 }
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:210
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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:149

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

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

1124 {
1125  if( m_selection.Empty() )
1126  {
1127  VECTOR2D cursorPos = getViewControls()->GetCursorPosition( true );
1128 
1129  ClearSelection();
1130  SelectPoint( cursorPos, aFilterList );
1131  m_selection.SetIsHover( true );
1133  }
1134  else // Trim an existing selection by aFilterList
1135  {
1136  for( int i = (int) m_selection.GetSize() - 1; i >= 0; --i )
1137  {
1138  EDA_ITEM* item = (EDA_ITEM*) m_selection.GetItem( i );
1139 
1140  if( !item->IsType( aFilterList ) )
1141  {
1142  unselect( item );
1144  }
1145  }
1146  }
1147 
1149 
1150  return m_selection;
1151 }
void ClearReferencePoint()
Definition: selection.h:269
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:210
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SetIsHover(bool aIsHover)
Definition: selection.h:67
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:232
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.h:106
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:101
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...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
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_TOOL::AutoplaceFields(), SCH_EDIT_TOOL::BreakWire(), SCH_EDIT_TOOL::ChangeSymbols(), SCH_EDIT_TOOL::ChangeTextType(), SCH_EDIT_TOOL::CleanupSheetPins(), SCH_EDIT_TOOL::ConvertDeMorgan(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), 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::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(), SelectConnection(), EE_INSPECTION_TOOL::ShowDatasheet(), BUS_UNFOLD_MENU::update(), and SCH_EDIT_FRAME::UpdateSymbolFromEditor().

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

232 {
233  m_frame = getEditFrame<SCH_BASE_FRAME>();
234 
235  if( aReason == TOOL_BASE::MODEL_RELOAD )
236  {
237  // Remove pointers to the selected items from containers without changing their
238  // properties (as they are already deleted while a new sheet is loaded)
239  m_selection.Clear();
240  getView()->GetPainter()->GetSettings()->SetHighlight( false );
241 
242  SYMBOL_EDIT_FRAME* symbolEditFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
243  SYMBOL_VIEWER_FRAME* symbolViewerFrame = dynamic_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
244 
245  if( symbolEditFrame )
246  {
247  m_isSymbolEditor = true;
248  m_unit = symbolEditFrame->GetUnit();
249  m_convert = symbolEditFrame->GetConvert();
250  }
251  else
252  m_isSymbolViewer = symbolViewerFrame != nullptr;
253  }
254  else
255  // Restore previous properties of selected items and remove them from containers
256  ClearSelection();
257 
258  // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
259  getView()->Remove( &m_selection );
260  getView()->Add( &m_selection );
261 }
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:96
Model changes (required full reload)
Definition: tool_base.h:81
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:351
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:321
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:215
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 1784 of file ee_selection_tool.cpp.

1785 {
1786  highlight( aItem, SELECTED, &m_selection );
1787 }
void highlight(EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
Highlight the item visually.
#define SELECTED
Definition: eda_item.h:113
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 1709 of file ee_selection_tool.cpp.

1710 {
1711  // NOTE: in the future this is where Eeschema layer/itemtype visibility will be handled
1712 
1713  SYMBOL_EDIT_FRAME* symEditFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
1714 
1715  // Do not allow selection of anything except fields when the current symbol in the symbol
1716  // editor is a derived symbol.
1717  if( symEditFrame && symEditFrame->IsSymbolAlias() && aItem->Type() != LIB_FIELD_T )
1718  return false;
1719 
1720  switch( aItem->Type() )
1721  {
1722  case SCH_PIN_T:
1723  if( !static_cast<const SCH_PIN*>( aItem )->IsVisible() && !m_frame->GetShowAllPins() )
1724  return false;
1725  break;
1726 
1727  case LIB_PART_T: // In symbol_editor we do not want to select the symbol itself.
1728  return false;
1729 
1730  case LIB_FIELD_T: // LIB_FIELD object can always be edited.
1731  break;
1732 
1733  case LIB_ARC_T:
1734  case LIB_CIRCLE_T:
1735  case LIB_TEXT_T:
1736  case LIB_RECTANGLE_T:
1737  case LIB_POLYLINE_T:
1738  case LIB_BEZIER_T:
1739  case LIB_PIN_T:
1740  {
1741  if( symEditFrame )
1742  {
1743  LIB_ITEM* lib_item = (LIB_ITEM*) aItem;
1744 
1745  if( lib_item->GetUnit() && lib_item->GetUnit() != symEditFrame->GetUnit() )
1746  return false;
1747 
1748  if( lib_item->GetConvert() && lib_item->GetConvert() != symEditFrame->GetConvert() )
1749  return false;
1750  }
1751 
1752  break;
1753  }
1754 
1755  case SCH_MARKER_T: // Always selectable
1756  return true;
1757 
1758  default: // Suppress warnings
1759  break;
1760  }
1761 
1762  return true;
1763 }
The base class for drawable items used by schematic library components.
Definition: lib_item.h:62
int GetUnit() const
Definition: lib_item.h:262
bool IsSymbolAlias() const
Restore the empty editor screen, without any part or library selected.
int GetConvert() const
Definition: lib_item.h:265
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:162
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_PART_T, LIB_PIN_T, LIB_POLYLINE_T, LIB_RECTANGLE_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 927 of file ee_selection_tool.cpp.

928 {
929  m_multiple = true; // Multiple selection mode is active
930  KIGFX::VIEW* view = getView();
931 
932  // hold all visible items
933  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
934  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> sheetPins;
935 
936  // Filter the view items based on the selection box
937  BOX2I selectionBox;
938 
939  selectionBox.SetMaximum();
940  view->Query( selectionBox, selectedItems ); // Get the list of selected items
941 
942  // Sheet pins aren't in the view; add them by hand
943  for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems )
944  {
945  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( pair.first );
946 
947  if( sheet )
948  {
949  int layer = pair.second;
950 
951  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
952  sheetPins.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( pin, layer ) );
953  }
954  }
955 
956  selectedItems.insert( selectedItems.end(), sheetPins.begin(), sheetPins.end() );
957 
958  for( const std::pair<KIGFX::VIEW_ITEM*, int>& item_pair : selectedItems )
959  {
960  if( EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( item_pair.first ) )
961  {
962  if( Selectable( item ) )
963  select( item );
964  }
965  }
966 
967  m_multiple = false;
968 
969  return 0;
970 }
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:73
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:85
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:219
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:365
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:149
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:427
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, 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 1375 of file ee_selection_tool.cpp.

1376 {
1377  static KICAD_T wiresAndBuses[] = { SCH_LINE_LOCATE_WIRE_T, SCH_LINE_LOCATE_BUS_T, EOT };
1378 
1379  RequestSelection( wiresAndBuses );
1380 
1381  if( m_selection.Empty() )
1382  return 0;
1383 
1384  SCH_LINE* line = (SCH_LINE*) m_selection.Front();
1385  EDA_ITEMS items;
1386 
1388  std::set<SCH_ITEM*> conns = m_frame->GetScreen()->MarkConnections( line );
1389 
1390  for( SCH_ITEM* item : conns )
1391  select( item );
1392 
1393  if( m_selection.GetSize() > 1 )
1395 
1396  return 0;
1397 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:209
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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:556
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:122
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:101
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:848
EE_SELECTION m_selection
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:196
EDA_ITEM * Front() const
Definition: selection.h:203
std::set< SCH_ITEM * > MarkConnections(SCH_LINE *aSegment)
Return all wires and junctions connected to aSegment which are not connected any component pin.
Definition: sch_screen.cpp:328

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 120 of file ee_selection_tool.h.

References highlight(), and SELECTED.

Referenced by SCH_EDIT_FRAME::UpdateSymbolFromEditor().

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

1863 {
1864  const unsigned GRIP_MARGIN = 20;
1865  VECTOR2I margin = getView()->ToWorld( VECTOR2I( GRIP_MARGIN, GRIP_MARGIN ), false );
1866 
1867  // Check if the point is located within any of the currently selected items bounding boxes
1868  for( EDA_ITEM* item : m_selection )
1869  {
1870  BOX2I itemBox = item->ViewBBox();
1871  itemBox.Inflate( margin.x, margin.y ); // Give some margin for gripping an item
1872 
1873  if( itemBox.Contains( aPoint ) )
1874  return true;
1875  }
1876 
1877  return false;
1878 }
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:450
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
bool Contains(const Vec &aPoint) const
Function Contains.
Definition: box2.h:151
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:302
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
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 1548 of file ee_selection_tool.cpp.

1549 {
1550  EE_COLLECTOR* collector = aEvent.Parameter<EE_COLLECTOR*>();
1551 
1552  if( !doSelectionMenu( collector ) )
1553  collector->m_MenuCancelled = true;
1554 
1555  return 0;
1556 }
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:443
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 1170 of file ee_selection_tool.cpp.

1171 {
1172  bool cancelled = false; // Was the tool canceled while it was running?
1173  m_multiple = true; // Multiple selection mode is active
1174  KIGFX::VIEW* view = getView();
1175 
1177  view->Add( &area );
1178 
1179  while( TOOL_EVENT* evt = Wait() )
1180  {
1181  int width = area.GetEnd().x - area.GetOrigin().x;
1182 
1183  /* Selection mode depends on direction of drag-selection:
1184  * Left > Right : Select objects that are fully enclosed by selection
1185  * Right > Left : Select objects that are crossed by selection
1186  */
1187  bool windowSelection = width >= 0;
1188 
1189  if( view->IsMirroredX() )
1190  windowSelection = !windowSelection;
1191 
1194 
1195  if( evt->IsCancelInteractive() || evt->IsActivate() )
1196  {
1197  cancelled = true;
1198  break;
1199  }
1200 
1201  if( evt->IsDrag( BUT_LEFT ) )
1202  {
1203  if( !m_additive && !m_subtractive && !m_exclusive_or )
1204  ClearSelection();
1205 
1206  // Start drawing a selection box
1207  area.SetOrigin( evt->DragOrigin() );
1208  area.SetEnd( evt->Position() );
1209  area.SetAdditive( m_additive );
1210  area.SetSubtractive( m_subtractive );
1212 
1213  view->SetVisible( &area, true );
1214  view->Update( &area );
1215  getViewControls()->SetAutoPan( true );
1216  }
1217 
1218  if( evt->IsMouseUp( BUT_LEFT ) )
1219  {
1220  getViewControls()->SetAutoPan( false );
1221 
1222  // End drawing the selection box
1223  view->SetVisible( &area, false );
1224 
1225  // Mark items within the selection box as selected
1226  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
1227  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> children;
1228 
1229  // Filter the view items based on the selection box
1230  BOX2I selectionBox = area.ViewBBox();
1231  view->Query( selectionBox, selectedItems ); // Get the list of selected items
1232 
1233  // Some children aren't in the view; add them by hand.
1234  // DO NOT add them directly to selectedItems. If we add enough to cause the vector
1235  // to grow it will re-allocate and invalidate the top-level for-loop iterator.
1236  for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems )
1237  {
1238  SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( pair.first );
1239 
1240  if( sheet )
1241  {
1242  int layer = pair.second;
1243 
1244  for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1245  children.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( pin, layer ) );
1246  }
1247 
1248  SCH_COMPONENT* symbol = dynamic_cast<SCH_COMPONENT*>( pair.first );
1249 
1250  if( symbol )
1251  {
1252  int layer = pair.second;
1253 
1254  for( SCH_FIELD& field : symbol->GetFields() )
1255  children.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( &field, layer ) );
1256  }
1257 
1258  SCH_GLOBALLABEL* gLabel = dynamic_cast<SCH_GLOBALLABEL*>( pair.first );
1259 
1260  if( gLabel )
1261  {
1262  int layer = pair.second;
1263  SCH_FIELD* intersheetRef = gLabel->GetIntersheetRefs();
1264 
1265  children.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( intersheetRef, layer ) );
1266  }
1267  }
1268 
1269  selectedItems.insert( selectedItems.end(), children.begin(), children.end() );
1270 
1271  int height = area.GetEnd().y - area.GetOrigin().y;
1272 
1273  bool anyAdded = false;
1274  bool anySubtracted = false;
1275 
1276  // Construct an EDA_RECT to determine EDA_ITEM selection
1277  EDA_RECT selectionRect( (wxPoint) area.GetOrigin(), wxSize( width, height ) );
1278 
1279  selectionRect.Normalize();
1280 
1281  for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems )
1282  {
1283  EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( pair.first );
1284 
1285  if( item && Selectable( item ) && item->HitTest( selectionRect, windowSelection ) )
1286  {
1287  if( m_subtractive || ( m_exclusive_or && item->IsSelected() ) )
1288  {
1289  unselect( item );
1290  anySubtracted = true;
1291  }
1292  else
1293  {
1294  select( item );
1295  item->SetFlags( STARTPOINT | ENDPOINT );
1296  anyAdded = true;
1297  }
1298  }
1299  }
1300 
1301  m_selection.SetIsHover( false );
1302 
1303  // Inform other potentially interested tools
1304  if( anyAdded )
1306 
1307  if( anySubtracted )
1309 
1310  break; // Stop waiting for events
1311  }
1312  }
1313 
1314  getViewControls()->SetAutoPan( false );
1315 
1316  // Stop drawing the selection box
1317  view->Remove( &area );
1318  m_multiple = false; // Multiple selection mode is inactive
1319 
1320  if( !cancelled )
1322 
1323  return cancelled;
1324 }
void ClearReferencePoint()
Definition: selection.h:269
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:51
static const TOOL_EVENT SelectedEvent
Definition: actions.h:209
void SetEnd(VECTOR2I aEnd)
Set the current end of the rectangle (the corner that moves with the cursor.
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:172
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:210
void SetOrigin(VECTOR2I aOrigin)
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:351
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.
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
void SetIsHover(bool aIsHover)
Definition: selection.h:67
void GetFields(std::vector< SCH_FIELD * > &aVector, bool aVisibleOnly)
Populates a std::vector with SCH_FIELDs.
Definition: sch_symbol.cpp:724
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:274
void SetFlags(STATUS_FLAGS aMask)
Definition: eda_item.h:202
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:173
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.h:85
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:219
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:365
void Normalize()
Ensures that the height ant width are positive.
Definition: eda_rect.cpp:35
SCH_FIELD * GetIntersheetRefs()
Definition: sch_text.h:442
void unselect(EDA_ITEM *aItem)
Take necessary action mark an item as unselected.
#define STARTPOINT
When a line is selected, these flags indicate which.
Definition: eda_item.h:111
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
Schematic symbol object.
Definition: sch_symbol.h:78
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:149
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1454
Represent a selection area (currently a rectangle) in a VIEW, drawn corner-to-corner between two poin...
#define ENDPOINT
ends. (Used to support dragging.)
Definition: eda_item.h:112
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:321
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:427
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:1508

References KIGFX::VIEW::Add(), BUT_LEFT, SELECTION::ClearReferencePoint(), ClearSelection(), ENDPOINT, SCH_BASE_FRAME::GetCanvas(), KIGFX::PREVIEW::SELECTION_AREA::GetEnd(), SCH_COMPONENT::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(), 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 1365 of file ee_selection_tool.cpp.

1366 {
1367  VECTOR2I cursorPos = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
1368 
1369  SelectPoint( cursorPos, nodeTypes );
1370 
1371  return 0;
1372 }
int Modifier(int aMask=MD_MODIFIER_MASK) const
Definition: tool_event.h:352
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(), MD_ALT, TOOL_EVENT::Modifier(), 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 911 of file ee_selection_tool.cpp.

915 {
916  EE_COLLECTOR collector;
917 
918  if( !CollectHits( collector, aWhere, aFilterList ) )
919  return false;
920 
921  narrowSelection( collector, aWhere, aCheckLocked );
922 
923  return selectPoint( collector, aItem, aSelectionCancelledFlag, aAdd, aSubtract, aExclusiveOr );
924 }
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 848 of file ee_selection_tool.cpp.

851 {
853 
854  // If still more than one item we're going to have to ask the user.
855  if( aCollector.GetCount() > 1 )
856  {
857  // Must call selectionMenu via RunAction() to avoid event-loop contention
858  m_toolMgr->RunAction( EE_ACTIONS::selectionMenu, true, &aCollector );
859 
860  if( aCollector.m_MenuCancelled )
861  {
862  if( aSelectionCancelledFlag )
863  *aSelectionCancelledFlag = true;
864 
865  return false;
866  }
867  }
868 
869  if( !aAdd && !aSubtract && !aExclusiveOr )
870  ClearSelection();
871 
872  bool anyAdded = false;
873  bool anySubtracted = false;
874 
875  if( aCollector.GetCount() > 0 )
876  {
877  for( int i = 0; i < aCollector.GetCount(); ++i )
878  {
879  if( aSubtract || ( aExclusiveOr && aCollector[i]->IsSelected() ) )
880  {
881  unselect( aCollector[i] );
882  anySubtracted = true;
883  }
884  else
885  {
886  select( aCollector[i] );
887  anyAdded = true;
888  }
889  }
890  }
891 
892  if( anyAdded )
893  {
895 
896  if( aItem && aCollector.GetCount() == 1 )
897  *aItem = aCollector[0];
898 
899  return true;
900  }
901  else if( anySubtracted )
902  {
904  return true;
905  }
906 
907  return false;
908 }
void ClearReferencePoint()
Definition: selection.h:269
static const TOOL_EVENT SelectedEvent
Definition: actions.h:209
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:210
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:141
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:65
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:215
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().

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

1882 {
1884 
1889 
1895 
1897 }
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:61
static TOOL_ACTION selectConnection
If current selection is a wire or bus, expand to entire connection.
Definition: ee_actions.h:51
int AddItemsToSel(const TOOL_EVENT &aEvent)
static TOOL_ACTION removeItemsFromSel
Definition: ee_actions.h:62
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:58
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:57
int SelectConnection(const TOOL_EVENT &aEvent)
Clear current selection event handler.
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:44
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:54
static TOOL_ACTION updateMenu
Definition: actions.h:170
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:65
static TOOL_ACTION selectNode
Select the junction, wire or bus segment under the cursor.
Definition: ee_actions.h:47
int RemoveItemsFromSel(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectAll
Definition: actions.h:73
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 1492 of file ee_selection_tool.cpp.

1493 {
1494  unhighlight( aItem, BRIGHTENED );
1495 }
#define BRIGHTENED
item is drawn with a bright contour
Definition: eda_item.h:130
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, EE_SELECTION *aGroup=nullptr)
Unhighlight the item visually.

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

1830 {
1831  KICAD_T itemType = aItem->Type();
1832 
1833  if( aMode == SELECTED )
1834  aItem->ClearSelected();
1835  else if( aMode == BRIGHTENED )
1836  aItem->ClearBrightened();
1837 
1838  if( aGroup )
1839  aGroup->Remove( aItem );
1840 
1841  // Unhighlight pins and fields. (All the other component children are currently only
1842  // represented in the LIB_PART.)
1843  if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
1844  {
1845  sch_item->RunOnChildren(
1846  [&]( SCH_ITEM* aChild )
1847  {
1848  if( aMode == SELECTED )
1849  aChild->ClearSelected();
1850  else if( aMode == BRIGHTENED )
1851  aChild->ClearBrightened();
1852  } );
1853  }
1854 
1855  if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
1856  getView()->Update( aItem->GetParent() );
1857  else
1858  getView()->Update( aItem );
1859 }
void ClearSelected()
Definition: eda_item.h:181
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
void ClearBrightened()
Definition: eda_item.h:182
#define BRIGHTENED
item is drawn with a bright contour
Definition: eda_item.h:130
#define SELECTED
Definition: eda_item.h:113
EDA_ITEM * GetParent() const
Definition: eda_item.h:164
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:196
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:1508
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:162
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:88

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

1791 {
1792  unhighlight( aItem, SELECTED, &m_selection );
1793 }
#define SELECTED
Definition: eda_item.h:113
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 264 of file ee_selection_tool.cpp.

265 {
266  ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
267  CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
268 
269  if( conditionalMenu )
270  conditionalMenu->Evaluate( m_selection );
271 
272  if( actionMenu )
273  actionMenu->UpdateAll();
274 
275  return 0;
276 }
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:45
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:443
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 1154 of file ee_selection_tool.cpp.

1155 {
1156  VECTOR2I refP( 0, 0 );
1157 
1158  if( m_selection.Size() > 0 )
1159  {
1160  if( m_isSymbolEditor )
1161  refP = static_cast<LIB_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
1162  else
1163  refP = static_cast<SCH_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
1164  }
1165 
1167 }
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:264
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
int Size() const
Returns the number of selected parts.
Definition: selection.h:128
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:215
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(), ZOOM_TOOL::Main(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PL_POINT_EDITOR::Main(), CVPCB_CONTROL::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(), SCH_DRAWING_TOOLS::PlaceComponent(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), 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 272 of file ee_selection_tool.h.

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

◆ m_convert

int EE_SELECTION_TOOL::m_convert
private

Definition at line 285 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 274 of file ee_selection_tool.h.

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

◆ m_frame

◆ m_isSymbolEditor

bool EE_SELECTION_TOOL::m_isSymbolEditor
private

◆ m_isSymbolViewer

bool EE_SELECTION_TOOL::m_isSymbolViewer
private

Definition at line 283 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_CONTROL::Init(), SYMBOL_EDITOR_DRAWING_TOOLS::Init(), PCB_VIEWER_TOOLS::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PL_SELECTION_TOOL::Init(), SCH_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), BOARD_EDITOR_CONTROL::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(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_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(), SCH_DRAWING_TOOLS::PlaceComponent(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), 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 275 of file ee_selection_tool.h.

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

◆ m_nonModifiedCursor

KICURSOR EE_SELECTION_TOOL::m_nonModifiedCursor
private

Definition at line 280 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 276 of file ee_selection_tool.h.

Referenced by Main(), and narrowSelection().

◆ m_subtractive

bool EE_SELECTION_TOOL::m_subtractive
private

Definition at line 273 of file ee_selection_tool.h.

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

◆ 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 210 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 215 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(), SCH_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(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), PCB_POINT_EDITOR::finishItem(), 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(), BOARD_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), 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(), BOARD_INSPECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), 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(), CVPCB_CONTROL::Main(), SYMBOL_EDITOR_MOVE_TOOL::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(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_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(), SCH_DRAWING_TOOLS::PlaceComponent(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), 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(), 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 214 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 207 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 284 of file ee_selection_tool.h.

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


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