60using namespace std::placeholders;
62#include <wx/hyperlink.h>
75 m_selectionTool( nullptr ),
85 m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
110 auto positioningToolsSubMenu = std::make_shared<POSITIONING_TOOLS_MENU>(
this );
113 auto propertiesCondition =
116 if( aSel.GetSize() == 0 )
130 if( aSel.GetSize() == 1 )
142 auto inFootprintEditor =
163 auto noActiveToolCondition =
169 auto notMovingCondition =
177 auto noItemsCondition =
178 [ this ](
const SELECTION& aSelections ) ->
bool
195 static std::vector<KICAD_T> unroutableTypes = {
PCB_TRACE_T,
201 static std::vector<KICAD_T> trackTypes = {
PCB_TRACE_T,
214 && notMovingCondition );
217 && notMovingCondition
218 && !inFootprintEditor );
220 && notMovingCondition );
243 && !inFootprintEditor );
282 FOOTPRINT* fp = getEditFrame<PCB_BASE_FRAME>()->GetFootprintFromBoardByReference();
316 if(
theRouter->CanInlineDrag( aDragMode ) )
319 static_cast<intptr_t
>( aDragMode ) );
362 std::vector<PCB_TRACK*> tracks;
363 std::vector<PCB_TRACK*> vias;
367 if( PCB_TRACK* track = dynamic_cast<PCB_TRACK*>( item ) )
369 if( track->Type() == PCB_VIA_T )
370 vias.push_back( track );
372 tracks.push_back( track );
381 if( tracks.size() == 2 && vias.size() == 0 )
383 if( connected( tracks[0], tracks[1]->GetStart() )
384 || connected( tracks[0], tracks[1]->GetEnd() ) )
386 aCollector.
Remove( tracks[1] );
389 else if( tracks.size() == 2 && vias.size() == 1 )
391 if( connected( tracks[0], vias[0]->GetPosition() )
392 && connected( tracks[1], vias[0]->GetPosition() ) )
394 aCollector.
Remove( tracks[0] );
395 aCollector.
Remove( tracks[1] );
401 if( selection.Empty() )
404 if( selection.Size() == 1 && selection.Front()->Type() ==
PCB_ARC_T )
408 return DragArcTrack( aEvent );
412 invokeInlineRouter( mode );
431 wxString msg =
wxString::Format(
_(
"Unable to resize arc tracks of %s or greater." ),
445 bool restore_state =
false;
456 tanStart.
A = *tanIntersect;
458 tanEnd.
A = *tanIntersect;
461 auto getUniqueTrackAtAnchorCollinear =
467 int allowedDeviation = theArc->
GetWidth();
469 std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
471 for(
int i = 0; i < 3; i++ )
473 itemsOnAnchor = conn->GetConnectedItemsAtAnchor( theArc, aAnchor,
477 allowedDeviation /= 2;
479 if( itemsOnAnchor.size() == 1 )
485 if( itemsOnAnchor.size() == 1 && itemsOnAnchor.front()->Type() ==
PCB_TRACE_T )
487 retval =
static_cast<PCB_TRACK*
>( itemsOnAnchor.front() );
491 if( trackSeg.
Angle( aCollinearSeg ) > maxTangentDeviation )
499 retval->
SetEnd( aAnchor );
511 PCB_TRACK* trackOnStart = getUniqueTrackAtAnchorCollinear( theArc->
GetStart(), tanStart);
512 PCB_TRACK* trackOnEnd = getUniqueTrackAtAnchorCollinear( theArc->
GetEnd(), tanEnd );
522 tanStart.
B = trackOnStart->
GetEnd();
528 tanEnd.
B = trackOnEnd->
GetEnd();
532 if( tanIntersect = tanStart.
IntersectLines( tanEnd ); !tanIntersect )
535 auto isTrackStartClosestToArcStart =
541 return trackStartToArcStart < trackEndToArcStart;
544 bool isStartTrackOnStartPt = isTrackStartClosestToArcStart( trackOnStart );
545 bool isEndTrackOnStartPt = isTrackStartClosestToArcStart( trackOnEnd );
574 auto getFurthestPointToTanInterstect =
577 if( ( aPointA - *tanIntersect ).EuclideanNorm()
589 VECTOR2I tanStartPoint = getFurthestPointToTanInterstect( tanStart.
A, tanStart.
B );
590 VECTOR2I tanEndPoint = getFurthestPointToTanInterstect( tanEnd.
A, tanEnd.
B );
591 VECTOR2I tempTangentPoint = tanEndPoint;
593 if( getFurthestPointToTanInterstect( tanStartPoint, tanEndPoint ) == tanEndPoint )
594 tempTangentPoint = tanStartPoint;
600 SEG cSegTanStart( maxTanPtStart, *tanIntersect );
601 SEG cSegTanEnd( maxTanPtEnd, *tanIntersect );
602 SEG cSegChord( maxTanPtStart, maxTanPtEnd );
604 int cSegTanStartSide = cSegTanStart.
Side( theArc->
GetMid() );
605 int cSegTanEndSide = cSegTanEnd.
Side( theArc->
GetMid() );
606 int cSegChordSide = cSegChord.
Side( theArc->
GetMid() );
608 bool eatFirstMouseUp =
true;
620 std::vector<VECTOR2I> possiblePoints;
627 for(
VECTOR2I candidate : possiblePoints )
629 if( ( candidate -
m_cursor ).SquaredEuclideanNorm()
630 < ( closest -
m_cursor ).SquaredEuclideanNorm() )
659 if( isStartTrackOnStartPt )
662 trackOnStart->
SetEnd( newStart );
664 if( isEndTrackOnStartPt )
667 trackOnEnd->
SetEnd( newEnd );
675 if( evt->IsMotion() || evt->IsDrag(
BUT_LEFT ) )
677 eatFirstMouseUp =
false;
679 else if( evt->IsCancelInteractive() || evt->IsActivate() )
681 restore_state =
true;
686 restore_state =
true;
695 eatFirstMouseUp =
false;
707 if( aTrack->
IsNew() )
711 if( aTrack->
GetLength() <= aMaxLengthIU )
719 aTrackCopy =
nullptr;
727 aTrackCopy->SetParentGroup(
nullptr );
729 aTrackCopy =
nullptr;
734 else if( aTrack->
GetLength() <= aMaxLengthIU )
739 aTrackCopy->SetParentGroup(
nullptr );
741 aTrackCopy =
nullptr;
747 m_commit->Modified( aTrack, aTrackCopy );
757 if( isStartTrackOnStartPt )
758 newStart = trackOnStart->
GetEnd();
760 if( isEndTrackOnStartPt )
761 newEnd = trackOnEnd->
GetEnd();
766 if( !processTrack( trackOnStart, trackOnStartCopy, maxLengthIU ) )
769 if( !processTrack( trackOnEnd, trackOnEndCopy, maxLengthIU ) )
772 processTrack( theArc, theArcCopy, 0 );
790 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
792 BOARD_ITEM* item = aCollector[ i ];
794 if( !dynamic_cast<PCB_TRACK*>( item ) )
795 aCollector.Remove( item );
824 via->SetDrill( new_drill );
825 via->SetWidth( new_width );
840 m_commit->Push(
_(
"Edit track width/via size" ) );
857 static long long filletRadiusIU = 0;
863 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
865 BOARD_ITEM* item = aCollector[i];
867 if( !dynamic_cast<PCB_TRACK*>( item ) )
868 aCollector.Remove( item );
882 if( dia.ShowModal() == wxID_CANCEL )
887 if( filletRadiusIU == 0 )
890 "The fillet operation was not performed." ) );
903 std::vector<FILLET_OP> filletOperations;
904 bool operationPerformedOnAtLeastOne =
false;
905 bool didOneAttemptFail =
false;
906 std::set<PCB_TRACK*> processedTracks;
910 PCB_TRACK* track = dyn_cast<PCB_TRACK*>( item );
917 auto processFilletOp =
918 [&](
bool aStartPoint )
923 std::vector<BOARD_CONNECTED_ITEM*> itemsOnAnchor;
925 itemsOnAnchor = c->GetConnectedItemsAtAnchor( track,
anchor,
929 if( itemsOnAnchor.size() > 0
933 PCB_TRACK* trackOther = dyn_cast<PCB_TRACK*>( itemsOnAnchor.at( 0 ) );
936 if( processedTracks.find( trackOther ) == processedTracks.end() )
938 if( itemsOnAnchor.size() == 1 )
942 filletOp.t2 = trackOther;
943 filletOp.t1Start = aStartPoint;
944 filletOp.t2Start = track->
IsPointOnEnds( filletOp.t2->GetStart() );
945 filletOperations.push_back( filletOp );
951 didOneAttemptFail =
true;
957 processFilletOp(
true );
958 processFilletOp(
false );
960 processedTracks.insert( track );
963 std::vector<BOARD_ITEM*> itemsToAddToSelection;
965 for( FILLET_OP filletOp : filletOperations )
973 if( trackOnStart && trackOnEnd )
976 if( ( trackOnStart || trackOnEnd ) && track1->
GetLayer() == track2->
GetLayer() )
984 SHAPE_ARC sArc( t1Seg, t2Seg, filletRadiusIU );
987 auto setIfPointOnSeg =
990 VECTOR2I segToVec = aSegment.NearestPoint( aVecToTest ) - aVecToTest;
995 aPointToSet.
x = aVecToTest.x;
996 aPointToSet.
y = aVecToTest.y;
1004 if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.
GetP0() )
1005 && !setIfPointOnSeg( t2newPoint, t2Seg, sArc.
GetP0() ) )
1007 didOneAttemptFail =
true;
1011 if( !setIfPointOnSeg( t1newPoint, t1Seg, sArc.
GetP1() )
1012 && !setIfPointOnSeg( t2newPoint, t2Seg, sArc.
GetP1() ) )
1014 didOneAttemptFail =
true;
1024 itemsToAddToSelection.push_back( tArc );
1029 if( filletOp.t1Start )
1032 track1->
SetEnd( t1newPoint );
1034 if( filletOp.t2Start )
1037 track2->
SetEnd( t2newPoint );
1039 operationPerformedOnAtLeastOne =
true;
1046 for(
BOARD_ITEM* item : itemsToAddToSelection )
1049 if( !operationPerformedOnAtLeastOne )
1051 else if( didOneAttemptFail )
1061 static long long filletRadiusIU = 0;
1067 std::vector<VECTOR2I> pts;
1070 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
1072 BOARD_ITEM* item = aCollector[i];
1076 if( !item->IsType( { PCB_SHAPE_LOCATE_SEGMENT_T,
1077 PCB_SHAPE_LOCATE_POLY_T,
1078 PCB_SHAPE_LOCATE_RECT_T } ) )
1080 aCollector.
Remove( item );
1086 std::set<PCB_SHAPE*> lines_to_add;
1087 std::vector<PCB_SHAPE*> items_to_remove;
1091 std::vector<VECTOR2I> pts;
1098 items_to_remove.push_back( graphic );
1101 pts.emplace_back( start );
1102 pts.emplace_back(
VECTOR2I( end.x, start.y ) );
1103 pts.emplace_back( end );
1104 pts.emplace_back(
VECTOR2I( start.x, end.y ) );
1109 items_to_remove.push_back( graphic );
1111 for(
int jj = 0; jj < graphic->
GetPolyShape().VertexCount(); ++jj )
1115 for(
size_t jj = 1; jj < pts.size(); ++jj )
1119 if( m_isFootprintEditor )
1128 lines_to_add.insert( line );
1131 if( pts.size() > 1 )
1135 if( m_isFootprintEditor )
1141 line->
SetEnd( pts.front() );
1144 lines_to_add.insert( line );
1149 selection.Add( item );
1151 for(
PCB_SHAPE* item : items_to_remove )
1152 selection.Remove( item );
1156 frame()->ShowInfoBarMsg(
_(
"A shape with least two lines must be selected." ) );
1163 if( dia.ShowModal() == wxID_CANCEL )
1166 filletRadiusIU = dia.GetValue();
1168 if( filletRadiusIU == 0 )
1170 frame()->ShowInfoBarMsg(
_(
"A radius of zero was entered.\n"
1171 "The fillet operation was not performed." ) );
1175 bool operationPerformedOnAtLeastOne =
false;
1176 bool didOneAttemptFail =
false;
1177 std::vector<BOARD_ITEM*> itemsToAddToSelection;
1180 if( m_isFootprintEditor )
1181 m_commit->Modify( selection.Front() );
1185 PCB_SHAPE* line_a = static_cast<PCB_SHAPE*>( a );
1186 PCB_SHAPE* line_b = static_cast<PCB_SHAPE*>( b );
1188 if( line_a->GetLength() == 0.0 || line_b->GetLength() == 0 )
1191 SEG seg_a( line_a->GetStart(), line_a->GetEnd() );
1192 SEG seg_b( line_b->GetStart(), line_b->GetEnd() );
1196 if (seg_a.A == seg_b.A)
1201 else if (seg_a.A == seg_b.B)
1206 else if (seg_a.B == seg_b.A)
1211 else if (seg_a.B == seg_b.B)
1220 SHAPE_ARC sArc( seg_a, seg_b, filletRadiusIU );
1223 auto setIfPointOnSeg =
1226 VECTOR2I segToVec = aSegment.NearestPoint( aVecToTest ) - aVecToTest;
1231 aPointToSet.
x = aVecToTest.x;
1232 aPointToSet.
y = aVecToTest.y;
1240 if( !setIfPointOnSeg( t1newPoint, seg_a, sArc.GetP0() )
1241 && !setIfPointOnSeg( t2newPoint, seg_b, sArc.GetP0() ) )
1243 didOneAttemptFail =
true;
1247 if( !setIfPointOnSeg( t1newPoint, seg_a, sArc.GetP1() )
1248 && !setIfPointOnSeg( t2newPoint, seg_b, sArc.GetP1() ) )
1250 didOneAttemptFail =
true;
1256 if( m_isFootprintEditor )
1261 tArc->
SetArcGeometry( sArc.GetP0(), sArc.GetArcMid(), sArc.GetP1() );
1262 tArc->
SetWidth( line_a->GetWidth() );
1263 tArc->
SetLayer( line_a->GetLayer() );
1266 if( lines_to_add.count( line_a ) )
1268 lines_to_add.erase( line_a );
1269 itemsToAddToSelection.push_back( line_a );
1271 else if( !m_isFootprintEditor )
1273 m_commit->Modify( line_a );
1276 if( lines_to_add.count( line_b ) )
1278 lines_to_add.erase( line_b );
1279 itemsToAddToSelection.push_back( line_b );
1281 else if( !m_isFootprintEditor )
1283 m_commit->Modify( line_b );
1286 itemsToAddToSelection.push_back( tArc );
1289 line_a->SetStart( seg_a.A );
1290 line_a->SetEnd( seg_a.B );
1291 line_b->SetStart( seg_b.A );
1292 line_b->SetEnd( seg_b.B );
1294 if( m_isFootprintEditor )
1296 static_cast<FP_SHAPE*
>( line_a )->SetLocalCoord();
1297 static_cast<FP_SHAPE*
>( line_b )->SetLocalCoord();
1298 static_cast<FP_SHAPE*
>( tArc )->SetLocalCoord();
1301 operationPerformedOnAtLeastOne =
true;
1305 for(
auto item : items_to_remove )
1307 m_commit->Remove( item );
1308 m_selectionTool->RemoveItemFromSel( item,
true );
1312 for(
BOARD_ITEM* item : itemsToAddToSelection )
1314 m_commit->Add( item );
1315 m_selectionTool->AddItemToSel( item,
true );
1318 if( !items_to_remove.empty() )
1321 if( !itemsToAddToSelection.empty() )
1327 m_commit->Push(
_(
"Fillet Lines" ) );
1329 if( !operationPerformedOnAtLeastOne )
1330 frame()->ShowInfoBarMsg(
_(
"Unable to fillet the selected lines." ) );
1331 else if( didOneAttemptFail )
1332 frame()->ShowInfoBarMsg(
_(
"Some of the lines could not be filleted." ) );
1385 for(
EDA_ITEM* eda_item : selCopy )
1423 std::optional<VECTOR2I> oldRefPt;
1457 viewBBox.
Merge( item->ViewBBox() );
1466 typedef std::numeric_limits<int> coord_limits;
1471 bool outOfBounds = rotPos.
x < min || rotPos.
x > max || rotPos.
y < min || rotPos.
y > max
1472 || rotEnd.
x < min || rotEnd.
x > max || rotEnd.
y < min || rotEnd.
y > max;
1529 mirrored.
x -= aMirrorPoint.
x;
1530 mirrored.
x = -mirrored.
x;
1531 mirrored.
x += aMirrorPoint.
x;
1544 mirrored.
y -= aMirrorPoint.
y;
1545 mirrored.
y = -mirrored.
y;
1546 mirrored.
y += aMirrorPoint.
y;
1647 bool mirrorLeftRight =
true;
1648 bool mirrorAroundXaxis =
false;
1652 mirrorLeftRight =
false;
1653 mirrorAroundXaxis =
true;
1665 switch( item->Type() )
1669 static_cast<PCB_SHAPE*
>( item )->
Mirror( mirrorPoint, mirrorAroundXaxis );
1674 static_cast<FP_ZONE*
>( item )->
Mirror( mirrorPoint, mirrorLeftRight );
1678 static_cast<FP_TEXT*
>( item )->
Mirror( mirrorPoint, mirrorAroundXaxis );
1682 static_cast<PCB_TEXT*
>( item )->
Mirror( mirrorPoint, mirrorAroundXaxis );
1686 static_cast<FP_TEXTBOX*
>( item )->
Mirror( mirrorPoint, mirrorAroundXaxis );
1694 if( mirrorLeftRight )
1704 static_cast<PCB_TRACK*
>( item )->
Mirror( mirrorPoint, mirrorAroundXaxis );
1750 std::optional<VECTOR2I> oldRefPt;
1793 m_commit->Push(
_(
"Change Side / Flip" ) );
1829 switch( item->Type() )
1836 switch(
text->GetType() )
1841 text->SetVisible(
false );
1864 parent->
Remove( textbox );
1876 parent->
Remove( fp_bitmap );
1912 if( !aIsCut && aItems.
GetSize() == 1 )
1915 ZONE* zone =
static_cast<ZONE*
>( item );
1917 int outlineIdx, holeIdx;
1951 if( bItem->GetParent() && bItem->GetParent()->Type() ==
PCB_FOOTPRINT_T )
1971 m_commit->Modify( bItem->GetParent() );
1973 bItem->GetParent()->Remove( bItem );
1981 removeItem(
group );
1985 removeItem( aDescendant );
1999 if( enteredGroup && enteredGroup->
GetItems().empty() )
2021 std::vector<BOARD_ITEM*> lockedItems;
2115 int ret = dialog.ShowModal();
2117 if( ret == wxID_OK )
2124 selCenter += translation;
2126 if( !
frame()->GetPcbNewSettings()->m_Display.m_DisplayInvertYAxis )
2127 rotation = -rotation;
2153 item->
Move( translation );
2155 switch( rotationAnchor )
2217 std::vector<BOARD_ITEM*> new_items;
2233 &&
static_cast<PAD*
>( dupe_item )->CanHaveNumber() )
2239 static_cast<PAD*
>( dupe_item )->SetNumber( padNumber );
2246 m_commit->Modify( parentFootprint );
2247 dupe_item = parentFootprint->
DuplicateItem( orig_item,
true );
2251 switch( orig_item->
Type() )
2272 dupe_item =
static_cast<PCB_GROUP*
>( orig_item )->DeepDuplicate();
2277 orig_item->
Type() ) );
2286 static_cast<PCB_GROUP*
>( dupe_item )->RunOnDescendants(
2297 new_items.push_back( dupe_item );
2312 (
int) new_items.size() ) );
2365 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
2378 for(
int i = aCollector.
GetCount() - 1; i >= 0; i-- )
2394 if( aSelection.
Empty() )
2398 if( aSelection.
Size() == 1 )
2416 const wxString& aCanceledMessage,
VECTOR2I& aReferencePoint )
2419 std::optional<VECTOR2I> pickedPoint;
2428 [&](
const VECTOR2D& aPoint ) ->
bool
2430 pickedPoint = aPoint;
2432 if( !aSuccessMessage.empty() )
2448 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
2454 if( !aCanceledMessage.empty() )
2466 [&](
const int& aFinalState )
2471 m_statusPopup->Move( wxGetMousePosition() + wxPoint( 20, -50 ) );
2481 evt->SetPassEvent();
2491 aReferencePoint = *pickedPoint;
2493 return pickedPoint.has_value();
2501 getEditFrame<PCB_BASE_EDIT_FRAME>()->GetMagneticItemsSettings() );
2503 "pcbnew.InteractiveEdit.selectReferencePoint",
2512 for(
int i = aCollector.
GetCount() - 1; i >= 0; --i )
2514 BOARD_ITEM* item = aCollector[i];
2518 if( item->Type() == PCB_FP_TEXT_T && aCollector.HasItem( item->GetParent() ) )
2519 aCollector.Remove( item );
2528 std::vector<BOARD_ITEM*> items;
2531 items.push_back(
static_cast<BOARD_ITEM*
>( item ) );
2538 _(
"Selection copied" ),
2539 _(
"Copy canceled" ),
2555 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)
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.
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
Update the board display after modifying it by a python script (note: it is automatically called by a...
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
TEXT_TYPE GetType() const
A specialization of ZONE for use in footprints.
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.
Object to handle a bitmap image that can be inserted in a PCB.
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.
void SetWidth(int aWidth)
virtual double GetLength() const
Function GetLength returns 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
Function IsPointOnEnds returns STARTPOINT if point if near (dist = min_dist) start point,...
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 aGlobalIndex-th vertex in the poly set.
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.
static ROUTER * theRouter
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
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.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
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_FP_SHAPE_T
class FP_SHAPE, a footprint edge
@ 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_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
@ 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_FP_ZONE_T
class ZONE, managed by a footprint
@ 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_FP_TEXT_T
class FP_TEXT, text in a footprint
@ 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".