KiCad PCB EDA Suite
DRAWING_TOOL Class Reference

Class DRAWING_TOOL. More...

#include <drawing_tool.h>

Inheritance diagram for DRAWING_TOOL:
PCB_TOOL TOOL_INTERACTIVE TOOL_BASE

Public Types

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

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 DrawGraphicPolygon (const TOOL_EVENT &aEvent)
 
int DrawVia (const TOOL_EVENT &aEvent)
 
int DrawZoneKeepout (const TOOL_EVENT &aEvent)
 Function DrawZoneKeepout() Starts interactively drawing a keepout area. More...
 
int DrawZoneCutout (const TOOL_EVENT &aEvent)
 Function DrawZoneCutout() Starts interactively drawing a zone cutout area of an existing zone. More...
 
int DrawSimilarZone (const TOOL_EVENT &aEvent)
 Function DrawSimilarZone() Starts interactively drawing a zone with same settings as an existing zone. More...
 
int 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 ()
 
bool IsToolActive () const
 

Protected Types

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

Protected Member Functions

void doInteractiveItemPlacement (INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
 Helper function for performing a common interactive idiom: wait for a left click, place an item there (perhaps with a dialog or other user interaction), then have it move with the mouse and respond to rotate/flip, etc. More...
 
KIGFX::VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () 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, ZONE_MODE::GRAPHIC_POLYGON }
 

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...
 
PCB_LAYER_ID getDrawingLayer () const
 

Selects a non-copper layer for drawing

More...
 

Private Attributes

KIGFX::VIEWm_view
 
KIGFX::VIEW_CONTROLSm_controls
 
BOARDm_board
 
PCB_BASE_EDIT_FRAMEm_frame
 
MODE m_mode
 
unsigned int m_lineWidth
 Stores the current line width for multisegment drawing. More...
 
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 Enumeration Documentation

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

Definition at line 98 of file pcb_tool.h.

enum DRAWING_TOOL::MODE
strong

The possible drawing modes of DRAWING_TOOL

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

Definition at line 68 of file drawing_tool.h.

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

GRAPHIC_POLYGON 

Definition at line 186 of file drawing_tool.h.

187  {
188  ADD,
189  CUTOUT,
190  SIMILAR,
191  GRAPHIC_POLYGON
192  };

Constructor & Destructor Documentation

DRAWING_TOOL::DRAWING_TOOL ( )

Definition at line 149 of file drawing_tool.cpp.

149  :
150  PCB_TOOL( "pcbnew.InteractiveDrawing" ),
151  m_view( nullptr ), m_controls( nullptr ),
152  m_board( nullptr ), m_frame( nullptr ), m_mode( MODE::NONE ),
153  m_lineWidth( 1 ),
154  m_menu( *this )
155 {
156 }
BOARD * m_board
Definition: drawing_tool.h:269
KIGFX::VIEW * m_view
Definition: drawing_tool.h:267
PCB_TOOL(TOOL_ID aId, const std::string &aName)
Constructor.
Definition: pcb_tool.h:65
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:274
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:268
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:270
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:277
DRAWING_TOOL::~DRAWING_TOOL ( )

Definition at line 159 of file drawing_tool.cpp.

160 {
161 }

Member Function Documentation

void TOOL_INTERACTIVE::Activate ( )
inherited

Function Activate() Runs the tool.

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

Definition at line 49 of file tool_interactive.cpp.

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

Referenced by EDIT_TOOL::copyToClipboard(), PCBNEW_CONTROL::DeleteItemCursor(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SetAnchor(), ROUTER_TOOL::SettingsDialog(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

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

Function attachManager()

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

Definition at line 59 of file tool_base.cpp.

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

Referenced by TOOL_MANAGER::RegisterTool().

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

Definition at line 126 of file pcb_tool.h.

Referenced by PCBNEW_CONTROL::AppendBoard(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), EDIT_TOOL::changeTrackWidthOnClick(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::doInteractiveItemPlacement(), MODULE_EDITOR_TOOLS::EnumeratePads(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::filterSelection(), ROUTER_TOOL::getNetclassDimensions(), PCBNEW_CONTROL::GridResetOrigin(), PAD_TOOL::haveFootprints(), PCBNEW_CONTROL::LayerNext(), PCBNEW_CONTROL::LayerPrev(), ROUTER_TOOL::mainLoop(), PCB_TOOL::module(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), ROUTER_TOOL::onTrackViaSizeChanged(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PadDisplayMode(), PCBNEW_CONTROL::PasteItemsFromClipboard(), PCB_EDITOR_CONTROL::PlaceModule(), MODULE_EDITOR_TOOLS::PlacePad(), PCB_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), PCBNEW_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), SELECTION_TOOL::selectable(), SELECTION_TOOL::selectAllItemsConnectedToItem(), SELECTION_TOOL::selectAllItemsConnectedToTrack(), SELECTION_TOOL::selectAllItemsOnNet(), SELECTION_TOOL::selectAllItemsOnSheet(), SELECTION_TOOL::selectPoint(), PCBNEW_CONTROL::TrackDisplayMode(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), PCBNEW_CONTROL::ZoneDisplayMode(), PCB_EDITOR_CONTROL::ZoneFillAll(), PCB_EDITOR_CONTROL::ZoneMerge(), and PCB_EDITOR_CONTROL::ZoneUnfillAll().

126 { return getModel<BOARD>(); }
void PCB_TOOL::doInteractiveItemPlacement ( INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

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

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

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

Definition at line 38 of file pcb_tool.cpp.

References TOOL_INTERACTIVE::Activate(), KIGFX::VIEW_GROUP::Add(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), PCB_TOOL::board(), BUT_LEFT, KIGFX::VIEW_CONTROLS::CaptureCursor(), SELECTION::Clear(), PCB_TOOL::controls(), INTERACTIVE_PLACER_BASE::CreateItem(), dyn_cast(), PCB_ACTIONS::flip, PCB_TOOL::frame(), KIGFX::VIEW_CONTROLS::GetCursorPosition(), TOOL_EVT_UTILS::GetEventRotationAngle(), TOOL_BASE::GetManager(), PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), INTERACTIVE_PLACER_BASE::m_board, INTERACTIVE_PLACER_BASE::m_frame, PCB_TOOL::module(), PCB_MODULE_T, INTERACTIVE_PLACER_BASE::PlaceItem(), 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(), DrawVia(), and MODULE_EDITOR_TOOLS::PlacePad().

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

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

Referenced by setTransitions().

283 {
285  DRAWSEGMENT* arc = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
286  BOARD_COMMIT commit( m_frame );
287 
288  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ARC );
289 
291  wxCURSOR_PENCIL, _( "Add graphic arc" ) );
293 
294  while( drawArc( arc ) )
295  {
296  if( arc )
297  {
298  commit.Add( arc );
299  commit.Push( _( "Draw an arc" ) );
300  }
301 
302  arc = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
303  }
304 
306 
307  return 0;
308 }
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:274
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:270
bool m_editModules
Definition: pcb_tool.h:129
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
Abstract interface for BOARD_ITEMs capable of storing other items inside.
bool drawArc(DRAWSEGMENT *&aGraphic)
Starts drawing an arc.
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 1108 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().

1109 {
1111 
1112  // Arc geometric construction manager
1114 
1115  // Arc drawing assistant overlay
1116  KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager );
1117 
1118  // Add a VIEW_GROUP that serves as a preview for the new item
1119  SELECTION preview;
1120  m_view->Add( &preview );
1121  m_view->Add( &arcAsst );
1122 
1123  m_controls->ShowCursor( true );
1124  m_controls->SetSnapping( true );
1125 
1126  Activate();
1127 
1128  bool firstPoint = false;
1129 
1130  // Main loop: keep receiving events
1131  while( OPT_TOOL_EVENT evt = Wait() )
1132  {
1133  const VECTOR2I cursorPos = m_controls->GetCursorPosition();
1134 
1135  if( evt->IsClick( BUT_LEFT ) )
1136  {
1137  if( !firstPoint )
1138  {
1139  m_controls->SetAutoPan( true );
1140  m_controls->CaptureCursor( true );
1141 
1142  PCB_LAYER_ID layer = getDrawingLayer();
1143 
1144  // Init the new item attributes
1145  // (non-geometric, those are handled by the manager)
1146  aGraphic->SetShape( S_ARC );
1147  aGraphic->SetWidth( m_lineWidth );
1148  aGraphic->SetLayer( layer );
1149 
1150  preview.Add( aGraphic );
1151  firstPoint = true;
1152  }
1153 
1154  arcManager.AddPoint( cursorPos, true );
1155  }
1156  else if( evt->IsAction( &deleteLastPoint ) )
1157  {
1158  arcManager.RemoveLastPoint();
1159  }
1160  else if( evt->IsMotion() )
1161  {
1162  // set angle snap
1163  arcManager.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1164 
1165  // update, but don't step the manager state
1166  arcManager.AddPoint( cursorPos, false );
1167  }
1168  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
1169  {
1170  preview.Clear();
1171  delete aGraphic;
1172  aGraphic = nullptr;
1173  break;
1174  }
1175  else if( evt->IsClick( BUT_RIGHT ) )
1176  {
1178  }
1179  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1180  {
1182  aGraphic->SetWidth( m_lineWidth );
1183  m_view->Update( &preview );
1184  }
1185  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && m_lineWidth > WIDTH_STEP )
1186  {
1188  aGraphic->SetWidth( m_lineWidth );
1189  m_view->Update( &preview );
1190  }
1191  else if( evt->IsAction( &PCB_ACTIONS::arcPosture ) )
1192  {
1193  arcManager.ToggleClockwise();
1194  }
1195 
1196  if( arcManager.IsComplete() )
1197  {
1198  break;
1199  }
1200  else if( arcManager.HasGeometryChanged() )
1201  {
1202  updateArcFromConstructionMgr( arcManager, *aGraphic );
1203  m_view->Update( &preview );
1204  m_view->Update( &arcAsst );
1205  }
1206  }
1207 
1208  preview.Remove( aGraphic );
1209  m_view->Remove( &arcAsst );
1210  m_view->Remove( &preview );
1211  m_controls->SetAutoPan( false );
1212  m_controls->CaptureCursor( false );
1213 
1214  return !arcManager.IsReset();
1215 }
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:178
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
static TOOL_ACTION deleteLastPoint("pcbnew.InteractiveDrawing.deleteLastPoint", AS_CONTEXT, WXK_BACK, _("Delete Last Point"), _("Delete the last point added to the current item"), undo_xpm)
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:280
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void RemoveLastPoint()
Undo the last point, and move the manager back to the previous step.
static void updateArcFromConstructionMgr(const KIGFX::PREVIEW::ARC_GEOM_MANAGER &aMgr, DRAWSEGMENT &aArc)
Update an arc DRAWSEGMENT from the current state of an Arc Geometry Manager.
void AddPoint(const VECTOR2I &aPt, bool aLockIn)
Add a point to the construction manager.
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:181
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW * m_view
Definition: drawing_tool.h:267
PCB_LAYER_ID
A quick note on layer IDs:
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
Arcs (with rounded ends)
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:274
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:268
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
static TOOL_ACTION arcPosture
Switch posture when drawing arc.
Definition: pcb_actions.h:184
void ToggleClockwise()
Reverse the current are direction
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:312
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:277
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 253 of file drawing_tool.cpp.

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

Referenced by setTransitions().

254 {
256  DRAWSEGMENT* circle = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
257  BOARD_COMMIT commit( m_frame );
258 
259  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::CIRCLE );
260 
262  wxCURSOR_PENCIL, _( "Add graphic circle" ) );
264 
265  while( drawSegment( S_CIRCLE, circle ) )
266  {
267  if( circle )
268  {
269  commit.Add( circle );
270  commit.Push( _( "Draw a circle" ) );
271  }
272 
273  circle = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
274  }
275 
277 
278  return 0;
279 }
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:274
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:270
bool m_editModules
Definition: pcb_tool.h:129
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
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 474 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_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(), EDA_DRAW_FRAME::SetNoToolSelected(), 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().

475 {
476  DIMENSION* dimension = NULL;
477  BOARD_COMMIT commit( m_frame );
478  int maxThickness;
479 
480  // Add a VIEW_GROUP that serves as a preview for the new item
481  SELECTION preview;
482 
483  m_view->Add( &preview );
484 
486  m_controls->ShowCursor( true );
487  m_controls->SetSnapping( true );
488 
489  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
490 
491  Activate();
492  m_frame->SetToolID( ID_PCB_DIMENSION_BUTT, wxCURSOR_PENCIL, _( "Add dimension" ) );
494 
495  enum DIMENSION_STEPS
496  {
497  SET_ORIGIN = 0,
498  SET_END,
499  SET_HEIGHT,
500  FINISHED
501  };
502  int step = SET_ORIGIN;
503 
504  // Main loop: keep receiving events
505  while( OPT_TOOL_EVENT evt = Wait() )
506  {
507  VECTOR2I cursorPos = m_controls->GetCursorPosition();
508 
510  {
511  if( step != SET_ORIGIN ) // start from the beginning
512  {
513  preview.Clear();
514 
515  delete dimension;
516  step = SET_ORIGIN;
517  }
518  else
519  break;
520 
521  if( evt->IsActivate() ) // now finish unconditionally
522  break;
523  }
524  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) && step != SET_ORIGIN )
525  {
527  dimension->SetWidth( m_lineWidth );
528  m_view->Update( &preview );
529  }
530  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && step != SET_ORIGIN )
531  {
532  if( m_lineWidth > WIDTH_STEP )
533  {
535  dimension->SetWidth( m_lineWidth );
536  m_view->Update( &preview );
537  }
538  }
539  else if( evt->IsClick( BUT_RIGHT ) )
540  {
542  }
543  else if( evt->IsClick( BUT_LEFT ) )
544  {
545  switch( step )
546  {
547  case SET_ORIGIN:
548  {
549  PCB_LAYER_ID layer = getDrawingLayer();
550 
551  if( layer == Edge_Cuts ) // dimensions are not allowed on EdgeCuts
552  layer = Dwgs_User;
553 
554  // Init the new item attributes
555  dimension = new DIMENSION( m_board );
556  dimension->SetLayer( layer );
557  dimension->SetOrigin( wxPoint( cursorPos.x, cursorPos.y ) );
558  dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
560 
562  maxThickness = Clamp_Text_PenSize( width, dimension->Text().GetTextSize() );
563 
564  if( width > maxThickness )
565  width = maxThickness;
566 
567  dimension->Text().SetThickness( width );
568  dimension->SetWidth( width );
569  dimension->AdjustDimensionDetails();
570 
571  preview.Add( dimension );
572 
573  m_controls->SetAutoPan( true );
574  m_controls->CaptureCursor( true );
575  }
576  break;
577 
578  case SET_END:
579  dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
580 
581  // Dimensions that have origin and end in the same spot are not valid
582  if( dimension->GetOrigin() == dimension->GetEnd() )
583  --step;
584 
585  break;
586 
587  case SET_HEIGHT:
588  {
589  if( wxPoint( cursorPos.x, cursorPos.y ) != dimension->GetPosition() )
590  {
591  assert( dimension->GetOrigin() != dimension->GetEnd() );
592  assert( dimension->GetWidth() > 0 );
593 
594  preview.Remove( dimension );
595 
596  commit.Add( dimension );
597  commit.Push( _( "Draw a dimension" ) );
598  }
599  }
600  break;
601  }
602 
603  if( ++step == FINISHED )
604  {
605  step = SET_ORIGIN;
606  m_controls->SetAutoPan( false );
607  m_controls->CaptureCursor( false );
608  }
609  }
610  else if( evt->IsMotion() )
611  {
612  switch( step )
613  {
614  case SET_END:
615  dimension->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
616  break;
617 
618  case SET_HEIGHT:
619  {
620  // Calculating the direction of travel perpendicular to the selected axis
621  double angle = dimension->GetAngle() + ( M_PI / 2 );
622 
623  wxPoint pos( cursorPos.x, cursorPos.y );
624  wxPoint delta( pos - dimension->m_featureLineDO );
625  double height = ( delta.x * cos( angle ) ) + ( delta.y * sin( angle ) );
626  dimension->SetHeight( height );
627  }
628  break;
629  }
630 
631  // Show a preview of the item
632  m_view->Update( &preview );
633  }
634  }
635 
636  if( step != SET_ORIGIN )
637  delete dimension;
638 
639  m_view->Remove( &preview );
641 
642  return 0;
643 }
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:269
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:178
int m_PcbTextWidth
current Pcb (not module) Text width
int GetWidth() const
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:280
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
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
void SetLayer(PCB_LAYER_ID aLayer) override
Function SetLayer sets the layer this item is on.
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:181
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW * m_view
Definition: drawing_tool.h:267
int getSegmentWidth(unsigned int aLayer) const
Returns the appropriate width for a segment depending on the settings.
PCB_LAYER_ID
A quick note on layer IDs:
void SetOrigin(const wxPoint &aOrigin)
Function SetOrigin Sets a new origin of the crossbar line.
RAII class that sets an value at construction and resets it to the original value at destruction...
const wxPoint & GetEnd()
Function GetEnd.
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.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
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:274
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:268
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
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:270
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
TEXTE_PCB & Text()
void Activate()
Function Activate() Runs the tool.
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
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:277
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::DrawGraphicPolygon ( const TOOL_EVENT aEvent)

Definition at line 675 of file drawing_tool.cpp.

References drawZone(), GRAPHIC_POLYGON, ID_PCB_ADD_POLYGON_BUTT, m_frame, m_mode, and PCB_BASE_FRAME::SetToolID().

Referenced by setTransitions().

676 {
677  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::GRAPHIC_POLYGON );
678 
679  m_frame->SetToolID( ID_PCB_ADD_POLYGON_BUTT, wxCURSOR_PENCIL, _( "Add graphic polygon" ) );
680 
681  return drawZone( false, ZONE_MODE::GRAPHIC_POLYGON );
682 }
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:270
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 217 of file drawing_tool.cpp.

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

Referenced by setTransitions().

218 {
220  DRAWSEGMENT* line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
221 
222  boost::optional<VECTOR2D> startingPoint;
223  BOARD_COMMIT commit( m_frame );
224 
225  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::LINE );
226 
228  wxCURSOR_PENCIL, _( "Add graphic line" ) );
230 
231  while( drawSegment( S_SEGMENT, line, startingPoint ) )
232  {
233  if( line )
234  {
235  commit.Add( line );
236  commit.Push( _( "Draw a line segment" ) );
237  startingPoint = line->GetEnd();
238  }
239  else
240  {
241  startingPoint = boost::none;
242  }
243 
244  line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
245  }
246 
248 
249  return 0;
250 }
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:274
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:270
bool m_editModules
Definition: pcb_tool.h:129
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
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.
aStartingPointis a starting point for this new DRAWSEGMENT. If exists the new item has its start point set to aStartingPoint, and its settings (width, layer) set to the current default values.
Returns
False if the tool was cancelled before the origin was set or origin and end are the same point.

Definition at line 921 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, PCB_TOOL::frame(), 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, PCB_GENERAL_SETTINGS::m_use45DegreeGraphicSegments, 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(), PCB_BASE_FRAME::Settings(), 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().

923 {
924  // Only two shapes are currently supported
925  assert( aShape == S_SEGMENT || aShape == S_CIRCLE );
926 
927  DRAWSEGMENT line45;
928 
929  // Add a VIEW_GROUP that serves as a preview for the new item
930  SELECTION preview;
931  m_view->Add( &preview );
932 
934  m_controls->ShowCursor( true );
935  m_controls->SetSnapping( true );
936 
937  Activate();
938 
939  bool direction45 = false; // 45 degrees only mode
940  bool started = false;
941  VECTOR2I cursorPos = m_controls->GetCursorPosition();
942 
943  if( aStartingPoint )
944  {
945  // Init the new item attributes
946  aGraphic->SetShape( (STROKE_T) aShape );
947  aGraphic->SetWidth( m_lineWidth );
948  aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) );
949  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
950  aGraphic->SetLayer( getDrawingLayer() );
951 
952  if( aShape == S_SEGMENT )
953  line45 = *aGraphic; // used only for direction 45 mode with lines
954 
955  preview.Add( aGraphic );
956  m_controls->SetAutoPan( true );
957  m_controls->CaptureCursor( true );
958 
959  started = true;
960  }
961 
962  // Main loop: keep receiving events
963  while( OPT_TOOL_EVENT evt = Wait() )
964  {
965  cursorPos = m_controls->GetCursorPosition();
966 
967  // 45 degree angle constraint enabled with an option and toggled with Ctrl
968  const bool limit45 = ( frame()->Settings().m_use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) );
969 
970  if( direction45 != limit45 && started && aShape == S_SEGMENT )
971  {
972  direction45 = limit45;
973 
974  if( direction45 )
975  {
976  preview.Add( &line45 );
977  make45DegLine( aGraphic, &line45 );
978  }
979  else
980  {
981  preview.Remove( &line45 );
982  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
983  }
984 
985  m_view->Update( &preview );
986  }
987 
989  {
990  preview.Clear();
991  m_view->Update( &preview );
992  delete aGraphic;
993  aGraphic = NULL;
994  break;
995  }
996  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
997  {
998  aGraphic->SetLayer( getDrawingLayer() );
999  m_view->Update( &preview );
1000  }
1001  else if( evt->IsClick( BUT_RIGHT ) )
1002  {
1004  }
1005  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
1006  {
1007  if( !started )
1008  {
1009  // Init the new item attributes
1010  aGraphic->SetShape( (STROKE_T) aShape );
1011  aGraphic->SetWidth( m_lineWidth );
1012  aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) );
1013  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1014  aGraphic->SetLayer( getDrawingLayer() );
1015 
1016  if( aShape == S_SEGMENT )
1017  line45 = *aGraphic; // used only for direction 45 mode with lines
1018 
1019  preview.Add( aGraphic );
1020  m_controls->SetAutoPan( true );
1021  m_controls->CaptureCursor( true );
1022 
1023  started = true;
1024  }
1025  else
1026  {
1027  if( aGraphic->GetEnd() == aGraphic->GetStart()
1028  || ( evt->IsDblClick( BUT_LEFT ) && aShape == S_SEGMENT ) )
1029  // User has clicked twice in the same spot
1030  {
1031  // a clear sign that the current drawing is finished
1032  // Now we have to add the helper line as well
1033  if( direction45 )
1034  {
1035  BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
1036  DRAWSEGMENT* l = m_editModules ? new EDGE_MODULE( (MODULE*) parent )
1037  : new DRAWSEGMENT;
1038 
1039  // Copy coordinates, layer, etc.
1040  *static_cast<DRAWSEGMENT*>( l ) = line45;
1041  l->SetEnd( aGraphic->GetStart() );
1042 
1043  BOARD_COMMIT commit( m_frame );
1044  commit.Add( l );
1045  commit.Push( _( "Draw a line" ) );
1046  }
1047 
1048  delete aGraphic;
1049  aGraphic = NULL;
1050  }
1051 
1052  preview.Clear();
1053  break;
1054  }
1055  }
1056  else if( evt->IsMotion() )
1057  {
1058  // 45 degree lines
1059  if( direction45 && aShape == S_SEGMENT )
1060  make45DegLine( aGraphic, &line45 );
1061  else
1062  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1063 
1064  m_view->Update( &preview );
1065  }
1066  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1067  {
1069  aGraphic->SetWidth( m_lineWidth );
1070  line45.SetWidth( m_lineWidth );
1071  m_view->Update( &preview );
1072  }
1073  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && ( m_lineWidth > WIDTH_STEP ) )
1074  {
1076  aGraphic->SetWidth( m_lineWidth );
1077  line45.SetWidth( m_lineWidth );
1078  m_view->Update( &preview );
1079  }
1080  }
1081 
1082  m_view->Remove( &preview );
1083  m_controls->SetAutoPan( false );
1084  m_controls->CaptureCursor( false );
1085 
1086  return started;
1087 }
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:178
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:280
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
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:181
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:71
KIGFX::VIEW * m_view
Definition: drawing_tool.h:267
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
PCB_GENERAL_SETTINGS & Settings()
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:274
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:268
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
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:270
bool m_editModules
Definition: pcb_tool.h:129
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:270
void SetEnd(const wxPoint &aEnd)
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
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:277
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 685 of file drawing_tool.cpp.

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

Referenced by setTransitions().

686 {
687  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
688 
689  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add similar zone" ) );
690 
691  return drawZone( false, ZONE_MODE::SIMILAR );
692 }
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:270
int DRAWING_TOOL::DrawVia ( const TOOL_EVENT aEvent)

Definition at line 1395 of file drawing_tool.cpp.

References B_Cu, PCB_TOOL::doInteractiveItemPlacement(), F_Cu, PCB_TOOL::frame(), PCB_BASE_FRAME::GetActiveLayer(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), ZONE_CONTAINER::GetLayer(), VIA::GetLayerSet(), NETINFO_ITEM::GetMicroViaDrillSize(), NETINFO_ITEM::GetMicroViaSize(), BOARD_CONNECTED_ITEM::GetNet(), VIA::GetPosition(), PCB_BASE_FRAME::GetScreen(), VIA::GetViaType(), ID_NO_TOOL_SELECTED, ID_PCB_DRAW_VIA_BUTT, In1_Cu, PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_PROPERTIES, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, BOARD::IsLayerVisible(), m_board, m_frame, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, mod, BOARD::Modules(), VIA::SetDrill(), VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), PCB_BASE_FRAME::SetToolID(), VIA::SetViaType(), TRACK::SetWidth(), ToLAYER_ID(), BOARD::Tracks(), VIA, VIA_BLIND_BURIED, VIA_MICROVIA, and BOARD::Zones().

Referenced by setTransitions().

1396 {
1397  struct VIA_PLACER : public INTERACTIVE_PLACER_BASE
1398  {
1399  int findStitchedZoneNet( VIA* aVia )
1400  {
1401  const auto pos = aVia->GetPosition();
1402  const auto lset = aVia->GetLayerSet();
1403 
1404  for( auto tv : m_board->Tracks() ) // fixme: move to BOARD class?
1405  {
1406  if( tv->HitTest( pos ) && ( tv->GetLayerSet() & lset ).any() )
1407  return -1;
1408  }
1409 
1410  for( auto mod : m_board->Modules() )
1411  {
1412  for( auto pad : mod->Pads() )
1413  {
1414  if( pad->HitTest( pos ) && ( pad->GetLayerSet() & lset ).any() )
1415  return -1;
1416  }
1417  }
1418 
1419  std::vector<ZONE_CONTAINER*> foundZones;
1420 
1421  for( auto zone : m_board->Zones() )
1422  {
1423  if( zone->HitTestFilledArea( pos ) )
1424  {
1425  foundZones.push_back( zone );
1426  }
1427  }
1428 
1429  std::sort( foundZones.begin(), foundZones.end(),
1430  [] ( const ZONE_CONTAINER* a, const ZONE_CONTAINER* b ) {
1431  return a->GetLayer() < b->GetLayer();
1432  } );
1433 
1434  // first take the net of the active layer
1435  for( auto z : foundZones )
1436  {
1437  if( m_frame->GetActiveLayer() == z->GetLayer() )
1438  return z->GetNetCode();
1439  }
1440 
1441  // none? take the topmost visible layer
1442  for( auto z : foundZones )
1443  {
1444  if( m_board->IsLayerVisible( z->GetLayer() ) )
1445  return z->GetNetCode();
1446  }
1447 
1448  return -1;
1449  }
1450 
1451  bool PlaceItem( BOARD_ITEM* aItem ) override
1452  {
1453  auto via = static_cast<VIA*>( aItem );
1454  int newNet = findStitchedZoneNet( via );
1455 
1456  if( newNet > 0 )
1457  via->SetNetCode( newNet );
1458 
1459  return false;
1460  }
1461 
1462  std::unique_ptr<BOARD_ITEM> CreateItem() override
1463  {
1464  auto& ds = m_board->GetDesignSettings();
1465  VIA* via = new VIA( m_board );
1466 
1467  via->SetNetCode( 0 );
1468  via->SetViaType( ds.m_CurrentViaType );
1469 
1470  // for microvias, the size and hole will be changed later.
1471  via->SetWidth( ds.GetCurrentViaSize() );
1472  via->SetDrill( ds.GetCurrentViaDrill() );
1473 
1474  // Usual via is from copper to component.
1475  // layer pair is B_Cu and F_Cu.
1476  via->SetLayerPair( B_Cu, F_Cu );
1477 
1478  PCB_LAYER_ID first_layer = m_frame->GetActiveLayer();
1479  PCB_LAYER_ID last_layer;
1480 
1481  // prepare switch to new active layer:
1482  if( first_layer != m_frame->GetScreen()->m_Route_Layer_TOP )
1483  last_layer = m_frame->GetScreen()->m_Route_Layer_TOP;
1484  else
1485  last_layer = m_frame->GetScreen()->m_Route_Layer_BOTTOM;
1486 
1487  // Adjust the actual via layer pair
1488  switch( via->GetViaType() )
1489  {
1490  case VIA_BLIND_BURIED:
1491  via->SetLayerPair( first_layer, last_layer );
1492  break;
1493 
1494  case VIA_MICROVIA: // from external to the near neighbor inner layer
1495  {
1496  PCB_LAYER_ID last_inner_layer =
1497  ToLAYER_ID( ( m_board->GetCopperLayerCount() - 2 ) );
1498 
1499  if( first_layer == B_Cu )
1500  last_layer = last_inner_layer;
1501  else if( first_layer == F_Cu )
1502  last_layer = In1_Cu;
1503  else if( first_layer == last_inner_layer )
1504  last_layer = B_Cu;
1505  else if( first_layer == In1_Cu )
1506  last_layer = F_Cu;
1507 
1508  // else error: will be removed later
1509  via->SetLayerPair( first_layer, last_layer );
1510 
1511  // Update diameter and hole size, which where set previously
1512  // for normal vias
1513  NETINFO_ITEM* net = via->GetNet();
1514 
1515  if( net )
1516  {
1517  via->SetWidth( net->GetMicroViaSize() );
1518  via->SetDrill( net->GetMicroViaDrillSize() );
1519  }
1520  }
1521  break;
1522 
1523  default:
1524  break;
1525  }
1526 
1527  return std::unique_ptr<BOARD_ITEM>( via );
1528  }
1529  };
1530 
1531  VIA_PLACER placer;
1532 
1533  frame()->SetToolID( ID_PCB_DRAW_VIA_BUTT, wxCURSOR_PENCIL, _( "Add vias" ) );
1534 
1535  doInteractiveItemPlacement( &placer, _( "Place via" ),
1537 
1538  frame()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
1539 
1540  return 0;
1541 }
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.
virtual LSET GetLayerSet() const override
Function GetLayerSet returns a "layer mask", which is a bitmap of all layers on which the TRACK segme...
BOARD * m_board
Definition: drawing_tool.h:269
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:440
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
int GetCopperLayerCount() const
Function GetCopperLayerCount.
virtual PCB_LAYER_ID GetLayer() const override
Function GetLayer returns the primary layer this item is on.
Definition: class_zone.cpp:182
void SetWidth(int aWidth)
Definition: class_track.h:114
PCB_LAYER_ID
A quick note on layer IDs:
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:250
VIATYPE_T GetViaType() const
Definition: class_track.h:439
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:125
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:532
PCB_LAYER_ID m_Route_Layer_BOTTOM
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_Layer contains the top layer, the other layer is in m_BottomLayer...
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:270
Class NETINFO_ITEM handles the data for a net.
Definition: class_netinfo.h:69
ZONE_CONTAINERS & Zones()
Definition: class_board.h:252
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:447
PCB_SCREEN * GetScreen() const override
Function GetScreen returns a pointer to a BASE_SCREEN or one of its derivatives.
const wxPoint & GetPosition() const override
Definition: class_track.h:411
int GetMicroViaDrillSize()
Function GetViaDrillSize returns the size of via drills used to route this net.
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:249
void doInteractiveItemPlacement(INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
Helper function for performing a common interactive idiom: wait for a left click, place an item there...
Definition: pcb_tool.cpp:38
int GetMicroViaSize()
Function GetMicroViaSize returns the size of vias used to route this net.
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:774
#define mod(a, n)
Definition: greymap.cpp:24
NETINFO_ITEM * GetNet() const
Function GetNet Returns NET_INFO object for a given item.
PCB_LAYER_ID m_Route_Layer_TOP
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
Function IsLayerVisible is a proxy function that calls the correspondent function in m_BoardSettings ...
Definition: class_board.h:451
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 646 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().

647 {
648  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
649 
650  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zones" ) );
651 
652  return drawZone( false, ZONE_MODE::ADD );
653 }
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:270
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: ADD add a new zone/keepout with fresh settings CUTOUT add a cutout to an existing zone SIMILAR add a new zone with the same settings as an existing one

Definition at line 1334 of file drawing_tool.cpp.

References TOOL_INTERACTIVE::Activate(), PCB_TOOL::controls(), getSourceZoneForAction(), TOOL_BASE::getViewControls(), 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, EDA_DRAW_FRAME::SetNoToolSelected(), KIGFX::VIEW_CONTROLS::SetSnapping(), and KIGFX::VIEW_CONTROLS::ShowCursor().

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

1335 {
1336  // get a source zone, if we need one. We need it for:
1337  // ZONE_MODE::CUTOUT (adding a hole to the source zone)
1338  // ZONE_MODE::SIMILAR (creating a new zone using settings of source zone
1339  ZONE_CONTAINER* sourceZone = nullptr;
1340 
1341  if( !getSourceZoneForAction( aMode, sourceZone ) )
1342  return 0;
1343 
1345 
1346  params.m_keepout = aKeepout;
1347  params.m_mode = aMode;
1348  params.m_sourceZone = sourceZone;
1349 
1350  ZONE_CREATE_HELPER zoneTool( *this, params );
1351 
1352  // the geometry manager which handles the zone geometry, and
1353  // hands the calculated points over to the zone creator tool
1354  POLYGON_GEOM_MANAGER polyGeomMgr( zoneTool );
1355 
1356  Activate(); // register for events
1357 
1358  auto& controls = *getViewControls();
1359 
1361 
1362  controls.ShowCursor( true );
1363  controls.SetSnapping( true );
1364 
1365  runPolygonEventLoop( polyGeomMgr );
1366 
1368 
1369  return 0;
1370 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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 getSourceZoneForAction(ZONE_MODE aMode, ZONE_CONTAINER *&aZone)
Function getSourceZoneForAction()
Parameters used to fully describe a zone creation process.
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:124
ZONE_CONTAINER * m_sourceZone
Zone settings source (for similar and cutout zones)
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
DRAWING_TOOL::ZONE_MODE m_mode
The zone mode to operate in
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:270
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
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 666 of file drawing_tool.cpp.

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

Referenced by setTransitions().

667 {
668  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
669 
670  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zone cutout" ) );
671 
672  return drawZone( false, ZONE_MODE::CUTOUT );
673 }
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:270
Make a cutout to an existing zone.
int DRAWING_TOOL::DrawZoneKeepout ( const TOOL_EVENT aEvent)

Function DrawZoneKeepout() Starts interactively drawing a keepout area.

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

Definition at line 656 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().

657 {
658  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::KEEPOUT );
659 
660  m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add keepout" ) );
661 
662  return drawZone( true, ZONE_MODE::ADD );
663 }
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:270
Add a new zone/keepout with fresh settings.
bool PCB_TOOL::EditingModules ( ) const
inlineinherited

Definition at line 91 of file pcb_tool.h.

References PCB_TOOL::m_editModules.

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

92  {
93  return m_editModules;
94  }
bool m_editModules
Definition: pcb_tool.h:129
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
PCB_EDIT_FRAME* PCB_TOOL::frame ( ) const
inlineprotectedinherited

Definition at line 125 of file pcb_tool.h.

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), PAD_TOOL::applyPadSettings(), EDIT_TOOL::changeTrackWidthOnClick(), PNS::TOOL_BASE::checkSnap(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), ROUTER_TOOL::CustomTrackWidthDialog(), PCB_TOOL::doInteractiveItemPlacement(), ROUTER_TOOL::DpDimensionsDialog(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), DrawVia(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), ROUTER_TOOL::finishInteractive(), ROUTER_TOOL::InlineDrag(), PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), LENGTH_TUNER_TOOL::meanderSettingsDialog(), EDIT_TOOL::MeasureTool(), MODULE_EDITOR_TOOLS::ModuleEdgeOutlines(), MODULE_EDITOR_TOOLS::ModuleTextOutlines(), ROUTER_TOOL::onViaCommand(), PCBNEW_CONTROL::PasteItemsFromClipboard(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), PNS::TOOL_BASE::pickSingleItem(), MODULE_EDITOR_TOOLS::PlacePad(), ROUTER_TOOL::prepareInteractive(), PAD_TOOL::pushPadSettings(), PNS::TOOL_BASE::Reset(), ROUTER_TOOL::RouteDiffPair(), ROUTER_TOOL::RouteSingleTrace(), ROUTER_TOOL::SettingsDialog(), ROUTER_TOOL::switchLayerOnViaPlacement(), LENGTH_TUNER_TOOL::TuneDiffPair(), LENGTH_TUNER_TOOL::TuneDiffPairSkew(), LENGTH_TUNER_TOOL::TuneSingleTrace(), and PCB_EDITOR_CONTROL::ZoneFillAll().

125 { return getEditFrame<PCB_EDIT_FRAME>(); }
PCB_LAYER_ID DRAWING_TOOL::getDrawingLayer ( ) const
private

Selects a non-copper layer for drawing

Definition at line 1575 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().

1576 {
1577  PCB_LAYER_ID layer = m_frame->GetActiveLayer();
1578 
1579  if( IsCopperLayer( layer ) )
1580  {
1581  if( layer == F_Cu )
1582  layer = F_SilkS;
1583  else if( layer == B_Cu )
1584  layer = B_SilkS;
1585  else
1586  layer = Dwgs_User;
1587 
1588  m_frame->SetActiveLayer( layer );
1589  }
1590 
1591  return layer;
1592 }
PCB_LAYER_ID
A quick note on layer IDs:
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:270
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active 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 211 of file drawing_tool.cpp.

References m_mode.

Referenced by PCB_EDITOR_CONTROL::Init().

212 {
213  return m_mode;
214 }
template<typename T >
T* TOOL_BASE::getEditFrame ( ) const
inlineprotectedinherited

Function getEditFrame()

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

Definition at line 188 of file tool_base.h.

References TOOL_BASE::getEditFrameInt().

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

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
T
enum T contains all this lexer's tokens.
wxWindow * getEditFrameInt() const
Definition: tool_base.cpp:47
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:210
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(), and CONTEXT_MENU::onMenuEvent().

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

Function getModel()

Returns the model object if it matches the requested type.

Definition at line 199 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

200  {
201  EDA_ITEM* m = getModelInt();
202 
203  return static_cast<T*>( m );
204  }
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:165
EDA_ITEM * getModelInt() const
Definition: tool_base.cpp:53
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:214
int DRAWING_TOOL::getSegmentWidth ( unsigned int  aLayer) const
private

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

Definition at line 1562 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().

1563 {
1564  assert( m_board );
1565 
1566  if( aLayer == Edge_Cuts )
1568  else if( m_editModules )
1570  else
1572 }
BOARD * m_board
Definition: drawing_tool.h:269
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:532
bool m_editModules
Definition: pcb_tool.h:129
int m_EdgeSegmentWidth
current graphic line width (EDGE layer only)
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

References TOOL_BASE::m_toolSettings.

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

78 {
79  return m_toolSettings;
80 }
TOOL_SETTINGS m_toolSettings
Definition: tool_base.h:216
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 1218 of file drawing_tool.cpp.

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

Referenced by drawZone().

1219 {
1220  aZone = nullptr;
1221 
1222  // not an action that needs a source zone
1223  if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON )
1224  return true;
1225 
1227  const SELECTION& selection = selTool->GetSelection();
1228 
1229  if( selection.Empty() )
1231 
1232  // we want a single zone
1233  if( selection.Size() != 1 )
1234  return false;
1235 
1236  aZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1237 
1238  // expected a zone, but didn't get one
1239  if( !aZone )
1240  return false;
1241 
1242  return true;
1243 }
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:215
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:277
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::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), and TOOL_MANAGER::runTool().

112  {
113  return m_type;
114  }
TOOL_TYPE m_type
Stores the type of the tool.
Definition: tool_base.h:207
KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Function getView()

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

Returns
The instance of VIEW.

Definition at line 35 of file tool_base.cpp.

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

Referenced by PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), PCBNEW_CONTROL::CursorControl(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::disambiguationMenu(), MICROWAVE_TOOL::drawMicrowaveInductor(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findCallback(), ROUTER_TOOL::getStartLayer(), PCBNEW_CONTROL::GridSetOrigin(), SELECTION_TOOL::guessSelectionCandidates(), PCBNEW_CONTROL::HighContrastMode(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), PCBNEW_CONTROL::LayerAlphaDec(), PCBNEW_CONTROL::LayerAlphaInc(), GERBVIEW_SELECTION_TOOL::MeasureTool(), 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(), PNS::TOOL_BASE::Reset(), Reset(), GERBVIEW_SELECTION_TOOL::Reset(), SELECTION_TOOL::Reset(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), SELECTION_TOOL::selectable(), GERBVIEW_SELECTION_TOOL::selectionContains(), SELECTION_TOOL::selectionContains(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), PCBNEW_CONTROL::TrackDisplayMode(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), POINT_EDITOR::updateEditedPoint(), COMMON_TOOLS::updateGrid(), PCBNEW_CONTROL::updateGrid(), POINT_EDITOR::updatePoints(), SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCBNEW_CONTROL::ViaDisplayMode(), PCB_TOOL::view(), PCBNEW_CONTROL::ZoneDisplayMode(), COMMON_TOOLS::ZoomFitScreen(), GERBVIEW_SELECTION_TOOL::zoomFitSelection(), SELECTION_TOOL::zoomFitSelection(), COMMON_TOOLS::ZoomInOutCenter(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and SELECTION_TOOL::~SELECTION_TOOL().

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

Function getViewControls()

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

Returns
The instance of VIEW_CONTROLS.

Definition at line 41 of file tool_base.cpp.

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

Referenced by POINT_EDITOR::addCorner(), PCB_TOOL::controls(), PCBNEW_CONTROL::CursorControl(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawZone(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::findMove(), PCB_EDITOR_CONTROL::HighlightNet(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), Reset(), PCBNEW_CONTROL::ResetCoords(), runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectCursor(), SELECTION_TOOL::selectCursor(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), ZOOM_TOOL::selectRegion(), PICKER_TOOL::setControls(), POINT_EDITOR::setEditedPoint(), EDIT_TOOL::updateModificationPoint(), COMMON_TOOLS::ZoomCenter(), and COMMON_TOOLS::ZoomInOut().

42 {
43  return m_toolMgr->GetViewControls();
44 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:257
template<class T >
void TOOL_INTERACTIVE::Go ( int(T::*)(const TOOL_EVENT &)  aStateFunc,
const TOOL_EVENT_LIST aConditions = TOOL_EVENTTC_ANYTA_ANY ) 
)
inherited

Function Go()

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

Definition at line 135 of file tool_interactive.h.

References TOOL_INTERACTIVE::goInternal().

Referenced by ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PAD_TOOL::setTransitions(), MICROWAVE_TOOL::setTransitions(), GERBVIEW_CONTROL::setTransitions(), POINT_EDITOR::setTransitions(), COMMON_TOOLS::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), PCBNEW_CONTROL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), MODULE_EDITOR_TOOLS::setTransitions(), PICKER_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), PCB_EDITOR_CONTROL::setTransitions(), SELECTION_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), and setTransitions().

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

165 {
166  auto activeToolFunctor = [ this ] ( const SELECTION& aSel ) {
167  return m_mode != MODE::NONE;
168  };
169 
170  // some interactive drawing tools can undo the last point
171  auto canUndoPoint = [ this ] ( const SELECTION& aSel ) {
172  return m_mode == MODE::ARC || m_mode == MODE::ZONE;
173  };
174 
175  // functor for zone-only actions
176  auto zoneActiveFunctor = [this ] ( const SELECTION& aSel ) {
177  return m_mode == MODE::ZONE;
178  };
179 
180  auto& ctxMenu = m_menu.GetMenu();
181 
182  // cancel current toool goes in main context menu at the top if present
183  ctxMenu.AddItem( ACTIONS::cancelInteractive, activeToolFunctor, 1000 );
184 
185  // tool-specific actions
186  ctxMenu.AddItem( closeZoneOutline, zoneActiveFunctor, 1000 );
187  ctxMenu.AddItem( deleteLastPoint, canUndoPoint, 1000 );
188 
189  ctxMenu.AddSeparator( activeToolFunctor, 1000 );
190 
191  // Type-specific sub-menus will be added for us by other tools
192  // For example, zone fill/unfill is provided by the PCB control tool
193 
194  // Finally, add the standard zoom/grid items
195  m_menu.AddStandardSubMenus( *getEditFrame<PCB_BASE_FRAME>() );
196 
197  return true;
198 }
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:277
bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 30 of file tool_base.cpp.

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

31 {
32  return m_toolMgr->IsToolActive( m_toolId );
33 }
bool IsToolActive(TOOL_ID aId) const
Function IsToolActive() Returns true if a tool with given id is active (executing) ...
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
TOOL_ID m_toolId
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:210
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 1373 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().

1374 {
1375  VECTOR2I cursorPos = m_controls->GetCursorPosition();
1376  VECTOR2I origin( aSegment->GetStart() );
1377  DIRECTION_45 direction( origin - cursorPos );
1378  SHAPE_LINE_CHAIN newChain = direction.BuildInitialTrace( origin, cursorPos );
1379 
1380  if( newChain.PointCount() > 2 )
1381  {
1382  aSegment->SetEnd( wxPoint( newChain.Point( -2 ).x, newChain.Point( -2 ).y ) );
1383  aHelper->SetStart( wxPoint( newChain.Point( -2 ).x, newChain.Point( -2 ).y ) );
1384  aHelper->SetEnd( wxPoint( newChain.Point( -1 ).x, newChain.Point( -1 ).y ) );
1385  }
1386  else
1387  {
1388  aSegment->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1389  aHelper->SetStart( wxPoint( cursorPos.x, cursorPos.y ) );
1390  aHelper->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1391  }
1392 }
int PointCount() const
Function PointCount()
Class DIRECTION_45.
Definition: direction45.h:33
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:268
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 695 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().

696 {
697  if( !m_frame->GetModel() )
698  return 0;
699 
700  DIALOG_DXF_IMPORT dlg( m_frame );
701  int dlgResult = dlg.ShowModal();
702 
703  const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
704 
705  if( dlgResult != wxID_OK || list.empty() )
706  return 0;
707 
708  VECTOR2I cursorPos = m_controls->GetCursorPosition();
709  VECTOR2I delta = cursorPos - list.front()->GetPosition();
710 
711  // Add a VIEW_GROUP that serves as a preview for the new item
712  SELECTION preview;
713  BOARD_COMMIT commit( m_frame );
714 
715  // Build the undo list & add items to the current view
716  for( auto item : list )
717  {
718  assert( item->Type() == PCB_LINE_T || item->Type() == PCB_TEXT_T );
719  preview.Add( item );
720  }
721 
722  BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( preview.Front() );
723  m_view->Add( &preview );
724 
726  m_controls->ShowCursor( true );
727  m_controls->SetSnapping( true );
728 
729  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
730 
731  Activate();
732 
733  // Main loop: keep receiving events
734  while( OPT_TOOL_EVENT evt = Wait() )
735  {
736  cursorPos = m_controls->GetCursorPosition();
737 
738  if( evt->IsMotion() )
739  {
740  delta = cursorPos - firstItem->GetPosition();
741 
742  for( auto item : preview )
743  static_cast<BOARD_ITEM*>( item )->Move( wxPoint( delta.x, delta.y ) );
744 
745  m_view->Update( &preview );
746  }
747  else if( evt->Category() == TC_COMMAND )
748  {
749  // TODO it should be handled by EDIT_TOOL, so add items and select?
750  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
751  {
752  const auto rotationPoint = wxPoint( cursorPos.x, cursorPos.y );
753  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
754  *m_frame, *evt );
755 
756  for( auto item : preview )
757  {
758  static_cast<BOARD_ITEM*>( item )->Rotate( rotationPoint, rotationAngle );
759  }
760 
761  m_view->Update( &preview );
762  }
763  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
764  {
765  for( auto item : preview )
766  static_cast<BOARD_ITEM*>( item )->Flip( wxPoint( cursorPos.x, cursorPos.y ) );
767 
768  m_view->Update( &preview );
769  }
770  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
771  {
772  preview.FreeItems();
773  break;
774  }
775  }
776  else if( evt->IsClick( BUT_RIGHT ) )
777  {
779  }
780  else if( evt->IsClick( BUT_LEFT ) )
781  {
782  // Place the drawing
784 
785  for( auto item : preview )
786  {
787  if( m_editModules )
788  {
789  // Modules use different types for the same things,
790  // so we need to convert imported items to appropriate classes.
791  BOARD_ITEM* converted = NULL;
792 
793  switch( item->Type() )
794  {
795  case PCB_TEXT_T:
796  {
797  TEXTE_PCB* text = static_cast<TEXTE_PCB*>( item );
798  TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) parent );
799 
800  // Assignment operator also copies the item PCB_TEXT_T type,
801  // so it cannot be added to a module which handles PCB_MODULE_TEXT_T
802  textMod->SetText( text->GetText() );
803 #if 0
804  textMod->SetTextSize( text->GetTextSize() );
805  textMod->SetThickness( text->GetThickness() );
806  textMod->SetOrientation( text->GetTextAngle() );
807  textMod->SetTextPos( text->GetTextPos() );
808  textMod->SetTextSize( text->GetTextSize() );
809  textMod->SetVisible( text->GetVisible() );
810  textMod->SetMirrored( text->IsMirrored() );
811  textMod->SetItalic( text->IsItalic() );
812  textMod->SetBold( text->IsBold() );
813  textMod->SetHorizJustify( text->GetHorizJustify() );
814  textMod->SetVertJustify( text->GetVertJustify() );
815  textMod->SetMultilineAllowed( text->IsMultilineAllowed() );
816 #else
817  textMod->EDA_TEXT::SetEffects( *text );
818  textMod->SetLocalCoord(); // using changed SetTexPos() via SetEffects()
819 #endif
820  converted = textMod;
821  break;
822  }
823 
824  case PCB_LINE_T:
825  {
826  DRAWSEGMENT* seg = static_cast<DRAWSEGMENT*>( item );
827  EDGE_MODULE* modSeg = new EDGE_MODULE( (MODULE*) parent );
828 
829  // Assignment operator also copies the item PCB_LINE_T type,
830  // so it cannot be added to a module which handles PCB_MODULE_EDGE_T
831  modSeg->SetWidth( seg->GetWidth() );
832  modSeg->SetStart( seg->GetStart() );
833  modSeg->SetEnd( seg->GetEnd() );
834  modSeg->SetAngle( seg->GetAngle() );
835  modSeg->SetShape( seg->GetShape() );
836  modSeg->SetType( seg->GetType() );
837  modSeg->SetBezControl1( seg->GetBezControl1() );
838  modSeg->SetBezControl2( seg->GetBezControl2() );
839  modSeg->SetBezierPoints( seg->GetBezierPoints() );
840  modSeg->SetPolyPoints( seg->GetPolyPoints() );
841  converted = modSeg;
842  break;
843  }
844 
845  default:
846  assert( false );
847  break;
848  }
849 
850  if( converted )
851  converted->SetLayer( static_cast<BOARD_ITEM*>( item )->GetLayer() );
852 
853  delete item;
854  item = converted;
855  }
856 
857  if( item )
858  commit.Add( item );
859  }
860 
861  commit.Push( _( "Place a DXF drawing" ) );
862  break;
863  }
864  }
865 
866  preview.Clear();
867  m_view->Remove( &preview );
868 
869  return 0;
870 }
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
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void SetType(int aType)
void SetItalic(bool isItalic)
Definition: eda_text.h:169
EDA_ITEM * Front() const
Definition: selection.h:144
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
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
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
const std::vector< wxPoint > GetPolyPoints() const
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:267
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.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
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:268
int GetType() const
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
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:270
bool m_editModules
Definition: pcb_tool.h:129
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:99
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()
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
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:277
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 311 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_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(), EDA_DRAW_FRAME::SetNoToolSelected(), 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().

312 {
313  BOARD_ITEM* text = NULL;
314  const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
315  BOARD_COMMIT commit( m_frame );
316 
317  // Add a VIEW_GROUP that serves as a preview for the new item
318  SELECTION preview;
319 
320  m_view->Add( &preview );
321 
323  m_controls->ShowCursor( true );
324  m_controls->SetSnapping( true );
325  // do not capture or auto-pan until we start placing some text
326 
327  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
328 
329  Activate();
331  wxCURSOR_PENCIL, _( "Add text" ) );
332 
333  // Main loop: keep receiving events
334  while( OPT_TOOL_EVENT evt = Wait() )
335  {
336  VECTOR2I cursorPos = m_controls->GetCursorPosition();
337 
339  {
340  if( text )
341  {
342  // Delete the old text and have another try
343  delete text;
344  text = NULL;
345 
346  preview.Clear();
347 
348  m_controls->SetAutoPan( false );
349  m_controls->CaptureCursor( false );
350  m_controls->ShowCursor( true );
351  }
352  else
353  break;
354 
355  if( evt->IsActivate() ) // now finish unconditionally
356  break;
357  }
358  else if( text && evt->Category() == TC_COMMAND )
359  {
360  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
361  {
362  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
363  *m_frame, *evt );
364 
365  text->Rotate( text->GetPosition(), rotationAngle );
366  m_view->Update( &preview );
367  }
368  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
369  {
370  text->Flip( text->GetPosition() );
371  m_view->Update( &preview );
372  }
373  }
374  else if( evt->IsClick( BUT_RIGHT ) )
375  {
377  }
378  else if( evt->IsClick( BUT_LEFT ) )
379  {
380  if( !text )
381  {
382  // Init the new item attributes
383  if( m_editModules )
384  {
385  TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) m_frame->GetModel() );
386 
387  textMod->SetLayer( m_frame->GetActiveLayer() );
388  textMod->SetTextSize( dsnSettings.m_ModuleTextSize );
389  textMod->SetThickness( dsnSettings.m_ModuleTextWidth );
390  textMod->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
391 
392  DialogEditModuleText textDialog( m_frame, textMod, NULL );
393  bool placing;
394 
395  RunMainStack([&]() {
396  placing = textDialog.ShowModal() && ( textMod->GetText().Length() > 0 );
397  } );
398 
399  if( placing )
400  text = textMod;
401  else
402  delete textMod;
403  }
404  else
405  {
406  TEXTE_PCB* textPcb = new TEXTE_PCB( m_frame->GetModel() );
407  // TODO we have to set IS_NEW, otherwise InstallTextPCB.. creates an undo entry :| LEGACY_CLEANUP
408  textPcb->SetFlags( IS_NEW );
409 
411  textPcb->SetLayer( layer );
412 
413  // Set the mirrored option for layers on the BACK side of the board
414  if( IsBackLayer( layer ) )
415  textPcb->SetMirrored( true );
416 
417  textPcb->SetTextSize( dsnSettings.m_PcbTextSize );
418  textPcb->SetThickness( dsnSettings.m_PcbTextWidth );
419  textPcb->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
420 
421  RunMainStack([&]() {
422  getEditFrame<PCB_EDIT_FRAME>()->InstallTextPCBOptionsFrame( textPcb, NULL );
423  } );
424 
425  if( textPcb->GetText().IsEmpty() )
426  delete textPcb;
427  else
428  text = textPcb;
429  }
430 
431  if( text == NULL )
432  continue;
433 
434  m_controls->CaptureCursor( true );
435  m_controls->SetAutoPan( true );
436  // m_controls->ShowCursor( false );
437 
438  preview.Add( text );
439  }
440  else
441  {
442  // assert( text->GetText().Length() > 0 );
443  // assert( text->GetTextSize().x > 0 && text->GetTextSize().y > 0 );
444 
445  text->ClearFlags();
446  preview.Remove( text );
447 
448  commit.Add( text );
449  commit.Push( _( "Place a text" ) );
450 
451  m_controls->CaptureCursor( false );
452  m_controls->SetAutoPan( false );
453  m_controls->ShowCursor( true );
454 
455  text = NULL;
456  }
457  }
458  else if( text && evt->IsMotion() )
459  {
460  text->SetPosition( wxPoint( cursorPos.x, cursorPos.y ) );
461 
462  // Show a preview of the item
463  m_view->Update( &preview );
464  }
465  }
466 
467  m_view->Remove( &preview );
469 
470  return 0;
471 }
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 void SetPosition(const wxPoint &aPos)=0
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
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(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:342
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:267
#define IS_NEW
New item, just created.
Definition: base_struct.h:127
PCB_LAYER_ID
A quick note on layer IDs:
RAII class that sets an value at construction and resets it to the original value at destruction...
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:267
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
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
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:268
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, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1385
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:270
bool m_editModules
Definition: pcb_tool.h:129
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:99
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:268
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:312
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
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:277
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 201 of file drawing_tool.cpp.

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

202 {
203  // Init variables used by every drawing tool
204  m_view = getView();
206  m_board = getModel<BOARD>();
207  m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
208 }
BOARD * m_board
Definition: drawing_tool.h:269
KIGFX::VIEW * m_view
Definition: drawing_tool.h:267
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:268
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:270
KIGFX::VIEW * getView() const
Function getView()
Definition: tool_base.cpp:35
void TOOL_INTERACTIVE::RunMainStack ( std::function< void()>  aFunc)
inherited

Function RunMainStack()

Calls a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 85 of file tool_interactive.cpp.

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

Referenced by PlaceText().

86 {
87  m_toolMgr->RunMainStack( this, std::move( aFunc ) );
88 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void RunMainStack(TOOL_BASE *aTool, std::function< void()> aFunc)
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 1246 of file drawing_tool.cpp.

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

Referenced by drawZone().

1247 {
1248  auto& controls = *getViewControls();
1249  bool started = false;
1250 
1251  while( OPT_TOOL_EVENT evt = Wait() )
1252  {
1253  VECTOR2I cursorPos = controls.GetCursorPosition();
1254 
1256  {
1257  // pre-empted by another tool, give up
1258  // cancelled without an inprogress polygon, give up
1259  if( !polyGeomMgr.IsPolygonInProgress() || evt->IsActivate() )
1260  {
1261  break;
1262  }
1263 
1264  polyGeomMgr.Reset();
1265  // start again
1266  started = false;
1267 
1268  controls.SetAutoPan( false );
1269  controls.CaptureCursor( false );
1270  }
1271  else if( evt->IsClick( BUT_RIGHT ) )
1272  {
1274  }
1275  // events that lock in nodes
1276  else if( evt->IsClick( BUT_LEFT )
1277  || evt->IsDblClick( BUT_LEFT )
1278  || evt->IsAction( &closeZoneOutline ) )
1279  {
1280  // Check if it is double click / closing line (so we have to finish the zone)
1281  const bool endPolygon = evt->IsDblClick( BUT_LEFT )
1282  || evt->IsAction( &closeZoneOutline )
1283  || polyGeomMgr.NewPointClosesOutline( cursorPos );
1284 
1285  if( endPolygon )
1286  {
1287  polyGeomMgr.SetFinished();
1288  polyGeomMgr.Reset();
1289 
1290  // ready to start again
1291  started = false;
1292  controls.SetAutoPan( false );
1293  controls.CaptureCursor( false );
1294  }
1295  else // adding a corner
1296  {
1297  polyGeomMgr.AddPoint( cursorPos );
1298 
1299  if( !started )
1300  {
1301  started = true;
1302  controls.SetAutoPan( true );
1303  controls.CaptureCursor( true );
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  else if( polyGeomMgr.IsPolygonInProgress()
1323  && ( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) )
1324  {
1325  bool draw45 = evt->Modifier( MD_CTRL );
1326  polyGeomMgr.SetLeaderMode( draw45 ? POLYGON_GEOM_MANAGER::LEADER_MODE::DEG45
1328  polyGeomMgr.SetCursorPosition( cursorPos );
1329  }
1330  } // end while
1331 }
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()
KIGFX::VIEW_CONTROLS * controls() const
Definition: pcb_tool.h:124
Unconstrained point-to-point
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
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...
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
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:277
int DRAWING_TOOL::SetAnchor ( const TOOL_EVENT aEvent)

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

Definition at line 873 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, TOOL_EVT_UTILS::IsCancelInteractive(), m_controls, PCB_TOOL::m_editModules, m_frame, m_menu, m_mode, COMMIT::Modify(), PCB_TOOL::module(), MODULE::MoveAnchorPosition(), BOARD_COMMIT::Push(), KIGFX::VIEW_CONTROLS::SetAutoPan(), EDA_DRAW_FRAME::SetNoToolSelected(), KIGFX::VIEW_CONTROLS::SetSnapping(), PCB_BASE_FRAME::SetToolID(), TOOL_MENU::ShowContextMenu(), KIGFX::VIEW_CONTROLS::ShowCursor(), TOOL_INTERACTIVE::Wait(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

874 {
875  assert( m_editModules );
876 
877  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR );
878 
879  Activate();
880  m_frame->SetToolID( ID_MODEDIT_ANCHOR_TOOL, wxCURSOR_PENCIL,
881  _( "Place the footprint anchor" ) );
882 
883  m_controls->ShowCursor( true );
884  m_controls->SetSnapping( true );
885  m_controls->SetAutoPan( true );
886  m_controls->CaptureCursor( false );
887 
888  while( OPT_TOOL_EVENT evt = Wait() )
889  {
890  if( evt->IsClick( BUT_LEFT ) )
891  {
893  BOARD_COMMIT commit( m_frame );
894  commit.Modify( module );
895 
896  // set the new relative internal local coordinates of footprint items
897  VECTOR2I cursorPos = m_controls->GetCursorPosition();
898  wxPoint moveVector = module->GetPosition() - wxPoint( cursorPos.x, cursorPos.y );
899  module->MoveAnchorPosition( moveVector );
900 
901  commit.Push( _( "Move the footprint reference anchor" ) );
902 
903  // Usually, we do not need to change twice the anchor position,
904  // so deselect the active tool
905  break;
906  }
907  else if( evt->IsClick( BUT_RIGHT ) )
908  {
910  }
911  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
912  break;
913  }
914 
916 
917  return 0;
918 }
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:155
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
void MoveAnchorPosition(const wxPoint &aMoveVector)
Function MoveAnchorPosition Move the reference point of the footprint It looks like a move footprint:...
RAII class that sets an value at construction and resets it to the original value at destruction...
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
MODULE * module() const
Definition: pcb_tool.h:127
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:268
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:270
bool m_editModules
Definition: pcb_tool.h:129
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
Definition: draw_frame.cpp:571
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: drawing_tool.h:277
void TOOL_INTERACTIVE::SetContextMenu ( CONTEXT_MENU aMenu,
CONTEXT_MENU_TRIGGER  aTrigger = CMENU_BUTTON 
)
inherited

Function SetContextMenu()

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

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

Definition at line 74 of file tool_interactive.cpp.

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

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

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

References PCB_TOOL::m_editModules.

87  {
88  m_editModules = aEnabled;
89  }
bool m_editModules
Definition: pcb_tool.h:129
void DRAWING_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Implements TOOL_INTERACTIVE.

Definition at line 1544 of file drawing_tool.cpp.

References DrawArc(), PCB_ACTIONS::drawArc, DrawCircle(), PCB_ACTIONS::drawCircle, DrawDimension(), PCB_ACTIONS::drawDimension, PCB_ACTIONS::drawGraphicPolygon, DrawGraphicPolygon(), DrawLine(), PCB_ACTIONS::drawLine, PCB_ACTIONS::drawSimilarZone, DrawSimilarZone(), DrawVia(), PCB_ACTIONS::drawVia, DrawZone(), PCB_ACTIONS::drawZone, DrawZoneCutout(), PCB_ACTIONS::drawZoneCutout, DrawZoneKeepout(), PCB_ACTIONS::drawZoneKeepout, TOOL_INTERACTIVE::Go(), PCB_ACTIONS::placeDXF, PlaceDXF(), PlaceText(), PCB_ACTIONS::placeText, PCB_ACTIONS::setAnchor, and SetAnchor().

1545 {
1559 }
static TOOL_ACTION drawLine
Activation of the drawing tool (line)
Definition: pcb_actions.h:133
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:172
int DrawVia(const TOOL_EVENT &aEvent)
int DrawZone(const TOOL_EVENT &aEvent)
Function DrawZone() Starts interactively drawing a zone.
static TOOL_ACTION drawSimilarZone
Activation of the drawing tool (drawing a similar ZONE to another one)
Definition: pcb_actions.h:163
static TOOL_ACTION drawArc
Activation of the drawing tool (arc)
Definition: pcb_actions.h:142
int DrawLine(const TOOL_EVENT &aEvent)
Function DrawLine() Starts interactively drawing a line.
static TOOL_ACTION drawZoneKeepout
Activation of the drawing tool (drawing a keepout area)
Definition: pcb_actions.h:157
static TOOL_ACTION setAnchor
Activation of the drawing tool (placing the footprint anchor)
Definition: pcb_actions.h:175
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:145
static TOOL_ACTION drawGraphicPolygon
Definition: pcb_actions.h:136
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:148
int DrawZoneKeepout(const TOOL_EVENT &aEvent)
Function DrawZoneKeepout() Starts interactively drawing a keepout area.
static TOOL_ACTION drawVia
Activation of the drawing tool (drawing a VIA)
Definition: pcb_actions.h:154
static TOOL_ACTION drawZoneCutout
Activation of the drawing tool (drawing a ZONE cutout)
Definition: pcb_actions.h:160
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:139
int SetAnchor(const TOOL_EVENT &aEvent)
Function SetAnchor() Places the footprint anchor (only in module editor).
int DrawGraphicPolygon(const TOOL_EVENT &aEvent)
int DrawSimilarZone(const TOOL_EVENT &aEvent)
Function DrawSimilarZone() Starts interactively drawing a zone with same settings as an existing zone...
int DrawArc(const TOOL_EVENT &aEvent)
Function DrawArc() Starts interactively drawing an arc.
static TOOL_ACTION drawZone
Activation of the drawing tool (drawing a ZONE)
Definition: pcb_actions.h:151
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 PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), 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(), GERBVIEW_SELECTION_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), runPolygonEventLoop(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), SetAnchor(), and PCB_EDITOR_CONTROL::ShowLocalRatsnest().

56 {
57  return m_toolMgr->ScheduleWait( this, aEventList );
58 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
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 284 of file drawing_tool.h.

Member Data Documentation

BOARD* DRAWING_TOOL::m_board
private

Definition at line 269 of file drawing_tool.h.

Referenced by DrawDimension(), DrawVia(), 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 274 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 277 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 210 of file tool_base.h.

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

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PAD_TOOL::applyPadSettings(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), GERBVIEW_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), 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(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), getSourceZoneForAction(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), PCBNEW_CONTROL::GridSetOrigin(), GERBVIEW_CONTROL::HighlightControl(), PCB_EDITOR_CONTROL::HighlightNet(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ALIGN_DISTRIBUTE_TOOL::Init(), PAD_TOOL::Init(), POINT_EDITOR::Init(), PCB_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), TOOL_BASE::IsToolActive(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), EDIT_TOOL::Mirror(), PCB_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), POSITION_RELATIVE_TOOL::PositionRelative(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), GERBVIEW_SELECTION_TOOL::RequestSelection(), SELECTION_TOOL::RequestSelection(), TOOL_INTERACTIVE::resetTransitions(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), SELECTION_TOOL::SanitizeSelection(), SELECTION_TOOL::selectConnection(), SELECTION_TOOL::selectCopper(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), GERBVIEW_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EDIT_TOOL::updateModificationPoint(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), 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 214 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

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

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

KIGFX::VIEW* DRAWING_TOOL::m_view
private

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

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


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