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 , REDRAW }
 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...
 
bool hasModifier ()
 True if a selection modifier is enabled, false otherwise. 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 58 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.

REDRAW 

Full drawing refresh.

Definition at line 77 of file tool_base.h.

78 {
79 RUN,
82 REDRAW
83 };
@ REDRAW
Full drawing refresh.
Definition: tool_base.h: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 131 of file ee_selection_tool.cpp.

131 :
132 SELECTION_TOOL( "eeschema.InteractiveSelection" ),
133 m_frame( nullptr ),
135 m_isSymbolEditor( false ),
136 m_isSymbolViewer( false ),
137 m_unit( 0 ),
138 m_convert( 0 )
139{
141}
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:92

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

◆ ~EE_SELECTION_TOOL()

EE_SELECTION_TOOL::~EE_SELECTION_TOOL ( )

Definition at line 144 of file ee_selection_tool.cpp.

145{
147}
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
Definition: view.cpp:349
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:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

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

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), 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 128 of file selection_tool.cpp.

129{
130 AddItemsToSel( aEvent.Parameter<EDA_ITEMS*>(), false );
131 selection().SetIsHover( false );
132 return 0;
133}
int AddItemsToSel(const TOOL_EVENT &aEvent)
virtual SELECTION & selection()=0
Return a reference to the selection.
void SetIsHover(bool aIsHover)
Definition: selection.h:78
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(), 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 136 of file selection_tool.cpp.

137{
138 if( aList )
139 {
140 for( EDA_ITEM* item : *aList )
141 select( item );
142
143 // Inform other potentially interested tools
144 if( !aQuietMode )
146 }
147}
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:206
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 115 of file selection_tool.cpp.

116{
117 if( aItem )
118 {
119 select( aItem );
120
121 // Inform other potentially interested tools
122 if( !aQuietMode )
124 }
125}

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

705{
706 VECTOR2I pos = aGrid.BestSnapAnchor( aEvent->Position(), LAYER_CONNECTABLE );
707
710 && aItem->IsPointClickableAnchor( pos ) )
711 {
713
714 if( aItem->Type() == SCH_BUS_BUS_ENTRY_T )
715 {
717 }
718 else if( aItem->Type() == SCH_BUS_WIRE_ENTRY_T )
719 {
720 SCH_BUS_WIRE_ENTRY* busEntry = static_cast<SCH_BUS_WIRE_ENTRY*>( aItem );
721
722 if( !busEntry->m_connected_bus_item )
724 }
725 else if( aItem->Type() == SCH_LINE_T )
726 {
727 SCH_LINE* line = static_cast<SCH_LINE*>( aItem );
728
729 if( line->IsBus() )
730 newEvt = EE_ACTIONS::drawBus.MakeEvent();
731 else if( line->IsGraphicLine() )
732 newEvt = EE_ACTIONS::drawLines.MakeEvent();
733 }
734 else if( aItem->Type() == SCH_LABEL_T || aItem->Type() == SCH_HIER_LABEL_T
735 || aItem->Type() == SCH_SHEET_PIN_T )
736 {
737 SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem );
738 SCH_CONNECTION possibleConnection( label->Schematic()->ConnectionGraph() );
739 possibleConnection.ConfigureFromLabel( label->GetText() );
740
741 if( possibleConnection.IsBus() )
743 }
744
745 newEvt->SetMousePosition( pos );
746 newEvt->SetHasPosition( true );
747 newEvt->SetForceImmediate( true );
748
749 getViewControls()->ForceCursorPosition( true, pos );
750
751 return newEvt;
752 }
753
754 return OPT_TOOL_EVENT();
755}
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
static TOOL_ACTION drawWire
Definition: ee_actions.h:81
static TOOL_ACTION drawBus
Definition: ee_actions.h:82
static TOOL_ACTION drawLines
Definition: ee_actions.h:98
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.
CONNECTION_GRAPH * ConnectionGraph() const override
Definition: schematic.h:130
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 ...
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:112
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:943
bool IsGraphicLine() const
Return if the line is a graphic (non electrical line)
Definition: sch_line.cpp:931
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
void SetMousePosition(const VECTOR2D &aP)
Definition: tool_event.h:470
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:146
@ SCH_LABEL_T
Definition: typeinfo.h:151
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:153
@ SCH_BUS_BUS_ENTRY_T
Definition: typeinfo.h:145
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:157
@ SCH_BUS_WIRE_ENTRY_T
Definition: typeinfo.h:144

References EESCHEMA_SETTINGS::DRAWING::auto_start_wires, EE_GRID_HELPER::BestSnapAnchor(), SCH_CONNECTION::ConfigureFromLabel(), SCHEMATIC::ConnectionGraph(), EE_ACTIONS::drawBus, EE_ACTIONS::drawLines, EE_ACTIONS::drawWire, SCH_BASE_FRAME::eeconfig(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), EDA_TEXT::GetText(), TOOL_MANAGER::GetTool(), TOOL_BASE::getViewControls(), EE_POINT_EDITOR::HasPoint(), SCH_CONNECTION::IsBus(), 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_HIER_LABEL_T, SCH_LABEL_T, SCH_LINE_T, SCH_SHEET_PIN_T, SCH_ITEM::Schematic(), TOOL_EVENT::SetMousePosition(), and EDA_ITEM::Type().

Referenced by Main().

◆ BrightenItem()

void SELECTION_TOOL::BrightenItem ( EDA_ITEM aItem)
inherited

Definition at line 207 of file selection_tool.cpp.

208{
209 highlight( aItem, BRIGHTENED );
210}
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(), SCH_EDIT_FRAME::DisplayCurrentSheet(), SCH_FIND_REPLACE_TOOL::FindNext(), and SCH_FIND_REPLACE_TOOL::UpdateFind().

◆ ClearSelection() [1/2]

void EE_SELECTION_TOOL::ClearSelection ( bool  aQuietMode = false)

Definition at line 1852 of file ee_selection_tool.cpp.

1853{
1854 if( m_selection.Empty() )
1855 return;
1856
1857 while( m_selection.GetSize() )
1859
1860 getView()->Update( &m_selection );
1861
1862 m_selection.SetIsHover( false );
1864
1865 // Inform other potentially interested tools
1866 if( !aQuietMode )
1868}
void unhighlight(EDA_ITEM *aItem, int aHighlightMode, SELECTION *aGroup=nullptr) override
Unhighlight the item visually.
static const TOOL_EVENT ClearedEvent
Definition: actions.h:208
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:1591
virtual unsigned int GetSize() const override
Return the number of stored items.
Definition: selection.h:99
EDA_ITEM * Front() const
Definition: selection.h:208
void ClearReferencePoint()
Definition: selection.h:265
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
#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 801 of file ee_selection_tool.cpp.

803{
804 int pixelThreshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
805 int gridThreshold = KiROUND( getView()->GetGAL()->GetGridSize().EuclideanNorm() / 2 );
806 aCollector.m_Threshold = std::max( pixelThreshold, gridThreshold );
808
809 if( m_isSymbolEditor )
810 {
811 LIB_SYMBOL* symbol = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
812
813 if( !symbol )
814 return false;
815
816 aCollector.Collect( symbol->GetDrawItems(), aScanTypes, aWhere, m_unit, m_convert );
817 }
818 else
819 {
820 aCollector.Collect( m_frame->GetScreen(), aScanTypes, aWhere, m_unit, m_convert );
821
823 {
824 int originalCount = aCollector.GetCount();
825
826 for( int ii = 0; ii < originalCount; ++ii )
827 {
828 if( aCollector[ii]->Type() == SCH_PIN_T )
829 {
830 SCH_PIN* pin = static_cast<SCH_PIN*>( aCollector[ii] );
831
832 if( !aCollector.HasItem( pin->GetParentSymbol() ) )
833 aCollector.Append( pin->GetParentSymbol() );
834 }
835 }
836 }
837 }
838
839 return aCollector.GetCount() > 0;
840}
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:99
LIB_ITEMS_CONTAINER & GetDrawItems()
Return a reference to the draw item list.
Definition: lib_symbol.h:508
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:159
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:85

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

127{ 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 758 of file ee_selection_tool.cpp.

759{
760 wxMouseState keyboardState = wxGetMouseState();
761
762 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(),
763 keyboardState.AltDown() );
764
765 m_skip_heuristics = true;
768 m_skip_heuristics = false;
769
770 return 0;
771}
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:183

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

246{
247 UNITS_PROVIDER* unitsProvider = getEditFrame<EDA_DRAW_FRAME>();
248 EDA_ITEM* current = nullptr;
249 SELECTION highlightGroup;
250 bool selectAll = false;
251 bool expandSelection = false;
252
253 highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
254 getView()->Add( &highlightGroup );
255
256 do
257 {
259 if( expandSelection )
260 aCollector->Combine();
261
262 expandSelection = false;
263
264 int limit = std::min( 100, aCollector->GetCount() );
265 ACTION_MENU menu( true );
266
267 for( int i = 0; i < limit; ++i )
268 {
269 EDA_ITEM* item = ( *aCollector )[i];
270 wxString menuText;
271
272 if( i < 9 )
273 {
274#ifdef __WXMAC__
275 menuText = wxString::Format( "%s\t%d",
276 item->GetItemDescription( unitsProvider ),
277 i + 1 );
278#else
279 menuText = wxString::Format( "&%d %s\t%d",
280 i + 1,
281 item->GetItemDescription( unitsProvider ),
282 i + 1 );
283#endif
284 }
285 else
286 {
287 menuText = item->GetItemDescription( unitsProvider );
288 }
289
290 menu.Add( menuText, i + 1, item->GetMenuImage() );
291 }
292
293 menu.AppendSeparator();
294 menu.Add( _( "Select &All\tA" ), limit + 1, BITMAPS::INVALID_BITMAP );
295
296 if( !expandSelection && aCollector->HasAdditionalItems() )
297 menu.Add( _( "&Expand Selection\tE" ), limit + 2, BITMAPS::INVALID_BITMAP );
298
299 if( aCollector->m_MenuTitle.Length() )
300 {
301 menu.SetTitle( aCollector->m_MenuTitle );
302 menu.SetIcon( BITMAPS::info );
303 menu.DisplayTitle( true );
304 }
305 else
306 {
307 menu.DisplayTitle( false );
308 }
309
310 SetContextMenu( &menu, CMENU_NOW );
311
312 while( TOOL_EVENT* evt = Wait() )
313 {
314 if( evt->Action() == TA_CHOICE_MENU_UPDATE )
315 {
316 if( selectAll )
317 {
318 for( int i = 0; i < aCollector->GetCount(); ++i )
319 unhighlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
320 }
321 else if( current )
322 {
323 unhighlight( current, BRIGHTENED, &highlightGroup );
324 }
325
326 int id = *evt->GetCommandId();
327
328 // User has pointed an item, so show it in a different way
329 if( id > 0 && id <= limit )
330 {
331 current = ( *aCollector )[id - 1];
332 highlight( current, BRIGHTENED, &highlightGroup );
333 }
334 else
335 {
336 current = nullptr;
337 }
338
339 // User has pointed on the "Select All" option
340 if( id == limit + 1 )
341 {
342 for( int i = 0; i < aCollector->GetCount(); ++i )
343 highlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
344
345 selectAll = true;
346 }
347 else
348 {
349 selectAll = false;
350 }
351 }
352 else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
353 {
354 if( selectAll )
355 {
356 for( int i = 0; i < aCollector->GetCount(); ++i )
357 unhighlight( ( *aCollector )[i], BRIGHTENED, &highlightGroup );
358 }
359 else if( current )
360 {
361 unhighlight( current, BRIGHTENED, &highlightGroup );
362 }
363
364 std::optional<int> id = evt->GetCommandId();
365
366 // User has selected the "Select All" option
367 if( id == limit + 1 )
368 {
369 selectAll = true;
370 current = nullptr;
371 }
372 // User has selected the "Expand Selection" option
373 else if( id == limit + 2 )
374 {
375 selectAll = false;
376 current = nullptr;
377 expandSelection = true;
378 }
379 // User has selected an item, so this one will be returned
380 else if( id && ( *id > 0 ) && ( *id <= limit ) )
381 {
382 selectAll = false;
383 current = ( *aCollector )[*id - 1];
384 }
385 // User has cancelled the menu (either by <esc> or clicking out of it)
386 else
387 {
388 selectAll = false;
389 current = nullptr;
390 }
391 }
392 else if( evt->Action() == TA_CHOICE_MENU_CLOSED )
393 {
394 break;
395 }
396
397 getView()->UpdateItems();
398 getEditFrame<EDA_DRAW_FRAME>()->GetCanvas()->Refresh();
399 }
400 } while( expandSelection );
401
402 getView()->Remove( &highlightGroup );
403
404 if( selectAll )
405 {
406 return true;
407 }
408 else if( current )
409 {
410 aCollector->Empty();
411 aCollector->Append( current );
412 return true;
413 }
414
415 return false;
416}
@ 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 wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider) const
Return a user-visible description string of this item.
Definition: eda_item.cpp:108
virtual BITMAPS GetMenuImage() const
Return a pointer to an image to be used in menus.
Definition: eda_item.cpp:269
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
void UpdateItems()
Iterate through the list of items that asked for updating and updates them.
Definition: view.cpp:1401
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::GetItemDescription(), EDA_ITEM::GetMenuImage(), 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(), KIGFX::VIEW::UpdateItems(), 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 185 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), 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 121 of file tool_base.h.

122 {
123 return m_toolId;
124 }

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

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

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), 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 1509 of file ee_selection_tool.cpp.

1510{
1511 EE_COLLECTOR collector;
1512
1513 //TODO(snh): Reimplement after exposing KNN interface
1514 int pixelThreshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
1515 int gridThreshold = KiROUND( getView()->GetGAL()->GetGridSize().EuclideanNorm() );
1516 int thresholdMax = std::max( pixelThreshold, gridThreshold );
1517
1518 for( int threshold : { 0, thresholdMax/4, thresholdMax/2, thresholdMax } )
1519 {
1520 collector.m_Threshold = threshold;
1521 collector.Collect( m_frame->GetScreen(), connectedTypes, aPosition );
1522
1523 if( collector.GetCount() > 0 )
1524 break;
1525 }
1526
1527 return collector.GetCount() ? collector[ 0 ] : nullptr;
1528}
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 109 of file tool_base.h.

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

References TOOL_BASE::m_type.

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

◆ getView()

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

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

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), 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(), EDIT_TOOL::DeleteItems(), 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(), BOARD_INSPECTION_TOOL::highlightNet(), PNS::TOOL_BASE::highlightNets(), 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(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), 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(), PCB_SELECTION_TOOL::selectionContains(), selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), 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_FIND_REPLACE_TOOL::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(), autostartEvent(), SCH_EDIT_TOOL::BreakWire(), PCB_SELECTION_TOOL::controls(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), COMMON_TOOLS::CursorControl(), EDIT_TOOL::DeleteItems(), 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(), SCH_EDITOR_CONTROL::Paste(), 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(), 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_FIND_REPLACE_TOOL::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 1046 of file ee_selection_tool.cpp.

1047{
1048 // Prefer exact hits to sloppy ones
1049 std::set<EDA_ITEM*> exactHits;
1050
1051 for( int i = collector.GetCount() - 1; i >= 0; --i )
1052 {
1053 EDA_ITEM* item = collector[ i ];
1054 SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
1055 LIB_SHAPE* shape = dynamic_cast<LIB_SHAPE*>( item );
1056 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
1057
1058 // Lines are hard to hit. Give them a bit more slop to still be considered "exact".
1059
1060 if( line || ( shape && shape->GetShape() == SHAPE_T::POLY )
1061 || ( shape && shape->GetShape() == SHAPE_T::ARC ) )
1062 {
1063 int pixelThreshold = KiROUND( getView()->ToWorld( 6 ) );
1064
1065 if( item->HitTest( aPos, pixelThreshold ) )
1066 exactHits.insert( item );
1067 }
1068 else if( symbol && m_frame->eeconfig()->m_Selection.select_pin_selects_symbol )
1069 {
1070 if( symbol->GetBodyAndPinsBoundingBox().Contains( aPos ) )
1071 exactHits.insert( item );
1072 }
1073 else
1074 {
1075 if( item->HitTest( aPos, 0 ) )
1076 exactHits.insert( item );
1077 }
1078 }
1079
1080 if( exactHits.size() > 0 && exactHits.size() < (unsigned) collector.GetCount() )
1081 {
1082 for( int i = collector.GetCount() - 1; i >= 0; --i )
1083 {
1084 EDA_ITEM* item = collector[ i ];
1085
1086 if( !exactHits.count( item ) )
1087 collector.Transfer( item );
1088 }
1089 }
1090
1091 // Find the closest item. (Note that at this point all hits are either exact or non-exact.)
1092 VECTOR2I pos( aPos );
1093 SEG poss( m_isSymbolEditor ? mapCoords( pos ) : pos,
1094 m_isSymbolEditor ? mapCoords( pos ) : pos );
1095 EDA_ITEM* closest = nullptr;
1096 int closestDist = INT_MAX / 2;
1097
1098 for( EDA_ITEM* item : collector )
1099 {
1100 BOX2I bbox = item->GetBoundingBox();
1101 int dist = INT_MAX / 2;
1102
1103 if( exactHits.count( item ) )
1104 {
1105 if( item->Type() == SCH_PIN_T || item->Type() == SCH_JUNCTION_T )
1106 {
1107 closest = item;
1108 break;
1109 }
1110
1111 SCH_LINE* line = dynamic_cast<SCH_LINE*>( item );
1112 EDA_TEXT* text = dynamic_cast<EDA_TEXT*>( item );
1113 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( item );
1114
1115 if( line )
1116 {
1117 dist = DistanceLinePoint( line->GetStartPoint(), line->GetEndPoint(), pos );
1118 }
1119 else if( text )
1120 {
1121 if( SCH_FIELD* field = dynamic_cast<SCH_FIELD*>( text ) )
1122 {
1123 if( field->GetParent() && field->GetParent()->Type() == SCH_SYMBOL_T )
1124 {
1125 symbol = static_cast<SCH_SYMBOL*>( field->GetParent() );
1126
1127 VECTOR2I relPos = pos - symbol->GetPosition();
1128 relPos = symbol->GetTransform().InverseTransform().TransformCoordinate( relPos );
1129 pos = relPos + symbol->GetPosition();
1130
1131 poss = SEG( pos, pos );
1132 }
1133 }
1134
1135 text->GetEffectiveTextShape()->Collide( poss, closestDist, &dist );
1136 }
1137 else if( symbol )
1138 {
1139 try
1140 {
1141 bbox = symbol->GetBodyBoundingBox();
1142 }
1143 catch( const boost::bad_pointer& exc )
1144 {
1145 // This may be overkill and could be an assertion but we are more likely to
1146 // find any boost pointer container errors this way.
1147 wxLogError( wxT( "Boost bad pointer exception '%s' occurred." ), exc.what() );
1148 }
1149
1150 SHAPE_RECT rect( bbox.GetPosition(), bbox.GetWidth(), bbox.GetHeight() );
1151
1152 if( bbox.Contains( pos ) )
1153 dist = EuclideanNorm( bbox.GetCenter() - pos );
1154 else
1155 rect.Collide( poss, closestDist, &dist );
1156 }
1157 else
1158 {
1159 dist = EuclideanNorm( bbox.GetCenter() - pos );
1160 }
1161 }
1162 else
1163 {
1164 SHAPE_RECT rect( bbox.GetPosition(), bbox.GetWidth(), bbox.GetHeight() );
1165 rect.Collide( poss, collector.m_Threshold, &dist );
1166 }
1167
1168 if( dist == closestDist )
1169 {
1170 if( item->GetParent() == closest )
1171 closest = item;
1172 }
1173 else if( dist < closestDist )
1174 {
1175 closestDist = dist;
1176 closest = item;
1177 }
1178 }
1179
1180 // Construct a tight box (1/2 height and width) around the center of the closest item.
1181 // All items which exist at least partly outside this box have sufficient other areas
1182 // for selection and can be dropped.
1183 if( closest ) // Don't try and get a tight bbox if nothing is near the mouse pointer
1184 {
1185 BOX2I tightBox = closest->GetBoundingBox();
1186 tightBox.Inflate( -tightBox.GetWidth() / 4, -tightBox.GetHeight() / 4 );
1187
1188 for( int i = collector.GetCount() - 1; i >= 0; --i )
1189 {
1190 EDA_ITEM* item = collector[i];
1191
1192 if( item == closest )
1193 continue;
1194
1195 if( !item->HitTest( tightBox, true ) )
1196 collector.Transfer( item );
1197 }
1198 }
1199}
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:113
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:72
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
VECTOR2I GetEndPoint() const
Definition: sch_line.h:143
VECTOR2I GetStartPoint() const
Definition: sch_line.h:138
Schematic symbol object.
Definition: sch_symbol.h:81
VECTOR2I GetPosition() const override
Definition: sch_symbol.h:712
TRANSFORM & GetTransform()
Definition: sch_symbol.h:283
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
TRANSFORM InverseTransform() const
Calculate the Inverse mirror/rotation transform.
Definition: transform.cpp:60
VECTOR2I TransformCoordinate(const VECTOR2I &aPoint) const
Calculate a new coordinate according to the mirror/rotation transform.
Definition: transform.cpp:45
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_SYMBOL_T
Definition: typeinfo.h:156
@ SCH_JUNCTION_T
Definition: typeinfo.h:142

References ARC, 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(), SCH_SYMBOL::GetPosition(), EDA_SHAPE::GetShape(), SCH_LINE::GetStartPoint(), SCH_SYMBOL::GetTransform(), TOOL_BASE::getView(), BOX2< Vec >::GetWidth(), EDA_ITEM::HitTest(), BOX2< Vec >::Inflate(), TRANSFORM::InverseTransform(), KiROUND(), m_frame, m_isSymbolEditor, EESCHEMA_SETTINGS::m_Selection, COLLECTOR::m_Threshold, mapCoords(), POLY, SCH_JUNCTION_T, SCH_PIN_T, SCH_SYMBOL_T, EESCHEMA_SETTINGS::SELECTION::select_pin_selects_symbol, text, COLLECTOR::Transfer(), and TRANSFORM::TransformCoordinate().

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

◆ hasModifier()

bool SELECTION_TOOL::hasModifier ( )
protectedinherited

True if a selection modifier is enabled, false otherwise.

Definition at line 86 of file selection_tool.cpp.

87{
89}

References SELECTION_TOOL::m_additive, SELECTION_TOOL::m_exclusive_or, and SELECTION_TOOL::m_subtractive.

Referenced by Main(), PL_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), and SELECTION_TOOL::onDisambiguationExpire().

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

1884{
1885 KICAD_T itemType = aItem->Type();
1886
1887 if( aMode == SELECTED )
1888 aItem->SetSelected();
1889 else if( aMode == BRIGHTENED )
1890 aItem->SetBrightened();
1891
1892 if( aGroup )
1893 aGroup->Add( aItem );
1894
1895 // Highlight pins and fields. (All the other symbol children are currently only
1896 // represented in the LIB_SYMBOL and will inherit the settings of the parent symbol.)
1897 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
1898 {
1899 sch_item->RunOnChildren(
1900 [&]( SCH_ITEM* aChild )
1901 {
1902 if( aMode == SELECTED )
1903 aChild->SetSelected();
1904 else if( aMode == BRIGHTENED )
1905 aChild->SetBrightened();
1906 } );
1907 }
1908
1909 if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
1910 getView()->Update( aItem->GetParent() );
1911 else
1912 getView()->Update( aItem );
1913}
void SetSelected()
Definition: eda_item.h:115
void SetBrightened()
Definition: eda_item.h:116
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:42
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
@ SCH_FIELD_T
Definition: typeinfo.h:155

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

171{
172 m_frame = getEditFrame<SCH_BASE_FRAME>();
173
174 SYMBOL_VIEWER_FRAME* symbolViewerFrame = dynamic_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
175 SYMBOL_EDIT_FRAME* symbolEditorFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
176
177 if( symbolEditorFrame )
178 {
179 m_isSymbolEditor = true;
180 m_unit = symbolEditorFrame->GetUnit();
181 m_convert = symbolEditorFrame->GetConvert();
182 }
183 else
184 {
185 m_isSymbolViewer = symbolViewerFrame != nullptr;
186 }
187
190 auto wireOrBusSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } );
191 auto connectedSelection = E_C::Count( 1 ) && E_C::OnlyTypes( connectedTypes );
192 auto sheetSelection = E_C::Count( 1 ) && E_C::OnlyTypes( { SCH_SHEET_T } );
193 auto crossProbingSelection = E_C::MoreThan( 0 ) && E_C::HasTypes( { SCH_SYMBOL_T, SCH_PIN_T, SCH_SHEET_T } );
194
195 auto schEditSheetPageNumberCondition =
196 [&] ( const SELECTION& aSel )
197 {
199 return false;
200
201 return E_C::LessThan( 2 )( aSel ) && E_C::OnlyTypes( { SCH_SHEET_T } )( aSel );
202 };
203
204 auto schEditCondition =
205 [this] ( const SELECTION& aSel )
206 {
208 };
209
210 auto belowRootSheetCondition =
211 [&]( const SELECTION& aSel )
212 {
213 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
214
215 return editFrame
216 && editFrame->GetCurrentSheet().Last() != &editFrame->Schematic().Root();
217 };
218
219 auto haveHighlight =
220 [&]( const SELECTION& sel )
221 {
222 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
223
224 return editFrame && editFrame->GetHighlightedConnection() != nullptr;
225 };
226
227 auto haveSymbol =
228 [&]( const SELECTION& sel )
229 {
230 return m_isSymbolEditor &&
231 static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
232 };
233
234 auto symbolDisplayNameIsEditable =
235 [&]( const SELECTION& sel )
236 {
237 if ( !m_isSymbolEditor )
238 return false;
239
240 SYMBOL_EDIT_FRAME* symbEditorFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
241
242 return symbEditorFrame
243 && symbEditorFrame->GetCurSymbol()
244 && symbEditorFrame->GetCurSymbol()->IsMulti()
245 && symbEditorFrame->IsSymbolEditable()
246 && !symbEditorFrame->IsSymbolAlias();
247 };
248
249 auto& menu = m_menu.GetMenu();
250
251 menu.AddItem( EE_ACTIONS::clearHighlight, haveHighlight && EE_CONDITIONS::Idle, 1 );
252 menu.AddSeparator( haveHighlight && EE_CONDITIONS::Idle, 1 );
253
254 menu.AddItem( EE_ACTIONS::enterSheet, sheetSelection && EE_CONDITIONS::Idle, 2 );
255 menu.AddItem( EE_ACTIONS::selectOnPCB, crossProbingSelection && EE_CONDITIONS::Idle, 2 );
256 menu.AddItem( EE_ACTIONS::leaveSheet, belowRootSheetCondition, 2 );
257
258 menu.AddSeparator( 100 );
259 menu.AddItem( EE_ACTIONS::drawWire, schEditCondition && EE_CONDITIONS::Empty, 100 );
260 menu.AddItem( EE_ACTIONS::drawBus, schEditCondition && EE_CONDITIONS::Empty, 100 );
261
262 menu.AddSeparator( 100 );
264
265 menu.AddSeparator( 100 );
267
268 menu.AddSeparator( 200 );
269 menu.AddItem( EE_ACTIONS::selectConnection, connectedSelection && EE_CONDITIONS::Idle, 250 );
270 menu.AddItem( EE_ACTIONS::placeJunction, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
271 menu.AddItem( EE_ACTIONS::placeLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
272 menu.AddItem( EE_ACTIONS::placeClassLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
273 menu.AddItem( EE_ACTIONS::placeGlobalLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
274 menu.AddItem( EE_ACTIONS::placeHierLabel, wireOrBusSelection && EE_CONDITIONS::Idle, 250 );
275 menu.AddItem( EE_ACTIONS::breakWire, linesSelection && EE_CONDITIONS::Idle, 250 );
276 menu.AddItem( EE_ACTIONS::slice, linesSelection && EE_CONDITIONS::Idle, 250 );
277 menu.AddItem( EE_ACTIONS::importSheetPin, sheetSelection && EE_CONDITIONS::Idle, 250 );
278 menu.AddItem( EE_ACTIONS::assignNetclass, connectedSelection && EE_CONDITIONS::Idle, 250 );
279 menu.AddItem( EE_ACTIONS::editPageNumber, schEditSheetPageNumberCondition, 250 );
280
281 menu.AddSeparator( 400 );
282 menu.AddItem( EE_ACTIONS::symbolProperties, haveSymbol && EE_CONDITIONS::Empty, 400 );
283 menu.AddItem( EE_ACTIONS::pinTable, haveSymbol && EE_CONDITIONS::Empty, 400 );
284 menu.AddItem( EE_ACTIONS::setUnitDisplayName,
285 haveSymbol && symbolDisplayNameIsEditable && EE_CONDITIONS::Empty, 400 );
286
287 menu.AddSeparator( 1000 );
289
290 m_disambiguateTimer.SetOwner( this );
291 Connect( wxEVT_TIMER, wxTimerEventHandler( EE_SELECTION_TOOL::onDisambiguationExpire ), nullptr, this );
292
293 return true;
294}
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:250
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:155
static TOOL_ACTION slice
Definition: ee_actions.h:144
static TOOL_ACTION assignNetclass
Definition: ee_actions.h:161
static TOOL_ACTION placeClassLabel
Definition: ee_actions.h:88
static TOOL_ACTION finishWire
Definition: ee_actions.h:103
static TOOL_ACTION breakWire
Definition: ee_actions.h:143
static TOOL_ACTION importSheetPin
Definition: ee_actions.h:92
static TOOL_ACTION selectOnPCB
Definition: ee_actions.h:220
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:199
static TOOL_ACTION placeGlobalLabel
Definition: ee_actions.h:89
static TOOL_ACTION placeHierLabel
Definition: ee_actions.h:90
static TOOL_ACTION symbolProperties
Definition: ee_actions.h:154
static TOOL_ACTION editPageNumber
Definition: ee_actions.h:163
static TOOL_ACTION enterSheet
Definition: ee_actions.h:198
static TOOL_ACTION setUnitDisplayName
Definition: ee_actions.h:194
static TOOL_ACTION placeLabel
Definition: ee_actions.h:87
static TOOL_ACTION placeJunction
Definition: ee_actions.h:85
static TOOL_ACTION finishBus
Definition: ee_actions.h:104
bool IsMulti() const
Definition: lib_symbol.h:557
SCH_SHEET & Root() const
Definition: schematic.h:91
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_ITEM_LOCATE_WIRE_T
Definition: typeinfo.h:170
@ SCH_SHEET_T
Definition: typeinfo.h:158
@ SCH_ITEM_LOCATE_BUS_T
Definition: typeinfo.h:171
@ SCH_ITEM_LOCATE_GRAPHIC_LINE_T
Definition: typeinfo.h:172

References CONDITIONAL_MENU::AddItem(), EDA_DRAW_FRAME::AddStandardSubMenus(), EE_ACTIONS::assignNetclass, 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::importSheetPin, 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_GRAPHIC_LINE_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, EE_ACTIONS::slice, 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 334 of file ee_selection_tool.cpp.

335{
337
338 KIID lastRolloverItem = niluuid;
339
340 // Main loop: keep receiving events
341 while( TOOL_EVENT* evt = Wait() )
342 {
343 bool selCancelled = false;
344 bool displayWireCursor = false;
345 bool displayBusCursor = false;
346 bool displayLineCursor = false;
347 KIID rolloverItem = lastRolloverItem;
348
349 // on left click, a selection is made, depending on modifiers ALT, SHIFT, CTRL:
350 setModifiersState( evt->Modifier( MD_SHIFT ), evt->Modifier( MD_CTRL ),
351 evt->Modifier( MD_ALT ) );
352
353 MOUSE_DRAG_ACTION drag_action = m_frame->GetDragAction();
355
356 if( evt->IsMouseDown( BUT_LEFT ) )
357 {
358 // Avoid triggering when running under other tools
359 // Distinguish point editor from selection modification by checking modifiers
362 {
364 m_disambiguateTimer.StartOnce( 500 );
365 }
366 }
367 // Single click? Select single object
368 else if( evt->IsClick( BUT_LEFT ) )
369 {
370 // If the timer has stopped, then we have already run the disambiguate routine
371 // and we don't want to register an extra click here
372 if( !m_disambiguateTimer.IsRunning() )
373 {
374 evt->SetPassEvent();
375 continue;
376 }
377
378 m_disambiguateTimer.Stop();
379
380 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
381 schframe->FocusOnItem( nullptr );
382
383 // Collect items at the clicked location (doesn't select them yet)
384 EE_COLLECTOR collector;
385 CollectHits( collector, evt->Position() );
386 narrowSelection( collector, evt->Position(), false );
387
388 if( collector.GetCount() == 1 && !m_isSymbolEditor && !hasModifier() )
389 {
390 OPT_TOOL_EVENT autostart = autostartEvent( evt, grid, collector[0] );
391
392 if( autostart )
393 {
395
396 params->layer = autostart->Parameter<DRAW_SEGMENT_EVENT_PARAMS*>()->layer;
397 params->quitOnDraw = true;
398 params->sourceSegment = dynamic_cast<SCH_LINE*>( collector[0] );
399
400 autostart->SetParameter( params );
401 m_toolMgr->ProcessEvent( *autostart );
402
403 selCancelled = true;
404 }
405 else if( collector[0]->IsHypertext() )
406 {
407 collector[ 0 ]->DoHypertextAction( m_frame );
408 selCancelled = true;
409 }
410 }
411
412 if( !selCancelled )
413 {
414 selectPoint( collector, evt->Position(), nullptr, nullptr, m_additive,
416 m_selection.SetIsHover( false );
417 }
418 }
419 else if( evt->IsClick( BUT_RIGHT ) )
420 {
421 m_disambiguateTimer.Stop();
422
423 // right click? if there is any object - show the context menu
424 if( m_selection.Empty() )
425 {
427 SelectPoint( evt->Position(), { SCH_LOCATE_ANY_T }, nullptr, &selCancelled );
428 m_selection.SetIsHover( true );
429 }
430 // If the cursor has moved off the bounding box of the selection by more than
431 // a grid square, check to see if there is another item available for selection
432 // under the cursor. If there is, the user likely meant to get the context menu
433 // for that item. If there is no new item, then keep the original selection and
434 // show the context menu for it.
435 else if( !m_selection.GetBoundingBox().Inflate( grid.GetGrid().x, grid.GetGrid().y )
436 .Contains( evt->Position() ) )
437 {
438 EE_COLLECTOR collector;
439
440 if( CollectHits( collector, evt->Position(), { SCH_LOCATE_ANY_T } ) )
441 {
443
444 SelectPoint( evt->Position(), { SCH_LOCATE_ANY_T }, nullptr, &selCancelled );
445 m_selection.SetIsHover( true );
446 }
447 }
448
449 if( !selCancelled )
451 }
452 else if( evt->IsDblClick( BUT_LEFT ) )
453 {
454 m_disambiguateTimer.Stop();
455
456 // double click? Display the properties window
457 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
458 schframe->FocusOnItem( nullptr );
459
460 if( m_selection.Empty() )
461 SelectPoint( evt->Position() );
462
463 EDA_ITEM* item = m_selection.Front();
464
465 if( item && item->Type() == SCH_SHEET_T )
467 else
469 }
470 else if( evt->IsDblClick( BUT_MIDDLE ) )
471 {
472 m_disambiguateTimer.Stop();
473
474 // Middle double click? Do zoom to fit or zoom to objects
475 if( evt->Modifier( MD_CTRL ) ) // Is CTRL key down?
477 else
479 }
480 else if( evt->IsDrag( BUT_LEFT ) )
481 {
482 m_disambiguateTimer.Stop();
483
484 // Is another tool already moving a new object? Don't allow a drag start
485 if( !m_selection.Empty() && m_selection[0]->HasFlag( IS_NEW | IS_MOVING ) )
486 {
487 evt->SetPassEvent();
488 continue;
489 }
490
491 // drag with LMB? Select multiple objects (or at least draw a selection box) or
492 // drag them
493 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
494 schframe->FocusOnItem( nullptr );
495
496 if( hasModifier() || drag_action == MOUSE_DRAG_ACTION::SELECT )
497 {
499 }
500 else if( m_selection.Empty() && drag_action != MOUSE_DRAG_ACTION::DRAG_ANY )
501 {
503 }
504 else
505 {
506 if( m_isSymbolEditor )
507 {
508 if( static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->IsSymbolAlias() )
509 {
511 }
512 else
513 {
517 LIB_PIN_T,
518 LIB_FIELD_T } );
519 }
520 }
521 else
522 {
524 }
525
526 // Check if dragging has started within any of selected items bounding box
527 if( selectionContains( evt->DragOrigin() ) )
528 {
529 // Yes -> run the move tool and wait till it finishes
530 if( m_isSymbolEditor )
531 m_toolMgr->InvokeTool( "eeschema.SymbolMoveTool" );
532 else
533 m_toolMgr->InvokeTool( "eeschema.InteractiveMove" );
534 }
535 else
536 {
537 // No -> drag a selection box
539 }
540 }
541 }
542 else if( evt->IsMouseDown( BUT_AUX1 ) )
543 {
545 }
546 else if( evt->IsMouseDown( BUT_AUX2 ) )
547 {
549 }
550 else if( evt->Category() == TC_COMMAND && evt->Action() == TA_CHOICE_MENU_CHOICE )
551 {
552 m_disambiguateTimer.Stop();
553
554 // context sub-menu selection? Handle unit selection or bus unfolding
555 if( *evt->GetCommandId() >= ID_POPUP_SCH_SELECT_UNIT_CMP
556 && *evt->GetCommandId() <= ID_POPUP_SCH_SELECT_UNIT_SYM_MAX )
557 {
558 SCH_SYMBOL* symbol = dynamic_cast<SCH_SYMBOL*>( m_selection.Front() );
559 int unit = *evt->GetCommandId() - ID_POPUP_SCH_SELECT_UNIT_CMP;
560
561 if( symbol )
562 static_cast<SCH_EDIT_FRAME*>( m_frame )->SelectUnit( symbol, unit );
563 }
564 else if( *evt->GetCommandId() >= ID_POPUP_SCH_UNFOLD_BUS
565 && *evt->GetCommandId() <= ID_POPUP_SCH_UNFOLD_BUS_END )
566 {
567 wxString* net = new wxString( *evt->Parameter<wxString*>() );
569 }
570 }
571 else if( evt->IsCancelInteractive() )
572 {
573 m_disambiguateTimer.Stop();
574
575 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
576 schframe->FocusOnItem( nullptr );
577
578 if( !GetSelection().Empty() )
579 {
581 }
582 else if( evt->FirstResponder() == this && evt->GetCommandId() == (int) WXK_ESCAPE )
583 {
585
587 editor->ClearHighlight( *evt );
588 }
589 }
590 else if( evt->Action() == TA_UNDO_REDO_PRE )
591 {
592 if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( m_frame ) )
593 schframe->FocusOnItem( nullptr );
594
596 }
597 else if( evt->IsMotion() && !m_isSymbolEditor && evt->FirstResponder() == this )
598 {
599 // Update cursor and rollover item
600 rolloverItem = niluuid;
601 EE_COLLECTOR collector;
602
604
605 if( CollectHits( collector, evt->Position() ) )
606 {
607 narrowSelection( collector, evt->Position(), false );
608
609 if( collector.GetCount() == 1 && !hasModifier() )
610 {
611 OPT_TOOL_EVENT autostartEvt = autostartEvent( evt, grid, collector[0] );
612
613 if( autostartEvt )
614 {
615 if( autostartEvt->Matches( EE_ACTIONS::drawBus.MakeEvent() ) )
616 displayBusCursor = true;
617 else if( autostartEvt->Matches( EE_ACTIONS::drawWire.MakeEvent() ) )
618 displayWireCursor = true;
619 else if( autostartEvt->Matches( EE_ACTIONS::drawLines.MakeEvent() ) )
620 displayLineCursor = true;
621 }
622 else if( collector[0]->IsHypertext() && !collector[0]->IsSelected() )
623 {
624 rolloverItem = collector[0]->m_Uuid;
625 }
626 }
627 }
628 }
629 else
630 {
631 evt->SetPassEvent();
632 }
633
634 if( rolloverItem != lastRolloverItem )
635 {
636 if( EDA_ITEM* item = m_frame->GetItem( lastRolloverItem ) )
637 {
638 item->ClearFlags( IS_ROLLOVER );
639 lastRolloverItem = niluuid;
640
641 if( item->Type() == SCH_FIELD_T )
642 m_frame->GetCanvas()->GetView()->Update( item->GetParent() );
643 else
644 m_frame->GetCanvas()->GetView()->Update( item );
645 }
646 }
647
648 if( EDA_ITEM* item = m_frame->GetItem( rolloverItem ) )
649 {
650 if( !( item->GetFlags() & IS_ROLLOVER ) )
651 {
652 item->SetFlags( IS_ROLLOVER );
653 lastRolloverItem = rolloverItem;
654
655 if( item->Type() == SCH_FIELD_T )
656 m_frame->GetCanvas()->GetView()->Update( item->GetParent() );
657 else
658 m_frame->GetCanvas()->GetView()->Update( item );
659 }
660 }
661
663 {
664 if( displayWireCursor )
665 {
667 }
668 else if( displayBusCursor )
669 {
671 }
672 else if( displayLineCursor )
673 {
675 }
676 else if( rolloverItem != niluuid )
677 {
679 }
680 else if( !m_selection.Empty()
681 && drag_action == MOUSE_DRAG_ACTION::DRAG_SELECTED
682 && evt->HasPosition()
683 && selectionContains( evt->Position() ) ) //move/drag option prediction
684 {
686 }
687 else
688 {
690 }
691 }
692 }
693
694 m_disambiguateTimer.Stop();
695
696 // Shutting down; clear the selection
698
699 return 0;
700}
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:139
void ClearFlags(EDA_ITEM_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: eda_item.h:141
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:142
static TOOL_ACTION properties
Definition: ee_actions.h:128
static TOOL_ACTION navigateForward
Definition: ee_actions.h:201
static TOOL_ACTION navigateBack
Definition: ee_actions.h:202
static TOOL_ACTION unfoldBus
Definition: ee_actions.h:83
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:48
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.
bool hasModifier()
True if a selection modifier is enabled, false otherwise.
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 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, SELECTION_TOOL::hasModifier(), 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, 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 843 of file ee_selection_tool.cpp.

845{
846 for( int i = collector.GetCount() - 1; i >= 0; --i )
847 {
848 if( !Selectable( collector[i], &aWhere ) )
849 {
850 collector.Remove( i );
851 continue;
852 }
853
854 if( aCheckLocked && collector[i]->IsLocked() )
855 {
856 collector.Remove( i );
857 continue;
858 }
859
860 if( aSelectedOnly && !collector[i]->IsSelected() )
861 {
862 collector.Remove( i );
863 continue;
864 }
865 }
866
867 // Apply some ugly heuristics to avoid disambiguation menus whenever possible
868 if( collector.GetCount() > 1 && !m_skip_heuristics )
869 GuessSelectionCandidates( collector, aWhere );
870}
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 219 of file selection_tool.cpp.

220{
221 // If there is a multiple selection then it's more likely that we're seeing a paused drag
222 // than a long-click.
223 if( selection().GetSize() >= 2 && !hasModifier() )
224 return;
225
226 // If another tool has since started running then we don't want to interrupt
227 if( !getEditFrame<EDA_DRAW_FRAME>()->ToolStackIsEmpty() )
228 return;
229
231}
static const TOOL_EVENT DisambiguatePoint
Definition: actions.h:223

References EVENTS::DisambiguatePoint, SELECTION_TOOL::hasModifier(), 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 774 of file ee_selection_tool.cpp.

775{
777 {
778 wxMouseState keyboardState = wxGetMouseState();
779
780 setModifiersState( keyboardState.ShiftDown(), keyboardState.ControlDown(),
781 keyboardState.AltDown() );
782
783 if( m_additive )
785 else if( m_subtractive )
787 else if( m_exclusive_or )
789 else
791 }
792}

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

1740{
1742
1743 if( m_isSymbolEditor )
1744 {
1745 LIB_SYMBOL* start = static_cast<SYMBOL_EDIT_FRAME*>( m_frame )->GetCurSymbol();
1746
1747 for( LIB_ITEM& item : start->GetDrawItems() )
1748 {
1749 if( item.IsSelected() )
1750 select( &item );
1751 }
1752 }
1753 else
1754 {
1755 for( SCH_ITEM* item : m_frame->GetScreen()->Items() )
1756 {
1757 // If the field and symbol are selected, only use the symbol
1758 if( item->IsSelected() )
1759 {
1760 select( item );
1761 }
1762 else
1763 {
1764 item->RunOnChildren(
1765 [&]( SCH_ITEM* aChild )
1766 {
1767 if( aChild->IsSelected() )
1768 select( aChild );
1769 } );
1770 }
1771 }
1772 }
1773
1775
1776 // Inform other potentially interested tools
1778}
bool IsSelected() const
Definition: eda_item.h:106
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:109

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

159{
160 if( aItem )
161 {
162 unselect( aItem );
163
164 // Inform other potentially interested tools
165 if( !aQuietMode )
167 }
168}
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:207
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 179 of file selection_tool.cpp.

180{
181 if( aList )
182 {
183 for( EDA_ITEM* item : *aList )
184 unselect( item );
185
186 // Inform other potentially interested tools
187 if( !aQuietMode )
189 }
190}

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

194{
195 EDA_ITEMS removeItems;
196
197 for( EDA_ITEM* item : selection() )
198 {
199 if( alg::contains( *aList, item->m_Uuid ) )
200 removeItems.push_back( item );
201 }
202
203 RemoveItemsFromSel( &removeItems, aQuietMode );
204}
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 1202 of file ee_selection_tool.cpp.

1203{
1204 if( m_selection.Empty() )
1205 {
1206 VECTOR2D cursorPos = getViewControls()->GetCursorPosition( true );
1207
1209 SelectPoint( cursorPos, aScanTypes );
1210 m_selection.SetIsHover( true );
1212 }
1213 else // Trim an existing selection by aFilterList
1214 {
1215 bool isMoving = false;
1216 bool anyUnselected = false;
1217
1218 for( int i = (int) m_selection.GetSize() - 1; i >= 0; --i )
1219 {
1220 EDA_ITEM* item = (EDA_ITEM*) m_selection.GetItem( i );
1221 isMoving |= static_cast<SCH_ITEM*>( item )->IsMoving();
1222
1223 if( !item->IsType( aScanTypes ) )
1224 {
1225 unselect( item );
1226 anyUnselected = true;
1227 }
1228 }
1229
1230 if( anyUnselected )
1232
1233 if( !isMoving )
1235 }
1236
1237 return m_selection;
1238}
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:181
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:75

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

Referenced by SCH_MOVE_TOOL::AlignElements(), SCH_EDIT_TOOL::AutoplaceFields(), SCH_EDIT_TOOL::BreakWire(), SCH_EDIT_TOOL::ChangeSymbols(), SCH_EDIT_TOOL::ChangeTextType(), SCH_EDIT_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 297 of file ee_selection_tool.cpp.

298{
299 m_frame = getEditFrame<SCH_BASE_FRAME>();
300
301 if( aReason == TOOL_BASE::MODEL_RELOAD )
302 {
303 // Remove pointers to the selected items from containers without changing their
304 // properties (as they are already deleted while a new sheet is loaded)
306 getView()->GetPainter()->GetSettings()->SetHighlight( false );
307
308 SYMBOL_EDIT_FRAME* symbolEditFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
309 SYMBOL_VIEWER_FRAME* symbolViewerFrame = dynamic_cast<SYMBOL_VIEWER_FRAME*>( m_frame );
310
311 if( symbolEditFrame )
312 {
313 m_isSymbolEditor = true;
314 m_unit = symbolEditFrame->GetUnit();
315 m_convert = symbolEditFrame->GetConvert();
316 }
317 else
318 {
319 m_isSymbolViewer = symbolViewerFrame != nullptr;
320 }
321 }
322 else
323 {
324 // Restore previous properties of selected items and remove them from containers
326 }
327
328 // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
330 getView()->Add( &m_selection );
331}
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 1871 of file ee_selection_tool.cpp.

1872{
1873 highlight( aItem, SELECTED, &m_selection );
1874}
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 1781 of file ee_selection_tool.cpp.

1783{
1784 // NOTE: in the future this is where Eeschema layer/itemtype visibility will be handled
1785
1786 SYMBOL_EDIT_FRAME* symEditFrame = dynamic_cast<SYMBOL_EDIT_FRAME*>( m_frame );
1787
1788 // Do not allow selection of anything except fields when the current symbol in the symbol
1789 // editor is a derived symbol.
1790 if( symEditFrame && symEditFrame->IsSymbolAlias() && aItem->Type() != LIB_FIELD_T )
1791 return false;
1792
1793 switch( aItem->Type() )
1794 {
1795 case SCH_PIN_T:
1796 {
1797 const SCH_PIN* pin = static_cast<const SCH_PIN*>( aItem );
1798
1799 if( !pin->IsVisible() && !m_frame->GetShowAllPins() )
1800 return false;
1801
1803 {
1804 // Pin anchors have to be allowed for auto-starting wires.
1805 if( aPos )
1806 {
1808
1809 if( pin->IsPointClickableAnchor( grid.BestSnapAnchor( *aPos, LAYER_CONNECTABLE ) ) )
1810 return true;
1811 }
1812
1813 return false;
1814 }
1815
1816 break;
1817 }
1818
1819 case LIB_SYMBOL_T: // In symbol_editor we do not want to select the symbol itself.
1820 return false;
1821
1822 case LIB_FIELD_T: // LIB_FIELD object can always be edited.
1823 break;
1824
1825 case LIB_SHAPE_T:
1826 case LIB_TEXT_T:
1827 case LIB_PIN_T:
1828 if( symEditFrame )
1829 {
1830 LIB_ITEM* lib_item = (LIB_ITEM*) aItem;
1831
1832 if( lib_item->GetUnit() && lib_item->GetUnit() != symEditFrame->GetUnit() )
1833 return false;
1834
1835 if( lib_item->GetConvert() && lib_item->GetConvert() != symEditFrame->GetConvert() )
1836 return false;
1837 }
1838
1839 break;
1840
1841 case SCH_MARKER_T: // Always selectable
1842 return true;
1843
1844 default: // Suppress warnings
1845 break;
1846 }
1847
1848 return true;
1849}
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:198
@ SCH_MARKER_T
Definition: typeinfo.h:141

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

994{
995 m_multiple = true; // Multiple selection mode is active
996 KIGFX::VIEW* view = getView();
997
998 // hold all visible items
999 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> selectedItems;
1000 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> sheetPins;
1001
1002 // Filter the view items based on the selection box
1003 BOX2I selectionBox;
1004
1005 selectionBox.SetMaximum();
1006 view->Query( selectionBox, selectedItems ); // Get the list of selected items
1007
1008 // Sheet pins aren't in the view; add them by hand
1009 for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : selectedItems )
1010 {
1011 SCH_SHEET* sheet = dynamic_cast<SCH_SHEET*>( pair.first );
1012
1013 if( sheet )
1014 {
1015 int layer = pair.second;
1016
1017 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
1018 sheetPins.emplace_back( KIGFX::VIEW::LAYER_ITEM_PAIR( pin, layer ) );
1019 }
1020 }
1021
1022 selectedItems.insert( selectedItems.end(), sheetPins.begin(), sheetPins.end() );
1023
1024 for( const std::pair<KIGFX::VIEW_ITEM*, int>& item_pair : selectedItems )
1025 {
1026 if( EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( item_pair.first ) )
1027 {
1028 if( Selectable( item ) )
1029 {
1030 if( item->Type() == SCH_LINE_T )
1031 item->SetFlags( STARTPOINT | ENDPOINT );
1032
1033 select( item );
1034 }
1035 }
1036 }
1037
1038 m_multiple = false;
1039
1041
1042 return 0;
1043}
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:425
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:57
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:175
#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, TOOL_BASE::m_toolMgr, pin, TOOL_MANAGER::ProcessEvent(), KIGFX::VIEW::Query(), SCH_LINE_T, select(), Selectable(), EVENTS::SelectedEvent, 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 1541 of file ee_selection_tool.cpp.

1542{
1544
1545 if( m_selection.Empty() )
1546 return 0;
1547
1548 SCH_LINE* line = (SCH_LINE*) m_selection.Front();
1549 unsigned done = false;
1550
1552 std::set<SCH_ITEM*> conns = m_frame->GetScreen()->MarkConnections( line, false );
1553
1554 for( SCH_ITEM* item : conns )
1555 {
1556 if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } )
1557 && !item->IsSelected() )
1558 {
1559 done = true;
1560 }
1561
1562 select( item );
1563 }
1564
1565 if( !done )
1566 {
1567 conns = m_frame->GetScreen()->MarkConnections( line, true );
1568
1569 for( SCH_ITEM* item : conns )
1570 select( item );
1571 }
1572
1573 if( m_selection.GetSize() > 1 )
1575
1576 return 0;
1577}
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:357

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

183{ 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 1954 of file ee_selection_tool.cpp.

1955{
1956 const unsigned GRIP_MARGIN = 20;
1957 double margin = getView()->ToWorld( GRIP_MARGIN );
1958
1959 // Check if the point is located within any of the currently selected items bounding boxes
1960 for( EDA_ITEM* item : m_selection )
1961 {
1962 BOX2I itemBox = item->ViewBBox();
1963 itemBox.Inflate( margin ); // Give some margin for gripping an item
1964
1965 if( itemBox.Contains( aPoint ) )
1966 return true;
1967 }
1968
1969 return false;
1970}
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:448

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

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

235{
236 COLLECTOR* collector = aEvent.Parameter<COLLECTOR*>();
237
238 if( !doSelectionMenu( collector ) )
239 collector->m_MenuCancelled = true;
240
241 return 0;
242}
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 1270 of file ee_selection_tool.cpp.

1271{
1272 bool cancelled = false; // Was the tool canceled while it was running?
1273 m_multiple = true; // Multiple selection mode is active
1274 KIGFX::VIEW* view = getView();
1275
1277 view->Add( &area );
1278
1279 while( TOOL_EVENT* evt = Wait() )
1280 {
1281 int width = area.GetEnd().x - area.GetOrigin().x;
1282 int height = area.GetEnd().y - area.GetOrigin().y;
1283
1284 /* Selection mode depends on direction of drag-selection:
1285 * Left > Right : Select objects that are fully enclosed by selection
1286 * Right > Left : Select objects that are crossed by selection
1287 */
1288 bool isGreedy = width < 0;
1289
1290 if( view->IsMirroredX() )
1291 isGreedy = !isGreedy;
1292
1295
1296 if( evt->IsCancelInteractive() || evt->IsActivate() )
1297 {
1298 cancelled = true;
1299 break;
1300 }
1301
1302 if( evt->IsDrag( BUT_LEFT ) )
1303 {
1306
1307 // Start drawing a selection box
1308 area.SetOrigin( evt->DragOrigin() );
1309 area.SetEnd( evt->Position() );
1312 area.SetExclusiveOr( false );
1313
1314 view->SetVisible( &area, true );
1315 view->Update( &area );
1316 getViewControls()->SetAutoPan( true );
1317 }
1318
1319 if( evt->IsMouseUp( BUT_LEFT ) )
1320 {
1321 getViewControls()->SetAutoPan( false );
1322
1323 // End drawing the selection box
1324 view->SetVisible( &area, false );
1325
1326 // Fetch items from the RTree that are in our area of interest
1327 std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> nearbyViewItems;
1328 view->Query( area.ViewBBox(), nearbyViewItems );
1329
1330 // Build lists of nearby items and their children
1331 std::unordered_set<EDA_ITEM*> nearbyItems;
1332 std::vector<EDA_ITEM*> nearbyChildren;
1333 std::vector<EDA_ITEM*> flaggedItems;
1334
1335 for( KIGFX::VIEW::LAYER_ITEM_PAIR& pair : nearbyViewItems )
1336 {
1337 if( EDA_ITEM* item = dynamic_cast<EDA_ITEM*>( pair.first ) )
1338 {
1339 if( nearbyItems.insert( item ).second )
1340 {
1341 item->ClearFlags( CANDIDATE );
1342
1343 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( item ) )
1344 {
1345 sch_item->RunOnChildren(
1346 [&]( SCH_ITEM* aChild )
1347 {
1348 // Filter pins by unit
1349 if( SCH_PIN* pin = dyn_cast<SCH_PIN*>( aChild ) )
1350 {
1351 int unit = pin->GetLibPin()->GetUnit();
1352
1353 if( unit && unit != pin->GetParentSymbol()->GetUnit() )
1354 return;
1355 }
1356
1357 nearbyChildren.push_back( aChild );
1358 } );
1359 }
1360 }
1361 }
1362 }
1363
1364 BOX2I selectionRect( area.GetOrigin(), VECTOR2I( width, height ) );
1365 selectionRect.Normalize();
1366
1367 bool anyAdded = false;
1368 bool anySubtracted = false;
1369
1370 auto selectItem =
1371 [&]( EDA_ITEM* aItem, EDA_ITEM_FLAGS flags )
1372 {
1373 if( m_subtractive || ( m_exclusive_or && aItem->IsSelected() ) )
1374 {
1375 if ( m_exclusive_or )
1376 aItem->XorFlags( flags );
1377 else
1378 aItem->ClearFlags( flags );
1379
1380 if( !aItem->HasFlag( STARTPOINT ) && !aItem->HasFlag( ENDPOINT ) )
1381 {
1382 unselect( aItem );
1383 anySubtracted = true;
1384 }
1385
1386 // We changed one line endpoint on a selected line,
1387 // update the view at least.
1388 if( flags && !anySubtracted )
1389 {
1390 getView()->Update( aItem );
1391 }
1392 }
1393 else
1394 {
1395 aItem->SetFlags( flags );
1396 select( aItem );
1397 anyAdded = true;
1398 }
1399 };
1400
1401 for( EDA_ITEM* item : nearbyItems )
1402 {
1403 bool selected = false;
1404 EDA_ITEM_FLAGS flags = 0;
1405
1407 item->SetFlags( SHOW_ELEC_TYPE );
1408
1409 if( Selectable( item ) )
1410 {
1411 if( item->Type() == SCH_LINE_T )
1412 {
1413 SCH_LINE* line = static_cast<SCH_LINE*>( item );
1414
1415 if( ( isGreedy && line->HitTest( selectionRect, false ) )
1416 || ( selectionRect.Contains( line->GetEndPoint() )
1417 && selectionRect.Contains( line->GetStartPoint() ) ) )
1418 {
1419 selected = true;
1420 flags |= STARTPOINT | ENDPOINT;
1421 }
1422 else if( !isGreedy )
1423 {
1424 if( selectionRect.Contains( line->GetStartPoint() )
1425 && line->IsStartDangling() )
1426 {
1427 selected = true;
1428 flags |= STARTPOINT;
1429 }
1430
1431 if( selectionRect.Contains( line->GetEndPoint() )
1432 && line->IsEndDangling() )
1433 {
1434 selected = true;
1435 flags |= ENDPOINT;
1436 }
1437 }
1438 }
1439 else
1440 {
1441 selected = item->HitTest( selectionRect, !isGreedy );
1442 }
1443 }
1444
1445 if( selected )
1446 {
1447 item->SetFlags( CANDIDATE );
1448 flaggedItems.push_back( item );
1449 selectItem( item, flags );
1450 }
1451
1452 item->ClearFlags( SHOW_ELEC_TYPE );
1453 }
1454
1455 for( EDA_ITEM* item : nearbyChildren )
1456 {
1458 item->SetFlags( SHOW_ELEC_TYPE );
1459
1460 if( Selectable( item )
1461 && !item->GetParent()->HasFlag( CANDIDATE )
1462 && item->HitTest( selectionRect, !isGreedy ) )
1463 {
1464 selectItem( item, 0 );
1465 }
1466
1467 item->ClearFlags( SHOW_ELEC_TYPE );
1468 }
1469
1470 for( EDA_ITEM* item : flaggedItems )
1471 item->ClearFlags( CANDIDATE );
1472
1473 m_selection.SetIsHover( false );
1474
1475 // Inform other potentially interested tools
1476 if( anyAdded )
1478
1479 if( anySubtracted )
1481
1482 break; // Stop waiting for events
1483 }
1484
1485 // Allow some actions for navigation
1486 for( int i = 0; allowedActions[i]; ++i )
1487 {
1488 if( evt->IsAction( allowedActions[i] ) )
1489 {
1490 evt->SetPassEvent();
1491 break;
1492 }
1493 }
1494 }
1495
1496 getViewControls()->SetAutoPan( false );
1497
1498 // Stop drawing the selection box
1499 view->Remove( &area );
1500 m_multiple = false; // Multiple selection mode is inactive
1501
1502 if( !cancelled )
1504
1505 return cancelled;
1506}
bool HasFlag(EDA_ITEM_FLAGS aFlag) const
Definition: eda_item.h:143
void XorFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:140
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:1529
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_line.cpp:776
bool IsStartDangling() const
Definition: sch_line.h:257
bool IsEndDangling() const
Definition: sch_line.h:258
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, EDA_ITEM::ClearFlags(), SELECTION::ClearReferencePoint(), ClearSelection(), BOX2< Vec >::Contains(), ENDPOINT, SCH_BASE_FRAME::GetCanvas(), KIGFX::PREVIEW::SELECTION_AREA::GetEnd(), SCH_LINE::GetEndPoint(), KIGFX::PREVIEW::SELECTION_AREA::GetOrigin(), SCH_BASE_FRAME::GetRenderSettings(), SCH_LINE::GetStartPoint(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), EDA_ITEM::HasFlag(), SCH_LINE::HitTest(), SCH_LINE::IsEndDangling(), KIGFX::VIEW::IsMirroredX(), EDA_ITEM::IsSelected(), SCH_LINE::IsStartDangling(), 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(), EDA_ITEM::SetFlags(), 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, EDA_ITEM::XorFlags(), 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 1531 of file ee_selection_tool.cpp.

1532{
1533 VECTOR2I cursorPos = getViewControls()->GetCursorPosition( false );
1534
1535 SelectPoint( cursorPos, connectedTypes );
1536
1537 return 0;
1538}

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

980{
981 EE_COLLECTOR collector;
982
983 if( !CollectHits( collector, aWhere, aScanTypes ) )
984 return false;
985
986 narrowSelection( collector, aWhere, aCheckLocked, aSubtract );
987
988 return selectPoint( collector, aWhere, aItem, aSelectionCancelledFlag, aAdd, aSubtract,
989 aExclusiveOr );
990}

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

876{
878
879 // If still more than one item we're going to have to ask the user.
880 if( aCollector.GetCount() > 1 )
881 {
882 // Try to call selectionMenu via RunAction() to avoid event-loop contention
883 // But it we cannot handle the event, then we don't have an active tool loop, so
884 // handle it directly.
885 if( !m_toolMgr->RunAction( EE_ACTIONS::selectionMenu, true, &aCollector ) )
886 {
887 if( !doSelectionMenu( &aCollector ) )
888 aCollector.m_MenuCancelled = true;
889 }
890
891 if( aCollector.m_MenuCancelled )
892 {
893 if( aSelectionCancelledFlag )
894 *aSelectionCancelledFlag = true;
895
896 return false;
897 }
898 }
899
900 if( !aAdd && !aSubtract && !aExclusiveOr )
902
903 int addedCount = 0;
904 bool anySubtracted = false;
905
906 if( aCollector.GetCount() > 0 )
907 {
908 for( int i = 0; i < aCollector.GetCount(); ++i )
909 {
910 EDA_ITEM_FLAGS flags = 0;
911 bool isLine = aCollector[i]->Type() == SCH_LINE_T;
912
913 // Handle line ends specially
914 if( isLine )
915 {
916 SCH_LINE* line = (SCH_LINE*) aCollector[i];
917
918 if( HitTestPoints( line->GetStartPoint(), aWhere, aCollector.m_Threshold ) )
919 flags = STARTPOINT;
920 else if( HitTestPoints( line->GetEndPoint(), aWhere, aCollector.m_Threshold ) )
921 flags = ENDPOINT;
922 else
923 flags = STARTPOINT | ENDPOINT;
924 }
925
926 if( aSubtract
927 || ( aExclusiveOr && aCollector[i]->IsSelected()
928 && ( !isLine || ( isLine && aCollector[i]->HasFlag( flags ) ) ) ) )
929 {
930 aCollector[i]->ClearFlags( flags );
931
932 // Need to update end shadows after ctrl-click unselecting one of two selected endpoints
933 if( isLine )
934 getView()->Update( aCollector[i] );
935
936 if( !aCollector[i]->HasFlag( STARTPOINT ) && !aCollector[i]->HasFlag( ENDPOINT ) )
937 {
938 unselect( aCollector[i] );
939 anySubtracted = true;
940 }
941 }
942 else
943 {
944 aCollector[i]->SetFlags( flags );
945 select( aCollector[i] );
946 addedCount++;
947 }
948 }
949 }
950
951 if( addedCount == 1 )
952 {
954
955 if( aItem && aCollector.GetCount() == 1 )
956 *aItem = aCollector[0];
957
958 return true;
959 }
960 else if( addedCount > 1 )
961 {
963 return true;
964 }
965 else if( anySubtracted )
966 {
968 return true;
969 }
970
971 return false;
972}
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:205
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(), TOOL_BASE::getView(), 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(), EVENTS::UnselectedEvent, and KIGFX::VIEW::Update().

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

1974{
1976
1981
1987
1989
1991}
static TOOL_ACTION updateMenu
Definition: actions.h:171
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 1696 of file ee_selection_tool.cpp.

1698{
1699 SCH_EDIT_FRAME* editFrame = dynamic_cast<SCH_EDIT_FRAME*>( m_frame );
1700
1701 if( !editFrame || m_isSymbolEditor || m_isSymbolViewer )
1702 return 0;
1703
1704 if( targetSheetPath && targetSheetPath != editFrame->Schematic().CurrentSheet() )
1705 {
1706 editFrame->Schematic().SetCurrentSheet( *targetSheetPath );
1707 editFrame->DisplayCurrentSheet();
1708 }
1709
1710 ClearSelection( items.size() > 0 ? true /*quiet mode*/ : false );
1711
1712 // Perform individual selection of each item before processing the event.
1713 for( SCH_ITEM* item : items )
1714 select( item );
1715
1717
1718 if( bbox.GetWidth() != 0 && bbox.GetHeight() != 0 )
1719 {
1721 {
1723 ZoomFitCrossProbeBBox( bbox );
1724
1725 editFrame->FocusOnItem( focusItem );
1726
1727 if( !focusItem )
1728 editFrame->FocusOnLocation( bbox.Centre() );
1729 }
1730 }
1731
1732 if( m_selection.Size() > 0 )
1734
1735 return 0;
1736}
CROSS_PROBING_SETTINGS m_CrossProbing
Definition: app_settings.h:173
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:120
void SetCurrentSheet(const SCH_SHEET_PATH &aPath) override
Definition: schematic.h:125
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:115
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 1916 of file ee_selection_tool.cpp.

1917{
1918 KICAD_T itemType = aItem->Type();
1919
1920 if( aMode == SELECTED )
1921 {
1922 aItem->ClearSelected();
1923 // Lines need endpoints cleared here
1924 if( aItem->Type() == SCH_LINE_T )
1925 aItem->ClearFlags( STARTPOINT | ENDPOINT );
1926 }
1927 else if( aMode == BRIGHTENED )
1928 aItem->ClearBrightened();
1929
1930 if( aGroup )
1931 aGroup->Remove( aItem );
1932
1933 // Unhighlight pins and fields. (All the other symbol children are currently only
1934 // represented in the LIB_SYMBOL.)
1935 if( SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( aItem ) )
1936 {
1937 sch_item->RunOnChildren(
1938 [&]( SCH_ITEM* aChild )
1939 {
1940 if( aMode == SELECTED )
1941 aChild->ClearSelected();
1942 else if( aMode == BRIGHTENED )
1943 aChild->ClearBrightened();
1944 } );
1945 }
1946
1947 if( itemType == SCH_PIN_T || itemType == SCH_FIELD_T || itemType == SCH_SHEET_PIN_T )
1948 getView()->Update( aItem->GetParent() );
1949 else
1950 getView()->Update( aItem );
1951}
void ClearSelected()
Definition: eda_item.h:118
void ClearBrightened()
Definition: eda_item.h:119
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.cpp:60

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

1878{
1879 unhighlight( aItem, SELECTED, &m_selection );
1880}

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

93{
94 ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
95 CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
96
97 if( conditionalMenu )
98 conditionalMenu->Evaluate( selection() );
99
100 if( actionMenu )
101 actionMenu->UpdateAll();
102
103 return 0;
104}
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 1241 of file ee_selection_tool.cpp.

1242{
1243 VECTOR2I refP( 0, 0 );
1244
1245 if( m_selection.Size() > 0 )
1246 {
1247 if( m_isSymbolEditor )
1248 refP = static_cast<LIB_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
1249 else
1250 refP = static_cast<SCH_ITEM*>( m_selection.GetTopLeftItem() )->GetPosition();
1251 }
1252
1254}
EDA_ITEM * GetTopLeftItem(bool onlyModules=false) const override
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:260

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(), 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 1588 of file ee_selection_tool.cpp.

1589{
1590 if( aBBox.GetWidth() == 0 )
1591 return;
1592
1593 BOX2I bbox = aBBox;
1594 bbox.Normalize();
1595
1596 VECTOR2I bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
1597 VECTOR2D screenSize = getView()->GetViewport().GetSize();
1598
1599 // This code tries to come up with a zoom factor that doesn't simply zoom in
1600 // to the cross probed symbol, but instead shows a reasonable amount of the
1601 // circuit around it to provide context. This reduces or eliminates the need
1602 // to manually change the zoom because it's too close.
1603
1604 // Using the default text height as a constant to compare against, use the
1605 // height of the bounding box of visible items for a footprint to figure out
1606 // if this is a big symbol (like a processor) or a small symbol (like a resistor).
1607 // This ratio is not useful by itself as a scaling factor. It must be "bent" to
1608 // provide good scaling at varying symbol sizes. Bigger symbols need less
1609 // scaling than small ones.
1610 double currTextHeight = schIUScale.MilsToIU( DEFAULT_TEXT_SIZE );
1611
1612 double compRatio = bbSize.y / currTextHeight; // Ratio of symbol to text height
1613 double compRatioBent = 1.0;
1614
1615 // LUT to scale zoom ratio to provide reasonable schematic context. Must work
1616 // with symbols of varying sizes (e.g. 0402 package and 200 pin BGA).
1617 // "first" is used as the input and "second" as the output
1618 //
1619 // "first" = compRatio (symbol height / default text height)
1620 // "second" = Amount to scale ratio by
1621 std::vector<std::pair<double, double>> lut{ { 1.25, 16 }, // 32
1622 { 2.5, 12 }, //24
1623 { 5, 8 }, // 16
1624 { 6, 6 }, //
1625 { 10, 4 }, //8
1626 { 20, 2 }, //4
1627 { 40, 1.5 }, // 2
1628 { 100, 1 } };
1629
1630 std::vector<std::pair<double, double>>::iterator it;
1631
1632 // Large symbol default is last LUT entry (1:1).
1633 compRatioBent = lut.back().second;
1634
1635 // Use LUT to do linear interpolation of "compRatio" within "first", then
1636 // use that result to linearly interpolate "second" which gives the scaling
1637 // factor needed.
1638 if( compRatio >= lut.front().first )
1639 {
1640 for( it = lut.begin(); it < lut.end() - 1; it++ )
1641 {
1642 if( it->first <= compRatio && next( it )->first >= compRatio )
1643 {
1644 double diffx = compRatio - it->first;
1645 double diffn = next( it )->first - it->first;
1646
1647 compRatioBent = it->second + ( next( it )->second - it->second ) * diffx / diffn;
1648 break; // We have our interpolated value
1649 }
1650 }
1651 }
1652 else
1653 {
1654 compRatioBent = lut.front().second; // Small symbol default is first entry
1655 }
1656
1657 // This is similar to the original KiCad code that scaled the zoom to make sure
1658 // symbols were visible on screen. It's simply a ratio of screen size to
1659 // symbol size, and its job is to zoom in to make the component fullscreen.
1660 // Earlier in the code the symbol BBox is given a 20% margin to add some
1661 // breathing room. We compare the height of this enlarged symbol bbox to the
1662 // default text height. If a symbol will end up with the sides clipped, we
1663 // adjust later to make sure it fits on screen.
1664 screenSize.x = std::max( 10.0, screenSize.x );
1665 screenSize.y = std::max( 10.0, screenSize.y );
1666 double ratio = std::max( -1.0, fabs( bbSize.y / screenSize.y ) );
1667
1668 // Original KiCad code for how much to scale the zoom
1669 double kicadRatio =
1670 std::max( fabs( bbSize.x / screenSize.x ), fabs( bbSize.y / screenSize.y ) );
1671
1672 // If the width of the part we're probing is bigger than what the screen width
1673 // will be after the zoom, then punt and use the KiCad zoom algorithm since it
1674 // guarantees the part's width will be encompassed within the screen.
1675 if( bbSize.x > screenSize.x * ratio * compRatioBent )
1676 {
1677 // Use standard KiCad zoom for parts too wide to fit on screen/
1678 ratio = kicadRatio;
1679 compRatioBent = 1.0; // Reset so we don't modify the "KiCad" ratio
1680 wxLogTrace( "CROSS_PROBE_SCALE",
1681 "Part TOO WIDE for screen. Using normal KiCad zoom ratio: %1.5f", ratio );
1682 }
1683
1684 // Now that "compRatioBent" holds our final scaling factor we apply it to the
1685 // original fullscreen zoom ratio to arrive at the final ratio itself.
1686 ratio *= compRatioBent;
1687
1688 bool alwaysZoom = false; // DEBUG - allows us to minimize zooming or not
1689
1690 // Try not to zoom on every cross-probe; it gets very noisy
1691 if( ( ratio < 0.5 || ratio > 1.0 ) || alwaysZoom )
1692 getView()->SetScale( getView()->GetScale() / ratio );
1693}
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:511
virtual void SetScale(double aScale, VECTOR2D aAnchor={ 0, 0 })
Set the scaling factor, zooming around a given anchor point.
Definition: view.cpp:551
#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 286 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 284 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

bool SELECTION_TOOL::m_multiple
protectedinherited

◆ m_nonModifiedCursor

KICURSOR EE_SELECTION_TOOL::m_nonModifiedCursor
private

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

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), 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(), EDIT_TOOL::DeleteItems(), 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(), PCB_SELECTION_TOOL::EnterGroup(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::ExitGroup(), 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(), 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(), EDIT_TOOL::rebuildConnectivity(), ZONE_FILLER_TOOL::rebuildConnectivity(), 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(), SelectAll(), PCB_SELECTION_TOOL::SelectAll(), 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_MOVE_TOOL::trimDanglingLines(), 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 214 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

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

Definition at line 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

◆ m_unit

int EE_SELECTION_TOOL::m_unit
private

Definition at line 285 of file ee_selection_tool.h.

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


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