54 _(
"Create Corner" ), _(
"Create a corner" ), add_corner_xpm );
58 _(
"Remove Corner" ), _(
"Remove corner" ), delete_xpm );
96 points->AddPoint( *iterator );
98 if( iterator.IsEndContour() )
104 for(
int i = 0;
i < cornersCount - 1; ++
i )
106 if( points->IsContourEnd(
i ) )
108 points->AddLine( points->Point(
i ),
109 points->Point( points->GetContourStartIdx(
i ) ) );
113 points->AddLine( points->Point(
i ), points->Point(
i + 1 ) );
116 points->Line(
i ).SetConstraint(
new EC_SNAPLINE( points->Line(
i ),
121 points->AddLine( points->Point( cornersCount - 1 ),
122 points->Point( points->GetContourStartIdx( cornersCount - 1 ) ) );
124 points->Line( points->LinesSize() - 1 ).SetConstraint(
125 new EC_SNAPLINE( points->Line( points->LinesSize() - 1 ),
132 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
138 switch( aItem->
Type() )
148 points->AddPoint( segment->
GetStart() );
149 points->AddPoint( segment->
GetEnd() );
153 points->AddPoint( segment->
GetCenter() );
155 points->AddPoint( segment->
GetArcEnd() );
159 points->Point( ARC_END ).SetConstraint(
new EC_CIRCLE( points->Point( ARC_END ),
165 points->AddPoint( segment->
GetCenter() );
166 points->AddPoint( segment->
GetEnd() );
171 buildForPolyOutline( points, &segment->
GetPolyShape(), aGal );
185 buildForPolyOutline( points, zone->Outline(), aGal );
221 PCB_TOOL(
"pcbnew.PointEditor" ), m_selectionTool( NULL ), m_editedPoint( NULL ),
236 m_statusPopup->SetText( _(
"Self-intersecting polygons are not allowed" ) );
247 DisplayError( NULL, wxT(
"pcbnew.InteractiveSelection tool is not available" ) );
282 if( selection.
Size() != 1 )
290 auto item = selection.
Front();
300 bool modified =
false;
334 bool enableAltConstraint = !!evt->Modifier(
MD_CTRL );
341 if( m_altConstraint )
342 m_altConstraint->Apply();
350 else if( evt->IsMouseUp(
BUT_LEFT ) )
357 commit.
Push( _(
"Drag a corner" ) );
365 else if( evt->IsCancel() )
387 if( modified && revert )
407 switch( item->
Type() )
435 segment->
Move( moveVector );
445 VECTOR2D startLine = start - center;
450 bool clockwise = ( segment->
GetAngle() > 0 );
452 if( clockwise && newAngle < 0.0 )
454 else if( !clockwise && newAngle > 0.0 )
471 segment->
Move( moveVector );
497 if(
EDGE_MODULE* edge = dyn_cast<EDGE_MODULE*>( item ) )
498 edge->SetLocalCoord();
527 if( featureLine.Cross( crossBar ) > 0 )
528 dimension->
SetHeight( -featureLine.EuclideanNorm() );
530 dimension->
SetHeight( featureLine.EuclideanNorm() );
538 if( featureLine.Cross( crossBar ) > 0 )
539 dimension->
SetHeight( -featureLine.EuclideanNorm() );
541 dimension->
SetHeight( featureLine.EuclideanNorm() );
588 filler.
Fill( { zone } );
611 aModified = *aOriginal;
627 switch( item->
Type() )
655 for(
unsigned i = 0;
i < points.size();
i++ )
757 switch( item->
Type() )
817 if( aSelection.
Size() != 1 )
820 auto item = aSelection.
Front();
825 static_cast<DRAWSEGMENT*>( item )->GetShape() ==
S_SEGMENT );
830 static std::pair<bool, SHAPE_POLY_SET::VERTEX_INDEX>
835 auto vertexIdx = it.GetIndex();
838 return std::make_pair(
true, vertexIdx );
856 auto& polyset = *zone->
Outline();
862 const auto& vertexIdx = vertex.second;
868 if( vertexIdx.m_contour == 0 && polyset.Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour].PointCount() <= 3 )
893 unsigned int nearestIdx = 0;
894 unsigned int nextNearestIdx = 0;
895 unsigned int nearestDist = INT_MAX;
896 unsigned int firstPointInContour = 0;
907 for( ; iterator; iterator++, curr_idx++ )
913 jj = firstPointInContour;
914 firstPointInContour = curr_idx+1;
917 SEG curr_segment( zoneOutline->
Vertex( curr_idx ), zoneOutline->
Vertex( jj ) );
919 unsigned int distance = curr_segment.
Distance( cursorPos );
921 if( distance < nearestDist )
923 nearestDist = distance;
924 nearestIdx = curr_idx;
933 SEG nearestSide( sideOrigin, sideEnd );
938 if( nearestPoint == sideOrigin || nearestPoint == sideEnd )
939 nearestPoint = ( sideOrigin + sideEnd ) / 2;
942 zoneOutline->
InsertVertex( nextNearestIdx, nearestPoint );
945 commit.
Push( _(
"Add a zone corner" ) );
959 VECTOR2I nearestPoint = seg.NearestPoint( cursorPos );
962 segment->
SetEnd(
wxPoint( nearestPoint.x, nearestPoint.y ) );
983 commit.
Add( newSegment );
984 commit.
Push( _(
"Split segment" ) );
1015 polygon = &ds->GetPolyShape();
1027 const auto& vertexIdx = vertex.second;
1028 auto& outline = polygon->
Polygon( vertexIdx.m_polygon )[vertexIdx.m_contour];
1031 if( outline.PointCount() > 3 )
1034 commit.Modify( item );
1041 if( vertexIdx.m_contour > 0 )
1044 commit.Modify( item );
1050 commit.Remove( item );
1057 commit.Push( _(
"Remove a zone/polygon corner" ) );
1063 static_cast<ZONE_CONTAINER*>( item )->Hatch();
static TOOL_ACTION selectionClear
Clears the current selection.
virtual void ShowCursor(bool aEnabled)
Function ShowCursor() Enables or disables display of cursor.
KICAD_T Type() const
Function Type()
BOARD_ITEM_CONTAINER * GetParent() const
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
int OnSelectionChange(const TOOL_EVENT &aEvent)
Function OnSelected()
COMMIT & Modify(EDA_ITEM *aItem)
Modifies a given item in the model.
void setTransitions() override
Sets up handlers for various events.
const VECTOR2I & CVertex(int aIndex, int aOutline, int aHole) const
Returns the index-th vertex in a given hole outline within a given outline
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...
virtual void Move(const wxPoint &aMoveVector) override
Function Move move this object.
void updateItem() const
Updates item's points with edit points.
void SetArcStart(const wxPoint &aArcStartPoint)
Initialize the start arc point.
This file is part of the common library.
void addCorner(const VECTOR2I &aPoint)
Adds a new edit point on a zone outline/line.
const wxPoint GetCenter() const override
Function GetCenter()
COMMIT & Add(EDA_ITEM *aItem)
Adds a new item to the model
VIEW_CONTROLS class definition.
void updateEditedPoint(const TOOL_EVENT &aEvent)
Updates which point is being edited.
void Fill(std::vector< ZONE_CONTAINER * > aZones, bool aCheck=false)
Class BOARD to handle a board.
virtual void Revert() override
Revertes the commit by restoring the modifed items state.
polygon (not yet used for tracks, but could be in microwave apps)
CONST_ITERATOR CIterateWithHoles(int aOutline) const
class ZONE_CONTAINER, a zone area
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes a VIEW_ITEM from the view.
int TotalVertices() const
Returns total number of vertices stored in the set.
SHAPE_POLY_SET * Outline()
double RAD2DECIDEG(double rad)
Classes to handle copper zones.
void setAltConstraint(bool aEnabled)
Sets up an alternative constraint (typically enabled upon a modifier key being pressed).
usual segment : line with rounded ends
std::unique_ptr< STATUS_TEXT_POPUP > m_statusPopup
ITERATOR Iterate(int aFirst, int aLast, bool aIterateHoles=false)
Function Iterate returns an object to iterate through the points of the polygons between aFirst and a...
int OutlineCount() const
Returns the number of outlines in the set
class EDGE_MODULE, a footprint edge
static TOOL_ACTION selectionModified
Modified selection notification.
bool removeCornerCondition(const SELECTION &aSelection)
Condition to display "Remove corner" context menu entry.
bool IsEndContour() const
Function IsEndContour.
const wxPoint & GetArcStart() const
VECTOR2I & Vertex(int aIndex, int aOutline, int aHole)
Returns the index-th vertex in a given hole outline within a given outline
DIMENSION class definition.
std::shared_ptr< EDIT_POINTS > m_editPoints
Currently available edit points.
void finishItem()
Applies the last changes to the edited item.
class MODULE, a footprint
double Angle() const
Function Angle computes the angle of the vector.
STROKE_T GetShape() const
void SetOrigin(const wxPoint &aOrigin)
Function SetOrigin Sets a new origin of the crossbar line.
const wxPoint & GetEnd() const
Function GetEnd returns the ending point of the graphic.
const wxPoint & GetEnd()
Function GetEnd.
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Function SetMsgPanel clears the message panel and populates it with the contents of aList...
ITERATOR IterateWithHoles(int aOutline)
Function IterateWithHoles.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Returns the reference to aIndex-th outline in the set
const wxPoint & GetOrigin() const
Function GetOrigin.
static TOOL_ACTION pointEditorAddCorner
Break outline (insert additional points to an edge)
static TOOL_ACTION pointEditorRemoveCorner
Removes a corner.
void SetEnd(const wxPoint &aEnd)
Function SetEnd Sets a new end of the crossbar line.
VECTOR2D GetCursorPosition() const
Returns the current cursor position in world coordinates.
std::shared_ptr< EDIT_CONSTRAINT< EDIT_POINT > > m_altConstraint
COMMIT & StageItems(const Range &aRange, CHANGE_TYPE aChangeType)
EDIT_POINT get45DegConstrainer() const
Returns a point that should be used as a constrainer for 45 degrees mode.
bool isModified(const EDIT_POINT &aPoint) const
Returns true if aPoint is the currently modified point.
Class VIEW_CONTROLS is an interface for classes handling user events controlling the view behaviour (...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Function ForceCursorPosition() Places the cursor immediately at a given point.
SHAPE_POLY_SET & GetPolyShape()
SELECTION_TOOL * m_selectionTool
Selection tool used for obtaining selected items
virtual void Update(VIEW_ITEM *aItem, int aUpdateFlags)
For dynamic VIEWs, informs the associated VIEW that the graphical representation of this item has cha...
class DIMENSION, a dimension (graphic item)
virtual void SetAutoPan(bool aEnabled)
Function SetAutoPan Turns on/off auto panning (this feature is used when there is a tool active (eg...
void SetStart(const wxPoint &aStart)
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Function NearestPoint()
virtual VECTOR2I GetPosition() const
Function GetPosition()
VECTOR2D GetGridPoint(const VECTOR2D &aPoint) const
Function GetGridPoint() For a given point it returns the nearest point belonging to the grid in world...
Common, abstract interface for edit frames.
void SetHeight(int aHeight)
Function SetHeight Sets the length of feature lines.
void RemoveVertex(int aGlobalIndex)
Function RemoveVertex deletes the aGlobalIndex-th vertex.
const wxPoint GetArcEnd() const
void Hatch()
Function Hatch computes the hatch lines depending on the hatch parameters and stores it in the zone's...
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
void removeCorner(EDIT_POINT *aPoint)
Removes a corner.
virtual void Push(const wxString &aMessage=wxT("A commit"), bool aCreateUndoEntry=true, bool aSetDirtyBit=true) override
Executes the changes.
void updatePoints()
Updates edit points with item's points.
void SetEnd(const wxPoint &aEnd)
static std::pair< bool, SHAPE_POLY_SET::VERTEX_INDEX > findVertex(SHAPE_POLY_SET &aPolySet, const EDIT_POINT &aPoint)
void SetAngle(double aAngle)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees...
EDIT_POINT m_original
Original position for the current drag point.
void InsertVertex(int aGlobalIndex, VECTOR2I aNewVertex)
Function InsertVertex Adds a vertex in the globally indexed position aGlobalIndex.
int Size() const
Returns the number of selected parts.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Function Add() Adds a VIEW_ITEM to the view.
bool Init() override
Function Init() Init() is called once upon a registration of the tool.
Module description (excepted pads)
POLYGON & Polygon(int aIndex)
Returns the aIndex-th subpolygon in the set
EDIT_POINT m_altConstrainer
EDGE_MODULE class definition.
class DRAWSEGMENT, a segment not on copper layers
EDIT_POINT * m_editedPoint
Currently edited point, NULL if there is none.
bool IsSelfIntersecting()
Function IsSelfIntersecting Checks whether any of the polygons in the set is self intersecting...
const wxPoint & GetStart() const
Function GetStart returns the starting point of the graphic.
int Distance(const SEG &aSeg) const
Function Distance()
void DisplayError(wxWindow *parent, const wxString &text, int displaytime)
Function DisplayError displays an error or warning message box with aMessage.
void Reset(RESET_REASON aReason) override
Function Reset() Brings the tool to a known, initial state.
class PCB_BASE_FRAME basic PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer...
void setEditedPoint(EDIT_POINT *aPoint)
Sets the current point being edited. NULL means none.
static void buildForPolyOutline(std::shared_ptr< EDIT_POINTS > points, const SHAPE_POLY_SET *aOutline, KIGFX::GAL *aGal)
virtual void ApplyConstraint()
Function ApplyConstraint()
int modifiedSelection(const TOOL_EVENT &aEvent)
void ClearFilledPolysList()
Function ClearFilledPolysList clears the list of filled polygons.
static bool addCornerCondition(const SELECTION &aSelection)
Condition to display "Create corner" context menu entry.
Class GAL is the abstract interface for drawing on a 2D-surface.
bool validatePolygon(SHAPE_POLY_SET &aModified, const SHAPE_POLY_SET *aOriginal=nullptr) const
Validates a polygon and restores it to its original version if available.
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, KIGFX::GAL *aGal)
void RemoveContour(int aContourIdx, int aPolygonIdx=-1)
Function RemoveContour deletes the aContourIdx-th contour of the aPolygonIdx-th polygon in the set...
virtual void SetPosition(const VECTOR2I &aPosition)
Function SetPosition()