29using namespace std::placeholders;
108 m_selectionTool( nullptr ),
109 m_editedPoint( nullptr ),
110 m_hoveredPoint( nullptr ),
114 m_altConstrainer(
VECTOR2I( 0, 0 ) )
133 wxASSERT_MSG(
m_selectionTool, wxT(
"pcbnew.InteractiveSelection tool is not available" ) );
151 points->AddPoint( *iterator );
153 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 );
195 switch( aItem->
Type() )
203 points->AddPoint( topLeft );
204 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
205 points->AddPoint( botRight );
206 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
221 points->AddPoint( shape->
GetStart() );
222 points->AddPoint( shape->
GetEnd() );
244 points->AddPoint( shape->
GetStart() );
246 points->AddPoint( shape->
GetEnd() );
251 points->AddPoint( shape->
GetEnd() );
259 points->AddPoint( shape->
GetStart() );
262 points->AddPoint( shape->
GetEnd() );
274 const PAD*
pad =
static_cast<const PAD*
>( aItem );
281 switch(
pad->GetShape() )
284 points->AddPoint(
VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y ) );
293 if( !
pad->GetOrientation().IsCardinal() )
297 std::swap( halfSize.
x, halfSize.
y );
299 points->AddPoint( shapePos - halfSize );
300 points->AddPoint(
VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y - halfSize.
y ) );
301 points->AddPoint( shapePos + halfSize );
302 points->AddPoint(
VECTOR2I( shapePos.
x - halfSize.
x, shapePos.
y + halfSize.
y ) );
315 const ZONE* zone =
static_cast<const ZONE*
>( aItem );
327 points->AddPoint( dimension->
GetStart() );
328 points->AddPoint( dimension->
GetEnd() );
355 points->AddPoint( dimension->
GetStart() );
356 points->AddPoint( dimension->
GetEnd() );
372 points->AddPoint( dimension->
GetStart() );
373 points->AddPoint( dimension->
GetEnd() );
375 points->AddPoint( dimension->
GetKnee() );
396 points->AddPoint( dimension->
GetStart() );
397 points->AddPoint( dimension->
GetEnd() );
491 bool useAltContraint =
false;
499 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
545 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
567 if(
grid.GetUseGrid() )
569 VECTOR2I gridPt =
grid.BestSnapAnchor( pos, {}, { item } );
573 VECTOR2I deltaGrid = gridPt -
grid.BestSnapAnchor( last, {}, { item } );
576 pos.
x = last.
x + deltaGrid.
x;
581 pos.
y = last.
y + deltaGrid.
y;
590 if( useAltContraint )
601 snapLayers, { item } ) );
612 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
622 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
633 commit.
Push(
_(
"Drag a corner" ) );
639 else if( evt->IsCancelInteractive() || evt->IsActivate() )
651 if( evt->IsActivate() && !evt->IsMoveTool() )
682 bool arcValid =
true;
694 else if( aEnd != aArc->
GetEnd() )
729 double det = u1.
x * u2.
y - u2.
x * u1.
y;
736 double tmpx =
v1.
x * u2.
y -
v1.
y * u2.
x;
737 double tmpy = -
v1.
x * u1.
y +
v1.
y * u1.
x;
749 bool transformCircle =
false;
786 transformCircle =
true;
798 if( !std::isfinite(
delta ) )
804 tmpx = v4.
x * u1.
x + v4.
y * u2.
x;
805 tmpy = v4.
x * u1.
y + v4.
y * u2.
y;
809 center = v4 + aCenter;
828 const int c_snapEpsilon_sq = 4;
830 VECTOR2I m = ( aStart / 2 + aEnd / 2 );
831 VECTOR2I perp = ( aEnd - aStart ).Perpendicular().
Resize( INT_MAX / 2 );
833 SEG legal( m - perp, m + perp );
835 const SEG testSegments[] = {
SEG( aCenter, aCenter +
VECTOR2( 1, 0 ) ),
838 std::vector<VECTOR2I> points = { legal.
A, legal.
B };
840 for(
const SEG& seg : testSegments )
845 points.push_back( *vec );
854 SEG::ecoord d_sq = ( pt - aCenter ).SquaredEuclideanNorm();
856 if( d_sq < min_d_sq - c_snapEpsilon_sq )
890 aTopLeft.
x = std::min( aTopLeft.
x, aHole.
x - aHoleSize.
x / 2 - minWidth );
891 aTopLeft.
y = std::min( aTopLeft.
y, aHole.
y - aHoleSize.
y / 2 - minHeight );
896 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
897 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
901 aTopRight.
y = aTopLeft.
y;
902 aBotLeft.
x = aTopLeft.
x;
909 aTopRight.
x = std::max( aTopRight.
x, aHole.
x + aHoleSize.
x / 2 + minWidth );
910 aTopRight.
y = std::min( aTopRight.
y, aHole.
y - aHoleSize.
y / 2 - minHeight );
915 aTopRight.
x = std::max( aTopRight.
x, aBotLeft.
x + minWidth );
916 aTopRight.
y = std::min( aTopRight.
y, aBotLeft.
y - minHeight );
920 aTopLeft.
y = aTopRight.
y;
921 aBotRight.
x = aTopRight.
x;
928 aBotLeft.
x = std::min( aBotLeft.
x, aHole.
x - aHoleSize.
x / 2 - minWidth );
929 aBotLeft.
y = std::max( aBotLeft.
y, aHole.
y + aHoleSize.
y / 2 + minHeight );
934 aBotLeft.
x = std::min( aBotLeft.
x, aTopRight.
x - minWidth );
935 aBotLeft.
y = std::max( aBotLeft.
y, aTopRight.
y + minHeight );
939 aBotRight.
y = aBotLeft.
y;
940 aTopLeft.
x = aBotLeft.
x;
947 aBotRight.
x = std::max( aBotRight.
x, aHole.
x + aHoleSize.
x / 2 + minWidth );
948 aBotRight.
y = std::max( aBotRight.
y, aHole.
y + aHoleSize.
y / 2 + minHeight );
953 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
954 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
958 aBotLeft.
y = aBotRight.
y;
959 aTopRight.
x = aBotRight.
x;
963 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
967 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
971 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
975 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
1001 prev_p1 = aArc->
GetEnd();
1004 movingStart =
false;
1010 if( p1.
x == 0 && p1.
y == 0 )
1011 p1 = prev_p1 - aCenter;
1013 if( p2.
x == 0 && p2.
y == 0 )
1018 if( radius < minRadius )
1021 p1 = aCenter + p1.
Resize( radius );
1022 p2 = aCenter + p2.
Resize( radius );
1045 SEG chord( aStart, aEnd );
1054 if( radius < minRadius )
1057 start = start.
Resize( radius );
1058 end = end.
Resize( radius );
1060 start = start + aCenter;
1061 end = end + aCenter;
1073 VECTOR2I m = ( aStart + aEnd ) / 2;
1077 const int JUST_OFF = ( aStart - aEnd ).
EuclideanNorm() / 100;
1093 switch( item->
Type() )
1105 double oldWidth = bitmap->
GetSize().
x;
1107 double widthRatio = newWidth / oldWidth;
1109 double oldHeight = bitmap->
GetSize().
y;
1112 double heightRatio = newHeight / oldHeight;
1172 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1200 shape->
Move( moveVector );
1234 shape->
Move( moveVector );
1251 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1282 fpShape->SetLocalCoord();
1284 if( fpShape->IsAnnotationProxy() )
1286 for(
PAD*
pad : fpShape->GetParentFootprint()->Pads() )
1296 textBox->ClearRenderCache();
1298 fpTextBox->ClearRenderCache();
1307 switch(
pad->GetShape() )
1331 pinEditedCorner( topLeft, topRight, botLeft, botRight, holeCenter, holeSize );
1333 if( (
pad->GetOffset().x ||
pad->GetOffset().y )
1334 || (
pad->GetDrillSize().x &&
pad->GetDrillSize().y ) )
1344 dist[0] = center.
x - topLeft.
x;
1345 dist[1] = center.
y - topLeft.
y;
1346 dist[2] = botRight.
x - center.
x;
1347 dist[3] = botRight.
y - center.
y;
1351 dist[0] = center.
x - botLeft.
x;
1352 dist[1] = center.
y - topRight.
y;
1353 dist[2] = topRight.
x - center.
x;
1354 dist[3] = botLeft.
y - center.
y;
1357 VECTOR2I padSize( dist[0] + dist[2], dist[1] + dist[3] );
1358 VECTOR2I deltaOffset( padSize.
x / 2 - dist[2], padSize.
y / 2 - dist[3] );
1361 std::swap( padSize.
x, padSize.
y );
1365 pad->SetSize( padSize );
1366 pad->SetOffset( -deltaOffset );
1380 bottom = botRight.
y;
1393 std::swap( padSize.
x, padSize.
y );
1395 pad->SetSize( padSize );
1397 pad->SetLocalCoord();
1412 ZONE* zone =
static_cast<ZONE*
>( item );
1424 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1448 if( featureLine.
Cross( crossBar ) > 0 )
1460 if( featureLine.
Cross( crossBar ) > 0 )
1517 VECTOR2I direction = ( directionA < directionB ) ? directionA : directionB;
1523 if( !bounds.
Contains( cursorPos ) )
1546 dimension->
SetHeight( vert ? featureLine.
x : featureLine.
y );
1646 dimension->
SetEnd( newPoint );
1685 switch( item->
Type() )
1773 std::vector<VECTOR2I> points;
1776 if(
m_editPoints->PointsSize() != (unsigned) points.size() )
1788 for(
unsigned i = 0; i < points.size(); i++ )
1811 const PAD*
pad =
static_cast<const PAD*
>( item );
1816 switch(
pad->GetShape() )
1820 int target =
locked ? 0 : 1;
1833 else if( target == 1 )
1835 shapePos.
x += halfSize.
x;
1848 int target =
locked || !
pad->GetOrientation().IsCardinal() ? 0 : 4;
1860 else if( target == 4 )
1863 std::swap( halfSize.
x, halfSize.
y );
1868 VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y - halfSize.
y ) );
1872 VECTOR2I( shapePos.
x - halfSize.
x, shapePos.
y + halfSize.
y ) );
1887 ZONE* zone =
static_cast<ZONE*
>( item );
1977 if(
frame()->ToolStackIsEmpty() )
1995 switch( parent->
Type() )
2012 if( line && isPoly )
2035 switch( item->
Type() )
2039 switch(
static_cast<const PCB_SHAPE*
>( item )->GetShape() )
2099 const auto type = aItem.
Type();
2117 if( aSelection.
Size() != 1 )
2127static std::pair<bool, SHAPE_POLY_SET::VERTEX_INDEX>
2132 auto vertexIdx = it.GetIndex();
2135 return std::make_pair(
true, vertexIdx );
2153 switch( item->
Type() )
2157 polyset =
static_cast<ZONE*
>( item )->Outline();
2217 unsigned int nearestIdx = 0;
2218 unsigned int nextNearestIdx = 0;
2219 unsigned int nearestDist = INT_MAX;
2220 unsigned int firstPointInContour = 0;
2225 ZONE* zone =
static_cast<ZONE*
>( item );
2226 zoneOutline = zone->
Outline();
2245 for( ; iterator; iterator++, curr_idx++ )
2247 int jj = curr_idx+1;
2251 jj = firstPointInContour;
2252 firstPointInContour = curr_idx+1;
2255 SEG curr_segment( zoneOutline->
CVertex( curr_idx ), zoneOutline->
CVertex( jj ) );
2262 nearestIdx = curr_idx;
2263 nextNearestIdx = jj;
2270 SEG nearestSide( sideOrigin, sideEnd );
2275 if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
2276 nearestPoint = ( sideOrigin + sideEnd ) / 2;
2278 zoneOutline->
InsertVertex( nextNearestIdx, nearestPoint );
2285 commit.
Push(
_(
"Add a zone corner" ) );
2289 commit.
Modify( graphicItem );
2298 static_cast<FP_SHAPE*
>( graphicItem )->SetLocalCoord();
2307 newSegment =
new FP_SHAPE( *edge );
2311 newSegment =
new PCB_SHAPE( *graphicItem );
2319 static_cast<FP_SHAPE*
>( newSegment )->SetLocalCoord();
2321 commit.
Add( newSegment );
2322 commit.
Push(
_(
"Split segment" ) );
2344 ZONE* zone =
static_cast<ZONE*
>( item );
2365 const auto& vertexIdx = vertex.second;
2366 auto& outline = polygon->
Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
2368 if( outline.PointCount() > 3 )
2378 if( vertexIdx.m_contour > 0 )
2393 commit.
Push(
_(
"Remove a zone/polygon corner" ) );
2397 static_cast<ZONE*
>( item )->HatchBorder();
ARC_EDIT_MODE
Settings for arc editing.
@ KEEP_ENDPOINTS_OR_START_DIRECTION
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
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 Revert() override
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) 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 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
coord_type GetTop() const
coord_type GetHeight() const
coord_type GetWidth() const
bool Contains(const Vec &aPoint) const
coord_type GetRight() const
coord_type GetLeft() const
coord_type GetBottom() const
COMMIT & Modify(EDA_ITEM *aItem)
Create an undo entry for an item that has been already modified.
COMMIT & StageItems(const Range &aRange, CHANGE_TYPE aChangeType)
Add a change of the item aItem of type aChangeType to the change list.
COMMIT & Remove(EDA_ITEM *aItem)
Notify observers that aItem has been removed.
COMMIT & Add(EDA_ITEM *aItem)
Notify observers that aItem has been added.
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
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
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.
const VECTOR2I & GetBezierC2() const
void SetBezierC2(const VECTOR2I &aPt)
void SetCenter(const VECTOR2I &aCenter)
virtual VECTOR2I GetTopLeft() const
void RebuildBezierToSegmentsPointsList(int aMinSegLen)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
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.
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
virtual void SetRight(int val)
VECTOR2I GetArcMid() const
const VECTOR2I & GetTextPos() const
void SetTextPos(const VECTOR2I &aPoint)
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.
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()
ARC_EDIT_MODE m_ArcEditMode
static TOOL_ACTION pointEditorArcKeepCenter
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION pointEditorArcKeepEndpoint
static TOOL_ACTION pointEditorRemoveCorner
static TOOL_ACTION pointEditorAddCorner
Common, abstract interface for edit frames.
void UndoRedoBlock(bool aBlock=true)
Enable/disable undo and redo operations.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
PCBNEW_SETTINGS * GetPcbNewSettings() const
virtual MAGNETIC_SETTINGS * GetMagneticItemsSettings()
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
FOOTPRINT_EDITOR_SETTINGS * GetFootprintEditorSettings() const
Object to handle a bitmap image that can be inserted in a PCB.
VECTOR2I GetPosition() const override
void SetImageScale(double aScale)
double GetImageScale() const
const VECTOR2I GetSize() 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)
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)
TOOL_ACTION handlers.
EDIT_POINT m_original
Original position 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.
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
bool validatePolygon(SHAPE_POLY_SET &aModified) const
Validate a polygon and displays a popup warning if invalid.
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
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
virtual void Move(const VECTOR2I &aMoveVector) override
Move this object.
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.
int Size() const
Returns the number of selected parts.
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
Delete aIdx-th polygon from the set.
POLYGON & Polygon(int aIndex)
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 aGlobalIndex-th vertex in the poly set.
int OutlineCount() const
Return the number of vertices in a given outline/hole.
CONST_ITERATOR CIterateWithHoles(int aOutline) const
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).
extended_type Cross(const VECTOR2< T > &aVector) const
Compute cross product of self with aVector.
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).
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
#define ENTERED
indicates a group has been entered
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)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
@ MANUAL
Text placement is manually set by the user.
@ BEZIER_CURVE_CONTROL_POINT2
@ BEZIER_CURVE_CONTROL_POINT1
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 v2(1, 0)
Test suite for KiCad math code.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
double EuclideanNorm(const VECTOR2I &vector)
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< double > VECTOR2D