22using namespace std::placeholders;
25#include <fmt/format.h>
60 std::shared_ptr<EDIT_POINTS> points = std::make_shared<EDIT_POINTS>( aItem );
66 switch( aItem->
Type() )
71 points->AddPoint( line->
GetStart() );
72 points->AddPoint( line->
GetEnd() );
82 if( topLeft.
y > botRight.
y )
83 std::swap( topLeft.
y, botRight.
y );
85 if( topLeft.
x > botRight.
x )
86 std::swap( topLeft.
x, botRight.
x );
88 points->AddPoint( topLeft );
89 points->AddPoint(
VECTOR2I( botRight.
x, topLeft.
y ) );
90 points->AddPoint(
VECTOR2I( topLeft.
x, botRight.
y ) );
91 points->AddPoint( botRight );
168 if( selection.
Size() != 1 || !selection.
Front()->
IsType( { WSG_LINE_T, WSG_RECT_T } ) )
193 bool modified =
false;
212 catch(
const fmt::format_error& exc )
214 wxLogWarning( wxS(
"Exception \"%s\" serializing string ocurred." ),
230 else if( inDrag && evt->IsMouseUp(
BUT_LEFT ) )
236 else if( evt->IsCancelInteractive() || evt->IsActivate() )
244 else if( evt->IsCancelInteractive() )
249 if( evt->IsActivate() && !evt->IsMoveTool() )
274 m_frame->GetCanvas()->Refresh();
284 switch( editedPointIndex )
288 topLeft.
x = std::min( topLeft.
x, botRight.
x - minWidth );
289 topLeft.
y = std::min( topLeft.
y, botRight.
y - minHeight );
292 topRight.
y = topLeft.
y;
293 botLeft.
x = topLeft.
x;
299 topRight.
x = std::max( topRight.
x, botLeft.
x + minWidth );
300 topRight.
y = std::min( topRight.
y, botLeft.
y - minHeight );
303 topLeft.
y = topRight.
y;
304 botRight.
x = topRight.
x;
310 botLeft.
x = std::min( botLeft.
x, topRight.
x - minWidth );
311 botLeft.
y = std::max( botLeft.
y, topRight.
y + minHeight );
314 botRight.
y = botLeft.
y;
315 topLeft.
x = botLeft.
x;
321 botRight.
x = std::max( botRight.
x, topLeft.
x + minWidth );
322 botRight.
y = std::max( botRight.
y, topLeft.
y + minHeight );
325 botLeft.
y = botRight.
y;
326 topRight.
x = botRight.
x;
346 switch( item->
Type() )
363 draw_line->
SetEnd( draw_line->
GetEnd() + move_endpoint );
380 topLeft, topRight, botLeft, botRight );
387 end_delta.
y = topLeft.
y - rect->
GetEnd().
y;
392 end_delta.
y = botRight.
y - rect->
GetEnd().
y;
398 end_delta.
x = topLeft.
x - rect->
GetEnd().
x;
403 end_delta.
x = botRight.
x - rect->
GetEnd().
x;
428 m_frame->GetPropertiesFrame()->Freeze();
429 m_frame->GetPropertiesFrame()->CopyPrmsFromItemToPanel( dataItem );
430 m_frame->GetPropertiesFrame()->Thaw();
444 switch( item->
Type() )
461 if( topLeft.
y > botRight.
y )
462 std::swap( topLeft.
y, botRight.
y );
464 if( topLeft.
x > botRight.
x )
465 std::swap( topLeft.
x, botRight.
x );
495 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.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
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