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...
 
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 DrawVia (const TOOL_EVENT &aEvent)
 
int PlaceImportedGraphics (const TOOL_EVENT &aEvent)
 Function PlaceImportedGraphics() Places a drawing imported from a DXF or SVG file in module editor. More...
 
int SetAnchor (const TOOL_EVENT &aEvent)
 Function SetAnchor() Places the footprint anchor (only in module editor). More...
 
void setTransitions () override
 

Sets up handlers for various events.

More...
 
void SetEditModules (bool aEnabled)
 Function SetEditModules() More...
 
bool EditingModules () const
 
void Activate ()
 Function Activate() Runs the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Function SetContextMenu() More...
 
void RunMainStack (std::function< void()> aFunc)
 Function RunMainStack() More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Go() More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Function Wait() More...
 
TOOL_TYPE GetType () const
 Function GetType() Returns the type of the tool. More...
 
TOOL_ID GetId () const
 Function GetId() Returns the unique identifier of the tool. More...
 
const std::string & GetName () const
 Function GetName() Returns the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Function GetManager() Returns the instance of TOOL_MANAGER that takes care of the tool. More...
 
TOOL_SETTINGSGetSettings ()
 
bool IsToolActive () const
 

Protected Types

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

Protected Member Functions

void doInteractiveItemPlacement (const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_BASE_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
const PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const PCBNEW_SELECTIONselection () const
 
PCBNEW_SELECTIONselection ()
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

bool m_editModules
 
TOOL_MENU m_menu
 functions below are not yet implemented - their interface may change More...
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Member Functions

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

Starts drawing a selected shape (i.e.

More...
 
bool drawArc (const std::string &aTool, DRAWSEGMENT *&aGraphic, bool aImmediateMode)
 

Starts drawing an arc.

More...
 
bool getSourceZoneForAction (ZONE_MODE aMode, ZONE_CONTAINER *&aZone)
 Draws a polygon, that is added as a zone or a keepout area. More...
 
void 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 *aDim)
 Function constrainDimension() Forces the dimension lime to be drawn on multiple of 45 degrees. More...
 
int getSegmentWidth (PCB_LAYER_ID aLayer) const
 

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

More...
 
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_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 62 of file drawing_tool.h.

63  {
64  NONE,
65  LINE,
66  CIRCLE,
67  ARC,
68  TEXT,
69  ANCHOR,
70  DXF,
71  DIMENSION,
72  KEEPOUT,
73  ZONE,
75  VIA
76  };
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 79 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ DRAWING_TOOL()

DRAWING_TOOL::DRAWING_TOOL ( )

Definition at line 64 of file drawing_tool.cpp.

64  :
65  PCB_TOOL_BASE( "pcbnew.InteractiveDrawing" ),
66  m_view( nullptr ), m_controls( nullptr ),
67  m_board( nullptr ), m_frame( nullptr ), m_mode( MODE::NONE ),
68  m_lineWidth( 1 )
69 {
70 }
BOARD * m_board
Definition: drawing_tool.h:225
KIGFX::VIEW * m_view
Definition: drawing_tool.h:223
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:230
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:224
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:226
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 73 of file drawing_tool.cpp.

74 {
75 }

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 51 of file tool_interactive.cpp.

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

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

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), DrawArc(), DrawCircle(), DrawDimension(), DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), LIB_TREE::onContextMenu(), POINT_EDITOR::OnSelectionChange(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SetAnchor(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Function attachManager()

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

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63  m_toolSettings = TOOL_SETTINGS( this );
64 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220
friend class TOOL_SETTINGS
Definition: tool_base.h:154

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 151 of file pcb_tool_base.h.

151 { return getModel<BOARD>(); }

Referenced by PCBNEW_CONTROL::AppendBoard(), AUTOPLACE_TOOL::autoplace(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), EDIT_TOOL::ChangeTrackWidth(), ZONE_FILLER_TOOL::CheckAllZones(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), PCB_INSPECTION_TOOL::ClearHighlight(), constrainDimension(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL_BASE::doInteractiveItemPlacement(), drawArc(), DrawDimension(), drawSegment(), PAD_TOOL::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ZONE_FILLER_TOOL::FillAllZones(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::getCollectorsGuide(), PCBNEW_CONTROL::GraphicDisplayMode(), PCB_INSPECTION_TOOL::highlightNet(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PCB_TOOL_BASE::module(), PCBNEW_CONTROL::ModuleEdgeOutlines(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::Paste(), PCBNEW_CONTROL::placeBoardItems(), PCB_EDITOR_CONTROL::PlaceModule(), 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(), DRC::testDisabledLayers(), DRC::TestZoneToZoneOutline(), PCBNEW_CONTROL::TrackDisplayMode(), POINT_EDITOR::updateItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCBNEW_CONTROL::ZoneDisplayMode(), ZONE_FILLER_TOOL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and ZONE_FILLER_TOOL::ZoneUnfillAll().

◆ canvas()

◆ constrainDimension()

void DRAWING_TOOL::constrainDimension ( DIMENSION aDim)
private

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

Parameters
aDimensionis the dimension element currently being drawn

Definition at line 449 of file drawing_tool.cpp.

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

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

Referenced by DrawDimension().

◆ controls()

◆ displayOptions()

const PCB_DISPLAY_OPTIONS & PCB_TOOL_BASE::displayOptions ( ) const
protectedinherited

◆ doInteractiveItemPlacement()

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

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

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

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

Definition at line 36 of file pcb_tool_base.cpp.

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

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

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

219 {
220  if( m_editModules && !m_frame->GetModel() )
221  return 0;
222 
223  MODULE* module = dynamic_cast<MODULE*>( m_frame->GetModel() );
225  BOARD_COMMIT commit( m_frame );
226  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ARC );
227  bool immediateMode = aEvent.HasPosition();
228 
229  arc->SetFlags( IS_NEW );
230 
231  std::string tool = aEvent.GetCommandStr().get();
232  m_frame->PushTool( tool );
233  Activate();
234 
235  while( drawArc( tool, arc, immediateMode ) )
236  {
237  if( arc )
238  {
239  if( m_editModules )
240  static_cast<EDGE_MODULE*>( arc )->SetLocalCoord();
241 
242  commit.Add( arc );
243  commit.Push( _( "Draw an arc" ) );
244 
246  }
247 
248  arc = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
249  arc->SetFlags( IS_NEW );
250  immediateMode = false;
251  }
252 
253  return 0;
254 }
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
bool drawArc(const std::string &aTool, DRAWSEGMENT *&aGraphic, bool aImmediateMode)
Starts drawing an arc.
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:265
#define _(s)
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:226
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
MODULE * module() const
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:76
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260

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

Referenced by setTransitions().

◆ drawArc()

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

Starts drawing an arc.

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

1170 {
1172 
1173  // Arc geometric construction manager
1175 
1176  // Arc drawing assistant overlay
1177  KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() );
1178 
1179  // Add a VIEW_GROUP that serves as a preview for the new item
1180  PCBNEW_SELECTION preview;
1181  m_view->Add( &preview );
1182  m_view->Add( &arcAsst );
1183  GRID_HELPER grid( m_frame );
1184 
1185  m_controls->ShowCursor( true );
1186  m_controls->SetSnapping( true );
1187 
1188  bool firstPoint = false;
1189  bool cancelled = false;
1190 
1191  // Prime the pump
1193 
1194  if( aImmediateMode )
1196 
1197  // Main loop: keep receiving events
1198  while( TOOL_EVENT* evt = Wait() )
1199  {
1200  PCB_LAYER_ID layer = getDrawingLayer();
1201  aGraphic->SetLayer( layer );
1202 
1203  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
1204  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1205  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1206  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1207  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), aGraphic );
1208  m_controls->ForceCursorPosition( true, cursorPos );
1209 
1210  auto cleanup = [&] () {
1211  preview.Clear();
1212  delete aGraphic;
1213  aGraphic = nullptr;
1214  };
1215 
1216  if( evt->IsCancelInteractive() )
1217  {
1218  if( firstPoint )
1219  cleanup();
1220  else
1221  {
1222  m_frame->PopTool( aTool );
1223  cancelled = true;
1224  }
1225 
1226  break;
1227  }
1228  else if( evt->IsActivate() )
1229  {
1230  if( evt->IsPointEditor() )
1231  {
1232  // don't exit (the point editor runs in the background)
1233  }
1234  else if( evt->IsMoveTool() )
1235  {
1236  if( firstPoint )
1237  cleanup();
1238 
1239  // leave ourselves on the stack so we come back after the move
1240  cancelled = true;
1241  break;
1242  }
1243  else
1244  {
1245  if( firstPoint )
1246  cleanup();
1247 
1248  m_frame->PopTool( aTool );
1249  cancelled = true;
1250  break;
1251  }
1252  }
1253  else if( evt->IsClick( BUT_LEFT ) )
1254  {
1255  if( !firstPoint )
1256  {
1258 
1259  m_controls->SetAutoPan( true );
1260  m_controls->CaptureCursor( true );
1261 
1263 
1264  // Init the new item attributes
1265  // (non-geometric, those are handled by the manager)
1266  aGraphic->SetShape( S_ARC );
1267  aGraphic->SetWidth( m_lineWidth );
1268 
1269  preview.Add( aGraphic );
1270  firstPoint = true;
1271  }
1272 
1273  arcManager.AddPoint( cursorPos, true );
1274  }
1275  else if( evt->IsAction( &PCB_ACTIONS::deleteLastPoint ) )
1276  {
1277  arcManager.RemoveLastPoint();
1278  }
1279  else if( evt->IsMotion() )
1280  {
1281  // set angle snap
1282  arcManager.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1283 
1284  // update, but don't step the manager state
1285  arcManager.AddPoint( cursorPos, false );
1286  }
1287  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1288  {
1290  aGraphic->SetLayer( getDrawingLayer() );
1291  aGraphic->SetWidth( m_lineWidth );
1292  m_view->Update( &preview );
1293  frame()->SetMsgPanel( aGraphic );
1294  }
1295  else if( evt->IsClick( BUT_RIGHT ) )
1296  {
1298  }
1299  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1300  {
1302  aGraphic->SetWidth( m_lineWidth );
1303  m_view->Update( &preview );
1304  frame()->SetMsgPanel( aGraphic );
1305  }
1306  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && m_lineWidth > WIDTH_STEP )
1307  {
1309  aGraphic->SetWidth( m_lineWidth );
1310  m_view->Update( &preview );
1311  frame()->SetMsgPanel( aGraphic );
1312  }
1313  else if( evt->IsAction( &PCB_ACTIONS::arcPosture ) )
1314  {
1315  arcManager.ToggleClockwise();
1316  }
1317  else
1318  evt->SetPassEvent();
1319 
1320  if( arcManager.IsComplete() )
1321  {
1322  break;
1323  }
1324  else if( arcManager.HasGeometryChanged() )
1325  {
1326  updateArcFromConstructionMgr( arcManager, *aGraphic );
1327  m_view->Update( &preview );
1328  m_view->Update( &arcAsst );
1329 
1330  if( firstPoint )
1331  frame()->SetMsgPanel( aGraphic );
1332  else
1333  frame()->SetMsgPanel( board() );
1334  }
1335  }
1336 
1337  preview.Remove( aGraphic );
1338  m_view->Remove( &arcAsst );
1339  m_view->Remove( &preview );
1340  frame()->SetMsgPanel( board() );
1341  m_controls->SetAutoPan( false );
1342  m_controls->CaptureCursor( false );
1343  m_controls->ForceCursorPosition( false );
1344 
1345  return !cancelled;
1346 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
void SetShape(STROKE_T aShape)
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
BOARD * board() const
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:172
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:233
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
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:175
KIGFX::VIEW * m_view
Definition: drawing_tool.h:223
PCB_BASE_EDIT_FRAME * frame() const
PCB_LAYER_ID
A quick note on layer IDs:
const PCBNEW_SELECTION & selection() const
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
Arcs (with rounded ends)
Class TOOL_EVENT.
Definition: tool_event.h:171
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:230
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:224
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
int getSegmentWidth(PCB_LAYER_ID aLayer) const
Returns the appropriate width for a segment depending on the settings.
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:226
static TOOL_ACTION arcPosture
Switch posture when drawing arc.
Definition: pcb_actions.h:178
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:280
EDA_UNITS_T GetUserUnits() const
Return the user units currently in use.
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
static TOOL_ACTION deleteLastPoint
Definition: pcb_actions.h:168
virtual void PopTool(const std::string &actionName)
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
static TOOL_ACTION refreshPreview
Definition: actions.h:101
static TOOL_ACTION cursorClick
Definition: actions.h:115
void SetWidth(int aWidth)

References 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(), ACTIONS::cursorClick, PCB_ACTIONS::decWidth, PCB_ACTIONS::deleteLastPoint, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), getDrawingLayer(), KIGFX::VIEW_CONTROLS::GetMousePosition(), getSegmentWidth(), EDA_BASE_FRAME::GetUserUnits(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::HasGeometryChanged(), PCB_ACTIONS::incWidth, KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::IsComplete(), PCB_ACTIONS::layerChanged, m_controls, m_frame, m_lineWidth, TOOL_INTERACTIVE::m_menu, TOOL_BASE::m_toolMgr, m_view, MD_ALT, MD_CTRL, MD_SHIFT, EDA_BASE_FRAME::PopTool(), ACTIONS::refreshPreview, KIGFX::VIEW::Remove(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::RemoveLastPoint(), TOOL_MANAGER::RunAction(), S_ARC, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, KIGFX::PREVIEW::ARC_GEOM_MANAGER::SetAngleSnap(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), 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 176 of file drawing_tool.cpp.

177 {
178  if( m_editModules && !m_frame->GetModel() )
179  return 0;
180 
181  MODULE* module = dynamic_cast<MODULE*>( m_frame->GetModel() );
182  DRAWSEGMENT* circle = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
183  BOARD_COMMIT commit( m_frame );
184  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::CIRCLE );
185  OPT<VECTOR2D> startingPoint = boost::make_optional<VECTOR2D>( false, VECTOR2D( 0, 0 ) );
186 
187  circle->SetFlags( IS_NEW );
188 
189  if( aEvent.HasPosition() )
190  startingPoint = getViewControls()->GetCursorPosition( !aEvent.Modifier( MD_ALT ) );
191 
192  std::string tool = aEvent.GetCommandStr().get();
193  m_frame->PushTool( tool );
194  Activate();
195 
196  while( drawSegment( tool, S_CIRCLE, circle, startingPoint ) )
197  {
198  if( circle )
199  {
200  if( m_editModules )
201  static_cast<EDGE_MODULE*>( circle )->SetLocalCoord();
202 
203  commit.Add( circle );
204  commit.Push( _( "Draw a circle" ) );
205 
206  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, circle );
207  }
208 
209  circle = m_editModules ? new EDGE_MODULE( module ) : new DRAWSEGMENT;
210  circle->SetFlags( IS_NEW );
211  startingPoint = NULLOPT;
212  }
213 
214  return 0;
215 }
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
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:265
const auto NULLOPT
Definition: optional.h:9
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
#define _(s)
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:226
int Modifier(int aMask=MD_MODIFIER_MASK) const
Returns information about key modifiers state (Ctrl, Alt, etc.)
Definition: tool_event.h:342
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
MODULE * module() const
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:76
boost::optional< T > OPT
Definition: optional.h:7
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
bool drawSegment(const std::string &aTool, int aShape, DRAWSEGMENT *&aGraphic, OPT< VECTOR2D > aStartingPoint)
Starts drawing a selected shape (i.e.
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.

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

Referenced by setTransitions().

◆ DrawDimension()

int DRAWING_TOOL::DrawDimension ( const TOOL_EVENT aEvent)

Function DrawDimension() Starts interactively drawing a dimension.

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

Definition at line 458 of file drawing_tool.cpp.

459 {
460  if( m_editModules && !m_frame->GetModel() )
461  return 0;
462 
463  POINT_EDITOR* pointEditor = m_toolMgr->GetTool<POINT_EDITOR>();
464  DIMENSION* dimension = NULL;
465  BOARD_COMMIT commit( m_frame );
466  GRID_HELPER grid( m_frame );
467 
468  const BOARD_DESIGN_SETTINGS& boardSettings = m_board->GetDesignSettings();
469 
470  // Add a VIEW_GROUP that serves as a preview for the new item
471  PCBNEW_SELECTION preview;
472 
473  m_view->Add( &preview );
474 
476  m_controls->ShowCursor( true );
477  m_controls->SetSnapping( true );
478 
479  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
480 
481  std::string tool = aEvent.GetCommandStr().get();
482  m_frame->PushTool( tool );
483  Activate();
484 
485  enum DIMENSION_STEPS
486  {
487  SET_ORIGIN = 0,
488  SET_END,
489  SET_HEIGHT,
490  FINISHED
491  };
492  int step = SET_ORIGIN;
493 
494  // Prime the pump
496 
497  if( aEvent.HasPosition() )
498  m_toolMgr->PrimeTool( aEvent.Position() );
499 
500  // Main loop: keep receiving events
501  while( TOOL_EVENT* evt = Wait() )
502  {
503  if( !pointEditor->HasPoint() )
504  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
505 
506  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
507  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
508  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
509  VECTOR2I cursorPos = grid.BestSnapAnchor(
510  evt->IsPrime() ? evt->Position() : m_controls->GetMousePosition(), nullptr );
511  m_controls->ForceCursorPosition( true, cursorPos );
512 
513  auto cleanup = [&] () {
514  m_controls->SetAutoPan( false );
515  m_controls->CaptureCursor( false );
516 
517  preview.Clear();
518  m_view->Update( &preview );
519 
520  delete dimension;
521  dimension = nullptr;
522  step = SET_ORIGIN;
523  };
524 
525  if( evt->IsCancelInteractive() )
526  {
527  m_controls->SetAutoPan( false );
528 
529  if( step != SET_ORIGIN ) // start from the beginning
530  cleanup();
531  else
532  {
533  m_frame->PopTool( tool );
534  break;
535  }
536  }
537  else if( evt->IsActivate() )
538  {
539  if( step != SET_ORIGIN )
540  cleanup();
541 
542  if( evt->IsPointEditor() )
543  {
544  // don't exit (the point editor runs in the background)
545  }
546  else if( evt->IsMoveTool() )
547  {
548  // leave ourselves on the stack so we come back after the move
549  break;
550  }
551  else
552  {
553  m_frame->PopTool( tool );
554  break;
555  }
556  }
557  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) && step != SET_ORIGIN )
558  {
560  dimension->SetWidth( m_lineWidth );
561  m_view->Update( &preview );
562  frame()->SetMsgPanel( dimension );
563  }
564  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && step != SET_ORIGIN )
565  {
566  if( m_lineWidth > WIDTH_STEP )
567  {
569  dimension->SetWidth( m_lineWidth );
570  m_view->Update( &preview );
571  frame()->SetMsgPanel( dimension );
572  }
573  }
574  else if( evt->IsClick( BUT_RIGHT ) )
575  {
577  }
578  else if( evt->IsClick( BUT_LEFT ) )
579  {
580  switch( step )
581  {
582  case SET_ORIGIN:
583  {
585 
586  PCB_LAYER_ID layer = getDrawingLayer();
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, boardSettings.m_DimensionPrecision );
595  dimension->SetEnd( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
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( boardSettings.m_DimensionUnits == 2 ? MILLIMETRES : INCHES,
601  boardSettings.m_DimensionUnits == 1 );
602  dimension->AdjustDimensionDetails( boardSettings.m_DimensionPrecision );
603 
604  preview.Add( dimension );
605  frame()->SetMsgPanel( dimension );
606 
607  m_controls->SetAutoPan( true );
608  m_controls->CaptureCursor( true );
609  }
610  break;
611 
612  case SET_END:
613  dimension->SetEnd( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
614 
615  if( !!evt->Modifier( MD_CTRL ) )
616  constrainDimension( dimension );
617 
618  // Dimensions that have origin and end in the same spot are not valid
619  if( dimension->GetOrigin() == dimension->GetEnd() )
620  --step;
621 
622  break;
623 
624  case SET_HEIGHT:
625  {
626  if( (wxPoint) cursorPos != dimension->GetPosition() )
627  {
628  assert( dimension->GetOrigin() != dimension->GetEnd() );
629  assert( dimension->GetWidth() > 0 );
630 
631  preview.Remove( dimension );
632 
633  commit.Add( dimension );
634  commit.Push( _( "Draw a dimension" ) );
635 
636  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, dimension );
637  }
638  }
639  break;
640  }
641 
642  if( ++step == FINISHED )
643  {
644  step = SET_ORIGIN;
645  m_controls->SetAutoPan( false );
646  m_controls->CaptureCursor( false );
647  }
648  }
649  else if( evt->IsMotion() )
650  {
651  switch( step )
652  {
653  case SET_END:
654  dimension->SetEnd( (wxPoint) cursorPos, boardSettings.m_DimensionPrecision );
655 
656  if( !!evt->Modifier( MD_CTRL ) )
657  constrainDimension( dimension );
658 
659  break;
660 
661  case SET_HEIGHT:
662  {
663  // Calculating the direction of travel perpendicular to the selected axis
664  double angle = dimension->GetAngle() + ( M_PI / 2 );
665 
666  wxPoint delta( (wxPoint) cursorPos - dimension->m_featureLineDO );
667  double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
668  dimension->SetHeight( height, boardSettings.m_DimensionPrecision );
669  }
670  break;
671  }
672 
673  // Show a preview of the item
674  m_view->Update( &preview );
675  if( step )
676  frame()->SetMsgPanel( dimension );
677  else
678  frame()->SetMsgPanel( board() );
679  }
680  else
681  evt->SetPassEvent();
682  }
683 
684  if( step != SET_ORIGIN )
685  delete dimension;
686 
687  m_controls->SetAutoPan( false );
689  m_controls->CaptureCursor( false );
690 
691  m_view->Remove( &preview );
692  frame()->SetMsgPanel( board() );
693  return 0;
694 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:93
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
BOARD * board() const
BOARD * m_board
Definition: drawing_tool.h:225
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:172
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:233
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
void PrimeTool(const VECTOR2D &aPosition)
Function PrimeTool() "Primes" a tool by sending a cursor left-click event with the mouse position set...
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:531
int GetTextThickness(PCB_LAYER_ID aLayer) const
Function GetTextThickness Returns the default text thickness from the layer class for the given layer...
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:175
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
KIGFX::VIEW * m_view
Definition: drawing_tool.h:223
void constrainDimension(DIMENSION *aDim)
Function constrainDimension() Forces the dimension lime to be drawn on multiple of 45 degrees.
PCB_BASE_EDIT_FRAME * frame() const
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:
RAII class that sets an value at construction and resets it to the original value at destruction.
const PCBNEW_SELECTION & selection() const
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
Definition: common.h:134
Class TOOL_EVENT.
Definition: tool_event.h:171
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:230
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:224
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
#define _(s)
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:226
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:76
bool HasPoint()
Indicates the cursor is over an edit point.
Definition: point_editor.h:65
Class POINT_EDITOR.
Definition: point_editor.h:43
virtual void PopTool(const std::string &actionName)
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:346
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Function GetTextSize Returns the default text size from the layer class for the given layer.
Class DIMENSION.
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:274
static TOOL_ACTION refreshPreview
Definition: actions.h:101
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(), PNS::angle(), GRID_HELPER::BestSnapAnchor(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), constrainDimension(), PCB_ACTIONS::decWidth, DIMENSION, Dwgs_User, Edge_Cuts, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), BOARD::GetDesignSettings(), getDrawingLayer(), BOARD_DESIGN_SETTINGS::GetLineThickness(), PCB_BASE_EDIT_FRAME::GetModel(), KIGFX::VIEW_CONTROLS::GetMousePosition(), BOARD_DESIGN_SETTINGS::GetTextItalic(), BOARD_DESIGN_SETTINGS::GetTextSize(), BOARD_DESIGN_SETTINGS::GetTextThickness(), TOOL_MANAGER::GetTool(), POINT_EDITOR::HasPoint(), TOOL_EVENT::HasPosition(), INCHES, PCB_ACTIONS::incWidth, m_board, m_controls, BOARD_DESIGN_SETTINGS::m_DimensionPrecision, BOARD_DESIGN_SETTINGS::m_DimensionUnits, PCB_TOOL_BASE::m_editModules, m_frame, m_lineWidth, TOOL_INTERACTIVE::m_menu, m_mode, TOOL_BASE::m_toolMgr, m_view, MD_ALT, MD_CTRL, MD_SHIFT, MILLIMETRES, EDA_BASE_FRAME::PopTool(), TOOL_EVENT::Position(), TOOL_MANAGER::PrimeTool(), BOARD_COMMIT::Push(), EDA_BASE_FRAME::PushTool(), ACTIONS::refreshPreview, SELECTION::Remove(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), EDA_DRAW_FRAME::SetMsgPanel(), GRID_HELPER::SetSnap(), KIGFX::VIEW_CONTROLS::SetSnapping(), GRID_HELPER::SetUseGrid(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), and WIDTH_STEP.

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

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

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

Referenced by setTransitions().

◆ drawSegment()

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

Starts drawing a selected shape (i.e.

DRAWSEGMENT).

Parameters
aShapeis the type of created shape (
See also
STROKE_T).
Parameters
aGraphicis an object that is going to be used by the tool for drawing. 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 903 of file drawing_tool.cpp.

905 {
906  // Only two shapes are currently supported
907  assert( aShape == S_SEGMENT || aShape == S_CIRCLE );
908  GRID_HELPER grid( m_frame );
909  POINT_EDITOR* pointEditor = m_toolMgr->GetTool<POINT_EDITOR>();
910 
913 
914  // Add a VIEW_GROUP that serves as a preview for the new item
915  PCBNEW_SELECTION preview;
916  m_view->Add( &preview );
917 
918  m_controls->ShowCursor( true );
919 
920  bool direction45 = false; // 45 degrees only mode
921  bool started = false;
922  bool cancelled = false;
923  bool isLocalOriginSet = ( m_frame->GetScreen()->m_LocalOrigin != VECTOR2D( 0, 0 ) );
924  VECTOR2I cursorPos = m_controls->GetMousePosition();
925 
926  // Prime the pump
928 
929  if( aStartingPoint )
931 
932  // Main loop: keep receiving events
933  while( TOOL_EVENT* evt = Wait() )
934  {
935  if( !pointEditor->HasPoint() )
936  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
937 
938  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
939  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
940  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
941  cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), getDrawingLayer() );
942  m_controls->ForceCursorPosition( true, cursorPos );
943 
944  // 45 degree angle constraint enabled with an option and toggled with Ctrl
945  bool limit45 = frame()->Settings().m_Use45DegreeGraphicSegments;
946 
947  if( evt->Modifier( MD_CTRL ) )
948  limit45 = !limit45;
949 
950  if( direction45 != limit45 && started && aShape == S_SEGMENT )
951  {
952  direction45 = limit45;
953 
954  if( direction45 )
955  {
956  const VECTOR2I lineVector( cursorPos - VECTOR2I( aGraphic->GetStart() ) );
957 
958  // get a restricted 45/H/V line from the last fixed point to the cursor
959  auto newEnd = GetVectorSnapped45( lineVector );
960  aGraphic->SetEnd( aGraphic->GetStart() + (wxPoint) newEnd );
961  m_controls->ForceCursorPosition( true, VECTOR2I( aGraphic->GetEnd() ) );
962  }
963  else
964  {
965  aGraphic->SetEnd( (wxPoint) cursorPos );
966  }
967 
968  m_view->Update( &preview );
969  frame()->SetMsgPanel( aGraphic );
970  }
971 
972  auto cleanup = [&] () {
973  preview.Clear();
974  m_view->Update( &preview );
975  delete aGraphic;
976  aGraphic = nullptr;
977 
978  if( !isLocalOriginSet )
979  m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
980  };
981 
982  if( evt->IsCancelInteractive() )
983  {
984  if( started )
985  cleanup();
986  else
987  {
988  m_frame->PopTool( aTool );
989  cancelled = true;
990  }
991 
992  break;
993  }
994  else if( evt->IsActivate() )
995  {
996  if( evt->IsPointEditor() )
997  {
998  // don't exit (the point editor runs in the background)
999  }
1000  else if( evt->IsMoveTool() )
1001  {
1002  if( started )
1003  cleanup();
1004 
1005  // leave ourselves on the stack so we come back after the move
1006  cancelled = true;
1007  break;
1008  }
1009  else
1010  {
1011  if( started )
1012  cleanup();
1013 
1014  m_frame->PopTool( aTool );
1015  cancelled = true;
1016  break;
1017  }
1018  }
1019  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1020  {
1022  aGraphic->SetLayer( getDrawingLayer() );
1023  aGraphic->SetWidth( m_lineWidth );
1024  m_view->Update( &preview );
1025  frame()->SetMsgPanel( aGraphic );
1026  }
1027  else if( evt->IsClick( BUT_RIGHT ) )
1028  {
1030  }
1031  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
1032  {
1033  if( !started )
1034  {
1036 
1037  if( aStartingPoint )
1038  {
1039  cursorPos = aStartingPoint.get();
1040  aStartingPoint = NULLOPT;
1041  }
1042 
1044 
1045  // Init the new item attributes
1046  aGraphic->SetShape( (STROKE_T) aShape );
1047  aGraphic->SetWidth( m_lineWidth );
1048  aGraphic->SetStart( (wxPoint) cursorPos );
1049  aGraphic->SetEnd( (wxPoint) cursorPos );
1050  aGraphic->SetLayer( getDrawingLayer() );
1051 
1052  if( !isLocalOriginSet )
1053  m_frame->GetScreen()->m_LocalOrigin = cursorPos;
1054 
1055  preview.Add( aGraphic );
1056  frame()->SetMsgPanel( aGraphic );
1057  m_controls->SetAutoPan( true );
1058  m_controls->CaptureCursor( true );
1059 
1060  started = true;
1061  }
1062  else
1063  {
1064  auto snapItem = dyn_cast<DRAWSEGMENT*>( grid.GetSnapped() );
1065 
1066  if( aGraphic->GetEnd() == aGraphic->GetStart()
1067  || ( evt->IsDblClick( BUT_LEFT ) && aShape == S_SEGMENT )
1068  || snapItem )
1069  // User has clicked twice in the same spot
1070  // or clicked on the end of an existing segment (closing a path)
1071  {
1072  BOARD_COMMIT commit( m_frame );
1073 
1074  // If the user clicks on an existing snap point from a drawsegment
1075  // we finish the segment as they are likely closing a path
1076  if( snapItem && aGraphic->GetLength() > 0.0 )
1077  {
1078  commit.Add( aGraphic );
1079  commit.Push( _( "Draw a line segment" ) );
1080  m_toolMgr->RunAction( PCB_ACTIONS::selectItem, true, aGraphic );
1081  }
1082  else
1083  {
1084  delete aGraphic;
1085  }
1086 
1087  aGraphic = nullptr;
1088  }
1089 
1090  preview.Clear();
1091  break;
1092  }
1093  }
1094  else if( evt->IsMotion() )
1095  {
1096  // 45 degree lines
1097  if( direction45 && aShape == S_SEGMENT )
1098  {
1099  const VECTOR2I lineVector( cursorPos - VECTOR2I( aGraphic->GetStart() ) );
1100 
1101  // get a restricted 45/H/V line from the last fixed point to the cursor
1102  auto newEnd = GetVectorSnapped45( lineVector );
1103  aGraphic->SetEnd( aGraphic->GetStart() + (wxPoint) newEnd );
1104  m_controls->ForceCursorPosition( true, VECTOR2I( aGraphic->GetEnd() ) );
1105  }
1106  else
1107  aGraphic->SetEnd( (wxPoint) cursorPos );
1108 
1109  m_view->Update( &preview );
1110 
1111  if( started )
1112  frame()->SetMsgPanel( aGraphic );
1113  else
1114  frame()->SetMsgPanel( board() );
1115  }
1116  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1117  {
1119  aGraphic->SetWidth( m_lineWidth );
1120  m_view->Update( &preview );
1121  frame()->SetMsgPanel( aGraphic );
1122  }
1123  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && ( m_lineWidth > WIDTH_STEP ) )
1124  {
1126  aGraphic->SetWidth( m_lineWidth );
1127  m_view->Update( &preview );
1128  frame()->SetMsgPanel( aGraphic );
1129  }
1130  else if( evt->IsAction( &ACTIONS::resetLocalCoords ) )
1131  {
1132  isLocalOriginSet = true;
1133  }
1134  else
1135  evt->SetPassEvent();
1136  }
1137 
1138  if( !isLocalOriginSet ) // reset the relative coordinte if it was not set before
1139  m_frame->GetScreen()->m_LocalOrigin = VECTOR2D( 0, 0 );
1140 
1141  m_view->Remove( &preview );
1142  frame()->SetMsgPanel( board() );
1143  m_controls->SetAutoPan( false );
1144  m_controls->CaptureCursor( false );
1145  m_controls->ForceCursorPosition( false );
1146 
1147  return !cancelled;
1148 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
void SetShape(STROKE_T aShape)
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:93
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
BOARD * board() const
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:172
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:233
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
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.
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:175
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
KIGFX::VIEW * m_view
Definition: drawing_tool.h:223
PCB_BASE_EDIT_FRAME * frame() const
const PCBNEW_SELECTION & selection() const
const auto NULLOPT
Definition: optional.h:9
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
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()
Class TOOL_EVENT.
Definition: tool_event.h:171
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:230
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:224
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
#define _(s)
int getSegmentWidth(PCB_LAYER_ID aLayer) const
Returns the appropriate width for a segment depending on the settings.
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
void SetStart(const wxPoint &aStart)
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:226
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:280
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
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:76
bool HasPoint()
Indicates the cursor is over an edit point.
Definition: point_editor.h:65
Class POINT_EDITOR.
Definition: point_editor.h:43
static TOOL_ACTION resetLocalCoords
Definition: actions.h:140
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SetEnd(const wxPoint &aEnd)
virtual void PopTool(const std::string &actionName)
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
static TOOL_ACTION refreshPreview
Definition: actions.h:101
static TOOL_ACTION cursorClick
Definition: actions.h:115
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:114
void SetWidth(int aWidth)

References _, SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), GRID_HELPER::BestSnapAnchor(), PCB_TOOL_BASE::board(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), ACTIONS::cursorClick, PCB_ACTIONS::decWidth, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetCanvas(), getDrawingLayer(), DRAWSEGMENT::GetEnd(), DRAWSEGMENT::GetLength(), KIGFX::VIEW_CONTROLS::GetMousePosition(), PCB_BASE_FRAME::GetScreen(), getSegmentWidth(), GRID_HELPER::GetSnapped(), DRAWSEGMENT::GetStart(), TOOL_MANAGER::GetTool(), GetVectorSnapped45(), POINT_EDITOR::HasPoint(), PCB_ACTIONS::incWidth, PCB_ACTIONS::layerChanged, m_controls, m_frame, m_lineWidth, BASE_SCREEN::m_LocalOrigin, TOOL_INTERACTIVE::m_menu, TOOL_BASE::m_toolMgr, PCB_GENERAL_SETTINGS::m_Use45DegreeGraphicSegments, m_view, MD_ALT, MD_CTRL, MD_SHIFT, NULLOPT, EDA_BASE_FRAME::PopTool(), BOARD_COMMIT::Push(), ACTIONS::refreshPreview, KIGFX::VIEW::Remove(), ACTIONS::resetLocalCoords, TOOL_MANAGER::RunAction(), S_CIRCLE, S_SEGMENT, PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, PCB_BASE_FRAME::SetActiveLayer(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), 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(), and WIDTH_STEP.

Referenced by DrawCircle(), and DrawLine().

◆ DrawVia()

int DRAWING_TOOL::DrawVia ( const TOOL_EVENT aEvent)

Definition at line 1583 of file drawing_tool.cpp.

1584 {
1585  struct VIA_PLACER : public INTERACTIVE_PLACER_BASE
1586  {
1587  GRID_HELPER m_gridHelper;
1588 
1589  VIA_PLACER( PCB_BASE_EDIT_FRAME* aFrame ) : m_gridHelper( aFrame )
1590  {}
1591 
1592  TRACK* findTrack( VIA* aVia )
1593  {
1594  const LSET lset = aVia->GetLayerSet();
1595  wxPoint position = aVia->GetPosition();
1596  BOX2I bbox = aVia->GetBoundingBox();
1597 
1598  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
1599  auto view = m_frame->GetCanvas()->GetView();
1600  std::vector<TRACK*> possible_tracks;
1601 
1602  view->Query( bbox, items );
1603 
1604  for( auto it : items )
1605  {
1606  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
1607 
1608  if( !(item->GetLayerSet() & lset ).any() )
1609  continue;
1610 
1611  if( auto track = dyn_cast<TRACK*>( item ) )
1612  {
1613  if( TestSegmentHit( position, track->GetStart(), track->GetEnd(),
1614  ( track->GetWidth() + aVia->GetWidth() ) / 2 ) )
1615  possible_tracks.push_back( track );
1616  }
1617  }
1618 
1619  TRACK* return_track = nullptr;
1620  int min_d = std::numeric_limits<int>::max();
1621  for( auto track : possible_tracks )
1622  {
1623  SEG test( track->GetStart(), track->GetEnd() );
1624  auto dist = ( test.NearestPoint( position ) - position ).EuclideanNorm();
1625 
1626  if( dist < min_d )
1627  {
1628  min_d = dist;
1629  return_track = track;
1630  }
1631  }
1632 
1633  return return_track;
1634  }
1635 
1636 
1637  bool hasDRCViolation( VIA* aVia )
1638  {
1639  const LSET lset = aVia->GetLayerSet();
1640  wxPoint position = aVia->GetPosition();
1641  int drillRadius = aVia->GetDrillValue() / 2;
1642  BOX2I bbox = aVia->GetBoundingBox();
1643 
1644  std::vector<KIGFX::VIEW::LAYER_ITEM_PAIR> items;
1645  int net = 0;
1646  int clearance = 0;
1647  auto view = m_frame->GetCanvas()->GetView();
1648  int holeToHoleMin = m_frame->GetBoard()->GetDesignSettings().m_HoleToHoleMin;
1649 
1650  view->Query( bbox, items );
1651 
1652  for( auto it : items )
1653  {
1654  BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it.first );
1655 
1656  if( !(item->GetLayerSet() & lset ).any() )
1657  continue;
1658 
1659  if( auto track = dyn_cast<TRACK*>( item ) )
1660  {
1661  int max_clearance = std::max( clearance, track->GetClearance() );
1662 
1663  if( TestSegmentHit( position, track->GetStart(), track->GetEnd(),
1664  ( track->GetWidth() + aVia->GetWidth() ) / 2 + max_clearance ) )
1665  {
1666  if( net && track->GetNetCode() != net )
1667  return true;
1668 
1669  net = track->GetNetCode();
1670  clearance = track->GetClearance();
1671  }
1672  }
1673 
1674  if( auto via = dyn_cast<VIA*>( item ) )
1675  {
1676  int dist = KiROUND( GetLineLength( position, via->GetPosition() ) );
1677 
1678  if( dist < drillRadius + via->GetDrillValue() / 2 + holeToHoleMin )
1679  return true;
1680  }
1681 
1682  if( auto mod = dyn_cast<MODULE*>( item ) )
1683  {
1684  for( D_PAD* pad : mod->Pads() )
1685  {
1686  int max_clearance = std::max( clearance, pad->GetClearance() );
1687 
1688  if( pad->HitTest( aVia->GetBoundingBox(), false, max_clearance ) )
1689  {
1690  if( net && pad->GetNetCode() != net )
1691  return true;
1692 
1693  net = pad->GetNetCode();
1694  clearance = pad->GetClearance();
1695  }
1696 
1697  if( pad->GetDrillSize().x && pad->GetDrillShape() == PAD_DRILL_SHAPE_CIRCLE )
1698  {
1699  int dist = KiROUND( GetLineLength( position, pad->GetPosition() ) );
1700 
1701  if( dist < drillRadius + pad->GetDrillSize().x / 2 + holeToHoleMin )
1702  return true;
1703  }
1704  }
1705  }
1706  }
1707 
1708  return false;
1709  }
1710 
1711 
1712  int findStitchedZoneNet( VIA* aVia )
1713  {
1714  const wxPoint position = aVia->GetPosition();
1715  const LSET lset = aVia->GetLayerSet();
1716 
1717  for( auto mod : m_board->Modules() )
1718  {
1719  for( D_PAD* pad : mod->Pads() )
1720  {
1721  if( pad->HitTest( position ) && ( pad->GetLayerSet() & lset ).any() )
1722  return -1;
1723  }
1724  }
1725 
1726  std::vector<ZONE_CONTAINER*> foundZones;
1727 
1728  for( ZONE_CONTAINER* zone : m_board->Zones() )
1729  {
1730  if( zone->HitTestFilledArea( position ) )
1731  foundZones.push_back( zone );
1732  }
1733 
1734  std::sort( foundZones.begin(), foundZones.end(),
1735  [] ( const ZONE_CONTAINER* a, const ZONE_CONTAINER* b )
1736  {
1737  return a->GetLayer() < b->GetLayer();
1738  } );
1739 
1740  // first take the net of the active layer
1741  for( ZONE_CONTAINER* z : foundZones )
1742  {
1743  if( m_frame->GetActiveLayer() == z->GetLayer() )
1744  return z->GetNetCode();
1745  }
1746 
1747  // none? take the topmost visible layer
1748  for( ZONE_CONTAINER* z : foundZones )
1749  {
1750  if( m_board->IsLayerVisible( z->GetLayer() ) )
1751  return z->GetNetCode();
1752  }
1753 
1754  return -1;
1755  }
1756 
1757  void SnapItem( BOARD_ITEM *aItem ) override
1758  {
1759  // If you place a Via on a track but not on its centerline, the current
1760  // connectivity algorithm will require us to put a kink in the track when
1761  // we break it (so that each of the two segments ends on the via center).
1762  // That's not ideal, and is in fact probably worse than forcing snap in
1763  // this situation.
1764 
1765  m_gridHelper.SetSnap( !( m_modifiers & MD_SHIFT ) );
1766  auto via = static_cast<VIA*>( aItem );
1767  wxPoint position = via->GetPosition();
1768  TRACK* track = findTrack( via );
1769 
1770  if( track )
1771  {
1772  SEG trackSeg( track->GetStart(), track->GetEnd() );
1773  VECTOR2I snap = m_gridHelper.AlignToSegment( position, trackSeg );
1774 
1775  aItem->SetPosition( (wxPoint) snap );
1776  }
1777  }
1778 
1779  bool PlaceItem( BOARD_ITEM* aItem, BOARD_COMMIT& aCommit ) override
1780  {
1781  VIA* via = static_cast<VIA*>( aItem );
1782  wxPoint viaPos = via->GetPosition();
1783  int newNet;
1784  TRACK* track = findTrack( via );
1785 
1786  if( hasDRCViolation( via ) )
1787  return false;
1788 
1789  if( track )
1790  {
1791  if( viaPos != track->GetStart() && viaPos != track->GetEnd() )
1792  {
1793  aCommit.Modify( track );
1794  TRACK* newTrack = dynamic_cast<TRACK*>( track->Clone() );
1795  track->SetEnd( viaPos );
1796  newTrack->SetStart( viaPos );
1797  aCommit.Add( newTrack );
1798  }
1799 
1800  newNet = track->GetNetCode();
1801  }
1802  else
1803  newNet = findStitchedZoneNet( via );
1804 
1805  if( newNet > 0 )
1806  via->SetNetCode( newNet );
1807 
1808  aCommit.Add( aItem );
1809  return true;
1810  }
1811 
1812  std::unique_ptr<BOARD_ITEM> CreateItem() override
1813  {
1814  auto& ds = m_board->GetDesignSettings();
1815  VIA* via = new VIA( m_board );
1816 
1817  via->SetNetCode( 0 );
1818  via->SetViaType( ds.m_CurrentViaType );
1819 
1820  // for microvias, the size and hole will be changed later.
1821  via->SetWidth( ds.GetCurrentViaSize() );
1822  via->SetDrill( ds.GetCurrentViaDrill() );
1823 
1824  // Usual via is from copper to component.
1825  // layer pair is B_Cu and F_Cu.
1826  via->SetLayerPair( B_Cu, F_Cu );
1827 
1828  PCB_LAYER_ID first_layer = m_frame->GetActiveLayer();
1829  PCB_LAYER_ID last_layer;
1830 
1831  // prepare switch to new active layer:
1832  if( first_layer != m_frame->GetScreen()->m_Route_Layer_TOP )
1833  last_layer = m_frame->GetScreen()->m_Route_Layer_TOP;
1834  else
1835  last_layer = m_frame->GetScreen()->m_Route_Layer_BOTTOM;
1836 
1837  // Adjust the actual via layer pair
1838  switch( via->GetViaType() )
1839  {
1840  case VIA_BLIND_BURIED:
1841  via->SetLayerPair( first_layer, last_layer );
1842  break;
1843 
1844  case VIA_MICROVIA: // from external to the near neighbor inner layer
1845  {
1846  PCB_LAYER_ID last_inner_layer =
1847  ToLAYER_ID( ( m_board->GetCopperLayerCount() - 2 ) );
1848 
1849  if( first_layer == B_Cu )
1850  last_layer = last_inner_layer;
1851  else if( first_layer == F_Cu )
1852  last_layer = In1_Cu;
1853  else if( first_layer == last_inner_layer )
1854  last_layer = B_Cu;
1855  else if( first_layer == In1_Cu )
1856  last_layer = F_Cu;
1857 
1858  // else error: will be removed later
1859  via->SetLayerPair( first_layer, last_layer );
1860 
1861  // Update diameter and hole size, which where set previously
1862  // for normal vias
1863  NETINFO_ITEM* net = via->GetNet();
1864 
1865  if( net )
1866  {
1867  via->SetWidth( net->GetMicroViaSize() );
1868  via->SetDrill( net->GetMicroViaDrillSize() );
1869  }
1870  }
1871  break;
1872 
1873  default:
1874  break;
1875  }
1876 
1877  return std::unique_ptr<BOARD_ITEM>( via );
1878  }
1879  };
1880 
1881  VIA_PLACER placer( frame() );
1882 
1883  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
1884 
1885  doInteractiveItemPlacement( aEvent.GetCommandStr().get(), &placer, _( "Place via" ),
1887 
1888  return 0;
1889 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:123
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
int GetNetCode() const
Function GetNetCode.
double GetLineLength(const wxPoint &aPointA, const wxPoint &aPointB)
Function GetLineLength returns the length of a line segment defined by aPointA and aPointB.
Definition: trigo.h:202
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:225
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:347
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:105
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:109
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:203
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
virtual EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: class_track.cpp:68
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:531
void SetWidth(int aWidth)
Definition: class_track.h:102
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID
A quick note on layer IDs:
int m_HoleToHoleMin
Min width of peninsula between two drilled holes.
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.
int GetDrillValue() const
Function GetDrillValue "calculates" the drill value for vias (m-Drill if > 0, or default drill value ...
MODULES & Modules()
Definition: class_board.h:227
KIGFX::PCB_VIEW * view() const
VIATYPE_T GetViaType() const
Definition: class_track.h:346
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:46
bool SetNetCode(int aNetCode, bool aNoAssert=false)
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.
#define _(s)
const wxPoint GetPosition() const override
Definition: class_track.h:319
virtual KIGFX::PCB_VIEW * GetView() const override
Function GetView() Returns a pointer to the VIEW instance used in the panel.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:226
void SetSnap(bool aSnap)
Definition: grid_helper.h:66
Definition: seg.h:36
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
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:450
ZONE_CONTAINERS & Zones()
Definition: class_board.h:241
int GetWidth() const
Definition: class_track.h:103
Common, abstract interface for edit frames.
#define max(a, b)
Definition: auxiliary.h:86
int GetCopperLayerCount() const
Function GetCopperLayerCount.
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:354
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:106
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:108
virtual int Query(const BOX2I &aRect, std::vector< LAYER_ITEM_PAIR > &aResult) const
Function Query() Finds all visible items that touch or are within the rectangle aRect.
Definition: view.cpp:452
void doInteractiveItemPlacement(const std::string &aTool, INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
Helper function for performing a common interactive idiom: wait for a left click, place an item there...
BOARD * GetBoard() const
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:127
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...
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:114

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

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

Definition at line 1383 of file drawing_tool.cpp.

1384 {
1385  if( m_editModules && !m_frame->GetModel() )
1386  return 0;
1387 
1388  ZONE_MODE zoneMode = aEvent.Parameter<ZONE_MODE>();
1389  MODE drawMode = MODE::ZONE;
1390 
1391  if( aEvent.IsAction( &PCB_ACTIONS::drawZoneKeepout ) )
1392  drawMode = MODE::KEEPOUT;
1393 
1394  if( aEvent.IsAction( &PCB_ACTIONS::drawPolygon ) )
1395  drawMode = MODE::GRAPHIC_POLYGON;
1396 
1397  SCOPED_DRAW_MODE scopedDrawMode( m_mode, drawMode );
1398 
1399  // get a source zone, if we need one. We need it for:
1400  // ZONE_MODE::CUTOUT (adding a hole to the source zone)
1401  // ZONE_MODE::SIMILAR (creating a new zone using settings of source zone
1402  ZONE_CONTAINER* sourceZone = nullptr;
1403 
1404  if( !getSourceZoneForAction( zoneMode, sourceZone ) )
1405  return 0;
1406 
1408 
1409  params.m_keepout = drawMode == MODE::KEEPOUT;
1410  params.m_mode = zoneMode;
1411  params.m_sourceZone = sourceZone;
1412 
1413  if( zoneMode == ZONE_MODE::GRAPHIC_POLYGON )
1414  params.m_layer = getDrawingLayer();
1415  else if( zoneMode == ZONE_MODE::SIMILAR )
1416  params.m_layer = sourceZone->GetLayer();
1417  else
1418  params.m_layer = m_frame->GetActiveLayer();
1419 
1420  ZONE_CREATE_HELPER zoneTool( *this, params );
1421 
1422  // the geometry manager which handles the zone geometry, and
1423  // hands the calculated points over to the zone creator tool
1424  POLYGON_GEOM_MANAGER polyGeomMgr( zoneTool );
1425  bool constrainAngle = false;
1426 
1427  std::string tool = aEvent.GetCommandStr().get();
1428  m_frame->PushTool( tool );
1429  Activate(); // register for events
1430 
1431  m_controls->ShowCursor( true );
1432  m_controls->SetSnapping( true );
1433 
1434  bool started = false;
1435  GRID_HELPER grid( m_frame );
1436  STATUS_TEXT_POPUP status( m_frame );
1437  status.SetTextColor( wxColour( 255, 0, 0 ) );
1438  status.SetText( _( "Self-intersecting polygons are not allowed" ) );
1439 
1440  // Prime the pump
1441  if( aEvent.HasPosition() )
1442  m_toolMgr->PrimeTool( aEvent.Position() );
1443 
1444  // Main loop: keep receiving events
1445  while( TOOL_EVENT* evt = Wait() )
1446  {
1447  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
1448  LSET layers( m_frame->GetActiveLayer() );
1449  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1450  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1451  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1452  VECTOR2I cursorPos = grid.BestSnapAnchor(
1453  evt->IsPrime() ? evt->Position() : m_controls->GetMousePosition(), layers );
1454  m_controls->ForceCursorPosition( true, cursorPos );
1455 
1456  if( ( sourceZone && sourceZone->GetHV45() ) || constrainAngle || evt->Modifier( MD_CTRL ) )
1457  polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45 );
1458  else
1459  polyGeomMgr.SetLeaderMode( POLYGON_GEOM_MANAGER::LEADER_MODE::DIRECT );
1460 
1461  auto cleanup = [&] () {
1462  polyGeomMgr.Reset();
1463  started = false;
1464  m_controls->SetAutoPan( false );
1465  m_controls->CaptureCursor( false );
1466  };
1467 
1468  if( evt->IsCancelInteractive())
1469  {
1470  if( polyGeomMgr.IsPolygonInProgress() )
1471  cleanup();
1472  else
1473  {
1474  m_frame->PopTool( tool );
1475  break;
1476  }
1477  }
1478  else if( evt->IsActivate() )
1479  {
1480  if( polyGeomMgr.IsPolygonInProgress() )
1481  cleanup();
1482 
1483  if( evt->IsPointEditor() )
1484  {
1485  // don't exit (the point editor runs in the background)
1486  }
1487  else if( evt->IsMoveTool() )
1488  {
1489  // leave ourselves on the stack so we come back after the move
1490  break;
1491  }
1492  else
1493  {
1494  m_frame->PopTool( tool );
1495  break;
1496  }
1497  }
1498  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1499  {
1500  if( zoneMode == ZONE_MODE::GRAPHIC_POLYGON )
1501  params.m_layer = getDrawingLayer();
1502  else if( zoneMode == ZONE_MODE::ADD || zoneMode == ZONE_MODE::CUTOUT )
1503  params.m_layer = frame()->GetActiveLayer();
1504  }
1505  else if( evt->IsClick( BUT_RIGHT ) )
1506  {
1508  }
1509  // events that lock in nodes
1510  else if( evt->IsClick( BUT_LEFT )
1511  || evt->IsDblClick( BUT_LEFT )
1512  || evt->IsAction( &PCB_ACTIONS::closeZoneOutline ) )
1513  {
1514  // Check if it is double click / closing line (so we have to finish the zone)
1515  const bool endPolygon = evt->IsDblClick( BUT_LEFT )
1516  || evt->IsAction( &PCB_ACTIONS::closeZoneOutline )
1517  || polyGeomMgr.NewPointClosesOutline( cursorPos );
1518 
1519  if( endPolygon )
1520  {
1521  polyGeomMgr.SetFinished();
1522  polyGeomMgr.Reset();
1523 
1524  started = false;
1525  m_controls->SetAutoPan( false );
1526  m_controls->CaptureCursor( false );
1527  }
1528 
1529  // adding a corner
1530  else if( polyGeomMgr.AddPoint( cursorPos ) )
1531  {
1532  if( !started )
1533  {
1534  started = true;
1535  constrainAngle = ( polyGeomMgr.GetLeaderMode() ==
1537  m_controls->SetAutoPan( true );
1538  m_controls->CaptureCursor( true );
1539  }
1540  }
1541  }
1542  else if( evt->IsAction( &PCB_ACTIONS::deleteLastPoint ) )
1543  {
1544  polyGeomMgr.DeleteLastCorner();
1545 
1546  if( !polyGeomMgr.IsPolygonInProgress() )
1547  {
1548  // report finished as an empty shape
1549  polyGeomMgr.SetFinished();
1550 
1551  // start again
1552  started = false;
1553  m_controls->SetAutoPan( false );
1554  m_controls->CaptureCursor( false );
1555  }
1556  }
1557  else if( polyGeomMgr.IsPolygonInProgress()
1558  && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
1559  {
1560  polyGeomMgr.SetCursorPosition( cursorPos );
1561 
1562  if( polyGeomMgr.IsSelfIntersecting( true ) )
1563  {
1564  wxPoint p = wxGetMousePosition() + wxPoint( 20, 20 );
1565  status.Move( p );
1566  status.PopupFor( 1500 );
1567  }
1568  else
1569  {
1570  status.Hide();
1571  }
1572  }
1573  else
1574  evt->SetPassEvent();
1575 
1576  } // end while
1577 
1578  m_controls->ForceCursorPosition( false );
1579  return 0;
1580 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
Add a new zone with the same settings as an existing one.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
Class STATUS_TEXT_POPUP.
Definition: status_popup.h:79
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
static TOOL_ACTION drawZoneKeepout
Definition: pcb_actions.h:161
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:203
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
PCB_LAYER_ID m_layer
Layer to begin drawing
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:154
void PrimeTool(const VECTOR2D &aPosition)
Function PrimeTool() "Primes" a tool by sending a cursor left-click event with the mouse position set...
bool getSourceZoneForAction(ZONE_MODE aMode, ZONE_CONTAINER *&aZone)
Draws a polygon, that is added as a zone or a keepout area.
Parameters used to fully describe a zone creation process.
bool IsAction(const TOOL_ACTION *aAction) const
Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_AC...
Definition: tool_event.cpp:67
PCB_BASE_EDIT_FRAME * frame() const
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
Unconstrained point-to-point
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.
const PCBNEW_SELECTION & selection() const
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
T Parameter() const
Function Parameter() Returns a non-standard parameter assigned to the event.
Definition: tool_event.h:435
ZONE_CONTAINER * m_sourceZone
Zone settings source (for similar and cutout zones)
Class TOOL_EVENT.
Definition: tool_event.h:171
Add a new zone/keepout with fresh settings.
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:224
#define _(s)
ZONE_MODE
Definition: pcb_actions.h:47
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg.
Make a cutout to an existing zone.
bool GetHV45() const
Definition: class_zone.h:689
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:226
static TOOL_ACTION closeZoneOutline
Definition: pcb_actions.h:169
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
MODE
The possible drawing modes of DRAWING_TOOL
Definition: drawing_tool.h:62
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:280
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 ...
static TOOL_ACTION deleteLastPoint
Definition: pcb_actions.h:168
virtual void PopTool(const std::string &actionName)
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
bool m_keepout
Should create a keepout zone?
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
Class that handles the drawing of a polygon, including management of last corner deletion and drawing...
const VECTOR2D Position() const
Returns mouse cursor position in world coordinates.
Definition: tool_event.h:274
ZONE_MODE m_mode
The zone mode to operate in

References _, TOOL_INTERACTIVE::Activate(), ADD, POLYGON_GEOM_MANAGER::AddPoint(), GRID_HELPER::BestSnapAnchor(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), PCB_ACTIONS::closeZoneOutline, CUTOUT, POLYGON_GEOM_MANAGER::DEG45, POLYGON_GEOM_MANAGER::DeleteLastCorner(), PCB_ACTIONS::deleteLastPoint, POLYGON_GEOM_MANAGER::DIRECT, PCB_ACTIONS::drawPolygon, PCB_ACTIONS::drawZoneKeepout, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), getDrawingLayer(), ZONE_CONTAINER::GetHV45(), ZONE_CONTAINER::GetLayer(), POLYGON_GEOM_MANAGER::GetLeaderMode(), PCB_BASE_EDIT_FRAME::GetModel(), KIGFX::VIEW_CONTROLS::GetMousePosition(), getSourceZoneForAction(), GRAPHIC_POLYGON, GRAPHIC_POLYGON, TOOL_EVENT::HasPosition(), TOOL_EVENT::IsAction(), POLYGON_GEOM_MANAGER::IsPolygonInProgress(), POLYGON_GEOM_MANAGER::IsSelfIntersecting(), KEEPOUT, PCB_ACTIONS::layerChanged, m_controls, PCB_TOOL_BASE::m_editModules, m_frame, ZONE_CREATE_HELPER::PARAMS::m_keepout, ZONE_CREATE_HELPER::PARAMS::m_layer, TOOL_INTERACTIVE::m_menu, ZONE_CREATE_HELPER::PARAMS::m_mode, m_mode, ZONE_CREATE_HELPER::PARAMS::m_sourceZone, TOOL_BASE::m_toolMgr, MD_ALT, MD_CTRL, MD_SHIFT, STATUS_POPUP::Move(), POLYGON_GEOM_MANAGER::NewPointClosesOutline(), TOOL_EVENT::Parameter(), EDA_BASE_FRAME::PopTool(), STATUS_POPUP::PopupFor(), TOOL_EVENT::Position(), TOOL_MANAGER::PrimeTool(), EDA_BASE_FRAME::PushTool(), POLYGON_GEOM_MANAGER::Reset(), PCB_TOOL_BASE::selection(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), POLYGON_GEOM_MANAGER::SetCursorPosition(), POLYGON_GEOM_MANAGER::SetFinished(), POLYGON_GEOM_MANAGER::SetLeaderMode(), 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, TOOL_INTERACTIVE::Wait(), and ZONE.

Referenced by setTransitions().

◆ EditingModules()

bool PCB_TOOL_BASE::EditingModules ( ) const
inlineinherited

◆ frame()

PCB_BASE_EDIT_FRAME* PCB_TOOL_BASE::frame ( ) const
inlineprotectedinherited

Definition at line 146 of file pcb_tool_base.h.

147  {
148  return getEditFrame<PCB_BASE_EDIT_FRAME>();
149  }

Referenced by POINT_EDITOR::addCorner(), MICROWAVE_TOOL::addMicrowaveFootprint(), AUTOPLACE_TOOL::autoplace(), PCB_TOOL_BASE::canvas(), ZONE_FILLER_TOOL::CheckAllZones(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), ROUTER_TOOL::CustomTrackWidthDialog(), MODULE_EDITOR_TOOLS::DeleteFootprint(), PCB_TOOL_BASE::displayOptions(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), DrawVia(), DrawZone(), PAD_TOOL::EnumeratePads(), PCB_EDITOR_CONTROL::ExportSpecctraDSN(), ROUTER_TOOL::finishInteractive(), EDIT_TOOL::Flip(), PCB_EDITOR_CONTROL::FlipPcbView(), GLOBAL_EDIT_TOOL::GlobalDeletions(), MODULE_EDITOR_TOOLS::ImportFootprint(), PCB_EDITOR_CONTROL::ImportSpecctraSession(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::SelectCopperLayerPair(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), POINT_EDITOR::setEditedPoint(), ROUTER_TOOL::SettingsDialog(), GLOBAL_EDIT_TOOL::swapBoardItem(), GLOBAL_EDIT_TOOL::SwapLayers(), ROUTER_TOOL::switchLayerOnViaPlacement(), POINT_EDITOR::updateItem(), 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 1899 of file drawing_tool.cpp.

1900 {
1901  PCB_LAYER_ID layer = m_frame->GetActiveLayer();
1902 
1904  && IsCopperLayer( layer ) )
1905  {
1906  if( layer == F_Cu )
1907  layer = F_SilkS;
1908  else if( layer == B_Cu )
1909  layer = B_SilkS;
1910  else
1911  layer = Dwgs_User;
1912 
1913  m_frame->SetActiveLayer( layer );
1914  }
1915 
1916  return layer;
1917 }
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:226
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 126 of file drawing_tool.cpp.

127 {
128  return m_mode;
129 }

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

188  {
189 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
190  wxASSERT( dynamic_cast<T*>( getEditFrameInt() ) );
191 #endif
192  return static_cast<T*>( getEditFrameInt() );
193  }
EDA_BASE_FRAME * getEditFrameInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getEditFrameInt().

Referenced by 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 121 of file tool_base.h.

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

References TOOL_BASE::m_toolId.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::isActive(), TOOL_MANAGER::RegisterTool(), ACTION_MANAGER::RunHotKey(), TOOL_MANAGER::runTool(), 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 143 of file tool_base.h.

144  {
145  return m_toolMgr;
146  }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219

References TOOL_BASE::m_toolMgr.

Referenced by BOARD_COMMIT::BOARD_COMMIT(), ZONE_CREATE_HELPER::commitZone(), ZONE_CREATE_HELPER::createNewZone(), PCB_TOOL_BASE::doInteractiveItemPlacement(), ACTION_MENU::getToolManager(), LIB_TREE::onContextMenu(), ZONE_CREATE_HELPER::OnFirstPoint(), ACTION_MENU::OnMenuEvent(), and ZONE_CREATE_HELPER::performZoneCutout().

◆ getModel()

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 201 of file tool_base.h.

202  {
203  EDA_ITEM* m = getModelInt();
204 #if !defined( QA_TEST ) // Dynamic casts give the linker a siezure in the test framework
205  wxASSERT( dynamic_cast<T*>( m ) );
206 #endif
207  return static_cast<T*>( m );
208  }
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:54
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163

References TOOL_BASE::getModelInt().

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

◆ GetName()

const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns the name of the tool.

Tool names are expected to obey the format: application.ToolName (eg. pcbnew.InteractiveSelection).

Returns
The name of the tool.

Definition at line 132 of file tool_base.h.

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

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_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 1892 of file drawing_tool.cpp.

1893 {
1894  assert( m_board );
1895  return m_board->GetDesignSettings().GetLineThickness( aLayer );
1896 }
BOARD * m_board
Definition: drawing_tool.h:225
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:531
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 78 of file tool_base.cpp.

79 {
80  return m_toolSettings;
81 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:220

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

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

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

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

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

Definition at line 1349 of file drawing_tool.cpp.

1350 {
1351  bool clearSelection = false;
1352  aZone = nullptr;
1353 
1354  // not an action that needs a source zone
1355  if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON )
1356  return true;
1357 
1359  const PCBNEW_SELECTION& selection = selTool->GetSelection();
1360 
1361  if( selection.Empty() )
1362  {
1363  clearSelection = true;
1365  }
1366 
1367  // we want a single zone
1368  if( selection.Size() == 1 )
1369  aZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1370 
1371  // expected a zone, but didn't get one
1372  if( !aZone )
1373  {
1374  if( clearSelection )
1376 
1377  return false;
1378  }
1379 
1380  return true;
1381 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
PCBNEW_SELECTION & GetSelection()
Function GetSelection()
const PCBNEW_SELECTION & selection() const
Add a new zone/keepout with fresh settings.
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:119
int Size() const
Returns the number of selected parts.
Definition: selection.h:125
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:70

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

Referenced by DrawZone().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 110 of file tool_base.h.

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

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), 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 36 of file tool_base.cpp.

37 {
38  return m_toolMgr->GetView();
39 }
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:250
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), COMMON_TOOLS::CursorControl(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PL_DRAWING_TOOLS::DrawShape(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), COMMON_TOOLS::GridPreset(), PCBNEW_CONTROL::GridResetOrigin(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::GuessSelectionCandidates(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCB_INSPECTION_TOOL::highlightNet(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PNS::TOOL_BASE::pickSingleItem(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), PCB_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCBNEW_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), Reset(), EE_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::Selectable(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), PL_EDITOR_CONTROL::ToggleBackgroundColor(), COMMON_TOOLS::ToggleGrid(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PCBNEW_CONTROL::updateGrid(), EE_POINT_EDITOR::updateItem(), PL_POINT_EDITOR::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateView(), PCB_TOOL_BASE::view(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

◆ getViewControls()

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

Function getViewControls()

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

43 {
44  return m_toolMgr->GetViewControls();
45 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:255

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_LINE_WIRE_BUS_TOOL::doDrawSegments(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), DrawCircle(), DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), LIB_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), COMMON_TOOLS::GridPreset(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::HighlightNetTool(), MODULE_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), LIB_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LIB_DRAWING_TOOLS::PlaceAnchor(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), POINT_EDITOR::Reset(), Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCBNEW_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), LIB_MOVE_TOOL::updateModificationPoint(), PL_EDIT_TOOL::updateModificationPoint(), EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

Function Go()

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

Definition at line 129 of file tool_interactive.h.

131 {
132  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
133 
134  goInternal( sptr, aConditions );
135 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), AUTOPLACE_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_CONTROL::setTransitions(), LIB_PIN_TOOL::setTransitions(), PAD_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), COMMON_CONTROL::setTransitions(), LIB_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), EE_POINT_EDITOR::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_POINT_EDITOR::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), LIB_MOVE_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), POINT_EDITOR::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), LIB_CONTROL::setTransitions(), LIB_EDIT_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), PCB_INSPECTION_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), CVPCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), PCBNEW_PICKER_TOOL::setTransitions(), PICKER_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), setTransitions(), EDIT_TOOL::setTransitions(), SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), EE_SELECTION_TOOL::setTransitions(), and DRC::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 78 of file drawing_tool.cpp.

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

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

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

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

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

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

698 {
699  if( !m_frame->GetModel() )
700  return 0;
701 
702  // Note: PlaceImportedGraphics() will convert PCB_LINE_T and PCB_TEXT_T to module graphic
703  // items if needed
705  int dlgResult = dlg.ShowModal();
706 
707  auto& list = dlg.GetImportedItems();
708 
709  if( dlgResult != wxID_OK )
710  return 0;
711 
712  // Ensure the list is not empty:
713  if( list.empty() )
714  {
715  wxMessageBox( _( "No graphic items found in file to import") );
716  return 0;
717  }
718 
720 
721  // Add a VIEW_GROUP that serves as a preview for the new item
722  PCBNEW_SELECTION preview;
723  BOARD_COMMIT commit( m_frame );
724 
725  // Build the undo list & add items to the current view
726  for( auto& ptr : list)
727  {
728  EDA_ITEM* item = ptr.get();
729 
730  if( m_editModules )
731  wxASSERT( item->Type() == PCB_MODULE_EDGE_T || item->Type() == PCB_MODULE_TEXT_T );
732  else
733  wxASSERT( item->Type() == PCB_LINE_T || item->Type() == PCB_TEXT_T );
734 
735  if( dlg.IsPlacementInteractive() )
736  preview.Add( item );
737  else
738  commit.Add( item );
739 
740  ptr.release();
741  }
742 
743  if( !dlg.IsPlacementInteractive() )
744  {
745  commit.Push( _( "Place a DXF_SVG drawing" ) );
746  return 0;
747  }
748 
749  BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( preview.Front() );
750  m_view->Add( &preview );
751 
753  m_controls->ShowCursor( true );
754  m_controls->SetSnapping( true );
756 
757  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
758 
759  // Now move the new items to the current cursor position:
760  VECTOR2I cursorPos = m_controls->GetCursorPosition();
761  VECTOR2I delta = cursorPos - firstItem->GetPosition();
762 
763  for( EDA_ITEM* item : preview )
764  static_cast<BOARD_ITEM*>( item )->Move( (wxPoint) delta );
765 
766  m_view->Update( &preview );
767 
768  std::string tool = aEvent.GetCommandStr().get();
769  m_frame->PushTool( tool );
770  Activate();
771 
772  // Main loop: keep receiving events
773  while( TOOL_EVENT* evt = Wait() )
774  {
775  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
776  cursorPos = m_controls->GetCursorPosition();
777 
778  if( evt->IsCancelInteractive() || evt->IsActivate() )
779  {
780  preview.FreeItems();
781  break;
782  }
783  else if( evt->IsMotion() )
784  {
785  delta = cursorPos - firstItem->GetPosition();
786 
787  for( auto item : preview )
788  static_cast<BOARD_ITEM*>( item )->Move( (wxPoint) delta );
789 
790  m_view->Update( &preview );
791  }
792  else if( evt->Category() == TC_COMMAND )
793  {
794  // TODO it should be handled by EDIT_TOOL, so add items and select?
795  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
796  {
797  const auto rotationPoint = (wxPoint) cursorPos;
798  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *m_frame, *evt );
799 
800  for( auto item : preview )
801  static_cast<BOARD_ITEM*>( item )->Rotate( rotationPoint, rotationAngle );
802 
803  m_view->Update( &preview );
804  }
805  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
806  {
807  bool leftRight = m_frame->Settings().m_FlipLeftRight;
808 
809  for( auto item : preview )
810  static_cast<BOARD_ITEM*>( item )->Flip( (wxPoint) cursorPos, leftRight);
811 
812  m_view->Update( &preview );
813  }
814  }
815  else if( evt->IsClick( BUT_RIGHT ) )
816  {
818  }
819  else if( evt->IsClick( BUT_LEFT ) )
820  {
821  // Place the imported drawings
822  for( auto item : preview )
823  commit.Add( item );
824 
825  commit.Push( _( "Place a DXF_SVG drawing" ) );
826  break; // This is a one-shot command, not a tool
827  }
828  else
829  evt->SetPassEvent();
830  }
831 
832  preview.Clear();
833  m_view->Remove( &preview );
834  m_frame->PopTool( tool );
835  return 0;
836 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
static TOOL_ACTION cancelInteractive
Definition: actions.h:65
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:376
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:109
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
KIGFX::VIEW * m_view
Definition: drawing_tool.h:223
RAII class that sets an value at construction and resets it to the original value at destruction.
const PCBNEW_SELECTION & selection() const
PCB_GENERAL_SETTINGS & Settings()
Class TOOL_EVENT.
Definition: tool_event.h:171
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:224
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
#define _(s)
virtual const wxPoint GetPosition() const =0
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:226
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:116
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
virtual void PopTool(const std::string &actionName)
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:182
KICAD_T Type() const
Function Type()
Definition: base_struct.h:210

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

Referenced by setTransitions().

◆ PlaceText()

int DRAWING_TOOL::PlaceText ( const TOOL_EVENT aEvent)

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

Definition at line 257 of file drawing_tool.cpp.

258 {
259  if( m_editModules && !m_frame->GetModel() )
260  return 0;
261 
262  BOARD_ITEM* text = NULL;
263  const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
264  BOARD_COMMIT commit( m_frame );
265 
267  m_controls->ShowCursor( true );
268  m_controls->SetSnapping( true );
269  // do not capture or auto-pan until we start placing some text
270 
271  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
272 
273  std::string tool = aEvent.GetCommandStr().get();
274  m_frame->PushTool( tool );
275  Activate();
276 
277  bool reselect = false;
278 
279  // Prime the pump
280  if( aEvent.HasPosition() )
282 
283  // Main loop: keep receiving events
284  while( TOOL_EVENT* evt = Wait() )
285  {
286  m_frame->GetCanvas()->SetCurrentCursor( text ? wxCURSOR_ARROW : wxCURSOR_PENCIL );
287  VECTOR2I cursorPos = m_controls->GetCursorPosition();
288 
289  if( reselect && text )
291 
292  auto cleanup = [&] () {
295  m_controls->ShowCursor( true );
296  m_controls->SetAutoPan( false );
297  m_controls->CaptureCursor( false );
298  delete text;
299  text = NULL;
300  };
301 
302  if( evt->IsCancelInteractive() )
303  {
304  if( text )
305  cleanup();
306  else
307  {
308  m_frame->PopTool( tool );
309  break;
310  }
311  }
312  else if( evt->IsActivate() )
313  {
314  if( text )
315  cleanup();
316 
317  if( evt->IsMoveTool() )
318  {
319  // leave ourselves on the stack so we come back after the move
320  break;
321  }
322  else
323  {
324  m_frame->PopTool( tool );
325  break;
326  }
327  }
328  else if( evt->IsClick( BUT_RIGHT ) )
329  {
331  }
332  else if( evt->IsClick( BUT_LEFT ) )
333  {
334  bool placing = text != nullptr;
335 
336  if( !text )
337  {
340 
341  // Init the new item attributes
342  if( m_editModules )
343  {
344  TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) m_frame->GetModel() );
345 
346  textMod->SetLayer( layer );
347  textMod->SetTextSize( dsnSettings.GetTextSize( layer ) );
348  textMod->SetThickness( dsnSettings.GetTextThickness( layer ) );
349  textMod->SetItalic( dsnSettings.GetTextItalic( layer ) );
350  textMod->SetKeepUpright( dsnSettings.GetTextUpright( layer ) );
351  textMod->SetTextPos( (wxPoint) cursorPos );
352 
353  text = textMod;
354 
355  DIALOG_TEXT_PROPERTIES textDialog( m_frame, textMod );
356  bool cancelled;
357 
358  RunMainStack([&]() {
359  cancelled = !textDialog.ShowModal() || textMod->GetText().IsEmpty();
360  } );
361 
362  if( cancelled )
363  {
364  delete text;
365  text = nullptr;
366  }
367  else if( textMod->GetTextPos() != (wxPoint) cursorPos )
368  {
369  // If the user modified the location then go ahead and place it there.
370  // Otherwise we'll drag.
371  placing = true;
372  }
373  }
374  else
375  {
376  TEXTE_PCB* textPcb = new TEXTE_PCB( m_frame->GetModel() );
377  // TODO we have to set IS_NEW, otherwise InstallTextPCB.. creates an undo entry :| LEGACY_CLEANUP
378  textPcb->SetFlags( IS_NEW );
379 
380  textPcb->SetLayer( layer );
381 
382  // Set the mirrored option for layers on the BACK side of the board
383  if( IsBackLayer( layer ) )
384  textPcb->SetMirrored( true );
385 
386  textPcb->SetTextSize( dsnSettings.GetTextSize( layer ) );
387  textPcb->SetThickness( dsnSettings.GetTextThickness( layer ) );
388  textPcb->SetItalic( dsnSettings.GetTextItalic( layer ) );
389  textPcb->SetTextPos( (wxPoint) cursorPos );
390 
391  RunMainStack([&]() {
392  m_frame->InstallTextOptionsFrame( textPcb );
393  } );
394 
395  if( textPcb->GetText().IsEmpty() )
396  delete textPcb;
397  else
398  text = textPcb;
399  }
400 
401  if( text )
402  {
403  m_controls->WarpCursor( text->GetPosition(), true );
405  }
406  }
407 
408  if( placing )
409  {
410  text->ClearFlags();
412 
413  commit.Add( text );
414  commit.Push( _( "Place a text" ) );
415 
417 
418  text = nullptr;
419  }
420 
422  m_controls->ShowCursor( true );
423  m_controls->CaptureCursor( text != nullptr );
424  m_controls->SetAutoPan( text != nullptr );
425  }
426  else if( text && evt->IsMotion() )
427  {
428  text->SetPosition( (wxPoint) cursorPos );
429  selection().SetReferencePoint( cursorPos );
430  m_view->Update( &selection() );
431  frame()->SetMsgPanel( text );
432  }
433 
434  else if( text && evt->IsAction( &PCB_ACTIONS::properties ) )
435  {
436  // Calling 'Properties' action clears the selection, so we need to restore it
437  reselect = true;
438  }
439 
440  else
441  evt->SetPassEvent();
442  }
443 
444  frame()->SetMsgPanel( board() );
445  return 0;
446 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:172
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
void SetKeepUpright(bool aKeepUpright)
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame.
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
BOARD * board() const
virtual void SetPosition(const wxPoint &aPos)=0
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
void RunMainStack(std::function< void()> aFunc)
Function RunMainStack()
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetItalic(bool isItalic)
Definition: eda_text.h:163
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:231
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:125
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:109
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:222
int GetTextThickness(PCB_LAYER_ID aLayer) const
Function GetTextThickness Returns the default text thickness from the layer class for the given layer...
void InstallTextOptionsFrame(BOARD_ITEM *aText)
Routine for main window class to launch text properties dialog.
KIGFX::VIEW * m_view
Definition: drawing_tool.h:223
bool GetTextUpright(PCB_LAYER_ID aLayer) const
#define IS_NEW
New item, just created.
Definition: base_struct.h:120
PCB_BASE_EDIT_FRAME * frame() const
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:243
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
PCB_LAYER_ID
A quick note on layer IDs:
RAII class that sets an value at construction and resets it to the original value at destruction.
const PCBNEW_SELECTION & selection() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:265
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.
Class TOOL_EVENT.
Definition: tool_event.h:171
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:224
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1540
#define _(s)
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:226
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:76
virtual void PopTool(const std::string &actionName)
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:266
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
const wxPoint & GetTextPos() const
Definition: eda_text.h:232
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events and context-menu or hotkey-based...
Definition: tool_event.h:260
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:59
virtual const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:124
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Function GetTextSize Returns the default text size from the layer class for the given layer.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
static TOOL_ACTION cursorClick
Definition: actions.h:115
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:142
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(), ACTIONS::cursorClick, KIGFX::VIEW_CONTROLS::ForceCursorPosition(), PCB_TOOL_BASE::frame(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetCanvas(), TOOL_EVENT::GetCommandStr(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetDesignSettings(), PCB_BASE_EDIT_FRAME::GetModel(), BOARD_ITEM::GetPosition(), EDA_TEXT::GetText(), BOARD_DESIGN_SETTINGS::GetTextItalic(), EDA_TEXT::GetTextPos(), BOARD_DESIGN_SETTINGS::GetTextSize(), BOARD_DESIGN_SETTINGS::GetTextThickness(), BOARD_DESIGN_SETTINGS::GetTextUpright(), TOOL_EVENT::HasPosition(), PCB_BASE_EDIT_FRAME::InstallTextOptionsFrame(), IS_NEW, IsBackLayer(), m_controls, PCB_TOOL_BASE::m_editModules, m_frame, TOOL_INTERACTIVE::m_menu, m_mode, TOOL_BASE::m_toolMgr, m_view, EDA_BASE_FRAME::PopTool(), PCB_ACTIONS::properties, BOARD_COMMIT::Push(), EDA_BASE_FRAME::PushTool(), TOOL_MANAGER::RunAction(), TOOL_INTERACTIVE::RunMainStack(), PCB_TOOL_BASE::selection(), PCB_ACTIONS::selectionClear, PCB_ACTIONS::selectItem, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_PANEL_GAL::SetCurrentCursor(), EDA_ITEM::SetFlags(), EDA_TEXT::SetItalic(), TEXTE_MODULE::SetKeepUpright(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), EDA_DRAW_FRAME::SetMsgPanel(), BOARD_ITEM::SetPosition(), SELECTION::SetReferencePoint(), KIGFX::VIEW_CONTROLS::SetSnapping(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), 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 116 of file drawing_tool.cpp.

117 {
118  // Init variables used by every drawing tool
119  m_view = getView();
121  m_board = getModel<BOARD>();
122  m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
123 }
BOARD * m_board
Definition: drawing_tool.h:225
KIGFX::VIEW * m_view
Definition: drawing_tool.h:223
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:224
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:36
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:226
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:42

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

◆ RunMainStack()

void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

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

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

Referenced by PlaceText().

◆ 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 PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( ) const
protectedinherited

Definition at line 269 of file pcb_tool_base.cpp.

270 {
271  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
272  const auto& selection = selTool->GetSelection();
273  return selection;
274 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
const PCBNEW_SELECTION & selection() const

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

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

◆ selection() [2/2]

PCBNEW_SELECTION & PCB_TOOL_BASE::selection ( )
protectedinherited

Definition at line 277 of file pcb_tool_base.cpp.

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

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

◆ SetAnchor()

int DRAWING_TOOL::SetAnchor ( const TOOL_EVENT aEvent)

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

Definition at line 839 of file drawing_tool.cpp.

840 {
841  assert( m_editModules );
842 
843  if( !m_frame->GetModel() )
844  return 0;
845 
846  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR );
847  GRID_HELPER grid( m_frame );
848 
849  std::string tool = aEvent.GetCommandStr().get();
850  m_frame->PushTool( tool );
851  Activate();
852 
854  m_controls->ShowCursor( true );
855  m_controls->SetSnapping( true );
856  m_controls->SetAutoPan( true );
857  m_controls->CaptureCursor( false );
858 
859  while( TOOL_EVENT* evt = Wait() )
860  {
861  m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
862 
863  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
864  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
865  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
866  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), LSET::AllLayersMask() );
867  m_controls->ForceCursorPosition( true, cursorPos );
868 
869  if( evt->IsClick( BUT_LEFT ) )
870  {
872  BOARD_COMMIT commit( m_frame );
873  commit.Modify( module );
874 
875  // set the new relative internal local coordinates of footprint items
876  wxPoint moveVector = module->GetPosition() - (wxPoint) cursorPos;
877  module->MoveAnchorPosition( moveVector );
878 
879  commit.Push( _( "Move the footprint reference anchor" ) );
880 
881  // Usually, we do not need to change twice the anchor position,
882  // so deselect the active tool
883  m_frame->PopTool( tool );
884  break;
885  }
886  else if( evt->IsClick( BUT_RIGHT ) )
887  {
889  }
890  else if( evt->IsCancelInteractive() || evt->IsActivate() )
891  {
892  m_frame->PopTool( tool );
893  break;
894  }
895  else
896  evt->SetPassEvent();
897  }
898 
899  return 0;
900 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:73
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
TOOL_MENU m_menu
functions below are not yet implemented - their interface may change
TOOL_EVENT * Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
void SetCurrentCursor(wxStockCursor aStockCursorID)
Function SetCurrentCursor Set the current cursor shape for this panel.
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
virtual void 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:109
void MoveAnchorPosition(const wxPoint &aMoveVector)
Function MoveAnchorPosition Move the reference point of the footprint It looks like a move footprint:...
RAII class that sets an value at construction and resets it to the original value at destruction.
const PCBNEW_SELECTION & selection() const
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area.
Class TOOL_EVENT.
Definition: tool_event.h:171
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
static LSET AllLayersMask()
Definition: lset.cpp:713
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:224
#define _(s)
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:226
OPT< std::string > GetCommandStr() const
Definition: tool_event.h:463
MODULE * module() const
virtual void PopTool(const std::string &actionName)
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:213

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

Referenced by setTransitions().

◆ SetContextMenu()

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

Function SetContextMenu()

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

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

Definition at line 76 of file tool_interactive.cpp.

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ SetEditModules()

void PCB_TOOL_BASE::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 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 1923 of file drawing_tool.cpp.

1924 {
1938 }
static TOOL_ACTION drawLine
Definition: pcb_actions.h:153
int DrawCircle(const TOOL_EVENT &aEvent)
Function DrawCircle() Starts interactively drawing a circle.
static TOOL_ACTION placeImportedGraphics
Definition: pcb_actions.h:166
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:163
static TOOL_ACTION drawArc
Definition: pcb_actions.h:156
int DrawLine(const TOOL_EVENT &aEvent)
Function DrawLine() Starts interactively drawing a line.
static TOOL_ACTION drawZoneKeepout
Definition: pcb_actions.h:161
static TOOL_ACTION drawPolygon
Definition: pcb_actions.h:154
static TOOL_ACTION setAnchor
Definition: pcb_actions.h:167
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:157
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:158
static TOOL_ACTION drawVia
Definition: pcb_actions.h:160
static TOOL_ACTION drawZoneCutout
Definition: pcb_actions.h:162
static TOOL_ACTION drawCircle
Definition: pcb_actions.h:155
int SetAnchor(const TOOL_EVENT &aEvent)
Function SetAnchor() Places the footprint anchor (only in module editor).
int DrawArc(const TOOL_EVENT &aEvent)
Function DrawArc() Starts interactively drawing an arc.
static TOOL_ACTION drawZone
Definition: pcb_actions.h:159
int DrawDimension(const TOOL_EVENT &aEvent)
Function DrawDimension() Starts interactively drawing a dimension.

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

◆ view()

◆ Wait()

TOOL_EVENT * TOOL_INTERACTIVE::Wait ( const TOOL_EVENT_LIST aEventList = TOOL_EVENTTC_ANYTA_ANY ))
inherited

Function Wait()

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

Definition at line 57 of file tool_interactive.cpp.

58 {
59  return m_toolMgr->ScheduleWait( this, aEventList );
60 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:219
TOOL_EVENT * ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses execution of a given tool until one or more events matching aConditions arrives.

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), SCH_MOVE_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), EDIT_TOOL::Move(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Remove(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Friends And Related Function Documentation

◆ ZONE_CREATE_HELPER

friend class ZONE_CREATE_HELPER
friend

Definition at line 237 of file drawing_tool.h.

Member Data Documentation

◆ m_board

BOARD* DRAWING_TOOL::m_board
private

Definition at line 225 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 230 of file drawing_tool.h.

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

◆ m_menu

TOOL_MENU TOOL_INTERACTIVE::m_menu
protectedinherited

functions below are not yet implemented - their interface may change

Definition at line 108 of file tool_interactive.h.

Referenced by SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DrawZone(), PAD_TOOL::EnumeratePads(), TOOL_INTERACTIVE::GetToolMenu(), PICKER_TOOL::Init(), SCH_EDIT_TOOL::Init(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Init(), PL_EDIT_TOOL::Init(), LIB_DRAWING_TOOLS::Init(), MODULE_EDITOR_TOOLS::Init(), PL_DRAWING_TOOLS::Init(), LIB_CONTROL::Init(), PCB_EDITOR_CONTROL::Init(), SCH_DRAWING_TOOLS::Init(), GERBVIEW_SELECTION_TOOL::Init(), Init(), PL_SELECTION_TOOL::Init(), EE_SELECTION_TOOL::Init(), SCH_LINE_WIRE_BUS_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), SELECTION_TOOL::Init(), EDIT_TOOL::Init(), PCB_TOOL_BASE::Init(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), LIB_MOVE_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PCBNEW_PICKER_TOOL::Main(), PICKER_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), LIB_DRAWING_TOOLS::PlaceAnchor(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), LIB_DRAWING_TOOLS::TwoClickPlace(), and SCH_DRAWING_TOOLS::TwoClickPlace().

◆ m_mode

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 214 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 219 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SELECTION_TOOL::AddItemToSel(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), PCB_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), EDIT_TOOL::ChangeTrackWidth(), PCB_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), SELECTION_TOOL::ClearSelection(), PL_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), LIB_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), SCH_EDITOR_CONTROL::Cut(), LIB_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), LIB_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), DrawArc(), drawArc(), DrawCircle(), DrawDimension(), drawSegment(), LIB_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DrawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), LIB_EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::editComponentFieldText(), EDIT_TOOL::EditFpInFpEditor(), LIB_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithLibEdit(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), GLOBAL_EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), SELECTION_TOOL::findCallback(), SCH_EDITOR_CONTROL::FindComponentAndItem(), POINT_EDITOR::finishItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_INSPECTION_TOOL::HighlightItem(), PCB_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), PCB_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PCB_INSPECTION_TOOL::HighlightNetTool(), MODULE_EDITOR_TOOLS::ImportFootprint(), PL_EDIT_TOOL::ImportWorksheetContent(), LIB_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), PAD_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), LIB_CONTROL::Init(), PL_DRAWING_TOOLS::Init(), PL_POINT_EDITOR::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), PCB_INSPECTION_TOOL::LocalRatsnestTool(), PL_EDIT_TOOL::Main(), SCH_MOVE_TOOL::Main(), CVPCB_CONTROL::Main(), LIB_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::Move(), EDIT_TOOL::MoveExact(), LIB_CONTROL::OnDeMorgan(), LIB_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), LIB_EDIT_TOOL::PinTable(), PCBNEW_CONTROL::placeBoardItems(), SCH_DRAWING_TOOLS::PlaceComponent(), SCH_DRAWING_TOOLS::PlaceImage(), PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), PCBNEW_CONTROL::Print(), GERBVIEW_CONTROL::Print(), LIB_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), LIB_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), LIB_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), LIB_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC::RunTests(), EE_SELECTION_TOOL::SelectConnection(), SELECTION_TOOL::selectCopper(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), SELECTION_TOOL::selectSheetContents(), SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), DRC::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), LIB_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), LIB_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCBNEW_CONTROL::UpdateMessagePanel(), PCB_INSPECTION_TOOL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName (eg. pcbnew.InteractiveSelection).

Definition at line 218 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_toolSettings

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 220 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 211 of file tool_base.h.

Referenced by TOOL_BASE::GetType(), and BOARD_COMMIT::Push().

◆ 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 233 of file drawing_tool.h.

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


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