59using namespace std::placeholders;
61#include <wx/hyperlink.h>
74 m_selectionTool( nullptr ),
84 m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
94 SetIcon( BITMAPS::special_tools );
109 auto positioningToolsSubMenu = std::make_shared<POSITIONING_TOOLS_MENU>(
this );
112 auto propertiesCondition =
115 if( aSel.GetSize() == 0 )
129 if( aSel.GetSize() == 1 )
141 auto inFootprintEditor =
162 auto noActiveToolCondition =
168 auto notMovingCondition =
176 auto noItemsCondition =
177 [ this ](
const SELECTION& aSelections ) ->
bool
194 static std::vector<KICAD_T> unroutableTypes = {
PCB_TRACE_T,
200 static std::vector<KICAD_T> trackTypes = {
PCB_TRACE_T,
213 && notMovingCondition );
216 && notMovingCondition
217 && !inFootprintEditor );
219 && notMovingCondition );
242 && !inFootprintEditor );
281 FOOTPRINT* fp = getEditFrame<PCB_BASE_FRAME>()->GetFootprintFromBoardByReference();
318 static_cast<intptr_t
>( aDragMode ) );
361 std::vector<PCB_TRACK*> tracks;
362 std::vector<PCB_TRACK*> vias;
366 if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item ) )
368 if( track->Type() == PCB_VIA_T )
369 vias.push_back( track );
371 tracks.push_back( track );
380 if( tracks.size() == 2 && vias.size() == 0 )
382 if( connected( tracks[0], tracks[1]->GetStart() )
383 || connected( tracks[0], tracks[1]->GetEnd() ) )
385 aCollector.
Remove( tracks[1] );
388 else if( tracks.size() == 2 && vias.size() == 1 )
390 if( connected( tracks[0], vias[0]->GetPosition() )
391 && connected( tracks[1], vias[0]->GetPosition() ) )
393 aCollector.
Remove( tracks[0] );
394 aCollector.
Remove( tracks[1] );
400 if( selection.Empty() )
403 if( selection.Size() == 1 && selection.Front()->Type() ==
PCB_ARC_T )
407 return DragArcTrack( aEvent );
411 invokeInlineRouter( mode );
430 wxString msg = wxString::Format(
_(
"Unable to resize arc tracks of %s or greater." ),
444 bool restore_state =
false;
455 tanStart.
A = *tanIntersect;
457 tanEnd.
A = *tanIntersect;
460 auto getUniqueTrackAtAnchorCollinear =
466 int allowedDeviation = theArc->
GetWidth();
468 std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
470 for(
int i = 0; i < 3; i++ )
472 itemsOnAnchor = conn->GetConnectedItemsAtAnchor( theArc, aAnchor,
476 allowedDeviation /= 2;
478 if( itemsOnAnchor.size() == 1 )
484 if( itemsOnAnchor.size() == 1 && itemsOnAnchor.front()->Type() ==
PCB_TRACE_T )
486 retval =
static_cast<PCB_TRACK*
>( itemsOnAnchor.front() );
490 if( trackSeg.
Angle( aCollinearSeg ) > maxTangentDeviation )
498 retval->
SetEnd( aAnchor );
510 PCB_TRACK* trackOnStart = getUniqueTrackAtAnchorCollinear( theArc->
GetStart(), tanStart);
511 PCB_TRACK* trackOnEnd = getUniqueTrackAtAnchorCollinear( theArc->
GetEnd(), tanEnd );
521 tanStart.
B = trackOnStart->
GetEnd();
527 tanEnd.
B = trackOnEnd->
GetEnd();
531 if( tanIntersect = tanStart.
IntersectLines( tanEnd ); !tanIntersect )
534 auto isTrackStartClosestToArcStart =
540 return trackStartToArcStart < trackEndToArcStart;
543 bool isStartTrackOnStartPt = isTrackStartClosestToArcStart( trackOnStart );
544 bool isEndTrackOnStartPt = isTrackStartClosestToArcStart( trackOnEnd );
573 auto getFurthestPointToTanInterstect =
576 if( ( aPointA - *tanIntersect ).EuclideanNorm()
588 VECTOR2I tanStartPoint = getFurthestPointToTanInterstect( tanStart.
A, tanStart.
B );
589 VECTOR2I tanEndPoint = getFurthestPointToTanInterstect( tanEnd.
A, tanEnd.
B );
590 VECTOR2I tempTangentPoint = tanEndPoint;
592 if( getFurthestPointToTanInterstect( tanStartPoint, tanEndPoint ) == tanEndPoint )
593 tempTangentPoint = tanStartPoint;
599 SEG cSegTanStart( maxTanPtStart, *tanIntersect );
600 SEG cSegTanEnd( maxTanPtEnd, *tanIntersect );
601 SEG cSegChord( maxTanPtStart, maxTanPtEnd );
603 int cSegTanStartSide = cSegTanStart.
Side( theArc->
GetMid() );
604 int cSegTanEndSide = cSegTanEnd.
Side( theArc->
GetMid() );
605 int cSegChordSide = cSegChord.
Side( theArc->
GetMid() );
607 bool eatFirstMouseUp =
true;
619 std::vector<VECTOR2I> possiblePoints;
626 for(
VECTOR2I candidate : possiblePoints )
628 if( ( candidate -
m_cursor ).SquaredEuclideanNorm()
629 < ( closest -
m_cursor ).SquaredEuclideanNorm() )
658 if( isStartTrackOnStartPt )
661 trackOnStart->
SetEnd( newStart );
663 if( isEndTrackOnStartPt )
666 trackOnEnd->
SetEnd( newEnd );
674 if( evt->IsMotion() || evt->IsDrag(
BUT_LEFT ) )
676 eatFirstMouseUp =
false;
678 else if( evt->IsCancelInteractive() || evt->IsActivate() )
680 restore_state =
true;
685 restore_state =
true;
694 eatFirstMouseUp =
false;
706 if( aTrack->
IsNew() )
710 if( aTrack->
GetLength() <= aMaxLengthIU )
718 aTrackCopy =
nullptr;
726 aTrackCopy->SetParentGroup(
nullptr );
728 aTrackCopy =
nullptr;
733 else if( aTrack->
GetLength() <= aMaxLengthIU )
738 aTrackCopy->SetParentGroup(
nullptr );
740 aTrackCopy =
nullptr;
746 m_commit->Modified( aTrack, aTrackCopy );
756 if( isStartTrackOnStartPt )
757 newStart = trackOnStart->
GetEnd();
759 if( isEndTrackOnStartPt )
760 newEnd = trackOnEnd->
GetEnd();
765 if( !processTrack( trackOnStart, trackOnStartCopy, maxLengthIU ) )
768 if( !processTrack( trackOnEnd, trackOnEndCopy, maxLengthIU ) )
771 processTrack( theArc, theArcCopy, 0 );
789 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
791 BOARD_ITEM* item = aCollector[ i ];
793 if( !dynamic_cast<PCB_TRACK*>( item ) )
794 aCollector.Remove( item );
810 if(
via->GetViaType() == VIATYPE::MICROVIA )
823 via->SetDrill( new_drill );
824 via->SetWidth( new_width );
839 m_commit->Push(
_(
"Edit track width/via size" ) );
856 static long long filletRadiusIU = 0;
862 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
864 BOARD_ITEM* item = aCollector[i];
866 if( !dynamic_cast<PCB_TRACK*>( item ) )
867 aCollector.Remove( item );
872 if( selection.
Size() < 2 )
881 if( dia.ShowModal() == wxID_CANCEL )
886 if( filletRadiusIU == 0 )
889 "The fillet operation was not performed." ) );
902 std::vector<FILLET_OP> filletOperations;
903 bool operationPerformedOnAtLeastOne =
false;
904 bool didOneAttemptFail =
false;
905 std::set<PCB_TRACK*> processedTracks;
909 PCB_TRACK* track = dyn_cast<PCB_TRACK*>( item );
916 auto processFilletOp =
917 [&](
bool aStartPoint )
922 std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
924 itemsOnAnchor = c->GetConnectedItemsAtAnchor( track,
anchor,
928 if( itemsOnAnchor.size() > 0
929 && selection.
Contains( itemsOnAnchor.at( 0 ) )
932 PCB_TRACK* trackOther = dyn_cast<PCB_TRACK*>( itemsOnAnchor.at( 0 ) );
935 if( processedTracks.find( trackOther ) == processedTracks.end() )
937 if( itemsOnAnchor.size() == 1 )
941 filletOp.t2 = trackOther;
942 filletOp.t1Start = aStartPoint;
943 filletOp.t2Start = track->
IsPointOnEnds( filletOp.t2->GetStart() );
944 filletOperations.push_back( filletOp );
950 didOneAttemptFail =
true;
956 processFilletOp(
true );
957 processFilletOp(
false );
959 processedTracks.insert( track );
962 std::vector<BOARD_ITEM*> itemsToAddToSelection;
964 for( FILLET_OP filletOp : filletOperations )
972 if( trackOnStart && trackOnEnd )
975 if( ( trackOnStart || trackOnEnd ) && track1->
GetLayer() == track2->
GetLayer() )
983 SHAPE_ARC sArc( t1Seg, t2Seg, filletRadiusIU );
986 auto setIfPointOnSeg =
989 VECTOR2I segToVec = aSegment.NearestPoint( aVecToTest ) - aVecToTest;
994 aPointToSet.
x = aVecToTest.x;
995 aPointToSet.
y = aVecToTest.y;
1003 if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.
GetP0() )
1004 && !setIfPointOnSeg( t2newPoint, t2Seg, sArc.
GetP0() ) )
1006 didOneAttemptFail =
true;
1010 if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.
GetP1() )
1011 && !setIfPointOnSeg( t2newPoint, t2Seg, sArc.
GetP1() ) )
1013 didOneAttemptFail =
true;
1023 itemsToAddToSelection.push_back( tArc );
1028 if( filletOp.t1Start )
1031 track1->
SetEnd( t1newPoint );
1033 if( filletOp.t2Start )
1036 track2->
SetEnd( t2newPoint );
1038 operationPerformedOnAtLeastOne =
true;
1045 for(
BOARD_ITEM* item : itemsToAddToSelection )
1048 if( !operationPerformedOnAtLeastOne )
1050 else if( didOneAttemptFail )
1060 static long long filletRadiusIU = 0;
1066 std::vector<VECTOR2I> pts;
1069 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1071 BOARD_ITEM* item = aCollector[i];
1075 if( !item->IsType( { PCB_SHAPE_LOCATE_SEGMENT_T,
1076 PCB_SHAPE_LOCATE_POLY_T,
1077 PCB_SHAPE_LOCATE_RECT_T } ) )
1079 aCollector.
Remove( item );
1085 std::set<PCB_SHAPE*> lines_to_add;
1086 std::vector<PCB_SHAPE*> items_to_remove;
1090 std::vector<VECTOR2I> pts;
1097 items_to_remove.push_back( graphic );
1100 pts.emplace_back( start );
1101 pts.emplace_back(
VECTOR2I( end.x, start.y ) );
1102 pts.emplace_back( end );
1103 pts.emplace_back(
VECTOR2I( start.x, end.y ) );
1108 items_to_remove.push_back( graphic );
1110 for(
int jj = 0; jj < graphic->
GetPolyShape().VertexCount(); ++jj )
1114 for(
size_t jj = 1; jj < pts.size(); ++jj )
1122 lines_to_add.insert( line );
1125 if( pts.size() > 1 )
1130 line->
SetEnd( pts.front() );
1133 lines_to_add.insert( line );
1138 selection.Add( item );
1140 for(
PCB_SHAPE* item : items_to_remove )
1141 selection.Remove( item );
1145 frame()->ShowInfoBarMsg(
_(
"A shape with least two lines must be selected." ) );
1152 if( dia.ShowModal() == wxID_CANCEL )
1155 filletRadiusIU = dia.GetValue();
1157 if( filletRadiusIU == 0 )
1159 frame()->ShowInfoBarMsg(
_(
"A radius of zero was entered.\n"
1160 "The fillet operation was not performed." ) );
1164 bool operationPerformedOnAtLeastOne =
false;
1165 bool didOneAttemptFail =
false;
1166 std::vector<BOARD_ITEM*> itemsToAddToSelection;
1169 if( m_isFootprintEditor )
1170 m_commit->Modify( selection.Front() );
1174 PCB_SHAPE* line_a = static_cast<PCB_SHAPE*>( a );
1175 PCB_SHAPE* line_b = static_cast<PCB_SHAPE*>( b );
1177 if( line_a->GetLength() == 0.0 || line_b->GetLength() == 0 )
1180 SEG seg_a( line_a->GetStart(), line_a->GetEnd() );
1181 SEG seg_b( line_b->GetStart(), line_b->GetEnd() );
1185 if (seg_a.A == seg_b.A)
1190 else if (seg_a.A == seg_b.B)
1195 else if (seg_a.B == seg_b.A)
1200 else if (seg_a.B == seg_b.B)
1209 SHAPE_ARC sArc( seg_a, seg_b, filletRadiusIU );
1212 auto setIfPointOnSeg =
1215 VECTOR2I segToVec = aSegment.NearestPoint( aVecToTest ) - aVecToTest;
1220 aPointToSet.
x = aVecToTest.x;
1221 aPointToSet.
y = aVecToTest.y;
1229 if( !setIfPointOnSeg( t1newPoint, seg_a, sArc.GetP0() )
1230 && !setIfPointOnSeg( t2newPoint, seg_b, sArc.GetP0() ) )
1232 didOneAttemptFail =
true;
1236 if( !setIfPointOnSeg( t1newPoint, seg_a, sArc.GetP1() )
1237 && !setIfPointOnSeg( t2newPoint, seg_b, sArc.GetP1() ) )
1239 didOneAttemptFail =
true;
1245 tArc->
SetArcGeometry( sArc.GetP0(), sArc.GetArcMid(), sArc.GetP1() );
1246 tArc->
SetWidth( line_a->GetWidth() );
1247 tArc->
SetLayer( line_a->GetLayer() );
1250 if( lines_to_add.count( line_a ) )
1252 lines_to_add.erase( line_a );
1253 itemsToAddToSelection.push_back( line_a );
1255 else if( !m_isFootprintEditor )
1257 m_commit->Modify( line_a );
1260 if( lines_to_add.count( line_b ) )
1262 lines_to_add.erase( line_b );
1263 itemsToAddToSelection.push_back( line_b );
1265 else if( !m_isFootprintEditor )
1267 m_commit->Modify( line_b );
1270 itemsToAddToSelection.push_back( tArc );
1273 line_a->SetStart( seg_a.A );
1274 line_a->SetEnd( seg_a.B );
1275 line_b->SetStart( seg_b.A );
1276 line_b->SetEnd( seg_b.B );
1278 operationPerformedOnAtLeastOne =
true;
1282 for(
auto item : items_to_remove )
1284 m_commit->Remove( item );
1285 m_selectionTool->RemoveItemFromSel( item,
true );
1289 for(
BOARD_ITEM* item : itemsToAddToSelection )
1291 m_commit->Add( item );
1292 m_selectionTool->AddItemToSel( item,
true );
1295 if( !items_to_remove.empty() )
1298 if( !itemsToAddToSelection.empty() )
1304 m_commit->Push(
_(
"Fillet Lines" ) );
1306 if( !operationPerformedOnAtLeastOne )
1307 frame()->ShowInfoBarMsg(
_(
"Unable to fillet the selected lines." ) );
1308 else if( didOneAttemptFail )
1309 frame()->ShowInfoBarMsg(
_(
"Some of the lines could not be filleted." ) );
1329 else if( selection.
Size() == 1 )
1362 for(
EDA_ITEM* eda_item : selCopy )
1397 if( selection.
Empty() )
1400 std::optional<VECTOR2I> oldRefPt;
1401 bool is_hover = selection.
IsHover();
1422 if( selection.
Empty() )
1434 viewBBox.
Merge( item->ViewBBox() );
1443 typedef std::numeric_limits<int> coord_limits;
1448 bool outOfBounds = rotPos.
x < min || rotPos.
x > max || rotPos.
y < min || rotPos.
y > max
1449 || rotEnd.
x < min || rotEnd.
x > max || rotEnd.
y < min || rotEnd.
y > max;
1506 mirrored.
x -= aMirrorPoint.
x;
1507 mirrored.
x = -mirrored.
x;
1508 mirrored.
x += aMirrorPoint.
x;
1521 mirrored.
y -= aMirrorPoint.
y;
1522 mirrored.
y = -mirrored.
y;
1523 mirrored.
y += aMirrorPoint.
y;
1603 if( selection.
Empty() )
1616 bool mirrorLeftRight =
true;
1617 bool mirrorAroundXaxis =
false;
1621 mirrorLeftRight =
false;
1622 mirrorAroundXaxis =
true;
1634 switch( item->Type() )
1637 static_cast<PCB_SHAPE*
>( item )->
Mirror( mirrorPoint, mirrorAroundXaxis );
1641 static_cast<ZONE*
>( item )->
Mirror( mirrorPoint, mirrorLeftRight );
1645 static_cast<PCB_TEXT*
>( item )->
Mirror( mirrorPoint, mirrorAroundXaxis );
1653 if( mirrorLeftRight )
1663 static_cast<PCB_TRACK*
>( item )->
Mirror( mirrorPoint, mirrorAroundXaxis );
1706 if( selection.
Empty() )
1709 std::optional<VECTOR2I> oldRefPt;
1721 if( selection.
GetSize() == 1 )
1752 m_commit->Push(
_(
"Change Side / Flip" ) );
1790 switch( item->Type() )
1797 wxASSERT( parentFP );
1799 static_cast<PCB_TEXT*
>( board_item )->SetVisible(
false );
1808 parentFP->
Remove( board_item );
1830 parentFP->
Remove( board_item );
1844 parentFP->
Remove( board_item );
1854 parentFP->
Remove( board_item );
1861 if( !aIsCut && aItems.
GetSize() == 1 )
1864 ZONE* zone =
static_cast<ZONE*
>( board_item );
1866 int outlineIdx, holeIdx;
1901 if( bItem->GetParent() && bItem->GetParent()->Type() ==
PCB_FOOTPRINT_T )
1921 m_commit->Modify( bItem->GetParent() );
1923 bItem->GetParent()->Remove( bItem );
1931 removeItem(
group );
1935 removeItem( aDescendant );
1949 if( enteredGroup && enteredGroup->
GetItems().empty() )
1971 std::vector<BOARD_ITEM*> lockedItems;
2053 if( selection.
Empty() )
2065 int ret = dialog.ShowModal();
2067 if( ret == wxID_OK )
2074 selCenter += translation;
2076 if( !
frame()->GetPcbNewSettings()->m_Display.m_DisplayInvertYAxis )
2077 rotation = -rotation;
2083 for(
EDA_ITEM* selItem : selection )
2103 item->
Move( translation );
2105 switch( rotationAnchor )
2111 item->
Rotate( selCenter, angle );
2127 if( selection.IsHover() )
2158 if( selection.
Empty() )
2165 bool is_hover = selection.
IsHover();
2167 std::vector<BOARD_ITEM*> new_items;
2168 new_items.reserve( selection.
Size() );
2183 &&
static_cast<PAD*
>( dupe_item )->CanHaveNumber() )
2189 static_cast<PAD*
>( dupe_item )->SetNumber( padNumber );
2194 m_commit->Modify( parentFootprint );
2195 dupe_item = parentFootprint->DuplicateItem( orig_item,
true );
2199 switch( orig_item->
Type() )
2220 dupe_item =
static_cast<PCB_GROUP*
>( orig_item )->DeepDuplicate();
2224 wxASSERT_MSG(
false, wxString::Format( wxT(
"Unhandled item type %d" ),
2225 orig_item->
Type() ) );
2234 static_cast<PCB_GROUP*
>( dupe_item )->RunOnDescendants(
2245 new_items.push_back( dupe_item );
2257 if( !selection.
Empty() )
2259 editFrame->
DisplayToolMsg( wxString::Format(
_(
"Duplicated %d item(s)" ),
2260 (
int) new_items.size() ) );
2298 if( selection.
Empty() )
2313 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
2326 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
2342 if( aSelection.
Empty() )
2346 if( aSelection.
Size() == 1 )
2364 const wxString& aCanceledMessage,
VECTOR2I& aReferencePoint )
2367 std::optional<VECTOR2I> pickedPoint;
2376 [&](
const VECTOR2D& aPoint ) ->
bool
2378 pickedPoint = aPoint;
2380 if( !aSuccessMessage.empty() )
2396 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
2402 if( !aCanceledMessage.empty() )
2414 [&](
const int& aFinalState )
2419 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
2430 evt->SetPassEvent();
2440 aReferencePoint = *pickedPoint;
2442 return pickedPoint.has_value();
2450 getEditFrame<PCB_BASE_EDIT_FRAME>()->GetMagneticItemsSettings() );
2452 "pcbnew.InteractiveEdit.selectReferencePoint",
2453 TOOL_ACTION_SCOPE::AS_GLOBAL );
2461 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
2463 BOARD_ITEM* item = aCollector[i];
2467 if( item->Type() == PCB_TEXT_T && aCollector.HasItem( item->GetParentFootprint() ) )
2468 aCollector.Remove( item );
2475 if( !selection.
Empty() )
2477 std::vector<BOARD_ITEM*> items;
2480 items.push_back(
static_cast<BOARD_ITEM*
>( item ) );
2487 _(
"Selection copied" ),
2488 _(
"Copy canceled" ),
2500 selection.SetReferencePoint( refPoint );
2504 frame()->SetStatusText(
_(
"Selection copied" ) );
constexpr EDA_IU_SCALE pcbIUScale
static TOOL_ACTION pickerSubTool
static TOOL_ACTION pasteSpecial
static TOOL_ACTION pageSettings
static TOOL_ACTION duplicate
static TOOL_ACTION doDelete
static TOOL_ACTION selectAll
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
VECTOR2D m_LocalOrigin
Relative Screen cursor coordinate (on grid) in user units.
NETINFO_ITEM * GetNet() const
Return #NET_INFO object for a given item.
void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
int GetCurrentViaSize() const
const VECTOR2I & GetAuxOrigin()
int GetCurrentTrackWidth() const
int GetCurrentViaDrill() const
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
void SetParentGroup(PCB_GROUP *aGroup)
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
virtual void SetLocked(bool aLocked)
PCB_GROUP * GetParentGroup() const
virtual void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle)
Rotate this object.
virtual BOARD_ITEM * Duplicate() const
Create a copy of this BOARD_ITEM.
virtual void Move(const VECTOR2I &aMoveVector)
Move this object.
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual bool IsLocked() const
BOARD_ITEM_CONTAINER * GetParent() const
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
const Vec & GetPosition() const
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
Represent basic circle geometry with utility geometry functions.
VECTOR2I Center
Public to make access simpler.
int Radius
Public to make access simpler.
CIRCLE & ConstructFromTanTanPt(const SEG &aLineA, const SEG &aLineB, const VECTOR2I &aP)
Construct this circle such that it is tangent to the given segments and passes through the given poin...
VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute the point on the circumference of the circle that is the closest to aP.
void SaveSelection(const PCB_SELECTION &selected, bool isFootprintEditor)
void SetBoard(BOARD *aBoard)
int GetCount() const
Return the number of objects in the list.
void Remove(int aIndex)
Remove the item at aIndex (first position is 0).
bool HitTestDrawingSheetItems(KIGFX::VIEW *aView, const VECTOR2I &aPosition)
void ShowInfoBarMsg(const wxString &aMsg, bool aShowCloseButton=false)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an info icon on the left of...
void ShowInfoBarError(const wxString &aErrorMsg, bool aShowCloseButton=false, WX_INFOBAR::MESSAGE_TYPE aType=WX_INFOBAR::MESSAGE_TYPE::GENERIC)
Show the WX_INFOBAR displayed on the top of the canvas with a message and an error icon on the left o...
void DisplayToolMsg(const wxString &msg) override
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
void SetStatusPopup(wxWindow *aPopup)
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
SHAPE_POLY_SET & GetPolyShape()
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
void SetWidth(int aWidth)
static const TOOL_EVENT SelectedEvent
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
static const TOOL_EVENT ConnectivityChangedEvent
Selected item had a property changed (except movement)
static const TOOL_EVENT UnselectedEvent
Used when the right click button is pressed, or when the select tool is in effect.
static const std::vector< KICAD_T > DraggableItems
A scan list for items that can be dragged.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
bool IsLayerVisible(int aLayer) const
Return information about visibility of a particular layer.
LSET is a set of PCB_LAYER_IDs.
A collection of nets and the parameters used to route or test these nets.
int GetuViaDiameter() const
void FlipPrimitives(bool aFlipLeftRight)
Flip (mirror) the primitives left to right or top to bottom, around the anchor position in custom pad...
VECTOR2I GetPosition() const override
void SetOffset(const VECTOR2I &aOffset)
const VECTOR2I & GetOffset() const
void SetDelta(const VECTOR2I &aSize)
void SetPosition(const VECTOR2I &aPos) override
const VECTOR2I & GetDelta() const
PAD_SHAPE GetShape() const
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
void SetOrientation(const EDA_ANGLE &aAngle)
Set the rotation angle of the pad.
static TOOL_ACTION drag45Degree
static TOOL_ACTION duplicateIncrement
Activation of the duplication tool with incrementing (e.g. pad number)
static TOOL_ACTION routerUndoLastSegment
static TOOL_ACTION changeTrackWidth
Update selected tracks & vias to the current track & via dimensions.
static TOOL_ACTION unrouteSelected
Removes all tracks from the selected items to the first pad.
static TOOL_ACTION mirrorH
Mirroring of selected items.
static TOOL_ACTION updateFootprint
static TOOL_ACTION breakTrack
Break a single track into two segments at the cursor.
static TOOL_ACTION getAndPlace
Find an item and start moving.
static TOOL_ACTION properties
Activation of the edit tool.
static TOOL_ACTION editFpInFpEditor
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION moveWithReference
move with a reference point
static TOOL_ACTION swap
Swapping of selected items.
static TOOL_ACTION moveExact
Activation of the exact move tool.
static TOOL_ACTION selectConnection
Select tracks between junctions or expands an existing selection to pads or the entire connection.
static TOOL_ACTION assignNetClass
static TOOL_ACTION packAndMoveFootprints
Pack and start moving selected footprints.
static TOOL_ACTION copyWithReference
copy command with manual reference point selection
static TOOL_ACTION dragFreeAngle
static TOOL_ACTION inspectClearance
static TOOL_ACTION updateLocalRatsnest
static TOOL_ACTION deleteFull
static TOOL_ACTION moveIndividually
move items one-by-one
static TOOL_ACTION selectItem
Select an item (specified as the event parameter).
static TOOL_ACTION filletTracks
Fillet (i.e. adds an arc tangent to) all selected straight tracks by a user defined radius.
static TOOL_ACTION footprintProperties
static TOOL_ACTION filletLines
static TOOL_ACTION changeFootprint
static TOOL_ACTION routerInlineDrag
Activation of the Push and Shove router (inline dragging mode)
static TOOL_ACTION positionRelative
Activation of the position relative tool.
static TOOL_ACTION move
move or drag an item
static TOOL_ACTION mirrorV
static TOOL_ACTION selectItems
Select a list of items (specified as the event parameter)
static TOOL_ACTION flip
Flipping of selected objects.
static TOOL_ACTION createArray
Tool for creating an array of objects.
static TOOL_ACTION rotateCw
Rotation of selected objects.
static TOOL_ACTION rotateCcw
void SetMid(const VECTOR2I &aMid)
EDA_ANGLE GetAngle() const
const VECTOR2I & GetMid() const
virtual VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Common, abstract interface for edit frames.
virtual void OnEditItemRequest(BOARD_ITEM *aItem)=0
Install the corresponding dialog editor for the given item.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
DS_PROXY_VIEW_ITEM * GetDrawingSheet() const
void RedrawRatsnest()
Return the bounding box of the view that should be used if model is not valid.
A set of BOARD_ITEMs (i.e., without duplicates).
std::unordered_set< BOARD_ITEM * > & GetItems()
bool RemoveItem(BOARD_ITEM *aItem)
Remove item from group.
TEXT_TYPE GetType() const
void SetWidth(int aWidth)
virtual double GetLength() const
Get the length of the track using the hypotenuse calculation.
void SetEnd(const VECTOR2I &aEnd)
void SetStart(const VECTOR2I &aStart)
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
EDA_ITEM_FLAGS IsPointOnEnds(const VECTOR2I &point, int min_dist=0) const
Return STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if point if near (dist = m...
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
bool ApproxCollinear(const SEG &aSeg, int aDistanceThreshold=1) const
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
SEG PerpendicularSeg(const VECTOR2I &aP) const
Compute a segment perpendicular to this one, passing through point aP.
int Side(const VECTOR2I &aP) const
Determine on which side of directed line passing via segment ends point aP lies.
EDA_ANGLE Angle(const SEG &aOther) const
Determine the smallest angle between two segments.
static SELECTION_CONDITION HasTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if among the selected items there is at least one of a given types.
static SELECTION_CONDITION HasType(KICAD_T aType)
Create a functor that tests if among the selected items there is at least one of a given type.
static bool NotEmpty(const SELECTION &aSelection)
Test if there are any items selected.
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 bool ShowAlways(const SELECTION &aSelection)
The default condition function (always returns true).
static SELECTION_CONDITION OnlyTypes(std::vector< KICAD_T > aTypes)
Create a functor that tests if the selected items are only of given types.
virtual KIGFX::VIEW_ITEM * GetItem(unsigned int aIdx) const override
VECTOR2I GetReferencePoint() const
virtual VECTOR2I GetCenter() const
Returns the center point of the selection area bounding box.
virtual unsigned int GetSize() const override
Return the number of stored items.
bool HasType(KICAD_T aType) const
Checks if there is at least one item of requested kind.
int Size() const
Returns the number of selected parts.
void ClearReferencePoint()
void SetReferencePoint(const VECTOR2I &aP)
bool Empty() const
Checks if there is anything selected.
bool HasReferencePoint() const
size_t CountType(KICAD_T aType) const
bool Contains(EDA_ITEM *aItem) const
virtual BOX2I GetBoundingBox() const
const VECTOR2I & GetP1() const
const VECTOR2I & GetP0() const
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
static const int MIN_PRECISION_IU
This is the minimum precision for all the points in a shape.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
An extension of WX_TEXT_ENTRY_DIALOG that uses UNIT_BINDER to request a dimension (e....
long long GetValue()
Returns the value in internal units.
Handle a list of polygons defining a copper zone.
bool UnFill()
Removes the zone filling.
bool HitTestCutout(const VECTOR2I &aRefPos, int *aOutlineIdx=nullptr, int *aHoleIdx=nullptr) const
Test if the given point is contained within a cutout of the zone.
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
void RemoveCutout(int aOutlineIdx, int aHoleIdx)
Remove a cutout from the zone.
@ ROTATE_AROUND_USER_ORIGIN
@ ROTATE_AROUND_SEL_CENTER
@ ROTATE_AROUND_AUX_ORIGIN
@ ROTATE_AROUND_ITEM_ANCHOR
static constexpr EDA_ANGLE & ANGLE_180
#define IS_NEW
New item, just created.
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
@ LAYER_SCHEMATIC_DRAWINGSHEET
PCB_LAYER_ID
A quick note on layer IDs:
wxString MessageTextFromValue(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, double aValue, bool aAddUnitsText=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A helper to convert the double length aValue to a string in inches, millimeters, or unscaled units.
SGLIB_API S3DMODEL * GetModel(SCENEGRAPH *aNode)
Function GetModel creates an S3DMODEL representation of aNode (raw data, no transforms)
void for_all_pairs(_InputIterator __first, _InputIterator __last, _Function __f)
Apply a function to every possible pair of elements of a sequence.
Class to handle a set of BOARD_ITEMs.
std::optional< VECTOR2I > OPT_VECTOR2I
constexpr int mmToIU(double mm) const
const VECTOR2I CalcArcMid(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aMinArcAngle=true)
Return the middle point of an arc, half-way between aStart and aEnd.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
double GetLineLength(const VECTOR2I &aPointA, const VECTOR2I &aPointB)
Return the length of a line segment defined by aPointA and aPointB.
double EuclideanNorm(const VECTOR2I &vector)
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
@ PCB_SHAPE_LOCATE_SEGMENT_T
@ PCB_SHAPE_LOCATE_RECT_T
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_SHAPE_LOCATE_POLY_T
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".