26using namespace std::placeholders;
29#include <fmt/format.h>
64 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
70 switch( aItem->
Type() )
75 points->AddPoint( line->
GetStart() );
76 points->AddPoint( line->
GetEnd() );
86 if( topLeft.
y > botRight.
y )
87 std::swap( topLeft.
y, botRight.
y );
89 if( topLeft.
x > botRight.
x )
90 std::swap( topLeft.
x, botRight.
x );
92 points->AddPoint( topLeft );
93 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
94 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
95 points->AddPoint( botRight );
162 if( selection.
Size() != 1 || !selection.
Front()->
IsType( { WSG_LINE_T, WSG_RECT_T } ) )
187 bool modified =
false;
206 catch(
const fmt::format_error& exc )
208 wxLogWarning( wxS(
"Exception \"%s\" serializing string ocurred." ),
224 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
230 else if( evt->IsCancelInteractive() || evt->IsActivate() )
238 else if( evt->IsCancelInteractive() )
243 if( evt->IsActivate() && !evt->IsMoveTool() )
268 m_frame->GetCanvas()->Refresh();
278 switch( editedPointIndex )
282 topLeft.
x = std::min( topLeft.
x, botRight.
x - minWidth );
283 topLeft.
y = std::min( topLeft.
y, botRight.
y - minHeight );
286 topRight.
y = topLeft.
y;
287 botLeft.
x = topLeft.
x;
293 topRight.
x = std::max( topRight.
x, botLeft.
x + minWidth );
294 topRight.
y = std::min( topRight.
y, botLeft.
y - minHeight );
297 topLeft.
y = topRight.
y;
298 botRight.
x = topRight.
x;
304 botLeft.
x = std::min( botLeft.
x, topRight.
x - minWidth );
305 botLeft.
y = std::max( botLeft.
y, topRight.
y + minHeight );
308 botRight.
y = botLeft.
y;
309 topLeft.
x = botLeft.
x;
315 botRight.
x = std::max( botRight.
x, topLeft.
x + minWidth );
316 botRight.
y = std::max( botRight.
y, topLeft.
y + minHeight );
319 botLeft.
y = botRight.
y;
320 topRight.
x = botRight.
x;
340 switch( item->
Type() )
357 draw_line->
SetEnd( draw_line->
GetEnd() + move_endpoint );
374 topLeft, topRight, botLeft, botRight );
381 end_delta.
y = topLeft.
y - rect->
GetEnd().
y;
386 end_delta.
y = botRight.
y - rect->
GetEnd().
y;
392 end_delta.
x = topLeft.
x - rect->
GetEnd().
x;
397 end_delta.
x = botRight.
x - rect->
GetEnd().
x;
422 m_frame->GetPropertiesFrame()->Freeze();
423 m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( dataItem );
424 m_frame->GetPropertiesFrame()->Thaw();
438 switch( item->
Type() )
455 if( topLeft.
y > botRight.
y )
456 std::swap( topLeft.
y, botRight.
y );
458 if( topLeft.
x > botRight.
x )
459 std::swap( topLeft.
x, botRight.
x );
489 if(
m_frame->ToolStackIsEmpty() )
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)
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 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 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.
std::unique_ptr< KIGFX::PREVIEW::ANGLE_ITEM > m_angleItem
void setEditedPoint(EDIT_POINT *aPoint)
Return true if aPoint is the currently modified point.
std::shared_ptr< EDIT_POINTS > m_editPoints
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)
VECTOR2< int32_t > VECTOR2I