KiCad PCB EDA Suite
MODULE_EDITOR_TOOLS Class Reference

Class MODULE_EDITOR_TOOLS. More...

#include <module_editor_tools.h>

Inheritance diagram for MODULE_EDITOR_TOOLS:
PCB_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

 MODULE_EDITOR_TOOLS ()
 
 ~MODULE_EDITOR_TOOLS ()
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
int PlacePad (const TOOL_EVENT &aEvent)
 Function PlacePad() Places a pad in module editor. More...
 
int EnumeratePads (const TOOL_EVENT &aEvent)
 Function EnumeratePads() Tool for quick pad enumeration. More...
 
int CreateArray (TOOL_EVENT &aEvent)
 Function CreateArray. More...
 
int ModuleTextOutlines (const TOOL_EVENT &aEvent)
 Function ModuleTextOutlines() More...
 
int ModuleEdgeOutlines (const TOOL_EVENT &aEvent)
 Function ModuleEdgeOutlines() More...
 
int CreatePadFromShapes (const TOOL_EVENT &aEvent)
 Function CreatePadFromShapes() More...
 
int ExplodePadToShapes (const TOOL_EVENT &aEvent)
 Function ExplodePadToShapes() More...
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
void SetContextMenu (CONTEXT_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...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
virtual bool Init ()
 Function Init() Init() is called once upon a registration of the tool. 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 Types

enum  INTERACTIVE_PLACEMENT_OPTIONS {
  IPO_ROTATE = 1, IPO_FLIP = 2, IPO_PROPERTIES = 4, IPO_SINGLE_CLICK = 8,
  IPO_REPEAT = 16
}
 

Protected Member Functions

void doInteractiveItemPlacement (INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
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

bool m_editModules
 
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
 

Detailed Description

Class MODULE_EDITOR_TOOLS.

Module editor specific tools.

Definition at line 43 of file module_editor_tools.h.

Member Enumeration Documentation

enum PCB_TOOL::INTERACTIVE_PLACEMENT_OPTIONS
protectedinherited
Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_PROPERTIES 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 98 of file pcb_tool.h.

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

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

Constructor & Destructor Documentation

MODULE_EDITOR_TOOLS::MODULE_EDITOR_TOOLS ( )

Definition at line 87 of file module_editor_tools.cpp.

87  :
88  PCB_TOOL( "pcbnew.ModuleEditor" )
89 {
90 }
PCB_TOOL(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool.h:65
MODULE_EDITOR_TOOLS::~MODULE_EDITOR_TOOLS ( )

Definition at line 93 of file module_editor_tools.cpp.

94 {
95 }

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

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

Referenced by EDIT_TOOL::copyToClipboard(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), ROUTER_TOOL::SettingsDialog(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID...
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 59 of file tool_base.cpp.

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

Referenced by TOOL_MANAGER::RegisterTool().

60 {
61  m_toolMgr = aManager;
62  m_toolSettings = TOOL_SETTINGS( this );
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
friend class TOOL_SETTINGS
Definition: tool_base.h:155
BOARD* PCB_TOOL::board ( ) const
inlineprotectedinherited

Definition at line 126 of file pcb_tool.h.

Referenced by PCBNEW_CONTROL::AppendBoard(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), EDIT_TOOL::changeTrackWidthOnClick(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::doInteractiveItemPlacement(), EnumeratePads(), ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), ROUTER_TOOL::getNetclassDimensions(), PCBNEW_CONTROL::GridResetOrigin(), PAD_TOOL::haveFootprints(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), ROUTER_TOOL::mainLoop(), PCB_TOOL::module(), ModuleEdgeOutlines(), ModuleTextOutlines(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PCB_EDITOR_CONTROL::PlaceModule(), PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectAllItemsConnectedToItem(), SELECTION_TOOL::selectAllItemsConnectedToTrack(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectPoint(), PCBNEW_CONTROL::TrackDisplayMode(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCBNEW_CONTROL::ZoneDisplayMode(), PCB_EDITOR_CONTROL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneMerge(), and PCB_EDITOR_CONTROL::ZoneUnfillAll().

126 { return getModel<BOARD>(); }
int MODULE_EDITOR_TOOLS::CreateArray ( TOOL_EVENT aEvent)

Function CreateArray.

Creates an array of objects using settings from a dialog

int MODULE_EDITOR_TOOLS::CreatePadFromShapes ( const TOOL_EVENT aEvent)

Function CreatePadFromShapes()

Creates a custom-shaped pad from a set of selected graphical shapes

Definition at line 384 of file module_editor_tools.cpp.

References COMMIT::Add(), PCB_TOOL::board(), D_PAD::Clone(), DisplayErrorMessage(), PCB_TOOL::frame(), TOOL_MANAGER::GetTool(), PAD_CS_PRIMITIVE::m_Start, TOOL_BASE::m_toolMgr, PAD_ATTRIB_SMD, PAD_SHAPE_CIRCLE, PAD_SHAPE_CUSTOM, PCB_MODULE_EDGE_T, PCB_PAD_T, BOARD_COMMIT::Push(), COMMIT::Remove(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, and D_PAD::SMDMask().

Referenced by setTransitions().

385 {
386  SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
387 
388  std::unique_ptr<D_PAD> pad ( new D_PAD ( board()->m_Modules ) );
389  D_PAD *refPad = nullptr;
390  bool multipleRefPadsFound = false;
391  bool illegalItemsFound = false;
392 
393  std::vector<PAD_CS_PRIMITIVE> shapes;
394 
395  BOARD_COMMIT commit( frame() );
396 
397  for( auto item : selection )
398  {
399  switch( item->Type() )
400  {
401  case PCB_PAD_T:
402  {
403  if( refPad )
404  multipleRefPadsFound = true;
405 
406  refPad = static_cast<D_PAD*>( item );
407  break;
408  }
409 
410  case PCB_MODULE_EDGE_T:
411  {
412  auto em = static_cast<EDGE_MODULE*> ( item );
413 
414  PAD_CS_PRIMITIVE shape( em->GetShape() );
415  shape.m_Start = em->GetStart();
416  shape.m_End = em->GetEnd();
417  shape.m_Radius = em->GetRadius();
418  shape.m_Thickness = em->GetWidth();
419  shape.m_ArcAngle = em->GetAngle();
420 
421  for ( auto p : em->GetPolyPoints() )
422  shape.m_Poly.push_back(p);
423 
424  shapes.push_back(shape);
425 
426  break;
427  }
428 
429  default:
430  {
431  illegalItemsFound = true;
432  break;
433  }
434  }
435  }
436 
437  if( refPad && selection.Size() == 1 )
438  {
439  // don't convert a pad into itself...
440  return 0;
441  }
442 
443  if( multipleRefPadsFound )
444  {
445  DisplayErrorMessage( frame(), _("Cannot convert items to a custom-shaped pad: selection contains more than one reference pad. ") );
446  return 0;
447  }
448 
449  if( illegalItemsFound )
450  {
451  DisplayErrorMessage( frame(), _("Cannot convert items to a custom-shaped pad: selection contains unsupported items. Only graphical lines, circles, arcs and polygons are allowed.") );
452  return 0;
453  }
454 
455  if( refPad )
456  {
457  pad.reset( static_cast<D_PAD*>( refPad->Clone() ) );
458  }
459  else
460  {
461  pad->SetAnchorPadShape( PAD_SHAPE_CIRCLE );
462  pad->SetAttribute( PAD_ATTRIB_SMD );
463  pad->SetLayerSet( D_PAD::SMDMask() );
464  pad->SetSize ( wxSize( 10000, 10000 ) );
465  pad->IncrementPadName( true, true );
466  }
467 
468 
469  pad->SetPrimitives( shapes );
470  pad->SetShape ( PAD_SHAPE_CUSTOM );
471 
473  VECTOR2I tmp;
474 
475  if( refPad )
476  {
477  anchor = pad->GetPosition();
478  }
479  else if( pad->GetBestAnchorPosition( tmp ) )
480  {
481  anchor = tmp;
482  }
483 
484  if( !anchor )
485  {
486  DisplayErrorMessage( frame(), _("Cannot convert items to a custom-shaped pad: unable to determine the anchor point position. Consider adding a small anchor pad to the selection and try again.") );
487  return 0;
488  }
489 
490 
491  // relocate the shapes, they are relative to the anchor pad position
492  for( auto& shape : shapes )
493  {
494  shape.m_Start.x -= anchor->x;
495  shape.m_Start.y -= anchor->y;
496  shape.m_End.x -= anchor->x;
497  shape.m_End.y -= anchor->y;
498 
499  for( auto&p : shape.m_Poly )
500  {
501  p.x -= anchor->x;
502  p.y -= anchor->y;
503  }
504  }
505 
506 
507  pad->SetPosition( wxPoint( anchor->x, anchor->y ) );
508  pad->SetPrimitives( shapes );
509 
510  bool result = pad->MergePrimitivesAsPolygon();
511 
512  if( !result )
513  {
514  DisplayErrorMessage( frame(), _("Cannot convert items to a custom-shaped pad: selected items do not form a single solid shape.") );
515  return 0;
516  }
517 
518  auto padPtr = pad.release();
519 
520  commit.Add( padPtr );
521  for ( auto item : selection )
522  {
523  commit.Remove( item );
524  }
525 
527  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, padPtr );
528 
529  commit.Push(_("Create Pad From Selected Shapes") );
530 
531  return 0;
532 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_pad.cpp:1208
static LSET SMDMask()
layer set for a SMD pad on Front layer
Definition: class_pad.cpp:106
Class SELECTION_TOOL.
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:99
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:61
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString aExtraInfo)
Function DisplayErrorMessage displays an error message with aMessage.
Definition: confirm.cpp:85
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom p...
Definition: class_pad.h:90
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
BOARD * board() const
Definition: pcb_tool.h:126
void PCB_TOOL::doInteractiveItemPlacement ( INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc.

More complex interactive processes are not supported here, you should implement a customised event loop for those.

Parameters
aItemCreatorthe callable that will attempt to create the item
aCommitMessagethe message used on a successful commit

Definition at line 38 of file pcb_tool.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), PCB_TOOL::board(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), BOARD_COMMIT::Push(), KIGFX::VIEW_GROUP::Remove(), SELECTION::Remove(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, KIGFX::VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), DRAWING_TOOL::DrawVia(), and PlacePad().

41 {
42  using namespace std::placeholders;
43  std::unique_ptr<BOARD_ITEM> newItem;
44 
45  Activate();
46 
47  BOARD_COMMIT commit( frame() );
48 
50 
51  // do not capture or auto-pan until we start placing an item
52  controls()->ShowCursor( true );
53  controls()->SetSnapping( true );
54 
55  // Add a VIEW_GROUP that serves as a preview for the new item
56  SELECTION preview;
57  view()->Add( &preview );
58 
59  aPlacer->m_board = board();
60  aPlacer->m_frame = frame();
61 
62  if( aOptions & IPO_SINGLE_CLICK )
63  {
64  VECTOR2I cursorPos = controls()->GetCursorPosition();
65 
66  newItem = aPlacer->CreateItem();
67  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
68 
69  preview.Add( newItem.get() );
70  }
71 
72  // Main loop: keep receiving events
73  while( OPT_TOOL_EVENT evt = Wait() )
74  {
75  VECTOR2I cursorPos = controls()->GetCursorPosition();
76 
78  {
79  if( newItem )
80  {
81  // Delete the old item and have another try
82  newItem = nullptr;
83 
84  preview.Clear();
85 
86  if( aOptions & IPO_SINGLE_CLICK )
87  break;
88 
89  controls()->SetAutoPan( false );
90  controls()->CaptureCursor( false );
91  controls()->ShowCursor( true );
92  }
93  else
94  {
95  break;
96  }
97 
98  if( evt->IsActivate() ) // now finish unconditionally
99  break;
100  }
101 
102  else if( evt->IsClick( BUT_LEFT ) )
103  {
104  if( !newItem )
105  {
106  // create the item if possible
107  newItem = aPlacer->CreateItem();
108 
109  // no item created, so wait for another click
110  if( !newItem )
111  continue;
112 
113  controls()->CaptureCursor( true );
114  controls()->SetAutoPan( true );
115 
116  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
117 
118  preview.Add( newItem.get() );
119 
120  if( newItem->Type() == PCB_MODULE_T )
121  {
122  auto module = dyn_cast<MODULE*>( newItem.get() );
123 
124  // modules have more drawable parts
125  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
126  }
127  }
128  else
129  {
130  newItem->ClearFlags();
131  preview.Remove( newItem.get() );
132 
133  aPlacer->PlaceItem( newItem.get() );
134 
135  if( newItem->Type() == PCB_MODULE_T )
136  {
137  auto module = dyn_cast<MODULE*>( newItem.get() );
138  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Remove, &preview, _1 ) );
139  }
140 
141  commit.Add( newItem.release() );
142  commit.Push( aCommitMessage );
143 
144  controls()->CaptureCursor( false );
145  controls()->SetAutoPan( false );
146  controls()->ShowCursor( true );
147 
148  if( !( aOptions & IPO_REPEAT ) )
149  break;
150 
151  if( aOptions & IPO_SINGLE_CLICK )
152  {
154 
155  newItem = aPlacer->CreateItem();
156  newItem->SetPosition( wxPoint( pos.x, pos.y ) );
157 
158  preview.Add( newItem.get() );
159  }
160  }
161  }
162 
163  else if( newItem && evt->Category() == TC_COMMAND )
164  {
165  /*
166  * Handle any events that can affect the item as we move
167  * it around, eg rotate and flip
168  */
169 
170  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
171  {
172  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
173  *frame(), *evt );
174  newItem->Rotate( newItem->GetPosition(), rotationAngle );
175  view()->Update( &preview );
176  }
177  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
178  {
179  newItem->Flip( newItem->GetPosition() );
180  view()->Update( &preview );
181  }
182  }
183 
184  else if( newItem && evt->IsMotion() )
185  {
186  // track the cursor
187  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
188 
189  // Show a preview of the item
190  view()->Update( &preview );
191  }
192  }
193 
194  view()->Remove( &preview );
195 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
void RunOnChildren(std::function< void(BOARD_ITEM *)> aFunction)
Function RunOnChildren.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
virtual bool PlaceItem(BOARD_ITEM *aItem)
Definition: pcb_tool.h:51
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
PCB_EDIT_FRAME * m_frame
Definition: pcb_tool.h:53
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:124
class MODULE, a footprint
Definition: typeinfo.h:101
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
MODULE * module() const
Definition: pcb_tool.h:127
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
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:1385
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:99
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool...
Definition: tool_base.h:144
void Activate()
Function Activate() Runs the tool.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
BOARD * board() const
Definition: pcb_tool.h:126
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 91 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PAD_TOOL::Init(), and EDIT_TOOL::MeasureTool().

92  {
93  return m_editModules;
94  }
bool m_editModules
Definition: pcb_tool.h:129
int MODULE_EDITOR_TOOLS::EnumeratePads ( const TOOL_EVENT aEvent)

Function EnumeratePads() Tool for quick pad enumeration.

Definition at line 131 of file module_editor_tools.cpp.

References TOOL_INTERACTIVE::Activate(), PCB_TOOL::board(), BUT_LEFT, GENERAL_COLLECTOR::Collect(), EDA_DRAW_FRAME::DisplayToolMsg(), COLLECTOR::Empty(), EOT, EuclideanNorm(), Format(), PCB_TOOL::frame(), PCB_BASE_FRAME::GetCollectorsGuide(), COLLECTOR::GetCount(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), EDA_DRAW_FRAME::GetGalCanvas(), DIALOG_ENUM_PADS::GetPrefix(), DIALOG_ENUM_PADS::GetStartNumber(), TOOL_BASE::getView(), TOOL_MANAGER::GetView(), TOOL_BASE::getViewControls(), TOOL_BASE::m_toolMgr, COMMIT::Modify(), PCB_PAD_T, BOARD_COMMIT::Push(), BOARD_COMMIT::Revert(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, GENERAL_COLLECTORS_GUIDE::SetIgnoreModulesRefs(), GENERAL_COLLECTORS_GUIDE::SetIgnoreModulesVals(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMTextsMarkedNoShow(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMTextsOnBack(), GENERAL_COLLECTORS_GUIDE::SetIgnoreMTextsOnFront(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by setTransitions().

132 {
133  if( !board()->m_Modules || !board()->m_Modules->PadsList() )
134  return 0;
135 
136  DIALOG_ENUM_PADS settingsDlg( frame() );
137 
138  if( settingsDlg.ShowModal() != wxID_OK )
139  return 0;
140 
141  Activate();
142 
143  GENERAL_COLLECTOR collector;
144  const KICAD_T types[] = { PCB_PAD_T, EOT };
145 
147  guide.SetIgnoreMTextsMarkedNoShow( true );
148  guide.SetIgnoreMTextsOnBack( true );
149  guide.SetIgnoreMTextsOnFront( true );
150  guide.SetIgnoreModulesVals( true );
151  guide.SetIgnoreModulesRefs( true );
152 
153  int padNumber = settingsDlg.GetStartNumber();
154  wxString padPrefix = settingsDlg.GetPrefix();
155 
156  frame()->DisplayToolMsg( _(
157  "Hold left mouse button and move cursor over pads to enumerate them" ) );
158 
160  getViewControls()->ShowCursor( true );
161  frame()->GetGalCanvas()->SetCursor( wxCURSOR_HAND );
162 
164  VECTOR2I oldCursorPos; // store the previous mouse cursor position, during mouse drag
165  std::list<D_PAD*> selectedPads;
166  BOARD_COMMIT commit( frame() );
167  std::map<wxString, wxString> oldNames;
168  bool isFirstPoint = true; // used to be sure oldCursorPos will be initialized at least once.
169 
170  while( OPT_TOOL_EVENT evt = Wait() )
171  {
172  if( evt->IsDrag( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
173  {
174  selectedPads.clear();
175  VECTOR2I cursorPos = getViewControls()->GetCursorPosition();
176 
177  // Be sure the old cursor mouse position was initialized:
178  if( isFirstPoint )
179  {
180  oldCursorPos = cursorPos;
181  isFirstPoint = false;
182  }
183 
184  // wxWidgets deliver mouse move events not frequently enough, resulting in skipping
185  // pads if the user moves cursor too fast. To solve it, create a line that approximates
186  // the mouse move and search pads that are on the line.
187  int distance = ( cursorPos - oldCursorPos ).EuclideanNorm();
188  // Search will be made every 0.1 mm:
189  int segments = distance / int( 0.1*IU_PER_MM ) + 1;
190  const wxPoint line_step( ( cursorPos - oldCursorPos ) / segments );
191 
192  collector.Empty();
193 
194  for( int j = 0; j < segments; ++j )
195  {
196  wxPoint testpoint( cursorPos.x - j * line_step.x,
197  cursorPos.y - j * line_step.y );
198  collector.Collect( board(), types, testpoint, guide );
199 
200  for( int i = 0; i < collector.GetCount(); ++i )
201  {
202  selectedPads.push_back( static_cast<D_PAD*>( collector[i] ) );
203  }
204  }
205 
206  selectedPads.unique();
207 
208  for( D_PAD* pad : selectedPads )
209  {
210  // If pad was not selected, then enumerate it
211  if( !pad->IsSelected() )
212  {
213  commit.Modify( pad );
214 
215  // Rename pad and store the old name
216  wxString newName = wxString::Format( wxT( "%s%d" ), padPrefix.c_str(), padNumber++ );
217  oldNames[newName] = pad->GetName();
218  pad->SetName( newName );
219  pad->SetSelected();
220  getView()->Update( pad );
221  }
222 
223  // ..or restore the old name if it was enumerated and clicked again
224  else if( pad->IsSelected() && evt->IsClick( BUT_LEFT ) )
225  {
226  auto it = oldNames.find( pad->GetName() );
227  wxASSERT( it != oldNames.end() );
228 
229  if( it != oldNames.end() )
230  {
231  pad->SetName( it->second );
232  oldNames.erase( it );
233  }
234 
235  pad->ClearSelected();
236  getView()->Update( pad );
237  }
238  }
239  }
240 
241  else if( ( evt->IsKeyPressed() && evt->KeyCode() == WXK_RETURN ) ||
242  evt->IsDblClick( BUT_LEFT ) )
243  {
244  commit.Push( _( "Enumerate pads" ) );
245  break;
246  }
247 
248  else if( evt->IsCancel() || evt->IsActivate() )
249  {
250  commit.Revert();
251  break;
252  }
253 
254  // Prepare the next loop by updating the old cursor mouse position
255  // to this last mouse cursor position
256  oldCursorPos = getViewControls()->GetCursorPosition();
257  }
258 
259  for( auto p : board()->m_Modules->Pads() )
260  {
261  p->ClearSelected();
262  view->Update( p );
263  }
264 
265  frame()->DisplayToolMsg( wxEmptyString );
266  frame()->GetGalCanvas()->SetCursor( wxCURSOR_ARROW );
267 
268  return 0;
269 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
void Empty()
Function Empty sets the list to empty.
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
int GetCount() const
Function GetCount returns the number of objects in the list.
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
void Collect(BOARD_ITEM *aItem, const KICAD_T aScanList[], const wxPoint &aRefPos, const COLLECTORS_GUIDE &aGuide)
Scan a BOARD_ITEM using this class's Inspector method, which does the collection. ...
Definition: collectors.cpp:435
void SetIgnoreModulesVals(bool ignore)
Definition: collectors.h:529
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
void SetIgnoreModulesRefs(bool ignore)
Definition: collectors.h:535
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
Implementing DIALOG_ENUM_PADS_BASE.
search types array terminator (End Of Types)
Definition: typeinfo.h:94
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
GENERAL_COLLECTORS_GUIDE GetCollectorsGuide()
Function GetCollectorsGuide.
void SetIgnoreMTextsOnBack(bool ignore)
Definition: collectors.h:493
void SetIgnoreMTextsOnFront(bool ignore)
Definition: collectors.h:499
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:487
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:1385
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void DisplayToolMsg(const wxString &msg)
Definition: draw_frame.cpp:508
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:212
void Activate()
Function Activate() Runs the tool.
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:870
Class VIEW.
Definition: view.h:58
A general implementation of a COLLECTORS_GUIDE.
Definition: collectors.h:351
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
BOARD * board() const
Definition: pcb_tool.h:126
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
int MODULE_EDITOR_TOOLS::ExplodePadToShapes ( const TOOL_EVENT aEvent)

Function ExplodePadToShapes()

Breaks apart a complex-shaped part into a set of graphical shapes

Definition at line 336 of file module_editor_tools.cpp.

References COMMIT::Add(), PCB_TOOL::board(), PCB_TOOL::frame(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, COMMIT::Modify(), PAD_SHAPE_CUSTOM, PCB_PAD_T, BOARD_COMMIT::Push(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, and SELECTION::Size().

Referenced by setTransitions().

337 {
338  SELECTION& selection = m_toolMgr->GetTool<SELECTION_TOOL>()->GetSelection();
339  BOARD_COMMIT commit( frame() );
340 
341  if( selection.Size() != 1 )
342  return 0;
343 
344  if( selection[0]->Type() != PCB_PAD_T )
345  return 0;
346 
347  auto pad = static_cast<D_PAD*>( selection[0] );
348 
349  if( pad->GetShape() != PAD_SHAPE_CUSTOM )
350  return 0;
351 
352  commit.Modify( pad );
353 
354  wxPoint anchor = pad->GetPosition();
355 
356  for( auto prim : pad->GetPrimitives() )
357  {
358  auto ds = new EDGE_MODULE( board()->m_Modules );
359 
360  ds->SetLayer( pad->GetLayer() );
361  ds->SetShape( prim.m_Shape );
362  ds->SetStart( prim.m_Start + anchor );
363  ds->SetEnd( prim.m_End + anchor );
364  ds->SetWidth( prim.m_Thickness );
365 
366  for( auto&p : prim.m_Poly )
367  p += anchor;
368 
369  ds->SetPolyPoints( prim.m_Poly );
370  ds->SetAngle( prim.m_ArcAngle );
371 
372  commit.Add( ds );
373  }
374 
375  pad->SetShape( pad->GetAnchorPadShape() );
376  commit.Push( _("Explode pad to shapes") );
377 
379 
380  return 0;
381 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
int Size() const
Returns the number of selected parts.
Definition: selection.h:112
BOARD * board() const
Definition: pcb_tool.h:126
PCB_EDIT_FRAME* PCB_TOOL::frame ( ) const
inlineprotectedinherited
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

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

Definition at line 188 of file tool_base.h.

References TOOL_BASE::getEditFrameInt().

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

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47
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 122 of file tool_base.h.

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), and TOOL_MANAGER::runTool().

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
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 144 of file tool_base.h.

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), PCB_TOOL::doInteractiveItemPlacement(), CONTEXT_MENU::getToolManager(), EDIT_TOOL::MeasureTool(), and CONTEXT_MENU::onMenuEvent().

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
template<typename T >
T* TOOL_BASE::getModel ( ) const
inlineprotectedinherited

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

200  {
201  EDA_ITEM* m = getModelInt();
202 
203  return static_cast<T*>( m );
204  }
T
enum T contains all this lexer's tokens.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
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 133 of file tool_base.h.

References TOOL_BASE::m_toolName.

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

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:214
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

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

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

References TOOL_BASE::m_type.

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

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:207
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 35 of file tool_base.cpp.

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

Referenced by PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), PCBNEW_CONTROL::HighContrastMode(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), ModuleEdgeOutlines(), ModuleTextOutlines(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), DRAWING_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), PCBNEW_CONTROL::TrackDisplayMode(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), POINT_EDITOR::updateEditedPoint(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

36 {
37  return m_toolMgr->GetView();
38 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
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 41 of file tool_base.cpp.

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

Referenced by POINT_EDITOR::addCorner(), PCB_TOOL::controls(), PCBNEW_CONTROL::CursorControl(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawZone(), EnumeratePads(), SELECTION_TOOL::findMove(), PCB_EDITOR_CONTROL::HighlightNet(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::Reset(), PCBNEW_CONTROL::ResetCoords(), DRAWING_TOOL::runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PICKER_TOOL::setControls(), POINT_EDITOR::setEditedPoint(), EDIT_TOOL::updateModificationPoint(), COMMON_TOOLS::ZoomCenter(), and COMMON_TOOLS::ZoomInOut().

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257
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 135 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), POINT_EDITOR::setTransitions(), COMMON_TOOLS::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), setTransitions(), PICKER_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), SELECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), and DRAWING_TOOL::setTransitions().

137 {
138  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
139 
140  goInternal( sptr, aConditions );
141 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
virtual bool TOOL_BASE::Init ( )
inlinevirtualinherited

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

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

Reimplemented in SELECTION_TOOL, DRAWING_TOOL, GERBVIEW_SELECTION_TOOL, EDIT_TOOL, POSITION_RELATIVE_TOOL, PCB_EDITOR_CONTROL, POINT_EDITOR, MICROWAVE_TOOL, PAD_TOOL, ALIGN_DISTRIBUTE_TOOL, and ROUTER_TOOL.

Definition at line 93 of file tool_base.h.

Referenced by TOOL_MANAGER::InitTools().

94  {
95  return true;
96  }
bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

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

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

Function ModuleEdgeOutlines()

Toggles display mode for module edges (outline/filled).

Definition at line 307 of file module_editor_tools.cpp.

References B_Adhes, B_Mask, B_Paste, B_SilkS, PCB_TOOL::board(), Cmts_User, Dwgs_User, Eco1_User, Eco2_User, Edge_Cuts, F_Adhes, F_Mask, F_Paste, F_SilkS, PCB_TOOL::frame(), KIGFX::GEOMETRY, EDA_DRAW_FRAME::GetGalCanvas(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), KIGFX::PCB_RENDER_SETTINGS::GetSketchMode(), TOOL_BASE::getView(), MODULE::GraphicalItems(), PCB_TOOL::module(), PCB_MODULE_EDGE_T, EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::PCB_RENDER_SETTINGS::SetSketchMode(), KIGFX::VIEW::Update(), and PCB_TOOL::view().

Referenced by setTransitions().

308 {
309  KIGFX::VIEW* view = getView();
310  KIGFX::PCB_RENDER_SETTINGS* settings =
311  static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
312 
313  const PCB_LAYER_ID layers[] = { F_Adhes, B_Adhes, F_Paste, B_Paste,
316 
317  bool enable = !settings->GetSketchMode( layers[0] );
318 
319  for( LAYER_NUM layer : layers )
320  settings->SetSketchMode( layer, enable );
321 
322  for( auto module : board()->Modules() )
323  {
324  for( auto item : module->GraphicalItems() )
325  {
326  if( item->Type() == PCB_MODULE_EDGE_T )
327  view->Update( item, KIGFX::GEOMETRY );
328  }
329  }
330 
331  frame()->GetGalCanvas()->Refresh();
332 
333  return 0;
334 }
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:106
bool GetSketchMode(int aItemLayer) const
Function GetSketchMode Returns sketch mode setting for a given item layer.
Definition: pcb_painter.h:124
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > GraphicalItems()
Definition: class_module.h:145
PCB_LAYER_ID
A quick note on layer IDs:
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
MODULE * module() const
Definition: pcb_tool.h:127
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
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:1385
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
void SetSketchMode(int aItemLayer, bool aEnabled)
Function SetSketchMode Turns on/off sketch mode for given item layer.
Definition: pcb_painter.h:114
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:870
Class VIEW.
Definition: view.h:58
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:126
int MODULE_EDITOR_TOOLS::ModuleTextOutlines ( const TOOL_EVENT aEvent)

Function ModuleTextOutlines()

Toggles display mode for module texts (outline/filled).

Definition at line 272 of file module_editor_tools.cpp.

References PCB_TOOL::board(), PCB_TOOL::frame(), KIGFX::GEOMETRY, EDA_DRAW_FRAME::GetGalCanvas(), KIGFX::VIEW::GetPainter(), KIGFX::PAINTER::GetSettings(), KIGFX::PCB_RENDER_SETTINGS::GetSketchMode(), TOOL_BASE::getView(), MODULE::GraphicalItems(), LAYER_MOD_REFERENCES, LAYER_MOD_TEXT_BK, LAYER_MOD_TEXT_FR, LAYER_MOD_TEXT_INVISIBLE, LAYER_MOD_VALUES, PCB_TOOL::module(), PCB_MODULE_TEXT_T, MODULE::Reference(), EDA_DRAW_PANEL_GAL::Refresh(), KIGFX::PCB_RENDER_SETTINGS::SetSketchMode(), KIGFX::VIEW::Update(), MODULE::Value(), and PCB_TOOL::view().

Referenced by setTransitions().

273 {
274  KIGFX::VIEW* view = getView();
275  KIGFX::PCB_RENDER_SETTINGS* settings =
276  static_cast<KIGFX::PCB_RENDER_SETTINGS*>( view->GetPainter()->GetSettings() );
277 
278  const LAYER_NUM layers[] = { LAYER_MOD_TEXT_BK,
283 
284  bool enable = !settings->GetSketchMode( layers[0] );
285 
286  for( LAYER_NUM layer : layers )
287  settings->SetSketchMode( layer, enable );
288 
289  for( auto module : board()->Modules() )
290  {
291  for( auto item : module->GraphicalItems() )
292  {
293  if( item->Type() == PCB_MODULE_TEXT_T )
294  view->Update( item, KIGFX::GEOMETRY );
295  }
296 
297  view->Update( &module->Reference(), KIGFX::GEOMETRY );
298  view->Update( &module->Value(), KIGFX::GEOMETRY );
299  }
300 
301  frame()->GetGalCanvas()->Refresh();
302 
303  return 0;
304 }
KIGFX::VIEW * view() const
Definition: pcb_tool.h:123
TEXTE_MODULE & Reference()
Definition: class_module.h:463
show modules values (when texts are visibles)
bool GetSketchMode(int aItemLayer) const
Function GetSketchMode Returns sketch mode setting for a given item layer.
Definition: pcb_painter.h:124
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
DLIST_ITERATOR_WRAPPER< BOARD_ITEM > GraphicalItems()
Definition: class_module.h:145
TEXTE_MODULE & Value()
read/write accessors:
Definition: class_module.h:462
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
MODULE * module() const
Definition: pcb_tool.h:127
PAINTER * GetPainter() const
Function GetPainter() Returns the painter object used by the view for drawing VIEW_ITEMS.
Definition: view.h:196
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:1385
void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it bu a python script (note: it is automatically called by a...
int LAYER_NUM
Type LAYER_NUM can be replaced with int and removed.
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
virtual RENDER_SETTINGS * GetSettings()=0
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
void SetSketchMode(int aItemLayer, bool aEnabled)
Function SetSketchMode Turns on/off sketch mode for given item layer.
Definition: pcb_painter.h:114
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Function GetGalCanvas returns a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:870
Class VIEW.
Definition: view.h:58
show modules references (when texts are visibles)
Color has changed.
Definition: view_item.h:57
BOARD * board() const
Definition: pcb_tool.h:126
int MODULE_EDITOR_TOOLS::PlacePad ( const TOOL_EVENT aEvent)

Function PlacePad() Places a pad in module editor.

Definition at line 104 of file module_editor_tools.cpp.

References PCB_TOOL::board(), PCB_TOOL::doInteractiveItemPlacement(), PCB_TOOL::frame(), ID_MODEDIT_PAD_TOOL, D_PAD::IncrementPadName(), PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_PROPERTIES, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, EDA_DRAW_FRAME::SetNoToolSelected(), and PCB_BASE_FRAME::SetToolID().

Referenced by setTransitions().

105 {
106  struct PAD_PLACER : public INTERACTIVE_PLACER_BASE
107  {
108  std::unique_ptr<BOARD_ITEM> CreateItem() override
109  {
110  D_PAD* pad = new D_PAD ( m_board->m_Modules );
111  m_frame->Import_Pad_Settings( pad, false ); // use the global settings for pad
112  pad->IncrementPadName( true, true );
113  return std::unique_ptr<BOARD_ITEM>( pad );
114  }
115  };
116 
117  PAD_PLACER placer;
118 
119  frame()->SetToolID( ID_MODEDIT_PAD_TOOL, wxCURSOR_PENCIL, _( "Add pads" ) );
120 
121  assert( board()->m_Modules );
122 
124 
126 
127  return 0;
128 }
bool IncrementPadName(bool aSkipUnconnectable, bool aFillSequenceGaps)
Function IncrementPadName.
Definition: class_pad.cpp:515
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
void doInteractiveItemPlacement(INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
Helper function for performing a common interactive idiom: wait for a left click, place an item there...
Definition: pcb_tool.cpp:38
BOARD * board() const
Definition: pcb_tool.h:126
void MODULE_EDITOR_TOOLS::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 98 of file module_editor_tools.cpp.

99 {
100 }
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 85 of file tool_interactive.cpp.

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

Referenced by DRAWING_TOOL::PlaceText().

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_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 74 of file tool_interactive.cpp.

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), and TOOL_MENU::ShowContextMenu().

75 {
76  if( aMenu )
77  aMenu->SetTool( this );
78  else
79  aTrigger = CMENU_OFF;
80 
81  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
82 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void PCB_TOOL::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

Toggles edit module mode. When enabled, one may select parts of modules individually (graphics, pads, etc.), so they can be modified.

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 86 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

87  {
88  m_editModules = aEnabled;
89  }
bool m_editModules
Definition: pcb_tool.h:129
void MODULE_EDITOR_TOOLS::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 534 of file module_editor_tools.cpp.

References CreatePadFromShapes(), PCB_ACTIONS::createPadFromShapes, EnumeratePads(), PCB_ACTIONS::enumeratePads, ExplodePadToShapes(), PCB_ACTIONS::explodePadToShapes, TOOL_INTERACTIVE::Go(), ModuleEdgeOutlines(), PCB_ACTIONS::moduleEdgeOutlines, ModuleTextOutlines(), PCB_ACTIONS::moduleTextOutlines, PlacePad(), and PCB_ACTIONS::placePad.

535 {
542 }
static TOOL_ACTION explodePadToShapes
Definition: pcb_actions.h:295
static TOOL_ACTION enumeratePads
Tool for quick pad enumeration.
Definition: pcb_actions.h:298
static TOOL_ACTION placePad
Activation of the drawing tool (placing a PAD)
Definition: pcb_actions.h:292
int CreatePadFromShapes(const TOOL_EVENT &aEvent)
Function CreatePadFromShapes()
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
int ExplodePadToShapes(const TOOL_EVENT &aEvent)
Function ExplodePadToShapes()
int ModuleTextOutlines(const TOOL_EVENT &aEvent)
Function ModuleTextOutlines()
int PlacePad(const TOOL_EVENT &aEvent)
Function PlacePad() Places a pad in module editor.
static TOOL_ACTION moduleEdgeOutlines
Display module edges as outlines.
Definition: pcb_actions.h:313
int ModuleEdgeOutlines(const TOOL_EVENT &aEvent)
Function ModuleEdgeOutlines()
static TOOL_ACTION moduleTextOutlines
Display module texts as outlines.
Definition: pcb_actions.h:316
static TOOL_ACTION createPadFromShapes
Definition: pcb_actions.h:294
int EnumeratePads(const TOOL_EVENT &aEvent)
Function EnumeratePads() Tool for quick pad enumeration.
OPT_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 55 of file tool_interactive.cpp.

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

Referenced by PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), PCB_EDITOR_CONTROL::DrillOrigin(), EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), DRAWING_TOOL::runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
boost::optional< 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.

Member Data Documentation

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 210 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), GERBVIEW_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), PAD_TOOL::copyPadSettings(), CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::drawSegment(), DRAWING_TOOL::drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), 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_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), DRAWING_TOOL::PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), GERBVIEW_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), TOOL_INTERACTIVE::resetTransitions(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), GERBVIEW_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EDIT_TOOL::updateModificationPoint(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and PCB_EDITOR_CONTROL::ZoneUnfill().

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

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

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

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().


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