KiCad PCB EDA Suite
EE_SELECTION_TOOL Class Reference

#include <ee_selection_tool.h>

Inheritance diagram for EE_SELECTION_TOOL:
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 Main (const TOOL_EVENT &aEvent)
 The main loop. More...
 
void OnIdle (wxIdleEvent &aEvent)
 Zoom the screen to fit the bounding box for cross probing/selection sync. More...
 
void ZoomFitCrossProbeBBox (const BOX2I &aBBox)
 
EE_SELECTIONGetSelection ()
 
EE_SELECTIONRequestSelection (const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T })
 Return either an existing selection (filtered), or the selection at the current cursor position if the existing selection is empty. More...
 
bool SelectPoint (const VECTOR2I &aWhere, const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T }, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
 Perform a click-type selection at a point (usually the cursor position). More...
 
EDA_ITEMGetNode (VECTOR2I aPosition)
 Finds a connected item at a point (usually the cursor position). More...
 
int SelectNode (const TOOL_EVENT &aEvent)
 Selects the connected item at the current cursor position. More...
 
int SelectConnection (const TOOL_EVENT &aEvent)
 If a connected item is selected then expand the selection to the entire connection, otherwise select connection under the current cursor position. More...
 
int ClearSelection (const TOOL_EVENT &aEvent)
 Select all visible items in sheet. More...
 
int SelectAll (const TOOL_EVENT &aEvent)
 
void ClearSelection (bool aQuietMode=false)
 
bool Selectable (const EDA_ITEM *aItem, const VECTOR2I *aPos=nullptr, 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...
 
void RebuildSelection ()
 Rebuild the selection from the EDA_ITEMs' selection flags. More...
 
bool CollectHits (EE_COLLECTOR &aCollector, const VECTOR2I &aWhere, const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T })
 Collect one or more items at a given point. More...
 
int SyncSelection (std::optional< SCH_SHEET_PATH > targetSheetPath, SCH_ITEM *focusItem, std::vector< SCH_ITEM * > items)
 
int UpdateMenu (const TOOL_EVENT &aEvent)
 Update a menu's state based on the current selection. More...
 
int AddItemToSel (const TOOL_EVENT &aEvent)
 
void AddItemToSel (EDA_ITEM *aItem, bool aQuietMode=false)
 
int AddItemsToSel (const TOOL_EVENT &aEvent)
 
void AddItemsToSel (EDA_ITEMS *aList, bool aQuietMode=false)
 
int RemoveItemFromSel (const TOOL_EVENT &aEvent)
 
void RemoveItemFromSel (EDA_ITEM *aItem, bool aQuietMode=false)
 
int RemoveItemsFromSel (const TOOL_EVENT &aEvent)
 
void RemoveItemsFromSel (EDA_ITEMS *aList, bool aQuietMode=false)
 
void RemoveItemsFromSel (std::vector< KIID > *aList, bool aQuietMode=false)
 A safer version of RemoveItemsFromSel( EDA_ITEMS ) which doesn't require the items to still exist. More...
 
void BrightenItem (EDA_ITEM *aItem)
 
void UnbrightenItem (EDA_ITEM *aItem)
 
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 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

SELECTIONselection () override
 Return a reference to the selection. More...
 
void onDisambiguationExpire (wxTimerEvent &aEvent)
 Start the process to show our disambiguation menu once the user has kept the mouse down for the minimum time. More...
 
void setModifiersState (bool aShiftState, bool aCtrlState, bool aAltState)
 Set the configuration of m_additive, m_subtractive, m_exclusive_or, m_skip_heuristics from the state of modifier keys SHIFT, CTRL, ALT and depending on the OS. More...
 
virtual bool ctrlClickHighlights ()
 Determines if ctrl-click is highlight net or XOR selection. More...
 
bool doSelectionMenu (COLLECTOR *aCollector)
 
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

bool m_additive
 
bool m_subtractive
 
bool m_exclusive_or
 
bool m_multiple
 
bool m_skip_heuristics
 
bool m_highlight_modifier
 
bool m_drag_additive
 
bool m_drag_subtractive
 
bool m_canceledMenu
 
wxTimer m_disambiguateTimer
 
VECTOR2I m_originalCursor
 
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

OPT_TOOL_EVENT autostartEvent (TOOL_EVENT *aEvent, EE_GRID_HELPER &aGrid, SCH_ITEM *aItem)
 
void narrowSelection (EE_COLLECTOR &collector, const VECTOR2I &aWhere, bool aCheckLocked, bool aSelectedOnly=false)
 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, const VECTOR2I &aWhere, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
 Perform a click-type selection at a point (usually the cursor position). More...
 
bool selectMultiple ()
 Handle drawing a selection box that allows one to select many items at the same time. More...
 
int disambiguateCursor (const TOOL_EVENT &aEvent)
 Handle disambiguation actions including displaying the menu. More...
 
void select (EDA_ITEM *aItem) override
 Take necessary action to mark an item as selected. More...
 
void unselect (EDA_ITEM *aItem) override
 Take necessary action to mark an item as unselected. More...
 
void highlight (EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
 Highlight the item visually. More...
 
void unhighlight (EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
 Unhighlight the item visually. More...
 
void updateReferencePoint ()
 Set the reference point to the anchor of the top-left item. More...
 
bool selectionContains (const VECTOR2I &aPoint) const
 Set up handlers for various events. More...
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
void resetTransitions ()
 Clear the current transition map and restores the default one created by setTransitions(). More...
 
void goInternal (TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
 
EDA_ITEMgetModelInt () const
 
TOOLS_HOLDERgetToolHolderInt () const
 

Private Attributes

SCH_BASE_FRAMEm_frame
 
EE_SELECTION m_selection
 
KICURSOR m_nonModifiedCursor
 
bool m_isSymbolEditor
 
bool m_isSymbolViewer
 
int m_unit
 
int m_convert
 

Detailed Description

Definition at line 57 of file ee_selection_tool.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determine the reason of reset for a tool.

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 77 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ EE_SELECTION_TOOL()

EE_SELECTION_TOOL::EE_SELECTION_TOOL ( )

Definition at line 125 of file ee_selection_tool.cpp.

125 :
126 SELECTION_TOOL( "eeschema.InteractiveSelection" ),
127 m_frame( nullptr ),
129 m_isSymbolEditor( false ),
130 m_isSymbolViewer( false ),
131 m_unit( 0 ),
132 m_convert( 0 )
133{
135}
EE_SELECTION m_selection
SCH_BASE_FRAME * m_frame
SELECTION_TOOL(const std::string &aName)
virtual void Clear() override
Remove all the stored items from the group.
Definition: selection.h:90

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

◆ ~EE_SELECTION_TOOL()

EE_SELECTION_TOOL::~EE_SELECTION_TOOL ( )

Definition at line 138 of file ee_selection_tool.cpp.

139{
141}
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:346
KIGFX::VIEW * getView() const
Returns the instance of #VIEW object used in the application.
Definition: tool_base.cpp:36

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

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

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

Definition at line 51 of file tool_interactive.cpp.

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

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

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_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(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), ROUTER_TOOL::RouteSelected(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ AddItemsToSel() [1/2]

int SELECTION_TOOL::AddItemsToSel ( const TOOL_EVENT aEvent)
inherited

Definition at line 122 of file selection_tool.cpp.

123{
124 AddItemsToSel( aEvent.Parameter<EDA_ITEMS*>(), false );
125 selection().SetIsHover( false );
126 return 0;
127}
int AddItemsToSel(const TOOL_EVENT &aEvent)
virtual SELECTION & selection()=0
Return a reference to the selection.
void SetIsHover(bool aIsHover)
Definition: selection.h:76
T Parameter() const
Return a non-standard parameter assigned to the event.
Definition: tool_event.h:442
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
Definition: eda_item.h:524

References SELECTION_TOOL::AddItemsToSel(), TOOL_EVENT::Parameter(), SELECTION_TOOL::selection(), and SELECTION::SetIsHover().

Referenced by SELECTION_TOOL::AddItemsToSel(), EDIT_TOOL::MoveIndividually(), setTransitions(), PL_SELECTION_TOOL::setTransitions(), and PCB_SELECTION_TOOL::setTransitions().

◆ AddItemsToSel() [2/2]

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

Definition at line 130 of file selection_tool.cpp.

131{
132 if( aList )
133 {
134 for( EDA_ITEM* item : *aList )
135 select( item );
136
137 // Inform other potentially interested tools
138 if( !aQuietMode )
140 }
141}
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
static const TOOL_EVENT SelectedEvent
Definition: actions.h:205
virtual void select(EDA_ITEM *aItem)=0
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(), SELECTION_TOOL::select(), and EVENTS::SelectedEvent.

◆ AddItemToSel() [1/2]

◆ AddItemToSel() [2/2]

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

Definition at line 109 of file selection_tool.cpp.

110{
111 if( aItem )
112 {
113 select( aItem );
114
115 // Inform other potentially interested tools
116 if( !aQuietMode )
118 }
119}

References TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), SELECTION_TOOL::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}

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ autostartEvent()

OPT_TOOL_EVENT EE_SELECTION_TOOL::autostartEvent ( TOOL_EVENT aEvent,
EE_GRID_HELPER aGrid,
SCH_ITEM aItem 
)
private

Definition at line 707 of file ee_selection_tool.cpp.

709{
710 VECTOR2I pos = aGrid.BestSnapAnchor( aEvent->Position(), LAYER_CONNECTABLE );
711
714 && aItem->IsPointClickableAnchor( pos ) )
715 {
717
718 if( aItem->Type() == SCH_BUS_BUS_ENTRY_T )
719 {
721 }
722 else if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
723 {
724 SCH_BUS_WIRE_ENTRY* busEntry = static_cast<SCH_BUS_WIRE_ENTRY*>( aItem );
725
726 if( !busEntry->m_connected_bus_item )
728 }
729 else if( aItem->Type() == SCH_LINE_T )
730 {
731 SCH_LINE* line = static_cast<SCH_LINE*>( aItem );
732
733 if( line->IsBus() )
734 newEvt = EE_ACTIONS::drawBus.MakeEvent();
735 else if( line->IsGraphicLine() )
736 newEvt = EE_ACTIONS::drawLines.MakeEvent();
737 }
738
739 newEvt->SetMousePosition( pos );
740 newEvt->SetHasPosition( true );
741 newEvt->SetForceImmediate( true );
742
743 getViewControls()->ForceCursorPosition( true, pos );
744
745 return newEvt;
746 }
747
748 return OPT_TOOL_EVENT();
749}
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
static TOOL_ACTION drawWire
Definition: ee_actions.h:83
static TOOL_ACTION drawBus
Definition: ee_actions.h:84
static TOOL_ACTION drawLines
Definition: ee_actions.h:101
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, int aLayer, SCH_ITEM *aDraggedItem)
Tool that displays edit points allowing to modify items by dragging the points.
bool HasPoint()
Indicate the cursor is over an edit point.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
EESCHEMA_SETTINGS * eeconfig() const
Class for a wire to bus entry.
SCH_ITEM * m_connected_bus_item
Pointer to the bus item (usually a bus wire) connected to this bus-wire entry, if it is connected to ...
virtual bool IsPointClickableAnchor(const VECTOR2I &aPos) const
Definition: sch_item.h:355
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
bool IsBus() const
Return true if the line is a bus.
Definition: sch_line.cpp:932
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
Definition: sch_line.cpp:920
TOOL_EVENT MakeEvent() const
Return the event associated with the action (i.e.
Definition: tool_action.cpp:72
KIGFX::VIEW_CONTROLS * getViewControls() const
Return the instance of VIEW_CONTROLS object used in the application.
Definition: tool_base.cpp:42
const VECTOR2D Position() const
Returns the point where dragging has started.
Definition: tool_event.h:266
@ LAYER_CONNECTABLE
std::optional< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:557
@ SCH_LINE_T
Definition: typeinfo.h:145
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:144
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:143

References EESCHEMA_SETTINGS::DRAWING::auto_start_wires, EE_GRID_HELPER::BestSnapAnchor(), EE_ACTIONS::drawBus, EE_ACTIONS::drawLines, EE_ACTIONS::drawWire, SCH_BASE_FRAME::eeconfig(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), TOOL_MANAGER::GetTool(), TOOL_BASE::getViewControls(), EE_POINT_EDITOR::HasPoint(), SCH_LINE::IsBus(), SCH_LINE::IsGraphicLine(), SCH_ITEM::IsPointClickableAnchor(), LAYER_CONNECTABLE, SCH_BUS_WIRE_ENTRY::m_connected_bus_item, EESCHEMA_SETTINGS::m_Drawing, m_frame, TOOL_BASE::m_toolMgr, TOOL_ACTION::MakeEvent(), TOOL_EVENT::Position(), SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_LINE_T, and EDA_ITEM::Type().

Referenced by Main().

◆ BrightenItem()

void SELECTION_TOOL::BrightenItem ( EDA_ITEM aItem)
inherited

Definition at line 201 of file selection_tool.cpp.

202{
203 highlight( aItem, BRIGHTENED );
204}
virtual void highlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr)=0
Highlight the item visually.
#define BRIGHTENED
item is drawn with a bright contour

References BRIGHTENED, and SELECTION_TOOL::highlight().

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

◆ ClearSelection() [1/2]

void EE_SELECTION_TOOL::ClearSelection ( bool  aQuietMode = false)

Definition at line 1794 of file ee_selection_tool.cpp.

1795{
1796 if( m_selection.Empty() )
1797 return;
1798
1799 while( m_selection.GetSize() )
1801
1802 getView()->Update( &m_selection );
1803
1804 m_selection.SetIsHover( false );
1806
1807 // Inform other potentially interested tools
1808 if( !aQuietMode )
1809 {
1811 }
1812}
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Unhighlight the item visually.
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
Definition: actions.h:207
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:1574
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:97
EDA_ITEM * Front() const
Definition: selection.h:200
void ClearReferencePoint()
Definition: selection.h:257
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:107
#define SELECTED
Item was manually selected by the user.

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

◆ ClearSelection() [2/2]

int EE_SELECTION_TOOL::ClearSelection ( const TOOL_EVENT aEvent)

◆ CollectHits()

bool EE_SELECTION_TOOL::CollectHits ( EE_COLLECTOR aCollector,
const VECTOR2I aWhere,
const std::vector< KICAD_T > &  aScanTypes = SCH_LOCATE_ANY_T } 
)

Collect one or more items at a given point.

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

Parameters
aCollector[in, out] Provides collection conditions and stores collected items.
aWherePoint from which the collection should be made.
aScanTypes[optional] A list of item types that are acceptable for collection. Set selection to items passed by parameter. Zooms to fit, if enabled.

Definition at line 795 of file ee_selection_tool.cpp.

797{
798 int pixelThreshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
799 int gridThreshold = KiROUND( getView()->GetGAL()->GetGridSize().EuclideanNorm() / 2 );
800 aCollector.m_Threshold = std::max( pixelThreshold, gridThreshold );
802
803 if( m_isSymbolEditor )
804 {
805 LIB_SYMBOL* symbol = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
806
807 if( !symbol )
808 return false;
809
810 aCollector.Collect( symbol->GetDrawItems(), aScanTypes, aWhere, m_unit, m_convert );
811 }
812 else
813 {
814 aCollector.Collect( m_frame->GetScreen(), aScanTypes, aWhere, m_unit, m_convert );
815
817 {
818 int originalCount = aCollector.GetCount();
819
820 for( int ii = 0; ii < originalCount; ++ii )
821 {
822 if( aCollector[ii]->Type() == SCH_PIN_T )
823 {
824 SCH_PIN* pin = static_cast<SCH_PIN*>( aCollector[ii] );
825
826 if( !aCollector.HasItem( pin->GetParentSymbol() ) )
827 aCollector.Append( pin->GetParentSymbol() );
828 }
829 }
830 }
831 }
832
833 return aCollector.GetCount() > 0;
834}
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
bool HasItem(const EDA_ITEM *aItem) const
Tests if aItem has already been collected.
Definition: collector.h:195
int m_Threshold
Definition: collector.h:234
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:99
bool m_ShowPinElectricalTypes
void Collect(SCH_SCREEN *aScreen, const std::vector< KICAD_T > &aScanTypes, const VECTOR2I &aPos, int aUnit=0, int aConvert=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
Define a library symbol object.
Definition: lib_symbol.h:98
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:519
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
The symbol library editor main window.
#define HITTEST_THRESHOLD_PIXELS
double EuclideanNorm(const VECTOR2I &vector)
Definition: trigo.h:129
@ SCH_PIN_T
Definition: typeinfo.h:158
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:80

References COLLECTOR::Append(), EE_COLLECTOR::Collect(), SCH_BASE_FRAME::eeconfig(), EuclideanNorm(), COLLECTOR::GetCount(), LIB_SYMBOL::GetDrawItems(), SCH_BASE_FRAME::GetRenderSettings(), SCH_BASE_FRAME::GetScreen(), TOOL_BASE::getView(), COLLECTOR::HasItem(), HITTEST_THRESHOLD_PIXELS, KiROUND(), m_convert, m_frame, m_isSymbolEditor, EESCHEMA_SETTINGS::m_Selection, EE_COLLECTOR::m_ShowPinElectricalTypes, KIGFX::SCH_RENDER_SETTINGS::m_ShowPinsElectricalType, COLLECTOR::m_Threshold, m_unit, pin, SCH_PIN_T, and EESCHEMA_SETTINGS::SELECTION::select_pin_selects_symbol.

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

◆ ctrlClickHighlights()

virtual bool SELECTION_TOOL::ctrlClickHighlights ( )
inlineprotectedvirtualinherited

Determines if ctrl-click is highlight net or XOR selection.

Reimplemented in PCB_SELECTION_TOOL.

Definition at line 122 of file selection_tool.h.

122{ return false; }

Referenced by SELECTION_TOOL::setModifiersState().

◆ disambiguateCursor()

int EE_SELECTION_TOOL::disambiguateCursor ( const TOOL_EVENT aEvent)
private

Handle disambiguation actions including displaying the menu.

Definition at line 752 of file ee_selection_tool.cpp.

753{
754 wxMouseState keyboardState = wxGetMouseState();
755
756 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(),
757 keyboardState.AltDown() );
758
759 m_skip_heuristics = true;
762 m_skip_heuristics = false;
763
764 return 0;
765}
bool SelectPoint(const VECTOR2I &aWhere, const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T }, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aCheckLocked=false, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
Perform a click-type selection at a point (usually the cursor position).
void setModifiersState(bool aShiftState, bool aCtrlState, bool aAltState)
Set the configuration of m_additive, m_subtractive, m_exclusive_or, m_skip_heuristics from the state ...
VECTOR2I m_originalCursor
@ SCH_LOCATE_ANY_T
Definition: typeinfo.h:182

References SELECTION_TOOL::m_additive, SELECTION_TOOL::m_canceledMenu, SELECTION_TOOL::m_exclusive_or, SELECTION_TOOL::m_originalCursor, SELECTION_TOOL::m_skip_heuristics, SELECTION_TOOL::m_subtractive, SCH_LOCATE_ANY_T, SelectPoint(), and SELECTION_TOOL::setModifiersState().

Referenced by setTransitions().

◆ doSelectionMenu()

bool SELECTION_TOOL::doSelectionMenu ( COLLECTOR aCollector)
protectedinherited

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

Definition at line 235 of file selection_tool.cpp.

236{
237 UNITS_PROVIDER* unitsProvider = getEditFrame<EDA_DRAW_FRAME>();
238 EDA_ITEM* current = nullptr;
239 SELECTION highlightGroup;
240 bool selectAll = false;
241 bool expandSelection = false;
242
243 highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
244 getView()->Add( &highlightGroup );
245
246 do
247 {
249 if( expandSelection )
250 aCollector->Combine();
251
252 expandSelection = false;
253
254 int limit = std::min( 100, aCollector->GetCount() );
255 ACTION_MENU menu( true );
256
257 for( int i = 0; i < limit; ++i )
258 {
259 EDA_ITEM* item = ( *aCollector )[i];
260 wxString menuText;
261
262 if( i < 9 )
263 {
264#ifdef __WXMAC__
265 menuText = wxString::Format( "%s\t%d",
266 item->GetSelectMenuText( unitsProvider ),
267 i + 1 );
268#else
269 menuText = wxString::Format( "&%d %s\t%d",
270 i + 1,
271 item->GetSelectMenuText( unitsProvider ),
272 i + 1 );
273#endif
274 }
275 else
276 {
277 menuText = item->GetSelectMenuText( unitsProvider );
278 }
279
280 menu.Add( menuText, i + 1, item->GetMenuImage() );
281 }
282
283 menu.AppendSeparator();
284 menu.Add( _( "Select &All\tA" ), limit + 1, BITMAPS::INVALID_BITMAP );
285
286 if( !expandSelection && aCollector->HasAdditionalItems() )
287 menu.Add( _( "&Expand Selection\tE" ), limit + 2, BITMAPS::INVALID_BITMAP );
288
289 if( aCollector->m_MenuTitle.Length() )
290 {
291 menu.SetTitle( aCollector->m_MenuTitle );
292 menu.SetIcon( BITMAPS::info );
293 menu.DisplayTitle( true );
294 }
295 else
296 {
297 menu.DisplayTitle( false );
298 }
299
300 SetContextMenu( &menu, CMENU_NOW );
301
302 while( TOOL_EVENT* evt = Wait() )
303 {
304 if( evt->Action() == TA_CHOICE_MENU_UPDATE )
305 {
306 if( selectAll )
307 {
308 for( int i = 0; i < aCollector->GetCount(); ++i )
309 unhighlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
310 }
311 else if( current )
312 {
313 unhighlight( current, BRIGHTENED, &highlightGroup );
314 }
315
316 int id = *evt->GetCommandId();
317
318 // User has pointed an item, so show it in a different way
319 if( id > 0 && id <= limit )
320 {
321 current = ( *aCollector )[id - 1];
322 highlight( current, BRIGHTENED, &highlightGroup );
323 }
324 else
325 {
326 current = nullptr;
327 }
328
329 // User has pointed on the "Select All" option
330 if( id == limit + 1 )
331 {
332 for( int i = 0; i < aCollector->GetCount(); ++i )
333 highlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
334
335 selectAll = true;
336 }
337 else
338 {
339 selectAll = false;
340 }
341 }
342 else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
343 {
344 if( selectAll )
345 {
346 for( int i = 0; i < aCollector->GetCount(); ++i )
347 unhighlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
348 }
349 else if( current )
350 {
351 unhighlight( current, BRIGHTENED, &highlightGroup );
352 }
353
354 std::optional<int> id = evt->GetCommandId();
355
356 // User has selected the "Select All" option
357 if( id == limit + 1 )
358 {
359 selectAll = true;
360 current = nullptr;
361 }
362 // User has selected the "Expand Selection" option
363 else if( id == limit + 2 )
364 {
365 selectAll = false;
366 current = nullptr;
367 expandSelection = true;
368 }
369 // User has selected an item, so this one will be returned
370 else if( id && ( *id > 0 ) && ( *id <= limit ) )
371 {
372 selectAll = false;
373 current = ( *aCollector )[*id - 1];
374 }
375 // User has cancelled the menu (either by <esc> or clicking out of it)
376 else
377 {
378 selectAll = false;
379 current = nullptr;
380 }
381 }
382 else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
383 {
384 break;
385 }
386 }
387 } while( expandSelection );
388
389 getView()->Remove( &highlightGroup );
390
391 if( selectAll )
392 {
393 return true;
394 }
395 else if( current )
396 {
397 aCollector->Empty();
398 aCollector->Append( current );
399 return true;
400 }
401
402 return false;
403}
@ INVALID_BITMAP
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
void Empty()
Clear the list.
Definition: collector.h:89
wxString m_MenuTitle
Definition: collector.h:236
bool HasAdditionalItems()
Test if the collector has heuristic backup items.
Definition: collector.h:132
void Combine()
Re-combine the backup list into the main list of the collector.
Definition: collector.h:140
virtual BITMAPS GetMenuImage() const
Return a pointer to an image to be used in menus.
Definition: eda_item.cpp:269
virtual wxString GetSelectMenuText(UNITS_PROVIDER *aUnitsProvider) const
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: eda_item.cpp:108
virtual void SetLayer(int aLayer)
Set layer used to draw the group.
Definition: view_group.h:98
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Definition: view.cpp:316
virtual void unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr)=0
Unhighlight the item visually.
Generic, UI-independent tool event.
Definition: tool_event.h:156
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Assign a context menu and tells when it should be activated.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Suspend execution of the tool until an event specified in aEventList arrives.
#define _(s)
@ LAYER_SELECT_OVERLAY
currently selected items overlay
Definition: layer_ids.h:219
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
@ CMENU_NOW
Definition: tool_event.h:148
@ TA_CHOICE_MENU_CHOICE
Definition: tool_event.h:93
@ TA_CHOICE_MENU_UPDATE
Definition: tool_event.h:89
@ TA_CHOICE_MENU_CLOSED
Definition: tool_event.h:96

References _, ACTION_MENU::Add(), KIGFX::VIEW::Add(), COLLECTOR::Append(), BRIGHTENED, CMENU_NOW, COLLECTOR::Combine(), ACTION_MENU::DisplayTitle(), COLLECTOR::Empty(), Format(), COLLECTOR::GetCount(), EDA_ITEM::GetMenuImage(), EDA_ITEM::GetSelectMenuText(), TOOL_BASE::getView(), COLLECTOR::HasAdditionalItems(), SELECTION_TOOL::highlight(), info, INVALID_BITMAP, LAYER_SELECT_OVERLAY, COLLECTOR::m_MenuTitle, KIGFX::VIEW::Remove(), TOOL_INTERACTIVE::SetContextMenu(), ACTION_MENU::SetIcon(), KIGFX::VIEW_GROUP::SetLayer(), ACTION_MENU::SetTitle(), TA_CHOICE_MENU_CHOICE, TA_CHOICE_MENU_CLOSED, TA_CHOICE_MENU_UPDATE, SELECTION_TOOL::unhighlight(), and TOOL_INTERACTIVE::Wait().

Referenced by SELECTION_TOOL::SelectionMenu(), GERBVIEW_SELECTION_TOOL::selectPoint(), PL_SELECTION_TOOL::SelectPoint(), PCB_SELECTION_TOOL::selectPoint(), and selectPoint().

◆ getEditFrame()

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

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

Definition at line 184 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), and ZONE_CREATE_HELPER::setUniquePriority().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 120 of file tool_base.h.

121 {
122 return m_toolId;
123 }

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

◆ getModel()

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

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ getModelInt()

EDA_ITEM * TOOL_BASE::getModelInt ( ) const
privateinherited

Definition at line 54 of file tool_base.cpp.

55{
56 return m_toolMgr->GetModel();
57}
EDA_ITEM * GetModel() const
Definition: tool_manager.h:292

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

Referenced by TOOL_BASE::getModel().

◆ GetName()

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

Return the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

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

References TOOL_BASE::m_toolName.

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

◆ GetNode()

EDA_ITEM * EE_SELECTION_TOOL::GetNode ( VECTOR2I  aPosition)

Finds a connected item at a point (usually the cursor position).

Iterative process with a decreasing slop factor.

Parameters
aPositionCursor position from which the search should be made.
Returns
a connected item or nullptr.

Definition at line 1451 of file ee_selection_tool.cpp.

1452{
1453 EE_COLLECTOR collector;
1454
1455 //TODO(snh): Reimplement after exposing KNN interface
1456 int pixelThreshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
1457 int gridThreshold = KiROUND( getView()->GetGAL()->GetGridSize().EuclideanNorm() );
1458 int thresholdMax = std::max( pixelThreshold, gridThreshold );
1459
1460 for( int threshold : { 0, thresholdMax/4, thresholdMax/2, thresholdMax } )
1461 {
1462 collector.m_Threshold = threshold;
1463 collector.Collect( m_frame->GetScreen(), connectedTypes, aPosition );
1464
1465 if( collector.GetCount() > 0 )
1466 break;
1467 }
1468
1469 return collector.GetCount() ? collector[ 0 ] : nullptr;
1470}
static std::vector< KICAD_T > connectedTypes

References EE_COLLECTOR::Collect(), connectedTypes, EuclideanNorm(), COLLECTOR::GetCount(), SCH_BASE_FRAME::GetScreen(), TOOL_BASE::getView(), HITTEST_THRESHOLD_PIXELS, KiROUND(), m_frame, and COLLECTOR::m_Threshold.

Referenced by highlightNet().

◆ GetSelection()

◆ getToolHolderInt()

TOOLS_HOLDER * TOOL_BASE::getToolHolderInt ( ) const
privateinherited

Definition at line 48 of file tool_base.cpp.

49{
50 return m_toolMgr->GetToolHolder();
51}
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296

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

Referenced by TOOL_BASE::getEditFrame().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

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

References TOOL_BASE::m_type.

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

◆ getView()

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

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

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), SCH_EDITOR_CONTROL::AssignNetclass(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), ClearSelection(), CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), SCH_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), GuessSelectionCandidates(), ROUTER_TOOL::handleCommonEvents(), highlight(), PL_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), SCH_MOVE_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), Reset(), EE_TOOL_BASE< T >::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), PNS::TOOL_BASE::Reset(), BOARD_EDITOR_CONTROL::Reset(), DRAWING_TOOL::Reset(), PCB_CONTROL::Reset(), PCB_SELECTION_TOOL::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::Selectable(), SelectAll(), PCB_SELECTION_TOOL::SelectAll(), selectionContains(), PL_SELECTION_TOOL::selectionContains(), selectMultiple(), PL_SELECTION_TOOL::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::ToggleERCErrors(), SCH_EDITOR_CONTROL::ToggleERCExclusions(), SCH_EDITOR_CONTROL::ToggleERCWarnings(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), unhighlight(), PL_SELECTION_TOOL::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< T >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_SELECTION_TOOL::view(), PCB_TOOL_BASE::view(), PCB_VIEWER_TOOLS::view(), ZoomFitCrossProbeBBox(), PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox(), 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}
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:287

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(), autostartEvent(), SCH_EDIT_TOOL::BreakWire(), PCB_SELECTION_TOOL::controls(), 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(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), EE_POINT_EDITOR::Main(), Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), RequestSelection(), DRAWING_TOOL::Reset(), PCB_POINT_EDITOR::Reset(), COMMON_TOOLS::ResetLocalCoords(), ROUTER_TOOL::RouteSelected(), PCB_SELECTION_TOOL::selectCursor(), selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCB_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

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

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

149{
150 TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
151
152 goInternal( sptr, aConditions );
153}
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58

References TOOL_INTERACTIVE::goInternal().

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

◆ goInternal()

void TOOL_INTERACTIVE::goInternal ( TOOL_STATE_FUNC aState,
const TOOL_EVENT_LIST aConditions 
)
privateinherited

Definition at line 70 of file tool_interactive.cpp.

71{
72 m_toolMgr->ScheduleNextState( this, aState, aConditions );
73}
void ScheduleNextState(TOOL_BASE *aTool, TOOL_STATE_FUNC &aHandler, const TOOL_EVENT_LIST &aConditions)
Define a state transition.

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

Referenced by TOOL_INTERACTIVE::Go().

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

1032{
1033 // Prefer exact hits to sloppy ones
1034 std::set<EDA_ITEM*> exactHits;
1035
1036 for( int i = collector.GetCount() - 1; i >= 0; --i )
1037 {
1038 EDA_ITEM* item = collector[ i ];
1039 SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
1040 LIB_SHAPE* shape = dynamic_cast<LIB_SHAPE*>( item );
1041 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
1042
1043 // Lines are hard to hit. Give them a bit more slop to still be considered "exact".
1044
1045 if( line || ( shape && shape->GetShape() == SHAPE_T::POLY ) )
1046 {
1047 int pixelThreshold = KiROUND( getView()->ToWorld( 1 ) );
1048
1049 if( item->HitTest( aPos, pixelThreshold ) )
1050 exactHits.insert( item );
1051 }
1052 else if( symbol && m_frame->eeconfig()->m_Selection.select_pin_selects_symbol )
1053 {
1054 if( symbol->GetBodyAndPinsBoundingBox().Contains( aPos ) )
1055 exactHits.insert( item );
1056 }
1057 else
1058 {
1059 if( item->HitTest( aPos, 0 ) )
1060 exactHits.insert( item );
1061 }
1062 }
1063
1064 if( exactHits.size() > 0 && exactHits.size() < (unsigned) collector.GetCount() )
1065 {
1066 for( int i = collector.GetCount() - 1; i >= 0; --i )
1067 {
1068 EDA_ITEM* item = collector[ i ];
1069
1070 if( !exactHits.count( item ) )
1071 collector.Transfer( item );
1072 }
1073 }
1074
1075 // Find the closest item. (Note that at this point all hits are either exact or non-exact.)
1076 VECTOR2I pos( aPos );
1077 SEG poss( m_isSymbolEditor ? mapCoords( pos ) : pos,
1078 m_isSymbolEditor ? mapCoords( pos ) : pos );
1079 EDA_ITEM* closest = nullptr;
1080 int closestDist = INT_MAX / 2;
1081
1082 for( EDA_ITEM* item : collector )
1083 {
1084 BOX2I bbox = item->GetBoundingBox();
1085 int dist = INT_MAX / 2;
1086
1087 if( exactHits.count( item ) )
1088 {
1089 if( item->Type() == SCH_PIN_T || item->Type() == SCH_JUNCTION_T )
1090 {
1091 closest = item;
1092 break;
1093 }
1094
1095 SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
1096 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( item );
1097 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
1098
1099 if( line )
1100 {
1101 dist = DistanceLinePoint( line->GetStartPoint(), line->GetEndPoint(), pos );
1102 }
1103 else if( text )
1104 {
1105 text->GetEffectiveTextShape()->Collide( poss, closestDist, &dist );
1106 }
1107 else if( symbol )
1108 {
1109 try
1110 {
1111 bbox = symbol->GetBodyBoundingBox();
1112 }
1113 catch( const boost::bad_pointer& exc )
1114 {
1115 // This may be overkill and could be an assertion but we are more likely to
1116 // find any boost pointer container errors this way.
1117 wxLogError( wxT( "Boost bad pointer exception '%s' occurred." ), exc.what() );
1118 }
1119
1120 SHAPE_RECT rect( bbox.GetPosition(), bbox.GetWidth(), bbox.GetHeight() );
1121
1122 if( bbox.Contains( pos ) )
1123 dist = EuclideanNorm( bbox.GetCenter() - pos );
1124 else
1125 rect.Collide( poss, closestDist, &dist );
1126 }
1127 else
1128 {
1129 dist = EuclideanNorm( bbox.GetCenter() - pos );
1130 }
1131 }
1132 else
1133 {
1134 SHAPE_RECT rect( bbox.GetPosition(), bbox.GetWidth(), bbox.GetHeight() );
1135 rect.Collide( poss, collector.m_Threshold, &dist );
1136 }
1137
1138 if( dist == closestDist )
1139 {
1140 if( item->GetParent() == closest )
1141 closest = item;
1142 }
1143 else if( dist < closestDist )
1144 {
1145 closestDist = dist;
1146 closest = item;
1147 }
1148 }
1149
1150 // Construct a tight box (1/2 height and width) around the center of the closest item.
1151 // All items which exist at least partly outside this box have sufficient other areas
1152 // for selection and can be dropped.
1153 if( closest ) // Don't try and get a tight bbox if nothing is near the mouse pointer
1154 {
1155 BOX2I tightBox = closest->GetBoundingBox();
1156 tightBox.Inflate( -tightBox.GetWidth() / 4, -tightBox.GetHeight() / 4 );
1157
1158 for( int i = collector.GetCount() - 1; i >= 0; --i )
1159 {
1160 EDA_ITEM* item = collector[i];
1161
1162 if( item == closest )
1163 continue;
1164
1165 if( !item->HitTest( tightBox, true ) )
1166 collector.Transfer( item );
1167 }
1168 }
1169}
VECTOR2D mapCoords(const VECTOR2D &aSource)
Definition: PS_plotter.cpp:568
const Vec & GetPosition() const
Definition: box2.h:184
const Vec GetCenter() const
Definition: box2.h:195
coord_type GetHeight() const
Definition: box2.h:188
coord_type GetWidth() const
Definition: box2.h:187
bool Contains(const Vec &aPoint) const
Definition: box2.h:141
BOX2< Vec > & Inflate(coord_type dx, coord_type dy)
Inflates the rectangle horizontally by dx and vertically by dy.
Definition: box2.h:506
void Transfer(int aIndex)
Move the item at aIndex (first position is 0) to the backup list.
Definition: collector.h:151
virtual const BOX2I GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
Definition: eda_item.cpp:74
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Test if aPosition is inside or on the boundary of this item.
Definition: eda_item.h:222
EDA_ITEM * GetParent() const
Definition: eda_item.h:99
SHAPE_T GetShape() const
Definition: eda_shape.h:111
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
VECTOR2I GetEndPoint() const
Definition: sch_line.h:137
VECTOR2I GetStartPoint() const
Definition: sch_line.h:132
Schematic symbol object.
Definition: sch_symbol.h:80
BOX2I GetBodyAndPinsBoundingBox() const
Return a bounding box for the symbol body and pins but not the fields.
BOX2I GetBodyBoundingBox() const
Return a bounding box for the symbol body but not the pins or fields.
Definition: seg.h:42
double DistanceLinePoint(const VECTOR2I &linePointA, const VECTOR2I &linePointB, const VECTOR2I &referencePoint)
Compute the distance between a line and a reference point Reference: http://mathworld....
Definition: trigo.h:140
@ SCH_JUNCTION_T
Definition: typeinfo.h:141

References SHAPE_RECT::Collide(), BOX2< Vec >::Contains(), DistanceLinePoint(), SCH_BASE_FRAME::eeconfig(), EuclideanNorm(), SCH_SYMBOL::GetBodyAndPinsBoundingBox(), SCH_SYMBOL::GetBodyBoundingBox(), EDA_ITEM::GetBoundingBox(), BOX2< Vec >::GetCenter(), COLLECTOR::GetCount(), SCH_LINE::GetEndPoint(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetPosition(), EDA_SHAPE::GetShape(), SCH_LINE::GetStartPoint(), TOOL_BASE::getView(), BOX2< Vec >::GetWidth(), EDA_ITEM::HitTest(), BOX2< Vec >::Inflate(), KiROUND(), m_frame, m_isSymbolEditor, EESCHEMA_SETTINGS::m_Selection, COLLECTOR::m_Threshold, mapCoords(), POLY, SCH_JUNCTION_T, SCH_PIN_T, EESCHEMA_SETTINGS::SELECTION::select_pin_selects_symbol, text, and COLLECTOR::Transfer().

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

◆ highlight()

void EE_SELECTION_TOOL::highlight ( EDA_ITEM aItem,
int  aHighlightMode,
SELECTION aGroup = nullptr 
)
overrideprivatevirtual

Highlight the item visually.

Parameters
aItemThe item to be highlighted.
aHighlightModeEither SELECTED or BRIGHTENED
aGroup[otpional] A group to add the item to.

Implements SELECTION_TOOL.

Definition at line 1827 of file ee_selection_tool.cpp.

1828{
1829 KICAD_T itemType = aItem->Type();
1830
1831 if( aMode == SELECTED )
1832 aItem->SetSelected();
1833 else if( aMode == BRIGHTENED )
1834 aItem->SetBrightened();
1835
1836 if( aGroup )
1837 aGroup->Add( aItem );
1838
1839 // Highlight pins and fields. (All the other symbol children are currently only
1840 // represented in the LIB_SYMBOL and will inherit the settings of the parent symbol.)
1841 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
1842 {
1843 sch_item->RunOnChildren(
1844 [&]( SCH_ITEM* aChild )
1845 {
1846 if( aMode == SELECTED )
1847 aChild->SetSelected();
1848 else if( aMode == BRIGHTENED )
1849 aChild->SetBrightened();
1850 } );
1851 }
1852
1853 if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
1854 getView()->Update( aItem->GetParent() );
1855 else
1856 getView()->Update( aItem );
1857}
void SetSelected()
Definition: eda_item.h:118
void SetBrightened()
Definition: eda_item.h:119
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
virtual void Add(EDA_ITEM *aItem)
Definition: selection.cpp:32
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_FIELD_T
Definition: typeinfo.h:154
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:156

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

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

165{
166 m_frame = getEditFrame<SCH_BASE_FRAME>();
167
168 SYMBOL_VIEWER_FRAME* symbolViewerFrame = dynamic_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
169 SYMBOL_EDIT_FRAME* symbolEditorFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
170
171 if( symbolEditorFrame )
172 {
173 m_isSymbolEditor = true;
174 m_unit = symbolEditorFrame->GetUnit();
175 m_convert = symbolEditorFrame->GetConvert();
176 }
177 else
178 {
179 m_isSymbolViewer = symbolViewerFrame != nullptr;
180 }
181
182 auto wireSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_WIRE_T } );
183 auto busSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_BUS_T });
184 auto wireOrBusSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } );
185 auto connectedSelection = E_C::Count( 1 ) && E_C::OnlyTypes( connectedTypes );
186 auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } );
187 auto crossProbingSelection = E_C::MoreThan( 0 ) && E_C::HasTypes( { SCH_SYMBOL_T, SCH_PIN_T, SCH_SHEET_T } );
188
189 auto schEditSheetPageNumberCondition =
190 [&] ( const SELECTION& aSel )
191 {
193 return false;
194
195 return E_C::LessThan( 2 )( aSel ) && E_C::OnlyTypes( { SCH_SHEET_T } )( aSel );
196 };
197
198 auto schEditCondition =
199 [this] ( const SELECTION& aSel )
200 {
202 };
203
204 auto belowRootSheetCondition =
205 [&]( const SELECTION& aSel )
206 {
207 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
208
209 return editFrame
210 && editFrame->GetCurrentSheet().Last() != &editFrame->Schematic().Root();
211 };
212
213 auto haveHighlight =
214 [&]( const SELECTION& sel )
215 {
216 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
217
218 return editFrame && editFrame->GetHighlightedConnection() != nullptr;
219 };
220
221 auto haveSymbol =
222 [&]( const SELECTION& sel )
223 {
224 return m_isSymbolEditor &&
225 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
226 };
227
228 auto symbolDisplayNameIsEditable =
229 [&]( const SELECTION& sel )
230 {
231 if ( !m_isSymbolEditor )
232 return false;
233
234 SYMBOL_EDIT_FRAME* symbEditorFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
235
236 return symbEditorFrame
237 && symbEditorFrame->GetCurSymbol()
238 && symbEditorFrame->GetCurSymbol()->IsMulti()
239 && symbEditorFrame->IsSymbolEditable()
240 && !symbEditorFrame->IsSymbolAlias();
241 };
242
243 auto& menu = m_menu.GetMenu();
244
245 menu.AddItem( EE_ACTIONS::clearHighlight, haveHighlight && EE_CONDITIONS::Idle, 1 );
246 menu.AddSeparator( haveHighlight && EE_CONDITIONS::Idle, 1 );
247
248 menu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 2 );
249 menu.AddItem( EE_ACTIONS::selectOnPCB, crossProbingSelection && EE_CONDITIONS::Idle, 2 );
250 menu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
251
252 menu.AddSeparator( 100 );
253 menu.AddItem( EE_ACTIONS::drawWire, schEditCondition && EE_CONDITIONS::Empty, 100 );
254 menu.AddItem( EE_ACTIONS::drawBus, schEditCondition && EE_CONDITIONS::Empty, 100 );
255
256 menu.AddSeparator( 100 );
258
259 menu.AddSeparator( 100 );
261
262 menu.AddSeparator( 200 );
263 menu.AddItem( EE_ACTIONS::selectConnection, connectedSelection && EE_CONDITIONS::Idle, 250 );
264 menu.AddItem( EE_ACTIONS::placeJunction, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
265 menu.AddItem( EE_ACTIONS::placeLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
266 menu.AddItem( EE_ACTIONS::placeClassLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
267 menu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
268 menu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
269 menu.AddItem( EE_ACTIONS::breakWire, wireSelection && EE_CONDITIONS::Idle, 250 );
270 menu.AddItem( EE_ACTIONS::breakBus, busSelection && EE_CONDITIONS::Idle, 250 );
271 menu.AddItem( EE_ACTIONS::importSingleSheetPin, sheetSelection && EE_CONDITIONS::Idle, 250 );
272 menu.AddItem( EE_ACTIONS::assignNetclass, connectedSelection && EE_CONDITIONS::Idle, 250 );
273 menu.AddItem( EE_ACTIONS::editPageNumber, schEditSheetPageNumberCondition, 250 );
274
275 menu.AddSeparator( 400 );
276 menu.AddItem( EE_ACTIONS::symbolProperties, haveSymbol && EE_CONDITIONS::Empty, 400 );
277 menu.AddItem( EE_ACTIONS::pinTable, haveSymbol && EE_CONDITIONS::Empty, 400 );
278 menu.AddItem( EE_ACTIONS::setUnitDisplayName,
279 haveSymbol && symbolDisplayNameIsEditable && EE_CONDITIONS::Empty, 400 );
280
281 menu.AddSeparator( 1000 );
283
284 m_disambiguateTimer.SetOwner( this );
285 Connect( wxEVT_TIMER, wxTimerEventHandler( EE_SELECTION_TOOL::onDisambiguationExpire ), nullptr, this );
286
287 return true;
288}
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.
void AddStandardSubMenus(TOOL_MENU &aMenu)
Construct a "basic" menu for a tool, containing only items that apply to all tools (e....
static TOOL_ACTION clearHighlight
Definition: ee_actions.h:253
static TOOL_ACTION selectConnection
If current selection is a wire or bus, expand to entire connection.
Definition: ee_actions.h:53
static TOOL_ACTION pinTable
Definition: ee_actions.h:158
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:164
static TOOL_ACTION placeClassLabel
Definition: ee_actions.h:90
static TOOL_ACTION finishWire
Definition: ee_actions.h:106
static TOOL_ACTION breakWire
Definition: ee_actions.h:146
static TOOL_ACTION selectOnPCB
Definition: ee_actions.h:223
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:202
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:91
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:92
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:157
static TOOL_ACTION editPageNumber
Definition: ee_actions.h:166
static TOOL_ACTION enterSheet
Definition: ee_actions.h:201
static TOOL_ACTION setUnitDisplayName
Definition: ee_actions.h:197
static TOOL_ACTION importSingleSheetPin
Definition: ee_actions.h:94
static TOOL_ACTION placeLabel
Definition: ee_actions.h:89
static TOOL_ACTION placeJunction
Definition: ee_actions.h:87
static TOOL_ACTION breakBus
Definition: ee_actions.h:147
static TOOL_ACTION finishBus
Definition: ee_actions.h:107
bool IsMulti() const
Definition: lib_symbol.h:568
SCH_SHEET & Root() const
Definition: schematic.h:90
Schematic editor (Eeschema) main window.
const SCH_CONNECTION * GetHighlightedConnection() const
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
static bool IsDrawingWire(const SELECTION &aSelection)
static bool IsDrawingBus(const SELECTION &aSelection)
SCH_SHEET * Last() const
Return a pointer to the last SCH_SHEET of the list.
static SELECTION_CONDITION HasTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if among the selected items there is at least one of a given types.
static bool Empty(const SELECTION &aSelection)
Test if there are no items selected.
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 LessThan(int aNumber)
Create a functor that tests if the number of selected items is smaller than the value given as parame...
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.
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
wxTimer m_disambiguateTimer
void onDisambiguationExpire(wxTimerEvent &aEvent)
Start the process to show our disambiguation menu once the user has kept the mouse down for the minim...
bool IsSymbolAlias() const
Return true if aLibId is an alias for the editor screen symbol.
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
Symbol library viewer main window.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
@ SCH_SYMBOL_T
Definition: typeinfo.h:155
@ SCH_ITEM_LOCATE_WIRE_T
Definition: typeinfo.h:169
@ SCH_SHEET_T
Definition: typeinfo.h:157
@ SCH_ITEM_LOCATE_BUS_T
Definition: typeinfo.h:170

References CONDITIONAL_MENU::AddItem(), EDA_DRAW_FRAME::AddStandardSubMenus(), EE_ACTIONS::assignNetclass, EE_ACTIONS::breakBus, EE_ACTIONS::breakWire, EE_ACTIONS::clearHighlight, connectedTypes, SELECTION_CONDITIONS::Count(), EE_ACTIONS::drawBus, EE_ACTIONS::drawWire, EE_ACTIONS::editPageNumber, SELECTION_CONDITIONS::Empty(), EE_ACTIONS::enterSheet, EE_ACTIONS::finishBus, EE_ACTIONS::finishWire, SYMBOL_EDIT_FRAME::GetConvert(), SCH_EDIT_FRAME::GetCurrentSheet(), SYMBOL_EDIT_FRAME::GetCurSymbol(), SCH_EDIT_FRAME::GetHighlightedConnection(), TOOL_MENU::GetMenu(), SYMBOL_EDIT_FRAME::GetUnit(), SELECTION_CONDITIONS::HasTypes(), SELECTION_CONDITIONS::Idle(), EE_ACTIONS::importSingleSheetPin, SCH_LINE_WIRE_BUS_TOOL::IsDrawingBus(), SCH_LINE_WIRE_BUS_TOOL::IsDrawingWire(), LIB_SYMBOL::IsMulti(), SYMBOL_EDIT_FRAME::IsSymbolAlias(), SYMBOL_EDIT_FRAME::IsSymbolEditable(), SCH_SHEET_PATH::Last(), EE_ACTIONS::leaveSheet, SELECTION_CONDITIONS::LessThan(), m_convert, SELECTION_TOOL::m_disambiguateTimer, m_frame, m_isSymbolEditor, m_isSymbolViewer, TOOL_INTERACTIVE::m_menu, m_unit, SELECTION_CONDITIONS::MoreThan(), SELECTION_TOOL::onDisambiguationExpire(), SELECTION_CONDITIONS::OnlyTypes(), EE_ACTIONS::pinTable, EE_ACTIONS::placeClassLabel, EE_ACTIONS::placeGlobalLabel, EE_ACTIONS::placeHierLabel, EE_ACTIONS::placeJunction, EE_ACTIONS::placeLabel, SCHEMATIC::Root(), SCH_ITEM_LOCATE_BUS_T, SCH_ITEM_LOCATE_WIRE_T, SCH_PIN_T, SCH_SHEET_T, SCH_SYMBOL_T, SCH_EDIT_FRAME::Schematic(), EE_ACTIONS::selectConnection, EE_ACTIONS::selectOnPCB, EE_ACTIONS::setUnitDisplayName, and EE_ACTIONS::symbolProperties.

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32{
34}
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 EDIT_TOOL::Drag(), ROUTER_TOOL::handleLayerSwitch(), 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 328 of file ee_selection_tool.cpp.

329{
331
332 KIID lastRolloverItem = niluuid;
333
334 // Main loop: keep receiving events
335 while( TOOL_EVENT* evt = Wait() )
336 {
337 bool selCancelled = false;
338 bool displayWireCursor = false;
339 bool displayBusCursor = false;
340 bool displayLineCursor = false;
341 KIID rolloverItem = lastRolloverItem;
342
343 // on left click, a selection is made, depending on modifiers ALT, SHIFT, CTRL:
344 setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ),
345 evt->Modifier( MD_ALT ) );
346
347 bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or;
348
349 MOUSE_DRAG_ACTION drag_action = m_frame->GetDragAction();
351
352 if( evt->IsMouseDown( BUT_LEFT ) )
353 {
354 // Avoid triggering when running under other tools
357 {
359 m_disambiguateTimer.StartOnce( 500 );
360 }
361 }
362 // Single click? Select single object
363 else if( evt->IsClick( BUT_LEFT ) )
364 {
365 // If the timer has stopped, then we have already run the disambiguate routine
366 // and we don't want to register an extra click here
367 if( !m_disambiguateTimer.IsRunning() )
368 {
369 evt->SetPassEvent();
370 continue;
371 }
372
373 m_disambiguateTimer.Stop();
374
375 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
376 schframe->FocusOnItem( nullptr );
377
378 // Collect items at the clicked location (doesn't select them yet)
379 EE_COLLECTOR collector;
380 CollectHits( collector, evt->Position() );
381 narrowSelection( collector, evt->Position(), false );
382
383 if( collector.GetCount() == 1 && !m_isSymbolEditor && !modifier_enabled )
384 {
385 OPT_TOOL_EVENT autostart = autostartEvent( evt, grid, collector[0] );
386
387 if( autostart )
388 {
390
391 params->layer = autostart->Parameter<DRAW_SEGMENT_EVENT_PARAMS*>()->layer;
392 params->quitOnDraw = true;
393 params->sourceSegment = dynamic_cast<SCH_LINE*>( collector[0] );
394
395 autostart->SetParameter( params );
396 m_toolMgr->ProcessEvent( *autostart );
397
398 selCancelled = true;
399 }
400 else if( collector[0]->IsHypertext() )
401 {
402 collector[ 0 ]->DoHypertextAction( m_frame );
403 selCancelled = true;
404 }
405 }
406
407 if( !selCancelled )
408 {
409 selectPoint( collector, evt->Position(), nullptr, nullptr, m_additive,
411 m_selection.SetIsHover( false );
412 }
413 }
414 else if( evt->IsClick( BUT_RIGHT ) )
415 {
416 m_disambiguateTimer.Stop();
417
418 // right click? if there is any object - show the context menu
419 if( m_selection.Empty() )
420 {
422 SelectPoint( evt->Position(), { SCH_LOCATE_ANY_T }, nullptr, &selCancelled );
423 m_selection.SetIsHover( true );
424 }
425 // If the cursor has moved off the bounding box of the selection by more than
426 // a grid square, check to see if there is another item available for selection
427 // under the cursor. If there is, the user likely meant to get the context menu
428 // for that item. If there is no new item, then keep the original selection and
429 // show the context menu for it.
430 else if( !m_selection.GetBoundingBox().Inflate( grid.GetGrid().x, grid.GetGrid().y )
431 .Contains( evt->Position() ) )
432 {
433 EE_SELECTION saved_selection = m_selection;
434
435 for( EDA_ITEM* item : saved_selection )
436 RemoveItemFromSel( item, true );
437
438 SelectPoint( evt->Position(), { SCH_LOCATE_ANY_T }, nullptr, &selCancelled );
439
440 if( m_selection.Empty() )
441 {
442 m_selection.SetIsHover( false );
443
444 for( EDA_ITEM* item : saved_selection )
445 AddItemToSel( item, true);
446 }
447 else
448 {
449 m_selection.SetIsHover( true );
450 }
451 }
452
453 if( !selCancelled )
455 }
456 else if( evt->IsDblClick( BUT_LEFT ) )
457 {
458 m_disambiguateTimer.Stop();
459
460 // double click? Display the properties window
461 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
462 schframe->FocusOnItem( nullptr );
463
464 if( m_selection.Empty() )
465 SelectPoint( evt->Position() );
466
467 EDA_ITEM* item = m_selection.Front();
468
469 if( item && item->Type() == SCH_SHEET_T )
471 else
473 }
474 else if( evt->IsDblClick( BUT_MIDDLE ) )
475 {
476 m_disambiguateTimer.Stop();
477
478 // Middle double click? Do zoom to fit or zoom to objects
479 if( evt->Modifier( MD_CTRL ) ) // Is CTRL key down?
481 else
483 }
484 else if( evt->IsDrag( BUT_LEFT ) )
485 {
486 m_disambiguateTimer.Stop();
487
488 // Is another tool already moving a new object? Don't allow a drag start
489 if( !m_selection.Empty() && m_selection[0]->HasFlag( IS_NEW | IS_MOVING ) )
490 {
491 evt->SetPassEvent();
492 continue;
493 }
494
495 // drag with LMB? Select multiple objects (or at least draw a selection box) or
496 // drag them
497 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
498 schframe->FocusOnItem( nullptr );
499
500 if( modifier_enabled || drag_action == MOUSE_DRAG_ACTION::SELECT )
501 {
503 }
504 else if( m_selection.Empty() && drag_action != MOUSE_DRAG_ACTION::DRAG_ANY )
505 {
507 }
508 else
509 {
510 if( m_isSymbolEditor )
511 {
512 if( static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->IsSymbolAlias() )
513 {
515 }
516 else
517 {
521 LIB_PIN_T,
522 LIB_FIELD_T } );
523 }
524 }
525 else
526 {
528 }
529
530 // Check if dragging has started within any of selected items bounding box
531 if( selectionContains( evt->Position() ) )
532 {
533 // Yes -> run the move tool and wait till it finishes
534 if( m_isSymbolEditor )
535 m_toolMgr->InvokeTool( "eeschema.SymbolMoveTool" );
536 else
537 m_toolMgr->InvokeTool( "eeschema.InteractiveMove" );
538 }
539 else
540 {
541 // No -> drag a selection box
543 }
544 }
545 }
546 else if( evt->IsMouseDown( BUT_AUX1 ) )
547 {
549 }
550 else if( evt->IsMouseDown( BUT_AUX2 ) )
551 {
553 }
554 else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
555 {
556 m_disambiguateTimer.Stop();
557
558 // context sub-menu selection? Handle unit selection or bus unfolding
559 if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_UNIT_CMP
560 && *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
561 {
562 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_selection.Front() );
563 int unit = *evt->GetCommandId() - ID_POPUP_SCH_SELECT_UNIT_CMP;
564
565 if( symbol )
566 static_cast<SCH_EDIT_FRAME*>( m_frame )->SelectUnit( symbol, unit );
567 }
568 else if( *evt->GetCommandId() >= ID_POPUP_SCH_UNFOLD_BUS
569 && *evt->GetCommandId() <= ID_POPUP_SCH_UNFOLD_BUS_END )
570 {
571 wxString* net = new wxString( *evt->Parameter<wxString*>() );
573 }
574 }
575 else if( evt->IsCancelInteractive() )
576 {
577 m_disambiguateTimer.Stop();
578
579 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
580 schframe->FocusOnItem( nullptr );
581
582 if( !GetSelection().Empty() )
583 {
585 }
586 else if( evt->FirstResponder() == this && evt->GetCommandId() == (int) WXK_ESCAPE )
587 {
589
591 editor->ClearHighlight( *evt );
592 }
593 }
594 else if( evt->Action() == TA_UNDO_REDO_PRE )
595 {
596 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
597 schframe->FocusOnItem( nullptr );
598
600 }
601 else if( evt->IsMotion() && !m_isSymbolEditor && evt->FirstResponder() == this )
602 {
603 // Update cursor and rollover item
604 rolloverItem = niluuid;
605 EE_COLLECTOR collector;
606
608
609 if( CollectHits( collector, evt->Position() ) )
610 {
611 narrowSelection( collector, evt->Position(), false );
612
613 if( collector.GetCount() == 1 && !modifier_enabled )
614 {
615 OPT_TOOL_EVENT autostartEvt = autostartEvent( evt, grid, collector[0] );
616
617 if( autostartEvt )
618 {
619 if( autostartEvt->Matches( EE_ACTIONS::drawBus.MakeEvent() ) )
620 displayBusCursor = true;
621 else if( autostartEvt->Matches( EE_ACTIONS::drawWire.MakeEvent() ) )
622 displayWireCursor = true;
623 else if( autostartEvt->Matches( EE_ACTIONS::drawLines.MakeEvent() ) )
624 displayLineCursor = true;
625 }
626 else if( collector[0]->IsHypertext() && !collector[0]->IsSelected() )
627 {
628 rolloverItem = collector[0]->m_Uuid;
629 }
630 }
631 }
632 }
633 else
634 {
635 evt->SetPassEvent();
636 }
637
638 if( rolloverItem != lastRolloverItem )
639 {
640 if( EDA_ITEM* item = m_frame->GetItem( lastRolloverItem ) )
641 {
642 item->ClearFlags( IS_ROLLOVER );
643 lastRolloverItem = niluuid;
644
645 if( item->Type() == SCH_FIELD_T )
646 m_frame->GetCanvas()->GetView()->Update( item->GetParent() );
647 else
648 m_frame->GetCanvas()->GetView()->Update( item );
649 }
650 }
651
652 if( EDA_ITEM* item = m_frame->GetItem( rolloverItem ) )
653 {
654 if( !( item->GetFlags() & IS_ROLLOVER ) )
655 {
656 item->SetFlags( IS_ROLLOVER );
657 lastRolloverItem = rolloverItem;
658
659 if( item->Type() == SCH_FIELD_T )
660 m_frame->GetCanvas()->GetView()->Update( item->GetParent() );
661 else
662 m_frame->GetCanvas()->GetView()->Update( item );
663 }
664 }
665
667 {
668 if( displayWireCursor )
669 {
671 }
672 else if( displayBusCursor )
673 {
675 }
676 else if( displayLineCursor )
677 {
679 }
680 else if( rolloverItem != niluuid )
681 {
683 }
684 else if( !m_selection.Empty()
685 && drag_action == MOUSE_DRAG_ACTION::DRAG_SELECTED
686 && evt->HasPosition()
687 && selectionContains( evt->Position() ) ) //move/drag option prediction
688 {
690 }
691 else
692 {
694 }
695 }
696 }
697
698 m_disambiguateTimer.Stop();
699
700 // Shutting down; clear the selection
702
703 return 0;
704}
static TOOL_ACTION zoomFitScreen
Definition: actions.h:98
static TOOL_ACTION zoomFitObjects
Definition: actions.h:99
virtual EDA_ITEM * GetItem(const KIID &aId) const
Fetch an item by KIID.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:142
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:143
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:144
static TOOL_ACTION properties
Definition: ee_actions.h:131
static TOOL_ACTION navigateForward
Definition: ee_actions.h:204
static TOOL_ACTION navigateBack
Definition: ee_actions.h:205
static TOOL_ACTION unfoldBus
Definition: ee_actions.h:85
static const std::vector< KICAD_T > MovableItems
Definition: ee_collectors.h:43
bool selectMultiple()
Handle drawing a selection box that allows one to select many items at the same time.
bool selectionContains(const VECTOR2I &aPoint) const
Set up handlers for various events.
bool CollectHits(EE_COLLECTOR &aCollector, const VECTOR2I &aWhere, const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T })
Collect one or more items at a given point.
bool selectPoint(EE_COLLECTOR &aCollector, const VECTOR2I &aWhere, EDA_ITEM **aItem=nullptr, bool *aSelectionCancelledFlag=nullptr, bool aAdd=false, bool aSubtract=false, bool aExclusiveOr=false)
Perform a click-type selection at a point (usually the cursor position).
EE_SELECTION & RequestSelection(const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T })
Return either an existing selection (filtered), or the selection at the current cursor position if th...
OPT_TOOL_EVENT autostartEvent(TOOL_EVENT *aEvent, EE_GRID_HELPER &aGrid, SCH_ITEM *aItem)
void narrowSelection(EE_COLLECTOR &collector, const VECTOR2I &aWhere, bool aCheckLocked, bool aSelectedOnly=false)
Apply rules to narrow the collection down to selectable objects, and then heuristics to try and narro...
EE_SELECTION & GetSelection()
BOX2I GetBoundingBox() const override
Definition: kiid.h:47
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
Handle actions specific to the schematic editor.
int RemoveItemFromSel(const TOOL_EVENT &aEvent)
MOUSE_DRAG_ACTION GetDragAction() const
Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects.
Definition: tools_holder.h:147
bool ToolStackIsEmpty()
Definition: tools_holder.h:128
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
VECTOR2D GetMousePosition() const
void ShowContextMenu(SELECTION &aSelection)
Helper function to set and immediately show a CONDITIONAL_MENU in concert with the given SELECTION.
Definition: tool_menu.cpp:57
MOUSE_DRAG_ACTION
#define IS_NEW
New item, just created.
#define IS_ROLLOVER
Rollover active. Used for hyperlink highlighting.
#define IS_MOVING
Item being moved.
@ ID_POPUP_SCH_UNFOLD_BUS_END
Definition: eeschema_id.h:91
@ ID_POPUP_SCH_SELECT_UNIT_CMP
Definition: eeschema_id.h:94
@ ID_POPUP_SCH_UNFOLD_BUS
Definition: eeschema_id.h:90
@ ID_POPUP_SCH_SELECT_UNIT_SYM_MAX
Definition: eeschema_id.h:98
KIID niluuid(0)
@ TA_UNDO_REDO_PRE
Definition: tool_event.h:101
@ TC_COMMAND
Definition: tool_event.h:52
@ MD_ALT
Definition: tool_event.h:140
@ MD_CTRL
Definition: tool_event.h:139
@ MD_SHIFT
Definition: tool_event.h:138
@ BUT_AUX1
Definition: tool_event.h:130
@ BUT_MIDDLE
Definition: tool_event.h:129
@ BUT_LEFT
Definition: tool_event.h:127
@ BUT_RIGHT
Definition: tool_event.h:128
@ BUT_AUX2
Definition: tool_event.h:131
@ LIB_TEXT_T
Definition: typeinfo.h:200
@ LIB_TEXTBOX_T
Definition: typeinfo.h:201
@ LIB_SHAPE_T
Definition: typeinfo.h:199
@ LIB_PIN_T
Definition: typeinfo.h:202
@ LIB_FIELD_T
Definition: typeinfo.h:208

References SELECTION_TOOL::AddItemToSel(), ARROW, autostartEvent(), BUT_AUX1, BUT_AUX2, BUT_LEFT, BUT_MIDDLE, BUT_RIGHT, SELECTION::Clear(), ClearSelection(), CollectHits(), BOX2< Vec >::Contains(), DRAG_ANY, DRAG_SELECTED, EE_ACTIONS::drawBus, EE_ACTIONS::drawLines, EE_ACTIONS::drawWire, editor, SCH_BASE_FRAME::eeconfig(), SELECTION::Empty(), EE_ACTIONS::enterSheet, EESCHEMA_SETTINGS::INPUT::esc_clears_net_highlight, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SELECTION::Front(), EE_SELECTION::GetBoundingBox(), SCH_BASE_FRAME::GetCanvas(), COLLECTOR::GetCount(), TOOLS_HOLDER::GetDragAction(), EDA_DRAW_FRAME::GetItem(), TOOL_MANAGER::GetMousePosition(), GetSelection(), TOOL_MANAGER::GetTool(), SCH_DRAW_PANEL::GetView(), TOOL_BASE::getViewControls(), grid, HAND, EE_POINT_EDITOR::HasPoint(), ID_POPUP_SCH_SELECT_UNIT_CMP, ID_POPUP_SCH_SELECT_UNIT_SYM_MAX, ID_POPUP_SCH_UNFOLD_BUS, ID_POPUP_SCH_UNFOLD_BUS_END, BOX2< Vec >::Inflate(), TOOL_MANAGER::InvokeTool(), IS_MOVING, IS_NEW, IS_ROLLOVER, DRAW_SEGMENT_EVENT_PARAMS::layer, LIB_FIELD_T, LIB_PIN_T, LIB_SHAPE_T, LIB_TEXT_T, LIB_TEXTBOX_T, LINE_BUS, LINE_GRAPHIC, LINE_WIRE_ADD, SELECTION_TOOL::m_additive, SELECTION_TOOL::m_disambiguateTimer, SELECTION_TOOL::m_exclusive_or, m_frame, EESCHEMA_SETTINGS::m_Input, m_isSymbolEditor, TOOL_INTERACTIVE::m_menu, m_nonModifiedCursor, SELECTION_TOOL::m_originalCursor, m_selection, SELECTION_TOOL::m_subtractive, TOOL_BASE::m_toolMgr, TOOL_ACTION::MakeEvent(), MD_ALT, MD_CTRL, MD_SHIFT, EE_COLLECTOR::MovableItems, MOVING, narrowSelection(), EE_ACTIONS::navigateBack, EE_ACTIONS::navigateForward, niluuid, TOOL_MANAGER::ProcessEvent(), EE_ACTIONS::properties, DRAW_SEGMENT_EVENT_PARAMS::quitOnDraw, SELECTION_TOOL::RemoveItemFromSel(), RequestSelection(), TOOL_MANAGER::RunAction(), SCH_FIELD_T, SCH_SHEET_T, SELECT, selectionContains(), selectMultiple(), SelectPoint(), selectPoint(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), SELECTION::SetIsHover(), SELECTION_TOOL::setModifiersState(), TOOL_MENU::ShowContextMenu(), DRAW_SEGMENT_EVENT_PARAMS::sourceSegment, TA_CHOICE_MENU_CHOICE, TA_UNDO_REDO_PRE, TC_COMMAND, TOOLS_HOLDER::ToolStackIsEmpty(), EDA_ITEM::Type(), EE_ACTIONS::unfoldBus, KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), ACTIONS::zoomFitObjects, and ACTIONS::zoomFitScreen.

Referenced by setTransitions().

◆ narrowSelection()

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

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

Parameters
aCollector[in, out] Provides collection conditions and stores collected items.
aWherepoint where we should narrow (if relevant)
aCheckLockedIf false, remove locked elements from #collector
aSelectedOnlyIf true, remove non-selected items from #collector

Definition at line 837 of file ee_selection_tool.cpp.

839{
840 for( int i = collector.GetCount() - 1; i >= 0; --i )
841 {
842 if( !Selectable( collector[i], &aWhere ) )
843 {
844 collector.Remove( i );
845 continue;
846 }
847
848 if( aCheckLocked && collector[i]->IsLocked() )
849 {
850 collector.Remove( i );
851 continue;
852 }
853
854 if( aSelectedOnly && !collector[i]->IsSelected() )
855 {
856 collector.Remove( i );
857 continue;
858 }
859 }
860
861 // Apply some ugly heuristics to avoid disambiguation menus whenever possible
862 if( collector.GetCount() > 1 && !m_skip_heuristics )
863 GuessSelectionCandidates( collector, aWhere );
864}
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:109
bool Selectable(const EDA_ITEM *aItem, const VECTOR2I *aPos=nullptr, bool checkVisibilityOnly=false) const
Check conditions for an item to be selected.
void GuessSelectionCandidates(EE_COLLECTOR &collector, const VECTOR2I &aPos)
Apply heuristics to try and determine a single object when multiple are found under the cursor.

References COLLECTOR::GetCount(), GuessSelectionCandidates(), SELECTION_TOOL::m_skip_heuristics, COLLECTOR::Remove(), and Selectable().

Referenced by Main(), and SelectPoint().

◆ onDisambiguationExpire()

void SELECTION_TOOL::onDisambiguationExpire ( wxTimerEvent &  aEvent)
protectedinherited

Start the process to show our disambiguation menu once the user has kept the mouse down for the minimum time.

Parameters
aEvent

Definition at line 213 of file selection_tool.cpp.

214{
215 // If there is a multiple selection then it's more likely that we're seeing a paused drag
216 // than a long-click.
217 if( selection().GetSize() >= 2 )
218 return;
219
221}
static const TOOL_EVENT DisambiguatePoint
Definition: actions.h:220

References EVENTS::DisambiguatePoint, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), and SELECTION_TOOL::selection().

Referenced by Init(), PL_SELECTION_TOOL::Init(), PCB_SELECTION_TOOL::Init(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ OnIdle()

void EE_SELECTION_TOOL::OnIdle ( wxIdleEvent &  aEvent)

Zoom the screen to fit the bounding box for cross probing/selection sync.

Definition at line 768 of file ee_selection_tool.cpp.

769{
771 {
772 wxMouseState keyboardState = wxGetMouseState();
773
774 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(),
775 keyboardState.AltDown() );
776
777 if( m_additive )
779 else if( m_subtractive )
781 else if( m_exclusive_or )
783 else
785 }
786}

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

Referenced by SCH_BASE_FRAME::SCH_BASE_FRAME().

◆ RebuildSelection()

void EE_SELECTION_TOOL::RebuildSelection ( )

Rebuild the selection from the EDA_ITEMs' selection flags.

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

Definition at line 1681 of file ee_selection_tool.cpp.

1682{
1684
1685 if( m_isSymbolEditor )
1686 {
1687 LIB_SYMBOL* start = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
1688
1689 for( LIB_ITEM& item : start->GetDrawItems() )
1690 {
1691 if( item.IsSelected() )
1692 select( &item );
1693 }
1694 }
1695 else
1696 {
1697 for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
1698 {
1699 // If the field and symbol are selected, only use the symbol
1700 if( item->IsSelected() )
1701 {
1702 select( item );
1703 }
1704 else
1705 {
1706 item->RunOnChildren(
1707 [&]( SCH_ITEM* aChild )
1708 {
1709 if( aChild->IsSelected() )
1710 select( aChild );
1711 } );
1712 }
1713 }
1714 }
1715
1717
1718 // Inform other potentially interested tools
1720}
bool IsSelected() const
Definition: eda_item.h:107
void select(EDA_ITEM *aItem) override
Take necessary action to mark an item as selected.
void updateReferencePoint()
Set the reference point to the anchor of the top-left item.
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
Definition: sch_screen.h:108

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

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

◆ RemoveItemFromSel() [1/2]

◆ RemoveItemFromSel() [2/2]

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

Definition at line 152 of file selection_tool.cpp.

153{
154 if( aItem )
155 {
156 unselect( aItem );
157
158 // Inform other potentially interested tools
159 if( !aQuietMode )
161 }
162}
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:206
virtual void unselect(EDA_ITEM *aItem)=0
Take necessary action mark an item as unselected.

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

◆ RemoveItemsFromSel() [1/3]

int SELECTION_TOOL::RemoveItemsFromSel ( const TOOL_EVENT aEvent)
inherited

◆ RemoveItemsFromSel() [2/3]

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

Definition at line 173 of file selection_tool.cpp.

174{
175 if( aList )
176 {
177 for( EDA_ITEM* item : *aList )
178 unselect( item );
179
180 // Inform other potentially interested tools
181 if( !aQuietMode )
183 }
184}

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

◆ RemoveItemsFromSel() [3/3]

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

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

Definition at line 187 of file selection_tool.cpp.

188{
189 EDA_ITEMS removeItems;
190
191 for( EDA_ITEM* item : selection() )
192 {
193 if( alg::contains( *aList, item->m_Uuid ) )
194 removeItems.push_back( item );
195 }
196
197 RemoveItemsFromSel( &removeItems, aQuietMode );
198}
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
Definition: kicad_algo.h:99

References alg::contains(), SELECTION_TOOL::RemoveItemsFromSel(), and SELECTION_TOOL::selection().

◆ RequestSelection()

EE_SELECTION & EE_SELECTION_TOOL::RequestSelection ( const std::vector< KICAD_T > &  aScanTypes = SCH_LOCATE_ANY_T })

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

Parameters
aScanTypes[optional] List of item types that are acceptable for selection.
Returns
either the current selection or, if empty, the selection at the cursor.

Definition at line 1172 of file ee_selection_tool.cpp.

1173{
1174 if( m_selection.Empty() )
1175 {
1176 VECTOR2D cursorPos = getViewControls()->GetCursorPosition( true );
1177
1179 SelectPoint( cursorPos, aScanTypes );
1180 m_selection.SetIsHover( true );
1182 }
1183 else // Trim an existing selection by aFilterList
1184 {
1185 bool isMoving = false;
1186 bool anyUnselected = false;
1187
1188 for( int i = (int) m_selection.GetSize() - 1; i >= 0; --i )
1189 {
1190 EDA_ITEM* item = (EDA_ITEM*) m_selection.GetItem( i );
1191 isMoving |= static_cast<SCH_ITEM*>( item )->IsMoving();
1192
1193 if( !item->IsType( aScanTypes ) )
1194 {
1195 unselect( item );
1196 anyUnselected = true;
1197 }
1198 }
1199
1200 if( anyUnselected )
1202
1203 if( !isMoving )
1205 }
1206
1207 return m_selection;
1208}
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:183
void unselect(EDA_ITEM *aItem) override
Take necessary action to mark an item as unselected.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
Definition: selection.cpp:65

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

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

◆ Reset()

void EE_SELECTION_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Bring the tool to a known, initial state.

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

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 291 of file ee_selection_tool.cpp.

292{
293 m_frame = getEditFrame<SCH_BASE_FRAME>();
294
295 if( aReason == TOOL_BASE::MODEL_RELOAD )
296 {
297 // Remove pointers to the selected items from containers without changing their
298 // properties (as they are already deleted while a new sheet is loaded)
300 getView()->GetPainter()->GetSettings()->SetHighlight( false );
301
302 SYMBOL_EDIT_FRAME* symbolEditFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
303 SYMBOL_VIEWER_FRAME* symbolViewerFrame = dynamic_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
304
305 if( symbolEditFrame )
306 {
307 m_isSymbolEditor = true;
308 m_unit = symbolEditFrame->GetUnit();
309 m_convert = symbolEditFrame->GetConvert();
310 }
311 else
312 {
313 m_isSymbolViewer = symbolViewerFrame != nullptr;
314 }
315 }
316 else
317 {
318 // Restore previous properties of selected items and remove them from containers
320 }
321
322 // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
324 getView()->Add( &m_selection );
325}
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.
PAINTER * GetPainter() const
Return the painter object used by the view for drawing #VIEW_ITEMS.
Definition: view.h:213

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

◆ resetTransitions()

void TOOL_INTERACTIVE::resetTransitions ( )
privateinherited

Clear the current transition map and restores the default one created by setTransitions().

Definition at line 63 of file tool_interactive.cpp.

64{
67}
virtual void setTransitions()=0
This method is meant to be overridden in order to specify handlers for events.
void ClearTransitions(TOOL_BASE *aTool)
Clear the state transition map for a tool.

References TOOL_MANAGER::ClearTransitions(), TOOL_BASE::m_toolMgr, and TOOL_INTERACTIVE::setTransitions().

◆ 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}
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)
overrideprivatevirtual

Take necessary action to mark an item as selected.

Parameters
aItemThe item to be selected.

Implements SELECTION_TOOL.

Definition at line 1815 of file ee_selection_tool.cpp.

1816{
1817 highlight( aItem, SELECTED, &m_selection );
1818}
void highlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Highlight the item visually.

References highlight(), m_selection, and SELECTED.

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

◆ Selectable()

bool EE_SELECTION_TOOL::Selectable ( const EDA_ITEM aItem,
const VECTOR2I aPos = nullptr,
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 1723 of file ee_selection_tool.cpp.

1725{
1726 // NOTE: in the future this is where Eeschema layer/itemtype visibility will be handled
1727
1728 SYMBOL_EDIT_FRAME* symEditFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
1729
1730 // Do not allow selection of anything except fields when the current symbol in the symbol
1731 // editor is a derived symbol.
1732 if( symEditFrame && symEditFrame->IsSymbolAlias() && aItem->Type() != LIB_FIELD_T )
1733 return false;
1734
1735 switch( aItem->Type() )
1736 {
1737 case SCH_PIN_T:
1738 {
1739 const SCH_PIN* pin = static_cast<const SCH_PIN*>( aItem );
1740
1741 if( !pin->IsVisible() && !m_frame->GetShowAllPins() )
1742 return false;
1743
1745 {
1746 // Pin anchors have to be allowed for auto-starting wires.
1747 if( aPos )
1748 {
1750
1751 if( pin->IsPointClickableAnchor( grid.BestSnapAnchor( *aPos, LAYER_CONNECTABLE ) ) )
1752 return true;
1753 }
1754
1755 return false;
1756 }
1757
1758 break;
1759 }
1760
1761 case LIB_SYMBOL_T: // In symbol_editor we do not want to select the symbol itself.
1762 return false;
1763
1764 case LIB_FIELD_T: // LIB_FIELD object can always be edited.
1765 break;
1766
1767 case LIB_SHAPE_T:
1768 case LIB_TEXT_T:
1769 case LIB_PIN_T:
1770 if( symEditFrame )
1771 {
1772 LIB_ITEM* lib_item = (LIB_ITEM*) aItem;
1773
1774 if( lib_item->GetUnit() && lib_item->GetUnit() != symEditFrame->GetUnit() )
1775 return false;
1776
1777 if( lib_item->GetConvert() && lib_item->GetConvert() != symEditFrame->GetConvert() )
1778 return false;
1779 }
1780
1781 break;
1782
1783 case SCH_MARKER_T: // Always selectable
1784 return true;
1785
1786 default: // Suppress warnings
1787 break;
1788 }
1789
1790 return true;
1791}
int GetUnit() const
Definition: lib_item.h:273
int GetConvert() const
Definition: lib_item.h:276
virtual bool GetShowAllPins() const
Allow some frames to show/hide hidden pins.
@ LIB_SYMBOL_T
Definition: typeinfo.h:197
@ SCH_MARKER_T
Definition: typeinfo.h:140

References SCH_BASE_FRAME::eeconfig(), LIB_ITEM::GetConvert(), SYMBOL_EDIT_FRAME::GetConvert(), SCH_BASE_FRAME::GetShowAllPins(), LIB_ITEM::GetUnit(), SYMBOL_EDIT_FRAME::GetUnit(), grid, SYMBOL_EDIT_FRAME::IsSymbolAlias(), LAYER_CONNECTABLE, LIB_FIELD_T, LIB_PIN_T, LIB_SHAPE_T, LIB_SYMBOL_T, LIB_TEXT_T, m_frame, EESCHEMA_SETTINGS::m_Selection, TOOL_BASE::m_toolMgr, pin, SCH_MARKER_T, SCH_PIN_T, EESCHEMA_SETTINGS::SELECTION::select_pin_selects_symbol, 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 980 of file ee_selection_tool.cpp.

981{
982 m_multiple = true; // Multiple selection mode is active
983 KIGFX::VIEW* view = getView();
984
985 // hold all visible items
986 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
987 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> sheetPins;
988
989 // Filter the view items based on the selection box
990 BOX2I selectionBox;
991
992 selectionBox.SetMaximum();
993 view->Query( selectionBox, selectedItems ); // Get the list of selected items
994
995 // Sheet pins aren't in the view; add them by hand
996 for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems )
997 {
998 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( pair.first );
999
1000 if( sheet )
1001 {
1002 int layer = pair.second;
1003
1004 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1005 sheetPins.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( pin, layer ) );
1006 }
1007 }
1008
1009 selectedItems.insert( selectedItems.end(), sheetPins.begin(), sheetPins.end() );
1010
1011 for( const std::pair<KIGFX::VIEW_ITEM*, int>& item_pair : selectedItems )
1012 {
1013 if( EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( item_pair.first ) )
1014 {
1015 if( Selectable( item ) )
1016 {
1017 if( item->Type() == SCH_LINE_T )
1018 item->SetFlags( STARTPOINT | ENDPOINT );
1019
1020 select( item );
1021 }
1022 }
1023 }
1024
1025 m_multiple = false;
1026
1027 return 0;
1028}
void SetMaximum()
Definition: box2.h:63
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
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:422
std::pair< VIEW_ITEM *, int > LAYER_ITEM_PAIR
Definition: view.h:73
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:172
#define ENDPOINT
ends. (Used to support dragging.)
#define STARTPOINT
When a line is selected, these flags indicate which.

References ENDPOINT, SCH_SHEET::GetPins(), TOOL_BASE::getView(), SELECTION_TOOL::m_multiple, pin, KIGFX::VIEW::Query(), SCH_LINE_T, select(), Selectable(), EDA_ITEM::SetFlags(), BOX2< Vec >::SetMaximum(), and STARTPOINT.

Referenced by setTransitions().

◆ SelectConnection()

int EE_SELECTION_TOOL::SelectConnection ( const TOOL_EVENT aEvent)

If a connected item is selected then expand the selection to the entire connection, otherwise select connection under the current cursor position.

Clear current selection event handler.

Definition at line 1483 of file ee_selection_tool.cpp.

1484{
1486
1487 if( m_selection.Empty() )
1488 return 0;
1489
1490 SCH_LINE* line = (SCH_LINE*) m_selection.Front();
1491 unsigned done = false;
1492
1494 std::set<SCH_ITEM*> conns = m_frame->GetScreen()->MarkConnections( line, false );
1495
1496 for( SCH_ITEM* item : conns )
1497 {
1498 if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } )
1499 && !item->IsSelected() )
1500 {
1501 done = true;
1502 }
1503
1504 select( item );
1505 }
1506
1507 if( !done )
1508 {
1509 conns = m_frame->GetScreen()->MarkConnections( line, true );
1510
1511 for( SCH_ITEM* item : conns )
1512 select( item );
1513 }
1514
1515 if( m_selection.GetSize() > 1 )
1517
1518 return 0;
1519}
void ClearDrawingState()
Clear the state flags of all the items in the screen.
std::set< SCH_ITEM * > MarkConnections(SCH_LINE *aSegment, bool aSecondPass)
Return all wires and junctions connected to aSegment which are not connected any symbol pin.
Definition: sch_screen.cpp:353

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

Referenced by setTransitions().

◆ selection()

SELECTION & EE_SELECTION_TOOL::selection ( )
inlineoverrideprotectedvirtual

Return a reference to the selection.

Implements SELECTION_TOOL.

Definition at line 182 of file ee_selection_tool.h.

182{ return m_selection; }

References m_selection.

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

Definition at line 1898 of file ee_selection_tool.cpp.

1899{
1900 const unsigned GRIP_MARGIN = 20;
1901 VECTOR2I margin = getView()->ToWorld( VECTOR2I( GRIP_MARGIN, GRIP_MARGIN ), false );
1902
1903 // Check if the point is located within any of the currently selected items bounding boxes
1904 for( EDA_ITEM* item : m_selection )
1905 {
1906 BOX2I itemBox = item->ViewBBox();
1907 itemBox.Inflate( margin.x, margin.y ); // Give some margin for gripping an item
1908
1909 if( itemBox.Contains( aPoint ) )
1910 return true;
1911 }
1912
1913 return false;
1914}
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:445
VECTOR2< int > VECTOR2I
Definition: vector2d.h:618

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 SELECTION_TOOL::SelectionMenu ( const TOOL_EVENT aEvent)
inherited

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

225{
226 COLLECTOR* collector = aEvent.Parameter<COLLECTOR*>();
227
228 if( !doSelectionMenu( collector ) )
229 collector->m_MenuCancelled = true;
230
231 return 0;
232}
An abstract class that will find and hold all the objects according to an inspection done by the Insp...
Definition: collector.h:48
bool m_MenuCancelled
Definition: collector.h:237
bool doSelectionMenu(COLLECTOR *aCollector)

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

Referenced by setTransitions(), PL_SELECTION_TOOL::setTransitions(), and PCB_SELECTION_TOOL::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 1240 of file ee_selection_tool.cpp.

1241{
1242 bool cancelled = false; // Was the tool canceled while it was running?
1243 m_multiple = true; // Multiple selection mode is active
1244 KIGFX::VIEW* view = getView();
1245
1247 view->Add( &area );
1248
1249 while( TOOL_EVENT* evt = Wait() )
1250 {
1251 int width = area.GetEnd().x - area.GetOrigin().x;
1252 int height = area.GetEnd().y - area.GetOrigin().y;
1253
1254 /* Selection mode depends on direction of drag-selection:
1255 * Left > Right : Select objects that are fully enclosed by selection
1256 * Right > Left : Select objects that are crossed by selection
1257 */
1258 bool isWindowSelection = width >= 0;
1259
1260 if( view->IsMirroredX() )
1261 isWindowSelection = !isWindowSelection;
1262
1265
1266 if( evt->IsCancelInteractive() || evt->IsActivate() )
1267 {
1268 cancelled = true;
1269 break;
1270 }
1271
1272 if( evt->IsDrag( BUT_LEFT ) )
1273 {
1276
1277 // Start drawing a selection box
1278 area.SetOrigin( evt->DragOrigin() );
1279 area.SetEnd( evt->Position() );
1282 area.SetExclusiveOr( false );
1283
1284 view->SetVisible( &area, true );
1285 view->Update( &area );
1286 getViewControls()->SetAutoPan( true );
1287 }
1288
1289 if( evt->IsMouseUp( BUT_LEFT ) )
1290 {
1291 getViewControls()->SetAutoPan( false );
1292
1293 // End drawing the selection box
1294 view->SetVisible( &area, false );
1295
1296 // Fetch items from the RTree that are in our area of interest
1297 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> nearbyViewItems;
1298 view->Query( area.ViewBBox(), nearbyViewItems );
1299
1300 // Build lists of nearby items and their children
1301 std::unordered_set<EDA_ITEM*> nearbyItems;
1302 std::vector<EDA_ITEM*> nearbyChildren;
1303 std::vector<EDA_ITEM*> flaggedItems;
1304
1305 for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : nearbyViewItems )
1306 {
1307 if( EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( pair.first ) )
1308 {
1309 if( nearbyItems.insert( item ).second )
1310 {
1311 item->ClearFlags( CANDIDATE );
1312
1313 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item ) )
1314 {
1315 sch_item->RunOnChildren(
1316 [&]( SCH_ITEM* aChild )
1317 {
1318 // Filter pins by unit
1319 if( SCH_PIN* pin = dyn_cast<SCH_PIN*>( aChild ) )
1320 {
1321 int unit = pin->GetLibPin()->GetUnit();
1322
1323 if( unit && unit != pin->GetParentSymbol()->GetUnit() )
1324 return;
1325 }
1326
1327 nearbyChildren.push_back( aChild );
1328 } );
1329 }
1330 }
1331 }
1332 }
1333
1334 BOX2I selectionRect( area.GetOrigin(), VECTOR2I( width, height ) );
1335 selectionRect.Normalize();
1336
1337 bool anyAdded = false;
1338 bool anySubtracted = false;
1339 auto selectItem = [&]( EDA_ITEM* aItem )
1340 {
1341 EDA_ITEM_FLAGS flags = 0;
1342
1343 // Handle line ends specially
1344 if( aItem->Type() == SCH_LINE_T )
1345 {
1346 SCH_LINE* line = (SCH_LINE*) aItem;
1347
1348 if( selectionRect.Contains( line->GetStartPoint() ) )
1349 flags |= STARTPOINT;
1350
1351 if( selectionRect.Contains( line->GetEndPoint() ) )
1352 flags |= ENDPOINT;
1353
1354
1355 // If no ends were selected, select whole line (both ends)
1356 // Also select both ends if the selection overlaps the midpoint
1357 if( ( !( flags & STARTPOINT ) && !( flags & ENDPOINT ) )
1358 || selectionRect.Contains( line->GetMidPoint() ) )
1359 {
1360 flags = STARTPOINT | ENDPOINT;
1361 }
1362 }
1363
1364 if( m_subtractive || ( m_exclusive_or && aItem->IsSelected() ) )
1365 {
1366 aItem->ClearFlags( flags );
1367
1368 if( !aItem->HasFlag( STARTPOINT ) && !aItem->HasFlag( ENDPOINT ) )
1369 {
1370 unselect( aItem );
1371 anySubtracted = true;
1372 }
1373 }
1374 else
1375 {
1376 aItem->SetFlags( flags );
1377 select( aItem );
1378 anyAdded = true;
1379 }
1380 };
1381
1382 for( EDA_ITEM* item : nearbyItems )
1383 {
1385 item->SetFlags( SHOW_ELEC_TYPE );
1386
1387 if( Selectable( item ) && item->HitTest( selectionRect, isWindowSelection ) )
1388 {
1389 item->SetFlags( CANDIDATE );
1390 flaggedItems.push_back( item );
1391 selectItem( item );
1392 }
1393
1394 item->ClearFlags( SHOW_ELEC_TYPE );
1395 }
1396
1397 for( EDA_ITEM* item : nearbyChildren )
1398 {
1400 item->SetFlags( SHOW_ELEC_TYPE );
1401
1402 if( Selectable( item )
1403 && !item->GetParent()->HasFlag( CANDIDATE )
1404 && item->HitTest( selectionRect, isWindowSelection ) )
1405 {
1406 selectItem( item );
1407 }
1408
1409 item->ClearFlags( SHOW_ELEC_TYPE );
1410 }
1411
1412 for( EDA_ITEM* item : flaggedItems )
1413 item->ClearFlags( CANDIDATE );
1414
1415 m_selection.SetIsHover( false );
1416
1417 // Inform other potentially interested tools
1418 if( anyAdded )
1420
1421 if( anySubtracted )
1423
1424 break; // Stop waiting for events
1425 }
1426
1427 // Allow some actions for navigation
1428 for( int i = 0; allowedActions[i]; ++i )
1429 {
1430 if( evt->IsAction( allowedActions[i] ) )
1431 {
1432 evt->SetPassEvent();
1433 break;
1434 }
1435 }
1436 }
1437
1438 getViewControls()->SetAutoPan( false );
1439
1440 // Stop drawing the selection box
1441 view->Remove( &area );
1442 m_multiple = false; // Multiple selection mode is inactive
1443
1444 if( !cancelled )
1446
1447 return cancelled;
1448}
Represent a selection area (currently a rectangle) in a VIEW, drawn corner-to-corner between two poin...
void SetSubtractive(bool aSubtractive)
void SetAdditive(bool aAdditive)
void SetOrigin(const VECTOR2I &aOrigin)
const BOX2I ViewBBox() const override
Set the origin of the rectangle (the fixed corner)
void SetExclusiveOr(bool aExclusiveOr)
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the corner that moves with the cursor.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool IsMirroredX() const
Return true if view is flipped across the X axis.
Definition: view.h:243
void SetVisible(VIEW_ITEM *aItem, bool aIsVisible=true)
Set the item visibility.
Definition: view.cpp:1512
VECTOR2I GetMidPoint() const
Definition: sch_line.h:135
std::uint32_t EDA_ITEM_FLAGS
#define CANDIDATE
flag indicating that the structure is connected
#define SHOW_ELEC_TYPE
Show pin electrical type. Shared with IS_ROLLOVER.
const TOOL_ACTION * allowedActions[]

References KIGFX::VIEW::Add(), allowedActions, BUT_LEFT, CANDIDATE, SELECTION::ClearReferencePoint(), ClearSelection(), BOX2< Vec >::Contains(), ENDPOINT, SCH_BASE_FRAME::GetCanvas(), KIGFX::PREVIEW::SELECTION_AREA::GetEnd(), SCH_LINE::GetEndPoint(), SCH_LINE::GetMidPoint(), KIGFX::PREVIEW::SELECTION_AREA::GetOrigin(), SCH_BASE_FRAME::GetRenderSettings(), SCH_LINE::GetStartPoint(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), KIGFX::VIEW::IsMirroredX(), SELECTION_TOOL::m_drag_additive, SELECTION_TOOL::m_drag_subtractive, SELECTION_TOOL::m_exclusive_or, m_frame, SELECTION_TOOL::m_multiple, m_selection, KIGFX::SCH_RENDER_SETTINGS::m_ShowPinsElectricalType, SELECTION_TOOL::m_subtractive, TOOL_BASE::m_toolMgr, BOX2< Vec >::Normalize(), pin, TOOL_MANAGER::ProcessEvent(), KIGFX::VIEW::Query(), KIGFX::VIEW::Remove(), SCH_LINE_T, 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(), SELECTION::SetIsHover(), KIGFX::PREVIEW::SELECTION_AREA::SetOrigin(), KIGFX::PREVIEW::SELECTION_AREA::SetSubtractive(), KIGFX::VIEW::SetVisible(), SHOW_ELEC_TYPE, 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)

Selects the connected item at the current cursor position.

Iterative process with a decreasing slop factor.

Definition at line 1473 of file ee_selection_tool.cpp.

1474{
1475 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( false );
1476
1477 SelectPoint( cursorPos, connectedTypes );
1478
1479 return 0;
1480}

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

Referenced by setTransitions().

◆ SelectPoint()

bool EE_SELECTION_TOOL::SelectPoint ( const VECTOR2I aWhere,
const std::vector< KICAD_T > &  aScanTypes = SCH_LOCATE_ANY_T },
EDA_ITEM **  aItem = nullptr,
bool *  aSelectionCancelledFlag = nullptr,
bool  aCheckLocked = false,
bool  aAdd = false,
bool  aSubtract = false,
bool  aExclusiveOr = false 
)

Perform a click-type selection at a point (usually the cursor position).

Parameters
aWherePoint from which the selection should be made.
aScanTypes[optional] List of item types that are acceptable for selection.
aItem[out, optional] The newly selected item if only one was selected, otherwise unchanged.
aSelectionCancelledFlag[out] Allows 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.
Returns
true if the selection was modified.

Definition at line 962 of file ee_selection_tool.cpp.

967{
968 EE_COLLECTOR collector;
969
970 if( !CollectHits( collector, aWhere, aScanTypes ) )
971 return false;
972
973 narrowSelection( collector, aWhere, aCheckLocked, aSubtract );
974
975 return selectPoint( collector, aWhere, aItem, aSelectionCancelledFlag, aAdd, aSubtract,
976 aExclusiveOr );
977}

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

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

◆ selectPoint()

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

Perform a click-type selection at a point (usually the cursor position).

Parameters
aCollector[in, out] Provides collection conditions and stores collected items.
aWherePoint from which the selection should be made.
aItem[out, optional] The newly selected item if only one was selected, otherwise unchanged.
aSelectionCancelledFlag[out] Allows 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.
Returns
true if the selection was modified.

Definition at line 867 of file ee_selection_tool.cpp.

870{
872
873 // If still more than one item we're going to have to ask the user.
874 if( aCollector.GetCount() > 1 )
875 {
876 // Try to call selectionMenu via RunAction() to avoid event-loop contention
877 // But it we cannot handle the event, then we don't have an active tool loop, so
878 // handle it directly.
879 if( !m_toolMgr->RunAction( EE_ACTIONS::selectionMenu, true, &aCollector ) )
880 {
881 if( !doSelectionMenu( &aCollector ) )
882 aCollector.m_MenuCancelled = true;
883 }
884
885 if( aCollector.m_MenuCancelled )
886 {
887 if( aSelectionCancelledFlag )
888 *aSelectionCancelledFlag = true;
889
890 return false;
891 }
892 }
893
894 if( !aAdd && !aSubtract && !aExclusiveOr )
896
897 int addedCount = 0;
898 bool anySubtracted = false;
899
900 if( aCollector.GetCount() > 0 )
901 {
902 for( int i = 0; i < aCollector.GetCount(); ++i )
903 {
904 EDA_ITEM_FLAGS flags = 0;
905
906 // Handle line ends specially
907 if( aCollector[i]->Type() == SCH_LINE_T )
908 {
909 SCH_LINE* line = (SCH_LINE*) aCollector[i];
910
911 if( HitTestPoints( line->GetStartPoint(), aWhere, aCollector.m_Threshold ) )
912 flags = STARTPOINT;
913 else if( HitTestPoints( line->GetEndPoint(), aWhere, aCollector.m_Threshold ) )
914 flags = ENDPOINT;
915 else
916 flags = STARTPOINT | ENDPOINT;
917 }
918
919 if( aSubtract || ( aExclusiveOr && aCollector[i]->IsSelected() ) )
920 {
921 aCollector[i]->ClearFlags( flags );
922
923 if( !aCollector[i]->HasFlag( STARTPOINT ) && !aCollector[i]->HasFlag( ENDPOINT ) )
924 {
925 unselect( aCollector[i] );
926 anySubtracted = true;
927 }
928 }
929 else
930 {
931 aCollector[i]->SetFlags( flags );
932 select( aCollector[i] );
933 addedCount++;
934 }
935 }
936 }
937
938 if( addedCount == 1 )
939 {
941
942 if( aItem && aCollector.GetCount() == 1 )
943 *aItem = aCollector[0];
944
945 return true;
946 }
947 else if( addedCount > 1 )
948 {
950 return true;
951 }
952 else if( anySubtracted )
953 {
955 return true;
956 }
957
958 return false;
959}
static TOOL_ACTION selectionMenu
Runs a selection menu to select from a list of items.
Definition: ee_actions.h:67
static const TOOL_EVENT PointSelectedEvent
Definition: actions.h:204
bool HitTestPoints(const VECTOR2I &pointA, const VECTOR2I &pointB, double threshold)
Test, if two points are near each other.
Definition: trigo.h:159

References SELECTION::ClearReferencePoint(), ClearSelection(), SELECTION_TOOL::doSelectionMenu(), ENDPOINT, COLLECTOR::GetCount(), SCH_LINE::GetEndPoint(), SCH_LINE::GetStartPoint(), HitTestPoints(), COLLECTOR::m_MenuCancelled, m_selection, COLLECTOR::m_Threshold, TOOL_BASE::m_toolMgr, EVENTS::PointSelectedEvent, TOOL_MANAGER::ProcessEvent(), TOOL_MANAGER::RunAction(), SCH_LINE_T, select(), EVENTS::SelectedEvent, EE_ACTIONS::selectionMenu, STARTPOINT, 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}
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.
@ CMENU_OFF
Definition: tool_event.h:149

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

Referenced by SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setModifiersState()

void SELECTION_TOOL::setModifiersState ( bool  aShiftState,
bool  aCtrlState,
bool  aAltState 
)
protectedinherited

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

Definition at line 48 of file selection_tool.cpp.

49{
50 // Set the configuration of m_additive, m_subtractive, m_exclusive_or from the state of
51 // modifier keys SHIFT and CTRL
52
53 // ALT key cannot be used on MSW because of a conflict with the system menu
54
55 m_subtractive = aCtrlState && aShiftState;
56 m_additive = !aCtrlState && aShiftState;
57
59 {
60 m_exclusive_or = false;
61 m_highlight_modifier = aCtrlState && !aShiftState;
62 }
63 else
64 {
65 m_exclusive_or = aCtrlState && !aShiftState;
67 }
68
69 // Drag is more forgiving and allows either Ctrl+Drag or Shift+Drag to add to the selection
70 // Note, however that we cannot provide disambiguation at the same time as the box selection
71 m_drag_additive = ( aCtrlState || aShiftState ) && !aAltState;
72 m_drag_subtractive = aCtrlState && aShiftState && !aAltState;
73
74 // While the ALT key has some conflicts under MSW (and some flavors of Linux WMs), it remains
75 // useful for users who only use tap-click rather than holding the button. We disable it for
76 // windows because it flashes the disambiguation menu without showing data
77#ifndef __WINDOWS__
78 m_skip_heuristics = aAltState;
79#else
80 m_skip_heuristics = false;
81#endif
82
83}
virtual bool ctrlClickHighlights()
Determines if ctrl-click is highlight net or XOR selection.

References SELECTION_TOOL::ctrlClickHighlights(), SELECTION_TOOL::m_additive, SELECTION_TOOL::m_drag_additive, SELECTION_TOOL::m_drag_subtractive, SELECTION_TOOL::m_exclusive_or, SELECTION_TOOL::m_highlight_modifier, SELECTION_TOOL::m_skip_heuristics, and SELECTION_TOOL::m_subtractive.

Referenced by disambiguateCursor(), PL_SELECTION_TOOL::disambiguateCursor(), PCB_SELECTION_TOOL::disambiguateCursor(), Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), OnIdle(), and PCB_SELECTION_TOOL::OnIdle().

◆ setTransitions()

void EE_SELECTION_TOOL::setTransitions ( )
overrideprivatevirtual

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

It is called every time tool is reset or finished.

Implements TOOL_INTERACTIVE.

Definition at line 1917 of file ee_selection_tool.cpp.

1918{
1920
1925
1931
1933
1935}
static TOOL_ACTION updateMenu
Definition: actions.h:170
static TOOL_ACTION selectAll
Definition: actions.h:71
static TOOL_ACTION selectionActivate
Activation of the selection tool.
Definition: ee_actions.h:46
static TOOL_ACTION addItemsToSel
Selects a list of items (specified as the event parameter)
Definition: ee_actions.h:63
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static TOOL_ACTION removeItemsFromSel
Definition: ee_actions.h:64
static TOOL_ACTION selectNode
Select the junction, wire or bus segment under the cursor.
Definition: ee_actions.h:49
static TOOL_ACTION removeItemFromSel
Definition: ee_actions.h:60
static TOOL_ACTION addItemToSel
Selects an item (specified as the event parameter).
Definition: ee_actions.h:59
int SelectConnection(const TOOL_EVENT &aEvent)
If a connected item is selected then expand the selection to the entire connection,...
int SelectAll(const TOOL_EVENT &aEvent)
int Main(const TOOL_EVENT &aEvent)
The main loop.
int disambiguateCursor(const TOOL_EVENT &aEvent)
Handle disambiguation actions including displaying the menu.
int SelectNode(const TOOL_EVENT &aEvent)
Selects the connected item at the current cursor position.
int UpdateMenu(const TOOL_EVENT &aEvent)
Update a menu's state based on the current selection.
int SelectionMenu(const TOOL_EVENT &aEvent)
Show a popup menu to trim the COLLECTOR passed as aEvent's parameter down to a single item.
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).

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

◆ SyncSelection()

int EE_SELECTION_TOOL::SyncSelection ( std::optional< SCH_SHEET_PATH targetSheetPath,
SCH_ITEM focusItem,
std::vector< SCH_ITEM * >  items 
)

Definition at line 1638 of file ee_selection_tool.cpp.

1640{
1641 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
1642
1643 if( !editFrame || m_isSymbolEditor || m_isSymbolViewer )
1644 return 0;
1645
1646 if( targetSheetPath && targetSheetPath != editFrame->Schematic().CurrentSheet() )
1647 {
1648 editFrame->Schematic().SetCurrentSheet( *targetSheetPath );
1649 editFrame->DisplayCurrentSheet();
1650 }
1651
1652 ClearSelection( items.size() > 0 ? true /*quiet mode*/ : false );
1653
1654 // Perform individual selection of each item before processing the event.
1655 for( SCH_ITEM* item : items )
1656 select( item );
1657
1659
1660 if( bbox.GetWidth() != 0 && bbox.GetHeight() != 0 )
1661 {
1663 {
1665 ZoomFitCrossProbeBBox( bbox );
1666
1667 editFrame->FocusOnItem( focusItem );
1668
1669 if( !focusItem )
1670 editFrame->FocusOnLocation( bbox.Centre() );
1671 }
1672 }
1673
1674 if( m_selection.Size() > 0 )
1676
1677 return 0;
1678}
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:170
Vec Centre() const
Definition: box2.h:70
void FocusOnLocation(const VECTOR2I &aPos)
Useful to focus on a particular location, in find functions.
void ZoomFitCrossProbeBBox(const BOX2I &aBBox)
SCH_SHEET_PATH & CurrentSheet() const override
Definition: schematic.h:119
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:124
void DisplayCurrentSheet()
Draw the current sheet on the display.
void FocusOnItem(SCH_ITEM *aItem)
int Size() const
Returns the number of selected parts.
Definition: selection.h:113
bool zoom_to_fit
Zoom to fit items (ignored if center_on_items is off)
Definition: app_settings.h:34
bool center_on_items
Automatically pan to cross-probed items.
Definition: app_settings.h:33

References CROSS_PROBING_SETTINGS::center_on_items, BOX2< Vec >::Centre(), ClearSelection(), SCHEMATIC::CurrentSheet(), SCH_EDIT_FRAME::DisplayCurrentSheet(), SCH_BASE_FRAME::eeconfig(), SCH_EDIT_FRAME::FocusOnItem(), EDA_DRAW_FRAME::FocusOnLocation(), EE_SELECTION::GetBoundingBox(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetWidth(), APP_SETTINGS_BASE::m_CrossProbing, m_frame, m_isSymbolEditor, m_isSymbolViewer, m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), SCH_EDIT_FRAME::Schematic(), select(), EVENTS::SelectedEvent, SCHEMATIC::SetCurrentSheet(), SELECTION::Size(), CROSS_PROBING_SETTINGS::zoom_to_fit, and ZoomFitCrossProbeBBox().

◆ UnbrightenItem()

◆ unhighlight()

void EE_SELECTION_TOOL::unhighlight ( EDA_ITEM aItem,
int  aHighlightMode,
SELECTION aGroup = nullptr 
)
overrideprivatevirtual

Unhighlight the item visually.

Parameters
aItemis an item to be highlighted.
aHighlightModeshould be either SELECTED or BRIGHTENED
aGroup[optional] A group to remove the item from.

Implements SELECTION_TOOL.

Definition at line 1860 of file ee_selection_tool.cpp.

1861{
1862 KICAD_T itemType = aItem->Type();
1863
1864 if( aMode == SELECTED )
1865 {
1866 aItem->ClearSelected();
1867 // Lines need endpoints cleared here
1868 if( aItem->Type() == SCH_LINE_T )
1869 aItem->ClearFlags( STARTPOINT | ENDPOINT );
1870 }
1871 else if( aMode == BRIGHTENED )
1872 aItem->ClearBrightened();
1873
1874 if( aGroup )
1875 aGroup->Remove( aItem );
1876
1877 // Unhighlight pins and fields. (All the other symbol children are currently only
1878 // represented in the LIB_SYMBOL.)
1879 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
1880 {
1881 sch_item->RunOnChildren(
1882 [&]( SCH_ITEM* aChild )
1883 {
1884 if( aMode == SELECTED )
1885 aChild->ClearSelected();
1886 else if( aMode == BRIGHTENED )
1887 aChild->ClearBrightened();
1888 } );
1889 }
1890
1891 if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
1892 getView()->Update( aItem->GetParent() );
1893 else
1894 getView()->Update( aItem );
1895}
void ClearSelected()
Definition: eda_item.h:121
void ClearBrightened()
Definition: eda_item.h:122
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.cpp:50

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

Referenced by ClearSelection(), and unselect().

◆ unselect()

void EE_SELECTION_TOOL::unselect ( EDA_ITEM aItem)
overrideprivatevirtual

Take necessary action to mark an item as unselected.

Parameters
aItemThe item to be unselected.

Implements SELECTION_TOOL.

Definition at line 1821 of file ee_selection_tool.cpp.

1822{
1823 unhighlight( aItem, SELECTED, &m_selection );
1824}

References m_selection, SELECTED, and unhighlight().

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

◆ UpdateMenu()

int SELECTION_TOOL::UpdateMenu ( const TOOL_EVENT aEvent)
inherited

Update a menu's state based on the current selection.

The menu is passed in aEvent's parameter.

Definition at line 86 of file selection_tool.cpp.

87{
88 ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
89 CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
90
91 if( conditionalMenu )
92 conditionalMenu->Evaluate( selection() );
93
94 if( actionMenu )
95 actionMenu->UpdateAll();
96
97 return 0;
98}
void UpdateAll()
Run update handlers for the menu and its submenus.
void Evaluate(SELECTION &aSelection)
Update the contents of the menu based on the supplied conditions.

References CONDITIONAL_MENU::Evaluate(), TOOL_EVENT::Parameter(), SELECTION_TOOL::selection(), and ACTION_MENU::UpdateAll().

Referenced by setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), and PCB_SELECTION_TOOL::setTransitions().

◆ updateReferencePoint()

void EE_SELECTION_TOOL::updateReferencePoint ( )
private

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

Definition at line 1211 of file ee_selection_tool.cpp.

1212{
1213 VECTOR2I refP( 0, 0 );
1214
1215 if( m_selection.Size() > 0 )
1216 {
1217 if( m_isSymbolEditor )
1218 refP = static_cast<LIB_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
1219 else
1220 refP = static_cast<SCH_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
1221 }
1222
1224}
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:252

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

◆ ZoomFitCrossProbeBBox()

void EE_SELECTION_TOOL::ZoomFitCrossProbeBBox ( const BOX2I aBBox)

Definition at line 1530 of file ee_selection_tool.cpp.

1531{
1532 if( aBBox.GetWidth() == 0 )
1533 return;
1534
1535 BOX2I bbox = aBBox;
1536 bbox.Normalize();
1537
1538 VECTOR2I bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
1539 VECTOR2D screenSize = getView()->GetViewport().GetSize();
1540
1541 // This code tries to come up with a zoom factor that doesn't simply zoom in
1542 // to the cross probed symbol, but instead shows a reasonable amount of the
1543 // circuit around it to provide context. This reduces or eliminates the need
1544 // to manually change the zoom because it's too close.
1545
1546 // Using the default text height as a constant to compare against, use the
1547 // height of the bounding box of visible items for a footprint to figure out
1548 // if this is a big symbol (like a processor) or a small symbol (like a resistor).
1549 // This ratio is not useful by itself as a scaling factor. It must be "bent" to
1550 // provide good scaling at varying symbol sizes. Bigger symbols need less
1551 // scaling than small ones.
1552 double currTextHeight = schIUScale.MilsToIU( DEFAULT_TEXT_SIZE );
1553
1554 double compRatio = bbSize.y / currTextHeight; // Ratio of symbol to text height
1555 double compRatioBent = 1.0;
1556
1557 // LUT to scale zoom ratio to provide reasonable schematic context. Must work
1558 // with symbols of varying sizes (e.g. 0402 package and 200 pin BGA).
1559 // "first" is used as the input and "second" as the output
1560 //
1561 // "first" = compRatio (symbol height / default text height)
1562 // "second" = Amount to scale ratio by
1563 std::vector<std::pair<double, double>> lut{ { 1.25, 16 }, // 32
1564 { 2.5, 12 }, //24
1565 { 5, 8 }, // 16
1566 { 6, 6 }, //
1567 { 10, 4 }, //8
1568 { 20, 2 }, //4
1569 { 40, 1.5 }, // 2
1570 { 100, 1 } };
1571
1572 std::vector<std::pair<double, double>>::iterator it;
1573
1574 // Large symbol default is last LUT entry (1:1).
1575 compRatioBent = lut.back().second;
1576
1577 // Use LUT to do linear interpolation of "compRatio" within "first", then
1578 // use that result to linearly interpolate "second" which gives the scaling
1579 // factor needed.
1580 if( compRatio >= lut.front().first )
1581 {
1582 for( it = lut.begin(); it < lut.end() - 1; it++ )
1583 {
1584 if( it->first <= compRatio && next( it )->first >= compRatio )
1585 {
1586 double diffx = compRatio - it->first;
1587 double diffn = next( it )->first - it->first;
1588
1589 compRatioBent = it->second + ( next( it )->second - it->second ) * diffx / diffn;
1590 break; // We have our interpolated value
1591 }
1592 }
1593 }
1594 else
1595 {
1596 compRatioBent = lut.front().second; // Small symbol default is first entry
1597 }
1598
1599 // This is similar to the original KiCad code that scaled the zoom to make sure
1600 // symbols were visible on screen. It's simply a ratio of screen size to
1601 // symbol size, and its job is to zoom in to make the component fullscreen.
1602 // Earlier in the code the symbol BBox is given a 20% margin to add some
1603 // breathing room. We compare the height of this enlarged symbol bbox to the
1604 // default text height. If a symbol will end up with the sides clipped, we
1605 // adjust later to make sure it fits on screen.
1606 screenSize.x = std::max( 10.0, screenSize.x );
1607 screenSize.y = std::max( 10.0, screenSize.y );
1608 double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) );
1609
1610 // Original KiCad code for how much to scale the zoom
1611 double kicadRatio =
1612 std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
1613
1614 // If the width of the part we're probing is bigger than what the screen width
1615 // will be after the zoom, then punt and use the KiCad zoom algorithm since it
1616 // guarantees the part's width will be encompassed within the screen.
1617 if( bbSize.x > screenSize.x * ratio * compRatioBent )
1618 {
1619 // Use standard KiCad zoom for parts too wide to fit on screen/
1620 ratio = kicadRatio;
1621 compRatioBent = 1.0; // Reset so we don't modify the "KiCad" ratio
1622 wxLogTrace( "CROSS_PROBE_SCALE",
1623 "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio );
1624 }
1625
1626 // Now that "compRatioBent" holds our final scaling factor we apply it to the
1627 // original fullscreen zoom ratio to arrive at the final ratio itself.
1628 ratio *= compRatioBent;
1629
1630 bool alwaysZoom = false; // DEBUG - allows us to minimize zooming or not
1631
1632 // Try not to zoom on every cross-probe; it gets very noisy
1633 if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
1634 getView()->SetScale( getView()->GetScale() / ratio );
1635}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
BOX2< Vec > & Normalize()
Ensure that the height and width are positive.
Definition: box2.h:119
const Vec & GetSize() const
Definition: box2.h:179
BOX2D GetViewport() const
Return the current viewport visible area rectangle.
Definition: view.cpp:508
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:548
#define DEFAULT_TEXT_SIZE
Ratio of the font height to the baseline of the text above the wire.
CITER next(CITER it)
Definition: ptree.cpp:126
constexpr int MilsToIU(int mils) const
Definition: base_units.h:94

References DEFAULT_TEXT_SIZE, BOX2< Vec >::GetSize(), TOOL_BASE::getView(), KIGFX::VIEW::GetViewport(), BOX2< Vec >::GetWidth(), BOX2< Vec >::Inflate(), EDA_IU_SCALE::MilsToIU(), next(), BOX2< Vec >::Normalize(), schIUScale, KIGFX::VIEW::SetScale(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SyncSelection().

Member Data Documentation

◆ m_additive

◆ m_canceledMenu

bool SELECTION_TOOL::m_canceledMenu
protectedinherited

◆ 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_disambiguateTimer

wxTimer SELECTION_TOOL::m_disambiguateTimer
protectedinherited

◆ m_drag_additive

bool SELECTION_TOOL::m_drag_additive
protectedinherited

◆ m_drag_subtractive

bool SELECTION_TOOL::m_drag_subtractive
protectedinherited

◆ m_exclusive_or

◆ m_frame

◆ m_highlight_modifier

bool SELECTION_TOOL::m_highlight_modifier
protectedinherited

◆ 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(), Reset(), and SyncSelection().

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

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

Definition at line 125 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(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), EDA_3D_CONTROLLER::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), Init(), EE_TOOL_BASE< T >::Init(), SCH_DRAWING_TOOLS::Init(), SCH_EDIT_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), SYMBOL_EDITOR_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), PICKER_TOOL::Init(), ZOOM_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_EDIT_TOOL::Init(), PL_SELECTION_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), ROUTER_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), DRAWING_TOOL::Init(), FOOTPRINT_EDITOR_CONTROL::Init(), PAD_TOOL::Init(), PCB_SELECTION_TOOL::Init(), PCB_TOOL_BASE::Init(), PCB_VIEWER_TOOLS::Init(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDA_3D_CONTROLLER::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace().

◆ m_multiple

◆ 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_originalCursor

◆ m_selection

◆ m_skip_heuristics

◆ m_subtractive

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Name of the tool.

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

Definition at line 209 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 214 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), SELECTION_TOOL::AddItemsToSel(), SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), BOARD_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), autostartEvent(), SCH_EDIT_TOOL::BreakWire(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDITOR_CONTROL::ChangeLineMode(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), SCH_EDITOR_CONTROL::ClearHighlight(), BOARD_INSPECTION_TOOL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), PL_SELECTION_TOOL::ClearSelection(), ClearSelection(), PCB_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MICROWAVE_TOOL::createInductorBetween(), EE_INSPECTION_TOOL::CrossProbe(), DRC_TOOL::CrossProbe(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), BOARD_EDITOR_CONTROL::doCrossProbePcbToSch(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SCH_EDIT_TOOL::DoDelete(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), BOARD_INSPECTION_TOOL::doHideRatsnestNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PCB_SELECTION_TOOL::doSyncSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::Drag(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties(), SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCB_SELECTION_TOOL::grabUnconnected(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCB_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PL_EDIT_TOOL::ImportDrawingSheetContent(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), EE_TOOL_BASE< T >::Init(), SCH_EDIT_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_EDIT_TOOL::Init(), PL_POINT_EDITOR::Init(), ROUTER_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), BOARD_INSPECTION_TOOL::Init(), BOARD_REANNOTATE_TOOL::Init(), CONVERT_TOOL::Init(), DRAWING_TOOL::Init(), EDIT_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), PCB_POINT_EDITOR::Init(), PCB_SELECTION_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), POSITION_RELATIVE_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EDA_3D_CONTROLLER::Main(), CVPCB_CONTROL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), EDIT_TOOL::MoveIndividually(), SCH_EDITOR_CONTROL::NextLineMode(), SYMBOL_EDITOR_CONTROL::OnDeMorgan(), SELECTION_TOOL::onDisambiguationExpire(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_EDIT_TOOL::PinTable(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), GERBVIEW_CONTROL::Print(), PCB_CONTROL::Print(), SCH_EDIT_TOOL::Properties(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), RebuildSelection(), PAD_TOOL::RecombinePad(), SCH_EDITOR_CONTROL::Redo(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem(), PCB_SELECTION_TOOL::RequestSelection(), RequestSelection(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), PAD_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), SCH_EDITOR_CONTROL::Revert(), SCH_EDIT_TOOL::Rotate(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), ROUTER_TOOL::RouteSelected(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), Selectable(), SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectNet(), GERBVIEW_SELECTION_TOOL::selectPoint(), PL_SELECTION_TOOL::SelectPoint(), PCB_SELECTION_TOOL::selectPoint(), 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(), SCH_EDIT_TOOL::Swap(), SyncSelection(), COMMON_TOOLS::ToggleCursor(), COMMON_TOOLS::ToggleCursorStyle(), EDA_3D_CONTROLLER::ToggleVisibility(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_EDITOR_CONTROL::Undo(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), GROUP_TOOL::Ungroup(), PCB_SELECTION_TOOL::unrouteSelected(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), BOARD_INSPECTION_TOOL::UpdateLocalRatsnest(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), EE_POINT_EDITOR::updateParentItem(), PNS::TOOL_BASE::updateStartItem(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), and BOARD_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Definition at line 213 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

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

Definition at line 206 of file tool_base.h.

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

◆ m_unit

int EE_SELECTION_TOOL::m_unit
private

Definition at line 284 of file ee_selection_tool.h.

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


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