Altium: import NOTE and TEXT_FRAME as TextBoxes instead of text objects
This commit is contained in:
parent
6cfbf895fc
commit
742757b98b
|
@ -249,22 +249,29 @@ ASCH_TEXT_FRAME::ASCH_TEXT_FRAME( const std::map<wxString, wxString>& aProps )
|
|||
wxASSERT( ReadRecord( aProps ) == ALTIUM_SCH_RECORD::NOTE
|
||||
|| ReadRecord( aProps ) == ALTIUM_SCH_RECORD::TEXT_FRAME );
|
||||
|
||||
location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
|
||||
BottomLeft = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
|
||||
-ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
|
||||
size = wxSize( ReadKiCadUnitFrac( aProps, "CORNER.X" ) - location.x,
|
||||
-ReadKiCadUnitFrac( aProps, "CORNER.Y" ) - location.y );
|
||||
TopRight = VECTOR2I( ReadKiCadUnitFrac( aProps, "CORNER.X" ),
|
||||
-ReadKiCadUnitFrac( aProps, "CORNER.Y" ) );
|
||||
|
||||
text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" );
|
||||
text.Replace( "~1", "\n", true );
|
||||
Location = VECTOR2I( ReadKiCadUnitFrac( aProps, "LOCATION.X" ),
|
||||
-ReadKiCadUnitFrac( aProps, "LOCATION.Y" ) );
|
||||
Size = wxSize( ReadKiCadUnitFrac( aProps, "CORNER.X" ) - Location.x,
|
||||
-ReadKiCadUnitFrac( aProps, "CORNER.Y" ) - Location.y );
|
||||
|
||||
fontId = ALTIUM_PARSER::ReadInt( aProps, "FONTID", 0 );
|
||||
isWordWrapped = ALTIUM_PARSER::ReadBool( aProps, "WORDWRAP", false );
|
||||
border = ALTIUM_PARSER::ReadBool( aProps, "SHOWBORDER", false );
|
||||
textMargin = ReadKiCadUnitFrac( aProps, "TEXTMARGIN" );
|
||||
areaColor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 );
|
||||
Text = ALTIUM_PARSER::ReadString( aProps, "TEXT", "" );
|
||||
Text.Replace( "~1", "\n", true );
|
||||
|
||||
alignment = ReadEnum<ASCH_TEXT_FRAME_ALIGNMENT>( aProps, "ALIGNMENT", 1, 3,
|
||||
ASCH_TEXT_FRAME_ALIGNMENT::LEFT );
|
||||
FontID = ALTIUM_PARSER::ReadInt( aProps, "FONTID", 0 );
|
||||
IsWordWrapped = ALTIUM_PARSER::ReadBool( aProps, "WORDWRAP", false );
|
||||
ShowBorder = ALTIUM_PARSER::ReadBool( aProps, "SHOWBORDER", false );
|
||||
TextMargin = ReadKiCadUnitFrac( aProps, "TEXTMARGIN" );
|
||||
AreaColor = ALTIUM_PARSER::ReadInt( aProps, "AREACOLOR", 0 );
|
||||
BorderColor = ALTIUM_PARSER::ReadInt( aProps, "COLOR", 0 );
|
||||
|
||||
IsSolid = ALTIUM_PARSER::ReadBool( aProps, "WORDWRAP", true );
|
||||
|
||||
Alignment = ReadEnum<ASCH_TEXT_FRAME_ALIGNMENT>( aProps, "ALIGNMENT", 1, 3, ASCH_TEXT_FRAME_ALIGNMENT::LEFT );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -289,18 +289,24 @@ struct ASCH_LABEL
|
|||
|
||||
struct ASCH_TEXT_FRAME
|
||||
{
|
||||
VECTOR2I location;
|
||||
wxSize size;
|
||||
VECTOR2I Location;
|
||||
wxSize Size;
|
||||
// have both coordinates, for convenience
|
||||
VECTOR2I BottomLeft;
|
||||
VECTOR2I TopRight;
|
||||
|
||||
wxString text;
|
||||
wxString Text;
|
||||
|
||||
int fontId;
|
||||
bool isWordWrapped;
|
||||
bool border;
|
||||
int textMargin;
|
||||
int areaColor;
|
||||
bool IsWordWrapped; // to do when kicad supports this
|
||||
bool ShowBorder;
|
||||
bool IsSolid;
|
||||
|
||||
ASCH_TEXT_FRAME_ALIGNMENT alignment;
|
||||
int FontID;
|
||||
int TextMargin; // to do when kicad supports this
|
||||
int AreaColor;
|
||||
int BorderColor;
|
||||
|
||||
ASCH_TEXT_FRAME_ALIGNMENT Alignment;
|
||||
|
||||
explicit ASCH_TEXT_FRAME( const std::map<wxString, wxString>& aProps );
|
||||
};
|
||||
|
|
|
@ -975,82 +975,67 @@ void SCH_ALTIUM_PLUGIN::ParseLabel( const std::map<wxString, wxString>& aPropert
|
|||
void SCH_ALTIUM_PLUGIN::ParseTextFrame( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
ASCH_TEXT_FRAME elem( aProperties );
|
||||
|
||||
SCH_TEXT* text = new SCH_TEXT( elem.location + m_sheetOffset, elem.text );
|
||||
|
||||
switch( elem.alignment )
|
||||
{
|
||||
default:
|
||||
case ASCH_TEXT_FRAME_ALIGNMENT::LEFT:
|
||||
text->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::RIGHT );
|
||||
break;
|
||||
case ASCH_TEXT_FRAME_ALIGNMENT::CENTER:
|
||||
// No support for centered text in Eeschema yet...
|
||||
text->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::RIGHT );
|
||||
break;
|
||||
case ASCH_TEXT_FRAME_ALIGNMENT::RIGHT:
|
||||
text->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::LEFT );
|
||||
break;
|
||||
}
|
||||
|
||||
// JEY TODO: set size and word-wrap once KiCad supports wrapped text.
|
||||
|
||||
// JEY TODO: set border and background color once KiCad supports them.
|
||||
|
||||
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 );
|
||||
m_currentSheet->GetScreen()->Append( text );
|
||||
AddTextBox( &elem );
|
||||
}
|
||||
|
||||
|
||||
void SCH_ALTIUM_PLUGIN::ParseNote( const std::map<wxString, wxString>& aProperties )
|
||||
{
|
||||
{
|
||||
ASCH_NOTE elem( aProperties );
|
||||
AddTextBox( static_cast<ASCH_TEXT_FRAME*>( &elem ) );
|
||||
|
||||
SCH_TEXT* text = new SCH_TEXT( elem.location + m_sheetOffset, elem.text );
|
||||
// TODO: need some sort of property system for storing author....
|
||||
}
|
||||
|
||||
switch( elem.alignment )
|
||||
|
||||
void SCH_ALTIUM_PLUGIN::AddTextBox(const ASCH_TEXT_FRAME *aElem )
|
||||
{
|
||||
SCH_TEXTBOX* textBox = new SCH_TEXTBOX();
|
||||
|
||||
VECTOR2I sheetTopRight = aElem->TopRight + m_sheetOffset;
|
||||
VECTOR2I sheetBottomLeft = aElem->BottomLeft + m_sheetOffset;
|
||||
textBox->SetStart( sheetTopRight );
|
||||
textBox->SetEnd( sheetBottomLeft );
|
||||
|
||||
textBox->SetText( aElem->Text );
|
||||
|
||||
textBox->SetFillColor( GetColorFromInt( aElem->AreaColor ) );
|
||||
textBox->SetFilled( aElem->IsSolid );
|
||||
|
||||
if( aElem->ShowBorder )
|
||||
textBox->SetStroke( STROKE_PARAMS( 0, PLOT_DASH_TYPE::DEFAULT, GetColorFromInt( aElem->BorderColor ) ) );
|
||||
else
|
||||
textBox->SetStroke( STROKE_PARAMS( -1, PLOT_DASH_TYPE::DEFAULT, GetColorFromInt( aElem->BorderColor ) ) );
|
||||
|
||||
switch( aElem->Alignment )
|
||||
{
|
||||
default:
|
||||
case ASCH_TEXT_FRAME_ALIGNMENT::LEFT:
|
||||
text->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::RIGHT );
|
||||
textBox->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
|
||||
break;
|
||||
case ASCH_TEXT_FRAME_ALIGNMENT::CENTER:
|
||||
// No support for centered text in Eeschema yet...
|
||||
text->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::RIGHT );
|
||||
textBox->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
|
||||
break;
|
||||
case ASCH_TEXT_FRAME_ALIGNMENT::RIGHT:
|
||||
text->SetTextSpinStyle( TEXT_SPIN_STYLE::SPIN::LEFT );
|
||||
textBox->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: set size and word-wrap once KiCad supports wrapped text.
|
||||
// JEY TODO: word-wrap once KiCad supports wrapped text.
|
||||
|
||||
// TODO: set border and background color once KiCad supports them.
|
||||
|
||||
// TODO: need some sort of property system for storing author....
|
||||
|
||||
size_t fontId = static_cast<int>( elem.fontId );
|
||||
size_t fontId = static_cast<int>( aElem->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 } );
|
||||
textBox->SetItalic( font.Italic );
|
||||
textBox->SetBold( font.Bold );
|
||||
textBox->SetTextSize( { font.Size / 2, font.Size / 2 } );
|
||||
//textBox->SetFont( //how to set font, we have a font mane here: ( font.fontname );
|
||||
}
|
||||
|
||||
text->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( text );
|
||||
textBox->SetFlags( IS_NEW );
|
||||
m_currentSheet->GetScreen()->Append( textBox );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -109,6 +109,7 @@ public:
|
|||
private:
|
||||
bool IsComponentPartVisible( int aOwnerindex, int aOwnerpartdisplaymode ) const;
|
||||
const ASCH_STORAGE_FILE* GetFileFromStorage( const wxString& aFilename ) const;
|
||||
void AddTextBox( const ASCH_TEXT_FRAME* aElem );
|
||||
|
||||
void ParseComponent( int aIndex, const std::map<wxString, wxString>& aProperties );
|
||||
void ParsePin( const std::map<wxString, wxString>& aProperties );
|
||||
|
|
Loading…
Reference in New Issue