Commit 539f4e1e authored by Wayne Stambaugh's avatar Wayne Stambaugh

Encapsulate DANGLING_END_ITEM class.

parent 68d752bb
...@@ -205,12 +205,10 @@ void SCH_BUS_ENTRY::Rotate( wxPoint rotationPoint ) ...@@ -205,12 +205,10 @@ void SCH_BUS_ENTRY::Rotate( wxPoint rotationPoint )
void SCH_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList ) void SCH_BUS_ENTRY::GetEndPoints( std::vector< DANGLING_END_ITEM >& aItemList )
{ {
DANGLING_END_ITEM item( ENTRY_END, this ); DANGLING_END_ITEM item( ENTRY_END, this, m_Pos );
item.m_Pos = m_Pos;
DANGLING_END_ITEM item1( ENTRY_END, this );
item1.m_Pos = m_End();
aItemList.push_back( item ); aItemList.push_back( item );
DANGLING_END_ITEM item1( ENTRY_END, this, m_End() );
aItemList.push_back( item1 ); aItemList.push_back( item1 );
} }
......
...@@ -1560,8 +1560,7 @@ void SCH_COMPONENT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) ...@@ -1560,8 +1560,7 @@ void SCH_COMPONENT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
if( Pin->GetConvert() && m_convert && ( m_convert != Pin->GetConvert() ) ) if( Pin->GetConvert() && m_convert && ( m_convert != Pin->GetConvert() ) )
continue; continue;
DANGLING_END_ITEM item( PIN_END, Pin ); DANGLING_END_ITEM item( PIN_END, Pin, GetPinPhysicalPosition( Pin ) );
item.m_Pos = GetPinPhysicalPosition( Pin );
aItemList.push_back( item ); aItemList.push_back( item );
} }
} }
......
...@@ -163,8 +163,7 @@ void SCH_JUNCTION::Rotate( wxPoint rotationPoint ) ...@@ -163,8 +163,7 @@ void SCH_JUNCTION::Rotate( wxPoint rotationPoint )
void SCH_JUNCTION::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) void SCH_JUNCTION::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{ {
DANGLING_END_ITEM item( JUNCTION_END, this ); DANGLING_END_ITEM item( JUNCTION_END, this, m_Pos );
item.m_Pos = m_Pos;
aItemList.push_back( item ); aItemList.push_back( item );
} }
......
...@@ -356,12 +356,12 @@ void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) ...@@ -356,12 +356,12 @@ void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) ) if( ( GetLayer() == LAYER_BUS ) || ( GetLayer() == LAYER_WIRE ) )
{ {
DANGLING_END_ITEM item( (GetLayer() == LAYER_BUS) ? BUS_START_END : WIRE_START_END, this ); DANGLING_END_ITEM item( (GetLayer() == LAYER_BUS) ? BUS_START_END : WIRE_START_END, this,
item.m_Pos = m_Start; m_Start );
DANGLING_END_ITEM item1( (GetLayer() == LAYER_BUS) ? BUS_END_END : WIRE_END_END, this );
item1.m_Pos = m_End;
aItemList.push_back( item ); aItemList.push_back( item );
DANGLING_END_ITEM item1( (GetLayer() == LAYER_BUS) ? BUS_END_END : WIRE_END_END, this,
m_End );
aItemList.push_back( item1 ); aItemList.push_back( item1 );
} }
} }
...@@ -378,13 +378,13 @@ bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi ...@@ -378,13 +378,13 @@ bool SCH_LINE::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
{ {
BOOST_FOREACH( DANGLING_END_ITEM item, aItemList ) BOOST_FOREACH( DANGLING_END_ITEM item, aItemList )
{ {
if( item.m_Item == this ) if( item.GetItem() == this )
continue; continue;
if( m_Start == item.m_Pos ) if( m_Start == item.GetPosition() )
m_StartIsDangling = false; m_StartIsDangling = false;
if( m_End == item.m_Pos ) if( m_End == item.GetPosition() )
m_EndIsDangling = false; m_EndIsDangling = false;
if( (m_StartIsDangling == false) && (m_EndIsDangling == false) ) if( (m_StartIsDangling == false) && (m_EndIsDangling == false) )
......
...@@ -516,8 +516,7 @@ void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wx ...@@ -516,8 +516,7 @@ void SCH_SHEET_PIN::CreateGraphicShape( std::vector <wxPoint>& aPoints, const wx
void SCH_SHEET_PIN::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) void SCH_SHEET_PIN::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
{ {
DANGLING_END_ITEM item( SHEET_LABEL_END, this ); DANGLING_END_ITEM item( SHEET_LABEL_END, this, m_Pos );
item.m_Pos = m_Pos;
aItemList.push_back( item ); aItemList.push_back( item );
} }
......
...@@ -529,8 +529,7 @@ void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList ) ...@@ -529,8 +529,7 @@ void SCH_TEXT::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
if( Type() == SCH_TEXT_T ) if( Type() == SCH_TEXT_T )
return; return;
DANGLING_END_ITEM item( LABEL_END, this ); DANGLING_END_ITEM item( LABEL_END, this, m_Pos );
item.m_Pos = m_Pos;
aItemList.push_back( item ); aItemList.push_back( item );
} }
...@@ -548,16 +547,17 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi ...@@ -548,16 +547,17 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
{ {
DANGLING_END_ITEM& item = aItemList[ii]; DANGLING_END_ITEM& item = aItemList[ii];
if( item.m_Item == this ) if( item.GetItem() == this )
continue; continue;
switch( item.m_Type ) switch( item.GetType() )
{ {
case PIN_END: case PIN_END:
case LABEL_END: case LABEL_END:
case SHEET_LABEL_END: case SHEET_LABEL_END:
if( m_Pos == item.m_Pos ) if( m_Pos == item.GetPosition() )
m_IsDangling = false; m_IsDangling = false;
break; break;
case WIRE_START_END: case WIRE_START_END:
...@@ -571,7 +571,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi ...@@ -571,7 +571,7 @@ bool SCH_TEXT::IsDanglingStateChanged( std::vector< DANGLING_END_ITEM >& aItemLi
wxT( "Dangling end type list overflow. Bad programmer!" ) ); wxT( "Dangling end type list overflow. Bad programmer!" ) );
DANGLING_END_ITEM & nextItem = aItemList[ii]; 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; break;
......
...@@ -78,19 +78,34 @@ enum DANGLING_END_T { ...@@ -78,19 +78,34 @@ enum DANGLING_END_T {
SHEET_LABEL_END 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 class DANGLING_END_ITEM
{ {
public: /// A pointer to the connectable ojbect.
const void* m_Item; // a pointer to the parent const void* m_item;
wxPoint m_Pos; // the position of the connecting point
DANGLING_END_T m_Type; // type of parent
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_item = aItem;
m_Type = type; 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; }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment