KiCad PCB EDA Suite
GERBVIEW_SELECTION_TOOL Class Reference

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

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

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 110 of file gerbview_selection_tool.cpp.

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

References m_preliminary.

◆ ~GERBVIEW_SELECTION_TOOL()

GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL ( )

Definition at line 136 of file gerbview_selection_tool.cpp.

137 {
138  getView()->Remove( &m_selection );
139 }
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(), EDIT_TOOL::doMoveSelection(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), 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(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), MeasureTool(), 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 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ ClearSelection()

int GERBVIEW_SELECTION_TOOL::ClearSelection ( const TOOL_EVENT aEvent)

Definition at line 313 of file gerbview_selection_tool.cpp.

314 {
315  clearSelection();
316 
317  return 0;
318 }
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 389 of file gerbview_selection_tool.cpp.

390 {
391  if( m_selection.Empty() )
392  return;
393 
394  for( auto item : m_selection )
395  unselectVisually( static_cast<EDA_ITEM*>( item ) );
396 
397  m_selection.Clear();
398 
399  // Inform other potentially interested tools
401 }
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:95
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:205
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:121

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 404 of file gerbview_selection_tool.cpp.

405 {
406  EDA_ITEM* current = NULL;
407  KIGFX::VIEW_GROUP highlightGroup;
408  ACTION_MENU menu( true );
409 
410  highlightGroup.SetLayer( LAYER_SELECT_OVERLAY );
411  getView()->Add( &highlightGroup );
412 
413  int limit = std::min( 10, aCollector->GetCount() );
414 
415  for( int i = 0; i < limit; ++i )
416  {
417  wxString text;
418  EDA_ITEM* item = ( *aCollector )[i];
419  text = item->GetSelectMenuText( m_frame->GetUserUnits() );
420  menu.Add( text, i + 1, item->GetMenuImage() );
421  }
422 
423  menu.SetTitle( _( "Clarify selection" ) );
424  menu.SetIcon( info_xpm );
425  menu.DisplayTitle( true );
426  SetContextMenu( &menu, CMENU_NOW );
427 
428  while( TOOL_EVENT* evt = Wait() )
429  {
430  if( evt->Action() == TA_CHOICE_MENU_UPDATE )
431  {
432  if( current )
433  {
434  current->ClearBrightened();
435  getView()->Hide( current, false );
436  highlightGroup.Remove( current );
438  }
439 
440  int id = *evt->GetCommandId();
441 
442  // User has pointed an item, so show it in a different way
443  if( id > 0 && id <= limit )
444  {
445  current = ( *aCollector )[id - 1];
446  current->SetBrightened();
447  getView()->Hide( current, true );
448  highlightGroup.Add( current );
450  }
451  else
452  {
453  current = NULL;
454  }
455  }
456  else if( evt->Action() == TA_CHOICE_MENU_CHOICE )
457  {
458  OPT<int> id = evt->GetCommandId();
459 
460  // User has selected an item, so this one will be returned
461  if( id && ( *id > 0 ) )
462  current = ( *aCollector )[*id - 1];
463  else
464  current = NULL;
465 
466  break;
467  }
468  }
469 
470  if( current && current->IsBrightened() )
471  {
472  current->ClearBrightened();
473  getView()->Hide( current, false );
475  }
476 
477  getView()->Remove( &highlightGroup );
478 
479  return current;
480 }
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()
ACTION_MENU.
Definition: action_menu.h:44
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:209
bool IsBrightened() const
Definition: base_struct.h:205
void SetContextMenu(ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
Function SetContextMenu()
void ClearBrightened()
Definition: base_struct.h:212
#define NULL
void MarkTargetDirty(int aTarget)
Function MarkTargetDirty() Sets or clears target 'dirty' flag.
Definition: view.h:585
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
const BITMAP_OPAQUE info_xpm[1]
Definition: info.cpp:75
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
#define _(s)
Definition: 3d_actions.cpp:33
virtual wxString GetSelectMenuText(EDA_UNITS aUnits) const
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
currently selected items overlay
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
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.
EDA_UNITS GetUserUnits() const
Return the user units currently in use.

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(), info_xpm, EDA_ITEM::IsBrightened(), LAYER_SELECT_OVERLAY, m_frame, KIGFX::VIEW::MarkTargetDirty(), NULL, 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*>( getToolHolderInt() ) );
191 #endif
192  return static_cast<T*>( getToolHolderInt() );
193  }
TOOLS_HOLDER * getToolHolderInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

◆ 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
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159

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_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 230 of file gerbview_selection_tool.cpp.

231 {
232  return m_selection;
233 }

References m_selection.

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

◆ 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(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ 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:284
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(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::checkPart(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), 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(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindComponentAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), 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(), PCB_VIEWER_TOOLS::MeasureTool(), MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), 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::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(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), 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(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), 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_VIEWER_TOOLS::view(), 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:286

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

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), 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(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), MeasureTool(), COMMON_TOOLS::OnGridChanged(), 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::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), 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(), ROUTER_TOOL::setTransitions(), LIB_PIN_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PL_POINT_EDITOR::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), POINT_EDITOR::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), SCH_MOVE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), PAD_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_TOOLS::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), setTransitions(), COMMON_TOOLS::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCBNEW_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCB_INSPECTION_TOOL::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(), DRC::setTransitions(), EDIT_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::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 142 of file gerbview_selection_tool.cpp.

143 {
144  auto selectMenu = std::make_shared<HIGHLIGHT_MENU>();
145  selectMenu->SetTool( this );
146  m_menu.AddSubMenu( selectMenu );
147 
148  auto& menu = m_menu.GetMenu();
149 
150  menu.AddMenu( selectMenu.get() );
151  menu.AddSeparator( 1000 );
152 
153  getEditFrame<GERBVIEW_FRAME>()->AddStandardSubMenus( m_menu );
154 
155  return true;
156 }
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.

Referenced by ROUTER_TOOL::onViaCommand().

◆ Main()

int GERBVIEW_SELECTION_TOOL::Main ( const TOOL_EVENT aEvent)

Function Main()

The main loop.

Definition at line 182 of file gerbview_selection_tool.cpp.

183 {
184  // Main loop: keep receiving events
185  while( TOOL_EVENT* evt = Wait() )
186  {
187  if( m_frame->ToolStackIsEmpty() )
188  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
189 
191 
192  if( evt->Modifier( MD_SHIFT ) && evt->Modifier( MD_CTRL ) )
193  m_subtractive = true;
194  else if( evt->Modifier( MD_SHIFT ) )
195  m_additive = true;
196  else if( evt->Modifier( MD_CTRL ) )
197  m_exclusive_or = true;
198 
199  // single click? Select single object
200  if( evt->IsClick( BUT_LEFT ) )
201  {
202  selectPoint( evt->Position() );
203  }
204 
205  // right click? if there is any object - show the context menu
206  else if( evt->IsClick( BUT_RIGHT ) )
207  {
208  if( m_selection.Empty() )
209  {
210  selectPoint( evt->Position() );
211  m_selection.SetIsHover( true );
212  }
213 
215  }
216 
217  else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
218  {
219  clearSelection();
220  }
221 
222  else
223  evt->SetPassEvent();
224  }
225 
226  return 0;
227 }
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:66
TOOL_EVENT.
Definition: tool_event.h:171
bool ToolStackIsEmpty()
Definition: tools_holder.h:84
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
void clearSelection()
Function clearSelection() Clears the current selection.
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59

References BUT_LEFT, BUT_RIGHT, clearSelection(), SELECTION::Empty(), EDA_DRAW_FRAME::GetCanvas(), m_additive, m_exclusive_or, m_frame, TOOL_INTERACTIVE::m_menu, m_selection, m_subtractive, MD_CTRL, MD_SHIFT, selectPoint(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), SELECTION::SetIsHover(), TOOL_MENU::ShowContextMenu(), TA_UNDO_REDO_PRE, TOOLS_HOLDER::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 555 of file gerbview_selection_tool.cpp.

556 {
557  auto& view = *getView();
558  auto& controls = *getViewControls();
559  auto previous_settings = controls.GetSettings();
560 
561  std::string tool = aEvent.GetCommandStr().get();
562  m_frame->PushTool( tool );
563  Activate();
564 
566  KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, m_frame->GetUserUnits() );
567 
568  view.Add( &ruler );
569  view.SetVisible( &ruler, false );
570 
571  bool originSet = false;
572 
573  controls.ShowCursor( true );
574  controls.SetSnapping( true );
575 
576  while( TOOL_EVENT* evt = Wait() )
577  {
578  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
579  const VECTOR2I cursorPos = controls.GetCursorPosition();
580 
581  auto clearRuler = [&] () {
582  view.SetVisible( &ruler, false );
583  controls.SetAutoPan( false );
584  controls.CaptureCursor( false );
585  originSet = false;
586  };
587 
588  if( evt->IsCancelInteractive() )
589  {
590  if( originSet )
591  clearRuler();
592  else
593  {
594  m_frame->PopTool( tool );
595  break;
596  }
597  }
598 
599  else if( evt->IsActivate() )
600  {
601  if( originSet )
602  clearRuler();
603 
604  if( evt->IsMoveTool() )
605  {
606  // leave ourselves on the stack so we come back after the move
607  break;
608  }
609  else
610  {
611  m_frame->PopTool( tool );
612  break;
613  }
614  }
615 
616  // click or drag starts
617  else if( !originSet && ( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) )
618  {
619  if( !evt->IsDrag( BUT_LEFT ) )
620  {
621  twoPtMgr.SetOrigin( cursorPos );
622  twoPtMgr.SetEnd( cursorPos );
623  }
624 
625  controls.CaptureCursor( true );
626  controls.SetAutoPan( true );
627 
628  originSet = true;
629  }
630 
631  else if( !originSet && evt->IsMotion() )
632  {
633  // make sure the origin is set before a drag starts
634  // otherwise you can miss a step
635  twoPtMgr.SetOrigin( cursorPos );
636  twoPtMgr.SetEnd( cursorPos );
637  }
638 
639  // second click or mouse up after drag ends
640  else if( originSet && ( evt->IsClick( BUT_LEFT ) || evt->IsMouseUp( BUT_LEFT ) ) )
641  {
642  originSet = false;
643 
644  controls.SetAutoPan( false );
645  controls.CaptureCursor( false );
646 
647  view.SetVisible( &ruler, false );
648  }
649 
650  // move or drag when origin set updates rules
651  else if( originSet && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
652  {
653  twoPtMgr.SetAngleSnap( evt->Modifier( MD_CTRL ) );
654  twoPtMgr.SetEnd( cursorPos );
655 
656  view.SetVisible( &ruler, true );
657  view.Update( &ruler, KIGFX::GEOMETRY );
658  }
659 
660  else if( evt->IsClick( BUT_RIGHT ) )
661  {
663  }
664 
665  else
666  evt->SetPassEvent();
667  }
668 
669  view.SetVisible( &ruler, false );
670  view.Remove( &ruler );
671  controls.ApplySettings( previous_settings );
672  return 0;
673 }
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.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
virtual void PopTool(const std::string &actionName)
TOOL_EVENT.
Definition: tool_event.h:171
void SetOrigin(const VECTOR2I &aOrigin)
Set the origin of the ruler (the fixed end)
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
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
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
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:59

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, TOOLS_HOLDER::PopTool(), TOOLS_HOLDER::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 159 of file gerbview_selection_tool.cpp.

160 {
161  m_frame = getEditFrame<GERBVIEW_FRAME>();
162  m_preliminary = true;
163 
164  if( aReason == TOOL_BASE::MODEL_RELOAD )
165  {
166  // Remove pointers to the selected items from containers
167  // without changing their properties (as they are already deleted
168  // while a new file is loaded)
169  m_selection.Clear();
170  getView()->GetPainter()->GetSettings()->SetHighlight( false );
171  }
172  else
173  // Restore previous properties of selected items and remove them from containers
174  clearSelection();
175 
176  // Reinsert the VIEW_GROUP, in case it was removed from the VIEW
177  getView()->Remove( &m_selection );
178  getView()->Add( &m_selection );
179 }
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:95
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
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
virtual RENDER_SETTINGS * GetSettings()=0
Function GetAdapter Returns pointer to current settings that are going to be used when drawing items.
void SetHighlight(bool aEnabled, int aNetcode=-1, bool aMulti=false)
Function SetHighlight Turns on/off highlighting - it may be done for the active layer or the specifie...
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 506 of file gerbview_selection_tool.cpp.

507 {
508  if( aItem->IsSelected() )
509  return;
510 
511  m_selection.Add( aItem );
512  getView()->Add( &m_selection, std::numeric_limits<int>::max() );
513  selectVisually( aItem );
514 }
bool IsSelected() const
Definition: base_struct.h:203
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:76
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
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, 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 483 of file gerbview_selection_tool.cpp.

484 {
485  GERBVIEW_FRAME* frame = getEditFrame<GERBVIEW_FRAME>();
486  const GERBER_DRAW_ITEM* item = static_cast<const GERBER_DRAW_ITEM*>( aItem );
487  int layer = item->GetLayer();
488 
489 
490  if( item->GetLayerPolarity() )
491  {
492  // Don't allow selection of invisible negative items
493  auto rs = static_cast<KIGFX::GERBVIEW_RENDER_SETTINGS*>( getView()->GetPainter()->GetSettings() );
494  if( !rs->IsShowNegativeItems() )
495  return false;
496  }
497 
498  // We do not want to select items that are in the background
499  if( frame->GetDisplayOptions().m_HighContrastMode && layer != frame->GetActiveLayer() )
500  return false;
501 
502  return frame->IsLayerVisible( layer );
503 }
int GetLayer() const
Function GetLayer returns the layer this item is on.
const GBR_DISPLAY_OPTIONS & GetDisplayOptions() const
bool m_HighContrastMode
High contrast mode (dim un-highlighted objects)
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
int GetActiveLayer() const
Function SetActiveLayer returns the active layer.
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::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 290 of file gerbview_selection_tool.cpp.

291 {
292  if( aSelectAlways || m_selection.Empty() )
293  {
294  clearSelection();
295  selectPoint( getViewControls()->GetCursorPosition( false ) );
296  }
297 
298  return !m_selection.Empty();
299 }
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:121
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 338 of file gerbview_selection_tool.cpp.

339 {
340  // Check if there is an item to be selected
341  EDA_ITEM* item = aEvent.Parameter<EDA_ITEM*>();
342 
343  if( item )
344  {
345  select( item );
346 
347  // Inform other potentially interested tools
349  }
350 
351  return 0;
352 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:203
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
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
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 321 of file gerbview_selection_tool.cpp.

322 {
323  std::vector<EDA_ITEM*>* items = aEvent.Parameter<std::vector<EDA_ITEM*>*>();
324 
325  if( items )
326  {
327  // Perform individual selection of each item before processing the event.
328  for( auto item : *items )
329  select( item );
330 
332  }
333 
334  return 0;
335 }
static const TOOL_EVENT SelectedEvent
Definition: actions.h:203
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 236 of file gerbview_selection_tool.cpp.

237 {
238  EDA_ITEM* item = NULL;
239  GERBER_COLLECTOR collector;
240  EDA_ITEM* model = getModel<EDA_ITEM>();
241 
242  collector.Collect( model, GERBER_COLLECTOR::AllItems, wxPoint( aWhere.x, aWhere.y ) );
243 
244  // Remove unselectable items
245  for( int i = collector.GetCount() - 1; i >= 0; --i )
246  {
247  if( !selectable( collector[i] ) )
248  collector.Remove( i );
249  }
250 
251  if( collector.GetCount() > 1 )
252  {
253  if( aOnDrag )
255 
256  item = disambiguationMenu( &collector );
257 
258  if( item )
259  {
260  collector.Empty();
261  collector.Append( item );
262  }
263  }
264 
266  clearSelection();
267 
268  if( collector.GetCount() == 1 )
269  {
270  item = collector[ 0 ];
271 
272  if( m_subtractive || ( m_exclusive_or && item->IsSelected() ) )
273  {
274  unselect( item );
276  return false;
277  }
278  else
279  {
280  select( item );
282  return true;
283  }
284  }
285 
286  return false;
287 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:110
static const TOOL_EVENT SelectedEvent
Definition: actions.h:203
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
bool IsSelected() const
Definition: base_struct.h:203
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:204
bool selectable(const EDA_ITEM *aItem) const
Function selectable() Checks conditions for an item to be selected.
GERBER_COLLECTOR is intended for use when the right click button is pressed, or when the plain "arrow...
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:130
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:120
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:101
#define NULL
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).
TOOL_EVENT.
Definition: tool_event.h:171
void unselect(EDA_ITEM *aItem)
Function unselect() Takes necessary action mark an item as unselected.
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
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(), EDA_ITEM::IsSelected(), m_additive, m_exclusive_or, m_subtractive, TOOL_BASE::m_toolMgr, NULL, 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 530 of file gerbview_selection_tool.cpp.

531 {
532  // Move the item's layer to the front
533  int layer = static_cast<GERBER_DRAW_ITEM*>( aItem )->GetLayer();
534  m_frame->SetActiveLayer( layer, true );
535 
536  // Hide the original item, so it is shown only on overlay
537  aItem->SetSelected();
538  getView()->Hide( aItem, true );
539 
540  getView()->Update( &m_selection );
541 }
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 update the GERBER_LAYER_...
void SetSelected()
Definition: base_struct.h:208
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 302 of file gerbview_selection_tool.cpp.

303 {
310 }
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:148
int UpdateMenu(const TOOL_EVENT &aEvent)
static TOOL_ACTION updateMenu
Definition: actions.h:163
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 517 of file gerbview_selection_tool.cpp.

518 {
519  if( !aItem->IsSelected() )
520  return;
521 
522  unselectVisually( aItem );
523  m_selection.Remove( aItem );
524 
525  if( m_selection.Empty() )
526  getView()->Remove( &m_selection );
527 }
bool IsSelected() const
Definition: base_struct.h:203
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:121
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:87

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 372 of file gerbview_selection_tool.cpp.

373 {
374  // Check if there is an item to be selected
375  EDA_ITEM* item = aEvent.Parameter<EDA_ITEM*>();
376 
377  if( item )
378  {
379  unselect( item );
380 
381  // Inform other potentially interested tools
383  }
384 
385  return 0;
386 }
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:204
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.
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159

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 355 of file gerbview_selection_tool.cpp.

356 {
357  std::vector<EDA_ITEM*>* items = aEvent.Parameter<std::vector<EDA_ITEM*>*>();
358 
359  if( items )
360  {
361  // Perform individual unselection of each item before processing the event
362  for( auto item : *items )
363  unselect( item );
364 
366  }
367 
368  return 0;
369 }
static const TOOL_EVENT UnselectedEvent
Definition: actions.h:204
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 544 of file gerbview_selection_tool.cpp.

545 {
546  // Restore original item visibility
547  aItem->ClearSelected();
548  getView()->Hide( aItem, false );
549  getView()->Update( aItem, KIGFX::ALL );
550 
551  getView()->Update( &m_selection );
552 }
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:211
Item needs to be redrawn.
Definition: view_item.h:63
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 121 of file gerbview_selection_tool.cpp.

122 {
123  ACTION_MENU* actionMenu = aEvent.Parameter<ACTION_MENU*>();
124  CONDITIONAL_MENU* conditionalMenu = dynamic_cast<CONDITIONAL_MENU*>( actionMenu );
125 
126  if( conditionalMenu )
127  conditionalMenu->Evaluate( m_selection );
128 
129  if( actionMenu )
130  actionMenu->UpdateAll();
131 
132  return 0;
133 }
ACTION_MENU.
Definition: action_menu.h:44
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(), EDIT_TOOL::doMoveSelection(), 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(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickReferencePoint(), 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(), SCH_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), FOOTPRINT_EDITOR_TOOLS::Init(), PCB_VIEWER_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), EDA_3D_CONTROLLER::Init(), Init(), PL_SELECTION_TOOL::Init(), DRAWING_TOOL::Init(), EE_SELECTION_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), EDIT_TOOL::Init(), PCB_TOOL_BASE::Init(), PL_EDIT_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), EDA_3D_CONTROLLER::Main(), PICKER_TOOL::Main(), Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), PCB_VIEWER_TOOLS::MeasureTool(), 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(), SCH_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), 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(), 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_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), 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::EditField(), SCH_EDIT_TOOL::editFieldText(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), LIB_EDIT_TOOL::editGraphicProperties(), PAD_TOOL::EditPad(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), 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::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), 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(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), LIB_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PCB_INSPECTION_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::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(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), COMMON_TOOLS::OnGridChanged(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickReferencePoint(), 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(), SCH_EDIT_TOOL::RefreshSymbolFromLibrary(), 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::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), 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(), EDA_3D_CONTROLLER::ToggleVisibility(), 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_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: