From 02a5d47de95f07bd963908aa5cc895f015e9e9d4 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 8 Sep 2020 06:27:13 -0700 Subject: [PATCH] Avoid passing references in EESchema This returns the connection list by value. This allows easier Python use Also renames m_End() to GetEnd() --- eeschema/bus-wire-junction.cpp | 19 ++++++++---- eeschema/connection_graph.cpp | 3 +- eeschema/sch_bus_entry.cpp | 35 +++++++++++------------ eeschema/sch_bus_entry.h | 4 +-- eeschema/sch_component.cpp | 8 ++++-- eeschema/sch_component.h | 2 +- eeschema/sch_edit_frame.cpp | 3 +- eeschema/sch_edit_frame.h | 4 +-- eeschema/sch_item.h | 2 +- eeschema/sch_junction.cpp | 4 +-- eeschema/sch_junction.h | 2 +- eeschema/sch_legacy_plugin.cpp | 4 +-- eeschema/sch_line.cpp | 5 ++-- eeschema/sch_line.h | 2 +- eeschema/sch_no_connect.cpp | 4 +-- eeschema/sch_no_connect.h | 2 +- eeschema/sch_painter.cpp | 4 +-- eeschema/sch_sexpr_plugin.cpp | 2 +- eeschema/sch_sheet.cpp | 8 ++++-- eeschema/sch_sheet.h | 2 +- eeschema/sch_text.cpp | 6 ++-- eeschema/sch_text.h | 2 +- eeschema/tools/sch_edit_tool.cpp | 11 +++---- eeschema/tools/sch_line_wire_bus_tool.cpp | 25 +++++++--------- eeschema/tools/sch_move_tool.cpp | 9 ++---- qa/eeschema/test_sch_sheet.cpp | 3 +- 26 files changed, 90 insertions(+), 85 deletions(-) diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 4ccdacbdb0..79542ac533 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -42,21 +42,28 @@ #include -void SCH_EDIT_FRAME::GetSchematicConnections( std::vector< wxPoint >& aConnections ) +std::vector SCH_EDIT_FRAME::GetSchematicConnections() { + std::vector retval; + for( auto item : GetScreen()->Items() ) { // Avoid items that are changing if( !( item->GetEditFlags() & ( IS_DRAGGED | IS_MOVED | IS_DELETED ) ) ) - item->GetConnectionPoints( aConnections ); + { + std::vector pts = item->GetConnectionPoints(); + retval.insert( retval.end(), pts.begin(), pts.end() ); + } } // We always have some overlapping connection points. Drop duplicates here - std::sort( aConnections.begin(), aConnections.end(), + std::sort( retval.begin(), retval.end(), []( const wxPoint& a, const wxPoint& b ) -> bool { return a.x < b.x || (a.x == b.x && a.y < b.y); } ); - aConnections.erase( - std::unique( aConnections.begin(), aConnections.end() ), aConnections.end() ); + retval.erase( + std::unique( retval.begin(), retval.end() ), retval.end() ); + + return retval; } @@ -357,7 +364,7 @@ bool SCH_EDIT_FRAME::BreakSegmentsOnJunctions( SCH_SCREEN* aScreen ) { SCH_BUS_WIRE_ENTRY* entry = static_cast( item ); point_set.insert( entry->GetPosition() ); - point_set.insert( entry->m_End() ); + point_set.insert( entry->GetEnd() ); } diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 0aaaf8b2aa..b33444bb2f 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -448,8 +448,7 @@ void CONNECTION_GRAPH::updateItemConnectivity( const SCH_SHEET_PATH& aSheet, for( SCH_ITEM* item : aItemList ) { - std::vector< wxPoint > points; - item->GetConnectionPoints( points ); + std::vector< wxPoint > points = item->GetConnectionPoints(); item->ConnectedItems( aSheet ).clear(); if( item->Type() == SCH_SHEET_T ) diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index ce5e2d000c..5cc748e5be 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -80,11 +80,11 @@ EDA_ITEM* SCH_BUS_BUS_ENTRY::Clone() const bool SCH_BUS_ENTRY_BASE::doIsConnected( const wxPoint& aPosition ) const { - return ( m_pos == aPosition || m_End() == aPosition ); + return ( m_pos == aPosition || GetEnd() == aPosition ); } -wxPoint SCH_BUS_ENTRY_BASE::m_End() const +wxPoint SCH_BUS_ENTRY_BASE::GetEnd() const { return wxPoint( m_pos.x + m_size.x, m_pos.y + m_size.y ); } @@ -114,7 +114,7 @@ const EDA_RECT SCH_BUS_ENTRY_BASE::GetBoundingBox() const EDA_RECT box; box.SetOrigin( m_pos ); - box.SetEnd( m_End() ); + box.SetEnd( GetEnd() ); box.Normalize(); box.Inflate( ( GetPenWidth() / 2 ) + 1 ); @@ -178,7 +178,7 @@ void SCH_BUS_WIRE_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemLi DANGLING_END_ITEM item( WIRE_ENTRY_END, this, m_pos ); aItemList.push_back( item ); - DANGLING_END_ITEM item1( WIRE_ENTRY_END, this, m_End() ); + DANGLING_END_ITEM item1( WIRE_ENTRY_END, this, GetEnd() ); aItemList.push_back( item1 ); } @@ -188,7 +188,7 @@ void SCH_BUS_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemLis DANGLING_END_ITEM item( BUS_ENTRY_END, this, m_pos ); aItemList.push_back( item ); - DANGLING_END_ITEM item1( BUS_ENTRY_END, this, m_End() ); + DANGLING_END_ITEM item1( BUS_ENTRY_END, this, GetEnd() ); aItemList.push_back( item1 ); } @@ -200,8 +200,8 @@ void SCH_BUS_ENTRY_BASE::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffs aSettings->GetLayerColor( m_Layer ) : GetStrokeColor(); int penWidth = ( GetPenWidth() == 0 ) ? aSettings->GetDefaultPenWidth() : GetPenWidth(); - GRLine( nullptr, DC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, m_End().x + aOffset.x, - m_End().y + aOffset.y, penWidth, color, + GRLine( nullptr, DC, m_pos.x + aOffset.x, m_pos.y + aOffset.y, GetEnd().x + aOffset.x, + GetEnd().y + aOffset.y, penWidth, color, GetwxPenStyle( (PLOT_DASH_TYPE) GetStrokeStyle() ) ); } @@ -255,7 +255,7 @@ bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector& aI case WIRE_END_END: if( m_pos == each_item.GetPosition() ) has_wire[0] = true; - else if( m_End() == each_item.GetPosition() ) + else if( GetEnd() == each_item.GetPosition() ) has_wire[1] = true; break; @@ -267,7 +267,7 @@ bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector& aI case BUS_END_END: if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_pos ) ) has_bus[0] = true; - else if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_End() ) ) + else if( IsPointOnSegment( seg_start, each_item.GetPosition(), GetEnd() ) ) has_bus[1] = true; break; @@ -316,7 +316,7 @@ bool SCH_BUS_BUS_ENTRY::UpdateDanglingState( std::vector& aIt case BUS_END_END: if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_pos ) ) m_isDanglingStart = false; - if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_End() ) ) + if( IsPointOnSegment( seg_start, each_item.GetPosition(), GetEnd() ) ) m_isDanglingEnd = false; break; default: @@ -334,10 +334,9 @@ bool SCH_BUS_ENTRY_BASE::IsDangling() const } -void SCH_BUS_ENTRY_BASE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const +std::vector SCH_BUS_ENTRY_BASE::GetConnectionPoints() const { - aPoints.push_back( m_pos ); - aPoints.push_back( m_End() ); + return { m_pos, GetEnd() }; } @@ -371,7 +370,7 @@ bool SCH_BUS_ENTRY_BASE::HitTest( const wxPoint& aPosition, int aAccuracy ) cons if( aAccuracy == 0 ) aAccuracy = ( GetPenWidth() / 2 ) + 4; - return TestSegmentHit( aPosition, m_pos, m_End(), aAccuracy ); + return TestSegmentHit( aPosition, m_pos, GetEnd(), aAccuracy ); } @@ -400,7 +399,7 @@ void SCH_BUS_ENTRY_BASE::Plot( PLOTTER* aPlotter ) aPlotter->SetColor( color ); aPlotter->SetDash( GetStrokeStyle() ); aPlotter->MoveTo( m_pos ); - aPlotter->FinishTo( m_End() ); + aPlotter->FinishTo( GetEnd() ); } @@ -443,10 +442,10 @@ bool SCH_BUS_ENTRY_BASE::operator <( const SCH_ITEM& aItem ) const if( GetPosition().y != component->GetPosition().y ) return GetPosition().y < component->GetPosition().y; - if( m_End().x != component->m_End().x ) - return m_End().x < component->m_End().x; + if( GetEnd().x != component->GetEnd().x ) + return GetEnd().x < component->GetEnd().x; - return m_End().y < component->m_End().y; + return GetEnd().y < component->GetEnd().y; } diff --git a/eeschema/sch_bus_entry.h b/eeschema/sch_bus_entry.h index 9942677171..c79f9db8a7 100644 --- a/eeschema/sch_bus_entry.h +++ b/eeschema/sch_bus_entry.h @@ -66,7 +66,7 @@ public: */ bool IsMovableFromAnchorPoint() override { return false; } - wxPoint m_End() const; + wxPoint GetEnd() const; wxSize GetSize() const { return m_size; } @@ -105,7 +105,7 @@ public: bool IsConnectable() const override { return true; } - void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; + std::vector GetConnectionPoints() const override; wxPoint GetPosition() const override { return m_pos; } void SetPosition( const wxPoint& aPosition ) override { m_pos = aPosition; } diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index e600d6f655..51d38886d0 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1541,8 +1541,10 @@ wxPoint SCH_COMPONENT::GetPinPhysicalPosition( const LIB_PIN* Pin ) const } -void SCH_COMPONENT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const +std::vector SCH_COMPONENT::GetConnectionPoints() const { + std::vector retval; + for( const std::unique_ptr& pin : m_pins ) { // Collect only pins attached to the current unit and convert. @@ -1556,8 +1558,10 @@ void SCH_COMPONENT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const if( pin_convert > 0 && pin_convert != GetConvert() ) continue; - aPoints.push_back( m_transform.TransformCoordinate( pin->GetLocalPosition() ) + m_Pos ); + retval.push_back( m_transform.TransformCoordinate( pin->GetLocalPosition() ) + m_Pos ); } + + return retval; } diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 26dd966ed2..050fbdcf7c 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -628,7 +628,7 @@ public: */ bool IsInNetlist() const; - void GetConnectionPoints( std::vector& aPoints ) const override; + std::vector GetConnectionPoints() const override; SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override; diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 3590cf14cd..7773edca14 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1070,8 +1070,7 @@ void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_SCREEN* aScreen, SCH_ITEM* if( !aItem->IsMoving() && aItem->IsConnectable() ) { - std::vector< wxPoint > pts; - aItem->GetConnectionPoints( pts ); + std::vector< wxPoint > pts = aItem->GetConnectionPoints(); for( auto i = pts.begin(); i != pts.end(); i++ ) { diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 7a4838a23d..7d6cbee2a4 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -573,9 +573,9 @@ public: /** * Collects a unique list of all possible connection points in the schematic. * - * @param aConnections vector of connections + * @return vector of connections */ - void GetSchematicConnections( std::vector< wxPoint >& aConnections ); + std::vector GetSchematicConnections(); void OnOpenPcbnew( wxCommandEvent& event ); void OnOpenCvpcb( wxCommandEvent& event ); diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index c03dc13464..f284b1f2ad 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -383,7 +383,7 @@ public: * * @param aPoints List of connection points to add to. */ - virtual void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const { } + virtual std::vector GetConnectionPoints() const { return {}; } /** * Clears all of the connection items from the list. diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index c427e97e5d..de5342e452 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -139,9 +139,9 @@ void SCH_JUNCTION::GetEndPoints( std::vector & aItemList ) } -void SCH_JUNCTION::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const +std::vector SCH_JUNCTION::GetConnectionPoints() const { - aPoints.push_back( m_pos ); + return { m_pos }; } diff --git a/eeschema/sch_junction.h b/eeschema/sch_junction.h index 5474d59f87..c5104dd9a3 100644 --- a/eeschema/sch_junction.h +++ b/eeschema/sch_junction.h @@ -76,7 +76,7 @@ public: bool IsConnectable() const override { return true; } - void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; + std::vector GetConnectionPoints() const override; bool CanConnect( const SCH_ITEM* aItem ) const override { diff --git a/eeschema/sch_legacy_plugin.cpp b/eeschema/sch_legacy_plugin.cpp index 4c44116f11..a9b66a023e 100644 --- a/eeschema/sch_legacy_plugin.cpp +++ b/eeschema/sch_legacy_plugin.cpp @@ -2263,12 +2263,12 @@ void SCH_LEGACY_PLUGIN::saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry ) m_out->Print( 0, "Entry Wire Line\n\t%-4d %-4d %-4d %-4d\n", Iu2Mils( aBusEntry->GetPosition().x ), Iu2Mils( aBusEntry->GetPosition().y ), - Iu2Mils( aBusEntry->m_End().x ), Iu2Mils( aBusEntry->m_End().y ) ); + Iu2Mils( aBusEntry->GetEnd().x ), Iu2Mils( aBusEntry->GetEnd().y ) ); else m_out->Print( 0, "Entry Bus Bus\n\t%-4d %-4d %-4d %-4d\n", Iu2Mils( aBusEntry->GetPosition().x ), Iu2Mils( aBusEntry->GetPosition().y ), - Iu2Mils( aBusEntry->m_End().x ), Iu2Mils( aBusEntry->m_End().y ) ); + Iu2Mils( aBusEntry->GetEnd().x ), Iu2Mils( aBusEntry->GetEnd().y ) ); } diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index a5dcf47123..1f501316bb 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -601,10 +601,9 @@ bool SCH_LINE::CanConnect( const SCH_ITEM* aItem ) const } -void SCH_LINE::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const +std::vector SCH_LINE::GetConnectionPoints() const { - aPoints.push_back( m_start ); - aPoints.push_back( m_end ); + return { m_start, m_end }; } diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index 843305ab1b..97a603f79b 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -197,7 +197,7 @@ public: bool IsConnectable() const override; - void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; + std::vector GetConnectionPoints() const override; void GetSelectedPoints( std::vector< wxPoint >& aPoints ) const; diff --git a/eeschema/sch_no_connect.cpp b/eeschema/sch_no_connect.cpp index 8ae8875c60..b0839f4b68 100644 --- a/eeschema/sch_no_connect.cpp +++ b/eeschema/sch_no_connect.cpp @@ -135,9 +135,9 @@ void SCH_NO_CONNECT::Rotate( wxPoint aPosition ) } -void SCH_NO_CONNECT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const +std::vector SCH_NO_CONNECT::GetConnectionPoints() const { - aPoints.push_back( m_pos ); + return { m_pos }; } diff --git a/eeschema/sch_no_connect.h b/eeschema/sch_no_connect.h index 0ddeacbef8..31c2aeb496 100644 --- a/eeschema/sch_no_connect.h +++ b/eeschema/sch_no_connect.h @@ -94,7 +94,7 @@ public: aItem->Type() == SCH_COMPONENT_T; } - void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; + std::vector GetConnectionPoints() const override; wxString GetSelectMenuText( EDA_UNITS aUnits ) const override { diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index ce94aa879e..b3ab06d41c 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -1722,7 +1722,7 @@ void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer ) line.SetBrightened(); line.SetStartPoint( aEntry->GetPosition() ); - line.SetEndPoint( aEntry->m_End() ); + line.SetEndPoint( aEntry->GetEnd() ); line.SetStroke( aEntry->GetStroke() ); COLOR4D color = getRenderColor( aEntry, LAYER_WIRE, drawingShadows ); @@ -1744,7 +1744,7 @@ void SCH_PAINTER::draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer ) aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) ); if( aEntry->IsDanglingEnd() ) - m_gal->DrawCircle( aEntry->m_End(), + m_gal->DrawCircle( aEntry->GetEnd(), aEntry->GetPenWidth() + ( TARGET_BUSENTRY_RADIUS / 2 ) ); } diff --git a/eeschema/sch_sexpr_plugin.cpp b/eeschema/sch_sexpr_plugin.cpp index 37fcfb5653..85fc74c6ee 100644 --- a/eeschema/sch_sexpr_plugin.cpp +++ b/eeschema/sch_sexpr_plugin.cpp @@ -1113,7 +1113,7 @@ void SCH_SEXPR_PLUGIN::saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry, int aNestLev { SCH_LINE busEntryLine( aBusEntry->GetPosition(), LAYER_BUS ); - busEntryLine.SetEndPoint( aBusEntry->m_End() ); + busEntryLine.SetEndPoint( aBusEntry->GetEnd() ); saveLine( &busEntryLine, aNestLevel ); } else diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 8e9ed997dd..b11716862d 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -855,10 +855,14 @@ bool SCH_SHEET::UpdateDanglingState( std::vector& aItemList, } -void SCH_SHEET::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const +std::vector SCH_SHEET::GetConnectionPoints() const { + std::vector retval; + for( SCH_SHEET_PIN* sheetPin : m_pins ) - aPoints.push_back( sheetPin->GetPosition() ); + retval.push_back( sheetPin->GetPosition() ); + + return retval; } diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 348779ac34..606017fb89 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -550,7 +550,7 @@ public: ( aItem->Type() == SCH_NO_CONNECT_T ); } - void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; + std::vector GetConnectionPoints() const override; SEARCH_RESULT Visit( INSPECTOR inspector, void* testData, const KICAD_T scanTypes[] ) override; diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 0216dff2ed..6f6d084734 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -425,13 +425,13 @@ bool SCH_TEXT::UpdateDanglingState( std::vector& aItemList, } -void SCH_TEXT::GetConnectionPoints( std::vector< wxPoint >& aPoints ) const +std::vector SCH_TEXT::GetConnectionPoints() const { // Normal text labels do not have connection points. All others do. if( Type() == SCH_TEXT_T ) - return; + return {}; - aPoints.push_back( GetTextPos() ); + return { GetTextPos() }; } diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index b9d59303f9..3f655938f4 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -304,7 +304,7 @@ public: bool IsDangling() const override { return m_isDangling; } void SetIsDangling( bool aIsDangling ) { m_isDangling = aIsDangling; } - void GetConnectionPoints( std::vector< wxPoint >& aPoints ) const override; + std::vector GetConnectionPoints() const override; wxString GetSelectMenuText( EDA_UNITS aUnits ) const override; diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 5eb6fc276c..e46fa586e6 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -1002,11 +1002,15 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) if( !sch_item ) continue; + if( sch_item->IsConnectable() ) + { + std::vector tmp_pts = sch_item->GetConnectionPoints(); + pts.insert( pts.end(), tmp_pts.begin(), tmp_pts.end() ); + } + if( sch_item->Type() == SCH_JUNCTION_T ) { sch_item->SetFlags( STRUCT_DELETED ); - sch_item->GetConnectionPoints( pts ); - // clean up junctions at the end } else @@ -1015,9 +1019,6 @@ int SCH_EDIT_TOOL::DoDelete( const TOOL_EVENT& aEvent ) saveCopyInUndoList( item, UNDO_REDO::DELETED, appendToUndo ); appendToUndo = true; - if( sch_item && sch_item->IsConnectable() ) - sch_item->GetConnectionPoints( pts ); - updateView( sch_item ); if( sch_item->Type() == SCH_SHEET_PIN_T ) diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index e81243430a..7d56a1c745 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -364,7 +364,7 @@ SCH_LINE* SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus( const wxString& aNet ) m_busUnfold.entry->SetParent( m_frame->GetScreen() ); m_frame->AddToScreen( m_busUnfold.entry, m_frame->GetScreen() ); - m_busUnfold.label = new SCH_LABEL( m_busUnfold.entry->m_End(), aNet ); + m_busUnfold.label = new SCH_LABEL( m_busUnfold.entry->GetEnd(), aNet ); m_busUnfold.label->SetTextSize( wxSize( cfg.m_DefaultTextSize, cfg.m_DefaultTextSize ) ); m_busUnfold.label->SetLabelSpinStyle( LABEL_SPIN_STYLE::RIGHT ); m_busUnfold.label->SetParent( m_frame->GetScreen() ); @@ -374,9 +374,9 @@ SCH_LINE* SCH_LINE_WIRE_BUS_TOOL::doUnfoldBus( const wxString& aNet ) m_busUnfold.origin = pos; m_busUnfold.net_name = aNet; - getViewControls()->SetCrossHairCursorPosition( m_busUnfold.entry->m_End(), false ); + getViewControls()->SetCrossHairCursorPosition( m_busUnfold.entry->GetEnd(), false ); - return startSegments( LAYER_WIRE, m_busUnfold.entry->m_End() ); + return startSegments( LAYER_WIRE, m_busUnfold.entry->GetEnd() ); } @@ -638,7 +638,7 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType m_busUnfold.flipX = flipX; m_frame->UpdateItem( entry ); - m_wires.front()->SetStartPoint( entry->m_End() ); + m_wires.front()->SetStartPoint( entry->GetEnd() ); } // Update the label "ghost" position @@ -803,9 +803,8 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments() simplifyWireList(); // Collect the possible connection points for the new lines - std::vector< wxPoint > connections; + std::vector< wxPoint > connections = m_frame->GetSchematicConnections(); std::vector< wxPoint > new_ends; - m_frame->GetSchematicConnections( connections ); // Check each new segment for possible junctions and add/split if needed for( auto wire : m_wires ) @@ -813,7 +812,9 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments() if( wire->HasFlag( SKIP_STRUCT ) ) continue; - wire->GetConnectionPoints( new_ends ); + std::vector tmpends = wire->GetConnectionPoints(); + + new_ends.insert( new_ends.end(), tmpends.begin(), tmpends.end() ); for( auto i : connections ) { @@ -857,8 +858,7 @@ void SCH_LINE_WIRE_BUS_TOOL::finishSegments() for( auto item : m_frame->GetScreen()->Items().OfType( SCH_COMPONENT_T ) ) { - std::vector< wxPoint > pts; - item->GetConnectionPoints( pts ); + std::vector< wxPoint > pts = item->GetConnectionPoints(); if( pts.size() > 2 ) continue; @@ -891,19 +891,16 @@ int SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded( const TOOL_EVENT& aEvent ) EE_SELECTION* aSelection = aEvent.Parameter(); std::vector pts; - std::vector connections; - - m_frame->GetSchematicConnections( connections ); + std::vector connections = m_frame->GetSchematicConnections(); for( unsigned ii = 0; ii < aSelection->GetSize(); ii++ ) { SCH_ITEM* item = dynamic_cast( aSelection->GetItem( ii ) ); - std::vector new_pts; if( !item || !item->IsConnectable() ) continue; - item->GetConnectionPoints( new_pts ); + std::vector new_pts = item->GetConnectionPoints(); pts.insert( pts.end(), new_pts.begin(), new_pts.end() ); // If the item is a line, we also add any connection points from the rest of the schematic diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 755844cfec..abb967290d 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -216,7 +216,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) if( item->Type() == SCH_LINE_T ) static_cast( item )->GetSelectedPoints( connections ); else - static_cast( item )->GetConnectionPoints( connections ); + connections = static_cast( item )->GetConnectionPoints(); for( wxPoint point : connections ) getConnectedDragItems( (SCH_ITEM*) item, point, m_dragAdditions ); @@ -602,8 +602,7 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoi // Select labels and bus entries that are connected to a wire being moved. if( aOriginalItem->Type() == SCH_LINE_T ) { - std::vector connections; - test->GetConnectionPoints( connections ); + std::vector connections = test->GetConnectionPoints(); for( wxPoint& point : connections ) { @@ -615,11 +614,9 @@ void SCH_MOVE_TOOL::getConnectedDragItems( SCH_ITEM* aOriginalItem, wxPoint aPoi // A bus entry needs its wire & label as well if( testType == SCH_BUS_WIRE_ENTRY_T || testType == SCH_BUS_BUS_ENTRY_T ) { - std::vector ends; + std::vector ends = test->GetConnectionPoints(); wxPoint otherEnd; - test->GetConnectionPoints( ends ); - if( ends[0] == point ) otherEnd = ends[1]; else diff --git a/qa/eeschema/test_sch_sheet.cpp b/qa/eeschema/test_sch_sheet.cpp index b4fd43a498..a36745adc6 100644 --- a/qa/eeschema/test_sch_sheet.cpp +++ b/qa/eeschema/test_sch_sheet.cpp @@ -230,8 +230,7 @@ BOOST_AUTO_TEST_CASE( EndconnectionPoints ) expectedConnections.push_back( pin.m_pos ); } - std::vector connections; - m_sheet.GetConnectionPoints( connections ); + std::vector connections = m_sheet.GetConnectionPoints(); BOOST_CHECK_EQUAL_COLLECTIONS( connections.begin(), connections.end(), expectedConnections.begin(), expectedConnections.end() );