46 std::vector<wxPoint> retval;
53 std::vector<wxPoint> pts = item->GetConnectionPoints();
54 retval.insert( retval.end(), pts.begin(), pts.end() );
59 std::sort( retval.begin(), retval.end(),
60 [](
const wxPoint& a,
const wxPoint& b ) ->
bool 61 {
return a.x < b.x || (a.x == b.x && a.y < b.y); } );
63 std::unique( retval.begin(), retval.end() ), retval.end() );
71 std::function<void(
SCH_ITEM* )> changeHandler =
72 [&](
SCH_ITEM* aChangedItem ) ->
void 86 std::vector<SCH_LINE*> wires;
87 EDA_RECT bb( aStart, wxSize( 1, 1 ) );
98 SCH_LINE* line = static_cast<SCH_LINE*>( item );
101 wires.push_back( line );
110 if( !
IsPointOnSegment( line->GetStartPoint(), line->GetEndPoint(), aStart ) ||
117 if( ( line->GetStartPoint() == aStart && line->GetEndPoint() == aEnd )
118 || ( line->GetStartPoint() == aEnd && line->GetEndPoint() == aStart ) )
152 std::vector<SCH_ITEM*> deletedItems;
153 std::vector<SCH_LINE*> lines;
154 std::vector<SCH_JUNCTION*> junctions;
155 std::vector<SCH_NO_CONNECT*> ncs;
158 if( aScreen ==
nullptr )
161 auto remove_item = [&](
SCH_ITEM* aItem ) ->
void 166 deletedItems.push_back( aItem );
176 junctions.push_back( static_cast<SCH_JUNCTION*>( item ) );
181 ncs.push_back( static_cast<SCH_NO_CONNECT*>( item ) );
193 if( aFirst->
GetPosition() == aSecond->GetPosition() )
194 remove_item( aSecond );
206 if( aFirst->
GetPosition() == aSecond->GetPosition() )
207 remove_item( aSecond );
219 lines.push_back( static_cast<SCH_LINE*>( item ) );
222 for(
auto it1 = lines.begin(); it1 != lines.end(); ++it1 )
231 remove_item( firstLine );
237 for( ++it2; it2 != lines.end(); ++it2 )
255 remove_item( secondLine );
263 if( mergedLine !=
nullptr )
265 remove_item( firstLine );
266 remove_item( secondLine );
280 for(
SCH_ITEM* item : deletedItems )
282 if( item->IsSelected() )
298 if( aScreen ==
nullptr )
313 *aNewSegment = newSegment;
323 if( aScreen ==
nullptr )
326 bool brokenSegments =
false;
327 std::vector<SCH_LINE*> wires;
331 if( item->IsType( wiresAndBuses ) )
333 SCH_LINE* wire = static_cast<SCH_LINE*>( item );
338 wires.push_back( wire );
346 return brokenSegments;
352 if( aScreen ==
nullptr )
355 bool brokenSegments =
false;
357 std::set<wxPoint> point_set;
360 point_set.insert( item->GetPosition() );
366 point_set.insert( entry->
GetEnd() );
370 for(
const wxPoint& pt : point_set )
373 return brokenSegments;
384 auto remove_item = [ & ](
SCH_ITEM* aItem ) ->
void 390 remove_item( aJunction );
395 std::list<SCH_LINE*> lines;
399 SCH_LINE* line = static_cast<SCH_LINE*>( item );
403 lines.push_back( line );
411 || !secondLine->IsParallel( firstLine ) )
417 if( firstLine->
IsEndPoint( secondLine->GetStartPoint() )
418 && firstLine->
IsEndPoint( secondLine->GetEndPoint() ) )
420 remove_item( firstLine );
427 remove_item( firstLine );
428 remove_item( secondLine );
432 if( line->IsSelected() )
435 lines.push_back( line );
446 if( line->IsSelected() )
456 bool aUndoAppend,
bool aFinal )
EE_TYPE OfType(KICAD_T aType) const
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
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 SchematicCleanUp(SCH_SCREEN *aScreen=nullptr)
Performs routine schematic cleaning including breaking wire and buses and deleting identical objects ...
void UpdateItem(EDA_ITEM *aItem, bool isAddOrDelete=false)
Mark an item for refresh.
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
void Merge(const EDA_RECT &aRect)
Modify the position and size of the rectangle in order to contain aRect.
bool IsStrokeEquivalent(const SCH_LINE *aLine)
wxPoint GetStartPoint() const
wxPoint GetPosition() const override
bool IsJunctionNeeded(const wxPoint &aPosition, bool aNew=false)
Test if a junction is required for the items at aPosition on the screen.
bool BreakSegments(const wxPoint &aPoint, SCH_SCREEN *aScreen=nullptr)
Checks every wire and bus for a intersection at aPoint and break into two segments at aPoint if an in...
bool BreakSegment(SCH_LINE *aSegment, const wxPoint &aPoint, SCH_LINE **aNewSegment=NULL, SCH_SCREEN *aScreen=nullptr)
Breaks a single segment into two at the specified point.
EE_TYPE Overlapping(const EDA_RECT &aRect)
bool IsPointOnSegment(const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
Test if aTestPoint is on line defined by aSegStart and aSegEnd.
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 PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
virtual wxPoint GetPosition() const
unsigned GetCount() const
search types array terminator (End Of Types)
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.
void SetEndPoint(const wxPoint &aPosition)
SCH_JUNCTION * AddJunction(SCH_SCREEN *aScreen, const wxPoint &aPos, bool aAppendToUndo, bool aFinal=true)
void ShowPreview(bool aShow=true)
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void for_all_pairs(_InputIterator __first, _InputIterator __last, _Function __f)
Apply a function to every possible pair of elements of a sequence.
Item needs to be redrawn.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
wxPoint GetPosition() const override
STATUS_FLAGS GetEditFlags() const
void SetStartPoint(const wxPoint &aPosition)
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
std::vector< wxPoint > GetSchematicConnections()
Collects a unique list of all possible connection points in the schematic.
bool IsEndPoint(const wxPoint &aPoint) const
#define STRUCT_DELETED
flag indication structures to be erased
void TestDanglingEnds(const SCH_SHEET_PATH *aPath=nullptr, std::function< void(SCH_ITEM *)> *aChangedHandler=nullptr)
Test all of the connectable objects in the schematic for unused connection points.
A holder to handle information on schematic or board items.
#define IS_MOVED
Item being moved.
#define IS_DRAGGED
Item being dragged.
SCH_LAYER_ID GetLayer() const
Return the layer this item is on.
bool BreakSegmentsOnJunctions(SCH_SCREEN *aScreen=nullptr)
Tests all junctions and bus entries in the schematic for intersections with wires and buses and break...
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 SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
void DeleteJunction(SCH_ITEM *aItem, bool aAppend=false)
Removes a given junction and heals any wire segments under the junction.
Handle the component boundary box.
A base class for most all the KiCad significant classes used in schematics and boards.
Class for a wire to bus entry.
bool TrimWire(const wxPoint &aStart, const wxPoint &aEnd)
If any single wire passes through both points, remove the portion between the two points,...
bool IsParallel(const SCH_LINE *aLine) const
void OnModify() override
Must be called after a schematic change in order to set the "modify" flag of the current screen and u...
#define SKIP_STRUCT
flag indicating that the structure should be ignored
STATUS_FLAGS GetFlags() const
bool IsType(const KICAD_T aScanTypes[]) const override
Check whether the item is one of the listed types.
Base class for any item which can be embedded within the SCHEMATIC container class,...
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...
wxPoint GetPosition() const override
wxPoint GetEndPoint() const