First take at repairing Eagle import of bus entries.
Simplify logic by adding quadrant-based BUS_ENTRY ctor. Fix issue with bus entry size having been in mils rather than IU. Fix issues with logic. Fixes https://gitlab.com/kicad/code/kicad/issues/7042
This commit is contained in:
parent
9a42ec753f
commit
3a84ee27fd
|
@ -60,6 +60,23 @@ SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, bool aFlipY ) :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SCH_BUS_WIRE_ENTRY::SCH_BUS_WIRE_ENTRY( const wxPoint& pos, int aQuadrant ) :
|
||||||
|
SCH_BUS_ENTRY_BASE( SCH_BUS_WIRE_ENTRY_T, pos, false )
|
||||||
|
{
|
||||||
|
switch( aQuadrant )
|
||||||
|
{
|
||||||
|
case 1: m_size.x *= 1; m_size.y *= -1; break;
|
||||||
|
case 2: m_size.x *= 1; m_size.y *= 1; break;
|
||||||
|
case 3: m_size.x *= -1; m_size.y *= 1; break;
|
||||||
|
case 4: m_size.x *= -1; m_size.y *= -1; break;
|
||||||
|
default: wxFAIL_MSG( "SCH_BUS_WIRE_ENTRY ctor: unexpected quadrant" );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_layer = LAYER_WIRE;
|
||||||
|
m_connected_bus_item = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SCH_BUS_BUS_ENTRY::SCH_BUS_BUS_ENTRY( const wxPoint& pos, bool aFlipY ) :
|
SCH_BUS_BUS_ENTRY::SCH_BUS_BUS_ENTRY( const wxPoint& pos, bool aFlipY ) :
|
||||||
SCH_BUS_ENTRY_BASE( SCH_BUS_BUS_ENTRY_T, pos, aFlipY )
|
SCH_BUS_ENTRY_BASE( SCH_BUS_BUS_ENTRY_T, pos, aFlipY )
|
||||||
{
|
{
|
||||||
|
|
|
@ -133,6 +133,8 @@ class SCH_BUS_WIRE_ENTRY : public SCH_BUS_ENTRY_BASE
|
||||||
public:
|
public:
|
||||||
SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), bool aFlipY = false );
|
SCH_BUS_WIRE_ENTRY( const wxPoint& pos = wxPoint( 0, 0 ), bool aFlipY = false );
|
||||||
|
|
||||||
|
SCH_BUS_WIRE_ENTRY( const wxPoint& pos, int aQuadrant );
|
||||||
|
|
||||||
~SCH_BUS_WIRE_ENTRY() { }
|
~SCH_BUS_WIRE_ENTRY() { }
|
||||||
|
|
||||||
static inline bool ClassOf( const EDA_ITEM* aItem )
|
static inline bool ClassOf( const EDA_ITEM* aItem )
|
||||||
|
|
|
@ -2261,6 +2261,19 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
wxPoint busstart = bus->GetStartPoint();
|
wxPoint busstart = bus->GetStartPoint();
|
||||||
wxPoint busend = bus->GetEndPoint();
|
wxPoint busend = bus->GetEndPoint();
|
||||||
|
|
||||||
|
auto entrySize =
|
||||||
|
[]( int signX, int signY ) -> wxPoint
|
||||||
|
{
|
||||||
|
return wxPoint( Mils2iu( DEFAULT_SCH_ENTRY_SIZE ) * signX,
|
||||||
|
Mils2iu( DEFAULT_SCH_ENTRY_SIZE ) * signY );
|
||||||
|
};
|
||||||
|
|
||||||
|
auto testBusHit =
|
||||||
|
[&]( const wxPoint& aPt ) -> bool
|
||||||
|
{
|
||||||
|
return TestSegmentHit( aPt, busstart, busend, 0 );
|
||||||
|
};
|
||||||
|
|
||||||
auto it2 = it1;
|
auto it2 = it1;
|
||||||
++it2;
|
++it2;
|
||||||
|
|
||||||
|
@ -2278,36 +2291,41 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
// Test for horizontal wire and vertical bus
|
// Test for horizontal wire and vertical bus
|
||||||
if( linestart.y == lineend.y && busstart.x == busend.x )
|
if( linestart.y == lineend.y && busstart.x == busend.x )
|
||||||
{
|
{
|
||||||
if( TestSegmentHit( linestart, busstart, busend, 0 ) )
|
if( testBusHit( linestart ) )
|
||||||
{
|
{
|
||||||
// Wire start is on a bus.
|
|
||||||
// Wire start is on the vertical bus
|
// Wire start is on the vertical bus
|
||||||
|
|
||||||
// if the end of the wire is to the left of the bus
|
|
||||||
if( lineend.x < busstart.x )
|
if( lineend.x < busstart.x )
|
||||||
{
|
{
|
||||||
// |
|
// the end of the wire is to the left of the bus
|
||||||
// ---|
|
// |
|
||||||
// |
|
// ----|
|
||||||
if( TestSegmentHit(
|
// |
|
||||||
linestart + wxPoint( 0, -100 ), busstart, busend, 0 ) )
|
wxPoint p = linestart + entrySize( -1, 0 );
|
||||||
|
|
||||||
|
if( testBusHit( linestart + entrySize( 0, -1 ) ) )
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// there is room above the wire for the bus entry
|
||||||
linestart + wxPoint( -100, 0 ), true );
|
// |
|
||||||
|
// ___/|
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, linestart + wxPoint( -100, 0 ) );
|
moveLabels( line, p );
|
||||||
line->SetStartPoint( linestart + wxPoint( -100, 0 ) );
|
line->SetStartPoint( p );
|
||||||
}
|
}
|
||||||
else if( TestSegmentHit(
|
else if( testBusHit( linestart + entrySize( 0, 1 ) ) )
|
||||||
linestart + wxPoint( 0, 100 ), busstart, busend, 0 ) )
|
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// there is room below the wire for the bus entry
|
||||||
linestart + wxPoint( -100, 0 ), false );
|
// ___ |
|
||||||
|
// \|
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, linestart + wxPoint( -100, 0 ) );
|
moveLabels( line, p );
|
||||||
line->SetStartPoint( linestart + wxPoint( -100, 0 ) );
|
line->SetStartPoint( p );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2318,34 +2336,37 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
m_currentSheet->GetScreen()->Append( marker );
|
m_currentSheet->GetScreen()->Append( marker );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else the wire end is to the right of the bus
|
|
||||||
// Wire is to the right of the bus
|
|
||||||
// |
|
|
||||||
// |----
|
|
||||||
// |
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// test is bus exists above the wire
|
// the wire end is to the right of the bus
|
||||||
if( TestSegmentHit(
|
// |
|
||||||
linestart + wxPoint( 0, -100 ), busstart, busend, 0 ) )
|
// |----
|
||||||
|
// |
|
||||||
|
wxPoint p = linestart + entrySize( 1, 0 );
|
||||||
|
|
||||||
|
if( testBusHit( linestart + entrySize( 0, -1 ) ) )
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// There is room above the wire for the bus entry
|
||||||
linestart + wxPoint( 0, -100 ), false );
|
// |
|
||||||
|
// |\___
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p , 4 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, linestart + wxPoint( 100, 0 ) );
|
moveLabels( line, p );
|
||||||
line->SetStartPoint( linestart + wxPoint( 100, 0 ) );
|
line->SetStartPoint( p );
|
||||||
}
|
}
|
||||||
// test is bus exists below the wire
|
else if( testBusHit( linestart + entrySize( 0, 100 ) ) )
|
||||||
else if( TestSegmentHit(
|
|
||||||
linestart + wxPoint( 0, 100 ), busstart, busend, 0 ) )
|
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// There is room below the wire for the bus entry
|
||||||
linestart + wxPoint( 0, 100 ), true );
|
// | ___
|
||||||
|
// |/
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, linestart + wxPoint( 100, 0 ) );
|
moveLabels( line, p );
|
||||||
line->SetStartPoint( linestart + wxPoint( 100, 0 ) );
|
line->SetStartPoint( p );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2359,36 +2380,41 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same thing but test end of the wire instead.
|
// Same thing but test end of the wire instead.
|
||||||
if( TestSegmentHit( lineend, busstart, busend, 0 ) )
|
if( testBusHit( lineend ) )
|
||||||
{
|
{
|
||||||
// Wire end is on the vertical bus
|
// Wire end is on the vertical bus
|
||||||
|
|
||||||
// if the start of the wire is to the left of the bus
|
|
||||||
if( linestart.x < busstart.x )
|
if( linestart.x < busstart.x )
|
||||||
{
|
{
|
||||||
// Test if bus exists above the wire
|
// start of the wire is to the left of the bus
|
||||||
if( TestSegmentHit( lineend + wxPoint( 0, 100 ), busstart, busend, 0 ) )
|
// |
|
||||||
|
// ----|
|
||||||
|
// |
|
||||||
|
wxPoint p = lineend + entrySize( -1, 0 );
|
||||||
|
|
||||||
|
if( testBusHit( lineend + entrySize( 0, -1 ) ) )
|
||||||
{
|
{
|
||||||
// |
|
// there is room above the wire for the bus entry
|
||||||
|
// |
|
||||||
// ___/|
|
// ___/|
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// |
|
||||||
lineend + wxPoint( -100, 0 ), false );
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, lineend + wxPoint( -100, 0 ) );
|
moveLabels( line, p );
|
||||||
line->SetEndPoint( lineend + wxPoint( -100, 0 ) );
|
line->SetEndPoint( p );
|
||||||
}
|
}
|
||||||
// Test if bus exists below the wire
|
else if( testBusHit( lineend + entrySize( 0, -1 ) ) )
|
||||||
else if( TestSegmentHit(
|
|
||||||
lineend + wxPoint( 0, -100 ), busstart, busend, 0 ) )
|
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry =
|
// there is room below the wire for the bus entry
|
||||||
new SCH_BUS_WIRE_ENTRY( lineend + wxPoint( -100, 0 ),
|
// ___ |
|
||||||
true );
|
// \|
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, lineend + wxPoint( -100, 0 ) );
|
moveLabels( line, lineend + entrySize( -1, 0 ) );
|
||||||
line->SetEndPoint( lineend + wxPoint( -100, 0 ) );
|
line->SetEndPoint( lineend + entrySize( -1, 0 ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2399,33 +2425,37 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
m_currentSheet->GetScreen()->Append( marker );
|
m_currentSheet->GetScreen()->Append( marker );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// else the start of the wire is to the right of the bus
|
|
||||||
// |
|
|
||||||
// |----
|
|
||||||
// |
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// test if bus existed above the wire
|
// the start of the wire is to the right of the bus
|
||||||
if( TestSegmentHit(
|
// |
|
||||||
lineend + wxPoint( 0, -100 ), busstart, busend, 0 ) )
|
// |----
|
||||||
|
// |
|
||||||
|
wxPoint p = lineend + entrySize( 1, 0 );
|
||||||
|
|
||||||
|
if( testBusHit( lineend + entrySize( 0, -1 ) ) )
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// There is room above the wire for the bus entry
|
||||||
lineend + wxPoint( 0, -100 ), false );
|
// |
|
||||||
|
// |\___
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, lineend + wxPoint( 100, 0 ) );
|
moveLabels( line, p );
|
||||||
line->SetEndPoint( lineend + wxPoint( 100, 0 ) );
|
line->SetEndPoint( p );
|
||||||
}
|
}
|
||||||
// test if bus existed below the wire
|
else if( testBusHit( lineend + entrySize( 0, 1 ) ) )
|
||||||
else if( TestSegmentHit(
|
|
||||||
lineend + wxPoint( 0, 100 ), busstart, busend, 0 ) )
|
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry =
|
// There is room below the wire for the bus entry
|
||||||
new SCH_BUS_WIRE_ENTRY( lineend + wxPoint( 0, 100 ), true );
|
// | ___
|
||||||
|
// |/
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, lineend + wxPoint( 100, 0 ) );
|
moveLabels( line, p );
|
||||||
line->SetEndPoint( lineend + wxPoint( 100, 0 ) );
|
line->SetEndPoint( p );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2439,29 +2469,41 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
}
|
}
|
||||||
} // if( linestart.y == lineend.y && busstart.x == busend.x)
|
} // if( linestart.y == lineend.y && busstart.x == busend.x)
|
||||||
|
|
||||||
// Test for horizontal wire and vertical bus
|
// Test for vertical wire and horizontal bus
|
||||||
if( linestart.x == lineend.x && busstart.y == busend.y )
|
if( linestart.x == lineend.x && busstart.y == busend.y )
|
||||||
{
|
{
|
||||||
if( TestSegmentHit( linestart, busstart, busend, 0 ) )
|
if( testBusHit( linestart ) )
|
||||||
{
|
{
|
||||||
// Wire start is on the bus
|
// Wire start is on the bus
|
||||||
// If wire end is above the bus,
|
|
||||||
if( lineend.y < busstart.y )
|
if( lineend.y < busstart.y )
|
||||||
{
|
{
|
||||||
// Test for bus existence to the left of the wire
|
// the end of the wire is above the bus
|
||||||
if( TestSegmentHit(
|
// |
|
||||||
linestart + wxPoint( -100, 0 ), busstart, busend, 0 ) )
|
// |
|
||||||
|
// -----
|
||||||
|
wxPoint p = linestart + entrySize( 0, -1 );
|
||||||
|
|
||||||
|
if( testBusHit( linestart + entrySize( -1, 0 ) ) )
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// there is room to the left of the wire for the bus entry
|
||||||
linestart + wxPoint( -100, 0 ), true );
|
// |
|
||||||
|
// |
|
||||||
|
// /
|
||||||
|
// -----
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, linestart + wxPoint( 0, -100 ) );
|
moveLabels( line, p );
|
||||||
line->SetStartPoint( linestart + wxPoint( 0, -100 ) );
|
line->SetStartPoint( p );
|
||||||
}
|
}
|
||||||
else if( TestSegmentHit(
|
else if( testBusHit( linestart + entrySize( 1, 0 ) ) )
|
||||||
linestart + wxPoint( 100, 0 ), busstart, busend, 0 ) )
|
|
||||||
{
|
{
|
||||||
|
// there is room to the right of the wire for the bus entry
|
||||||
|
// |
|
||||||
|
// |
|
||||||
|
// \
|
||||||
|
// -----
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
||||||
linestart + wxPoint( 0, 100 ), false );
|
linestart + wxPoint( 0, 100 ), false );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
|
@ -2478,28 +2520,39 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
m_currentSheet->GetScreen()->Append( marker );
|
m_currentSheet->GetScreen()->Append( marker );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // wire end is below the bus.
|
else
|
||||||
{
|
{
|
||||||
// Test for bus existence to the left of the wire
|
// wire end is below the bus
|
||||||
if( TestSegmentHit(
|
// -----
|
||||||
linestart + wxPoint( -100, 0 ), busstart, busend, 0 ) )
|
// |
|
||||||
|
// |
|
||||||
|
wxPoint p = linestart + entrySize( 0, 1 );
|
||||||
|
|
||||||
|
if( testBusHit( linestart + entrySize( -1, 0 ) ) )
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// there is room to the left of the wire for the bus entry
|
||||||
linestart + wxPoint( -100, 0 ), false );
|
// -----
|
||||||
|
// \
|
||||||
|
// |
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, linestart + wxPoint( 0, 100 ) );
|
moveLabels( line, p );
|
||||||
line->SetStartPoint( linestart + wxPoint( 0, 100 ) );
|
line->SetStartPoint( p );
|
||||||
}
|
}
|
||||||
else if( TestSegmentHit(
|
else if( testBusHit( linestart + entrySize( 1, 0 ) ) )
|
||||||
linestart + wxPoint( 100, 0 ), busstart, busend, 0 ) )
|
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// there is room to the right of the wire for the bus entry
|
||||||
linestart + wxPoint( 100, 0 ), true );
|
// -----
|
||||||
|
// /
|
||||||
|
// |
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, linestart + wxPoint( 0, 100 ) );
|
moveLabels( line, p );
|
||||||
line->SetStartPoint( linestart + wxPoint( 0, 100 ) );
|
line->SetStartPoint( p );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2512,34 +2565,43 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( TestSegmentHit( lineend, busstart, busend, 0 ) )
|
if( testBusHit( lineend ) )
|
||||||
{
|
{
|
||||||
// Wire end is on the bus
|
// Wire end is on the bus
|
||||||
// If wire start is above the bus,
|
|
||||||
|
|
||||||
if( linestart.y < busstart.y )
|
if( linestart.y < busstart.y )
|
||||||
{
|
{
|
||||||
// Test for bus existence to the left of the wire
|
// the start of the wire is above the bus
|
||||||
if( TestSegmentHit(
|
// |
|
||||||
lineend + wxPoint( -100, 0 ), busstart, busend, 0 ) )
|
// |
|
||||||
|
// -----
|
||||||
|
wxPoint p = linestart + entrySize( 0, -1 );
|
||||||
|
|
||||||
|
if( testBusHit( lineend + entrySize( -1, 0 ) ) )
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry =
|
// there is room to the left of the wire for the bus entry
|
||||||
new SCH_BUS_WIRE_ENTRY( lineend + wxPoint( -100, 0 ),
|
// |
|
||||||
true );
|
// |
|
||||||
|
// /
|
||||||
|
// -----
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, lineend + wxPoint( 0, -100 ) );
|
moveLabels( line, lineend + wxPoint( 0, -100 ) );
|
||||||
line->SetEndPoint( lineend + wxPoint( 0, -100 ) );
|
line->SetEndPoint( lineend + wxPoint( 0, -100 ) );
|
||||||
}
|
}
|
||||||
else if( TestSegmentHit(
|
else if( testBusHit( lineend + entrySize( 1, 0 ) ) )
|
||||||
lineend + wxPoint( 100, 0 ), busstart, busend, 0 ) )
|
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// there is room to the right of the wire for the bus entry
|
||||||
lineend + wxPoint( 0, -100 ), false );
|
// |
|
||||||
|
// |
|
||||||
|
// \
|
||||||
|
// -----
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, lineend + wxPoint( 0, -100 ) );
|
moveLabels( line, p );
|
||||||
line->SetEndPoint( lineend + wxPoint( 0, -100 ) );
|
line->SetEndPoint( p );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2550,28 +2612,39 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
m_currentSheet->GetScreen()->Append( marker );
|
m_currentSheet->GetScreen()->Append( marker );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // wire end is below the bus.
|
else
|
||||||
{
|
{
|
||||||
// Test for bus existence to the left of the wire
|
// wire start is below the bus
|
||||||
if( TestSegmentHit(
|
// -----
|
||||||
lineend + wxPoint( -100, 0 ), busstart, busend, 0 ) )
|
// |
|
||||||
|
// |
|
||||||
|
wxPoint p = lineend + entrySize( 0, 1 );
|
||||||
|
|
||||||
|
if( testBusHit( lineend + entrySize( -1, 0 ) ) )
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY(
|
// there is room to the left of the wire for the bus entry
|
||||||
lineend + wxPoint( -100, 0 ), false );
|
// -----
|
||||||
|
// \
|
||||||
|
// |
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, lineend + wxPoint( 0, 100 ) );
|
moveLabels( line, p );
|
||||||
line->SetEndPoint( lineend + wxPoint( 0, 100 ) );
|
line->SetEndPoint( p );
|
||||||
}
|
}
|
||||||
else if( TestSegmentHit(
|
else if( testBusHit( lineend + entrySize( 1, 0 ) ) )
|
||||||
lineend + wxPoint( 100, 0 ), busstart, busend, 0 ) )
|
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry =
|
// there is room to the right of the wire for the bus entry
|
||||||
new SCH_BUS_WIRE_ENTRY( lineend + wxPoint( 0, 100 ), true );
|
// -----
|
||||||
|
// /
|
||||||
|
// |
|
||||||
|
// |
|
||||||
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, lineend + wxPoint( 0, 100 ) );
|
moveLabels( line, p );
|
||||||
line->SetEndPoint( lineend + wxPoint( 0, 100 ) );
|
line->SetEndPoint( p );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2591,7 +2664,7 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
busend = bus->GetEndPoint();
|
busend = bus->GetEndPoint();
|
||||||
|
|
||||||
// bus entry wire isn't horizontal or vertical
|
// bus entry wire isn't horizontal or vertical
|
||||||
if( TestSegmentHit( linestart, busstart, busend, 0 ) )
|
if( testBusHit( linestart ) )
|
||||||
{
|
{
|
||||||
wxPoint wirevector = linestart - lineend;
|
wxPoint wirevector = linestart - lineend;
|
||||||
|
|
||||||
|
@ -2599,87 +2672,64 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
{
|
{
|
||||||
if( wirevector.y > 0 )
|
if( wirevector.y > 0 )
|
||||||
{
|
{
|
||||||
wxPoint p = linestart + wxPoint( -100, -100 );
|
wxPoint p = linestart + entrySize( -1, -1 );
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, false );
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, p );
|
moveLabels( line, p );
|
||||||
|
|
||||||
if( p == lineend ) // wire is overlapped by bus entry symbol
|
if( p == lineend ) // wire is overlapped by bus entry symbol
|
||||||
{
|
|
||||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||||
line = nullptr;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
line->SetStartPoint( p );
|
line->SetStartPoint( p );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxPoint p = linestart + wxPoint( -100, 100 );
|
wxPoint p = linestart + entrySize( -1, 1 );
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, true );
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
|
|
||||||
moveLabels( line, p );
|
moveLabels( line, p );
|
||||||
|
|
||||||
if( p == lineend ) // wire is overlapped by bus entry symbol
|
if( p == lineend ) // wire is overlapped by bus entry symbol
|
||||||
{
|
|
||||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||||
line = nullptr;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
line->SetStartPoint( p );
|
line->SetStartPoint( p );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( wirevector.y > 0 )
|
if( wirevector.y > 0 )
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( linestart,
|
wxPoint p = linestart + entrySize( 1, -1 );
|
||||||
true );
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
|
|
||||||
moveLabels( line, linestart + wxPoint( 100, -100 ) );
|
moveLabels( line, linestart + wxPoint( 100, -100 ) );
|
||||||
|
|
||||||
if( linestart + wxPoint( 100, -100 )
|
if( p == lineend ) // wire is overlapped by bus entry symbol
|
||||||
== lineend ) // wire is overlapped by bus entry symbol
|
|
||||||
{
|
|
||||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||||
line = nullptr;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
line->SetStartPoint( p );
|
||||||
line->SetStartPoint( linestart + wxPoint( 100, -100 ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry =
|
wxPoint p = linestart + entrySize( 1, 1 );
|
||||||
new SCH_BUS_WIRE_ENTRY( linestart, false );
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, linestart + wxPoint( 100, 100 ) );
|
moveLabels( line, p );
|
||||||
|
|
||||||
if( linestart + wxPoint( 100, 100 )
|
if( p == lineend ) // wire is overlapped by bus entry symbol
|
||||||
== lineend ) // wire is overlapped by bus entry symbol
|
|
||||||
{
|
|
||||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||||
line = nullptr;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
line->SetStartPoint( p );
|
||||||
line->SetStartPoint( linestart + wxPoint( 100, 100 ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if( testBusHit( lineend ) )
|
||||||
if( line && TestSegmentHit( lineend, busstart, busend, 0 ) )
|
|
||||||
{
|
{
|
||||||
wxPoint wirevector = linestart - lineend;
|
wxPoint wirevector = linestart - lineend;
|
||||||
|
|
||||||
|
@ -2687,76 +2737,60 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
||||||
{
|
{
|
||||||
if( wirevector.y > 0 )
|
if( wirevector.y > 0 )
|
||||||
{
|
{
|
||||||
wxPoint p = lineend + wxPoint( 100, 100 );
|
wxPoint p = lineend + entrySize( 1, 1 );
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( lineend, false );
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
|
|
||||||
moveLabels( line, p );
|
moveLabels( line, p );
|
||||||
|
|
||||||
if( p == linestart ) // wire is overlapped by bus entry symbol
|
if( p == linestart ) // wire is overlapped by bus entry symbol
|
||||||
{
|
|
||||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
line->SetEndPoint( p );
|
line->SetEndPoint( p );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxPoint p = lineend + wxPoint( 100, -100 );
|
wxPoint p = lineend + entrySize( 1, -1 );
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( lineend, true );
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
|
|
||||||
moveLabels( line, p );
|
moveLabels( line, p );
|
||||||
|
|
||||||
if( p == linestart ) // wire is overlapped by bus entry symbol
|
if( p == linestart ) // wire is overlapped by bus entry symbol
|
||||||
{
|
|
||||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
line->SetEndPoint( p );
|
line->SetEndPoint( p );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( wirevector.y > 0 )
|
if( wirevector.y > 0 )
|
||||||
{
|
{
|
||||||
wxPoint p = lineend + wxPoint( -100, 100 );
|
wxPoint p = lineend + entrySize( -1, 1 );
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, true );
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, p );
|
moveLabels( line, p );
|
||||||
|
|
||||||
if( p == linestart ) // wire is overlapped by bus entry symbol
|
if( p == linestart ) // wire is overlapped by bus entry symbol
|
||||||
{
|
|
||||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
line->SetEndPoint( p );
|
line->SetEndPoint( p );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxPoint p = lineend + wxPoint( -100, -100 );
|
wxPoint p = lineend + entrySize( -1, -1 );
|
||||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, false );
|
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||||
busEntry->SetFlags( IS_NEW );
|
busEntry->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( busEntry );
|
m_currentSheet->GetScreen()->Append( busEntry );
|
||||||
moveLabels( line, p );
|
moveLabels( line, p );
|
||||||
|
|
||||||
if( p == linestart ) // wire is overlapped by bus entry symbol
|
if( p == linestart ) // wire is overlapped by bus entry symbol
|
||||||
{
|
|
||||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
line->SetEndPoint( p );
|
line->SetEndPoint( p );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue