28 using namespace std::placeholders;
93 m_selectionTool( nullptr ),
94 m_editedPoint( nullptr ),
95 m_hoveredPoint( nullptr ),
98 m_altEditMethod( false ),
111 m_statusPopup = std::make_unique<STATUS_TEXT_POPUP>( getEditFrame<PCB_BASE_EDIT_FRAME>() );
113 m_statusPopup->SetText(
_(
"Self-intersecting polygons are not allowed." ) );
122 wxASSERT_MSG(
m_selectionTool,
"pcbnew.InteractiveSelection tool is not available" );
140 points->AddPoint( *iterator );
142 if( iterator.IsEndContour() )
148 for(
int i = 0; i < cornersCount - 1; ++i )
150 if( points->IsContourEnd( i ) )
151 points->AddLine( points->Point( i ), points->Point( points->GetContourStartIdx( i ) ) );
153 points->AddLine( points->Point( i ), points->Point( i + 1 ) );
155 points->Line( i ).SetConstraint(
new EC_PERPLINE( points->Line( i ) ) );
159 points->AddLine( points->Point( cornersCount - 1 ),
160 points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
162 points->Line( points->LinesSize() - 1 )
163 .SetConstraint(
new EC_PERPLINE( points->Line( points->LinesSize() - 1 ) ) );
169 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
175 switch( aItem->
Type() )
180 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( aItem );
185 points->AddPoint( shape->
GetStart() );
186 points->AddPoint( shape->
GetEnd() );
190 points->AddPoint( shape->
GetStart() );
191 points->AddPoint( wxPoint( shape->
GetEnd().x, shape->
GetStart().y ) );
192 points->AddPoint( shape->
GetEnd() );
193 points->AddPoint( wxPoint( shape->
GetStart().x, shape->
GetEnd().y ) );
220 points->AddPoint( shape->
GetEnd() );
228 points->AddPoint( shape->
GetStart() );
231 points->AddPoint( shape->
GetEnd() );
243 const PAD* pad = static_cast<const PAD*>( aItem );
253 points->AddPoint( shapePos );
254 points->AddPoint( wxPoint( shapePos.x + halfSize.x, shapePos.y ) );
267 std::swap( halfSize.x, halfSize.y );
269 points->AddPoint( shapePos - halfSize );
270 points->AddPoint( wxPoint( shapePos.x + halfSize.x, shapePos.y - halfSize.y ) );
271 points->AddPoint( shapePos + halfSize );
272 points->AddPoint( wxPoint( shapePos.x - halfSize.x, shapePos.y + halfSize.y ) );
285 const ZONE* zone = static_cast<const ZONE*>( aItem );
293 const ALIGNED_DIMENSION* dimension = static_cast<const ALIGNED_DIMENSION*>( aItem );
295 points->AddPoint( dimension->
GetStart() );
296 points->AddPoint( dimension->
GetEnd() );
317 const CENTER_DIMENSION* dimension = static_cast<const CENTER_DIMENSION*>( aItem );
319 points->AddPoint( dimension->
GetStart() );
320 points->AddPoint( dimension->
GetEnd() );
330 const LEADER* dimension = static_cast<const LEADER*>( aItem );
332 points->AddPoint( dimension->
GetStart() );
333 points->AddPoint( dimension->
GetEnd() );
425 LSET snapLayers = item->GetLayerSet();
433 grid.SetSnap( !evt->Modifier(
MD_SHIFT ) );
485 if( grid.GetUseGrid() )
487 VECTOR2I gridPt = grid.BestSnapAnchor( pos, {}, { item } );
491 VECTOR2I deltaGrid = gridPt - grid.BestSnapAnchor( last, {}, { item } );
493 if( abs( delta.
x ) > grid.GetGrid().x / 2 )
494 pos.
x = last.x + deltaGrid.
x;
498 if( abs( delta.
y ) > grid.GetGrid().y / 2 )
499 pos.
y = last.y + deltaGrid.
y;
510 bool enableAltConstraint = !!evt->Modifier(
MD_CTRL );
512 if( enableAltConstraint )
529 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
540 commit.
Push(
_(
"Drag a corner" ) );
547 else if( evt->IsCancelInteractive() || evt->IsActivate() )
555 else if( evt->IsCancelInteractive() )
560 if( evt->IsActivate() && !evt->IsMoveTool() )
592 VECTOR2D startLine = aStart - aCenter;
598 bool arcValid =
true;
638 u2 = v3 - ( u1.
x * v3.
x + u1.
y * v3.
y ) * u1;
647 double det = u1.
x * u2.y - u2.x * u1.
y;
654 double tmpx = v1.
x * u2.y - v1.
y * u2.x;
655 double tmpy = -v1.
x * u1.
y + v1.
y * u1.
x;
660 tmpx =
v2.
x * u2.y -
v2.
y * u2.x;
667 bool transformCircle =
false;
704 transformCircle =
true;
708 double delta = ( R * R -
v2.
x *
v2.
x -
v2.
y *
v2.
y ) / ( 2 *
v2.
x - 2 * R );
716 if( !std::isfinite( delta ) )
721 v4 = ( !transformCircle ) ?
VECTOR2D( -delta, 0 ) :
VECTOR2D( 2 * R + delta, 0 );
725 if( transformCircle )
726 clockwise = !clockwise;
728 tmpx = v4.
x * u1.
x + v4.
y * u2.x;
729 tmpy = v4.
x * u1.
y + v4.
y * u2.y;
733 aCenter = v4 + aCenter;
735 startLine = aStart - aCenter;
736 endLine = aEnd - aCenter;
739 if( clockwise && newAngle < 0.0 )
741 else if( !clockwise && newAngle > 0.0 )
747 aArc->
SetCenter( wxPoint( aCenter.x, aCenter.y ) );
775 switch( aEditedPointIndex )
781 aTopLeft.
x = std::min( aTopLeft.
x, aHole.
x - aHoleSize.
x / 2 - aMinWidth );
782 aTopLeft.
y = std::min( aTopLeft.
y, aHole.
y - aHoleSize.
y / 2 - aMinHeight );
787 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - aMinWidth );
788 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - aMinHeight );
792 aTopRight.
y = aTopLeft.
y;
793 aBotLeft.
x = aTopLeft.
x;
801 aTopRight.
x = std::max( aTopRight.
x, aHole.
x + aHoleSize.
x / 2 + aMinWidth );
802 aTopRight.
y = std::min( aTopRight.
y, aHole.
y - aHoleSize.
y / 2 - aMinHeight );
807 aTopRight.
x = std::max( aTopRight.
x, aBotLeft.
x + aMinWidth );
808 aTopRight.
y = std::min( aTopRight.
y, aBotLeft.
y - aMinHeight );
812 aTopLeft.
y = aTopRight.
y;
813 aBotRight.
x = aTopRight.
x;
821 aBotLeft.
x = std::min( aBotLeft.
x, aHole.
x - aHoleSize.
x / 2 - aMinWidth );
822 aBotLeft.
y = std::max( aBotLeft.
y, aHole.
y + aHoleSize.
y / 2 + aMinHeight );
827 aBotLeft.
x = std::min( aBotLeft.
x, aTopRight.
x - aMinWidth );
828 aBotLeft.
y = std::max( aBotLeft.
y, aTopRight.
y + aMinHeight );
832 aBotRight.
y = aBotLeft.
y;
833 aTopLeft.
x = aBotLeft.
x;
841 aBotRight.
x = std::max( aBotRight.
x, aHole.
x + aHoleSize.
x / 2 + aMinWidth );
842 aBotRight.
y = std::max( aBotRight.
y, aHole.
y + aHoleSize.
y / 2 + aMinHeight );
847 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + aMinWidth );
848 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + aMinHeight );
852 aBotLeft.
y = aBotRight.
y;
853 aTopRight.
x = aBotRight.
x;
885 target = *p2 - aCenter;
887 double sqRadius = ( *p1 - aCenter ).SquaredEuclideanNorm();
900 p2->
y = ( target.
y > 0 ) ? sqrt( sqRadius ) : -sqrt( sqRadius );
904 double tan = target.
y / static_cast<double>( target.
x );
906 double tmp = sqrt( sqRadius / ( 1.0 + tan * tan ) );
908 tmp = target.
x > 0 ? tmp : -tmp;
909 p2->
y = target.
y / static_cast<double>( target.
x ) * tmp;
918 VECTOR2D startLine = aStart - aCenter;
922 if( clockwise && newAngle < 0.0 )
924 else if( !clockwise && newAngle > 0.0 )
943 aStart = aStart - aCenter;
944 aEnd = aEnd - aCenter;
946 double sqRadius = ( aCursor - aCenter ).SquaredEuclideanNorm();
951 aStart.
y = aCursor.
y > 0 ? sqrt( sqRadius ) : -sqrt( sqRadius );
960 double tan = aStart.
y / static_cast<double>( aStart.
x );
961 double tmp = sqrt( sqRadius / ( 1.0 + tan * tan ) );
963 tmp = aStart.
x > 0 ? tmp : -tmp;
964 aStart.
y = aStart.
y / static_cast<double>( aStart.
x ) * tmp;
971 aEnd.
y = aMid.
y > 0 ? sqrt( sqRadius ) : -sqrt( sqRadius );
980 double tan = aEnd.
y / static_cast<double>( aEnd.
x );
981 double tmp = sqrt( sqRadius / ( 1.0 + tan * tan ) );
983 tmp = aEnd.
x > 0 ? tmp : -tmp;
984 aEnd.
y = aEnd.
y / static_cast<double>( aEnd.
x ) * tmp;
988 aStart = aStart + aCenter;
989 aEnd = aEnd + aCenter;
1000 VECTOR2I m = ( aStart + aEnd ) / 2;
1004 const int JUST_OFF = ( aStart - aEnd ).
EuclideanNorm() / 100;
1007 VECTOR2I mid = legal.NearestPoint( aCursor );
1009 aArc->
SetArcGeometry( (wxPoint) aStart, (wxPoint) mid, (wxPoint) aEnd );
1020 switch( item->
Type() )
1025 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
1080 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1097 wxPoint moveVector = wxPoint( center.
x, center.
y ) - shape->
GetCenter();
1098 shape->
Move( moveVector );
1129 wxPoint moveVector = wxPoint( center.
x, center.
y ) - shape->
GetCenter();
1130 shape->
Move( moveVector );
1134 shape->
SetEnd( wxPoint( end.
x, end.
y ) );
1146 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1174 if(
FP_SHAPE* fpShape = dyn_cast<FP_SHAPE*>( item ) )
1175 fpShape->SetLocalCoord();
1182 PAD* pad = static_cast<PAD*>( item );
1193 wxPoint moveVector = center - pad->
ShapePos();
1199 pad->
SetSize( wxSize( diameter, diameter ) );
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] );
1246 std::swap( padSize.x, padSize.y );
1257 int left, top, right, bottom;
1265 bottom = botRight.
y;
1275 wxSize padSize( abs( right - left ), abs( bottom - top ) );
1278 std::swap( padSize.x, padSize.y );
1281 pad->
SetPosition( wxPoint( ( left + right ) / 2, ( top + bottom ) / 2 ) );
1295 ZONE* zone = static_cast<ZONE*>( item );
1322 if( featureLine.Cross( crossBar ) > 0 )
1323 dimension->
SetHeight( -featureLine.EuclideanNorm() );
1325 dimension->
SetHeight( featureLine.EuclideanNorm() );
1334 if( featureLine.Cross( crossBar ) > 0 )
1335 dimension->
SetHeight( -featureLine.EuclideanNorm() );
1337 dimension->
SetHeight( featureLine.EuclideanNorm() );
1388 VECTOR2I direction = ( directionA < directionB ) ? directionA : directionB;
1394 if( !bounds.Contains( cursorPos ) )
1398 if( bounds.GetWidth() == 0 )
1402 else if( bounds.GetHeight() == 0 )
1406 else if( cursorPos.x > bounds.GetLeft() && cursorPos.x < bounds.GetRight() )
1410 else if( cursorPos.y > bounds.GetTop() && cursorPos.y < bounds.GetBottom() )
1416 vert = std::abs( direction.y ) < std::abs( direction.x );
1426 dimension->
SetHeight( vert ? featureLine.x : featureLine.y );
1472 LEADER* dimension = static_cast<LEADER*>( item );
1482 wxPoint delta = newPoint - dimension->
GetEnd();
1484 dimension->
SetEnd( newPoint );
1514 ZONE* zone = static_cast<ZONE*>( item );
1534 wxPoint p = wxGetMousePosition() + wxPoint( 20, 20 );
1554 switch( item->
Type() )
1559 const PCB_SHAPE* shape = static_cast<const PCB_SHAPE*>( item );
1593 if(
m_editPoints->PointsSize() != (unsigned) points.size() )
1605 for(
unsigned i = 0; i < points.size(); i++ )
1627 const PAD* pad = static_cast<const PAD*>( item );
1629 wxPoint shapePos = pad->
ShapePos();
1636 int target = locked ? 0 : 2;
1649 else if( target == 2 )
1653 vec.
Resize( halfSize.x );
1668 int target = locked || (int) pad->
GetOrientation() % 900 > 0 ? 0 : 4;
1680 else if( target == 4 )
1683 std::swap( halfSize.x, halfSize.y );
1687 shapePos.y - halfSize.y ) );
1690 shapePos.y + halfSize.y ) );
1704 ZONE* zone = static_cast<ZONE*>( item );
1729 const ALIGNED_DIMENSION* dimension = static_cast<const ALIGNED_DIMENSION*>( item );
1741 const CENTER_DIMENSION* dimension = static_cast<const CENTER_DIMENSION*>( item );
1750 const LEADER* dimension = static_cast<const LEADER*>( item );
1778 if(
frame()->ToolStackIsEmpty() )
1793 bool isPoly =
false;
1808 if( line && isPoly )
1831 switch( item->
Type() )
1835 switch( static_cast<const PCB_SHAPE*>( item )->GetShape() )
1884 const auto type = aItem.
Type();
1892 const PCB_SHAPE& shape = static_cast<const PCB_SHAPE&>( aItem );
1902 if( aSelection.
Size() != 1 )
1912 static std::pair<bool, SHAPE_POLY_SET::VERTEX_INDEX>
1917 auto vertexIdx = it.GetIndex();
1920 return std::make_pair(
true, vertexIdx );
1940 && static_cast<PCB_SHAPE*>( item )->GetShape() ==
S_POLYGON ) ) )
1948 polyset = static_cast<ZONE*>( item )->
Outline();
1950 polyset = &static_cast<PCB_SHAPE*>( item )->GetPolyShape();
1957 const auto& vertexIdx = vertex.second;
1963 if( vertexIdx.m_contour == 0 && polyset->
Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour].PointCount() <= 3 )
1987 PCB_SHAPE* graphicItem = dynamic_cast<PCB_SHAPE*>( item );
1993 unsigned int nearestIdx = 0;
1994 unsigned int nextNearestIdx = 0;
1995 unsigned int nearestDist = INT_MAX;
1996 unsigned int firstPointInContour = 0;
2001 ZONE* zone = static_cast<ZONE*>( item );
2002 zoneOutline = zone->
Outline();
2019 for( ; iterator; iterator++, curr_idx++ )
2021 int jj = curr_idx+1;
2025 jj = firstPointInContour;
2026 firstPointInContour = curr_idx+1;
2029 SEG curr_segment( zoneOutline->
CVertex( curr_idx ), zoneOutline->
CVertex( jj ) );
2031 unsigned int distance = curr_segment.Distance( cursorPos );
2036 nearestIdx = curr_idx;
2037 nextNearestIdx = jj;
2042 auto& sideOrigin = zoneOutline->
CVertex( nearestIdx );
2043 auto& sideEnd = zoneOutline->
CVertex( nextNearestIdx );
2044 SEG nearestSide( sideOrigin, sideEnd );
2049 if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
2050 nearestPoint = ( sideOrigin + sideEnd ) / 2;
2052 zoneOutline->
InsertVertex( nextNearestIdx, nearestPoint );
2056 static_cast<ZONE*>( item )->HatchBorder();
2059 commit.
Push(
_(
"Add a zone corner" ) );
2064 commit.
Modify( graphicItem );
2067 VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
2070 graphicItem->
SetEnd( wxPoint( nearestPoint.x, nearestPoint.y ) );
2073 static_cast<FP_SHAPE*>( graphicItem )->SetLocalCoord();
2080 FP_SHAPE* edge = static_cast<FP_SHAPE*>( graphicItem );
2082 newSegment =
new FP_SHAPE( *edge );
2086 newSegment =
new PCB_SHAPE( *graphicItem );
2090 newSegment->
SetStart( wxPoint( nearestPoint.x, nearestPoint.y ) );
2091 newSegment->
SetEnd( wxPoint( seg.B.x, seg.B.y ) );
2094 static_cast<FP_SHAPE*>( newSegment )->SetLocalCoord();
2096 commit.
Add( newSegment );
2097 commit.
Push(
_(
"Split segment" ) );
2119 ZONE* zone = static_cast<ZONE*>( item );
2125 PCB_SHAPE* shape = static_cast<PCB_SHAPE*>( item );
2140 const auto& vertexIdx = vertex.second;
2141 auto& outline = polygon->
Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
2143 if( outline.PointCount() > 3 )
2153 if( vertexIdx.m_contour > 0 )
2168 commit.
Push(
_(
"Remove a zone/polygon corner" ) );
2172 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...
wxPoint GetArcEnd() const
void SetOffset(const wxPoint &aOffset)
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
static const TOOL_EVENT SelectedEvent
class ALIGNED_DIMENSION, a linear dimension (graphic item)
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
class 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.
bool IsEndContour() const
EDIT_POINT get45DegConstrainer() const
Condition to display "Create corner" context menu entry.
static TOOL_ACTION activatePointEditor
virtual void SetStart(const wxPoint &aPoint)
void updatePoints()
Update which point is being edited.
SHAPE_POLY_SET & GetPolyShape()
virtual void SetPosition(const wxPoint &aPos) override
static const TOOL_EVENT UnselectedEvent
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
void updateEditedPoint(const TOOL_EVENT &aEvent)
Set the current point being edited. NULL means none.
void SetBezControl2(const wxPoint &aPoint)
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...
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)
Returns 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 CENTER_DIMENSION, 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.
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...
virtual const wxPoint & GetStart() const
The dimension's origin is the first feature point for the dimension.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
polygon (not yet used for tracks, but could be in microwave apps)
EDIT_CONSTRAINT for a EDIT_LINE, that constrains the line to move perpendicular to the line itself.
bool IsLocked() const override
CONST_ITERATOR CIterateWithHoles(int aOutline) const
double RAD2DECIDEG(double rad)
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
usual segment : line with rounded ends
double m_DrawArcCenterMaxAngle
When drawing an arc, the angle ( center - start ) - ( start - end ) can be limited to avoid extremely...
GAL * GetGAL() const
Return the #GAL this view is using to draw graphical primitives.
class FP_SHAPE, a footprint edge
class PAD, a pad in a footprint
PAD_SHAPE_T GetShape() const
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.
void SetSize(const wxSize &aSize)
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 Update()
Updates the dimension's cached text and geometry.
void RotatePoint(int *pX, int *pY, double angle)
segment with non rounded ends
const wxPoint & GetCrossbarStart() const
std::shared_ptr< EDIT_POINTS > m_editPoints
static TOOL_ACTION zoneFill
void editArcEndpointKeepCenter(PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
Move an end point of the arc around the circumference.
GRID_CONSTRAINT_TYPE GetGridConstraint() const
EDIT_CONSTRAINT that imposes a constraint that a point has to lie on a line (determined by 2 points).
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
virtual void Remove(VIEW_ITEM *aItem) override
Remove a VIEW_ITEM from the view.
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.
int modifiedSelection(const TOOL_EVENT &aEvent)
const wxPoint & GetCrossbarEnd() const
wxPoint GetArcStart() const
EDIT_POINT * m_editedPoint
EDIT_POINT m_altConstrainer
std::shared_ptr< EDIT_POINTS > makePoints(EDA_ITEM *aItem)
Update item's points with edit points.
int getEditedPointIndex() const
Return true if aPoint is the currently modified point.
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.
void SetArcGeometry(const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd)
Set the three controlling points for an arc.
virtual void Move(const wxPoint &aMoveVector) override
Move this object.
const std::vector< wxPoint > BuildPolyPointsList() const
Build and return the list of corners in a std::vector<wxPoint> It must be used only to convert the SH...
const wxPoint & GetOffset() const
bool GetGridSnapping() const
void SetActive(bool aActive=true)
const wxSize & GetDrillSize() const
void SetHeight(int aHeight)
Sets the distance from the feature points to the crossbar line.
LSET is a set of PCB_LAYER_IDs.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
double GetOrientation() const
Return the rotation angle of the pad in a variety of units (the basic call returns tenths of degrees)...
VECTOR2< double > VECTOR2D
int OnSelectionChange(const TOOL_EVENT &aEvent)
Change selection event handler.
virtual wxPoint GetPosition() const override
A leader is a dimension-like object pointing to a specific point.
PCB_SELECTION_TOOL * m_selectionTool
STATUS_FLAGS GetEditFlags() const
void HatchBorder()
Function HatchBorder computes the hatch lines depending on the hatch parameters and stores it in the ...
ITERATOR IterateWithHoles(int aOutline)
Represent a set of closed polygons.
SHAPE_LINE_CHAIN & Outline(int aIndex)
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.
const wxSize & GetSize() const
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
int changeEditMethod(const TOOL_EVENT &aEvent)
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
DIR GetOrientation() const
COMMIT & StageItems(const Range &aRange, CHANGE_TYPE aChangeType)
Add a change of the item aItem of type aChangeType to the change list.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
static const TOOL_EVENT UninhibitSelectionEditing
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 SetEnd(const wxPoint &aPoint)
Text placement is manually set by the user.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
static LSET AllLayersMask()
ZONE handles 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
void SetCenter(const wxPoint &aCenterPoint)
For arcs and circles:
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
double Angle() const
Compute the angle of the vector.
void SetBezControl1(const wxPoint &aPoint)
class DIMENSION_BASE: abstract dimension meta-type
void SetOrientation(DIR aOrientation)
Sets the orientation of the dimension line (so, perpendicular to the feature lines)
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
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
FOOTPRINT * GetParent() const
EDIT_POINT m_original
Original position for the current drag point.
void editArcMidKeepEndpoints(PCB_SHAPE *aArc, VECTOR2I aStart, VECTOR2I aEnd, const VECTOR2I aCursor) const
Move the mid point of the arc, while keeping the two endpoints.
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
void editArcMidKeepCenter(PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
Move the mid point of the arc, while keeping the angle.
bool Init() override
Init() is called once upon a registration of the tool.
Common, abstract interface for edit frames.
wxPoint GetPosition() const override
void SetStart(const wxPoint &aStart)
const wxPoint & GetBezControl2() const
void RemoveVertex(int aGlobalIndex)
Delete the aGlobalIndex-th vertex.
Base class for iterating over all vertices in a given SHAPE_POLY_SET.
void SetPosition(const wxPoint &aPos) override
void editArcEndpointKeepTangent(PCB_SHAPE *aArc, VECTOR2I aCenter, VECTOR2I aStart, VECTOR2I aMid, VECTOR2I aEnd, const VECTOR2I aCursor) const
Move an end point of the arc, while keeping the tangent at the other endpoint.
class ZONE, managed by a footprint
void SetHover(bool aHover=true)
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 RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_BezierPoints vertex list that approximate the Bezier curve by a list of segments Has me...
void SetArcEnd(const wxPoint &aArcEndPoint)
Initialize the end arc point.
bool isModified(const EDIT_POINT &aPoint) const
Set up an alternative constraint (typically enabled upon a modifier key being pressed).
void InsertVertex(int aGlobalIndex, VECTOR2I aNewVertex)
Adds a vertex in the globally indexed position aGlobalIndex.
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.
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
EDIT_POINT * m_hoveredPoint
class ORTHOGONAL_DIMENSION, a linear dimension constrained to x/y
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1) override
Add a VIEW_ITEM to the view.
wxPoint GetArcMid() const
T EuclideanNorm() const
Compute the Euclidean norm of the vector, which is defined as sqrt(x ** 2 + y ** 2).
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.
PCB_SHAPE_TYPE_T GetShape() const
POLYGON & Polygon(int aIndex)
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
For better understanding of the points that make a dimension:
bool validatePolygon(SHAPE_POLY_SET &aModified) const
Validate a polygon and displays a popup warning if invalid.
void SetTextPositionMode(DIM_TEXT_POSITION aMode)
BOARD_ITEM_CONTAINER * GetParent() const
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
void updateItem() const
Apply the last changes to the edited item.
class PCB_SHAPE, a segment not on copper layers
virtual const wxPoint & GetEnd() const
const wxPoint & GetBezControl1() const
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.
void SetEnd(const wxPoint &aEnd)
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
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...
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
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.
Marks the center of a circle or arc with a cross shape The size and orientation of the cross is adjus...