KiCad PCB EDA Suite
DRAWING_TOOL Class Reference

Class DRAWING_TOOL. More...

#include <drawing_tool.h>

Inheritance diagram for DRAWING_TOOL:
PCB_TOOL TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  MODE {
  MODE::NONE, MODE::LINE, 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...
 
TOOL_MENUGetToolMenu ()
 

Get the DRAWING_TOOL top-level context menu

More...
 
MODE GetDrawingMode () const
 Function GetDrawingMode. More...
 
int DrawLine (const TOOL_EVENT &aEvent)
 Function DrawLine() Starts interactively drawing a line. 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 DrawGraphicPolygon (const TOOL_EVENT &aEvent)
 
int DrawVia (const TOOL_EVENT &aEvent)
 
int DrawZoneKeepout (const TOOL_EVENT &aEvent)
 Function DrawZoneKeepout() Starts interactively drawing a keepout area. More...
 
int DrawZoneCutout (const TOOL_EVENT &aEvent)
 Function DrawZoneCutout() Starts interactively drawing a zone cutout area of an existing zone. More...
 
int DrawSimilarZone (const TOOL_EVENT &aEvent)
 Function DrawSimilarZone() Starts interactively drawing a zone with same settings as an existing zone. More...
 
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...
 
void SetContextMenu (CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
OPT_TOOL_EVENT Wait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Protected Types

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

Protected Member Functions

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

Protected Attributes

TOOL_MENU m_menu
 Menu model displayed by the tool. More...
 
bool m_editModules
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Types

enum  ZONE_MODE { ZONE_MODE::ADD, ZONE_MODE::CUTOUT, ZONE_MODE::SIMILAR, ZONE_MODE::GRAPHIC_POLYGON }
 

Private Member Functions

bool drawSegment (int aShape, DRAWSEGMENT *&aGraphic, OPT< VECTOR2D > aStartingPoint=NULLOPT)
 

Starts drawing a selected shape (i.e.

More...
 
bool drawArc (DRAWSEGMENT *&aGraphic)
 

Starts drawing an arc.

More...
 
int drawZone (bool aKeepout, ZONE_MODE aMode)
 Draws a polygon, that is added as a zone or a keepout area. More...
 
bool getSourceZoneForAction (ZONE_MODE aMode, ZONE_CONTAINER *&aZone)
 Function getSourceZoneForAction() More...
 
void runPolygonEventLoop (POLYGON_GEOM_MANAGER &aPolyGeomMgr)
 Run the event loop for polygon creation, sending user input on to the given POLYGON_GEOM_MANAGER for processing into a complete polygon. More...
 
void constrainDimension (DIMENSION *dimension)
 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...
 
PCB_LAYER_ID getDrawingLayer () const
 

Selects a non-copper layer for drawing

More...
 

Private Attributes

KIGFX::VIEWm_view
 
KIGFX::VIEW_CONTROLSm_controls
 
BOARDm_board
 
PCB_BASE_EDIT_FRAMEm_frame
 
MODE m_mode
 
unsigned int m_lineWidth
 Stores the current line width for multisegment drawing. More...
 

Static Private Attributes

static const unsigned int WIDTH_STEP = Millimeter2iu( 0.1 )
 

Friends

class ZONE_CREATE_HELPER
 

Detailed Description

Class DRAWING_TOOL.

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

Definition at line 49 of file drawing_tool.h.

Member Enumeration Documentation

◆ INTERACTIVE_PLACEMENT_OPTIONS

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

Definition at line 109 of file pcb_tool.h.

◆ MODE

enum DRAWING_TOOL::MODE
strong

The possible drawing modes of DRAWING_TOOL

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

Definition at line 68 of file drawing_tool.h.

69  {
70  NONE,
71  LINE,
72  CIRCLE,
73  ARC,
74  TEXT,
75  ANCHOR,
76  DXF,
77  DIMENSION,
78  KEEPOUT,
79  ZONE,
80  GRAPHIC_POLYGON,
81  VIA
82  };
Class 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 80 of file tool_base.h.

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

◆ ZONE_MODE

enum DRAWING_TOOL::ZONE_MODE
strongprivate
Enumerator
ADD 

Add a new zone/keepout with fresh settings.

CUTOUT 

Make a cutout to an existing zone.

SIMILAR 

Add a new zone with the same settings as an existing one.

GRAPHIC_POLYGON 

Definition at line 187 of file drawing_tool.h.

188  {
189  ADD,
190  CUTOUT,
191  SIMILAR,
192  GRAPHIC_POLYGON
193  };
Definition: am_param.h:150

Constructor & Destructor Documentation

◆ DRAWING_TOOL()

DRAWING_TOOL::DRAWING_TOOL ( )

Definition at line 150 of file drawing_tool.cpp.

150  :
151  PCB_TOOL( "pcbnew.InteractiveDrawing" ),
152  m_view( nullptr ), m_controls( nullptr ),
153  m_board( nullptr ), m_frame( nullptr ), m_mode( MODE::NONE ),
154  m_lineWidth( 1 )
155 {
156 }
BOARD * m_board
Definition: drawing_tool.h:263
KIGFX::VIEW * m_view
Definition: drawing_tool.h:261
PCB_TOOL(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool.h:71
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:268
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:262
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264

◆ ~DRAWING_TOOL()

DRAWING_TOOL::~DRAWING_TOOL ( )

Definition at line 159 of file drawing_tool.cpp.

160 {
161 }

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 49 of file tool_interactive.cpp.

50 {
52 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
bool InvokeTool(TOOL_ID aToolId)
Function InvokeTool() Calls a tool by sending a tool activation event to tool of given ID.

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

Referenced by AUTOPLACE_TOOL::autoplace(), PCBNEW_CONTROL::DeleteItemCursor(), EDIT_TOOL::doCopyToClipboard(), PCB_TOOL::doInteractiveItemPlacement(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

◆ 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 59 of file tool_base.cpp.

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

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

Referenced by TOOL_MANAGER::RegisterTool().

◆ board()

BOARD* PCB_TOOL::board ( ) const
inlineprotectedinherited

Definition at line 140 of file pcb_tool.h.

140 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), EDIT_TOOL::changeTrackWidthOnClick(), PCB_EDITOR_CONTROL::ClearHighlight(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), EDIT_TOOL::doCopyToClipboard(), PCB_TOOL::doInteractiveItemPlacement(), drawArc(), DrawDimension(), drawSegment(), MODULE_EDITOR_TOOLS::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), POINT_EDITOR::finishItem(), SELECTION_TOOL::getCollectorsGuide(), PCBNEW_CONTROL::GraphicDisplayMode(), PAD_TOOL::haveFootprints(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_TOOL::module(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PCBNEW_CONTROL::placeBoardItems(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), ROUTER_TOOL::prepareInteractive(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), ZONE_FILLER_TOOL::SegzoneDeleteFill(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectAllItemsConnectedToItem(), SELECTION_TOOL::selectAllItemsConnectedToTrack(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectPoint(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), PCBNEW_CONTROL::TrackDisplayMode(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), ZONE_FILLER_TOOL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ canvas()

◆ constrainDimension()

void DRAWING_TOOL::constrainDimension ( DIMENSION dimension)
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 488 of file drawing_tool.cpp.

489 {
490  const VECTOR2I lineVector{ dimension->GetEnd() - dimension->GetOrigin() };
491 
492  dimension->SetEnd( wxPoint(
493  VECTOR2I( dimension->GetOrigin() ) + GetVectorSnapped45( lineVector ) ) );
494 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
const wxPoint & GetEnd()
Function GetEnd.
void SetEnd(const wxPoint &aEnd)
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 DIMENSION::GetEnd(), DIMENSION::GetOrigin(), GetVectorSnapped45(), and DIMENSION::SetEnd().

Referenced by DrawDimension().

◆ controls()

◆ displayOptions()

PCB_DISPLAY_OPTIONS * PCB_TOOL::displayOptions ( ) const
protectedinherited

◆ doInteractiveItemPlacement()

void PCB_TOOL::doInteractiveItemPlacement ( INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

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

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

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

Definition at line 39 of file pcb_tool.cpp.

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

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

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), DrawVia(), and MODULE_EDITOR_TOOLS::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 293 of file drawing_tool.cpp.

294 {
295  if( m_editModules && !m_frame->GetModel() )
296  return 0;
297 
299  DRAWSEGMENT* arc = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
300  BOARD_COMMIT commit( m_frame );
301 
302  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ARC );
303 
305  wxCURSOR_PENCIL, _( "Add graphic arc" ) );
306 
307  while( drawArc( arc ) )
308  {
309  if( arc )
310  {
311  if( m_editModules )
312  static_cast<EDGE_MODULE*>( arc )->SetLocalCoord();
313 
314  commit.Add( arc );
315  commit.Push( _( "Draw an arc" ) );
316  }
317 
318  arc = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
319  }
320 
322 
323  return 0;
324 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
RAII class that sets an value at construction and resets it to the original value at destruction.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
bool m_editModules
Definition: pcb_tool.h:150
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
Abstract interface for BOARD_ITEMs capable of storing other items inside.
bool drawArc(DRAWSEGMENT *&aGraphic)
Starts drawing an arc.

References COMMIT::Add(), ARC, drawArc(), PCB_BASE_EDIT_FRAME::GetModel(), ID_MODEDIT_ARC_TOOL, ID_PCB_ARC_BUTT, PCB_TOOL::m_editModules, m_frame, m_mode, BOARD_COMMIT::Push(), EDA_DRAW_FRAME::SetNoToolSelected(), and PCB_BASE_FRAME::SetToolID().

Referenced by setTransitions().

◆ drawArc()

bool DRAWING_TOOL::drawArc ( DRAWSEGMENT *&  aGraphic)
private

Starts drawing an arc.

Parameters
aGraphicis an object that is going to be used by the tool for drawing. It has to 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 1170 of file drawing_tool.cpp.

1171 {
1173 
1175 
1176  // Arc geometric construction manager
1178 
1179  // Arc drawing assistant overlay
1180  KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() );
1181 
1182  // Add a VIEW_GROUP that serves as a preview for the new item
1183  SELECTION preview;
1184  m_view->Add( &preview );
1185  m_view->Add( &arcAsst );
1186  GRID_HELPER grid( m_frame );
1187 
1188  m_controls->ShowCursor( true );
1189  m_controls->SetSnapping( true );
1190 
1191  Activate();
1192 
1193  bool firstPoint = false;
1194 
1195  // Main loop: keep receiving events
1196  while( OPT_TOOL_EVENT evt = Wait() )
1197  {
1198  PCB_LAYER_ID layer = getDrawingLayer();
1199  aGraphic->SetLayer( layer );
1200 
1201  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1202  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1203  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1204  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), aGraphic );
1205  m_controls->ForceCursorPosition( true, cursorPos );
1206 
1207  if( evt->IsClick( BUT_LEFT ) )
1208  {
1209  if( !firstPoint )
1210  {
1211  m_controls->SetAutoPan( true );
1212  m_controls->CaptureCursor( true );
1213 
1215 
1216  // Init the new item attributes
1217  // (non-geometric, those are handled by the manager)
1218  aGraphic->SetShape( S_ARC );
1219  aGraphic->SetWidth( m_lineWidth );
1220 
1221  preview.Add( aGraphic );
1222  firstPoint = true;
1223  }
1224 
1225  arcManager.AddPoint( cursorPos, true );
1226  }
1227  else if( evt->IsAction( &deleteLastPoint ) )
1228  {
1229  arcManager.RemoveLastPoint();
1230  }
1231  else if( evt->IsMotion() )
1232  {
1233  // set angle snap
1234  arcManager.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1235 
1236  // update, but don't step the manager state
1237  arcManager.AddPoint( cursorPos, false );
1238  }
1239  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
1240  {
1241  preview.Clear();
1242  delete aGraphic;
1243  aGraphic = nullptr;
1244  break;
1245  }
1246  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1247  {
1249  aGraphic->SetLayer( getDrawingLayer() );
1250  aGraphic->SetWidth( m_lineWidth );
1251  m_view->Update( &preview );
1252  frame()->SetMsgPanel( aGraphic );
1253  }
1254  else if( evt->IsClick( BUT_RIGHT ) )
1255  {
1257  }
1258  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1259  {
1261  aGraphic->SetWidth( m_lineWidth );
1262  m_view->Update( &preview );
1263  frame()->SetMsgPanel( aGraphic );
1264  }
1265  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && m_lineWidth > WIDTH_STEP )
1266  {
1268  aGraphic->SetWidth( m_lineWidth );
1269  m_view->Update( &preview );
1270  frame()->SetMsgPanel( aGraphic );
1271  }
1272  else if( evt->IsAction( &PCB_ACTIONS::arcPosture ) )
1273  {
1274  arcManager.ToggleClockwise();
1275  }
1276 
1277  if( arcManager.IsComplete() )
1278  {
1279  break;
1280  }
1281  else if( arcManager.HasGeometryChanged() )
1282  {
1283  updateArcFromConstructionMgr( arcManager, *aGraphic );
1284  m_view->Update( &preview );
1285  m_view->Update( &arcAsst );
1286 
1287  if(firstPoint)
1288  frame()->SetMsgPanel( aGraphic );
1289  else
1290  frame()->SetMsgPanel( board() );
1291  }
1292  }
1293 
1294  preview.Remove( aGraphic );
1295  m_view->Remove( &arcAsst );
1296  m_view->Remove( &preview );
1297  frame()->SetMsgPanel( board() );
1298  m_controls->SetAutoPan( false );
1299  m_controls->CaptureCursor( false );
1300  m_controls->ForceCursorPosition( false );
1301 
1302  return !arcManager.IsReset();
1303 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void SetShape(STROKE_T aShape)
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:192
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
static TOOL_ACTION deleteLastPoint("pcbnew.InteractiveDrawing.deleteLastPoint", AS_CONTEXT, WXK_BACK, _("Delete Last Point"), _("Delete the last point added to the current item"), undo_xpm)
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:271
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void RemoveLastPoint()
Undo the last point, and move the manager back to the previous step.
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.
void AddPoint(const VECTOR2I &aPt, bool aLockIn)
Add a point to the construction manager.
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:195
KIGFX::VIEW * m_view
Definition: drawing_tool.h:261
PCB_LAYER_ID
A quick note on layer IDs:
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
BOARD * board() const
Definition: pcb_tool.h:140
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:291
Arcs (with rounded ends)
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:268
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:262
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
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:1539
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:264
static TOOL_ACTION arcPosture
Switch posture when drawing arc.
Definition: pcb_actions.h:198
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:291
void ToggleClockwise()
Reverse the current are direction
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
Class SELECTION_AREA.
Definition: arc_assistant.h:38
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
void Activate()
Function Activate() Runs the tool.
void SetAngleSnap(bool aSnap)
Set angle snapping (for the next point)
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:62
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
void SetWidth(int aWidth)

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW::Add(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::AddPoint(), PCB_ACTIONS::arcPosture, GRID_HELPER::BestSnapAnchor(), PCB_TOOL::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), PCB_ACTIONS::decWidth, deleteLastPoint, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL::frame(), getDrawingLayer(), KIGFX::VIEW_CONTROLS::GetMousePosition(), getSegmentWidth(), EDA_DRAW_FRAME::GetUserUnits(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::HasGeometryChanged(), PCB_ACTIONS::incWidth, TOOL_EVT_UTILS::IsCancelInteractive(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::IsComplete(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::IsReset(), PCB_ACTIONS::layerChanged, m_controls, m_frame, m_lineWidth, PCB_TOOL::m_menu, TOOL_BASE::m_toolMgr, m_view, MD_ALT, MD_CTRL, MD_SHIFT, KIGFX::VIEW::Remove(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::RemoveLastPoint(), TOOL_MANAGER::RunAction(), S_ARC, PCB_ACTIONS::selectionClear, KIGFX::PREVIEW::ARC_GEOM_MANAGER::SetAngleSnap(), KIGFX::VIEW_CONTROLS::SetAutoPan(), BOARD_ITEM::SetLayer(), EDA_DRAW_FRAME::SetMsgPanel(), DRAWSEGMENT::SetShape(), GRID_HELPER::SetSnap(), KIGFX::VIEW_CONTROLS::SetSnapping(), GRID_HELPER::SetUseGrid(), DRAWSEGMENT::SetWidth(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::PREVIEW::ARC_GEOM_MANAGER::ToggleClockwise(), 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 259 of file drawing_tool.cpp.

260 {
261  if( m_editModules && !m_frame->GetModel() )
262  return 0;
263 
265  DRAWSEGMENT* circle = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
266  BOARD_COMMIT commit( m_frame );
267 
268  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::CIRCLE );
269 
271  wxCURSOR_PENCIL, _( "Add graphic circle" ) );
272 
273  while( drawSegment( S_CIRCLE, circle ) )
274  {
275  if( circle )
276  {
277  if( m_editModules )
278  static_cast<EDGE_MODULE*>( circle )->SetLocalCoord();
279 
280  commit.Add( circle );
281  commit.Push( _( "Draw a circle" ) );
282  }
283 
284  circle = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
285  }
286 
288 
289  return 0;
290 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
bool drawSegment(int aShape, DRAWSEGMENT *&aGraphic, OPT< VECTOR2D > aStartingPoint=NULLOPT)
Starts drawing a selected shape (i.e.
RAII class that sets an value at construction and resets it to the original value at destruction.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
bool m_editModules
Definition: pcb_tool.h:150
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
Abstract interface for BOARD_ITEMs capable of storing other items inside.

References COMMIT::Add(), CIRCLE, drawSegment(), PCB_BASE_EDIT_FRAME::GetModel(), ID_MODEDIT_CIRCLE_TOOL, ID_PCB_CIRCLE_BUTT, PCB_TOOL::m_editModules, m_frame, m_mode, BOARD_COMMIT::Push(), S_CIRCLE, EDA_DRAW_FRAME::SetNoToolSelected(), and PCB_BASE_FRAME::SetToolID().

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 497 of file drawing_tool.cpp.

498 {
499  if( m_editModules && !m_frame->GetModel() )
500  return 0;
501 
502  DIMENSION* dimension = NULL;
503  BOARD_COMMIT commit( m_frame );
504  GRID_HELPER grid( m_frame );
505 
506  // Add a VIEW_GROUP that serves as a preview for the new item
507  SELECTION preview;
508 
509  m_view->Add( &preview );
510 
512  m_controls->ShowCursor( true );
513  m_controls->SetSnapping( true );
514 
515  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
516 
517  Activate();
518  m_frame->SetToolID( ID_PCB_DIMENSION_BUTT, wxCURSOR_PENCIL, _( "Add dimension" ) );
519 
520  enum DIMENSION_STEPS
521  {
522  SET_ORIGIN = 0,
523  SET_END,
524  SET_HEIGHT,
525  FINISHED
526  };
527  int step = SET_ORIGIN;
528 
529  // Main loop: keep receiving events
530  while( OPT_TOOL_EVENT evt = Wait() )
531  {
532  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
533  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
534  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
535  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), nullptr );
536  m_controls->ForceCursorPosition( true, cursorPos );
537 
539  {
540  m_controls->SetAutoPan( false );
541 
542  if( step != SET_ORIGIN ) // start from the beginning
543  {
544  preview.Clear();
545 
546  delete dimension;
547  step = SET_ORIGIN;
548  }
549  else
550  break;
551 
552  if( evt->IsActivate() ) // now finish unconditionally
553  break;
554  }
555  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) && step != SET_ORIGIN )
556  {
558  dimension->SetWidth( m_lineWidth );
559  m_view->Update( &preview );
560  frame()->SetMsgPanel( dimension );
561  }
562  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && step != SET_ORIGIN )
563  {
564  if( m_lineWidth > WIDTH_STEP )
565  {
567  dimension->SetWidth( m_lineWidth );
568  m_view->Update( &preview );
569  frame()->SetMsgPanel( dimension );
570  }
571  }
572  else if( evt->IsClick( BUT_RIGHT ) )
573  {
575  }
576  else if( evt->IsClick( BUT_LEFT ) )
577  {
578  switch( step )
579  {
580  case SET_ORIGIN:
581  {
582  PCB_LAYER_ID layer = getDrawingLayer();
583  const BOARD_DESIGN_SETTINGS& boardSettings = m_board->GetDesignSettings();
584 
585  if( layer == Edge_Cuts ) // dimensions are not allowed on EdgeCuts
586  layer = Dwgs_User;
587 
588  // Init the new item attributes
589  dimension = new DIMENSION( m_board );
590  dimension->SetLayer( layer );
591  dimension->SetOrigin( wxPoint( cursorPos.x, cursorPos.y ) );
592  dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
593  dimension->Text().SetTextSize( boardSettings.GetTextSize( layer ) );
594  dimension->Text().SetThickness( boardSettings.GetTextThickness( layer ) );
595  dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) );
596  dimension->SetWidth( boardSettings.GetLineThickness( layer ) );
597  dimension->SetUnits( m_frame->GetUserUnits(), false );
598  dimension->AdjustDimensionDetails();
599 
600  preview.Add( dimension );
601  frame()->SetMsgPanel( dimension );
602 
603  m_controls->SetAutoPan( true );
604  m_controls->CaptureCursor( true );
605  }
606  break;
607 
608  case SET_END:
609  dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
610 
611  if( !!evt->Modifier( MD_CTRL ) )
612  constrainDimension( dimension );
613 
614  // Dimensions that have origin and end in the same spot are not valid
615  if( dimension->GetOrigin() == dimension->GetEnd() )
616  --step;
617 
618  break;
619 
620  case SET_HEIGHT:
621  {
622  if( wxPoint( cursorPos.x, cursorPos.y ) != dimension->GetPosition() )
623  {
624  assert( dimension->GetOrigin() != dimension->GetEnd() );
625  assert( dimension->GetWidth() > 0 );
626 
627  preview.Remove( dimension );
628 
629  commit.Add( dimension );
630  commit.Push( _( "Draw a dimension" ) );
631  }
632  }
633  break;
634  }
635 
636  if( ++step == FINISHED )
637  {
638  step = SET_ORIGIN;
639  m_controls->SetAutoPan( false );
640  m_controls->CaptureCursor( false );
641  }
642  }
643  else if( evt->IsMotion() )
644  {
645  switch( step )
646  {
647  case SET_END:
648  dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
649 
650  if( !!evt->Modifier( MD_CTRL ) )
651  constrainDimension( dimension );
652 
653  break;
654 
655  case SET_HEIGHT:
656  {
657  // Calculating the direction of travel perpendicular to the selected axis
658  double angle = dimension->GetAngle() + ( M_PI / 2 );
659 
660  wxPoint pos( cursorPos.x, cursorPos.y );
661  wxPoint delta( pos - dimension->m_featureLineDO );
662  double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
663  dimension->SetHeight( height );
664  }
665  break;
666  }
667 
668  // Show a preview of the item
669  m_view->Update( &preview );
670  if( step )
671  frame()->SetMsgPanel( dimension );
672  else
673  frame()->SetMsgPanel( board() );
674  }
675  }
676 
677  if( step != SET_ORIGIN )
678  delete dimension;
679 
680  m_controls->SetAutoPan( false );
681 
682  m_view->Remove( &preview );
683  frame()->SetMsgPanel( board() );
685 
686  return 0;
687 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:90
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
int GetWidth() const
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
BOARD * m_board
Definition: drawing_tool.h:263
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:192
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:271
void SetItalic(bool isItalic)
Definition: eda_text.h:182
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:539
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
int GetTextThickness(PCB_LAYER_ID aLayer) const
Function GetTextThickness Returns the default text thickness from the layer class for the given layer...
static const int delta[8][2]
Definition: solve.cpp:112
void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:195
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
KIGFX::VIEW * m_view
Definition: drawing_tool.h:261
bool GetTextItalic(PCB_LAYER_ID aLayer) const
int GetLineThickness(PCB_LAYER_ID aLayer) const
Function GetLineThickness Returns the default graphic segment thickness from the layer class for the ...
PCB_LAYER_ID
A quick note on layer IDs:
void SetOrigin(const wxPoint &aOrigin)
Function SetOrigin Sets a new origin of the crossbar line.
RAII class that sets an value at construction and resets it to the original value at destruction.
const wxPoint & GetEnd()
Function GetEnd.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
BOARD * board() const
Definition: pcb_tool.h:140
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:291
void SetEnd(const wxPoint &aEnd)
Function SetEnd Sets a new end of the crossbar line.
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:268
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
void AdjustDimensionDetails()
Function AdjustDimensionDetails Calculate coordinates of segments used to draw the dimension.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:262
void SetUnits(EDA_UNITS_T aUnits, bool aUseMils)
const wxPoint & GetOrigin() const
Function GetOrigin.
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
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:1539
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:264
bool m_editModules
Definition: pcb_tool.h:150
double GetAngle() const
Function GetAngle Returns angle of the crossbar.
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
void constrainDimension(DIMENSION *dimension)
Function constrainDimension() Forces the dimension lime to be drawn on multiple of 45 degrees.
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
TEXTE_PCB & Text()
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
const wxPoint GetPosition() const override
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
void SetWidth(int aWidth)
wxPoint m_featureLineDO
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Function GetTextSize Returns the default text size from the layer class for the given layer.
Class DIMENSION.
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:161
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:82

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), DIMENSION::AdjustDimensionDetails(), PNS::angle(), GRID_HELPER::BestSnapAnchor(), PCB_TOOL::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), constrainDimension(), PCB_ACTIONS::decWidth, delta, DIMENSION, Dwgs_User, Edge_Cuts, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL::frame(), DIMENSION::GetAngle(), BOARD::GetDesignSettings(), getDrawingLayer(), DIMENSION::GetEnd(), BOARD_DESIGN_SETTINGS::GetLineThickness(), PCB_BASE_EDIT_FRAME::GetModel(), KIGFX::VIEW_CONTROLS::GetMousePosition(), DIMENSION::GetOrigin(), DIMENSION::GetPosition(), BOARD_DESIGN_SETTINGS::GetTextItalic(), BOARD_DESIGN_SETTINGS::GetTextSize(), BOARD_DESIGN_SETTINGS::GetTextThickness(), EDA_DRAW_FRAME::GetUserUnits(), DIMENSION::GetWidth(), ID_PCB_DIMENSION_BUTT, PCB_ACTIONS::incWidth, TOOL_EVT_UTILS::IsCancelInteractive(), m_board, m_controls, PCB_TOOL::m_editModules, DIMENSION::m_featureLineDO, m_frame, m_lineWidth, PCB_TOOL::m_menu, m_mode, TOOL_BASE::m_toolMgr, m_view, MD_ALT, MD_CTRL, MD_SHIFT, BOARD_COMMIT::Push(), SELECTION::Remove(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), DIMENSION::SetEnd(), DIMENSION::SetHeight(), EDA_TEXT::SetItalic(), DIMENSION::SetLayer(), EDA_DRAW_FRAME::SetMsgPanel(), EDA_DRAW_FRAME::SetNoToolSelected(), DIMENSION::SetOrigin(), GRID_HELPER::SetSnap(), KIGFX::VIEW_CONTROLS::SetSnapping(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), PCB_BASE_FRAME::SetToolID(), DIMENSION::SetUnits(), GRID_HELPER::SetUseGrid(), DIMENSION::SetWidth(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), DIMENSION::Text(), KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), WIDTH_STEP, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ DrawGraphicPolygon()

int DRAWING_TOOL::DrawGraphicPolygon ( const TOOL_EVENT aEvent)

Definition at line 720 of file drawing_tool.cpp.

721 {
722  if( m_editModules && !m_frame->GetModel() )
723  return 0;
724 
725  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::GRAPHIC_POLYGON );
726 
728  wxCURSOR_PENCIL, _( "Add graphic polygon" ) );
729 
730  return drawZone( false, ZONE_MODE::GRAPHIC_POLYGON );
731 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
RAII class that sets an value at construction and resets it to the original value at destruction.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
bool m_editModules
Definition: pcb_tool.h:150
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()

References drawZone(), PCB_BASE_EDIT_FRAME::GetModel(), GRAPHIC_POLYGON, ID_MODEDIT_POLYGON_TOOL, ID_PCB_ADD_POLYGON_BUTT, PCB_TOOL::m_editModules, m_frame, m_mode, and PCB_BASE_FRAME::SetToolID().

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 218 of file drawing_tool.cpp.

219 {
220  if( m_editModules && !m_frame->GetModel() )
221  return 0;
222 
224  DRAWSEGMENT* line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
225 
226  auto startingPoint = boost::make_optional<VECTOR2D>( false, VECTOR2D( 0, 0 ) );
227  BOARD_COMMIT commit( m_frame );
228 
229  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::LINE );
230 
232  wxCURSOR_PENCIL, _( "Add graphic line" ) );
233 
234  while( drawSegment( S_SEGMENT, line, startingPoint ) )
235  {
236  if( line )
237  {
238  if( m_editModules )
239  static_cast<EDGE_MODULE*>( line )->SetLocalCoord();
240 
241  commit.Add( line );
242  commit.Push( _( "Draw a line segment" ) );
243  startingPoint = VECTOR2D( line->GetEnd() );
244  }
245  else
246  {
247  startingPoint = NULLOPT;
248  }
249 
250  line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
251  }
252 
254 
255  return 0;
256 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
bool drawSegment(int aShape, DRAWSEGMENT *&aGraphic, OPT< VECTOR2D > aStartingPoint=NULLOPT)
Starts drawing a selected shape (i.e.
usual segment : line with rounded ends
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
RAII class that sets an value at construction and resets it to the original value at destruction.
const auto NULLOPT
Definition: optional.h:9
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
bool m_editModules
Definition: pcb_tool.h:150
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
Abstract interface for BOARD_ITEMs capable of storing other items inside.

References COMMIT::Add(), drawSegment(), DRAWSEGMENT::GetEnd(), PCB_BASE_EDIT_FRAME::GetModel(), ID_MODEDIT_LINE_TOOL, ID_PCB_ADD_LINE_BUTT, LINE, PCB_TOOL::m_editModules, m_frame, m_mode, NULLOPT, BOARD_COMMIT::Push(), S_SEGMENT, EDA_DRAW_FRAME::SetNoToolSelected(), and PCB_BASE_FRAME::SetToolID().

Referenced by setTransitions().

◆ drawSegment()

bool DRAWING_TOOL::drawSegment ( int  aShape,
DRAWSEGMENT *&  aGraphic,
OPT< VECTOR2D aStartingPoint = NULLOPT 
)
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. It has to 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 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 938 of file drawing_tool.cpp.

940 {
941  // Only two shapes are currently supported
942  assert( aShape == S_SEGMENT || aShape == S_CIRCLE );
943  GRID_HELPER grid( m_frame );
944 
947 
948  // Add a VIEW_GROUP that serves as a preview for the new item
949  SELECTION preview;
950  m_view->Add( &preview );
951 
953  m_controls->ShowCursor( true );
954 
955  Activate();
956 
957  bool direction45 = false; // 45 degrees only mode
958  bool started = false;
959  bool IsOCurseurSet = ( m_frame->GetScreen()->m_O_Curseur != wxPoint( 0, 0 ) );
960  VECTOR2I cursorPos = m_controls->GetMousePosition();
961 
962  if( aStartingPoint )
963  {
964  // Init the new item attributes
965  aGraphic->SetShape( (STROKE_T) aShape );
966  aGraphic->SetWidth( m_lineWidth );
967  aGraphic->SetLayer( getDrawingLayer() );
968  aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) );
969 
970  cursorPos = grid.BestSnapAnchor( cursorPos, aGraphic );
971  m_controls->ForceCursorPosition( true, cursorPos );
972  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
973 
974  preview.Add( aGraphic );
975  m_controls->SetAutoPan( true );
976  m_controls->CaptureCursor( true );
977 
978  if( !IsOCurseurSet )
979  m_frame->GetScreen()->m_O_Curseur = wxPoint( aStartingPoint->x, aStartingPoint->y );
980 
981  started = true;
982  }
983 
984  // Main loop: keep receiving events
985  while( OPT_TOOL_EVENT evt = Wait() )
986  {
987  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
988  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
989  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
990  cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), getDrawingLayer() );
991  m_controls->ForceCursorPosition( true, cursorPos );
992 
993  // 45 degree angle constraint enabled with an option and toggled with Ctrl
994  const bool limit45 = ( frame()->Settings().m_use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) );
995 
996  if( direction45 != limit45 && started && aShape == S_SEGMENT )
997  {
998  direction45 = limit45;
999 
1000  if( direction45 )
1001  {
1002  const VECTOR2I lineVector( cursorPos - VECTOR2I( aGraphic->GetStart() ) );
1003 
1004  // get a restricted 45/H/V line from the last fixed point to the cursor
1005  auto newEnd = GetVectorSnapped45( lineVector );
1006  aGraphic->SetEnd( aGraphic->GetStart() + wxPoint( newEnd.x, newEnd.y ) );
1007  m_controls->ForceCursorPosition( true, VECTOR2I( aGraphic->GetEnd() ) );
1008  }
1009  else
1010  {
1011  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1012  }
1013 
1014  m_view->Update( &preview );
1015  frame()->SetMsgPanel( aGraphic );
1016  }
1017 
1019  {
1020  preview.Clear();
1021  m_view->Update( &preview );
1022  delete aGraphic;
1023  aGraphic = NULL;
1024  if( !IsOCurseurSet )
1025  m_frame->GetScreen()->m_O_Curseur = wxPoint( 0, 0 );
1026  break;
1027  }
1028  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1029  {
1031  aGraphic->SetLayer( getDrawingLayer() );
1032  aGraphic->SetWidth( m_lineWidth );
1033  m_view->Update( &preview );
1034  frame()->SetMsgPanel( aGraphic );
1035  }
1036  else if( evt->IsClick( BUT_RIGHT ) )
1037  {
1039  }
1040  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
1041  {
1042  if( !started )
1043  {
1045 
1046  // Init the new item attributes
1047  aGraphic->SetShape( (STROKE_T) aShape );
1048  aGraphic->SetWidth( m_lineWidth );
1049  aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) );
1050  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1051  aGraphic->SetLayer( getDrawingLayer() );
1052 
1053  if( !IsOCurseurSet )
1054  m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
1055 
1056  preview.Add( aGraphic );
1057  frame()->SetMsgPanel( aGraphic );
1058  m_controls->SetAutoPan( true );
1059  m_controls->CaptureCursor( true );
1060 
1061  started = true;
1062  }
1063  else
1064  {
1065  auto snapItem = dyn_cast<DRAWSEGMENT*>( grid.GetSnapped() );
1066  auto mod = dyn_cast<MODULE*>( m_frame->GetModel() );
1067 
1068  if( aGraphic->GetEnd() == aGraphic->GetStart()
1069  || ( evt->IsDblClick( BUT_LEFT ) && aShape == S_SEGMENT )
1070  || snapItem )
1071  // User has clicked twice in the same spot
1072  // or clicked on the end of an existing segment (closing a path)
1073  {
1074  BOARD_COMMIT commit( m_frame );
1075 
1076  // If the user clicks on an existing snap point from a drawsegment
1077  // we finish the segment as they are likely closing a path
1078  if( snapItem && aGraphic->GetLength() > 0.0 )
1079  {
1080  DRAWSEGMENT* l = m_editModules ? new EDGE_MODULE( mod ) : new DRAWSEGMENT;
1081 
1082  *l = *aGraphic;
1083  commit.Add( l );
1084  }
1085 
1086  if( !commit.Empty() )
1087  commit.Push( _( "Draw a line" ) );
1088 
1089  delete aGraphic;
1090  aGraphic = NULL;
1091  }
1092 
1093  preview.Clear();
1094  break;
1095  }
1096  }
1097  else if( evt->IsMotion() )
1098  {
1099  // 45 degree lines
1100  if( direction45 && aShape == S_SEGMENT )
1101  {
1102  const VECTOR2I lineVector( cursorPos - VECTOR2I( aGraphic->GetStart() ) );
1103 
1104  // get a restricted 45/H/V line from the last fixed point to the cursor
1105  auto newEnd = GetVectorSnapped45( lineVector );
1106  aGraphic->SetEnd( aGraphic->GetStart() + wxPoint( newEnd.x, newEnd.y ) );
1107  m_controls->ForceCursorPosition( true, VECTOR2I( aGraphic->GetEnd() ) );
1108  }
1109  else
1110  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1111 
1112  m_view->Update( &preview );
1113 
1114  if( started )
1115  frame()->SetMsgPanel( aGraphic );
1116  else
1117  frame()->SetMsgPanel( board() );
1118  }
1119  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1120  {
1122  aGraphic->SetWidth( m_lineWidth );
1123  m_view->Update( &preview );
1124  frame()->SetMsgPanel( aGraphic );
1125  }
1126  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && ( m_lineWidth > WIDTH_STEP ) )
1127  {
1129  aGraphic->SetWidth( m_lineWidth );
1130  m_view->Update( &preview );
1131  frame()->SetMsgPanel( aGraphic );
1132  }
1133  else if( evt->IsAction( &PCB_ACTIONS::resetCoords ) )
1134  {
1135  IsOCurseurSet = true;
1136  }
1137  }
1138 
1139  if( !IsOCurseurSet ) // reset the relative coordinte if it was not set before
1140  m_frame->GetScreen()->m_O_Curseur = wxPoint( 0, 0 );
1141 
1142  m_view->Remove( &preview );
1143  frame()->SetMsgPanel( board() );
1144  m_controls->SetAutoPan( false );
1145  m_controls->CaptureCursor( false );
1146  m_controls->ForceCursorPosition( false );
1147 
1148  return started;
1149 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void SetShape(STROKE_T aShape)
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:90
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:192
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:271
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
usual segment : line with rounded ends
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
static TOOL_ACTION resetCoords
Definition: pcb_actions.h:369
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:195
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
KIGFX::VIEW * m_view
Definition: drawing_tool.h:261
static bool m_use45DegreeGraphicSegments
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
PCB_GENERAL_SETTINGS & Settings()
BOARD * board() const
Definition: pcb_tool.h:140
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:268
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:262
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
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:1539
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.
void SetStart(const wxPoint &aStart)
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
bool m_editModules
Definition: pcb_tool.h:150
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:291
double GetLength() const
Function GetLength returns the length of the track using the hypotenuse calculation.
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
void SetEnd(const wxPoint &aEnd)
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec)
Snap a vector onto the nearest 0, 45 or 90 degree line.
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
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:62
#define mod(a, n)
Definition: greymap.cpp:24
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
void SetWidth(int aWidth)

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), GRID_HELPER::BestSnapAnchor(), PCB_TOOL::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_ACTIONS::decWidth, COMMIT::Empty(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL::frame(), getDrawingLayer(), DRAWSEGMENT::GetEnd(), DRAWSEGMENT::GetLength(), PCB_BASE_EDIT_FRAME::GetModel(), KIGFX::VIEW_CONTROLS::GetMousePosition(), PCB_BASE_FRAME::GetScreen(), getSegmentWidth(), GRID_HELPER::GetSnapped(), DRAWSEGMENT::GetStart(), GetVectorSnapped45(), PCB_ACTIONS::incWidth, TOOL_EVT_UTILS::IsCancelInteractive(), PCB_ACTIONS::layerChanged, m_controls, PCB_TOOL::m_editModules, m_frame, m_lineWidth, PCB_TOOL::m_menu, BASE_SCREEN::m_O_Curseur, TOOL_BASE::m_toolMgr, PCB_GENERAL_SETTINGS::m_use45DegreeGraphicSegments, m_view, MD_ALT, MD_CTRL, MD_SHIFT, mod, BOARD_COMMIT::Push(), KIGFX::VIEW::Remove(), PCB_ACTIONS::resetCoords, TOOL_MANAGER::RunAction(), S_CIRCLE, S_SEGMENT, PCB_ACTIONS::selectionClear, PCB_BASE_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), DRAWSEGMENT::SetEnd(), BOARD_ITEM::SetLayer(), EDA_DRAW_FRAME::SetMsgPanel(), DRAWSEGMENT::SetShape(), GRID_HELPER::SetSnap(), KIGFX::VIEW_CONTROLS::SetSnapping(), DRAWSEGMENT::SetStart(), PCB_BASE_FRAME::Settings(), GRID_HELPER::SetUseGrid(), DRAWSEGMENT::SetWidth(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), WIDTH_STEP, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DrawCircle(), and DrawLine().

◆ DrawSimilarZone()

int DRAWING_TOOL::DrawSimilarZone ( const TOOL_EVENT aEvent)

Function DrawSimilarZone() Starts interactively drawing a zone with same settings as an existing zone.

The normal zone interactive tool is used, but the zone settings dialog is not shown at the start.

Definition at line 734 of file drawing_tool.cpp.

735 {
736  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
737 
738  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add similar zone" ) );
739 
740  return drawZone( false, ZONE_MODE::SIMILAR );
741 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
Add a new zone with the same settings as an existing one.
RAII class that sets an value at construction and resets it to the original value at destruction.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264

References drawZone(), ID_PCB_ZONES_BUTT, m_frame, m_mode, PCB_BASE_FRAME::SetToolID(), SIMILAR, and ZONE.

Referenced by setTransitions().

◆ DrawVia()

int DRAWING_TOOL::DrawVia ( const TOOL_EVENT aEvent)

Definition at line 1495 of file drawing_tool.cpp.

1496 {
1497  struct VIA_PLACER : public INTERACTIVE_PLACER_BASE
1498  {
1499  GRID_HELPER m_gridHelper;
1500 
1501  VIA_PLACER( PCB_EDIT_FRAME* aFrame ) : m_gridHelper( aFrame )
1502  {}
1503 
1504  TRACK* findTrack( VIA* aVia )
1505  {
1506  const LSET lset = aVia->GetLayerSet();
1507  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
1508  BOX2I bbox = aVia->GetBoundingBox();
1509  auto view = m_frame->GetGalCanvas()->GetView();
1510  std::vector<TRACK*> possible_tracks;
1511 
1512  view->Query( bbox, items );
1513 
1514  for( auto it : items )
1515  {
1516  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
1517 
1518  if( !(item->GetLayerSet() & lset ).any() )
1519  continue;
1520 
1521  if( auto track = dyn_cast<TRACK*>( item ) )
1522  {
1523  if( TestSegmentHit( aVia->GetPosition(), track->GetStart(), track->GetEnd(),
1524  ( track->GetWidth() + aVia->GetWidth() ) / 2 ) )
1525  possible_tracks.push_back( track );
1526  }
1527  }
1528 
1529  TRACK* return_track = nullptr;
1530  int min_d = std::numeric_limits<int>::max();
1531  for( auto track : possible_tracks )
1532  {
1533  SEG test( track->GetStart(), track->GetEnd() );
1534  auto dist = ( test.NearestPoint( aVia->GetPosition() ) -
1535  VECTOR2I( aVia->GetPosition() ) ).EuclideanNorm();
1536 
1537  if( dist < min_d )
1538  {
1539  min_d = dist;
1540  return_track = track;
1541  }
1542  }
1543 
1544  return return_track;
1545  }
1546 
1547 
1548  bool hasDRCViolation( VIA* aVia )
1549  {
1550  const LSET lset = aVia->GetLayerSet();
1551  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
1552  int net = 0;
1553  int clearance = 0;
1554  BOX2I bbox = aVia->GetBoundingBox();
1555  auto view = m_frame->GetGalCanvas()->GetView();
1556 
1557  view->Query( bbox, items );
1558 
1559  for( auto it : items )
1560  {
1561  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
1562 
1563  if( !(item->GetLayerSet() & lset ).any() )
1564  continue;
1565 
1566  if( auto track = dyn_cast<TRACK*>( item ) )
1567  {
1568  int max_clearance = std::max( clearance, track->GetClearance() );
1569 
1570  if( TestSegmentHit( aVia->GetPosition(), track->GetStart(), track->GetEnd(),
1571  ( track->GetWidth() + aVia->GetWidth() ) / 2 + max_clearance ) )
1572  {
1573  if( net && track->GetNetCode() != net )
1574  return true;
1575 
1576  net = track->GetNetCode();
1577  clearance = track->GetClearance();
1578  }
1579  }
1580 
1581  if( auto mod = dyn_cast<MODULE*>( item ) )
1582  {
1583  for( auto pad : mod->Pads() )
1584  {
1585  int max_clearance = std::max( clearance, pad->GetClearance() );
1586 
1587  if( pad->HitTest( aVia->GetBoundingBox(), false, max_clearance ) )
1588  {
1589  if( net && pad->GetNetCode() != net )
1590  return true;
1591 
1592  net = pad->GetNetCode();
1593  clearance = pad->GetClearance();
1594  }
1595  }
1596  }
1597  }
1598 
1599  return false;
1600  }
1601 
1602 
1603  int findStitchedZoneNet( VIA* aVia )
1604  {
1605  const auto pos = aVia->GetPosition();
1606  const auto lset = aVia->GetLayerSet();
1607 
1608  for( auto mod : m_board->Modules() )
1609  {
1610  for( D_PAD* pad : mod->Pads() )
1611  {
1612  if( pad->HitTest( pos ) && ( pad->GetLayerSet() & lset ).any() )
1613  return -1;
1614  }
1615  }
1616 
1617  std::vector<ZONE_CONTAINER*> foundZones;
1618 
1619  for( auto zone : m_board->Zones() )
1620  {
1621  if( zone->HitTestFilledArea( pos ) )
1622  {
1623  foundZones.push_back( zone );
1624  }
1625  }
1626 
1627  std::sort( foundZones.begin(), foundZones.end(),
1628  [] ( const ZONE_CONTAINER* a, const ZONE_CONTAINER* b ) {
1629  return a->GetLayer() < b->GetLayer();
1630  } );
1631 
1632  // first take the net of the active layer
1633  for( auto z : foundZones )
1634  {
1635  if( m_frame->GetActiveLayer() == z->GetLayer() )
1636  return z->GetNetCode();
1637  }
1638 
1639  // none? take the topmost visible layer
1640  for( auto z : foundZones )
1641  {
1642  if( m_board->IsLayerVisible( z->GetLayer() ) )
1643  return z->GetNetCode();
1644  }
1645 
1646  return -1;
1647  }
1648 
1649  void SnapItem( BOARD_ITEM *aItem ) override
1650  {
1651  // If you place a Via on a track but not on its centerline, the current
1652  // connectivity algorithm will require us to put a kink in the track when
1653  // we break it (so that each of the two segments ends on the via center).
1654  // That's not ideal, and is in fact probably worse than forcing snap in
1655  // this situation.
1656 
1657  m_gridHelper.SetSnap( !( m_modifiers & MD_SHIFT ) );
1658  auto via = static_cast<VIA*>( aItem );
1659  wxPoint pos = via->GetPosition();
1660  TRACK* track = findTrack( via );
1661 
1662  if( track )
1663  {
1664  SEG trackSeg( track->GetStart(), track->GetEnd() );
1665  VECTOR2I snap = m_gridHelper.AlignToSegment( pos, trackSeg );
1666 
1667  aItem->SetPosition( wxPoint( snap.x, snap.y ) );
1668  }
1669  }
1670 
1671  bool PlaceItem( BOARD_ITEM* aItem, BOARD_COMMIT& aCommit ) override
1672  {
1673  auto via = static_cast<VIA*>( aItem );
1674  int newNet;
1675  TRACK* track = findTrack( via );
1676 
1677  if( hasDRCViolation( via ) )
1678  return false;
1679 
1680  if( track )
1681  {
1682  aCommit.Modify( track );
1683  TRACK* newTrack = dynamic_cast<TRACK*>( track->Clone() );
1684  track->SetEnd( via->GetPosition() );
1685  newTrack->SetStart( via->GetPosition() );
1686  aCommit.Add( newTrack );
1687 
1688  newNet = track->GetNetCode();
1689  }
1690  else
1691  newNet = findStitchedZoneNet( via );
1692 
1693  if( newNet > 0 )
1694  via->SetNetCode( newNet );
1695 
1696  aCommit.Add( aItem );
1697  return true;
1698  }
1699 
1700  std::unique_ptr<BOARD_ITEM> CreateItem() override
1701  {
1702  auto& ds = m_board->GetDesignSettings();
1703  VIA* via = new VIA( m_board );
1704 
1705  via->SetNetCode( 0 );
1706  via->SetViaType( ds.m_CurrentViaType );
1707 
1708  // for microvias, the size and hole will be changed later.
1709  via->SetWidth( ds.GetCurrentViaSize() );
1710  via->SetDrill( ds.GetCurrentViaDrill() );
1711 
1712  // Usual via is from copper to component.
1713  // layer pair is B_Cu and F_Cu.
1714  via->SetLayerPair( B_Cu, F_Cu );
1715 
1716  PCB_LAYER_ID first_layer = m_frame->GetActiveLayer();
1717  PCB_LAYER_ID last_layer;
1718 
1719  // prepare switch to new active layer:
1720  if( first_layer != m_frame->GetScreen()->m_Route_Layer_TOP )
1721  last_layer = m_frame->GetScreen()->m_Route_Layer_TOP;
1722  else
1723  last_layer = m_frame->GetScreen()->m_Route_Layer_BOTTOM;
1724 
1725  // Adjust the actual via layer pair
1726  switch( via->GetViaType() )
1727  {
1728  case VIA_BLIND_BURIED:
1729  via->SetLayerPair( first_layer, last_layer );
1730  break;
1731 
1732  case VIA_MICROVIA: // from external to the near neighbor inner layer
1733  {
1734  PCB_LAYER_ID last_inner_layer =
1735  ToLAYER_ID( ( m_board->GetCopperLayerCount() - 2 ) );
1736 
1737  if( first_layer == B_Cu )
1738  last_layer = last_inner_layer;
1739  else if( first_layer == F_Cu )
1740  last_layer = In1_Cu;
1741  else if( first_layer == last_inner_layer )
1742  last_layer = B_Cu;
1743  else if( first_layer == In1_Cu )
1744  last_layer = F_Cu;
1745 
1746  // else error: will be removed later
1747  via->SetLayerPair( first_layer, last_layer );
1748 
1749  // Update diameter and hole size, which where set previously
1750  // for normal vias
1751  NETINFO_ITEM* net = via->GetNet();
1752 
1753  if( net )
1754  {
1755  via->SetWidth( net->GetMicroViaSize() );
1756  via->SetDrill( net->GetMicroViaDrillSize() );
1757  }
1758  }
1759  break;
1760 
1761  default:
1762  break;
1763  }
1764 
1765  return std::unique_ptr<BOARD_ITEM>( via );
1766  }
1767  };
1768 
1769  VIA_PLACER placer( frame() );
1770 
1771  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
1772 
1773  frame()->SetToolID( ID_PCB_DRAW_VIA_BUTT, wxCURSOR_PENCIL, _( "Add vias" ) );
1774 
1775  doInteractiveItemPlacement( &placer, _( "Place via" ),
1777 
1778  frame()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
1779 
1780  return 0;
1781 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
int GetNetCode() const
Function GetNetCode.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
static const int dist[10][10]
Definition: ar_matrix.cpp:320
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:263
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:462
virtual void SetPosition(const wxPoint &aPos)=0
Class 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:122
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:126
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:935
KIGFX::PCB_VIEW * view() const
Definition: pcb_tool.h:137
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:179
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.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:539
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
void SetWidth(int aWidth)
Definition: class_track.h:119
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID
A quick note on layer IDs:
Class 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.
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:255
VIATYPE_T GetViaType() const
Definition: class_track.h:461
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:46
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
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.
const wxPoint GetPosition() const override
Definition: class_track.h:433
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
void SetSnap(bool aSnap)
Definition: grid_helper.h:72
Definition: seg.h:36
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:458
ZONE_CONTAINERS & Zones()
Definition: class_board.h:257
int GetWidth() const
Definition: class_track.h:120
#define max(a, b)
Definition: auxiliary.h:86
KIGFX::VIEW * GetView() const
Function GetView() Returns a pointer to the VIEW instance used in the panel.
int GetCopperLayerCount() const
Function GetCopperLayerCount.
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:469
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
const wxPoint & GetEnd() const
Definition: class_track.h:123
int GetMicroViaDrillSize()
Function GetViaDrillSize returns the size of via drills used to route this net.
Definition: netinfo.h:186
void SetStart(const wxPoint &aStart)
Definition: class_track.h:125
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(INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
Helper function for performing a common interactive idiom: wait for a left click, place an item there...
Definition: pcb_tool.cpp:39
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:122
int GetMicroViaSize()
Function GetMicroViaSize returns the size of vias used to route this net.
Definition: netinfo.h:166
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:813
#define mod(a, n)
Definition: greymap.cpp:24
PCB_LAYER_ID m_Route_Layer_TOP
Definition: pcb_screen.h:45
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, TRACK::Clone(), dist, PCB_TOOL::doInteractiveItemPlacement(), F_Cu, PCB_TOOL::frame(), PCB_BASE_FRAME::GetActiveLayer(), TRACK::GetBoundingBox(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), TRACK::GetEnd(), EDA_DRAW_FRAME::GetGalCanvas(), ZONE_CONTAINER::GetLayer(), BOARD_ITEM::GetLayerSet(), VIA::GetLayerSet(), NETINFO_ITEM::GetMicroViaDrillSize(), NETINFO_ITEM::GetMicroViaSize(), BOARD_CONNECTED_ITEM::GetNet(), BOARD_CONNECTED_ITEM::GetNetCode(), VIA::GetPosition(), PCB_BASE_FRAME::GetScreen(), TRACK::GetStart(), VIA::GetViaType(), EDA_DRAW_PANEL_GAL::GetView(), TRACK::GetWidth(), ID_NO_TOOL_SELECTED, ID_PCB_DRAW_VIA_BUTT, In1_Cu, PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, BOARD::IsLayerVisible(), m_board, m_frame, m_mode, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, max, MD_SHIFT, mod, COMMIT::Modify(), BOARD::Modules(), KIGFX::VIEW::Query(), VIA::SetDrill(), TRACK::SetEnd(), VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), BOARD_ITEM::SetPosition(), GRID_HELPER::SetSnap(), TRACK::SetStart(), PCB_BASE_FRAME::SetToolID(), VIA::SetViaType(), TRACK::SetWidth(), TestSegmentHit(), ToLAYER_ID(), VIA, VIA_BLIND_BURIED, VIA_MICROVIA, PCB_TOOL::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.

Definition at line 690 of file drawing_tool.cpp.

691 {
692  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
693 
694  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zones" ) );
695 
696  return drawZone( false, ZONE_MODE::ADD );
697 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
RAII class that sets an value at construction and resets it to the original value at destruction.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
Add a new zone/keepout with fresh settings.

References ADD, drawZone(), ID_PCB_ZONES_BUTT, m_frame, m_mode, PCB_BASE_FRAME::SetToolID(), and ZONE.

Referenced by setTransitions().

◆ drawZone()

int DRAWING_TOOL::drawZone ( bool  aKeepout,
ZONE_MODE  aMode 
)
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 one

Definition at line 1340 of file drawing_tool.cpp.

1341 {
1342  // get a source zone, if we need one. We need it for:
1343  // ZONE_MODE::CUTOUT (adding a hole to the source zone)
1344  // ZONE_MODE::SIMILAR (creating a new zone using settings of source zone
1345  ZONE_CONTAINER* sourceZone = nullptr;
1346 
1347  if( !getSourceZoneForAction( aMode, sourceZone ) )
1348  {
1350  return 0;
1351  }
1352 
1354 
1355  params.m_keepout = aKeepout;
1356  params.m_mode = aMode;
1357  params.m_sourceZone = sourceZone;
1358 
1359  if( aMode == ZONE_MODE::GRAPHIC_POLYGON )
1360  params.m_layer = getDrawingLayer();
1361  else if( aMode == ZONE_MODE::SIMILAR )
1362  params.m_layer = sourceZone->GetLayer();
1363  else
1364  params.m_layer = m_frame->GetActiveLayer();
1365 
1366  ZONE_CREATE_HELPER zoneTool( *this, params );
1367 
1368  // the geometry manager which handles the zone geometry, and
1369  // hands the calculated points over to the zone creator tool
1370  POLYGON_GEOM_MANAGER polyGeomMgr( zoneTool );
1371 
1372  Activate(); // register for events
1373 
1374  m_controls->ShowCursor( true );
1375  m_controls->SetSnapping( true );
1376 
1377  bool started = false;
1378  GRID_HELPER grid( m_frame );
1379  STATUS_TEXT_POPUP status( m_frame );
1380  status.SetTextColor( wxColour( 255, 0, 0 ) );
1381  status.SetText( _( "Self-intersecting polygons are not allowed" ) );
1382 
1383  while( OPT_TOOL_EVENT evt = Wait() )
1384  {
1385  LSET layers( m_frame->GetActiveLayer() );
1386  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1387  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1388  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1389  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), layers );
1390  m_controls->ForceCursorPosition( true, cursorPos );
1391 
1393  {
1394  // pre-empted by another tool, give up
1395  // cancelled without an inprogress polygon, give up
1396  if( !polyGeomMgr.IsPolygonInProgress() || evt->IsActivate() )
1397  {
1398  break;
1399  }
1400 
1401  polyGeomMgr.Reset();
1402  // start again
1403  started = false;
1404 
1405  m_controls->SetAutoPan( false );
1406  m_controls->CaptureCursor( false );
1407  }
1408  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1409  {
1410  if( aMode == ZONE_MODE::GRAPHIC_POLYGON )
1411  params.m_layer = getDrawingLayer();
1412  else if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::CUTOUT )
1413  params.m_layer = frame()->GetActiveLayer();
1414  }
1415  else if( evt->IsClick( BUT_RIGHT ) )
1416  {
1418  }
1419  // events that lock in nodes
1420  else if( evt->IsClick( BUT_LEFT )
1421  || evt->IsDblClick( BUT_LEFT )
1422  || evt->IsAction( &closeZoneOutline ) )
1423  {
1424  // Check if it is double click / closing line (so we have to finish the zone)
1425  const bool endPolygon = evt->IsDblClick( BUT_LEFT )
1426  || evt->IsAction( &closeZoneOutline )
1427  || polyGeomMgr.NewPointClosesOutline( cursorPos );
1428 
1429  if( endPolygon )
1430  {
1431  polyGeomMgr.SetFinished();
1432  polyGeomMgr.Reset();
1433 
1434  started = false;
1435  m_controls->SetAutoPan( false );
1436  m_controls->CaptureCursor( false );
1437  }
1438 
1439  // adding a corner
1440  else if( polyGeomMgr.AddPoint( cursorPos ) )
1441  {
1442  if( !started )
1443  {
1444  started = true;
1445  m_controls->SetAutoPan( true );
1446  m_controls->CaptureCursor( true );
1447  }
1448  }
1449 
1450  }
1451  else if( evt->IsAction( &deleteLastPoint ) )
1452  {
1453  polyGeomMgr.DeleteLastCorner();
1454 
1455  if( !polyGeomMgr.IsPolygonInProgress() )
1456  {
1457  // report finished as an empty shape
1458  polyGeomMgr.SetFinished();
1459 
1460  // start again
1461  started = false;
1462  m_controls->SetAutoPan( false );
1463  m_controls->CaptureCursor( false );
1464  }
1465  }
1466  else if( polyGeomMgr.IsPolygonInProgress()
1467  && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
1468  {
1469  polyGeomMgr.SetCursorPosition( cursorPos, evt->Modifier( MD_CTRL )
1472 
1473  if( polyGeomMgr.IsSelfIntersecting( true ) )
1474  {
1475  wxPoint p = wxGetMousePosition() + wxPoint( 20, 20 );
1476  status.Move( p );
1477  status.Popup( m_frame );
1478  status.Expire( 1500 );
1479  }
1480  else
1481  {
1482  status.Hide();
1483  }
1484  }
1485  } // end while
1486 
1489  m_controls->ForceCursorPosition( false );
1490 
1491  return 0;
1492 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:59
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
static TOOL_ACTION closeZoneOutline("pcbnew.InteractiveDrawing.closeZoneOutline", AS_CONTEXT, 0, _("Close Zone Outline"), _("Close the outline of a zone in progress"), checked_ok_xpm)
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
static TOOL_ACTION deleteLastPoint("pcbnew.InteractiveDrawing.deleteLastPoint", AS_CONTEXT, WXK_BACK, _("Delete Last Point"), _("Delete the last point added to the current item"), undo_xpm)
Class STATUS_TEXT_POPUP.
Definition: status_popup.h:79
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:179
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
PCB_LAYER_ID m_layer
Layer to begin drawing
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
bool getSourceZoneForAction(ZONE_MODE aMode, ZONE_CONTAINER *&aZone)
Function getSourceZoneForAction()
Parameters used to fully describe a zone creation process.
Add a new zone with the same settings as an existing one.
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
Unconstrained point-to-point
Class LSET is a set of PCB_LAYER_IDs.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
ZONE_CONTAINER * m_sourceZone
Zone settings source (for similar and cutout zones)
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:262
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
DRAWING_TOOL::ZONE_MODE m_mode
The zone mode to operate in
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:291
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
This class is an adjuct helper to the DRAWING_TOOL interactive tool, which handles incoming geometry ...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
void Activate()
Function Activate() Runs the tool.
bool m_keepout
Should create a keepout zone?
Add a new zone/keepout with fresh settings.
Make a cutout to an existing zone.
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
Class that handles the drawing of a polygon, including management of last corner deletion and drawing...
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495

References TOOL_INTERACTIVE::Activate(), ADD, POLYGON_GEOM_MANAGER::AddPoint(), GRID_HELPER::BestSnapAnchor(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), closeZoneOutline, CUTOUT, POLYGON_GEOM_MANAGER::DEG45, POLYGON_GEOM_MANAGER::DeleteLastCorner(), deleteLastPoint, POLYGON_GEOM_MANAGER::DIRECT, STATUS_POPUP::Expire(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL::frame(), PCB_BASE_FRAME::GetActiveLayer(), getDrawingLayer(), ZONE_CONTAINER::GetLayer(), KIGFX::VIEW_CONTROLS::GetMousePosition(), getSourceZoneForAction(), GRAPHIC_POLYGON, TOOL_EVT_UTILS::IsCancelInteractive(), POLYGON_GEOM_MANAGER::IsPolygonInProgress(), POLYGON_GEOM_MANAGER::IsSelfIntersecting(), PCB_ACTIONS::layerChanged, m_controls, m_frame, ZONE_CREATE_HELPER::PARAMS::m_keepout, ZONE_CREATE_HELPER::PARAMS::m_layer, PCB_TOOL::m_menu, ZONE_CREATE_HELPER::PARAMS::m_mode, ZONE_CREATE_HELPER::PARAMS::m_sourceZone, TOOL_BASE::m_toolMgr, MD_ALT, MD_CTRL, MD_SHIFT, STATUS_POPUP::Move(), POLYGON_GEOM_MANAGER::NewPointClosesOutline(), STATUS_POPUP::Popup(), POLYGON_GEOM_MANAGER::Reset(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), POLYGON_GEOM_MANAGER::SetCursorPosition(), POLYGON_GEOM_MANAGER::SetFinished(), EDA_DRAW_FRAME::SetNoToolSelected(), GRID_HELPER::SetSnap(), KIGFX::VIEW_CONTROLS::SetSnapping(), STATUS_TEXT_POPUP::SetText(), STATUS_TEXT_POPUP::SetTextColor(), GRID_HELPER::SetUseGrid(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), SIMILAR, and TOOL_INTERACTIVE::Wait().

Referenced by DrawGraphicPolygon(), DrawSimilarZone(), DrawZone(), DrawZoneCutout(), and DrawZoneKeepout().

◆ DrawZoneCutout()

int DRAWING_TOOL::DrawZoneCutout ( const TOOL_EVENT aEvent)

Function DrawZoneCutout() Starts interactively drawing a zone cutout area of an existing zone.

The normal zone interactive tool is used, but the zone settings dialog is not shown (since the cutout affects only shape of an existing zone).

Definition at line 710 of file drawing_tool.cpp.

711 {
712  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
713 
714  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zone cutout" ) );
715 
716  return drawZone( false, ZONE_MODE::CUTOUT );
717 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
RAII class that sets an value at construction and resets it to the original value at destruction.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
Make a cutout to an existing zone.

References CUTOUT, drawZone(), ID_PCB_ZONES_BUTT, m_frame, m_mode, PCB_BASE_FRAME::SetToolID(), and ZONE.

Referenced by setTransitions().

◆ DrawZoneKeepout()

int DRAWING_TOOL::DrawZoneKeepout ( const TOOL_EVENT aEvent)

Function DrawZoneKeepout() Starts interactively drawing a keepout area.

After invoking the function an area 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 area. Double click or clicking on the origin of the boundary polyline finishes the drawing.

Definition at line 700 of file drawing_tool.cpp.

701 {
702  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::KEEPOUT );
703 
704  m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add keepout" ) );
705 
706  return drawZone( true, ZONE_MODE::ADD );
707 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
RAII class that sets an value at construction and resets it to the original value at destruction.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
Add a new zone/keepout with fresh settings.

References ADD, drawZone(), ID_PCB_KEEPOUT_AREA_BUTT, KEEPOUT, m_frame, m_mode, and PCB_BASE_FRAME::SetToolID().

Referenced by setTransitions().

◆ EditingModules()

bool PCB_TOOL::EditingModules ( ) const
inlineinherited

◆ evActivate()

const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

◆ evButtonDown()

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited

◆ evButtonUp()

const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited

◆ evClick()

const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited

◆ evCommand() [1/2]

const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited

◆ evCommand() [2/2]

const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited

◆ evDrag()

const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited

◆ evMotion()

const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited

◆ frame()

PCB_EDIT_FRAME* PCB_TOOL::frame ( ) const
inlineprotectedinherited

Definition at line 139 of file pcb_tool.h.

139 { return getEditFrame<PCB_EDIT_FRAME>(); }

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL::canvas(), EDIT_TOOL::changeTrackWidthOnClick(), PNS::TOOL_BASE::checkSnap(), PCB_EDITOR_CONTROL::ClearHighlight(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::displayOptions(), EDIT_TOOL::doCopyToClipboard(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), DrawVia(), drawZone(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ROUTER_TOOL::finishInteractive(), PAD_TOOL::Init(), EDIT_TOOL::Init(), SELECTION_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), MODULE_EDITOR_TOOLS::PlacePad(), PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::RouteDiffPair(), ROUTER_TOOL::RouteSingleTrace(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ROUTER_TOOL::SettingsDialog(), ROUTER_TOOL::switchLayerOnViaPlacement(), LENGTH_TUNER_TOOL::TuneDiffPair(), LENGTH_TUNER_TOOL::TuneDiffPairSkew(), LENGTH_TUNER_TOOL::TuneSingleTrace(), POINT_EDITOR::updateItem(), ZONE_FILLER_TOOL::ZoneFill(), and ZONE_FILLER_TOOL::ZoneFillAll().

◆ getDrawingLayer()

PCB_LAYER_ID DRAWING_TOOL::getDrawingLayer ( ) const
private

Selects a non-copper layer for drawing

Definition at line 1809 of file drawing_tool.cpp.

1810 {
1811  PCB_LAYER_ID layer = m_frame->GetActiveLayer();
1812 
1813  if( IsCopperLayer( layer ) )
1814  {
1815  if( layer == F_Cu )
1816  layer = F_SilkS;
1817  else if( layer == B_Cu )
1818  layer = B_SilkS;
1819  else
1820  layer = Dwgs_User;
1821 
1822  m_frame->SetActiveLayer( layer );
1823  }
1824 
1825  return layer;
1826 }
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID
A quick note on layer IDs:
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.

References B_Cu, B_SilkS, Dwgs_User, F_Cu, F_SilkS, PCB_BASE_FRAME::GetActiveLayer(), IsCopperLayer(), m_frame, and PCB_BASE_FRAME::SetActiveLayer().

Referenced by ZONE_CREATE_HELPER::commitZone(), drawArc(), DrawDimension(), drawSegment(), and drawZone().

◆ 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 212 of file drawing_tool.cpp.

213 {
214  return m_mode;
215 }

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

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47

References TOOL_BASE::getEditFrameInt().

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

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

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

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 144 of file tool_base.h.

145  {
146  return m_toolMgr;
147  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL::doInteractiveItemPlacement(), CONTEXT_MENU::getToolManager(), CONTEXT_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 199 of file tool_base.h.

200  {
201  EDA_ITEM* m = getModelInt();
202 
203  return static_cast<T*>( m );
204  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154

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

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

References TOOL_BASE::m_toolName.

Referenced by TOOL_SETTINGS::getKeyName(), 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 1802 of file drawing_tool.cpp.

1803 {
1804  assert( m_board );
1805  return m_board->GetDesignSettings().GetLineThickness( aLayer );
1806 }
BOARD * m_board
Definition: drawing_tool.h:263
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:539
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().

◆ GetSettings()

TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216

References TOOL_BASE::m_toolSettings.

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

◆ getSourceZoneForAction()

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

Function 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 1306 of file drawing_tool.cpp.

1307 {
1308  bool clearSelection = false;
1309  aZone = nullptr;
1310 
1311  // not an action that needs a source zone
1312  if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON )
1313  return true;
1314 
1316  const SELECTION& selection = selTool->GetSelection();
1317 
1318  if( selection.Empty() )
1319  {
1320  clearSelection = true;
1322  }
1323 
1324  // we want a single zone
1325  if( selection.Size() == 1 )
1326  aZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1327 
1328  // expected a zone, but didn't get one
1329  if( !aZone )
1330  {
1331  if( clearSelection )
1333 
1334  return false;
1335  }
1336 
1337  return true;
1338 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
Class SELECTION_TOOL.
const SELECTION & selection() const
Definition: pcb_tool.cpp:251
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
SELECTION & GetSelection()
Function GetSelection()
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:116
int Size() const
Returns the number of selected parts.
Definition: selection.h:122
Add a new zone/keepout with fresh settings.
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:50

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

Referenced by drawZone().

◆ GetToolMenu()

TOOL_MENU& DRAWING_TOOL::GetToolMenu ( )
inline

Get the DRAWING_TOOL top-level context menu

Definition at line 62 of file drawing_tool.h.

63  {
64  return m_menu;
65  }
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148

References PCB_TOOL::m_menu.

Referenced by PCB_EDITOR_CONTROL::Init().

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

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

References TOOL_BASE::m_type.

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

◆ getView()

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

Function getView()

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

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

36 {
37  return m_toolMgr->GetView();
38 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:252
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

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

Referenced by ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), Reset(), GERBVIEW_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), POINT_EDITOR::updateEditedPoint(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_TOOL::view(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), CVPCB_SELECTION_TOOL::~CVPCB_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 41 of file tool_base.cpp.

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257

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

Referenced by POINT_EDITOR::addCorner(), PCB_TOOL::controls(), COMMON_TOOLS::CursorControl(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), POINT_EDITOR::Reset(), Reset(), CVPCB_CONTROL::ResetCoords(), GERBVIEW_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), POINT_EDITOR::setEditedPoint(), 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

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

Definition at line 164 of file drawing_tool.cpp.

165 {
166  auto activeToolFunctor = [ this ] ( const SELECTION& aSel ) {
167  return m_mode != MODE::NONE;
168  };
169 
170  // some interactive drawing tools can undo the last point
171  auto canUndoPoint = [ this ] ( const SELECTION& aSel ) {
172  return m_mode == MODE::ARC || m_mode == MODE::ZONE;
173  };
174 
175  // functor for zone-only actions
176  auto zoneActiveFunctor = [this ] ( const SELECTION& aSel ) {
177  return m_mode == MODE::ZONE;
178  };
179 
180  auto& ctxMenu = m_menu.GetMenu();
181 
182  // cancel current tool goes in main context menu at the top if present
183  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolFunctor, 1 );
184  ctxMenu.AddSeparator( activeToolFunctor, 1 );
185 
186  // tool-specific actions
187  ctxMenu.AddItem( closeZoneOutline, zoneActiveFunctor, 200 );
188  ctxMenu.AddItem( deleteLastPoint, canUndoPoint, 200 );
189 
190  ctxMenu.AddSeparator( canUndoPoint, 500 );
191 
192  // Type-specific sub-menus will be added for us by other tools
193  // For example, zone fill/unfill is provided by the PCB control tool
194 
195  // Finally, add the standard zoom/grid items
196  m_menu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
197 
198  return true;
199 }
static TOOL_ACTION closeZoneOutline("pcbnew.InteractiveDrawing.closeZoneOutline", AS_CONTEXT, 0, _("Close Zone Outline"), _("Close the outline of a zone in progress"), checked_ok_xpm)
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
static TOOL_ACTION deleteLastPoint("pcbnew.InteractiveDrawing.deleteLastPoint", AS_CONTEXT, WXK_BACK, _("Delete Last Point"), _("Delete the last point added to the current item"), undo_xpm)
CONDITIONAL_MENU & GetMenu()
Function GetMenu.
Definition: tool_menu.cpp:49
static TOOL_ACTION cancelInteractive
Definition: actions.h:45
void AddStandardSubMenus(EDA_DRAW_FRAME &aFrame)
Function CreateBasicMenu.
Definition: tool_menu.cpp:95
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Function AddItem()

References CONDITIONAL_MENU::AddItem(), TOOL_MENU::AddStandardSubMenus(), ARC, ACTIONS::cancelInteractive, closeZoneOutline, deleteLastPoint, TOOL_MENU::GetMenu(), PCB_TOOL::m_menu, m_mode, NONE, and ZONE.

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

31 {
32  return m_toolMgr->IsToolActive( m_toolId );
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
bool 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.

◆ 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 744 of file drawing_tool.cpp.

745 {
746  if( !m_frame->GetModel() )
747  return 0;
748 
749  // Note: PlaceImportedGraphics() will convert PCB_LINE_T and PCB_TEXT_T to module graphic items
750  // if needed
752  int dlgResult = dlg.ShowModal();
753 
754  auto& list = dlg.GetImportedItems();
755 
756  if( dlgResult != wxID_OK )
757  return 0;
758 
759  // Ensure the list is not empty:
760  if( list.empty() )
761  {
762  wxMessageBox( _( "No graphic items found in file to import") );
763  return 0;
764  }
765 
766 
768 
769  // Add a VIEW_GROUP that serves as a preview for the new item
770  SELECTION preview;
771  BOARD_COMMIT commit( m_frame );
772 
773  // Build the undo list & add items to the current view
774  for( auto it = list.begin(), itEnd = list.end(); it != itEnd; ++it )
775  {
776  EDA_ITEM* item = it->get();
777 
778  if( m_editModules )
779  {
780  wxASSERT( item->Type() == PCB_MODULE_EDGE_T || item->Type() == PCB_MODULE_TEXT_T );
781  }
782  else
783  {
784  wxASSERT( item->Type() == PCB_LINE_T || item->Type() == PCB_TEXT_T );
785  }
786 
787  if( dlg.IsPlacementInteractive() )
788  preview.Add( item );
789  else
790  commit.Add( item );
791 
792  it->release();
793  }
794 
795  if( !dlg.IsPlacementInteractive() )
796  {
797  commit.Push( _( "Place a DXF_SVG drawing" ) );
798  return 0;
799  }
800 
801  BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( preview.Front() );
802  m_view->Add( &preview );
803 
805  m_controls->ShowCursor( true );
806  m_controls->SetSnapping( true );
808 
809  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
810 
811  // Now move the new items to the current cursor position:
812  VECTOR2I cursorPos = m_controls->GetCursorPosition();
813  VECTOR2I delta = cursorPos - firstItem->GetPosition();
814 
815  for( auto item : preview )
816  static_cast<BOARD_ITEM*>( item )->Move( wxPoint( delta.x, delta.y ) );
817 
818  m_view->Update( &preview );
819 
820  Activate();
821 
822  // Main loop: keep receiving events
823  while( OPT_TOOL_EVENT evt = Wait() )
824  {
825  cursorPos = m_controls->GetCursorPosition();
826 
827  if( evt->IsMotion() )
828  {
829  delta = cursorPos - firstItem->GetPosition();
830 
831  for( auto item : preview )
832  static_cast<BOARD_ITEM*>( item )->Move( wxPoint( delta.x, delta.y ) );
833 
834  m_view->Update( &preview );
835  }
836  else if( evt->Category() == TC_COMMAND )
837  {
838  // TODO it should be handled by EDIT_TOOL, so add items and select?
839  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
840  {
841  const auto rotationPoint = wxPoint( cursorPos.x, cursorPos.y );
842  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
843  *m_frame, *evt );
844 
845  for( auto item : preview )
846  {
847  static_cast<BOARD_ITEM*>( item )->Rotate( rotationPoint, rotationAngle );
848  }
849 
850  m_view->Update( &preview );
851  }
852  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
853  {
854  for( auto item : preview )
855  static_cast<BOARD_ITEM*>( item )->Flip( wxPoint( cursorPos.x, cursorPos.y ) );
856 
857  m_view->Update( &preview );
858  }
859  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
860  {
861  preview.FreeItems();
862  break;
863  }
864  }
865  else if( evt->IsClick( BUT_RIGHT ) )
866  {
868  }
869  else if( evt->IsClick( BUT_LEFT ) )
870  {
871  // Place the imported drawings
872  for( auto item : preview )
873  commit.Add( item );
874 
875  commit.Push( _( "Place a DXF_SVG drawing" ) );
876  break;
877  }
878  }
879 
880  preview.Clear();
881  m_view->Remove( &preview );
882 
883  return 0;
884 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
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:125
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
static const int delta[8][2]
Definition: solve.cpp:112
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
KIGFX::VIEW * m_view
Definition: drawing_tool.h:261
RAII class that sets an value at construction and resets it to the original value at destruction.
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:262
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
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:1539
virtual const wxPoint GetPosition() const =0
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
bool m_editModules
Definition: pcb_tool.h:150
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
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:62
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:152
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), BUT_LEFT, BUT_RIGHT, delta, DXF, PCB_ACTIONS::flip, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), SELECTION::Front(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), DIALOG_IMPORT_GFX::GetImportedItems(), PCB_BASE_EDIT_FRAME::GetModel(), BOARD_ITEM::GetPosition(), TOOL_EVT_UTILS::IsCancelInteractive(), DIALOG_IMPORT_GFX::IsPlacementInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), m_controls, PCB_TOOL::m_editModules, m_frame, PCB_TOOL::m_menu, m_mode, TOOL_BASE::m_toolMgr, m_view, PCB_LINE_T, PCB_MODULE_EDGE_T, PCB_MODULE_TEXT_T, PCB_TEXT_T, BOARD_COMMIT::Push(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, EDA_DRAW_FRAME::SetNoToolSelected(), KIGFX::VIEW_CONTROLS::SetSnapping(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, EDA_ITEM::Type(), KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

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 327 of file drawing_tool.cpp.

328 {
329  if( m_editModules && !m_frame->GetModel() )
330  return 0;
331 
332  BOARD_ITEM* text = NULL;
333  const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
335  SELECTION& selection = selTool->GetSelection();
336  BOARD_COMMIT commit( m_frame );
337 
339  m_controls->ShowCursor( true );
340  m_controls->SetSnapping( true );
341  // do not capture or auto-pan until we start placing some text
342 
343  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
344 
345  Activate();
347  wxCURSOR_PENCIL, _( "Add text" ) );
348 
349  bool reselect = false;
350 
351  // Main loop: keep receiving events
352  while( OPT_TOOL_EVENT evt = Wait() )
353  {
354  VECTOR2I cursorPos = m_controls->GetCursorPosition();
355 
356  if( reselect && text )
358 
360  {
361  if( text )
362  {
364 
365  // Delete the old text and have another try
366  delete text;
367  text = NULL;
368 
369  m_controls->SetAutoPan( false );
370  m_controls->CaptureCursor( false );
371  m_controls->ShowCursor( true );
372  }
373  else
374  break;
375 
376  if( evt->IsActivate() ) // now finish unconditionally
377  break;
378  }
379  else if( evt->IsClick( BUT_RIGHT ) )
380  {
382  }
383  else if( evt->IsClick( BUT_LEFT ) )
384  {
385  if( !text )
386  {
389 
390  // Init the new item attributes
391  if( m_editModules )
392  {
393  TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) m_frame->GetModel() );
394 
395  textMod->SetLayer( layer );
396  textMod->SetTextSize( dsnSettings.GetTextSize( layer ) );
397  textMod->SetThickness( dsnSettings.GetTextThickness( layer ) );
398  textMod->SetItalic( dsnSettings.GetTextItalic( layer ) );
399  textMod->SetKeepUpright( dsnSettings.GetTextUpright( layer ) );
400  textMod->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
401 
402  DIALOG_TEXT_PROPERTIES textDialog( m_frame, textMod, NULL );
403  bool placing;
404 
405  RunMainStack([&]() {
406  placing = textDialog.ShowModal() && ( textMod->GetText().Length() > 0 );
407  } );
408 
409  if( placing )
410  text = textMod;
411  else
412  delete textMod;
413  }
414  else
415  {
416  TEXTE_PCB* textPcb = new TEXTE_PCB( m_frame->GetModel() );
417  // TODO we have to set IS_NEW, otherwise InstallTextPCB.. creates an undo entry :| LEGACY_CLEANUP
418  textPcb->SetFlags( IS_NEW );
419 
420  textPcb->SetLayer( layer );
421 
422  // Set the mirrored option for layers on the BACK side of the board
423  if( IsBackLayer( layer ) )
424  textPcb->SetMirrored( true );
425 
426  textPcb->SetTextSize( dsnSettings.GetTextSize( layer ) );
427  textPcb->SetThickness( dsnSettings.GetTextThickness( layer ) );
428  textPcb->SetItalic( dsnSettings.GetTextItalic( layer ) );
429  textPcb->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
430 
431  RunMainStack([&]() {
432  m_frame->InstallTextOptionsFrame( textPcb, NULL );
433  } );
434 
435  if( textPcb->GetText().IsEmpty() )
436  delete textPcb;
437  else
438  text = textPcb;
439  }
440 
441  if( text == NULL )
442  continue;
443 
444  m_controls->WarpCursor( text->GetPosition(), true );
446  m_controls->CaptureCursor( true );
447  m_controls->SetAutoPan( true );
448 
450  }
451  else
452  {
453  text->ClearFlags();
455 
456  commit.Add( text );
457  commit.Push( _( "Place a text" ) );
458 
459  m_controls->CaptureCursor( false );
460  m_controls->SetAutoPan( false );
461  m_controls->ShowCursor( true );
462 
463  text = NULL;
464  }
465  }
466  else if( text && evt->IsMotion() )
467  {
468  text->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
469  selection.SetReferencePoint( cursorPos );
470  m_view->Update( &selection );
471  frame()->SetMsgPanel( text );
472  }
473 
474  else if( text && evt->IsAction( &PCB_ACTIONS::properties ) )
475  {
476  // Calling 'Properties' action clears the selection, so we need to restore it
477  reselect = true;
478  }
479  }
480 
481  frame()->SetMsgPanel( board() );
483 
484  return 0;
485 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:191
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void SetKeepUpright(bool aKeepUpright)
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
virtual void SetPosition(const wxPoint &aPos)=0
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void RunMainStack(std::function< void()> aFunc)
Function RunMainStack()
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Class SELECTION_TOOL.
const SELECTION & selection() const
Definition: pcb_tool.cpp:251
void SetItalic(bool isItalic)
Definition: eda_text.h:182
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:236
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:111
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
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, wxDC *aDC)
Routine for main window class to launch text properties dialog.
KIGFX::VIEW * m_view
Definition: drawing_tool.h:261
bool GetTextUpright(PCB_LAYER_ID aLayer) const
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
bool GetTextItalic(PCB_LAYER_ID aLayer) const
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
void SetReferencePoint(const VECTOR2I &aP)
Definition: selection.h:205
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.
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
BOARD * board() const
Definition: pcb_tool.h:140
SELECTION & GetSelection()
Function GetSelection()
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:262
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
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:1539
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
virtual const wxPoint GetPosition() const =0
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
bool m_editModules
Definition: pcb_tool.h:150
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
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.
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:161
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References TOOL_INTERACTIVE::Activate(), COMMIT::Add(), PCB_TOOL::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), EDA_ITEM::ClearFlags(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL::frame(), PCB_BASE_FRAME::GetActiveLayer(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetDesignSettings(), PCB_BASE_EDIT_FRAME::GetModel(), BOARD_ITEM::GetPosition(), SELECTION_TOOL::GetSelection(), EDA_TEXT::GetText(), BOARD_DESIGN_SETTINGS::GetTextItalic(), BOARD_DESIGN_SETTINGS::GetTextSize(), BOARD_DESIGN_SETTINGS::GetTextThickness(), BOARD_DESIGN_SETTINGS::GetTextUpright(), TOOL_MANAGER::GetTool(), ID_MODEDIT_TEXT_TOOL, ID_PCB_ADD_TEXT_BUTT, PCB_BASE_EDIT_FRAME::InstallTextOptionsFrame(), IS_NEW, IsBackLayer(), TOOL_EVT_UTILS::IsCancelInteractive(), m_controls, PCB_TOOL::m_editModules, m_frame, PCB_TOOL::m_menu, m_mode, TOOL_BASE::m_toolMgr, m_view, PCB_ACTIONS::properties, BOARD_COMMIT::Push(), TOOL_MANAGER::RunAction(), TOOL_INTERACTIVE::RunMainStack(), PCB_TOOL::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_ITEM::SetFlags(), EDA_TEXT::SetItalic(), TEXTE_MODULE::SetKeepUpright(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), EDA_DRAW_FRAME::SetMsgPanel(), EDA_DRAW_FRAME::SetNoToolSelected(), BOARD_ITEM::SetPosition(), SELECTION::SetReferencePoint(), KIGFX::VIEW_CONTROLS::SetSnapping(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), PCB_BASE_FRAME::SetToolID(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TEXT, KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), KIGFX::VIEW_CONTROLS::WarpCursor(), VECTOR2< T >::x, and VECTOR2< T >::y.

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.

Definition at line 202 of file drawing_tool.cpp.

203 {
204  // Init variables used by every drawing tool
205  m_view = getView();
207  m_board = getModel<BOARD>();
208  m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
209 }
BOARD * m_board
Definition: drawing_tool.h:263
KIGFX::VIEW * m_view
Definition: drawing_tool.h:261
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:262
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:264
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41

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 85 of file tool_interactive.cpp.

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)

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

Referenced by PlaceText().

◆ runPolygonEventLoop()

void DRAWING_TOOL::runPolygonEventLoop ( POLYGON_GEOM_MANAGER aPolyGeomMgr)
private

Run the event loop for polygon creation, sending user input on to the given POLYGON_GEOM_MANAGER for processing into a complete polygon.

◆ selection() [1/2]

const SELECTION & PCB_TOOL::selection ( ) const
protectedinherited

Definition at line 251 of file pcb_tool.cpp.

252 {
253  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
254  const auto& selection = selTool->GetSelection();
255  return selection;
256 }
Class SELECTION_TOOL.
const SELECTION & selection() const
Definition: pcb_tool.cpp:251
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

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

Referenced by AUTOPLACE_TOOL::autoplaceSelected(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::changeTrackWidthOnClick(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::CreateArray(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), EDIT_TOOL::doCopyToClipboard(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), EDIT_TOOL::Flip(), getSourceZoneForAction(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Rotate(), ZONE_FILLER_TOOL::SegzoneDeleteFill(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), SELECTION_TOOL::selectNet(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ZoneDuplicate(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfill().

◆ selection() [2/2]

SELECTION & PCB_TOOL::selection ( )
protectedinherited

Definition at line 258 of file pcb_tool.cpp.

259 {
260  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
261  auto& selection = selTool->GetSelection();
262  return selection;
263 }
Class SELECTION_TOOL.
const SELECTION & selection() const
Definition: pcb_tool.cpp:251
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215

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

◆ SetAnchor()

int DRAWING_TOOL::SetAnchor ( const TOOL_EVENT aEvent)

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

Definition at line 887 of file drawing_tool.cpp.

888 {
889  assert( m_editModules );
890 
891  if( !m_frame->GetModel() )
892  return 0;
893 
894  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR );
895 
896  Activate();
897  m_frame->SetToolID( ID_MODEDIT_ANCHOR_TOOL, wxCURSOR_PENCIL,
898  _( "Place the footprint anchor" ) );
899 
900  m_controls->ShowCursor( true );
901  m_controls->SetSnapping( true );
902  m_controls->SetAutoPan( true );
903  m_controls->CaptureCursor( false );
904 
905  while( OPT_TOOL_EVENT evt = Wait() )
906  {
907  if( evt->IsClick( BUT_LEFT ) )
908  {
910  BOARD_COMMIT commit( m_frame );
911  commit.Modify( module );
912 
913  // set the new relative internal local coordinates of footprint items
914  VECTOR2I cursorPos = m_controls->GetCursorPosition();
915  wxPoint moveVector = module->GetPosition() - wxPoint( cursorPos.x, cursorPos.y );
916  module->MoveAnchorPosition( moveVector );
917 
918  commit.Push( _( "Move the footprint reference anchor" ) );
919 
920  // Usually, we do not need to change twice the anchor position,
921  // so deselect the active tool
922  break;
923  }
924  else if( evt->IsClick( BUT_RIGHT ) )
925  {
927  }
928  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
929  break;
930  }
931 
933 
934  return 0;
935 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
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.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:262
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
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:264
bool m_editModules
Definition: pcb_tool.h:150
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
MODULE * module() const
Definition: pcb_tool.h:141
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
const wxPoint GetPosition() const override
Definition: class_module.h:183
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495

References TOOL_INTERACTIVE::Activate(), ANCHOR, BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_EDIT_FRAME::GetModel(), MODULE::GetPosition(), ID_MODEDIT_ANCHOR_TOOL, TOOL_EVT_UTILS::IsCancelInteractive(), m_controls, PCB_TOOL::m_editModules, m_frame, PCB_TOOL::m_menu, m_mode, COMMIT::Modify(), PCB_TOOL::module(), MODULE::MoveAnchorPosition(), BOARD_COMMIT::Push(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_FRAME::SetNoToolSelected(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::SetToolID(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ SetContextMenu()

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

Function SetContextMenu()

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

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

Definition at line 74 of file tool_interactive.cpp.

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

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

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

◆ SetEditModules()

void PCB_TOOL::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 97 of file pcb_tool.h.

98  {
99  m_editModules = aEnabled;
100  }
bool m_editModules
Definition: pcb_tool.h:150

References PCB_TOOL::m_editModules.

◆ setTransitions()

void DRAWING_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL.

Definition at line 1784 of file drawing_tool.cpp.

1785 {
1799 }
static TOOL_ACTION drawLine
Activation of the drawing tool (line)
Definition: pcb_actions.h:147
int DrawCircle(const TOOL_EVENT &aEvent)
Function DrawCircle() Starts interactively drawing a circle.
static TOOL_ACTION placeImportedGraphics
Activation of the drawing tool (placing a drawing imported from DXF or SVG file)
Definition: pcb_actions.h:186
int DrawVia(const TOOL_EVENT &aEvent)
int DrawZone(const TOOL_EVENT &aEvent)
Function DrawZone() Starts interactively drawing a zone.
static TOOL_ACTION drawSimilarZone
Activation of the drawing tool (drawing a similar ZONE to another one)
Definition: pcb_actions.h:177
static TOOL_ACTION drawArc
Activation of the drawing tool (arc)
Definition: pcb_actions.h:156
int DrawLine(const TOOL_EVENT &aEvent)
Function DrawLine() Starts interactively drawing a line.
static TOOL_ACTION drawZoneKeepout
Activation of the drawing tool (drawing a keepout area)
Definition: pcb_actions.h:171
static TOOL_ACTION setAnchor
Activation of the drawing tool (placing the footprint anchor)
Definition: pcb_actions.h:189
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
Activation of the drawing tool (text)
Definition: pcb_actions.h:159
static TOOL_ACTION drawGraphicPolygon
Definition: pcb_actions.h:150
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
Activation of the drawing tool (dimension)
Definition: pcb_actions.h:162
int DrawZoneKeepout(const TOOL_EVENT &aEvent)
Function DrawZoneKeepout() Starts interactively drawing a keepout area.
static TOOL_ACTION drawVia
Activation of the drawing tool (drawing a VIA)
Definition: pcb_actions.h:168
static TOOL_ACTION drawZoneCutout
Activation of the drawing tool (drawing a ZONE cutout)
Definition: pcb_actions.h:174
int DrawZoneCutout(const TOOL_EVENT &aEvent)
Function DrawZoneCutout() Starts interactively drawing a zone cutout area of an existing zone.
static TOOL_ACTION drawCircle
Activation of the drawing tool (circle)
Definition: pcb_actions.h:153
int SetAnchor(const TOOL_EVENT &aEvent)
Function SetAnchor() Places the footprint anchor (only in module editor).
int DrawGraphicPolygon(const TOOL_EVENT &aEvent)
int DrawSimilarZone(const TOOL_EVENT &aEvent)
Function DrawSimilarZone() Starts interactively drawing a zone with same settings as an existing zone...
int DrawArc(const TOOL_EVENT &aEvent)
Function DrawArc() Starts interactively drawing an arc.
static TOOL_ACTION drawZone
Activation of the drawing tool (drawing a ZONE)
Definition: pcb_actions.h:165
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, DrawGraphicPolygon(), PCB_ACTIONS::drawGraphicPolygon, DrawLine(), PCB_ACTIONS::drawLine, DrawSimilarZone(), PCB_ACTIONS::drawSimilarZone, DrawVia(), PCB_ACTIONS::drawVia, DrawZone(), PCB_ACTIONS::drawZone, DrawZoneCutout(), PCB_ACTIONS::drawZoneCutout, DrawZoneKeepout(), PCB_ACTIONS::drawZoneKeepout, TOOL_INTERACTIVE::Go(), PlaceImportedGraphics(), PCB_ACTIONS::placeImportedGraphics, PlaceText(), PCB_ACTIONS::placeText, SetAnchor(), and PCB_ACTIONS::setAnchor.

◆ view()

◆ Wait()

OPT_TOOL_EVENT TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

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

Definition at line 55 of file tool_interactive.cpp.

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
OPT< 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 PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), SELECTION_TOOL::doSelectionMenu(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Remove(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

Friends And Related Function Documentation

◆ ZONE_CREATE_HELPER

friend class ZONE_CREATE_HELPER
friend

Definition at line 275 of file drawing_tool.h.

Member Data Documentation

◆ m_board

BOARD* DRAWING_TOOL::m_board
private

Definition at line 263 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

Stores the current line width for multisegment drawing.

Definition at line 268 of file drawing_tool.h.

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

◆ m_menu

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

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), PCB_EDITOR_CONTROL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), drawArc(), DrawDimension(), drawSegment(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), SELECTION_TOOL::RequestSelection(), CVPCB_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), TOOL_INTERACTIVE::resetTransitions(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), ZONE_FILLER_TOOL::SegzoneDeleteFill(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), GERBVIEW_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), PCB_EDITOR_CONTROL::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 214 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

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

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

◆ m_view

KIGFX::VIEW* DRAWING_TOOL::m_view
private

◆ WIDTH_STEP

const unsigned int DRAWING_TOOL::WIDTH_STEP = Millimeter2iu( 0.1 )
staticprivate

Definition at line 271 of file drawing_tool.h.

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


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