26using namespace std::placeholders;
58 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
64 switch( aItem->
Type() )
69 points->AddPoint( line->
GetStart() );
70 points->AddPoint( line->
GetEnd() );
79 if( topLeft.
y > botRight.
y )
80 std::swap( topLeft.
y, botRight.
y );
82 if( topLeft.
x > botRight.
x )
83 std::swap( topLeft.
x, botRight.
x );
85 points->AddPoint( topLeft );
86 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
87 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
88 points->AddPoint( botRight );
107 m_selectionTool( nullptr ),
108 m_editedPoint( nullptr )
118 m_frame = getEditFrame<PL_EDITOR_FRAME>();
127 m_frame = getEditFrame<PL_EDITOR_FRAME>();
154 if( selection.
Size() != 1 || !selection.
Front()->
IsType( { WSG_LINE_T, WSG_RECT_T } ) )
176 bool modified =
false;
203 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
209 else if( evt->IsCancelInteractive() || evt->IsActivate() )
217 else if( evt->IsCancelInteractive() )
220 if( evt->IsActivate() && !evt->IsMoveTool() )
252 switch( editedPointIndex )
256 topLeft.
x = std::min( topLeft.
x, botRight.
x - minWidth );
257 topLeft.
y = std::min( topLeft.
y, botRight.
y - minHeight );
260 topRight.
y = topLeft.
y;
261 botLeft.
x = topLeft.
x;
267 topRight.
x = std::max( topRight.
x, botLeft.
x + minWidth );
268 topRight.
y = std::min( topRight.
y, botLeft.
y - minHeight );
271 topLeft.
y = topRight.
y;
272 botRight.
x = topRight.
x;
278 botLeft.
x = std::min( botLeft.
x, topRight.
x - minWidth );
279 botLeft.
y = std::max( botLeft.
y, topRight.
y + minHeight );
282 botRight.
y = botLeft.
y;
283 topLeft.
x = botLeft.
x;
289 botRight.
x = std::max( botRight.
x, topLeft.
x + minWidth );
290 botRight.
y = std::max( botRight.
y, topLeft.
y + minHeight );
293 botLeft.
y = botRight.
y;
294 topRight.
x = botRight.
x;
314 switch( item->
Type() )
331 draw_line->
SetEnd( draw_line->
GetEnd() + move_endpoint );
348 topLeft, topRight, botLeft, botRight );
355 end_delta.
y = topLeft.
y - rect->
GetEnd().
y;
360 end_delta.
y = botRight.
y - rect->
GetEnd().
y;
366 end_delta.
x = topLeft.
x - rect->
GetEnd().
x;
371 end_delta.
x = botRight.
x - rect->
GetEnd().
x;
412 switch( item->
Type() )
429 if( topLeft.
y > botRight.
y )
430 std::swap( topLeft.
y, botRight.
y );
432 if( topLeft.
x > botRight.
x )
433 std::swap( topLeft.
x, botRight.
x );
constexpr EDA_IU_SCALE drawSheetIUScale
static TOOL_ACTION activatePointEditor
Drawing sheet structure type definitions.
const VECTOR2I GetStartPosUi(int ii=0) const
void MoveEndPointToUi(const VECTOR2I &aPosition)
Move the ending point of the item to a new position.
void MoveStartPointToUi(const VECTOR2I &aPosition)
Move the starting point of the item to a new position.
const VECTOR2I GetEndPosUi(int ii=0) const
const std::vector< DS_DRAW_ITEM_BASE * > & GetDrawItems() const
Base class to handle basic graphic items.
void SetEnd(const VECTOR2I &aPos) override
void SetStart(const VECTOR2I &aPos)
const VECTOR2I & GetStart() const
const VECTOR2I & GetEnd() const
Non filled rectangle with thick segment.
const VECTOR2I & GetEnd() const
const VECTOR2I & GetStart() const
VECTOR2I GetPosition() const override
void SetEnd(const VECTOR2I &aPos) override
void SetStart(const VECTOR2I &aPos)
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.
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem, SCH_BASE_FRAME *frame)
static std::shared_ptr< EDIT_POINTS > Make(EDA_ITEM *aItem)
Represent a single point that can be used for modifying items.
virtual void SetPosition(const VECTOR2I &aPosition)
Set new coordinates for an EDIT_POINT.
virtual VECTOR2I GetPosition() const
Return coordinates of an EDIT_POINT.
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.
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.
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...
void OnModify() override
Must be called after a change in order to set the "modify" flag.
void RollbackFromUndo()
Apply the last command in Undo List without stacking a Redo.
void SaveCopyInUndoList()
Save a copy of the description (in a S expr string) for Undo/redo commands.
PROPERTIES_FRAME * GetPropertiesFrame()
PL_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void setTransitions() override
This method is meant to be overridden in order to specify handlers for events.
PL_EDITOR_FRAME * m_frame
PL_SELECTION_TOOL * m_selectionTool
Currently edited point, NULL if there is none.
int modifiedSelection(const TOOL_EVENT &aEvent)
int getEditedPointIndex() const
void updateItem() const
< Update item's points with edit points.
void Reset(RESET_REASON aReason) override
Bring the tool to a known, initial state.
void updateEditedPoint(const TOOL_EVENT &aEvent)
Set the current point being edited. NULL means none.
EDIT_POINT * m_editedPoint
Currently available edit points.
bool Init() override
Init() is called once upon a registration of the tool.
int Main(const TOOL_EVENT &aEvent)
void updatePoints()
Update which point is being edited.
void setEditedPoint(EDIT_POINT *aPoint)
Return true if aPoint is the currently modified point.
std::shared_ptr< EDIT_POINTS > m_editPoints
void CopyPrmsFromItemToPanel(DS_DATA_ITEM *aItem)
int Size() const
Returns the number of selected parts.
This file is part of the common library.
void pinEditedCorner(int editedPointIndex, int minWidth, int minHeight, VECTOR2I &topLeft, VECTOR2I &topRight, VECTOR2I &botLeft, VECTOR2I &botRight)
constexpr int MilsToIU(int mils) const