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 );
190 if( shape->
GetShape() != SHAPE_T::RECTANGLE )
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 ) );
218 case SHAPE_T::SEGMENT:
219 points->AddPoint( shape->
GetStart() );
220 points->AddPoint( shape->
GetEnd() );
223 case SHAPE_T::RECTANGLE:
242 points->AddPoint( shape->
GetStart() );
244 points->AddPoint( shape->
GetEnd() );
247 case SHAPE_T::CIRCLE:
249 points->AddPoint( shape->
GetEnd() );
256 case SHAPE_T::BEZIER:
257 points->AddPoint( shape->
GetStart() );
260 points->AddPoint( shape->
GetEnd() );
272 const PAD*
pad =
static_cast<const PAD*
>( aItem );
279 switch(
pad->GetShape() )
281 case PAD_SHAPE::CIRCLE:
282 points->AddPoint(
VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y ) );
285 case PAD_SHAPE::OVAL:
286 case PAD_SHAPE::TRAPEZOID:
287 case PAD_SHAPE::RECTANGLE:
288 case PAD_SHAPE::ROUNDRECT:
289 case PAD_SHAPE::CHAMFERED_RECT:
291 if( !
pad->GetOrientation().IsCardinal() )
295 std::swap( halfSize.
x, halfSize.
y );
297 points->AddPoint( shapePos - halfSize );
298 points->AddPoint(
VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y - halfSize.
y ) );
299 points->AddPoint( shapePos + halfSize );
300 points->AddPoint(
VECTOR2I( shapePos.
x - halfSize.
x, shapePos.
y + halfSize.
y ) );
313 const ZONE* zone =
static_cast<const ZONE*
>( aItem );
323 points->AddPoint( dimension->
GetStart() );
324 points->AddPoint( dimension->
GetEnd() );
350 points->AddPoint( dimension->
GetStart() );
351 points->AddPoint( dimension->
GetEnd() );
366 points->AddPoint( dimension->
GetStart() );
367 points->AddPoint( dimension->
GetEnd() );
369 points->AddPoint( dimension->
GetKnee() );
389 points->AddPoint( dimension->
GetStart() );
390 points->AddPoint( dimension->
GetEnd() );
484 bool useAltContraint =
false;
492 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
538 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
560 if(
grid.GetUseGrid() )
562 VECTOR2I gridPt =
grid.BestSnapAnchor( pos, {},
grid.GetItemGrid( item ), { item } );
566 VECTOR2I deltaGrid = gridPt -
grid.BestSnapAnchor( last, {},
grid.GetItemGrid( item ), { item } );
568 if( abs(
delta.x ) >
grid.GetGrid().x / 2 )
569 pos.
x = last.
x + deltaGrid.
x;
573 if( abs(
delta.y ) >
grid.GetGrid().y / 2 )
574 pos.
y = last.
y + deltaGrid.
y;
583 if( useAltContraint )
595 grid.GetItemGrid( item ), { item } ) );
606 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
616 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
627 commit.
Push(
_(
"Drag Corner" ) );
633 else if( evt->IsCancelInteractive() || evt->IsActivate() )
645 if( evt->IsActivate() && !evt->IsMoveTool() )
683 title =
_(
"Move Midpoint to Location" );
684 msg =
_(
"Move Midpoint" );
688 title =
_(
"Move Corner to Location" );
689 msg =
_(
"Move Corner" );
694 if( dlg.ShowModal() == wxID_OK )
712 bool arcValid =
true;
724 else if( aEnd != aArc->
GetEnd() )
759 double det = u1.
x * u2.
y - u2.
x * u1.
y;
766 double tmpx =
v1.
x * u2.
y -
v1.
y * u2.
x;
767 double tmpy = -
v1.
x * u1.
y +
v1.
y * u1.
x;
779 bool transformCircle =
false;
816 transformCircle =
true;
828 if( !std::isfinite(
delta ) )
839 center =
v4 + aCenter;
858 const int c_snapEpsilon_sq = 4;
860 VECTOR2I m = ( aStart / 2 + aEnd / 2 );
861 VECTOR2I perp = ( aEnd - aStart ).Perpendicular().
Resize( INT_MAX / 2 );
863 SEG legal( m - perp, m + perp );
865 const SEG testSegments[] = {
SEG( aCenter, aCenter +
VECTOR2( 1, 0 ) ),
868 std::vector<VECTOR2I> points = { legal.
A, legal.
B };
870 for(
const SEG& seg : testSegments )
875 points.push_back( *vec );
884 SEG::ecoord d_sq = ( pt - aCenter ).SquaredEuclideanNorm();
886 if( d_sq < min_d_sq - c_snapEpsilon_sq )
920 aTopLeft.
x = std::min( aTopLeft.
x, aHole.
x - aHoleSize.
x / 2 - minWidth );
921 aTopLeft.
y = std::min( aTopLeft.
y, aHole.
y - aHoleSize.
y / 2 - minHeight );
926 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
927 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
931 aTopRight.
y = aTopLeft.
y;
932 aBotLeft.
x = aTopLeft.
x;
939 aTopRight.
x = std::max( aTopRight.
x, aHole.
x + aHoleSize.
x / 2 + minWidth );
940 aTopRight.
y = std::min( aTopRight.
y, aHole.
y - aHoleSize.
y / 2 - minHeight );
945 aTopRight.
x = std::max( aTopRight.
x, aBotLeft.
x + minWidth );
946 aTopRight.
y = std::min( aTopRight.
y, aBotLeft.
y - minHeight );
950 aTopLeft.
y = aTopRight.
y;
951 aBotRight.
x = aTopRight.
x;
958 aBotLeft.
x = std::min( aBotLeft.
x, aHole.
x - aHoleSize.
x / 2 - minWidth );
959 aBotLeft.
y = std::max( aBotLeft.
y, aHole.
y + aHoleSize.
y / 2 + minHeight );
964 aBotLeft.
x = std::min( aBotLeft.
x, aTopRight.
x - minWidth );
965 aBotLeft.
y = std::max( aBotLeft.
y, aTopRight.
y + minHeight );
969 aBotRight.
y = aBotLeft.
y;
970 aTopLeft.
x = aBotLeft.
x;
977 aBotRight.
x = std::max( aBotRight.
x, aHole.
x + aHoleSize.
x / 2 + minWidth );
978 aBotRight.
y = std::max( aBotRight.
y, aHole.
y + aHoleSize.
y / 2 + minHeight );
983 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
984 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
988 aBotLeft.
y = aBotRight.
y;
989 aTopRight.
x = aBotRight.
x;
993 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
997 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
1001 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
1005 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
1031 prev_p1 = aArc->
GetEnd();
1034 movingStart =
false;
1040 if( p1.
x == 0 && p1.
y == 0 )
1041 p1 = prev_p1 - aCenter;
1043 if( p2.
x == 0 && p2.
y == 0 )
1048 if( radius < minRadius )
1051 p1 = aCenter + p1.
Resize( radius );
1052 p2 = aCenter + p2.
Resize( radius );
1075 SEG chord( aStart, aEnd );
1084 if( radius < minRadius )
1087 start = start.
Resize( radius );
1088 end = end.
Resize( radius );
1090 start = start + aCenter;
1091 end = end + aCenter;
1103 VECTOR2I m = ( aStart + aEnd ) / 2;
1107 const int JUST_OFF = ( aStart - aEnd ).
EuclideanNorm() / 100;
1123 switch( item->
Type() )
1135 double oldWidth = bitmap->
GetSize().
x;
1137 double widthRatio = newWidth / oldWidth;
1139 double oldHeight = bitmap->
GetSize().
y;
1142 double heightRatio = newHeight / oldHeight;
1156 case SHAPE_T::SEGMENT:
1164 case SHAPE_T::RECTANGLE:
1200 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1221 if(
m_arcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION )
1228 shape->
Move( moveVector );
1235 if(
m_arcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION )
1245 if(
m_arcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION )
1254 case SHAPE_T::CIRCLE:
1262 shape->
Move( moveVector );
1279 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1290 case SHAPE_T::BEZIER:
1311 if(
pad->IsEntered() )
1318 textBox->ClearRenderCache();
1327 switch(
pad->GetShape() )
1329 case PAD_SHAPE::CIRCLE:
1338 case PAD_SHAPE::OVAL:
1339 case PAD_SHAPE::TRAPEZOID:
1340 case PAD_SHAPE::RECTANGLE:
1341 case PAD_SHAPE::ROUNDRECT:
1342 case PAD_SHAPE::CHAMFERED_RECT:
1351 pinEditedCorner( topLeft, topRight, botLeft, botRight, holeCenter, holeSize );
1353 if( (
pad->GetOffset().x ||
pad->GetOffset().y )
1354 || (
pad->GetDrillSize().x &&
pad->GetDrillSize().y ) )
1364 dist[0] = center.
x - topLeft.
x;
1365 dist[1] = center.
y - topLeft.
y;
1366 dist[2] = botRight.
x - center.
x;
1367 dist[3] = botRight.
y - center.
y;
1371 dist[0] = center.
x - botLeft.
x;
1372 dist[1] = center.
y - topRight.
y;
1373 dist[2] = topRight.
x - center.
x;
1374 dist[3] = botLeft.
y - center.
y;
1377 VECTOR2I padSize( dist[0] + dist[2], dist[1] + dist[3] );
1378 VECTOR2I deltaOffset( padSize.
x / 2 - dist[2], padSize.
y / 2 - dist[3] );
1381 std::swap( padSize.
x, padSize.
y );
1385 pad->SetSize( padSize );
1386 pad->SetOffset( -deltaOffset );
1400 bottom = botRight.
y;
1413 std::swap( padSize.
x, padSize.
y );
1415 pad->SetSize( padSize );
1430 ZONE* zone =
static_cast<ZONE*
>( item );
1442 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1465 if( featureLine.
Cross( crossBar ) > 0 )
1477 if( featureLine.
Cross( crossBar ) > 0 )
1533 VECTOR2I direction = ( directionA < directionB ) ? directionA : directionB;
1539 if( !bounds.
Contains( cursorPos ) )
1562 dimension->
SetHeight( vert ? featureLine.
x : featureLine.
y );
1659 dimension->
SetEnd( newPoint );
1698 switch( item->
Type() )
1717 int target = shape->
GetShape() == SHAPE_T::RECTANGLE ? 4 : 0;
1733 if( shape->
GetShape() == SHAPE_T::RECTANGLE )
1742 else if( shape->
GetShape() == SHAPE_T::POLY )
1756 case SHAPE_T::SEGMENT:
1761 case SHAPE_T::RECTANGLE:
1777 case SHAPE_T::CIRCLE:
1784 std::vector<VECTOR2I> points;
1787 if(
m_editPoints->PointsSize() != (unsigned) points.size() )
1799 for(
unsigned i = 0; i < points.size(); i++ )
1806 case SHAPE_T::BEZIER:
1822 const PAD*
pad =
static_cast<const PAD*
>( item );
1827 switch(
pad->GetShape() )
1829 case PAD_SHAPE::CIRCLE:
1831 int target =
locked ? 0 : 1;
1844 else if( target == 1 )
1846 shapePos.
x += halfSize.
x;
1852 case PAD_SHAPE::OVAL:
1853 case PAD_SHAPE::TRAPEZOID:
1854 case PAD_SHAPE::RECTANGLE:
1855 case PAD_SHAPE::ROUNDRECT:
1856 case PAD_SHAPE::CHAMFERED_RECT:
1859 int target =
locked || !
pad->GetOrientation().IsCardinal() ? 0 : 4;
1871 else if( target == 4 )
1874 std::swap( halfSize.
x, halfSize.
y );
1879 VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y - halfSize.
y ) );
1883 VECTOR2I( shapePos.
x - halfSize.
x, shapePos.
y + halfSize.
y ) );
1897 ZONE* zone =
static_cast<ZONE*
>( item );
1982 if(
frame()->ToolStackIsEmpty() )
2000 switch( parent->
Type() )
2007 isPoly =
static_cast<PCB_SHAPE*
>( parent )->GetShape() == SHAPE_T::POLY;
2015 if( line && isPoly )
2038 switch( item->
Type() )
2041 switch(
static_cast<const PCB_SHAPE*
>( item )->GetShape() )
2043 case SHAPE_T::SEGMENT:
2047 case SHAPE_T::CIRCLE:
2098 const auto type = aItem.
Type();
2107 return shape.
GetShape() == SHAPE_T::SEGMENT || shape.
GetShape() == SHAPE_T::POLY;
2116 if( aSelection.
Size() != 1 )
2126static std::pair<bool, SHAPE_POLY_SET::VERTEX_INDEX>
2131 auto vertexIdx = it.GetIndex();
2134 return std::make_pair(
true, vertexIdx );
2152 switch( item->
Type() )
2155 polyset =
static_cast<ZONE*
>( item )->Outline();
2213 unsigned int nearestIdx = 0;
2214 unsigned int nextNearestIdx = 0;
2215 unsigned int nearestDist = INT_MAX;
2216 unsigned int firstPointInContour = 0;
2221 ZONE* zone =
static_cast<ZONE*
>( item );
2222 zoneOutline = zone->
Outline();
2241 for( ; iterator; iterator++, curr_idx++ )
2243 int jj = curr_idx+1;
2247 jj = firstPointInContour;
2248 firstPointInContour = curr_idx+1;
2251 SEG curr_segment( zoneOutline->
CVertex( curr_idx ), zoneOutline->
CVertex( jj ) );
2258 nearestIdx = curr_idx;
2259 nextNearestIdx = jj;
2266 SEG nearestSide( sideOrigin, sideEnd );
2271 if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
2272 nearestPoint = ( sideOrigin + sideEnd ) / 2;
2274 zoneOutline->
InsertVertex( nextNearestIdx, nearestPoint );
2281 commit.
Push(
_(
"Add Zone Corner" ) );
2283 else if( graphicItem && graphicItem->
GetShape() == SHAPE_T::SEGMENT )
2285 commit.
Modify( graphicItem );
2300 commit.
Add( newSegment );
2301 commit.
Push(
_(
"Split Segment" ) );
2323 ZONE* zone =
static_cast<ZONE*
>( item );
2331 if( shape->
GetShape() == SHAPE_T::POLY )
2344 const auto& vertexIdx = vertex.second;
2345 auto& outline = polygon->
Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
2347 if( outline.PointCount() > 3 )
2357 if( vertexIdx.m_contour > 0 )
2373 commit.
Push(
_(
"Remove Zone Corner" ) );
2375 commit.
Push(
_(
"Remove Polygon Corner" ) );
2379 static_cast<ZONE*
>( item )->HatchBorder();
2408 case ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS:
2409 m_arcEditMode = ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION;
2411 case ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION:
2412 m_arcEditMode = ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS;
ARC_EDIT_MODE
Settings for arc editing.
@ 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.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr) override
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...
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual bool IsLocked() 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 & 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 & StageItems(const Range &aRange, CHANGE_TYPE aChangeType)
Add a change of the item aItem of type aChangeType to the change list.
COMMIT & Add(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
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)
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.
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 pointEditorMoveMidpoint
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION pointEditorMoveCorner
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)
bool HasPoint()
Indicate the cursor is over an edit point.
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.
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
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.
int GetWidth() const override
bool IsProxyItem() const override
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
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
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).
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
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)
@ 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_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_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_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
@ 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