KiCad PCB EDA Suite
GERBVIEW_SELECTION_TOOL Class Reference

Class GERBVIEW_SELECTION_TOOL. More...

#include <gerbview_selection_tool.h>

Inheritance diagram for GERBVIEW_SELECTION_TOOL:
TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 GERBVIEW_SELECTION_TOOL ()
 
 ~GERBVIEW_SELECTION_TOOL ()
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
int UpdateMenu (const TOOL_EVENT &aEvent)
 
int Main (const TOOL_EVENT &aEvent)
 Function Main() More...
 
GERBVIEW_SELECTIONGetSelection ()
 Function GetSelection() More...
 
int ClearSelection (const TOOL_EVENT &aEvent)
 
int SelectItem (const TOOL_EVENT &aEvent)
 
int SelectItems (const TOOL_EVENT &aEvent)
 
int UnselectItem (const TOOL_EVENT &aEvent)
 
int UnselectItems (const TOOL_EVENT &aEvent)
 
int MeasureTool (const TOOL_EVENT &aEvent)
 

Launches a tool to measure between points

More...
 
void setTransitions () override
 

Sets up handlers for various events.

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

Protected Member Functions

void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

TOOL_MENU m_menu
 functions below are not yet implemented - their interface may change More...
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

bool selectPoint (const VECTOR2I &aWhere, bool aOnDrag=false)
 Function selectPoint() Selects an item pointed by the parameter aWhere. More...
 
bool selectCursor (bool aSelectAlways=false)
 Function selectCursor() Selects an item under the cursor unless there is something already selected or aSelectAlways is true. More...
 
void clearSelection ()
 Function clearSelection() Clears the current selection. More...
 
EDA_ITEMdisambiguationMenu (GERBER_COLLECTOR *aItems)
 Function disambiguationMenu() Handles the menu that allows one to select one of many items in case there is more than one item at the selected point (. More...
 
bool selectable (const EDA_ITEM *aItem) const
 Function selectable() Checks conditions for an item to be selected. More...
 
void select (EDA_ITEM *aItem)
 Function select() Takes necessary action mark an item as selected. More...
 
void unselect (EDA_ITEM *aItem)
 Function unselect() Takes necessary action mark an item as unselected. More...
 
void selectVisually (EDA_ITEM *aItem)
 Function selectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST. More...
 
void unselectVisually (EDA_ITEM *aItem)
 Function unselectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST. More...
 

Private Attributes

GERBVIEW_FRAMEm_frame
 
GERBVIEW_SELECTION m_selection
 
bool m_additive
 
bool m_subtractive
 
bool m_exclusive_or
 
bool m_preliminary
 

Detailed Description

Class GERBVIEW_SELECTION_TOOL.

Selection tool for GerbView, based on the one in PcbNew

Definition at line 47 of file gerbview_selection_tool.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 79 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ GERBVIEW_SELECTION_TOOL()

GERBVIEW_SELECTION_TOOL::GERBVIEW_SELECTION_TOOL ( )

Definition at line 108 of file gerbview_selection_tool.cpp.

108  :
109  TOOL_INTERACTIVE( "gerbview.InteractiveSelection" ),
110  m_frame( NULL ),
111  m_additive( false ),
112  m_subtractive( false ),
113  m_exclusive_or( false )
114 {
115  m_preliminary = true;
116 }
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Constructor.

References m_preliminary.

◆ ~GERBVIEW_SELECTION_TOOL()

GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL ( )

Definition at line 134 of file gerbview_selection_tool.cpp.

135 {
136  getView()->Remove( &m_selection );
137 }
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36

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

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs 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:219
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls 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(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

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

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63  m_toolSettings = TOOL_SETTINGS( this );
64 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220
friend class TOOL_SETTINGS
Definition: tool_base.h:154

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

Referenced by TOOL_MANAGER::RegisterTool().

◆ ClearSelection()

int GERBVIEW_SELECTION_TOOL::ClearSelection ( const TOOL_EVENT aEvent)

Definition at line 329 of file gerbview_selection_tool.cpp.

330 {
331  clearSelection();
332 
333  return 0;
334 }
void clearSelection()
Function clearSelection() Clears the current selection.

References clearSelection().

Referenced by setTransitions().

◆ clearSelection()

void GERBVIEW_SELECTION_TOOL::clearSelection ( )
private

Function clearSelection() Clears the current selection.

Definition at line 405 of file gerbview_selection_tool.cpp.

406 {
407  if( m_selection.Empty() )
408  return;
409 
410  for( auto item : m_selection )
411  unselectVisually( static_cast<EDA_ITEM*>( item ) );
412 
413  m_selection.Clear();
414 
415  // Inform other potentially interested tools
417 }
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:93
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
static const TOOL_EVENT ClearedEvent
Definition: actions.h:199
void unselectVisually(EDA_ITEM *aItem)
Function unselectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119

References SELECTION::Clear(), EVENTS::ClearedEvent, SELECTION::Empty(), m_selection, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), and unselectVisually().

Referenced by ClearSelection(), Main(), Reset(), selectCursor(), and selectPoint().

◆ disambiguationMenu()

EDA_ITEM * GERBVIEW_SELECTION_TOOL::disambiguationMenu ( GERBER_COLLECTOR aItems)
private

Function disambiguationMenu() Handles the menu that allows one to select one of many items in case there is more than one item at the selected point (.

See also
selectCursor()).
Parameters
aItemscontains list of items that are displayed to the user.

Definition at line 420 of file gerbview_selection_tool.cpp.

421 {
422  EDA_ITEM* current = NULL;
423  KIGFX::VIEW_GROUP highlightGroup;
424  ACTION_MENU menu( true );
425 
426  highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
427  getView()->Add( &highlightGroup );
428 
429  int limit = std::min( 10, aCollector->GetCount() );
430 
431  for( int i = 0; i < limit; ++i )
432  {
433  wxString text;
434  EDA_ITEM* item = ( *aCollector )[i];
435  text = item->GetSelectMenuText( m_frame->GetUserUnits() );
436  menu.Add( text, i + 1, item->GetMenuImage() );
437  }
438 
439  menu.SetTitle( _( "Clarify selection" ) );
440  menu.SetIcon( info_xpm );
441  menu.DisplayTitle( true );
442  SetContextMenu( &menu, CMENU_NOW );
443 
444  while( TOOL_EVENT* evt = Wait() )
445  {
446  if( evt->Action() == TA_CHOICE_MENU_UPDATE )
447  {
448  if( current )
449  {
450  current->ClearBrightened();
451  getView()->Hide( current, false );
452  highlightGroup.Remove( current );
454  }
455 
456  int id = *evt->GetCommandId();
457 
458  // User has pointed an item, so show it in a different way
459  if( id > 0 && id <= limit )
460  {
461  current = ( *aCollector )[id - 1];
462  current->SetBrightened();
463  getView()->Hide( current, true );
464  highlightGroup.Add( current );
466  }
467  else
468  {
469  current = NULL;
470  }
471  }
472  else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
473  {
474  OPT<int> id = evt->GetCommandId();
475 
476  // User has selected an item, so this one will be returned
477  if( id && ( *id > 0 ) )
478  current = ( *aCollector )[*id - 1];
479  else
480  current = NULL;
481 
482  break;
483  }
484  }
485 
486  if( current && current->IsBrightened() )
487  {
488  current->ClearBrightened();
489  getView()->Hide( current, false );
491  }
492 
493  getView()->Remove( &highlightGroup );
494 
495  return current;
496 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1507
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Class ACTION_MENU.
Definition: action_menu.h:43
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
void SetBrightened()
Definition: base_struct.h:241
bool IsBrightened() const
Definition: base_struct.h:236
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
void ClearBrightened()
Definition: base_struct.h:245
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:585
Class TOOL_EVENT.
Definition: tool_event.h:171
Items that may change while the view stays the same (noncached)
Definition: definitions.h:50
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
#define _(s)
virtual void SetLayer(int aLayer)
Function SetLayer() Sets layer used to draw the group.
Definition: view_group.h:115
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
size_t i
Definition: json11.cpp:649
virtual wxString GetSelectMenuText(EDA_UNITS_T aUnits) const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
currently selected items overlay
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
boost::optional< T > OPT
Definition: optional.h:7
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
virtual BITMAP_DEF GetMenuImage() const
Function GetMenuImage returns a pointer to an image to be used in menus.
#define min(a, b)
Definition: auxiliary.h:85

References _, KIGFX::VIEW_GROUP::Add(), ACTION_MENU::Add(), KIGFX::VIEW::Add(), EDA_ITEM::ClearBrightened(), CMENU_NOW, ACTION_MENU::DisplayTitle(), COLLECTOR::GetCount(), EDA_ITEM::GetMenuImage(), EDA_ITEM::GetSelectMenuText(), EDA_BASE_FRAME::GetUserUnits(), TOOL_BASE::getView(), KIGFX::VIEW::Hide(), i, EDA_ITEM::IsBrightened(), LAYER_SELECT_OVERLAY, m_frame, KIGFX::VIEW::MarkTargetDirty(), min, KIGFX::VIEW_GROUP::Remove(), KIGFX::VIEW::Remove(), EDA_ITEM::SetBrightened(), TOOL_INTERACTIVE::SetContextMenu(), ACTION_MENU::SetIcon(), KIGFX::VIEW_GROUP::SetLayer(), ACTION_MENU::SetTitle(), TA_CHOICE_MENU_CHOICE, TA_CHOICE_MENU_UPDATE, KIGFX::TARGET_OVERLAY, and TOOL_INTERACTIVE::Wait().

Referenced by selectPoint().

◆ getEditFrame()

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

Function getEditFrame()

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

Definition at line 187 of file tool_base.h.

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

References TOOL_BASE::getEditFrameInt().

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

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 121 of file tool_base.h.

122  {
123  return m_toolId;
124  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:214

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(), and TOOL_MANAGER::saveViewControls().

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 143 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

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

◆ getModel()

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

202  {
203  EDA_ITEM* m = getModelInt();
204 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
205  wxASSERT( dynamic_cast<T*>( m ) );
206 #endif
207  return static_cast<T*>( m );
208  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:54
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 132 of file tool_base.h.

133  {
134  return m_toolName;
135  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:218

References TOOL_BASE::m_toolName.

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

◆ GetSelection()

GERBVIEW_SELECTION & GERBVIEW_SELECTION_TOOL::GetSelection ( )

Function GetSelection()

Returns the set of currently selected items.

Definition at line 246 of file gerbview_selection_tool.cpp.

247 {
248  return m_selection;
249 }

References m_selection.

Referenced by GERBVIEW_FRAME::Process_Special_Functions(), and GERBVIEW_CONTROL::UpdateMessagePanel().

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 78 of file tool_base.cpp.

79 {
80  return m_toolSettings;
81 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220

References TOOL_BASE::m_toolSettings.

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

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 110 of file tool_base.h.

111  {
112  return m_type;
113  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:211

References TOOL_BASE::m_type.

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

◆ getView()

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

Function getView()

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

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), COMMON_TOOLS::GridPreset(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), select(), selectable(), SELECTION_TOOL::Selectable(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), selectVisually(), PL_EDITOR_CONTROL::ToggleBackgroundColor(), COMMON_TOOLS::ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), unselect(), unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), ~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), COMMON_TOOLS::GridPreset(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), MODULE_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), Main(), ROUTER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), selectCursor(), SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCBNEW_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), LIB_MOVE_TOOL::updateModificationPoint(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

Function Go()

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

Definition at line 129 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), COMMON_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_POINT_EDITOR::setTransitions(), LIB_MOVE_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), POINT_EDITOR::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), setTransitions(), COMMON_TOOLS::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), EE_SELECTION_TOOL::setTransitions(), and DRC::setTransitions().

◆ Init()

bool GERBVIEW_SELECTION_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from TOOL_BASE.

Definition at line 140 of file gerbview_selection_tool.cpp.

141 {
142  auto selectMenu = std::make_shared<HIGHLIGHT_MENU>();
143  selectMenu->SetTool( this );
144  m_menu.AddSubMenu( selectMenu );
145 
146  auto& menu = m_menu.GetMenu();
147 
148  menu.AddMenu( selectMenu.get() );
149  menu.AddSeparator( 1000 );
150 
151  getEditFrame<GERBVIEW_FRAME>()->AddStandardSubMenus( m_menu );
152 
153  return true;
154 }
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddMenu()
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
void AddSubMenu(std::shared_ptr< ACTION_MENU > aSubMenu)
Function CreateSubMenu.
Definition: tool_menu.cpp:52

References CONDITIONAL_MENU::AddMenu(), TOOL_MENU::AddSubMenu(), TOOL_MENU::GetMenu(), and TOOL_INTERACTIVE::m_menu.

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

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

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

◆ Main()

int GERBVIEW_SELECTION_TOOL::Main ( const TOOL_EVENT aEvent)

Function Main()

The main loop.

Definition at line 180 of file gerbview_selection_tool.cpp.

181 {
182  // Main loop: keep receiving events
183  while( TOOL_EVENT* evt = Wait() )
184  {
185  if( m_frame->ToolStackIsEmpty() )
186  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
187 
189 
190  if( evt->Modifier( MD_SHIFT ) && evt->Modifier( MD_CTRL ) )
191  m_subtractive = true;
192  else if( evt->Modifier( MD_SHIFT ) )
193  m_additive = true;
194  else if( evt->Modifier( MD_CTRL ) )
195  m_exclusive_or = true;
196 
197  // This is kind of hacky: activate RMB drag on any event.
198  // There doesn't seem to be any other good way to tell when another tool
199  // is canceled and control returns to the selection tool, except by the
200  // fact that the selection tool starts to get events again.
202  {
203  getViewControls()->SetAdditionalPanButtons( false, true );
204  }
205 
206  // Disable RMB pan for other tools; they can re-enable if desired
207  if( evt->IsActivate() )
208  {
209  getViewControls()->SetAdditionalPanButtons( false, false );
210  }
211 
212  // single click? Select single object
213  if( evt->IsClick( BUT_LEFT ) )
214  {
215  selectPoint( evt->Position() );
216  }
217 
218  // right click? if there is any object - show the context menu
219  else if( evt->IsClick( BUT_RIGHT ) )
220  {
221  if( m_selection.Empty() )
222  {
223  selectPoint( evt->Position() );
224  m_selection.SetIsHover( true );
225  }
226 
228  }
229 
230  else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
231  {
232  clearSelection();
233  }
234 
235  else
236  evt->SetPassEvent();
237  }
238 
239  // This tool is supposed to be active forever
240  assert( false );
241 
242  return 0;
243 }
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetIsHover(bool aIsHover)
Definition: selection.h:64
Class TOOL_EVENT.
Definition: tool_event.h:171
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
void SetAdditionalPanButtons(bool aLeft=false, bool aRight=false)
bool ToolStackIsEmpty()
void clearSelection()
Function clearSelection() Clears the current selection.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
bool IsCurrentTool(const TOOL_ACTION &aAction) const
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION selectionTool
Definition: actions.h:143

References BUT_LEFT, BUT_RIGHT, clearSelection(), SELECTION::Empty(), EDA_DRAW_FRAME::GetCanvas(), TOOL_BASE::getViewControls(), EDA_BASE_FRAME::IsCurrentTool(), m_additive, m_exclusive_or, m_frame, TOOL_INTERACTIVE::m_menu, m_selection, m_subtractive, MD_CTRL, MD_SHIFT, ACTIONS::selectionTool, selectPoint(), KIGFX::VIEW_CONTROLS::SetAdditionalPanButtons(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), SELECTION::SetIsHover(), TOOL_MENU::ShowContextMenu(), TA_UNDO_REDO_PRE, EDA_BASE_FRAME::ToolStackIsEmpty(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ MeasureTool()

int GERBVIEW_SELECTION_TOOL::MeasureTool ( const TOOL_EVENT aEvent)

Launches a tool to measure between points

Definition at line 571 of file gerbview_selection_tool.cpp.

572 {
573  auto& view = *getView();
574  auto& controls = *getViewControls();
575  auto previous_settings = controls.GetSettings();
576 
577  std::string tool = aEvent.GetCommandStr().get();
578  m_frame->PushTool( tool );
579  Activate();
580 
582  KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() );
583 
584  view.Add( &ruler );
585  view.SetVisible( &ruler, false );
586 
587  bool originSet = false;
588 
589  controls.ShowCursor( true );
590  controls.SetSnapping( true );
591  controls.SetAdditionalPanButtons( false, true );
592 
593  while( TOOL_EVENT* evt = Wait() )
594  {
595  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
596  const VECTOR2I cursorPos = controls.GetCursorPosition();
597 
598  auto clearRuler = [&] () {
599  view.SetVisible( &ruler, false );
600  controls.SetAutoPan( false );
601  controls.CaptureCursor( false );
602  originSet = false;
603  };
604 
605  if( evt->IsCancelInteractive() )
606  {
607  if( originSet )
608  clearRuler();
609  else
610  {
611  m_frame->PopTool( tool );
612  break;
613  }
614  }
615 
616  else if( evt->IsActivate() )
617  {
618  if( originSet )
619  clearRuler();
620 
621  if( evt->IsMoveTool() )
622  {
623  // leave ourselves on the stack so we come back after the move
624  break;
625  }
626  else
627  {
628  m_frame->PopTool( tool );
629  break;
630  }
631  }
632 
633  // click or drag starts
634  else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
635  {
636  if( !evt->IsDrag( BUT_LEFT ) )
637  {
638  twoPtMgr.SetOrigin( cursorPos );
639  twoPtMgr.SetEnd( cursorPos );
640  }
641 
642  controls.CaptureCursor( true );
643  controls.SetAutoPan( true );
644 
645  originSet = true;
646  }
647 
648  else if( !originSet && evt->IsMotion() )
649  {
650  // make sure the origin is set before a drag starts
651  // otherwise you can miss a step
652  twoPtMgr.SetOrigin( cursorPos );
653  twoPtMgr.SetEnd( cursorPos );
654  }
655 
656  // second click or mouse up after drag ends
657  else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
658  {
659  originSet = false;
660 
661  controls.SetAutoPan( false );
662  controls.CaptureCursor( false );
663 
664  view.SetVisible( &ruler, false );
665  }
666 
667  // move or drag when origin set updates rules
668  else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
669  {
670  twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) );
671  twoPtMgr.SetEnd( cursorPos );
672 
673  view.SetVisible( &ruler, true );
674  view.Update( &ruler, KIGFX::GEOMETRY );
675  }
676 
677  else if( evt->IsClick( BUT_RIGHT ) )
678  {
680  }
681 
682  else
683  evt->SetPassEvent();
684  }
685 
686  view.SetVisible( &ruler, false );
687  view.Remove( &ruler );
688  controls.ApplySettings( previous_settings );
689  return 0;
690 }
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
virtual EDA_DRAW_PANEL_GAL * GetCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Class TOOL_EVENT.
Definition: tool_event.h:171
void SetOrigin(const VECTOR2I &aOrigin)
Set the origin of the ruler (the fixed end)
Class RULER_ITEM.
Definition: ruler_item.h:43
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
virtual void PopTool(const std::string &actionName)
void Activate()
Function Activate() Runs the tool.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
void SetEnd(const VECTOR2I &aEnd)
Set the current end of the rectangle (the end that moves with the cursor.
Color has changed.
Definition: view_item.h:57

References TOOL_INTERACTIVE::Activate(), BUT_LEFT, BUT_RIGHT, KIGFX::GEOMETRY, EDA_DRAW_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), EDA_BASE_FRAME::GetUserUnits(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), m_frame, TOOL_INTERACTIVE::m_menu, m_selection, MD_CTRL, EDA_BASE_FRAME::PopTool(), EDA_BASE_FRAME::PushTool(), KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetAngleSnap(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetEnd(), KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER::SetOrigin(), TOOL_MENU::ShowContextMenu(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ Reset()

void GERBVIEW_SELECTION_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

Function Reset() Brings the tool to a known, initial state.

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

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 157 of file gerbview_selection_tool.cpp.

158 {
159  m_frame = getEditFrame<GERBVIEW_FRAME>();
160  m_preliminary = true;
161 
162  if( aReason == TOOL_BASE::MODEL_RELOAD )
163  {
164  // Remove pointers to the selected items from containers
165  // without changing their properties (as they are already deleted
166  // while a new file is loaded)
167  m_selection.Clear();
168  getView()->GetPainter()->GetSettings()->SetHighlight( false );
169  }
170  else
171  // Restore previous properties of selected items and remove them from containers
172  clearSelection();
173 
174  // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
175  getView()->Remove( &m_selection );
176  getView()->Add( &m_selection );
177 }
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:93
Model changes (required full reload)
Definition: tool_base.h:82
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:199
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aHighlightItems=false)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer,...
Definition: painter.h:141
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
void clearSelection()
Function clearSelection() Clears the current selection.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346

References KIGFX::VIEW::Add(), SELECTION::Clear(), clearSelection(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), TOOL_BASE::getView(), m_frame, m_preliminary, m_selection, TOOL_BASE::MODEL_RELOAD, KIGFX::VIEW::Remove(), and KIGFX::RENDER_SETTINGS::SetHighlight().

◆ RunMainStack()

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

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

88 {
89  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
90 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
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 GERBVIEW_SELECTION_TOOL::select ( EDA_ITEM aItem)
private

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

Parameters
aItemis an item to be selected.

Definition at line 522 of file gerbview_selection_tool.cpp.

523 {
524  if( aItem->IsSelected() )
525  return;
526 
527  m_selection.Add( aItem );
529  selectVisually( aItem );
530 }
bool IsSelected() const
Definition: base_struct.h:233
void selectVisually(EDA_ITEM *aItem)
Function selectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
#define max(a, b)
Definition: auxiliary.h:86
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346

References SELECTION::Add(), KIGFX::VIEW::Add(), TOOL_BASE::getView(), EDA_ITEM::IsSelected(), m_selection, max, and selectVisually().

Referenced by SelectItem(), SelectItems(), and selectPoint().

◆ selectable()

bool GERBVIEW_SELECTION_TOOL::selectable ( const EDA_ITEM aItem) const
private

Function selectable() Checks conditions for an item to be selected.

Returns
True if the item fulfills conditions to be selected.

Definition at line 499 of file gerbview_selection_tool.cpp.

500 {
501  GERBVIEW_FRAME* frame = getEditFrame<GERBVIEW_FRAME>();
502  const GERBER_DRAW_ITEM* item = static_cast<const GERBER_DRAW_ITEM*>( aItem );
503  int layer = item->GetLayer();
504 
505 
506  if( item->GetLayerPolarity() )
507  {
508  // Don't allow selection of invisible negative items
509  auto rs = static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( getView()->GetPainter()->GetSettings() );
510  if( !rs->IsShowNegativeItems() )
511  return false;
512  }
513 
514  // We do not want to select items that are in the background
515  if( frame->GetDisplayOptions().m_HighContrastMode && layer != frame->GetActiveLayer() )
516  return false;
517 
518  return frame->IsLayerVisible( layer );
519 }
int GetLayer() const
Function GetLayer returns the layer this item is on.
const GBR_DISPLAY_OPTIONS & GetDisplayOptions() const
Function GetDisplayOptions returns the display options current in use.
bool m_HighContrastMode
High contrast mode (dim un-highlighted objects)
int GetActiveLayer()
Function SetActiveLayer returns the active layer.
TOOL_SETTINGS & GetSettings()
Definition: tool_base.cpp:78
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
bool IsLayerVisible(int aLayer) const
Function IsLayerVisible tests whether a given layer is visible.
bool GetLayerPolarity() const

References GERBVIEW_FRAME::GetActiveLayer(), GERBVIEW_FRAME::GetDisplayOptions(), GERBER_DRAW_ITEM::GetLayer(), GERBER_DRAW_ITEM::GetLayerPolarity(), TOOL_BASE::GetSettings(), TOOL_BASE::getView(), GERBVIEW_FRAME::IsLayerVisible(), and GBR_DISPLAY_OPTIONS::m_HighContrastMode.

Referenced by selectPoint().

◆ selectCursor()

bool GERBVIEW_SELECTION_TOOL::selectCursor ( bool  aSelectAlways = false)
private

Function selectCursor() Selects an item under the cursor unless there is something already selected or aSelectAlways is true.

Parameters
aSelectAlwaysforces to select an item even if there is an item already selected.
Returns
true if eventually there is an item selected, false otherwise.

Definition at line 306 of file gerbview_selection_tool.cpp.

307 {
308  if( aSelectAlways || m_selection.Empty() )
309  {
310  clearSelection();
311  selectPoint( getViewControls()->GetCursorPosition( false ) );
312  }
313 
314  return !m_selection.Empty();
315 }
bool selectPoint(const VECTOR2I &aWhere, bool aOnDrag=false)
Function selectPoint() Selects an item pointed by the parameter aWhere.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
void clearSelection()
Function clearSelection() Clears the current selection.
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42

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

◆ SelectItem()

int GERBVIEW_SELECTION_TOOL::SelectItem ( const TOOL_EVENT aEvent)

Definition at line 354 of file gerbview_selection_tool.cpp.

355 {
356  // Check if there is an item to be selected
357  EDA_ITEM* item = aEvent.Parameter<EDA_ITEM*>();
358 
359  if( item )
360  {
361  select( item );
362 
363  // Inform other potentially interested tools
365  }
366 
367  return 0;
368 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:197
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
void select(EDA_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.

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

Referenced by setTransitions().

◆ SelectItems()

int GERBVIEW_SELECTION_TOOL::SelectItems ( const TOOL_EVENT aEvent)

Definition at line 337 of file gerbview_selection_tool.cpp.

338 {
339  std::vector<EDA_ITEM*>* items = aEvent.Parameter<std::vector<EDA_ITEM*>*>();
340 
341  if( items )
342  {
343  // Perform individual selection of each item before processing the event.
344  for( auto item : *items )
345  select( item );
346 
348  }
349 
350  return 0;
351 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:197
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
void select(EDA_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.

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

◆ selectPoint()

bool GERBVIEW_SELECTION_TOOL::selectPoint ( const VECTOR2I aWhere,
bool  aOnDrag = false 
)
private

Function selectPoint() Selects an item pointed by the parameter aWhere.

If there is more than one item at that place, there is a menu displayed that allows one to choose the item.

Parameters
aWhereis the place where the item should be selected.
aAllowDisambiguationdecides what to do in case of disambiguation. If true, then a menu is shown, otherise function finishes without selecting anything.
Returns
True if an item was selected, false otherwise.

Definition at line 252 of file gerbview_selection_tool.cpp.

253 {
254  EDA_ITEM* item = NULL;
255  GERBER_COLLECTOR collector;
256  EDA_ITEM* model = getModel<EDA_ITEM>();
257 
258  collector.Collect( model, GERBER_COLLECTOR::AllItems, wxPoint( aWhere.x, aWhere.y ) );
259 
260  // Remove unselectable items
261  for( int i = collector.GetCount() - 1; i >= 0; --i )
262  {
263  if( !selectable( collector[i] ) )
264  collector.Remove( i );
265  }
266 
267  if( collector.GetCount() > 1 )
268  {
269  if( aOnDrag )
271 
272  item = disambiguationMenu( &collector );
273 
274  if( item )
275  {
276  collector.Empty();
277  collector.Append( item );
278  }
279  }
280 
282  clearSelection();
283 
284  if( collector.GetCount() == 1 )
285  {
286  item = collector[ 0 ];
287 
288  if( m_subtractive || ( m_exclusive_or && item->IsSelected() ) )
289  {
290  unselect( item );
292  return false;
293  }
294  else
295  {
296  select( item );
298  return true;
299  }
300  }
301 
302  return false;
303 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:122
static const TOOL_EVENT SelectedEvent
Definition: actions.h:197
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool IsSelected() const
Definition: base_struct.h:233
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:198
bool selectable(const EDA_ITEM *aItem) const
Function selectable() Checks conditions for an item to be selected.
Class GERBER_COLLECTOR is intended for use when the right click button is pressed,...
EDA_ITEM * disambiguationMenu(GERBER_COLLECTOR *aItems)
Function disambiguationMenu() Handles the menu that allows one to select one of many items in case th...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static const KICAD_T AllItems[]
A scan list for all selectable gerber items.
void Remove(int aIndex)
Function Remove removes the item at aIndex (first position is 0);.
Definition: collector.h:142
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:132
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:113
void Collect(EDA_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos)
Function Collect scans an EDA_ITEM using this class's Inspector method, which does the collection.
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
Class TOOL_EVENT.
Definition: tool_event.h:171
void unselect(EDA_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
size_t i
Definition: json11.cpp:649
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
void select(EDA_ITEM *aItem)
Function select() Takes necessary action mark an item as selected.
void clearSelection()
Function clearSelection() Clears the current selection.

References GERBER_COLLECTOR::AllItems, COLLECTOR::Append(), BUT_LEFT, clearSelection(), GERBER_COLLECTOR::Collect(), disambiguationMenu(), COLLECTOR::Empty(), COLLECTOR::GetCount(), i, EDA_ITEM::IsSelected(), m_additive, m_exclusive_or, m_subtractive, TOOL_BASE::m_toolMgr, TOOL_MANAGER::ProcessEvent(), COLLECTOR::Remove(), select(), selectable(), EVENTS::SelectedEvent, TA_MOUSE_UP, TC_ANY, unselect(), EVENTS::UnselectedEvent, TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by Main(), and selectCursor().

◆ selectVisually()

void GERBVIEW_SELECTION_TOOL::selectVisually ( EDA_ITEM aItem)
private

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

Parameters
aItemis an item to be be marked.

Definition at line 546 of file gerbview_selection_tool.cpp.

547 {
548  // Move the item's layer to the front
549  int layer = static_cast<GERBER_DRAW_ITEM*>( aItem )->GetLayer();
550  m_frame->SetActiveLayer( layer, true );
551 
552  // Hide the original item, so it is shown only on overlay
553  aItem->SetSelected();
554  getView()->Hide( aItem, true );
555 
556  getView()->Update( &m_selection );
557 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1507
void SetActiveLayer(int aLayer, bool doLayerWidgetUpdate=true)
Function SetActiveLayer will change the currently active layer to aLayer and also update the GERBER_L...
void SetSelected()
Definition: base_struct.h:239
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36

References TOOL_BASE::getView(), KIGFX::VIEW::Hide(), m_frame, m_selection, GERBVIEW_FRAME::SetActiveLayer(), EDA_ITEM::SetSelected(), and KIGFX::VIEW::Update().

Referenced by select().

◆ SetContextMenu()

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

Function SetContextMenu()

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

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

Definition at line 76 of file tool_interactive.cpp.

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

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

Referenced by disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setTransitions()

void GERBVIEW_SELECTION_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 318 of file gerbview_selection_tool.cpp.

319 {
326 }
static TOOL_ACTION selectionClear
Clears the current selection.
int Main(const TOOL_EVENT &aEvent)
Function Main()
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int UnselectItem(const TOOL_EVENT &aEvent)
static TOOL_ACTION measureTool
Definition: actions.h:144
int UpdateMenu(const TOOL_EVENT &aEvent)
static TOOL_ACTION updateMenu
Definition: actions.h:158
int MeasureTool(const TOOL_EVENT &aEvent)
Launches a tool to measure between points
int SelectItem(const TOOL_EVENT &aEvent)
static TOOL_ACTION selectionActivate
Activation of the selection tool.
static TOOL_ACTION unselectItem
Unselects an item (specified as the event parameter).
int ClearSelection(const TOOL_EVENT &aEvent)

References ClearSelection(), TOOL_INTERACTIVE::Go(), Main(), MeasureTool(), ACTIONS::measureTool, GERBVIEW_ACTIONS::selectionActivate, GERBVIEW_ACTIONS::selectionClear, GERBVIEW_ACTIONS::selectItem, SelectItem(), GERBVIEW_ACTIONS::unselectItem, UnselectItem(), UpdateMenu(), and ACTIONS::updateMenu.

◆ unselect()

void GERBVIEW_SELECTION_TOOL::unselect ( EDA_ITEM aItem)
private

Function unselect() Takes necessary action mark an item as unselected.

Parameters
aItemis an item to be unselected.

Definition at line 533 of file gerbview_selection_tool.cpp.

534 {
535  if( !aItem->IsSelected() )
536  return;
537 
538  unselectVisually( aItem );
539  m_selection.Remove( aItem );
540 
541  if( m_selection.Empty() )
542  getView()->Remove( &m_selection );
543 }
bool IsSelected() const
Definition: base_struct.h:233
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
void unselectVisually(EDA_ITEM *aItem)
Function unselectVisually() Marks item as selected, but does not add it to the ITEMS_PICKED_LIST.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:85

References SELECTION::Empty(), TOOL_BASE::getView(), EDA_ITEM::IsSelected(), m_selection, SELECTION::Remove(), KIGFX::VIEW::Remove(), and unselectVisually().

Referenced by selectPoint(), UnselectItem(), and UnselectItems().

◆ UnselectItem()

int GERBVIEW_SELECTION_TOOL::UnselectItem ( const TOOL_EVENT aEvent)

Definition at line 388 of file gerbview_selection_tool.cpp.

389 {
390  // Check if there is an item to be selected
391  EDA_ITEM* item = aEvent.Parameter<EDA_ITEM*>();
392 
393  if( item )
394  {
395  unselect( item );
396 
397  // Inform other potentially interested tools
399  }
400 
401  return 0;
402 }
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:198
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
void unselect(EDA_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163

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

Referenced by setTransitions().

◆ UnselectItems()

int GERBVIEW_SELECTION_TOOL::UnselectItems ( const TOOL_EVENT aEvent)

Definition at line 371 of file gerbview_selection_tool.cpp.

372 {
373  std::vector<EDA_ITEM*>* items = aEvent.Parameter<std::vector<EDA_ITEM*>*>();
374 
375  if( items )
376  {
377  // Perform individual unselection of each item before processing the event
378  for( auto item : *items )
379  unselect( item );
380 
382  }
383 
384  return 0;
385 }
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:198
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagates an event to tools that requested events of matching type(s).
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
void unselect(EDA_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.

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

◆ unselectVisually()

void GERBVIEW_SELECTION_TOOL::unselectVisually ( EDA_ITEM aItem)
private

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

Parameters
aItemis an item to be be marked.

Definition at line 560 of file gerbview_selection_tool.cpp.

561 {
562  // Restore original item visibility
563  aItem->ClearSelected();
564  getView()->Hide( aItem, false );
565  getView()->Update( aItem, KIGFX::ALL );
566 
567  getView()->Update( &m_selection );
568 }
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hides the item in the view (e.g.
Definition: view.cpp:1507
void ClearSelected()
Definition: base_struct.h:243
Item needs to be redrawn.
Definition: view_item.h:61
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36

References KIGFX::ALL, EDA_ITEM::ClearSelected(), TOOL_BASE::getView(), KIGFX::VIEW::Hide(), m_selection, and KIGFX::VIEW::Update().

Referenced by clearSelection(), and unselect().

◆ UpdateMenu()

int GERBVIEW_SELECTION_TOOL::UpdateMenu ( const TOOL_EVENT aEvent)

Definition at line 119 of file gerbview_selection_tool.cpp.

120 {
121  ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
122  CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
123 
124  if( conditionalMenu )
125  conditionalMenu->Evaluate( m_selection );
126 
127  if( actionMenu )
128  actionMenu->UpdateAll();
129 
130  return 0;
131 }
Class ACTION_MENU.
Definition: action_menu.h:43
void UpdateAll()
Function UpdateAll() Runs update handlers for the menu and its submenus.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435

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

Referenced by setTransitions().

◆ Wait()

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

Function Wait()

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

Definition at line 57 of file tool_interactive.cpp.

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

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

Referenced by disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_additive

bool GERBVIEW_SELECTION_TOOL::m_additive
private

Definition at line 168 of file gerbview_selection_tool.h.

Referenced by Main(), and selectPoint().

◆ m_exclusive_or

bool GERBVIEW_SELECTION_TOOL::m_exclusive_or
private

Definition at line 170 of file gerbview_selection_tool.h.

Referenced by Main(), and selectPoint().

◆ m_frame

GERBVIEW_FRAME* GERBVIEW_SELECTION_TOOL::m_frame
private

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

functions below are not yet implemented - their interface may change

Definition at line 108 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), PICKER_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), MODULE_EDITOR_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), Init(), DRAWING_TOOL::Init(), PL_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), PCB_TOOL_BASE::Init(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), MeasureTool(), EDIT_TOOL::MeasureTool(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_preliminary

bool GERBVIEW_SELECTION_TOOL::m_preliminary
private

Definition at line 171 of file gerbview_selection_tool.h.

Referenced by GERBVIEW_SELECTION_TOOL(), and Reset().

◆ m_selection

◆ m_subtractive

bool GERBVIEW_SELECTION_TOOL::m_subtractive
private

Definition at line 169 of file gerbview_selection_tool.h.

Referenced by Main(), and selectPoint().

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

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

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::editComponentFieldText(), EDIT_TOOL::EditFpInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), MODULE_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), PAD_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), LIB_CONTROL::Init(), PL_DRAWING_TOOLS::Init(), PL_POINT_EDITOR::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC::RunTests(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), SelectItem(), SelectItems(), SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), UnselectItem(), UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

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

Definition at line 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 220 of file tool_base.h.

Referenced by TOOL_BASE::attachManager(), and TOOL_BASE::GetSettings().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 211 of file tool_base.h.

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


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