29 using namespace std::placeholders;
103 m_selectionTool( nullptr ),
104 m_editedPoint( nullptr ),
105 m_hoveredPoint( nullptr ),
108 m_altEditMethod( false ),
109 m_altConstrainer(
VECTOR2I( 0, 0 ) )
121 m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
123 m_statusPopup->SetText(
_(
"Self-intersecting polygons are not allowed." ) );
132 wxASSERT_MSG(
m_selectionTool, wxT(
"pcbnew.InteractiveSelection tool is not available" ) );
150 points->AddPoint( *iterator );
152 if( iterator.IsEndContour() )
158 for(
int i = 0; i < cornersCount - 1; ++i )
160 if( points->IsContourEnd( i ) )
161 points->AddLine( points->Point( i ), points->Point( points->GetContourStartIdx( i ) ) );
163 points->AddLine( points->Point( i ), points->Point( i + 1 ) );
165 points->Line( i ).SetConstraint(
new EC_PERPLINE( points->Line( i ) ) );
169 points->AddLine( points->Point( cornersCount - 1 ),
170 points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
172 points->Line( points->LinesSize() - 1 )
173 .SetConstraint(
new EC_PERPLINE( points->Line( points->LinesSize() - 1 ) ) );
179 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
185 switch( aItem->
Type() )
190 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aItem );
195 points->AddPoint( shape->
GetStart() );
196 points->AddPoint( shape->
GetEnd() );
200 points->AddPoint( shape->
GetStart() );
201 points->AddPoint( wxPoint( shape->
GetEnd().x, shape->
GetStart().y ) );
202 points->AddPoint( shape->
GetEnd() );
203 points->AddPoint( wxPoint( shape->
GetStart().x, shape->
GetEnd().y ) );
218 points->AddPoint( shape->
GetStart() );
220 points->AddPoint( shape->
GetEnd() );
230 points->AddPoint( shape->
GetEnd() );
238 points->AddPoint( shape->
GetStart() );
241 points->AddPoint( shape->
GetEnd() );
253 const PAD*
pad = static_cast<const PAD*>( aItem );
254 wxPoint shapePos =
pad->ShapePos();
255 wxPoint halfSize(
pad->GetSize().x / 2,
pad->GetSize().y / 2 );
260 switch(
pad->GetShape() )
263 points->AddPoint( wxPoint( shapePos.x + halfSize.x, shapePos.y ) );
272 if( (
int)
pad->GetOrientation() % 900 != 0 )
275 if(
pad->GetOrientation() == 900 ||
pad->GetOrientation() == 2700 )
276 std::swap( halfSize.x, halfSize.y );
278 points->AddPoint( shapePos - halfSize );
279 points->AddPoint( wxPoint( shapePos.x + halfSize.x, shapePos.y - halfSize.y ) );
280 points->AddPoint( shapePos + halfSize );
281 points->AddPoint( wxPoint( shapePos.x - halfSize.x, shapePos.y + halfSize.y ) );
294 const ZONE* zone = static_cast<const ZONE*>( aItem );
302 const PCB_DIM_ALIGNED* dimension = static_cast<const PCB_DIM_ALIGNED*>( aItem );
304 points->AddPoint( dimension->
GetStart() );
305 points->AddPoint( dimension->
GetEnd() );
326 const PCB_DIM_CENTER* dimension = static_cast<const PCB_DIM_CENTER*>( aItem );
328 points->AddPoint( dimension->
GetStart() );
329 points->AddPoint( dimension->
GetEnd() );
339 const PCB_DIM_LEADER* dimension = static_cast<const PCB_DIM_LEADER*>( aItem );
341 points->AddPoint( dimension->
GetStart() );
342 points->AddPoint( dimension->
GetEnd() );
444 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
479 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
503 if(
grid.GetUseGrid() )
505 VECTOR2I gridPt =
grid.BestSnapAnchor( pos, {}, { item } );
509 VECTOR2I deltaGrid = gridPt -
grid.BestSnapAnchor( last, {}, { item } );
511 if( abs(
delta.x ) >
grid.GetGrid().x / 2 )
512 pos.
x = last.x + deltaGrid.
x;
516 if( abs(
delta.y ) >
grid.GetGrid().y / 2 )
517 pos.
y = last.y + deltaGrid.
y;
536 snapLayers, { item } ) );
547 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
557 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
568 commit.
Push(
_(
"Drag a corner" ) );
577 evt->SetPassEvent(
false );
579 else if( evt->IsCancelInteractive() || evt->IsActivate() )
591 if( evt->IsActivate() && !evt->IsMoveTool() )
629 bool arcValid =
true;
642 else if( aEnd != aArc->
GetEnd() )
669 u2 = v3 - ( u1.
x * v3.
x + u1.
y * v3.
y ) * u1;
678 double det = u1.
x * u2.y - u2.x * u1.
y;
685 double tmpx = v1.
x * u2.y - v1.
y * u2.x;
686 double tmpy = -v1.
x * u1.
y + v1.
y * u1.
x;
691 tmpx =
v2.
x * u2.y -
v2.
y * u2.x;
698 bool transformCircle =
false;
735 transformCircle =
true;
747 if( !std::isfinite(
delta ) )
753 tmpx = v4.
x * u1.
x + v4.
y * u2.x;
754 tmpy = v4.
x * u1.
y + v4.
y * u2.y;
758 center = v4 + aCenter;
767 aArc->
SetEnd( (wxPoint) end );
790 switch( aEditedPointIndex )
796 aTopLeft.
x = std::min( aTopLeft.
x, aHole.
x - aHoleSize.
x / 2 - aMinWidth );
797 aTopLeft.
y = std::min( aTopLeft.
y, aHole.
y - aHoleSize.
y / 2 - aMinHeight );
802 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - aMinWidth );
803 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - aMinHeight );
807 aTopRight.
y = aTopLeft.
y;
808 aBotLeft.
x = aTopLeft.
x;
816 aTopRight.
x = std::max( aTopRight.
x, aHole.
x + aHoleSize.
x / 2 + aMinWidth );
817 aTopRight.
y = std::min( aTopRight.
y, aHole.
y - aHoleSize.
y / 2 - aMinHeight );
822 aTopRight.
x = std::max( aTopRight.
x, aBotLeft.
x + aMinWidth );
823 aTopRight.
y = std::min( aTopRight.
y, aBotLeft.
y - aMinHeight );
827 aTopLeft.
y = aTopRight.
y;
828 aBotRight.
x = aTopRight.
x;
836 aBotLeft.
x = std::min( aBotLeft.
x, aHole.
x - aHoleSize.
x / 2 - aMinWidth );
837 aBotLeft.
y = std::max( aBotLeft.
y, aHole.
y + aHoleSize.
y / 2 + aMinHeight );
842 aBotLeft.
x = std::min( aBotLeft.
x, aTopRight.
x - aMinWidth );
843 aBotLeft.
y = std::max( aBotLeft.
y, aTopRight.
y + aMinHeight );
847 aBotRight.
y = aBotLeft.
y;
848 aTopLeft.
x = aBotLeft.
x;
856 aBotRight.
x = std::max( aBotRight.
x, aHole.
x + aHoleSize.
x / 2 + aMinWidth );
857 aBotRight.
y = std::max( aBotRight.
y, aHole.
y + aHoleSize.
y / 2 + aMinHeight );
862 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + aMinWidth );
863 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + aMinHeight );
867 aBotLeft.
y = aBotRight.
y;
868 aTopRight.
x = aBotRight.
x;
900 target = p2 - aCenter;
902 double sqRadius = ( p1 - aCenter ).SquaredEuclideanNorm();
915 p2.
y = ( target.
y > 0 ) ? sqrt( sqRadius ) : -sqrt( sqRadius );
919 double tan = target.
y / static_cast<double>( target.
x );
922 double tmp = sqrt( sqRadius / ( 1.0 + tan * tan ) );
925 tmp = target.
x > 0 ? tmp : -tmp;
926 p2.
y = target.
y / static_cast<double>( target.
x ) * tmp;
938 aArc->
SetEnd( (wxPoint) aEnd );
951 double sqRadius = ( aCursor - aCenter ).SquaredEuclideanNorm();
956 start.
y = aCursor.
y > 0 ? sqrt( sqRadius ) : -sqrt( sqRadius );
965 double tan = aStart.
y / static_cast<double>( start.
x );
966 double tmp = sqrt( sqRadius / ( 1.0 + tan * tan ) );
969 tmp = start.
x > 0 ? tmp : -tmp;
970 start.
y = start.
y / static_cast<double>( start.
x ) * tmp;
977 end.
y = aMid.
y > 0 ? sqrt( sqRadius ) : -sqrt( sqRadius );
986 double tan = end.
y / static_cast<double>( end.
x );
987 double tmp = sqrt( sqRadius / ( 1.0 + tan * tan ) );
990 tmp = end.
x > 0 ? tmp : -tmp;
991 end.
y = end.
y / static_cast<double>( end.
x ) * tmp;
995 start = start + aCenter;
999 aArc->
SetEnd( (wxPoint) end );
1008 VECTOR2I m = ( aStart + aEnd ) / 2;
1012 const int JUST_OFF = ( aStart - aEnd ).
EuclideanNorm() / 100;
1015 VECTOR2I mid = legal.NearestPoint( aCursor );
1017 aArc->
SetArcGeometry( (wxPoint) aStart, (wxPoint) mid, (wxPoint) aEnd );
1028 switch( item->
Type() )
1033 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
1082 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1100 wxPoint moveVector = wxPoint( center.
x, center.
y ) - shape->
GetCenter();
1101 shape->
Move( moveVector );
1132 wxPoint moveVector = wxPoint( center.
x, center.
y ) - shape->
GetCenter();
1133 shape->
Move( moveVector );
1137 shape->
SetEnd( wxPoint( end.
x, end.
y ) );
1149 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1181 if(
FP_SHAPE* fpShape = dyn_cast<FP_SHAPE*>( item ) )
1182 fpShape->SetLocalCoord();
1189 PAD*
pad = static_cast<PAD*>( item );
1191 switch(
pad->GetShape() )
1195 wxPoint end = (wxPoint)
m_editPoints->Point( 0 ).GetPosition();
1198 pad->SetSize( wxSize( diameter, diameter ) );
1216 botLeft, botRight, holeCenter, holeSize );
1218 if( (
pad->GetOffset().x ||
pad->GetOffset().y )
1219 || (
pad->GetDrillSize().x &&
pad->GetDrillSize().y ) )
1223 wxPoint center =
pad->GetPosition();
1229 dist[0] = center.x - topLeft.
x;
1230 dist[1] = center.y - topLeft.
y;
1231 dist[2] = botRight.
x - center.x;
1232 dist[3] = botRight.
y - center.y;
1236 dist[0] = center.x - botLeft.
x;
1237 dist[1] = center.y - topRight.
y;
1238 dist[2] = topRight.
x - center.x;
1239 dist[3] = botLeft.
y - center.y;
1242 wxSize padSize( dist[0] + dist[2], dist[1] + dist[3] );
1243 wxPoint deltaOffset( padSize.x / 2 - dist[2], padSize.y / 2 - dist[3] );
1245 if(
pad->GetOrientation() == 900 ||
pad->GetOrientation() == 2700 )
1246 std::swap( padSize.x, padSize.y );
1250 pad->SetSize( padSize );
1251 pad->SetOffset( -deltaOffset );
1265 bottom = botRight.
y;
1275 wxSize padSize( abs(
right -
left ), abs( bottom - top ) );
1277 if(
pad->GetOrientation() == 900 ||
pad->GetOrientation() == 2700 )
1278 std::swap( padSize.x, padSize.y );
1280 pad->SetSize( padSize );
1281 pad->SetPosition( wxPoint( (
left +
right ) / 2, ( top + bottom ) / 2 ) );
1282 pad->SetLocalCoord();
1297 ZONE* zone = static_cast<ZONE*>( item );
1309 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1332 if( featureLine.Cross( crossBar ) > 0 )
1333 dimension->
SetHeight( -featureLine.EuclideanNorm() );
1335 dimension->
SetHeight( featureLine.EuclideanNorm() );
1344 if( featureLine.Cross( crossBar ) > 0 )
1345 dimension->
SetHeight( -featureLine.EuclideanNorm() );
1347 dimension->
SetHeight( featureLine.EuclideanNorm() );
1400 VECTOR2I direction = ( directionA < directionB ) ? directionA : directionB;
1406 if( !bounds.Contains( cursorPos ) )
1410 if( bounds.GetWidth() == 0 )
1412 else if( bounds.GetHeight() == 0 )
1414 else if( cursorPos.x > bounds.GetLeft() && cursorPos.x < bounds.GetRight() )
1416 else if( cursorPos.y > bounds.GetTop() && cursorPos.y < bounds.GetBottom() )
1419 vert = std::abs( direction.y ) < std::abs( direction.x );
1429 dimension->
SetHeight( vert ? featureLine.x : featureLine.y );
1453 PCB_DIM_CENTER* dimension = static_cast<PCB_DIM_CENTER*>( item );
1467 PCB_DIM_LEADER* dimension = static_cast<PCB_DIM_LEADER*>( item );
1478 dimension->
SetEnd( newPoint );
1522 wxPoint p = wxGetMousePosition() + wxPoint( 20, 20 );
1542 switch( item->
Type() )
1547 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( item );
1579 std::vector<wxPoint> points;
1582 if(
m_editPoints->PointsSize() != (unsigned) points.size() )
1594 for(
unsigned i = 0; i < points.size(); i++ )
1617 const PAD*
pad = static_cast<const PAD*>( item );
1619 wxPoint shapePos =
pad->ShapePos();
1620 wxPoint halfSize(
pad->GetSize().x / 2,
pad->GetSize().y / 2 );
1622 switch(
pad->GetShape() )
1626 int target =
locked ? 0 : 1;
1639 else if( target == 1 )
1641 shapePos.x += halfSize.x;
1654 int target =
locked || (int)
pad->GetOrientation() % 900 > 0 ? 0 : 4;
1666 else if( target == 4 )
1668 if(
pad->GetOrientation() == 900 ||
pad->GetOrientation() == 2700 )
1669 std::swap( halfSize.x, halfSize.y );
1673 shapePos.y - halfSize.y ) );
1676 shapePos.y + halfSize.y ) );
1691 ZONE* zone = static_cast<ZONE*>( item );
1716 const PCB_DIM_ALIGNED* dimension = static_cast<const PCB_DIM_ALIGNED*>( item );
1728 const PCB_DIM_CENTER* dimension = static_cast<const PCB_DIM_CENTER*>( item );
1737 const PCB_DIM_LEADER* dimension = static_cast<const PCB_DIM_LEADER*>( item );
1765 if(
frame()->ToolStackIsEmpty() )
1783 switch( parent->
Type() )
1792 isPoly = static_cast<PCB_SHAPE*>( parent )->GetShape() ==
SHAPE_T::POLY;
1800 if( line && isPoly )
1823 switch( item->
Type() )
1827 switch( static_cast<const PCB_SHAPE*>( item )->GetShape() )
1876 const auto type = aItem.
Type();
1884 const PCB_SHAPE& shape = static_cast<const PCB_SHAPE&>( aItem );
1894 if( aSelection.
Size() != 1 )
1904 static std::pair<bool, SHAPE_POLY_SET::VERTEX_INDEX>
1909 auto vertexIdx = it.GetIndex();
1912 return std::make_pair(
true, vertexIdx );
1930 switch( item->
Type() )
1934 polyset = static_cast<ZONE*>( item )->
Outline();
1939 if( static_cast<PCB_SHAPE*>( item )->GetShape() ==
SHAPE_T::POLY )
1940 polyset = &static_cast<PCB_SHAPE*>( item )->GetPolyShape();
1955 const auto& vertexIdx = vertex.second;
1961 if( vertexIdx.m_contour == 0 &&
1962 polyset->
Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour].PointCount() <= 3 )
1986 PCB_SHAPE* graphicItem = dynamic_cast<PCB_SHAPE*>( item );
1992 unsigned int nearestIdx = 0;
1993 unsigned int nextNearestIdx = 0;
1994 unsigned int nearestDist = INT_MAX;
1995 unsigned int firstPointInContour = 0;
2000 ZONE* zone = static_cast<ZONE*>( item );
2001 zoneOutline = zone->
Outline();
2018 for( ; iterator; iterator++, curr_idx++ )
2020 int jj = curr_idx+1;
2024 jj = firstPointInContour;
2025 firstPointInContour = curr_idx+1;
2028 SEG curr_segment( zoneOutline->
CVertex( curr_idx ), zoneOutline->
CVertex( jj ) );
2030 unsigned int distance = curr_segment.Distance( cursorPos );
2035 nearestIdx = curr_idx;
2036 nextNearestIdx = jj;
2041 auto& sideOrigin = zoneOutline->
CVertex( nearestIdx );
2042 auto& sideEnd = zoneOutline->
CVertex( nextNearestIdx );
2043 SEG nearestSide( sideOrigin, sideEnd );
2048 if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
2049 nearestPoint = ( sideOrigin + sideEnd ) / 2;
2051 zoneOutline->
InsertVertex( nextNearestIdx, nearestPoint );
2055 static_cast<ZONE*>( item )->HatchBorder();
2058 commit.
Push(
_(
"Add a zone corner" ) );
2062 commit.
Modify( graphicItem );
2065 VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
2068 graphicItem->
SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
2071 static_cast<FP_SHAPE*>( graphicItem )->SetLocalCoord();
2078 FP_SHAPE* edge = static_cast<FP_SHAPE*>( graphicItem );
2080 newSegment =
new FP_SHAPE( *edge );
2084 newSegment =
new PCB_SHAPE( *graphicItem );
2088 newSegment->
SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
2089 newSegment->
SetEnd( wxPoint( seg.B.x, seg.B.y ) );
2092 static_cast<FP_SHAPE*>( newSegment )->SetLocalCoord();
2094 commit.
Add( newSegment );
2095 commit.
Push(
_(
"Split segment" ) );
2117 ZONE* zone = static_cast<ZONE*>( item );
2123 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
2138 const auto& vertexIdx = vertex.second;
2139 auto& outline = polygon->
Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
2141 if( outline.PointCount() > 3 )
2151 if( vertexIdx.m_contour > 0 )
2166 commit.
Push(
_(
"Remove a zone/polygon corner" ) );
2170 static_cast<ZONE*>( item )->HatchBorder();
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
static TOOL_ACTION selectionClear
Clear the current selection.
int removeCorner(const TOOL_EVENT &aEvent)
int TotalVertices() const
Delete aIdx-th polygon from the set.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
EDIT_CONSTRAINT for 3 segments: dragged and two adjacent ones, enforcing to keep their slopes and all...
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 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.
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
static const TOOL_EVENT SelectedEvent
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
class PCB_DIM_LEADER, a leader dimension (graphic item)
int OutlineCount() const
Return the number of vertices in a given outline/hole.
void setTransitions() override
< Set up handlers for various events.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
const wxPoint & GetCrossbarStart() const
bool IsEndContour() const
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
EDIT_POINT get45DegConstrainer() const
Condition to display "Create corner" context menu entry.
static TOOL_ACTION activatePointEditor
void updatePoints()
Update which point is being edited.
void SetEnd(const wxPoint &aEnd)
virtual void SetPosition(const wxPoint &aPos) override
void SetArcGeometry(const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd)
Set the three controlling points for an arc.
static const TOOL_EVENT UnselectedEvent
void updateEditedPoint(const TOOL_EVENT &aEvent)
Set the current point being edited. NULL means none.
int addCorner(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
This file is part of the common library.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
const wxPoint & GetStart() const
Return the starting point of the graphic.
bool removeCornerCondition(const SELECTION &aSelection)
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
void buildForPolyOutline(std::shared_ptr< EDIT_POINTS > points, const SHAPE_POLY_SET *aOutline)
void setEditedPoint(EDIT_POINT *aPoint)
constexpr KICAD_T BaseType(const KICAD_T aType)
Return the underlying type of the given type.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Return the aGlobalIndex-th vertex in the poly set.
class PCB_DIM_CENTER, a center point marking (graphic item)
SHAPE_POLY_SET * Outline()
static TOOL_ACTION changeEditMethod
virtual void Revert() override
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
Represent a line connecting two EDIT_POINTs.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
EDIT_CONSTRAINT for a EDIT_LINE, that constrains the line to move perpendicular to the line itself.
const wxPoint & GetCrossbarEnd() const
CONST_ITERATOR CIterateWithHoles(int aOutline) const
void DupPolyPointsList(std::vector< wxPoint > &aBuffer) const
Duplicate the list of corners in a std::vector<wxPoint>
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
double m_DrawArcCenterMaxAngle
When drawing an arc, the angle ( center - start ) - ( start - end ) can be limited to avoid extremely...
void InsertVertex(int aGlobalIndex, const VECTOR2I &aNewVertex)
Adds a vertex in the globally indexed position aGlobalIndex.
class FP_SHAPE, a footprint edge
class PAD, a pad in a footprint
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEX > findVertex(SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Return an object to iterate through the points of the polygons between aFirst and aLast.
void RotatePoint(int *pX, int *pY, double angle)
virtual bool IsLocked() const
std::shared_ptr< EDIT_POINTS > m_editPoints
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
GRID_CONSTRAINT_TYPE GetGridConstraint() const
EDIT_CONSTRAINT that imposes a constraint that a point has to lie on a line (determined by 2 points).
EDIT_CONSTRAINT that imposes a constraint that two points have to be located at angle of 45 degree mu...
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
void SetBezierC1(const wxPoint &aPt)
int modifiedSelection(const TOOL_EVENT &aEvent)
EDIT_POINT * m_editedPoint
For better understanding of the points that make a dimension:
EDIT_POINT m_altConstrainer
std::shared_ptr< EDIT_POINTS > makePoints(EDA_ITEM *aItem)
Update item's points with edit points.
void SetStart(const wxPoint &aStart)
int getEditedPointIndex() const
Return true if aPoint is the currently modified point.
const wxPoint & GetBezierC1() const
void SetVertex(const VERTEX_INDEX &aIndex, const VECTOR2I &aPos)
Accessor function to set the position of a specific point.
static bool canAddCorner(const EDA_ITEM &aItem)
Condition to display "Remove corner" context menu entry.
virtual void Move(const wxPoint &aMoveVector) override
Move this object.
virtual const wxPoint & GetStart() const
The dimension's origin is the first feature point for the dimension.
void SetActive(bool aActive=true)
const wxPoint & GetEnd() const
Return the ending point of the graphic.
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.
LSET is a set of PCB_LAYER_IDs.
DIR GetOrientation() const
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
VECTOR2< double > VECTOR2D
int OnSelectionChange(const TOOL_EVENT &aEvent)
Change selection event handler.
virtual wxPoint GetPosition() const override
PCB_SELECTION_TOOL * m_selectionTool
void HatchBorder()
Compute the hatch lines depending on the hatch parameters and stores it in the zone's attribute m_bor...
ITERATOR IterateWithHoles(int aOutline)
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
virtual void SetEnd(const wxPoint &aPoint)
static TOOL_ACTION pointEditorAddCorner
Break outline (insert additional points to an edge)
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
void setAltConstraint(bool aEnabled)
Return a point that should be used as a constrainer for 45 degrees mode.
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
int changeEditMethod(const TOOL_EVENT &aEvent)
static void pinEditedCorner(int aEditedPointIndex, int aMinWidth, int aMinHeight, VECTOR2I &aTopLeft, VECTOR2I &aTopRight, VECTOR2I &aBotLeft, VECTOR2I &aBotRight, VECTOR2I &aHole, VECTOR2I &aHoleSize)
Update the coordinates of 4 corners of a rectangle, according to pad constraints and the moved corner...
Mark the center of a circle or arc with a cross shape.
COMMIT & StageItems(const Range &aRange, CHANGE_TYPE aChangeType)
Add a change of the item aItem of type aChangeType to the change list.
const wxPoint & GetBezierC2() const
static const TOOL_EVENT UninhibitSelectionEditing
Used to inform tool that it should display the disambiguation menu.
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
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.
static LSET AllLayersMask()
Handle a list of polygons defining a copper zone.
class ZONE, a copper pour area
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
EDA_ITEM_FLAGS GetEditFlags() const
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
void SetCenter(const wxPoint &aCenter)
void SetOrientation(DIR aOrientation)
Set the orientation of the dimension line (so, perpendicular to the feature lines).
class PCB_DIMENSION_BASE: abstract dimension meta-type
SHAPE_POLY_SET & GetPolyShape()
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
class FOOTPRINT, a footprint
EDIT_POINT m_original
Original position for the current drag point.
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
bool Init() override
Init() is called once upon a registration of the tool.
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.
Common, abstract interface for edit frames.
void RemoveVertex(int aGlobalIndex)
Delete the aGlobalIndex-th vertex.
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
class ZONE, managed by a footprint
wxPoint GetArcMid() const
void SetHover(bool aHover=true)
virtual void SetStart(const wxPoint &aPoint)
int Size() const
Returns the number of selected parts.
A base class for most all the KiCad significant classes used in schematics and boards.
static const TOOL_EVENT InhibitSelectionEditing
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Revert the commit by restoring the modified items state.
void SetBezierC2(const wxPoint &aPt)
bool isModified(const EDIT_POINT &aPoint) const
Set up an alternative constraint (typically enabled upon a modifier key being pressed).
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
static bool addCornerCondition(const SELECTION &aSelection)
Determine if the tool can currently add a corner to the given item.
A leader is a dimension-like object pointing to a specific point.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
EDIT_POINT * m_hoveredPoint
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
virtual const wxPoint & GetEnd() const
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
void SetNeedRefill(bool aNeedRefill)
Represent a single point that can be used for modifying items.
POLYGON & Polygon(int aIndex)
Text placement is manually set by the user.
bool UnFill()
Removes the zone filling.
bool validatePolygon(SHAPE_POLY_SET &aModified) const
Validate a polygon and displays a popup warning if invalid.
BOARD_ITEM_CONTAINER * GetParent() const
void updateItem() const
Apply the last changes to the edited item.
class PCB_SHAPE, a segment not on copper layers
static TOOL_ACTION toggle45
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
virtual void ApplyConstraint()
Correct coordinates of an EDIT_POINT by applying previously set constraint.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
void SetTextPositionMode(DIM_TEXT_POSITION aMode)
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...
KICAD_T Type() const
Returns the type of object.
virtual void UpdateMsgPanel()
Redraw the message panel.
bool IsSelfIntersecting() const
Check whether any of the polygons in the set is self intersecting.
void RemoveContour(int aContourIdx, int aPolygonIdx=-1)
Delete the aContourIdx-th contour of the aPolygonIdx-th polygon in the set.
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
void Update()
Update the dimension's cached text and geometry.