diff --git a/eeschema/sch_bus_entry.cpp b/eeschema/sch_bus_entry.cpp index 2192de443c..c645eb74d0 100644 --- a/eeschema/sch_bus_entry.cpp +++ b/eeschema/sch_bus_entry.cpp @@ -205,12 +205,10 @@ void SCH_BUS_ENTRY::Rotate( wxPoint rotationPoint ) void SCH_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) { - DANGLING_END_ITEM item( ENTRY_END, this ); - item.m_Pos = m_Pos; - - DANGLING_END_ITEM item1( ENTRY_END, this ); - item1.m_Pos = m_End(); + DANGLING_END_ITEM item( ENTRY_END, this, m_Pos ); aItemList.push_back( item ); + + DANGLING_END_ITEM item1( ENTRY_END, this, m_End() ); aItemList.push_back( item1 ); } diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index ce86a51acc..60d6208282 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -1560,8 +1560,7 @@ void SCH_COMPONENT::GetEndPoints( std::vector & aItemList ) if( Pin->GetConvert() && m_convert && ( m_convert != Pin->GetConvert() ) ) continue; - DANGLING_END_ITEM item( PIN_END, Pin ); - item.m_Pos = GetPinPhysicalPosition( Pin ); + DANGLING_END_ITEM item( PIN_END, Pin, GetPinPhysicalPosition( Pin ) ); aItemList.push_back( item ); } } diff --git a/eeschema/sch_junction.cpp b/eeschema/sch_junction.cpp index cacc64f94b..e0330ed366 100644 --- a/eeschema/sch_junction.cpp +++ b/eeschema/sch_junction.cpp @@ -163,8 +163,7 @@ void SCH_JUNCTION::Rotate( wxPoint rotationPoint ) void SCH_JUNCTION::GetEndPoints( std::vector & aItemList ) { - DANGLING_END_ITEM item( JUNCTION_END, this ); - item.m_Pos = m_Pos; + DANGLING_END_ITEM item( JUNCTION_END, this, m_Pos ); aItemList.push_back( item ); } diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index ce4a2b1b33..27cc397eb6 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -356,12 +356,12 @@ void SCH_LINE::GetEndPoints( std::vector & aItemList ) if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) ) { - DANGLING_END_ITEM item( (GetLayer() == LAYER_BUS) ? BUS_START_END : WIRE_START_END, this ); - item.m_Pos = m_Start; - DANGLING_END_ITEM item1( (GetLayer() == LAYER_BUS) ? BUS_END_END : WIRE_END_END, this ); - item1.m_Pos = m_End; - + DANGLING_END_ITEM item( (GetLayer() == LAYER_BUS) ? BUS_START_END : WIRE_START_END, this, + m_Start ); aItemList.push_back( item ); + + DANGLING_END_ITEM item1( (GetLayer() == LAYER_BUS) ? BUS_END_END : WIRE_END_END, this, + m_End ); aItemList.push_back( item1 ); } } @@ -378,13 +378,13 @@ bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi { BOOST_FOREACH( DANGLING_END_ITEM item, aItemList ) { - if( item.m_Item == this ) + if( item.GetItem() == this ) continue; - if( m_Start == item.m_Pos ) + if( m_Start == item.GetPosition() ) m_StartIsDangling = false; - if( m_End == item.m_Pos ) + if( m_End == item.GetPosition() ) m_EndIsDangling = false; if( (m_StartIsDangling == false) && (m_EndIsDangling == false) ) diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index eefbf182d1..96f0b7e4e6 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -516,8 +516,7 @@ void SCH_SHEET_PIN::CreateGraphicShape( std::vector & aPoints, const wx void SCH_SHEET_PIN::GetEndPoints( std::vector & aItemList ) { - DANGLING_END_ITEM item( SHEET_LABEL_END, this ); - item.m_Pos = m_Pos; + DANGLING_END_ITEM item( SHEET_LABEL_END, this, m_Pos ); aItemList.push_back( item ); } diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index d97d41f63b..71f35bf2ac 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -529,8 +529,7 @@ void SCH_TEXT::GetEndPoints( std::vector & aItemList ) if( Type() == SCH_TEXT_T ) return; - DANGLING_END_ITEM item( LABEL_END, this ); - item.m_Pos = m_Pos; + DANGLING_END_ITEM item( LABEL_END, this, m_Pos ); aItemList.push_back( item ); } @@ -548,16 +547,17 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi { DANGLING_END_ITEM& item = aItemList[ii]; - if( item.m_Item == this ) + if( item.GetItem() == this ) continue; - switch( item.m_Type ) + switch( item.GetType() ) { case PIN_END: case LABEL_END: case SHEET_LABEL_END: - if( m_Pos == item.m_Pos ) + if( m_Pos == item.GetPosition() ) m_IsDangling = false; + break; case WIRE_START_END: @@ -571,7 +571,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi wxT( "Dangling end type list overflow. Bad programmer!" ) ); DANGLING_END_ITEM & nextItem = aItemList[ii]; - m_IsDangling = !SegmentIntersect( item.m_Pos, nextItem.m_Pos, m_Pos ); + m_IsDangling = !SegmentIntersect( item.GetPosition(), nextItem.GetPosition(), m_Pos ); } break; diff --git a/include/sch_item_struct.h b/include/sch_item_struct.h index a77984b51c..d82d2de86a 100644 --- a/include/sch_item_struct.h +++ b/include/sch_item_struct.h @@ -78,19 +78,34 @@ enum DANGLING_END_T { SHEET_LABEL_END }; -// A helper class to store a list of items that can be connected to something: + +/** + * Class DANLIGN_END_ITEM + * is a helper class used to store the state of schematic items that can be connected to + * other schematic items. + */ class DANGLING_END_ITEM { -public: - const void* m_Item; // a pointer to the parent - wxPoint m_Pos; // the position of the connecting point - DANGLING_END_T m_Type; // type of parent + /// A pointer to the connectable ojbect. + const void* m_item; - DANGLING_END_ITEM( DANGLING_END_T type, const void* aItem ) + /// The position of the connection point. + wxPoint m_pos; + + /// The type of connection of #m_item. + DANGLING_END_T m_type; + +public: + DANGLING_END_ITEM( DANGLING_END_T aType, const void* aItem, const wxPoint& aPosition ) { - m_Item = aItem; - m_Type = type; + m_item = aItem; + m_type = aType; + m_pos = aPosition; } + + wxPoint GetPosition() const { return m_pos; } + const void* GetItem() const { return m_item; } + DANGLING_END_T GetType() const { return m_type; } };