KiCad PCB EDA Suite
DRAWING_TOOL Class Reference

Class DRAWING_TOOL. More...

#include <drawing_tool.h>

Inheritance diagram for DRAWING_TOOL:
PCB_TOOL TOOL_INTERACTIVE TOOL_BASE

Public Types

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

The possible drawing modes of DRAWING_TOOL

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

Determines the reason of reset for a tool

More...
 

Public Member Functions

 DRAWING_TOOL ()
 
 ~DRAWING_TOOL ()
 
bool Init () override
 Function Init() Init() is called once upon a registration of the tool. More...
 
void Reset (RESET_REASON aReason) override
 Function Reset() Brings the tool to a known, initial state. More...
 
TOOL_MENUGetToolMenu ()
 

Get the DRAWING_TOOL top-level context menu

More...
 
MODE GetDrawingMode () const
 Function GetDrawingMode. More...
 
int DrawLine (const TOOL_EVENT &aEvent)
 Function DrawLine() Starts interactively drawing a line. More...
 
int DrawCircle (const TOOL_EVENT &aEvent)
 Function DrawCircle() Starts interactively drawing a circle. More...
 
int DrawArc (const TOOL_EVENT &aEvent)
 Function DrawArc() Starts interactively drawing an arc. More...
 
int PlaceText (const TOOL_EVENT &aEvent)
 Function PlaceText() Displays a dialog that allows 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 DrawKeepout (const TOOL_EVENT &aEvent)
 Function DrawKeepout() Starts interactively drawing a keepout area. More...
 
int DrawZoneCutout (const TOOL_EVENT &aEvent)
 Function DrawZoneCutout() Starts interactively drawing a zone cutout area of an existing zone. More...
 
int DrawSimilarZone (const TOOL_EVENT &aEvent)
 Function DrawSimilarZone() Starts interactively drawing a zone with same settings as an existing zone. More...
 
int PlaceDXF (const TOOL_EVENT &aEvent)
 Function PlaceDXF() Places a drawing imported from a DXF file in module editor. More...
 
int SetAnchor (const TOOL_EVENT &aEvent)
 Function SetAnchor() Places the footprint anchor (only in module editor). More...
 
void SetTransitions () override
 

Sets up handlers for various events.

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

Protected Types

using ITEM_CREATOR = std::function< std::unique_ptr< BOARD_ITEM >(const TOOL_EVENT &aEvt) >
 Callable that returns a new board item. More...
 

Protected Member Functions

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

Protected Attributes

bool m_editModules
 
TOOL_TYPE m_type
 

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Types

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

Private Member Functions

void showContextMenu ()
 

Shows the context menu for the drawing tool This menu consists of normal UI functions (zoom, grid, etc) And any suitable global functions for the active drawing type.

More...
 
bool drawSegment (int aShape, DRAWSEGMENT *&aGraphic, boost::optional< VECTOR2D > aStartingPoint=boost::none)
 

Starts drawing a selected shape (i.e.

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

Starts drawing an arc.

More...
 
int drawZone (bool aKeepout, ZONE_MODE aMode)
 Draws a polygon, that is added as a zone or a keepout area. More...
 
bool getSourceZoneForAction (ZONE_MODE aMode, ZONE_CONTAINER *&aZone)
 Function getSourceZoneForAction() More...
 
void runPolygonEventLoop (POLYGON_GEOM_MANAGER &aPolyGeomMgr)
 Run the event loop for polygon creation, sending user input on to the given POLYGON_GEOM_MANAGER for processing into a complete polygon. More...
 
void make45DegLine (DRAWSEGMENT *aSegment, DRAWSEGMENT *aHelper) const
 Function make45DegLine() Forces a DRAWSEGMENT to be drawn at multiple of 45 degrees. More...
 
int getSegmentWidth (unsigned int aLayer) const
 

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

More...
 
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...
 
TOOL_MENU m_menu
 Menu model displayed by the tool. More...
 

Static Private Attributes

static const unsigned int WIDTH_STEP = 100000
 

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 Typedef Documentation

using PCB_TOOL::ITEM_CREATOR = std::function< std::unique_ptr< BOARD_ITEM >( const TOOL_EVENT& aEvt ) >
protectedinherited

Callable that returns a new board item.

The event that triggered it is provided, so you can check modifier keys, position, etc, if required

Definition at line 91 of file pcb_tool.h.

Member Enumeration Documentation

enum DRAWING_TOOL::MODE
strong

The possible drawing modes of DRAWING_TOOL

Enumerator
NONE 
LINE 
CIRCLE 
ARC 
TEXT 
ANCHOR 
DXF 
DIMENSION 
KEEPOUT 
ZONE 

Definition at line 68 of file drawing_tool.h.

69  {
70  NONE,
71  LINE,
72  CIRCLE,
73  ARC,
74  TEXT,
75  ANCHOR,
76  DXF,
77  DIMENSION,
78  KEEPOUT,
79  ZONE,
80  };
Class DIMENSION.
enum TOOL_BASE::RESET_REASON
inherited

Determines the reason of reset for a tool

Enumerator
RUN 

Tool is invoked after being inactive.

MODEL_RELOAD 

Model changes (required full reload)

GAL_SWITCH 

Rendering engine changes.

Definition at line 80 of file tool_base.h.

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

Add a new zone/keepout with fresh settings.

CUTOUT 

Make a cutout to an existing zone.

SIMILAR 

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

Definition at line 182 of file drawing_tool.h.

183  {
184  ADD,
185  CUTOUT,
186  SIMILAR
187  };

Constructor & Destructor Documentation

DRAWING_TOOL::DRAWING_TOOL ( )

Definition at line 141 of file drawing_tool.cpp.

141  :
142  PCB_TOOL( "pcbnew.InteractiveDrawing" ),
143  m_view( nullptr ), m_controls( nullptr ),
144  m_board( nullptr ), m_frame( nullptr ), m_mode( MODE::NONE ),
145  m_lineWidth( 1 ),
146  m_menu( *this )
147 {
148 }
BOARD * m_board
Definition: drawing_tool.h:258
KIGFX::VIEW * m_view
Definition: drawing_tool.h:256
PCB_TOOL(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool.h:52
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:263
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:257
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:266
DRAWING_TOOL::~DRAWING_TOOL ( )

Definition at line 151 of file drawing_tool.cpp.

152 {
153 }

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited
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 54 of file tool_base.cpp.

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

Referenced by TOOL_MANAGER::RegisterTool().

55 {
56  m_toolMgr = aManager;
57  m_toolSettings = TOOL_SETTINGS( this );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
friend class TOOL_SETTINGS
Definition: tool_base.h:160
void PCB_TOOL::doInteractiveItemPlacement ( ITEM_CREATOR  aItemCreator,
const wxString &  aCommitMessage 
)
protectedinherited

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

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

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

Definition at line 39 of file pcb_tool.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), PCB_MODULE_T, BOARD_COMMIT::Push(), KIGFX::VIEW_GROUP::Remove(), SELECTION::Remove(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), MODULE::RunOnChildren(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), KIGFX::VIEW_CONTROLS::SetSnapping(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, KIGFX::VIEW::Update(), PCB_TOOL::view(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint().

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

References COMMIT::Add(), ARC, drawArc(), getDrawingLayer(), PCB_BASE_EDIT_FRAME::GetModel(), getSegmentWidth(), ID_MODEDIT_ARC_TOOL, ID_NO_TOOL_SELECTED, ID_PCB_ARC_BUTT, PCB_TOOL::m_editModules, m_frame, m_lineWidth, m_mode, BOARD_COMMIT::Push(), and PCB_BASE_FRAME::SetToolID().

Referenced by SetTransitions().

274 {
276  DRAWSEGMENT* arc = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
277  BOARD_COMMIT commit( m_frame );
278 
279  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ARC );
280 
282  wxCURSOR_PENCIL, _( "Add graphic arc" ) );
284 
285  while( drawArc( arc ) )
286  {
287  if( arc )
288  {
289  commit.Add( arc );
290  commit.Push( _( "Draw an arc" ) );
291  }
292 
293  arc = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
294  }
295 
296  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
297 
298  return 0;
299 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
int getSegmentWidth(unsigned int aLayer) const
Returns the appropriate width for a segment depending on the settings.
RAII class that sets an value at construction and resets it to the original value at destruction...
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:263
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
bool m_editModules
Definition: pcb_tool.h:112
LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel() returns the primary data model.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
bool drawArc(DRAWSEGMENT *&aGraphic)
Starts drawing an arc.
bool DRAWING_TOOL::drawArc ( DRAWSEGMENT *&  aGraphic)
private

Starts drawing an arc.

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

Definition at line 1099 of file drawing_tool.cpp.

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), KIGFX::VIEW::Add(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::AddPoint(), PCB_ACTIONS::arcPosture, BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_ACTIONS::decWidth, deleteLastPoint, KIGFX::VIEW_CONTROLS::GetCursorPosition(), getDrawingLayer(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::HasGeometryChanged(), PCB_ACTIONS::incWidth, TOOL_EVT_UTILS::IsCancelInteractive(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::IsComplete(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::IsReset(), m_controls, m_lineWidth, m_menu, TOOL_BASE::m_toolMgr, m_view, MD_CTRL, SELECTION::Remove(), KIGFX::VIEW::Remove(), KIGFX::PREVIEW::MULTISTEP_GEOM_MANAGER::RemoveLastPoint(), TOOL_MANAGER::RunAction(), S_ARC, PCB_ACTIONS::selectionClear, KIGFX::PREVIEW::ARC_GEOM_MANAGER::SetAngleSnap(), KIGFX::VIEW_CONTROLS::SetAutoPan(), BOARD_ITEM::SetLayer(), DRAWSEGMENT::SetShape(), KIGFX::VIEW_CONTROLS::SetSnapping(), 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().

1100 {
1102 
1103  // Arc geometric construction manager
1105 
1106  // Arc drawing assistant overlay
1107  KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager );
1108 
1109  // Add a VIEW_GROUP that serves as a preview for the new item
1110  SELECTION preview;
1111  m_view->Add( &preview );
1112  m_view->Add( &arcAsst );
1113 
1114  m_controls->ShowCursor( true );
1115  m_controls->SetSnapping( true );
1116 
1117  Activate();
1118 
1119  bool firstPoint = false;
1120 
1121  // Main loop: keep receiving events
1122  while( OPT_TOOL_EVENT evt = Wait() )
1123  {
1124  const VECTOR2I cursorPos = m_controls->GetCursorPosition();
1125 
1126  if( evt->IsClick( BUT_LEFT ) )
1127  {
1128  if( !firstPoint )
1129  {
1130  m_controls->SetAutoPan( true );
1131  m_controls->CaptureCursor( true );
1132 
1133  LAYER_ID layer = getDrawingLayer();
1134 
1135  // Init the new item attributes
1136  // (non-geometric, those are handled by the manager)
1137  aGraphic->SetShape( S_ARC );
1138  aGraphic->SetWidth( m_lineWidth );
1139  aGraphic->SetLayer( layer );
1140 
1141  preview.Add( aGraphic );
1142  firstPoint = true;
1143  }
1144 
1145  arcManager.AddPoint( cursorPos, true );
1146  }
1147 
1148  else if( evt->IsAction( &deleteLastPoint ) )
1149  {
1150  arcManager.RemoveLastPoint();
1151  }
1152 
1153  else if( evt->IsMotion() )
1154  {
1155  // set angle snap
1156  arcManager.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1157 
1158  // update, but don't step the manager state
1159  arcManager.AddPoint( cursorPos, false );
1160  }
1161 
1162  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
1163  {
1164  preview.Clear();
1165  delete aGraphic;
1166  aGraphic = nullptr;
1167  break;
1168  }
1169  else if( evt->IsClick( BUT_RIGHT ) )
1170  {
1172  }
1173 
1174  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1175  {
1177  aGraphic->SetWidth( m_lineWidth );
1178  m_view->Update( &preview );
1179  }
1180 
1181  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && m_lineWidth > WIDTH_STEP )
1182  {
1184  aGraphic->SetWidth( m_lineWidth );
1185  m_view->Update( &preview );
1186  }
1187 
1188  else if( evt->IsAction( &PCB_ACTIONS::arcPosture ) )
1189  {
1190  arcManager.ToggleClockwise();
1191  }
1192 
1193  if( arcManager.IsComplete() )
1194  {
1195  break;
1196  }
1197  else if( arcManager.HasGeometryChanged() )
1198  {
1199  updateArcFromConstructionMgr( arcManager, *aGraphic );
1200  m_view->Update( &preview );
1201  m_view->Update( &arcAsst );
1202  }
1203  }
1204 
1205  preview.Remove( aGraphic );
1206  m_view->Remove( &arcAsst );
1207  m_view->Remove( &preview );
1208  m_controls->SetAutoPan( false );
1209  m_controls->CaptureCursor( false );
1210 
1211  return !arcManager.IsReset();
1212 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
Class ARC_GEOM_MANAGER.
void SetShape(STROKE_T aShape)
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:158
static TOOL_ACTION deleteLastPoint("pcbnew.InteractiveDrawing.deleteLastPoint", AS_CONTEXT, WXK_BACK, _("Delete Last Point"), _("Delete the last point added to the current item"), undo_xpm)
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:269
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
virtual void SetLayer(LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void RemoveLastPoint()
Undo the last point, and move the manager back to the previous step.
static void updateArcFromConstructionMgr(const KIGFX::PREVIEW::ARC_GEOM_MANAGER &aMgr, DRAWSEGMENT &aArc)
Update an arc DRAWSEGMENT from the current state of an Arc Geoemetry 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:161
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW * m_view
Definition: drawing_tool.h:256
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
Arcs (with rounded ends)
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:263
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:257
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
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 arcPosture
Switch posture when drawing arc.
Definition: pcb_actions.h:164
void ToggleClockwise()
Reverse the current are direction
LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
Class SELECTION_AREA.
Definition: arc_assistant.h:38
void Activate()
Function Activate() Runs the tool.
void SetAngleSnap(bool aSnap)
Set angle snapping (for the next point)
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:266
void SetWidth(int aWidth)
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
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 244 of file drawing_tool.cpp.

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

Referenced by SetTransitions().

245 {
247  DRAWSEGMENT* circle = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
248  BOARD_COMMIT commit( m_frame );
249 
250  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::CIRCLE );
251 
253  wxCURSOR_PENCIL, _( "Add graphic circle" ) );
255 
256  while( drawSegment( S_CIRCLE, circle ) )
257  {
258  if( circle )
259  {
260  commit.Add( circle );
261  commit.Push( _( "Draw a circle" ) );
262  }
263 
264  circle = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
265  }
266 
267  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
268 
269  return 0;
270 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
bool drawSegment(int aShape, DRAWSEGMENT *&aGraphic, boost::optional< VECTOR2D > aStartingPoint=boost::none)
Starts drawing a selected shape (i.e.
int getSegmentWidth(unsigned int aLayer) const
Returns the appropriate width for a segment depending on the settings.
RAII class that sets an value at construction and resets it to the original value at destruction...
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:263
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
bool m_editModules
Definition: pcb_tool.h:112
LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel() returns the primary data model.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
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 468 of file drawing_tool.cpp.

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), DIMENSION::AdjustDimensionDetails(), PNS::angle(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), Clamp_Text_PenSize(), SELECTION::Clear(), PCB_ACTIONS::decWidth, delta, DIMENSION, Dwgs_User, Edge_Cuts, DIMENSION::GetAngle(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), BOARD::GetDesignSettings(), getDrawingLayer(), DIMENSION::GetEnd(), DIMENSION::GetOrigin(), DIMENSION::GetPosition(), getSegmentWidth(), EDA_TEXT::GetTextSize(), DIMENSION::GetWidth(), ID_NO_TOOL_SELECTED, ID_PCB_DIMENSION_BUTT, PCB_ACTIONS::incWidth, TOOL_EVT_UTILS::IsCancelInteractive(), m_board, m_controls, DIMENSION::m_featureLineDO, m_frame, m_lineWidth, m_menu, m_mode, BOARD_DESIGN_SETTINGS::m_PcbTextSize, BOARD_DESIGN_SETTINGS::m_PcbTextWidth, TOOL_BASE::m_toolMgr, m_view, BOARD_COMMIT::Push(), SELECTION::Remove(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), DIMENSION::SetEnd(), DIMENSION::SetHeight(), DIMENSION::SetLayer(), DIMENSION::SetOrigin(), KIGFX::VIEW_CONTROLS::SetSnapping(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), PCB_BASE_FRAME::SetToolID(), DIMENSION::SetWidth(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), DIMENSION::Text(), KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), WIDTH_STEP, wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

Referenced by SetTransitions().

469 {
470  DIMENSION* dimension = NULL;
471  BOARD_COMMIT commit( m_frame );
472  int maxThickness;
473 
474  // Add a VIEW_GROUP that serves as a preview for the new item
475  SELECTION preview;
476  m_view->Add( &preview );
477 
479  m_controls->ShowCursor( true );
480  m_controls->SetSnapping( true );
481 
482  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
483 
484  Activate();
485  m_frame->SetToolID( ID_PCB_DIMENSION_BUTT, wxCURSOR_PENCIL, _( "Add dimension" ) );
487 
488  enum DIMENSION_STEPS
489  {
490  SET_ORIGIN = 0,
491  SET_END,
492  SET_HEIGHT,
493  FINISHED
494  };
495  int step = SET_ORIGIN;
496 
497  // Main loop: keep receiving events
498  while( OPT_TOOL_EVENT evt = Wait() )
499  {
500  VECTOR2I cursorPos = m_controls->GetCursorPosition();
501 
503  {
504  if( step != SET_ORIGIN ) // start from the beginning
505  {
506  preview.Clear();
507 
508  delete dimension;
509  step = SET_ORIGIN;
510  }
511  else
512  break;
513 
514  if( evt->IsActivate() ) // now finish unconditionally
515  break;
516  }
517 
518  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) && step != SET_ORIGIN )
519  {
521  dimension->SetWidth( m_lineWidth );
522  m_view->Update( &preview );
523  }
524 
525  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && step != SET_ORIGIN )
526  {
527  if( m_lineWidth > WIDTH_STEP )
528  {
530  dimension->SetWidth( m_lineWidth );
531  m_view->Update( &preview );
532  }
533  }
534 
535  else if( evt->IsClick( BUT_RIGHT ) )
536  {
538  }
539 
540  else if( evt->IsClick( BUT_LEFT ) )
541  {
542  switch( step )
543  {
544  case SET_ORIGIN:
545  {
546  LAYER_ID layer = getDrawingLayer();
547 
548  if( layer == Edge_Cuts ) // dimensions are not allowed on EdgeCuts
549  layer = Dwgs_User;
550 
551  // Init the new item attributes
552  dimension = new DIMENSION( m_board );
553  dimension->SetLayer( layer );
554  dimension->SetOrigin( wxPoint( cursorPos.x, cursorPos.y ) );
555  dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
557 
559  maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetTextSize() );
560 
561  if( width > maxThickness )
562  width = maxThickness;
563 
564  dimension->Text().SetThickness( width );
565  dimension->SetWidth( width );
566  dimension->AdjustDimensionDetails();
567 
568  preview.Add( dimension );
569 
570  m_controls->SetAutoPan( true );
571  m_controls->CaptureCursor( true );
572  }
573  break;
574 
575  case SET_END:
576  dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
577 
578  // Dimensions that have origin and end in the same spot are not valid
579  if( dimension->GetOrigin() == dimension->GetEnd() )
580  --step;
581  break;
582 
583  case SET_HEIGHT:
584  {
585  if( wxPoint( cursorPos.x, cursorPos.y ) != dimension->GetPosition() )
586  {
587  assert( dimension->GetOrigin() != dimension->GetEnd() );
588  assert( dimension->GetWidth() > 0 );
589 
590  preview.Remove( dimension );
591 
592  commit.Add( dimension );
593  commit.Push( _( "Draw a dimension" ) );
594 
595  }
596  }
597  break;
598  }
599 
600  if( ++step == FINISHED )
601  {
602  step = SET_ORIGIN;
603  m_controls->SetAutoPan( false );
604  m_controls->CaptureCursor( false );
605  }
606  }
607 
608  else if( evt->IsMotion() )
609  {
610  switch( step )
611  {
612  case SET_END:
613  dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
614  break;
615 
616  case SET_HEIGHT:
617  {
618  // Calculating the direction of travel perpendicular to the selected axis
619  double angle = dimension->GetAngle() + ( M_PI / 2 );
620 
621  wxPoint pos( cursorPos.x, cursorPos.y );
622  wxPoint delta( pos - dimension->m_featureLineDO );
623  double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
624  dimension->SetHeight( height );
625  }
626  break;
627  }
628 
629  // Show a preview of the item
630  m_view->Update( &preview );
631  }
632  }
633 
634  if( step != SET_ORIGIN )
635  delete dimension;
636 
637  m_view->Remove( &preview );
638  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
639 
640  return 0;
641 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
BOARD * m_board
Definition: drawing_tool.h:258
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:158
int m_PcbTextWidth
current Pcb (not module) Text width
int GetWidth() const
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:269
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
double GetAngle() const
Function GetAngle Returns angle of the crossbar.
static const int delta[8][2]
Definition: solve.cpp:112
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:161
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW * m_view
Definition: drawing_tool.h:256
int getSegmentWidth(unsigned int aLayer) const
Returns the appropriate width for a segment depending on the settings.
void SetLayer(LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
void SetOrigin(const wxPoint &aOrigin)
Function SetOrigin Sets a new origin of the crossbar line.
RAII class that sets an value at construction and resets it to the original value at destruction...
const wxPoint & GetEnd()
Function GetEnd.
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
wxSize m_PcbTextSize
current Pcb (not module) Text size
const wxPoint & GetOrigin() const
Function GetOrigin.
void SetEnd(const wxPoint &aEnd)
Function SetEnd Sets a new end of the crossbar line.
int Clamp_Text_PenSize(int aPenSize, int aSize, bool aBold)
Function Clamp_Text_PenSize As a rule, pen width should not be >1/4em, otherwise the character will b...
Definition: drawtxt.cpp:67
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:263
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:257
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
void AdjustDimensionDetails(bool aDoNotChangeText=false)
Function AdjustDimensionDetails Calculate coordinates of segments used to draw the dimension...
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
TEXTE_PCB & Text()
void Activate()
Function Activate() Runs the tool.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
const wxSize & GetTextSize() const
Definition: eda_text.h:215
const wxPoint & GetPosition() const override
void SetWidth(int aWidth)
wxPoint m_featureLineDO
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
Class DIMENSION.
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:266
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:148
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
int DRAWING_TOOL::DrawKeepout ( const TOOL_EVENT aEvent)

Function DrawKeepout() Starts interactively drawing a keepout area.

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

Definition at line 653 of file drawing_tool.cpp.

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

Referenced by SetTransitions().

654 {
655  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::KEEPOUT );
656  m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add keepout" ) );
657 
658  return drawZone( true, ZONE_MODE::ADD );
659 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
RAII class that sets an value at construction and resets it to the original value at destruction...
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
Add a new zone/keepout with fresh settings.
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 209 of file drawing_tool.cpp.

References COMMIT::Add(), drawSegment(), getDrawingLayer(), DRAWSEGMENT::GetEnd(), PCB_BASE_EDIT_FRAME::GetModel(), getSegmentWidth(), ID_MODEDIT_LINE_TOOL, ID_NO_TOOL_SELECTED, ID_PCB_ADD_LINE_BUTT, LINE, PCB_TOOL::m_editModules, m_frame, m_lineWidth, m_mode, BOARD_COMMIT::Push(), S_SEGMENT, and PCB_BASE_FRAME::SetToolID().

Referenced by SetTransitions().

210 {
212  DRAWSEGMENT* line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
213  boost::optional<VECTOR2D> startingPoint;
214  BOARD_COMMIT commit( m_frame );
215 
216  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::LINE );
217 
219  wxCURSOR_PENCIL, _( "Add graphic line" ) );
221 
222  while( drawSegment( S_SEGMENT, line, startingPoint ) )
223  {
224  if( line )
225  {
226  commit.Add( line );
227  commit.Push( _( "Draw a line segment" ) );
228  startingPoint = line->GetEnd();
229  }
230  else
231  {
232  startingPoint = boost::none;
233  }
234 
235  line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
236  }
237 
238  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
239 
240  return 0;
241 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
usual segment : line with rounded ends
bool drawSegment(int aShape, DRAWSEGMENT *&aGraphic, boost::optional< VECTOR2D > aStartingPoint=boost::none)
Starts drawing a selected shape (i.e.
int getSegmentWidth(unsigned int aLayer) const
Returns the appropriate width for a segment depending on the settings.
RAII class that sets an value at construction and resets it to the original value at destruction...
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:263
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
bool m_editModules
Definition: pcb_tool.h:112
LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel() returns the primary data model.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
bool DRAWING_TOOL::drawSegment ( int  aShape,
DRAWSEGMENT *&  aGraphic,
boost::optional< VECTOR2D aStartingPoint = boost::none 
)
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.
Returns
False if the tool was cancelled before the origin was set or origin and end are the same point.

Definition at line 909 of file drawing_tool.cpp.

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_ACTIONS::decWidth, g_Segments_45_Only, KIGFX::VIEW_CONTROLS::GetCursorPosition(), getDrawingLayer(), DRAWSEGMENT::GetEnd(), PCB_BASE_EDIT_FRAME::GetModel(), DRAWSEGMENT::GetStart(), PCB_ACTIONS::incWidth, TOOL_EVT_UTILS::IsCancelInteractive(), PCB_ACTIONS::layerChanged, m_controls, PCB_TOOL::m_editModules, m_frame, m_lineWidth, m_menu, TOOL_BASE::m_toolMgr, m_view, make45DegLine(), MD_CTRL, BOARD_COMMIT::Push(), SELECTION::Remove(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), S_CIRCLE, S_SEGMENT, PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), DRAWSEGMENT::SetEnd(), BOARD_ITEM::SetLayer(), DRAWSEGMENT::SetShape(), KIGFX::VIEW_CONTROLS::SetSnapping(), DRAWSEGMENT::SetStart(), DRAWSEGMENT::SetWidth(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), WIDTH_STEP, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by DrawCircle(), and DrawLine().

911 {
912  // Only two shapes are currently supported
913  assert( aShape == S_SEGMENT || aShape == S_CIRCLE );
914 
915  DRAWSEGMENT line45;
916 
917  // Add a VIEW_GROUP that serves as a preview for the new item
918  SELECTION preview;
919  m_view->Add( &preview );
920 
922  m_controls->ShowCursor( true );
923  m_controls->SetSnapping( true );
924 
925  Activate();
926 
927  bool direction45 = false; // 45 degrees only mode
928  bool started = false;
929  VECTOR2I cursorPos = m_controls->GetCursorPosition();
930 
931  if( aStartingPoint )
932  {
933  // Init the new item attributes
934  aGraphic->SetShape( (STROKE_T) aShape );
935  aGraphic->SetWidth( m_lineWidth );
936  aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) );
937  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
938  aGraphic->SetLayer( getDrawingLayer() );
939 
940  if( aShape == S_SEGMENT )
941  line45 = *aGraphic; // used only for direction 45 mode with lines
942 
943  preview.Add( aGraphic );
944  m_controls->SetAutoPan( true );
945  m_controls->CaptureCursor( true );
946 
947  started = true;
948  }
949 
950  // Main loop: keep receiving events
951  while( OPT_TOOL_EVENT evt = Wait() )
952  {
953  cursorPos = m_controls->GetCursorPosition();
954 
955  // 45 degree angle constraint enabled with an option and toggled with Ctrl
956  const bool limit45 = ( g_Segments_45_Only != !!( evt->Modifier( MD_CTRL ) ) );
957 
958  if( direction45 != limit45 && started && aShape == S_SEGMENT )
959  {
960  direction45 = limit45;
961 
962  if( direction45 )
963  {
964  preview.Add( &line45 );
965  make45DegLine( aGraphic, &line45 );
966  }
967  else
968  {
969  preview.Remove( &line45 );
970  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
971  }
972 
973  m_view->Update( &preview );
974  }
975 
977  {
978  preview.Clear();
979  m_view->Update( &preview );
980  delete aGraphic;
981  aGraphic = NULL;
982  break;
983  }
984  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
985  {
986  aGraphic->SetLayer( getDrawingLayer() );
987  m_view->Update( &preview );
988  }
989  else if( evt->IsClick( BUT_RIGHT ) )
990  {
992  }
993  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
994  {
995  if( !started )
996  {
997  // Init the new item attributes
998  aGraphic->SetShape( (STROKE_T) aShape );
999  aGraphic->SetWidth( m_lineWidth );
1000  aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) );
1001  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1002  aGraphic->SetLayer( getDrawingLayer() );
1003 
1004  if( aShape == S_SEGMENT )
1005  line45 = *aGraphic; // used only for direction 45 mode with lines
1006 
1007  preview.Add( aGraphic );
1008  m_controls->SetAutoPan( true );
1009  m_controls->CaptureCursor( true );
1010 
1011  started = true;
1012  }
1013  else
1014  {
1015  if( aGraphic->GetEnd() == aGraphic->GetStart() ||
1016  ( evt->IsDblClick( BUT_LEFT ) && aShape == S_SEGMENT ) )
1017  // User has clicked twice in the same spot
1018  { // a clear sign that the current drawing is finished
1019  // Now we have to add the helper line as well
1020  if( direction45 )
1021  {
1022  BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
1023  DRAWSEGMENT* l = m_editModules ? new EDGE_MODULE( (MODULE*) parent )
1024  : new DRAWSEGMENT;
1025 
1026  // Copy coordinates, layer, etc.
1027  *static_cast<DRAWSEGMENT*>( l ) = line45;
1028  l->SetEnd( aGraphic->GetStart() );
1029 
1030  BOARD_COMMIT commit( m_frame );
1031  commit.Add( l );
1032  commit.Push( _( "Draw a line" ) );
1033  }
1034 
1035  delete aGraphic;
1036  aGraphic = NULL;
1037  }
1038 
1039  preview.Clear();
1040  break;
1041  }
1042  }
1043 
1044  else if( evt->IsMotion() )
1045  {
1046  // 45 degree lines
1047  if( direction45 && aShape == S_SEGMENT )
1048  make45DegLine( aGraphic, &line45 );
1049  else
1050  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1051 
1052  m_view->Update( &preview );
1053  }
1054 
1055  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1056  {
1058  aGraphic->SetWidth( m_lineWidth );
1059  line45.SetWidth( m_lineWidth );
1060  m_view->Update( &preview );
1061  }
1062 
1063  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && ( m_lineWidth > WIDTH_STEP ) )
1064  {
1066  aGraphic->SetWidth( m_lineWidth );
1067  line45.SetWidth( m_lineWidth );
1068  m_view->Update( &preview );
1069  }
1070  }
1071 
1072  m_view->Remove( &preview );
1073  m_controls->SetAutoPan( false );
1074  m_controls->CaptureCursor( false );
1075 
1076  return started;
1077 }
bool g_Segments_45_Only
Definition: pcbnew.cpp:72
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void SetShape(STROKE_T aShape)
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:158
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:269
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
virtual void SetLayer(LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
usual segment : line with rounded ends
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:161
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW * m_view
Definition: drawing_tool.h:256
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:263
STROKE_T
Enum STROKE_T is the set of shapes for segments (graphic segments and tracks) which are often in the ...
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:257
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
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:259
bool m_editModules
Definition: pcb_tool.h:112
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:245
LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
void SetEnd(const wxPoint &aEnd)
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel() returns the primary data model.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
Abstract interface for BOARD_ITEMs capable of storing other items inside.
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:266
void make45DegLine(DRAWSEGMENT *aSegment, DRAWSEGMENT *aHelper) const
Function make45DegLine() Forces a DRAWSEGMENT to be drawn at multiple of 45 degrees.
void SetWidth(int aWidth)
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
int DRAWING_TOOL::DrawSimilarZone ( const TOOL_EVENT aEvent)

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

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

Definition at line 671 of file drawing_tool.cpp.

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

Referenced by SetTransitions().

672 {
673  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
674  m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add similar zone" ) );
675 
676  return drawZone( false, ZONE_MODE::SIMILAR );
677 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
Add a new zone with the same settings as an existing one.
RAII class that sets an value at construction and resets it to the original value at destruction...
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
int DRAWING_TOOL::DrawZone ( const TOOL_EVENT aEvent)

Function DrawZone() Starts interactively drawing a zone.

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

Definition at line 644 of file drawing_tool.cpp.

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

Referenced by SetTransitions().

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

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

Parameters
aKeepoutdictates if the drawn polygon is a zone or a keepout area.
aModedictates the mode of the zone tool

Definition at line 1335 of file drawing_tool.cpp.

References TOOL_INTERACTIVE::Activate(), getSourceZoneForAction(), TOOL_BASE::getViewControls(), ID_NO_TOOL_SELECTED, m_frame, ZONE_CREATE_HELPER::PARAMS::m_keepout, ZONE_CREATE_HELPER::PARAMS::m_mode, ZONE_CREATE_HELPER::PARAMS::m_sourceZone, TOOL_BASE::m_toolMgr, TOOL_MANAGER::RunAction(), runPolygonEventLoop(), PCB_ACTIONS::selectionClear, and PCB_BASE_FRAME::SetToolID().

Referenced by DrawKeepout(), DrawSimilarZone(), DrawZone(), and DrawZoneCutout().

1336 {
1337  // get a source zone, if we need one
1338  ZONE_CONTAINER* sourceZone = nullptr;
1339 
1340  if( !getSourceZoneForAction( aMode, sourceZone ) )
1341  return 0;
1342 
1344 
1345  params.m_keepout = aKeepout;
1346  params.m_mode = aMode;
1347  params.m_sourceZone = sourceZone;
1348 
1349  ZONE_CREATE_HELPER zoneTool( *this, params );
1350 
1351  // the geometry manager which handles the zone geometry, and
1352  // hands the calculated points over to the zone creator tool
1353  POLYGON_GEOM_MANAGER polyGeomMgr( zoneTool );
1354 
1355  Activate(); // register for events
1356 
1357  auto& controls = *getViewControls();
1358 
1360 
1361  controls.ShowCursor( true );
1362  controls.SetSnapping( true );
1363 
1364  runPolygonEventLoop( polyGeomMgr );
1365 
1366  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
1367 
1368  return 0;
1369 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
bool getSourceZoneForAction(ZONE_MODE aMode, ZONE_CONTAINER *&aZone)
Function getSourceZoneForAction()
Parameters used to fully describe a zone creation process.
ZONE_CONTAINER * m_sourceZone
Zone settings source (for similar and cutout zones)
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
DRAWING_TOOL::ZONE_MODE m_mode
The zone mode to operate in
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
This class is an adjuct helper to the DRAWING_TOOL interactive tool, which handles incoming geometry ...
void Activate()
Function Activate() Runs the tool.
bool m_keepout
Should create a keepout zone?
void runPolygonEventLoop(POLYGON_GEOM_MANAGER &aPolyGeomMgr)
Run the event loop for polygon creation, sending user input on to the given POLYGON_GEOM_MANAGER for ...
Class that handles the drawing of a polygon, including management of last corner deletion and drawing...
int DRAWING_TOOL::DrawZoneCutout ( const TOOL_EVENT aEvent)

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

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

Definition at line 662 of file drawing_tool.cpp.

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

Referenced by SetTransitions().

663 {
664  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
665  m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add zone cutout" ) );
666 
667  return drawZone( false, ZONE_MODE::CUTOUT );
668 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
RAII class that sets an value at construction and resets it to the original value at destruction...
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
Make a cutout to an existing zone.
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 78 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

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

79  {
80  return m_editModules;
81  }
bool m_editModules
Definition: pcb_tool.h:112
const TOOL_EVENT TOOL_INTERACTIVE::evActivate ( std::string  aToolName = "")
protectedinherited

functions below are not yet implemented - their interface may change

const TOOL_EVENT TOOL_INTERACTIVE::evButtonDown ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evButtonUp ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evClick ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( int  aCommandId = -1)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evCommand ( std::string  aCommandStr = "")
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evDrag ( int  aButton = BUT_ANY)
protectedinherited
const TOOL_EVENT TOOL_INTERACTIVE::evMotion ( )
protectedinherited
LAYER_ID DRAWING_TOOL::getDrawingLayer ( ) const
private

Selects a non-copper layer for drawing

Definition at line 1423 of file drawing_tool.cpp.

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

Referenced by DrawArc(), drawArc(), DrawCircle(), DrawDimension(), DrawLine(), and drawSegment().

1424 {
1425  LAYER_ID layer = m_frame->GetActiveLayer();
1426 
1427  if( IsCopperLayer( layer ) )
1428  {
1429  if( layer == F_Cu )
1430  layer = F_SilkS;
1431  else if( layer == B_Cu )
1432  layer = B_SilkS;
1433  else
1434  layer = Dwgs_User;
1435 
1436  m_frame->SetActiveLayer( layer );
1437  }
1438 
1439  return layer;
1440 }
virtual LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
virtual void SetActiveLayer(LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
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 203 of file drawing_tool.cpp.

References m_mode.

Referenced by PCB_EDITOR_CONTROL::Init().

204 {
205  return m_mode;
206 }
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

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

Definition at line 193 of file tool_base.h.

References TOOL_BASE::getEditFrameInt().

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

194  {
195  return static_cast<T*>( getEditFrameInt() );
196  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:42
TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

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

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 122 of file tool_base.h.

References TOOL_BASE::m_toolId.

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

123  {
124  return m_toolId;
125  }
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:215
TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

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

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

Definition at line 144 of file tool_base.h.

References TOOL_BASE::m_toolMgr.

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

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 204 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

205  {
206  EDA_ITEM* m = getModelInt();
207 
208  return static_cast<T*>( m );
209  }
T
enum T contains all this lexer's tokens.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:48
const std::string& TOOL_BASE::GetName ( void  ) const
inlineinherited

Function GetName() Returns the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

References TOOL_BASE::m_toolName.

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

134  {
135  return m_toolName;
136  }
std::string m_toolName
Name of the tool.
Definition: tool_base.h:219
int DRAWING_TOOL::getSegmentWidth ( unsigned int  aLayer) const
private

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

Definition at line 1410 of file drawing_tool.cpp.

References Edge_Cuts, BOARD::GetDesignSettings(), m_board, BOARD_DESIGN_SETTINGS::m_DrawSegmentWidth, BOARD_DESIGN_SETTINGS::m_EdgeSegmentWidth, PCB_TOOL::m_editModules, and BOARD_DESIGN_SETTINGS::m_ModuleSegmentWidth.

Referenced by DrawArc(), DrawCircle(), DrawDimension(), and DrawLine().

1411 {
1412  assert( m_board );
1413 
1414  if( aLayer == Edge_Cuts )
1416  else if( m_editModules )
1418  else
1420 }
BOARD * m_board
Definition: drawing_tool.h:258
int m_ModuleSegmentWidth
Default width for all graphic lines.
int m_DrawSegmentWidth
current graphic line width (not EDGE layer)
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:530
bool m_editModules
Definition: pcb_tool.h:112
int m_EdgeSegmentWidth
current graphic line width (EDGE layer only)
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 72 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

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

73 {
74  return m_toolSettings;
75 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:221
bool DRAWING_TOOL::getSourceZoneForAction ( ZONE_MODE  aMode,
ZONE_CONTAINER *&  aZone 
)
private

Function getSourceZoneForAction()

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

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

Definition at line 1215 of file drawing_tool.cpp.

References ADD, dyn_cast(), SELECTION_TOOL::GetSelection(), TOOL_MANAGER::GetTool(), TOOL_BASE::m_toolMgr, TOOL_MANAGER::RunAction(), and PCB_ACTIONS::selectionCursor.

Referenced by drawZone().

1216 {
1217  aZone = nullptr;
1218 
1219  // not an action that needs a source zone
1220  if( aMode == ZONE_MODE::ADD )
1221  return true;
1222 
1224  const SELECTION& selection = selTool->GetSelection();
1225 
1226  if( selection.Empty() )
1228 
1229  // we want a single zone
1230  if( selection.Size() != 1 )
1231  return false;
1232 
1233  aZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1234 
1235  // expected a zone, but didn't get one
1236  if( !aZone )
1237  return false;
1238 
1239  return true;
1240 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
Casted dyn_cast(From aObject)
Function dyn_cast()
Definition: typeinfo.h:73
SELECTION & GetSelection()
Function GetSelection()
Add a new zone/keepout with fresh settings.
static TOOL_ACTION selectionCursor
Select a single item under the cursor position.
Definition: pcb_actions.h:50
TOOL_MENU& DRAWING_TOOL::GetToolMenu ( )
inline

Get the DRAWING_TOOL top-level context menu

Definition at line 62 of file drawing_tool.h.

References m_menu.

Referenced by PCB_EDITOR_CONTROL::Init().

63  {
64  return m_menu;
65  }
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:266
TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Function GetType() Returns the type of the tool.

Returns
The type of the tool.

Definition at line 111 of file tool_base.h.

References TOOL_BASE::m_type.

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

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

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

Referenced by PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), SELECTION_TOOL::disambiguationMenu(), PCB_TOOL::doInteractiveItemPlacement(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), PCBNEW_CONTROL::HighContrastMode(), PNS::TOOL_BASE::highlightNet(), PCB_EDITOR_CONTROL::HighlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), EDIT_TOOL::Main(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PanControl(), PNS::TOOL_BASE::pickSingleItem(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PCB_EDITOR_CONTROL::Reset(), PCBNEW_CONTROL::Reset(), MODULE_EDITOR_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), Reset(), SELECTION_TOOL::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PCBNEW_CONTROL::TrackDisplayMode(), POINT_EDITOR::updateEditedPoint(), PNS::TOOL_BASE::updateEndItem(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneUnfill(), PCB_EDITOR_CONTROL::ZoneUnfillAll(), COMMON_TOOLS::ZoomFitScreen(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), and SELECTION_TOOL::~SELECTION_TOOL().

31 {
32  return m_toolMgr->GetView();
33 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
KIGFX::VIEW * GetView() const
Definition: tool_manager.h:243
KIGFX::VIEW_CONTROLS * TOOL_BASE::getViewControls ( ) const
protectedinherited
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 122 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by LENGTH_TUNER_TOOL::Reset(), ZOOM_TOOL::SetTransitions(), LENGTH_TUNER_TOOL::SetTransitions(), ROUTER_TOOL::SetTransitions(), PAD_TOOL::SetTransitions(), MICROWAVE_TOOL::SetTransitions(), POINT_EDITOR::SetTransitions(), COMMON_TOOLS::SetTransitions(), PLACEMENT_TOOL::SetTransitions(), PCBNEW_CONTROL::SetTransitions(), MODULE_EDITOR_TOOLS::SetTransitions(), PICKER_TOOL::SetTransitions(), PCB_EDITOR_CONTROL::SetTransitions(), SELECTION_TOOL::SetTransitions(), EDIT_TOOL::SetTransitions(), and SetTransitions().

124 {
125  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
126 
127  goInternal( sptr, aConditions );
128 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:59
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
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 TOOL_BASE.

Definition at line 156 of file drawing_tool.cpp.

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

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

Function make45DegLine() Forces a DRAWSEGMENT to be drawn at multiple of 45 degrees.

The origin stays the same, the end of the aSegment is modified according to the current cursor position.

Parameters
aSegmentis the segment that is currently drawn.
aHelperis a helper line that shows the next possible segment.

Definition at line 1372 of file drawing_tool.cpp.

References KIGFX::VIEW_CONTROLS::GetCursorPosition(), DRAWSEGMENT::GetStart(), m_controls, SHAPE_LINE_CHAIN::Point(), SHAPE_LINE_CHAIN::PointCount(), DRAWSEGMENT::SetEnd(), DRAWSEGMENT::SetStart(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by drawSegment().

1373 {
1374  VECTOR2I cursorPos = m_controls->GetCursorPosition();
1375  VECTOR2I origin( aSegment->GetStart() );
1376  DIRECTION_45 direction( origin - cursorPos );
1377  SHAPE_LINE_CHAIN newChain = direction.BuildInitialTrace( origin, cursorPos );
1378 
1379  if( newChain.PointCount() > 2 )
1380  {
1381  aSegment->SetEnd( wxPoint( newChain.Point( -2 ).x, newChain.Point( -2 ).y ) );
1382  aHelper->SetStart( wxPoint( newChain.Point( -2 ).x, newChain.Point( -2 ).y ) );
1383  aHelper->SetEnd( wxPoint( newChain.Point( -1 ).x, newChain.Point( -1 ).y ) );
1384  }
1385  else
1386  {
1387  aSegment->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1388  aHelper->SetStart( wxPoint( cursorPos.x, cursorPos.y ) );
1389  aHelper->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1390  }
1391 }
int PointCount() const
Function PointCount()
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
Class DIRECTION_45.
Definition: direction45.h:33
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:257
void SetStart(const wxPoint &aStart)
Class SHAPE_LINE_CHAIN.
void SetEnd(const wxPoint &aEnd)
VECTOR2I & Point(int aIndex)
Function Point()
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int DRAWING_TOOL::PlaceDXF ( const TOOL_EVENT aEvent)

Function PlaceDXF() Places a drawing imported from a DXF file in module editor.

Definition at line 680 of file drawing_tool.cpp.

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), BUT_LEFT, BUT_RIGHT, SELECTION::Clear(), delta, DXF, PCB_ACTIONS::flip, KIGFX::VIEW_GROUP::FreeItems(), SELECTION::Front(), DRAWSEGMENT::GetAngle(), DRAWSEGMENT::GetBezControl1(), DRAWSEGMENT::GetBezControl2(), DRAWSEGMENT::GetBezierPoints(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), DRAWSEGMENT::GetEnd(), TOOL_EVT_UTILS::GetEventRotationAngle(), EDA_TEXT::GetHorizJustify(), DIALOG_DXF_IMPORT::GetImportedItems(), GetLayer(), PCB_BASE_EDIT_FRAME::GetModel(), DRAWSEGMENT::GetPolyPoints(), BOARD_ITEM::GetPosition(), DRAWSEGMENT::GetShape(), DRAWSEGMENT::GetStart(), EDA_TEXT::GetText(), EDA_TEXT::GetTextAngle(), EDA_TEXT::GetTextPos(), EDA_TEXT::GetTextSize(), EDA_TEXT::GetThickness(), DRAWSEGMENT::GetType(), EDA_TEXT::GetVertJustify(), DRAWSEGMENT::GetWidth(), EDA_TEXT::IsBold(), TOOL_EVT_UTILS::IsCancelInteractive(), EDA_TEXT::IsItalic(), EDA_TEXT::IsMirrored(), EDA_TEXT::IsMultilineAllowed(), TOOL_EVT_UTILS::IsRotateToolEvt(), m_controls, PCB_TOOL::m_editModules, m_frame, m_menu, m_mode, TOOL_BASE::m_toolMgr, m_view, PCB_LINE_T, PCB_TEXT_T, BOARD_COMMIT::Push(), KIGFX::VIEW::Remove(), TOOL_MANAGER::RunAction(), PCB_ACTIONS::selectionClear, DRAWSEGMENT::SetAngle(), DRAWSEGMENT::SetBezControl1(), DRAWSEGMENT::SetBezControl2(), DRAWSEGMENT::SetBezierPoints(), EDA_TEXT::SetBold(), DRAWSEGMENT::SetEnd(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetItalic(), BOARD_ITEM::SetLayer(), TEXTE_MODULE::SetLocalCoord(), EDA_TEXT::SetMirrored(), EDA_TEXT::SetMultilineAllowed(), DRAWSEGMENT::SetPolyPoints(), DRAWSEGMENT::SetShape(), KIGFX::VIEW_CONTROLS::SetSnapping(), DRAWSEGMENT::SetStart(), EDA_TEXT::SetText(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), DRAWSEGMENT::SetType(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), DRAWSEGMENT::SetWidth(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SetTransitions().

681 {
682  if( !m_frame->GetModel() )
683  return 0;
684 
685  DIALOG_DXF_IMPORT dlg( m_frame );
686  int dlgResult = dlg.ShowModal();
687 
688  const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
689 
690  if( dlgResult != wxID_OK || list.empty() )
691  return 0;
692 
693  VECTOR2I cursorPos = m_controls->GetCursorPosition();
694  VECTOR2I delta = cursorPos - list.front()->GetPosition();
695 
696  // Add a VIEW_GROUP that serves as a preview for the new item
697  SELECTION preview;
698  BOARD_COMMIT commit( m_frame );
699 
700  // Build the undo list & add items to the current view
701  for( auto item : list )
702  {
703  assert( item->Type() == PCB_LINE_T || item->Type() == PCB_TEXT_T );
704  preview.Add( item );
705  }
706 
707  BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( preview.Front() );
708  m_view->Add( &preview );
709 
711  m_controls->ShowCursor( true );
712  m_controls->SetSnapping( true );
713 
714  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
715 
716  Activate();
717 
718  // Main loop: keep receiving events
719  while( OPT_TOOL_EVENT evt = Wait() )
720  {
721  cursorPos = m_controls->GetCursorPosition();
722 
723  if( evt->IsMotion() )
724  {
725  delta = cursorPos - firstItem->GetPosition();
726 
727  for( auto item : preview )
728  static_cast<BOARD_ITEM*>( item )->Move( wxPoint( delta.x, delta.y ) );
729 
730  m_view->Update( &preview );
731  }
732 
733  else if( evt->Category() == TC_COMMAND )
734  {
735  // TODO it should be handled by EDIT_TOOL, so add items and select?
736  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
737  {
738  const auto rotationPoint = wxPoint( cursorPos.x, cursorPos.y );
739  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
740  *m_frame, *evt );
741 
742  for( auto item : preview )
743  {
744  static_cast<BOARD_ITEM*>( item )->Rotate( rotationPoint, rotationAngle );
745  }
746 
747  m_view->Update( &preview );
748  }
749  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
750  {
751  for( auto item : preview )
752  static_cast<BOARD_ITEM*>( item )->Flip( wxPoint( cursorPos.x, cursorPos.y ) );
753 
754  m_view->Update( &preview );
755  }
756  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
757  {
758  preview.FreeItems();
759  break;
760  }
761  }
762 
763  else if( evt->IsClick( BUT_RIGHT ) )
764  {
766  }
767 
768  else if( evt->IsClick( BUT_LEFT ) )
769  {
770  // Place the drawing
772 
773  for( auto item : preview )
774  {
775  if( m_editModules )
776  {
777  // Modules use different types for the same things,
778  // so we need to convert imported items to appropriate classes.
779  BOARD_ITEM* converted = NULL;
780 
781  switch( item->Type() )
782  {
783  case PCB_TEXT_T:
784  {
785  TEXTE_PCB* text = static_cast<TEXTE_PCB*>( item );
786  TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) parent );
787 
788  // Assignment operator also copies the item PCB_TEXT_T type,
789  // so it cannot be added to a module which handles PCB_MODULE_TEXT_T
790  textMod->SetText( text->GetText() );
791 #if 0
792  textMod->SetTextSize( text->GetTextSize() );
793  textMod->SetThickness( text->GetThickness() );
794  textMod->SetOrientation( text->GetTextAngle() );
795  textMod->SetTextPos( text->GetTextPos() );
796  textMod->SetTextSize( text->GetTextSize() );
797  textMod->SetVisible( text->GetVisible() );
798  textMod->SetMirrored( text->IsMirrored() );
799  textMod->SetItalic( text->IsItalic() );
800  textMod->SetBold( text->IsBold() );
801  textMod->SetHorizJustify( text->GetHorizJustify() );
802  textMod->SetVertJustify( text->GetVertJustify() );
803  textMod->SetMultilineAllowed( text->IsMultilineAllowed() );
804 #else
805  textMod->EDA_TEXT::SetEffects( *text );
806  textMod->SetLocalCoord(); // using changed SetTexPos() via SetEffects()
807 #endif
808  converted = textMod;
809  break;
810  }
811 
812  case PCB_LINE_T:
813  {
814  DRAWSEGMENT* seg = static_cast<DRAWSEGMENT*>( item );
815  EDGE_MODULE* modSeg = new EDGE_MODULE( (MODULE*) parent );
816 
817  // Assignment operator also copies the item PCB_LINE_T type,
818  // so it cannot be added to a module which handles PCB_MODULE_EDGE_T
819  modSeg->SetWidth( seg->GetWidth() );
820  modSeg->SetStart( seg->GetStart() );
821  modSeg->SetEnd( seg->GetEnd() );
822  modSeg->SetAngle( seg->GetAngle() );
823  modSeg->SetShape( seg->GetShape() );
824  modSeg->SetType( seg->GetType() );
825  modSeg->SetBezControl1( seg->GetBezControl1() );
826  modSeg->SetBezControl2( seg->GetBezControl2() );
827  modSeg->SetBezierPoints( seg->GetBezierPoints() );
828  modSeg->SetPolyPoints( seg->GetPolyPoints() );
829  converted = modSeg;
830  break;
831  }
832 
833  default:
834  assert( false );
835  break;
836  }
837 
838  if( converted )
839  converted->SetLayer( static_cast<BOARD_ITEM*>( item )->GetLayer() );
840 
841  delete item;
842  item = converted;
843  }
844 
845  if( item )
846  commit.Add( item );
847  }
848 
849  commit.Push( _( "Place a DXF drawing" ) );
850  break;
851  }
852  }
853 
854  preview.Clear();
855  m_view->Remove( &preview );
856 
857  return 0;
858 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:178
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void SetShape(STROKE_T aShape)
const wxPoint & GetBezControl2() const
bool IsMultilineAllowed() const
Definition: eda_text.h:188
void SetBezierPoints(const std::vector< wxPoint > &aPoints)
const wxPoint & GetTextPos() const
Definition: eda_text.h:224
bool IsItalic() const
Definition: eda_text.h:170
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void SetType(int aType)
void SetItalic(bool isItalic)
Definition: eda_text.h:169
EDA_ITEM * Front() const
Definition: selection.h:137
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
virtual void SetLayer(LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
void SetVisible(bool aVisible)
Definition: eda_text.h:175
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual const wxPoint & GetPosition() const =0
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:104
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
const std::vector< wxPoint > & GetPolyPoints() const
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:190
void SetBezControl2(const wxPoint &aPoint)
static const int delta[8][2]
Definition: solve.cpp:112
bool IsBold() const
Definition: eda_text.h:173
double GetTextAngle() const
Definition: eda_text.h:164
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:154
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW * m_view
Definition: drawing_tool.h:256
STROKE_T GetShape() const
RAII class that sets an value at construction and resets it to the original value at destruction...
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:194
const wxPoint & GetBezControl1() const
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:257
int GetType() const
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
void SetMultilineAllowed(bool aAllow)
Function SetMultiLineAllowed.
Definition: eda_text.h:187
void SetStart(const wxPoint &aStart)
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
bool m_editModules
Definition: pcb_tool.h:112
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
const std::vector< wxPoint > & GetBezierPoints() const
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:191
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:90
void SetLocalCoord()
Set relative coordinates.
double GetAngle() const
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:193
bool IsMirrored() const
Definition: eda_text.h:179
int GetWidth() const
void SetEnd(const wxPoint &aEnd)
static bool GetLayer(MODEL_VRML &aModel, LAYER_NUM layer, VRML_LAYER **vlayer)
void SetAngle(double aAngle)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees...
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel() returns the primary data model.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
const wxSize & GetTextSize() const
Definition: eda_text.h:215
Abstract interface for BOARD_ITEMs capable of storing other items inside.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void SetBold(bool aBold)
Definition: eda_text.h:172
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:266
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:148
void SetBezControl1(const wxPoint &aPoint)
virtual void SetText(const wxString &aText)
Definition: eda_text.h:141
void SetWidth(int aWidth)
int DRAWING_TOOL::PlaceText ( const TOOL_EVENT aEvent)

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

Definition at line 302 of file drawing_tool.cpp.

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), BUT_LEFT, BUT_RIGHT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), EDA_ITEM::ClearFlags(), PCB_ACTIONS::flip, BOARD_ITEM::Flip(), PCB_BASE_FRAME::GetActiveLayer(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), PCB_BASE_FRAME::GetDesignSettings(), TOOL_EVT_UTILS::GetEventRotationAngle(), PCB_BASE_EDIT_FRAME::GetModel(), BOARD_ITEM::GetPosition(), EDA_TEXT::GetText(), ID_MODEDIT_TEXT_TOOL, ID_NO_TOOL_SELECTED, ID_PCB_ADD_TEXT_BUTT, IS_NEW, IsBackLayer(), TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), m_controls, PCB_TOOL::m_editModules, m_frame, m_menu, m_mode, BOARD_DESIGN_SETTINGS::m_ModuleTextSize, BOARD_DESIGN_SETTINGS::m_ModuleTextWidth, BOARD_DESIGN_SETTINGS::m_PcbTextSize, BOARD_DESIGN_SETTINGS::m_PcbTextWidth, TOOL_BASE::m_toolMgr, m_view, BOARD_COMMIT::Push(), SELECTION::Remove(), KIGFX::VIEW::Remove(), BOARD_ITEM::Rotate(), TOOL_MANAGER::RunAction(), TOOL_INTERACTIVE::RunMainStack(), PCB_ACTIONS::selectionClear, KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_ITEM::SetFlags(), BOARD_ITEM::SetLayer(), EDA_TEXT::SetMirrored(), BOARD_ITEM::SetPosition(), KIGFX::VIEW_CONTROLS::SetSnapping(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetThickness(), PCB_BASE_FRAME::SetToolID(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TC_COMMAND, TEXT, KIGFX::VIEW::Update(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SetTransitions().

303 {
304  BOARD_ITEM* text = NULL;
305  const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
306  BOARD_COMMIT commit( m_frame );
307 
308  // Add a VIEW_GROUP that serves as a preview for the new item
309  SELECTION preview;
310  m_view->Add( &preview );
311 
313  m_controls->ShowCursor( true );
314  m_controls->SetSnapping( true );
315  // do not capture or auto-pan until we start placing some text
316 
317  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
318 
319  Activate();
321  wxCURSOR_PENCIL, _( "Add text" ) );
322 
323  // Main loop: keep receiving events
324  while( OPT_TOOL_EVENT evt = Wait() )
325  {
326  VECTOR2I cursorPos = m_controls->GetCursorPosition();
327 
329  {
330  if( text )
331  {
332  // Delete the old text and have another try
333  delete text;
334  text = NULL;
335 
336  preview.Clear();
337 
338  m_controls->SetAutoPan( false );
339  m_controls->CaptureCursor( false );
340  m_controls->ShowCursor( true );
341  }
342  else
343  break;
344 
345  if( evt->IsActivate() ) // now finish unconditionally
346  break;
347  }
348 
349  else if( text && evt->Category() == TC_COMMAND )
350  {
351  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
352  {
353  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
354  *m_frame, *evt );
355 
356  text->Rotate( text->GetPosition(), rotationAngle );
357  m_view->Update( &preview );
358  }
359  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
360  {
361  text->Flip( text->GetPosition() );
362  m_view->Update( &preview );
363  }
364  }
365 
366  else if( evt->IsClick( BUT_RIGHT ) )
367  {
369  }
370 
371  else if( evt->IsClick( BUT_LEFT ) )
372  {
373  if( !text )
374  {
375  // Init the new item attributes
376  if( m_editModules )
377  {
378  TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) m_frame->GetModel() );
379 
380  textMod->SetLayer( m_frame->GetActiveLayer() );
381  textMod->SetTextSize( dsnSettings.m_ModuleTextSize );
382  textMod->SetThickness( dsnSettings.m_ModuleTextWidth );
383  textMod->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
384 
385  DialogEditModuleText textDialog( m_frame, textMod, NULL );
386  bool placing;
387 
388  RunMainStack( [&]() {
389  placing = textDialog.ShowModal() && ( textMod->GetText().Length() > 0 );
390  } );
391 
392  if( placing )
393  text = textMod;
394  else
395  delete textMod;
396  }
397  else
398  {
399  TEXTE_PCB* textPcb = new TEXTE_PCB( m_frame->GetModel() );
400  // TODO we have to set IS_NEW, otherwise InstallTextPCB.. creates an undo entry :| LEGACY_CLEANUP
401  textPcb->SetFlags( IS_NEW );
402 
403  LAYER_ID layer = m_frame->GetActiveLayer();
404  textPcb->SetLayer( layer );
405 
406  // Set the mirrored option for layers on the BACK side of the board
407  if( IsBackLayer( layer ) )
408  textPcb->SetMirrored( true );
409 
410  textPcb->SetTextSize( dsnSettings.m_PcbTextSize );
411  textPcb->SetThickness( dsnSettings.m_PcbTextWidth );
412  textPcb->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
413 
414  RunMainStack( [&]() {
415  getEditFrame<PCB_EDIT_FRAME>()->InstallTextPCBOptionsFrame( textPcb, NULL );
416  } );
417 
418  if( textPcb->GetText().IsEmpty() )
419  delete textPcb;
420  else
421  text = textPcb;
422  }
423 
424  if( text == NULL )
425  continue;
426 
427  m_controls->CaptureCursor( true );
428  m_controls->SetAutoPan( true );
429  //m_controls->ShowCursor( false );
430 
431  preview.Add( text );
432  }
433  else
434  {
435  //assert( text->GetText().Length() > 0 );
436  //assert( text->GetTextSize().x > 0 && text->GetTextSize().y > 0 );
437 
438  text->ClearFlags();
439  preview.Remove( text );
440 
441  commit.Add( text );
442  commit.Push( _( "Place a text" ) );
443 
444  m_controls->CaptureCursor( false );
445  m_controls->SetAutoPan( false );
446  m_controls->ShowCursor( true );
447 
448  text = NULL;
449  }
450  }
451  else if( text && evt->IsMotion() )
452  {
453  text->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
454 
455  // Show a preview of the item
456  m_view->Update( &preview );
457  }
458  }
459 
460  m_view->Remove( &preview );
461  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
462 
463  return 0;
464 
465 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:178
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:81
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
virtual LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
virtual void SetPosition(const wxPoint &aPos)=0
int m_ModuleTextWidth
Default footprint texts thickness.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
int m_PcbTextWidth
current Pcb (not module) Text width
void RunMainStack(std::function< void()> aFunc)
Function RunMainStack()
bool IsBackLayer(LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
virtual void SetLayer(LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:340
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:223
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual const wxPoint & GetPosition() const =0
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
wxSize m_ModuleTextSize
Default footprint texts size.
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW * m_view
Definition: drawing_tool.h:256
#define IS_NEW
New item, just created.
Definition: base_struct.h:113
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:253
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
wxSize m_PcbTextSize
current Pcb (not module) Text size
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
virtual BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings returns the BOARD_DESIGN_SETTINGS for the BOARD owned by this frame...
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:257
virtual void Rotate(const wxPoint &aRotCentre, double aAngle)
Function Rotate Rotate this object.
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Update(VIEW_ITEM *aItem)
Function Update() For dynamic VIEWs, informs the associated VIEW that the graphical representation of...
Definition: view.cpp:1378
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:259
bool m_editModules
Definition: pcb_tool.h:112
virtual void Flip(const wxPoint &aCentre)
Function Flip Flip this object, i.e.
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:90
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:254
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel() returns the primary data model.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:310
int GetEventRotationAngle(const PCB_BASE_EDIT_FRAME &aFrame, const TOOL_EVENT &aEvt)
Function getEventRotationAngle()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:266
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:148
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:76
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.

Implements TOOL_BASE.

Definition at line 193 of file drawing_tool.cpp.

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

194 {
195  // Init variables used by every drawing tool
196  m_view = getView();
198  m_board = getModel<BOARD>();
199  m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
200 }
BOARD * m_board
Definition: drawing_tool.h:258
KIGFX::VIEW * m_view
Definition: drawing_tool.h:256
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:257
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:30
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 78 of file tool_interactive.cpp.

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

Referenced by PlaceText().

79 {
80  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
81 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
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.

Definition at line 1243 of file drawing_tool.cpp.

References POLYGON_GEOM_MANAGER::AddPoint(), BUT_LEFT, BUT_RIGHT, closeZoneOutline, POLYGON_GEOM_MANAGER::DEG45, POLYGON_GEOM_MANAGER::DeleteLastCorner(), deleteLastPoint, POLYGON_GEOM_MANAGER::DIRECT, TOOL_BASE::getViewControls(), TOOL_EVT_UTILS::IsCancelInteractive(), POLYGON_GEOM_MANAGER::IsPolygonInProgress(), m_menu, MD_CTRL, POLYGON_GEOM_MANAGER::NewPointClosesOutline(), POLYGON_GEOM_MANAGER::Reset(), POLYGON_GEOM_MANAGER::SetCursorPosition(), POLYGON_GEOM_MANAGER::SetFinished(), POLYGON_GEOM_MANAGER::SetLeaderMode(), TOOL_MENU::ShowContextMenu(), and TOOL_INTERACTIVE::Wait().

Referenced by drawZone().

1244 {
1245  auto& controls = *getViewControls();
1246  bool started = false;
1247 
1248  while( OPT_TOOL_EVENT evt = Wait() )
1249  {
1250  VECTOR2I cursorPos = controls.GetCursorPosition();
1251 
1253  {
1254  // pre-empted by another tool, give up
1255  // cancelled without an inprogress polygon, give up
1256  if( !polyGeomMgr.IsPolygonInProgress() || evt->IsActivate() )
1257  {
1258  break;
1259  }
1260 
1261  polyGeomMgr.Reset();
1262  // start again
1263  started = false;
1264 
1265  controls.SetAutoPan( false );
1266  controls.CaptureCursor( false );
1267  }
1268 
1269  else if( evt->IsClick( BUT_RIGHT ) )
1270  {
1272  }
1273 
1274  // events that lock in nodes
1275  else if( evt->IsClick( BUT_LEFT )
1276  || evt->IsDblClick( BUT_LEFT )
1277  || evt->IsAction( &closeZoneOutline ) )
1278  {
1279  // Check if it is double click / closing line (so we have to finish the zone)
1280  const bool endPolygon = evt->IsDblClick( BUT_LEFT )
1281  || evt->IsAction( &closeZoneOutline )
1282  || polyGeomMgr.NewPointClosesOutline( cursorPos );
1283 
1284  if( endPolygon )
1285  {
1286  polyGeomMgr.SetFinished();
1287  polyGeomMgr.Reset();
1288 
1289  // ready to start again
1290  started = false;
1291  controls.SetAutoPan( false );
1292  controls.CaptureCursor( false );
1293  }
1294  else // adding a corner
1295  {
1296  polyGeomMgr.AddPoint( cursorPos );
1297 
1298  if( !started )
1299  {
1300  started = true;
1301  controls.SetAutoPan( true );
1302  controls.CaptureCursor( true );
1303  }
1304  }
1305  }
1306 
1307  else if( evt->IsAction( &deleteLastPoint ) )
1308  {
1309  polyGeomMgr.DeleteLastCorner();
1310 
1311  if( !polyGeomMgr.IsPolygonInProgress() )
1312  {
1313  // report finished as an empty shape
1314  polyGeomMgr.SetFinished();
1315 
1316  // start again
1317  started = false;
1318  controls.SetAutoPan( false );
1319  controls.CaptureCursor( false );
1320  }
1321  }
1322 
1323  else if( polyGeomMgr.IsPolygonInProgress()
1324  && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
1325  {
1326  bool draw45 = evt->Modifier( MD_CTRL );
1327  polyGeomMgr.SetLeaderMode( draw45 ? POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45
1329  polyGeomMgr.SetCursorPosition( cursorPos );
1330  }
1331  } // end while
1332 }
static TOOL_ACTION closeZoneOutline("pcbnew.InteractiveDrawing.closeZoneOutline", AS_CONTEXT, 0, _("Close Zone Outline"), _("Close the outline of a zone in progress"), checked_ok_xpm)
static TOOL_ACTION deleteLastPoint("pcbnew.InteractiveDrawing.deleteLastPoint", AS_CONTEXT, WXK_BACK, _("Delete Last Point"), _("Delete the last point added to the current item"), undo_xpm)
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
Unconstrained point-to-point
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:36
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:266
int DRAWING_TOOL::SetAnchor ( const TOOL_EVENT aEvent)

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

Definition at line 861 of file drawing_tool.cpp.

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

Referenced by SetTransitions().

862 {
863  assert( m_editModules );
864 
865  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR );
866 
867  Activate();
868  m_frame->SetToolID( ID_MODEDIT_ANCHOR_TOOL, wxCURSOR_PENCIL,
869  _( "Place the footprint anchor" ) );
870 
871  m_controls->ShowCursor( true );
872  m_controls->SetSnapping( true );
873  m_controls->SetAutoPan( true );
874  m_controls->CaptureCursor( false );
875 
876  while( OPT_TOOL_EVENT evt = Wait() )
877  {
878  if( evt->IsClick( BUT_LEFT ) )
879  {
880  MODULE* module = (MODULE*) m_frame->GetModel();
881  BOARD_COMMIT commit( m_frame );
882  commit.Modify( module );
883 
884  // set the new relative internal local coordinates of footprint items
885  VECTOR2I cursorPos = m_controls->GetCursorPosition();
886  wxPoint moveVector = module->GetPosition() - wxPoint( cursorPos.x, cursorPos.y );
887  module->MoveAnchorPosition( moveVector );
888 
889  commit.Push( _( "Move the footprint reference anchor" ) );
890 
891  // Usually, we do not need to change twice the anchor position,
892  // so deselect the active tool
893  break;
894  }
895  else if( evt->IsClick( BUT_RIGHT ) )
896  {
898  }
899  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
900  break;
901  }
902 
903  m_frame->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
904 
905  return 0;
906 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Function SetToolID sets the tool command ID to aId and sets the cursor to aCursor.
const wxPoint & GetPosition() const override
Definition: class_module.h:143
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
void MoveAnchorPosition(const wxPoint &aMoveVector)
Function MoveAnchorPosition Move the reference point of the footprint It looks like a move footprint:...
RAII class that sets an value at construction and resets it to the original value at destruction...
virtual VECTOR2D GetCursorPosition() const =0
Function GetCursorPosition() Returns the current cursor position in world coordinates.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:257
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:259
bool m_editModules
Definition: pcb_tool.h:112
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel() returns the primary data model.
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:266
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

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

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

Definition at line 67 of file tool_interactive.cpp.

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

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

68 {
69  if( aMenu )
70  aMenu->SetTool( this );
71  else
72  aTrigger = CMENU_OFF;
73 
74  m_toolMgr->ScheduleContextMenu( this, aMenu, aTrigger );
75 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:220
void ScheduleContextMenu(TOOL_BASE *aTool, CONTEXT_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger)
Sets behaviour of the tool's context popup menu.
void SetTool(TOOL_INTERACTIVE *aTool)
Function SetTool() Sets a tool that is the creator of the menu.
void PCB_TOOL::SetEditModules ( bool  aEnabled)
inlineinherited

Function SetEditModules()

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

Parameters
aEnableddecides if the mode should be enabled.

Definition at line 73 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

74  {
75  m_editModules = aEnabled;
76  }
bool m_editModules
Definition: pcb_tool.h:112
void DRAWING_TOOL::SetTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from TOOL_BASE.

Definition at line 1394 of file drawing_tool.cpp.

References DrawArc(), PCB_ACTIONS::drawArc, DrawCircle(), PCB_ACTIONS::drawCircle, DrawDimension(), PCB_ACTIONS::drawDimension, PCB_ACTIONS::drawKeepout, DrawKeepout(), DrawLine(), PCB_ACTIONS::drawLine, PCB_ACTIONS::drawSimilarZone, DrawSimilarZone(), PCB_ACTIONS::drawZone, DrawZone(), PCB_ACTIONS::drawZoneCutout, DrawZoneCutout(), TOOL_INTERACTIVE::Go(), PCB_ACTIONS::placeDXF, PlaceDXF(), PlaceText(), PCB_ACTIONS::placeText, PCB_ACTIONS::setAnchor, and SetAnchor().

1395 {
1407 }
static TOOL_ACTION drawLine
Activation of the drawing tool (line)
Definition: pcb_actions.h:119
int DrawKeepout(const TOOL_EVENT &aEvent)
Function DrawKeepout() Starts interactively drawing a keepout area.
int DrawCircle(const TOOL_EVENT &aEvent)
Function DrawCircle() Starts interactively drawing a circle.
static TOOL_ACTION placeDXF
Activation of the drawing tool (placing a drawing from DXF file)
Definition: pcb_actions.h:152
int DrawZone(const TOOL_EVENT &aEvent)
Function DrawZone() Starts interactively drawing a zone.
static TOOL_ACTION drawSimilarZone
Activation of the drawing tool (drawing a similar ZONE to another one)
Definition: pcb_actions.h:143
static TOOL_ACTION drawArc
Activation of the drawing tool (arc)
Definition: pcb_actions.h:125
int DrawLine(const TOOL_EVENT &aEvent)
Function DrawLine() Starts interactively drawing a line.
static TOOL_ACTION setAnchor
Activation of the drawing tool (placing the footprint anchor)
Definition: pcb_actions.h:155
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Function Go()
static TOOL_ACTION placeText
Activation of the drawing tool (text)
Definition: pcb_actions.h:128
int PlaceDXF(const TOOL_EVENT &aEvent)
Function PlaceDXF() Places a drawing imported from a DXF file in module editor.
int PlaceText(const TOOL_EVENT &aEvent)
Function PlaceText() Displays a dialog that allows to input text and its settings and then lets the u...
static TOOL_ACTION drawDimension
Activation of the drawing tool (dimension)
Definition: pcb_actions.h:131
static TOOL_ACTION drawKeepout
Activation of the drawing tool (drawing a keepout area)
Definition: pcb_actions.h:137
static TOOL_ACTION drawZoneCutout
Activation of the drawing tool (drawing a ZONE cutout)
Definition: pcb_actions.h:140
int DrawZoneCutout(const TOOL_EVENT &aEvent)
Function DrawZoneCutout() Starts interactively drawing a zone cutout area of an existing zone...
static TOOL_ACTION drawCircle
Activation of the drawing tool (circle)
Definition: pcb_actions.h:122
int SetAnchor(const TOOL_EVENT &aEvent)
Function SetAnchor() Places the footprint anchor (only in module editor).
int DrawSimilarZone(const TOOL_EVENT &aEvent)
Function DrawSimilarZone() Starts interactively drawing a zone with same settings as an existing zone...
int DrawArc(const TOOL_EVENT &aEvent)
Function DrawArc() Starts interactively drawing an arc.
static TOOL_ACTION drawZone
Activation of the drawing tool (drawing a ZONE)
Definition: pcb_actions.h:134
int DrawDimension(const TOOL_EVENT &aEvent)
Function DrawDimension() Starts interactively drawing a dimension.
void DRAWING_TOOL::showContextMenu ( )
private

Shows the context menu for the drawing tool This menu consists of normal UI functions (zoom, grid, etc) And any suitable global functions for the active drawing type.

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

Function Wait()

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

Definition at line 55 of file tool_interactive.cpp.

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

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

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

Friends And Related Function Documentation

friend class ZONE_CREATE_HELPER
friend

Definition at line 273 of file drawing_tool.h.

Member Data Documentation

BOARD* DRAWING_TOOL::m_board
private

Definition at line 258 of file drawing_tool.h.

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

KIGFX::VIEW_CONTROLS* DRAWING_TOOL::m_controls
private
unsigned int DRAWING_TOOL::m_lineWidth
private

Stores the current line width for multisegment drawing.

Definition at line 263 of file drawing_tool.h.

Referenced by DrawArc(), drawArc(), DrawCircle(), DrawDimension(), DrawLine(), and drawSegment().

TOOL_MENU DRAWING_TOOL::m_menu
private

Menu model displayed by the tool.

Definition at line 266 of file drawing_tool.h.

Referenced by drawArc(), DrawDimension(), drawSegment(), GetToolMenu(), Init(), PlaceDXF(), PlaceText(), runPolygonEventLoop(), and SetAnchor().

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

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

Definition at line 215 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 220 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PCBNEW_CONTROL::AppendBoard(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), SELECTION_TOOL::clearSelection(), MODULE_EDITOR_TOOLS::CopyItems(), PAD_TOOL::copyPadSettings(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), drawArc(), DrawDimension(), drawSegment(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), EDIT_TOOL::getModificationPoint(), getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::Init(), PLACEMENT_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), MODULE_EDITOR_TOOLS::PasteItems(), PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::Remove(), SELECTION_TOOL::RequestSelection(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), SELECTION_TOOL::SelectItem(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), SELECTION_TOOL::UnselectItem(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), PCB_EDITOR_CONTROL::ZoneFill(), PCB_EDITOR_CONTROL::ZoneMerge(), and PCB_EDITOR_CONTROL::ZoneUnfill().

std::string TOOL_BASE::m_toolName
protectedinherited

Name of the tool.

Names are expected to obey the format application.ToolName

(eg. pcbnew.InteractiveSelection).

Definition at line 219 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 221 of file tool_base.h.

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

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 212 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

KIGFX::VIEW* DRAWING_TOOL::m_view
private

Definition at line 256 of file drawing_tool.h.

Referenced by drawArc(), DrawDimension(), drawSegment(), PlaceDXF(), PlaceText(), and Reset().

const unsigned int DRAWING_TOOL::WIDTH_STEP = 100000
staticprivate

Definition at line 269 of file drawing_tool.h.

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


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