Fixes for Eagle importer.
1) Make sure we set an absolute path on the sheet. 2) Don't mix RTree iterators; wires get skipped between buses. 3) Implement a real ERC error so we don't assert. Fixes https://gitlab.com/kicad/code/kicad/issues/7042
This commit is contained in:
parent
decfe89091
commit
4b28bac89a
|
@ -150,6 +150,10 @@ ERC_ITEM ERC_ITEM::duplicateReference( ERCE_DUPLICATE_REFERENCE,
|
|||
_( "Duplicate reference designators" ),
|
||||
wxT( "duplicate_reference" ) );
|
||||
|
||||
ERC_ITEM ERC_ITEM::busEntryNeeded( ERCE_BUS_ENTRY_NEEDED,
|
||||
_( "Bus Entry needed" ),
|
||||
wxT( "bus_entry_needed" ) );
|
||||
|
||||
std::vector<std::reference_wrapper<RC_ITEM>> ERC_ITEM::allItemTypes( {
|
||||
ERC_ITEM::heading_connections,
|
||||
ERC_ITEM::pinNotConnected,
|
||||
|
@ -160,6 +164,7 @@ std::vector<std::reference_wrapper<RC_ITEM>> ERC_ITEM::allItemTypes( {
|
|||
ERC_ITEM::labelDangling,
|
||||
ERC_ITEM::globalLabelDangling,
|
||||
ERC_ITEM::wireDangling,
|
||||
ERC_ITEM::busEntryNeeded,
|
||||
|
||||
ERC_ITEM::heading_conflicts,
|
||||
ERC_ITEM::duplicateReference,
|
||||
|
@ -217,6 +222,7 @@ std::shared_ptr<ERC_ITEM> ERC_ITEM::Create( int aErrorCode )
|
|||
case ERCE_EXTRA_UNITS: return std::make_shared<ERC_ITEM>( extraUnits );
|
||||
case ERCE_DIFFERENT_UNIT_VALUE: return std::make_shared<ERC_ITEM>( differentUnitValue );
|
||||
case ERCE_DUPLICATE_REFERENCE: return std::make_shared<ERC_ITEM>( duplicateReference );
|
||||
case ERCE_BUS_ENTRY_NEEDED: return std::make_shared<ERC_ITEM>( busEntryNeeded );
|
||||
case ERCE_UNSPECIFIED:
|
||||
default:
|
||||
wxFAIL_MSG( "Unknown ERC error code" );
|
||||
|
|
|
@ -98,6 +98,7 @@ private:
|
|||
static ERC_ITEM extraUnits;
|
||||
static ERC_ITEM differentUnitValue;
|
||||
static ERC_ITEM duplicateReference;
|
||||
static ERC_ITEM busEntryNeeded;
|
||||
|
||||
/// True if this item is specific to a sheet instance (as opposed to applying to all instances)
|
||||
bool m_sheetSpecific;
|
||||
|
|
|
@ -69,8 +69,9 @@ enum ERCE_T
|
|||
ERCE_EXTRA_UNITS, ///< Symbol has more units than are defined.
|
||||
ERCE_DIFFERENT_UNIT_VALUE, ///< Units of same symbol have different values.
|
||||
ERCE_DUPLICATE_REFERENCE, ///< More than one symbol with the same reference.
|
||||
ERCE_BUS_ENTRY_NEEDED, ///< Importer failed to auto-place a bus entry.
|
||||
|
||||
ERCE_LAST = ERCE_DUPLICATE_REFERENCE,
|
||||
ERCE_LAST = ERCE_BUS_ENTRY_NEEDED,
|
||||
|
||||
// Errors after this point will not automatically appear in the Severities Panel
|
||||
|
||||
|
|
|
@ -718,10 +718,12 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode, int aSheetIndex )
|
|||
ReplaceIllegalFileNameChars( &filename );
|
||||
replace( filename.begin(), filename.end(), ' ', '_' );
|
||||
|
||||
wxString fn = wxString( filename + "." + KiCadSchematicFileExtension );
|
||||
filenameField.SetText( fn );
|
||||
wxFileName fileName( fn );
|
||||
m_currentSheet->GetScreen()->SetFileName( fileName.GetFullPath() );
|
||||
wxFileName fn( m_filename );
|
||||
fn.SetName( filename );
|
||||
fn.SetExt( KiCadSchematicFileExtension );
|
||||
|
||||
filenameField.SetText( fn.GetFullName() );
|
||||
m_currentSheet->GetScreen()->SetFileName( fn.GetFullPath() );
|
||||
m_currentSheet->AutoplaceFields( m_currentSheet->GetScreen(), true );
|
||||
|
||||
|
||||
|
@ -2249,17 +2251,15 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
// for each wire segment, compare each end with all busses.
|
||||
// If the wire end is found to end on a bus segment, place a bus entry symbol.
|
||||
|
||||
for( auto it1 = m_currentSheet->GetScreen()->Items().OfType( SCH_LINE_T ).begin();
|
||||
it1 != m_currentSheet->GetScreen()->Items().end(); ++it1 )
|
||||
for( SCH_ITEM* ii : m_currentSheet->GetScreen()->Items().OfType( SCH_LINE_T ) )
|
||||
{
|
||||
SCH_LINE* bus = static_cast<SCH_LINE*>( *it1 );
|
||||
SCH_LINE* bus = static_cast<SCH_LINE*>( ii );
|
||||
|
||||
// Check line type for wire
|
||||
if( bus->GetLayer() != LAYER_BUS )
|
||||
if( !bus->IsBus() )
|
||||
continue;
|
||||
|
||||
wxPoint busstart = bus->GetStartPoint();
|
||||
wxPoint busend = bus->GetEndPoint();
|
||||
wxPoint busStart = bus->GetStartPoint();
|
||||
wxPoint busEnd = bus->GetEndPoint();
|
||||
|
||||
auto entrySize =
|
||||
[]( int signX, int signY ) -> wxPoint
|
||||
|
@ -2271,39 +2271,35 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
auto testBusHit =
|
||||
[&]( const wxPoint& aPt ) -> bool
|
||||
{
|
||||
return TestSegmentHit( aPt, busstart, busend, 0 );
|
||||
return TestSegmentHit( aPt, busStart, busEnd, 0 );
|
||||
};
|
||||
|
||||
auto it2 = it1;
|
||||
++it2;
|
||||
|
||||
for( ; it2 != m_currentSheet->GetScreen()->Items().end(); ++it2 )
|
||||
for( SCH_ITEM* jj : m_currentSheet->GetScreen()->Items().OfType( SCH_LINE_T ) )
|
||||
{
|
||||
SCH_LINE* line = static_cast<SCH_LINE*>( *it2 );
|
||||
SCH_LINE* wire = static_cast<SCH_LINE*>( jj );
|
||||
|
||||
// Check line type for bus
|
||||
if( ( (SCH_LINE*) *it2 )->GetLayer() == LAYER_WIRE )
|
||||
{
|
||||
// Get points of both segments.
|
||||
wxPoint linestart = line->GetStartPoint();
|
||||
wxPoint lineend = line->GetEndPoint();
|
||||
if( !wire->IsWire() )
|
||||
continue;
|
||||
|
||||
wxPoint wireStart = wire->GetStartPoint();
|
||||
wxPoint wireEnd = wire->GetEndPoint();
|
||||
|
||||
// Test for horizontal wire and vertical bus
|
||||
if( linestart.y == lineend.y && busstart.x == busend.x )
|
||||
if( wireStart.y == wireEnd.y && busStart.x == busEnd.x )
|
||||
{
|
||||
if( testBusHit( linestart ) )
|
||||
if( testBusHit( wireStart ) )
|
||||
{
|
||||
// Wire start is on the vertical bus
|
||||
|
||||
if( lineend.x < busstart.x )
|
||||
if( wireEnd.x < busStart.x )
|
||||
{
|
||||
// the end of the wire is to the left of the bus
|
||||
// |
|
||||
// ----|
|
||||
// |
|
||||
wxPoint p = linestart + entrySize( -1, 0 );
|
||||
wxPoint p = wireStart + entrySize( -1, 0 );
|
||||
|
||||
if( testBusHit( linestart + entrySize( 0, -1 ) ) )
|
||||
if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
|
||||
{
|
||||
// there is room above the wire for the bus entry
|
||||
// |
|
||||
|
@ -2312,10 +2308,10 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
else if( testBusHit( linestart + entrySize( 0, 1 ) ) )
|
||||
else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
|
||||
{
|
||||
// there is room below the wire for the bus entry
|
||||
// ___ |
|
||||
|
@ -2324,15 +2320,13 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
|
||||
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, linestart );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, wireStart );
|
||||
m_currentSheet->GetScreen()->Append( marker );
|
||||
}
|
||||
}
|
||||
|
@ -2342,9 +2336,9 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
// |
|
||||
// |----
|
||||
// |
|
||||
wxPoint p = linestart + entrySize( 1, 0 );
|
||||
wxPoint p = wireStart + entrySize( 1, 0 );
|
||||
|
||||
if( testBusHit( linestart + entrySize( 0, -1 ) ) )
|
||||
if( testBusHit( wireStart + entrySize( 0, -1 ) ) )
|
||||
{
|
||||
// There is room above the wire for the bus entry
|
||||
// |
|
||||
|
@ -2353,10 +2347,10 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p , 4 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
else if( testBusHit( linestart + entrySize( 0, 1 ) ) )
|
||||
else if( testBusHit( wireStart + entrySize( 0, 1 ) ) )
|
||||
{
|
||||
// There is room below the wire for the bus entry
|
||||
// | ___
|
||||
|
@ -2365,34 +2359,32 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
|
||||
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, linestart );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, wireStart );
|
||||
m_currentSheet->GetScreen()->Append( marker );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Same thing but test end of the wire instead.
|
||||
if( testBusHit( lineend ) )
|
||||
if( testBusHit( wireEnd ) )
|
||||
{
|
||||
// Wire end is on the vertical bus
|
||||
|
||||
if( linestart.x < busstart.x )
|
||||
if( wireStart.x < busStart.x )
|
||||
{
|
||||
// start of the wire is to the left of the bus
|
||||
// |
|
||||
// ----|
|
||||
// |
|
||||
wxPoint p = lineend + entrySize( -1, 0 );
|
||||
wxPoint p = wireEnd + entrySize( -1, 0 );
|
||||
|
||||
if( testBusHit( lineend + entrySize( 0, -1 ) ) )
|
||||
if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
|
||||
{
|
||||
// there is room above the wire for the bus entry
|
||||
// |
|
||||
|
@ -2401,10 +2393,10 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
else if( testBusHit( lineend + entrySize( 0, -1 ) ) )
|
||||
else if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
|
||||
{
|
||||
// there is room below the wire for the bus entry
|
||||
// ___ |
|
||||
|
@ -2413,15 +2405,13 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, lineend + entrySize( -1, 0 ) );
|
||||
line->SetEndPoint( lineend + entrySize( -1, 0 ) );
|
||||
moveLabels( wire, wireEnd + entrySize( -1, 0 ) );
|
||||
wire->SetEndPoint( wireEnd + entrySize( -1, 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
|
||||
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, lineend );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, wireEnd );
|
||||
m_currentSheet->GetScreen()->Append( marker );
|
||||
}
|
||||
}
|
||||
|
@ -2431,9 +2421,9 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
// |
|
||||
// |----
|
||||
// |
|
||||
wxPoint p = lineend + entrySize( 1, 0 );
|
||||
wxPoint p = wireEnd + entrySize( 1, 0 );
|
||||
|
||||
if( testBusHit( lineend + entrySize( 0, -1 ) ) )
|
||||
if( testBusHit( wireEnd + entrySize( 0, -1 ) ) )
|
||||
{
|
||||
// There is room above the wire for the bus entry
|
||||
// |
|
||||
|
@ -2442,10 +2432,10 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
else if( testBusHit( lineend + entrySize( 0, 1 ) ) )
|
||||
else if( testBusHit( wireEnd + entrySize( 0, 1 ) ) )
|
||||
{
|
||||
// There is room below the wire for the bus entry
|
||||
// | ___
|
||||
|
@ -2454,37 +2444,35 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
|
||||
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, lineend );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, wireEnd );
|
||||
m_currentSheet->GetScreen()->Append( marker );
|
||||
}
|
||||
}
|
||||
}
|
||||
} // if( linestart.y == lineend.y && busstart.x == busend.x)
|
||||
} // if( wireStart.y == wireEnd.y && busStart.x == busEnd.x)
|
||||
|
||||
// Test for vertical wire and horizontal bus
|
||||
if( linestart.x == lineend.x && busstart.y == busend.y )
|
||||
if( wireStart.x == wireEnd.x && busStart.y == busEnd.y )
|
||||
{
|
||||
if( testBusHit( linestart ) )
|
||||
if( testBusHit( wireStart ) )
|
||||
{
|
||||
// Wire start is on the bus
|
||||
|
||||
if( lineend.y < busstart.y )
|
||||
if( wireEnd.y < busStart.y )
|
||||
{
|
||||
// the end of the wire is above the bus
|
||||
// |
|
||||
// |
|
||||
// -----
|
||||
wxPoint p = linestart + entrySize( 0, -1 );
|
||||
wxPoint p = wireStart + entrySize( 0, -1 );
|
||||
|
||||
if( testBusHit( linestart + entrySize( -1, 0 ) ) )
|
||||
if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
|
||||
{
|
||||
// there is room to the left of the wire for the bus entry
|
||||
// |
|
||||
|
@ -2494,10 +2482,10 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
else if( testBusHit( linestart + entrySize( 1, 0 ) ) )
|
||||
else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
|
||||
{
|
||||
// there is room to the right of the wire for the bus entry
|
||||
// |
|
||||
|
@ -2507,15 +2495,13 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
|
||||
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, linestart );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, wireStart );
|
||||
m_currentSheet->GetScreen()->Append( marker );
|
||||
}
|
||||
}
|
||||
|
@ -2525,9 +2511,9 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
// -----
|
||||
// |
|
||||
// |
|
||||
wxPoint p = linestart + entrySize( 0, 1 );
|
||||
wxPoint p = wireStart + entrySize( 0, 1 );
|
||||
|
||||
if( testBusHit( linestart + entrySize( -1, 0 ) ) )
|
||||
if( testBusHit( wireStart + entrySize( -1, 0 ) ) )
|
||||
{
|
||||
// there is room to the left of the wire for the bus entry
|
||||
// -----
|
||||
|
@ -2537,10 +2523,10 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
else if( testBusHit( linestart + entrySize( 1, 0 ) ) )
|
||||
else if( testBusHit( wireStart + entrySize( 1, 0 ) ) )
|
||||
{
|
||||
// there is room to the right of the wire for the bus entry
|
||||
// -----
|
||||
|
@ -2550,33 +2536,31 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
|
||||
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, linestart );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, wireStart );
|
||||
m_currentSheet->GetScreen()->Append( marker );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( testBusHit( lineend ) )
|
||||
if( testBusHit( wireEnd ) )
|
||||
{
|
||||
// Wire end is on the bus
|
||||
|
||||
if( linestart.y < busstart.y )
|
||||
if( wireStart.y < busStart.y )
|
||||
{
|
||||
// the start of the wire is above the bus
|
||||
// |
|
||||
// |
|
||||
// -----
|
||||
wxPoint p = lineend + entrySize( 0, -1 );
|
||||
wxPoint p = wireEnd + entrySize( 0, -1 );
|
||||
|
||||
if( testBusHit( lineend + entrySize( -1, 0 ) ) )
|
||||
if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
|
||||
{
|
||||
// there is room to the left of the wire for the bus entry
|
||||
// |
|
||||
|
@ -2586,10 +2570,10 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
else if( testBusHit( lineend + entrySize( 1, 0 ) ) )
|
||||
else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
|
||||
{
|
||||
// there is room to the right of the wire for the bus entry
|
||||
// |
|
||||
|
@ -2599,15 +2583,13 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
|
||||
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, lineend );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, wireEnd );
|
||||
m_currentSheet->GetScreen()->Append( marker );
|
||||
}
|
||||
}
|
||||
|
@ -2617,9 +2599,9 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
// -----
|
||||
// |
|
||||
// |
|
||||
wxPoint p = lineend + entrySize( 0, 1 );
|
||||
wxPoint p = wireEnd + entrySize( 0, 1 );
|
||||
|
||||
if( testBusHit( lineend + entrySize( -1, 0 ) ) )
|
||||
if( testBusHit( wireEnd + entrySize( -1, 0 ) ) )
|
||||
{
|
||||
// there is room to the left of the wire for the bus entry
|
||||
// -----
|
||||
|
@ -2629,10 +2611,10 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
else if( testBusHit( lineend + entrySize( 1, 0 ) ) )
|
||||
else if( testBusHit( wireEnd + entrySize( 1, 0 ) ) )
|
||||
{
|
||||
// there is room to the right of the wire for the bus entry
|
||||
// -----
|
||||
|
@ -2642,160 +2624,129 @@ void SCH_EAGLE_PLUGIN::addBusEntries()
|
|||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( 0 );
|
||||
ercItem->SetErrorMessage( _( "Bus Entry needed" ) );
|
||||
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, lineend );
|
||||
auto ercItem = ERC_ITEM::Create( ERCE_BUS_ENTRY_NEEDED );
|
||||
SCH_MARKER* marker = new SCH_MARKER( ercItem, wireEnd );
|
||||
m_currentSheet->GetScreen()->Append( marker );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
linestart = line->GetStartPoint();
|
||||
lineend = line->GetEndPoint();
|
||||
busstart = bus->GetStartPoint();
|
||||
busend = bus->GetEndPoint();
|
||||
wireStart = wire->GetStartPoint();
|
||||
wireEnd = wire->GetEndPoint();
|
||||
busStart = bus->GetStartPoint();
|
||||
busEnd = bus->GetEndPoint();
|
||||
|
||||
// bus entry wire isn't horizontal or vertical
|
||||
if( testBusHit( linestart ) )
|
||||
if( testBusHit( wireStart ) )
|
||||
{
|
||||
wxPoint wirevector = linestart - lineend;
|
||||
wxPoint wirevector = wireStart - wireEnd;
|
||||
|
||||
if( wirevector.x > 0 )
|
||||
{
|
||||
if( wirevector.y > 0 )
|
||||
{
|
||||
wxPoint p = linestart + entrySize( -1, -1 );
|
||||
wxPoint p = wireStart + entrySize( -1, -1 );
|
||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
|
||||
if( p == lineend ) // wire is overlapped by bus entry symbol
|
||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||
else
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPoint p = linestart + entrySize( -1, 1 );
|
||||
wxPoint p = wireStart + entrySize( -1, 1 );
|
||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
|
||||
moveLabels( line, p );
|
||||
|
||||
if( p == lineend ) // wire is overlapped by bus entry symbol
|
||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||
else
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( wirevector.y > 0 )
|
||||
{
|
||||
wxPoint p = linestart + entrySize( 1, -1 );
|
||||
wxPoint p = wireStart + entrySize( 1, -1 );
|
||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
|
||||
moveLabels( line, p );
|
||||
|
||||
if( p == lineend ) // wire is overlapped by bus entry symbol
|
||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||
else
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPoint p = linestart + entrySize( 1, 1 );
|
||||
wxPoint p = wireStart + entrySize( 1, 1 );
|
||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
|
||||
if( p == lineend ) // wire is overlapped by bus entry symbol
|
||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||
else
|
||||
line->SetStartPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetStartPoint( p );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( testBusHit( lineend ) )
|
||||
else if( testBusHit( wireEnd ) )
|
||||
{
|
||||
wxPoint wirevector = linestart - lineend;
|
||||
wxPoint wirevector = wireStart - wireEnd;
|
||||
|
||||
if( wirevector.x > 0 )
|
||||
{
|
||||
if( wirevector.y > 0 )
|
||||
{
|
||||
wxPoint p = lineend + entrySize( 1, 1 );
|
||||
wxPoint p = wireEnd + entrySize( 1, 1 );
|
||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 4 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
|
||||
moveLabels( line, p );
|
||||
|
||||
if( p == linestart ) // wire is overlapped by bus entry symbol
|
||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||
else
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPoint p = lineend + entrySize( 1, -1 );
|
||||
wxPoint p = wireEnd + entrySize( 1, -1 );
|
||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 3 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
|
||||
moveLabels( line, p );
|
||||
|
||||
if( p == linestart ) // wire is overlapped by bus entry symbol
|
||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||
else
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( wirevector.y > 0 )
|
||||
{
|
||||
wxPoint p = lineend + entrySize( -1, 1 );
|
||||
wxPoint p = wireEnd + entrySize( -1, 1 );
|
||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 1 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
|
||||
if( p == linestart ) // wire is overlapped by bus entry symbol
|
||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||
else
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPoint p = lineend + entrySize( -1, -1 );
|
||||
wxPoint p = wireEnd + entrySize( -1, -1 );
|
||||
SCH_BUS_WIRE_ENTRY* busEntry = new SCH_BUS_WIRE_ENTRY( p, 2 );
|
||||
busEntry->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( busEntry );
|
||||
moveLabels( line, p );
|
||||
|
||||
if( p == linestart ) // wire is overlapped by bus entry symbol
|
||||
m_currentSheet->GetScreen()->DeleteItem( line );
|
||||
else
|
||||
line->SetEndPoint( p );
|
||||
moveLabels( wire, p );
|
||||
wire->SetEndPoint( p );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // for ( bus ..
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue