46 std::function<void(
SCH_ITEM* )> changeHandler =
47 [&](
SCH_ITEM* aChangedItem ) ->
void
62 std::vector<SCH_LINE*> wires;
74 wires.push_back( line );
83 if( !
IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), aStart ) ||
90 if( ( line->GetStartPoint() == aStart && line->GetEndPoint() == aEnd )
91 || ( line->GetStartPoint() == aEnd && line->GetEndPoint() == aStart ) )
125 std::vector<SCH_ITEM*> deletedItems;
126 std::vector<SCH_LINE*> lines;
127 std::vector<SCH_JUNCTION*> junctions;
128 std::vector<SCH_NO_CONNECT*> ncs;
131 if( aScreen ==
nullptr )
134 auto remove_item = [&](
SCH_ITEM* aItem ) ->
void
142 deletedItems.push_back( aItem );
153 junctions.push_back(
static_cast<SCH_JUNCTION*
>( item ) );
164 if( ( aFirst->GetEditFlags() & STRUCT_DELETED )
165 || ( aSecond->GetEditFlags() & STRUCT_DELETED ) )
171 remove_item( aSecond );
177 if( ( aFirst->GetEditFlags() & STRUCT_DELETED )
178 || ( aSecond->GetEditFlags() & STRUCT_DELETED ) )
184 remove_item( aSecond );
196 lines.push_back(
static_cast<SCH_LINE*
>( item ) );
199 for(
auto it1 = lines.begin(); it1 != lines.end(); ++it1 )
208 remove_item( firstLine );
214 for( ++it2; it2 != lines.end(); ++it2 )
232 remove_item( secondLine );
240 if( mergedLine !=
nullptr )
242 remove_item( firstLine );
243 remove_item( secondLine );
246 AddToScreen( mergedLine, aScreen );
249 selectionTool->AddItemToSel( mergedLine,
true );
257 for(
SCH_ITEM* item : deletedItems )
259 if( item->IsSelected() )
260 selectionTool->RemoveItemFromSel( item,
true );
262 RemoveFromScreen( item, aScreen );
265 if( itemList.GetCount() )
268 return itemList.GetCount() > 0;
275 if( aScreen ==
nullptr )
291 *aNewSegment = newSegment;
297 if( aScreen ==
nullptr )
300 bool brokenSegments =
false;
305 brokenSegments =
true;
308 return brokenSegments;
314 if( aScreen ==
nullptr )
317 bool brokenSegments =
false;
319 std::set<VECTOR2I> point_set;
322 point_set.insert( item->GetPosition() );
328 point_set.insert( entry->
GetEnd() );
331 for(
const VECTOR2I& pt : point_set )
334 brokenSegments =
true;
337 return brokenSegments;
354 remove_item( aJunction );
359 std::list<SCH_LINE*> lines;
365 if( line->
IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } )
369 lines.push_back( line );
376 if( ( firstLine->GetEditFlags() & STRUCT_DELETED )
377 || ( secondLine->GetEditFlags() & STRUCT_DELETED )
378 || !secondLine->IsParallel( firstLine ) )
387 remove_item( firstLine );
394 remove_item( firstLine );
395 remove_item( secondLine );
396 undoList.PushItem( ITEM_PICKER( screen, line, UNDO_REDO::NEWITEM ) );
397 AddToScreen( line, screen );
399 if( line->IsSelected() )
400 selectionTool->AddItemToSel( line, true );
402 lines.push_back( line );
412 if( line->IsSelected() )
413 selectionTool->RemoveItemFromSel( line,
true );
415 RemoveFromScreen( line, screen );
422 bool aUndoAppend,
bool aFinal )
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
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)
EDA_ITEM_FLAGS GetFlags() const
EE_TYPE Overlapping(const BOX2I &aRect) const
EE_TYPE OfType(KICAD_T aType) const
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
void ShowPreview(bool aShow=true)
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...
A holder to handle information on schematic or board items.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
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,...
VECTOR2I GetPosition() const override
Class for a wire to bus entry.
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
bool SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
void DeleteJunction(SCH_ITEM *aItem, bool aAppend=false)
Removes a given junction and heals any wire segments under the junction.
bool TrimWire(const VECTOR2I &aStart, const VECTOR2I &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag and update other data struc...
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
bool BreakSegments(const VECTOR2I &aPoint, SCH_SCREEN *aScreen=nullptr)
Check every wire and bus for a intersection at aPoint and break into two segments at aPoint if an int...
bool BreakSegmentsOnJunctions(SCH_SCREEN *aScreen=nullptr)
Test all junctions and bus entries in the schematic for intersections with wires and buses and breaks...
void BreakSegment(SCH_LINE *aSegment, const VECTOR2I &aPoint, SCH_LINE **aNewSegment=nullptr, SCH_SCREEN *aScreen=nullptr)
Break a single segment into two at the specified point.
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false, bool aUpdateRtree=false) override
Mark an item for refresh.
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const VECTOR2I &aPos, bool aAppendToUndo, bool aFinal=true)
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
VECTOR2I GetPosition() const override
Segment description base class to describe items which have 2 end points (track, wire,...
bool IsParallel(const SCH_LINE *aLine) const
VECTOR2I GetEndPoint() const
VECTOR2I GetStartPoint() const
SCH_LINE * MergeOverlap(SCH_SCREEN *aScreen, SCH_LINE *aLine, bool aCheckJunctions)
Check line against aLine to see if it overlaps and merge if it does.
bool IsEndPoint(const VECTOR2I &aPoint) const
bool IsStrokeEquivalent(const SCH_LINE *aLine)
SCH_LINE * BreakAt(const VECTOR2I &aPoint)
Break this segment into two at the specified point.
bool IsType(const std::vector< KICAD_T > &aScanTypes) const override
Check whether the item is one of the listed types.
VECTOR2I GetPosition() const override
void TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr, std::function< void(SCH_ITEM *)> *aChangedHandler=nullptr) const
Test all of the connectable objects in the schematic for unused connection points.
std::vector< SCH_LINE * > GetBusesAndWires(const VECTOR2I &aPosition, bool aIgnoreEndpoints=false) const
Return buses and wires passing through aPosition.
bool IsExplicitJunction(const VECTOR2I &aPosition) const
Indicates that a junction dot is necessary at the given location.
EE_RTREE & Items()
Gets the full RTree, usually for iterating.
#define IS_CHANGED
Item was edited, and modified.
#define IS_NEW
New item, just created.
#define IS_BROKEN
Is a segment just broken by BreakSegment.
#define STRUCT_DELETED
flag indication structures to be erased
#define SKIP_STRUCT
flag indicating that the structure should be ignored
#define IS_MOVING
Item being moved.
@ REPAINT
Item needs to be redrawn.
void for_all_pairs(_InputIterator __first, _InputIterator __last, _Function __f)
Apply a function to every possible pair of elements of a sequence.
bool IsPointOnSegment(const VECTOR2I &aSegStart, const VECTOR2I &aSegEnd, const VECTOR2I &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.