KiCad PCB EDA Suite
DRAWING_TOOL Class Reference

Class DRAWING_TOOL. More...

#include <drawing_tool.h>

Inheritance diagram for DRAWING_TOOL:
PCB_TOOL TOOL_INTERACTIVE TOOL_BASE

Public Types

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

The possible drawing modes of DRAWING_TOOL

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

Determines the reason of reset for a tool

More...
 

Public Member Functions

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

Get the DRAWING_TOOL top-level context menu

More...
 
MODE GetDrawingMode () const
 Function GetDrawingMode. More...
 
int DrawLine (const TOOL_EVENT &aEvent)
 Function DrawLine() Starts interactively drawing a line. More...
 
int DrawCircle (const TOOL_EVENT &aEvent)
 Function DrawCircle() Starts interactively drawing a circle. More...
 
int DrawArc (const TOOL_EVENT &aEvent)
 Function DrawArc() Starts interactively drawing an arc. More...
 
int PlaceText (const TOOL_EVENT &aEvent)
 Function PlaceText() Displays a dialog that allows one to input text and its settings and then lets the user decide where to place the text in editor. More...
 
int DrawDimension (const TOOL_EVENT &aEvent)
 Function DrawDimension() Starts interactively drawing a dimension. More...
 
int DrawZone (const TOOL_EVENT &aEvent)
 Function DrawZone() Starts interactively drawing a zone. More...
 
int DrawGraphicPolygon (const TOOL_EVENT &aEvent)
 
int DrawVia (const TOOL_EVENT &aEvent)
 
int DrawZoneKeepout (const TOOL_EVENT &aEvent)
 Function DrawZoneKeepout() Starts interactively drawing a keepout area. More...
 
int DrawZoneCutout (const TOOL_EVENT &aEvent)
 Function DrawZoneCutout() Starts interactively drawing a zone cutout area of an existing zone. More...
 
int DrawSimilarZone (const TOOL_EVENT &aEvent)
 Function DrawSimilarZone() Starts interactively drawing a zone with same settings as an existing zone. More...
 
int 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::PCB_VIEWview () const
 
KIGFX::VIEW_CONTROLScontrols () const
 
PCB_EDIT_FRAMEframe () const
 
BOARDboard () const
 
MODULEmodule () const
 
PCB_DISPLAY_OPTIONSdisplayOptions () const
 
PCB_DRAW_PANEL_GALcanvas () const
 
const SELECTIONselection () const
 
SELECTIONselection ()
 
const TOOL_EVENT evActivate (std::string aToolName="")
 functions below are not yet implemented - their interface may change More...
 
const TOOL_EVENT evCommand (int aCommandId=-1)
 
const TOOL_EVENT evCommand (std::string aCommandStr="")
 
const TOOL_EVENT evMotion ()
 
const TOOL_EVENT evClick (int aButton=BUT_ANY)
 
const TOOL_EVENT evDrag (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonUp (int aButton=BUT_ANY)
 
const TOOL_EVENT evButtonDown (int aButton=BUT_ANY)
 
void attachManager (TOOL_MANAGER *aManager)
 Function attachManager() More...
 
KIGFX::VIEWgetView () const
 Function getView() More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Function getViewControls() More...
 
template<typename T >
T * getEditFrame () const
 Function getEditFrame() More...
 
template<typename T >
T * getModel () const
 Function getModel() More...
 

Protected Attributes

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

Stores the type of the tool.

More...
 
TOOL_ID m_toolId
 

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

More...
 
std::string m_toolName
 

Name of the tool.

More...
 
TOOL_MANAGERm_toolMgr
 
TOOL_SETTINGS m_toolSettings
 

Private Types

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

Private Member Functions

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

Starts drawing a selected shape (i.e.

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

Starts drawing an arc.

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

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

More...
 
PCB_LAYER_ID getDrawingLayer () const
 

Selects a non-copper layer for drawing

More...
 

Private Attributes

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

Static Private Attributes

static const unsigned int WIDTH_STEP = 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 109 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 
VIA 

Definition at line 68 of file drawing_tool.h.

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

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

Constructor & Destructor Documentation

DRAWING_TOOL::DRAWING_TOOL ( )

Definition at line 151 of file drawing_tool.cpp.

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

Definition at line 160 of file drawing_tool.cpp.

161 {
162 }

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 AUTOPLACE_TOOL::autoplace(), PCBNEW_CONTROL::DeleteItemCursor(), EDIT_TOOL::doCopyToClipboard(), PCB_TOOL::doInteractiveItemPlacement(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), EDIT_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), EDIT_TOOL::pickCopyReferencePoint(), PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SetAnchor(), 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 140 of file pcb_tool.h.

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

140 { return getModel<BOARD>(); }
PCB_DRAW_PANEL_GAL * PCB_TOOL::canvas ( ) const
protectedinherited
void DRAWING_TOOL::constrainDimension ( DIMENSION dimension)
private

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

Parameters
aDimensionis the dimension element currently being drawn

Definition at line 480 of file drawing_tool.cpp.

References DIMENSION::GetEnd(), DIMENSION::GetOrigin(), GetVectorSnapped45(), and DIMENSION::SetEnd().

Referenced by DrawDimension().

481 {
482  const VECTOR2I lineVector{ dimension->GetEnd() - dimension->GetOrigin() };
483 
484  dimension->SetEnd( wxPoint(
485  VECTOR2I( dimension->GetOrigin() ) + GetVectorSnapped45( lineVector ) ) );
486 }
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
const wxPoint & GetEnd()
Function GetEnd.
const wxPoint & GetOrigin() const
Function GetOrigin.
void SetEnd(const wxPoint &aEnd)
Function SetEnd Sets a new end of the crossbar line.
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec)
Snap a vector onto the nearest 0, 45 or 90 degree line.
PCB_DISPLAY_OPTIONS * PCB_TOOL::displayOptions ( ) const
protectedinherited

Definition at line 235 of file pcb_tool.cpp.

References PCB_TOOL::frame(), and PCB_BASE_FRAME::GetDisplayOptions().

Referenced by PCBNEW_CONTROL::GraphicDisplayMode(), PCBNEW_CONTROL::HighContrastMode(), PCBNEW_CONTROL::ModuleEdgeOutlines(), PCBNEW_CONTROL::ModuleTextOutlines(), PCBNEW_CONTROL::PadDisplayMode(), PNS::TOOL_BASE::pickSingleItem(), PCBNEW_CONTROL::TrackDisplayMode(), PCBNEW_CONTROL::ViaDisplayMode(), and PCBNEW_CONTROL::ZoneDisplayMode().

236 {
237  return static_cast<PCB_DISPLAY_OPTIONS*>( frame()->GetDisplayOptions() );
238 }
void * GetDisplayOptions() override
Function GetDisplayOptions returns the display options current in use Display options are relative to...
Class PCB_DISPLAY_OPTIONS handles display options like enable/disable some optional drawings...
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
void PCB_TOOL::doInteractiveItemPlacement ( INTERACTIVE_PLACER_BASE aPlacer,
const wxString &  aCommitMessage,
int  aOptions = IPO_ROTATE | IPO_FLIP | IPO_REPEAT 
)
protectedinherited

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

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

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

Definition at line 39 of file pcb_tool.cpp.

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

Referenced by MICROWAVE_TOOL::addMicrowaveFootprint(), DrawVia(), and MODULE_EDITOR_TOOLS::PlacePad().

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

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

Referenced by setTransitions().

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

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

Referenced by DrawArc().

1206 {
1208 
1210 
1211  // Arc geometric construction manager
1213 
1214  // Arc drawing assistant overlay
1215  KIGFX::PREVIEW::ARC_ASSISTANT arcAsst( arcManager, m_frame->GetUserUnits() );
1216 
1217  // Add a VIEW_GROUP that serves as a preview for the new item
1218  SELECTION preview;
1219  m_view->Add( &preview );
1220  m_view->Add( &arcAsst );
1221  GRID_HELPER grid( m_frame );
1222 
1223  m_controls->ShowCursor( true );
1224  m_controls->SetSnapping( true );
1225 
1226  Activate();
1227 
1228  bool firstPoint = false;
1229 
1230  // Main loop: keep receiving events
1231  while( OPT_TOOL_EVENT evt = Wait() )
1232  {
1233  PCB_LAYER_ID layer = getDrawingLayer();
1234  aGraphic->SetLayer( layer );
1235 
1236  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1237  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1238  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1239  VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), aGraphic );
1240  m_controls->ForceCursorPosition( true, cursorPos );
1241 
1242  if( evt->IsClick( BUT_LEFT ) )
1243  {
1244  if( !firstPoint )
1245  {
1246  m_controls->SetAutoPan( true );
1247  m_controls->CaptureCursor( true );
1248 
1250 
1251  // Init the new item attributes
1252  // (non-geometric, those are handled by the manager)
1253  aGraphic->SetShape( S_ARC );
1254  aGraphic->SetWidth( m_lineWidth );
1255 
1256  preview.Add( aGraphic );
1257  firstPoint = true;
1258  }
1259 
1260  arcManager.AddPoint( cursorPos, true );
1261  }
1262  else if( evt->IsAction( &deleteLastPoint ) )
1263  {
1264  arcManager.RemoveLastPoint();
1265  }
1266  else if( evt->IsMotion() )
1267  {
1268  // set angle snap
1269  arcManager.SetAngleSnap( evt->Modifier( MD_CTRL ) );
1270 
1271  // update, but don't step the manager state
1272  arcManager.AddPoint( cursorPos, false );
1273  }
1274  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
1275  {
1276  preview.Clear();
1277  delete aGraphic;
1278  aGraphic = nullptr;
1279  break;
1280  }
1281  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1282  {
1284  aGraphic->SetLayer( getDrawingLayer() );
1285  aGraphic->SetWidth( m_lineWidth );
1286  m_view->Update( &preview );
1287  frame()->SetMsgPanel( aGraphic );
1288  }
1289  else if( evt->IsClick( BUT_RIGHT ) )
1290  {
1292  }
1293  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1294  {
1296  aGraphic->SetWidth( m_lineWidth );
1297  m_view->Update( &preview );
1298  frame()->SetMsgPanel( aGraphic );
1299  }
1300  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && m_lineWidth > WIDTH_STEP )
1301  {
1303  aGraphic->SetWidth( m_lineWidth );
1304  m_view->Update( &preview );
1305  frame()->SetMsgPanel( aGraphic );
1306  }
1307  else if( evt->IsAction( &PCB_ACTIONS::arcPosture ) )
1308  {
1309  arcManager.ToggleClockwise();
1310  }
1311 
1312  if( arcManager.IsComplete() )
1313  {
1314  break;
1315  }
1316  else if( arcManager.HasGeometryChanged() )
1317  {
1318  updateArcFromConstructionMgr( arcManager, *aGraphic );
1319  m_view->Update( &preview );
1320  m_view->Update( &arcAsst );
1321 
1322  if(firstPoint)
1323  frame()->SetMsgPanel( aGraphic );
1324  else
1325  frame()->SetMsgPanel( board() );
1326  }
1327  }
1328 
1329  preview.Remove( aGraphic );
1330  m_view->Remove( &arcAsst );
1331  m_view->Remove( &preview );
1332  frame()->SetMsgPanel( board() );
1333  m_controls->SetAutoPan( false );
1334  m_controls->CaptureCursor( false );
1335  m_controls->ForceCursorPosition( false );
1336 
1337  return !arcManager.IsReset();
1338 }
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 VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:187
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
static TOOL_ACTION deleteLastPoint("pcbnew.InteractiveDrawing.deleteLastPoint", AS_CONTEXT, WXK_BACK, _("Delete Last Point"), _("Delete the last point added to the current item"), undo_xpm)
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:281
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:365
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:190
KIGFX::VIEW * m_view
Definition: drawing_tool.h:271
PCB_LAYER_ID
A quick note on layer IDs:
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
EDA_UNITS_T GetUserUnits() const override
Return the user units currently in use.
Definition: draw_frame.h:284
Arcs (with rounded ends)
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:278
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:272
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1521
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:274
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:193
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:286
void ToggleClockwise()
Reverse the current are direction
Class SELECTION_AREA.
Definition: arc_assistant.h:38
int getSegmentWidth(PCB_LAYER_ID aLayer) const
Returns the appropriate width for a segment depending on the settings.
void Activate()
Function Activate() Runs the tool.
void SetAngleSnap(bool aSnap)
Set angle snapping (for the next point)
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:335
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
BOARD * board() const
Definition: pcb_tool.h:140
void SetWidth(int aWidth)
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 257 of file drawing_tool.cpp.

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

Referenced by setTransitions().

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

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

Referenced by setTransitions().

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

Definition at line 712 of file drawing_tool.cpp.

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

Referenced by setTransitions().

713 {
714  if( m_editModules && !m_frame->GetModel() )
715  return 0;
716 
717  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::GRAPHIC_POLYGON );
718 
720  wxCURSOR_PENCIL, _( "Add graphic polygon" ) );
721 
722  return drawZone( false, ZONE_MODE::GRAPHIC_POLYGON );
723 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
RAII class that sets an value at construction and resets it to the original value at destruction...
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:274
bool m_editModules
Definition: pcb_tool.h:150
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
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 219 of file drawing_tool.cpp.

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

Referenced by setTransitions().

220 {
221  if( m_editModules && !m_frame->GetModel() )
222  return 0;
223 
225  DRAWSEGMENT* line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
226 
227  OPT<VECTOR2D> startingPoint;
228  BOARD_COMMIT commit( m_frame );
229 
230  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::LINE );
231 
233  wxCURSOR_PENCIL, _( "Add graphic line" ) );
234 
235  while( drawSegment( S_SEGMENT, line, startingPoint ) )
236  {
237  if( line )
238  {
239  commit.Add( line );
240  commit.Push( _( "Draw a line segment" ) );
241  startingPoint = VECTOR2D( line->GetEnd() );
242  }
243  else
244  {
245  startingPoint = NULLOPT;
246  }
247 
248  line = m_editModules ? new EDGE_MODULE( (MODULE*) parent ) : new DRAWSEGMENT;
249  }
250 
252 
253  return 0;
254 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
bool drawSegment(int aShape, DRAWSEGMENT *&aGraphic, OPT< VECTOR2D > aStartingPoint=NULLOPT)
Starts drawing a selected shape (i.e.
usual segment : line with rounded ends
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 auto NULLOPT
Definition: optional.h:9
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:274
bool m_editModules
Definition: pcb_tool.h:150
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
boost::optional< T > OPT
Definition: optional.h:7
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,
OPT< VECTOR2D aStartingPoint = NULLOPT 
)
private

Starts drawing a selected shape (i.e.

DRAWSEGMENT).

Parameters
aShapeis the type of created shape (
See also
STROKE_T).
Parameters
aGraphicis an object that is going to be used by the tool for drawing. It has to be already created. The tool deletes the object if it is not added to a BOARD.
aStartingPointis a starting point for this new DRAWSEGMENT. If exists the new item has its start point set to aStartingPoint, and its settings (width, layer) set to the current default values.
Returns
False if the tool was cancelled before the origin was set or origin and end are the same point.

Definition at line 976 of file drawing_tool.cpp.

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

Referenced by DrawCircle(), and DrawLine().

978 {
979  // Only two shapes are currently supported
980  assert( aShape == S_SEGMENT || aShape == S_CIRCLE );
981 
982  DRAWSEGMENT line45;
983  GRID_HELPER grid( m_frame );
984 
987 
988  // Add a VIEW_GROUP that serves as a preview for the new item
989  SELECTION preview;
990  m_view->Add( &preview );
991 
993  m_controls->ShowCursor( true );
994 
995  Activate();
996 
997  bool direction45 = false; // 45 degrees only mode
998  bool started = false;
999  bool IsOCurseurSet = ( m_frame->GetScreen()->m_O_Curseur != wxPoint( 0, 0 ) );
1000  VECTOR2I cursorPos = m_controls->GetMousePosition();
1001 
1002  if( aStartingPoint )
1003  {
1004  // Init the new item attributes
1005  aGraphic->SetShape( (STROKE_T) aShape );
1006  aGraphic->SetWidth( m_lineWidth );
1007  aGraphic->SetLayer( getDrawingLayer() );
1008  aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) );
1009 
1010  cursorPos = grid.BestSnapAnchor( cursorPos, aGraphic );
1011  m_controls->ForceCursorPosition( true, cursorPos );
1012  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1013 
1014  if( aShape == S_SEGMENT )
1015  line45 = *aGraphic; // used only for direction 45 mode with lines
1016 
1017  preview.Add( aGraphic );
1018  m_controls->SetAutoPan( true );
1019  m_controls->CaptureCursor( true );
1020 
1021  if( !IsOCurseurSet )
1022  m_frame->GetScreen()->m_O_Curseur = wxPoint( aStartingPoint->x, aStartingPoint->y );
1023 
1024  started = true;
1025  }
1026 
1027  // Main loop: keep receiving events
1028  while( OPT_TOOL_EVENT evt = Wait() )
1029  {
1030  grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
1031  grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
1032  m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
1033  cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), getDrawingLayer() );
1034  m_controls->ForceCursorPosition( true, cursorPos );
1035 
1036  // 45 degree angle constraint enabled with an option and toggled with Ctrl
1037  const bool limit45 = ( frame()->Settings().m_use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) );
1038 
1039  if( direction45 != limit45 && started && aShape == S_SEGMENT )
1040  {
1041  direction45 = limit45;
1042 
1043  if( direction45 )
1044  {
1045  preview.Add( &line45 );
1046  make45DegLine( aGraphic, &line45, cursorPos );
1047  }
1048  else
1049  {
1050  preview.Remove( &line45 );
1051  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1052  }
1053 
1054  m_view->Update( &preview );
1055  frame()->SetMsgPanel( aGraphic );
1056  }
1057 
1059  {
1060  preview.Clear();
1061  m_view->Update( &preview );
1062  delete aGraphic;
1063  aGraphic = NULL;
1064  if( !IsOCurseurSet )
1065  m_frame->GetScreen()->m_O_Curseur = wxPoint( 0, 0 );
1066  break;
1067  }
1068  else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
1069  {
1071  aGraphic->SetLayer( getDrawingLayer() );
1072  aGraphic->SetWidth( m_lineWidth );
1073  m_view->Update( &preview );
1074  frame()->SetMsgPanel( aGraphic );
1075  }
1076  else if( evt->IsClick( BUT_RIGHT ) )
1077  {
1079  }
1080  else if( evt->IsClick( BUT_LEFT ) || evt->IsDblClick( BUT_LEFT ) )
1081  {
1082  if( !started )
1083  {
1085 
1086  // Init the new item attributes
1087  aGraphic->SetShape( (STROKE_T) aShape );
1088  aGraphic->SetWidth( m_lineWidth );
1089  aGraphic->SetStart( wxPoint( cursorPos.x, cursorPos.y ) );
1090  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1091  aGraphic->SetLayer( getDrawingLayer() );
1092 
1093  if( !IsOCurseurSet )
1094  m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
1095 
1096  if( aShape == S_SEGMENT )
1097  line45 = *aGraphic; // used only for direction 45 mode with lines
1098 
1099  preview.Add( aGraphic );
1100  frame()->SetMsgPanel( aGraphic );
1101  m_controls->SetAutoPan( true );
1102  m_controls->CaptureCursor( true );
1103 
1104  started = true;
1105  }
1106  else
1107  {
1108  if( aGraphic->GetEnd() == aGraphic->GetStart()
1109  || ( evt->IsDblClick( BUT_LEFT ) && aShape == S_SEGMENT ) )
1110  // User has clicked twice in the same spot
1111  {
1112  // a clear sign that the current drawing is finished
1113  // Now we have to add the helper line as well, unless it is zero-length
1114  if( direction45 && line45.GetStart() != aGraphic->GetStart() )
1115  {
1116  BOARD_ITEM_CONTAINER* parent = m_frame->GetModel();
1117  DRAWSEGMENT* l = m_editModules ? new EDGE_MODULE( (MODULE*) parent )
1118  : new DRAWSEGMENT;
1119 
1120  // Copy coordinates, layer, etc.
1121  *static_cast<DRAWSEGMENT*>( l ) = line45;
1122  l->SetEnd( aGraphic->GetStart() );
1123 
1124  BOARD_COMMIT commit( m_frame );
1125  commit.Add( l );
1126  commit.Push( _( "Draw a line" ) );
1127  }
1128 
1129  delete aGraphic;
1130  aGraphic = NULL;
1131  }
1132 
1133  preview.Clear();
1134  break;
1135  }
1136  }
1137  else if( evt->IsMotion() )
1138  {
1139  // 45 degree lines
1140  if( direction45 && aShape == S_SEGMENT )
1141  make45DegLine( aGraphic, &line45, cursorPos );
1142  else
1143  aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
1144 
1145  m_view->Update( &preview );
1146 
1147  if( started )
1148  frame()->SetMsgPanel( aGraphic );
1149  else
1150  frame()->SetMsgPanel( board() );
1151  }
1152  else if( evt->IsAction( &PCB_ACTIONS::incWidth ) )
1153  {
1155  aGraphic->SetWidth( m_lineWidth );
1156  line45.SetWidth( m_lineWidth );
1157  m_view->Update( &preview );
1158  frame()->SetMsgPanel( aGraphic );
1159  }
1160  else if( evt->IsAction( &PCB_ACTIONS::decWidth ) && ( m_lineWidth > WIDTH_STEP ) )
1161  {
1163  aGraphic->SetWidth( m_lineWidth );
1164  line45.SetWidth( m_lineWidth );
1165  m_view->Update( &preview );
1166  frame()->SetMsgPanel( aGraphic );
1167  }
1168  else if( evt->IsAction( &PCB_ACTIONS::resetCoords ) )
1169  {
1170  IsOCurseurSet = true;
1171  }
1172  }
1173 
1174  if( !IsOCurseurSet ) // reset the relative coordinte if it was not set before
1175  m_frame->GetScreen()->m_O_Curseur = wxPoint( 0, 0 );
1176 
1177  m_view->Remove( &preview );
1178  frame()->SetMsgPanel( board() );
1179  m_controls->SetAutoPan( false );
1180  m_controls->CaptureCursor( false );
1181  m_controls->ForceCursorPosition( false );
1182 
1183  return started;
1184 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void SetShape(STROKE_T aShape)
virtual void Clear() override
Function Clear() Removes all the stored items from the group.
Definition: selection.h:90
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Function GetMousePosition() Returns the current mouse pointer position.
static TOOL_ACTION incWidth
Increase width of currently drawn line.
Definition: pcb_actions.h:187
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
static const unsigned int WIDTH_STEP
Definition: drawing_tool.h:281
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:365
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
wxPoint m_O_Curseur
Relative Screen cursor coordinate (on grid) in user units.
Definition: base_screen.h:185
static TOOL_ACTION resetCoords
Definition: pcb_actions.h:364
static TOOL_ACTION decWidth
Decrease width of currently drawn line.
Definition: pcb_actions.h:190
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
KIGFX::VIEW * m_view
Definition: drawing_tool.h:271
static bool m_use45DegreeGraphicSegments
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
PCB_GENERAL_SETTINGS & Settings()
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
unsigned int m_lineWidth
Stores the current line width for multisegment drawing.
Definition: drawing_tool.h:278
STROKE_T
Enum STROKE_T is the set of shapes for segments (graphic segments and tracks) which are often in the ...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:272
virtual void SetActiveLayer(PCB_LAYER_ID aLayer)
Function SetActiveLayer will change the currently active layer to aLayer.
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1521
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:274
bool m_editModules
Definition: pcb_tool.h:150
PCB_LAYER_ID getDrawingLayer() const
Selects a non-copper layer for drawing
static TOOL_ACTION layerChanged
Definition: pcb_actions.h:286
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
int getSegmentWidth(PCB_LAYER_ID aLayer) const
Returns the appropriate width for a segment depending on the settings.
void SetEnd(const wxPoint &aEnd)
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:335
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 make45DegLine(DRAWSEGMENT *aSegment, DRAWSEGMENT *aHelper, VECTOR2I &aPos) const
Function make45DegLine() Forces a DRAWSEGMENT to be drawn at multiple of 45 degrees.
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
BOARD * board() const
Definition: pcb_tool.h:140
void SetWidth(int aWidth)
virtual void Remove(EDA_ITEM *aItem)
Definition: selection.h:82
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 726 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().

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

Definition at line 1553 of file drawing_tool.cpp.

References COMMIT::Add(), GRID_HELPER::AlignToSegment(), B_Cu, TRACK::Clone(), PCB_TOOL::doInteractiveItemPlacement(), F_Cu, PCB_TOOL::frame(), PCB_BASE_FRAME::GetActiveLayer(), BOARD::GetCopperLayerCount(), BOARD::GetDesignSettings(), TRACK::GetEnd(), ZONE_CONTAINER::GetLayer(), VIA::GetLayerSet(), NETINFO_ITEM::GetMicroViaDrillSize(), NETINFO_ITEM::GetMicroViaSize(), BOARD_CONNECTED_ITEM::GetNet(), BOARD_CONNECTED_ITEM::GetNetCode(), VIA::GetPosition(), PCB_BASE_FRAME::GetScreen(), TRACK::GetStart(), VIA::GetViaType(), TRACK::GetWidth(), ID_NO_TOOL_SELECTED, ID_PCB_DRAW_VIA_BUTT, In1_Cu, PCB_TOOL::IPO_FLIP, PCB_TOOL::IPO_REPEAT, PCB_TOOL::IPO_ROTATE, PCB_TOOL::IPO_SINGLE_CLICK, BOARD::IsLayerVisible(), m_board, m_frame, m_mode, PCB_SCREEN::m_Route_Layer_BOTTOM, PCB_SCREEN::m_Route_Layer_TOP, MD_SHIFT, mod, COMMIT::Modify(), BOARD::Modules(), VIA::SetDrill(), TRACK::SetEnd(), VIA::SetLayerPair(), BOARD_CONNECTED_ITEM::SetNetCode(), BOARD_ITEM::SetPosition(), GRID_HELPER::SetSnap(), TRACK::SetStart(), PCB_BASE_FRAME::SetToolID(), VIA::SetViaType(), TRACK::SetWidth(), TestSegmentHit(), ToLAYER_ID(), BOARD::Tracks(), VIA, VIA_BLIND_BURIED, VIA_MICROVIA, and BOARD::Zones().

Referenced by setTransitions().

1554 {
1555  struct VIA_PLACER : public INTERACTIVE_PLACER_BASE
1556  {
1557  GRID_HELPER m_gridHelper;
1558 
1559  VIA_PLACER( PCB_EDIT_FRAME* aFrame ) : m_gridHelper( aFrame )
1560  {}
1561 
1562  TRACK* findTrack( VIA* aVia )
1563  {
1564  const LSET lset = aVia->GetLayerSet();
1565 
1566  for( TRACK* track : m_board->Tracks() )
1567  {
1568  if( !(track->GetLayerSet() & lset ).any() )
1569  continue;
1570 
1571  if( TestSegmentHit( aVia->GetPosition(), track->GetStart(), track->GetEnd(),
1572  ( track->GetWidth() + aVia->GetWidth() ) / 2 ) )
1573  return track;
1574  }
1575 
1576  return nullptr;
1577  }
1578 
1579  int findStitchedZoneNet( VIA* aVia )
1580  {
1581  const auto pos = aVia->GetPosition();
1582  const auto lset = aVia->GetLayerSet();
1583 
1584  for( auto mod : m_board->Modules() )
1585  {
1586  for( D_PAD* pad : mod->Pads() )
1587  {
1588  if( pad->HitTest( pos ) && ( pad->GetLayerSet() & lset ).any() )
1589  return -1;
1590  }
1591  }
1592 
1593  std::vector<ZONE_CONTAINER*> foundZones;
1594 
1595  for( auto zone : m_board->Zones() )
1596  {
1597  if( zone->HitTestFilledArea( pos ) )
1598  {
1599  foundZones.push_back( zone );
1600  }
1601  }
1602 
1603  std::sort( foundZones.begin(), foundZones.end(),
1604  [] ( const ZONE_CONTAINER* a, const ZONE_CONTAINER* b ) {
1605  return a->GetLayer() < b->GetLayer();
1606  } );
1607 
1608  // first take the net of the active layer
1609  for( auto z : foundZones )
1610  {
1611  if( m_frame->GetActiveLayer() == z->GetLayer() )
1612  return z->GetNetCode();
1613  }
1614 
1615  // none? take the topmost visible layer
1616  for( auto z : foundZones )
1617  {
1618  if( m_board->IsLayerVisible( z->GetLayer() ) )
1619  return z->GetNetCode();
1620  }
1621 
1622  return -1;
1623  }
1624 
1625  void SnapItem( BOARD_ITEM *aItem ) override
1626  {
1627  // If you place a Via on a track but not on its centerline, the current
1628  // connectivity algorithm will require us to put a kink in the track when
1629  // we break it (so that each of the two segments ends on the via center).
1630  // That's not ideal, and is in fact probably worse than forcing snap in
1631  // this situation.
1632 
1633 // bool do_snap = ( m_frame->Settings().m_magneticTracks == CAPTURE_CURSOR_IN_TRACK_TOOL
1634 // || m_frame->Settings().m_magneticTracks == CAPTURE_ALWAYS );
1635  m_gridHelper.SetSnap( !( m_modifiers & MD_SHIFT ) );
1636  auto via = static_cast<VIA*>( aItem );
1637  wxPoint pos = via->GetPosition();
1638  TRACK* track = findTrack( via );
1639 
1640  if( track )
1641  {
1642  SEG trackSeg( track->GetStart(), track->GetEnd() );
1643  VECTOR2I snap = m_gridHelper.AlignToSegment( pos, trackSeg );
1644 
1645  aItem->SetPosition( wxPoint( snap.x, snap.y ) );
1646  }
1647  }
1648 
1649  void PlaceItem( BOARD_ITEM* aItem, BOARD_COMMIT& aCommit ) override
1650  {
1651  auto via = static_cast<VIA*>( aItem );
1652  int newNet;
1653  TRACK* track = findTrack( via );
1654 
1655  if( track )
1656  {
1657  aCommit.Modify( track );
1658  TRACK* newTrack = dynamic_cast<TRACK*>( track->Clone() );
1659  track->SetEnd( via->GetPosition() );
1660  newTrack->SetStart( via->GetPosition() );
1661  aCommit.Add( newTrack );
1662 
1663  newNet = track->GetNetCode();
1664  }
1665  else
1666  newNet = findStitchedZoneNet( via );
1667 
1668  if( newNet > 0 )
1669  via->SetNetCode( newNet );
1670 
1671  aCommit.Add( aItem );
1672  }
1673 
1674  std::unique_ptr<BOARD_ITEM> CreateItem() override
1675  {
1676  auto& ds = m_board->GetDesignSettings();
1677  VIA* via = new VIA( m_board );
1678 
1679  via->SetNetCode( 0 );
1680  via->SetViaType( ds.m_CurrentViaType );
1681 
1682  // for microvias, the size and hole will be changed later.
1683  via->SetWidth( ds.GetCurrentViaSize() );
1684  via->SetDrill( ds.GetCurrentViaDrill() );
1685 
1686  // Usual via is from copper to component.
1687  // layer pair is B_Cu and F_Cu.
1688  via->SetLayerPair( B_Cu, F_Cu );
1689 
1690  PCB_LAYER_ID first_layer = m_frame->GetActiveLayer();
1691  PCB_LAYER_ID last_layer;
1692 
1693  // prepare switch to new active layer:
1694  if( first_layer != m_frame->GetScreen()->m_Route_Layer_TOP )
1695  last_layer = m_frame->GetScreen()->m_Route_Layer_TOP;
1696  else
1697  last_layer = m_frame->GetScreen()->m_Route_Layer_BOTTOM;
1698 
1699  // Adjust the actual via layer pair
1700  switch( via->GetViaType() )
1701  {
1702  case VIA_BLIND_BURIED:
1703  via->SetLayerPair( first_layer, last_layer );
1704  break;
1705 
1706  case VIA_MICROVIA: // from external to the near neighbor inner layer
1707  {
1708  PCB_LAYER_ID last_inner_layer =
1709  ToLAYER_ID( ( m_board->GetCopperLayerCount() - 2 ) );
1710 
1711  if( first_layer == B_Cu )
1712  last_layer = last_inner_layer;
1713  else if( first_layer == F_Cu )
1714  last_layer = In1_Cu;
1715  else if( first_layer == last_inner_layer )
1716  last_layer = B_Cu;
1717  else if( first_layer == In1_Cu )
1718  last_layer = F_Cu;
1719 
1720  // else error: will be removed later
1721  via->SetLayerPair( first_layer, last_layer );
1722 
1723  // Update diameter and hole size, which where set previously
1724  // for normal vias
1725  NETINFO_ITEM* net = via->GetNet();
1726 
1727  if( net )
1728  {
1729  via->SetWidth( net->GetMicroViaSize() );
1730  via->SetDrill( net->GetMicroViaDrillSize() );
1731  }
1732  }
1733  break;
1734 
1735  default:
1736  break;
1737  }
1738 
1739  return std::unique_ptr<BOARD_ITEM>( via );
1740  }
1741  };
1742 
1743  VIA_PLACER placer( frame() );
1744 
1745  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::VIA );
1746 
1747  frame()->SetToolID( ID_PCB_DRAW_VIA_BUTT, wxCURSOR_PENCIL, _( "Add vias" ) );
1748 
1749  doInteractiveItemPlacement( &placer, _( "Place via" ),
1751 
1752  frame()->SetToolID( ID_NO_TOOL_SELECTED, wxCURSOR_DEFAULT, wxEmptyString );
1753 
1754  return 0;
1755 }
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
Definition: commit.h:103
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
virtual 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:273
void SetViaType(VIATYPE_T aViaType)
Definition: class_track.h:458
virtual void SetPosition(const wxPoint &aPos)=0
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void SetEnd(const wxPoint &aEnd)
Definition: class_track.h:118
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
Definition: commit.h:78
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:175
VECTOR2I AlignToSegment(const VECTOR2I &aPoint, const SEG &aSeg)
virtual EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
const wxPoint & GetEnd() const
Definition: class_track.h:119
void SetWidth(int aWidth)
Definition: class_track.h:115
PCB_LAYER_ID
A quick note on layer IDs:
Class LSET is a set of PCB_LAYER_IDs.
RAII class that sets an value at construction and resets it to the original value at destruction...
DLIST_ITERATOR_WRAPPER< MODULE > Modules()
Definition: class_board.h:254
VIATYPE_T GetViaType() const
Definition: class_track.h:457
const wxPoint & GetStart() const
Definition: class_track.h:122
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
PCB_LAYER_ID m_Route_Layer_BOTTOM
Definition: pcb_screen.h:46
bool SetNetCode(int aNetCode, bool aNoAssert=false)
Function SetNetCode sets net using a net code.
void SetLayerPair(PCB_LAYER_ID aTopLayer, PCB_LAYER_ID aBottomLayer)
Function SetLayerPair For a via m_Layer contains the top layer, the other layer is in m_BottomLayer...
const wxPoint GetPosition() const override
Definition: class_track.h:429
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:274
void SetSnap(bool aSnap)
Definition: grid_helper.h:63
int GetNetCode() const
Function GetNetCode.
Definition: seg.h:36
Class NETINFO_ITEM handles the data for a net.
Definition: netinfo.h:69
ZONE_CONTAINERS & Zones()
Definition: class_board.h:256
int GetWidth() const
Definition: class_track.h:116
void SetDrill(int aDrill)
Function SetDrill sets the drill value for vias.
Definition: class_track.h:465
Class PCB_EDIT_FRAME is the main frame for Pcbnew.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
int GetMicroViaDrillSize()
Function GetViaDrillSize returns the size of via drills used to route this net.
Definition: netinfo.h:186
void SetStart(const wxPoint &aStart)
Definition: class_track.h:121
DLIST_ITERATOR_WRAPPER< TRACK > Tracks()
Definition: class_board.h:253
void doInteractiveItemPlacement(INTERACTIVE_PLACER_BASE *aPlacer, const wxString &aCommitMessage, int aOptions=IPO_ROTATE|IPO_FLIP|IPO_REPEAT)
Helper function for performing a common interactive idiom: wait for a left click, place an item there...
Definition: pcb_tool.cpp:39
bool TestSegmentHit(const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
Function TestSegmentHit test for hit on line segment i.e.
Definition: trigo.cpp:122
int GetMicroViaSize()
Function GetMicroViaSize returns the size of vias used to route this net.
Definition: netinfo.h:166
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
Definition: lset.cpp:810
#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
Definition: pcb_screen.h:45
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:457
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 682 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().

683 {
684  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
685 
686  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zones" ) );
687 
688  return drawZone( false, ZONE_MODE::ADD );
689 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
RAII class that sets an value at construction and resets it to the original value at destruction...
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:274
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 1375 of file drawing_tool.cpp.

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

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

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

703 {
704  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ZONE );
705 
706  m_frame->SetToolID( ID_PCB_ZONES_BUTT, wxCURSOR_PENCIL, _( "Add zone cutout" ) );
707 
708  return drawZone( false, ZONE_MODE::CUTOUT );
709 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
RAII class that sets an value at construction and resets it to the original value at destruction...
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:274
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 692 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().

693 {
694  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::KEEPOUT );
695 
696  m_frame->SetToolID( ID_PCB_KEEPOUT_AREA_BUTT, wxCURSOR_PENCIL, _( "Add keepout" ) );
697 
698  return drawZone( true, ZONE_MODE::ADD );
699 }
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
int drawZone(bool aKeepout, ZONE_MODE aMode)
Draws a polygon, that is added as a zone or a keepout area.
RAII class that sets an value at construction and resets it to the original value at destruction...
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:274
Add a new zone/keepout with fresh settings.
bool PCB_TOOL::EditingModules ( ) const
inlineinherited
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 139 of file pcb_tool.h.

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

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

Selects a non-copper layer for drawing

Definition at line 1783 of file drawing_tool.cpp.

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

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

1784 {
1785  PCB_LAYER_ID layer = m_frame->GetActiveLayer();
1786 
1787  if( IsCopperLayer( layer ) )
1788  {
1789  if( layer == F_Cu )
1790  layer = F_SilkS;
1791  else if( layer == B_Cu )
1792  layer = B_SilkS;
1793  else
1794  layer = Dwgs_User;
1795 
1796  m_frame->SetActiveLayer( layer );
1797  }
1798 
1799  return layer;
1800 }
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:274
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 213 of file drawing_tool.cpp.

References m_mode.

Referenced by PCB_EDITOR_CONTROL::Init().

214 {
215  return m_mode;
216 }
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.

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

189  {
190  return static_cast<T*>( getEditFrameInt() );
191  }
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.

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

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.

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

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.

Referenced by ZONE_CREATE_HELPER::commitZone(), 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  }
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
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.

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 ( PCB_LAYER_ID  aLayer) const
private

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

Definition at line 1776 of file drawing_tool.cpp.

References BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetLineThickness(), and m_board.

Referenced by drawArc(), and drawSegment().

1777 {
1778  assert( m_board );
1779  return m_board->GetDesignSettings().GetLineThickness( aLayer );
1780 }
BOARD * m_board
Definition: drawing_tool.h:273
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:538
int GetLineThickness(PCB_LAYER_ID aLayer) const
Function GetLineThickness Returns the default graphic segment thickness from the layer class for the ...
TOOL_SETTINGS & TOOL_BASE::GetSettings ( )
inherited

Definition at line 77 of file tool_base.cpp.

Referenced by GERBVIEW_CONTROL::HighlightControl(), ROUTER_TOOL::Init(), 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 1341 of file drawing_tool.cpp.

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

Referenced by drawZone().

1342 {
1343  bool clearSelection = false;
1344  aZone = nullptr;
1345 
1346  // not an action that needs a source zone
1347  if( aMode == ZONE_MODE::ADD || aMode == ZONE_MODE::GRAPHIC_POLYGON )
1348  return true;
1349 
1351  const SELECTION& selection = selTool->GetSelection();
1352 
1353  if( selection.Empty() )
1354  {
1355  clearSelection = true;
1357  }
1358 
1359  // we want a single zone
1360  if( selection.Size() == 1 )
1361  aZone = dyn_cast<ZONE_CONTAINER*>( selection[0] );
1362 
1363  // expected a zone, but didn't get one
1364  if( !aZone )
1365  {
1366  if( clearSelection )
1368 
1369  return false;
1370  }
1371 
1372  return true;
1373 }
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
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
SELECTION & GetSelection()
Function GetSelection()
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
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.

Referenced by PCB_EDITOR_CONTROL::Init().

63  {
64  return m_menu;
65  }
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
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.

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

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

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
bool DRAWING_TOOL::Init ( )
overridevirtual

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

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

Reimplemented from PCB_TOOL.

Definition at line 165 of file drawing_tool.cpp.

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

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

Definition at line 1531 of file drawing_tool.cpp.

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

Referenced by drawSegment().

1533 {
1534  VECTOR2I origin( aSegment->GetStart() );
1535  DIRECTION_45 direction( origin - aPos );
1536  SHAPE_LINE_CHAIN newChain = direction.BuildInitialTrace( origin, aPos );
1537 
1538  if( newChain.PointCount() > 2 )
1539  {
1540  aSegment->SetEnd( wxPoint( newChain.Point( -2 ).x, newChain.Point( -2 ).y ) );
1541  aHelper->SetStart( wxPoint( newChain.Point( -2 ).x, newChain.Point( -2 ).y ) );
1542  aHelper->SetEnd( wxPoint( newChain.Point( -1 ).x, newChain.Point( -1 ).y ) );
1543  }
1544  else
1545  {
1546  aSegment->SetEnd( wxPoint( aPos.x, aPos.y ) );
1547  aHelper->SetStart( wxPoint( aPos.x, aPos.y ) );
1548  aHelper->SetEnd( wxPoint( aPos.x, aPos.y ) );
1549  }
1550 }
int PointCount() const
Function PointCount()
Class DIRECTION_45.
Definition: direction45.h:36
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 736 of file drawing_tool.cpp.

References TOOL_INTERACTIVE::Activate(), SELECTION::Add(), COMMIT::Add(), KIGFX::VIEW::Add(), BUT_LEFT, BUT_RIGHT, delta, DXF, PCB_ACTIONS::flip, Flip(), KIGFX::VIEW_CONTROLS::ForceCursorPosition(), 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::GetPolyShape(), 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, PCB_TOOL::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(), EDGE_MODULE::SetLocalCoord(), TEXTE_MODULE::SetLocalCoord(), EDA_TEXT::SetMirrored(), EDA_TEXT::SetMultilineAllowed(), DRAWSEGMENT::SetPolyShape(), 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().

737 {
738  if( !m_frame->GetModel() )
739  return 0;
740 
741  DIALOG_DXF_IMPORT dlg( m_frame );
742  int dlgResult = dlg.ShowModal();
743 
744  const std::list<BOARD_ITEM*>& list = dlg.GetImportedItems();
745 
746  if( dlgResult != wxID_OK || list.empty() )
747  return 0;
748 
749  VECTOR2I cursorPos = m_controls->GetCursorPosition();
750  VECTOR2I delta = cursorPos - list.front()->GetPosition();
751 
752  // Add a VIEW_GROUP that serves as a preview for the new item
753  SELECTION preview;
754  BOARD_COMMIT commit( m_frame );
755 
756  // Build the undo list & add items to the current view
757  for( auto item : list )
758  {
759  assert( item->Type() == PCB_LINE_T || item->Type() == PCB_TEXT_T );
760  preview.Add( item );
761  }
762 
763  BOARD_ITEM* firstItem = static_cast<BOARD_ITEM*>( preview.Front() );
764  m_view->Add( &preview );
765 
767  m_controls->ShowCursor( true );
768  m_controls->SetSnapping( true );
770 
771  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
772 
773  // Now move the new items to the current cursor position:
774  cursorPos = m_controls->GetCursorPosition();
775  delta = cursorPos - firstItem->GetPosition();
776 
777  for( auto item : preview )
778  static_cast<BOARD_ITEM*>( item )->Move( wxPoint( delta.x, delta.y ) );
779 
780  m_view->Update( &preview );
781 
782  Activate();
783 
784  // Main loop: keep receiving events
785  while( OPT_TOOL_EVENT evt = Wait() )
786  {
787  cursorPos = m_controls->GetCursorPosition();
788 
789  if( evt->IsMotion() )
790  {
791  delta = cursorPos - firstItem->GetPosition();
792 
793  for( auto item : preview )
794  static_cast<BOARD_ITEM*>( item )->Move( wxPoint( delta.x, delta.y ) );
795 
796  m_view->Update( &preview );
797  }
798  else if( evt->Category() == TC_COMMAND )
799  {
800  // TODO it should be handled by EDIT_TOOL, so add items and select?
801  if( TOOL_EVT_UTILS::IsRotateToolEvt( *evt ) )
802  {
803  const auto rotationPoint = wxPoint( cursorPos.x, cursorPos.y );
804  const auto rotationAngle = TOOL_EVT_UTILS::GetEventRotationAngle(
805  *m_frame, *evt );
806 
807  for( auto item : preview )
808  {
809  static_cast<BOARD_ITEM*>( item )->Rotate( rotationPoint, rotationAngle );
810  }
811 
812  m_view->Update( &preview );
813  }
814  else if( evt->IsAction( &PCB_ACTIONS::flip ) )
815  {
816  for( auto item : preview )
817  static_cast<BOARD_ITEM*>( item )->Flip( wxPoint( cursorPos.x, cursorPos.y ) );
818 
819  m_view->Update( &preview );
820  }
821  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
822  {
823  preview.FreeItems();
824  break;
825  }
826  }
827  else if( evt->IsClick( BUT_RIGHT ) )
828  {
830  }
831  else if( evt->IsClick( BUT_LEFT ) )
832  {
833  // Place the drawing
835 
836  for( auto item : preview )
837  {
838  if( m_editModules )
839  {
840  // Modules use different types for the same things,
841  // so we need to convert imported items to appropriate classes.
842  BOARD_ITEM* converted = NULL;
843 
844  switch( item->Type() )
845  {
846  case PCB_TEXT_T:
847  {
848  TEXTE_PCB* text = static_cast<TEXTE_PCB*>( item );
849  TEXTE_MODULE* textMod = new TEXTE_MODULE( (MODULE*) parent );
850 
851  // Assignment operator also copies the item PCB_TEXT_T type,
852  // so it cannot be added to a module which handles PCB_MODULE_TEXT_T
853  textMod->SetText( text->GetText() );
854 #if 0
855  textMod->SetTextSize( text->GetTextSize() );
856  textMod->SetThickness( text->GetThickness() );
857  textMod->SetOrientation( text->GetTextAngle() );
858  textMod->SetTextPos( text->GetTextPos() );
859  textMod->SetTextSize( text->GetTextSize() );
860  textMod->SetVisible( text->GetVisible() );
861  textMod->SetMirrored( text->IsMirrored() );
862  textMod->SetItalic( text->IsItalic() );
863  textMod->SetBold( text->IsBold() );
864  textMod->SetHorizJustify( text->GetHorizJustify() );
865  textMod->SetVertJustify( text->GetVertJustify() );
866  textMod->SetMultilineAllowed( text->IsMultilineAllowed() );
867 #else
868  textMod->EDA_TEXT::SetEffects( *text );
869  textMod->SetLocalCoord(); // using changed SetTexPos() via SetEffects()
870 #endif
871  converted = textMod;
872  break;
873  }
874 
875  case PCB_LINE_T:
876  {
877  DRAWSEGMENT* seg = static_cast<DRAWSEGMENT*>( item );
878  EDGE_MODULE* modSeg = new EDGE_MODULE( (MODULE*) parent );
879 
880  // Assignment operator also copies the item PCB_LINE_T type,
881  // so it cannot be added to a module which handles PCB_MODULE_EDGE_T
882  modSeg->SetWidth( seg->GetWidth() );
883  modSeg->SetStart( seg->GetStart() );
884  modSeg->SetEnd( seg->GetEnd() );
885  modSeg->SetAngle( seg->GetAngle() );
886  modSeg->SetShape( seg->GetShape() );
887  modSeg->SetType( seg->GetType() );
888  modSeg->SetBezControl1( seg->GetBezControl1() );
889  modSeg->SetBezControl2( seg->GetBezControl2() );
890  modSeg->SetBezierPoints( seg->GetBezierPoints() );
891  modSeg->SetPolyShape( seg->GetPolyShape() );
892  modSeg->SetLocalCoord();
893  converted = modSeg;
894  break;
895  }
896 
897  default:
898  assert( false );
899  break;
900  }
901 
902  if( converted )
903  converted->SetLayer( static_cast<BOARD_ITEM*>( item )->GetLayer() );
904 
905  delete item;
906  item = converted;
907  }
908 
909  if( item )
910  commit.Add( item );
911  }
912 
913  commit.Push( _( "Place a DXF drawing" ) );
914  break;
915  }
916  }
917 
918  preview.Clear();
919  m_view->Remove( &preview );
920 
921  return 0;
922 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:191
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void SetShape(STROKE_T aShape)
const wxPoint & GetBezControl2() const
void SetPolyShape(const SHAPE_POLY_SET &aShape)
bool IsMultilineAllowed() const
Definition: eda_text.h:201
void SetBezierPoints(const std::vector< wxPoint > &aPoints)
const wxPoint & GetTextPos() const
Definition: eda_text.h:237
bool IsItalic() const
Definition: eda_text.h:183
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void SetType(int aType)
void SetItalic(bool isItalic)
Definition: eda_text.h:182
EDA_ITEM * Front() const
Definition: selection.h:152
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
Definition: view.cpp:365
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:236
void SetVisible(bool aVisible)
Definition: eda_text.h:188
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
bool IsRotateToolEvt(const TOOL_EVENT &aEvt)
Function isRotateToolEvt()
EDA_TEXT_HJUSTIFY_T GetHorizJustify() const
Definition: eda_text.h:203
void SetBezControl2(const wxPoint &aPoint)
static const int delta[8][2]
Definition: solve.cpp:112
bool IsBold() const
Definition: eda_text.h:186
double GetTextAngle() const
Definition: eda_text.h:177
int GetThickness() const
Function GetThickness returns pen width.
Definition: eda_text.h:167
virtual void Add(EDA_ITEM *aItem)
Definition: selection.h:74
KIGFX::VIEW * m_view
Definition: drawing_tool.h:271
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:143
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:207
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
const wxPoint & GetBezControl1() const
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:272
SHAPE_POLY_SET & GetPolyShape()
int GetType() const
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1521
void SetMultilineAllowed(bool aAllow)
Function SetMultiLineAllowed.
Definition: eda_text.h:200
void SetStart(const wxPoint &aStart)
virtual const wxPoint GetPosition() const =0
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:274
bool m_editModules
Definition: pcb_tool.h:150
const std::vector< wxPoint > & GetBezierPoints() const
void SetLocalCoord()
Set relative coordinates from draw coordinates.
EDA_TEXT_VJUSTIFY_T GetVertJustify() const
Definition: eda_text.h:204
static TOOL_ACTION flip
Flipping of selected objects.
Definition: pcb_actions.h:105
void SetLocalCoord()
Set relative coordinates.
double GetAngle() const
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:206
bool IsMirrored() const
Definition: eda_text.h:192
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()
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
Definition: view.cpp:335
const wxSize & GetTextSize() const
Definition: eda_text.h:228
Abstract interface for BOARD_ITEMs capable of storing other items inside.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
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:185
void Flip(T &aValue)
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:161
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
void SetBezControl1(const wxPoint &aPoint)
virtual void SetText(const wxString &aText)
Definition: eda_text.h:154
void SetWidth(int aWidth)
int DRAWING_TOOL::PlaceText ( const TOOL_EVENT aEvent)

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

Definition at line 319 of file drawing_tool.cpp.

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

Referenced by setTransitions().

320 {
321  if( m_editModules && !m_frame->GetModel() )
322  return 0;
323 
324  BOARD_ITEM* text = NULL;
325  const BOARD_DESIGN_SETTINGS& dsnSettings = m_frame->GetDesignSettings();
327  SELECTION& selection = selTool->GetSelection();
328  BOARD_COMMIT commit( m_frame );
329 
331  m_controls->ShowCursor( true );
332  m_controls->SetSnapping( true );
333  // do not capture or auto-pan until we start placing some text
334 
335  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT );
336 
337  Activate();
339  wxCURSOR_PENCIL, _( "Add text" ) );
340 
341  bool reselect = false;
342 
343  // Main loop: keep receiving events
344  while( OPT_TOOL_EVENT evt = Wait() )
345  {
346  VECTOR2I cursorPos = m_controls->GetCursorPosition();
347 
348  if( reselect && text )
350 
352  {
353  if( text )
354  {
356 
357  // Delete the old text and have another try
358  delete text;
359  text = NULL;
360 
361  m_controls->SetAutoPan( false );
362  m_controls->CaptureCursor( false );
363  m_controls->ShowCursor( true );
364  }
365  else
366  break;
367 
368  if( evt->IsActivate() ) // now finish unconditionally
369  break;
370  }
371  else if( evt->IsClick( BUT_RIGHT ) )
372  {
374  }
375  else if( evt->IsClick( BUT_LEFT ) )
376  {
377  if( !text )
378  {
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( layer );
388  textMod->SetTextSize( dsnSettings.GetTextSize( layer ) );
389  textMod->SetThickness( dsnSettings.GetTextThickness( layer ) );
390  textMod->SetItalic( dsnSettings.GetTextItalic( layer ) );
391  textMod->SetKeepUpright( dsnSettings.GetTextUpright( layer ) );
392  textMod->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
393 
394  DIALOG_TEXT_PROPERTIES textDialog( m_frame, textMod, NULL );
395  bool placing;
396 
397  RunMainStack([&]() {
398  placing = textDialog.ShowModal() && ( textMod->GetText().Length() > 0 );
399  } );
400 
401  if( placing )
402  text = textMod;
403  else
404  delete textMod;
405  }
406  else
407  {
408  TEXTE_PCB* textPcb = new TEXTE_PCB( m_frame->GetModel() );
409  // TODO we have to set IS_NEW, otherwise InstallTextPCB.. creates an undo entry :| LEGACY_CLEANUP
410  textPcb->SetFlags( IS_NEW );
411 
412  textPcb->SetLayer( layer );
413 
414  // Set the mirrored option for layers on the BACK side of the board
415  if( IsBackLayer( layer ) )
416  textPcb->SetMirrored( true );
417 
418  textPcb->SetTextSize( dsnSettings.GetTextSize( layer ) );
419  textPcb->SetThickness( dsnSettings.GetTextThickness( layer ) );
420  textPcb->SetItalic( dsnSettings.GetTextItalic( layer ) );
421  textPcb->SetTextPos( wxPoint( cursorPos.x, cursorPos.y ) );
422 
423  RunMainStack([&]() {
424  m_frame->InstallTextOptionsFrame( textPcb, NULL );
425  } );
426 
427  if( textPcb->GetText().IsEmpty() )
428  delete textPcb;
429  else
430  text = textPcb;
431  }
432 
433  if( text == NULL )
434  continue;
435 
436  m_controls->WarpCursor( text->GetPosition(), true );
438  m_controls->CaptureCursor( true );
439  m_controls->SetAutoPan( true );
440 
442  }
443  else
444  {
445  text->ClearFlags();
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  selection.SetReferencePoint( cursorPos );
462  m_view->Update( &selection );
463  frame()->SetMsgPanel( text );
464  }
465 
466  else if( text && evt->IsAction( &PCB_ACTIONS::properties ) )
467  {
468  // Calling 'Properties' action clears the selection, so we need to restore it
469  reselect = true;
470  }
471  }
472 
473  frame()->SetMsgPanel( board() );
475 
476  return 0;
477 }
void SetMirrored(bool isMirrored)
Definition: eda_text.h:191
static TOOL_ACTION selectionClear
Clears the current selection.
Definition: pcb_actions.h:53
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
void SetKeepUpright(bool aKeepUpright)
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
bool GetTextItalic(PCB_LAYER_ID aLayer) const
virtual void SetPosition(const wxPoint &aPos)=0
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
void RunMainStack(std::function< void()> aFunc)
Function RunMainStack()
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it&#39;s a back layer.
Class SELECTION_TOOL.
void SetItalic(bool isItalic)
Definition: eda_text.h:182
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
void SetTextPos(const wxPoint &aPoint)
Definition: eda_text.h:236
static TOOL_ACTION properties
Activation of the edit tool.
Definition: pcb_actions.h:111
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Function RunAction() Runs the specified action.
Definition: tool_manager.h:125
int GetTextThickness(PCB_LAYER_ID aLayer) const
Function GetTextThickness Returns the default text thickness from the layer class for the given layer...
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
void InstallTextOptionsFrame(BOARD_ITEM *aText, wxDC *aDC)
Routine for main window class to launch text properties dialog.
wxSize GetTextSize(PCB_LAYER_ID aLayer) const
Function GetTextSize Returns the default text size from the layer class for the given layer...
KIGFX::VIEW * m_view
Definition: drawing_tool.h:271
#define IS_NEW
New item, just created.
Definition: base_struct.h:114
virtual void WarpCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
Function WarpCursor() If enabled (.
PCB_LAYER_ID
A quick note on layer IDs:
RAII class that sets an value at construction and resets it to the original value at destruction...
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:256
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
PCB_EDIT_FRAME * frame() const
Definition: pcb_tool.h:139
SELECTION & GetSelection()
Function GetSelection()
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
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:272
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
bool IsCancelInteractive(const TOOL_EVENT &aEvt)
Function IsCancelInteractive()
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
Definition: view.cpp:1521
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
virtual const wxPoint GetPosition() const =0
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:274
bool m_editModules
Definition: pcb_tool.h:150
bool GetTextUpright(PCB_LAYER_ID aLayer) const
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
static TOOL_ACTION selectItem
Selects an item (specified as the event parameter).
Definition: pcb_actions.h:56
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:257
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
virtual PCB_LAYER_ID GetActiveLayer() const
Function GetActiveLayer returns the active layer.
void SetThickness(int aNewThickness)
Function SetThickness sets pen width.
Definition: eda_text.h:161
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
Class BOARD_DESIGN_SETTINGS contains design settings for a BOARD object.
BOARD * board() const
Definition: pcb_tool.h:140
void DRAWING_TOOL::Reset ( RESET_REASON  aReason)
overridevirtual

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

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

Parameters
aReasoncontains information about the reason of tool reset.

Reimplemented from PCB_TOOL.

Definition at line 203 of file drawing_tool.cpp.

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

204 {
205  // Init variables used by every drawing tool
206  m_view = getView();
208  m_board = getModel<BOARD>();
209  m_frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
210 }
BOARD * m_board
Definition: drawing_tool.h:273
KIGFX::VIEW * m_view
Definition: drawing_tool.h:271
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:272
KIGFX::VIEW_CONTROLS * getViewControls() const
Function getViewControls()
Definition: tool_base.cpp:41
PCB_BASE_EDIT_FRAME * m_frame
Definition: drawing_tool.h:274
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.

const SELECTION & PCB_TOOL::selection ( ) const
protectedinherited

Definition at line 245 of file pcb_tool.cpp.

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

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

246 {
247  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
248  const auto& selection = selTool->GetSelection();
249  return selection;
250 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
SELECTION & PCB_TOOL::selection ( )
protectedinherited

Definition at line 252 of file pcb_tool.cpp.

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

253 {
254  auto selTool = m_toolMgr->GetTool<SELECTION_TOOL>();
255  auto& selection = selTool->GetSelection();
256  return selection;
257 }
Class SELECTION_TOOL.
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:215
const SELECTION & selection() const
Definition: pcb_tool.cpp:245
int DRAWING_TOOL::SetAnchor ( const TOOL_EVENT aEvent)

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

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

Referenced by setTransitions().

926 {
927  assert( m_editModules );
928 
929  if( !m_frame->GetModel() )
930  return 0;
931 
932  SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::ANCHOR );
933 
934  Activate();
935  m_frame->SetToolID( ID_MODEDIT_ANCHOR_TOOL, wxCURSOR_PENCIL,
936  _( "Place the footprint anchor" ) );
937 
938  m_controls->ShowCursor( true );
939  m_controls->SetSnapping( true );
940  m_controls->SetAutoPan( true );
941  m_controls->CaptureCursor( false );
942 
943  while( OPT_TOOL_EVENT evt = Wait() )
944  {
945  if( evt->IsClick( BUT_LEFT ) )
946  {
948  BOARD_COMMIT commit( m_frame );
949  commit.Modify( module );
950 
951  // set the new relative internal local coordinates of footprint items
952  VECTOR2I cursorPos = m_controls->GetCursorPosition();
953  wxPoint moveVector = module->GetPosition() - wxPoint( cursorPos.x, cursorPos.y );
954  module->MoveAnchorPosition( moveVector );
955 
956  commit.Push( _( "Move the footprint reference anchor" ) );
957 
958  // Usually, we do not need to change twice the anchor position,
959  // so deselect the active tool
960  break;
961  }
962  else if( evt->IsClick( BUT_RIGHT ) )
963  {
965  }
966  else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
967  break;
968  }
969 
971 
972  return 0;
973 }
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
virtual void SetToolID(int aId, int aCursor, const wxString &aToolMsg) override
Set the tool command ID to aId and sets the cursor to aCursor.
TOOL_MENU m_menu
Menu model displayed by the tool.
Definition: pcb_tool.h:148
OPT_TOOL_EVENT Wait(const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
Function Wait()
virtual void SetSnapping(bool aEnabled)
Function SetSnapping() Enables/disables snapping cursor to grid.
void MoveAnchorPosition(const wxPoint &aMoveVector)
Function MoveAnchorPosition Move the reference point of the footprint It looks like a move footprint:...
RAII class that sets an value at construction and resets it to the original value at destruction...
virtual void CaptureCursor(bool aEnabled)
Function CaptureCursor() Forces the cursor to stay within the drawing panel area. ...
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
MODULE * module() const
Definition: pcb_tool.h:141
KIGFX::VIEW_CONTROLS * m_controls
Definition: drawing_tool.h:272
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:274
bool m_editModules
Definition: pcb_tool.h:150
virtual void SetNoToolSelected()
Select the ID_NO_TOOL_SELECTED id tool (Idle tool)
void Activate()
Function Activate() Runs the tool.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Function GetModel()
void ShowContextMenu(SELECTION &aSelection)
Function ShowContextMenu.
Definition: tool_menu.cpp:62
const wxPoint GetPosition() const override
Definition: class_module.h:184
OPT< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:495
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::doSelectionMenu(), 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&#39;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 97 of file pcb_tool.h.

98  {
99  m_editModules = aEnabled;
100  }
bool m_editModules
Definition: pcb_tool.h:150
void DRAWING_TOOL::setTransitions ( )
overridevirtual

Sets up handlers for various events.

Reimplemented from PCB_TOOL.

Definition at line 1758 of file drawing_tool.cpp.

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

1759 {
1773 }
static TOOL_ACTION drawLine
Activation of the drawing tool (line)
Definition: pcb_actions.h:142
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:181
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:172
static TOOL_ACTION drawArc
Activation of the drawing tool (arc)
Definition: pcb_actions.h:151
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:166
static TOOL_ACTION setAnchor
Activation of the drawing tool (placing the footprint anchor)
Definition: pcb_actions.h:184
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:154
static TOOL_ACTION drawGraphicPolygon
Definition: pcb_actions.h:145
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 one to input text and its settings and then lets t...
static TOOL_ACTION drawDimension
Activation of the drawing tool (dimension)
Definition: pcb_actions.h:157
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:163
static TOOL_ACTION drawZoneCutout
Activation of the drawing tool (drawing a ZONE cutout)
Definition: pcb_actions.h:169
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:148
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:160
int DrawDimension(const TOOL_EVENT &aEvent)
Function DrawDimension() Starts interactively drawing a dimension.
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(), PCB_TOOL::doInteractiveItemPlacement(), SELECTION_TOOL::doSelectionMenu(), drawArc(), DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), drawSegment(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), MODULE_EDITOR_TOOLS::EnumeratePads(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineDrag(), ZOOM_TOOL::Main(), PICKER_TOOL::Main(), CVPCB_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EDIT_TOOL::Main(), SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::mainLoop(), ROUTER_TOOL::mainLoop(), CVPCB_SELECTION_TOOL::MeasureTool(), GERBVIEW_SELECTION_TOOL::MeasureTool(), EDIT_TOOL::MeasureTool(), POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), EDIT_TOOL::pickCopyReferencePoint(), PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), 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
OPT< TOOL_EVENT > ScheduleWait(TOOL_BASE *aTool, const TOOL_EVENT_LIST &aConditions)
Pauses execution of a given tool until one or more events matching aConditions arrives.

Friends And Related Function Documentation

friend class ZONE_CREATE_HELPER
friend

Definition at line 285 of file drawing_tool.h.

Member Data Documentation

BOARD* DRAWING_TOOL::m_board
private

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

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

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(), and TOOL_BASE::IsToolActive().

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), TOOL_BASE::attachManager(), PCB_EDITOR_CONTROL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), PCB_EDITOR_CONTROL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), SELECTION_TOOL::clearSelection(), PAD_TOOL::copyPadSettings(), MODULE_EDITOR_TOOLS::CreatePadFromShapes(), PCB_EDITOR_CONTROL::CrossProbePcbToSch(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), ROUTER_TOOL::CustomTrackWidthDialog(), PCBNEW_CONTROL::DeleteItemCursor(), drawArc(), DrawDimension(), drawSegment(), drawZone(), PCB_EDITOR_CONTROL::DrillOrigin(), EDIT_TOOL::Duplicate(), EDIT_TOOL::editFootprintInFpEditor(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::ExchangeFootprints(), SELECTION_TOOL::expandSelectedConnection(), MODULE_EDITOR_TOOLS::ExplodePadToShapes(), SELECTION_TOOL::findCallback(), SELECTION_TOOL::findMove(), EDIT_TOOL::Flip(), TOOL_BASE::getEditFrameInt(), TOOL_BASE::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(), PCB_EDITOR_CONTROL::Init(), POINT_EDITOR::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(), PAD_TOOL::pastePadProperties(), EDIT_TOOL::pickCopyReferencePoint(), PCBNEW_CONTROL::placeBoardItems(), PlaceDXF(), PCB_EDITOR_CONTROL::PlaceModule(), PCB_EDITOR_CONTROL::PlaceTarget(), PlaceText(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), POINT_EDITOR::removeCorner(), SELECTION_TOOL::RequestSelection(), CVPCB_CONTROL::ResetCoords(), PCBNEW_CONTROL::ResetCoords(), TOOL_INTERACTIVE::resetTransitions(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), ZONE_FILLER_TOOL::SegzoneDeleteFill(), SELECTION_TOOL::selectCopper(), PCB_TOOL::selection(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), GERBVIEW_SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectMultiple(), SELECTION_TOOL::selectNet(), SELECTION_TOOL::selectOnSheetFromEeschema(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), SELECTION_TOOL::selectSameSheet(), TOOL_INTERACTIVE::SetContextMenu(), PCB_EDITOR_CONTROL::ShowLocalRatsnest(), GERBVIEW_SELECTION_TOOL::toggleSelection(), SELECTION_TOOL::toggleSelection(), PCB_EDITOR_CONTROL::TrackWidthDec(), PCB_EDITOR_CONTROL::TrackWidthInc(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), PCB_EDITOR_CONTROL::UpdateSelectionRatsnest(), PCB_EDITOR_CONTROL::ViaSizeDec(), PCB_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), PCB_EDITOR_CONTROL::ZoneDuplicate(), and PCB_EDITOR_CONTROL::ZoneMerge().

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.

TOOL_SETTINGS TOOL_BASE::m_toolSettings
protectedinherited

Definition at line 216 of file tool_base.h.

Referenced by TOOL_BASE::attachManager().

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

Stores the type of the tool.

Definition at line 207 of file tool_base.h.

KIGFX::VIEW* DRAWING_TOOL::m_view
private

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

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


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