26 using namespace std::placeholders;
72 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
78 switch( aItem->
Type() )
102 for( wxPoint pt : pts )
120 points->AddPoint( topLeft );
121 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
122 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
123 points->AddPoint( botRight );
132 points->AddPoint( (wxPoint) topLeft );
133 points->AddPoint( wxPoint( botRight.x, topLeft.y ) );
134 points->AddPoint( wxPoint( topLeft.x, botRight.y ) );
135 points->AddPoint( (wxPoint) botRight );
144 points->AddPoint( (wxPoint) topLeft );
145 points->AddPoint( wxPoint( botRight.x, topLeft.y ) );
146 points->AddPoint( wxPoint( topLeft.x, botRight.y ) );
147 points->AddPoint( (wxPoint) botRight );
153 std::pair<EDA_ITEM*, int> connectedStart = {
nullptr,
STARTPOINT };
154 std::pair<EDA_ITEM*, int> connectedEnd = {
nullptr,
STARTPOINT };
172 connectedStart = { testLine,
ENDPOINT };
180 connectedEnd = { testLine,
ENDPOINT };
186 points->AddPoint( line->
GetEndPoint(), connectedEnd );
204 m_editedPoint( nullptr )
255 static KICAD_T supportedTypes[] = {
271 if( selection.
Size() != 1 || !selection.
Front()->
IsType( supportedTypes ) )
291 bool modified =
false;
312 bool snap = !evt->Modifier(
MD_ALT );
322 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
333 else if( evt->IsCancelInteractive() || evt->IsActivate() )
342 else if( evt->IsCancelInteractive() )
347 if( evt->IsActivate() )
394 #define MOVE_TO_GRID(z) { z.x = ( (z.x +1 ) / aGridSize ) * aGridSize;\ 395 z.y = ( (z.y +1 ) / aGridSize ) * aGridSize; } 396 switch( aEditedPointIndex )
400 topLeft.
x = std::min( topLeft.
x, botRight.
x - minWidth );
401 topLeft.
y = std::min( topLeft.
y, botRight.
y - minHeight );
405 topLeft.
x = ( topLeft.
x / aGridSize ) * aGridSize;
406 topLeft.
y = ( topLeft.
y / aGridSize ) * aGridSize;
410 topRight.
y = topLeft.
y;
411 botLeft.
x = topLeft.
x;
417 topRight.
x = std::max( topRight.
x, botLeft.
x + minWidth );
418 topRight.
y = std::min( topRight.
y, botLeft.
y - minHeight );
422 topRight.
x = ( ( topRight.
x+1 ) / aGridSize ) * aGridSize;
423 topRight.
y = ( topRight.
y / aGridSize ) * aGridSize;
427 topLeft.
y = topRight.
y;
428 botRight.
x = topRight.
x;
434 botLeft.
x = std::min( botLeft.
x, topRight.
x - minWidth );
435 botLeft.
y = std::max( botLeft.
y, topRight.
y + minHeight );
439 botLeft.
x = ( botLeft.
x / aGridSize ) * aGridSize;
440 botLeft.
y = ( ( botLeft.
y+1 ) / aGridSize ) * aGridSize;
444 botRight.
y = botLeft.
y;
445 topLeft.
x = botLeft.
x;
451 botRight.
x = std::max( botRight.
x, topLeft.
x + minWidth );
452 botRight.
y = std::max( botRight.
y, topLeft.
y + minHeight );
456 botRight.
x = ( ( botRight.
x+1 ) / aGridSize ) * aGridSize;
457 botRight.
y = ( ( botRight.
y+1 ) / aGridSize ) * aGridSize;
461 botLeft.
y = botRight.
y;
462 topRight.
x = botRight.
x;
476 switch( item->
Type() )
517 for(
unsigned i = 0; i <
m_editPoints->PointsSize(); ++i )
531 topLeft, topRight, botLeft, botRight );
548 topLeft, topRight, botLeft, botRight );
550 double oldWidth = bitmap->
GetSize().x;
551 double newWidth = topRight.
x - topLeft.
x;
552 double widthRatio = newWidth / oldWidth;
554 double oldHeight = bitmap->
GetSize().y;
555 double newHeight = botLeft.
y - topLeft.
y;
556 double heightRatio = newHeight / oldHeight;
573 int grid_size = Mils2iu( 50 );
575 topLeft, topRight, botLeft, botRight, grid_size );
579 wxPoint originDelta = sheet->
GetPosition() - (wxPoint) topLeft;
582 sheet->
SetSize( wxSize( botRight.x - topLeft.x, botRight.y - topLeft.y ) );
591 wxPoint pos = pin->GetPosition();
595 switch( pin->GetEdge() )
604 pin->SetPosition( pos );
619 if( connected.first )
622 static_cast<SCH_LINE*>( connected.first )->SetStartPoint( line->
GetPosition() );
623 else if( connected.second ==
ENDPOINT )
624 static_cast<SCH_LINE*>( connected.first )->SetEndPoint( line->
GetPosition() );
631 if( connected.first )
634 static_cast<SCH_LINE*>( connected.first )->SetStartPoint( line->
GetEndPoint() );
635 else if( connected.second ==
ENDPOINT )
636 static_cast<SCH_LINE*>( connected.first )->SetEndPoint( line->
GetEndPoint() );
663 switch( item->
Type() )
689 if(
m_editPoints->PointsSize() != (unsigned) pts.size() )
698 for(
unsigned i = 0; i < pts.size(); i++ )
889 if( connected.first )
894 if( connected.first )
904 static_cast<SYMBOL_EDIT_FRAME*>(
m_frame )->RollbackSymbolFromUndo();
906 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.
void AddCorner(const wxPoint &aPosition)
EE_TYPE OfType(KICAD_T aType) const
static const TOOL_EVENT SelectedEvent
static TOOL_ACTION activatePointEditor
wxPoint GetStartPoint() const
VECTOR2D ToWorld(const VECTOR2D &aCoord, bool aAbsolute=true) const
Converts a screen space point/vector to a point/vector in world space coordinates.
static TOOL_ACTION pointEditorAddCorner
void updateEditedPoint(const TOOL_EVENT &aEvent)
Set the current point being edited. NULL means none.
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.
wxPoint GetPosition() const override
static LIB_PART * dummy()
Used to draw a dummy shape when a LIB_PART is not found in library.
EDIT_POINT * m_editedPoint
< Currently edited point, NULL if there is none.
void updatePoints()
Update which point is being edited.
virtual wxPoint GetPosition() const
wxPoint GetPosition() const override
int modifiedSelection(const TOOL_EVENT &aEvent)
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
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.
unsigned GetCornerCount() const
void SetEndPoint(const wxPoint &aPosition)
bool addCornerCondition(const SELECTION &aSelection)
const std::vector< wxPoint > & GetPolyPoints() const
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
bool Init() override
Init() is called once upon a registration of the tool.
static void pinEditedCorner(int aEditedPointIndex, int minWidth, int minHeight, VECTOR2I &topLeft, VECTOR2I &topRight, VECTOR2I &botLeft, VECTOR2I &botRight, int aGridSize=0)
Update the coordinates of 4 corners of a rectangle, accordint to constraints and the moved corner.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
static TOOL_ACTION pointEditorRemoveCorner
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.
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)
int GetMinHeight() const
Return the minimum height that the sheet can be resized based on the sheet pin positions.
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 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.
int addCorner(const TOOL_EVENT &aEvent)
TOOL_ACTION handlers.
void AddPoint(const wxPoint &aPoint)
static VECTOR2D mapCoords(const wxPoint &aCoord)
wxPoint GetPosition() const override
Object to handle a bitmap image that can be inserted in a schematic.
void CalcEdit(const wxPoint &aPosition) override
Calculates the attributes of an item at aPosition when it is being edited.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=NULL) override
Update the board display after modifying it by a python script (note: it is automatically called by a...
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()
#define STARTPOINT
When a line is selected, these flags indicate which.
int GetMinWidth() const
Return the minimum width of the sheet based on the widths of the sheet pin text.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
void SetEnd(const wxPoint &aEnd)
std::shared_ptr< EDIT_POINTS > m_editPoints
Segment description base class to describe items which have 2 end points (track, wire,...
int getEditedPointIndex() const
wxPoint GetPosition() const override
void SetPosition(const wxPoint &aPosition) override
double GetImageScale() const
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.
void SetPosition(const wxPoint &aPosition) override
#define ENDPOINT
ends. (Used to support dragging.)
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...
void RemoveCorner(int aIdx)
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)
wxPoint GetPosition() const override
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
void SetEnd(const wxPoint &aPosition)
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.
Position or shape has changed.
wxPoint GetPosition() const override
void SetEditState(int aState)
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
wxPoint GetEndPoint() const