Simplify dangling end stuff a bit and remove graphic lines from it.
This commit is contained in:
parent
d39f79b55b
commit
2d72ccb6ae
|
@ -312,41 +312,37 @@ bool SCH_BUS_WIRE_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aI
|
|||
|
||||
m_isDanglingStart = m_isDanglingEnd = true;
|
||||
|
||||
// Wires and buses are stored in the list as a pair, start and end. This
|
||||
// variable holds the start position from one iteration so it can be used
|
||||
// when the end position is found.
|
||||
wxPoint seg_start;
|
||||
|
||||
// Store the connection type and state for the start (0) and end (1)
|
||||
bool has_wire[2] = { false };
|
||||
bool has_bus[2] = { false };
|
||||
|
||||
for( const DANGLING_END_ITEM& each_item : aItemList )
|
||||
for( unsigned ii = 0; ii < aItemList.size(); ii++ )
|
||||
{
|
||||
if( each_item.GetItem() == this )
|
||||
DANGLING_END_ITEM& item = aItemList[ii];
|
||||
|
||||
if( item.GetItem() == this )
|
||||
continue;
|
||||
|
||||
switch( each_item.GetType() )
|
||||
switch( item.GetType() )
|
||||
{
|
||||
case WIRE_START_END:
|
||||
case WIRE_END_END:
|
||||
if( m_pos == each_item.GetPosition() )
|
||||
case WIRE_END:
|
||||
if( m_pos == item.GetPosition() )
|
||||
has_wire[0] = true;
|
||||
else if( GetEnd() == each_item.GetPosition() )
|
||||
else if( GetEnd() == item.GetPosition() )
|
||||
has_wire[1] = true;
|
||||
|
||||
break;
|
||||
|
||||
case BUS_START_END:
|
||||
seg_start = each_item.GetPosition();
|
||||
break;
|
||||
case BUS_END:
|
||||
{
|
||||
// The bus has created 2 DANGLING_END_ITEMs, one per end.
|
||||
DANGLING_END_ITEM& nextItem = aItemList[++ii];
|
||||
|
||||
case BUS_END_END:
|
||||
if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_pos ) )
|
||||
if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
|
||||
has_bus[0] = true;
|
||||
else if( IsPointOnSegment( seg_start, each_item.GetPosition(), GetEnd() ) )
|
||||
else if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
|
||||
has_bus[1] = true;
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -375,27 +371,27 @@ bool SCH_BUS_BUS_ENTRY::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aIt
|
|||
|
||||
m_isDanglingStart = m_isDanglingEnd = true;
|
||||
|
||||
// Wires and buses are stored in the list as a pair, start and end. This
|
||||
// variable holds the start position from one iteration so it can be used
|
||||
// when the end position is found.
|
||||
wxPoint seg_start;
|
||||
|
||||
for( const DANGLING_END_ITEM& each_item : aItemList )
|
||||
for( unsigned ii = 0; ii < aItemList.size(); ii++ )
|
||||
{
|
||||
if( each_item.GetItem() == this )
|
||||
DANGLING_END_ITEM& item = aItemList[ii];
|
||||
|
||||
if( item.GetItem() == this )
|
||||
continue;
|
||||
|
||||
switch( each_item.GetType() )
|
||||
switch( item.GetType() )
|
||||
{
|
||||
case BUS_START_END:
|
||||
seg_start = each_item.GetPosition();
|
||||
break;
|
||||
case BUS_END_END:
|
||||
if( IsPointOnSegment( seg_start, each_item.GetPosition(), m_pos ) )
|
||||
case BUS_END:
|
||||
{
|
||||
// The bus has created 2 DANGLING_END_ITEMs, one per end.
|
||||
DANGLING_END_ITEM& nextItem = aItemList[++ii];
|
||||
|
||||
if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), m_pos ) )
|
||||
m_isDanglingStart = false;
|
||||
if( IsPointOnSegment( seg_start, each_item.GetPosition(), GetEnd() ) )
|
||||
if( IsPointOnSegment( item.GetPosition(), nextItem.GetPosition(), GetEnd() ) )
|
||||
m_isDanglingEnd = false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -60,12 +60,8 @@ enum FIELDS_AUTOPLACED
|
|||
enum DANGLING_END_T
|
||||
{
|
||||
UNKNOWN = 0,
|
||||
GRAPHIC_START_END,
|
||||
GRAPHIC_END_END,
|
||||
WIRE_START_END,
|
||||
WIRE_END_END,
|
||||
BUS_START_END,
|
||||
BUS_END_END,
|
||||
WIRE_END,
|
||||
BUS_END,
|
||||
JUNCTION_END,
|
||||
PIN_END,
|
||||
LABEL_END,
|
||||
|
@ -91,8 +87,8 @@ public:
|
|||
m_parent = aItem;
|
||||
}
|
||||
|
||||
DANGLING_END_ITEM( DANGLING_END_T aType, EDA_ITEM* aItem,
|
||||
const wxPoint& aPosition, const EDA_ITEM* aParent )
|
||||
DANGLING_END_ITEM( DANGLING_END_T aType, EDA_ITEM* aItem, const wxPoint& aPosition,
|
||||
const EDA_ITEM* aParent )
|
||||
{
|
||||
m_item = aItem;
|
||||
m_type = aType;
|
||||
|
@ -128,17 +124,10 @@ public:
|
|||
DANGLING_END_T GetType() const { return m_type; }
|
||||
|
||||
private:
|
||||
/// A pointer to the connectable object.
|
||||
EDA_ITEM* m_item;
|
||||
|
||||
/// The position of the connection point.
|
||||
wxPoint m_pos;
|
||||
|
||||
/// The type of connection of #m_item.
|
||||
DANGLING_END_T m_type;
|
||||
|
||||
/// A pointer to the parent object (in the case of pins)
|
||||
const EDA_ITEM* m_parent;
|
||||
EDA_ITEM* m_item; /// A pointer to the connectable object.
|
||||
wxPoint m_pos; /// The position of the connection point.
|
||||
DANGLING_END_T m_type; /// The type of connection of #m_item.
|
||||
const EDA_ITEM* m_parent; /// A pointer to the parent object (in the case of pins)
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -579,29 +579,11 @@ SCH_LINE* SCH_LINE::MergeOverlap( SCH_SCREEN* aScreen, SCH_LINE* aLine, bool aCh
|
|||
|
||||
void SCH_LINE::GetEndPoints( std::vector <DANGLING_END_ITEM>& aItemList )
|
||||
{
|
||||
DANGLING_END_T startType, endType;
|
||||
|
||||
switch( GetLayer() )
|
||||
if( IsConnectable() )
|
||||
{
|
||||
case LAYER_WIRE:
|
||||
startType = WIRE_START_END;
|
||||
endType = WIRE_END_END;
|
||||
break;
|
||||
case LAYER_BUS:
|
||||
startType = BUS_START_END;
|
||||
endType = BUS_END_END;
|
||||
break;
|
||||
default:
|
||||
startType = GRAPHIC_START_END;
|
||||
endType = GRAPHIC_END_END;
|
||||
break;
|
||||
aItemList.emplace_back( IsBus() ? BUS_END : WIRE_END, this, m_start );
|
||||
aItemList.emplace_back( IsBus() ? BUS_END : WIRE_END, this, m_end );
|
||||
}
|
||||
|
||||
DANGLING_END_ITEM item( startType, this, m_start );
|
||||
aItemList.push_back( item );
|
||||
|
||||
DANGLING_END_ITEM item1( endType, this, m_end );
|
||||
aItemList.push_back( item1 );
|
||||
}
|
||||
|
||||
|
||||
|
@ -618,34 +600,26 @@ bool SCH_LINE::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
|
|||
if( item.GetItem() == this )
|
||||
continue;
|
||||
|
||||
if( ( IsWire()
|
||||
&& ( item.GetType() == BUS_START_END || item.GetType() == BUS_END_END
|
||||
|| item.GetType() == BUS_ENTRY_END ) )
|
||||
|| ( IsBus()
|
||||
&& ( item.GetType() == WIRE_START_END || item.GetType() == WIRE_END_END
|
||||
|| item.GetType() == PIN_END ) )
|
||||
|| ( IsGraphicLine()
|
||||
&& ( item.GetType() != GRAPHIC_START_END && item.GetType() != GRAPHIC_END_END ) ) )
|
||||
continue;
|
||||
if( ( IsWire() && item.GetType() != BUS_END && item.GetType() != BUS_ENTRY_END )
|
||||
|| ( IsBus() && item.GetType() != WIRE_END && item.GetType() != PIN_END ) )
|
||||
{
|
||||
if( m_start == item.GetPosition() )
|
||||
m_startIsDangling = false;
|
||||
|
||||
if( m_start == item.GetPosition() )
|
||||
m_startIsDangling = false;
|
||||
if( m_end == item.GetPosition() )
|
||||
m_endIsDangling = false;
|
||||
|
||||
if( m_end == item.GetPosition() )
|
||||
m_endIsDangling = false;
|
||||
|
||||
if( !m_startIsDangling && !m_endIsDangling )
|
||||
break;
|
||||
if( !m_startIsDangling && !m_endIsDangling )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( IsBus() || IsGraphicLine() )
|
||||
{
|
||||
// Force unchanged return state for graphic lines and busses
|
||||
previousStartState = m_startIsDangling;
|
||||
previousEndState = m_endIsDangling;
|
||||
}
|
||||
|
||||
return ( previousStartState != m_startIsDangling ) || ( previousEndState != m_endIsDangling );
|
||||
// We only use the bus dangling state for automatic line starting, so we don't care if it
|
||||
// has changed or not (and returning true will result in extra work)
|
||||
if( IsBus() )
|
||||
return false;
|
||||
else
|
||||
return previousStartState != m_startIsDangling || previousEndState != m_endIsDangling;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1555,8 +1555,7 @@ bool SCH_SYMBOL::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
|
|||
case PIN_END:
|
||||
case LABEL_END:
|
||||
case SHEET_LABEL_END:
|
||||
case WIRE_START_END:
|
||||
case WIRE_END_END:
|
||||
case WIRE_END:
|
||||
case NO_CONNECT_END:
|
||||
case JUNCTION_END:
|
||||
|
||||
|
|
|
@ -486,22 +486,16 @@ bool SCH_TEXT::UpdateDanglingState( std::vector<DANGLING_END_ITEM>& aItemList,
|
|||
|
||||
break;
|
||||
|
||||
case BUS_START_END:
|
||||
case BUS_END:
|
||||
m_connectionType = CONNECTION_TYPE::BUS;
|
||||
KI_FALLTHROUGH;
|
||||
|
||||
case WIRE_START_END:
|
||||
case WIRE_END:
|
||||
{
|
||||
// These schematic items have created 2 DANGLING_END_ITEM one per end. But being
|
||||
// a paranoid programmer, I'll check just in case.
|
||||
ii++;
|
||||
|
||||
wxCHECK_MSG( ii < aItemList.size(), previousState != m_isDangling,
|
||||
wxT( "Dangling end type list overflow. Bad programmer!" ) );
|
||||
DANGLING_END_ITEM& nextItem = aItemList[++ii];
|
||||
|
||||
int accuracy = 1; // We have rounding issues with an accuracy of 0
|
||||
|
||||
DANGLING_END_ITEM & nextItem = aItemList[ii];
|
||||
m_isDangling = !TestSegmentHit( GetTextPos(), item.GetPosition(),
|
||||
nextItem.GetPosition(), accuracy );
|
||||
|
||||
|
|
Loading…
Reference in New Issue