altium: parse fonts from sheet record and use them for label styling
This commit is contained in:
parent
a6072a40f5
commit
1ce215a1f2
|
@ -175,7 +175,10 @@ ASCH_LABEL::ASCH_LABEL( const std::map<wxString, wxString>& aProperties )
|
||||||
-PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) );
|
-PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) );
|
||||||
|
|
||||||
text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" );
|
text = ALTIUM_PARSER::PropertiesReadString( aProperties, "TEXT", "" );
|
||||||
|
|
||||||
|
fontId = ALTIUM_PARSER::PropertiesReadInt( aProperties, "FONTID", 0 );
|
||||||
isMirrored = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISMIRRORED", false );
|
isMirrored = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ISMIRRORED", false );
|
||||||
|
|
||||||
justification = PropertiesReadEnum<ASCH_LABEL_JUSTIFICATION>(
|
justification = PropertiesReadEnum<ASCH_LABEL_JUSTIFICATION>(
|
||||||
aProperties, "JUSTIFICATION", 0, 8, ASCH_LABEL_JUSTIFICATION::UNKNOWN );
|
aProperties, "JUSTIFICATION", 0, 8, ASCH_LABEL_JUSTIFICATION::UNKNOWN );
|
||||||
}
|
}
|
||||||
|
@ -422,6 +425,32 @@ ASCH_JUNCTION::ASCH_JUNCTION( const std::map<wxString, wxString>& aProperties )
|
||||||
-PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) );
|
-PropertiesReadKiCadUnitFrac( aProperties, "LOCATION.Y" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASCH_SHEET_FONT::ASCH_SHEET_FONT( const std::map<wxString, wxString>& aProperties, int aId )
|
||||||
|
{
|
||||||
|
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::SHEET );
|
||||||
|
|
||||||
|
const wxString sid = std::to_string( aId );
|
||||||
|
|
||||||
|
fontname = ALTIUM_PARSER::PropertiesReadString( aProperties, "FONTNAME" + sid, "" );
|
||||||
|
|
||||||
|
size = PropertiesReadKiCadUnitFrac( aProperties, "SIZE" + sid );
|
||||||
|
rotation = ALTIUM_PARSER::PropertiesReadInt( aProperties, "ROTATION" + sid, 0 );
|
||||||
|
|
||||||
|
italic = ALTIUM_PARSER::PropertiesReadBool( aProperties, "ITALIC" + sid, false );
|
||||||
|
bold = ALTIUM_PARSER::PropertiesReadBool( aProperties, "BOLD" + sid, false );
|
||||||
|
underline = ALTIUM_PARSER::PropertiesReadBool( aProperties, "UNDERLINE" + sid, false );
|
||||||
|
}
|
||||||
|
|
||||||
|
ASCH_SHEET::ASCH_SHEET( const std::map<wxString, wxString>& aProperties )
|
||||||
|
{
|
||||||
|
wxASSERT( PropertiesReadRecord( aProperties ) == ALTIUM_SCH_RECORD::SHEET );
|
||||||
|
|
||||||
|
int fontidcount = ALTIUM_PARSER::PropertiesReadInt( aProperties, "FONTIDCOUNT", 0 );
|
||||||
|
for( int i = 1; i <= fontidcount; i++ )
|
||||||
|
{
|
||||||
|
fonts.emplace_back( aProperties, i );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map<wxString, wxString>& aProperties )
|
ASCH_DESIGNATOR::ASCH_DESIGNATOR( const std::map<wxString, wxString>& aProperties )
|
||||||
{
|
{
|
||||||
|
|
|
@ -221,7 +221,10 @@ struct ASCH_LABEL
|
||||||
wxPoint location;
|
wxPoint location;
|
||||||
|
|
||||||
wxString text;
|
wxString text;
|
||||||
|
|
||||||
|
int fontId;
|
||||||
bool isMirrored;
|
bool isMirrored;
|
||||||
|
|
||||||
ASCH_LABEL_JUSTIFICATION justification;
|
ASCH_LABEL_JUSTIFICATION justification;
|
||||||
|
|
||||||
explicit ASCH_LABEL( const std::map<wxString, wxString>& aProperties );
|
explicit ASCH_LABEL( const std::map<wxString, wxString>& aProperties );
|
||||||
|
@ -407,6 +410,28 @@ struct ASCH_JUNCTION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct ASCH_SHEET_FONT
|
||||||
|
{
|
||||||
|
wxString fontname;
|
||||||
|
|
||||||
|
int size;
|
||||||
|
int rotation;
|
||||||
|
|
||||||
|
bool italic;
|
||||||
|
bool bold;
|
||||||
|
bool underline;
|
||||||
|
|
||||||
|
explicit ASCH_SHEET_FONT( const std::map<wxString, wxString>& aProperties, int aId );
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ASCH_SHEET
|
||||||
|
{
|
||||||
|
std::vector<ASCH_SHEET_FONT> fonts;
|
||||||
|
|
||||||
|
explicit ASCH_SHEET( const std::map<wxString, wxString>& aProperties );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct ASCH_DESIGNATOR
|
struct ASCH_DESIGNATOR
|
||||||
{
|
{
|
||||||
int ownerindex;
|
int ownerindex;
|
||||||
|
|
|
@ -365,6 +365,7 @@ void SCH_ALTIUM_PLUGIN::Parse( const CFB::CompoundFileReader& aReader )
|
||||||
case ALTIUM_SCH_RECORD::IMAGE:
|
case ALTIUM_SCH_RECORD::IMAGE:
|
||||||
break;
|
break;
|
||||||
case ALTIUM_SCH_RECORD::SHEET:
|
case ALTIUM_SCH_RECORD::SHEET:
|
||||||
|
ParseSheet( properties );
|
||||||
break;
|
break;
|
||||||
case ALTIUM_SCH_RECORD::SHEET_NAME:
|
case ALTIUM_SCH_RECORD::SHEET_NAME:
|
||||||
break;
|
break;
|
||||||
|
@ -652,6 +653,7 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map<wxString, wxString>& aPropert
|
||||||
{
|
{
|
||||||
ASCH_LABEL elem( aProperties );
|
ASCH_LABEL elem( aProperties );
|
||||||
|
|
||||||
|
// TODO: text variable support
|
||||||
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
|
if( elem.ownerpartid == ALTIUM_COMPONENT_NONE )
|
||||||
{
|
{
|
||||||
SCH_TEXT* text = new SCH_TEXT( elem.location, elem.text );
|
SCH_TEXT* text = new SCH_TEXT( elem.location, elem.text );
|
||||||
|
@ -659,6 +661,15 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map<wxString, wxString>& aPropert
|
||||||
|
|
||||||
SetEdaTextJustification( text, elem.justification );
|
SetEdaTextJustification( text, elem.justification );
|
||||||
|
|
||||||
|
size_t fontId = static_cast<int>( elem.fontId );
|
||||||
|
if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() )
|
||||||
|
{
|
||||||
|
const ASCH_SHEET_FONT& font = m_altiumSheet->fonts.at( fontId - 1 );
|
||||||
|
text->SetItalic( font.italic );
|
||||||
|
text->SetBold( font.bold );
|
||||||
|
text->SetTextSize( { font.size / 2, font.size / 2 } );
|
||||||
|
}
|
||||||
|
|
||||||
text->SetFlags( IS_NEW );
|
text->SetFlags( IS_NEW );
|
||||||
m_currentSheet->GetScreen()->Append( text );
|
m_currentSheet->GetScreen()->Append( text );
|
||||||
}
|
}
|
||||||
|
@ -683,6 +694,15 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map<wxString, wxString>& aPropert
|
||||||
text->SetText( elem.text );
|
text->SetText( elem.text );
|
||||||
|
|
||||||
SetEdaTextJustification( text, elem.justification );
|
SetEdaTextJustification( text, elem.justification );
|
||||||
|
|
||||||
|
size_t fontId = static_cast<int>( elem.fontId );
|
||||||
|
if( m_altiumSheet && fontId > 0 && fontId <= m_altiumSheet->fonts.size() )
|
||||||
|
{
|
||||||
|
const ASCH_SHEET_FONT& font = m_altiumSheet->fonts.at( fontId - 1 );
|
||||||
|
text->SetItalic( font.italic );
|
||||||
|
text->SetBold( font.bold );
|
||||||
|
text->SetTextSize( { font.size / 2, font.size / 2 } );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1219,6 +1239,12 @@ void SCH_ALTIUM_PLUGIN::ParseJunction( const std::map<wxString, wxString>& aProp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SCH_ALTIUM_PLUGIN::ParseSheet( const std::map<wxString, wxString>& aProperties )
|
||||||
|
{
|
||||||
|
m_altiumSheet = std::make_unique<ASCH_SHEET>( aProperties );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SCH_ALTIUM_PLUGIN::ParseDesignator( const std::map<wxString, wxString>& aProperties )
|
void SCH_ALTIUM_PLUGIN::ParseDesignator( const std::map<wxString, wxString>& aProperties )
|
||||||
{
|
{
|
||||||
ASCH_DESIGNATOR elem( aProperties );
|
ASCH_DESIGNATOR elem( aProperties );
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include <sch_io_mgr.h>
|
#include <sch_io_mgr.h>
|
||||||
#include <wx/filename.h>
|
#include <wx/filename.h>
|
||||||
|
|
||||||
|
struct ASCH_SHEET;
|
||||||
|
|
||||||
class SCH_COMPONENT;
|
class SCH_COMPONENT;
|
||||||
|
|
||||||
namespace CFB
|
namespace CFB
|
||||||
|
@ -113,6 +115,7 @@ private:
|
||||||
void ParseBus( const std::map<wxString, wxString>& aProperties );
|
void ParseBus( const std::map<wxString, wxString>& aProperties );
|
||||||
void ParseWire( const std::map<wxString, wxString>& aProperties );
|
void ParseWire( const std::map<wxString, wxString>& aProperties );
|
||||||
void ParseJunction( const std::map<wxString, wxString>& aProperties );
|
void ParseJunction( const std::map<wxString, wxString>& aProperties );
|
||||||
|
void ParseSheet( const std::map<wxString, wxString>& aProperties );
|
||||||
void ParseDesignator( const std::map<wxString, wxString>& aProperties );
|
void ParseDesignator( const std::map<wxString, wxString>& aProperties );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -125,6 +128,7 @@ private:
|
||||||
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi; ///< Plugin to create the KiCad symbol library.
|
SCH_PLUGIN::SCH_PLUGIN_RELEASER m_pi; ///< Plugin to create the KiCad symbol library.
|
||||||
std::unique_ptr<PROPERTIES> m_properties; ///< Library plugin properties.
|
std::unique_ptr<PROPERTIES> m_properties; ///< Library plugin properties.
|
||||||
|
|
||||||
|
std::unique_ptr<ASCH_SHEET> m_altiumSheet;
|
||||||
std::map<int, SCH_COMPONENT*> m_components;
|
std::map<int, SCH_COMPONENT*> m_components;
|
||||||
std::map<int, LIB_PART*> m_symbols; // for the start, every component has its unique symbol
|
std::map<int, LIB_PART*> m_symbols; // for the start, every component has its unique symbol
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue