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 , REDRAW }
 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
 

Private Member Functions

SHAPE_POLY_SET makePolysFromChainedSegs (const std::deque< EDA_ITEM * > &aItems, CONVERT_STRATEGY aStrategy)
 Try to make polygons from chained segments in the selected items. More...
 
SHAPE_POLY_SET makePolysFromOpenGraphics (const std::deque< EDA_ITEM * > &aItems, int aGap)
 Make polygons from graphic shapes and zones. More...
 
SHAPE_POLY_SET makePolysFromClosedGraphics (const std::deque< EDA_ITEM * > &aItems, CONVERT_STRATEGY aStrategy)
 
void resetTransitions ()
 Clear the current transition map and restores the default one created by setTransitions(). More...
 
void goInternal (TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
 
EDA_ITEMgetModelInt () const
 
TOOLS_HOLDERgetToolHolderInt () const
 

Static Private Member Functions

static std::optional< SEGgetStartEndPoints (EDA_ITEM *aItem)
 Retrieve the start and end points for a generic item. More...
 

Private Attributes

PCB_SELECTION_TOOLm_selectionTool
 
CONDITIONAL_MENUm_menu
 
PCB_BASE_FRAMEm_frame
 
CONVERT_SETTINGS m_userSettings
 

Detailed Description

Definition at line 37 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.

REDRAW 

Full drawing refresh.

Definition at line 77 of file tool_base.h.

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

Constructor & Destructor Documentation

◆ CONVERT_TOOL()

CONVERT_TOOL::CONVERT_TOOL ( )

Definition at line 204 of file convert_tool.cpp.

204 :
205 TOOL_INTERACTIVE( "pcbnew.Convert" ),
206 m_selectionTool( nullptr ),
207 m_menu( nullptr ),
208 m_frame( nullptr )
209{
214}
PCB_SELECTION_TOOL * m_selectionTool
Definition: convert_tool.h:100
CONVERT_SETTINGS m_userSettings
Definition: convert_tool.h:103
CONDITIONAL_MENU * m_menu
Definition: convert_tool.h:101
PCB_BASE_FRAME * m_frame
Definition: convert_tool.h:102
TOOL_INTERACTIVE(TOOL_ID aId, const std::string &aName)
Create a tool with given id & name.
@ CENTERLINE
CONVERT_STRATEGY m_Strategy

References CENTERLINE, CONVERT_SETTINGS::m_DeleteOriginals, CONVERT_SETTINGS::m_Gap, CONVERT_SETTINGS::m_LineWidth, CONVERT_SETTINGS::m_Strategy, and m_userSettings.

◆ ~CONVERT_TOOL()

CONVERT_TOOL::~CONVERT_TOOL ( )
virtual

Definition at line 217 of file convert_tool.cpp.

218{
219 delete m_menu;
220}

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:215
TOOL_ID m_toolId
Name of the tool.
Definition: tool_base.h:210
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(), SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_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(), SCH_DRAWING_TOOLS::DrawShape(), 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(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), PCB_POINT_EDITOR::OnSelectionChange(), GROUP_TOOL::PickNewMember(), SYMBOL_EDITOR_DRAWING_TOOLS::PlaceAnchor(), BOARD_EDITOR_CONTROL::PlaceFootprint(), SCH_DRAWING_TOOLS::PlaceImage(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), EDIT_TOOL::Remove(), ROUTER_TOOL::RouteSelected(), POSITION_RELATIVE_TOOL::SelectPositionRelativeItem(), DRAWING_TOOL::SetAnchor(), DRC_TOOL::ShowDRCDialog(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_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}

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

809{
810 auto& selection = m_selectionTool->RequestSelection(
811 []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
812 {
813 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
814 {
815 BOARD_ITEM* item = aCollector[i];
816
817 switch( item->Type() )
818 {
819 case PCB_SHAPE_T:
820 case PCB_FP_SHAPE_T:
821 switch( static_cast<PCB_SHAPE*>( item )->GetShape() )
822 {
823 case SHAPE_T::SEGMENT:
824 case SHAPE_T::ARC:
825 case SHAPE_T::POLY:
826 case SHAPE_T::RECT:
827 break;
828
829 default:
830 aCollector.Remove( item );
831 }
832
833 break;
834
835 case PCB_ZONE_T:
836 case PCB_FP_ZONE_T:
837 break;
838
839 default:
840 aCollector.Remove( item );
841 }
842 }
843 } );
844
845 if( selection.Empty() )
846 return 0;
847
848 auto getPolySet =
849 []( EDA_ITEM* aItem )
850 {
851 SHAPE_POLY_SET set;
852
853 switch( aItem->Type() )
854 {
855 case PCB_ZONE_T:
856 case PCB_FP_ZONE_T:
857 set = *static_cast<ZONE*>( aItem )->Outline();
858 break;
859
860 case PCB_SHAPE_T:
861 case PCB_FP_SHAPE_T:
862 {
863 PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
864
865 if( graphic->GetShape() == SHAPE_T::POLY )
866 {
867 set = graphic->GetPolyShape();
868 }
869 else if( graphic->GetShape() == SHAPE_T::RECT )
870 {
871 SHAPE_LINE_CHAIN outline;
872 VECTOR2I start( graphic->GetStart() );
873 VECTOR2I end( graphic->GetEnd() );
874
875 outline.Append( start );
876 outline.Append( VECTOR2I( end.x, start.y ) );
877 outline.Append( end );
878 outline.Append( VECTOR2I( start.x, end.y ) );
879 outline.SetClosed( true );
880
881 set.AddOutline( outline );
882 }
883 else
884 {
885 wxFAIL_MSG( wxT( "Unhandled graphic shape type in PolyToLines - getPolySet" ) );
886 }
887 break;
888 }
889
890 default:
891 wxFAIL_MSG( wxT( "Unhandled type in PolyToLines - getPolySet" ) );
892 break;
893 }
894
895 return set;
896 };
897
898 auto getSegList =
899 []( SHAPE_POLY_SET& aPoly )
900 {
901 std::vector<SEG> segs;
902
903 // Our input should be valid polys, so OK to assert here
904 wxASSERT( aPoly.VertexCount() >= 2 );
905
906 for( int i = 1; i < aPoly.VertexCount(); i++ )
907 segs.emplace_back( SEG( aPoly.CVertex( i - 1 ), aPoly.CVertex( i ) ) );
908
909 segs.emplace_back( SEG( aPoly.CVertex( aPoly.VertexCount() - 1 ),
910 aPoly.CVertex( 0 ) ) );
911
912 return segs;
913 };
914
915 BOARD_COMMIT commit( m_frame );
916 PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
917 FOOTPRINT_EDIT_FRAME* fpEditor = dynamic_cast<FOOTPRINT_EDIT_FRAME*>( m_frame );
918 FOOTPRINT* footprint = nullptr;
919 PCB_LAYER_ID targetLayer = m_frame->GetActiveLayer();
920 BOARD_ITEM_CONTAINER* parent = frame->GetModel();
921
922 if( fpEditor )
923 footprint = fpEditor->GetBoard()->GetFirstFootprint();
924
925 auto handleGraphicSeg =
926 [&]( EDA_ITEM* aItem )
927 {
928 if( aItem->Type() != PCB_SHAPE_T && aItem->Type() != PCB_FP_SHAPE_T )
929 return false;
930
931 PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
932
933 if( graphic->GetShape() == SHAPE_T::SEGMENT )
934 {
935 PCB_TRACK* track = new PCB_TRACK( parent );
936
937 track->SetLayer( targetLayer );
938 track->SetStart( graphic->GetStart() );
939 track->SetEnd( graphic->GetEnd() );
940 track->SetWidth( graphic->GetWidth() );
941 commit.Add( track );
942
943 return true;
944 }
945 else if( graphic->GetShape() == SHAPE_T::ARC )
946 {
947 PCB_ARC* arc = new PCB_ARC( parent );
948
949 arc->SetLayer( targetLayer );
950 arc->SetStart( graphic->GetStart() );
951 arc->SetEnd( graphic->GetEnd() );
952 arc->SetMid( graphic->GetArcMid() );
953 arc->SetWidth( graphic->GetWidth() );
954 commit.Add( arc );
955
956 return true;
957 }
958
959 return false;
960 };
961
963 {
964 if( !IsCopperLayer( targetLayer ) )
965 {
966 targetLayer = frame->SelectOneLayer( F_Cu, LSET::AllNonCuMask() );
967
968 if( targetLayer == UNDEFINED_LAYER ) // User canceled
969 return true;
970 }
971 }
972
973 for( EDA_ITEM* item : selection )
974 {
975 if( handleGraphicSeg( item ) )
976 continue;
977
978 SHAPE_POLY_SET polySet = getPolySet( item );
979 std::vector<SEG> segs = getSegList( polySet );
980
982 {
983 for( SEG& seg : segs )
984 {
985 if( fpEditor )
986 {
987 FP_SHAPE* graphic = new FP_SHAPE( footprint, SHAPE_T::SEGMENT );
988
989 graphic->SetLayer( targetLayer );
990 graphic->SetStart( VECTOR2I( seg.A ) );
991 graphic->SetStart0( VECTOR2I( seg.A ) );
992 graphic->SetEnd( VECTOR2I( seg.B ) );
993 graphic->SetEnd0( VECTOR2I( seg.B ) );
994 commit.Add( graphic );
995 }
996 else
997 {
998 PCB_SHAPE* graphic = new PCB_SHAPE( nullptr, SHAPE_T::SEGMENT );
999
1000 graphic->SetLayer( targetLayer );
1001 graphic->SetStart( VECTOR2I( seg.A ) );
1002 graphic->SetEnd( VECTOR2I( seg.B ) );
1003 commit.Add( graphic );
1004 }
1005 }
1006 }
1007 else
1008 {
1009 // I am really unsure converting a polygon to "tracks" (i.e. segments on
1010 // copper layers) make sense for footprints, but anyway this code exists
1011 if( fpEditor )
1012 {
1013 // Creating segments on copper layer
1014 for( SEG& seg : segs )
1015 {
1016 FP_SHAPE* graphic = new FP_SHAPE( footprint, SHAPE_T::SEGMENT );
1017 graphic->SetLayer( targetLayer );
1018 graphic->SetStart( VECTOR2I( seg.A ) );
1019 graphic->SetStart0( VECTOR2I( seg.A ) );
1020 graphic->SetEnd( VECTOR2I( seg.B ) );
1021 graphic->SetEnd0( VECTOR2I( seg.B ) );
1022 commit.Add( graphic );
1023 }
1024 }
1025 else
1026 {
1027 // Creating tracks
1028 for( SEG& seg : segs )
1029 {
1030 PCB_TRACK* track = new PCB_TRACK( parent );
1031
1032 track->SetLayer( targetLayer );
1033 track->SetStart( VECTOR2I( seg.A ) );
1034 track->SetEnd( VECTOR2I( seg.B ) );
1035 commit.Add( track );
1036 }
1037 }
1038 }
1039 }
1040
1041 commit.Push( _( "Convert polygons to lines" ) );
1042
1043 return 0;
1044}
Abstract interface for BOARD_ITEMs capable of storing other items inside.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:226
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
Definition: board.h:403
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:247
SHAPE_T GetShape() const
Definition: eda_shape.h:113
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:145
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:124
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:120
int GetWidth() const
Definition: eda_shape.h:109
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:149
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:488
void SetEnd0(const VECTOR2I &aPoint)
Definition: fp_shape.h:94
void SetStart0(const VECTOR2I &aPoint)
Definition: fp_shape.h:91
Used when the right click button is pressed, or when the select tool is in effect.
Definition: collectors.h:204
static LSET AllNonCuMask()
Return a mask holding all layer minus CU layers.
Definition: lset.cpp:794
static TOOL_ACTION convertToTracks
Definition: pcb_actions.h:525
static TOOL_ACTION convertToLines
Definition: pcb_actions.h:523
void SetMid(const VECTOR2I &aMid)
Definition: pcb_track.h:312
Common, abstract interface for edit frames.
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
virtual PCB_LAYER_ID GetActiveLayer() const
BOARD * GetBoard() const
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
The selection tool: currently supports:
PCB_SELECTION & RequestSelection(CLIENT_SELECTION_FILTER aClientFilter, bool aConfirmLockedItems=false)
Return the current selection, filtered according to aClientFilter.
void SetWidth(int aWidth)
Definition: pcb_track.h:107
void SetEnd(const VECTOR2I &aEnd)
Definition: pcb_track.h:110
void SetStart(const VECTOR2I &aStart)
Definition: pcb_track.h:113
Definition: seg.h:42
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
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.
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:81
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
#define _(s)
bool IsCopperLayer(int aLayerId)
Tests whether a layer is a copper layer.
Definition: layer_ids.h:827
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ UNDEFINED_LAYER
Definition: layer_ids.h:60
@ F_Cu
Definition: layer_ids.h:64
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590

References COLLECTOR::GetCount(), m_selectionTool, and PCB_SELECTION_TOOL::RequestSelection().

Referenced by setTransitions().

◆ CreatePolys()

int CONVERT_TOOL::CreatePolys ( const TOOL_EVENT aEvent)

Convert selected lines to a polygon, if possible.

Definition at line 285 of file convert_tool.cpp.

286{
287 std::vector<SHAPE_POLY_SET> polys;
288 PCB_LAYER_ID destLayer = m_frame->GetActiveLayer();
289 FOOTPRINT* parentFootprint = nullptr;
290
292 []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
293 {
294 } );
295
296 if( selection.Empty() )
297 return 0;
298
299 auto getPolys =
300 [&]( CONVERT_SETTINGS cfg )
301 {
302 polys.clear();
303
304 for( EDA_ITEM* item : selection )
305 item->ClearTempFlags();
306
307 SHAPE_POLY_SET polySet;
308
309 polySet.Append( makePolysFromClosedGraphics( selection.GetItems(), cfg.m_Strategy ) );
310
311 polySet.Append( makePolysFromChainedSegs( selection.GetItems(), cfg.m_Strategy ) );
312
313 if( cfg.m_Strategy == BOUNDING_HULL )
314 polySet.Append( makePolysFromOpenGraphics( selection.GetItems(), cfg.m_Gap ) );
315
316 if( polySet.IsEmpty() )
317 return false;
318
319 if( cfg.m_Strategy == BOUNDING_HULL )
320 {
321 polySet.ClearArcs();
323 }
324
325 for( int ii = 0; ii < polySet.OutlineCount(); ++ii )
326 {
327 polys.emplace_back( SHAPE_POLY_SET( polySet.COutline( ii ) ) );
328
329 for( int jj = 0; jj < polySet.HoleCount( ii ); ++jj )
330 polys.back().AddHole( polySet.Hole( ii, jj ) );
331 }
332
333 return true;
334 };
335
336 // Pre-flight getPolys() to see if there's anything to convert.
337 CONVERT_SETTINGS preflightSettings = m_userSettings;
338 preflightSettings.m_Strategy = BOUNDING_HULL;
339
340 if( !getPolys( preflightSettings ) )
341 return 0;
342
343 bool isFootprint = m_frame->IsType( FRAME_FOOTPRINT_EDITOR );
344
345 if( isFootprint )
346 {
347 if( FP_SHAPE* graphic = dynamic_cast<FP_SHAPE*>( selection.Front() ) )
348 parentFootprint = graphic->GetParentFootprint();
349 else if( FP_ZONE* zone = dynamic_cast<FP_ZONE*>( selection.Front() ) )
350 parentFootprint = static_cast<FOOTPRINT*>( zone->GetParent() );
351 else
352 wxFAIL_MSG( wxT( "Unimplemented footprint parent in CONVERT_TOOL::CreatePolys" ) );
353 }
354
357 BOARD_COMMIT commit( m_frame );
358
359 if( aEvent.IsAction( &PCB_ACTIONS::convertToPoly ) )
360 {
362
363 if( dlg.ShowModal() != wxID_OK )
364 return 0;
365
366 CONVERT_SETTINGS resolvedSettings = m_userSettings;
367
368 if( resolvedSettings.m_LineWidth == 0 )
369 resolvedSettings.m_LineWidth = bds.m_LineThickness[ bds.GetLayerClass( layer ) ];
370
371 if( resolvedSettings.m_Strategy == BOUNDING_HULL )
372 {
373 if( resolvedSettings.m_Gap > 0 )
374 resolvedSettings.m_Gap += KiROUND( (double) resolvedSettings.m_LineWidth / 2 );
375 }
376
377 if( !getPolys( resolvedSettings ) )
378 return 0;
379
380 for( const SHAPE_POLY_SET& poly : polys )
381 {
382 PCB_SHAPE* graphic = isFootprint ? new FP_SHAPE( parentFootprint ) : new PCB_SHAPE;
383
384 if( resolvedSettings.m_Strategy == COPY_LINEWIDTH )
385 {
386 BOARD_ITEM* topLeftItem = nullptr;
387 VECTOR2I pos;
388
389 for( EDA_ITEM* item : selection )
390 {
391 if( BOARD_ITEM* candidate = dynamic_cast<BOARD_ITEM*>( item ) )
392 {
393 if( candidate->HasLineStroke() )
394 {
395 pos = candidate->GetPosition();
396
397 if( !topLeftItem
398 || ( pos.x < topLeftItem->GetPosition().x )
399 || ( topLeftItem->GetPosition().x == pos.x
400 && pos.y < topLeftItem->GetPosition().y ) )
401 {
402 topLeftItem = candidate;
403 resolvedSettings.m_LineWidth = topLeftItem->GetStroke().GetWidth();
404 }
405 }
406 }
407 }
408 }
409
410 graphic->SetShape( SHAPE_T::POLY );
411 graphic->SetStroke( STROKE_PARAMS( resolvedSettings.m_LineWidth, PLOT_DASH_TYPE::SOLID,
412 COLOR4D::UNSPECIFIED ) );
413 graphic->SetLayer( destLayer );
414 graphic->SetPolyShape( poly );
415
416 commit.Add( graphic );
417 }
418 }
419 else
420 {
421 // Creating zone or keepout
422 PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
423 BOARD_ITEM_CONTAINER* parent = frame->GetModel();
424 ZONE_SETTINGS zoneInfo = frame->GetZoneSettings();
425
426 bool nonCopper = IsNonCopperLayer( destLayer );
427 zoneInfo.m_Layers.reset().set( destLayer );
428 zoneInfo.m_Name.Empty();
429
430 int ret;
431
432 // No copy-line-width option for zones/keepouts
435
437 {
438 zoneInfo.SetIsRuleArea( true );
439 ret = InvokeRuleAreaEditor( frame, &zoneInfo, &m_userSettings );
440 }
441 else if( nonCopper )
442 {
443 zoneInfo.SetIsRuleArea( false );
444 ret = InvokeNonCopperZonesEditor( frame, &zoneInfo, &m_userSettings );
445 }
446 else
447 {
448 zoneInfo.SetIsRuleArea( false );
449 ret = InvokeCopperZonesEditor( frame, &zoneInfo, &m_userSettings );
450 }
451
452 if( ret == wxID_CANCEL )
453 return 0;
454
455 if( !getPolys( m_userSettings ) )
456 return 0;
457
458 for( const SHAPE_POLY_SET& poly : polys )
459 {
460 ZONE* zone = isFootprint ? new FP_ZONE( parent ) : new ZONE( parent );
461
462 *zone->Outline() = poly;
463 zone->HatchBorder();
464
465 zoneInfo.ExportSetting( *zone );
466
467 commit.Add( zone );
468 }
469 }
470
472 {
473 PCB_SELECTION selectionCopy = selection;
475
476 for( EDA_ITEM* item : selectionCopy )
477 {
478 if( item->GetFlags() & SKIP_STRUCT )
479 commit.Remove( item );
480 }
481 }
482
483 if( aEvent.IsAction( &PCB_ACTIONS::convertToPoly ) )
484 commit.Push( _( "Convert shapes to polygon" ) );
485 else
486 commit.Push( _( "Convert shapes to zone" ) );
487
488 return 0;
489}
Container for design settings for a BOARD object.
int GetLayerClass(PCB_LAYER_ID aLayer) const
int m_LineThickness[LAYER_CLASS_COUNT]
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:70
virtual STROKE_PARAMS GetStroke() const
Definition: board_item.cpp:82
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:704
SHAPE_POLY_SET makePolysFromChainedSegs(const std::deque< EDA_ITEM * > &aItems, CONVERT_STRATEGY aStrategy)
Try to make polygons from chained segments in the selected items.
SHAPE_POLY_SET makePolysFromOpenGraphics(const std::deque< EDA_ITEM * > &aItems, int aGap)
Make polygons from graphic shapes and zones.
SHAPE_POLY_SET makePolysFromClosedGraphics(const std::deque< EDA_ITEM * > &aItems, CONVERT_STRATEGY aStrategy)
bool IsType(FRAME_T aType) const
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249
void SetPolyShape(const SHAPE_POLY_SET &aShape)
Definition: eda_shape.h:255
void SetShape(SHAPE_T aShape)
Definition: eda_shape.h:112
A specialization of ZONE for use in footprints.
Definition: zone.h:916
static TOOL_ACTION convertToKeepout
Definition: pcb_actions.h:522
static TOOL_ACTION convertToPoly
Definition: pcb_actions.h:520
const ZONE_SETTINGS & GetZoneSettings() const
int ClearSelection(const TOOL_EVENT &aEvent)
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: pcb_shape.h:72
bool Empty() const
Checks if there is anything selected.
Definition: selection.h:109
void ClearArcs()
Appends a vertex at the end of the given outline/hole (default: the last outline)
bool IsEmpty() const
int HoleCount(int aOutline) const
Return the reference to aIndex-th outline in the set.
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...
void Simplify(POLYGON_MODE aFastMode)
SHAPE_LINE_CHAIN & Hole(int aOutline, int aHole)
Return the aIndex-th subpolygon in the set.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88
int GetWidth() const
Definition: stroke_params.h:98
ZONE_SETTINGS handles zones parameters.
Definition: zone_settings.h:70
void SetIsRuleArea(bool aEnable)
void ExportSetting(ZONE &aTarget, bool aFullExport=true) const
Function ExportSetting copy settings to a given zone.
wxString m_Name
Definition: zone_settings.h:97
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
Definition: zone.cpp:861
SHAPE_POLY_SET * Outline()
Definition: zone.h:318
int InvokeCopperZonesEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeCopperZonesEditor invokes up a modal dialog window for copper zone editing.
int InvokeNonCopperZonesEditor(PCB_BASE_FRAME *aParent, ZONE_SETTINGS *aSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeNonCopperZonesEditor invokes up a modal dialog window for non-copper zone editing.
int InvokeRuleAreaEditor(PCB_BASE_FRAME *aCaller, ZONE_SETTINGS *aZoneSettings, CONVERT_SETTINGS *aConvertSettings)
Function InvokeRuleAreaEditor invokes up a modal dialog window for copper zone editing.
#define SKIP_STRUCT
flag indicating that the structure should be ignored
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
bool IsNonCopperLayer(int aLayerId)
Test whether a layer is a non copper layer.
Definition: layer_ids.h:838
@ COPY_LINEWIDTH
@ BOUNDING_HULL
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References _, COMMIT::Add(), SHAPE_POLY_SET::Append(), BOUNDING_HULL, CENTERLINE, SHAPE_POLY_SET::ClearArcs(), PCB_SELECTION_TOOL::ClearSelection(), PCB_ACTIONS::convertToKeepout, PCB_ACTIONS::convertToPoly, COPY_LINEWIDTH, SHAPE_POLY_SET::COutline(), SELECTION::Empty(), ZONE_SETTINGS::ExportSetting(), FRAME_FOOTPRINT_EDITOR, SELECTION::Front(), PCB_BASE_FRAME::GetActiveLayer(), PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetLayerClass(), PCB_BASE_FRAME::GetModel(), BOARD_ITEM::GetParentFootprint(), EDA_ITEM::GetPosition(), BOARD_ITEM::GetStroke(), STROKE_PARAMS::GetWidth(), PCB_BASE_FRAME::GetZoneSettings(), ZONE::HatchBorder(), SHAPE_POLY_SET::Hole(), SHAPE_POLY_SET::HoleCount(), InvokeCopperZonesEditor(), InvokeNonCopperZonesEditor(), InvokeRuleAreaEditor(), TOOL_EVENT::IsAction(), SHAPE_POLY_SET::IsEmpty(), IsNonCopperLayer(), EDA_BASE_FRAME::IsType(), KiROUND(), CONVERT_SETTINGS::m_DeleteOriginals, m_frame, CONVERT_SETTINGS::m_Gap, ZONE_SETTINGS::m_Layers, BOARD_DESIGN_SETTINGS::m_LineThickness, CONVERT_SETTINGS::m_LineWidth, ZONE_SETTINGS::m_Name, m_selectionTool, CONVERT_SETTINGS::m_Strategy, m_userSettings, makePolysFromChainedSegs(), makePolysFromClosedGraphics(), makePolysFromOpenGraphics(), ZONE::Outline(), SHAPE_POLY_SET::OutlineCount(), SHAPE_POLY_SET::PM_FAST, POLY, BOARD_COMMIT::Push(), COMMIT::Remove(), PCB_SELECTION_TOOL::RequestSelection(), ZONE_SETTINGS::SetIsRuleArea(), BOARD_ITEM::SetLayer(), EDA_SHAPE::SetPolyShape(), EDA_SHAPE::SetShape(), PCB_SHAPE::SetStroke(), SHAPE_POLY_SET::Simplify(), SKIP_STRUCT, SOLID, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by setTransitions().

◆ getEditFrame()

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

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

Definition at line 185 of file tool_base.h.

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

References TOOL_BASE::getToolHolderInt().

Referenced by ZONE_CREATE_HELPER::createNewZone(), and ZONE_CREATE_HELPER::setUniquePriority().

◆ 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 121 of file tool_base.h.

122 {
123 return m_toolId;
124 }

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

◆ 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 197 of file tool_base.h.

References TOOL_BASE::getModelInt().

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

◆ getModelInt()

EDA_ITEM * TOOL_BASE::getModelInt ( ) const
privateinherited

Definition at line 54 of file tool_base.cpp.

55{
56 return m_toolMgr->GetModel();
57}
EDA_ITEM * GetModel() const
Definition: tool_manager.h:292

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

Referenced by TOOL_BASE::getModel().

◆ 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 134 of file tool_base.h.

135 {
136 return m_toolName;
137 }
std::string m_toolName
Definition: tool_base.h:214

References TOOL_BASE::m_toolName.

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

◆ getStartEndPoints()

std::optional< SEG > CONVERT_TOOL::getStartEndPoints ( EDA_ITEM aItem)
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 std::nullopt if invalid.

Definition at line 1135 of file convert_tool.cpp.

1136{
1137 switch( aItem->Type() )
1138 {
1139 case PCB_SHAPE_T:
1140 case PCB_FP_SHAPE_T:
1141 {
1142 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( aItem );
1143
1144 switch( shape->GetShape() )
1145 {
1146 case SHAPE_T::SEGMENT:
1147 case SHAPE_T::ARC:
1148 case SHAPE_T::POLY:
1149 case SHAPE_T::BEZIER:
1150 if( shape->GetStart() == shape->GetEnd() )
1151 return std::nullopt;
1152
1153 return std::make_optional<SEG>( VECTOR2I( shape->GetStart() ),
1154 VECTOR2I( shape->GetEnd() ) );
1155
1156 default:
1157 return std::nullopt;
1158 }
1159 }
1160
1161 case PCB_TRACE_T:
1162 {
1163 PCB_TRACK* line = static_cast<PCB_TRACK*>( aItem );
1164 return std::make_optional<SEG>( VECTOR2I( line->GetStart() ), VECTOR2I( line->GetEnd() ) );
1165 }
1166
1167 case PCB_ARC_T:
1168 {
1169 PCB_ARC* arc = static_cast<PCB_ARC*>( aItem );
1170 return std::make_optional<SEG>( VECTOR2I( arc->GetStart() ), VECTOR2I( arc->GetEnd() ) );
1171 }
1172
1173 default:
1174 return std::nullopt;
1175 }
1176}
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
const VECTOR2I & GetStart() const
Definition: pcb_track.h:114
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:111
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101

References ARC, BEZIER, EDA_SHAPE::GetEnd(), PCB_TRACK::GetEnd(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), PCB_TRACK::GetStart(), PCB_ARC_T, PCB_FP_SHAPE_T, PCB_SHAPE_T, PCB_TRACE_T, POLY, SEGMENT, and EDA_ITEM::Type().

Referenced by makePolysFromChainedSegs().

◆ getToolHolderInt()

TOOLS_HOLDER * TOOL_BASE::getToolHolderInt ( ) const
privateinherited

Definition at line 48 of file tool_base.cpp.

49{
50 return m_toolMgr->GetToolHolder();
51}
TOOLS_HOLDER * GetToolHolder() const
Definition: tool_manager.h:296

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

Referenced by TOOL_BASE::getEditFrame().

◆ GetToolMenu()

◆ GetType()

TOOL_TYPE TOOL_BASE::GetType ( ) const
inlineinherited

Return the type of the tool.

Returns
The type of the tool.

Definition at line 109 of file tool_base.h.

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

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:285

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(), SCH_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::DeleteItems(), PL_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), SELECTION_TOOL::doSelectionMenu(), COMMON_TOOLS::doZoomFit(), COMMON_TOOLS::doZoomInOut(), COMMON_TOOLS::doZoomToPreset(), EDIT_TOOL::DragArcTrack(), DRAWING_TOOL::drawArc(), DRAWING_TOOL::DrawDimension(), MICROWAVE_TOOL::drawMicrowaveInductor(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::drawShape(), DRAWING_TOOL::DrawZone(), BOARD_EDITOR_CONTROL::DrillOrigin(), SYMBOL_EDITOR_EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EE_SELECTION_TOOL::GetNode(), ROUTER_TOOL::getStartLayer(), PCB_CONTROL::GridResetOrigin(), PCB_CONTROL::GridSetOrigin(), EE_SELECTION_TOOL::GuessSelectionCandidates(), PCB_SELECTION_TOOL::GuessSelectionCandidates(), ROUTER_TOOL::handleCommonEvents(), EE_SELECTION_TOOL::highlight(), PL_SELECTION_TOOL::highlight(), PCB_SELECTION_TOOL::highlight(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::highlightNet(), PNS::TOOL_BASE::highlightNets(), PCB_SELECTION_TOOL::hitTestDistance(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), ROUTER_TOOL::InlineDrag(), EE_POINT_EDITOR::Main(), SCH_MOVE_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), EDIT_TOOL::MoveExact(), PL_EDIT_TOOL::moveItem(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), COMMON_TOOLS::PanControl(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::Paste(), ROUTER_TOOL::performRouting(), PNS::TOOL_BASE::pickSingleItem(), BOARD_EDITOR_CONTROL::PlaceFootprint(), DRAWING_TOOL::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), ROUTER_TOOL::prepareInteractive(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), EE_SELECTION_TOOL::Reset(), EE_TOOL_BASE< T >::Reset(), GERBVIEW_SELECTION_TOOL::Reset(), PNS::TOOL_BASE::Reset(), BOARD_EDITOR_CONTROL::Reset(), DRAWING_TOOL::Reset(), PCB_CONTROL::Reset(), PCB_SELECTION_TOOL::Reset(), SCH_EDIT_TOOL::Rotate(), GERBVIEW_SELECTION_TOOL::select(), PCB_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectAll(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::selectionContains(), PCB_SELECTION_TOOL::selectionContains(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::SelectPoint(), EE_SELECTION_TOOL::selectPoint(), ZOOM_TOOL::selectRegion(), GERBVIEW_SELECTION_TOOL::selectVisually(), DRAWING_TOOL::SetAnchor(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_EDITOR_CONTROL::ToggleERCErrors(), SCH_EDITOR_CONTROL::ToggleERCExclusions(), SCH_EDITOR_CONTROL::ToggleERCWarnings(), SCH_EDITOR_CONTROL::ToggleHiddenFields(), SCH_EDITOR_CONTROL::ToggleHiddenPins(), SCH_EDITOR_CONTROL::ToggleOPCurrents(), SCH_EDITOR_CONTROL::ToggleOPVoltages(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), EE_SELECTION_TOOL::unhighlight(), PL_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_FIND_REPLACE_TOOL::UpdateFind(), PL_POINT_EDITOR::updateItem(), PCB_POINT_EDITOR::updateItem(), EE_TOOL_BASE< T >::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_SELECTION_TOOL::view(), PCB_TOOL_BASE::view(), PCB_VIEWER_TOOLS::view(), EE_SELECTION_TOOL::ZoomFitCrossProbeBBox(), PCB_SELECTION_TOOL::ZoomFitCrossProbeBBox(), 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}
KIGFX::VIEW_CONTROLS * GetViewControls() const
Definition: tool_manager.h:287

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

Referenced by EE_POINT_EDITOR::addCorner(), PCB_POINT_EDITOR::addCorner(), EE_POINT_EDITOR::addCornerCondition(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::BreakWire(), PCB_SELECTION_TOOL::controls(), PCB_TOOL_BASE::controls(), EDIT_TOOL::copyToClipboard(), COMMON_TOOLS::CursorControl(), EDIT_TOOL::DeleteItems(), 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(), SCH_DRAWING_TOOLS::DrawShape(), 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_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), SCH_EDIT_TOOL::Init(), EDIT_TOOL::Init(), EE_POINT_EDITOR::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), PICKER_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_POINT_EDITOR::Main(), PCB_PICKER_TOOL::Main(), ROUTER_TOOL::MainLoop(), GERBVIEW_INSPECTION_TOOL::MeasureTool(), PCB_VIEWER_TOOLS::MeasureTool(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SCH_EDITOR_CONTROL::Paste(), 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(), DRAWING_TOOL::PlaceImage(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), SCH_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), SCH_EDIT_TOOL::RepeatDrawItem(), PL_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), DRAWING_TOOL::Reset(), PCB_POINT_EDITOR::Reset(), COMMON_TOOLS::ResetLocalCoords(), ROUTER_TOOL::RouteSelected(), PCB_SELECTION_TOOL::selectCursor(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), EE_SELECTION_TOOL::SelectNode(), ZOOM_TOOL::selectRegion(), ALIGN_DISTRIBUTE_TOOL::selectTarget(), PICKER_TOOL::setControls(), PCB_PICKER_TOOL::setControls(), EE_POINT_EDITOR::setEditedPoint(), PL_POINT_EDITOR::setEditedPoint(), PCB_POINT_EDITOR::setEditedPoint(), SCH_DRAWING_TOOLS::SingleClickPlace(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_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}
void goInternal(TOOL_STATE_FUNC &aState, const TOOL_EVENT_LIST &aConditions)
std::function< int(const TOOL_EVENT &)> TOOL_STATE_FUNC
Definition: tool_base.h:58

References TOOL_INTERACTIVE::goInternal().

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

◆ goInternal()

void TOOL_INTERACTIVE::goInternal ( TOOL_STATE_FUNC aState,
const TOOL_EVENT_LIST aConditions 
)
privateinherited

Definition at line 70 of file tool_interactive.cpp.

71{
72 m_toolMgr->ScheduleNextState( this, aState, aConditions );
73}
void ScheduleNextState(TOOL_BASE *aTool, TOOL_STATE_FUNC &aHandler, const TOOL_EVENT_LIST &aConditions)
Define a state transition.

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

Referenced by TOOL_INTERACTIVE::Go().

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

228{
230 m_frame = getEditFrame<PCB_BASE_FRAME>();
231
232 // Create a context menu and make it available through selection tool
233 m_menu = new CONDITIONAL_MENU( this );
235 m_menu->SetTitle( _( "Create from Selection" ) );
236
240 && P_S_C::SameLayer();
241
243
244 auto anyTracks = S_C::MoreThan( 0 ) && S_C::OnlyTypes( { PCB_TRACE_T, PCB_ARC_T, PCB_VIA_T } )
245 && P_S_C::SameLayer();
246
247 auto anyPolys = S_C::OnlyTypes( { PCB_ZONE_T, PCB_FP_ZONE_T,
249
250 auto canCreateArcs = S_C::Count( 1 )
252 auto canCreateArray = S_C::MoreThan( 0 );
253 auto canCreatePolyType = graphicLines || anyPolys || anyTracks;
254 auto canCreateLines = anyPolys;
255 auto canCreateTracks = anyPolys || graphicToTrack;
256 auto canCreate = canCreatePolyType
257 || canCreateLines
258 || canCreateTracks
259 || canCreateArcs
260 || canCreateArray;
261
262 m_menu->AddItem( PCB_ACTIONS::convertToPoly, canCreatePolyType );
263 m_menu->AddItem( PCB_ACTIONS::convertToZone, canCreatePolyType );
264 m_menu->AddItem( PCB_ACTIONS::convertToKeepout, canCreatePolyType );
265 m_menu->AddItem( PCB_ACTIONS::convertToLines, canCreateLines );
266 m_menu->AppendSeparator();
267
268 // Currently the code exists, but tracks are not really existing in footprints
269 // only segments on copper layers
271 m_menu->AddItem( PCB_ACTIONS::convertToTracks, canCreateTracks );
272
273 m_menu->AddItem( PCB_ACTIONS::convertToArc, canCreateArcs );
274
275 m_menu->AppendSeparator();
276 m_menu->AddItem( PCB_ACTIONS::createArray, canCreateArray );
277
279 selToolMenu.AddMenu( m_menu, canCreate, 100 );
280
281 return true;
282}
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:73
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.
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 convertToZone
Definition: pcb_actions.h:521
static TOOL_ACTION convertToArc
Definition: pcb_actions.h:524
static TOOL_ACTION createArray
Tool for creating an array of objects.
Definition: pcb_actions.h:435
static SELECTION_CONDITION SameLayer()
Creates a functor that tests if selection contains items that belong exclusively to the same layer.
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 Count(int aNumber)
Create a functor that tests if the number of selected items is equal to the value given as parameter.
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
TOOL_MENU & GetToolMenu()
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_SHAPE_LOCATE_CIRCLE_T
Definition: typeinfo.h:133
@ PCB_SHAPE_LOCATE_SEGMENT_T
Definition: typeinfo.h:131
@ PCB_SHAPE_LOCATE_RECT_T
Definition: typeinfo.h:132
@ PCB_SHAPE_LOCATE_BEZIER_T
Definition: typeinfo.h:136
@ PCB_SHAPE_LOCATE_POLY_T
Definition: typeinfo.h:135
@ PCB_SHAPE_LOCATE_ARC_T
Definition: typeinfo.h:134

References _, CONDITIONAL_MENU::AddItem(), CONDITIONAL_MENU::AddMenu(), convert, PCB_ACTIONS::convertToArc, PCB_ACTIONS::convertToKeepout, PCB_ACTIONS::convertToLines, PCB_ACTIONS::convertToPoly, PCB_ACTIONS::convertToTracks, PCB_ACTIONS::convertToZone, SELECTION_CONDITIONS::Count(), PCB_ACTIONS::createArray, 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(), SELECTION_CONDITIONS::OnlyTypes(), PCB_ARC_T, PCB_FP_ZONE_T, PCB_SHAPE_LOCATE_ARC_T, PCB_SHAPE_LOCATE_BEZIER_T, PCB_SHAPE_LOCATE_CIRCLE_T, PCB_SHAPE_LOCATE_POLY_T, PCB_SHAPE_LOCATE_RECT_T, PCB_SHAPE_LOCATE_SEGMENT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, PCB_SELECTION_CONDITIONS::SameLayer(), ACTION_MENU::SetIcon(), and ACTION_MENU::SetTitle().

◆ IsToolActive()

bool TOOL_BASE::IsToolActive ( ) const
inherited

Definition at line 31 of file tool_base.cpp.

32{
34}
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(), PCB_SELECTION_TOOL::Main(), BOARD_EDITOR_CONTROL::TrackWidthDec(), and BOARD_EDITOR_CONTROL::TrackWidthInc().

◆ makePolysFromChainedSegs()

SHAPE_POLY_SET CONVERT_TOOL::makePolysFromChainedSegs ( const std::deque< EDA_ITEM * > &  aItems,
CONVERT_STRATEGY  aStrategy 
)
private

Try to make polygons from chained 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 492 of file convert_tool.cpp.

494{
495 // TODO: This code has a somewhat-similar purpose to ConvertOutlineToPolygon but is slightly
496 // different, so this remains a separate algorithm. It might be nice to analyze the dfiferences
497 // in requirements and refactor this.
498
499 // Using a large epsilon here to allow for sloppy drawing can cause the algorithm to miss very
500 // short segments in a converted bezier. So use an epsilon only large enough to cover for
501 // rouding errors in the conversion.
502 int chainingEpsilon = 100; // max dist from one endPt to next startPt in IU
503
505 SHAPE_POLY_SET poly;
506
507 // Stores pairs of (anchor, item) where anchor == 0 -> SEG.A, anchor == 1 -> SEG.B
508 std::map<VECTOR2I, std::vector<std::pair<int, EDA_ITEM*>>> connections;
509 std::deque<EDA_ITEM*> toCheck;
510
511 auto closeEnough =
512 []( VECTOR2I aLeft, VECTOR2I aRight, int aLimit )
513 {
514 return ( aLeft - aRight ).SquaredEuclideanNorm() <= SEG::Square( aLimit );
515 };
516
517 auto findInsertionPoint =
518 [&]( VECTOR2I aPoint ) -> VECTOR2I
519 {
520 if( connections.count( aPoint ) )
521 return aPoint;
522
523 for( const auto& candidatePair : connections )
524 {
525 if( closeEnough( aPoint, candidatePair.first, chainingEpsilon ) )
526 return candidatePair.first;
527 }
528
529 return aPoint;
530 };
531
532 for( EDA_ITEM* item : aItems )
533 {
534 if( std::optional<SEG> seg = getStartEndPoints( item ) )
535 {
536 toCheck.push_back( item );
537 connections[findInsertionPoint( seg->A )].emplace_back( std::make_pair( 0, item ) );
538 connections[findInsertionPoint( seg->B )].emplace_back( std::make_pair( 1, item ) );
539 }
540 }
541
542 while( !toCheck.empty() )
543 {
544 std::vector<BOARD_ITEM*> insertedItems;
545
546 EDA_ITEM* candidate = toCheck.front();
547 toCheck.pop_front();
548
549 if( candidate->GetFlags() & SKIP_STRUCT )
550 continue;
551
552 SHAPE_LINE_CHAIN outline;
553
554 auto insert =
555 [&]( EDA_ITEM* aItem, VECTOR2I aAnchor, bool aDirection )
556 {
557 if( aItem->Type() == PCB_ARC_T
558 || ( ( aItem->Type() == PCB_SHAPE_T || aItem->Type() == PCB_FP_SHAPE_T )
559 && static_cast<PCB_SHAPE*>( aItem )->GetShape() == SHAPE_T::ARC ) )
560 {
561 SHAPE_ARC arc;
562
563 if( aItem->Type() == PCB_ARC_T )
564 {
565 PCB_ARC* pcb_arc = static_cast<PCB_ARC*>( aItem );
566 arc = *static_cast<SHAPE_ARC*>( pcb_arc->GetEffectiveShape().get() );
567 }
568 else
569 {
570 PCB_SHAPE* pcb_shape = static_cast<PCB_SHAPE*>( aItem );
571 arc = SHAPE_ARC( pcb_shape->GetStart(), pcb_shape->GetArcMid(),
572 pcb_shape->GetEnd(), pcb_shape->GetWidth() );
573 }
574
575 if( aDirection )
576 outline.Append( aAnchor == arc.GetP0() ? arc : arc.Reversed() );
577 else
578 outline.Insert( 0, aAnchor == arc.GetP0() ? arc : arc.Reversed() );
579
580 insertedItems.push_back( static_cast<BOARD_ITEM*>( aItem ) );
581 }
582 else if( aItem->IsType( { PCB_SHAPE_LOCATE_BEZIER_T } ) )
583 {
584 PCB_SHAPE* graphic = static_cast<PCB_SHAPE*>( aItem );
585
586 if( aAnchor == graphic->GetStart() )
587 {
588 for( auto it = graphic->GetBezierPoints().begin();
589 it != graphic->GetBezierPoints().end();
590 ++it )
591 {
592 if( aDirection )
593 outline.Append( *it );
594 else
595 outline.Insert( 0, *it );
596 }
597
598 }
599 else
600 {
601 for( auto it = graphic->GetBezierPoints().rbegin();
602 it != graphic->GetBezierPoints().rend();
603 ++it )
604 {
605 if( aDirection )
606 outline.Append( *it );
607 else
608 outline.Insert( 0, *it );
609 }
610 }
611
612 insertedItems.push_back( static_cast<BOARD_ITEM*>( aItem ) );
613 }
614 else if( std::optional<SEG> nextSeg = getStartEndPoints( aItem ) )
615 {
616 VECTOR2I& point = ( aAnchor == nextSeg->A ) ? nextSeg->B : nextSeg->A;
617
618 if( aDirection )
619 outline.Append( point );
620 else
621 outline.Insert( 0, point );
622
623 insertedItems.push_back( static_cast<BOARD_ITEM*>( aItem ) );
624 }
625 };
626
627 // aDirection == true for walking "right" and appending to the end of points
628 // false for walking "left" and prepending to the beginning
629 std::function<void( EDA_ITEM*, VECTOR2I, bool )> process =
630 [&]( EDA_ITEM* aItem, VECTOR2I aAnchor, bool aDirection )
631 {
632 if( aItem->GetFlags() & SKIP_STRUCT )
633 return;
634
635 aItem->SetFlags( SKIP_STRUCT );
636
637 insert( aItem, aAnchor, aDirection );
638
639 std::optional<SEG> anchors = getStartEndPoints( aItem );
640 wxASSERT( anchors );
641
642 VECTOR2I nextAnchor = ( aAnchor == anchors->A ) ? anchors->B : anchors->A;
643
644 for( std::pair<int, EDA_ITEM*> pair : connections[nextAnchor] )
645 {
646 if( pair.second == aItem )
647 continue;
648
649 process( pair.second, nextAnchor, aDirection );
650 }
651 };
652
653 std::optional<SEG> anchors = getStartEndPoints( candidate );
654 wxASSERT( anchors );
655
656 // Start with the first object and walk "right"
657 // Note if the first object is an arc, we don't need to insert its first point here, the
658 // whole arc will be inserted at anchor B inside process()
659 if( !( candidate->Type() == PCB_ARC_T
660 || ( ( candidate->Type() == PCB_SHAPE_T || candidate->Type() == PCB_FP_SHAPE_T )
661 && static_cast<PCB_SHAPE*>( candidate )->GetShape() == SHAPE_T::ARC ) ) )
662 {
663 insert( candidate, anchors->A, true );
664 }
665
666 process( candidate, anchors->B, true );
667
668 // check for any candidates on the "left"
669 EDA_ITEM* left = nullptr;
670
671 for( std::pair<int, EDA_ITEM*> possibleLeft : connections[anchors->A] )
672 {
673 if( possibleLeft.second != candidate )
674 {
675 left = possibleLeft.second;
676 break;
677 }
678 }
679
680 if( left )
681 process( left, anchors->A, false );
682
683 if( outline.PointCount() < 3
684 || !closeEnough( outline.GetPoint( 0 ), outline.GetPoint( -1 ), chainingEpsilon ) )
685 {
686 for( EDA_ITEM* item : insertedItems )
687 item->ClearFlags( SKIP_STRUCT );
688
689 continue;
690 }
691
692 outline.SetClosed( true );
693
694 poly.AddOutline( outline );
695
696 if( aStrategy == BOUNDING_HULL )
697 {
698 for( BOARD_ITEM* item : insertedItems )
699 {
700 item->TransformShapeToPolygon( poly, UNDEFINED_LAYER, 0, bds.m_MaxError,
701 ERROR_INSIDE, false );
702 }
703 }
704
705 insertedItems.clear();
706 }
707
708 return poly;
709}
static std::optional< SEG > getStartEndPoints(EDA_ITEM *aItem)
Retrieve the start and end points for a generic item.
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:139
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
Definition: eda_item.h:181
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:142
const std::vector< VECTOR2I > & GetBezierPoints() const
Definition: eda_shape.h:230
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
Definition: pcb_track.cpp:1206
static SEG::ecoord Square(int a)
Definition: seg.h:123
SHAPE_ARC Reversed() const
Definition: shape_arc.cpp:587
const VECTOR2I & GetP0() const
Definition: shape_arc.h:112
virtual const VECTOR2I GetPoint(int aIndex) const override
int PointCount() const
Return the number of points (vertices) in this line chain.
void Insert(size_t aVertex, const VECTOR2I &aP)
@ ERROR_INSIDE
void process(const BOARD_CONNECTED_ITEM *item, int net)

References SHAPE_POLY_SET::AddOutline(), SHAPE_LINE_CHAIN::Append(), ARC, BOUNDING_HULL, ERROR_INSIDE, EDA_SHAPE::GetArcMid(), EDA_SHAPE::GetBezierPoints(), PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), PCB_ARC::GetEffectiveShape(), EDA_SHAPE::GetEnd(), EDA_ITEM::GetFlags(), SHAPE_ARC::GetP0(), SHAPE_LINE_CHAIN::GetPoint(), EDA_SHAPE::GetShape(), EDA_SHAPE::GetStart(), getStartEndPoints(), EDA_SHAPE::GetWidth(), SHAPE_LINE_CHAIN::Insert(), EDA_ITEM::IsType(), left, m_frame, BOARD_DESIGN_SETTINGS::m_MaxError, PCB_ARC_T, PCB_FP_SHAPE_T, PCB_SHAPE_T, SHAPE_LINE_CHAIN::PointCount(), process(), SHAPE_ARC::Reversed(), SHAPE_LINE_CHAIN::SetClosed(), EDA_ITEM::SetFlags(), SKIP_STRUCT, SEG::Square(), EDA_ITEM::Type(), and UNDEFINED_LAYER.

Referenced by CreatePolys().

◆ makePolysFromClosedGraphics()

SHAPE_POLY_SET CONVERT_TOOL::makePolysFromClosedGraphics ( const std::deque< EDA_ITEM * > &  aItems,
CONVERT_STRATEGY  aStrategy 
)
private

Definition at line 762 of file convert_tool.cpp.

764{
766 SHAPE_POLY_SET poly;
767
768 for( EDA_ITEM* item : aItems )
769 {
770 if( item->GetFlags() & SKIP_STRUCT )
771 continue;
772
773 switch( item->Type() )
774 {
775 case PCB_SHAPE_T:
776 case PCB_FP_SHAPE_T:
777 {
778 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
779 FILL_T wasFilled = shape->GetFillMode();
780
781 if( !shape->IsClosed() )
782 continue;
783
784 shape->SetFilled( true );
786 aStrategy == COPY_LINEWIDTH || aStrategy == CENTERLINE );
787 shape->SetFillMode( wasFilled );
788 shape->SetFlags( SKIP_STRUCT );
789
790 break;
791 }
792
793 case PCB_ZONE_T:
794 case PCB_FP_ZONE_T:
795 poly.Append( *static_cast<ZONE*>( item )->Outline() );
796 item->SetFlags( SKIP_STRUCT );
797 break;
798
799 default:
800 continue;
801 }
802 }
803
804 return poly;
805}
FILL_T GetFillMode() const
Definition: eda_shape.h:101
void SetFilled(bool aFlag)
Definition: eda_shape.h:95
bool IsClosed() const
Definition: eda_shape.cpp:141
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:100
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
Definition: pcb_shape.cpp:390
FILL_T
Definition: eda_shape.h:54

References SHAPE_POLY_SET::Append(), CENTERLINE, COPY_LINEWIDTH, ERROR_INSIDE, PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), EDA_SHAPE::GetFillMode(), EDA_SHAPE::IsClosed(), m_frame, BOARD_DESIGN_SETTINGS::m_MaxError, ZONE::Outline(), PCB_FP_SHAPE_T, PCB_FP_ZONE_T, PCB_SHAPE_T, PCB_ZONE_T, EDA_SHAPE::SetFilled(), EDA_SHAPE::SetFillMode(), EDA_ITEM::SetFlags(), SKIP_STRUCT, PCB_SHAPE::TransformShapeToPolygon(), and UNDEFINED_LAYER.

Referenced by CreatePolys().

◆ makePolysFromOpenGraphics()

SHAPE_POLY_SET CONVERT_TOOL::makePolysFromOpenGraphics ( const std::deque< EDA_ITEM * > &  aItems,
int  aGap 
)
private

Make polygons from graphic shapes and zones.

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

Definition at line 712 of file convert_tool.cpp.

714{
716 SHAPE_POLY_SET poly;
717
718 for( EDA_ITEM* item : aItems )
719 {
720 if( item->GetFlags() & SKIP_STRUCT )
721 continue;
722
723 switch( item->Type() )
724 {
725 case PCB_SHAPE_T:
726 case PCB_FP_SHAPE_T:
727 {
728 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
729
730 if( shape->IsClosed() )
731 continue;
732
733 shape->TransformShapeToPolygon( poly, UNDEFINED_LAYER, aGap, bds.m_MaxError,
734 ERROR_INSIDE, false );
735 shape->SetFlags( SKIP_STRUCT );
736
737 break;
738 }
739
740 case PCB_TRACE_T:
741 case PCB_ARC_T:
742 case PCB_VIA_T:
743 {
744 PCB_TRACK* track = static_cast<PCB_TRACK*>( item );
745
746 track->TransformShapeToPolygon( poly, UNDEFINED_LAYER, aGap, bds.m_MaxError,
747 ERROR_INSIDE, false );
748 track->SetFlags( SKIP_STRUCT );
749
750 break;
751 }
752
753 default:
754 continue;
755 }
756 }
757
758 return poly;
759}
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Function TransformShapeToPolygon Convert the track shape to a closed polygon Used in filling zones ca...
Definition: pcb_track.cpp:1212

References ERROR_INSIDE, PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), EDA_SHAPE::IsClosed(), m_frame, BOARD_DESIGN_SETTINGS::m_MaxError, PCB_ARC_T, PCB_FP_SHAPE_T, PCB_SHAPE_T, PCB_TRACE_T, PCB_VIA_T, EDA_ITEM::SetFlags(), SKIP_STRUCT, PCB_SHAPE::TransformShapeToPolygon(), PCB_TRACK::TransformShapeToPolygon(), and UNDEFINED_LAYER.

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 44 of file convert_tool.h.

44{}

◆ resetTransitions()

void TOOL_INTERACTIVE::resetTransitions ( )
privateinherited

Clear the current transition map and restores the default one created by setTransitions().

Definition at line 63 of file tool_interactive.cpp.

64{
67}
virtual void setTransitions()=0
This method is meant to be overridden in order to specify handlers for events.
void ClearTransitions(TOOL_BASE *aTool)
Clear the state transition map for a tool.

References TOOL_MANAGER::ClearTransitions(), TOOL_BASE::m_toolMgr, and TOOL_INTERACTIVE::setTransitions().

◆ 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}
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 1047 of file convert_tool.cpp.

1048{
1049 auto& selection = m_selectionTool->RequestSelection(
1050 []( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, PCB_SELECTION_TOOL* sTool )
1051 {
1052 for( int i = aCollector.GetCount() - 1; i >= 0; --i )
1053 {
1054 BOARD_ITEM* item = aCollector[i];
1055
1056 if( !( item->Type() == PCB_SHAPE_T ||
1057 item->Type() == PCB_TRACE_T ||
1058 item->Type() == PCB_FP_SHAPE_T ) )
1059 {
1060 aCollector.Remove( item );
1061 }
1062 }
1063 } );
1064
1065 EDA_ITEM* source = selection.Front();
1066 VECTOR2I start, end, mid;
1067
1068 // Offset the midpoint along the normal a little bit so that it's more obviously an arc
1069 const double offsetRatio = 0.1;
1070
1071 if( std::optional<SEG> seg = getStartEndPoints( source ) )
1072 {
1073 start = seg->A;
1074 end = seg->B;
1075
1076 VECTOR2I normal = ( seg->B - seg->A ).Perpendicular().Resize( offsetRatio * seg->Length() );
1077 mid = seg->Center() + normal;
1078 }
1079 else
1080 {
1081 return -1;
1082 }
1083
1084 PCB_BASE_EDIT_FRAME* frame = getEditFrame<PCB_BASE_EDIT_FRAME>();
1085 BOARD_ITEM_CONTAINER* parent = frame->GetModel();
1086
1087 BOARD_ITEM* boardItem = dynamic_cast<BOARD_ITEM*>( source );
1088
1089 // Don't continue processing if we don't actually have a board item
1090 if( !boardItem )
1091 return 0;
1092
1093 PCB_LAYER_ID layer = boardItem->GetLayer();
1094
1095 BOARD_COMMIT commit( m_frame );
1096
1097 if( source->Type() == PCB_SHAPE_T || source->Type() == PCB_FP_SHAPE_T )
1098 {
1099 PCB_SHAPE* line = static_cast<PCB_SHAPE*>( source );
1100 PCB_SHAPE* arc = new PCB_SHAPE( parent, SHAPE_T::ARC );
1101
1102 VECTOR2I center = CalcArcCenter( start, mid, end );
1103
1104 arc->SetFilled( false );
1105 arc->SetLayer( layer );
1106 arc->SetStroke( line->GetStroke() );
1107
1108 arc->SetCenter( VECTOR2I( center ) );
1109 arc->SetStart( VECTOR2I( start ) );
1110 arc->SetEnd( VECTOR2I( end ) );
1111
1112 commit.Add( arc );
1113 }
1114 else
1115 {
1116 wxASSERT( source->Type() == PCB_TRACE_T );
1117 PCB_TRACK* line = static_cast<PCB_TRACK*>( source );
1118 PCB_ARC* arc = new PCB_ARC( parent );
1119
1120 arc->SetLayer( layer );
1121 arc->SetWidth( line->GetWidth() );
1122 arc->SetStart( VECTOR2I( start ) );
1123 arc->SetMid( VECTOR2I( mid ) );
1124 arc->SetEnd( VECTOR2I( end ) );
1125
1126 commit.Add( arc );
1127 }
1128
1129 commit.Push( _( "Create arc from line segment" ) );
1130
1131 return 0;
1132}
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:192
void SetCenter(const VECTOR2I &aCenter)
Definition: eda_shape.cpp:470
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:71
int GetWidth() const
Definition: pcb_track.h:108
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:458

References COLLECTOR::GetCount(), m_selectionTool, and PCB_SELECTION_TOOL::RequestSelection().

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}
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.
@ CMENU_OFF
Definition: tool_event.h:149

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

Referenced by 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 1179 of file convert_tool.cpp.

1180{
1187}
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.
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).

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

Member Data Documentation

◆ m_frame

PCB_BASE_FRAME* CONVERT_TOOL::m_frame
private

◆ m_menu

CONDITIONAL_MENU* CONVERT_TOOL::m_menu
private

Definition at line 101 of file convert_tool.h.

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

◆ m_selectionTool

PCB_SELECTION_TOOL* CONVERT_TOOL::m_selectionTool
private

Definition at line 100 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 210 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 215 of file tool_base.h.

Referenced by TOOL_INTERACTIVE::Activate(), SELECTION_TOOL::AddItemsToSel(), SELECTION_TOOL::AddItemToSel(), SCH_MOVE_TOOL::AlignElements(), SCH_EDITOR_CONTROL::AssignNetclass(), BOARD_EDITOR_CONTROL::AssignNetclass(), CVPCB_ASSOCIATION_TOOL::Associate(), TOOL_BASE::attachManager(), SCH_EDIT_TOOL::AutoplaceFields(), EE_SELECTION_TOOL::autostartEvent(), SCH_EDIT_TOOL::BreakWire(), BOARD_INSPECTION_TOOL::calculateSelectionRatsnest(), ROUTER_TOOL::CanInlineDrag(), SCH_EDITOR_CONTROL::ChangeLineMode(), SCH_EDIT_TOOL::ChangeTextType(), EDIT_TOOL::ChangeTrackWidth(), SCH_EDIT_TOOL::CleanupSheetPins(), GERBVIEW_CONTROL::ClearAllLayers(), SCH_EDITOR_CONTROL::ClearHighlight(), BOARD_INSPECTION_TOOL::ClearHighlight(), GERBVIEW_SELECTION_TOOL::clearSelection(), PL_SELECTION_TOOL::ClearSelection(), EE_SELECTION_TOOL::ClearSelection(), PCB_SELECTION_TOOL::ClearSelection(), SCH_EDIT_TOOL::ConvertDeMorgan(), SYMBOL_EDITOR_EDIT_TOOL::Copy(), PL_EDIT_TOOL::Copy(), PAD_TOOL::copyPadSettings(), EDIT_TOOL::copyToClipboard(), EDIT_TOOL::CreateArray(), MICROWAVE_TOOL::createInductorBetween(), EE_INSPECTION_TOOL::CrossProbe(), DRC_TOOL::CrossProbe(), COMMON_TOOLS::CursorControl(), SCH_EDITOR_CONTROL::Cut(), SCH_EDIT_TOOL::DeleteItemCursor(), SYMBOL_EDITOR_EDIT_TOOL::DeleteItemCursor(), PL_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), EDIT_TOOL::DeleteItems(), SCH_EDITOR_CONTROL::doCopy(), BOARD_EDITOR_CONTROL::doCrossProbePcbToSch(), SCH_EDITOR_CONTROL::doCrossProbeSchToPcb(), SCH_EDIT_TOOL::DoDelete(), SYMBOL_EDITOR_EDIT_TOOL::DoDelete(), SCH_LINE_WIRE_BUS_TOOL::doDrawSegments(), BOARD_INSPECTION_TOOL::doHideRatsnestNet(), PCB_TOOL_BASE::doInteractiveItemPlacement(), EDIT_TOOL::doMoveSelection(), PCB_SELECTION_TOOL::doSyncSelection(), 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(), SCH_LINE_WIRE_BUS_TOOL::DrawSegments(), SCH_DRAWING_TOOLS::DrawShape(), SYMBOL_EDITOR_DRAWING_TOOLS::DrawShape(), PL_DRAWING_TOOLS::DrawShape(), DRAWING_TOOL::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(), PCB_SELECTION_TOOL::EnterGroup(), GROUP_TOOL::EnterGroup(), SCH_NAVIGATE_TOOL::EnterSheet(), PAD_TOOL::EnumeratePads(), EE_INSPECTION_TOOL::ExcludeMarker(), PCB_SELECTION_TOOL::ExitGroup(), 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(), PCB_SELECTION_TOOL::grabUnconnected(), COMMON_TOOLS::GridNext(), COMMON_TOOLS::GridPreset(), COMMON_TOOLS::GridPrev(), PCB_CONTROL::GridSetOrigin(), GROUP_TOOL::Group(), GERBVIEW_CONTROL::HighlightControl(), BOARD_INSPECTION_TOOL::HighlightItem(), SCH_EDITOR_CONTROL::HighlightNet(), BOARD_INSPECTION_TOOL::HighlightNet(), BOARD_INSPECTION_TOOL::highlightNet(), SCH_EDITOR_CONTROL::HighlightNetCursor(), PL_EDIT_TOOL::ImportDrawingSheetContent(), FOOTPRINT_EDITOR_CONTROL::ImportFootprint(), EE_TOOL_BASE< T >::Init(), SCH_EDIT_TOOL::Init(), SYMBOL_EDITOR_CONTROL::Init(), SYMBOL_EDITOR_EDIT_TOOL::Init(), PL_DRAWING_TOOLS::Init(), PL_EDIT_TOOL::Init(), PL_POINT_EDITOR::Init(), ROUTER_TOOL::Init(), BOARD_EDITOR_CONTROL::Init(), BOARD_INSPECTION_TOOL::Init(), BOARD_REANNOTATE_TOOL::Init(), Init(), DRAWING_TOOL::Init(), EDIT_TOOL::Init(), GLOBAL_EDIT_TOOL::Init(), GROUP_TOOL::Init(), PAD_TOOL::Init(), PCB_POINT_EDITOR::Init(), PCB_SELECTION_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), POSITION_RELATIVE_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(), BOARD_INSPECTION_TOOL::LocalRatsnestTool(), EDA_3D_CONTROLLER::Main(), CVPCB_CONTROL::Main(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::Main(), EE_SELECTION_TOOL::Main(), SCH_MOVE_TOOL::Main(), SYMBOL_EDITOR_MOVE_TOOL::Main(), GERBVIEW_SELECTION_TOOL::Main(), PL_EDIT_TOOL::Main(), PL_SELECTION_TOOL::Main(), PCB_PICKER_TOOL::Main(), PCB_SELECTION_TOOL::Main(), LENGTH_TUNER_TOOL::MainLoop(), ROUTER_TOOL::MainLoop(), PCB_VIEWER_TOOLS::MeasureTool(), SCH_EDIT_TOOL::Mirror(), SYMBOL_EDITOR_EDIT_TOOL::Mirror(), EDIT_TOOL::Mirror(), BOARD_EDITOR_CONTROL::modifyLockSelected(), EDIT_TOOL::MoveExact(), SCH_EDITOR_CONTROL::NextLineMode(), SYMBOL_EDITOR_CONTROL::OnDeMorgan(), SELECTION_TOOL::onDisambiguationExpire(), COMMON_TOOLS::OnGridChanged(), PCB_POINT_EDITOR::OnSelectionChange(), SCH_EDITOR_CONTROL::Paste(), SYMBOL_EDITOR_EDIT_TOOL::Paste(), PL_EDIT_TOOL::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::PlaceImage(), DRAWING_TOOL::PlaceImportedGraphics(), PL_DRAWING_TOOLS::PlaceItem(), SCH_DRAWING_TOOLS::PlaceSymbol(), DRAWING_TOOL::PlaceText(), GERBVIEW_CONTROL::Print(), PCB_CONTROL::Print(), SCH_EDIT_TOOL::Properties(), SYMBOL_EDITOR_EDIT_TOOL::Properties(), EDIT_TOOL::Properties(), PAD_TOOL::pushPadSettings(), EDIT_TOOL::rebuildConnectivity(), ZONE_FILLER_TOOL::rebuildConnectivity(), EE_SELECTION_TOOL::RebuildSelection(), PAD_TOOL::RecombinePad(), SCH_EDITOR_CONTROL::Redo(), SYMBOL_EDITOR_EDIT_TOOL::Redo(), POSITION_RELATIVE_TOOL::RelativeItemSelectionMove(), EDIT_TOOL::Remove(), PCB_POINT_EDITOR::removeCorner(), GROUP_TOOL::RemoveFromGroup(), SELECTION_TOOL::RemoveItemFromSel(), SELECTION_TOOL::RemoveItemsFromSel(), SCH_EDIT_TOOL::RepeatDrawItem(), SYMBOL_EDITOR_DRAWING_TOOLS::RepeatDrawItem(), PCB_SELECTION_TOOL::RequestSelection(), EE_SELECTION_TOOL::RequestSelection(), EDA_3D_CONTROLLER::Reset(), COMMON_TOOLS::Reset(), PNS::TOOL_BASE::Reset(), PAD_TOOL::Reset(), COMMON_TOOLS::ResetLocalCoords(), TOOL_INTERACTIVE::resetTransitions(), SCH_EDITOR_CONTROL::Revert(), SCH_EDIT_TOOL::Rotate(), SYMBOL_EDITOR_EDIT_TOOL::Rotate(), EDIT_TOOL::Rotate(), ROUTER_TOOL::RouteSelected(), TOOL_INTERACTIVE::RunMainStack(), DRC_TOOL::RunTests(), EE_SELECTION_TOOL::Selectable(), EE_SELECTION_TOOL::SelectAll(), PCB_SELECTION_TOOL::SelectAll(), EE_SELECTION_TOOL::SelectConnection(), PCB_TOOL_BASE::selection(), COMMON_TOOLS::SelectionTool(), GERBVIEW_SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), EE_SELECTION_TOOL::selectMultiple(), PL_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectMultiple(), PCB_SELECTION_TOOL::selectNet(), GERBVIEW_SELECTION_TOOL::selectPoint(), PL_SELECTION_TOOL::SelectPoint(), PCB_SELECTION_TOOL::selectPoint(), EE_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(), SCH_EDIT_TOOL::Swap(), EE_SELECTION_TOOL::SyncSelection(), COMMON_TOOLS::ToggleCursor(), COMMON_TOOLS::ToggleCursorStyle(), EDA_3D_CONTROLLER::ToggleVisibility(), BOARD_EDITOR_CONTROL::TrackWidthDec(), BOARD_EDITOR_CONTROL::TrackWidthInc(), SCH_MOVE_TOOL::trimDanglingLines(), SCH_DRAWING_TOOLS::TwoClickPlace(), SYMBOL_EDITOR_DRAWING_TOOLS::TwoClickPlace(), SCH_EDITOR_CONTROL::Undo(), SYMBOL_EDITOR_EDIT_TOOL::Undo(), GROUP_TOOL::Ungroup(), PCB_SELECTION_TOOL::unrouteSelected(), GERBVIEW_SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), PNS::TOOL_BASE::updateEndItem(), BOARD_INSPECTION_TOOL::UpdateLocalRatsnest(), EE_INSPECTION_TOOL::UpdateMessagePanel(), GERBVIEW_CONTROL::UpdateMessagePanel(), PL_EDITOR_CONTROL::UpdateMessagePanel(), PCB_CONTROL::UpdateMessagePanel(), EDIT_TOOL::updateModificationPoint(), EE_POINT_EDITOR::updateParentItem(), 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 214 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 207 of file tool_base.h.

Referenced by TOOL_BASE::GetType().

◆ m_userSettings

CONVERT_SETTINGS CONVERT_TOOL::m_userSettings
private

Definition at line 103 of file convert_tool.h.

Referenced by CONVERT_TOOL(), and CreatePolys().


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