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 50 of file convert_tool.cpp.

50  :
51  TOOL_INTERACTIVE( "pcbnew.Convert" ),
52  m_selectionTool( nullptr ),
53  m_menu( nullptr ),
54  m_frame( nullptr )
55 {
56 }
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 59 of file convert_tool.cpp.

60 {
61  delete m_menu;
62 }
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 546 of file convert_tool.cpp.

547 {
548  auto& selection = m_selectionTool->RequestSelection(
549  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
550  {
551  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
552  {
553  BOARD_ITEM* item = aCollector[i];
554 
555  switch( item->Type() )
556  {
557  case PCB_SHAPE_T:
558  case PCB_FP_SHAPE_T:
559  switch( static_cast<PCB_SHAPE*>( item )->GetShape() )
560  {
561  case SHAPE_T::SEGMENT:
562  case SHAPE_T::ARC:
563  case SHAPE_T::POLY:
564  case SHAPE_T::RECT:
565  break;
566 
567  default:
568  aCollector.Remove( item );
569  }
570 
571  break;
572 
573  case PCB_ZONE_T:
574  case PCB_FP_ZONE_T:
575  break;
576 
577  default:
578  aCollector.Remove( item );
579  }
580  }
581  } );
582 
583  if( selection.Empty() )
584  return 0;
585 
586  auto getPolySet =
587  []( EDA_ITEM* aItem )
588  {
589  SHAPE_POLY_SET set;
590 
591  switch( aItem->Type() )
592  {
593  case PCB_ZONE_T:
594  case PCB_FP_ZONE_T:
595  set = *static_cast<ZONE*>( aItem )->Outline();
596  break;
597 
598  case PCB_SHAPE_T:
599  case PCB_FP_SHAPE_T:
600  {
601  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
602 
603  if( graphic->GetShape() == SHAPE_T::POLY )
604  {
605  set = graphic->GetPolyShape();
606  }
607  else if( graphic->GetShape() == SHAPE_T::RECT )
608  {
609  SHAPE_LINE_CHAIN outline;
610  VECTOR2I start( graphic->GetStart() );
611  VECTOR2I end( graphic->GetEnd() );
612 
613  outline.Append( start );
614  outline.Append( VECTOR2I( end.x, start.y ) );
615  outline.Append( end );
616  outline.Append( VECTOR2I( start.x, end.y ) );
617  outline.SetClosed( true );
618 
619  set.AddOutline( outline );
620  }
621  else
622  {
623  wxFAIL_MSG( wxT( "Unhandled graphic shape type in PolyToLines - getPolySet" ) );
624  }
625  break;
626  }
627 
628  default:
629  wxFAIL_MSG( wxT( "Unhandled type in PolyToLines - getPolySet" ) );
630  break;
631  }
632 
633  return set;
634  };
635 
636  auto getSegList =
637  []( SHAPE_POLY_SET& aPoly )
638  {
639  std::vector<SEG> segs;
640 
641  // Our input should be valid polys, so OK to assert here
642  wxASSERT( aPoly.VertexCount() >= 2 );
643 
644  for( int i = 1; i < aPoly.VertexCount(); i++ )
645  segs.emplace_back( SEG( aPoly.CVertex( i - 1 ), aPoly.CVertex( i ) ) );
646 
647  segs.emplace_back( SEG( aPoly.CVertex( aPoly.VertexCount() - 1 ),
648  aPoly.CVertex( 0 ) ) );
649 
650  return segs;
651  };
652 
653  BOARD_COMMIT commit( m_frame );
654  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
655  FOOTPRINT_EDIT_FRAME* fpEditor = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame );
656  FOOTPRINT* footprint = nullptr;
657  PCB_LAYER_ID targetLayer = m_frame->GetActiveLayer();
658  PCB_LAYER_ID copperLayer = F_Cu;
659  BOARD_ITEM_CONTAINER* parent = frame->GetModel();
660 
661  if( fpEditor )
662  footprint = fpEditor->GetBoard()->GetFirstFootprint();
663 
664  auto handleGraphicSeg =
665  [&]( EDA_ITEM* aItem )
666  {
667  if( aItem->Type() != PCB_SHAPE_T && aItem->Type() != PCB_FP_SHAPE_T )
668  return false;
669 
670  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
671 
672  if( graphic->GetShape() == SHAPE_T::SEGMENT )
673  {
674  PCB_TRACK* track = new PCB_TRACK( parent );
675 
676  track->SetLayer( targetLayer );
677  track->SetStart( graphic->GetStart() );
678  track->SetEnd( graphic->GetEnd() );
679  commit.Add( track );
680 
681  return true;
682  }
683  else if( graphic->GetShape() == SHAPE_T::ARC )
684  {
685  PCB_ARC* arc = new PCB_ARC( parent );
686 
687  arc->SetLayer( targetLayer );
688  arc->SetStart( graphic->GetStart() );
689  arc->SetEnd( graphic->GetEnd() );
690  arc->SetMid( graphic->GetArcMid() );
691  commit.Add( arc );
692 
693  return true;
694  }
695 
696  return false;
697  };
698 
699  if( aEvent.IsAction( &PCB_ACTIONS::convertToTracks ) )
700  {
701  if( !IsCopperLayer( targetLayer ) )
702  {
703  copperLayer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() );
704 
705  if( copperLayer == UNDEFINED_LAYER ) // User canceled
706  return true;
707 
708  targetLayer = copperLayer;
709  }
710  }
711 
712  for( EDA_ITEM* item : selection )
713  {
714  if( handleGraphicSeg( item ) )
715  continue;
716 
717  SHAPE_POLY_SET polySet = getPolySet( item );
718  std::vector<SEG> segs = getSegList( polySet );
719 
720  if( aEvent.IsAction( &PCB_ACTIONS::convertToLines ) )
721  {
722  for( SEG& seg : segs )
723  {
724  if( fpEditor )
725  {
726  FP_SHAPE* graphic = new FP_SHAPE( footprint, SHAPE_T::SEGMENT );
727 
728  graphic->SetLayer( targetLayer );
729  graphic->SetStart( wxPoint( seg.A ) );
730  graphic->SetStart0( wxPoint( seg.A ) );
731  graphic->SetEnd( wxPoint( seg.B ) );
732  graphic->SetEnd0( wxPoint( seg.B ) );
733  commit.Add( graphic );
734  }
735  else
736  {
737  PCB_SHAPE* graphic = new PCB_SHAPE( nullptr, SHAPE_T::SEGMENT );
738 
739  graphic->SetLayer( targetLayer );
740  graphic->SetStart( wxPoint( seg.A ) );
741  graphic->SetEnd( wxPoint( seg.B ) );
742  commit.Add( graphic );
743  }
744  }
745  }
746  else
747  {
748  // I am really unsure converting a polygon to "tracks" (i.e. segments on
749  // copper layers) make sense for footprints, but anyway this code exists
750  if( fpEditor )
751  {
752  // Creating segments on copper layer
753  for( SEG& seg : segs )
754  {
755  FP_SHAPE* graphic = new FP_SHAPE( footprint, SHAPE_T::SEGMENT );
756  graphic->SetLayer( targetLayer );
757  graphic->SetStart( wxPoint( seg.A ) );
758  graphic->SetStart0( wxPoint( seg.A ) );
759  graphic->SetEnd( wxPoint( seg.B ) );
760  graphic->SetEnd0( wxPoint( seg.B ) );
761  commit.Add( graphic );
762  }
763  }
764  else
765  {
766  // Creating tracks
767  for( SEG& seg : segs )
768  {
769  PCB_TRACK* track = new PCB_TRACK( parent );
770 
771  track->SetLayer( targetLayer );
772  track->SetStart( wxPoint( seg.A ) );
773  track->SetEnd( wxPoint( seg.B ) );
774  commit.Add( track );
775  }
776  }
777  }
778  }
779 
780  commit.Push( _( "Convert polygons to lines" ) );
781 
782  return 0;
783 }
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:274
void SetEnd0(const wxPoint &aPoint)
Definition: fp_shape.h:114
static TOOL_ACTION convertToTracks
Definition: pcb_actions.h:479
void SetEnd(const wxPoint &aEnd)
Definition: eda_shape.h:135
static TOOL_ACTION convertToLines
Definition: pcb_actions.h:477
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:164
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:106
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:782
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:622
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
Definition: collector.h:110
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
void SetStart(const wxPoint &aStart)
Definition: eda_shape.h:110
virtual PCB_LAYER_ID GetActiveLayer() const
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:131
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:318
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
void SetMid(const wxPoint &aMid)
Definition: pcb_track.h:271
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
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:227
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:808
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.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
Definition: layer_ids.h:71
class ZONE, managed by a footprint
Definition: typeinfo.h:94
wxPoint GetArcMid() const
Definition: eda_shape.cpp:437
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
SHAPE_T GetShape() const
Definition: eda_shape.h:101
Abstract interface for BOARD_ITEMs capable of storing other items inside.
BOARD * GetBoard() const
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, COMMIT::Add(), SHAPE_POLY_SET::AddOutline(), LSET::AllNonCuMask(), SHAPE_LINE_CHAIN::Append(), ARC, PCB_ACTIONS::convertToLines, PCB_ACTIONS::convertToTracks, F_Cu, PCB_BASE_FRAME::GetActiveLayer(), EDA_SHAPE::GetArcMid(), PCB_BASE_FRAME::GetBoard(), COLLECTOR::GetCount(), EDA_SHAPE::GetEnd(), BOARD::GetFirstFootprint(), PCB_BASE_FRAME::GetModel(), EDA_SHAPE::GetPolyShape(), EDA_SHAPE::GetShape(), EDA_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(), EDA_SHAPE::SetEnd(), FP_SHAPE::SetEnd0(), BOARD_ITEM::SetLayer(), PCB_ARC::SetMid(), PCB_TRACK::SetStart(), EDA_SHAPE::SetStart(), FP_SHAPE::SetStart0(), EDA_ITEM::Type(), and UNDEFINED_LAYER.

Referenced by setTransitions().

◆ CreatePolys()

int CONVERT_TOOL::CreatePolys ( const TOOL_EVENT aEvent)

Convert selected lines to a polygon, if possible.

Definition at line 124 of file convert_tool.cpp.

125 {
126  FOOTPRINT* parentFootprint = nullptr;
127 
128  auto& selection = m_selectionTool->RequestSelection(
129  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
130  {
131  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
132  {
133  BOARD_ITEM* item = aCollector[i];
134 
135  switch( item->Type() )
136  {
137  case PCB_SHAPE_T:
138  case PCB_FP_SHAPE_T:
139  {
140  PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
141 
142  switch( shape->GetShape() )
143  {
144  case SHAPE_T::SEGMENT:
145  case SHAPE_T::RECT:
146  case SHAPE_T::CIRCLE:
147  case SHAPE_T::ARC:
148  if( shape->GetStart() == shape->GetEnd() )
149  aCollector.Remove( item );
150 
151  break;
152 
153  case SHAPE_T::POLY:
154  break;
155 
156  default:
157  aCollector.Remove( item );
158  }
159 
160  break;
161  }
162  case PCB_TRACE_T:
163  case PCB_ARC_T:
164  break;
165 
166  case PCB_ZONE_T:
167  case PCB_FP_ZONE_T:
168  break;
169 
170  default:
171  aCollector.Remove( item );
172  }
173  }
174  } );
175 
176  if( selection.Empty() )
177  return 0;
178 
179  PCB_LAYER_ID destLayer = m_frame->GetActiveLayer();
180  SHAPE_POLY_SET polySet = makePolysFromSegs( selection.GetItems() );
181 
182  polySet.Append( makePolysFromRects( selection.GetItems() ) );
183 
184  polySet.Append( makePolysFromCircles( selection.GetItems() ) );
185 
186  polySet.Append( extractPolygons( selection.GetItems() ) );
187 
188  if( polySet.IsEmpty() )
189  return 0;
190 
191  bool isFootprint = m_frame->IsType( FRAME_FOOTPRINT_EDITOR );
192 
193  if( isFootprint )
194  {
195  if( FP_SHAPE* graphic = dynamic_cast<FP_SHAPE*>( selection.Front() ) )
196  parentFootprint = graphic->GetParentFootprint();
197  else if( FP_ZONE* zone = dynamic_cast<FP_ZONE*>( selection.Front() ) )
198  parentFootprint = static_cast<FOOTPRINT*>( zone->GetParent() );
199  else
200  wxFAIL_MSG( wxT( "Unimplemented footprint parent in CONVERT_TOOL::CreatePolys" ) );
201  }
202 
203  BOARD_COMMIT commit( m_frame );
204 
205  // For now, we convert each outline in the returned shape to its own polygon
206  std::vector<SHAPE_POLY_SET> polys;
207 
208  for( int i = 0; i < polySet.OutlineCount(); i++ )
209  polys.emplace_back( SHAPE_POLY_SET( polySet.COutline( i ) ) );
210 
211  if( aEvent.IsAction( &PCB_ACTIONS::convertToPoly ) )
212  {
213  for( const SHAPE_POLY_SET& poly : polys )
214  {
215  PCB_SHAPE* graphic = isFootprint ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
216 
217  graphic->SetShape( SHAPE_T::POLY );
218  graphic->SetFilled( false );
219  graphic->SetWidth( poly.Outline( 0 ).Width() );
220  graphic->SetLayer( destLayer );
221  graphic->SetPolyShape( poly );
222 
223  commit.Add( graphic );
224  }
225 
226  commit.Push( _( "Convert shapes to polygon" ) );
227  }
228  else
229  {
230  // Creating zone or keepout
231  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
232  BOARD_ITEM_CONTAINER* parent = frame->GetModel();
233  ZONE_SETTINGS zoneInfo = frame->GetZoneSettings();
234 
235  bool nonCopper = IsNonCopperLayer( destLayer );
236  zoneInfo.m_Layers.reset().set( destLayer );
237  zoneInfo.m_Name.Empty();
238 
239  int ret;
240 
241  if( aEvent.IsAction( &PCB_ACTIONS::convertToKeepout ) )
242  {
243  zoneInfo.SetIsRuleArea( true );
244  ret = InvokeRuleAreaEditor( frame, &zoneInfo );
245  }
246  else if( nonCopper )
247  {
248  zoneInfo.SetIsRuleArea( false );
249  ret = InvokeNonCopperZonesEditor( frame, &zoneInfo );
250  }
251  else
252  {
253  zoneInfo.SetIsRuleArea( false );
254  ret = InvokeCopperZonesEditor( frame, &zoneInfo );
255  }
256 
257  if( ret == wxID_CANCEL )
258  return 0;
259 
260  for( const SHAPE_POLY_SET& poly : polys )
261  {
262  ZONE* zone = isFootprint ? new FP_ZONE( parent ) : new ZONE( parent );
263 
264  *zone->Outline() = poly;
265  zone->HatchBorder();
266 
267  zoneInfo.ExportSetting( *zone );
268 
269  commit.Add( zone );
270  }
271 
272  commit.Push( _( "Convert shapes to zone" ) );
273  }
274 
275  return 0;
276 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void SetFilled(bool aFlag)
Definition: eda_shape.h:92
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:164
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:106
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: eda_shape.h:235
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
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
wxString m_Name
Definition: zone_settings.h:95
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:110
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:82
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:131
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:906
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:819
static TOOL_ACTION convertToKeepout
Definition: pcb_actions.h:476
#define _(s)
void SetWidth(int aWidth)
Definition: eda_shape.h:97
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
class ZONE, a copper pour area
Definition: typeinfo.h:105
void SetIsRuleArea(bool aEnable)
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:65
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 SetShape(SHAPE_T aShape)
Definition: eda_shape.h:100
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:474
static SHAPE_POLY_SET makePolysFromSegs(const std::deque< EDA_ITEM * > &aItems)
Try to make polygons from segments in the selected items.
SHAPE_T GetShape() const
Definition: eda_shape.h:101
Abstract interface for BOARD_ITEMs capable of storing other items inside.
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:947
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
BOARD_ITEM_CONTAINER * GetParentFootprint() const
Definition: board_item.cpp:191
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(), EDA_SHAPE::GetEnd(), PCB_BASE_FRAME::GetModel(), BOARD_ITEM::GetParentFootprint(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), 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, ZONE_SETTINGS::m_Name, 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, EDA_SHAPE::SetFilled(), ZONE_SETTINGS::SetIsRuleArea(), BOARD_ITEM::SetLayer(), EDA_SHAPE::SetPolyShape(), EDA_SHAPE::SetShape(), EDA_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 510 of file convert_tool.cpp.

511 {
512  SHAPE_POLY_SET poly;
513 
514  for( EDA_ITEM* item : aItems )
515  {
516  switch( item->Type() )
517  {
518  case PCB_SHAPE_T:
519  case PCB_FP_SHAPE_T:
520  switch( static_cast<PCB_SHAPE*>( item )->GetShape() )
521  {
522  case SHAPE_T::POLY:
523  poly.Append( static_cast<PCB_SHAPE*>( item )->GetPolyShape() );
524  break;
525 
526  default:
527  continue;
528  }
529 
530  break;
531 
532  case PCB_ZONE_T:
533  case PCB_FP_ZONE_T:
534  poly.Append( *static_cast<ZONE*>( item )->Outline() );
535  break;
536 
537  default:
538  continue;
539  }
540  }
541 
542  return poly;
543 }
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
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:99
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_SHAPE_T, 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 874 of file convert_tool.cpp.

875 {
876  switch( aItem->Type() )
877  {
878  case PCB_SHAPE_T:
879  case PCB_FP_SHAPE_T:
880  {
881  PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( aItem );
882 
883  if( aWidth )
884  *aWidth = shape->GetWidth();
885 
886  return boost::make_optional<SEG>( { VECTOR2I( shape->GetStart() ),
887  VECTOR2I( shape->GetEnd() ) } );
888  }
889 
890  case PCB_TRACE_T:
891  {
892  PCB_TRACK* line = static_cast<PCB_TRACK*>( aItem );
893 
894  if( aWidth )
895  *aWidth = line->GetWidth();
896 
897  return boost::make_optional<SEG>( { VECTOR2I( line->GetStart() ),
898  VECTOR2I( line->GetEnd() ) } );
899  }
900 
901  case PCB_ARC_T:
902  {
903  PCB_ARC* arc = static_cast<PCB_ARC*>( aItem );
904 
905  if( aWidth )
906  *aWidth = arc->GetWidth();
907 
908  return boost::make_optional<SEG>( { VECTOR2I( arc->GetStart() ),
909  VECTOR2I( arc->GetEnd() ) } );
910  }
911 
912  default:
913  return NULLOPT;
914  }
915 }
int GetWidth() const
Definition: eda_shape.h:98
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:106
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:622
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:131
const auto NULLOPT
Definition: optional.h:9
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:112

References PCB_TRACK::GetEnd(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetStart(), PCB_TRACK::GetStart(), EDA_SHAPE::GetWidth(), PCB_TRACK::GetWidth(), NULLOPT, PCB_ARC_T, PCB_FP_SHAPE_T, PCB_SHAPE_T, PCB_TRACE_T, 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(), PL_EDIT_TOOL::moveItem(), SCH_MOVE_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(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), 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::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(), PL_POINT_EDITOR::setEditedPoint(), EE_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(), 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(), ROUTER_TOOL::setTransitions(), SCRIPTING_TOOL::setTransitions(), COMMON_CONTROL::setTransitions(), KICAD_MANAGER_CONTROL::setTransitions(), setTransitions(), SYMBOL_EDITOR_DRAWING_TOOLS::setTransitions(), ZONE_FILLER_TOOL::setTransitions(), PCB_VIEWER_TOOLS::setTransitions(), MICROWAVE_TOOL::setTransitions(), EE_INSPECTION_TOOL::setTransitions(), PCB_POINT_EDITOR::setTransitions(), GERBVIEW_CONTROL::setTransitions(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::setTransitions(), PAD_TOOL::setTransitions(), GLOBAL_EDIT_TOOL::setTransitions(), GROUP_TOOL::setTransitions(), PL_EDITOR_CONTROL::setTransitions(), SYMBOL_EDITOR_EDIT_TOOL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::setTransitions(), SCH_MOVE_TOOL::setTransitions(), SCH_EDIT_TOOL::setTransitions(), FOOTPRINT_EDITOR_CONTROL::setTransitions(), ALIGN_DISTRIBUTE_TOOL::setTransitions(), COMMON_TOOLS::setTransitions(), DRC_TOOL::setTransitions(), EDA_3D_CONTROLLER::setTransitions(), PCB_CONTROL::setTransitions(), CVPCB_ASSOCIATION_TOOL::setTransitions(), SCH_LINE_WIRE_BUS_TOOL::setTransitions(), CVPCB_CONTROL::setTransitions(), BOARD_INSPECTION_TOOL::setTransitions(), BOARD_EDITOR_CONTROL::setTransitions(), PICKER_TOOL::setTransitions(), EDIT_TOOL::setTransitions(), PCB_SELECTION_TOOL::setTransitions(), PL_SELECTION_TOOL::setTransitions(), DRAWING_TOOL::setTransitions(), SCH_EDITOR_CONTROL::setTransitions(), and EE_SELECTION_TOOL::setTransitions().

◆ Init()

bool CONVERT_TOOL::Init ( )
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 69 of file convert_tool.cpp.

70 {
72  m_frame = getEditFrame<PCB_BASE_FRAME>();
73 
74  // Create a context menu and make it available through selection tool
75  m_menu = new CONDITIONAL_MENU( this );
77  m_menu->SetTitle( _( "Create from Selection" ) );
78 
79  static KICAD_T convertibleTracks[] = { PCB_TRACE_T, PCB_ARC_T, EOT };
80  static KICAD_T zones[] = { PCB_ZONE_T, PCB_FP_ZONE_T, EOT };
81 
82  auto graphicLines = P_S_C::OnlyGraphicShapeTypes( { SHAPE_T::SEGMENT,
85  SHAPE_T::ARC } )
86  && P_S_C::SameLayer();
87 
88  auto graphicToTrack = P_S_C::OnlyGraphicShapeTypes( { SHAPE_T::SEGMENT, SHAPE_T::ARC } );
89 
90  auto trackLines = S_C::MoreThan( 1 ) && S_C::OnlyTypes( convertibleTracks )
91  && P_S_C::SameLayer();
92 
93  auto anyLines = graphicLines || trackLines;
94  auto anyPolys = S_C::OnlyTypes( zones )
96 
97  auto lineToArc = S_C::Count( 1 )
99  || S_C::OnlyType( PCB_TRACE_T ) );
100 
101  auto showConvert = anyPolys || anyLines || lineToArc;
102  auto canCreatePolyType = anyLines || anyPolys;
103  auto canCreateTracks = anyPolys || graphicToTrack;
104 
105  m_menu->AddItem( PCB_ACTIONS::convertToPoly, canCreatePolyType );
106  m_menu->AddItem( PCB_ACTIONS::convertToZone, canCreatePolyType );
107  m_menu->AddItem( PCB_ACTIONS::convertToKeepout, canCreatePolyType );
109 
110  // Currently the code exists, but tracks are not really existing in footprints
111  // only segments on copper layers
113  m_menu->AddItem( PCB_ACTIONS::convertToTracks, canCreateTracks );
114 
116 
118  selToolMenu.AddMenu( m_menu, showConvert, 100 );
119 
120  return true;
121 }
void AddMenu(ACTION_MENU *aMenu, const SELECTION_CONDITION &aCondition=SELECTION_CONDITIONS::ShowAlways, int aOrder=ANY_ORDER)
Add a submenu to the menu.
static TOOL_ACTION convertToTracks
Definition: pcb_actions.h:479
static TOOL_ACTION convertToLines
Definition: pcb_actions.h:477
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
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:475
static TOOL_ACTION convertToKeepout
Definition: pcb_actions.h:476
#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:478
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:474
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 EDIT_TOOL::Drag(), 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 483 of file convert_tool.cpp.

484 {
485  SHAPE_POLY_SET poly;
486 
487  for( EDA_ITEM* item : aItems )
488  {
489  if( item->Type() != PCB_SHAPE_T && item->Type() != PCB_FP_SHAPE_T )
490  continue;
491 
492  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( item );
493 
494  if( graphic->GetShape() != SHAPE_T::CIRCLE )
495  continue;
496 
497  BOARD_DESIGN_SETTINGS& bds = graphic->GetBoard()->GetDesignSettings();
498  SHAPE_LINE_CHAIN outline;
499 
500  TransformCircleToPolygon( outline, graphic->GetPosition(), graphic->GetRadius(),
501  bds.m_MaxError, ERROR_OUTSIDE );
502 
503  poly.AddOutline( outline );
504  }
505 
506  return poly;
507 }
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:590
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.h:77
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:36
SHAPE_T GetShape() const
Definition: eda_shape.h:101
int GetRadius() const
Definition: eda_shape.cpp:472
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(), EDA_SHAPE::GetRadius(), EDA_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 450 of file convert_tool.cpp.

451 {
452  SHAPE_POLY_SET poly;
453 
454  for( EDA_ITEM* item : aItems )
455  {
456  if( item->Type() != PCB_SHAPE_T && item->Type() != PCB_FP_SHAPE_T )
457  continue;
458 
459  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( item );
460 
461  if( graphic->GetShape() != SHAPE_T::RECT )
462  continue;
463 
464  SHAPE_LINE_CHAIN outline;
465  VECTOR2I start( graphic->GetStart() );
466  VECTOR2I end( graphic->GetEnd() );
467 
468  outline.Append( start );
469  outline.Append( VECTOR2I( end.x, start.y ) );
470  outline.Append( end );
471  outline.Append( VECTOR2I( start.x, end.y ) );
472  outline.SetClosed( true );
473 
474  outline.SetWidth( graphic->GetWidth() );
475 
476  poly.AddOutline( outline );
477  }
478 
479  return poly;
480 }
int GetWidth() const
Definition: eda_shape.h:98
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:106
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
VECTOR2< int > VECTOR2I
Definition: vector2d.h:622
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.
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:131
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new hole to the given outline (default: last) and returns its index.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
SHAPE_T GetShape() const
Definition: eda_shape.h:101
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90

References SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), EDA_SHAPE::GetEnd(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), EDA_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 279 of file convert_tool.cpp.

280 {
281  // TODO: This code has a somewhat-similar purpose to ConvertOutlineToPolygon but is slightly
282  // different, so this remains a separate algorithm. It might be nice to analyze the dfiferences
283  // in requirements and refactor this.
284 
285  // Very tight epsilon used here to account for rounding errors in import, not sloppy drawing
286  const int chainingEpsilonSquared = SEG::Square( 100 );
287 
288  SHAPE_POLY_SET poly;
289 
290  // Stores pairs of (anchor, item) where anchor == 0 -> SEG.A, anchor == 1 -> SEG.B
291  std::map<VECTOR2I, std::vector<std::pair<int, EDA_ITEM*>>> connections;
292  std::set<EDA_ITEM*> used;
293  std::deque<EDA_ITEM*> toCheck;
294 
295  auto closeEnough =
296  []( VECTOR2I aLeft, VECTOR2I aRight, unsigned aLimit )
297  {
298  return ( aLeft - aRight ).SquaredEuclideanNorm() <= aLimit;
299  };
300 
301  auto findInsertionPoint =
302  [&]( VECTOR2I aPoint ) -> VECTOR2I
303  {
304  if( connections.count( aPoint ) )
305  return aPoint;
306 
307  for( const auto& candidatePair : connections )
308  {
309  if( closeEnough( aPoint, candidatePair.first, chainingEpsilonSquared ) )
310  return candidatePair.first;
311  }
312 
313  return aPoint;
314  };
315 
316  for( EDA_ITEM* item : aItems )
317  {
318  if( OPT<SEG> seg = getStartEndPoints( item, nullptr ) )
319  {
320  toCheck.push_back( item );
321  connections[findInsertionPoint( seg->A )].emplace_back( std::make_pair( 0, item ) );
322  connections[findInsertionPoint( seg->B )].emplace_back( std::make_pair( 1, item ) );
323  }
324  }
325 
326  while( !toCheck.empty() )
327  {
328  EDA_ITEM* candidate = toCheck.front();
329  toCheck.pop_front();
330 
331  if( used.count( candidate ) )
332  continue;
333 
334  int width = -1;
335  SHAPE_LINE_CHAIN outline;
336 
337  auto insert =
338  [&]( EDA_ITEM* aItem, VECTOR2I aAnchor, bool aDirection )
339  {
340  if( aItem->Type() == PCB_ARC_T
341  || ( ( aItem->Type() == PCB_SHAPE_T || aItem->Type() == PCB_FP_SHAPE_T )
342  && static_cast<PCB_SHAPE*>( aItem )->GetShape() == SHAPE_T::ARC ) )
343  {
344  SHAPE_ARC arc;
345 
346  if( aItem->Type() == PCB_ARC_T )
347  {
348  std::shared_ptr<SHAPE> es =
349  static_cast<PCB_ARC*>( aItem )->GetEffectiveShape();
350  arc = *static_cast<SHAPE_ARC*>( es.get() );
351  }
352  else
353  {
354  PCB_SHAPE* ps = static_cast<PCB_SHAPE*>( aItem );
355  arc = SHAPE_ARC( ps->GetStart(), ps->GetArcMid(), ps->GetEnd(),
356  ps->GetWidth() );
357  }
358 
359  if( aDirection )
360  outline.Append( aAnchor == arc.GetP0() ? arc : arc.Reversed() );
361  else
362  outline.Insert( 0, aAnchor == arc.GetP0() ? arc : arc.Reversed() );
363  }
364  else
365  {
366  OPT<SEG> nextSeg = getStartEndPoints( aItem, &width );
367  wxASSERT( nextSeg );
368 
369  VECTOR2I& point = ( aAnchor == nextSeg->A ) ? nextSeg->B : nextSeg->A;
370 
371  if( aDirection )
372  outline.Append( point );
373  else
374  outline.Insert( 0, point );
375  }
376  };
377 
378  // aDirection == true for walking "right" and appending to the end of points
379  // false for walking "left" and prepending to the beginning
380  std::function<void( EDA_ITEM*, VECTOR2I, bool )> process =
381  [&]( EDA_ITEM* aItem, VECTOR2I aAnchor, bool aDirection )
382  {
383  if( used.count( aItem ) )
384  return;
385 
386  used.insert( aItem );
387 
388  insert( aItem, aAnchor, aDirection );
389 
390  OPT<SEG> anchors = getStartEndPoints( aItem, &width );
391  wxASSERT( anchors );
392 
393  VECTOR2I nextAnchor = ( aAnchor == anchors->A ) ? anchors->B : anchors->A;
394 
395  for( std::pair<int, EDA_ITEM*> pair : connections[nextAnchor] )
396  {
397  if( pair.second == aItem )
398  continue;
399 
400  process( pair.second, nextAnchor, aDirection );
401  }
402  };
403 
404  OPT<SEG> anchors = getStartEndPoints( candidate, &width );
405  wxASSERT( anchors );
406 
407  // Start with the first object and walk "right"
408  // Note if the first object is an arc, we don't need to insert its first point here, the
409  // whole arc will be inserted at anchor B inside process()
410  if( !( candidate->Type() == PCB_ARC_T
411  || ( ( candidate->Type() == PCB_SHAPE_T || candidate->Type() == PCB_FP_SHAPE_T )
412  && static_cast<PCB_SHAPE*>( candidate )->GetShape() == SHAPE_T::ARC ) ) )
413  {
414  insert( candidate, anchors->A, true );
415  }
416 
417  process( candidate, anchors->B, true );
418 
419  // check for any candidates on the "left"
420  EDA_ITEM* left = nullptr;
421 
422  for( std::pair<int, EDA_ITEM*> possibleLeft : connections[anchors->A] )
423  {
424  if( possibleLeft.second != candidate )
425  {
426  left = possibleLeft.second;
427  break;
428  }
429  }
430 
431  if( left )
432  process( left, anchors->A, false );
433 
434  if( outline.PointCount() < 3 )
435  continue;
436 
437  outline.SetClosed( true );
438  outline.Simplify();
439 
440  if( width >= 0 )
441  outline.SetWidth( width );
442 
443  poly.AddOutline( outline );
444  }
445 
446  return poly;
447 }
int GetWidth() const
Definition: eda_shape.h:98
static OPT< SEG > getStartEndPoints(EDA_ITEM *aItem, int *aWidth)
Retrieve the start and end points for a generic item.
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:106
SHAPE_LINE_CHAIN & Simplify(bool aRemoveColinear=true)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
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 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.
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.
const wxPoint & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:131
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 containing arcs as well as line segments: A chain of connected line and/or arc s...
wxPoint GetArcMid() const
Definition: eda_shape.cpp:437
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:99
boost::optional< T > OPT
Definition: optional.h:7
SHAPE_ARC Reversed() const
Definition: shape_arc.cpp:584
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), ARC, EDA_SHAPE::GetArcMid(), EDA_SHAPE::GetEnd(), SHAPE_ARC::GetP0(), EDA_SHAPE::GetStart(), getStartEndPoints(), EDA_SHAPE::GetWidth(), SHAPE_LINE_CHAIN::Insert(), left, PCB_ARC_T, PCB_FP_SHAPE_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 786 of file convert_tool.cpp.

787 {
788  auto& selection = m_selectionTool->RequestSelection(
789  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
790  {
791  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
792  {
793  BOARD_ITEM* item = aCollector[i];
794 
795  if( !( item->Type() == PCB_SHAPE_T ||
796  item->Type() == PCB_TRACE_T ||
797  item->Type() == PCB_FP_SHAPE_T ) )
798  {
799  aCollector.Remove( item );
800  }
801  }
802  } );
803 
804  EDA_ITEM* source = selection.Front();
805  VECTOR2I start, end, mid;
806 
807  // Offset the midpoint along the normal a little bit so that it's more obviously an arc
808  const double offsetRatio = 0.1;
809 
810  if( OPT<SEG> seg = getStartEndPoints( source, nullptr ) )
811  {
812  start = seg->A;
813  end = seg->B;
814 
815  VECTOR2I normal = ( seg->B - seg->A ).Perpendicular().Resize( offsetRatio * seg->Length() );
816  mid = seg->Center() + normal;
817  }
818  else
819  {
820  return -1;
821  }
822 
823  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
824  BOARD_ITEM_CONTAINER* parent = frame->GetModel();
825 
826  BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( source );
827 
828  // Don't continue processing if we don't actually have a board item
829  if( !boardItem )
830  return 0;
831 
832  PCB_LAYER_ID layer = boardItem->GetLayer();
833 
834  BOARD_COMMIT commit( m_frame );
835 
836  if( source->Type() == PCB_SHAPE_T || source->Type() == PCB_FP_SHAPE_T )
837  {
838  PCB_SHAPE* line = static_cast<PCB_SHAPE*>( source );
839  PCB_SHAPE* arc = new PCB_SHAPE( parent, SHAPE_T::ARC );
840 
841  VECTOR2I center = CalcArcCenter( start, mid, end );
842 
843  arc->SetFilled( false );
844  arc->SetLayer( layer );
845  arc->SetWidth( line->GetWidth() );
846 
847  arc->SetCenter( wxPoint( center ) );
848  arc->SetStart( wxPoint( start ) );
849  arc->SetEnd( wxPoint( end ) );
850 
851  commit.Add( arc );
852  }
853  else
854  {
855  wxASSERT( source->Type() == PCB_TRACE_T );
856  PCB_TRACK* line = static_cast<PCB_TRACK*>( source );
857  PCB_ARC* arc = new PCB_ARC( parent );
858 
859  arc->SetLayer( layer );
860  arc->SetWidth( line->GetWidth() );
861  arc->SetStart( wxPoint( start ) );
862  arc->SetMid( wxPoint( mid ) );
863  arc->SetEnd( wxPoint( end ) );
864 
865  commit.Add( arc );
866  }
867 
868  commit.Push( _( "Create arc from line segment" ) );
869 
870  return 0;
871 }
int GetWidth() const
Definition: eda_shape.h:98
static OPT< SEG > getStartEndPoints(EDA_ITEM *aItem, int *aWidth)
Retrieve the start and end points for a generic item.
void SetFilled(bool aFlag)
Definition: eda_shape.h:92
void SetEnd(const wxPoint &aEnd)
Definition: eda_shape.h:135
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:164
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void SetEnd(const wxPoint &aEnd)
Definition: pcb_track.h:104
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:110
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
void SetStart(const wxPoint &aStart)
Definition: eda_shape.h:110
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
void SetMid(const wxPoint &aMid)
Definition: pcb_track.h:271
void SetStart(const wxPoint &aStart)
Definition: pcb_track.h:107
#define _(s)
void SetWidth(int aWidth)
Definition: eda_shape.h:97
void SetCenter(const wxPoint &aCenter)
Definition: eda_shape.cpp:419
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:65
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:240
The selection tool: currently supports:
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
boost::optional< T > OPT
Definition: optional.h:7
Abstract interface for BOARD_ITEMs capable of storing other items inside.
const VECTOR2I CalcArcCenter(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:525
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:143
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112

References _, COMMIT::Add(), ARC, CalcArcCenter(), COLLECTOR::GetCount(), BOARD_ITEM::GetLayer(), PCB_BASE_FRAME::GetModel(), getStartEndPoints(), EDA_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(), EDA_SHAPE::SetCenter(), PCB_TRACK::SetEnd(), EDA_SHAPE::SetEnd(), EDA_SHAPE::SetFilled(), BOARD_ITEM::SetLayer(), PCB_ARC::SetMid(), PCB_TRACK::SetStart(), EDA_SHAPE::SetStart(), EDA_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 918 of file convert_tool.cpp.

919 {
926 }
static TOOL_ACTION convertToTracks
Definition: pcb_actions.h:479
static TOOL_ACTION convertToLines
Definition: pcb_actions.h:477
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:475
static TOOL_ACTION convertToKeepout
Definition: pcb_actions.h:476
static TOOL_ACTION convertToArc
Definition: pcb_actions.h:478
static TOOL_ACTION convertToPoly
Definition: pcb_actions.h:474
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(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), SCH_MOVE_TOOL::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(), EDIT_TOOL::CreateArray(), MICROWAVE_TOOL::createInductorBetween(), DRC_TOOL::CrossProbe(), 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(), 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(), EDIT_TOOL::Drag(), 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(), PAD_TOOL::EditPad(), SYMBOL_EDITOR_EDIT_TOOL::editShapeProperties(), 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(), SYMBOL_EDITOR_CONTROL::Init(), GLOBAL_EDIT_TOOL::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::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(), PL_EDIT_TOOL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), CVPCB_CONTROL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PL_SELECTION_TOOL::Main(), EDA_3D_CONTROLLER::Main(), SCH_MOVE_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::performDragging(), 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(), PAD_TOOL::recombinePad(), 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(), PAD_TOOL::Reset(), 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(), EE_POINT_EDITOR::updateParentItem(), 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: