41 m_moveInProgress( false )
61 if( !
editor->IsSymbolEditable() )
64 if(
editor->IsSymbolAlias() )
109 localCommit.
Push(
_(
"Move" ) );
130 bool unselect = selection.
IsHover();
149 bool restore_state =
false;
182 std::set<SCH_PIN*> sync_pins;
184 for(
EDA_ITEM* sel_item : selection )
186 lib_item =
static_cast<SCH_ITEM*
>( sel_item );
192 std::vector<bool> got_unit( symbol->
GetUnitCount() + 1 );
194 got_unit[cur_pin->
GetUnit()] =
true;
198 if( !got_unit[
pin->GetUnit()]
205 if( sync_pins.insert(
pin ).second )
206 got_unit[
pin->GetUnit()] =
true;
225 if( lib_item->
IsNew() )
241 VECTOR2I itemPos = selection.GetTopLeftItem()->GetPosition();
264 grid.GetSelectionGrid( selection ), selection );
287 restore_state =
true;
340 restore_state =
true;
343 catch(
const boost::bad_pointer& e )
345 restore_state =
true;
346 wxFAIL_MSG( wxString::Format( wxT(
"Boost pointer exception occurred: %s" ),
358 }
while( ( evt =
Wait() ) );
367 item->ClearEditFlags();
375 return !restore_state;
397 VECTOR2I newStart =
grid.AlignGrid( shape->GetStart(),
grid.GetItemGrid( shape ) );
398 VECTOR2I newEnd =
grid.AlignGrid( shape->GetEnd(),
grid.GetItemGrid( shape ) );
400 switch( shape->GetShape() )
402 case SHAPE_T::SEGMENT:
403 case SHAPE_T::RECTANGLE:
404 case SHAPE_T::CIRCLE:
406 if( newStart == newEnd ||
407 shape->GetShape() == SHAPE_T::CIRCLE || shape->GetShape() == SHAPE_T::ARC )
411 if( newStart != shape->GetStart() )
412 doMoveItem( shape, newStart - shape->GetStart() );
414 else if( newStart != shape->GetStart() || newEnd != shape->GetEnd() )
419 shape->SetStart( newStart );
420 shape->SetEnd( newEnd );
428 if( shape->GetPointCount() > 0 )
430 std::vector<VECTOR2I> newPts;
432 for(
const VECTOR2I& pt : shape->GetPolyShape().Outline( 0 ).CPoints() )
433 newPts.push_back(
grid.AlignGrid( pt,
grid.GetItemGrid( shape ) ) );
435 bool collapsed =
false;
437 for(
int ii = 0; ii < (int) newPts.size() - 1; ++ii )
439 if( newPts[ii] == newPts[ii + 1] )
446 if( newStart != shape->GetStart() )
447 doMoveItem( shape, newStart - shape->GetStart() );
453 for(
int ii = 0; ii < (int) newPts.size(); ++ii )
454 shape->GetPolyShape().Outline( 0 ).SetPoint( ii, newPts[ii] );
462 case SHAPE_T::BEZIER:
465 if( newStart != shape->GetStart() )
466 doMoveItem( shape, newStart - shape->GetStart() );
470 case SHAPE_T::UNDEFINED:
471 wxASSERT_MSG(
false, wxT(
"Undefined shape in AlignElements" ) );
481 doMoveItem( item,
delta );
485 int length =
pin->GetLength();
488 if(
pin->GetOrientation() == PIN_ORIENTATION::PIN_LEFT
489 ||
pin->GetOrientation() == PIN_ORIENTATION::PIN_RIGHT )
498 int newLength =
KiROUND( (
double) length / pinGrid ) * pinGrid;
501 pin->SetLength( newLength );
508 commit.
Push(
_(
"Align" ) );
515 static_cast<SCH_ITEM*
>( aItem )->Move( aDelta );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
static TOOL_ACTION duplicate
static TOOL_ACTION doDelete
static TOOL_ACTION cursorClick
static TOOL_ACTION refreshPreview
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
void SetCurrentCursor(KICURSOR aCursor)
Set the current cursor shape for this panel.
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
EDA_ITEM_FLAGS GetEditFlags() const
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
static TOOL_ACTION alignToGrid
static TOOL_ACTION clearSelection
Clears the current selection.
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
An interface for classes handling user events controlling the view behavior such as zooming,...
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.
virtual void WarpMouseCursor(const VECTOR2D &aPosition, bool aWorldCoordinates=false, bool aWarpView=false)=0
If enabled (.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual void SetCursorPosition(const VECTOR2D &aPosition, bool aWarpView=true, bool aTriggeredByArrows=false, long aArrowCommand=0)=0
Move cursor to the requested position expressed in world coordinates.
virtual void SetAutoPan(bool aEnabled)
Turn on/off auto panning (this feature is used when there is a tool active (eg.
Define a library symbol object.
std::vector< SCH_PIN * > GetAllLibPins() const
Return a list of pin pointers for all units / converts.
int GetUnitCount() const override
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual void Push(const wxString &aMessage=wxT("A commit"), int aCommitFlags=0) override
Revert the commit by restoring the modified items state.
virtual void Revert() override
Base class for any item which can be embedded within the SCHEMATIC container class,...
const wxString & GetName() const
PIN_ORIENTATION GetOrientation() const
VECTOR2I GetPosition() const override
ELECTRICAL_PINTYPE GetType() const
static bool IdleSelection(const SELECTION &aSelection)
Test if all selected items are not being edited.
virtual unsigned int GetSize() const override
Return the number of stored items.
bool Empty() const
Checks if there is anything selected.
The symbol library editor main window.
bool IsSymbolAlias() const
Return true if aLibId is an alias for the editor screen symbol.
bool IsSymbolEditable() const
Test if a symbol is loaded and can be edited.
LIB_SYMBOL * GetCurSymbol() const
Return the current symbol being edited or NULL if none selected.
#define IS_PASTED
Modifier on IS_NEW which indicates it came from clipboard.
#define IS_MOVING
Item being moved.
VECTOR2< int32_t > VECTOR2I