KiCad PCB EDA Suite
CONVERT_TOOL Class Reference

#include <convert_tool.h>

Inheritance diagram for CONVERT_TOOL:
TOOL_INTERACTIVE TOOL_BASE

Public Types

enum  RESET_REASON { RUN, MODEL_RELOAD, GAL_SWITCH }
 Determine the reason of reset for a tool. More...
 

Public Member Functions

 CONVERT_TOOL ()
 
virtual ~CONVERT_TOOL ()
 
void Reset (RESET_REASON aReason) override
 Bring the tool to a known, initial state. More...
 
bool Init () override
 Init() is called once upon a registration of the tool. More...
 
int CreatePolys (const TOOL_EVENT &aEvent)
 Convert selected lines to a polygon, if possible. More...
 
int CreateLines (const TOOL_EVENT &aEvent)
 Convert selected polygon-like object to graphic lines, if possible. More...
 
int SegmentToArc (const TOOL_EVENT &aEvent)
 Convert selected segment (graphic or track) to an arc of the same type. More...
 
void setTransitions () override
 This method is meant to be overridden in order to specify handlers for events. More...
 
void Activate ()
 Run the tool. More...
 
TOOL_MENUGetToolMenu ()
 
void SetContextMenu (ACTION_MENU *aMenu, CONTEXT_MENU_TRIGGER aTrigger=CMENU_BUTTON)
 Assign a context menu and tells when it should be activated. More...
 
void RunMainStack (std::function< void()> aFunc)
 Call a function using the main stack. More...
 
template<class T >
void Go (int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
 Define which state (aStateFunc) to go when a certain event arrives (aConditions). More...
 
TOOL_EVENTWait (const TOOL_EVENT_LIST &aEventList=TOOL_EVENT(TC_ANY, TA_ANY))
 Suspend execution of the tool until an event specified in aEventList arrives. More...
 
TOOL_TYPE GetType () const
 Return the type of the tool. More...
 
TOOL_ID GetId () const
 Return the unique identifier of the tool. More...
 
const std::string & GetName () const
 Return the name of the tool. More...
 
TOOL_MANAGERGetManager () const
 Return the instance of TOOL_MANAGER that takes care of the tool. More...
 
bool IsToolActive () const
 

Protected Member Functions

void attachManager (TOOL_MANAGER *aManager)
 Set the TOOL_MANAGER the tool will belong to. More...
 
KIGFX::VIEWgetView () const
 Returns the instance of #VIEW object used in the application. More...
 
KIGFX::VIEW_CONTROLSgetViewControls () const
 Return the instance of VIEW_CONTROLS object used in the application. More...
 
template<typename T >
T * getEditFrame () const
 Return the application window object, casted to requested user type. More...
 
template<typename T >
T * getModel () const
 Return the model object if it matches the requested type. More...
 

Protected Attributes

TOOL_TYPE m_type
 Unique identifier for the tool, assigned by a TOOL_MANAGER instance. More...
 
TOOL_ID m_toolId
 Name of the tool. More...
 
std::string m_toolName
 
TOOL_MANAGERm_toolMgr
 

Static Private Member Functions

static OPT< SEGgetStartEndPoints (EDA_ITEM *aItem, int *aWidth)
 Retrieve the start and end points for a generic item. More...
 
static SHAPE_POLY_SET makePolysFromSegs (const std::deque< EDA_ITEM * > &aItems)
 Try to make polygons from segments in the selected items. More...
 
static SHAPE_POLY_SET makePolysFromRects (const std::deque< EDA_ITEM * > &aItems)
 Try to make polygons from rectangles. More...
 
static SHAPE_POLY_SET makePolysFromCircles (const std::deque< EDA_ITEM * > &aItems)
 Try to make polygons from circles. More...
 
static SHAPE_POLY_SET extractPolygons (const std::deque< EDA_ITEM * > &aItems)
 For any polygon shapes (zones, keepouts, graphic polys) in aItems, extracts the polygon outlines into the returned SHAPE_POLY_SET. More...
 

Private Attributes

PCB_SELECTION_TOOLm_selectionTool
 
CONDITIONAL_MENUm_menu
 
PCB_BASE_FRAMEm_frame
 

Detailed Description

Definition at line 36 of file convert_tool.h.

Member Enumeration Documentation

◆ RESET_REASON

enum TOOL_BASE::RESET_REASON
inherited

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

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

Constructor & Destructor Documentation

◆ CONVERT_TOOL()

CONVERT_TOOL::CONVERT_TOOL ( )

Definition at line 49 of file convert_tool.cpp.

49  :
50  TOOL_INTERACTIVE( "pcbnew.Convert" ),
51  m_selectionTool( nullptr ),
52  m_menu( nullptr ),
53  m_frame( nullptr )
54 {
55 }
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Create a tool with given id & name.
PCB_SELECTION_TOOL * m_selectionTool
Definition: convert_tool.h:109
PCB_BASE_FRAME * m_frame
Definition: convert_tool.h:111
CONDITIONAL_MENU * m_menu
Definition: convert_tool.h:110

◆ ~CONVERT_TOOL()

CONVERT_TOOL::~CONVERT_TOOL ( )
virtual

Definition at line 58 of file convert_tool.cpp.

59 {
60  delete m_menu;
61 }
CONDITIONAL_MENU * m_menu
Definition: convert_tool.h:110

References m_menu.

Member Function Documentation

◆ Activate()

void TOOL_INTERACTIVE::Activate ( )
inherited

Run the tool.

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

Definition at line 51 of file tool_interactive.cpp.

52 {
54 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool InvokeTool(TOOL_ID aToolId)
Call a tool by sending a tool activation event to tool of given ID.

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

Referenced by AUTOPLACE_TOOL::autoplace(), EDIT_TOOL::copyToClipboard(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), PAD_TOOL::EnumeratePads(), PCB_CONTROL::GridSetOrigin(), SCH_EDITOR_CONTROL::HighlightNetCursor(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), EE_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), LIB_TREE::onContextMenu(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ attachManager()

void TOOL_BASE::attachManager ( TOOL_MANAGER aManager)
protectedinherited

Set the TOOL_MANAGER the tool will belong to.

Called by TOOL_MANAGER::RegisterTool()

Definition at line 60 of file tool_base.cpp.

61 {
62  m_toolMgr = aManager;
63 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214

References TOOL_BASE::m_toolMgr.

Referenced by TOOL_MANAGER::RegisterTool().

◆ CreateLines()

int CONVERT_TOOL::CreateLines ( const TOOL_EVENT aEvent)

Convert selected polygon-like object to graphic lines, if possible.

Definition at line 511 of file convert_tool.cpp.

512 {
513  auto& selection = m_selectionTool->RequestSelection(
514  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
515  {
516  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
517  {
518  BOARD_ITEM* item = aCollector[i];
519 
520  switch( item->Type() )
521  {
522  case PCB_SHAPE_T:
523  case PCB_FP_SHAPE_T:
524  switch( static_cast<PCB_SHAPE*>( item )->GetShape() )
525  {
526  case SHAPE_T::POLY:
527  break;
528 
529  case SHAPE_T::RECT:
530  break;
531 
532  default:
533  aCollector.Remove( item );
534  }
535 
536  break;
537 
538  case PCB_ZONE_T:
539  case PCB_FP_ZONE_T:
540  break;
541 
542  default:
543  aCollector.Remove( item );
544  }
545  }
546  } );
547 
548  if( selection.Empty() )
549  return 0;
550 
551  auto getPolySet =
552  []( EDA_ITEM* aItem )
553  {
554  SHAPE_POLY_SET set;
555 
556  switch( aItem->Type() )
557  {
558  case PCB_ZONE_T:
559  case PCB_FP_ZONE_T:
560  set = *static_cast<ZONE*>( aItem )->Outline();
561  break;
562 
563  case PCB_SHAPE_T:
564  case PCB_FP_SHAPE_T:
565  {
566  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
567 
568  if( graphic->GetShape() == SHAPE_T::POLY )
569  {
570  set = graphic->GetPolyShape();
571  }
572  else if( graphic->GetShape() == SHAPE_T::RECT )
573  {
574  SHAPE_LINE_CHAIN outline;
575  VECTOR2I start( graphic->GetStart() );
576  VECTOR2I end( graphic->GetEnd() );
577 
578  outline.Append( start );
579  outline.Append( VECTOR2I( end.x, start.y ) );
580  outline.Append( end );
581  outline.Append( VECTOR2I( start.x, end.y ) );
582  outline.SetClosed( true );
583 
584  set.AddOutline( outline );
585  }
586  else
587  {
588  wxFAIL_MSG( "Unhandled graphic shape type in PolyToLines - getPolySet" );
589  }
590  break;
591  }
592 
593  default:
594  wxFAIL_MSG( "Unhandled type in PolyToLines - getPolySet" );
595  break;
596  }
597 
598  return set;
599  };
600 
601  auto getSegList =
602  []( SHAPE_POLY_SET& aPoly )
603  {
604  std::vector<SEG> segs;
605 
606  // Our input should be valid polys, so OK to assert here
607  wxASSERT( aPoly.VertexCount() >= 2 );
608 
609  for( int i = 1; i < aPoly.VertexCount(); i++ )
610  segs.emplace_back( SEG( aPoly.CVertex( i - 1 ), aPoly.CVertex( i ) ) );
611 
612  segs.emplace_back( SEG( aPoly.CVertex( aPoly.VertexCount() - 1 ),
613  aPoly.CVertex( 0 ) ) );
614 
615  return segs;
616  };
617 
618  BOARD_COMMIT commit( m_frame );
619  FOOTPRINT_EDIT_FRAME* fpEditor = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame );
620  FOOTPRINT* footprint = nullptr;
621  PCB_LAYER_ID targetLayer = m_frame->GetActiveLayer();
622  PCB_LAYER_ID copperLayer = UNSELECTED_LAYER;
623 
624  if( fpEditor )
625  footprint = fpEditor->GetBoard()->GetFirstFootprint();
626 
627  for( EDA_ITEM* item : selection )
628  {
629  SHAPE_POLY_SET polySet = getPolySet( item );
630  std::vector<SEG> segs = getSegList( polySet );
631 
632  if( aEvent.IsAction( &PCB_ACTIONS::convertToLines ) )
633  {
634  for( SEG& seg : segs )
635  {
636  if( fpEditor )
637  {
638  FP_SHAPE* graphic = new FP_SHAPE( footprint, SHAPE_T::SEGMENT );
639 
640  graphic->SetLayer( targetLayer );
641  graphic->SetStart( wxPoint( seg.A ) );
642  graphic->SetStart0( wxPoint( seg.A ) );
643  graphic->SetEnd( wxPoint( seg.B ) );
644  graphic->SetEnd0( wxPoint( seg.B ) );
645  commit.Add( graphic );
646  }
647  else
648  {
649  PCB_SHAPE* graphic = new PCB_SHAPE;
650 
651  graphic->SetShape( SHAPE_T::SEGMENT );
652  graphic->SetLayer( targetLayer );
653  graphic->SetStart( wxPoint( seg.A ) );
654  graphic->SetEnd( wxPoint( seg.B ) );
655  commit.Add( graphic );
656  }
657  }
658  }
659  else
660  {
661  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
662  BOARD_ITEM_CONTAINER* parent = frame->GetModel();
663 
664  if( !IsCopperLayer( targetLayer ) )
665  {
666  if( copperLayer == UNSELECTED_LAYER )
667  copperLayer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() );
668 
669  if( copperLayer == UNDEFINED_LAYER ) // User canceled
670  continue;
671 
672  targetLayer = copperLayer;
673  }
674 
675  // I am really unsure converting a polygon to "tracks" (i.e. segments on
676  // copper layers) make sense for footprints, but anyway this code exists
677  if( fpEditor )
678  {
679  // Creating segments on copper layer
680  for( SEG& seg : segs )
681  {
682  FP_SHAPE* graphic = new FP_SHAPE( footprint, SHAPE_T::SEGMENT );
683  graphic->SetLayer( targetLayer );
684  graphic->SetStart( wxPoint( seg.A ) );
685  graphic->SetStart0( wxPoint( seg.A ) );
686  graphic->SetEnd( wxPoint( seg.B ) );
687  graphic->SetEnd0( wxPoint( seg.B ) );
688  commit.Add( graphic );
689  }
690  }
691  else
692  {
693  // Creating tracks
694  for( SEG& seg : segs )
695  {
696  PCB_TRACK* track = new PCB_TRACK( parent );
697 
698  track->SetLayer( targetLayer );
699  track->SetStart( wxPoint( seg.A ) );
700  track->SetEnd( wxPoint( seg.B ) );
701  commit.Add( track );
702  }
703  }
704  }
705  }
706 
707  commit.Push( _( "Convert polygons to lines" ) );
708 
709  return 0;
710 }
PCB_LAYER_ID SelectOneLayer(PCB_LAYER_ID aDefaultLayer, LSET aNotAllowedLayersMask=LSET(), wxPoint aDlgPosition=wxDefaultPosition)
Show the dialog box for a layer selection.
Definition: sel_layer.cpp:231
void SetEnd0(const wxPoint &aPoint)
Definition: fp_shape.h:114
void SetShape(SHAPE_T aShape)
Definition: pcb_shape.h:109
polygon (not yet used for tracks, but could be in microwave apps)
SHAPE_POLY_SET & GetPolyShape()
Definition: pcb_shape.h:240
static TOOL_ACTION convertToLines
Definition: pcb_actions.h:475
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: pcb_shape.h:134
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:192
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
SHAPE_T GetShape() const
Definition: pcb_shape.h:110
void SetEnd(const wxPoint &aEnd)
Definition: pcb_track.h:104
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:773
usual segment : line with rounded ends
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
PCB_SELECTION_TOOL * m_selectionTool
Definition: convert_tool.h:109
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
virtual PCB_LAYER_ID GetActiveLayer() const
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:317
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: pcb_shape.h:124
void SetStart(const wxPoint &aStart)
Definition: pcb_track.h:107
#define _(s)
class ZONE, a copper pour area
Definition: typeinfo.h:105
void SetStart0(const wxPoint &aPoint)
Definition: fp_shape.h:111
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:787
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
Definition: seg.h:40
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
PCB_BASE_FRAME * m_frame
Definition: convert_tool.h:111
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
Common, abstract interface for edit frames.
void SetStart(const wxPoint &aStart)
Definition: pcb_shape.h:127
Represent a polyline (an zero-thickness chain of connected line segments).
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
Definition: layer_ids.h:70
class ZONE, managed by a footprint
Definition: typeinfo.h:94
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD * GetBoard() const
segment with non rounded ends
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
void SetEnd(const wxPoint &aEnd)
Definition: pcb_shape.h:137
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References _, COMMIT::Add(), SHAPE_POLY_SET::AddOutline(), LSET::AllNonCuMask(), SHAPE_LINE_CHAIN::Append(), PCB_ACTIONS::convertToLines, F_Cu, PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetBoard(), COLLECTOR::GetCount(), PCB_SHAPE::GetEnd(), BOARD::GetFirstFootprint(), PCB_BASE_FRAME::GetModel(), PCB_SHAPE::GetPolyShape(), PCB_SHAPE::GetShape(), PCB_SHAPE::GetStart(), TOOL_EVENT::IsAction(), IsCopperLayer(), m_frame, m_selectionTool, SHAPE_POLY_SET::Outline(), PCB_FP_SHAPE_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_ZONE_T, POLY, BOARD_COMMIT::Push(), RECT, COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), SEGMENT, PCB_BASE_FRAME::SelectOneLayer(), SHAPE_LINE_CHAIN::SetClosed(), PCB_TRACK::SetEnd(), PCB_SHAPE::SetEnd(), FP_SHAPE::SetEnd0(), BOARD_ITEM::SetLayer(), PCB_SHAPE::SetShape(), PCB_TRACK::SetStart(), PCB_SHAPE::SetStart(), FP_SHAPE::SetStart0(), EDA_ITEM::Type(), UNDEFINED_LAYER, and UNSELECTED_LAYER.

Referenced by setTransitions().

◆ CreatePolys()

int CONVERT_TOOL::CreatePolys ( const TOOL_EVENT aEvent)

Convert selected lines to a polygon, if possible.

Definition at line 120 of file convert_tool.cpp.

121 {
122  FOOTPRINT* parentFootprint = nullptr;
123 
124  auto& selection = m_selectionTool->RequestSelection(
125  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
126  {
127  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
128  {
129  BOARD_ITEM* item = aCollector[i];
130 
131  switch( item->Type() )
132  {
133  case PCB_SHAPE_T:
134  case PCB_FP_SHAPE_T:
135  switch( static_cast<PCB_SHAPE*>( item )->GetShape() )
136  {
137  case SHAPE_T::SEGMENT:
138  case SHAPE_T::RECT:
139  case SHAPE_T::CIRCLE:
140  case SHAPE_T::ARC:
141  case SHAPE_T::POLY:
142  break;
143 
144  default:
145  aCollector.Remove( item );
146  }
147 
148  break;
149 
150  case PCB_TRACE_T:
151  case PCB_ARC_T:
152  break;
153 
154  case PCB_ZONE_T:
155  case PCB_FP_ZONE_T:
156  break;
157 
158  default:
159  aCollector.Remove( item );
160  }
161  }
162  } );
163 
164  if( selection.Empty() )
165  return 0;
166 
167  PCB_LAYER_ID destLayer = m_frame->GetActiveLayer();
168  SHAPE_POLY_SET polySet = makePolysFromSegs( selection.GetItems() );
169 
170  polySet.Append( makePolysFromRects( selection.GetItems() ) );
171 
172  polySet.Append( makePolysFromCircles( selection.GetItems() ) );
173 
174  polySet.Append( extractPolygons( selection.GetItems() ) );
175 
176  if( polySet.IsEmpty() )
177  return 0;
178 
179  bool isFootprint = m_frame->IsType( FRAME_FOOTPRINT_EDITOR );
180 
181  if( FP_SHAPE* graphic = dynamic_cast<FP_SHAPE*>( selection.Front() ) )
182  parentFootprint = graphic->GetParentFootprint();
183 
184  BOARD_COMMIT commit( m_frame );
185 
186  // For now, we convert each outline in the returned shape to its own polygon
187  std::vector<SHAPE_POLY_SET> polys;
188 
189  for( int i = 0; i < polySet.OutlineCount(); i++ )
190  polys.emplace_back( SHAPE_POLY_SET( polySet.COutline( i ) ) );
191 
192  if( aEvent.IsAction( &PCB_ACTIONS::convertToPoly ) )
193  {
194  for( const SHAPE_POLY_SET& poly : polys )
195  {
196  PCB_SHAPE* graphic = isFootprint ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
197 
198  graphic->SetShape( SHAPE_T::POLY );
199  graphic->SetFilled( false );
200  graphic->SetWidth( poly.Outline( 0 ).Width() );
201  graphic->SetLayer( destLayer );
202  graphic->SetPolyShape( poly );
203 
204  commit.Add( graphic );
205  }
206 
207  commit.Push( _( "Convert shapes to polygon" ) );
208  }
209  else
210  {
211  // Creating zone or keepout
212  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
213  BOARD_ITEM_CONTAINER* parent = frame->GetModel();
214  ZONE_SETTINGS zoneInfo = frame->GetZoneSettings();
215 
216  bool nonCopper = IsNonCopperLayer( destLayer );
217  zoneInfo.m_Layers.reset().set( destLayer );
218 
219  int ret;
220 
221  if( aEvent.IsAction( &PCB_ACTIONS::convertToKeepout ) )
222  ret = InvokeRuleAreaEditor( frame, &zoneInfo );
223  else if( nonCopper )
224  ret = InvokeNonCopperZonesEditor( frame, &zoneInfo );
225  else
226  ret = InvokeCopperZonesEditor( frame, &zoneInfo );
227 
228  if( ret == wxID_CANCEL )
229  return 0;
230 
231  for( const SHAPE_POLY_SET& poly : polys )
232  {
233  ZONE* zone = isFootprint ? new FP_ZONE( parent ) : new ZONE( parent );
234 
235  *zone->Outline() = poly;
236  zone->HatchBorder();
237 
238  zoneInfo.ExportSetting( *zone );
239 
240  commit.Add( zone );
241  }
242 
243  commit.Push( _( "Convert shapes to zone" ) );
244  }
245 
246  return 0;
247 }
Arcs (with rounded ends)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void SetShape(SHAPE_T aShape)
Definition: pcb_shape.h:109
polygon (not yet used for tracks, but could be in microwave apps)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:192
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
void SetFilled(bool aFlag)
Definition: pcb_shape.h:73
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
SHAPE_POLY_SET * Outline()
Definition: zone.h:320
bool IsEmpty() const
usual segment : line with rounded ends
static SHAPE_POLY_SET makePolysFromCircles(const std::deque< EDA_ITEM * > &aItems)
Try to make polygons from circles.
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
PCB_SELECTION_TOOL * m_selectionTool
Definition: convert_tool.h:109
static SHAPE_POLY_SET makePolysFromRects(const std::deque< EDA_ITEM * > &aItems)
Try to make polygons from rectangles.
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
bool IsAction(const TOOL_ACTION *aAction) const
Test if the event contains an action issued upon activation of the given TOOL_ACTION.
Definition: tool_event.cpp:88
virtual PCB_LAYER_ID GetActiveLayer() const
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition: zone.cpp:927
Represent a set of closed polygons.
const ZONE_SETTINGS & GetZoneSettings() const
bool IsNonCopperLayer(LAYER_NUM aLayerId)
Test whether a layer is a non copper layer.
Definition: layer_ids.h:798
static TOOL_ACTION convertToKeepout
Definition: pcb_actions.h:474
#define _(s)
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
class ZONE, a copper pour area
Definition: typeinfo.h:105
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:67
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
PCB_BASE_FRAME * m_frame
Definition: convert_tool.h:111
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
bool IsType(FRAME_T aType) const
Common, abstract interface for edit frames.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
class ZONE, managed by a footprint
Definition: typeinfo.h:94
void SetWidth(int aWidth)
Definition: pcb_shape.h:96
The selection tool: currently supports:
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
static TOOL_ACTION convertToPoly
Definition: pcb_actions.h:472
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: pcb_shape.h:248
static SHAPE_POLY_SET makePolysFromSegs(const std::deque< EDA_ITEM * > &aItems)
Try to make polygons from segments in the selected items.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
segment with non rounded ends
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
static SHAPE_POLY_SET extractPolygons(const std::deque< EDA_ITEM * > &aItems)
For any polygon shapes (zones, keepouts, graphic polys) in aItems, extracts the polygon outlines into...
A specialization of ZONE for use in footprints.
Definition: zone.h:946
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

References _, COMMIT::Add(), SHAPE_POLY_SET::Append(), ARC, CIRCLE, PCB_ACTIONS::convertToKeepout, PCB_ACTIONS::convertToPoly, SHAPE_POLY_SET::COutline(), ZONE_SETTINGS::ExportSetting(), extractPolygons(), FRAME_FOOTPRINT_EDITOR, PCB_BASE_FRAME::GetActiveLayer(), COLLECTOR::GetCount(), PCB_BASE_FRAME::GetModel(), PCB_BASE_FRAME::GetZoneSettings(), ZONE::HatchBorder(), InvokeCopperZonesEditor(), InvokeNonCopperZonesEditor(), InvokeRuleAreaEditor(), TOOL_EVENT::IsAction(), SHAPE_POLY_SET::IsEmpty(), IsNonCopperLayer(), EDA_BASE_FRAME::IsType(), m_frame, ZONE_SETTINGS::m_Layers, m_selectionTool, makePolysFromCircles(), makePolysFromRects(), makePolysFromSegs(), ZONE::Outline(), SHAPE_POLY_SET::OutlineCount(), PCB_ARC_T, PCB_FP_SHAPE_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_TRACE_T, PCB_ZONE_T, POLY, BOARD_COMMIT::Push(), RECT, COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), SEGMENT, PCB_SHAPE::SetFilled(), BOARD_ITEM::SetLayer(), PCB_SHAPE::SetPolyShape(), PCB_SHAPE::SetShape(), PCB_SHAPE::SetWidth(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ extractPolygons()

SHAPE_POLY_SET CONVERT_TOOL::extractPolygons ( const std::deque< EDA_ITEM * > &  aItems)
staticprivate

For any polygon shapes (zones, keepouts, graphic polys) in aItems, extracts the polygon outlines into the returned SHAPE_POLY_SET.

Definition at line 476 of file convert_tool.cpp.

477 {
478  SHAPE_POLY_SET poly;
479 
480  for( EDA_ITEM* item : aItems )
481  {
482  switch( item->Type() )
483  {
484  case PCB_SHAPE_T:
485  switch( static_cast<PCB_SHAPE*>( item )->GetShape() )
486  {
487  case SHAPE_T::POLY:
488  poly.Append( static_cast<PCB_SHAPE*>( item )->GetPolyShape() );
489  break;
490 
491  default:
492  continue;
493  }
494 
495  break;
496 
497  case PCB_ZONE_T:
498  case PCB_FP_ZONE_T:
499  poly.Append( *static_cast<ZONE*>( item )->Outline() );
500  break;
501 
502  default:
503  continue;
504  }
505  }
506 
507  return poly;
508 }
polygon (not yet used for tracks, but could be in microwave apps)
Represent a set of closed polygons.
class ZONE, a copper pour area
Definition: typeinfo.h:105
class ZONE, managed by a footprint
Definition: typeinfo.h:94
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...

References SHAPE_POLY_SET::Append(), PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_ZONE_T, and POLY.

Referenced by CreatePolys().

◆ getEditFrame()

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

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

Definition at line 184 of file tool_base.h.

185  {
186 #if !defined( QA_TEST ) // Dynamic casts give the linker a seizure in the test framework
187  wxASSERT( dynamic_cast<T*>( getToolHolderInt() ) );
188 #endif
189  return static_cast<T*>( getToolHolderInt() );
190  }
TOOLS_HOLDER * getToolHolderInt() const
Definition: tool_base.cpp:48

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone().

◆ GetId()

TOOL_ID TOOL_BASE::GetId ( ) const
inlineinherited

Return the unique identifier of the tool.

The identifier is set by an instance of TOOL_MANAGER.

Returns
Identifier of the tool.

Definition at line 120 of file tool_base.h.

121  {
122  return m_toolId;
123  }
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209

References TOOL_BASE::m_toolId.

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

◆ GetManager()

TOOL_MANAGER* TOOL_BASE::GetManager ( ) const
inlineinherited

Return the instance of TOOL_MANAGER that takes care of the tool.

Returns
Instance of the TOOL_MANAGER or NULL if there is no associated tool manager.

Definition at line 143 of file tool_base.h.

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

References TOOL_BASE::m_toolMgr.

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

◆ getModel()

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

Return the model object if it matches the requested type.

Store the type of the tool.

Definition at line 196 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ GetName()

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

Return the name of the tool.

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

Returns
The name of the tool.

Definition at line 133 of file tool_base.h.

134  {
135  return m_toolName;
136  }
std::string m_toolName
Definition: tool_base.h:213

References TOOL_BASE::m_toolName.

Referenced by TOOL_MANAGER::dispatchInternal(), TOOL_MANAGER::InitTools(), TOOL_MANAGER::invokeTool(), TOOL_MANAGER::RegisterTool(), and TOOL_MANAGER::runTool().

◆ getStartEndPoints()

OPT< SEG > CONVERT_TOOL::getStartEndPoints ( EDA_ITEM aItem,
int *  aWidth 
)
staticprivate

Retrieve the start and end points for a generic item.

Parameters
aItemis an item that has a start and end point.
Returns
a segment from start to end, or NULLOPT if invalid.

Definition at line 803 of file convert_tool.cpp.

804 {
805  switch( aItem->Type() )
806  {
807  case PCB_SHAPE_T:
808  case PCB_FP_SHAPE_T:
809  {
810  PCB_SHAPE* line = static_cast<PCB_SHAPE*>( aItem );
811 
812  if( aWidth )
813  *aWidth = line->GetWidth();
814 
815  if( line->GetShape() == SHAPE_T::SEGMENT )
816  {
817  return boost::make_optional<SEG>( { VECTOR2I( line->GetStart() ),
818  VECTOR2I( line->GetEnd() ) } );
819  }
820  else
821  {
822  return boost::make_optional<SEG>( { VECTOR2I( line->GetArcStart() ),
823  VECTOR2I( line->GetArcEnd() ) } );
824  }
825  }
826 
827  case PCB_TRACE_T:
828  {
829  PCB_TRACK* line = static_cast<PCB_TRACK*>( aItem );
830 
831  if( aWidth )
832  *aWidth = line->GetWidth();
833 
834  return boost::make_optional<SEG>( { VECTOR2I( line->GetStart() ),
835  VECTOR2I( line->GetEnd() ) } );
836  }
837 
838  case PCB_ARC_T:
839  {
840  PCB_ARC* arc = static_cast<PCB_ARC*>( aItem );
841 
842  if( aWidth )
843  *aWidth = arc->GetWidth();
844 
845  return boost::make_optional<SEG>( { VECTOR2I( arc->GetStart() ),
846  VECTOR2I( arc->GetEnd() ) } );
847  }
848 
849  default:
850  return NULLOPT;
851  }
852 }
wxPoint GetArcEnd() const
Definition: pcb_shape.cpp:417
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: pcb_shape.h:134
SHAPE_T GetShape() const
Definition: pcb_shape.h:110
int GetWidth() const
Definition: pcb_shape.h:97
usual segment : line with rounded ends
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
int GetWidth() const
Definition: pcb_track.h:102
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
wxPoint GetArcStart() const
Definition: pcb_shape.h:156
const auto NULLOPT
Definition: optional.h:9
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: pcb_shape.h:124
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
const wxPoint & GetStart() const
Definition: pcb_track.h:108
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References PCB_SHAPE::GetArcEnd(), PCB_SHAPE::GetArcStart(), PCB_TRACK::GetEnd(), PCB_SHAPE::GetEnd(), PCB_SHAPE::GetShape(), PCB_TRACK::GetStart(), PCB_SHAPE::GetStart(), PCB_SHAPE::GetWidth(), PCB_TRACK::GetWidth(), NULLOPT, PCB_ARC_T, PCB_FP_SHAPE_T, PCB_SHAPE_T, PCB_TRACE_T, SEGMENT, and EDA_ITEM::Type().

Referenced by makePolysFromSegs(), and SegmentToArc().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 108 of file tool_base.h.

109  {
110  return m_type;
111  }
TOOL_TYPE m_type
Unique identifier for the tool, assigned by a TOOL_MANAGER instance.
Definition: tool_base.h:206

References TOOL_BASE::m_type.

Referenced by TOOL_MANAGER::finishTool(), TOOL_MANAGER::InvokeTool(), TOOL_MANAGER::ResetTools(), TOOL_MANAGER::runTool(), and TOOL_MANAGER::ShutdownTool().

◆ getView()

KIGFX::VIEW * TOOL_BASE::getView ( ) const
protectedinherited

Returns the instance of #VIEW object used in the application.

It allows tools to draw.

Returns
The instance of VIEW.

Definition at line 36 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCornerCondition(), ALIGN_DISTRIBUTE_TOOL::AlignLeft(), ALIGN_DISTRIBUTE_TOOL::AlignRight(), COMMON_TOOLS::CenterContents(), SCH_EDIT_TOOL::ChangeTextType(), EE_INSPECTION_TOOL::CheckSymbol(), GERBVIEW_CONTROL::ClearAllLayers(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::CollectHits(), SCH_LINE_WIRE_BUS_TOOL::computeBreakPoint(), COMMON_TOOLS::CursorControl(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), ROUTER_TOOL::handleCommonEvents(), PL_SELECTION_TOOL::highlight(), EE_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), PNS::TOOL_BASE::highlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), PL_DRAWING_TOOLS::PlaceItem(), BOARD_EDITOR_CONTROL::PlaceTarget(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), BOARD_EDITOR_CONTROL::Reset(), PNS::TOOL_BASE::Reset(), PCB_CONTROL::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), DRAWING_TOOL::Reset(), EE_SELECTION_TOOL::Reset(), PCB_SELECTION_TOOL::Reset(), EE_TOOL_BASE< SCH_BASE_FRAME >::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), GERBVIEW_SELECTION_TOOL::selectable(), PCB_SELECTION_TOOL::Selectable(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectAll(), PL_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_DRAWING_TOOLS::TwoClickPlace(), PL_SELECTION_TOOL::unhighlight(), EE_SELECTION_TOOL::unhighlight(), PCB_SELECTION_TOOL::unhighlight(), GERBVIEW_SELECTION_TOOL::unselect(), GERBVIEW_SELECTION_TOOL::unselectVisually(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), SCH_EDITOR_CONTROL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< SCH_BASE_FRAME >::updateItem(), SCH_EDITOR_CONTROL::UpdateNetHighlighting(), EE_POINT_EDITOR::updateParentItem(), EE_POINT_EDITOR::updatePoints(), PL_POINT_EDITOR::updatePoints(), PCB_POINT_EDITOR::updatePoints(), PCB_SELECTION_TOOL::updateSelection(), PNS::TOOL_BASE::updateStartItem(), PCB_VIEWER_TOOLS::view(), PCB_TOOL_BASE::view(), PCB_SELECTION_TOOL::zoomFitSelection(), EE_SELECTION_TOOL::~EE_SELECTION_TOOL(), GERBVIEW_SELECTION_TOOL::~GERBVIEW_SELECTION_TOOL(), and PCB_SELECTION_TOOL::~PCB_SELECTION_TOOL().

◆ getViewControls()

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

Return the instance of VIEW_CONTROLS object used in the application.

It allows tools to read & modify user input and its settings (eg. show cursor, enable snapping to grid, etc.).

Returns
The instance of VIEW_CONTROLS.

Definition at line 42 of file tool_base.cpp.

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

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

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), SCH_EDITOR_CONTROL::AssignNetclass(), SCH_EDIT_TOOL::BreakWire(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), SCH_DRAWING_TOOLS::createSheetPin(), COMMON_TOOLS::CursorControl(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawLine(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::DrawRectangle(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), SCH_DRAWING_TOOLS::GetCanvasFreeAreaPixels(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), EE_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), ROUTER_TOOL::performDragging(), LENGTH_TUNER_TOOL::performTuning(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EDIT_TOOL::Remove(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), PCB_POINT_EDITOR::Reset(), DRAWING_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), GERBVIEW_SELECTION_TOOL::selectCursor(), PCB_SELECTION_TOOL::selectCursor(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PCB_PICKER_TOOL::setControls(), PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), EE_POINT_EDITOR::updateEditedPoint(), PL_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateEditedPoint(), PCB_POINT_EDITOR::updateItem(), PL_EDIT_TOOL::updateModificationPoint(), and COMMON_TOOLS::ZoomCenter().

◆ Go()

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

Define which state (aStateFunc) to go when a certain event arrives (aConditions).

No conditions means any event.

Definition at line 147 of file tool_interactive.h.

149 {
150  TOOL_STATE_FUNC sptr = std::bind( aStateFunc, static_cast<T*>( this ), std::placeholders::_1 );
151 
152  goInternal( sptr, aConditions );
153 }
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)

References TOOL_INTERACTIVE::goInternal().

Referenced by AUTOPLACE_TOOL::setTransitions(), ZOOM_TOOL::setTransitions(), LENGTH_TUNER_TOOL::setTransitions(), BOARD_REANNOTATE_TOOL::setTransitions(), GERBVIEW_INSPECTION_TOOL::setTransitions(), ROUTER_TOOL::setTransitions(), PCB_PICKER_TOOL::setTransitions(), SCH_NAVIGATE_TOOL::setTransitions(), SYMBOL_EDITOR_PIN_TOOL::setTransitions(), SYMBOL_EDITOR_MOVE_TOOL::setTransitions(), PL_DRAWING_TOOLS::setTransitions(), EE_POINT_EDITOR::setTransitions(), PL_POINT_EDITOR::setTransitions(), SCRIPTING_TOOL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), COMMON_CONTROL::setTransitions(), setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PAD_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), DRC_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), DRAWING_TOOL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ Init()

bool CONVERT_TOOL::Init ( void  )
overridevirtual

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

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

Reimplemented from TOOL_BASE.

Definition at line 68 of file convert_tool.cpp.

69 {
71  m_frame = getEditFrame<PCB_BASE_FRAME>();
72 
73  // Create a context menu and make it available through selection tool
74  m_menu = new CONDITIONAL_MENU( this );
76  m_menu->SetTitle( _( "Create from Selection" ) );
77 
78  static KICAD_T convertibleTracks[] = { PCB_TRACE_T, PCB_ARC_T, EOT };
79  static KICAD_T zones[] = { PCB_ZONE_T, PCB_FP_ZONE_T, EOT };
80 
81  auto graphicLines = P_S_C::OnlyGraphicShapeTypes( { SHAPE_T::SEGMENT,
84  SHAPE_T::ARC } )
85  && P_S_C::SameLayer();
86 
87  auto trackLines = S_C::MoreThan( 1 ) && S_C::OnlyTypes( convertibleTracks )
88  && P_S_C::SameLayer();
89 
90  auto anyLines = graphicLines || trackLines;
91  auto anyPolys = S_C::OnlyTypes( zones )
93 
94  auto lineToArc = S_C::Count( 1 )
96  || S_C::OnlyType( PCB_TRACE_T ) );
97 
98  auto showConvert = anyPolys || anyLines || lineToArc;
99  auto canCreatePolyType = anyLines || anyPolys;
100 
101  m_menu->AddItem( PCB_ACTIONS::convertToPoly, canCreatePolyType );
102  m_menu->AddItem( PCB_ACTIONS::convertToZone, canCreatePolyType );
103  m_menu->AddItem( PCB_ACTIONS::convertToKeepout, canCreatePolyType );
105 
106  // Currently the code exists, but tracks are not really existing in footprints
107  // only segments on copper layers
110 
112 
114  selToolMenu.AddMenu( m_menu, showConvert, 100 );
115 
116  return true;
117 }
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Add a submenu to the menu.
Arcs (with rounded ends)
static TOOL_ACTION convertToTracks
Definition: pcb_actions.h:477
polygon (not yet used for tracks, but could be in microwave apps)
static TOOL_ACTION convertToLines
Definition: pcb_actions.h:475
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:73
static SELECTION_CONDITION MoreThan(int aNumber)
Create a functor that tests if the number of selected items is greater than the value given as parame...
static SELECTION_CONDITION OnlyTypes(const KICAD_T aTypes[])
Create a functor that tests if the selected items are only of given types.
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:46
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
usual segment : line with rounded ends
TOOL_MENU & GetToolMenu()
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
static SELECTION_CONDITION Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
PCB_SELECTION_TOOL * m_selectionTool
Definition: convert_tool.h:109
static SELECTION_CONDITION SameLayer()
Creates a functor that tests if selection contains items that belong exclusively to the same layer.
static SELECTION_CONDITION OnlyGraphicShapeTypes(const std::set< SHAPE_T > aTypes)
Create a functor that tests if the selection contains PCB_SHAPE* items of certain shapes.
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
static TOOL_ACTION convertToZone
Definition: pcb_actions.h:473
static TOOL_ACTION convertToKeepout
Definition: pcb_actions.h:474
#define _(s)
class ZONE, a copper pour area
Definition: typeinfo.h:105
PCB_BASE_FRAME * m_frame
Definition: convert_tool.h:111
static TOOL_ACTION convertToArc
Definition: pcb_actions.h:476
CONDITIONAL_MENU * m_menu
Definition: convert_tool.h:110
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
bool IsType(FRAME_T aType) const
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
class ZONE, managed by a footprint
Definition: typeinfo.h:94
The selection tool: currently supports:
static TOOL_ACTION convertToPoly
Definition: pcb_actions.h:472
segment with non rounded ends
void AddItem(const TOOL_ACTION &aAction, const SELECTION_CONDITION &aCondition, int aOrder=ANY_ORDER)
Add a menu entry to run a TOOL_ACTION on selected items.

References _, CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddMenu(), ARC, CIRCLE, convert, PCB_ACTIONS::convertToArc, PCB_ACTIONS::convertToKeepout, PCB_ACTIONS::convertToLines, PCB_ACTIONS::convertToPoly, PCB_ACTIONS::convertToTracks, PCB_ACTIONS::convertToZone, SELECTION_CONDITIONS::Count(), EOT, FRAME_PCB_EDITOR, TOOL_MENU::GetMenu(), TOOL_MANAGER::GetTool(), TOOL_INTERACTIVE::GetToolMenu(), EDA_BASE_FRAME::IsType(), m_frame, m_menu, m_selectionTool, TOOL_BASE::m_toolMgr, SELECTION_CONDITIONS::MoreThan(), PCB_SELECTION_CONDITIONS::OnlyGraphicShapeTypes(), SELECTION_CONDITIONS::OnlyType(), SELECTION_CONDITIONS::OnlyTypes(), PCB_ARC_T, PCB_FP_ZONE_T, PCB_TRACE_T, PCB_ZONE_T, POLY, RECT, PCB_SELECTION_CONDITIONS::SameLayer(), SEGMENT, ACTION_MENU::SetIcon(), and ACTION_MENU::SetTitle().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32 {
33  return m_toolMgr->IsToolActive( m_toolId );
34 }
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:214
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:209
bool IsToolActive(TOOL_ID aId) const
Return true if a tool with given id is active (executing)

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

Referenced by ROUTER_TOOL::handleLayerSwitch(), EDIT_TOOL::isRouterActive(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ makePolysFromCircles()

SHAPE_POLY_SET CONVERT_TOOL::makePolysFromCircles ( const std::deque< EDA_ITEM * > &  aItems)
staticprivate

Try to make polygons from circles.

Parameters
aItemsis a list of circle shapes to process.
Returns
a SHAPE_POLY_SET containing any polygons that were created.

Definition at line 449 of file convert_tool.cpp.

450 {
451  SHAPE_POLY_SET poly;
452 
453  for( EDA_ITEM* item : aItems )
454  {
455  if( item->Type() != PCB_SHAPE_T && item->Type() != PCB_FP_SHAPE_T )
456  continue;
457 
458  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( item );
459 
460  if( graphic->GetShape() != SHAPE_T::CIRCLE )
461  continue;
462 
463  BOARD_DESIGN_SETTINGS& bds = graphic->GetBoard()->GetDesignSettings();
464  SHAPE_LINE_CHAIN outline;
465 
466  TransformCircleToPolygon( outline, graphic->GetPosition(), graphic->GetRadius(),
467  bds.m_MaxError, ERROR_OUTSIDE );
468 
469  poly.AddOutline( outline );
470  }
471 
472  return poly;
473 }
SHAPE_T GetShape() const
Definition: pcb_shape.h:110
int GetRadius() const
Return the radius of this item.
Definition: pcb_shape.cpp:487
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:589
Represent a set of closed polygons.
void TransformCircleToPolygon(SHAPE_LINE_CHAIN &aCornerBuffer, const wxPoint &aCenter, int aRadius, int aError, ERROR_LOC aErrorLoc, int aMinSegCount=0)
Convert a circle to a polygon, using multiple straight lines.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
wxPoint GetPosition() const override
Definition: pcb_shape.cpp:70
Represent a polyline (an zero-thickness chain of connected line segments).
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:50
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
Container for design settings for a BOARD object.

References SHAPE_POLY_SET::AddOutline(), CIRCLE, ERROR_OUTSIDE, BOARD_ITEM::GetBoard(), BOARD::GetDesignSettings(), PCB_SHAPE::GetPosition(), PCB_SHAPE::GetRadius(), PCB_SHAPE::GetShape(), BOARD_DESIGN_SETTINGS::m_MaxError, PCB_FP_SHAPE_T, PCB_SHAPE_T, and TransformCircleToPolygon().

Referenced by CreatePolys().

◆ makePolysFromRects()

SHAPE_POLY_SET CONVERT_TOOL::makePolysFromRects ( const std::deque< EDA_ITEM * > &  aItems)
staticprivate

Try to make polygons from rectangles.

Parameters
aItemsis a list of rect shapes to process.
Returns
a SHAPE_POLY_SET containing any polygons that were created.

Definition at line 416 of file convert_tool.cpp.

417 {
418  SHAPE_POLY_SET poly;
419 
420  for( EDA_ITEM* item : aItems )
421  {
422  if( item->Type() != PCB_SHAPE_T && item->Type() != PCB_FP_SHAPE_T )
423  continue;
424 
425  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( item );
426 
427  if( graphic->GetShape() != SHAPE_T::RECT )
428  continue;
429 
430  SHAPE_LINE_CHAIN outline;
431  VECTOR2I start( graphic->GetStart() );
432  VECTOR2I end( graphic->GetEnd() );
433 
434  outline.Append( start );
435  outline.Append( VECTOR2I( end.x, start.y ) );
436  outline.Append( end );
437  outline.Append( VECTOR2I( start.x, end.y ) );
438  outline.SetClosed( true );
439 
440  outline.SetWidth( graphic->GetWidth() );
441 
442  poly.AddOutline( outline );
443  }
444 
445  return poly;
446 }
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: pcb_shape.h:134
SHAPE_T GetShape() const
Definition: pcb_shape.h:110
int GetWidth() const
Definition: pcb_shape.h:97
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
void SetWidth(int aWidth)
Set the width of all segments in the chain.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
Represent a set of closed polygons.
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: pcb_shape.h:124
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
Represent a polyline (an zero-thickness chain of connected line segments).
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
segment with non rounded ends
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90

References SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), PCB_SHAPE::GetEnd(), PCB_SHAPE::GetShape(), PCB_SHAPE::GetStart(), PCB_SHAPE::GetWidth(), PCB_FP_SHAPE_T, PCB_SHAPE_T, RECT, SHAPE_LINE_CHAIN::SetClosed(), and SHAPE_LINE_CHAIN::SetWidth().

Referenced by CreatePolys().

◆ makePolysFromSegs()

SHAPE_POLY_SET CONVERT_TOOL::makePolysFromSegs ( const std::deque< EDA_ITEM * > &  aItems)
staticprivate

Try to make polygons from segments in the selected items.

Polygons are formed from chains of lines/arcs. Each set containing two or more lines/arcs that are connected will be added to the return SHAPE_POLY_SET as an outline. No attempt is made to guess at holes.

Parameters
aItemsis a list of items to process.
Returns
a SHAPE_POLY_SET containing any polygons that were created.

Definition at line 250 of file convert_tool.cpp.

251 {
252  // TODO: This code has a somewhat-similar purpose to ConvertOutlineToPolygon but is slightly
253  // different, so this remains a separate algorithm. It might be nice to analyze the dfiferences
254  // in requirements and refactor this.
255  const int chainingEpsilon = Millimeter2iu( 0.02 );
256 
257  SHAPE_POLY_SET poly;
258 
259  // Stores pairs of (anchor, item) where anchor == 0 -> SEG.A, anchor == 1 -> SEG.B
260  std::map<VECTOR2I, std::vector<std::pair<int, EDA_ITEM*>>> connections;
261  std::set<EDA_ITEM*> used;
262  std::deque<EDA_ITEM*> toCheck;
263 
264  auto closeEnough =
265  []( VECTOR2I aLeft, VECTOR2I aRight, unsigned aLimit )
266  {
267  return ( aLeft - aRight ).SquaredEuclideanNorm() <= SEG::Square( aLimit );
268  };
269 
270  auto findInsertionPoint =
271  [&]( VECTOR2I aPoint ) -> VECTOR2I
272  {
273  for( const auto& candidatePair : connections )
274  {
275  if( closeEnough( aPoint, candidatePair.first, chainingEpsilon ) )
276  return candidatePair.first;
277  }
278 
279  return aPoint;
280  };
281 
282  for( EDA_ITEM* item : aItems )
283  {
284  if( OPT<SEG> seg = getStartEndPoints( item, nullptr ) )
285  {
286  toCheck.push_back( item );
287  connections[findInsertionPoint( seg->A )].emplace_back( std::make_pair( 0, item ) );
288  connections[findInsertionPoint( seg->B )].emplace_back( std::make_pair( 1, item ) );
289  }
290  }
291 
292  while( !toCheck.empty() )
293  {
294  EDA_ITEM* candidate = toCheck.front();
295  toCheck.pop_front();
296 
297  if( used.count( candidate ) )
298  continue;
299 
300  int width = -1;
301  SHAPE_LINE_CHAIN outline;
302 
303  auto insert =
304  [&]( EDA_ITEM* aItem, VECTOR2I aAnchor, bool aDirection )
305  {
306  if( aItem->Type() == PCB_ARC_T ||
307  ( aItem->Type() == PCB_SHAPE_T &&
308  static_cast<PCB_SHAPE*>( aItem )->GetShape() == SHAPE_T::ARC ) )
309  {
310  SHAPE_ARC arc;
311 
312  if( aItem->Type() == PCB_ARC_T )
313  {
314  std::shared_ptr<SHAPE> es =
315  static_cast<PCB_ARC*>( aItem )->GetEffectiveShape();
316  arc = *static_cast<SHAPE_ARC*>( es.get() );
317  }
318  else
319  {
320  PCB_SHAPE* ps = static_cast<PCB_SHAPE*>( aItem );
321  arc = SHAPE_ARC( ps->GetArcStart(), ps->GetArcMid(), ps->GetArcEnd(),
322  ps->GetWidth() );
323  }
324 
325  if( aDirection )
326  outline.Append( aAnchor == arc.GetP0() ? arc : arc.Reversed() );
327  else
328  outline.Insert( 0, aAnchor == arc.GetP0() ? arc : arc.Reversed() );
329  }
330  else
331  {
332  OPT<SEG> nextSeg = getStartEndPoints( aItem, &width );
333  wxASSERT( nextSeg );
334 
335  VECTOR2I& point = ( aAnchor == nextSeg->A ) ? nextSeg->B : nextSeg->A;
336 
337  if( aDirection )
338  outline.Append( point );
339  else
340  outline.Insert( 0, point );
341  }
342  };
343 
344  // aDirection == true for walking "right" and appending to the end of points
345  // false for walking "left" and prepending to the beginning
346  std::function<void( EDA_ITEM*, VECTOR2I, bool )> process =
347  [&]( EDA_ITEM* aItem, VECTOR2I aAnchor, bool aDirection )
348  {
349  if( used.count( aItem ) )
350  return;
351 
352  used.insert( aItem );
353 
354  insert( aItem, aAnchor, aDirection );
355 
356  OPT<SEG> anchors = getStartEndPoints( aItem, &width );
357  wxASSERT( anchors );
358 
359  VECTOR2I nextAnchor = ( aAnchor == anchors->A ) ? anchors->B : anchors->A;
360 
361  for( std::pair<int, EDA_ITEM*> pair : connections[nextAnchor] )
362  {
363  if( pair.second == aItem )
364  continue;
365 
366  process( pair.second, nextAnchor, aDirection );
367  }
368  };
369 
370  OPT<SEG> anchors = getStartEndPoints( candidate, &width );
371  wxASSERT( anchors );
372 
373  // Start with the first object and walk "right"
374  // Note if the first object is an arc, we don't need to insert its first point here, the
375  // whole arc will be inserted at anchor B inside process()
376  if( !( candidate->Type() == PCB_ARC_T ||
377  ( candidate->Type() == PCB_SHAPE_T &&
378  static_cast<PCB_SHAPE*>( candidate )->GetShape() == SHAPE_T::ARC ) ) )
379  {
380  insert( candidate, anchors->A, true );
381  }
382 
383  process( candidate, anchors->B, true );
384 
385  // check for any candidates on the "left"
386  EDA_ITEM* left = nullptr;
387 
388  for( std::pair<int, EDA_ITEM*> possibleLeft : connections[anchors->A] )
389  {
390  if( possibleLeft.second != candidate )
391  {
392  left = possibleLeft.second;
393  break;
394  }
395  }
396 
397  if( left )
398  process( left, anchors->A, false );
399 
400  if( outline.PointCount() < 3 )
401  continue;
402 
403  outline.SetClosed( true );
404  outline.Simplify();
405 
406  if( width >= 0 )
407  outline.SetWidth( width );
408 
409  poly.AddOutline( outline );
410  }
411 
412  return poly;
413 }
wxPoint GetArcEnd() const
Definition: pcb_shape.cpp:417
Arcs (with rounded ends)
static OPT< SEG > getStartEndPoints(EDA_ITEM *aItem, int *aWidth)
Retrieve the start and end points for a generic item.
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
int GetWidth() const
Definition: pcb_shape.h:97
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
int PointCount() const
Return the number of points (vertices) in this line chain.
static SEG::ecoord Square(int a)
Definition: seg.h:122
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
wxPoint GetArcStart() const
Definition: pcb_shape.h:156
void Insert(size_t aVertex, const VECTOR2I &aP)
void SetWidth(int aWidth)
Set the width of all segments in the chain.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
Represent a set of closed polygons.
const VECTOR2I & GetP0() const
Definition: shape_arc.h:111
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
Represent a polyline (an zero-thickness chain of connected line segments).
void process(const BOARD_CONNECTED_ITEM *item, int net)
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
boost::optional< T > OPT
Definition: optional.h:7
SHAPE_ARC Reversed() const
Definition: shape_arc.cpp:624
wxPoint GetArcMid() const
Definition: pcb_shape.cpp:435
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
static constexpr int Millimeter2iu(double mm)
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), ARC, PCB_SHAPE::GetArcEnd(), PCB_SHAPE::GetArcMid(), PCB_SHAPE::GetArcStart(), SHAPE_ARC::GetP0(), getStartEndPoints(), PCB_SHAPE::GetWidth(), SHAPE_LINE_CHAIN::Insert(), left, Millimeter2iu(), PCB_ARC_T, PCB_SHAPE_T, SHAPE_LINE_CHAIN::PointCount(), process(), SHAPE_ARC::Reversed(), SHAPE_LINE_CHAIN::SetClosed(), SHAPE_LINE_CHAIN::SetWidth(), SHAPE_LINE_CHAIN::Simplify(), SEG::Square(), and EDA_ITEM::Type().

Referenced by CreatePolys().

◆ Reset()

void CONVERT_TOOL::Reset ( RESET_REASON  aReason)
inlineoverridevirtual

Bring the tool to a known, initial state.

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

Parameters
aReasoncontains information about the reason of tool reset.

Implements TOOL_BASE.

Definition at line 43 of file convert_tool.h.

43 {}

◆ RunMainStack()

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

Call a function using the main stack.

Parameters
aFuncis the function to be calls.

Definition at line 87 of file tool_interactive.cpp.

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

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

Referenced by DRAWING_TOOL::PlaceText().

◆ SegmentToArc()

int CONVERT_TOOL::SegmentToArc ( const TOOL_EVENT aEvent)

Convert selected segment (graphic or track) to an arc of the same type.

This method is meant to be overridden in order to specify handlers for events. It is called every time tool is reset or finished.

Definition at line 713 of file convert_tool.cpp.

714 {
715  auto& selection = m_selectionTool->RequestSelection(
716  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
717  {
718  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
719  {
720  BOARD_ITEM* item = aCollector[i];
721 
722  if( !( item->Type() == PCB_SHAPE_T ||
723  item->Type() == PCB_TRACE_T ||
724  item->Type() == PCB_FP_SHAPE_T ) )
725  {
726  aCollector.Remove( item );
727  }
728  }
729  } );
730 
731  EDA_ITEM* source = selection.Front();
732  VECTOR2I start, end, mid;
733 
734  // Offset the midpoint along the normal a little bit so that it's more obviously an arc
735  const double offsetRatio = 0.1;
736 
737  if( OPT<SEG> seg = getStartEndPoints( source, nullptr ) )
738  {
739  start = seg->A;
740  end = seg->B;
741 
742  VECTOR2I normal = ( seg->B - seg->A ).Perpendicular().Resize( offsetRatio * seg->Length() );
743  mid = seg->Center() + normal;
744  }
745  else
746  {
747  return -1;
748  }
749 
750  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
751  BOARD_ITEM_CONTAINER* parent = frame->GetModel();
752 
753  BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( source );
754 
755  // Don't continue processing if we don't actually have a board item
756  if( !boardItem )
757  return 0;
758 
759  PCB_LAYER_ID layer = boardItem->GetLayer();
760 
761  BOARD_COMMIT commit( m_frame );
762 
763  if( source->Type() == PCB_SHAPE_T || source->Type() == PCB_FP_SHAPE_T )
764  {
765  PCB_SHAPE* line = static_cast<PCB_SHAPE*>( source );
766  PCB_SHAPE* arc = new PCB_SHAPE( parent );
767 
768  VECTOR2I center = GetArcCenter( start, mid, end );
769 
770  arc->SetShape( SHAPE_T::ARC );
771  arc->SetFilled( false );
772  arc->SetLayer( layer );
773  arc->SetWidth( line->GetWidth() );
774 
775  arc->SetCenter( wxPoint( center ) );
776  arc->SetArcStart( wxPoint( start ) );
777  arc->SetAngle( GetArcAngle( start, mid, end ) );
778 
779  arc->SetArcEnd( wxPoint( end ) );
780  commit.Add( arc );
781  }
782  else
783  {
784  wxASSERT( source->Type() == PCB_TRACE_T );
785  PCB_TRACK* line = static_cast<PCB_TRACK*>( source );
786  PCB_ARC* arc = new PCB_ARC( parent );
787 
788  arc->SetLayer( layer );
789  arc->SetWidth( line->GetWidth() );
790  arc->SetStart( wxPoint( start ) );
791  arc->SetMid( wxPoint( mid ) );
792  arc->SetEnd( wxPoint( end ) );
793 
794  commit.Add( arc );
795  }
796 
797  commit.Push( _( "Create arc from line segment" ) );
798 
799  return 0;
800 }
Arcs (with rounded ends)
static OPT< SEG > getStartEndPoints(EDA_ITEM *aItem, int *aWidth)
Retrieve the start and end points for a generic item.
double GetArcAngle(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Return the subtended angle for a given arc.
Definition: trigo.cpp:496
void SetShape(SHAPE_T aShape)
Definition: pcb_shape.h:109
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:192
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
void SetEnd(const wxPoint &aEnd)
Definition: pcb_track.h:104
void SetFilled(bool aFlag)
Definition: pcb_shape.h:73
int GetWidth() const
Definition: pcb_shape.h:97
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
PCB_SELECTION_TOOL * m_selectionTool
Definition: convert_tool.h:109
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:115
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87
void SetMid(const wxPoint &aMid)
Definition: pcb_track.h:272
void SetStart(const wxPoint &aStart)
Definition: pcb_track.h:107
#define _(s)
void SetCenter(const wxPoint &aCenterPoint)
Definition: pcb_shape.h:198
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
PCB_BASE_FRAME * m_frame
Definition: convert_tool.h:111
void SetWidth(int aWidth)
Definition: pcb_track.h:101
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection set, filtered according to aFlags and aClientFilter.
Common, abstract interface for edit frames.
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:64
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
void SetWidth(int aWidth)
Definition: pcb_shape.h:96
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100
void SetArcEnd(const wxPoint &aArcEndPoint)
Initialize the end arc point.
Definition: pcb_shape.h:193
boost::optional< T > OPT
Definition: optional.h:7
Abstract interface for BOARD_ITEMs capable of storing other items inside.
const VECTOR2I GetArcCenter(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Determine the center of an arc or circle given three points on its circumference.
Definition: trigo.cpp:454
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Set the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: pcb_shape.cpp:519
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:171
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
Definition: pcb_shape.h:183
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References _, COMMIT::Add(), ARC, GetArcAngle(), GetArcCenter(), COLLECTOR::GetCount(), BOARD_ITEM::GetLayer(), PCB_BASE_FRAME::GetModel(), getStartEndPoints(), PCB_SHAPE::GetWidth(), m_frame, m_selectionTool, normal, PCB_FP_SHAPE_T, PCB_SHAPE_T, PCB_TRACE_T, BOARD_COMMIT::Push(), COLLECTOR::Remove(), PCB_SELECTION_TOOL::RequestSelection(), PCB_SHAPE::SetAngle(), PCB_SHAPE::SetArcEnd(), PCB_SHAPE::SetArcStart(), PCB_SHAPE::SetCenter(), PCB_TRACK::SetEnd(), PCB_SHAPE::SetFilled(), BOARD_ITEM::SetLayer(), PCB_ARC::SetMid(), PCB_SHAPE::SetShape(), PCB_TRACK::SetStart(), PCB_SHAPE::SetWidth(), PCB_TRACK::SetWidth(), and EDA_ITEM::Type().

Referenced by setTransitions().

◆ SetContextMenu()

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

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

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

Definition at line 76 of file tool_interactive.cpp.

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), TOOL_MENU::ShowContextMenu(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setTransitions()

void CONVERT_TOOL::setTransitions ( )
overridevirtual

This method is meant to be overridden in order to specify handlers for events.

It is called every time tool is reset or finished.

Implements TOOL_INTERACTIVE.

Definition at line 855 of file convert_tool.cpp.

856 {
863 }
static TOOL_ACTION convertToTracks
Definition: pcb_actions.h:477
static TOOL_ACTION convertToLines
Definition: pcb_actions.h:475
int CreatePolys(const TOOL_EVENT &aEvent)
Convert selected lines to a polygon, if possible.
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
static TOOL_ACTION convertToZone
Definition: pcb_actions.h:473
static TOOL_ACTION convertToKeepout
Definition: pcb_actions.h:474
static TOOL_ACTION convertToArc
Definition: pcb_actions.h:476
static TOOL_ACTION convertToPoly
Definition: pcb_actions.h:472
int CreateLines(const TOOL_EVENT &aEvent)
Convert selected polygon-like object to graphic lines, if possible.
int SegmentToArc(const TOOL_EVENT &aEvent)
Convert selected segment (graphic or track) to an arc of the same type.

References PCB_ACTIONS::convertToArc, PCB_ACTIONS::convertToKeepout, PCB_ACTIONS::convertToLines, PCB_ACTIONS::convertToPoly, PCB_ACTIONS::convertToTracks, PCB_ACTIONS::convertToZone, CreateLines(), CreatePolys(), TOOL_INTERACTIVE::Go(), and SegmentToArc().

◆ Wait()

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

Suspend execution of the tool until an event specified in aEventList arrives.

No parameters means waiting for any event.

Definition at line 57 of file tool_interactive.cpp.

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

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

Referenced by GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), DRAWING_TOOL::drawSegment(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), PAD_TOOL::EnumeratePads(), ROUTER_TOOL::InlineDrag(), DRAWING_TOOL::InteractivePlaceWithPreview(), ZOOM_TOOL::Main(), PCB_PICKER_TOOL::Main(), EE_POINT_EDITOR::Main(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), PL_POINT_EDITOR::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), ROUTER_TOOL::performDragging(), ROUTER_TOOL::performRouting(), LENGTH_TUNER_TOOL::performTuning(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), ZOOM_TOOL::selectRegion(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

Member Data Documentation

◆ m_frame

PCB_BASE_FRAME* CONVERT_TOOL::m_frame
private

Definition at line 111 of file convert_tool.h.

Referenced by CreateLines(), CreatePolys(), Init(), and SegmentToArc().

◆ m_menu

CONDITIONAL_MENU* CONVERT_TOOL::m_menu
private

Definition at line 110 of file convert_tool.h.

Referenced by Init(), and ~CONVERT_TOOL().

◆ m_selectionTool

PCB_SELECTION_TOOL* CONVERT_TOOL::m_selectionTool
private

Definition at line 109 of file convert_tool.h.

Referenced by CreateLines(), CreatePolys(), Init(), and SegmentToArc().

◆ m_toolId

TOOL_ID TOOL_BASE::m_toolId
protectedinherited

Name of the tool.

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

Definition at line 209 of file tool_base.h.

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

◆ m_toolMgr

TOOL_MANAGER* TOOL_BASE::m_toolMgr
protectedinherited

Definition at line 214 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), PL_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemsToSel(), PL_SELECTION_TOOL::AddItemToSel(), PCB_SELECTION_TOOL::AddItemToSel(), EE_SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), SCH_EDIT_TOOL::BreakWire(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), BOARD_INSPECTION_TOOL::ClearHighlight(), SCH_EDITOR_CONTROL::ClearHighlight(), PL_SELECTION_TOOL::ClearSelection(), PCB_SELECTION_TOOL::ClearSelection(), GERBVIEW_SELECTION_TOOL::clearSelection(), EE_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), PL_EDIT_TOOL::Copy(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), MICROWAVE_TOOL::createInductorBetween(), BOARD_INSPECTION_TOOL::CrossProbePcbToSch(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), PL_SELECTION_TOOL::disambiguateCursor(), EE_SELECTION_TOOL::disambiguateCursor(), PCB_SELECTION_TOOL::disambiguateCursor(), SCH_EDITOR_CONTROL::doCopy(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), BOARD_INSPECTION_TOOL::doHideNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), DRAWING_TOOL::DrawArc(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawCircle(), DRAWING_TOOL::DrawDimension(), DRAWING_TOOL::DrawRectangle(), DRAWING_TOOL::drawSegment(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), SCH_DRAWING_TOOLS::DrawSheet(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), SCH_EDIT_TOOL::editFieldText(), BOARD_EDITOR_CONTROL::EditFpInFpEditor(), SYMBOL_EDITOR_EDIT_TOOL::editGraphicProperties(), PAD_TOOL::EditPad(), SYMBOL_EDITOR_EDIT_TOOL::editSymbolProperties(), SCH_EDITOR_CONTROL::EditWithSymbolEditor(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), SCH_EDITOR_CONTROL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::expandConnection(), PAD_TOOL::explodePad(), PCB_SELECTION_TOOL::filterSelection(), PCB_SELECTION_TOOL::FindItem(), SCH_EDITOR_CONTROL::FindSymbolAndItem(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), EDIT_TOOL::Flip(), EDIT_TOOL::GetAndPlace(), TOOL_BASE::GetManager(), TOOL_BASE::getModelInt(), DRAWING_TOOL::getSourceZoneForAction(), TOOL_BASE::getToolHolderInt(), TOOL_BASE::getView(), TOOL_BASE::getViewControls(), TOOL_INTERACTIVE::goInternal(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCB_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), BOARD_INSPECTION_TOOL::HighlightNet(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PL_EDIT_TOOL::ImportDrawingSheetContent(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), BOARD_REANNOTATE_TOOL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_EDIT_TOOL::Init(), SCH_EDIT_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), Init(), PL_DRAWING_TOOLS::Init(), GLOBAL_EDIT_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), PL_POINT_EDITOR::Init(), BOARD_INSPECTION_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), PCB_POINT_EDITOR::Init(), BOARD_EDITOR_CONTROL::Init(), POSITION_RELATIVE_TOOL::Init(), EE_TOOL_BASE< SCH_BASE_FRAME >::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineBreakTrack(), ROUTER_TOOL::InlineDrag(), BOARD_INSPECTION_TOOL::InspectClearance(), BOARD_INSPECTION_TOOL::InspectConstraints(), DRAWING_TOOL::InteractivePlaceWithPreview(), EDIT_TOOL::invokeInlineRouter(), EDIT_TOOL::isInteractiveDragEnabled(), EDIT_TOOL::isRouterActive(), TOOL_BASE::IsToolActive(), GROUP_TOOL::LeaveGroup(), SCH_NAVIGATE_TOOL::LeaveSheet(), SCH_EDITOR_CONTROL::LeaveSheet(), COMMON_CONTROL::ListHotKeys(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), PCB_PICKER_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), CVPCB_CONTROL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), SCH_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), PCB_SELECTION_TOOL::Main(), ROUTER_TOOL::MainLoop(), LENGTH_TUNER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), SYMBOL_EDITOR_CONTROL::OnDeMorgan(), PL_SELECTION_TOOL::onDisambiguationExpire(), EE_SELECTION_TOOL::onDisambiguationExpire(), PCB_SELECTION_TOOL::onDisambiguationExpire(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), SCH_EDITOR_CONTROL::Paste(), PAD_TOOL::pastePadProperties(), ROUTER_TOOL::performRouting(), GROUP_TOOL::PickNewMember(), EDIT_TOOL::pickReferencePoint(), SYMBOL_EDITOR_EDIT_TOOL::PinTable(), PCB_CONTROL::placeBoardItems(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), BOARD_EDITOR_CONTROL::PlaceTarget(), DRAWING_TOOL::PlaceText(), PCB_CONTROL::Print(), GERBVIEW_CONTROL::Print(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EE_SELECTION_TOOL::RebuildSelection(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), SCH_EDITOR_CONTROL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), PL_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemFromSel(), PCB_SELECTION_TOOL::RemoveItemFromSel(), PL_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem(), EE_SELECTION_TOOL::RequestSelection(), PCB_SELECTION_TOOL::RequestSelection(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), SCH_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), PCB_SELECTION_TOOL::SelectItems(), PL_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectNet(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), PCB_SELECTION_TOOL::selectSameSheet(), PCB_SELECTION_TOOL::selectSheetContents(), DRAWING_TOOL::SetAnchor(), TOOL_INTERACTIVE::SetContextMenu(), EDA_3D_CONTROLLER::SetMaterial(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), EDA_3D_CONTROLLER::ToggleVisibility(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), SCH_EDITOR_CONTROL::Undo(), GROUP_TOOL::Ungroup(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), PCB_SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), BOARD_INSPECTION_TOOL::UpdateSelectionRatsnest(), PNS::TOOL_BASE::updateStartItem(), BOARD_EDITOR_CONTROL::ViaSizeDec(), BOARD_EDITOR_CONTROL::ViaSizeInc(), TOOL_INTERACTIVE::Wait(), BOARD_EDITOR_CONTROL::ZoneDuplicate(), and BOARD_EDITOR_CONTROL::ZoneMerge().

◆ m_toolName

std::string TOOL_BASE::m_toolName
protectedinherited

Definition at line 213 of file tool_base.h.

Referenced by TOOL_BASE::GetName().

◆ m_type

TOOL_TYPE TOOL_BASE::m_type
protectedinherited

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

Definition at line 206 of file tool_base.h.

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


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