26 using namespace std::placeholders;
71 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
77 switch( aItem->
Type() )
81 LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( aItem );
108 points->AddPoint( topLeft );
109 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
110 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
111 points->AddPoint( botRight );
126 wxFAIL_MSG( wxT(
"EDIT_POINTS_FACTORY::Make not implemented for " )
138 points->AddPoint( (wxPoint) topLeft );
139 points->AddPoint( wxPoint( botRight.x, topLeft.y ) );
140 points->AddPoint( wxPoint( topLeft.x, botRight.y ) );
141 points->AddPoint( (wxPoint) botRight );
151 points->AddPoint( (wxPoint) topLeft );
152 points->AddPoint( wxPoint( botRight.x, topLeft.y ) );
153 points->AddPoint( wxPoint( topLeft.x, botRight.y ) );
154 points->AddPoint( (wxPoint) botRight );
161 std::pair<EDA_ITEM*, int> connectedStart = {
nullptr,
STARTPOINT };
162 std::pair<EDA_ITEM*, int> connectedEnd = {
nullptr,
STARTPOINT };
180 connectedStart = { testLine,
ENDPOINT };
188 connectedEnd = { testLine,
ENDPOINT };
193 points->AddPoint( line->
GetEndPoint(), connectedEnd );
212 m_editedPoint( nullptr )
276 static KICAD_T supportedTypes[] = {
291 if( !
editor->IsSymbolEditable() ||
editor->IsSymbolAlias() )
297 if( selection.
Size() != 1 || !selection.
Front()->
IsType( supportedTypes ) )
317 bool modified =
false;
338 bool snap = !evt->DisableGridSnapping();
339 EDA_SHAPE* shape = dynamic_cast<EDA_SHAPE*>( item );
349 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
360 else if( evt->IsCancelInteractive() || evt->IsActivate() )
369 else if( evt->IsCancelInteractive() )
374 if( evt->IsActivate() )
419 switch( aEditedPointIndex )
423 topLeft.
x = std::min( topLeft.
x, botRight.
x - minWidth );
424 topLeft.
y = std::min( topLeft.
y, botRight.
y - minHeight );
429 topRight.
y = topLeft.
y;
430 botLeft.
x = topLeft.
x;
436 topRight.
x = std::max( topRight.
x, botLeft.
x + minWidth );
437 topRight.
y = std::min( topRight.
y, botLeft.
y - minHeight );
442 topLeft.
y = topRight.
y;
443 botRight.
x = topRight.
x;
449 botLeft.
x = std::min( botLeft.
x, topRight.
x - minWidth );
450 botLeft.
y = std::max( botLeft.
y, topRight.
y + minHeight );
455 botRight.
y = botLeft.
y;
456 topLeft.
x = botLeft.
x;
462 botRight.
x = std::max( botRight.
x, topLeft.
x + minWidth );
463 botRight.
y = std::max( botRight.
y, topLeft.
y + minHeight );
468 botLeft.
y = botRight.
y;
469 topRight.
x = botRight.
x;
483 switch( item->
Type() )
487 LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( item );
518 for(
unsigned i = 0; i <
m_editPoints->PointsSize(); ++i )
535 topLeft, topRight, botLeft, botRight, &gridHelper );
547 wxFAIL_MSG( wxT(
"EE_POINT_EDITOR::updateParentItem not implemented for " )
563 topLeft, topRight, botLeft, botRight, &gridHelper );
565 double oldWidth = bitmap->
GetSize().x;
566 double newWidth = topRight.
x - topLeft.
x;
567 double widthRatio = newWidth / oldWidth;
569 double oldHeight = bitmap->
GetSize().y;
570 double newHeight = botLeft.
y - topLeft.
y;
571 double heightRatio = newHeight / oldHeight;
590 topLeft, topRight, botLeft, botRight, &gridHelper );
594 wxPoint originDelta = sheet->
GetPosition() - (wxPoint) topLeft;
597 sheet->
SetSize( wxSize( botRight.x - topLeft.x, botRight.y - topLeft.y ) );
606 wxPoint pos =
pin->GetPosition();
610 switch(
pin->GetSide() )
619 pin->SetPosition( pos );
633 if( connected.first )
636 static_cast<SCH_LINE*>( connected.first )->SetStartPoint( line->
GetPosition() );
637 else if( connected.second ==
ENDPOINT )
638 static_cast<SCH_LINE*>( connected.first )->SetEndPoint( line->
GetPosition() );
645 if( connected.first )
648 static_cast<SCH_LINE*>( connected.first )->SetStartPoint( line->
GetEndPoint() );
649 else if( connected.second ==
ENDPOINT )
650 static_cast<SCH_LINE*>( connected.first )->SetEndPoint( line->
GetEndPoint() );
676 switch( item->
Type() )
680 LIB_SHAPE* shape = static_cast<LIB_SHAPE*>( item );
739 wxFAIL_MSG( wxT(
"EE_POINT_EDITOR::updatePoints not implemented for " )
848 return shape->
HitTest( (wxPoint) cursorPos, (
int) threshold );
862 int currentMinDistance = INT_MAX;
863 int closestLineStart = 0;
865 for(
unsigned i = 0; i < poly.GetPointCount() - 1; ++i )
868 (wxPoint) poly.CPoint( i + 1 ), pos );
873 closestLineStart = i;
878 poly.Insert( closestLineStart + 1, pos );
897 if( poly.GetPointCount() < 3 )
933 if( connected.first )
938 if( connected.first )
948 static_cast<SYMBOL_EDIT_FRAME*>(
m_frame )->RollbackSymbolFromUndo();
950 static_cast<SCH_EDIT_FRAME*>(
m_frame )->RollbackSchematicFromUndo();
int Main(const TOOL_EVENT &aEvent)
virtual void ShowCursor(bool aEnabled)
Enable or disables display of cursor.
EE_TYPE OfType(KICAD_T aType) const
static const TOOL_EVENT SelectedEvent
#define STARTPOINT
When a line is selected, these flags indicate which.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
virtual size_t GetPointCount() const override
static TOOL_ACTION activatePointEditor
void SetEnd(const wxPoint &aEnd)
wxPoint GetStartPoint() const
int clearEditedPoints(const TOOL_EVENT &aEvent)
Set the current point being edited. NULL means none.
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
const wxPoint & GetStart() const
Return the starting point of the graphic.
int GetMinWidth(bool aFromLeft) const
Return the minimum width of the sheet based on the widths of the sheet pin text.
static TOOL_ACTION pointEditorAddCorner
void updateEditedPoint(const TOOL_EVENT &aEvent)
Clear references to the points.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual void Remove(VIEW_ITEM *aItem)
Remove a VIEW_ITEM from the view.
void SetEditState(int aState)
EDIT_POINT * m_editedPoint
< Currently edited point, NULL if there is none.
void updatePoints()
Update which point is being edited.
int GetMinHeight(bool aFromTop) const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
#define ENDPOINT
ends. (Used to support dragging.)
virtual wxPoint GetPosition() const
wxPoint GetPosition() const override
int modifiedSelection(const TOOL_EVENT &aEvent)
search types array terminator (End Of Types)
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
FIELDS_AUTOPLACED GetFieldsAutoplaced() const
Return whether the fields have been automatically placed.
void SetEndPoint(const wxPoint &aPosition)
bool addCornerCondition(const SELECTION &aSelection)
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
void SetPosition(const wxPoint &aPosition) override
int GetPointCount() const
const wxPoint & GetEnd() const
Return the ending point of the graphic.
bool Init() override
Init() is called once upon a registration of the tool.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
static TOOL_ACTION pointEditorRemoveCorner
const std::vector< VECTOR2I > & CPoints() const
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void OnModify()
Must be called after a model change in order to set the "modify" flag and do other frame-specific pro...
virtual void CaptureCursor(bool aEnabled)
Force the cursor to stay within the drawing panel area.
SHAPE_LINE_CHAIN & Outline(int aIndex)
void SetStartPoint(const wxPoint &aPosition)
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void SetImageScale(double aScale)
int removeCorner(const TOOL_EVENT &aEvent)
An interface for classes handling user events controlling the view behavior such as zooming,...
static const TOOL_EVENT ClearedEvent
Selected item had a property changed (except movement)
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
void updateParentItem() const
< Update item's points with edit points.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
void CalcEdit(const wxPoint &aPosition) override
Calculate the attributes of an item at aPosition when it is being edited.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
static float distance(const SFVEC2UI &a, const SFVEC2UI &b)
int addCorner(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
wxString SHAPE_T_asString() const
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxPoint GetPosition() const override
int NewOutline()
Creates a new hole in a given outline.
Object to handle a bitmap image that can be inserted in a schematic.
SHAPE_POLY_SET & GetPolyShape()
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
bool removeCornerCondition(const SELECTION &aSelection)
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
void SetSize(const wxSize &aSize)
std::vector< SCH_SHEET_PIN * > & GetPins()
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
std::shared_ptr< EDIT_POINTS > m_editPoints
Segment description base class to describe items which have 2 end points (track, wire,...
int getEditedPointIndex() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
wxPoint GetPosition() const override
void SetPosition(const wxPoint &aPosition) override
double GetImageScale() const
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
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...
int Size() const
Returns the number of selected parts.
void setEditedPoint(EDIT_POINT *aPoint)
Return true if aPoint is the currently modified point.
A base class for most all the KiCad significant classes used in schematics and boards.
static const int POINT_SIZE
Border size when not hovering.
virtual void Add(VIEW_ITEM *aItem, int aDrawPriority=-1)
Add a VIEW_ITEM to the view.
Represent a single point that can be used for modifying items.
void AutoplaceFields(SCH_SCREEN *aScreen, bool aManual) override
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
wxPoint GetPosition() const override
static void pinEditedCorner(int aEditedPointIndex, int minWidth, int minHeight, VECTOR2I &topLeft, VECTOR2I &topRight, VECTOR2I &botLeft, VECTOR2I &botRight, EE_GRID_HELPER *aGrid)
Update the coordinates of 4 corners of a rectangle, according to constraints and the moved corner.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, SCH_BASE_FRAME *frame)
double DistanceLinePoint(const wxPoint &linePointA, const wxPoint &linePointB, const wxPoint &referencePoint)
Compute the distance between a line and a reference point Reference: http://mathworld....
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
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...
KICAD_T Type() const
Returns the type of object.
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...
The symbol library editor main window.
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
VECTOR2I AlignGrid(const VECTOR2I &aPoint) const
wxPoint GetEndPoint() const