26using namespace std::placeholders;
29#include <fmt/format.h>
63 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
69 switch( aItem->
Type() )
74 points->AddPoint( line->
GetStart() );
75 points->AddPoint( line->
GetEnd() );
84 if( topLeft.
y > botRight.
y )
85 std::swap( topLeft.
y, botRight.
y );
87 if( topLeft.
x > botRight.
x )
88 std::swap( topLeft.
x, botRight.
x );
90 points->AddPoint( topLeft );
91 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
92 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
93 points->AddPoint( botRight );
112 m_selectionTool( nullptr ),
113 m_editedPoint( nullptr )
123 m_frame = getEditFrame<PL_EDITOR_FRAME>();
132 m_frame = getEditFrame<PL_EDITOR_FRAME>();
159 if( selection.
Size() != 1 || !selection.
Front()->
IsType( { WSG_LINE_T, WSG_RECT_T } ) )
181 bool modified =
false;
200 catch(
const fmt::format_error& exc )
202 wxLogWarning( wxS(
"Exception \"%s\" serializing string ocurred." ),
218 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
224 else if( evt->IsCancelInteractive() || evt->IsActivate() )
232 else if( evt->IsCancelInteractive() )
237 if( evt->IsActivate() && !evt->IsMoveTool() )
270 switch( editedPointIndex )
274 topLeft.
x = std::min( topLeft.
x, botRight.
x - minWidth );
275 topLeft.
y = std::min( topLeft.
y, botRight.
y - minHeight );
278 topRight.
y = topLeft.
y;
279 botLeft.
x = topLeft.
x;
285 topRight.
x = std::max( topRight.
x, botLeft.
x + minWidth );
286 topRight.
y = std::min( topRight.
y, botLeft.
y - minHeight );
289 topLeft.
y = topRight.
y;
290 botRight.
x = topRight.
x;
296 botLeft.
x = std::min( botLeft.
x, topRight.
x - minWidth );
297 botLeft.
y = std::max( botLeft.
y, topRight.
y + minHeight );
300 botRight.
y = botLeft.
y;
301 topLeft.
x = botLeft.
x;
307 botRight.
x = std::max( botRight.
x, topLeft.
x + minWidth );
308 botRight.
y = std::max( botRight.
y, topLeft.
y + minHeight );
311 botLeft.
y = botRight.
y;
312 topRight.
x = botRight.
x;
332 switch( item->
Type() )
349 draw_line->
SetEnd( draw_line->
GetEnd() + move_endpoint );
366 topLeft, topRight, botLeft, botRight );
373 end_delta.
y = topLeft.
y - rect->
GetEnd().
y;
378 end_delta.
y = botRight.
y - rect->
GetEnd().
y;
384 end_delta.
x = topLeft.
x - rect->
GetEnd().
x;
389 end_delta.
x = botRight.
x - rect->
GetEnd().
x;
430 switch( item->
Type() )
447 if( topLeft.
y > botRight.
y )
448 std::swap( topLeft.
y, botRight.
y );
450 if( topLeft.
x > botRight.
x )
451 std::swap( topLeft.
x, botRight.
x );
constexpr EDA_IU_SCALE drawSheetIUScale
static TOOL_ACTION activatePointEditor
Drawing sheet structure type definitions.
void MoveStartPointToIU(const VECTOR2I &aPosition)
Move the starting point of the item to a new position.
void MoveEndPointToIU(const VECTOR2I &aPosition)
Move the ending point of the item to a new position.
const VECTOR2I GetStartPosIU(int ii=0) const
const VECTOR2I GetEndPosIU(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
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)
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
VECTOR2< int32_t > VECTOR2I