26using namespace std::placeholders;
79 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
85 switch( aItem->
Type() )
111 points->AddPoint( topLeft );
112 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
113 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
114 points->AddPoint( botRight );
154 points->AddPoint( topLeft );
155 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
156 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
157 points->AddPoint( botRight );
179 points->AddPoint( shape->
GetStart() );
180 points->AddPoint( shape->
GetEnd() );
185 points->AddPoint( shape->
GetEnd() );
195 points->AddPoint( topLeft );
196 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
197 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
198 points->AddPoint( botRight );
214 points->AddPoint( pt );
238 points->AddPoint( topLeft );
239 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
240 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
241 points->AddPoint( botRight );
261 points->AddPoint( topLeft );
262 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
263 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
264 points->AddPoint( botRight );
284 points->AddPoint( topLeft );
285 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
286 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
287 points->AddPoint( botRight );
294 std::pair<EDA_ITEM*, int> connectedStart = {
nullptr,
STARTPOINT };
295 std::pair<EDA_ITEM*, int> connectedEnd = {
nullptr,
STARTPOINT };
313 connectedStart = { testLine,
ENDPOINT };
321 connectedEnd = { testLine,
ENDPOINT };
326 points->AddPoint( line->
GetEndPoint(), connectedEnd );
345 m_editedPoint( nullptr )
416 if( !
editor->IsSymbolEditable() ||
editor->IsSymbolAlias() )
422 if( selection.
Size() != 1 || !selection.
Front()->
IsType( { LIB_SHAPE_T, SCH_SHAPE_T,
423 LIB_TEXTBOX_T, SCH_TEXTBOX_T,
425 SCH_ITEM_LOCATE_GRAPHIC_LINE_T,
448 bool modified =
false;
469 bool snap = !evt->DisableGridSnapping();
480 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
491 else if( evt->IsCancelInteractive() || evt->IsActivate() )
500 else if( evt->IsCancelInteractive() )
505 if( evt->IsActivate() )
552 topLeft.
x = std::min( topLeft.
x, botRight.
x - minWidth );
553 topLeft.
y = std::min( topLeft.
y, botRight.
y - minHeight );
559 topRight.
y = topLeft.
y;
560 botLeft.
x = topLeft.
x;
565 topRight.
x = std::max( topRight.
x, botLeft.
x + minWidth );
566 topRight.
y = std::min( topRight.
y, botLeft.
y - minHeight );
572 topLeft.
y = topRight.
y;
573 botRight.
x = topRight.
x;
578 botLeft.
x = std::min( botLeft.
x, topRight.
x - minWidth );
579 botLeft.
y = std::max( botLeft.
y, topRight.
y + minHeight );
585 botRight.
y = botLeft.
y;
586 topLeft.
x = botLeft.
x;
591 botRight.
x = std::max( botRight.
x, topLeft.
x + minWidth );
592 botRight.
y = std::max( botRight.
y, topLeft.
y + minHeight );
598 botLeft.
y = botRight.
y;
599 topRight.
x = botRight.
x;
603 topLeft.
y = std::min( topLeft.
y, botRight.
y - minHeight );
610 topLeft.
x = std::min( topLeft.
x, botRight.
x - minWidth );
617 botRight.
y = std::max( botRight.
y, topLeft.
y + minHeight );
624 botRight.
x = std::max( botRight.
x, topLeft.
x + minWidth );
639 switch( item->
Type() )
674 for(
unsigned i = 0; i <
m_editPoints->PointsSize(); ++i )
690 gridHelper.
SetSnap( aSnapToGrid );
693 botLeft, botRight, &gridHelper );
720 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
752 gridHelper.
SetSnap( aSnapToGrid );
755 botLeft, botRight, &gridHelper );
782 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
828 for(
unsigned i = 0; i <
m_editPoints->PointsSize(); ++i )
844 gridHelper.
SetSnap( aSnapToGrid );
847 botLeft, botRight, &gridHelper );
855 shape->
SetEnd( botRight );
874 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
906 gridHelper.
SetSnap( aSnapToGrid );
909 botLeft, botRight, &gridHelper );
917 textBox->
SetEnd( botRight );
936 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
958 gridHelper.
SetSnap( aSnapToGrid );
961 botLeft, botRight, &gridHelper );
963 double oldWidth = bitmap->
GetSize().
x;
964 double newWidth = topRight.
x - topLeft.
x;
965 double widthRatio = newWidth / oldWidth;
967 double oldHeight = bitmap->
GetSize().
y;
968 double newHeight = botLeft.
y - topLeft.
y;
969 double heightRatio = newHeight / oldHeight;
986 gridHelper.
SetSnap( aSnapToGrid );
995 gridHelper.
SetSnap( aSnapToGrid );
999 topLeft, topRight, botLeft, botRight, &gridHelper );
1006 sheetNewPos = topLeft;
1007 sheetNewSize =
VECTOR2I( botRight.
x - topLeft.
x, botRight.
y - topLeft.
y );
1028 for(
unsigned i = 0; i <
m_editPoints->LinesSize(); ++i )
1042 switch(
pin->GetSide() )
1060 if( sheet->
GetSize() != sheetNewSize )
1062 sheet->
Resize( sheetNewSize );
1077 if( connected.first )
1081 else if( connected.second ==
ENDPOINT )
1089 if( connected.first )
1093 else if( connected.second ==
ENDPOINT )
1121 switch( item->
Type() )
1402 return shape->
HitTest( cursorPos, (
int) threshold );
1416 int currentMinDistance = INT_MAX;
1417 int closestLineStart = 0;
1422 poly.
CPoint( i + 1 ), pos );
1424 if(
distance < currentMinDistance )
1427 closestLineStart = i;
1432 poly.
Insert( closestLineStart + 1, pos );
1487 if( connected.first )
1492 if( connected.first )
VECTOR2D mapCoords(const VECTOR2D &aSource)
constexpr EDA_IU_SCALE schIUScale
static TOOL_ACTION activatePointEditor
EDIT_CONSTRAINT for a EDIT_LINE, that constrains the line to move perpendicular to the line itself.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
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.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
virtual bool IsType(const std::vector< KICAD_T > &aScanTypes) const
Check whether the item is one of the listed types.
SHAPE_POLY_SET & GetPolyShape()
int GetPointCount() const
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
void SetEnd(const VECTOR2I &aEnd)
wxString SHAPE_T_asString() const
virtual void ClearRenderCache()
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, SCH_BASE_FRAME *frame)
Represent a single point that can be used for modifying items.
static const int POINT_SIZE
Border size when not hovering.
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
static TOOL_ACTION pointEditorRemoveCorner
static TOOL_ACTION pointEditorAddCorner
void updatePoints()
Update which point is being edited.
int Main(const TOOL_EVENT &aEvent)
void updateEditedPoint(const TOOL_EVENT &aEvent)
Clear references to the points.
void setEditedPoint(EDIT_POINT *aPoint)
Return true if aPoint is the currently modified point.
int modifiedSelection(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
EDIT_POINT * m_editedPoint
< Currently edited point, NULL if there is none.
bool addCornerCondition(const SELECTION &aSelection)
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
void pinEditedCorner(int minWidth, int minHeight, VECTOR2I &topLeft, VECTOR2I &topRight, VECTOR2I &botLeft, VECTOR2I &botRight, EE_GRID_HELPER *aGrid) const
Update the coordinates of 4 corners of a rectangle, according to constraints and the moved corner.
bool isModified(const EDIT_POINT &aPoint) const
int addCorner(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
std::shared_ptr< EDIT_POINTS > m_editPoints
bool removeCornerCondition(const SELECTION &aSelection)
int removeCorner(const TOOL_EVENT &aEvent)
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
int getEditedPointIndex() const
int clearEditedPoints(const TOOL_EVENT &aEvent)
Set the current point being edited. NULL means none.
void updateParentItem(bool aSnapToGrid) const
< Update item's points with edit points.
EE_TYPE OfType(KICAD_T aType) const
static const TOOL_EVENT ClearedEvent
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 PointSelectedEvent
VECTOR2I AlignGrid(const VECTOR2I &aPoint) const
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
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.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
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...
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
void SetEditState(int aState)
void SetPosition(const VECTOR2I &aPosition) override
void CalcEdit(const VECTOR2I &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
VECTOR2I GetPosition() const override
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
Object to handle a bitmap image that can be inserted in a schematic.
double GetImageScale() const
VECTOR2I GetPosition() const override
void SetImageScale(double aScale)
Schematic editor (Eeschema) main window.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Segment description base class to describe items which have 2 end points (track, wire,...
void SetStartPoint(const VECTOR2I &aPosition)
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
void SetEndPoint(const VECTOR2I &aPosition)
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
void SetPosition(const VECTOR2I &aPos) override
void CalcEdit(const VECTOR2I &aPosition)
void SetEditState(int aState)
VECTOR2I GetPosition() const override
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetPosition(const VECTOR2I &aPosition) override
int GetMinWidth(bool aFromLeft) const
Return the minimum width of the sheet based on the widths of the sheet pin text.
VECTOR2I GetPosition() const override
int GetMinHeight(bool aFromTop) const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
void Resize(const VECTOR2I &aSize)
Resize this sheet to aSize and adjust all of the labels accordingly.
std::vector< SCH_SHEET_PIN * > & GetPins()
int Size() const
Returns the number of selected parts.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
virtual size_t GetPointCount() const override
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
void Remove(int aStartIndex, int aEndIndex)
Remove the range of points [start_index, end_index] from the line chain.
void Insert(size_t aVertex, const VECTOR2I &aP)
const std::vector< VECTOR2I > & CPoints() const
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Add a new vertex to the contour indexed by aOutline and aHole (defaults to the outline of the last po...
SHAPE_LINE_CHAIN & Outline(int aIndex)
int NewOutline()
Creates a new hole in a given outline.
The symbol library editor main window.
#define ENDPOINT
ends. (Used to support dragging.)
#define STARTPOINT
When a line is selected, these flags indicate which.
#define UNIMPLEMENTED_FOR(type)
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
std::vector< FAB_LAYER_COLOR > dummy
constexpr int MilsToIU(int mils) const
double DistanceLinePoint(const VECTOR2I &linePointA, const VECTOR2I &linePointB, const VECTOR2I &referencePoint)
Compute the distance between a line and a reference point Reference: http://mathworld....