diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index a85b64527e..1628b8edd5 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -451,6 +451,20 @@ public: return false; } + /** + * Test if \a aPt is an end point of this schematic object. + * + * @note The end point test doe **not** imply electrical connectivity. See IsConnectable(). + * In other words all connection points are end points but not all end points are + * connection points such as graphical lines and arcs. Override this method for all + * objects that have end points. + * + * @param aPt is the coordinate to test for an end point. + * @retval true if \a aPt is an end point. + * @retval false if \a aPt is not an end point. + */ + virtual bool IsEndPoint( const VECTOR2I& aPt ) const { return false; } + virtual bool IsDangling() const { return false; } virtual bool CanConnect( const SCH_ITEM* aItem ) const { return m_layer == aItem->GetLayer(); } diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 6a3a7c6789..57bf4e9fb4 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -87,7 +87,7 @@ public: return false; } - bool IsEndPoint( const VECTOR2I& aPoint ) const + bool IsEndPoint( const VECTOR2I& aPoint ) const override { return aPoint == m_start || aPoint == m_end; } diff --git a/eeschema/sch_screen.cpp b/eeschema/sch_screen.cpp index b8c5d7bf86..57ffbb7d37 100644 --- a/eeschema/sch_screen.cpp +++ b/eeschema/sch_screen.cpp @@ -439,33 +439,21 @@ std::set SCH_SCREEN::MarkConnections( SCH_LINE* aSegment, bool aSecon if( item->GetLayer() != line->GetLayer() ) continue; + // SCH_RTREE::Overlapping() included crossing lines. + if( !item->IsEndPoint( line->GetStartPoint() ) && !item->IsEndPoint( line->GetEndPoint() ) ) + continue; + + to_search.push( line ); + retval.insert( line ); + for( VECTOR2I pt : { line->GetStartPoint(), line->GetEndPoint() } ) { if( item->IsConnected( pt ) ) { SCH_ITEM* junction = GetItem( pt, 0, SCH_JUNCTION_T ); - SCH_ITEM* pin = GetItem( pt, 0, SCH_PIN_T ); - if( item->IsSelected() && aSecondPass ) - { - if( junction ) - retval.insert( junction ); - - retval.insert( line ); - to_search.push( line ); - } - else if( !junction && !pin ) - { - retval.insert( line ); - to_search.push( line ); - } - - break; - } - else if( line->GetLayer() == LAYER_NOTES && item->GetLayer() == LAYER_NOTES ) - { - retval.insert( line ); - to_search.push( line ); + if( aSecondPass && junction ) + retval.insert( junction ); } } } diff --git a/eeschema/sch_screen.h b/eeschema/sch_screen.h index edf13f1ca8..03b4a9ad6a 100644 --- a/eeschema/sch_screen.h +++ b/eeschema/sch_screen.h @@ -299,9 +299,13 @@ public: /** * Return all wires and junctions connected to \a aSegment which are not connected any - * symbol pin. + * symbol pin or all graphical lines connected to \a aSegement. + * + * @note This only works for line segments. It will need to be modified for connected arcs and/or + * Bezier curves. * * @param aSegment The segment to test for connections. + * @return a set of all #SCH_ITEM objects connected to \a aSegment. */ std::set MarkConnections( SCH_LINE* aSegment, bool aSecondPass ); diff --git a/eeschema/sch_shape.cpp b/eeschema/sch_shape.cpp index 7532a90063..c281e3f9ce 100644 --- a/eeschema/sch_shape.cpp +++ b/eeschema/sch_shape.cpp @@ -137,6 +137,17 @@ bool SCH_SHAPE::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) co } +bool SCH_SHAPE::IsEndPoint( const VECTOR2I& aPt ) const +{ + SHAPE_T shape = GetShape(); + + if( ( shape == SHAPE_T::ARC ) || ( shape == SHAPE_T::BEZIER ) ) + return ( aPt == GetStart() ) || ( aPt == GetEnd() ); + + return false; +} + + void SCH_SHAPE::Plot( PLOTTER* aPlotter, bool aBackground, const SCH_PLOT_OPTS& aPlotOpts, int aUnit, int aBodyStyle, const VECTOR2I& aOffset, bool aDimmed ) { diff --git a/eeschema/sch_shape.h b/eeschema/sch_shape.h index 7393c8e83a..4e6bf79930 100644 --- a/eeschema/sch_shape.h +++ b/eeschema/sch_shape.h @@ -50,6 +50,8 @@ public: bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override; bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override; + bool IsEndPoint( const VECTOR2I& aPoint ) const override; + int GetPenWidth() const override { return GetStroke().GetWidth(); } bool HasLineStroke() const override { return true; } diff --git a/eeschema/tools/sch_selection_tool.cpp b/eeschema/tools/sch_selection_tool.cpp index e5aaed3a2d..c29015226e 100644 --- a/eeschema/tools/sch_selection_tool.cpp +++ b/eeschema/tools/sch_selection_tool.cpp @@ -2260,8 +2260,6 @@ int SCH_SELECTION_TOOL::SelectConnection( const TOOL_EVENT& aEvent ) if( m_selection.Empty() ) return 0; - unsigned done = false; - m_frame->GetScreen()->ClearDrawingState(); for( EDA_ITEM* selItem : m_selection.GetItems() ) @@ -2271,26 +2269,10 @@ int SCH_SELECTION_TOOL::SelectConnection( const TOOL_EVENT& aEvent ) SCH_LINE* line = static_cast( selItem ); - std::set conns = m_frame->GetScreen()->MarkConnections( line, false ); + std::set conns = m_frame->GetScreen()->MarkConnections( line, line->IsConnectable() ); + for( SCH_ITEM* item : conns ) - { - if( item->IsType( { SCH_ITEM_LOCATE_WIRE_T, SCH_ITEM_LOCATE_BUS_T, - SCH_ITEM_LOCATE_GRAPHIC_LINE_T } ) - && !item->IsSelected() ) - { - done = true; - } - select( item ); - } - - if( !done ) - { - conns = m_frame->GetScreen()->MarkConnections( line, true ); - - for( SCH_ITEM* item : conns ) - select( item ); - } } if( m_selection.GetSize() > 1 ) @@ -2869,5 +2851,3 @@ void SCH_SELECTION_TOOL::setTransitions() Go( &SCH_SELECTION_TOOL::disambiguateCursor, EVENTS::DisambiguatePoint ); } - -