44 #define QUIET_MODE true 49 m_moveInProgress( false ),
50 m_isDragOperation( false ),
112 if( sel && !sel->IsNew() )
120 controls->SetAutoPan(
false );
133 bool unselect = selection.
IsHover();
136 std::vector<DANGLING_END_ITEM> internalPoints;
139 controls->ShowCursor(
true );
144 if( selection.
Empty() )
152 bool restore_state =
false;
153 bool chain_commands =
false;
154 TOOL_EVENT* evt = const_cast<TOOL_EVENT*>( &aEvent );
158 m_cursor = controls->GetCursorPosition();
178 bool appendUndo = sch_item && sch_item->
IsNew();
179 bool placingNewItems = sch_item && sch_item->
IsNew();
186 internalPoints.clear();
192 if( !it->IsSelected() )
195 if( !selection.
IsHover() && it->IsSelected() )
203 for(
EDA_ITEM* edaItem : selection )
205 SCH_ITEM* item = static_cast<SCH_ITEM*>( edaItem );
206 std::vector<wxPoint> connections;
209 static_cast<SCH_LINE*>( item )->GetSelectedPoints( connections );
213 for( wxPoint point : connections )
223 static_cast<SCH_ITEM*>( item )->GetEndPoints( internalPoints );
226 static_cast<SCH_ITEM*>( item )->UpdateDanglingState( internalPoints );
232 if( static_cast<SCH_ITEM*>( item )->IsConnectable() )
261 else if( item->GetParent() && item->GetParent()->IsSelected() )
277 m_cursor = controls->GetCursorPosition();
281 wxASSERT_MSG(
m_anchorPos,
"Should be already set from previous cmd" );
283 else if( placingNewItems )
296 if( item->GetParent() && item->GetParent()->IsSelected() )
326 controls->SetCursorPosition(
m_cursor,
false );
330 controls->SetAutoPan(
true );
338 snapLayer, selection );
349 if( item->GetParent() && item->GetParent()->IsSelected() )
367 restore_state =
true;
394 restore_state =
true;
396 chain_commands =
true;
435 }
while( ( evt =
Wait() ) );
437 controls->ForceCursorPosition(
false );
438 controls->ShowCursor(
false );
439 controls->SetAutoPan(
false );
441 if( !chain_commands )
447 item->ClearEditFlags();
496 bool ptHasUnselectedJunction =
false;
498 for(
SCH_ITEM* item : itemsOverlapping )
500 if( item->Type() ==
SCH_JUNCTION_T && item->IsConnected( aPoint ) && !item->IsSelected() )
502 ptHasUnselectedJunction =
true;
509 if(
test == aOriginalItem ||
test->IsSelected() || !
test->CanConnect( aOriginalItem ) )
520 if( ptHasUnselectedJunction )
528 aList.push_back( testLine );
535 aList.push_back( testLine );
547 for(
SCH_ITEM* item : itemsOverlapping )
551 SCH_TEXT* label = static_cast<SCH_TEXT*>( item );
560 aList.push_back( label );
580 if(
test->IsConnected( aPoint ) )
595 aList.push_back( newWire );
603 aList.push_back(
test );
621 std::vector<wxPoint> connections =
test->GetConnectionPoints();
623 for( wxPoint& point : connections )
625 if( aOriginalItem->
HitTest( point, 1 ) )
628 aList.push_back(
test );
633 std::vector<wxPoint> ends =
test->GetConnectionPoints();
636 if( ends[0] == point )
659 switch( aItem->
Type() )
663 SCH_LINE* line = static_cast<SCH_LINE*>( aItem );
669 line->
MoveEnd( (wxPoint) aDelta );
678 wxPoint delta( aDelta );
688 static_cast<SCH_ITEM*>( aItem )->Move( delta );
705 SCH_TEXT* label = static_cast<SCH_TEXT*>( aItem );
715 label->
Move( (wxPoint) aDelta );
721 static_cast<SCH_ITEM*>( aItem )->Move( (wxPoint) aDelta );
734 bool append_undo =
false;
738 if( !it->IsSelected() )
741 if( !selection.
IsHover() && it->IsSelected() )
744 it->SetStoredPos( it->GetPosition() );
748 for(
SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( it )->GetPins() )
749 pin->SetStoredPos( pin->GetPosition() );
757 SCH_LINE* line = static_cast<SCH_LINE*>( item );
761 for(
int ii = 0; ii < 2; ++ii )
767 std::set<EDA_ITEM*> unique_items( drag_items.begin(), drag_items.end() );
773 for(
EDA_ITEM* dragItem : unique_items )
775 if( dragItem->GetParent() && dragItem->GetParent()->IsSelected() )
802 std::vector<wxPoint> connections;
804 connections = static_cast<SCH_ITEM*>( item )->GetConnectionPoints();
806 for(
const wxPoint& point : connections )
809 std::map<VECTOR2I, int> shifts;
813 for(
const wxPoint& conn : connections )
819 if( shifts[gridpt] > max_count )
821 most_common = gridpt;
822 max_count = shifts[most_common];
826 if( most_common !=
VECTOR2I( 0, 0 ) )
828 for(
EDA_ITEM* dragItem : drag_items )
830 if( dragItem->GetParent() && dragItem->GetParent()->IsSelected() )
static TOOL_ACTION moveActivate
void Hide(VIEW_ITEM *aItem, bool aHide=true)
Temporarily hide the item in the view (e.g.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
virtual std::vector< wxPoint > GetConnectionPoints() const
Add all the connection points for this item to aPoints.
wxPoint GetStartPoint() const
static TOOL_ACTION doDelete
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
static TOOL_ACTION restartMove
void MoveStart(const wxPoint &aMoveVector)
EE_TYPE Overlapping(const EDA_RECT &aRect)
VECTOR2I BestSnapAnchor(const VECTOR2I &aOrigin, int aLayer, SCH_ITEM *aDraggedItem)
Schematic editor (Eeschema) main window.
EE_RTREE - Implements an R-tree for fast spatial and type indexing of schematic items.
virtual wxPoint GetPosition() const
static const KICAD_T MovableItems[]
static TOOL_ACTION alignToGrid
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
#define TEMP_SELECTED
flag indicating that the structure has already selected
void SetCurrentCursor(KICURSOR cursor)
Set the current cursor shape for this panel.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const wxPoint &aPos, bool aAppendToUndo, bool aFinal=true)
VECTOR2I BestDragOrigin(const VECTOR2I &aMousePos, int aLayer, const EE_SELECTION &aItems)
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const
Test if aPosition is contained within or on the bounding box of an item.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
virtual bool CanConnect(const SCH_ITEM *aItem) const
void Move(const wxPoint &aMoveVector) override
Move the item by aMoveVector to a new position.
void SetFlags(STATUS_FLAGS aMask)
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
virtual bool IsMovableFromAnchorPoint() const
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void ClearFieldsAutoplaced()
Set fields automatically placed flag false.
EDA_ITEM * GetParent() const
An interface for classes handling user events controlling the view behavior such as zooming,...
static const TOOL_EVENT SelectedItemsMoved
Used to inform tools that the selection should temporarily be non-editable.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
std::vector< EDA_ITEM * > EDA_ITEMS
Define list of drawing items for screens.
static TOOL_ACTION clearSelection
Clears the current selection.
TRANSFORM & GetTransform()
static TOOL_ACTION addNeededJunctions
void ConstrainOnEdge(wxPoint Pos)
Adjust label position to edge based on proximity to vertical or horizontal edge of the parent sheet.
wxPoint GetPosition() const override
#define IS_MOVED
Item being moved.
void SelectUnit(SCH_COMPONENT *aComponent, int aUnit)
bool Empty() const
Checks if there is anything selected.
#define STARTPOINT
When a line is selected, these flags indicate which.
void SetUseGrid(bool aSnapToGrid)
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
Segment description base class to describe items which have 2 end points (track, wire,...
void MoveEnd(const wxPoint &aMoveVector)
void RollbackSchematicFromUndo()
Performs an undo of the last edit WITHOUT logging a corresponding redo.
static SELECTION_CONDITION OnlyType(KICAD_T aType)
Create a functor that tests if the selected items are only of given type.
The EE_TYPE struct provides a type-specific auto-range iterator to the RTree.
A base class for most all the KiCad significant classes used in schematics and boards.
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
#define ENDPOINT
ends. (Used to support dragging.)
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
Helper class used to store the state of schematic items that can be connected to other schematic item...
virtual const EDA_RECT GetBoundingBox() const
Return the orthogonal bounding box of this object for display purposes.
void SetPosition(const wxPoint &aPosition) override
void SetStoredPos(wxPoint aPos)
Base class for any item which can be embedded within the SCHEMATIC container class,...
#define IS_NEW
New item, just created.
static TOOL_ACTION duplicate
bool HasFlag(STATUS_FLAGS aFlag) const
static TOOL_ACTION refreshPreview
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
KICAD_T Type() const
Returns the type of object.
VECTOR2I AlignGrid(const VECTOR2I &aPoint) const
wxPoint GetEndPoint() const