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

536 {
537  auto& selection = m_selectionTool->RequestSelection(
538  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
539  {
540  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
541  {
542  BOARD_ITEM* item = aCollector[i];
543 
544  switch( item->Type() )
545  {
546  case PCB_SHAPE_T:
547  case PCB_FP_SHAPE_T:
548  switch( static_cast<PCB_SHAPE*>( item )->GetShape() )
549  {
550  case SHAPE_T::SEGMENT:
551  case SHAPE_T::ARC:
552  case SHAPE_T::POLY:
553  case SHAPE_T::RECT:
554  break;
555 
556  default:
557  aCollector.Remove( item );
558  }
559 
560  break;
561 
562  case PCB_ZONE_T:
563  case PCB_FP_ZONE_T:
564  break;
565 
566  default:
567  aCollector.Remove( item );
568  }
569  }
570  } );
571 
572  if( selection.Empty() )
573  return 0;
574 
575  auto getPolySet =
576  []( EDA_ITEM* aItem )
577  {
578  SHAPE_POLY_SET set;
579 
580  switch( aItem->Type() )
581  {
582  case PCB_ZONE_T:
583  case PCB_FP_ZONE_T:
584  set = *static_cast<ZONE*>( aItem )->Outline();
585  break;
586 
587  case PCB_SHAPE_T:
588  case PCB_FP_SHAPE_T:
589  {
590  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
591 
592  if( graphic->GetShape() == SHAPE_T::POLY )
593  {
594  set = graphic->GetPolyShape();
595  }
596  else if( graphic->GetShape() == SHAPE_T::RECT )
597  {
598  SHAPE_LINE_CHAIN outline;
599  VECTOR2I start( graphic->GetStart() );
600  VECTOR2I end( graphic->GetEnd() );
601 
602  outline.Append( start );
603  outline.Append( VECTOR2I( end.x, start.y ) );
604  outline.Append( end );
605  outline.Append( VECTOR2I( start.x, end.y ) );
606  outline.SetClosed( true );
607 
608  set.AddOutline( outline );
609  }
610  else
611  {
612  wxFAIL_MSG( "Unhandled graphic shape type in PolyToLines - getPolySet" );
613  }
614  break;
615  }
616 
617  default:
618  wxFAIL_MSG( "Unhandled type in PolyToLines - getPolySet" );
619  break;
620  }
621 
622  return set;
623  };
624 
625  auto getSegList =
626  []( SHAPE_POLY_SET& aPoly )
627  {
628  std::vector<SEG> segs;
629 
630  // Our input should be valid polys, so OK to assert here
631  wxASSERT( aPoly.VertexCount() >= 2 );
632 
633  for( int i = 1; i < aPoly.VertexCount(); i++ )
634  segs.emplace_back( SEG( aPoly.CVertex( i - 1 ), aPoly.CVertex( i ) ) );
635 
636  segs.emplace_back( SEG( aPoly.CVertex( aPoly.VertexCount() - 1 ),
637  aPoly.CVertex( 0 ) ) );
638 
639  return segs;
640  };
641 
642  BOARD_COMMIT commit( m_frame );
643  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
644  FOOTPRINT_EDIT_FRAME* fpEditor = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame );
645  FOOTPRINT* footprint = nullptr;
646  PCB_LAYER_ID targetLayer = m_frame->GetActiveLayer();
647  PCB_LAYER_ID copperLayer = UNSELECTED_LAYER;
648  BOARD_ITEM_CONTAINER* parent = frame->GetModel();
649 
650  if( fpEditor )
651  footprint = fpEditor->GetBoard()->GetFirstFootprint();
652 
653  auto handleGraphicSeg =
654  [&]( EDA_ITEM* aItem )
655  {
656  if( aItem->Type() != PCB_SHAPE_T && aItem->Type() != PCB_FP_SHAPE_T )
657  return false;
658 
659  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
660 
661  if( graphic->GetShape() == SHAPE_T::SEGMENT )
662  {
663  PCB_TRACK* track = new PCB_TRACK( parent );
664 
665  track->SetLayer( targetLayer );
666  track->SetStart( graphic->GetStart() );
667  track->SetEnd( graphic->GetEnd() );
668  commit.Add( track );
669 
670  return true;
671  }
672  else if( graphic->GetShape() == SHAPE_T::ARC )
673  {
674  PCB_ARC* arc = new PCB_ARC( parent );
675 
676  arc->SetLayer( targetLayer );
677  arc->SetStart( graphic->GetStart() );
678  arc->SetEnd( graphic->GetEnd() );
679  arc->SetMid( graphic->GetArcMid() );
680  commit.Add( arc );
681 
682  return true;
683  }
684 
685  return false;
686  };
687 
688  for( EDA_ITEM* item : selection )
689  {
690  if( handleGraphicSeg( item ) )
691  continue;
692 
693  SHAPE_POLY_SET polySet = getPolySet( item );
694  std::vector<SEG> segs = getSegList( polySet );
695 
696  if( aEvent.IsAction( &PCB_ACTIONS::convertToLines ) )
697  {
698  for( SEG& seg : segs )
699  {
700  if( fpEditor )
701  {
702  FP_SHAPE* graphic = new FP_SHAPE( footprint, SHAPE_T::SEGMENT );
703 
704  graphic->SetLayer( targetLayer );
705  graphic->SetStart( wxPoint( seg.A ) );
706  graphic->SetStart0( wxPoint( seg.A ) );
707  graphic->SetEnd( wxPoint( seg.B ) );
708  graphic->SetEnd0( wxPoint( seg.B ) );
709  commit.Add( graphic );
710  }
711  else
712  {
713  PCB_SHAPE* graphic = new PCB_SHAPE( nullptr, SHAPE_T::SEGMENT );
714 
715  graphic->SetLayer( targetLayer );
716  graphic->SetStart( wxPoint( seg.A ) );
717  graphic->SetEnd( wxPoint( seg.B ) );
718  commit.Add( graphic );
719  }
720  }
721  }
722  else
723  {
724 
725 
726  if( !IsCopperLayer( targetLayer ) )
727  {
728  if( copperLayer == UNSELECTED_LAYER )
729  copperLayer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() );
730 
731  if( copperLayer == UNDEFINED_LAYER ) // User canceled
732  continue;
733 
734  targetLayer = copperLayer;
735  }
736 
737  // I am really unsure converting a polygon to "tracks" (i.e. segments on
738  // copper layers) make sense for footprints, but anyway this code exists
739  if( fpEditor )
740  {
741  // Creating segments on copper layer
742  for( SEG& seg : segs )
743  {
744  FP_SHAPE* graphic = new FP_SHAPE( footprint, SHAPE_T::SEGMENT );
745  graphic->SetLayer( targetLayer );
746  graphic->SetStart( wxPoint( seg.A ) );
747  graphic->SetStart0( wxPoint( seg.A ) );
748  graphic->SetEnd( wxPoint( seg.B ) );
749  graphic->SetEnd0( wxPoint( seg.B ) );
750  commit.Add( graphic );
751  }
752  }
753  else
754  {
755  // Creating tracks
756  for( SEG& seg : segs )
757  {
758  PCB_TRACK* track = new PCB_TRACK( parent );
759 
760  track->SetLayer( targetLayer );
761  track->SetStart( wxPoint( seg.A ) );
762  track->SetEnd( wxPoint( seg.B ) );
763  commit.Add( track );
764  }
765  }
766  }
767  }
768 
769  commit.Push( _( "Convert polygons to lines" ) );
770 
771  return 0;
772 }
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
void SetEnd(const wxPoint &aEnd)
Definition: eda_shape.h:126
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:163
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:97
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:101
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:122
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:270
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:207
bool IsCopperLayer(LAYER_NUM aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:797
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:92
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, 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(), EDA_SHAPE::SetStart(), PCB_TRACK::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 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  switch( static_cast<PCB_SHAPE*>( item )->GetShape() )
140  {
141  case SHAPE_T::SEGMENT:
142  case SHAPE_T::RECT:
143  case SHAPE_T::CIRCLE:
144  case SHAPE_T::ARC:
145  case SHAPE_T::POLY:
146  break;
147 
148  default:
149  aCollector.Remove( item );
150  }
151 
152  break;
153 
154  case PCB_TRACE_T:
155  case PCB_ARC_T:
156  break;
157 
158  case PCB_ZONE_T:
159  case PCB_FP_ZONE_T:
160  break;
161 
162  default:
163  aCollector.Remove( item );
164  }
165  }
166  } );
167 
168  if( selection.Empty() )
169  return 0;
170 
171  PCB_LAYER_ID destLayer = m_frame->GetActiveLayer();
172  SHAPE_POLY_SET polySet = makePolysFromSegs( selection.GetItems() );
173 
174  polySet.Append( makePolysFromRects( selection.GetItems() ) );
175 
176  polySet.Append( makePolysFromCircles( selection.GetItems() ) );
177 
178  polySet.Append( extractPolygons( selection.GetItems() ) );
179 
180  if( polySet.IsEmpty() )
181  return 0;
182 
183  bool isFootprint = m_frame->IsType( FRAME_FOOTPRINT_EDITOR );
184 
185  if( FP_SHAPE* graphic = dynamic_cast<FP_SHAPE*>( selection.Front() ) )
186  parentFootprint = graphic->GetParentFootprint();
187  else if( FP_ZONE* zone = dynamic_cast<FP_ZONE*>( selection.Front() ) )
188  parentFootprint = static_cast<FOOTPRINT*>( zone->GetParent() );
189  else
190  wxFAIL_MSG( "Unimplemented footprint parent in CONVERT_TOOL::CreatePolys" );
191 
192  BOARD_COMMIT commit( m_frame );
193 
194  // For now, we convert each outline in the returned shape to its own polygon
195  std::vector<SHAPE_POLY_SET> polys;
196 
197  for( int i = 0; i < polySet.OutlineCount(); i++ )
198  polys.emplace_back( SHAPE_POLY_SET( polySet.COutline( i ) ) );
199 
200  if( aEvent.IsAction( &PCB_ACTIONS::convertToPoly ) )
201  {
202  for( const SHAPE_POLY_SET& poly : polys )
203  {
204  PCB_SHAPE* graphic = isFootprint ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
205 
206  graphic->SetShape( SHAPE_T::POLY );
207  graphic->SetFilled( false );
208  graphic->SetWidth( poly.Outline( 0 ).Width() );
209  graphic->SetLayer( destLayer );
210  graphic->SetPolyShape( poly );
211 
212  commit.Add( graphic );
213  }
214 
215  commit.Push( _( "Convert shapes to polygon" ) );
216  }
217  else
218  {
219  // Creating zone or keepout
220  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
221  BOARD_ITEM_CONTAINER* parent = frame->GetModel();
222  ZONE_SETTINGS zoneInfo = frame->GetZoneSettings();
223 
224  bool nonCopper = IsNonCopperLayer( destLayer );
225  zoneInfo.m_Layers.reset().set( destLayer );
226  zoneInfo.m_Name.Empty();
227 
228  int ret;
229 
230  if( aEvent.IsAction( &PCB_ACTIONS::convertToKeepout ) )
231  {
232  zoneInfo.SetIsRuleArea( true );
233  ret = InvokeRuleAreaEditor( frame, &zoneInfo );
234  }
235  else if( nonCopper )
236  {
237  zoneInfo.SetIsRuleArea( false );
238  ret = InvokeNonCopperZonesEditor( frame, &zoneInfo );
239  }
240  else
241  {
242  zoneInfo.SetIsRuleArea( false );
243  ret = InvokeCopperZonesEditor( frame, &zoneInfo );
244  }
245 
246  if( ret == wxID_CANCEL )
247  return 0;
248 
249  for( const SHAPE_POLY_SET& poly : polys )
250  {
251  ZONE* zone = isFootprint ? new FP_ZONE( parent ) : new ZONE( parent );
252 
253  *zone->Outline() = poly;
254  zone->HatchBorder();
255 
256  zoneInfo.ExportSetting( *zone );
257 
258  commit.Add( zone );
259  }
260 
261  commit.Push( _( "Convert shapes to zone" ) );
262  }
263 
264  return 0;
265 }
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void SetFilled(bool aFlag)
Definition: eda_shape.h:83
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:163
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: eda_shape.h:215
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
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:941
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:808
static TOOL_ACTION convertToKeepout
Definition: pcb_actions.h:476
#define _(s)
void SetWidth(int aWidth)
Definition: eda_shape.h:88
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:91
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.
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:945
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
BOARD_ITEM_CONTAINER * GetParentFootprint() const
Definition: board_item.cpp:179
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(), BOARD_ITEM::GetParentFootprint(), 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 499 of file convert_tool.cpp.

500 {
501  SHAPE_POLY_SET poly;
502 
503  for( EDA_ITEM* item : aItems )
504  {
505  switch( item->Type() )
506  {
507  case PCB_SHAPE_T:
508  case PCB_FP_SHAPE_T:
509  switch( static_cast<PCB_SHAPE*>( item )->GetShape() )
510  {
511  case SHAPE_T::POLY:
512  poly.Append( static_cast<PCB_SHAPE*>( item )->GetPolyShape() );
513  break;
514 
515  default:
516  continue;
517  }
518 
519  break;
520 
521  case PCB_ZONE_T:
522  case PCB_FP_ZONE_T:
523  poly.Append( *static_cast<ZONE*>( item )->Outline() );
524  break;
525 
526  default:
527  continue;
528  }
529  }
530 
531  return poly;
532 }
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 863 of file convert_tool.cpp.

864 {
865  switch( aItem->Type() )
866  {
867  case PCB_SHAPE_T:
868  case PCB_FP_SHAPE_T:
869  {
870  PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( aItem );
871 
872  if( aWidth )
873  *aWidth = shape->GetWidth();
874 
875  return boost::make_optional<SEG>( { VECTOR2I( shape->GetStart() ),
876  VECTOR2I( shape->GetEnd() ) } );
877  }
878 
879  case PCB_TRACE_T:
880  {
881  PCB_TRACK* line = static_cast<PCB_TRACK*>( aItem );
882 
883  if( aWidth )
884  *aWidth = line->GetWidth();
885 
886  return boost::make_optional<SEG>( { VECTOR2I( line->GetStart() ),
887  VECTOR2I( line->GetEnd() ) } );
888  }
889 
890  case PCB_ARC_T:
891  {
892  PCB_ARC* arc = static_cast<PCB_ARC*>( aItem );
893 
894  if( aWidth )
895  *aWidth = arc->GetWidth();
896 
897  return boost::make_optional<SEG>( { VECTOR2I( arc->GetStart() ),
898  VECTOR2I( arc->GetEnd() ) } );
899  }
900 
901  default:
902  return NULLOPT;
903  }
904 }
int GetWidth() const
Definition: eda_shape.h:89
const wxPoint & GetEnd() const
Definition: pcb_track.h:105
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
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:122
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(), SCH_MOVE_TOOL::moveItem(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), PL_EDIT_TOOL::Paste(), SYMBOL_EDITOR_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::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(), 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_EDIT_TOOL::setTransitions(), SYMBOL_EDITOR_CONTROL::setTransitions(), SCH_MOVE_TOOL::setTransitions(), PL_EDIT_TOOL::setTransitions(), POSITION_RELATIVE_TOOL::setTransitions(), GERBVIEW_SELECTION_TOOL::setTransitions(), SCH_DRAWING_TOOLS::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_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(), 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 472 of file convert_tool.cpp.

473 {
474  SHAPE_POLY_SET poly;
475 
476  for( EDA_ITEM* item : aItems )
477  {
478  if( item->Type() != PCB_SHAPE_T && item->Type() != PCB_FP_SHAPE_T )
479  continue;
480 
481  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( item );
482 
483  if( graphic->GetShape() != SHAPE_T::CIRCLE )
484  continue;
485 
486  BOARD_DESIGN_SETTINGS& bds = graphic->GetBoard()->GetDesignSettings();
487  SHAPE_LINE_CHAIN outline;
488 
489  TransformCircleToPolygon( outline, graphic->GetPosition(), graphic->GetRadius(),
490  bds.m_MaxError, ERROR_OUTSIDE );
491 
492  poly.AddOutline( outline );
493  }
494 
495  return poly;
496 }
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:92
int GetRadius() const
Definition: eda_shape.cpp:466
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 439 of file convert_tool.cpp.

440 {
441  SHAPE_POLY_SET poly;
442 
443  for( EDA_ITEM* item : aItems )
444  {
445  if( item->Type() != PCB_SHAPE_T && item->Type() != PCB_FP_SHAPE_T )
446  continue;
447 
448  PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( item );
449 
450  if( graphic->GetShape() != SHAPE_T::RECT )
451  continue;
452 
453  SHAPE_LINE_CHAIN outline;
454  VECTOR2I start( graphic->GetStart() );
455  VECTOR2I end( graphic->GetEnd() );
456 
457  outline.Append( start );
458  outline.Append( VECTOR2I( end.x, start.y ) );
459  outline.Append( end );
460  outline.Append( VECTOR2I( start.x, end.y ) );
461  outline.SetClosed( true );
462 
463  outline.SetWidth( graphic->GetWidth() );
464 
465  poly.AddOutline( outline );
466  }
467 
468  return poly;
469 }
int GetWidth() const
Definition: eda_shape.h:89
const wxPoint & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:97
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:122
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:92
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 268 of file convert_tool.cpp.

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

776 {
777  auto& selection = m_selectionTool->RequestSelection(
778  []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
779  {
780  for( int i = aCollector.GetCount() - 1; i >= 0; --i )
781  {
782  BOARD_ITEM* item = aCollector[i];
783 
784  if( !( item->Type() == PCB_SHAPE_T ||
785  item->Type() == PCB_TRACE_T ||
786  item->Type() == PCB_FP_SHAPE_T ) )
787  {
788  aCollector.Remove( item );
789  }
790  }
791  } );
792 
793  EDA_ITEM* source = selection.Front();
794  VECTOR2I start, end, mid;
795 
796  // Offset the midpoint along the normal a little bit so that it's more obviously an arc
797  const double offsetRatio = 0.1;
798 
799  if( OPT<SEG> seg = getStartEndPoints( source, nullptr ) )
800  {
801  start = seg->A;
802  end = seg->B;
803 
804  VECTOR2I normal = ( seg->B - seg->A ).Perpendicular().Resize( offsetRatio * seg->Length() );
805  mid = seg->Center() + normal;
806  }
807  else
808  {
809  return -1;
810  }
811 
812  PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
813  BOARD_ITEM_CONTAINER* parent = frame->GetModel();
814 
815  BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( source );
816 
817  // Don't continue processing if we don't actually have a board item
818  if( !boardItem )
819  return 0;
820 
821  PCB_LAYER_ID layer = boardItem->GetLayer();
822 
823  BOARD_COMMIT commit( m_frame );
824 
825  if( source->Type() == PCB_SHAPE_T || source->Type() == PCB_FP_SHAPE_T )
826  {
827  PCB_SHAPE* line = static_cast<PCB_SHAPE*>( source );
828  PCB_SHAPE* arc = new PCB_SHAPE( parent, SHAPE_T::ARC );
829 
830  VECTOR2I center = CalcArcCenter( start, mid, end );
831 
832  arc->SetFilled( false );
833  arc->SetLayer( layer );
834  arc->SetWidth( line->GetWidth() );
835 
836  arc->SetCenter( wxPoint( center ) );
837  arc->SetStart( wxPoint( start ) );
838  arc->SetEnd( wxPoint( end ) );
839 
840  commit.Add( arc );
841  }
842  else
843  {
844  wxASSERT( source->Type() == PCB_TRACE_T );
845  PCB_TRACK* line = static_cast<PCB_TRACK*>( source );
846  PCB_ARC* arc = new PCB_ARC( parent );
847 
848  arc->SetLayer( layer );
849  arc->SetWidth( line->GetWidth() );
850  arc->SetStart( wxPoint( start ) );
851  arc->SetMid( wxPoint( mid ) );
852  arc->SetEnd( wxPoint( end ) );
853 
854  commit.Add( arc );
855  }
856 
857  commit.Push( _( "Create arc from line segment" ) );
858 
859  return 0;
860 }
int GetWidth() const
Definition: eda_shape.h:89
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:83
void SetEnd(const wxPoint &aEnd)
Definition: eda_shape.h:126
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:163
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:101
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:82
void SetMid(const wxPoint &aMid)
Definition: pcb_track.h:270
void SetStart(const wxPoint &aStart)
Definition: pcb_track.h:107
#define _(s)
void SetWidth(int aWidth)
Definition: eda_shape.h:88
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:454
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:142
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(), EDA_SHAPE::SetStart(), PCB_TRACK::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 907 of file convert_tool.cpp.

908 {
915 }
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(), 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(), 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(), PAD_TOOL::Init(), GROUP_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(), SYMBOL_EDITOR_MOVE_TOOL::Main(), CVPCB_CONTROL::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(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_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(), 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(), 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: