27using namespace std::placeholders;
75 if( aDirection.
x != 0 || aDirection.
y != 0 )
76 aDirections.push_back( aDirection );
81 std::vector<VECTOR2I> directions;
86 switch( aRelation->
Kind() )
142 if( !aShape || !aPoints || !aEditedPoint )
150 if( position == aShape->
GetStart() )
153 if( position == aShape->
GetEnd() )
167 if( aEditedPoint == &aPoints->
Point( i ) )
171 for(
unsigned i = 0; i < aPoints->
LinesSize() && i < 4; ++i )
173 if( aEditedPoint == &aPoints->
Line( i ) )
179 for(
unsigned i = 0; i < aPoints->
PointsSize(); ++i )
181 if( aEditedPoint == &aPoints->
Point( i ) )
185 for(
unsigned i = 0; i < aPoints->
LinesSize(); ++i )
187 if( aEditedPoint == &aPoints->
Line( i ) )
251 wxArrayString strings;
273 return wxT(
"RECT_RADIUS_TEXT_ITEM" );
309 if( aPoints.
SwapX() )
310 std::swap( topLeft.
x, botRight.
x );
312 if( aPoints.
SwapY() )
313 std::swap( topLeft.
y, botRight.
y );
370 PinEditedCorner( aEditedPoint, aPoints, topLeft, topRight, botLeft, botRight,
371 { 0, 0 }, { 0, 0 }, aMinSize );
379 setLeft( topLeft.
x );
380 setRight( botRight.
x );
381 setBottom( botRight.
y );
386 aRectangle.
Move( moveVector );
390 int width =
std::abs( botRight.
x - topLeft.
x );
391 int height =
std::abs( botRight.
y - topLeft.
y );
392 int maxRadius = std::min( width, height ) / 2;
394 x = std::clamp( x, botRight.
x - maxRadius, botRight.
x );
406 setLeft( topLeft.
x );
411 setBottom( botRight.
y );
416 setRight( botRight.
x );
419 for(
unsigned i = 0; i < aPoints.
LinesSize(); ++i )
437 if( aPoints.
SwapX() )
438 std::swap( topLeft.
x, botRight.
x );
440 if( aPoints.
SwapY() )
441 std::swap( topLeft.
y, botRight.
y );
468 std::vector<EDA_ITEM*>& aUpdatedItems )
override
489 const VECTOR2I& aMinSize = { 0, 0 } )
499 aTopLeft.
x = std::min( aTopLeft.
x, aHole.x - aHoleSize.
x / 2 - minWidth );
500 aTopLeft.
y = std::min( aTopLeft.
y, aHole.y - aHoleSize.
y / 2 - minHeight );
505 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
506 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
510 aTopRight.
y = aTopLeft.
y;
511 aBotLeft.
x = aTopLeft.
x;
518 aTopRight.
x = std::max( aTopRight.
x, aHole.x + aHoleSize.
x / 2 + minWidth );
519 aTopRight.
y = std::min( aTopRight.
y, aHole.y - aHoleSize.
y / 2 - minHeight );
524 aTopRight.
x = std::max( aTopRight.
x, aBotLeft.
x + minWidth );
525 aTopRight.
y = std::min( aTopRight.
y, aBotLeft.
y - minHeight );
529 aTopLeft.
y = aTopRight.
y;
530 aBotRight.
x = aTopRight.
x;
537 aBotLeft.
x = std::min( aBotLeft.
x, aHole.x - aHoleSize.
x / 2 - minWidth );
538 aBotLeft.
y = std::max( aBotLeft.
y, aHole.y + aHoleSize.
y / 2 + minHeight );
543 aBotLeft.
x = std::min( aBotLeft.
x, aTopRight.
x - minWidth );
544 aBotLeft.
y = std::max( aBotLeft.
y, aTopRight.
y + minHeight );
548 aBotRight.
y = aBotLeft.
y;
549 aTopLeft.
x = aBotLeft.
x;
556 aBotRight.
x = std::max( aBotRight.
x, aHole.x + aHoleSize.
x / 2 + minWidth );
557 aBotRight.
y = std::max( aBotRight.
y, aHole.y + aHoleSize.
y / 2 + minHeight );
562 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
563 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
567 aBotLeft.
y = aBotRight.
y;
568 aTopRight.
x = aBotRight.
x;
572 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
576 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
580 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
584 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
602 std::vector<EDA_ITEM*>& aUpdatedItems )
override
627 std::vector<EDA_ITEM*>& aUpdatedItems )
override
688 std::vector<EDA_ITEM*>& aUpdatedItems )
override
704 const VECTOR2I newOffset = xfrmOrigin - ( topLeft + botRight ) / 2;
719 oldCorner -= oldSize / 2;
723 newCorner = topRight;
724 oldCorner -=
VECTOR2I( -oldSize.
x, oldSize.
y ) / 2;
729 oldCorner -=
VECTOR2I( oldSize.
x, -oldSize.
y ) / 2;
733 newCorner = botRight;
734 oldCorner += oldSize / 2;
740 *newCorner -= xfrmOrigin;
741 oldCorner -= oldOrigin;
744 if(
sign( newCorner->x ) !=
sign( oldCorner.
x ) ||
sign( newCorner->y ) !=
sign( oldCorner.
y ) )
752 double ratio = oldLength > 0 ? ( newLength / oldLength ) : 1.0;
758 ratio = std::min( newWidth / oldSize.
x, newHeight / oldSize.
y );
795 auto set45Constraint =
824 std::vector<EDA_ITEM*>& aUpdatedItems )
override
873 wxFAIL_MSG( wxT(
"MakePoints: unhandled PCB_GRID_TYPE" ) );
904 wxFAIL_MSG( wxT(
"UpdatePoints: unhandled PCB_GRID_TYPE" ) );
910 std::vector<EDA_ITEM*>& aUpdatedItems )
override
927 const double dragAngle = std::atan2( worldOff.
y, worldOff.
x );
928 const int newRadius = std::max( 1,
KiROUND( std::hypot( worldOff.
x, worldOff.
y ) ) );
929 const double orientOld =
m_gridItem.GetOrientation().AsRadians();
930 const double phiMaxOld =
m_gridItem.GetPhiExtent().AsRadians();
935 const auto wrap2pi = [](
double a )
939 while( a >= 2 *
M_PI )
948 const double newOrient = -dragAngle;
949 const double newPhiMax = wrap2pi( phiMaxOld - orientOld - dragAngle );
957 const double newPhiMax = wrap2pi( dragAngle + orientOld );
964 const double newOrient = phiMaxOld / 2.0 - dragAngle;
976 const int newHalfX = std::max( 1,
std::abs( local.
x ) );
977 const int newHalfY = std::max( 1,
std::abs( local.
y ) );
986 wxFAIL_MSG( wxT(
"UpdateItem: unhandled PCB_GRID_TYPE" ) );
1009 const int sx = ( aX == 0 ) ? -1 : +1;
1010 const int sy = ( aY == 0 ) ? -1 : +1;
1018 const double phi =
m_gridItem.GetPhiExtent().AsRadians();
1025 const double phi =
m_gridItem.GetPhiExtent().AsRadians() / 2.0;
1059 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1065 aUpdatedItems.push_back( &
table );
1071 int colWidth =
m_cell.GetRectangleWidth();
1073 for(
int ii = 0; ii <
m_cell.GetColSpan() - 1; ++ii )
1074 colWidth -=
table.GetColWidth(
m_cell.GetColumn() + ii );
1082 int rowHeight =
m_cell.GetRectangleHeight();
1084 for(
int ii = 0; ii <
m_cell.GetRowSpan() - 1; ++ii )
1085 rowHeight -=
table.GetRowHeight(
m_cell.GetRow() + ii );
1098 std::vector<VECTOR2I> corners =
m_cell.GetCorners();
1100 return aPoint ==
COL_WIDTH ? ( corners[1] + corners[2] ) / 2 : ( corners[2] + corners[3] ) / 2;
1133 if(
m_pad.IsLocked() )
1148 if( !
m_pad.GetOrientation().IsCardinal() )
1151 if(
m_pad.GetOrientation().IsVertical() )
1152 std::swap( halfSize.
x, halfSize.
y );
1155 aPoints.
AddPoint( shapePos - halfSize );
1157 aPoints.
AddPoint( shapePos + halfSize );
1177 int target =
locked ? 0 : 1;
1185 else if( target == 1 )
1187 shapePos.
x += halfSize.
x;
1200 int target =
locked || !
m_pad.GetOrientation().IsCardinal() ? 0 : 4;
1207 else if( target == 4 )
1209 if(
m_pad.GetOrientation().IsVertical() )
1210 std::swap( halfSize.
x, halfSize.
y );
1214 shapePos.
y - halfSize.
y ) );
1217 shapePos.
y + halfSize.
y ) );
1231 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1258 botLeft, botRight, holeCenter, holeSize );
1261 || (
m_pad.GetDrillSize().x &&
m_pad.GetDrillSize().y ) )
1271 dist[0] =
center.x - topLeft.
x;
1272 dist[1] =
center.y - topLeft.
y;
1273 dist[2] = botRight.
x -
center.x;
1274 dist[3] = botRight.
y -
center.y;
1278 dist[0] =
center.x - botLeft.
x;
1279 dist[1] =
center.y - topRight.
y;
1280 dist[2] = topRight.
x -
center.x;
1281 dist[3] = botLeft.
y -
center.y;
1284 VECTOR2I padSize( dist[0] + dist[2], dist[1] + dist[3] );
1285 VECTOR2I deltaOffset( padSize.
x / 2 - dist[2], padSize.
y / 2 - dist[3] );
1287 if(
m_pad.GetOrientation().IsVertical() )
1288 std::swap( padSize.
x, padSize.
y );
1307 bottom = botRight.
y;
1319 if(
m_pad.GetOrientation().IsVertical() )
1320 std::swap( padSize.
x, padSize.
y );
1362 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1386 m_oldCrossBar(
SEG{ aDimension.GetCrossbarStart(), aDimension.GetCrossbarEnd() } )
1409 const VECTOR2I newProject = newCrossBar.LineProject( newTextPos );
1411 const VECTOR2I oldProjectedOffset =
1413 const VECTOR2I newProjectedOffset = newProject - newCrossBar.NearestPoint( newProject );
1415 const bool textWasLeftOf = oldProjectedOffset.
x < 0
1416 || ( oldProjectedOffset.
x == 0 && oldProjectedOffset.
y > 0 );
1417 const bool textIsLeftOf = newProjectedOffset.
x < 0
1418 || ( newProjectedOffset.
x == 0 && newProjectedOffset.
y > 0 );
1420 if( textWasLeftOf != textIsLeftOf )
1440 const EDA_ANGLE rotation = oldAngle - newAngle;
1453 rotTextOffsetFromCbCenter,
1454 newCrossBar.Center() );
1460 return newCbRefPt + rotTextOffsetFromCbEnd;
1473 const VECTOR2I newProjected = newCrossBar.A + ( newCrossBar.B - newCrossBar.A ) * oldRatio;
1474 return newProjected + rotCbNormalToText;
1529 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1566 if( featureLine.
Cross( crossBar ) > 0 )
1578 if( featureLine.
Cross( crossBar ) > 0 )
1638 VECTOR2I direction = ( directionA < directionB ) ? directionA : directionB;
1644 if( !bounds.
Contains( cursorPos ) )
1667 m_dimension.SetHeight( vert ? featureLine.
x : featureLine.
y );
1722 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1739 return std::nullopt;
1785 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1837 return std::nullopt;
1876 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1936 std::vector<EDA_ITEM*>& aUpdatedItems )
override
1959 if( item->Type() == PCB_SHAPE_T )
1961 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
1962 m_shapes.push_back( shape );
1963 m_originalWidths[shape] = static_cast<double>( shape->GetWidth() );
2010 std::vector<EDA_ITEM*>& aUpdatedItems )
override
2029 shape->Move(
delta );
2034 aUpdatedItems.push_back( shape );
2047 double sx =
static_cast<double>( br.
x - tl.
x ) /
static_cast<double>( oldBox.
GetWidth() );
2048 double sy =
static_cast<double>( br.
y - tl.
y ) /
static_cast<double>( oldBox.
GetHeight() );
2049 double scale = ( sx + sy ) / 2.0;
2062 shape->Move( -oldCenter );
2063 shape->Scale(
scale );
2064 shape->Move( oldCenter );
2068 shapeIt->second = shapeIt->second *
scale;
2069 shape->SetWidth(
KiROUND( shapeIt->second ) );
2073 shape->SetWidth(
KiROUND( shape->GetWidth() *
scale ) );
2076 aUpdatedItems.push_back( shape );
2090 bbox.
Merge( shape->GetBoundingBox() );
2165 const auto type = aItem.
Type();
2184 double angleRad = aAngleDeg *
M_PI / 180.0;
2187 double chord = (
next - prev ).EuclideanNorm();
2188 double sinA = sin( angleRad );
2190 if( chord == 0.0 || fabs( sinA ) < 1e-9 )
2193 double radius = chord / ( 2.0 * sinA );
2198 double h_sq =
radius *
radius - ( chord * chord ) / 4.0;
2199 double h = h_sq > 0.0 ? sqrt( h_sq ) : 0.0;
2223 return d1 < d2 ? p1 : p2;
2232 wxASSERT_MSG(
m_selectionTool, wxT(
"pcbnew.InteractiveSelection tool is not available" ) );
2234 const auto arcIsEdited =
2235 [](
const SELECTION& aSelection ) ->
bool
2237 const EDA_ITEM* item = aSelection.Front();
2254 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
2262 switch( aItem->
Type() )
2267 m_editorBehavior = std::make_unique<REFERENCE_IMAGE_POINT_EDIT_BEHAVIOR>( refImage );
2273 m_editorBehavior = std::make_unique<BARCODE_POINT_EDIT_BEHAVIOR>( barcode );
2285 m_editorBehavior = std::make_unique<TEXTBOX_POINT_EDIT_BEHAVIOR>( textbox );
2295 m_editorBehavior = std::make_unique<EDA_SEGMENT_POINT_EDIT_BEHAVIOR>( *shape );
2299 m_editorBehavior = std::make_unique<RECTANGLE_POINT_EDIT_BEHAVIOR>( *shape );
2309 m_editorBehavior = std::make_unique<EDA_CIRCLE_POINT_EDIT_BEHAVIOR>( *shape );
2313 m_editorBehavior = std::make_unique<EDA_POLYGON_POINT_EDIT_BEHAVIOR>( *shape );
2317 m_editorBehavior = std::make_unique<EDA_BEZIER_POINT_EDIT_BEHAVIOR>( *shape,
2323 m_editorBehavior = std::make_unique<EDA_ELLIPSE_POINT_EDIT_BEHAVIOR>( *shape );
2336 bool shapesOnly =
true;
2361 m_editorBehavior = std::make_unique<PCB_TABLECELL_POINT_EDIT_BEHAVIOR>( *cell );
2385 ZONE& zone =
static_cast<ZONE&
>( *aItem );
2395 m_editorBehavior = std::make_unique<GENERATOR_POLY_POINT_EDIT_BEHAVIOR>( *generator );
2401 m_editorBehavior = std::make_unique<GENERATOR_POINT_EDIT_BEHAVIOR>( *generator );
2410 m_editorBehavior = std::make_unique<ALIGNED_DIMENSION_POINT_EDIT_BEHAVIOR>( dimension );
2417 m_editorBehavior = std::make_unique<DIM_CENTER_POINT_EDIT_BEHAVIOR>( dimension );
2424 m_editorBehavior = std::make_unique<DIM_RADIAL_POINT_EDIT_BEHAVIOR>( dimension );
2431 m_editorBehavior = std::make_unique<DIM_LEADER_POINT_EDIT_BEHAVIOR>( dimension );
2506 if( selItem->GetEditFlags() || !selItem->IsBOARD_ITEM() )
2513 if( !item || ( item->
IsLocked() && !overrideLocks ) )
2521 grid.SetPointEditProfile(
true );
2525 std::vector<std::unique_ptr<BOARD_ITEM>> clones;
2532 std::vector<PCB_SHAPE*> shapes;
2533 bool allShapes =
true;
2534 bool anyLocked =
false;
2541 shapes.push_back( shape );
2552 if( allShapes && shapes.size() > 1 && ( !anyLocked || overrideLocks ) )
2555 std::move( shapes ), item );
2595 bool inDrag =
false;
2596 bool isConstrained =
false;
2597 bool haveSnapLineDirections =
false;
2599 auto updateSnapLineDirections =
2602 std::vector<VECTOR2I> directions;
2616 if( directions.empty() )
2618 grid.SetSnapLineDirections( {} );
2619 grid.SetSnapLineEnd( std::nullopt );
2620 haveSnapLineDirections =
false;
2626 grid.SetSnapLineDirections( directions );
2627 grid.SetSnapLineOrigin( origin );
2628 grid.SetSnapLineEnd( std::nullopt );
2629 haveSnapLineDirections =
true;
2635 auto installFeasibilityCallback =
2638 grid.SetFeasibilityCallback( {} );
2645 grid.SetFeasibilityCallback(
2647 const std::vector<SNAP_CANDIDATE>& aCandidates )
2649 return session->ResolveCandidates( aContext, aCandidates );
2657 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
2658 installFeasibilityCallback();
2687 frame()->UndoRedoBlock(
true );
2702 if( std::optional<CONSTRAINT_MEMBER> member =
2710 installFeasibilityCallback();
2719 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
2735 shape->UpdateHatching();
2740 clones.emplace_back( clone );
2741 grid.AddConstructionItems( { clone },
false, true );
2743 updateSnapLineDirections();
2747 bool ctrlHeld = evt->Modifier(
MD_CTRL );
2751 if( isConstrained != need_constraint )
2754 isConstrained = need_constraint;
2755 updateSnapLineDirections();
2758 if( need_constraint )
2766 grid.SetAngleRestriction( std::nullopt, 0.0 );
2773 bool isPoly =
false;
2775 switch( item->
Type() )
2798 if( policy->
GetMode() != targetMode )
2799 policy->
SetMode( targetMode );
2817 if(
grid.GetUseGrid() )
2822 bool snappedAlongPerp =
false;
2844 double step = std::hypot( gridSize.
x * perpUnit.
x,
2845 gridSize.
y * perpUnit.
y );
2849 double offset =
VECTOR2D( pos - origCenter ).
Dot( perpUnit );
2850 double snapped = std::round( offset / step ) * step;
2853 snappedAlongPerp =
true;
2858 if( !snappedAlongPerp )
2861 grid.ResolveSnap( pos, {},
grid.GetItemGrid( item ), { item } )
2868 -
grid.ResolveSnap( last, {},
grid.GetItemGrid( item ), { item } )
2871 if( abs(
delta.x ) >
grid.GetGrid().x / 2 )
2872 pos.
x = last.
x + deltaGrid.
x;
2876 if( abs(
delta.y ) >
grid.GetGrid().y / 2 )
2877 pos.
y = last.
y + deltaGrid.
y;
2899 bool isFreePolygon =
2907 if( idx != wxNOT_FOUND )
2910 int nextIdx = ( idx + 1 ) %
m_editPoints->PointsSize();
2913 SEG segA( pos, prev );
2916 double snapAng = 45.0 * std::round( ang / 45.0 );
2918 if(
std::abs( ang - snapAng ) < 2.0 )
2925 grid.ResolveSnap( snapped, {},
grid.GetItemGrid( item ), { item } )
2929 snapped =
std::abs( griddedAng - snapAng ) < 2.0 ? gridded : pos;
2932 if( snapped != pos )
2943 bool constraintSnapped =
false;
2944 std::vector<VECTOR2I> stationarySelfPoints;
2945 std::vector<SEG> stationarySelfSegments;
2953 for(
unsigned i = 0; i <
m_editPoints->PointsSize(); ++i )
2960 && &point != &editedLine->
GetEnd() ) ) )
2962 stationarySelfPoints.push_back( point.
GetPosition() );
2966 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
2970 if( &stationaryLine != editedLine
2977 && &stationaryLine.
GetEnd() != &editedLine->
GetEnd() ) ) )
2979 stationarySelfSegments.emplace_back(
2992 int opposite = ( editedIndex + 2 ) % 4;
2993 stationarySelfPoints.push_back(
m_editPoints->Point( opposite ).GetPosition() );
2997 for(
unsigned i = 0; i <
m_editPoints->LinesSize() && i < 4; ++i )
3012 constexpr int arcStart = 0;
3013 constexpr int arcMid = 1;
3014 constexpr int arcEnd = 2;
3015 constexpr int arcCenter = 3;
3019 if( editedIndex != arcStart )
3020 stationarySelfPoints.push_back(
m_editPoints->Point( arcStart ).GetPosition() );
3022 if( editedIndex != arcEnd )
3023 stationarySelfPoints.push_back(
m_editPoints->Point( arcEnd ).GetPosition() );
3025 else if( editedIndex == arcStart || editedIndex == arcMid || editedIndex == arcEnd )
3027 stationarySelfPoints.push_back(
m_editPoints->Point( arcCenter ).GetPosition() );
3032 grid.SetStationarySelfGeometry( std::move( stationarySelfPoints ),
3033 std::move( stationarySelfSegments ) );
3039 grid.ResolveSnap( pos, snapLayers,
grid.GetItemGrid( item ), { item } )
3041 constraintSnapped =
true;
3047 constraintSnapped =
true;
3052 if(
grid.GetSnap() && !snapLayers.empty() )
3056 grid.ResolveSnap( constrainedPos, snapLayers,
grid.GetItemGrid( item ),
3061 if( snapPos != constrainedPos )
3067 if( projectedPos != snapPos )
3075 grid.ResolveSnap( pos, snapLayers,
grid.GetItemGrid( item ), { item } )
3083 if( haveSnapLineDirections )
3086 grid.SetSnapLineOrigin( snapOrigin );
3088 if( constraintSnapped )
3091 grid.SetSnapLineEnd( std::nullopt );
3105 int radius = rect->GetCornerRadius();
3107 VECTOR2I topLeft = rect->GetTopLeft();
3108 VECTOR2I botRight = rect->GetBotRight();
3126 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
3139 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
3157 updateSnapLineDirections();
3174 commit.
Push(
_(
"Resize Table Cells" ) );
3178 commit.
Push(
_(
"Move Point" ) );
3184 shape->UpdateHatching();
3189 frame()->UndoRedoBlock(
false );
3190 updateSnapLineDirections();
3194 else if( evt->IsCancelInteractive() || evt->IsActivate() )
3209 shape->UpdateHatching();
3214 frame()->UndoRedoBlock(
false );
3215 updateSnapLineDirections();
3221 if( evt->IsActivate() && !evt->IsMoveTool() )
3252 evt->SetPassEvent();
3263 shape->UpdateHatching();
3287 grid.SetSnapLineDirections( {} );
3309 title =
_(
"Move Midpoint to Location" );
3310 msg =
_(
"Move Midpoint" );
3314 title =
_(
"Move Corner to Location" );
3315 msg =
_(
"Move Corner" );
3340 std::vector<EDA_ITEM*> updatedItems = { item };
3352 auto anyConstraints =
3364 if( !fp->Constraints().empty() )
3377 std::optional<CONSTRAINT_MEMBER> member;
3378 std::optional<std::pair<CONSTRAINT_MEMBER, VECTOR2I>> coDragged;
3416 if( !member.has_value() )
3418 for(
unsigned i = 0; i <
m_editPoints->LinesSize() && i < 4; ++i )
3437 for(
unsigned i = 0; i <
m_editPoints->PointsSize(); ++i )
3453 if( !member.has_value() )
3455 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
3480 std::vector<PCB_SHAPE*> modified;
3484 auto stageNeighbor = [&](
BOARD_ITEM* aItem )
3489 updatedItems.push_back( aItem );
3492 if( member.has_value() )
3506 false, {}, coDragged );
3511 false,
false, {}, coDragged );
3528 updatedItems.push_back( neighbor );
3533 switch( item->
Type() )
3544 if(
pad->IsEntered() )
3551 textBox->ClearRenderCache();
3579 for(
EDA_ITEM* updatedItem : updatedItems )
3582 frame()->SetMsgPanel( item );
3599 int editedIndex = -1;
3600 bool editingLine =
false;
3605 for(
unsigned ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
3615 if( editedIndex == -1 )
3617 for(
unsigned ii = 0; ii <
m_editPoints->LinesSize(); ++ii )
3638 if( editedIndex >= 0 )
3640 if( editingLine && editedIndex < (
int)
m_editPoints->LinesSize() )
3642 else if( !editingLine && editedIndex < (
int)
m_editPoints->PointsSize() )
3671 if(
frame()->ToolStackIsEmpty() )
3674 controls->ForceCursorPosition(
false );
3685 bool isPoly =
false;
3689 switch( parent->
Type() )
3706 if( line && isPoly )
3730 if( line && isPoly )
3765 auto vertexIdx = it.GetIndex();
3768 return std::make_pair(
true, vertexIdx );
3786 switch( item->
Type() )
3789 polyset =
static_cast<ZONE*
>( item )->Outline();
3794 polyset = &
static_cast<PCB_SHAPE*
>( item )->GetPolyShape();
3847 unsigned int nearestIdx = 0;
3848 unsigned int nextNearestIdx = 0;
3849 unsigned int nearestDist = INT_MAX;
3850 unsigned int firstPointInContour = 0;
3855 ZONE* zone =
static_cast<ZONE*
>( item );
3856 zoneOutline = zone->
Outline();
3875 for( ; iterator; iterator++, curr_idx++ )
3877 int jj = curr_idx+1;
3881 jj = firstPointInContour;
3882 firstPointInContour = curr_idx+1;
3885 SEG curr_segment( zoneOutline->
CVertex( curr_idx ), zoneOutline->
CVertex( jj ) );
3892 nearestIdx = curr_idx;
3893 nextNearestIdx = jj;
3900 SEG nearestSide( sideOrigin, sideEnd );
3905 if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
3906 nearestPoint = ( sideOrigin + sideEnd ) / 2;
3908 zoneOutline->
InsertVertex( nextNearestIdx, nearestPoint );
3912 if( graphicItem && nextNearestIdx < (
unsigned) zoneOutline->
COutline( 0 ).
PointCount() )
3915 [&](
BOARD_ITEM* aConstraint ) { commit.Modify( aConstraint ); },
3916 [&](
BOARD_ITEM* aConstraint ) { commit.Remove( aConstraint ); } );
3920 static_cast<ZONE*
>( item )->HatchBorder();
3922 commit.
Push(
_(
"Add Zone Corner" ) );
3924 else if( graphicItem )
3930 commit.
Modify( graphicItem );
3936 graphicItem->
SetEnd( nearestPoint );
3941 newSegment->
SetStart( nearestPoint );
3944 commit.
Add( newSegment );
3945 commit.
Push(
_(
"Split Segment" ) );
3950 commit.
Modify( graphicItem );
3956 graphicItem->
SetEnd( nearestPoint );
3965 commit.
Add( newArc );
3966 commit.
Push(
_(
"Split Arc" ) );
3994 ZONE* zone =
static_cast<ZONE*
>( item );
4015 const auto& vertexIdx = vertex.second;
4016 auto& outline = polygon->
Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
4018 if( outline.PointCount() > 3 )
4029 [&](
BOARD_ITEM* aConstraint ) { commit.Modify( aConstraint ); },
4030 [&](
BOARD_ITEM* aConstraint ) { commit.Remove( aConstraint ); } );
4036 if( vertexIdx.m_contour > 0 )
4052 commit.
Push(
_(
"Remove Zone Corner" ) );
4054 commit.
Push(
_(
"Remove Polygon Corner" ) );
4057 static_cast<ZONE*
>( item )->HatchBorder();
4080 ZONE* zone =
static_cast<ZONE*
>( item );
4101 unsigned int nearestIdx = 0;
4102 unsigned int nearestDist = INT_MAX;
4110 for( ; iterator; iterator++, curr_idx++ )
4117 nearestIdx = curr_idx;
4121 int prevIdx, nextIdx;
4129 setback = std::min( setback, (
int) ( segA.Length() * 0.25 ) );
4130 setback = std::min( setback, (
int) ( segB.Length() * 0.25 ) );
4134 std::optional<CHAMFER_RESULT> chamferResult =
ComputeChamferPoints( segA, segB, chamferParams );
4136 if( chamferResult && chamferResult->m_updated_seg_a && chamferResult->m_updated_seg_b )
4142 polygon->
InsertVertex( nearestIdx, chamferResult->m_updated_seg_b->B );
4143 polygon->
InsertVertex( nearestIdx, chamferResult->m_updated_seg_a->B );
4149 auto modify = [&](
BOARD_ITEM* aConstraint ) { commit.
Modify( aConstraint ); };
4150 auto remove = [&](
BOARD_ITEM* aConstraint ) { commit.
Remove( aConstraint ); };
4161 commit.
Push(
_(
"Break Zone Corner" ) );
4163 commit.
Push(
_(
"Break Polygon Corner" ) );
4166 static_cast<ZONE*
>( item )->HatchBorder();
ARC_EDIT_MODE
Settings for arc editing.
@ KEEP_ENDPOINTS_OR_START_DIRECTION
Whe editing endpoints, the other end remains in place.
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
When editing endpoints, the angle and radius are adjusted.
constexpr EDA_IU_SCALE pcbIUScale
void ReSolveAfterShapeResize(BOARD *aBoard, PCB_SHAPE *aShape, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify)
Re-solve after a resize, e.g. a circle radius edit. Holds aShape fixed so its neighbors adjust.
CONSTRAINT_DIAGNOSIS SolveCluster(BOARD *aBoard, const CONSTRAINT_MEMBER &aDragged, const VECTOR2I &aCursor, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify, bool aIncludeDragged, bool aStabilize, const std::set< KIID > &aEdited, const std::optional< std::pair< CONSTRAINT_MEMBER, VECTOR2I > > &aCoDragged, const std::set< KIID > &aFixedShapes, bool aHoldDraggedRigid)
Gather the cluster of shapes transitively constrained with the dragged shape, solve with the dragged ...
bool ReSolveShapeClustersHoldingEdited(BOARD *aBoard, const std::vector< PCB_SHAPE * > &aEditedShapes, std::vector< PCB_SHAPE * > *aModified, const std::function< void(BOARD_ITEM *)> &aBeforeModify)
Re-solve clusters whose new geometry is authoritative holding every edited shape fully fixed so only ...
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION cycleArcEditMode
static TOOL_ACTION pointEditorArcKeepCenter
static TOOL_ACTION pointEditorArcKeepRadius
static TOOL_ACTION reselectItem
static TOOL_ACTION activatePointEditor
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION pointEditorArcKeepEndpoint
PCB_DIM_ALIGNED & m_dimension
void updateOrthogonalDimension(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints)
Update orthogonal dimension points.
ALIGNED_DIMENSION_POINT_EDIT_BEHAVIOR(PCB_DIM_ALIGNED &aDimension)
void updateAlignedDimension(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints)
Update non-orthogonal dimension points.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
OPT_VECTOR2I Get45DegreeConstrainer(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints) const override
Get the 45-degree constrainer for the item, when the given point is moved.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
BARCODE_POINT_EDIT_BEHAVIOR(PCB_BARCODE &aBarcode)
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
PCB_SHAPE makeDummyRect()
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE) override
Add a change of the item aItem of type aChangeType to the change list.
virtual void Revert() override
Revert the commit by restoring the modified items state.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
virtual BOARD_ITEM * Duplicate(bool addToParentGroup, BOARD_COMMIT *aCommit=nullptr) const
Create a copy of this BOARD_ITEM.
bool IsLocked() const override
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
constexpr void SetMaximum()
constexpr const Vec GetEnd() const
constexpr size_type GetWidth() const
constexpr Vec Centre() const
constexpr BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
constexpr const Vec GetCenter() const
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr const Vec & GetOrigin() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
Represent a set of changes (additions, deletions or modifications) of a data model (e....
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Add a new item to the model.
Class to help update the text position of a dimension when the crossbar changes.
DIM_ALIGNED_TEXT_UPDATER(PCB_DIM_ALIGNED &aDimension)
VECTOR2I getDimensionNewTextPosition()
PCB_DIM_ALIGNED & m_dimension
const VECTOR2I m_originalTextPos
void UpdateTextAfterChange()
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
PCB_DIM_CENTER & m_dimension
OPT_VECTOR2I Get45DegreeConstrainer(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints) const override
Get the 45-degree constrainer for the item, when the given point is moved.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
DIM_CENTER_POINT_EDIT_BEHAVIOR(PCB_DIM_CENTER &aDimension)
DIM_LEADER_POINT_EDIT_BEHAVIOR(PCB_DIM_LEADER &aDimension)
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
PCB_DIM_LEADER & m_dimension
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
DIM_RADIAL_POINT_EDIT_BEHAVIOR(PCB_DIM_RADIAL &aDimension)
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
OPT_VECTOR2I Get45DegreeConstrainer(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints) const override
Get the 45-degree constrainer for the item, when the given point is moved.
PCB_DIM_RADIAL & m_dimension
bool IsType(FRAME_T aType) const
bool GetOverrideLocks() const
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
virtual void SetParent(EDA_ITEM *aParent)
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
virtual VECTOR2I GetTopLeft() const
void SetCornerRadius(int aRadius)
SHAPE_POLY_SET & GetPolyShape()
virtual VECTOR2I GetBotRight() const
virtual void SetBottom(int val)
virtual void SetTop(int val)
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
virtual void SetLeft(int val)
virtual void SetRight(int val)
int GetCornerRadius() const
VECTOR2I GetArcMid() const
EDA_TABLECELL_POINT_EDIT_BEHAVIOR(EDA_SHAPE &aCell)
Represent a line connecting two EDIT_POINTs.
POLYGON_EDGE_DRAG_POLICY * GetDragPolicy() const
void SetRelation(std::unique_ptr< EDIT_RELATION > aRelation)
Set a relation for an EDIT_LINE.
EDIT_POINT & GetEnd()
Return the end EDIT_POINT.
EDIT_POINT & GetOrigin()
Return the origin EDIT_POINT.
EDIT_POINTS is a VIEW_ITEM that manages EDIT_POINTs and EDIT_LINEs and draws them.
unsigned int PointsSize() const
Return number of stored EDIT_POINTs.
void AddPoint(const EDIT_POINT &aPoint)
Add an EDIT_POINT.
void SetSwapY(bool aSwap)
void Clear()
Clear all stored EDIT_POINTs and EDIT_LINEs.
EDIT_LINE & Line(unsigned int aIndex)
void AddIndicatorLine(EDIT_POINT &aOrigin, EDIT_POINT &aEnd)
Adds an EDIT_LINE that is shown as an indicator, rather than an editable line (no center point drag,...
void SetSwapX(bool aSwap)
unsigned int LinesSize() const
Return number of stored EDIT_LINEs.
EDIT_POINT & Point(unsigned int aIndex)
void AddLine(const EDIT_LINE &aLine)
Adds an EDIT_LINE.
Represent a single point that can be used for modifying items.
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
void SetSnapConstraint(SNAP_CONSTRAINT_TYPE aConstraint)
int GetX() const
Return X coordinate of an EDIT_POINT.
void SetRelation(std::unique_ptr< EDIT_RELATION > aRelation)
Set a relation for an EDIT_POINT.
void SetActive(bool aActive=true)
void SetDrawCircle(bool aDrawCircle=true)
static std::unique_ptr< EDIT_RELATION > Angle90(const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > Angle45(const EDIT_POINT &aReference)
static std::unique_ptr< EDIT_RELATION > PerpendicularTranslation(const EDIT_LINE &aLine)
const VECTOR2I & Direction() const
static std::unique_ptr< EDIT_RELATION > PointOnLine(const EDIT_POINT &aConstrained, const EDIT_POINT &aReference)
EDIT_RELATION_KIND Kind() const
static const TOOL_EVENT InhibitSelectionEditing
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 UninhibitSelectionEditing
Used to inform tool that it should display the disambiguation menu.
static const TOOL_EVENT PointSelectedEvent
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
static const TOOL_EVENT UnselectedEvent
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
PCB_GENERATOR & m_generator
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
GENERATOR_POINT_EDIT_BEHAVIOR(PCB_GENERATOR &aGenerator)
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
PCB_GENERATOR_POLY & m_gen
GENERATOR_POLY_POINT_EDIT_BEHAVIOR(PCB_GENERATOR_POLY &aGen)
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
VECTOR2I toLocal(const VECTOR2I &aWorld) const
VECTOR2I radiusEndLocal() const
VECTOR2I arcEndLocal() const
GRID_POINT_EDIT_BEHAVIOR(PCB_GRID_ITEM &aGridItem)
VECTOR2I arcMidLocal() const
VECTOR2I cornerLocal(int aX, int aY) const
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
VECTOR2I toWorld(const VECTOR2I &aLocal) const
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
PCB_GRID_ITEM & m_gridItem
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
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 void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
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...
LSET is a set of PCB_LAYER_IDs.
static const LSET & AllLayersMask()
static constexpr PCB_LAYER_ID TEMP_ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
PAD_POINT_EDIT_BEHAVIOR(PAD &aPad, PCB_LAYER_ID aLayer)
ARC_EDIT_MODE m_ArcEditMode
static TOOL_ACTION layerChanged
static TOOL_ACTION pointEditorMoveMidpoint
static TOOL_ACTION genFinishEdit
static TOOL_ACTION genStartEdit
static TOOL_ACTION pointEditorMoveCorner
static TOOL_ACTION genCancelEdit
static TOOL_ACTION genUpdateEdit
static TOOL_ACTION pointEditorChamferCorner
static TOOL_ACTION pointEditorRemoveCorner
static TOOL_ACTION pointEditorAddCorner
Common, abstract interface for edit frames.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
For better understanding of the points that make a dimension:
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
void SetOrientation(DIR aOrientation)
Set the orientation of the dimension line (so, perpendicular to the feature lines).
DIR GetOrientation() const
A radial dimension indicates either the radius or diameter of an arc or circle.
virtual wxString GetCommitMessage() const =0
A set of BOARD_ITEMs (i.e., without duplicates).
std::unordered_set< BOARD_ITEM * > GetBoardItems() const
int changeArcEditMode(const TOOL_EVENT &aEvent)
bool CanRemoveCorner(const SELECTION &aSelection)
Condition to display "Remove Corner" context menu entry.
void updateItem(BOARD_COMMIT &aCommit)
Update edit points with item's points.
VECTOR2I m_stickyDisplacement
int OnSelectionChange(const TOOL_EVENT &aEvent)
Change selection event handler.
void setAltConstraint(bool aEnabled)
Return a point that should be used as a constrainer for 45 degrees mode.
static const unsigned int COORDS_PADDING
EDIT_POINT * m_hoveredPoint
int addCorner(const TOOL_EVENT &aEvent)
bool HasPoint()
Indicate the cursor is over an edit point.
EDIT_POINT m_original
Original pos for the current drag point.
static bool CanChamferCorner(const EDA_ITEM &aItem)
Check if a corner of the given item can be chamfered (zones, polys only).
EDIT_POINT get45DegConstrainer() const
int modifiedSelection(const TOOL_EVENT &aEvent)
Change the edit method for arcs.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
std::unique_ptr< POINT_EDIT_BEHAVIOR > m_editorBehavior
int removeCorner(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
std::shared_ptr< BOARD_CONSTRAINT_DRAG_SESSION > m_constraintDragSession
std::unique_ptr< EDIT_RELATION > m_altConstraint
RECT_RADIUS_TEXT_ITEM * m_radiusHelper
int movePoint(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
static bool CanAddCorner(const EDA_ITEM &aItem)
Check if a corner can be added to the given item (zones, polys, segments, arcs).
void setEditedPoint(EDIT_POINT *aPoint)
EDIT_POINT m_altConstrainer
bool isModified(const EDIT_POINT &aPoint) const
Set up an alternative constraint (typically enabled upon a modifier key being pressed).
ARC_EDIT_MODE m_arcEditMode
std::unique_ptr< KIGFX::PREVIEW::ANGLE_ITEM > m_angleItem
EDIT_POINT * m_editedPoint
void updateEditedPoint(const TOOL_EVENT &aEvent)
Set the current point being edited. NULL means none.
int getEditedPointIndex() const
Return true if aPoint is the currently modified point.
void updatePoints()
Update which point is being edited.
int chamferCorner(const TOOL_EVENT &aEvent)
void setTransitions() override
< Set up handlers for various events.
std::shared_ptr< EDIT_POINTS > m_editPoints
std::shared_ptr< EDIT_POINTS > makePoints(EDA_ITEM *aItem)
Update item's points with edit points.
PCB_SELECTION_TOOL * m_selectionTool
Object to handle a bitmap image that can be inserted in a PCB.
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
void SetEnd(const VECTOR2I &aEnd) override
bool IsProxyItem() const override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetStart(const VECTOR2I &aStart) override
VECTOR2I unturned(const VECTOR2I &aPoint) const
VECTOR2I edgeMidpoint(TABLECELL_POINTS aPoint) const
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
PCB_TABLECELL_POINT_EDIT_BEHAVIOR(PCB_TABLECELL &aCell)
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
A helper class interface to manage the edit points for a single item.
static bool isModified(const EDIT_POINT &aEditedPoint, const EDIT_POINT &aPoint)
Checks if two points are the same instance - which means the point is being edited.
void SetMode(POLYGON_LINE_MODE aMode)
POLYGON_LINE_MODE GetMode() const
const VECTOR2I & GetOriginalCenter() const
const VECTOR2I & GetPerpVector() const
POLYGON_POINT_EDIT_BEHAVIOR(SHAPE_POLY_SET &aPolygon)
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
static void UpdateItem(SCH_SHAPE &aRect, const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, const VECTOR2I &aMinSize={ 0, 0 })
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
static void UpdateItem(PCB_SHAPE &aRectangle, const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, const VECTOR2I &aMinSize={ 0, 0 })
static void UpdatePoints(SCH_SHAPE &aRect, EDIT_POINTS &aPoints)
static void PinEditedCorner(const EDIT_POINT &aEditedPoint, const EDIT_POINTS &aPoints, int minWidth, int minHeight, VECTOR2I &topLeft, VECTOR2I &topRight, VECTOR2I &botLeft, VECTOR2I &botRight)
Update the coordinates of 4 corners of a rectangle, according to constraints and the moved corner.
static void PinEditedCorner(const EDIT_POINT &aEditedPoint, const EDIT_POINTS &aEditPoints, VECTOR2I &aTopLeft, VECTOR2I &aTopRight, VECTOR2I &aBotLeft, VECTOR2I &aBotRight, const VECTOR2I &aHole={ 0, 0 }, const VECTOR2I &aHoleSize={ 0, 0 }, const VECTOR2I &aMinSize={ 0, 0 })
Update the coordinates of 4 corners of a rectangle, according to constraints and the moved corner.
static void MakePoints(SCH_SHAPE &aRect, EDIT_POINTS &aPoints)
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
static void MakePoints(const PCB_SHAPE &aRectangle, EDIT_POINTS &aPoints)
Standard rectangle points construction utility (other shapes may use this as well)
static void UpdatePoints(const PCB_SHAPE &aRectangle, EDIT_POINTS &aPoints)
RECTANGLE_POINT_EDIT_BEHAVIOR(PCB_SHAPE &aRectangle)
const EDA_IU_SCALE & m_iuScale
wxString GetClass() const override
Return the class name.
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
void Set(int aRadius, const VECTOR2I &aCorner, const VECTOR2I &aQuadrant, EDA_UNITS aUnits)
RECT_RADIUS_TEXT_ITEM(const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits)
void ViewDraw(int aLayer, KIGFX::VIEW *aView) const override
Draw the parts of the object belonging to layer aLayer.
REFERENCE_IMAGE_POINT_EDIT_BEHAVIOR(PCB_REFERENCE_IMAGE &aRefImage)
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
PCB_REFERENCE_IMAGE & m_refImage
A REFERENCE_IMAGE is a wrapper around a BITMAP_IMAGE that is displayed in an editor as a reference fo...
void SetTransformOriginOffset(const VECTOR2I &aCenter)
VECTOR2I GetTransformOriginOffset() const
Get the center of scaling, etc, relative to the image center (GetPosition()).
VECTOR2I GetPosition() const
double GetImageScale() const
void SetImageScale(double aScale)
Set the image "zoom" value.
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
int Distance(const SEG &aSeg) const
Compute minimum Euclidean distance to segment aSeg.
EDA_ANGLE Angle(const SEG &aOther) const
Determine the smallest angle between two segments.
Class that groups generic conditions for selected items.
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.
VECTOR2I NearestPoint(const VECTOR2I &aP) const
const VECTOR2I & GetP1() const
SHAPE_GROUP_POINT_EDIT_BEHAVIOR(PCB_GROUP &aGroup)
SHAPE_GROUP_POINT_EDIT_BEHAVIOR(std::vector< PCB_SHAPE * > aShapes, BOARD_ITEM *aParent)
BOARD_ITEM * GetParent() const
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
std::unordered_map< PCB_SHAPE *, double > m_originalWidths
std::vector< PCB_SHAPE * > m_shapes
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
BOX2I getBoundingBox() const
int PointCount() const
Return the number of points (vertices) in this line chain.
bool IsEndContour() const
Represent a set of closed polygons.
ITERATOR_TEMPLATE< VECTOR2I > ITERATOR
ITERATOR IterateWithHoles(int aOutline)
void InsertVertex(int aGlobalIndex, const VECTOR2I &aNewVertex)
Adds a vertex in the globally indexed position aGlobalIndex.
POLYGON & Polygon(int aIndex)
Return the aIndex-th subpolygon in the set.
void RemoveVertex(int aGlobalIndex)
Delete the aGlobalIndex-th vertex.
void RemoveContour(int aContourIdx, int aPolygonIdx=-1)
Delete the aContourIdx-th contour of the aPolygonIdx-th polygon in the set.
bool GetNeighbourIndexes(int aGlobalIndex, int *aPrevious, int *aNext) const
Return the global indexes of the previous and the next corner of the aGlobalIndex-th corner of a cont...
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Return an object to iterate through the points of the polygons between aFirst and aLast.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the index-th vertex in a given hole outline within a given outline.
int OutlineCount() const
Return the number of outlines in the set.
const SHAPE_LINE_CHAIN & COutline(int aIndex) const
A textbox is edited as a rectnagle when it is orthogonally aligned.
TEXTBOX_POINT_EDIT_BEHAVIOR(PCB_TEXTBOX &aTextbox)
void MakePoints(EDIT_POINTS &aPoints) override
Construct the initial set of edit points for the item and append to the given list.
bool UpdatePoints(EDIT_POINTS &aPoints) override
Update the list of the edit points for the item.
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
EDA_UNITS GetUserUnits() const
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
double Distance(const VECTOR2< extended_type > &aVector) const
Compute the distance between two vectors.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
constexpr extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
VECTOR2I GetValue()
Return the value in internal units.
ZONE_POINT_EDIT_BEHAVIOR(ZONE &aZone)
void UpdateItem(const EDIT_POINT &aEditedPoint, EDIT_POINTS &aPoints, COMMIT &aCommit, std::vector< EDA_ITEM * > &aUpdatedItems) override
Update the item with the new positions of the edit points.
Handle a list of polygons defining a copper zone.
void SetNeedRefill(bool aNeedRefill)
SHAPE_POLY_SET * Outline()
This file is part of the common library.
void RemapPolygonVertexMembers(BOARD *aBoard, const KIID &aPoly, int aChangedIndex, int aDelta, const std::function< void(BOARD_ITEM *)> &aBeforeModify, const std::function< void(BOARD_ITEM *)> &aBeforeRemove)
Repoint persisted VERTEX constraint members after an outline edit of polygon aPoly inserts or removes...
std::optional< CONSTRAINT_ANCHOR_POINT > ConstraintShapeVertex(const PCB_SHAPE *aShape, int aIndex)
VERTEX anchor at ordinal aIndex of a rectangle or eligible polygon or std::nullopt if the shape has n...
bool ConstraintPolygonIsModelable(const PCB_SHAPE *aShape)
True when polygon has one non empty hole free arc free outline making it solver eligible Shared by ad...
std::optional< CHAMFER_RESULT > ComputeChamferPoints(const SEG &aSegA, const SEG &aSegB, const CHAMFER_PARAMS &aChamferParams)
Compute the chamfer points for a given line pair and chamfer parameters.
static constexpr double MIN_SCALE
static bool empty(const wxTextEntryBase *aCtrl)
const int minSize
Push and Shove router track width and via size dialog.
#define IS_MOVING
Item being moved.
@ RECTANGLE
Use RECTANGLE instead of RECT to avoid collision in a Windows header.
a few functions useful in geometry calculations.
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=1u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
@ LAYER_GP_OVERLAY
General purpose overlay.
@ LAYER_SELECT_OVERLAY
Selected items overlay.
PCB_LAYER_ID
A quick note on layer IDs:
constexpr int Mils2IU(const EDA_IU_SCALE &aIuScale, int mils)
bool PointProjectsOntoSegment(const VECTOR2I &aPoint, const SEG &aSeg)
Determine if a point projects onto a segment.
double GetLengthRatioFromStart(const VECTOR2I &aPoint, const SEG &aSeg)
Get the ratio of the vector to a point from the segment's start, compared to the segment's length.
const VECTOR2I & GetNearestEndpoint(const SEG &aSeg, const VECTOR2I &aPoint)
Get the nearest end of a segment to a point.
bool PointIsInDirection(const VECTOR2< T > &aPoint, const VECTOR2< T > &aDirection, const VECTOR2< T > &aFrom)
void DrawTextNextToCursor(KIGFX::VIEW *aView, const VECTOR2D &aCursorPos, const VECTOR2D &aTextQuadrant, const wxArrayString &aStrings, bool aDrawingDropShadows)
Draw strings next to the cursor.
wxString DimensionLabel(const wxString &prefix, double aVal, const EDA_IU_SCALE &aIuScale, EDA_UNITS aUnits, bool aIncludeUnits=true)
Get a formatted string showing a dimension to a sane precision with an optional prefix and unit suffi...
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
BARCODE class definition.
@ VERTEX
An indexed rectangle corner or polygon outline vertex; pairs with CONSTRAINT_MEMBER::m_index.
@ START
First endpoint of a segment or arc.
@ END
Second endpoint of a segment or arc.
@ CENTER
Center of an arc or circle.
@ MANUAL
Text placement is manually set by the user.
#define STATUS_ITEMS_ONLY
Class to handle a set of BOARD_ITEMs.
static VECTOR2I snapCorner(const VECTOR2I &aPrev, const VECTOR2I &aNext, const VECTOR2I &aGuess, double aAngleDeg)
static std::optional< CONSTRAINT_MEMBER > constraintMemberForEditPoint(PCB_SHAPE *aShape, EDIT_POINTS *aPoints, EDIT_POINT *aEditedPoint)
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEX > findVertex(SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
static std::vector< VECTOR2I > getConstraintDirections(EDIT_RELATION *aRelation)
static void appendDirection(std::vector< VECTOR2I > &aDirections, const VECTOR2I &aDirection)
ARC_EDIT_MODE IncrementArcEditMode(ARC_EDIT_MODE aMode)
#define CHECK_POINT_COUNT(aPoints, aExpected)
#define CHECK_POINT_COUNT_GE(aPoints, aExpected)
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
std::optional< VECTOR2I > OPT_VECTOR2I
std::vector< FAB_LAYER_COLOR > dummy
Parameters that define a simple chamfer operation.
One participant in a constraint: a referenced board item plus the feature of that item that participa...
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
KIBIS top(path, &reporter)
GR_TEXT_H_ALIGN_T
This is API surface mapped to common.types.HorizontalAlignment.
VECTOR2I GetRotated(const VECTOR2I &aVector, const EDA_ANGLE &aAngle)
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
@ 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_GENERATOR_T
class PCB_GENERATOR, generator on a 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_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ NOT_USED
the 3d code uses this value
@ PCB_BARCODE_T
class PCB_BARCODE, a barcode (graphic item)
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_GRID_ITEM_T
a subgrid placed on a board
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
constexpr int sign(T val)
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D
Supplemental functions for working with vectors and simple objects that interact with vectors.