Import HARNESS_ENTRY as Hierarchical sheet pins

This commit is contained in:
WhiteChairFromIkea 2022-08-09 15:15:42 +03:00 committed by Jeff Young
parent 14ceece4f6
commit 15549364d5
4 changed files with 111 additions and 11 deletions

View File

@ -448,6 +448,31 @@ ASCH_HARNESS_CONNECTOR::ASCH_HARNESS_CONNECTOR( const std::map<wxString, wxStrin
} }
// Based on "ASCH_SHEET_ENTRY" import
ASCH_HARNESS_ENTRY::ASCH_HARNESS_ENTRY( const std::map<wxString, wxString>& aProps )
{
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::HARNESS_ENTRY );
// ownerindex = ReadOwnerIndex( aProps ); // use SCH_ALTIUM_PLUGIN::m_harnessEntryParent instead, because this property sometimes does not exist in altium file!
ownerpartid = ReadOwnerPartId( aProps );
indexInSheet = ALTIUM_PARSER::ReadInt( aProps, "INDEXINSHEET", 0 );
distanceFromTop = ReadKiCadUnitFrac1( aProps, "DISTANCEFROMTOP" );
side = ReadEnum<ASCH_SHEET_ENTRY_SIDE>( aProps, "SIDE", 0, 3, ASCH_SHEET_ENTRY_SIDE::LEFT );
name = ALTIUM_PARSER::ReadString( aProps, "NAME", "" );
ownerIndexAdditionalList = ALTIUM_PARSER::ReadBool( aProps, "OWNERINDEXADDITIONALLIST", true );
color = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 );
areaColor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 );
textColor = ALTIUM_PARSER::ReadInt( aProps, "TEXTCOLOR", 0 );
textFontId = ALTIUM_PARSER::ReadInt( aProps, "TEXTFONTID", 0 );
}
ASCH_RECTANGLE::ASCH_RECTANGLE( const std::map<wxString, wxString>& aProps ) ASCH_RECTANGLE::ASCH_RECTANGLE( const std::map<wxString, wxString>& aProps )
{ {
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::RECTANGLE ); wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::RECTANGLE );

View File

@ -100,7 +100,7 @@ enum class ALTIUM_SCH_RECORD
NOTE = 209, NOTE = 209,
COMPILE_MASK = 211, COMPILE_MASK = 211,
HARNESS_CONNECTOR = 215, HARNESS_CONNECTOR = 215,
RECORD_216 = 216, HARNESS_ENTRY = 216,
RECORD_217 = 217, RECORD_217 = 217,
SIGNAL_HARNESS = 218, SIGNAL_HARNESS = 218,
RECORD_226 = 226, RECORD_226 = 226,
@ -337,6 +337,15 @@ enum class ASCH_POLYLINE_LINESTYLE
}; };
enum class ASCH_SHEET_ENTRY_SIDE
{
LEFT = 0,
RIGHT = 1,
TOP = 2,
BOTTOM = 3
};
struct ASCH_POLYLINE struct ASCH_POLYLINE
{ {
int ownerindex; int ownerindex;
@ -444,6 +453,28 @@ struct ASCH_HARNESS_CONNECTOR
}; };
struct ASCH_HARNESS_ENTRY
{
// int ownerindex; // Completely random, mostly this entry exists, but not always, should not be used!
int ownerpartid; // always -1, can be safely ignored I think
int areaColor;
int color;
int distanceFromTop;
int indexInSheet;
int textColor;
int textFontId;
int textStyle;
bool ownerIndexAdditionalList; // what is that?
wxString name;
ASCH_SHEET_ENTRY_SIDE side;
explicit ASCH_HARNESS_ENTRY( const std::map<wxString, wxString>& aProps );
};
struct ASCH_RECTANGLE : ASCH_SHAPE_INTERFACE struct ASCH_RECTANGLE : ASCH_SHAPE_INTERFACE
{ {
VECTOR2I bottomLeft; VECTOR2I bottomLeft;
@ -469,15 +500,6 @@ struct ASCH_SHEET_SYMBOL
}; };
enum class ASCH_SHEET_ENTRY_SIDE
{
LEFT = 0,
RIGHT = 1,
TOP = 2,
BOTTOM = 3
};
enum class ASCH_PORT_IOTYPE enum class ASCH_PORT_IOTYPE
{ {
UNSPECIFIED = 0, UNSPECIFIED = 0,

View File

@ -378,7 +378,8 @@ void SCH_ALTIUM_PLUGIN::ParseAdditional( const ALTIUM_COMPOUND_FILE& aAltiumSchF
case ALTIUM_SCH_RECORD::HARNESS_CONNECTOR: case ALTIUM_SCH_RECORD::HARNESS_CONNECTOR:
ParseHarnessConnector( index, properties ); ParseHarnessConnector( index, properties );
break; break;
case ALTIUM_SCH_RECORD::RECORD_216: case ALTIUM_SCH_RECORD::HARNESS_ENTRY:
ParseHarnessEntry( properties );
break; break;
case ALTIUM_SCH_RECORD::RECORD_217: case ALTIUM_SCH_RECORD::RECORD_217:
break; break;
@ -565,6 +566,7 @@ void SCH_ALTIUM_PLUGIN::ParseFileHeader( const ALTIUM_COMPOUND_FILE& aAltiumSchF
RPT_SEVERITY_ERROR ); RPT_SEVERITY_ERROR );
break; break;
} }
SCH_ALTIUM_PLUGIN::m_harnessOwnerIndexOffset = index;
} }
if( reader.HasParsingError() ) if( reader.HasParsingError() )
@ -1524,6 +1526,56 @@ void SCH_ALTIUM_PLUGIN::ParseHarnessConnector( int aIndex, const std::map<wxStri
} }
void SCH_ALTIUM_PLUGIN::ParseHarnessEntry( const std::map<wxString, wxString>& aProperties )
{
ASCH_HARNESS_ENTRY elem( aProperties );
const auto& sheetIt = m_sheets.find( m_harnessEntryParent );
if( sheetIt == m_sheets.end() )
{
m_reporter->Report( wxString::Format( _( "Harness entry's paren (%d) not found." ),
SCH_ALTIUM_PLUGIN::m_harnessEntryParent ),
RPT_SEVERITY_ERROR );
return;
}
SCH_SHEET_PIN* sheetPin = new SCH_SHEET_PIN( sheetIt->second );
sheetIt->second->AddPin( sheetPin );
sheetPin->SetText( elem.name );
sheetPin->SetShape( LABEL_FLAG_SHAPE::L_UNSPECIFIED );
VECTOR2I pos = sheetIt->second->GetPosition();
wxSize size = sheetIt->second->GetSize();
switch( elem.side )
{
default:
case ASCH_SHEET_ENTRY_SIDE::LEFT:
sheetPin->SetPosition( { pos.x, pos.y + elem.distanceFromTop } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::LEFT );
sheetPin->SetSide( SHEET_SIDE::LEFT );
break;
case ASCH_SHEET_ENTRY_SIDE::RIGHT:
sheetPin->SetPosition( { pos.x + size.x, pos.y + elem.distanceFromTop } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::RIGHT );
sheetPin->SetSide( SHEET_SIDE::RIGHT );
break;
case ASCH_SHEET_ENTRY_SIDE::TOP:
sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::UP );
sheetPin->SetSide( SHEET_SIDE::TOP );
break;
case ASCH_SHEET_ENTRY_SIDE::BOTTOM:
sheetPin->SetPosition( { pos.x + elem.distanceFromTop, pos.y + size.y } );
sheetPin->SetTextSpinStyle( TEXT_SPIN_STYLE::BOTTOM );
sheetPin->SetSide( SHEET_SIDE::BOTTOM );
break;
}
}
void SCH_ALTIUM_PLUGIN::ParseRectangle( const std::map<wxString, wxString>& aProperties ) void SCH_ALTIUM_PLUGIN::ParseRectangle( const std::map<wxString, wxString>& aProperties )
{ {
ASCH_RECTANGLE elem( aProperties ); ASCH_RECTANGLE elem( aProperties );

View File

@ -123,6 +123,7 @@ private:
void ParseLine( const std::map<wxString, wxString>& aProperties ); void ParseLine( const std::map<wxString, wxString>& aProperties );
void ParseSignalHarness( const std::map<wxString, wxString>& aProperties ); void ParseSignalHarness( const std::map<wxString, wxString>& aProperties );
void ParseHarnessConnector( int aIndex, const std::map<wxString, wxString>& aProperties ); void ParseHarnessConnector( int aIndex, const std::map<wxString, wxString>& aProperties );
void ParseHarnessEntry( const std::map<wxString, wxString>& aProperties );
void ParseRectangle( const std::map<wxString, wxString>& aProperties ); void ParseRectangle( const std::map<wxString, wxString>& aProperties );
void ParseSheetSymbol( int aIndex, const std::map<wxString, wxString>& aProperties ); void ParseSheetSymbol( int aIndex, const std::map<wxString, wxString>& aProperties );
void ParseSheetEntry( const std::map<wxString, wxString>& aProperties ); void ParseSheetEntry( const std::map<wxString, wxString>& aProperties );