43 std::function<void(
SCH_ITEM* )> changeHandler =
44 [&](
SCH_ITEM* aChangedItem ) ->
void
59 std::vector<SCH_LINE*> wires;
71 wires.push_back( line );
80 if( !
IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), aStart ) ||
87 if( ( line->GetStartPoint() == aStart && line->GetEndPoint() == aEnd )
88 || ( line->GetStartPoint() == aEnd && line->GetEndPoint() == aStart ) )
96 BreakSegment( aCommit, line, aStart, &new_line, screen );
109 aCommit->
Removed( line, screen );
121 std::vector<SCH_LINE*> lines;
122 std::vector<SCH_JUNCTION*> junctions;
123 std::vector<SCH_NO_CONNECT*> ncs;
124 std::vector<SCH_ITEM*> items_to_remove;
127 if( aScreen ==
nullptr )
130 auto remove_item = [&](
SCH_ITEM* aItem ) ->
void
138 if( aItem->IsSelected() )
142 aCommit->
Removed( aItem, aScreen );
151 items_to_remove.push_back( item );
153 junctions.push_back(
static_cast<SCH_JUNCTION*
>( item ) );
156 for(
SCH_ITEM* item : items_to_remove )
165 if( ( aFirst->GetEditFlags() & STRUCT_DELETED )
166 || ( aSecond->GetEditFlags() & STRUCT_DELETED ) )
172 remove_item( aSecond );
178 if( ( aFirst->GetEditFlags() & STRUCT_DELETED )
179 || ( aSecond->GetEditFlags() & STRUCT_DELETED ) )
185 remove_item( aSecond );
197 lines.push_back(
static_cast<SCH_LINE*
>( item ) );
200 for(
auto it1 = lines.begin(); it1 != lines.end(); ++it1 )
209 remove_item( firstLine );
215 for( ++it2; it2 != lines.end(); ++it2 )
233 remove_item( secondLine );
241 if( mergedLine !=
nullptr )
243 remove_item( firstLine );
244 remove_item( secondLine );
246 AddToScreen( mergedLine, aScreen );
247 aCommit->Added( mergedLine, aScreen );
250 selectionTool->AddItemToSel( mergedLine,
true );
264 aCommit->
Modify( aSegment, aScreen );
272 aCommit->
Added( newSegment, aScreen );
274 *aNewSegment = newSegment;
280 bool brokenSegments =
false;
285 BreakSegment( aCommit, wire, aPos, &new_line, aScreen );
286 brokenSegments =
true;
289 return brokenSegments;
295 bool brokenSegments =
false;
297 std::set<VECTOR2I> point_set;
300 point_set.insert( item->GetPosition() );
306 point_set.insert( entry->
GetEnd() );
309 for(
const VECTOR2I& pt : point_set )
312 brokenSegments =
true;
315 return brokenSegments;
327 aCommit->
Removed( aJunction, screen );
331 std::list<SCH_LINE*> lines;
337 if( line->
IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T } )
341 lines.push_back( line );
348 if( ( firstLine->GetEditFlags() & STRUCT_DELETED )
349 || ( secondLine->GetEditFlags() & STRUCT_DELETED )
350 || !secondLine->IsParallel( firstLine ) )
359 firstLine->SetFlags( STRUCT_DELETED );
366 firstLine->SetFlags( STRUCT_DELETED );
367 secondLine->SetFlags( STRUCT_DELETED );
368 AddToScreen( new_line, screen );
369 aCommit->Added( new_line, screen );
371 if( new_line->IsSelected() )
372 selectionTool->AddItemToSel( new_line, true );
374 lines.push_back( new_line );
382 if( line->IsSelected() )
383 selectionTool->RemoveItemFromSel( line,
true );
385 RemoveFromScreen( line, screen );
386 aCommit->Removed( line, screen );
398 aCommit->
Added( junction, aScreen );
BOX2< Vec > & Merge(const BOX2< Vec > &aRect)
Modify the position and size of the rectangle in order to contain aRect.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Create an undo entry for an item that has been already modified.
COMMIT & Added(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Remove a new item from the model.
COMMIT & Removed(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr)
Modify a given item in the model.
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
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 AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to the screen (and view) aScreen is the screen the item is located on,...
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,...
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.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
bool BreakSegmentsOnJunctions(SCH_COMMIT *aCommit, SCH_SCREEN *aScreen)
Test all junctions and bus entries in the schematic for intersections with wires and buses and breaks...
void SchematicCleanUp(SCH_COMMIT *aCommit, SCH_SCREEN *aScreen=nullptr)
Perform routine schematic cleaning including breaking wire and buses and deleting identical objects s...
bool BreakSegments(SCH_COMMIT *aCommit, const VECTOR2I &aPoint, SCH_SCREEN *aScreen)
Check every wire and bus for a intersection at aPoint and break into two segments at aPoint if an int...
void BreakSegment(SCH_COMMIT *aCommit, SCH_LINE *aSegment, const VECTOR2I &aPoint, SCH_LINE **aNewSegment, SCH_SCREEN *aScreen)
Break a single segment into two at the specified point.
bool TrimWire(SCH_COMMIT *aCommit, const VECTOR2I &aStart, const VECTOR2I &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
void DeleteJunction(SCH_COMMIT *aCommit, SCH_ITEM *aItem)
Removes a given junction and heals any wire segments under the junction.
SCH_JUNCTION * AddJunction(SCH_COMMIT *aCommit, SCH_SCREEN *aScreen, const VECTOR2I &aPos)
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.