29using namespace std::placeholders;
119 m_selectionTool( nullptr ),
120 m_editedPoint( nullptr ),
121 m_hoveredPoint( nullptr ),
124 m_altConstrainer(
VECTOR2I( 0, 0 ) ),
125 m_inPointEditorTool( false )
143 wxASSERT_MSG(
m_selectionTool, wxT(
"pcbnew.InteractiveSelection tool is not available" ) );
161 points->AddPoint( *iterator );
163 if( iterator.IsEndContour() )
168 for(
int i = 0; i < cornersCount - 1; ++i )
170 if( points->IsContourEnd( i ) )
171 points->AddLine( points->Point( i ), points->Point( points->GetContourStartIdx( i ) ) );
173 points->AddLine( points->Point( i ), points->Point( i + 1 ) );
175 points->Line( i ).SetConstraint(
new EC_PERPLINE( points->Line( i ) ) );
179 points->AddLine( points->Point( cornersCount - 1 ),
180 points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
182 points->Line( points->LinesSize() - 1 )
183 .SetConstraint(
new EC_PERPLINE( points->Line( points->LinesSize() - 1 ) ) );
189 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
200 if( shape->
GetShape() != SHAPE_T::RECTANGLE )
205 switch( aItem->
Type() )
213 points->AddPoint( topLeft );
214 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
215 points->AddPoint( botRight );
216 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
228 case SHAPE_T::SEGMENT:
229 points->AddPoint( shape->
GetStart() );
230 points->AddPoint( shape->
GetEnd() );
233 case SHAPE_T::RECTANGLE:
238 points->SetSwapX( topLeft.
x > botRight.
x );
239 points->SetSwapY( topLeft.
y > botRight.
y );
241 if( points->SwapX() )
242 std::swap( topLeft.
x, botRight.
x );
244 if( points->SwapY() )
245 std::swap( topLeft.
y, botRight.
y );
247 points->AddPoint( topLeft );
248 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
249 points->AddPoint( botRight );
250 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
265 points->AddPoint( shape->
GetStart() );
267 points->AddPoint( shape->
GetEnd() );
271 case SHAPE_T::CIRCLE:
273 points->AddPoint( shape->
GetEnd() );
280 case SHAPE_T::BEZIER:
281 points->AddPoint( shape->
GetStart() );
284 points->AddPoint( shape->
GetEnd() );
304 const PAD*
pad =
static_cast<const PAD*
>( aItem );
311 switch(
pad->GetShape() )
313 case PAD_SHAPE::CIRCLE:
314 points->AddPoint(
VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y ) );
317 case PAD_SHAPE::OVAL:
318 case PAD_SHAPE::TRAPEZOID:
319 case PAD_SHAPE::RECTANGLE:
320 case PAD_SHAPE::ROUNDRECT:
321 case PAD_SHAPE::CHAMFERED_RECT:
323 if( !
pad->GetOrientation().IsCardinal() )
327 std::swap( halfSize.
x, halfSize.
y );
329 points->AddPoint( shapePos - halfSize );
330 points->AddPoint(
VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y - halfSize.
y ) );
331 points->AddPoint( shapePos + halfSize );
332 points->AddPoint(
VECTOR2I( shapePos.
x - halfSize.
x, shapePos.
y + halfSize.
y ) );
345 const ZONE* zone =
static_cast<const ZONE*
>( aItem );
362 points->AddPoint( dimension->
GetStart() );
363 points->AddPoint( dimension->
GetEnd() );
389 points->AddPoint( dimension->
GetStart() );
390 points->AddPoint( dimension->
GetEnd() );
405 points->AddPoint( dimension->
GetStart() );
406 points->AddPoint( dimension->
GetEnd() );
408 points->AddPoint( dimension->
GetKnee() );
428 points->AddPoint( dimension->
GetStart() );
429 points->AddPoint( dimension->
GetEnd() );
530 bool useAltContraint =
false;
538 grid.SetUseGrid(
getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() );
599 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
621 if(
grid.GetUseGrid() )
628 VECTOR2I deltaGrid = gridPt -
grid.BestSnapAnchor( last, {},
629 grid.GetItemGrid( item ),
632 if( abs(
delta.x ) >
grid.GetGrid().x / 2 )
633 pos.
x = last.
x + deltaGrid.
x;
637 if( abs(
delta.y ) >
grid.GetGrid().y / 2 )
638 pos.
y = last.
y + deltaGrid.
y;
647 if( useAltContraint )
659 grid.GetItemGrid( item ),
671 for(
size_t ii = 0; ii <
m_editPoints->PointsSize(); ++ii )
681 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
700 commit.
Push(
_(
"Resize Table Cells" ) );
704 commit.
Push(
_(
"Move Point" ) );
713 else if( evt->IsCancelInteractive() || evt->IsActivate() )
731 if( evt->IsActivate() && !evt->IsMoveTool() )
772 title =
_(
"Move Midpoint to Location" );
773 msg =
_(
"Move Midpoint" );
777 title =
_(
"Move Corner to Location" );
778 msg =
_(
"Move Corner" );
783 if( dlg.ShowModal() == wxID_OK )
801 bool arcValid =
true;
813 else if( aEnd != aArc->
GetEnd() )
848 double det = u1.
x * u2.
y - u2.
x * u1.
y;
855 double tmpx =
v1.
x * u2.
y -
v1.
y * u2.
x;
856 double tmpy = -
v1.
x * u1.
y +
v1.
y * u1.
x;
868 bool transformCircle =
false;
905 transformCircle =
true;
917 if( !std::isfinite(
delta ) )
928 center =
v4 + aCenter;
947 const int c_snapEpsilon_sq = 4;
949 VECTOR2I m = ( aStart / 2 + aEnd / 2 );
950 VECTOR2I perp = ( aEnd - aStart ).Perpendicular().
Resize( INT_MAX / 2 );
952 SEG legal( m - perp, m + perp );
954 const SEG testSegments[] = {
SEG( aCenter, aCenter +
VECTOR2( 1, 0 ) ),
957 std::vector<VECTOR2I> points = { legal.
A, legal.
B };
959 for(
const SEG& seg : testSegments )
964 points.push_back( *vec );
973 SEG::ecoord d_sq = ( pt - aCenter ).SquaredEuclideanNorm();
975 if( d_sq < min_d_sq - c_snapEpsilon_sq )
1009 aTopLeft.
x = std::min( aTopLeft.
x, aHole.
x - aHoleSize.
x / 2 - minWidth );
1010 aTopLeft.
y = std::min( aTopLeft.
y, aHole.
y - aHoleSize.
y / 2 - minHeight );
1015 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
1016 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
1020 aTopRight.
y = aTopLeft.
y;
1021 aBotLeft.
x = aTopLeft.
x;
1028 aTopRight.
x = std::max( aTopRight.
x, aHole.
x + aHoleSize.
x / 2 + minWidth );
1029 aTopRight.
y = std::min( aTopRight.
y, aHole.
y - aHoleSize.
y / 2 - minHeight );
1034 aTopRight.
x = std::max( aTopRight.
x, aBotLeft.
x + minWidth );
1035 aTopRight.
y = std::min( aTopRight.
y, aBotLeft.
y - minHeight );
1039 aTopLeft.
y = aTopRight.
y;
1040 aBotRight.
x = aTopRight.
x;
1047 aBotLeft.
x = std::min( aBotLeft.
x, aHole.
x - aHoleSize.
x / 2 - minWidth );
1048 aBotLeft.
y = std::max( aBotLeft.
y, aHole.
y + aHoleSize.
y / 2 + minHeight );
1053 aBotLeft.
x = std::min( aBotLeft.
x, aTopRight.
x - minWidth );
1054 aBotLeft.
y = std::max( aBotLeft.
y, aTopRight.
y + minHeight );
1058 aBotRight.
y = aBotLeft.
y;
1059 aTopLeft.
x = aBotLeft.
x;
1066 aBotRight.
x = std::max( aBotRight.
x, aHole.
x + aHoleSize.
x / 2 + minWidth );
1067 aBotRight.
y = std::max( aBotRight.
y, aHole.
y + aHoleSize.
y / 2 + minHeight );
1072 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
1073 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
1077 aBotLeft.
y = aBotRight.
y;
1078 aTopRight.
x = aBotRight.
x;
1082 aTopLeft.
y = std::min( aTopLeft.
y, aBotRight.
y - minHeight );
1086 aTopLeft.
x = std::min( aTopLeft.
x, aBotRight.
x - minWidth );
1090 aBotRight.
y = std::max( aBotRight.
y, aTopLeft.
y + minHeight );
1094 aBotRight.
x = std::max( aBotRight.
x, aTopLeft.
x + minWidth );
1120 prev_p1 = aArc->
GetEnd();
1123 movingStart =
false;
1129 if( p1.
x == 0 && p1.
y == 0 )
1130 p1 = prev_p1 - aCenter;
1132 if( p2.
x == 0 && p2.
y == 0 )
1137 if( radius < minRadius )
1140 p1 = aCenter + p1.
Resize( radius );
1141 p2 = aCenter + p2.
Resize( radius );
1164 SEG chord( aStart, aEnd );
1171 double radius = ( aCursor - aCenter ).EuclideanNorm();
1173 if( radius < minRadius )
1176 start = start.
Resize( radius );
1177 end = end.
Resize( radius );
1179 start = start + aCenter;
1180 end = end + aCenter;
1192 VECTOR2I m = ( aStart + aEnd ) / 2;
1196 const int JUST_OFF = ( aStart - aEnd ).EuclideanNorm() / 100;
1212 switch( item->
Type() )
1224 double oldWidth = bitmap->
GetSize().
x;
1226 double widthRatio = newWidth / oldWidth;
1228 double oldHeight = bitmap->
GetSize().
y;
1231 double heightRatio = newHeight / oldHeight;
1245 case SHAPE_T::SEGMENT:
1253 case SHAPE_T::RECTANGLE:
1288 setLeft( topLeft.
x );
1289 setTop( topLeft.
y );
1290 setRight( botRight.
x );
1291 setBottom( botRight.
y );
1295 setTop( topLeft.
y );
1299 setLeft( topLeft.
x );
1303 setBottom( botRight.
y );
1307 setRight( botRight.
x );
1310 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1331 if(
m_arcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION )
1338 shape->
Move( moveVector );
1345 if(
m_arcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION )
1355 if(
m_arcEditMode == ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION )
1364 case SHAPE_T::CIRCLE:
1372 shape->
Move( moveVector );
1389 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1398 case SHAPE_T::BEZIER:
1419 if(
pad->IsEntered() )
1426 textBox->ClearRenderCache();
1442 for(
int ii = 0; ii < cell->
GetColSpan() - 1; ++ii )
1454 for(
int ii = 0; ii < cell->
GetRowSpan() - 1; ++ii )
1469 switch(
pad->GetShape() )
1471 case PAD_SHAPE::CIRCLE:
1474 int diameter = 2 * ( end -
pad->GetPosition() ).EuclideanNorm();
1480 case PAD_SHAPE::OVAL:
1481 case PAD_SHAPE::TRAPEZOID:
1482 case PAD_SHAPE::RECTANGLE:
1483 case PAD_SHAPE::ROUNDRECT:
1484 case PAD_SHAPE::CHAMFERED_RECT:
1493 pinEditedCorner( topLeft, topRight, botLeft, botRight, holeCenter, holeSize );
1495 if( (
pad->GetOffset().x ||
pad->GetOffset().y )
1496 || (
pad->GetDrillSize().x &&
pad->GetDrillSize().y ) )
1506 dist[0] = center.
x - topLeft.
x;
1507 dist[1] = center.
y - topLeft.
y;
1508 dist[2] = botRight.
x - center.
x;
1509 dist[3] = botRight.
y - center.
y;
1513 dist[0] = center.
x - botLeft.
x;
1514 dist[1] = center.
y - topRight.
y;
1515 dist[2] = topRight.
x - center.
x;
1516 dist[3] = botLeft.
y - center.
y;
1519 VECTOR2I padSize( dist[0] + dist[2], dist[1] + dist[3] );
1520 VECTOR2I deltaOffset( padSize.
x / 2 - dist[2], padSize.
y / 2 - dist[3] );
1523 std::swap( padSize.
x, padSize.
y );
1527 pad->SetSize( padSize );
1528 pad->SetOffset( -deltaOffset );
1542 bottom = botRight.
y;
1555 std::swap( padSize.
x, padSize.
y );
1557 pad->SetSize( padSize );
1572 ZONE* zone =
static_cast<ZONE*
>( item );
1584 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1607 for(
EDA_ITEM* previewItem : generatorItem->GetPreviewItems( generatorTool,
frame(),
1627 if( featureLine.
Cross( crossBar ) > 0 )
1639 if( featureLine.
Cross( crossBar ) > 0 )
1695 VECTOR2I direction = ( directionA < directionB ) ? directionA : directionB;
1701 if( !bounds.
Contains( cursorPos ) )
1724 dimension->
SetHeight( vert ? featureLine.
x : featureLine.
y );
1821 dimension->
SetEnd( newPoint );
1854 switch( item->
Type() )
1873 int target = shape->
GetShape() == SHAPE_T::RECTANGLE ? 4 : 0;
1889 if( shape->
GetShape() == SHAPE_T::RECTANGLE )
1898 else if( shape->
GetShape() == SHAPE_T::POLY )
1912 case SHAPE_T::SEGMENT:
1917 case SHAPE_T::RECTANGLE:
1926 std::swap( topLeft.
x, botRight.
x );
1929 std::swap( topLeft.
y, botRight.
y );
1945 case SHAPE_T::CIRCLE:
1952 std::vector<VECTOR2I> points;
1955 if(
m_editPoints->PointsSize() != (unsigned) points.size() )
1967 for(
unsigned i = 0; i < points.size(); i++ )
1974 case SHAPE_T::BEZIER:
2001 const PAD*
pad =
static_cast<const PAD*
>( item );
2006 switch(
pad->GetShape() )
2008 case PAD_SHAPE::CIRCLE:
2010 int target =
locked ? 0 : 1;
2023 else if( target == 1 )
2025 shapePos.
x += halfSize.
x;
2031 case PAD_SHAPE::OVAL:
2032 case PAD_SHAPE::TRAPEZOID:
2033 case PAD_SHAPE::RECTANGLE:
2034 case PAD_SHAPE::ROUNDRECT:
2035 case PAD_SHAPE::CHAMFERED_RECT:
2038 int target =
locked || !
pad->GetOrientation().IsCardinal() ? 0 : 4;
2050 else if( target == 4 )
2053 std::swap( halfSize.
x, halfSize.
y );
2058 VECTOR2I( shapePos.
x + halfSize.
x, shapePos.
y - halfSize.
y ) );
2062 VECTOR2I( shapePos.
x - halfSize.
x, shapePos.
y + halfSize.
y ) );
2076 ZONE* zone =
static_cast<ZONE*
>( item );
2168 if(
frame()->ToolStackIsEmpty() )
2186 switch( parent->
Type() )
2193 isPoly =
static_cast<PCB_SHAPE*
>( parent )->GetShape() == SHAPE_T::POLY;
2201 if( line && isPoly )
2224 switch( item->
Type() )
2227 switch(
static_cast<const PCB_SHAPE*
>( item )->GetShape() )
2229 case SHAPE_T::SEGMENT:
2233 case SHAPE_T::CIRCLE:
2284 const auto type = aItem.
Type();
2293 return shape.
GetShape() == SHAPE_T::SEGMENT || shape.
GetShape() == SHAPE_T::POLY;
2302 if( aSelection.
Size() != 1 )
2312static std::pair<bool, SHAPE_POLY_SET::VERTEX_INDEX>
2317 auto vertexIdx = it.GetIndex();
2320 return std::make_pair(
true, vertexIdx );
2338 switch( item->
Type() )
2341 polyset =
static_cast<ZONE*
>( item )->Outline();
2399 unsigned int nearestIdx = 0;
2400 unsigned int nextNearestIdx = 0;
2401 unsigned int nearestDist = INT_MAX;
2402 unsigned int firstPointInContour = 0;
2407 ZONE* zone =
static_cast<ZONE*
>( item );
2408 zoneOutline = zone->
Outline();
2427 for( ; iterator; iterator++, curr_idx++ )
2429 int jj = curr_idx+1;
2433 jj = firstPointInContour;
2434 firstPointInContour = curr_idx+1;
2437 SEG curr_segment( zoneOutline->
CVertex( curr_idx ), zoneOutline->
CVertex( jj ) );
2444 nearestIdx = curr_idx;
2445 nextNearestIdx = jj;
2452 SEG nearestSide( sideOrigin, sideEnd );
2457 if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
2458 nearestPoint = ( sideOrigin + sideEnd ) / 2;
2460 zoneOutline->
InsertVertex( nextNearestIdx, nearestPoint );
2467 commit.
Push(
_(
"Add Zone Corner" ) );
2469 else if( graphicItem && graphicItem->
GetShape() == SHAPE_T::SEGMENT )
2471 commit.
Modify( graphicItem );
2486 commit.
Add( newSegment );
2487 commit.
Push(
_(
"Split Segment" ) );
2509 ZONE* zone =
static_cast<ZONE*
>( item );
2517 if( shape->
GetShape() == SHAPE_T::POLY )
2530 const auto& vertexIdx = vertex.second;
2531 auto& outline = polygon->
Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
2533 if( outline.PointCount() > 3 )
2542 if( vertexIdx.m_contour > 0 )
2558 commit.
Push(
_(
"Remove Zone Corner" ) );
2560 commit.
Push(
_(
"Remove Polygon Corner" ) );
2564 static_cast<ZONE*
>( item )->HatchBorder();
2593 case ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS:
2594 m_arcEditMode = ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION;
2596 case ARC_EDIT_MODE::KEEP_ENDPOINTS_OR_START_DIRECTION:
2597 m_arcEditMode = ARC_EDIT_MODE::KEEP_CENTER_ADJUST_ANGLE_RADIUS;
ARC_EDIT_MODE
Settings for arc editing.
@ KEEP_CENTER_ADJUST_ANGLE_RADIUS
constexpr int ARC_HIGH_DEF
constexpr EDA_IU_SCALE pcbIUScale
static TOOL_ACTION cycleArcEditMode
static TOOL_ACTION activatePointEditor
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
COMMIT & Stage(EDA_ITEM *aItem, CHANGE_TYPE aChangeType, BASE_SCREEN *aScreen=nullptr) override
virtual void Revert() override
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
FOOTPRINT * GetParentFootprint() const
virtual LSET GetLayerSet() const
Return a std::bitset of all layers on which the item physically resides.
virtual bool IsLocked() const
BOARD_ITEM_CONTAINER * GetParent() const
size_type GetHeight() const
coord_type GetTop() const
size_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 & 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
int GetRectangleWidth() const
SHAPE_POLY_SET & GetPolyShape()
virtual VECTOR2I GetBotRight() const
virtual void SetBottom(int val)
virtual void SetTop(int val)
void RebuildBezierToSegmentsPointsList(int aMaxError)
Rebuild the m_bezierPoints vertex list that approximate the Bezier curve by a list of segments.
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
void SetStart(const VECTOR2I &aStart)
void DupPolyPointsList(std::vector< VECTOR2I > &aBuffer) const
Duplicate the list of corners in a std::vector<VECTOR2I>
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
void SetBezierC1(const VECTOR2I &aPt)
void SetArcGeometry(const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
Set the three controlling points for an arc.
virtual void SetLeft(int val)
const VECTOR2I & GetBezierC1() const
int GetRectangleHeight() const
virtual void SetRight(int val)
VECTOR2I GetArcMid() const
const VECTOR2I & GetTextPos() const
void SetTextPos(const VECTOR2I &aPoint)
Describe constraints between two edit handles.
Represent a line connecting two EDIT_POINTs.
Represent a single point that can be used for modifying items.
SNAP_CONSTRAINT_TYPE GetSnapConstraint() const
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
virtual void ApplyConstraint(const GRID_HELPER &aGrid)
Correct coordinates of an EDIT_POINT by applying previously set constraint.
void SetHover(bool aHover=true)
bool IsConstrained() const
Check if point is constrained.
void SetActive(bool aActive=true)
GRID_CONSTRAINT_TYPE GetGridConstraint() const
static const TOOL_EVENT InhibitSelectionEditing
static const TOOL_EVENT SelectedEvent
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
static const TOOL_EVENT UninhibitSelectionEditing
Used to inform tool that it should display the disambiguation menu.
static const TOOL_EVENT PointSelectedEvent
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
static const TOOL_EVENT UnselectedEvent
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const override
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
void FreeItems()
Free all the items that were added to the group.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
virtual void Update(const VIEW_ITEM *aItem, int aUpdateFlags) const
For dynamic VIEWs, inform the associated VIEW that the graphical representation of this item has chan...
LSET is a set of PCB_LAYER_IDs.
static LSET AllLayersMask()
ARC_EDIT_MODE m_ArcEditMode
static TOOL_ACTION pointEditorArcKeepCenter
static TOOL_ACTION pointEditorMoveMidpoint
static TOOL_ACTION genPushEdit
static TOOL_ACTION genStartEdit
static TOOL_ACTION selectionClear
Clear the current selection.
static TOOL_ACTION pointEditorMoveCorner
static TOOL_ACTION genUpdateEdit
static TOOL_ACTION pointEditorArcKeepEndpoint
static TOOL_ACTION pointEditorRemoveCorner
static TOOL_ACTION pointEditorAddCorner
static TOOL_ACTION reselectItem
static TOOL_ACTION genRevertEdit
Common, abstract interface for edit frames.
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
void Update()
Update the dimension's cached text and geometry.
void SetTextPositionMode(DIM_TEXT_POSITION aMode)
virtual const VECTOR2I & GetStart() const
The dimension's origin is the first feature point for the dimension.
virtual void SetEnd(const VECTOR2I &aPoint)
virtual void SetStart(const VECTOR2I &aPoint)
virtual const VECTOR2I & GetEnd() const
For better understanding of the points that make a dimension:
const VECTOR2I & GetCrossbarStart() const
const VECTOR2I & GetCrossbarEnd() const
void SetHeight(int aHeight)
Set the distance from the feature points to the crossbar line.
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
void SetOrientation(DIR aOrientation)
Set the orientation of the dimension line (so, perpendicular to the feature lines).
DIR GetOrientation() const
A radial dimension indicates either the radius or diameter of an arc or circle.
void SetLeaderLength(int aLength)
virtual bool UpdateEditPoints(std::shared_ptr< EDIT_POINTS > aEditPoints)
virtual bool MakeEditPoints(std::shared_ptr< EDIT_POINTS > aEditPoints) const
virtual bool UpdateFromEditPoints(std::shared_ptr< EDIT_POINTS > aEditPoints, BOARD_COMMIT *aCommit)
int changeArcEditMode(const TOOL_EVENT &aEvent)
void pinEditedCorner(VECTOR2I &aTopLeft, VECTOR2I &aTopRight, VECTOR2I &aBotLeft, VECTOR2I &aBotRight, const VECTOR2I &aHole={ 0, 0 }, const VECTOR2I &aHoleSize={ 0, 0 }) const
Set up an alternative constraint (typically enabled upon a modifier key being pressed).
void editArcMidKeepEndpoints(PCB_SHAPE *aArc, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCursor) const
Move the mid point of the arc, while keeping the two endpoints.
int OnSelectionChange(const TOOL_EVENT &aEvent)
Change selection event handler.
void setAltConstraint(bool aEnabled)
Return a point that should be used as a constrainer for 45 degrees mode.
static const unsigned int COORDS_PADDING
bool removeCornerCondition(const SELECTION &aSelection)
EDIT_POINT * m_hoveredPoint
void editArcMidKeepCenter(PCB_SHAPE *aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCursor) const
Move the mid point of the arc, while keeping the angle.
int addCorner(const TOOL_EVENT &aEvent)
void updateItem(BOARD_COMMIT *aCommit)
Update edit points with item's points.
bool HasPoint()
Indicate the cursor is over an edit point.
EDIT_POINT m_original
Original pos for the current drag point.
EDIT_POINT get45DegConstrainer() const
Condition to display "Create corner" context menu entry.
int modifiedSelection(const TOOL_EVENT &aEvent)
void editArcEndpointKeepTangent(PCB_SHAPE *aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCursor) const
Move an end point of the arc, while keeping the tangent at the other endpoint.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int removeCorner(const TOOL_EVENT &aEvent)
static bool canAddCorner(const EDA_ITEM &aItem)
Condition to display "Remove corner" context menu entry.
bool Init() override
Init() is called once upon a registration of the tool.
int movePoint(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
void setEditedPoint(EDIT_POINT *aPoint)
void buildForPolyOutline(std::shared_ptr< EDIT_POINTS > points, const SHAPE_POLY_SET *aOutline)
EDIT_POINT m_altConstrainer
bool isModified(const EDIT_POINT &aPoint) const
ARC_EDIT_MODE m_arcEditMode
EDIT_POINT * m_editedPoint
void updateEditedPoint(const TOOL_EVENT &aEvent)
Set the current point being edited. NULL means none.
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
void updatePoints()
Update which point is being edited.
void editArcCenterKeepEndpoints(PCB_SHAPE *aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd) const
Move the arc center but keep endpoint locations.
static bool addCornerCondition(const SELECTION &aSelection)
Determine if the tool can currently add a corner to the given item.
void setTransitions() override
< Set up handlers for various events.
std::shared_ptr< EDIT_POINTS > m_editPoints
std::shared_ptr< EDIT_POINTS > makePoints(EDA_ITEM *aItem)
Update item's points with edit points.
void editArcEndpointKeepCenter(PCB_SHAPE *aArc, const VECTOR2I &aCenter, const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd, const VECTOR2I &aCursor) const
Move an end point of the arc around the circumference.
PCB_SELECTION_TOOL * m_selectionTool
Object to handle a bitmap image that can be inserted in a PCB.
VECTOR2I GetPosition() const override
double GetImageScale() const
void SetImageScale(double aScale)
const VECTOR2I GetSize() const
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
bool IsProxyItem() const override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
void SetColWidth(int aCol, int aWidth)
void Normalize() override
Perform any normalization required after a user rotate and/or flip.
int GetColWidth(int aCol) const
void SetRowHeight(int aRow, int aHeight)
int GetRowHeight(int aRow) const
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.
virtual void Add(EDA_ITEM *aItem)
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)
#define STATUS_ITEMS_ONLY
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEX > findVertex(SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
std::optional< VECTOR2I > OPT_VECTOR2I
constexpr int mmToIU(double mm) const
Structure to hold the necessary information in order to index a vertex on a SHAPE_POLY_SET object: th...
VECTOR2I v2(1, 0)
Test suite for KiCad math code.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_REFERENCE_IMAGE_T
class PCB_REFERENCE_IMAGE, bitmap on a layer
@ PCB_TABLECELL_T
class PCB_TABLECELL, PCB_TEXTBOX for use in tables
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
VECTOR2< int32_t > VECTOR2I
VECTOR2< double > VECTOR2D