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() );
85 if( topLeft.
y > botRight.
y )
86 std::swap( topLeft.
y, botRight.
y );
88 if( topLeft.
x > botRight.
x )
89 std::swap( topLeft.
x, botRight.
x );
91 points->AddPoint( topLeft );
92 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
93 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
94 points->AddPoint( botRight );
160 if( selection.
Size() != 1 || !selection.
Front()->
IsType( { WSG_LINE_T, WSG_RECT_T } ) )
185 bool modified =
false;
204 catch(
const fmt::format_error& exc )
206 wxLogWarning( wxS(
"Exception \"%s\" serializing string ocurred." ),
222 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
228 else if( evt->IsCancelInteractive() || evt->IsActivate() )
236 else if( evt->IsCancelInteractive() )
241 if( evt->IsActivate() && !evt->IsMoveTool() )
266 m_frame->GetCanvas()->Refresh();
276 switch( editedPointIndex )
280 topLeft.
x = std::min( topLeft.
x, botRight.
x - minWidth );
281 topLeft.
y = std::min( topLeft.
y, botRight.
y - minHeight );
284 topRight.
y = topLeft.
y;
285 botLeft.
x = topLeft.
x;
291 topRight.
x = std::max( topRight.
x, botLeft.
x + minWidth );
292 topRight.
y = std::min( topRight.
y, botLeft.
y - minHeight );
295 topLeft.
y = topRight.
y;
296 botRight.
x = topRight.
x;
302 botLeft.
x = std::min( botLeft.
x, topRight.
x - minWidth );
303 botLeft.
y = std::max( botLeft.
y, topRight.
y + minHeight );
306 botRight.
y = botLeft.
y;
307 topLeft.
x = botLeft.
x;
313 botRight.
x = std::max( botRight.
x, topLeft.
x + minWidth );
314 botRight.
y = std::max( botRight.
y, topLeft.
y + minHeight );
317 botLeft.
y = botRight.
y;
318 topRight.
x = botRight.
x;
338 switch( item->
Type() )
355 draw_line->
SetEnd( draw_line->
GetEnd() + move_endpoint );
372 topLeft, topRight, botLeft, botRight );
379 end_delta.
y = topLeft.
y - rect->
GetEnd().
y;
384 end_delta.
y = botRight.
y - rect->
GetEnd().
y;
390 end_delta.
x = topLeft.
x - rect->
GetEnd().
x;
395 end_delta.
x = botRight.
x - rect->
GetEnd().
x;
420 m_frame->GetPropertiesFrame()->Freeze();
421 m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( dataItem );
422 m_frame->GetPropertiesFrame()->Thaw();
436 switch( item->
Type() )
453 if( topLeft.
y > botRight.
y )
454 std::swap( topLeft.
y, botRight.
y );
456 if( topLeft.
x > botRight.
x )
457 std::swap( topLeft.
x, botRight.
x );
487 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