KiCad PCB EDA Suite
DRAWING_TOOL Class Reference

Class DRAWING_TOOL. More...

#include <drawing_tool.h>

Inheritance diagram for DRAWING_TOOL:
PCB_TOOL_BASE TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  MODE {
  MODE::NONE, MODE::LINE, MODE::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 (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
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

Enumerator
IPO_ROTATE 
IPO_FLIP 
IPO_PROPERTIES 
IPO_SINGLE_CLICK 
IPO_REPEAT 

Definition at line 109 of file pcb_tool_base.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_BASE( "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
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
PCB_TOOL_BASE(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool_base.h:71

◆ ~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:216
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:211
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(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), EDIT_TOOL::doCopyToClipboard(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), 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(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SetAnchor(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartWire(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

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

Definition at line 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:216
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:217
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_BASE::board ( ) const
inlineprotectedinherited

Definition at line 140 of file pcb_tool_base.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_BASE::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_BASE::module(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), ROUTER_TOOL::prepareInteractive(), SELECTION_TOOL::RebuildSelection(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), 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 491 of file drawing_tool.cpp.

492 {
493  const VECTOR2I lineVector{ dimension->GetEnd() - dimension->GetOrigin() };
494 
495  dimension->SetEnd( wxPoint(
496  VECTOR2I( dimension->GetOrigin() ) + GetVectorSnapped45( lineVector ) ) );
497 }
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()

◆ doInteractiveItemPlacement()

void PCB_TOOL_BASE::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_base.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.
TOOL_MENU m_menu
Menu model displayed by the tool.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:93
void RunOnChildren(const std::function< void(BOARD_ITEM *)> &aFunction)
Function RunOnChildren.
virtual bool PlaceItem(BOARD_ITEM *aItem, BOARD_COMMIT &aCommit)
BOARD * board() const
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags) override
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: pcb_view.cpp:91
virtual std::unique_ptr< BOARD_ITEM > CreateItem()=0
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_base.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)
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.
KIGFX::PCB_VIEW * view() const
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()
Definition: tool_event.cpp:177
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
PCB_EDIT_FRAME * frame() const
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:99
KIGFX::VIEW_CONTROLS * controls() const
MODULE * module() const
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
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:85

References TOOL_INTERACTIVE::Activate(), KIGFX::PCB_VIEW::Add(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL_BASE::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), PCB_ACTIONS::flip, PCB_TOOL_BASE::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_PROPERTIES, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL_BASE::m_menu, INTERACTIVE_PLACER_BASE::m_modifiers, PCB_TOOL_BASE::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_BASE::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
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_BASE::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 1164 of file drawing_tool.cpp.

1165 {
1167 
1169 
1170  // Arc geometric construction manager
1172 
1173  // Arc drawing assistant overlay
1174  KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() );
1175 
1176  // Add a VIEW_GROUP that serves as a preview for the new item
1177  SELECTION preview;
1178  m_view->Add( &preview );
1179  m_view->Add( &arcAsst );
1180  GRID_HELPER grid( m_frame );
1181 
1182  m_controls->ShowCursor( true );
1183  m_controls->SetSnapping( true );
1184 
1185  Activate();
1186 
1187  bool firstPoint = false;
1188 
1189  // Main loop: keep receiving events
1190  while( OPT_TOOL_EVENT evt = Wait() )
1191  {
1192  PCB_LAYER_ID layer = getDrawingLayer();
1193  aGraphic->SetLayer( layer );
1194 
1195  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1196  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1197  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1198  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), aGraphic );
1199  m_controls->ForceCursorPosition( true, cursorPos );
1200 
1201  if( evt->IsClick( BUT_LEFT ) )
1202  {
1203  if( !firstPoint )
1204  {
1205  m_controls->SetAutoPan( true );
1206  m_controls->CaptureCursor( true );
1207 
1209 
1210  // Init the new item attributes
1211  // (non-geometric, those are handled by the manager)
1212  aGraphic->SetShape( S_ARC );
1213  aGraphic->SetWidth( m_lineWidth );
1214 
1215  preview.Add( aGraphic );
1216  firstPoint = true;
1217  }
1218 
1219  arcManager.AddPoint( cursorPos, true );
1220  }
1221  else if( evt->IsAction( &deleteLastPoint ) )
1222  {
1223  arcManager.RemoveLastPoint();
1224  }
1225  else if( evt->IsMotion() )
1226  {
1227  // set angle snap
1228  arcManager.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1229 
1230  // update, but don't step the manager state
1231  arcManager.AddPoint( cursorPos, false );
1232  }
1233  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
1234  {
1235  preview.Clear();
1236  delete aGraphic;
1237  aGraphic = nullptr;
1238  break;
1239  }
1240  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1241  {
1243  aGraphic->SetLayer( getDrawingLayer() );
1244  aGraphic->SetWidth( m_lineWidth );
1245  m_view->Update( &preview );
1246  frame()->SetMsgPanel( aGraphic );
1247  }
1248  else if( evt->IsClick( BUT_RIGHT ) )
1249  {
1251  }
1252  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1253  {
1255  aGraphic->SetWidth( m_lineWidth );
1256  m_view->Update( &preview );
1257  frame()->SetMsgPanel( aGraphic );
1258  }
1259  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && m_lineWidth > WIDTH_STEP )
1260  {
1262  aGraphic->SetWidth( m_lineWidth );
1263  m_view->Update( &preview );
1264  frame()->SetMsgPanel( aGraphic );
1265  }
1266  else if( evt->IsAction( &PCB_ACTIONS::arcPosture ) )
1267  {
1268  arcManager.ToggleClockwise();
1269  }
1270 
1271  if( arcManager.IsComplete() )
1272  {
1273  break;
1274  }
1275  else if( arcManager.HasGeometryChanged() )
1276  {
1277  updateArcFromConstructionMgr( arcManager, *aGraphic );
1278  m_view->Update( &preview );
1279  m_view->Update( &arcAsst );
1280 
1281  if(firstPoint)
1282  frame()->SetMsgPanel( aGraphic );
1283  else
1284  frame()->SetMsgPanel( board() );
1285  }
1286  }
1287 
1288  preview.Remove( aGraphic );
1289  m_view->Remove( &arcAsst );
1290  m_view->Remove( &preview );
1291  frame()->SetMsgPanel( board() );
1292  m_controls->SetAutoPan( false );
1293  m_controls->CaptureCursor( false );
1294  m_controls->ForceCursorPosition( false );
1295 
1296  return !arcManager.IsReset();
1297 }
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.
void SetShape(STROKE_T aShape)
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
BOARD * board() const
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:154
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:216
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:157
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.
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
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()
Definition: tool_event.cpp:177
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.
PCB_EDIT_FRAME * frame() const
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:160
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:239
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
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:59
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
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_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), PCB_ACTIONS::decWidth, deleteLastPoint, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::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_BASE::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
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_BASE::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 500 of file drawing_tool.cpp.

501 {
502  if( m_editModules && !m_frame->GetModel() )
503  return 0;
504 
505  DIMENSION* dimension = NULL;
506  BOARD_COMMIT commit( m_frame );
507  GRID_HELPER grid( m_frame );
508 
509  // Add a VIEW_GROUP that serves as a preview for the new item
510  SELECTION preview;
511 
512  m_view->Add( &preview );
513 
515  m_controls->ShowCursor( true );
516  m_controls->SetSnapping( true );
517 
518  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
519 
520  Activate();
521  m_frame->SetToolID( ID_PCB_DIMENSION_BUTT, wxCURSOR_PENCIL, _( "Add dimension" ) );
522 
523  enum DIMENSION_STEPS
524  {
525  SET_ORIGIN = 0,
526  SET_END,
527  SET_HEIGHT,
528  FINISHED
529  };
530  int step = SET_ORIGIN;
531 
532  // Main loop: keep receiving events
533  while( OPT_TOOL_EVENT evt = Wait() )
534  {
535  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
536  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
537  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
538  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), nullptr );
539  m_controls->ForceCursorPosition( true, cursorPos );
540 
542  {
543  m_controls->SetAutoPan( false );
544 
545  if( step != SET_ORIGIN ) // start from the beginning
546  {
547  preview.Clear();
548 
549  delete dimension;
550  step = SET_ORIGIN;
551  }
552  else
553  break;
554 
555  if( evt->IsActivate() ) // now finish unconditionally
556  break;
557  }
558  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) && step != SET_ORIGIN )
559  {
561  dimension->SetWidth( m_lineWidth );
562  m_view->Update( &preview );
563  frame()->SetMsgPanel( dimension );
564  }
565  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && step != SET_ORIGIN )
566  {
567  if( m_lineWidth > WIDTH_STEP )
568  {
570  dimension->SetWidth( m_lineWidth );
571  m_view->Update( &preview );
572  frame()->SetMsgPanel( dimension );
573  }
574  }
575  else if( evt->IsClick( BUT_RIGHT ) )
576  {
578  }
579  else if( evt->IsClick( BUT_LEFT ) )
580  {
581  switch( step )
582  {
583  case SET_ORIGIN:
584  {
585  PCB_LAYER_ID layer = getDrawingLayer();
586  const BOARD_DESIGN_SETTINGS& boardSettings = m_board->GetDesignSettings();
587 
588  if( layer == Edge_Cuts ) // dimensions are not allowed on EdgeCuts
589  layer = Dwgs_User;
590 
591  // Init the new item attributes
592  dimension = new DIMENSION( m_board );
593  dimension->SetLayer( layer );
594  dimension->SetOrigin( (wxPoint) cursorPos );
595  dimension->SetEnd( (wxPoint) cursorPos );
596  dimension->Text().SetTextSize( boardSettings.GetTextSize( layer ) );
597  dimension->Text().SetThickness( boardSettings.GetTextThickness( layer ) );
598  dimension->Text().SetItalic( boardSettings.GetTextItalic( layer ) );
599  dimension->SetWidth( boardSettings.GetLineThickness( layer ) );
600  dimension->SetUnits( m_frame->GetUserUnits(), false );
601  dimension->AdjustDimensionDetails();
602 
603  preview.Add( dimension );
604  frame()->SetMsgPanel( dimension );
605 
606  m_controls->SetAutoPan( true );
607  m_controls->CaptureCursor( true );
608  }
609  break;
610 
611  case SET_END:
612  dimension->SetEnd( (wxPoint) cursorPos );
613 
614  if( !!evt->Modifier( MD_CTRL ) )
615  constrainDimension( dimension );
616 
617  // Dimensions that have origin and end in the same spot are not valid
618  if( dimension->GetOrigin() == dimension->GetEnd() )
619  --step;
620 
621  break;
622 
623  case SET_HEIGHT:
624  {
625  if( (wxPoint) cursorPos != dimension->GetPosition() )
626  {
627  assert( dimension->GetOrigin() != dimension->GetEnd() );
628  assert( dimension->GetWidth() > 0 );
629 
630  preview.Remove( dimension );
631 
632  commit.Add( dimension );
633  commit.Push( _( "Draw a dimension" ) );
634  }
635  }
636  break;
637  }
638 
639  if( ++step == FINISHED )
640  {
641  step = SET_ORIGIN;
642  m_controls->SetAutoPan( false );
643  m_controls->CaptureCursor( false );
644  }
645  }
646  else if( evt->IsMotion() )
647  {
648  switch( step )
649  {
650  case SET_END:
651  dimension->SetEnd( (wxPoint) cursorPos );
652 
653  if( !!evt->Modifier( MD_CTRL ) )
654  constrainDimension( dimension );
655 
656  break;
657 
658  case SET_HEIGHT:
659  {
660  // Calculating the direction of travel perpendicular to the selected axis
661  double angle = dimension->GetAngle() + ( M_PI / 2 );
662 
663  wxPoint delta( (wxPoint) cursorPos - dimension->m_featureLineDO );
664  double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
665  dimension->SetHeight( height );
666  }
667  break;
668  }
669 
670  // Show a preview of the item
671  m_view->Update( &preview );
672  if( step )
673  frame()->SetMsgPanel( dimension );
674  else
675  frame()->SetMsgPanel( board() );
676  }
677  }
678 
679  if( step != SET_ORIGIN )
680  delete dimension;
681 
682  m_controls->SetAutoPan( false );
684 
685  m_view->Remove( &preview );
686  frame()->SetMsgPanel( board() );
688 
689  return 0;
690 }
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.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:93
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 * board() const
BOARD * m_board
Definition: drawing_tool.h:263
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:154
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:271
void SetItalic(bool isItalic)
Definition: eda_text.h:186
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
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:534
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:231
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:157
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.
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:289
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()
Definition: tool_event.cpp:177
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
PCB_EDIT_FRAME * frame() const
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
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()
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:59
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:165
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:85

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), DIMENSION::AdjustDimensionDetails(), PNS::angle(), GRID_HELPER::BestSnapAnchor(), PCB_TOOL_BASE::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_BASE::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_BASE::m_editModules, DIMENSION::m_featureLineDO, m_frame, m_lineWidth, PCB_TOOL_BASE::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(), and WIDTH_STEP.

Referenced by setTransitions().

◆ DrawGraphicPolygon()

int DRAWING_TOOL::DrawGraphicPolygon ( const TOOL_EVENT aEvent)

Definition at line 723 of file drawing_tool.cpp.

724 {
725  if( m_editModules && !m_frame->GetModel() )
726  return 0;
727 
728  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::GRAPHIC_POLYGON );
729 
731  wxCURSOR_PENCIL, _( "Add graphic polygon" ) );
732 
733  return drawZone( false, ZONE_MODE::GRAPHIC_POLYGON );
734 }
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
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_BASE::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
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_BASE::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 933 of file drawing_tool.cpp.

934 {
935  // Only two shapes are currently supported
936  assert( aShape == S_SEGMENT || aShape == S_CIRCLE );
937  GRID_HELPER grid( m_frame );
938 
941 
942  // Add a VIEW_GROUP that serves as a preview for the new item
943  SELECTION preview;
944  m_view->Add( &preview );
945 
947  m_controls->ShowCursor( true );
948 
949  Activate();
950 
951  bool direction45 = false; // 45 degrees only mode
952  bool started = false;
953  bool IsOCurseurSet = ( m_frame->GetScreen()->m_O_Curseur != wxPoint( 0, 0 ) );
954  VECTOR2I cursorPos = m_controls->GetMousePosition();
955 
956  if( aStartingPoint )
957  {
958  // Init the new item attributes
959  aGraphic->SetShape( (STROKE_T) aShape );
960  aGraphic->SetWidth( m_lineWidth );
961  aGraphic->SetLayer( getDrawingLayer() );
962  aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) );
963 
964  cursorPos = grid.BestSnapAnchor( cursorPos, aGraphic );
965  m_controls->ForceCursorPosition( true, cursorPos );
966  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
967 
968  preview.Add( aGraphic );
969  m_controls->SetAutoPan( true );
970  m_controls->CaptureCursor( true );
971 
972  if( !IsOCurseurSet )
973  m_frame->GetScreen()->m_O_Curseur = wxPoint( aStartingPoint->x, aStartingPoint->y );
974 
975  started = true;
976  }
977 
978  // Main loop: keep receiving events
979  while( OPT_TOOL_EVENT evt = Wait() )
980  {
981  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
982  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
983  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
984  cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), getDrawingLayer() );
985  m_controls->ForceCursorPosition( true, cursorPos );
986 
987  // 45 degree angle constraint enabled with an option and toggled with Ctrl
988  const bool limit45 = ( frame()->Settings().m_use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) );
989 
990  if( direction45 != limit45 && started && aShape == S_SEGMENT )
991  {
992  direction45 = limit45;
993 
994  if( direction45 )
995  {
996  const VECTOR2I lineVector( cursorPos - VECTOR2I( aGraphic->GetStart() ) );
997 
998  // get a restricted 45/H/V line from the last fixed point to the cursor
999  auto newEnd = GetVectorSnapped45( lineVector );
1000  aGraphic->SetEnd( aGraphic->GetStart() + (wxPoint) newEnd );
1001  m_controls->ForceCursorPosition( true, VECTOR2I( aGraphic->GetEnd() ) );
1002  }
1003  else
1004  {
1005  aGraphic->SetEnd( (wxPoint) cursorPos );
1006  }
1007 
1008  m_view->Update( &preview );
1009  frame()->SetMsgPanel( aGraphic );
1010  }
1011 
1013  {
1014  preview.Clear();
1015  m_view->Update( &preview );
1016  delete aGraphic;
1017  aGraphic = NULL;
1018  if( !IsOCurseurSet )
1019  m_frame->GetScreen()->m_O_Curseur = wxPoint( 0, 0 );
1020  break;
1021  }
1022  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1023  {
1025  aGraphic->SetLayer( getDrawingLayer() );
1026  aGraphic->SetWidth( m_lineWidth );
1027  m_view->Update( &preview );
1028  frame()->SetMsgPanel( aGraphic );
1029  }
1030  else if( evt->IsClick( BUT_RIGHT ) )
1031  {
1033  }
1034  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
1035  {
1036  if( !started )
1037  {
1039 
1040  // Init the new item attributes
1041  aGraphic->SetShape( (STROKE_T) aShape );
1042  aGraphic->SetWidth( m_lineWidth );
1043  aGraphic->SetStart( (wxPoint) cursorPos );
1044  aGraphic->SetEnd( (wxPoint) cursorPos );
1045  aGraphic->SetLayer( getDrawingLayer() );
1046 
1047  if( !IsOCurseurSet )
1048  m_frame->GetScreen()->m_O_Curseur = (wxPoint) cursorPos;
1049 
1050  preview.Add( aGraphic );
1051  frame()->SetMsgPanel( aGraphic );
1052  m_controls->SetAutoPan( true );
1053  m_controls->CaptureCursor( true );
1054 
1055  started = true;
1056  }
1057  else
1058  {
1059  auto snapItem = dyn_cast<DRAWSEGMENT*>( grid.GetSnapped() );
1060  auto mod = dyn_cast<MODULE*>( m_frame->GetModel() );
1061 
1062  if( aGraphic->GetEnd() == aGraphic->GetStart()
1063  || ( evt->IsDblClick( BUT_LEFT ) && aShape == S_SEGMENT )
1064  || snapItem )
1065  // User has clicked twice in the same spot
1066  // or clicked on the end of an existing segment (closing a path)
1067  {
1068  BOARD_COMMIT commit( m_frame );
1069 
1070  // If the user clicks on an existing snap point from a drawsegment
1071  // we finish the segment as they are likely closing a path
1072  if( snapItem && aGraphic->GetLength() > 0.0 )
1073  {
1074  DRAWSEGMENT* l = m_editModules ? new EDGE_MODULE( mod ) : new DRAWSEGMENT;
1075 
1076  *l = *aGraphic;
1077  commit.Add( l );
1078  }
1079 
1080  if( !commit.Empty() )
1081  commit.Push( _( "Draw a line" ) );
1082 
1083  delete aGraphic;
1084  aGraphic = NULL;
1085  }
1086 
1087  preview.Clear();
1088  break;
1089  }
1090  }
1091  else if( evt->IsMotion() )
1092  {
1093  // 45 degree lines
1094  if( direction45 && aShape == S_SEGMENT )
1095  {
1096  const VECTOR2I lineVector( cursorPos - VECTOR2I( aGraphic->GetStart() ) );
1097 
1098  // get a restricted 45/H/V line from the last fixed point to the cursor
1099  auto newEnd = GetVectorSnapped45( lineVector );
1100  aGraphic->SetEnd( aGraphic->GetStart() + (wxPoint) newEnd );
1101  m_controls->ForceCursorPosition( true, VECTOR2I( aGraphic->GetEnd() ) );
1102  }
1103  else
1104  aGraphic->SetEnd( (wxPoint) cursorPos );
1105 
1106  m_view->Update( &preview );
1107 
1108  if( started )
1109  frame()->SetMsgPanel( aGraphic );
1110  else
1111  frame()->SetMsgPanel( board() );
1112  }
1113  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1114  {
1116  aGraphic->SetWidth( m_lineWidth );
1117  m_view->Update( &preview );
1118  frame()->SetMsgPanel( aGraphic );
1119  }
1120  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && ( m_lineWidth > WIDTH_STEP ) )
1121  {
1123  aGraphic->SetWidth( m_lineWidth );
1124  m_view->Update( &preview );
1125  frame()->SetMsgPanel( aGraphic );
1126  }
1127  else if( evt->IsAction( &PCB_ACTIONS::resetCoords ) )
1128  {
1129  IsOCurseurSet = true;
1130  }
1131  }
1132 
1133  if( !IsOCurseurSet ) // reset the relative coordinte if it was not set before
1134  m_frame->GetScreen()->m_O_Curseur = wxPoint( 0, 0 );
1135 
1136  m_view->Remove( &preview );
1137  frame()->SetMsgPanel( board() );
1138  m_controls->SetAutoPan( false );
1139  m_controls->CaptureCursor( false );
1140  m_controls->ForceCursorPosition( false );
1141 
1142  return started;
1143 }
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.
void SetShape(STROKE_T aShape)
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:93
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
BOARD * board() const
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:154
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:216
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:307
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:157
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()
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()
Definition: tool_event.cpp:177
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.
PCB_EDIT_FRAME * frame() const
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
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:239
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.
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:59
#define mod(a, n)
Definition: greymap.cpp:24
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
void SetWidth(int aWidth)

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), GRID_HELPER::BestSnapAnchor(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_ACTIONS::decWidth, COMMIT::Empty(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::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_BASE::m_editModules, m_frame, m_lineWidth, PCB_TOOL_BASE::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 737 of file drawing_tool.cpp.

738 {
739  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
740 
741  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add similar zone" ) );
742 
743  return drawZone( false, ZONE_MODE::SIMILAR );
744 }
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 1489 of file drawing_tool.cpp.

1490 {
1491  struct VIA_PLACER : public INTERACTIVE_PLACER_BASE
1492  {
1493  GRID_HELPER m_gridHelper;
1494 
1495  VIA_PLACER( PCB_EDIT_FRAME* aFrame ) : m_gridHelper( aFrame )
1496  {}
1497 
1498  TRACK* findTrack( VIA* aVia )
1499  {
1500  const LSET lset = aVia->GetLayerSet();
1501  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
1502  BOX2I bbox = aVia->GetBoundingBox();
1503  auto view = m_frame->GetGalCanvas()->GetView();
1504  std::vector<TRACK*> possible_tracks;
1505 
1506  view->Query( bbox, items );
1507 
1508  for( auto it : items )
1509  {
1510  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
1511 
1512  if( !(item->GetLayerSet() & lset ).any() )
1513  continue;
1514 
1515  if( auto track = dyn_cast<TRACK*>( item ) )
1516  {
1517  if( TestSegmentHit( aVia->GetPosition(), track->GetStart(), track->GetEnd(),
1518  ( track->GetWidth() + aVia->GetWidth() ) / 2 ) )
1519  possible_tracks.push_back( track );
1520  }
1521  }
1522 
1523  TRACK* return_track = nullptr;
1524  int min_d = std::numeric_limits<int>::max();
1525  for( auto track : possible_tracks )
1526  {
1527  SEG test( track->GetStart(), track->GetEnd() );
1528  auto dist = ( test.NearestPoint( aVia->GetPosition() ) -
1529  VECTOR2I( aVia->GetPosition() ) ).EuclideanNorm();
1530 
1531  if( dist < min_d )
1532  {
1533  min_d = dist;
1534  return_track = track;
1535  }
1536  }
1537 
1538  return return_track;
1539  }
1540 
1541 
1542  bool hasDRCViolation( VIA* aVia )
1543  {
1544  const LSET lset = aVia->GetLayerSet();
1545  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
1546  int net = 0;
1547  int clearance = 0;
1548  BOX2I bbox = aVia->GetBoundingBox();
1549  auto view = m_frame->GetGalCanvas()->GetView();
1550 
1551  view->Query( bbox, items );
1552 
1553  for( auto it : items )
1554  {
1555  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
1556 
1557  if( !(item->GetLayerSet() & lset ).any() )
1558  continue;
1559 
1560  if( auto track = dyn_cast<TRACK*>( item ) )
1561  {
1562  int max_clearance = std::max( clearance, track->GetClearance() );
1563 
1564  if( TestSegmentHit( aVia->GetPosition(), track->GetStart(), track->GetEnd(),
1565  ( track->GetWidth() + aVia->GetWidth() ) / 2 + max_clearance ) )
1566  {
1567  if( net && track->GetNetCode() != net )
1568  return true;
1569 
1570  net = track->GetNetCode();
1571  clearance = track->GetClearance();
1572  }
1573  }
1574 
1575  if( auto mod = dyn_cast<MODULE*>( item ) )
1576  {
1577  for( auto pad : mod->Pads() )
1578  {
1579  int max_clearance = std::max( clearance, pad->GetClearance() );
1580 
1581  if( pad->HitTest( aVia->GetBoundingBox(), false, max_clearance ) )
1582  {
1583  if( net && pad->GetNetCode() != net )
1584  return true;
1585 
1586  net = pad->GetNetCode();
1587  clearance = pad->GetClearance();
1588  }
1589  }
1590  }
1591  }
1592 
1593  return false;
1594  }
1595 
1596 
1597  int findStitchedZoneNet( VIA* aVia )
1598  {
1599  const auto pos = aVia->GetPosition();
1600  const auto lset = aVia->GetLayerSet();
1601 
1602  for( auto mod : m_board->Modules() )
1603  {
1604  for( D_PAD* pad : mod->Pads() )
1605  {
1606  if( pad->HitTest( pos ) && ( pad->GetLayerSet() & lset ).any() )
1607  return -1;
1608  }
1609  }
1610 
1611  std::vector<ZONE_CONTAINER*> foundZones;
1612 
1613  for( auto zone : m_board->Zones() )
1614  {
1615  if( zone->HitTestFilledArea( pos ) )
1616  {
1617  foundZones.push_back( zone );
1618  }
1619  }
1620 
1621  std::sort( foundZones.begin(), foundZones.end(),
1622  [] ( const ZONE_CONTAINER* a, const ZONE_CONTAINER* b ) {
1623  return a->GetLayer() < b->GetLayer();
1624  } );
1625 
1626  // first take the net of the active layer
1627  for( auto z : foundZones )
1628  {
1629  if( m_frame->GetActiveLayer() == z->GetLayer() )
1630  return z->GetNetCode();
1631  }
1632 
1633  // none? take the topmost visible layer
1634  for( auto z : foundZones )
1635  {
1636  if( m_board->IsLayerVisible( z->GetLayer() ) )
1637  return z->GetNetCode();
1638  }
1639 
1640  return -1;
1641  }
1642 
1643  void SnapItem( BOARD_ITEM *aItem ) override
1644  {
1645  // If you place a Via on a track but not on its centerline, the current
1646  // connectivity algorithm will require us to put a kink in the track when
1647  // we break it (so that each of the two segments ends on the via center).
1648  // That's not ideal, and is in fact probably worse than forcing snap in
1649  // this situation.
1650 
1651  m_gridHelper.SetSnap( !( m_modifiers & MD_SHIFT ) );
1652  auto via = static_cast<VIA*>( aItem );
1653  wxPoint pos = via->GetPosition();
1654  TRACK* track = findTrack( via );
1655 
1656  if( track )
1657  {
1658  SEG trackSeg( track->GetStart(), track->GetEnd() );
1659  VECTOR2I snap = m_gridHelper.AlignToSegment( pos, trackSeg );
1660 
1661  aItem->SetPosition( (wxPoint) snap );
1662  }
1663  }
1664 
1665  bool PlaceItem( BOARD_ITEM* aItem, BOARD_COMMIT& aCommit ) override
1666  {
1667  auto via = static_cast<VIA*>( aItem );
1668  int newNet;
1669  TRACK* track = findTrack( via );
1670 
1671  if( hasDRCViolation( via ) )
1672  return false;
1673 
1674  if( track )
1675  {
1676  aCommit.Modify( track );
1677  TRACK* newTrack = dynamic_cast<TRACK*>( track->Clone() );
1678  track->SetEnd( via->GetPosition() );
1679  newTrack->SetStart( via->GetPosition() );
1680  aCommit.Add( newTrack );
1681 
1682  newNet = track->GetNetCode();
1683  }
1684  else
1685  newNet = findStitchedZoneNet( via );
1686 
1687  if( newNet > 0 )
1688  via->SetNetCode( newNet );
1689 
1690  aCommit.Add( aItem );
1691  return true;
1692  }
1693 
1694  std::unique_ptr<BOARD_ITEM> CreateItem() override
1695  {
1696  auto& ds = m_board->GetDesignSettings();
1697  VIA* via = new VIA( m_board );
1698 
1699  via->SetNetCode( 0 );
1700  via->SetViaType( ds.m_CurrentViaType );
1701 
1702  // for microvias, the size and hole will be changed later.
1703  via->SetWidth( ds.GetCurrentViaSize() );
1704  via->SetDrill( ds.GetCurrentViaDrill() );
1705 
1706  // Usual via is from copper to component.
1707  // layer pair is B_Cu and F_Cu.
1708  via->SetLayerPair( B_Cu, F_Cu );
1709 
1710  PCB_LAYER_ID first_layer = m_frame->GetActiveLayer();
1711  PCB_LAYER_ID last_layer;
1712 
1713  // prepare switch to new active layer:
1714  if( first_layer != m_frame->GetScreen()->m_Route_Layer_TOP )
1715  last_layer = m_frame->GetScreen()->m_Route_Layer_TOP;
1716  else
1717  last_layer = m_frame->GetScreen()->m_Route_Layer_BOTTOM;
1718 
1719  // Adjust the actual via layer pair
1720  switch( via->GetViaType() )
1721  {
1722  case VIA_BLIND_BURIED:
1723  via->SetLayerPair( first_layer, last_layer );
1724  break;
1725 
1726  case VIA_MICROVIA: // from external to the near neighbor inner layer
1727  {
1728  PCB_LAYER_ID last_inner_layer =
1729  ToLAYER_ID( ( m_board->GetCopperLayerCount() - 2 ) );
1730 
1731  if( first_layer == B_Cu )
1732  last_layer = last_inner_layer;
1733  else if( first_layer == F_Cu )
1734  last_layer = In1_Cu;
1735  else if( first_layer == last_inner_layer )
1736  last_layer = B_Cu;
1737  else if( first_layer == In1_Cu )
1738  last_layer = F_Cu;
1739 
1740  // else error: will be removed later
1741  via->SetLayerPair( first_layer, last_layer );
1742 
1743  // Update diameter and hole size, which where set previously
1744  // for normal vias
1745  NETINFO_ITEM* net = via->GetNet();
1746 
1747  if( net )
1748  {
1749  via->SetWidth( net->GetMicroViaSize() );
1750  via->SetDrill( net->GetMicroViaDrillSize() );
1751  }
1752  }
1753  break;
1754 
1755  default:
1756  break;
1757  }
1758 
1759  return std::unique_ptr<BOARD_ITEM>( via );
1760  }
1761  };
1762 
1763  VIA_PLACER placer( frame() );
1764 
1765  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
1766 
1767  frame()->SetToolID( ID_PCB_DRAW_VIA_BUTT, wxCURSOR_PENCIL, _( "Add vias" ) );
1768 
1769  doInteractiveItemPlacement( &placer, _( "Place via" ),
1771 
1772  frame()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
1773 
1774  return 0;
1775 }
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:438
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:129
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:133
EDA_DRAW_PANEL_GAL * GetGalCanvas() const
Return a pointer to GAL-based canvas of given EDA draw frame.
Definition: draw_frame.h:931
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:185
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:534
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
void SetWidth(int aWidth)
Definition: class_track.h:126
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:252
KIGFX::PCB_VIEW * view() const
VIATYPE_T GetViaType() const
Definition: class_track.h:437
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:410
PCB_EDIT_FRAME * frame() const
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:65
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:453
ZONE_CONTAINERS & Zones()
Definition: class_board.h:254
int GetWidth() const
Definition: class_track.h:127
#define max(a, b)
Definition: auxiliary.h:86
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...
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:445
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.
const wxPoint & GetEnd() const
Definition: class_track.h:130
int GetMicroViaDrillSize()
Function GetViaDrillSize returns the size of via drills used to route this net.
Definition: netinfo.h:182
void SetStart(const wxPoint &aStart)
Definition: class_track.h:132
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
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:162
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_BASE::doInteractiveItemPlacement(), F_Cu, PCB_TOOL_BASE::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_BASE::IPO_FLIP, PCB_TOOL_BASE::IPO_REPEAT, PCB_TOOL_BASE::IPO_ROTATE, PCB_TOOL_BASE::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_BASE::view(), and BOARD::Zones().

Referenced by setTransitions().

◆ DrawZone()

int DRAWING_TOOL::DrawZone ( const TOOL_EVENT aEvent)

Function DrawZone() Starts interactively drawing a zone.

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

Definition at line 693 of file drawing_tool.cpp.

694 {
695  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
696 
697  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zones" ) );
698 
699  return drawZone( false, ZONE_MODE::ADD );
700 }
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 1334 of file drawing_tool.cpp.

1335 {
1336  // get a source zone, if we need one. We need it for:
1337  // ZONE_MODE::CUTOUT (adding a hole to the source zone)
1338  // ZONE_MODE::SIMILAR (creating a new zone using settings of source zone
1339  ZONE_CONTAINER* sourceZone = nullptr;
1340 
1341  if( !getSourceZoneForAction( aMode, sourceZone ) )
1342  {
1344  return 0;
1345  }
1346 
1348 
1349  params.m_keepout = aKeepout;
1350  params.m_mode = aMode;
1351  params.m_sourceZone = sourceZone;
1352 
1353  if( aMode == ZONE_MODE::GRAPHIC_POLYGON )
1354  params.m_layer = getDrawingLayer();
1355  else if( aMode == ZONE_MODE::SIMILAR )
1356  params.m_layer = sourceZone->GetLayer();
1357  else
1358  params.m_layer = m_frame->GetActiveLayer();
1359 
1360  ZONE_CREATE_HELPER zoneTool( *this, params );
1361 
1362  // the geometry manager which handles the zone geometry, and
1363  // hands the calculated points over to the zone creator tool
1364  POLYGON_GEOM_MANAGER polyGeomMgr( zoneTool );
1365 
1366  Activate(); // register for events
1367 
1368  m_controls->ShowCursor( true );
1369  m_controls->SetSnapping( true );
1370 
1371  bool started = false;
1372  GRID_HELPER grid( m_frame );
1373  STATUS_TEXT_POPUP status( m_frame );
1374  status.SetTextColor( wxColour( 255, 0, 0 ) );
1375  status.SetText( _( "Self-intersecting polygons are not allowed" ) );
1376 
1377  while( OPT_TOOL_EVENT evt = Wait() )
1378  {
1379  LSET layers( m_frame->GetActiveLayer() );
1380  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1381  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1382  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1383  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), layers );
1384  m_controls->ForceCursorPosition( true, cursorPos );
1385 
1387  {
1388  // pre-empted by another tool, give up
1389  // cancelled without an inprogress polygon, give up
1390  if( !polyGeomMgr.IsPolygonInProgress() || evt->IsActivate() )
1391  {
1392  break;
1393  }
1394 
1395  polyGeomMgr.Reset();
1396  // start again
1397  started = false;
1398 
1399  m_controls->SetAutoPan( false );
1400  m_controls->CaptureCursor( false );
1401  }
1402  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1403  {
1404  if( aMode == ZONE_MODE::GRAPHIC_POLYGON )
1405  params.m_layer = getDrawingLayer();
1406  else if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::CUTOUT )
1407  params.m_layer = frame()->GetActiveLayer();
1408  }
1409  else if( evt->IsClick( BUT_RIGHT ) )
1410  {
1412  }
1413  // events that lock in nodes
1414  else if( evt->IsClick( BUT_LEFT )
1415  || evt->IsDblClick( BUT_LEFT )
1416  || evt->IsAction( &closeZoneOutline ) )
1417  {
1418  // Check if it is double click / closing line (so we have to finish the zone)
1419  const bool endPolygon = evt->IsDblClick( BUT_LEFT )
1420  || evt->IsAction( &closeZoneOutline )
1421  || polyGeomMgr.NewPointClosesOutline( cursorPos );
1422 
1423  if( endPolygon )
1424  {
1425  polyGeomMgr.SetFinished();
1426  polyGeomMgr.Reset();
1427 
1428  started = false;
1429  m_controls->SetAutoPan( false );
1430  m_controls->CaptureCursor( false );
1431  }
1432 
1433  // adding a corner
1434  else if( polyGeomMgr.AddPoint( cursorPos ) )
1435  {
1436  if( !started )
1437  {
1438  started = true;
1439  m_controls->SetAutoPan( true );
1440  m_controls->CaptureCursor( true );
1441  }
1442  }
1443 
1444  }
1445  else if( evt->IsAction( &deleteLastPoint ) )
1446  {
1447  polyGeomMgr.DeleteLastCorner();
1448 
1449  if( !polyGeomMgr.IsPolygonInProgress() )
1450  {
1451  // report finished as an empty shape
1452  polyGeomMgr.SetFinished();
1453 
1454  // start again
1455  started = false;
1456  m_controls->SetAutoPan( false );
1457  m_controls->CaptureCursor( false );
1458  }
1459  }
1460  else if( polyGeomMgr.IsPolygonInProgress()
1461  && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
1462  {
1463  polyGeomMgr.SetCursorPosition( cursorPos, evt->Modifier( MD_CTRL )
1466 
1467  if( polyGeomMgr.IsSelfIntersecting( true ) )
1468  {
1469  wxPoint p = wxGetMousePosition() + wxPoint( 20, 20 );
1470  status.Move( p );
1471  status.Popup( m_frame );
1472  status.Expire( 1500 );
1473  }
1474  else
1475  {
1476  status.Hide();
1477  }
1478  }
1479  } // end while
1480 
1483  m_controls->ForceCursorPosition( false );
1484 
1485  return 0;
1486 }
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.
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)
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:216
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:185
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()
Definition: tool_event.cpp:177
PCB_EDIT_FRAME * frame() const
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:239
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 ...
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:59
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:486

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_BASE::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_BASE::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 713 of file drawing_tool.cpp.

714 {
715  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
716 
717  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zone cutout" ) );
718 
719  return drawZone( false, ZONE_MODE::CUTOUT );
720 }
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 703 of file drawing_tool.cpp.

704 {
705  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::KEEPOUT );
706 
707  m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add keepout" ) );
708 
709  return drawZone( true, ZONE_MODE::ADD );
710 }
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_BASE::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_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 139 of file pcb_tool_base.h.

139 { return getEditFrame<PCB_EDIT_FRAME>(); }

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::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_BASE::displayOptions(), EDIT_TOOL::doCopyToClipboard(), PCB_TOOL_BASE::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 1803 of file drawing_tool.cpp.

1804 {
1805  PCB_LAYER_ID layer = m_frame->GetActiveLayer();
1806 
1808  && IsCopperLayer( layer ) )
1809  {
1810  if( layer == F_Cu )
1811  layer = F_SilkS;
1812  else if( layer == B_Cu )
1813  layer = B_SilkS;
1814  else
1815  layer = Dwgs_User;
1816 
1817  m_frame->SetActiveLayer( layer );
1818  }
1819 
1820  return layer;
1821 }
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.
MODE GetDrawingMode() const
Function GetDrawingMode.

References B_Cu, B_SilkS, DIMENSION, Dwgs_User, F_Cu, F_SilkS, PCB_BASE_FRAME::GetActiveLayer(), GetDrawingMode(), GRAPHIC_POLYGON, 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 getDrawingLayer(), and 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:211

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:216

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), ACTION_MENU::onMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

200  {
201  EDA_ITEM* m = getModelInt();
202  wxASSERT( dynamic_cast<T*>( m ) );
203 
204  return static_cast<T*>( m );
205  }
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:157

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:215

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

1797 {
1798  assert( m_board );
1799  return m_board->GetDesignSettings().GetLineThickness( aLayer );
1800 }
BOARD * m_board
Definition: drawing_tool.h:263
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:534
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:217

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

1301 {
1302  bool clearSelection = false;
1303  aZone = nullptr;
1304 
1305  // not an action that needs a source zone
1306  if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON )
1307  return true;
1308 
1310  const SELECTION& selection = selTool->GetSelection();
1311 
1312  if( selection.Empty() )
1313  {
1314  clearSelection = true;
1316  }
1317 
1318  // we want a single zone
1319  if( selection.Size() == 1 )
1320  aZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1321 
1322  // expected a zone, but didn't get one
1323  if( !aZone )
1324  {
1325  if( clearSelection )
1327 
1328  return false;
1329  }
1330 
1331  return true;
1332 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
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:119
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
Add a new zone/keepout with fresh settings.
const SELECTION & selection() const
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_BASE::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.

References PCB_TOOL_BASE::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:208

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:216

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), EE_SELECTION_TOOL::clearSelection(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), COMMON_TOOLS::doGridPreset(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EE_POINT_EDITOR::Main(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), COMMON_TOOLS::ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), CVPCB_SELECTION_TOOL::~CVPCB_SELECTION_TOOL(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 41 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), COMMON_TOOLS::CursorControl(), SCH_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), COMMON_TOOLS::doZoomToPreset(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), SCH_WIRE_BUS_TOOL::finishSegments(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), 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(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), Reset(), CVPCB_CONTROL::ResetCoords(), GERBVIEW_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), EE_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), LIB_MOVE_TOOL::updateModificationPoint(), SCH_MOVE_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

Function Go()

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

Definition at line 135 of file tool_interactive.h.

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

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), LIB_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), LIB_MOVE_TOOL::setTransitions(), POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), CVPCB_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), SCH_WIRE_BUS_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), EE_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), SELECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ Init()

bool DRAWING_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from PCB_TOOL_BASE.

Definition at line 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 }
TOOL_MENU m_menu
Menu model displayed by the tool.
void AddStandardSubMenus(EDA_DRAW_FRAME *aFrame)
Function CreateBasicMenu.
Definition: tool_menu.cpp:83
static TOOL_ACTION closeZoneOutline("pcbnew.InteractiveDrawing.closeZoneOutline", AS_CONTEXT, 0, _("Close Zone Outline"), _("Close the outline of a zone in progress"), checked_ok_xpm)
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:46
static TOOL_ACTION cancelInteractive
Definition: actions.h:45
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Function AddItem()

References CONDITIONAL_MENU::AddItem(), TOOL_MENU::AddStandardSubMenus(), ARC, ACTIONS::cancelInteractive, closeZoneOutline, deleteLastPoint, TOOL_MENU::GetMenu(), PCB_TOOL_BASE::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:216
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:211
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 747 of file drawing_tool.cpp.

748 {
749  if( !m_frame->GetModel() )
750  return 0;
751 
752  // Note: PlaceImportedGraphics() will convert PCB_LINE_T and PCB_TEXT_T to module graphic items
753  // if needed
755  int dlgResult = dlg.ShowModal();
756 
757  auto& list = dlg.GetImportedItems();
758 
759  if( dlgResult != wxID_OK )
760  return 0;
761 
762  // Ensure the list is not empty:
763  if( list.empty() )
764  {
765  wxMessageBox( _( "No graphic items found in file to import") );
766  return 0;
767  }
768 
769 
771 
772  // Add a VIEW_GROUP that serves as a preview for the new item
773  SELECTION preview;
774  BOARD_COMMIT commit( m_frame );
775 
776  // Build the undo list & add items to the current view
777  for( auto& ptr : list)
778  {
779  EDA_ITEM* item = ptr.get();
780 
781  if( m_editModules )
782  wxASSERT( item->Type() == PCB_MODULE_EDGE_T || item->Type() == PCB_MODULE_TEXT_T );
783  else
784  wxASSERT( item->Type() == PCB_LINE_T || item->Type() == PCB_TEXT_T );
785 
786  if( dlg.IsPlacementInteractive() )
787  preview.Add( item );
788  else
789  commit.Add( item );
790 
791  ptr.release();
792  }
793 
794  if( !dlg.IsPlacementInteractive() )
795  {
796  commit.Push( _( "Place a DXF_SVG drawing" ) );
797  return 0;
798  }
799 
800  BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( preview.Front() );
801  m_view->Add( &preview );
802 
804  m_controls->ShowCursor( true );
805  m_controls->SetSnapping( true );
807 
808  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
809 
810  // Now move the new items to the current cursor position:
811  VECTOR2I cursorPos = m_controls->GetCursorPosition();
812  VECTOR2I delta = cursorPos - firstItem->GetPosition();
813 
814  for( EDA_ITEM* item : preview )
815  static_cast<BOARD_ITEM*>( item )->Move( (wxPoint) delta );
816 
817  m_view->Update( &preview );
818 
819  Activate();
820 
821  // Main loop: keep receiving events
822  while( OPT_TOOL_EVENT evt = Wait() )
823  {
824  cursorPos = m_controls->GetCursorPosition();
825 
826  if( evt->IsMotion() )
827  {
828  delta = cursorPos - firstItem->GetPosition();
829 
830  for( auto item : preview )
831  static_cast<BOARD_ITEM*>( item )->Move( (wxPoint) delta );
832 
833  m_view->Update( &preview );
834  }
835  else if( evt->Category() == TC_COMMAND )
836  {
837  // TODO it should be handled by EDIT_TOOL, so add items and select?
838  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
839  {
840  const auto rotationPoint = (wxPoint) cursorPos;
841  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *m_frame, *evt );
842 
843  for( auto item : preview )
844  static_cast<BOARD_ITEM*>( item )->Rotate( rotationPoint, rotationAngle );
845 
846  m_view->Update( &preview );
847  }
848  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
849  {
850  for( auto item : preview )
851  static_cast<BOARD_ITEM*>( item )->Flip( (wxPoint) cursorPos );
852 
853  m_view->Update( &preview );
854  }
855  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
856  {
857  preview.FreeItems();
858  break;
859  }
860  }
861  else if( evt->IsClick( BUT_RIGHT ) )
862  {
864  }
865  else if( evt->IsClick( BUT_LEFT ) )
866  {
867  // Place the imported drawings
868  for( auto item : preview )
869  commit.Add( item );
870 
871  commit.Push( _( "Place a DXF_SVG drawing" ) );
872  break;
873  }
874  }
875 
876  preview.Clear();
877  m_view->Remove( &preview );
878 
879  return 0;
880 }
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.
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:216
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()
Definition: tool_event.cpp:177
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
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:99
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:157
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:59
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
EDA_ITEM * Front() const
Definition: selection.h:155
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
KICAD_T Type() const
Function Type()
Definition: base_struct.h:204

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_BASE::m_editModules, m_frame, PCB_TOOL_BASE::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(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ PlaceText()

int DRAWING_TOOL::PlaceText ( const TOOL_EVENT aEvent)

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

Definition at line 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 );
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 );
430 
431  RunMainStack([&]() {
432  m_frame->InstallTextOptionsFrame( textPcb, NULL );
433  } );
434 
435  if( textPcb->GetText().IsEmpty() )
436  {
438  delete textPcb;
439  }
440  else
441  text = textPcb;
442  }
443 
444  if( text == NULL )
445  continue;
446 
447  m_controls->WarpCursor( text->GetPosition(), true );
449  m_controls->CaptureCursor( true );
450  m_controls->SetAutoPan( true );
451 
453  }
454  else
455  {
456  text->ClearFlags();
458 
459  commit.Add( text );
460  commit.Push( _( "Place a text" ) );
461 
462  m_controls->CaptureCursor( false );
463  m_controls->SetAutoPan( false );
464  m_controls->ShowCursor( true );
465 
466  text = NULL;
467  }
468  }
469  else if( text && evt->IsMotion() )
470  {
471  text->SetPosition( (wxPoint) cursorPos );
472  selection.SetReferencePoint( cursorPos );
473  m_view->Update( &selection );
474  frame()->SetMsgPanel( text );
475  }
476 
477  else if( text && evt->IsAction( &PCB_ACTIONS::properties ) )
478  {
479  // Calling 'Properties' action clears the selection, so we need to restore it
480  reselect = true;
481  }
482  }
483 
484  frame()->SetMsgPanel( board() );
486 
487  return 0;
488 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:195
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
Menu model displayed by the tool.
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.
BOARD * board() const
virtual void SetPosition(const wxPoint &aPos)=0
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
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.
void SetItalic(bool isItalic)
Definition: eda_text.h:186
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:240
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:105
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
virtual const wxString GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:147
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:231
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:208
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:259
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.
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()
Definition: tool_event.cpp:177
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
PCB_EDIT_FRAME * frame() const
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
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
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:260
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
const SELECTION & selection() const
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
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:165
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:486
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.

References TOOL_INTERACTIVE::Activate(), COMMIT::Add(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), EDA_ITEM::ClearFlags(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::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_BASE::m_editModules, m_frame, PCB_TOOL_BASE::m_menu, m_mode, TOOL_BASE::m_toolMgr, m_view, PCB_ACTIONS::properties, BOARD_COMMIT::Push(), TOOL_MANAGER::RunAction(), TOOL_INTERACTIVE::RunMainStack(), PCB_TOOL_BASE::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(), and KIGFX::VIEW_CONTROLS::WarpCursor().

Referenced by setTransitions().

◆ Reset()

void DRAWING_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

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

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

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PCB_TOOL_BASE.

Definition at line 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:216
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_BASE::selection ( ) const
protectedinherited

Definition at line 251 of file pcb_tool_base.cpp.

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

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::expandConnection(), 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(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::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_BASE::selection ( )
protectedinherited

Definition at line 258 of file pcb_tool_base.cpp.

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

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

◆ SetAnchor()

int DRAWING_TOOL::SetAnchor ( const TOOL_EVENT aEvent)

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

Definition at line 883 of file drawing_tool.cpp.

884 {
885  assert( m_editModules );
886 
887  if( !m_frame->GetModel() )
888  return 0;
889 
890  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR );
891 
892  Activate();
893  m_frame->SetToolID( ID_MODEDIT_ANCHOR_TOOL, wxCURSOR_PENCIL, _( "Place the footprint anchor" ) );
894 
895  m_controls->ShowCursor( true );
896  m_controls->SetSnapping( true );
897  m_controls->SetAutoPan( true );
898  m_controls->CaptureCursor( false );
899 
900  while( OPT_TOOL_EVENT evt = Wait() )
901  {
902  if( evt->IsClick( BUT_LEFT ) )
903  {
905  BOARD_COMMIT commit( m_frame );
906  commit.Modify( module );
907 
908  // set the new relative internal local coordinates of footprint items
909  VECTOR2I cursorPos = m_controls->GetCursorPosition();
910  wxPoint moveVector = module->GetPosition() - (wxPoint) cursorPos;
911  module->MoveAnchorPosition( moveVector );
912 
913  commit.Push( _( "Move the footprint reference anchor" ) );
914 
915  // Usually, we do not need to change twice the anchor position,
916  // so deselect the active tool
917  break;
918  }
919  else if( evt->IsClick( BUT_RIGHT ) )
920  {
922  }
923  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
924  break;
925  }
926 
928 
929  return 0;
930 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
Menu model displayed by the tool.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
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()
Definition: tool_event.cpp:177
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
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
MODULE * module() const
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:59
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:486

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_BASE::m_editModules, m_frame, PCB_TOOL_BASE::m_menu, m_mode, COMMIT::Modify(), PCB_TOOL_BASE::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(), and TOOL_INTERACTIVE::Wait().

Referenced by setTransitions().

◆ SetContextMenu()

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

Function SetContextMenu()

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

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

Definition at line 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:216
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void ScheduleContextMenu(TOOL_BASE *aTool, ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.

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

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

◆ SetEditModules()

void PCB_TOOL_BASE::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 97 of file pcb_tool_base.h.

98  {
99  m_editModules = aEnabled;
100  }

References PCB_TOOL_BASE::m_editModules.

◆ setTransitions()

void DRAWING_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL_BASE.

Definition at line 1778 of file drawing_tool.cpp.

1779 {
1793 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:137
int DrawCircle(const TOOL_EVENT &aEvent)
Function DrawCircle() Starts interactively drawing a circle.
static TOOL_ACTION placeImportedGraphics
Definition: pcb_actions.h:150
int DrawVia(const TOOL_EVENT &aEvent)
int DrawZone(const TOOL_EVENT &aEvent)
Function DrawZone() Starts interactively drawing a zone.
static TOOL_ACTION drawSimilarZone
Definition: pcb_actions.h:147
static TOOL_ACTION drawArc
Definition: pcb_actions.h:140
int DrawLine(const TOOL_EVENT &aEvent)
Function DrawLine() Starts interactively drawing a line.
static TOOL_ACTION drawZoneKeepout
Definition: pcb_actions.h:145
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:151
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION placeText
Definition: pcb_actions.h:141
static TOOL_ACTION drawGraphicPolygon
Definition: pcb_actions.h:138
int PlaceImportedGraphics(const TOOL_EVENT &aEvent)
Function PlaceImportedGraphics() Places a drawing imported from a DXF or SVG file in module editor.
int PlaceText(const TOOL_EVENT &aEvent)
Function PlaceText() Displays a dialog that allows one to input text and its settings and then lets t...
static TOOL_ACTION drawDimension
Definition: pcb_actions.h:142
int DrawZoneKeepout(const TOOL_EVENT &aEvent)
Function DrawZoneKeepout() Starts interactively drawing a keepout area.
static TOOL_ACTION drawVia
Definition: pcb_actions.h:144
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:146
int DrawZoneCutout(const TOOL_EVENT &aEvent)
Function DrawZoneCutout() Starts interactively drawing a zone cutout area of an existing zone.
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:139
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
Definition: pcb_actions.h:143
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, PCB_ACTIONS::drawGraphicPolygon, DrawGraphicPolygon(), DrawLine(), PCB_ACTIONS::drawLine, PCB_ACTIONS::drawSimilarZone, DrawSimilarZone(), DrawVia(), PCB_ACTIONS::drawVia, DrawZone(), PCB_ACTIONS::drawZone, PCB_ACTIONS::drawZoneCutout, DrawZoneCutout(), PCB_ACTIONS::drawZoneKeepout, DrawZoneKeepout(), TOOL_INTERACTIVE::Go(), PCB_ACTIONS::placeImportedGraphics, PlaceImportedGraphics(), PlaceText(), PCB_ACTIONS::placeText, PCB_ACTIONS::setAnchor, and 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:216
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 LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_DRAWING_TOOLS::doPlaceComponent(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_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(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceImage(), PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Remove(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), SetAnchor(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), and SCH_WIRE_BUS_TOOL::UnfoldBus().

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

Referenced by TOOL_INTERACTIVE::Activate(), EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_DRAWING_TOOLS::AddJunction(), SCH_DRAWING_TOOLS::AddLabel(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDITOR_CONTROL::ClearHighlight(), PCB_EDITOR_CONTROL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_WIRE_BUS_TOOL::doDrawSegments(), SCH_DRAWING_TOOLS::doPlaceComponent(), SCH_DRAWING_TOOLS::doSingleClickPlace(), LIB_DRAWING_TOOLS::doTwoClickPlace(), SCH_DRAWING_TOOLS::doTwoClickPlace(), drawArc(), SCH_WIRE_BUS_TOOL::DrawBusses(), DrawDimension(), SCH_WIRE_BUS_TOOL::DrawLines(), drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SCH_WIRE_BUS_TOOL::DrawWires(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), SCH_EDITOR_CONTROL::EnterSheet(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), SCH_WIRE_BUS_TOOL::finishSegments(), 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(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_EDITOR_CONTROL::HighlightNetCursor(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PAD_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), EE_PICKER_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceImage(), PlaceImportedGraphics(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), EE_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), SELECTION_TOOL::RequestSelection(), CVPCB_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), EE_SELECTION_TOOL::SelectConnection(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), EE_SELECTION_TOOL::SelectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), SCH_WIRE_BUS_TOOL::StartBus(), SCH_WIRE_BUS_TOOL::StartLine(), SCH_WIRE_BUS_TOOL::StartWire(), GERBVIEW_SELECTION_TOOL::toggleSelection(), EE_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SCH_EDITOR_CONTROL::Undo(), SCH_WIRE_BUS_TOOL::UnfoldBus(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), 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 215 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 217 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 208 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: