29using namespace std::placeholders;
127 m_selectionTool( nullptr ),
128 m_editedPoint( nullptr ),
129 m_hoveredPoint( nullptr ),
132 m_altConstrainer(
VECTOR2I( 0, 0 ) ),
133 m_inPointEditorTool( false )
151 wxASSERT_MSG(
m_selectionTool, wxT(
"pcbnew.InteractiveSelection tool is not available" ) );
169 points->AddPoint( *iterator );
171 if( iterator.IsEndContour() )
176 for(
int i = 0; i < cornersCount - 1; ++i )
178 if( points->IsContourEnd( i ) )
179 points->AddLine( points->Point( i ), points->Point( points->GetContourStartIdx( i ) ) );
181 points->AddLine( points->Point( i ), points->Point( i + 1 ) );
183 points->Line( i ).SetConstraint(
new EC_PERPLINE( points->Line( i ) ) );
187 points->AddLine( points->Point( cornersCount - 1 ),
188 points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
190 points->Line( points->LinesSize() - 1 )
191 .SetConstraint(
new EC_PERPLINE( points->Line( points->LinesSize() - 1 ) ) );
197 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
208 if( shape->
GetShape() != SHAPE_T::RECTANGLE )
213 switch( aItem->
Type() )
223 points->AddPoint( topLeft );
224 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
225 points->AddPoint( botRight );
226 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
240 case SHAPE_T::SEGMENT:
241 points->AddPoint( shape->
GetStart() );
242 points->AddPoint( shape->
GetEnd() );
245 case SHAPE_T::RECTANGLE:
250 points->SetSwapX( topLeft.
x > botRight.
x );
251 points->SetSwapY( topLeft.
y > botRight.
y );
253 if( points->SwapX() )
254 std::swap( topLeft.
x, botRight.
x );
256 if( points->SwapY() )
257 std::swap( topLeft.
y, botRight.
y );
259 points->AddPoint( topLeft );
260 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
261 points->AddPoint( botRight );
262 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
277 points->AddPoint( shape->
GetStart() );
279 points->AddPoint( shape->
GetEnd() );
283 points->AddIndicatorLine( points->Point(
ARC_CENTER ), points->Point(
ARC_END ) );
286 case SHAPE_T::CIRCLE:
288 points->AddPoint( shape->
GetEnd() );
295 case SHAPE_T::BEZIER:
296 points->AddPoint( shape->
GetStart() );
299 points->AddPoint( shape->
GetEnd() );
301 points->AddIndicatorLine( points->Point(
BEZIER_START ),
324 const PAD*
pad =
static_cast<const PAD*
>( aItem );
335 case PAD_SHAPE::CIRCLE:
336 points->AddPoint(
VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y ) );
339 case PAD_SHAPE::OVAL:
340 case PAD_SHAPE::TRAPEZOID:
341 case PAD_SHAPE::RECTANGLE:
342 case PAD_SHAPE::ROUNDRECT:
343 case PAD_SHAPE::CHAMFERED_RECT:
345 if( !
pad->GetOrientation().IsCardinal() )
349 std::swap( halfSize.
x, halfSize.
y );
351 points->AddPoint( shapePos - halfSize );
352 points->AddPoint(
VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y - halfSize.
y ) );
353 points->AddPoint( shapePos + halfSize );
354 points->AddPoint(
VECTOR2I( shapePos.
x - halfSize.
x, shapePos.
y + halfSize.
y ) );
367 const ZONE* zone =
static_cast<const ZONE*
>( aItem );
384 points->AddPoint( dimension->
GetStart() );
385 points->AddPoint( dimension->
GetEnd() );
411 points->AddPoint( dimension->
GetStart() );
412 points->AddPoint( dimension->
GetEnd() );
427 points->AddPoint( dimension->
GetStart() );
428 points->AddPoint( dimension->
GetEnd() );
430 points->AddPoint( dimension->
GetKnee() );
450 points->AddPoint( dimension->
GetStart() );
451 points->AddPoint( dimension->
GetEnd() );
542 std::unique_ptr<BOARD_ITEM> clone;
556 bool useAltContraint =
false;
564 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
595 frame()->UndoRedoBlock(
true );
625 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
635 std::unique_ptr<BOARD_ITEM> oldClone = std::move( clone );
637 grid.AddConstructionItems( { clone.get() },
false, true );
654 if(
grid.GetUseGrid() )
661 VECTOR2I deltaGrid = gridPt -
grid.BestSnapAnchor( last, {},
662 grid.GetItemGrid( item ),
665 if( abs(
delta.x ) >
grid.GetGrid().x / 2 )
666 pos.
x = last.
x + deltaGrid.
x;
670 if( abs(
delta.y ) >
grid.GetGrid().y / 2 )
671 pos.
y = last.
y + deltaGrid.
y;
680 if( useAltContraint )
692 grid.GetItemGrid( item ),
704 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
714 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
733 commit.
Push(
_(
"Resize Table Cells" ) );
737 commit.
Push(
_(
"Move Point" ) );
741 frame()->UndoRedoBlock(
false );
746 else if( evt->IsCancelInteractive() || evt->IsActivate() )
758 frame()->UndoRedoBlock(
false );
764 if( evt->IsActivate() && !evt->IsMoveTool() )
808 title =
_(
"Move Midpoint to Location" );
809 msg =
_(
"Move Midpoint" );
813 title =
_(
"Move Corner to Location" );
814 msg =
_(
"Move Corner" );
819 if( dlg.ShowModal() == wxID_OK )
838 bool arcValid =
true;
850 else if( aEnd != aArc->
GetEnd() )
885 double det = u1.
x * u2.
y - u2.
x * u1.
y;
892 double tmpx =
v1.
x * u2.
y -
v1.
y * u2.
x;
893 double tmpy = -
v1.
x * u1.
y +
v1.
y * u1.
x;
905 bool transformCircle =
false;
942 transformCircle =
true;
954 if( !std::isfinite(
delta ) )
965 center =
v4 + aCenter;
984 const int c_snapEpsilon_sq = 4;
986 VECTOR2I m = ( aStart / 2 + aEnd / 2 );
987 VECTOR2I perp = ( aEnd - aStart ).Perpendicular().
Resize( INT_MAX / 2 );
989 SEG legal( m - perp, m + perp );
991 const SEG testSegments[] = {
SEG( aCenter, aCenter +
VECTOR2( 1, 0 ) ),
994 std::vector<VECTOR2I> points = { legal.
A, legal.
B };
996 for(
const SEG& seg : testSegments )
1001 points.push_back( *vec );
1010 SEG::ecoord d_sq = ( pt - aCenter ).SquaredEuclideanNorm();
1012 if( d_sq < min_d_sq - c_snapEpsilon_sq )
1046 aTopLeft.
x = std::min( aTopLeft.
x, aHole.
x - aHoleSize.
x / 2 - minWidth );
1047 aTopLeft.
y = std::min( aTopLeft.
y, aHole.
y - aHoleSize.
y / 2 - minHeight );
1052 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
1053 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
1057 aTopRight.
y = aTopLeft.
y;
1058 aBotLeft.
x = aTopLeft.
x;
1065 aTopRight.
x = std::max( aTopRight.
x, aHole.
x + aHoleSize.
x / 2 + minWidth );
1066 aTopRight.
y = std::min( aTopRight.
y, aHole.
y - aHoleSize.
y / 2 - minHeight );
1071 aTopRight.
x = std::max( aTopRight.
x, aBotLeft.
x + minWidth );
1072 aTopRight.
y = std::min( aTopRight.
y, aBotLeft.
y - minHeight );
1076 aTopLeft.
y = aTopRight.
y;
1077 aBotRight.
x = aTopRight.
x;
1084 aBotLeft.
x = std::min( aBotLeft.
x, aHole.
x - aHoleSize.
x / 2 - minWidth );
1085 aBotLeft.
y = std::max( aBotLeft.
y, aHole.
y + aHoleSize.
y / 2 + minHeight );
1090 aBotLeft.
x = std::min( aBotLeft.
x, aTopRight.
x - minWidth );
1091 aBotLeft.
y = std::max( aBotLeft.
y, aTopRight.
y + minHeight );
1095 aBotRight.
y = aBotLeft.
y;
1096 aTopLeft.
x = aBotLeft.
x;
1103 aBotRight.
x = std::max( aBotRight.
x, aHole.
x + aHoleSize.
x / 2 + minWidth );
1104 aBotRight.
y = std::max( aBotRight.
y, aHole.
y + aHoleSize.
y / 2 + minHeight );
1109 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
1110 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
1114 aBotLeft.
y = aBotRight.
y;
1115 aTopRight.
x = aBotRight.
x;
1119 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
1123 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
1127 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
1131 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
1157 prev_p1 = aArc->
GetEnd();
1160 movingStart =
false;
1166 if( p1.
x == 0 && p1.
y == 0 )
1167 p1 = prev_p1 - aCenter;
1169 if( p2.
x == 0 && p2.
y == 0 )
1174 if( radius < minRadius )
1177 p1 = aCenter + p1.
Resize( radius );
1178 p2 = aCenter + p2.
Resize( radius );
1201 SEG chord( aStart, aEnd );
1208 double radius = ( aCursor - aCenter ).EuclideanNorm();
1210 if( radius < minRadius )
1213 start = start.
Resize( radius );
1214 end = end.
Resize( radius );
1216 start = start + aCenter;
1217 end = end + aCenter;
1229 VECTOR2I m = ( aStart + aEnd ) / 2;
1233 const int JUST_OFF = ( aStart - aEnd ).EuclideanNorm() / 100;
1254 m_oldCrossBar(
SEG{ aDimension.GetCrossbarStart(), aDimension.GetCrossbarEnd() } )
1274 if( oldJustify == GR_TEXT_H_ALIGN_T::GR_TEXT_H_ALIGN_LEFT
1275 || oldJustify == GR_TEXT_H_ALIGN_T::GR_TEXT_H_ALIGN_RIGHT )
1278 const VECTOR2I newProject = newCrossBar.LineProject( newTextPos );
1280 const VECTOR2I oldProjectedOffset =
1282 const VECTOR2I newProjectedOffset = newProject - newCrossBar.NearestPoint( newProject );
1284 const bool textWasLeftOf = oldProjectedOffset.
x < 0
1285 || ( oldProjectedOffset.
x == 0 && oldProjectedOffset.
y > 0 );
1286 const bool textIsLeftOf = newProjectedOffset.
x < 0
1287 || ( newProjectedOffset.
x == 0 && newProjectedOffset.
y > 0 );
1289 if( textWasLeftOf != textIsLeftOf )
1293 ( oldJustify == GR_TEXT_H_ALIGN_T::GR_TEXT_H_ALIGN_LEFT )
1294 ? GR_TEXT_H_ALIGN_T::GR_TEXT_H_ALIGN_RIGHT
1295 : GR_TEXT_H_ALIGN_T::GR_TEXT_H_ALIGN_LEFT );
1310 const EDA_ANGLE rotation = oldAngle - newAngle;
1315 const VECTOR2I cbNearestEndToText =
1317 const VECTOR2I rotTextOffsetFromCbCenter =
1319 const VECTOR2I rotTextOffsetFromCbEnd =
1324 const bool startIsInOffsetDirection =
1326 rotTextOffsetFromCbCenter, newCrossBar.Center() );
1332 return newCbRefPt + rotTextOffsetFromCbEnd;
1339 const double oldRatio =
1347 const VECTOR2I newProjected = newCrossBar.A + ( newCrossBar.B - newCrossBar.A ) * oldRatio;
1348 return newProjected + rotCbNormalToText;
1364 switch( item->
Type() )
1380 const VECTOR2I newOffset = xfrmOrigin - ( topLeft + botRight ) / 2;
1394 newCorner = topLeft;
1395 oldCorner -= oldSize / 2;
1399 newCorner = topRight;
1400 oldCorner -=
VECTOR2I( -oldSize.
x, oldSize.
y ) / 2;
1404 newCorner = botLeft;
1405 oldCorner -=
VECTOR2I( oldSize.
x, -oldSize.
y ) / 2;
1409 newCorner = botRight;
1410 oldCorner += oldSize / 2;
1416 *newCorner -= xfrmOrigin;
1417 oldCorner -= oldOrigin;
1420 if(
sign( newCorner->x ) !=
sign( oldCorner.
x )
1421 ||
sign( newCorner->y ) !=
sign( oldCorner.
y ) )
1426 const double newLength = newCorner->EuclideanNorm();
1429 double ratio = oldLength > 0 ? ( newLength / oldLength ) : 1.0;
1432 VECTOR2I newSize = oldSize * ratio;
1435 ratio = std::min( newWidth / oldSize.
x, newHeight / oldSize.
y );
1452 case SHAPE_T::SEGMENT:
1460 case SHAPE_T::RECTANGLE:
1495 setLeft( topLeft.
x );
1496 setTop( topLeft.
y );
1497 setRight( botRight.
x );
1498 setBottom( botRight.
y );
1502 setTop( topLeft.
y );
1506 setLeft( topLeft.
x );
1510 setBottom( botRight.
y );
1514 setRight( botRight.
x );
1517 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1538 if(
m_arcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION )
1545 shape->
Move( moveVector );
1552 if(
m_arcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION )
1562 if(
m_arcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION )
1571 case SHAPE_T::CIRCLE:
1579 shape->
Move( moveVector );
1596 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1605 case SHAPE_T::BEZIER:
1626 if(
pad->IsEntered() )
1633 textBox->ClearRenderCache();
1649 for(
int ii = 0; ii < cell->
GetColSpan() - 1; ++ii )
1661 for(
int ii = 0; ii < cell->
GetRowSpan() - 1; ++ii )
1679 case PAD_SHAPE::CIRCLE:
1682 int diameter = 2 * ( end -
pad->GetPosition() ).EuclideanNorm();
1688 case PAD_SHAPE::OVAL:
1689 case PAD_SHAPE::TRAPEZOID:
1690 case PAD_SHAPE::RECTANGLE:
1691 case PAD_SHAPE::ROUNDRECT:
1692 case PAD_SHAPE::CHAMFERED_RECT:
1701 pinEditedCorner( topLeft, topRight, botLeft, botRight, holeCenter, holeSize );
1704 || (
pad->GetDrillSize().x &&
pad->GetDrillSize().y ) )
1714 dist[0] = center.
x - topLeft.
x;
1715 dist[1] = center.
y - topLeft.
y;
1716 dist[2] = botRight.
x - center.
x;
1717 dist[3] = botRight.
y - center.
y;
1721 dist[0] = center.
x - botLeft.
x;
1722 dist[1] = center.
y - topRight.
y;
1723 dist[2] = topRight.
x - center.
x;
1724 dist[3] = botLeft.
y - center.
y;
1727 VECTOR2I padSize( dist[0] + dist[2], dist[1] + dist[3] );
1728 VECTOR2I deltaOffset( padSize.
x / 2 - dist[2], padSize.
y / 2 - dist[3] );
1731 std::swap( padSize.
x, padSize.
y );
1750 bottom = botRight.
y;
1763 std::swap( padSize.
x, padSize.
y );
1780 ZONE* zone =
static_cast<ZONE*
>( item );
1792 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1815 for(
EDA_ITEM* previewItem : generatorItem->GetPreviewItems( generatorTool,
frame(),
1837 if( featureLine.
Cross( crossBar ) > 0 )
1849 if( featureLine.
Cross( crossBar ) > 0 )
1908 VECTOR2I direction = ( directionA < directionB ) ? directionA : directionB;
1914 if( !bounds.
Contains( cursorPos ) )
1937 dimension->
SetHeight( vert ? featureLine.
x : featureLine.
y );
2037 dimension->
SetEnd( newPoint );
2056 frame()->SetMsgPanel( item );
2070 switch( item->
Type() )
2093 int target = shape->
GetShape() == SHAPE_T::RECTANGLE ? 4 : 0;
2109 if( shape->
GetShape() == SHAPE_T::RECTANGLE )
2118 else if( shape->
GetShape() == SHAPE_T::POLY )
2132 case SHAPE_T::SEGMENT:
2137 case SHAPE_T::RECTANGLE:
2146 std::swap( topLeft.
x, botRight.
x );
2149 std::swap( topLeft.
y, botRight.
y );
2165 case SHAPE_T::CIRCLE:
2172 std::vector<VECTOR2I> points;
2175 if(
m_editPoints->PointsSize() != (unsigned) points.size() )
2187 for(
unsigned i = 0; i < points.size(); i++ )
2194 case SHAPE_T::BEZIER:
2222 const PAD*
pad =
static_cast<const PAD*
>( item );
2229 case PAD_SHAPE::CIRCLE:
2231 int target =
locked ? 0 : 1;
2244 else if( target == 1 )
2246 shapePos.
x += halfSize.
x;
2252 case PAD_SHAPE::OVAL:
2253 case PAD_SHAPE::TRAPEZOID:
2254 case PAD_SHAPE::RECTANGLE:
2255 case PAD_SHAPE::ROUNDRECT:
2256 case PAD_SHAPE::CHAMFERED_RECT:
2259 int target =
locked || !
pad->GetOrientation().IsCardinal() ? 0 : 4;
2271 else if( target == 4 )
2274 std::swap( halfSize.
x, halfSize.
y );
2279 VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y - halfSize.
y ) );
2283 VECTOR2I( shapePos.
x - halfSize.
x, shapePos.
y + halfSize.
y ) );
2297 ZONE* zone =
static_cast<ZONE*
>( item );
2383 frame()->GetCanvas()->SetCurrentCursor( KICURSOR::ARROW );
2389 if(
frame()->ToolStackIsEmpty() )
2407 switch( parent->
Type() )
2414 isPoly =
static_cast<PCB_SHAPE*
>( parent )->GetShape() == SHAPE_T::POLY;
2422 if( line && isPoly )
2445 switch( item->
Type() )
2448 switch(
static_cast<const PCB_SHAPE*
>( item )->GetShape() )
2450 case SHAPE_T::SEGMENT:
2454 case SHAPE_T::CIRCLE:
2505 const auto type = aItem.
Type();
2515 return shapeType == SHAPE_T::SEGMENT || shapeType == SHAPE_T::POLY
2516 || shapeType == SHAPE_T::ARC;
2525 if( aSelection.
Size() != 1 )
2535static std::pair<bool, SHAPE_POLY_SET::VERTEX_INDEX>
2540 auto vertexIdx = it.GetIndex();
2543 return std::make_pair(
true, vertexIdx );
2561 switch( item->
Type() )
2564 polyset =
static_cast<ZONE*
>( item )->Outline();
2622 unsigned int nearestIdx = 0;
2623 unsigned int nextNearestIdx = 0;
2624 unsigned int nearestDist = INT_MAX;
2625 unsigned int firstPointInContour = 0;
2630 ZONE* zone =
static_cast<ZONE*
>( item );
2631 zoneOutline = zone->
Outline();
2650 for( ; iterator; iterator++, curr_idx++ )
2652 int jj = curr_idx+1;
2656 jj = firstPointInContour;
2657 firstPointInContour = curr_idx+1;
2660 SEG curr_segment( zoneOutline->
CVertex( curr_idx ), zoneOutline->
CVertex( jj ) );
2667 nearestIdx = curr_idx;
2668 nextNearestIdx = jj;
2675 SEG nearestSide( sideOrigin, sideEnd );
2680 if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
2681 nearestPoint = ( sideOrigin + sideEnd ) / 2;
2683 zoneOutline->
InsertVertex( nextNearestIdx, nearestPoint );
2689 commit.
Push(
_(
"Add Zone Corner" ) );
2691 else if( graphicItem )
2695 case SHAPE_T::SEGMENT:
2697 commit.
Modify( graphicItem );
2703 graphicItem->
SetEnd( nearestPoint );
2706 auto newSegment = std::make_unique<PCB_SHAPE>( *graphicItem );
2708 newSegment->ClearSelected();
2709 newSegment->SetStart( nearestPoint );
2712 commit.
Add( newSegment.release() );
2713 commit.
Push(
_(
"Split Segment" ) );
2718 commit.
Modify( graphicItem );
2721 graphicItem->
GetEnd(), 0 );
2725 graphicItem->
SetEnd( nearestPoint );
2728 auto newArc = std::make_unique<PCB_SHAPE>( *graphicItem );
2730 newArc->ClearSelected();
2731 newArc->SetEnd( arc.
GetP1() );
2732 newArc->SetStart( nearestPoint );
2734 commit.
Add( newArc.release() );
2735 commit.
Push(
_(
"Split Arc" ) );
2763 ZONE* zone =
static_cast<ZONE*
>( item );
2771 if( shape->
GetShape() == SHAPE_T::POLY )
2784 const auto& vertexIdx = vertex.second;
2785 auto& outline = polygon->
Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
2787 if( outline.PointCount() > 3 )
2796 if( vertexIdx.m_contour > 0 )
2812 commit.
Push(
_(
"Remove Zone Corner" ) );
2814 commit.
Push(
_(
"Remove Polygon Corner" ) );
2818 static_cast<ZONE*
>( item )->HatchBorder();
2847 case ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS:
2848 m_arcEditMode = ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION;
2850 case ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION:
2851 m_arcEditMode = ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS;
ARC_EDIT_MODE
Settings for arc editing.
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
static TOOL_ACTION cycleArcEditMode
static TOOL_ACTION activatePointEditor
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr) override
virtual void Revert() override
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
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
constexpr size_type GetWidth() const
constexpr size_type GetHeight() const
constexpr coord_type GetLeft() const
constexpr bool Contains(const Vec &aPoint) const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
COMMIT & Remove(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been removed.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Notify observers that aItem has been added.
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()
EDIT_CONSTRAINT that imposes a constraint that two points have to be located at angle of 45 degree mu...
EDIT_CONSTRAINT for 3 segments: dragged and two adjacent ones, enforcing to keep their slopes and all...
EDIT_CONSTRAINT that imposes a constraint that a point has to lie on a line (determined by 2 points).
EDIT_CONSTRAINT for a EDIT_LINE, that constrains the line to move perpendicular to the line itself.
bool IsType(FRAME_T aType) const
A base class for most all the KiCad significant classes used in schematics and boards.
EDA_ITEM_FLAGS GetEditFlags() const
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.
const VECTOR2I & GetBezierC2() const
void SetBezierC2(const VECTOR2I &aPt)
void SetCenter(const VECTOR2I &aCenter)
virtual VECTOR2I GetTopLeft() const
int GetRectangleWidth() const
SHAPE_POLY_SET & GetPolyShape()
virtual VECTOR2I GetBotRight() const
virtual void SetBottom(int val)
virtual void SetTop(int val)
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
void DupPolyPointsList(std::vector< VECTOR2I > &aBuffer) const
Duplicate the list of corners in a std::vector<VECTOR2I>
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
void SetBezierC1(const VECTOR2I &aPt)
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
virtual void SetLeft(int val)
const VECTOR2I & GetBezierC1() const
int GetRectangleHeight() const
virtual void SetRight(int val)
VECTOR2I GetArcMid() const
const VECTOR2I & GetTextPos() const
void SetTextPos(const VECTOR2I &aPoint)
GR_TEXT_H_ALIGN_T GetHorizJustify() const
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Describe constraints between two edit handles.
Represent a line connecting two EDIT_POINTs.
Represent a single point that can be used for modifying items.
SNAP_CONSTRAINT_TYPE GetSnapConstraint() const
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
virtual void ApplyConstraint(const GRID_HELPER &aGrid)
Correct coordinates of an EDIT_POINT by applying previously set constraint.
void SetHover(bool aHover=true)
bool IsConstrained() const
Check if point is constrained.
void SetActive(bool aActive=true)
GRID_CONSTRAINT_TYPE GetGridConstraint() 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
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.
void FreeItems()
Free all the items that were added to the group.
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 LSET AllLayersMask()
static constexpr PCB_LAYER_ID ALL_LAYERS
! Temporary layer identifier to identify code that is not padstack-aware
ARC_EDIT_MODE m_ArcEditMode
static TOOL_ACTION pointEditorArcKeepCenter
static TOOL_ACTION pointEditorMoveMidpoint
static TOOL_ACTION genPushEdit
static TOOL_ACTION genStartEdit
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION pointEditorMoveCorner
static TOOL_ACTION genUpdateEdit
static TOOL_ACTION pointEditorArcKeepEndpoint
static TOOL_ACTION pointEditorRemoveCorner
static TOOL_ACTION pointEditorAddCorner
static TOOL_ACTION reselectItem
static TOOL_ACTION genRevertEdit
Common, abstract interface for edit frames.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
ORIGIN_TRANSFORMS & GetOriginTransforms() override
Return a reference to the default ORIGIN_TRANSFORMS object.
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
void Update()
Update the dimension's cached text and geometry.
void SetTextPositionMode(DIM_TEXT_POSITION aMode)
virtual const VECTOR2I & GetStart() const
The dimension's origin is the first feature point for the dimension.
virtual void SetEnd(const VECTOR2I &aPoint)
virtual void SetStart(const VECTOR2I &aPoint)
virtual const VECTOR2I & GetEnd() const
For better understanding of the points that make a dimension:
const VECTOR2I & GetCrossbarStart() const
const VECTOR2I & GetCrossbarEnd() const
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
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.
void SetLeaderLength(int aLength)
virtual bool UpdateEditPoints(std::shared_ptr< EDIT_POINTS > aEditPoints)
virtual bool MakeEditPoints(std::shared_ptr< EDIT_POINTS > aEditPoints) const
virtual bool UpdateFromEditPoints(std::shared_ptr< EDIT_POINTS > aEditPoints, BOARD_COMMIT *aCommit)
int changeArcEditMode(const TOOL_EVENT &aEvent)
void pinEditedCorner(VECTOR2I &aTopLeft, VECTOR2I &aTopRight, VECTOR2I &aBotLeft, VECTOR2I &aBotRight, const VECTOR2I &aHole={ 0, 0 }, const VECTOR2I &aHoleSize={ 0, 0 }) const
Set up an alternative constraint (typically enabled upon a modifier key being pressed).
void editArcMidKeepEndpoints(PCB_SHAPE *aArc, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCursor) const
Move the mid point of the arc, while keeping the two endpoints.
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
bool removeCornerCondition(const SELECTION &aSelection)
EDIT_POINT * m_hoveredPoint
void editArcMidKeepCenter(PCB_SHAPE *aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCursor) const
Move the mid point of the arc, while keeping the angle.
int addCorner(const TOOL_EVENT &aEvent)
void updateItem(BOARD_COMMIT *aCommit)
Update edit points with item's points.
bool HasPoint()
Indicate the cursor is over an edit point.
EDIT_POINT m_original
Original pos for the current drag point.
EDIT_POINT get45DegConstrainer() const
Condition to display "Create corner" context menu entry.
int modifiedSelection(const TOOL_EVENT &aEvent)
void editArcEndpointKeepTangent(PCB_SHAPE *aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCursor) const
Move an end point of the arc, while keeping the tangent at the other endpoint.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int removeCorner(const TOOL_EVENT &aEvent)
static bool canAddCorner(const EDA_ITEM &aItem)
Condition to display "Remove corner" context menu entry.
bool Init() override
Init() is called once upon a registration of the tool.
int movePoint(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
void setEditedPoint(EDIT_POINT *aPoint)
void buildForPolyOutline(std::shared_ptr< EDIT_POINTS > points, const SHAPE_POLY_SET *aOutline)
EDIT_POINT m_altConstrainer
bool isModified(const EDIT_POINT &aPoint) const
ARC_EDIT_MODE m_arcEditMode
EDIT_POINT * m_editedPoint
void updateEditedPoint(const TOOL_EVENT &aEvent)
Set the current point being edited. NULL means none.
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
void updatePoints()
Update which point is being edited.
void editArcCenterKeepEndpoints(PCB_SHAPE *aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd) const
Move the arc center but keep endpoint locations.
static bool addCornerCondition(const SELECTION &aSelection)
Determine if the tool can currently add a corner to the given item.
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.
void editArcEndpointKeepCenter(PCB_SHAPE *aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCursor) const
Move an end point of the arc around the circumference.
PCB_SELECTION_TOOL * m_selectionTool
Object to handle a bitmap image that can be inserted in a PCB.
REFERENCE_IMAGE & GetReferenceImage()
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
bool IsProxyItem() const override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetColWidth(int aCol, int aWidth)
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
int GetColWidth(int aCol) const
void SetRowHeight(int aRow, int aHeight)
int GetRowHeight(int aRow) const
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.
ecoord SquaredDistance(const SEG &aSeg) const
VECTOR2I::extended_type ecoord
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.
int Distance(const SEG &aSeg) const
Compute minimum Euclidean distance to segment aSeg.
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
virtual void Add(EDA_ITEM *aItem)
int Size() const
Returns the number of selected parts.
VECTOR2I NearestPoint(const VECTOR2I &aP) const
const VECTOR2I & GetP1() const
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
bool IsEndContour() const
Represent a set of closed polygons.
ITERATOR IterateWithHoles(int aOutline)
void InsertVertex(int aGlobalIndex, const VECTOR2I &aNewVertex)
Adds a vertex in the globally indexed position aGlobalIndex.
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
int TotalVertices() const
Return total number of vertices stored in the set.
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.
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_ITERATOR CIterateWithHoles(int aOutline) const
constexpr extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
static constexpr extended_type ECOORD_MAX
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
VECTOR2I GetValue()
Returns the value in internal units.
Handle a list of polygons defining a copper zone.
void SetNeedRefill(bool aNeedRefill)
bool UnFill()
Removes the zone filling.
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
SHAPE_POLY_SET * Outline()
This file is part of the common library.
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_270
a few functions useful in geometry calculations.
double m_DrawArcCenterMaxAngle
When drawing an arc, the angle ( center - start ) - ( start - end ) can be limited to avoid extremely...
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)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
#define STATUS_ITEMS_ONLY
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEX > findVertex(SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
std::optional< VECTOR2I > OPT_VECTOR2I
constexpr int mmToIU(double mm) const
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
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.
@ 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_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
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ 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.