KiCad PCB EDA Suite
DRAWING_TOOL Class Reference

DRAWING_TOOL. More...

#include <drawing_tool.h>

Inheritance diagram for DRAWING_TOOL:
PCB_TOOL_BASE TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  MODE {
  MODE::NONE, MODE::LINE, MODE::RECTANGLE, MODE::CIRCLE,
  MODE::ARC, MODE::TEXT, MODE::ANCHOR, MODE::DXF,
  MODE::DIMENSION, MODE::KEEPOUT, MODE::ZONE, MODE::GRAPHIC_POLYGON,
  MODE::VIA
}
 

The possible drawing modes of DRAWING_TOOL

More...
 
enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 

Determines the reason of reset for a tool

More...
 

Public Member Functions

 DRAWING_TOOL ()
 
 ~DRAWING_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...
 
MODE GetDrawingMode () const
 Function GetDrawingMode. More...
 
int DrawLine (const TOOL_EVENT &aEvent)
 Function DrawLine() Starts interactively drawing a line. More...
 
int DrawRectangle (const TOOL_EVENT &aEvent)
 Function DrawRectangle() Starts interactively drawing a rectangle. More...
 
int DrawCircle (const TOOL_EVENT &aEvent)
 Function DrawCircle() Starts interactively drawing a circle. More...
 
int DrawArc (const TOOL_EVENT &aEvent)
 Function DrawArc() Starts interactively drawing an arc. More...
 
int PlaceText (const TOOL_EVENT &aEvent)
 Function PlaceText() Displays a dialog that allows one to input text and its settings and then lets the user decide where to place the text in editor. More...
 
int DrawDimension (const TOOL_EVENT &aEvent)
 Function DrawDimension() Starts interactively drawing a dimension. More...
 
int DrawZone (const TOOL_EVENT &aEvent)
 Function DrawZone() Starts interactively drawing a zone. More...
 
int DrawVia (const TOOL_EVENT &aEvent)
 
int PlaceImportedGraphics (const TOOL_EVENT &aEvent)
 Function PlaceImportedGraphics() Places a drawing imported from a DXF or SVG file in module editor. More...
 
int SetAnchor (const TOOL_EVENT &aEvent)
 Function SetAnchor() Places the footprint anchor (only in module editor). 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...
 
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 Types

enum  INTERACTIVE_PLACEMENT_OPTIONS { IPO_ROTATE = 0x01, IPO_FLIP = 0x02, IPO_SINGLE_CLICK = 0x04, IPO_REPEAT = 0x08 }
 Options for placing items interactively. More...
 

Protected Member Functions

void doInteractiveItemPlacement (const std::string &aTool, 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::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCBNEW_SELECTIONselection () const
 
PCBNEW_SELECTIONselection ()
 
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_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 drawSegment (const std::string &aTool, int aShape, DRAWSEGMENT **aGraphic, OPT< VECTOR2D > aStartingPoint)
 Starts drawing a selected shape (i.e. More...
 
bool drawArc (const std::string &aTool, DRAWSEGMENT **aGraphic, bool aImmediateMode)
 Starts drawing an arc. More...
 
bool getSourceZoneForAction (ZONE_MODE aMode, ZONE_CONTAINER **aZone)
 Draws a polygon, that is added as a zone or a keepout area. More...
 
void constrainDimension (DIMENSION *aDim)
 Function constrainDimension() Forces the dimension lime to be drawn on multiple of 45 degrees. More...
 
int getSegmentWidth (PCB_LAYER_ID aLayer) const
 

Returns the appropriate width for a segment depending on the settings.

More...
 

Private Attributes

KIGFX::VIEWm_view
 
KIGFX::VIEW_CONTROLSm_controls
 
BOARDm_board
 
PCB_BASE_EDIT_FRAMEm_frame
 
MODE m_mode
 
unsigned int m_lineWidth
 

Static Private Attributes

static const unsigned int WIDTH_STEP = Millimeter2iu( 0.1 )
 

Friends

class ZONE_CREATE_HELPER
 

Detailed Description

DRAWING_TOOL.

Tool responsible for drawing graphical elements like lines, arcs, circles, etc.

Definition at line 50 of file drawing_tool.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

Options for placing items interactively.

Enumerator
IPO_ROTATE 

Handle the rotate action in the loop by calling the item's rotate method.

IPO_FLIP 

Handle flip action in the loop by calling the item's flip method.

IPO_SINGLE_CLICK 

Create an item immediately on placement starting, otherwise show the pencil cursor until the item is created.

IPO_REPEAT 

Allow repeat placement of the item.

Definition at line 116 of file pcb_tool_base.h.

116  {
118  IPO_ROTATE = 0x01,
119 
121  IPO_FLIP = 0x02,
122 
125  IPO_SINGLE_CLICK = 0x04,
126 
128  IPO_REPEAT = 0x08
129  };
Handle flip action in the loop by calling the item's flip method.
Allow repeat placement of the item.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
Handle the rotate action in the loop by calling the item's rotate method.

◆ MODE

enum DRAWING_TOOL::MODE
strong

The possible drawing modes of DRAWING_TOOL

Enumerator
NONE 
LINE 
RECTANGLE 
CIRCLE 
ARC 
TEXT 
ANCHOR 
DXF 
DIMENSION 
KEEPOUT 
ZONE 
GRAPHIC_POLYGON 
VIA 

Definition at line 63 of file drawing_tool.h.

64  {
65  NONE,
66  LINE,
67  RECTANGLE,
68  CIRCLE,
69  ARC,
70  TEXT,
71  ANCHOR,
72  DXF,
73  DIMENSION,
74  KEEPOUT,
75  ZONE,
77  VIA
78  };
DIMENSION.

◆ 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

◆ DRAWING_TOOL()

DRAWING_TOOL::DRAWING_TOOL ( )

Definition at line 62 of file drawing_tool.cpp.

62  :
63  PCB_TOOL_BASE( "pcbnew.InteractiveDrawing" ),
64  m_view( nullptr ), m_controls( nullptr ),
65  m_board( nullptr ), m_frame( nullptr ), m_mode( MODE::NONE ),
66  m_lineWidth( 1 )
67 {
68 }
BOARD * m_board
Definition: drawing_tool.h:229
KIGFX::VIEW * m_view
Definition: drawing_tool.h:227
unsigned int m_lineWidth
Definition: drawing_tool.h:233
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:228
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:75

◆ ~DRAWING_TOOL()

DRAWING_TOOL::~DRAWING_TOOL ( )

Definition at line 71 of file drawing_tool.cpp.

72 {
73 }

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(), DrawArc(), DrawCircle(), DrawDimension(), DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DrawRectangle(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), 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(), GERBVIEW_SELECTION_TOOL::MeasureTool(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), 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().

◆ board()

BOARD* PCB_TOOL_BASE::board ( ) const
inlineprotectedinherited

Definition at line 166 of file pcb_tool_base.h.

166 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), PCB_INSPECTION_TOOL::ClearHighlight(), constrainDimension(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), drawArc(), DrawDimension(), drawSegment(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), ZONE_FILLER_TOOL::FillAllZones(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::getCollectorsGuide(), PCB_INSPECTION_TOOL::highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PCB_TOOL_BASE::module(), EDIT_TOOL::MoveExact(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::Paste(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), PAD_TOOL::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), ROUTER_TOOL::prepareInteractive(), SELECTION_TOOL::RebuildSelection(), PAD_TOOL::recombinePad(), EDIT_TOOL::Remove(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), SELECTION_TOOL::Selectable(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectConnectedTracks(), SELECTION_TOOL::selectPoint(), PCBNEW_CONTROL::TrackDisplayMode(), POINT_EDITOR::updateItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ canvas()

◆ constrainDimension()

void DRAWING_TOOL::constrainDimension ( DIMENSION aDim)
private

Function constrainDimension() Forces the dimension lime to be drawn on multiple of 45 degrees.

Parameters
aDimensionis the dimension element currently being drawn

Definition at line 501 of file drawing_tool.cpp.

502 {
503  const VECTOR2I lineVector{ aDim->GetEnd() - aDim->GetOrigin() };
504 
505  aDim->SetEnd( wxPoint( VECTOR2I( aDim->GetOrigin() ) + GetVectorSnapped45( lineVector ) ),
507 }
BOARD * board() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
const wxPoint & GetEnd()
Function GetEnd.
void SetEnd(const wxPoint &aEnd, int aPrecision)
Function SetEnd Sets a new end of the crossbar line.
const wxPoint & GetOrigin() const
Function GetOrigin.
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec)
Snap a vector onto the nearest 0, 45 or 90 degree line.

References PCB_TOOL_BASE::board(), BOARD::GetDesignSettings(), DIMENSION::GetEnd(), DIMENSION::GetOrigin(), GetVectorSnapped45(), BOARD_DESIGN_SETTINGS::m_DimensionPrecision, and DIMENSION::SetEnd().

Referenced by DrawDimension().

◆ controls()

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::doInteractiveItemPlacement ( const std::string &  aTool,
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 37 of file pcb_tool_base.cpp.

40 {
41  using namespace std::placeholders;
42  std::unique_ptr<BOARD_ITEM> newItem;
43 
44  frame()->PushTool( aTool );
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  PCBNEW_SELECTION preview;
57  view()->Add( &preview );
58 
59  aPlacer->m_board = board();
60  aPlacer->m_frame = frame();
61  aPlacer->m_modifiers = 0;
62 
63  auto makeNewItem = [&] ( VECTOR2I aPosition )
64  {
65  if( frame()->GetModel() )
66  newItem = aPlacer->CreateItem();
67 
68  if( newItem )
69  {
70  newItem->SetPosition( (wxPoint) aPosition );
71  preview.Add( newItem.get() );
72 
73  if( newItem->Type() == PCB_MODULE_T )
74  {
75  auto module = dyn_cast<MODULE*>( newItem.get() );
76 
77  // modules have more drawable parts
78  module->RunOnChildren( std::bind( &KIGFX::VIEW_GROUP::Add, &preview, _1 ) );
79  }
80  }
81  };
82 
83  if( aOptions & IPO_SINGLE_CLICK )
84  makeNewItem( controls()->GetCursorPosition() );
85 
86  // Main loop: keep receiving events
87  while( TOOL_EVENT* evt = Wait() )
88  {
89  if( !newItem )
90  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
91  else
92  frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
93 
94  VECTOR2I cursorPos = controls()->GetCursorPosition();
95  aPlacer->m_modifiers = evt->Modifier();
96 
97  auto cleanup = [&] ()
98  {
99  newItem = nullptr;
100  preview.Clear();
101  view()->Update( &preview );
102  controls()->SetAutoPan( false );
103  controls()->CaptureCursor( false );
104  controls()->ShowCursor( true );
105  };
106 
107  if( evt->IsCancelInteractive() )
108  {
109  if( aOptions & IPO_SINGLE_CLICK )
110  {
111  cleanup();
112  frame()->PopTool( aTool );
113  break;
114  }
115  else if( newItem )
116  cleanup();
117  else
118  {
119  frame()->PopTool( aTool );
120  break;
121  }
122  }
123  else if( evt->IsActivate() )
124  {
125  if( newItem )
126  cleanup();
127 
128  if( evt->IsPointEditor() )
129  {
130  // don't exit (the point editor runs in the background)
131  }
132  else if( evt->IsMoveTool() )
133  {
134  // leave ourselves on the stack so we come back after the move
135  break;
136  }
137  else
138  {
139  frame()->PopTool( aTool );
140  break;
141  }
142  }
143  else if( evt->IsClick( BUT_LEFT ) )
144  {
145  if( !newItem )
146  {
147  // create the item if possible
148  makeNewItem( cursorPos );
149 
150  // no item created, so wait for another click
151  if( !newItem )
152  continue;
153 
154  controls()->CaptureCursor( true );
155  controls()->SetAutoPan( true );
156  }
157  else
158  {
159  auto oldFlags = newItem->GetFlags();
160  newItem->ClearFlags();
161 
162  if( !aPlacer->PlaceItem( newItem.get(), commit ) )
163  {
164  newItem->SetFlags( oldFlags );
165  continue;
166  }
167 
168  preview.Clear();
169  newItem.release();
170  commit.Push( aCommitMessage );
171 
172  controls()->CaptureCursor( false );
173  controls()->SetAutoPan( false );
174  controls()->ShowCursor( true );
175 
176  if( !( aOptions & IPO_REPEAT ) )
177  break;
178 
179  if( aOptions & IPO_SINGLE_CLICK )
180  makeNewItem( controls()->GetCursorPosition() );
181  }
182  }
183  else if( evt->IsClick( BUT_RIGHT ) )
184  {
186  }
187  else if( newItem && evt->Category() == TC_COMMAND )
188  {
189  /*
190  * Handle any events that can affect the item as we move it around
191  */
192  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) && ( aOptions & IPO_ROTATE ) )
193  {
194  const int rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *frame(), *evt );
195  newItem->Rotate( newItem->GetPosition(), rotationAngle );
196  view()->Update( &preview );
197  }
198  else if( evt->IsAction( &PCB_ACTIONS::flip ) && ( aOptions & IPO_FLIP ) )
199  {
200  newItem->Flip( newItem->GetPosition(), frame()->Settings().m_FlipLeftRight );
201  view()->Update( &preview );
202  }
203  else if( evt->IsAction( &PCB_ACTIONS::viaSizeInc )
204  || evt->IsAction( &PCB_ACTIONS::viaSizeDec ) )
205  {
206  // Refresh preview after event runs
208  }
209  else if( evt->IsAction( &ACTIONS::refreshPreview ) )
210  {
211  preview.Clear();
212  newItem.release();
213 
214  makeNewItem( controls()->GetCursorPosition() );
215  view()->Update( &preview );
216  }
217  }
218 
219  else if( newItem && evt->IsMotion() )
220  {
221  // track the cursor
222  newItem->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
223  aPlacer->SnapItem( newItem.get() );
224 
225  // Show a preview of the item
226  view()->Update( &preview );
227  }
228 
229  else
230  evt->SetPassEvent();
231  }
232 
233  view()->Remove( &preview );
234 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:95
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
Handle flip action in the loop by calling the item's flip method.
BOARD * board() const
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:91
static TOOL_ACTION viaSizeInc
Definition: pcb_actions.h:282
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
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:140
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
virtual void Remove(VIEW_ITEM *aItem) override
Function Remove() Removes a VIEW_ITEM from the view.
Definition: pcb_view.cpp:74
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:76
TOOL_MANAGER * GetManager() const
Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143
PCB_BASE_EDIT_FRAME * frame() const
virtual void SnapItem(BOARD_ITEM *aItem)
class MODULE, a footprint
Definition: typeinfo.h:89
const PCBNEW_SELECTION & selection() const
Allow repeat placement of the item.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
TOOL_EVENT.
Definition: tool_event.h:171
KIGFX::PCB_VIEW * view() const
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:103
Handle the rotate action in the loop by calling the item's rotate method.
KIGFX::VIEW_CONTROLS * controls() const
MODULE * module() const
PCBNEW_SETTINGS & Settings()
void Activate()
Function Activate() Runs the tool.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Function Add() Adds a VIEW_ITEM to the view.
Definition: pcb_view.cpp:58
PCB_BASE_EDIT_FRAME * m_frame
Definition: pcb_tool_base.h:62
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
static TOOL_ACTION viaSizeDec
Definition: pcb_actions.h:283
static TOOL_ACTION refreshPreview
Definition: actions.h:102
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_BASE_FRAME::GetModel(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, PCBNEW_SETTINGS::m_FlipLeftRight, INTERACTIVE_PLACER_BASE::m_frame, TOOL_INTERACTIVE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, TOOL_BASE::m_toolMgr, PCB_TOOL_BASE::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), TOOLS_HOLDER::PopTool(), BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, KIGFX::PCB_VIEW::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), INTERACTIVE_PLACER_BASE::SnapItem(), TC_COMMAND, KIGFX::PCB_VIEW::Update(), PCB_ACTIONS::viaSizeDec, PCB_ACTIONS::viaSizeInc, PCB_TOOL_BASE::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

◆ DrawArc()

int DRAWING_TOOL::DrawArc ( const TOOL_EVENT aEvent)

Function DrawArc() Starts interactively drawing an arc.

After invoking the function it expects the user to first click on a point that is going to be used as the center of the arc. The second click determines the origin and radius, the third one - the angle.

Definition at line 266 of file drawing_tool.cpp.

267 {
268  if( m_editModules && !m_frame->GetModel() )
269  return 0;
270 
271  MODULE* module = dynamic_cast<MODULE*>( m_frame->GetModel() );
273  BOARD_COMMIT commit( m_frame );
274  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ARC );
275  bool immediateMode = aEvent.HasPosition();
276 
277  arc->SetFlags( IS_NEW );
278 
279  std::string tool = aEvent.GetCommandStr().get();
280  m_frame->PushTool( tool );
281  Activate();
282 
283  while( drawArc( tool, &arc, immediateMode ) )
284  {
285  if( arc )
286  {
287  if( m_editModules )
288  static_cast<EDGE_MODULE*>( arc )->SetLocalCoord();
289 
290  commit.Add( arc );
291  commit.Push( _( "Draw an arc" ) );
292 
294  }
295 
296  arc = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
297  arc->SetFlags( IS_NEW );
298  immediateMode = false;
299  }
300 
301  return 0;
302 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
RAII class that sets an value at construction and resets it to the original value at destruction.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
bool drawArc(const std::string &aTool, DRAWSEGMENT **aGraphic, bool aImmediateMode)
Starts drawing an arc.
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:65
void Activate()
Function Activate() Runs the tool.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260

References _, TOOL_INTERACTIVE::Activate(), COMMIT::Add(), ARC, drawArc(), TOOL_EVENT::GetCommandStr(), PCB_BASE_FRAME::GetModel(), TOOL_EVENT::HasPosition(), IS_NEW, PCB_TOOL_BASE::m_editModules, m_frame, m_mode, TOOL_BASE::m_toolMgr, PCB_TOOL_BASE::module(), BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectItem, and EDA_ITEM::SetFlags().

Referenced by setTransitions().

◆ drawArc()

bool DRAWING_TOOL::drawArc ( const std::string &  aTool,
DRAWSEGMENT **  aGraphic,
bool  aImmediateMode 
)
private

Starts drawing an arc.

Parameters
aGraphicis an object that is going to be used by the tool for drawing. Must be already created. The tool deletes the object if it is not added to a BOARD.
Returns
False if the tool was cancelled before the origin was set or origin and end are the same point.

Definition at line 1264 of file drawing_tool.cpp.

1265 {
1266  DRAWSEGMENT*& graphic = *aGraphic;
1268 
1269  // Arc geometric construction manager
1271 
1272  // Arc drawing assistant overlay
1273  KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() );
1274 
1275  // Add a VIEW_GROUP that serves as a preview for the new item
1276  PCBNEW_SELECTION preview;
1277  m_view->Add( &preview );
1278  m_view->Add( &arcAsst );
1280 
1281  m_controls->ShowCursor( true );
1282  m_controls->SetSnapping( true );
1283 
1284  bool firstPoint = false;
1285  bool cancelled = false;
1286 
1287  // Prime the pump
1289 
1290  if( aImmediateMode )
1292 
1293  // Main loop: keep receiving events
1294  while( TOOL_EVENT* evt = Wait() )
1295  {
1296  PCB_LAYER_ID layer = m_frame->GetActiveLayer();
1297  graphic->SetLayer( layer );
1298 
1299  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
1300  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1301  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1302  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1303  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic );
1304  m_controls->ForceCursorPosition( true, cursorPos );
1305 
1306  auto cleanup = [&] () {
1307  preview.Clear();
1308  delete *aGraphic;
1309  *aGraphic = nullptr;
1310  };
1311 
1312  if( evt->IsCancelInteractive() )
1313  {
1314  cleanup();
1315 
1316  if( !firstPoint )
1317  {
1318  m_frame->PopTool( aTool );
1319  cancelled = true;
1320  }
1321 
1322  break;
1323  }
1324  else if( evt->IsActivate() )
1325  {
1326  if( evt->IsPointEditor() )
1327  {
1328  // don't exit (the point editor runs in the background)
1329  }
1330  else if( evt->IsMoveTool() )
1331  {
1332  cleanup();
1333  // leave ourselves on the stack so we come back after the move
1334  cancelled = true;
1335  break;
1336  }
1337  else
1338  {
1339  cleanup();
1340  m_frame->PopTool( aTool );
1341  cancelled = true;
1342  break;
1343  }
1344  }
1345  else if( evt->IsClick( BUT_LEFT ) )
1346  {
1347  if( !firstPoint )
1348  {
1350 
1351  m_controls->SetAutoPan( true );
1352  m_controls->CaptureCursor( true );
1353 
1355 
1356  // Init the new item attributes
1357  // (non-geometric, those are handled by the manager)
1358  graphic->SetShape( S_ARC );
1359  graphic->SetWidth( m_lineWidth );
1360 
1361  preview.Add( graphic );
1362  firstPoint = true;
1363  }
1364 
1365  arcManager.AddPoint( cursorPos, true );
1366  }
1367  else if( evt->IsAction( &PCB_ACTIONS::deleteLastPoint ) )
1368  {
1369  arcManager.RemoveLastPoint();
1370  }
1371  else if( evt->IsMotion() )
1372  {
1373  // set angle snap
1374  arcManager.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1375 
1376  // update, but don't step the manager state
1377  arcManager.AddPoint( cursorPos, false );
1378  }
1379  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1380  {
1382  graphic->SetLayer( m_frame->GetActiveLayer() );
1383  graphic->SetWidth( m_lineWidth );
1384  m_view->Update( &preview );
1385  frame()->SetMsgPanel( graphic );
1386  }
1387  else if( evt->IsClick( BUT_RIGHT ) )
1388  {
1390  }
1391  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1392  {
1394  graphic->SetWidth( m_lineWidth );
1395  m_view->Update( &preview );
1396  frame()->SetMsgPanel( graphic );
1397  }
1398  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && m_lineWidth > WIDTH_STEP )
1399  {
1401  graphic->SetWidth( m_lineWidth );
1402  m_view->Update( &preview );
1403  frame()->SetMsgPanel( graphic );
1404  }
1405  else if( evt->IsAction( &PCB_ACTIONS::arcPosture ) )
1406  {
1407  arcManager.ToggleClockwise();
1408  }
1409  else
1410  evt->SetPassEvent();
1411 
1412  if( arcManager.IsComplete() )
1413  {
1414  break;
1415  }
1416  else if( arcManager.HasGeometryChanged() )
1417  {
1418  updateArcFromConstructionMgr( arcManager, *graphic );
1419  m_view->Update( &preview );
1420  m_view->Update( &arcAsst );
1421 
1422  if( firstPoint )
1423  frame()->SetMsgPanel( graphic );
1424  else
1425  frame()->SetMsgPanel( board() );
1426  }
1427  }
1428 
1429  preview.Remove( graphic );
1430  m_view->Remove( &arcAsst );
1431  m_view->Remove( &preview );
1432  frame()->SetMsgPanel( board() );
1433  m_controls->SetAutoPan( false );
1434  m_controls->CaptureCursor( false );
1435  m_controls->ForceCursorPosition( false );
1436 
1437  return !cancelled;
1438 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
void SetShape(STROKE_T aShape)
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
BOARD * board() const
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:160
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:234
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
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:140
static void updateArcFromConstructionMgr(const KIGFX::PREVIEW::ARC_GEOM_MANAGER &aMgr, DRAWSEGMENT &aArc)
Update an arc DRAWSEGMENT from the current state of an Arc Geometry Manager.
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:163
KIGFX::VIEW * m_view
Definition: drawing_tool.h:227
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
PCB_LAYER_ID
A quick note on layer IDs:
const PCBNEW_SELECTION & selection() const
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
Arcs (with rounded ends)
TOOL_EVENT.
Definition: tool_event.h:171
unsigned int m_lineWidth
Definition: drawing_tool.h:233
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:228
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
int getSegmentWidth(PCB_LAYER_ID aLayer) const
Returns the appropriate width for a segment depending on the settings.
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
static TOOL_ACTION arcPosture
Switch posture when drawing arc.
Definition: pcb_actions.h:166
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:275
static TOOL_ACTION deleteLastPoint
Definition: pcb_actions.h:156
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
static TOOL_ACTION refreshPreview
Definition: actions.h:102
static TOOL_ACTION cursorClick
Definition: actions.h:119
void SetWidth(int aWidth)

References KIGFX::VIEW::Add(), PCB_ACTIONS::arcPosture, PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), ACTIONS::cursorClick, PCB_ACTIONS::decWidth, PCB_ACTIONS::deleteLastPoint, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetMagneticItemsSettings(), KIGFX::VIEW_CONTROLS::GetMousePosition(), getSegmentWidth(), EDA_BASE_FRAME::GetUserUnits(), PCB_ACTIONS::incWidth, PCB_ACTIONS::layerChanged, m_controls, m_frame, m_lineWidth, TOOL_INTERACTIVE::m_menu, TOOL_BASE::m_toolMgr, m_view, MD_ALT, MD_CTRL, MD_SHIFT, TOOLS_HOLDER::PopTool(), ACTIONS::refreshPreview, KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), S_ARC, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), BOARD_ITEM::SetLayer(), EDA_DRAW_FRAME::SetMsgPanel(), DRAWSEGMENT::SetShape(), KIGFX::VIEW_CONTROLS::SetSnapping(), DRAWSEGMENT::SetWidth(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::VIEW::Update(), updateArcFromConstructionMgr(), TOOL_INTERACTIVE::Wait(), and WIDTH_STEP.

Referenced by DrawArc().

◆ DrawCircle()

int DRAWING_TOOL::DrawCircle ( const TOOL_EVENT aEvent)

Function DrawCircle() Starts interactively drawing a circle.

After invoking the function it expects the user to first click on a point that is going to be used as the center of the circle. The second click determines the circle radius.

Definition at line 224 of file drawing_tool.cpp.

225 {
226  if( m_editModules && !m_frame->GetModel() )
227  return 0;
228 
229  MODULE* module = dynamic_cast<MODULE*>( m_frame->GetModel() );
230  DRAWSEGMENT* circle = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
231  BOARD_COMMIT commit( m_frame );
232  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::CIRCLE );
233  OPT<VECTOR2D> startingPoint = boost::make_optional<VECTOR2D>( false, VECTOR2D( 0, 0 ) );
234 
235  circle->SetFlags( IS_NEW );
236 
237  if( aEvent.HasPosition() )
238  startingPoint = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
239 
240  std::string tool = aEvent.GetCommandStr().get();
241  m_frame->PushTool( tool );
242  Activate();
243 
244  while( drawSegment( tool, S_CIRCLE, &circle, startingPoint ) )
245  {
246  if( circle )
247  {
248  if( m_editModules )
249  static_cast<EDGE_MODULE*>( circle )->SetLocalCoord();
250 
251  commit.Add( circle );
252  commit.Push( _( "Draw a circle" ) );
253 
254  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, circle );
255  }
256 
257  circle = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
258  circle->SetFlags( IS_NEW );
259  startingPoint = NULLOPT;
260  }
261 
262  return 0;
263 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
RAII class that sets an value at construction and resets it to the original value at destruction.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
const auto NULLOPT
Definition: optional.h:9
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:65
boost::optional< T > OPT
Definition: optional.h:7
void Activate()
Function Activate() Runs the tool.
bool drawSegment(const std::string &aTool, int aShape, DRAWSEGMENT **aGraphic, OPT< VECTOR2D > aStartingPoint)
Starts drawing a selected shape (i.e.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References _, TOOL_INTERACTIVE::Activate(), COMMIT::Add(), CIRCLE, drawSegment(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetModel(), TOOL_BASE::getViewControls(), TOOL_EVENT::HasPosition(), IS_NEW, PCB_TOOL_BASE::m_editModules, m_frame, m_mode, TOOL_BASE::m_toolMgr, MD_ALT, TOOL_EVENT::Modifier(), PCB_TOOL_BASE::module(), NULLOPT, BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), TOOL_MANAGER::RunAction(), S_CIRCLE, PCB_ACTIONS::selectItem, and EDA_ITEM::SetFlags().

Referenced by setTransitions().

◆ DrawDimension()

int DRAWING_TOOL::DrawDimension ( const TOOL_EVENT aEvent)

Function DrawDimension() Starts interactively drawing a dimension.

After invoking the function it expects the user to first click on a point that is going to be used as the origin of the dimension. The second click determines the end and the third click modifies its height.

Definition at line 510 of file drawing_tool.cpp.

511 {
512  if( m_editModules && !m_frame->GetModel() )
513  return 0;
514 
515  POINT_EDITOR* pointEditor = m_toolMgr->GetTool<POINT_EDITOR>();
516  DIMENSION* dimension = NULL;
517  BOARD_COMMIT commit( m_frame );
519 
520  const BOARD_DESIGN_SETTINGS& boardSettings = m_board->GetDesignSettings();
521 
522  // Add a VIEW_GROUP that serves as a preview for the new item
523  PCBNEW_SELECTION preview;
524 
525  m_view->Add( &preview );
526 
528  m_controls->ShowCursor( true );
529  m_controls->SetSnapping( true );
530 
531  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
532 
533  std::string tool = aEvent.GetCommandStr().get();
534  m_frame->PushTool( tool );
535  Activate();
536 
537  enum DIMENSION_STEPS
538  {
539  SET_ORIGIN = 0,
540  SET_END,
541  SET_HEIGHT,
542  FINISHED
543  };
544  int step = SET_ORIGIN;
545 
546  // Prime the pump
548 
549  if( aEvent.HasPosition() )
550  m_toolMgr->PrimeTool( aEvent.Position() );
551 
552  // Main loop: keep receiving events
553  while( TOOL_EVENT* evt = Wait() )
554  {
555  if( !pointEditor->HasPoint() )
556  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
557 
558  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
559  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
560  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
561  VECTOR2I cursorPos = grid.BestSnapAnchor(
562  evt->IsPrime() ? evt->Position() : m_controls->GetMousePosition(), nullptr );
563  m_controls->ForceCursorPosition( true, cursorPos );
564 
565  auto cleanup = [&] () {
566  m_controls->SetAutoPan( false );
567  m_controls->CaptureCursor( false );
568 
569  preview.Clear();
570  m_view->Update( &preview );
571 
572  delete dimension;
573  dimension = nullptr;
574  step = SET_ORIGIN;
575  };
576 
577  if( evt->IsCancelInteractive() )
578  {
579  m_controls->SetAutoPan( false );
580 
581  if( step != SET_ORIGIN ) // start from the beginning
582  cleanup();
583  else
584  {
585  m_frame->PopTool( tool );
586  break;
587  }
588  }
589  else if( evt->IsActivate() )
590  {
591  if( step != SET_ORIGIN )
592  cleanup();
593 
594  if( evt->IsPointEditor() )
595  {
596  // don't exit (the point editor runs in the background)
597  }
598  else if( evt->IsMoveTool() )
599  {
600  // leave ourselves on the stack so we come back after the move
601  break;
602  }
603  else
604  {
605  m_frame->PopTool( tool );
606  break;
607  }
608  }
609  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) && step != SET_ORIGIN )
610  {
612  dimension->SetWidth( m_lineWidth );
613  m_view->Update( &preview );
614  frame()->SetMsgPanel( dimension );
615  }
616  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && step != SET_ORIGIN )
617  {
618  if( m_lineWidth > WIDTH_STEP )
619  {
621  dimension->SetWidth( m_lineWidth );
622  m_view->Update( &preview );
623  frame()->SetMsgPanel( dimension );
624  }
625  }
626  else if( evt->IsClick( BUT_RIGHT ) )
627  {
629  }
630  else if( evt->IsClick( BUT_LEFT ) )
631  {
632  switch( step )
633  {
634  case SET_ORIGIN:
635  {
637 
639 
640  if( layer == Edge_Cuts ) // dimensions are not allowed on EdgeCuts
641  layer = Dwgs_User;
642 
643  // Init the new item attributes
644  dimension = new DIMENSION( m_board );
645  dimension->SetLayer( layer );
646  dimension->SetOrigin( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
647  dimension->SetEnd( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
648  dimension->Text().SetTextSize( boardSettings.GetTextSize( layer ) );
649  dimension->Text().SetTextThickness( boardSettings.GetTextThickness( layer ) );
650  dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) );
651  dimension->SetWidth( boardSettings.GetLineThickness( layer ) );
652  dimension->SetUnits( boardSettings.m_DimensionUnits == 2 ? EDA_UNITS::MILLIMETRES :
654  boardSettings.m_DimensionUnits == 1 );
655  dimension->AdjustDimensionDetails( boardSettings.m_DimensionPrecision );
656 
657  preview.Add( dimension );
658  frame()->SetMsgPanel( dimension );
659 
660  m_controls->SetAutoPan( true );
661  m_controls->CaptureCursor( true );
662  }
663  break;
664 
665  case SET_END:
666  dimension->SetEnd( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
667 
668  if( !!evt->Modifier( MD_CTRL ) )
669  constrainDimension( dimension );
670 
671  // Dimensions that have origin and end in the same spot are not valid
672  if( dimension->GetOrigin() == dimension->GetEnd() )
673  --step;
674 
675  break;
676 
677  case SET_HEIGHT:
678  {
679  if( (wxPoint) cursorPos != dimension->GetPosition() )
680  {
681  assert( dimension->GetOrigin() != dimension->GetEnd() );
682  assert( dimension->GetWidth() > 0 );
683 
684  preview.Remove( dimension );
685 
686  commit.Add( dimension );
687  commit.Push( _( "Draw a dimension" ) );
688 
689  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, dimension );
690  }
691  }
692  break;
693  }
694 
695  if( ++step == FINISHED )
696  {
697  step = SET_ORIGIN;
698  m_controls->SetAutoPan( false );
699  m_controls->CaptureCursor( false );
700  }
701  }
702  else if( evt->IsMotion() )
703  {
704  switch( step )
705  {
706  case SET_END:
707  dimension->SetEnd( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
708 
709  if( !!evt->Modifier( MD_CTRL ) )
710  constrainDimension( dimension );
711 
712  break;
713 
714  case SET_HEIGHT:
715  {
716  // Calculating the direction of travel perpendicular to the selected axis
717  double angle = dimension->GetAngle() + ( M_PI / 2 );
718 
719  wxPoint delta( (wxPoint) cursorPos - dimension->m_featureLineDO );
720  double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
721  dimension->SetHeight( height, boardSettings.m_DimensionPrecision );
722  }
723  break;
724  }
725 
726  // Show a preview of the item
727  m_view->Update( &preview );
728  if( step )
729  frame()->SetMsgPanel( dimension );
730  else
731  frame()->SetMsgPanel( board() );
732  }
733  else
734  evt->SetPassEvent();
735  }
736 
737  if( step != SET_ORIGIN )
738  delete dimension;
739 
740  m_controls->SetAutoPan( false );
742  m_controls->CaptureCursor( false );
743 
744  m_view->Remove( &preview );
745  frame()->SetMsgPanel( board() );
746  return 0;
747 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:95
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
BOARD * board() const
BOARD * m_board
Definition: drawing_tool.h:229
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:160
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:234
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
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:140
void PrimeTool(const VECTOR2D &aPosition)
Function PrimeTool() "Primes" a tool by sending a cursor left-click event with the mouse position set...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:163
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:76
KIGFX::VIEW * m_view
Definition: drawing_tool.h:227
void constrainDimension(DIMENSION *aDim)
Function constrainDimension() Forces the dimension lime to be drawn on multiple of 45 degrees.
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
PCB_LAYER_ID
A quick note on layer IDs:
RAII class that sets an value at construction and resets it to the original value at destruction.
const PCBNEW_SELECTION & selection() const
#define NULL
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
TOOL_EVENT.
Definition: tool_event.h:171
unsigned int m_lineWidth
Definition: drawing_tool.h:233
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:228
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
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
#define _(s)
Definition: 3d_actions.cpp:33
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:65
bool HasPoint()
Indicates the cursor is over an edit point.
Definition: point_editor.h:65
POINT_EDITOR.
Definition: point_editor.h:43
void Activate()
Function Activate() Runs the tool.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
DIMENSION.
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:274
static TOOL_ACTION refreshPreview
Definition: actions.h:102
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:87

References _, TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), PNS::angle(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), constrainDimension(), PCB_ACTIONS::decWidth, DIMENSION, Dwgs_User, Edge_Cuts, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), BOARD::GetDesignSettings(), PCB_BASE_FRAME::GetMagneticItemsSettings(), PCB_BASE_FRAME::GetModel(), KIGFX::VIEW_CONTROLS::GetMousePosition(), TOOL_MANAGER::GetTool(), POINT_EDITOR::HasPoint(), TOOL_EVENT::HasPosition(), INCHES, PCB_ACTIONS::incWidth, m_board, m_controls, PCB_TOOL_BASE::m_editModules, m_frame, m_lineWidth, TOOL_INTERACTIVE::m_menu, m_mode, TOOL_BASE::m_toolMgr, m_view, MD_ALT, MD_CTRL, MD_SHIFT, MILLIMETRES, NULL, TOOLS_HOLDER::PopTool(), TOOL_EVENT::Position(), TOOL_MANAGER::PrimeTool(), BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), ACTIONS::refreshPreview, SELECTION::Remove(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), EDA_DRAW_FRAME::SetMsgPanel(), KIGFX::VIEW_CONTROLS::SetSnapping(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), WIDTH_STEP, wxPoint::x, and wxPoint::y.

Referenced by setTransitions().

◆ DrawLine()

int DRAWING_TOOL::DrawLine ( const TOOL_EVENT aEvent)

Function DrawLine() Starts interactively drawing a line.

After invoking the function it expects the user to click at least two times to determine the origin and the end for a line. If there are more clicks, the line is drawn as a continous polyline.

Definition at line 138 of file drawing_tool.cpp.

139 {
140  if( m_editModules && !m_frame->GetModel() )
141  return 0;
142 
143  MODULE* module = dynamic_cast<MODULE*>( m_frame->GetModel() );
144  DRAWSEGMENT* line = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
145  BOARD_COMMIT commit( m_frame );
146  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::LINE );
147  OPT<VECTOR2D> startingPoint = boost::make_optional<VECTOR2D>( false, VECTOR2D( 0, 0 ) );
148 
149  line->SetFlags( IS_NEW );
150 
151  if( aEvent.HasPosition() )
152  startingPoint = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
153 
154  std::string tool = aEvent.GetCommandStr().get();
155  m_frame->PushTool( tool );
156  Activate();
157 
158  while( drawSegment( tool, S_SEGMENT, &line, startingPoint ) )
159  {
160  if( line )
161  {
162  if( m_editModules )
163  static_cast<EDGE_MODULE*>( line )->SetLocalCoord();
164 
165  commit.Add( line );
166  commit.Push( _( "Draw a line segment" ) );
167  startingPoint = VECTOR2D( line->GetEnd() );
168  }
169  else
170  {
171  startingPoint = NULLOPT;
172  }
173 
174  line = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
175  line->SetFlags( IS_NEW );
176  }
177 
178  return 0;
179 }
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
usual segment : line with rounded ends
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
RAII class that sets an value at construction and resets it to the original value at destruction.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
const auto NULLOPT
Definition: optional.h:9
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
boost::optional< T > OPT
Definition: optional.h:7
void Activate()
Function Activate() Runs the tool.
bool drawSegment(const std::string &aTool, int aShape, DRAWSEGMENT **aGraphic, OPT< VECTOR2D > aStartingPoint)
Starts drawing a selected shape (i.e.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References _, TOOL_INTERACTIVE::Activate(), COMMIT::Add(), drawSegment(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetModel(), TOOL_BASE::getViewControls(), TOOL_EVENT::HasPosition(), IS_NEW, LINE, PCB_TOOL_BASE::m_editModules, m_frame, m_mode, MD_ALT, TOOL_EVENT::Modifier(), PCB_TOOL_BASE::module(), NULLOPT, BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), S_SEGMENT, and EDA_ITEM::SetFlags().

Referenced by setTransitions().

◆ DrawRectangle()

int DRAWING_TOOL::DrawRectangle ( const TOOL_EVENT aEvent)

Function DrawRectangle() Starts interactively drawing a rectangle.

After invoking the function it expects the user to first click on a point that is going to be used as the top-left of the rectangle. The second click determines the bottom-right.

Definition at line 182 of file drawing_tool.cpp.

183 {
184  if( m_editModules && !m_frame->GetModel() )
185  return 0;
186 
187  MODULE* module = dynamic_cast<MODULE*>( m_frame->GetModel() );
188  DRAWSEGMENT* rect = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
189  BOARD_COMMIT commit( m_frame );
190  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::RECTANGLE );
191  OPT<VECTOR2D> startingPoint = boost::make_optional<VECTOR2D>( false, VECTOR2D( 0, 0 ) );
192 
193  rect->SetFlags(IS_NEW );
194 
195  if( aEvent.HasPosition() )
196  startingPoint = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
197 
198  std::string tool = aEvent.GetCommandStr().get();
199  m_frame->PushTool( tool );
200  Activate();
201 
202  while( drawSegment( tool, S_RECT, &rect, startingPoint ) )
203  {
204  if( rect )
205  {
206  if( m_editModules )
207  static_cast<EDGE_MODULE*>( rect )->SetLocalCoord();
208 
209  commit.Add( rect );
210  commit.Push( _( "Draw a rectangle" ) );
211 
213  }
214 
215  rect = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
216  rect->SetFlags(IS_NEW );
217  startingPoint = NULLOPT;
218  }
219 
220  return 0;
221 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
segment with non rounded ends
RAII class that sets an value at construction and resets it to the original value at destruction.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
const auto NULLOPT
Definition: optional.h:9
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:65
boost::optional< T > OPT
Definition: optional.h:7
void Activate()
Function Activate() Runs the tool.
bool drawSegment(const std::string &aTool, int aShape, DRAWSEGMENT **aGraphic, OPT< VECTOR2D > aStartingPoint)
Starts drawing a selected shape (i.e.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

References _, TOOL_INTERACTIVE::Activate(), COMMIT::Add(), drawSegment(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetModel(), TOOL_BASE::getViewControls(), TOOL_EVENT::HasPosition(), IS_NEW, PCB_TOOL_BASE::m_editModules, m_frame, m_mode, TOOL_BASE::m_toolMgr, MD_ALT, TOOL_EVENT::Modifier(), PCB_TOOL_BASE::module(), NULLOPT, BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), RECTANGLE, TOOL_MANAGER::RunAction(), S_RECT, PCB_ACTIONS::selectItem, and EDA_ITEM::SetFlags().

Referenced by setTransitions().

◆ drawSegment()

bool DRAWING_TOOL::drawSegment ( const std::string &  aTool,
int  aShape,
DRAWSEGMENT **  aGraphic,
OPT< VECTOR2D aStartingPoint 
)
private

Starts drawing a selected shape (i.e.

DRAWSEGMENT).

Parameters
aShapeis the type of created shape (
See also
STROKE_T).
Parameters
aGraphicis an object that is going to be used by the tool for drawing. Must be already created. The tool deletes the object if it is not added to a BOARD.
aStartingPointis a starting point for this new DRAWSEGMENT. If it exists the new item has its start point set to aStartingPoint, and its settings (width, layer) set to the current default values.
Returns
False if the tool was cancelled before the origin was set or origin and end are the same point.

Definition at line 972 of file drawing_tool.cpp.

974 {
975  // Only three shapes are currently supported
976  assert( aShape == S_SEGMENT || aShape == S_CIRCLE || aShape == S_RECT );
978  POINT_EDITOR* pointEditor = m_toolMgr->GetTool<POINT_EDITOR>();
979  DRAWSEGMENT*& graphic = *aGraphic;
980 
982 
983  // geometric construction manager
985 
986  // drawing assistant overlay
987  // TODO: workaround because STROKE_T is not visible from commons.
988  KIGFX::PREVIEW::GEOM_SHAPE geomShape =
993  twoPointManager, m_frame->GetUserUnits(), geomShape );
994 
995  // Add a VIEW_GROUP that serves as a preview for the new item
996  PCBNEW_SELECTION preview;
997  m_view->Add( &preview );
998  m_view->Add( &twoPointAsst );
999 
1000  m_controls->ShowCursor( true );
1001 
1002  bool direction45 = false; // 45 degrees only mode
1003  bool started = false;
1004  bool cancelled = false;
1005  bool isLocalOriginSet = ( m_frame->GetScreen()->m_LocalOrigin != VECTOR2D( 0, 0 ) );
1006  VECTOR2I cursorPos = m_controls->GetMousePosition();
1007 
1008  // Prime the pump
1010 
1011  if( aStartingPoint )
1013 
1014  // Main loop: keep receiving events
1015  while( TOOL_EVENT* evt = Wait() )
1016  {
1017  if( !pointEditor->HasPoint() )
1018  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
1019 
1020  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1021  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1022  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1023  cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), m_frame->GetActiveLayer() );
1024  m_controls->ForceCursorPosition( true, cursorPos );
1025 
1026  // 45 degree angle constraint enabled with an option and toggled with Ctrl
1027  bool limit45 = frame()->Settings().m_Use45DegreeGraphicSegments;
1028 
1029  if( evt->Modifier( MD_CTRL ) )
1030  limit45 = !limit45;
1031 
1032  if( direction45 != limit45 && started && aShape == S_SEGMENT )
1033  {
1034  direction45 = limit45;
1035 
1036  if( direction45 )
1037  {
1038  const VECTOR2I lineVector( cursorPos - VECTOR2I( twoPointManager.GetOrigin() ) );
1039 
1040  // get a restricted 45/H/V line from the last fixed point to the cursor
1041  auto newEnd = GetVectorSnapped45( lineVector );
1042  m_controls->ForceCursorPosition( true, VECTOR2I( twoPointManager.GetEnd() ) );
1043  twoPointManager.SetEnd( twoPointManager.GetOrigin() + (wxPoint) newEnd );
1044  twoPointManager.SetAngleSnap( true );
1045  }
1046  else
1047  {
1048  twoPointManager.SetEnd( (wxPoint) cursorPos );
1049  twoPointManager.SetAngleSnap( false );
1050  }
1051 
1052  updateSegmentFromConstructionMgr( twoPointManager, graphic );
1053  m_view->Update( &preview );
1054  m_view->Update( &twoPointAsst );
1055 
1056  frame()->SetMsgPanel( graphic );
1057  }
1058 
1059  auto cleanup = [&] () {
1060  preview.Clear();
1061  m_view->Update( &preview );
1062  delete graphic;
1063  graphic = nullptr;
1064 
1065  if( !isLocalOriginSet )
1066  m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
1067  };
1068 
1069  if( evt->IsCancelInteractive() )
1070  {
1071  cleanup();
1072 
1073  if( !started )
1074  {
1075  m_frame->PopTool( aTool );
1076  cancelled = true;
1077  }
1078 
1079  break;
1080  }
1081  else if( evt->IsActivate() )
1082  {
1083  if( evt->IsPointEditor() )
1084  {
1085  // don't exit (the point editor runs in the background)
1086  }
1087  else if( evt->IsMoveTool() )
1088  {
1089  cleanup();
1090  // leave ourselves on the stack so we come back after the move
1091  cancelled = true;
1092  break;
1093  }
1094  else
1095  {
1096  cleanup();
1097  m_frame->PopTool( aTool );
1098  cancelled = true;
1099  break;
1100  }
1101  }
1102  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1103  {
1105  graphic->SetLayer( m_frame->GetActiveLayer() );
1106  graphic->SetWidth( m_lineWidth );
1107  m_view->Update( &preview );
1108  frame()->SetMsgPanel( graphic );
1109  }
1110  else if( evt->IsClick( BUT_RIGHT ) )
1111  {
1113  }
1114  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
1115  {
1116  if( !started )
1117  {
1119 
1120  if( aStartingPoint )
1121  {
1122  cursorPos = aStartingPoint.get();
1123  aStartingPoint = NULLOPT;
1124  }
1125 
1127 
1128  // Init the new item attributes
1129  graphic->SetShape( (STROKE_T) aShape );
1130  graphic->SetWidth( m_lineWidth );
1131  graphic->SetLayer( m_frame->GetActiveLayer() );
1132  grid.SetSkipPoint( cursorPos );
1133 
1134  twoPointManager.SetOrigin( (wxPoint) cursorPos );
1135  twoPointManager.SetEnd( (wxPoint) cursorPos );
1136 
1137  if( !isLocalOriginSet )
1138  m_frame->GetScreen()->m_LocalOrigin = cursorPos;
1139 
1140  preview.Add( graphic );
1141  frame()->SetMsgPanel( graphic );
1142  m_controls->SetAutoPan( true );
1143  m_controls->CaptureCursor( true );
1144 
1145  updateSegmentFromConstructionMgr( twoPointManager, graphic );
1146 
1147  started = true;
1148  }
1149  else
1150  {
1151  auto snapItem = dyn_cast<DRAWSEGMENT*>( grid.GetSnapped() );
1152 
1153  if( twoPointManager.GetOrigin() == twoPointManager.GetEnd()
1154  || ( evt->IsDblClick( BUT_LEFT ) && aShape == S_SEGMENT ) || snapItem )
1155  // User has clicked twice in the same spot
1156  // or clicked on the end of an existing segment (closing a path)
1157  {
1158  BOARD_COMMIT commit( m_frame );
1159 
1160  // If the user clicks on an existing snap point from a drawsegment
1161  // we finish the segment as they are likely closing a path
1162  if( snapItem && graphic->GetLength() > 0.0 )
1163  {
1164  commit.Add( graphic );
1165  commit.Push( _( "Draw a line segment" ) );
1166  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, graphic );
1167  }
1168  else
1169  {
1170  delete graphic;
1171  }
1172 
1173  graphic = nullptr;
1174  }
1175 
1176  preview.Clear();
1177  break;
1178  }
1179 
1180  twoPointManager.SetEnd( cursorPos );
1181  }
1182  else if( evt->IsMotion() )
1183  {
1184  // 45 degree lines
1185  if( direction45 && aShape == S_SEGMENT )
1186  {
1187  const VECTOR2I lineVector( cursorPos - VECTOR2I( twoPointManager.GetOrigin() ) );
1188 
1189  // get a restricted 45/H/V line from the last fixed point to the cursor
1190  auto newEnd = GetVectorSnapped45( lineVector );
1191  m_controls->ForceCursorPosition( true, VECTOR2I( twoPointManager.GetEnd() ) );
1192  twoPointManager.SetEnd( twoPointManager.GetOrigin() + (wxPoint) newEnd );
1193  twoPointManager.SetAngleSnap( true );
1194  }
1195  else
1196  {
1197  twoPointManager.SetEnd( (wxPoint) cursorPos );
1198  twoPointManager.SetAngleSnap( false );
1199  }
1200 
1201  updateSegmentFromConstructionMgr( twoPointManager, graphic );
1202  m_view->Update( &preview );
1203  m_view->Update( &twoPointAsst );
1204 
1205  if( started )
1206  frame()->SetMsgPanel( graphic );
1207  else
1208  frame()->SetMsgPanel( board() );
1209  }
1210  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1211  {
1213  graphic->SetWidth( m_lineWidth );
1214  m_view->Update( &preview );
1215  frame()->SetMsgPanel( graphic );
1216  }
1217  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && ( m_lineWidth > WIDTH_STEP ) )
1218  {
1220  graphic->SetWidth( m_lineWidth );
1221  m_view->Update( &preview );
1222  frame()->SetMsgPanel( graphic );
1223  }
1224  else if( evt->IsAction( &ACTIONS::resetLocalCoords ) )
1225  {
1226  isLocalOriginSet = true;
1227  }
1228  else
1229  evt->SetPassEvent();
1230  }
1231 
1232  if( !isLocalOriginSet ) // reset the relative coordinte if it was not set before
1233  m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
1234 
1235  m_view->Remove( &twoPointAsst );
1236  m_view->Remove( &preview );
1237  frame()->SetMsgPanel( board() );
1238  m_controls->SetAutoPan( false );
1239  m_controls->CaptureCursor( false );
1240  m_controls->ForceCursorPosition( false );
1241 
1242  return !cancelled;
1243 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
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()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
BOARD * board() const
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:160
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:234
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
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:140
usual segment : line with rounded ends
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
VECTOR2< int > VECTOR2I
Definition: vector2d.h:594
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:163
KIGFX::VIEW * m_view
Definition: drawing_tool.h:227
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
bool m_Use45DegreeGraphicSegments
segment with non rounded ends
const PCBNEW_SELECTION & selection() const
const auto NULLOPT
Definition: optional.h:9
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
TOOL_EVENT.
Definition: tool_event.h:171
static void updateSegmentFromConstructionMgr(const KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER &aMgr, DRAWSEGMENT *aGraphic)
Update an DRAWSEGMENT from the current state of an Two POINT Geometry Manager.
unsigned int m_lineWidth
Definition: drawing_tool.h:233
STROKE_T
Enum STROKE_T is the set of shapes for segments (graphic segments and tracks) which are often in the ...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:228
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
int getSegmentWidth(PCB_LAYER_ID aLayer) const
Returns the appropriate width for a segment depending on the settings.
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:275
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:65
PCBNEW_SETTINGS & Settings()
POINT_EDITOR.
Definition: point_editor.h:43
static TOOL_ACTION resetLocalCoords
Definition: actions.h:144
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec)
Snap a vector onto the nearest 0, 45 or 90 degree line.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
EDA_UNITS GetUserUnits() const
Return the user units currently in use.
static TOOL_ACTION refreshPreview
Definition: actions.h:102
static TOOL_ACTION cursorClick
Definition: actions.h:119
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:62

References _, COMMIT::Add(), KIGFX::VIEW::Add(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), KIGFX::PREVIEW::CIRCLE, ACTIONS::cursorClick, PCB_ACTIONS::decWidth, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), PCB_BASE_FRAME::GetMagneticItemsSettings(), KIGFX::VIEW_CONTROLS::GetMousePosition(), PCB_BASE_FRAME::GetScreen(), getSegmentWidth(), TOOL_MANAGER::GetTool(), EDA_BASE_FRAME::GetUserUnits(), GetVectorSnapped45(), PCB_ACTIONS::incWidth, PCB_ACTIONS::layerChanged, m_controls, m_frame, m_lineWidth, BASE_SCREEN::m_LocalOrigin, TOOL_INTERACTIVE::m_menu, TOOL_BASE::m_toolMgr, PCBNEW_SETTINGS::m_Use45DegreeGraphicSegments, m_view, MD_ALT, MD_CTRL, MD_SHIFT, NULLOPT, TOOLS_HOLDER::PopTool(), BOARD_COMMIT::Push(), KIGFX::PREVIEW::RECT, ACTIONS::refreshPreview, KIGFX::VIEW::Remove(), ACTIONS::resetLocalCoords, TOOL_MANAGER::RunAction(), S_CIRCLE, S_RECT, S_SEGMENT, KIGFX::PREVIEW::SEGMENT, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), EDA_DRAW_FRAME::SetMsgPanel(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::VIEW::Update(), updateSegmentFromConstructionMgr(), TOOL_INTERACTIVE::Wait(), and WIDTH_STEP.

Referenced by DrawCircle(), DrawLine(), and DrawRectangle().

◆ DrawVia()

int DRAWING_TOOL::DrawVia ( const TOOL_EVENT aEvent)

Definition at line 1672 of file drawing_tool.cpp.

1673 {
1674  struct VIA_PLACER : public INTERACTIVE_PLACER_BASE
1675  {
1676  GRID_HELPER m_gridHelper;
1677 
1678  VIA_PLACER( PCB_BASE_EDIT_FRAME* aFrame ) :
1679  m_gridHelper( aFrame->GetToolManager(), aFrame->GetMagneticItemsSettings() )
1680  {}
1681 
1682  virtual ~VIA_PLACER()
1683  {
1684  }
1685 
1686  TRACK* findTrack( VIA* aVia )
1687  {
1688  const LSET lset = aVia->GetLayerSet();
1689  wxPoint position = aVia->GetPosition();
1690  BOX2I bbox = aVia->GetBoundingBox();
1691 
1692  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
1693  auto view = m_frame->GetCanvas()->GetView();
1694  std::vector<TRACK*> possible_tracks;
1695 
1696  view->Query( bbox, items );
1697 
1698  for( auto it : items )
1699  {
1700  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
1701 
1702  if( !(item->GetLayerSet() & lset ).any() )
1703  continue;
1704 
1705  if( auto track = dyn_cast<TRACK*>( item ) )
1706  {
1707  if( TestSegmentHit( position, track->GetStart(), track->GetEnd(),
1708  ( track->GetWidth() + aVia->GetWidth() ) / 2 ) )
1709  possible_tracks.push_back( track );
1710  }
1711  }
1712 
1713  TRACK* return_track = nullptr;
1714  int min_d = std::numeric_limits<int>::max();
1715  for( auto track : possible_tracks )
1716  {
1717  SEG test( track->GetStart(), track->GetEnd() );
1718  auto dist = ( test.NearestPoint( position ) - position ).EuclideanNorm();
1719 
1720  if( dist < min_d )
1721  {
1722  min_d = dist;
1723  return_track = track;
1724  }
1725  }
1726 
1727  return return_track;
1728  }
1729 
1730 
1731  bool hasDRCViolation( VIA* aVia )
1732  {
1733  const LSET lset = aVia->GetLayerSet();
1734  wxPoint position = aVia->GetPosition();
1735  int drillRadius = aVia->GetDrillValue() / 2;
1736  BOX2I bbox = aVia->GetBoundingBox();
1737 
1738  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
1739  int net = 0;
1740  int clearance = 0;
1741  auto view = m_frame->GetCanvas()->GetView();
1742  int holeToHoleMin = m_frame->GetBoard()->GetDesignSettings().m_HoleToHoleMin;
1743 
1744  view->Query( bbox, items );
1745 
1746  for( auto it : items )
1747  {
1748  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
1749 
1750  if( !(item->GetLayerSet() & lset ).any() )
1751  continue;
1752 
1753  if( auto track = dyn_cast<TRACK*>( item ) )
1754  {
1755  int max_clearance = std::max( clearance, track->GetClearance() );
1756 
1757  if( TestSegmentHit( position, track->GetStart(), track->GetEnd(),
1758  ( track->GetWidth() + aVia->GetWidth() ) / 2 + max_clearance ) )
1759  {
1760  if( net && track->GetNetCode() != net )
1761  return true;
1762 
1763  net = track->GetNetCode();
1764  clearance = track->GetClearance();
1765  }
1766  }
1767 
1768  if( auto via = dyn_cast<VIA*>( item ) )
1769  {
1770  int dist = KiROUND( GetLineLength( position, via->GetPosition() ) );
1771 
1772  if( dist < drillRadius + via->GetDrillValue() / 2 + holeToHoleMin )
1773  return true;
1774  }
1775 
1776  if( auto mod = dyn_cast<MODULE*>( item ) )
1777  {
1778  for( D_PAD* pad : mod->Pads() )
1779  {
1780  int max_clearance = std::max( clearance, pad->GetClearance() );
1781 
1782  if( pad->HitTest( aVia->GetBoundingBox(), false, max_clearance ) )
1783  {
1784  if( net && pad->GetNetCode() != net )
1785  return true;
1786 
1787  net = pad->GetNetCode();
1788  clearance = pad->GetClearance();
1789  }
1790 
1791  if( pad->GetDrillSize().x && pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
1792  {
1793  int dist = KiROUND( GetLineLength( position, pad->GetPosition() ) );
1794 
1795  if( dist < drillRadius + pad->GetDrillSize().x / 2 + holeToHoleMin )
1796  return true;
1797  }
1798  }
1799  }
1800  }
1801 
1802  return false;
1803  }
1804 
1805 
1806  int findStitchedZoneNet( VIA* aVia )
1807  {
1808  const wxPoint position = aVia->GetPosition();
1809  const LSET lset = aVia->GetLayerSet();
1810 
1811  for( auto mod : m_board->Modules() )
1812  {
1813  for( D_PAD* pad : mod->Pads() )
1814  {
1815  if( pad->HitTest( position ) && ( pad->GetLayerSet() & lset ).any() )
1816  return -1;
1817  }
1818  }
1819 
1820  std::vector<ZONE_CONTAINER*> foundZones;
1821 
1822  for( ZONE_CONTAINER* zone : m_board->Zones() )
1823  {
1824  for( PCB_LAYER_ID layer : LSET( zone->GetLayerSet() & lset ).Seq() )
1825  if( zone->HitTestFilledArea( layer, position ) )
1826  foundZones.push_back( zone );
1827  }
1828 
1829  std::sort( foundZones.begin(), foundZones.end(),
1830  [] ( const ZONE_CONTAINER* a, const ZONE_CONTAINER* b )
1831  {
1832  return a->GetLayer() < b->GetLayer();
1833  } );
1834 
1835  // first take the net of the active layer
1836  for( ZONE_CONTAINER* z : foundZones )
1837  {
1838  if( m_frame->GetActiveLayer() == z->GetLayer() )
1839  return z->GetNetCode();
1840  }
1841 
1842  // none? take the topmost visible layer
1843  for( ZONE_CONTAINER* z : foundZones )
1844  {
1845  if( m_board->IsLayerVisible( z->GetLayer() ) )
1846  return z->GetNetCode();
1847  }
1848 
1849  return -1;
1850  }
1851 
1852  void SnapItem( BOARD_ITEM *aItem ) override
1853  {
1854  // If you place a Via on a track but not on its centerline, the current
1855  // connectivity algorithm will require us to put a kink in the track when
1856  // we break it (so that each of the two segments ends on the via center).
1857  // That's not ideal, and is in fact probably worse than forcing snap in
1858  // this situation.
1859 
1860  m_gridHelper.SetSnap( !( m_modifiers & MD_SHIFT ) );
1861  auto via = static_cast<VIA*>( aItem );
1862  wxPoint position = via->GetPosition();
1863  TRACK* track = findTrack( via );
1864 
1865  if( track )
1866  {
1867  SEG trackSeg( track->GetStart(), track->GetEnd() );
1868  VECTOR2I snap = m_gridHelper.AlignToSegment( position, trackSeg );
1869 
1870  aItem->SetPosition( (wxPoint) snap );
1871  }
1872  }
1873 
1874  bool PlaceItem( BOARD_ITEM* aItem, BOARD_COMMIT& aCommit ) override
1875  {
1876  VIA* via = static_cast<VIA*>( aItem );
1877  wxPoint viaPos = via->GetPosition();
1878  int newNet;
1879  TRACK* track = findTrack( via );
1880 
1881  if( hasDRCViolation( via ) )
1882  return false;
1883 
1884  if( track )
1885  {
1886  if( viaPos != track->GetStart() && viaPos != track->GetEnd() )
1887  {
1888  aCommit.Modify( track );
1889  TRACK* newTrack = dynamic_cast<TRACK*>( track->Clone() );
1890  track->SetEnd( viaPos );
1891  newTrack->SetStart( viaPos );
1892  aCommit.Add( newTrack );
1893  }
1894 
1895  newNet = track->GetNetCode();
1896  }
1897  else
1898  newNet = findStitchedZoneNet( via );
1899 
1900  if( newNet > 0 )
1901  via->SetNetCode( newNet );
1902 
1903  aCommit.Add( aItem );
1904  return true;
1905  }
1906 
1907  std::unique_ptr<BOARD_ITEM> CreateItem() override
1908  {
1909  auto& ds = m_board->GetDesignSettings();
1910  VIA* via = new VIA( m_board );
1911 
1912  via->SetNetCode( 0 );
1913  via->SetViaType( ds.m_CurrentViaType );
1914 
1915  // for microvias, the size and hole will be changed later.
1916  via->SetWidth( ds.GetCurrentViaSize() );
1917  via->SetDrill( ds.GetCurrentViaDrill() );
1918 
1919  // Usual via is from copper to component.
1920  // layer pair is B_Cu and F_Cu.
1921  via->SetLayerPair( B_Cu, F_Cu );
1922 
1923  PCB_LAYER_ID first_layer = m_frame->GetActiveLayer();
1924  PCB_LAYER_ID last_layer;
1925 
1926  // prepare switch to new active layer:
1927  if( first_layer != m_frame->GetScreen()->m_Route_Layer_TOP )
1928  last_layer = m_frame->GetScreen()->m_Route_Layer_TOP;
1929  else
1930  last_layer = m_frame->GetScreen()->m_Route_Layer_BOTTOM;
1931 
1932  // Adjust the actual via layer pair
1933  switch( via->GetViaType() )
1934  {
1935  case VIATYPE::BLIND_BURIED:
1936  via->SetLayerPair( first_layer, last_layer );
1937  break;
1938 
1939  case VIATYPE::MICROVIA: // from external to the near neighbor inner layer
1940  {
1941  PCB_LAYER_ID last_inner_layer =
1942  ToLAYER_ID( ( m_board->GetCopperLayerCount() - 2 ) );
1943 
1944  if( first_layer == B_Cu )
1945  last_layer = last_inner_layer;
1946  else if( first_layer == F_Cu )
1947  last_layer = In1_Cu;
1948  else if( first_layer == last_inner_layer )
1949  last_layer = B_Cu;
1950  else if( first_layer == In1_Cu )
1951  last_layer = F_Cu;
1952 
1953  // else error: will be removed later
1954  via->SetLayerPair( first_layer, last_layer );
1955 
1956  // Update diameter and hole size, which where set previously
1957  // for normal vias
1958  NETINFO_ITEM* net = via->GetNet();
1959 
1960  if( net )
1961  {
1962  via->SetWidth( net->GetMicroViaSize() );
1963  via->SetDrill( net->GetMicroViaDrillSize() );
1964  }
1965  }
1966  break;
1967 
1968  default:
1969  break;
1970  }
1971 
1972  return std::unique_ptr<BOARD_ITEM>( via );
1973  }
1974  };
1975 
1976  VIA_PLACER placer( frame() );
1977 
1978  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
1979 
1980  doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, _( "Place via" ),
1982 
1983  return 0;
1984 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
int GetNetCode() const
Function GetNetCode.
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:206
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
BOARD * m_board
Definition: drawing_tool.h:229
virtual void SetPosition(const wxPoint &aPos)=0
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:114
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
const wxPoint & GetStart() const
Definition: class_track.h:118
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:236
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
virtual EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_track.cpp:45
bool SetNetCode(int aNetCode, bool aNoAssert)
Sets net using a net code.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
void SetWidth(int aWidth)
Definition: class_track.h:111
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.
Definition: trigo.cpp:129
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
double dist(const double ax, const double ay, const double bx, const double by)
Definition: delauney.h:168
PCB_LAYER_ID
A quick note on layer IDs:
LSET is a set of PCB_LAYER_IDs.
RAII class that sets an value at construction and resets it to the original value at destruction.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
MODULES & Modules()
Definition: class_board.h:266
Allow repeat placement of the item.
KIGFX::PCB_VIEW * view() const
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:39
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_Layer contains the top layer, the other layer is in m_BottomLayer.
Create an item immediately on placement starting, otherwise show the pencil cursor until the item is ...
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
void SetSnap(bool aSnap)
Definition: grid_helper.h:83
Definition: seg.h:39
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:65
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
ZONE_CONTAINERS & Zones()
Definition: class_board.h:280
int GetWidth() const
Definition: class_track.h:112
Common, abstract interface for edit frames.
#define _(s)
Definition: 3d_actions.cpp:33
int GetCopperLayerCount() const
Function GetCopperLayerCount.
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:447
VIATYPE GetViaType() const
Definition: class_track.h:373
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:68
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
const wxPoint & GetEnd() const
Definition: class_track.h:115
int GetMicroViaDrillSize()
Function GetViaDrillSize returns the size of via drills used to route this net.
Definition: netinfo.h:188
void SetStart(const wxPoint &aStart)
Definition: class_track.h:117
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Function Query() Finds all visible items that touch or are within the rectangle aRect.
Definition: view.cpp:452
void doInteractiveItemPlacement(const std::string &aTool, 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...
BOARD * GetBoard() const
wxPoint GetPosition() const override
Definition: class_track.h:411
int GetMicroViaSize()
Function GetMicroViaSize returns the size of vias used to route this net.
Definition: netinfo.h:168
void SetViaType(VIATYPE aViaType)
Definition: class_track.h:374
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:849
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:38
virtual LSET GetLayerSet() const
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...

References _, COMMIT::Add(), GRID_HELPER::AlignToSegment(), B_Cu, BLIND_BURIED, TRACK::Clone(), dist(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EuclideanNorm(), F_Cu, PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetBoard(), TRACK::GetBoundingBox(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), VIA::GetDrillValue(), TRACK::GetEnd(), ZONE_CONTAINER::GetLayer(), BOARD_ITEM::GetLayerSet(), VIA::GetLayerSet(), GetLineLength(), PCB_BASE_FRAME::GetMagneticItemsSettings(), NETINFO_ITEM::GetMicroViaDrillSize(), NETINFO_ITEM::GetMicroViaSize(), BOARD_CONNECTED_ITEM::GetNet(), BOARD_CONNECTED_ITEM::GetNetCode(), VIA::GetPosition(), PCB_BASE_FRAME::GetScreen(), TRACK::GetStart(), TOOLS_HOLDER::GetToolManager(), VIA::GetViaType(), PCB_DRAW_PANEL_GAL::GetView(), TRACK::GetWidth(), In1_Cu, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_SINGLE_CLICK, BOARD::IsLayerVisible(), KiROUND(), m_board, m_frame, BOARD_DESIGN_SETTINGS::m_HoleToHoleMin, m_mode, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, MD_SHIFT, MICROVIA, COMMIT::Modify(), BOARD::Modules(), PAD_DRILL_SHAPE_CIRCLE, KIGFX::VIEW::Query(), VIA::SetDrill(), TRACK::SetEnd(), VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), BOARD_ITEM::SetPosition(), GRID_HELPER::SetSnap(), TRACK::SetStart(), VIA::SetViaType(), TRACK::SetWidth(), TestSegmentHit(), ToLAYER_ID(), VIA, PCB_TOOL_BASE::view(), and BOARD::Zones().

Referenced by setTransitions().

◆ DrawZone()

int DRAWING_TOOL::DrawZone ( const TOOL_EVENT aEvent)

Function DrawZone() Starts interactively drawing a zone.

After invoking the function a zone settings dialog is displayed. After confirmation it allows the user to set points that are going to be used as a boundary polygon of the zone. Double click or clicking on the origin of the boundary polyline finishes the drawing.

The event parameter indicates which type of zone to draw: ADD add a new zone/keepout with fresh settings CUTOUT add a cutout to an existing zone SIMILAR add a new zone with the same settings as an existing one

Definition at line 1475 of file drawing_tool.cpp.

1476 {
1477  if( m_editModules && !m_frame->GetModel() )
1478  return 0;
1479 
1480  ZONE_MODE zoneMode = aEvent.Parameter<ZONE_MODE>();
1481  MODE drawMode = MODE::ZONE;
1482 
1483  if( aEvent.IsAction( &PCB_ACTIONS::drawZoneKeepout ) )
1484  drawMode = MODE::KEEPOUT;
1485 
1486  if( aEvent.IsAction( &PCB_ACTIONS::drawPolygon ) )
1487  drawMode = MODE::GRAPHIC_POLYGON;
1488 
1489  SCOPED_DRAW_MODE scopedDrawMode( m_mode, drawMode );
1490 
1491  // get a source zone, if we need one. We need it for:
1492  // ZONE_MODE::CUTOUT (adding a hole to the source zone)
1493  // ZONE_MODE::SIMILAR (creating a new zone using settings of source zone
1494  ZONE_CONTAINER* sourceZone = nullptr;
1495 
1496  if( !getSourceZoneForAction( zoneMode, &sourceZone ) )
1497  return 0;
1498 
1500 
1501  params.m_keepout = drawMode == MODE::KEEPOUT;
1502  params.m_mode = zoneMode;
1503  params.m_sourceZone = sourceZone;
1504 
1505  if( zoneMode == ZONE_MODE::SIMILAR )
1506  params.m_layer = sourceZone->GetLayer();
1507  else
1508  params.m_layer = m_frame->GetActiveLayer();
1509 
1510  ZONE_CREATE_HELPER zoneTool( *this, params );
1511 
1512  // the geometry manager which handles the zone geometry, and
1513  // hands the calculated points over to the zone creator tool
1514  POLYGON_GEOM_MANAGER polyGeomMgr( zoneTool );
1515  bool constrainAngle = false;
1516 
1517  std::string tool = aEvent.GetCommandStr().get();
1518  m_frame->PushTool( tool );
1519  Activate(); // register for events
1520 
1521  m_controls->ShowCursor( true );
1522  m_controls->SetSnapping( true );
1523 
1524  bool started = false;
1526  STATUS_TEXT_POPUP status( m_frame );
1527  status.SetTextColor( wxColour( 255, 0, 0 ) );
1528  status.SetText( _( "Self-intersecting polygons are not allowed" ) );
1529 
1530  // Prime the pump
1531  if( aEvent.HasPosition() )
1532  m_toolMgr->PrimeTool( aEvent.Position() );
1533 
1534  // Main loop: keep receiving events
1535  while( TOOL_EVENT* evt = Wait() )
1536  {
1537  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
1538  LSET layers( m_frame->GetActiveLayer() );
1539  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1540  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1541  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1542  VECTOR2I cursorPos = grid.BestSnapAnchor(
1543  evt->IsPrime() ? evt->Position() : m_controls->GetMousePosition(), layers );
1544  m_controls->ForceCursorPosition( true, cursorPos );
1545 
1546  if( ( sourceZone && sourceZone->GetHV45() ) || constrainAngle || evt->Modifier( MD_CTRL ) )
1547  polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45 );
1548  else
1549  polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
1550 
1551  auto cleanup = [&] () {
1552  polyGeomMgr.Reset();
1553  started = false;
1554  grid.ClearSkipPoint();
1555  m_controls->SetAutoPan( false );
1556  m_controls->CaptureCursor( false );
1557  };
1558 
1559  if( evt->IsCancelInteractive())
1560  {
1561  if( polyGeomMgr.IsPolygonInProgress() )
1562  cleanup();
1563  else
1564  {
1565  m_frame->PopTool( tool );
1566  break;
1567  }
1568  }
1569  else if( evt->IsActivate() )
1570  {
1571  if( polyGeomMgr.IsPolygonInProgress() )
1572  cleanup();
1573 
1574  if( evt->IsPointEditor() )
1575  {
1576  // don't exit (the point editor runs in the background)
1577  }
1578  else if( evt->IsMoveTool() )
1579  {
1580  // leave ourselves on the stack so we come back after the move
1581  break;
1582  }
1583  else
1584  {
1585  m_frame->PopTool( tool );
1586  break;
1587  }
1588  }
1589  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1590  {
1591  if( zoneMode != ZONE_MODE::SIMILAR )
1592  params.m_layer = frame()->GetActiveLayer();
1593  }
1594  else if( evt->IsClick( BUT_RIGHT ) )
1595  {
1597  }
1598  // events that lock in nodes
1599  else if( evt->IsClick( BUT_LEFT )
1600  || evt->IsDblClick( BUT_LEFT )
1601  || evt->IsAction( &PCB_ACTIONS::closeOutline ) )
1602  {
1603  // Check if it is double click / closing line (so we have to finish the zone)
1604  const bool endPolygon = evt->IsDblClick( BUT_LEFT )
1605  || evt->IsAction( &PCB_ACTIONS::closeOutline )
1606  || polyGeomMgr.NewPointClosesOutline( cursorPos );
1607 
1608  if( endPolygon )
1609  {
1610  polyGeomMgr.SetFinished();
1611  polyGeomMgr.Reset();
1612 
1613  started = false;
1614  m_controls->SetAutoPan( false );
1615  m_controls->CaptureCursor( false );
1616  }
1617 
1618  // adding a corner
1619  else if( polyGeomMgr.AddPoint( cursorPos ) )
1620  {
1621  if( !started )
1622  {
1623  started = true;
1624  constrainAngle = ( polyGeomMgr.GetLeaderMode() ==
1626  m_controls->SetAutoPan( true );
1627  m_controls->CaptureCursor( true );
1628  }
1629  }
1630  }
1631  else if( evt->IsAction( &PCB_ACTIONS::deleteLastPoint ) )
1632  {
1633  polyGeomMgr.DeleteLastCorner();
1634 
1635  if( !polyGeomMgr.IsPolygonInProgress() )
1636  {
1637  // report finished as an empty shape
1638  polyGeomMgr.SetFinished();
1639 
1640  // start again
1641  started = false;
1642  m_controls->SetAutoPan( false );
1643  m_controls->CaptureCursor( false );
1644  }
1645  }
1646  else if( polyGeomMgr.IsPolygonInProgress()
1647  && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
1648  {
1649  polyGeomMgr.SetCursorPosition( cursorPos );
1650 
1651  if( polyGeomMgr.IsSelfIntersecting( true ) )
1652  {
1653  wxPoint p = wxGetMousePosition() + wxPoint( 20, 20 );
1654  status.Move( p );
1655  status.PopupFor( 1500 );
1656  }
1657  else
1658  {
1659  status.Hide();
1660  }
1661  }
1662  else
1663  evt->SetPassEvent();
1664 
1665  } // end while
1666 
1667  m_controls->ForceCursorPosition( false );
1668  return 0;
1669 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
Add a new zone with the same settings as an existing one.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
STATUS_TEXT_POPUP.
Definition: status_popup.h:79
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static TOOL_ACTION drawZoneKeepout
Definition: pcb_actions.h:149
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:236
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
PCB_LAYER_ID m_layer
Layer to begin drawing
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:141
void PrimeTool(const VECTOR2D &aPosition)
Function PrimeTool() "Primes" a tool by sending a cursor left-click event with the mouse position set...
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
Parameters used to fully describe a zone creation process.
bool getSourceZoneForAction(ZONE_MODE aMode, ZONE_CONTAINER **aZone)
Draws a polygon, that is added as a zone or a keepout area.
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
Unconstrained point-to-point
LSET is a set of PCB_LAYER_IDs.
RAII class that sets an value at construction and resets it to the original value at destruction.
const PCBNEW_SELECTION & selection() const
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
ZONE_CONTAINER * m_sourceZone
Zone settings source (for similar and cutout zones)
TOOL_EVENT.
Definition: tool_event.h:171
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:228
ZONE_MODE
Definition: pcb_actions.h:36
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
bool GetHV45() const
Definition: class_zone.h:781
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
MODE
The possible drawing modes of DRAWING_TOOL
Definition: drawing_tool.h:63
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:275
#define _(s)
Definition: 3d_actions.cpp:33
This class is an adjuct helper to the DRAWING_TOOL interactive tool, which handles incoming geometry ...
static TOOL_ACTION deleteLastPoint
Definition: pcb_actions.h:156
void Activate()
Function Activate() Runs the tool.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
bool m_keepout
Should create a keepout zone?
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
Class that handles the drawing of a polygon, including management of last corner deletion and drawing...
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:274
ZONE_MODE m_mode
The zone mode to operate in
static TOOL_ACTION closeOutline
Definition: pcb_actions.h:157

References _, TOOL_INTERACTIVE::Activate(), POLYGON_GEOM_MANAGER::AddPoint(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), PCB_ACTIONS::closeOutline, POLYGON_GEOM_MANAGER::DEG45, POLYGON_GEOM_MANAGER::DeleteLastCorner(), PCB_ACTIONS::deleteLastPoint, POLYGON_GEOM_MANAGER::DIRECT, PCB_ACTIONS::drawPolygon, PCB_ACTIONS::drawZoneKeepout, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), ZONE_CONTAINER::GetHV45(), ZONE_CONTAINER::GetLayer(), POLYGON_GEOM_MANAGER::GetLeaderMode(), PCB_BASE_FRAME::GetMagneticItemsSettings(), PCB_BASE_FRAME::GetModel(), KIGFX::VIEW_CONTROLS::GetMousePosition(), getSourceZoneForAction(), GRAPHIC_POLYGON, TOOL_EVENT::HasPosition(), TOOL_EVENT::IsAction(), POLYGON_GEOM_MANAGER::IsPolygonInProgress(), POLYGON_GEOM_MANAGER::IsSelfIntersecting(), KEEPOUT, PCB_ACTIONS::layerChanged, m_controls, PCB_TOOL_BASE::m_editModules, m_frame, ZONE_CREATE_HELPER::PARAMS::m_keepout, ZONE_CREATE_HELPER::PARAMS::m_layer, TOOL_INTERACTIVE::m_menu, ZONE_CREATE_HELPER::PARAMS::m_mode, m_mode, ZONE_CREATE_HELPER::PARAMS::m_sourceZone, TOOL_BASE::m_toolMgr, MD_ALT, MD_CTRL, MD_SHIFT, POLYGON_GEOM_MANAGER::NewPointClosesOutline(), TOOL_EVENT::Parameter(), TOOLS_HOLDER::PopTool(), TOOL_EVENT::Position(), TOOL_MANAGER::PrimeTool(), TOOLS_HOLDER::PushTool(), POLYGON_GEOM_MANAGER::Reset(), PCB_TOOL_BASE::selection(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), POLYGON_GEOM_MANAGER::SetCursorPosition(), POLYGON_GEOM_MANAGER::SetFinished(), POLYGON_GEOM_MANAGER::SetLeaderMode(), KIGFX::VIEW_CONTROLS::SetSnapping(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), SIMILAR, TOOL_INTERACTIVE::Wait(), and ZONE.

Referenced by setTransitions().

◆ EditingModules()

bool PCB_TOOL_BASE::EditingModules ( ) const
inlineinherited

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 161 of file pcb_tool_base.h.

162  {
163  return getEditFrame<PCB_BASE_EDIT_FRAME>();
164  }

Referenced by POINT_EDITOR::addCorner(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), ROUTER_TOOL::CustomTrackWidthDialog(), FOOTPRINT_EDITOR_TOOLS::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), ROUTER_TOOL::DpDimensionsDialog(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), DrawVia(), DrawZone(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), PAD_TOOL::explodePad(), PCB_EDITOR_CONTROL::ExportSpecctraDSN(), ROUTER_TOOL::finishInteractive(), EDIT_TOOL::Flip(), PCB_EDITOR_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), FOOTPRINT_EDITOR_TOOLS::ImportFootprint(), PCB_EDITOR_CONTROL::ImportSpecctraSession(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCBNEW_PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickReferencePoint(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), PAD_TOOL::recombinePad(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), POINT_EDITOR::setEditedPoint(), ROUTER_TOOL::SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), ROUTER_TOOL::switchLayerOnViaPlacement(), POINT_EDITOR::updateItem(), PCB_EDITOR_CONTROL::UpdateSchematicFromPCB(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ GetDrawingMode()

DRAWING_TOOL::MODE DRAWING_TOOL::GetDrawingMode ( ) const

Function GetDrawingMode.

Returns the current drawing mode of the DRAWING_TOOL, or MODE::NONE if not currently in any drawing mode

Definition at line 132 of file drawing_tool.cpp.

133 {
134  return m_mode;
135 }

References m_mode.

Referenced by PCB_EDITOR_CONTROL::Init().

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

◆ getSegmentWidth()

int DRAWING_TOOL::getSegmentWidth ( PCB_LAYER_ID  aLayer) const
private

Returns the appropriate width for a segment depending on the settings.

Definition at line 1987 of file drawing_tool.cpp.

1988 {
1989  assert( m_board );
1990  return m_board->GetDesignSettings().GetLineThickness( aLayer );
1991 }
BOARD * m_board
Definition: drawing_tool.h:229
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
int GetLineThickness(PCB_LAYER_ID aLayer) const
Function GetLineThickness Returns the default graphic segment thickness from the layer class for the ...

References BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetLineThickness(), and m_board.

Referenced by drawArc(), and drawSegment().

◆ getSourceZoneForAction()

bool DRAWING_TOOL::getSourceZoneForAction ( ZONE_MODE  aMode,
ZONE_CONTAINER **  aZone 
)
private

Draws a polygon, that is added as a zone or a keepout area.

Parameters
aKeepoutdictates if the drawn polygon is a zone or a keepout area.
aModedictates the mode of the zone tool: ADD add a new zone/keepout with fresh settings CUTOUT add a cutout to an existing zone SIMILAR add a new zone with the same settings as an existing oneFunction getSourceZoneForAction()

Gets a source zone item for an action that takes an existing zone into account (for example a cutout of an existing zone). The source zone is taken from the current selection

Parameters
aModemode of the zone tool
aZoneupdated pointer to a suitable source zone, or nullptr if none found, or the action doesn't need a source
Returns
true if a suitable zone was found, or the action doesn't need a zone. False if the action needs a zone but none was found.

Definition at line 1441 of file drawing_tool.cpp.

1442 {
1443  bool clearSelection = false;
1444  *aZone = nullptr;
1445 
1446  // not an action that needs a source zone
1447  if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON )
1448  return true;
1449 
1451  const PCBNEW_SELECTION& selection = selTool->GetSelection();
1452 
1453  if( selection.Empty() )
1454  {
1455  clearSelection = true;
1457  }
1458 
1459  // we want a single zone
1460  if( selection.Size() == 1 )
1461  *aZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1462 
1463  // expected a zone, but didn't get one
1464  if( !*aZone )
1465  {
1466  if( clearSelection )
1468 
1469  return false;
1470  }
1471 
1472  return true;
1473 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:140
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
const PCBNEW_SELECTION & selection() const
Add a new zone/keepout with fresh settings.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:121
int Size() const
Returns the number of selected parts.
Definition: selection.h:127
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:59

References ADD, SELECTION::Empty(), SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), GRAPHIC_POLYGON, TOOL_BASE::m_toolMgr, TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectionCursor, and SELECTION::Size().

Referenced by DrawZone().

◆ 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(), GERBVIEW_SELECTION_TOOL::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(), GERBVIEW_SELECTION_TOOL::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(), GERBVIEW_SELECTION_TOOL::Reset(), Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::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(), GERBVIEW_SELECTION_TOOL::selectVisually(), PL_EDITOR_CONTROL::ToggleBackgroundColor(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::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::~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(), DrawCircle(), DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), 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(), GERBVIEW_SELECTION_TOOL::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(), Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::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(), GERBVIEW_SELECTION_TOOL::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(), setTransitions(), SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ Init()

bool DRAWING_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 PCB_TOOL_BASE.

Definition at line 76 of file drawing_tool.cpp.

77 {
78  auto activeToolFunctor = [ this ] ( const SELECTION& aSel )
79  {
80  return m_mode != MODE::NONE;
81  };
82 
83  // some interactive drawing tools can undo the last point
84  auto canUndoPoint = [ this ] ( const SELECTION& aSel )
85  {
86  return ( m_mode == MODE::ARC
87  || m_mode == MODE::ZONE
88  || m_mode == MODE::KEEPOUT
90  };
91 
92  // functor for tools that can automatically close the outline
93  auto canCloseOutline = [ this ] ( const SELECTION& aSel )
94  {
95  return ( m_mode == MODE::ZONE
96  || m_mode == MODE::KEEPOUT
98  };
99 
100  auto& ctxMenu = m_menu.GetMenu();
101 
102  // cancel current tool goes in main context menu at the top if present
103  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolFunctor, 1 );
104  ctxMenu.AddSeparator( 1 );
105 
106  // tool-specific actions
107  ctxMenu.AddItem( PCB_ACTIONS::closeOutline, canCloseOutline, 200 );
108  ctxMenu.AddItem( PCB_ACTIONS::deleteLastPoint, canUndoPoint, 200 );
109 
110  ctxMenu.AddSeparator( 500 );
111 
112  // Type-specific sub-menus will be added for us by other tools
113  // For example, zone fill/unfill is provided by the PCB control tool
114 
115  // Finally, add the standard zoom/grid items
116  getEditFrame<PCB_BASE_FRAME>()->AddStandardSubMenus( m_menu );
117 
118  return true;
119 }
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:46
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
static TOOL_ACTION deleteLastPoint
Definition: pcb_actions.h:156
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()
static TOOL_ACTION closeOutline
Definition: pcb_actions.h:157

References CONDITIONAL_MENU::AddItem(), ARC, ACTIONS::cancelInteractive, PCB_ACTIONS::closeOutline, PCB_ACTIONS::deleteLastPoint, TOOL_MENU::GetMenu(), GRAPHIC_POLYGON, KEEPOUT, TOOL_INTERACTIVE::m_menu, m_mode, NONE, and ZONE.

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

◆ module()

◆ PlaceImportedGraphics()

int DRAWING_TOOL::PlaceImportedGraphics ( const TOOL_EVENT aEvent)

Function PlaceImportedGraphics() Places a drawing imported from a DXF or SVG file in module editor.

Definition at line 750 of file drawing_tool.cpp.

751 {
752  if( !m_frame->GetModel() )
753  return 0;
754 
755  // Note: PlaceImportedGraphics() will convert PCB_LINE_T and PCB_TEXT_T to module graphic
756  // items if needed
758  int dlgResult = dlg.ShowModal();
759 
760  auto& list = dlg.GetImportedItems();
761 
762  if( dlgResult != wxID_OK )
763  return 0;
764 
765  // Ensure the list is not empty:
766  if( list.empty() )
767  {
768  wxMessageBox( _( "No graphic items found in file to import") );
769  return 0;
770  }
771 
773 
774  // Add a VIEW_GROUP that serves as a preview for the new item
775  PCBNEW_SELECTION preview;
776  BOARD_COMMIT commit( m_frame );
777 
778  // Build the undo list & add items to the current view
779  for( auto& ptr : list)
780  {
781  EDA_ITEM* item = ptr.get();
782 
783  if( m_editModules )
784  wxASSERT( item->Type() == PCB_MODULE_EDGE_T || item->Type() == PCB_MODULE_TEXT_T );
785  else
786  wxASSERT( item->Type() == PCB_LINE_T || item->Type() == PCB_TEXT_T );
787 
788  if( dlg.IsPlacementInteractive() )
789  preview.Add( item );
790  else
791  commit.Add( item );
792 
793  ptr.release();
794  }
795 
796  if( !dlg.IsPlacementInteractive() )
797  {
798  commit.Push( _( "Place a DXF_SVG drawing" ) );
799  return 0;
800  }
801 
802  BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( preview.Front() );
803  m_view->Add( &preview );
804 
806  m_controls->ShowCursor( true );
807  m_controls->SetSnapping( true );
809 
810  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
811 
812  // Now move the new items to the current cursor position:
813  VECTOR2I cursorPos = m_controls->GetCursorPosition();
814  VECTOR2I delta = cursorPos - firstItem->GetPosition();
815 
816  for( EDA_ITEM* item : preview )
817  static_cast<BOARD_ITEM*>( item )->Move( (wxPoint) delta );
818 
819  m_view->Update( &preview );
820 
821  std::string tool = aEvent.GetCommandStr().get();
822  m_frame->PushTool( tool );
823  Activate();
824 
825  // Main loop: keep receiving events
826  while( TOOL_EVENT* evt = Wait() )
827  {
828  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
829  cursorPos = m_controls->GetCursorPosition();
830 
831  if( evt->IsCancelInteractive() || evt->IsActivate() )
832  {
833  preview.FreeItems();
834  break;
835  }
836  else if( evt->IsMotion() )
837  {
838  delta = cursorPos - firstItem->GetPosition();
839 
840  for( auto item : preview )
841  static_cast<BOARD_ITEM*>( item )->Move( (wxPoint) delta );
842 
843  m_view->Update( &preview );
844  }
845  else if( evt->Category() == TC_COMMAND )
846  {
847  // TODO it should be handled by EDIT_TOOL, so add items and select?
848  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
849  {
850  const auto rotationPoint = (wxPoint) cursorPos;
851  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *m_frame, *evt );
852 
853  for( auto item : preview )
854  static_cast<BOARD_ITEM*>( item )->Rotate( rotationPoint, rotationAngle );
855 
856  m_view->Update( &preview );
857  }
858  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
859  {
860  bool leftRight = m_frame->Settings().m_FlipLeftRight;
861 
862  for( auto item : preview )
863  static_cast<BOARD_ITEM*>( item )->Flip( (wxPoint) cursorPos, leftRight);
864 
865  m_view->Update( &preview );
866  }
867  }
868  else if( evt->IsClick( BUT_RIGHT ) )
869  {
871  }
872  else if( evt->IsClick( BUT_LEFT ) )
873  {
874  // Place the imported drawings
875  for( auto item : preview )
876  commit.Add( item );
877 
878  commit.Push( _( "Place a DXF_SVG drawing" ) );
879  break; // This is a one-shot command, not a tool
880  }
881  else
882  evt->SetPassEvent();
883  }
884 
885  preview.Clear();
886  m_view->Remove( &preview );
887  m_frame->PopTool( tool );
888  return 0;
889 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
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()
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
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:140
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:76
KIGFX::VIEW * m_view
Definition: drawing_tool.h:227
RAII class that sets an value at construction and resets it to the original value at destruction.
const PCBNEW_SELECTION & selection() const
virtual void PopTool(const std::string &actionName)
TOOL_EVENT.
Definition: tool_event.h:171
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:228
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
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:103
#define _(s)
Definition: 3d_actions.cpp:33
PCBNEW_SETTINGS & Settings()
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:159
void Activate()
Function Activate() Runs the tool.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:184
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References _, TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), BUT_LEFT, BUT_RIGHT, ACTIONS::cancelInteractive, DXF, PCB_ACTIONS::flip, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SELECTION::Front(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), DIALOG_IMPORT_GFX::GetImportedItems(), PCB_BASE_FRAME::GetModel(), EDA_ITEM::GetPosition(), DIALOG_IMPORT_GFX::IsPlacementInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), m_controls, PCB_TOOL_BASE::m_editModules, PCBNEW_SETTINGS::m_FlipLeftRight, m_frame, TOOL_INTERACTIVE::m_menu, m_mode, TOOL_BASE::m_toolMgr, m_view, PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, PCB_TEXT_T, TOOLS_HOLDER::PopTool(), BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::Settings(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, EDA_ITEM::Type(), KIGFX::VIEW::Update(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ PlaceText()

int DRAWING_TOOL::PlaceText ( const TOOL_EVENT aEvent)

Function PlaceText() Displays a dialog that allows one to input text and its settings and then lets the user decide where to place the text in editor.

Definition at line 305 of file drawing_tool.cpp.

306 {
307  if( m_editModules && !m_frame->GetModel() )
308  return 0;
309 
310  BOARD_ITEM* text = NULL;
311  const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
312  BOARD_COMMIT commit( m_frame );
313 
315  m_controls->ShowCursor( true );
316  m_controls->SetSnapping( true );
317  // do not capture or auto-pan until we start placing some text
318 
319  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
320 
321  std::string tool = aEvent.GetCommandStr().get();
322  m_frame->PushTool( tool );
323  Activate();
324 
325  bool reselect = false;
326 
327  // Prime the pump
328  if( aEvent.HasPosition() )
330 
331  // Main loop: keep receiving events
332  while( TOOL_EVENT* evt = Wait() )
333  {
334  m_frame->GetCanvas()->SetCurrentCursor( text ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
335  VECTOR2I cursorPos = m_controls->GetCursorPosition();
336 
337  if( reselect && text )
339 
340  auto cleanup = [&] () {
343  m_controls->ShowCursor( true );
344  m_controls->SetAutoPan( false );
345  m_controls->CaptureCursor( false );
346  delete text;
347  text = NULL;
348  };
349 
350  if( evt->IsCancelInteractive() )
351  {
352  if( text )
353  cleanup();
354  else
355  {
356  m_frame->PopTool( tool );
357  break;
358  }
359  }
360  else if( evt->IsActivate() )
361  {
362  if( text )
363  cleanup();
364 
365  if( evt->IsMoveTool() )
366  {
367  // leave ourselves on the stack so we come back after the move
368  break;
369  }
370  else
371  {
372  m_frame->PopTool( tool );
373  break;
374  }
375  }
376  else if( evt->IsClick( BUT_RIGHT ) )
377  {
379  }
380  else if( evt->IsClick( BUT_LEFT ) )
381  {
382  bool placing = text != nullptr;
383 
384  if( !text )
385  {
388 
389  // Init the new item attributes
390  if( m_editModules )
391  {
392  TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) m_frame->GetModel() );
393 
394  textMod->SetLayer( layer );
395  textMod->SetTextSize( dsnSettings.GetTextSize( layer ) );
396  textMod->SetTextThickness( dsnSettings.GetTextThickness( layer ) );
397  textMod->SetItalic( dsnSettings.GetTextItalic( layer ) );
398  textMod->SetKeepUpright( dsnSettings.GetTextUpright( layer ) );
399  textMod->SetTextPos( (wxPoint) cursorPos );
400 
401  text = textMod;
402 
403  DIALOG_TEXT_PROPERTIES textDialog( m_frame, textMod );
404  bool cancelled;
405 
406  RunMainStack( [&]()
407  {
408  cancelled = !textDialog.ShowModal()
409  || textMod->GetText().IsEmpty();
410  } );
411 
412  if( cancelled )
413  {
414  delete text;
415  text = nullptr;
416  }
417  else if( textMod->GetTextPos() != (wxPoint) cursorPos )
418  {
419  // If the user modified the location then go ahead and place it there.
420  // Otherwise we'll drag.
421  placing = true;
422  }
423  }
424  else
425  {
426  TEXTE_PCB* textPcb = new TEXTE_PCB( m_frame->GetModel() );
427  // TODO we have to set IS_NEW, otherwise InstallTextPCB.. creates an undo entry :| LEGACY_CLEANUP
428  textPcb->SetFlags( IS_NEW );
429 
430  textPcb->SetLayer( layer );
431 
432  // Set the mirrored option for layers on the BACK side of the board
433  if( IsBackLayer( layer ) )
434  textPcb->SetMirrored( true );
435 
436  textPcb->SetTextSize( dsnSettings.GetTextSize( layer ) );
437  textPcb->SetTextThickness( dsnSettings.GetTextThickness( layer ) );
438  textPcb->SetItalic( dsnSettings.GetTextItalic( layer ) );
439  textPcb->SetTextPos( (wxPoint) cursorPos );
440 
441  RunMainStack( [&]()
442  {
443  m_frame->InstallTextOptionsFrame( textPcb );
444  } );
445 
446  if( textPcb->GetText().IsEmpty() )
447  delete textPcb;
448  else
449  text = textPcb;
450  }
451 
452  if( text )
453  {
454  m_controls->WarpCursor( text->GetPosition(), true );
456  m_view->Update( &selection() );
457  }
458  }
459 
460  if( placing )
461  {
462  text->ClearFlags();
464 
465  commit.Add( text );
466  commit.Push( _( "Place a text" ) );
467 
469 
470  text = nullptr;
471  }
472 
474  m_controls->ShowCursor( true );
475  m_controls->CaptureCursor( text != nullptr );
476  m_controls->SetAutoPan( text != nullptr );
477  }
478  else if( text && evt->IsMotion() )
479  {
480  text->SetPosition( (wxPoint) cursorPos );
481  selection().SetReferencePoint( cursorPos );
482  m_view->Update( &selection() );
483  frame()->SetMsgPanel( text );
484  }
485 
486  else if( text && evt->IsAction( &PCB_ACTIONS::properties ) )
487  {
488  // Calling 'Properties' action clears the selection, so we need to restore it
489  reselect = true;
490  }
491 
492  else
493  evt->SetPassEvent();
494  }
495 
496  frame()->SetMsgPanel( board() );
497  return 0;
498 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:187
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void SetKeepUpright(bool aKeepUpright)
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Returns the BOARD_DESIGN_SETTINGS for the open project Overloaded in FOOTPRINT_EDIT_FRAME.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
BOARD * board() const
virtual void SetPosition(const wxPoint &aPos)=0
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
void RunMainStack(std::function< void()> aFunc)
Function RunMainStack()
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetItalic(bool isItalic)
Definition: eda_text.h:178
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:246
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:112
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:140
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
virtual wxPoint GetPosition() const
Definition: base_struct.h:337
int GetTextThickness(PCB_LAYER_ID aLayer) const
Function GetTextThickness Returns the default text thickness from the layer class for the given layer...
void InstallTextOptionsFrame(BOARD_ITEM *aText)
Routine for main window class to launch text properties dialog.
KIGFX::VIEW * m_view
Definition: drawing_tool.h:227
bool GetTextUpright(PCB_LAYER_ID aLayer) const
#define IS_NEW
New item, just created.
Definition: base_struct.h:117
PCB_BASE_EDIT_FRAME * frame() const
bool GetTextItalic(PCB_LAYER_ID aLayer) const
virtual PCB_LAYER_ID GetActiveLayer() const
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:245
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
PCB_LAYER_ID
A quick note on layer IDs:
RAII class that sets an value at construction and resets it to the original value at destruction.
const PCBNEW_SELECTION & selection() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:232
#define NULL
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
TOOL_EVENT.
Definition: tool_event.h:171
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:228
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
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
#define _(s)
Definition: 3d_actions.cpp:33
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:65
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:233
void Activate()
Function Activate() Runs the tool.
const wxPoint & GetTextPos() const
Definition: eda_text.h:247
void SetTextThickness(int aWidth)
The TextThickness is that set by the user.
Definition: eda_text.h:157
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:126
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Function GetTextSize Returns the default text size from the layer class for the given layer.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:119
BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References _, TOOL_INTERACTIVE::Activate(), COMMIT::Add(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), EDA_ITEM::ClearFlags(), ACTIONS::cursorClick, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetDesignSettings(), PCB_BASE_FRAME::GetModel(), EDA_ITEM::GetPosition(), EDA_TEXT::GetText(), BOARD_DESIGN_SETTINGS::GetTextItalic(), EDA_TEXT::GetTextPos(), BOARD_DESIGN_SETTINGS::GetTextSize(), BOARD_DESIGN_SETTINGS::GetTextThickness(), BOARD_DESIGN_SETTINGS::GetTextUpright(), TOOL_EVENT::HasPosition(), PCB_BASE_EDIT_FRAME::InstallTextOptionsFrame(), IS_NEW, IsBackLayer(), m_controls, PCB_TOOL_BASE::m_editModules, m_frame, TOOL_INTERACTIVE::m_menu, m_mode, TOOL_BASE::m_toolMgr, m_view, NULL, TOOLS_HOLDER::PopTool(), PCB_ACTIONS::properties, BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), TOOL_MANAGER::RunAction(), TOOL_INTERACTIVE::RunMainStack(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), EDA_ITEM::SetFlags(), EDA_TEXT::SetItalic(), TEXTE_MODULE::SetKeepUpright(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), EDA_DRAW_FRAME::SetMsgPanel(), BOARD_ITEM::SetPosition(), SELECTION::SetReferencePoint(), KIGFX::VIEW_CONTROLS::SetSnapping(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TEXT, KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), and KIGFX::VIEW_CONTROLS::WarpCursor().

Referenced by setTransitions().

◆ Reset()

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

Reimplemented from PCB_TOOL_BASE.

Definition at line 122 of file drawing_tool.cpp.

123 {
124  // Init variables used by every drawing tool
125  m_view = getView();
127  m_board = getModel<BOARD>();
128  m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
129 }
BOARD * m_board
Definition: drawing_tool.h:229
KIGFX::VIEW * m_view
Definition: drawing_tool.h:227
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:228
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42

References TOOL_BASE::getView(), TOOL_BASE::getViewControls(), m_board, m_controls, m_frame, and m_view.

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

◆ selection() [1/2]

const PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 275 of file pcb_tool_base.cpp.

276 {
277  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
278  const auto& selection = selTool->GetSelection();
279  return selection;
280 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

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

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), PCB_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), DrawZone(), EDIT_TOOL::Duplicate(), PCB_EDITOR_CONTROL::EditFpInFpEditor(), PAD_TOOL::EditPad(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), getSourceZoneForAction(), PCB_INSPECTION_TOOL::highlightNet(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), PCBNEW_CONTROL::placeBoardItems(), PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Rotate(), PCB_TOOL_BASE::selection(), SELECTION_TOOL::selectNet(), SetAnchor(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 283 of file pcb_tool_base.cpp.

284 {
285  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
286  auto& selection = selTool->GetSelection();
287  return selection;
288 }
SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

References TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, and PCB_TOOL_BASE::selection().

◆ SetAnchor()

int DRAWING_TOOL::SetAnchor ( const TOOL_EVENT aEvent)

Function SetAnchor() Places the footprint anchor (only in module editor).

Definition at line 892 of file drawing_tool.cpp.

893 {
894  assert( m_editModules );
895 
896  if( !m_frame->GetModel() )
897  return 0;
898 
899  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR );
901 
902  std::string tool = aEvent.GetCommandStr().get();
903  m_frame->PushTool( tool );
904  Activate();
905 
907  m_controls->ShowCursor( true );
908  m_controls->SetSnapping( true );
909  m_controls->SetAutoPan( true );
910  m_controls->CaptureCursor( false );
911 
912  while( TOOL_EVENT* evt = Wait() )
913  {
914  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
915 
916  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
917  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
918  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
919  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), LSET::AllLayersMask() );
920  m_controls->ForceCursorPosition( true, cursorPos );
921 
922  if( evt->IsClick( BUT_LEFT ) )
923  {
925  BOARD_COMMIT commit( m_frame );
926  commit.Modify( module );
927 
928  // set the new relative internal local coordinates of footprint items
929  wxPoint moveVector = module->GetPosition() - (wxPoint) cursorPos;
930  module->MoveAnchorPosition( moveVector );
931 
932  commit.Push( _( "Move the footprint reference anchor" ) );
933 
934  // Usually, we do not need to change twice the anchor position,
935  // so deselect the active tool
936  m_frame->PopTool( tool );
937  break;
938  }
939  else if( evt->IsClick( BUT_RIGHT ) )
940  {
942  }
943  else if( evt->IsCancelInteractive() || evt->IsActivate() )
944  {
945  m_frame->PopTool( tool );
946  break;
947  }
948  else
949  evt->SetPassEvent();
950  }
951 
952  return 0;
953 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:62
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
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()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
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:140
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
void MoveAnchorPosition(const wxPoint &aMoveVector)
Function MoveAnchorPosition Move the reference point of the footprint It looks like a move footprint:...
RAII class that sets an value at construction and resets it to the original value at destruction.
const PCBNEW_SELECTION & selection() const
virtual void PopTool(const std::string &actionName)
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
TOOL_EVENT.
Definition: tool_event.h:171
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
static LSET AllLayersMask()
Definition: lset.cpp:749
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:228
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:230
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
MODULE * module() const
#define _(s)
Definition: 3d_actions.cpp:33
void Activate()
Function Activate() Runs the tool.
wxPoint GetPosition() const override
Definition: class_module.h:206
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59

References _, TOOL_INTERACTIVE::Activate(), LSET::AllLayersMask(), ANCHOR, BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), PCB_BASE_FRAME::GetMagneticItemsSettings(), PCB_BASE_FRAME::GetModel(), KIGFX::VIEW_CONTROLS::GetMousePosition(), MODULE::GetPosition(), m_controls, PCB_TOOL_BASE::m_editModules, m_frame, TOOL_INTERACTIVE::m_menu, m_mode, TOOL_BASE::m_toolMgr, MD_ALT, MD_SHIFT, COMMIT::Modify(), PCB_TOOL_BASE::module(), MODULE::MoveAnchorPosition(), TOOLS_HOLDER::PopTool(), BOARD_COMMIT::Push(), TOOLS_HOLDER::PushTool(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), KIGFX::VIEW_CONTROLS::SetSnapping(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ 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 GERBVIEW_SELECTION_TOOL::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().

◆ SetEditModules()

void PCB_TOOL_BASE::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 101 of file pcb_tool_base.h.

102  {
103  m_editModules = aEnabled;
104  }

References PCB_TOOL_BASE::m_editModules.

◆ setTransitions()

void DRAWING_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL_BASE.

Definition at line 1997 of file drawing_tool.cpp.

1998 {
2013 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:140
int DrawCircle(const TOOL_EVENT &aEvent)
Function DrawCircle() Starts interactively drawing a circle.
static TOOL_ACTION placeImportedGraphics
Definition: pcb_actions.h:154
int DrawVia(const TOOL_EVENT &aEvent)
int DrawZone(const TOOL_EVENT &aEvent)
Function DrawZone() Starts interactively drawing a zone.
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:151
static TOOL_ACTION drawArc
Definition: pcb_actions.h:144
int DrawLine(const TOOL_EVENT &aEvent)
Function DrawLine() Starts interactively drawing a line.
int DrawRectangle(const TOOL_EVENT &aEvent)
Function DrawRectangle() Starts interactively drawing a rectangle.
static TOOL_ACTION drawZoneKeepout
Definition: pcb_actions.h:149
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:141
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:155
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION placeText
Definition: pcb_actions.h:145
int PlaceImportedGraphics(const TOOL_EVENT &aEvent)
Function PlaceImportedGraphics() Places a drawing imported from a DXF or SVG file in module editor.
int PlaceText(const TOOL_EVENT &aEvent)
Function PlaceText() Displays a dialog that allows one to input text and its settings and then lets t...
static TOOL_ACTION drawDimension
Definition: pcb_actions.h:146
static TOOL_ACTION drawRectangle
Definition: pcb_actions.h:142
static TOOL_ACTION drawVia
Definition: pcb_actions.h:148
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:150
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:143
int SetAnchor(const TOOL_EVENT &aEvent)
Function SetAnchor() Places the footprint anchor (only in module editor).
int DrawArc(const TOOL_EVENT &aEvent)
Function DrawArc() Starts interactively drawing an arc.
static TOOL_ACTION drawZone
Definition: pcb_actions.h:147
int DrawDimension(const TOOL_EVENT &aEvent)
Function DrawDimension() Starts interactively drawing a dimension.

References DrawArc(), PCB_ACTIONS::drawArc, DrawCircle(), PCB_ACTIONS::drawCircle, DrawDimension(), PCB_ACTIONS::drawDimension, DrawLine(), PCB_ACTIONS::drawLine, PCB_ACTIONS::drawPolygon, DrawRectangle(), PCB_ACTIONS::drawRectangle, PCB_ACTIONS::drawSimilarZone, PCB_ACTIONS::drawVia, DrawVia(), DrawZone(), PCB_ACTIONS::drawZone, PCB_ACTIONS::drawZoneCutout, PCB_ACTIONS::drawZoneKeepout, TOOL_INTERACTIVE::Go(), PCB_ACTIONS::placeImportedGraphics, PlaceImportedGraphics(), PlaceText(), PCB_ACTIONS::placeText, PCB_ACTIONS::setAnchor, and SetAnchor().

◆ view()

◆ 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 GERBVIEW_SELECTION_TOOL::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(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), 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(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::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(), PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Remove(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Friends And Related Function Documentation

◆ ZONE_CREATE_HELPER

friend class ZONE_CREATE_HELPER
friend

Definition at line 237 of file drawing_tool.h.

Member Data Documentation

◆ m_board

BOARD* DRAWING_TOOL::m_board
private

Definition at line 229 of file drawing_tool.h.

Referenced by DrawDimension(), DrawVia(), getSegmentWidth(), and Reset().

◆ m_controls

KIGFX::VIEW_CONTROLS* DRAWING_TOOL::m_controls
private

◆ m_editModules

◆ m_frame

◆ m_lineWidth

unsigned int DRAWING_TOOL::m_lineWidth
private

Definition at line 233 of file drawing_tool.h.

Referenced by drawArc(), DrawDimension(), and drawSegment().

◆ 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(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), PICKER_TOOL::Init(), SCH_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_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(), GERBVIEW_SELECTION_TOOL::Init(), PL_SELECTION_TOOL::Init(), 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(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), PCB_VIEWER_TOOLS::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_mode

◆ 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(), GERBVIEW_SELECTION_TOOL::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(), DrawArc(), drawArc(), DrawCircle(), DrawDimension(), DrawRectangle(), drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), 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(), 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(), PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), 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(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), 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(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::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().

◆ m_view