CADSTAR Schematic: Fix Text Positioning within Symbols
This commit is contained in:
parent
4c914421a1
commit
9148542219
|
@ -235,7 +235,7 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||||
|
|
||||||
if( strings.GetCount() ) // GetCount() == 0 for void strings
|
if( strings.GetCount() ) // GetCount() == 0 for void strings
|
||||||
{
|
{
|
||||||
if( aLine >= 0 && ( aLine < (int)strings.GetCount() ) )
|
if( aLine >= 0 && ( aLine < static_cast<int>( strings.GetCount() ) ) )
|
||||||
text = strings.Item( aLine );
|
text = strings.Item( aLine );
|
||||||
else
|
else
|
||||||
text = strings.Item( 0 );
|
text = strings.Item( 0 );
|
||||||
|
@ -267,6 +267,11 @@ EDA_RECT EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
|
||||||
wxSize textsize = wxSize( dx, dy );
|
wxSize textsize = wxSize( dx, dy );
|
||||||
wxPoint pos = GetTextPos();
|
wxPoint pos = GetTextPos();
|
||||||
|
|
||||||
|
if( IsMultilineAllowed() && aLine > 0 && ( aLine < static_cast<int>( strings.GetCount() ) ) )
|
||||||
|
{
|
||||||
|
pos.y -= aLine * GetInterline();
|
||||||
|
}
|
||||||
|
|
||||||
if( aInvertY )
|
if( aInvertY )
|
||||||
pos.y = -pos.y;
|
pos.y = -pos.y;
|
||||||
|
|
||||||
|
|
|
@ -2541,6 +2541,15 @@ void CADSTAR_ARCHIVE_PARSER::FixTextPositionNoAlignment( EDA_TEXT* aKiCadTextIte
|
||||||
wxPoint positionOffset( 0, aKiCadTextItem->GetInterline() );
|
wxPoint positionOffset( 0, aKiCadTextItem->GetInterline() );
|
||||||
RotatePoint( &positionOffset, txtAngleDecideg );
|
RotatePoint( &positionOffset, txtAngleDecideg );
|
||||||
|
|
||||||
|
EDA_ITEM* textEdaItem = dynamic_cast<EDA_ITEM*>( aKiCadTextItem );
|
||||||
|
|
||||||
|
if( textEdaItem && ( textEdaItem->Type() == LIB_TEXT_T )
|
||||||
|
|| ( textEdaItem->Type() == LIB_FIELD_T ) )
|
||||||
|
{
|
||||||
|
// Y coordinate increases upwards in the symbol editor
|
||||||
|
positionOffset.y = -positionOffset.y;
|
||||||
|
}
|
||||||
|
|
||||||
//Count num of additional lines
|
//Count num of additional lines
|
||||||
wxString text = aKiCadTextItem->GetText();
|
wxString text = aKiCadTextItem->GetText();
|
||||||
int numExtraLines = text.Replace( "\n", "\n" );
|
int numExtraLines = text.Replace( "\n", "\n" );
|
||||||
|
|
|
@ -1280,11 +1280,13 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
|
||||||
|
|
||||||
for( std::pair<TEXT_ID, TEXT> textPair : symbol.Texts )
|
for( std::pair<TEXT_ID, TEXT> textPair : symbol.Texts )
|
||||||
{
|
{
|
||||||
TEXT csText = textPair.second;
|
TEXT csText = textPair.second;
|
||||||
|
|
||||||
LIB_TEXT* libtext = new LIB_TEXT( aPart );
|
LIB_TEXT* libtext = new LIB_TEXT( aPart );
|
||||||
libtext->SetText( csText.Text );
|
libtext->SetText( csText.Text );
|
||||||
libtext->SetUnit( gateNumber );
|
libtext->SetUnit( gateNumber );
|
||||||
libtext->SetPosition( getKiCadLibraryPoint( csText.Position, symbol.Origin ) );
|
libtext->SetPosition( getKiCadLibraryPoint( csText.Position, symbol.Origin ) );
|
||||||
|
libtext->SetMultilineAllowed( true ); // temporarily so that we calculate bbox correctly
|
||||||
|
|
||||||
applyTextSettings( libtext,
|
applyTextSettings( libtext,
|
||||||
csText.TextCodeID,
|
csText.TextCodeID,
|
||||||
|
@ -1293,7 +1295,39 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadSymDefIntoLibrary( const SYMDEF_ID& aSymdef
|
||||||
csText.OrientAngle,
|
csText.OrientAngle,
|
||||||
csText.Mirror );
|
csText.Mirror );
|
||||||
|
|
||||||
aPart->AddDrawItem( libtext );
|
// Split out multi line text items into individual text elements
|
||||||
|
if( csText.Text.Contains( "\n" ) )
|
||||||
|
{
|
||||||
|
wxArrayString strings;
|
||||||
|
wxStringSplit( csText.Text, strings, '\n' );
|
||||||
|
wxPoint firstLinePos;
|
||||||
|
|
||||||
|
for( int ii = 0; ii < strings.size(); ++ii )
|
||||||
|
{
|
||||||
|
EDA_RECT bbox = libtext->GetTextBox( ii, true );
|
||||||
|
wxPoint linePos = { bbox.GetLeft(), -bbox.GetBottom() };
|
||||||
|
|
||||||
|
RotatePoint( &linePos, libtext->GetTextPos(), -libtext->GetTextAngle() );
|
||||||
|
|
||||||
|
LIB_TEXT* line = static_cast<LIB_TEXT*>( libtext->Clone() );
|
||||||
|
line->SetText( strings[ii] );
|
||||||
|
line->SetHorizJustify( GR_TEXT_HJUSTIFY_LEFT );
|
||||||
|
line->SetVertJustify( GR_TEXT_VJUSTIFY_BOTTOM );
|
||||||
|
line->SetTextPos( linePos );
|
||||||
|
|
||||||
|
// Multiline text not allowed in LIB_TEXT
|
||||||
|
line->SetMultilineAllowed( false );
|
||||||
|
aPart->AddDrawItem( line );
|
||||||
|
}
|
||||||
|
|
||||||
|
delete libtext;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Multiline text not allowed in LIB_TEXT
|
||||||
|
libtext->SetMultilineAllowed( false );
|
||||||
|
aPart->AddDrawItem( libtext );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( symbol.TextLocations.find( SYMBOL_NAME_ATTRID ) != symbol.TextLocations.end() )
|
if( symbol.TextLocations.find( SYMBOL_NAME_ATTRID ) != symbol.TextLocations.end() )
|
||||||
|
@ -2494,6 +2528,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT
|
||||||
{
|
{
|
||||||
// Some KiCad schematic text items only permit a limited amount of angles
|
// Some KiCad schematic text items only permit a limited amount of angles
|
||||||
// and text justifications
|
// and text justifications
|
||||||
|
case LIB_TEXT_T:
|
||||||
case SCH_FIELD_T:
|
case SCH_FIELD_T:
|
||||||
case LIB_FIELD_T:
|
case LIB_FIELD_T:
|
||||||
{
|
{
|
||||||
|
@ -2560,6 +2595,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::applyTextSettings( EDA_TEXT* aKiCadT
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
wxFAIL_MSG( "Unexpected item type" );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue