CADSTAR PCB Archive Loader: Correctly handle Dimension text
Do not parse fields in dimension text to allow splitting it into prefix and suffix
This commit is contained in:
parent
f74a86b7e1
commit
a2cbbb963e
|
@ -1525,11 +1525,22 @@ void CADSTAR_ARCHIVE_PARSER::FIGURE::Parse( XNODE* aNode, PARSER_CONTEXT* aConte
|
|||
|
||||
|
||||
void CADSTAR_ARCHIVE_PARSER::TEXT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext )
|
||||
{
|
||||
Parse( aNode, aContext, true );
|
||||
}
|
||||
|
||||
|
||||
void CADSTAR_ARCHIVE_PARSER::TEXT::Parse( XNODE* aNode, PARSER_CONTEXT* aContext,
|
||||
bool aParseFields )
|
||||
{
|
||||
wxASSERT( aNode->GetName() == wxT( "TEXT" ) );
|
||||
|
||||
ID = GetXmlAttributeIDString( aNode, 0 );
|
||||
Text = ParseTextFields( GetXmlAttributeIDString( aNode, 1 ), aContext );
|
||||
Text = GetXmlAttributeIDString( aNode, 1 );
|
||||
|
||||
if( aParseFields )
|
||||
Text = ParseTextFields( Text, aContext );
|
||||
|
||||
TextCodeID = GetXmlAttributeIDString( aNode, 2 );
|
||||
LayerID = GetXmlAttributeIDString( aNode, 3 );
|
||||
|
||||
|
|
|
@ -884,6 +884,7 @@ public:
|
|||
REUSEBLOCKREF ReuseBlockRef;
|
||||
|
||||
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext ) override;
|
||||
void Parse( XNODE* aNode, PARSER_CONTEXT* aContext, bool aParseFields );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1324,7 +1324,10 @@ void CADSTAR_PCB_ARCHIVE_LOADER::loadDimensions()
|
|||
|
||||
leaderDim->SetEnd( getKiCadPoint( endPoint ) );
|
||||
leaderDim->Text().SetTextPos( getKiCadPoint( txtPoint ) );
|
||||
leaderDim->SetText( csDim.Text.Text );
|
||||
leaderDim->SetText( ParseTextFields( csDim.Text.Text, &mContext ) );
|
||||
leaderDim->SetPrefix( wxEmptyString );
|
||||
leaderDim->SetSuffix( wxEmptyString );
|
||||
leaderDim->SetUnitsFormat( DIM_UNITS_FORMAT::NO_SUFFIX );
|
||||
|
||||
if( orientX == 1 )
|
||||
leaderDim->Text().SetHorizJustify( GR_TEXT_HJUSTIFY_RIGHT );
|
||||
|
@ -2993,6 +2996,32 @@ void CADSTAR_PCB_ARCHIVE_LOADER::applyDimensionSettings( const DIMENSION& aCads
|
|||
aKiCadDim->Text().SetTextThickness( getKiCadLength( txtCode.LineWidth ) );
|
||||
aKiCadDim->Text().SetTextSize( txtSize );
|
||||
|
||||
// Find prefix and suffix:
|
||||
wxString prefix = wxEmptyString;
|
||||
wxString suffix = wxEmptyString;
|
||||
size_t startpos = aCadstarDim.Text.Text.Find( wxT( "<@DISTANCE" ) );
|
||||
|
||||
if( startpos != wxNOT_FOUND )
|
||||
{
|
||||
prefix = ParseTextFields( aCadstarDim.Text.Text.SubString( 0, startpos - 1 ), &mContext );
|
||||
wxString remainingStr = aCadstarDim.Text.Text.Mid( startpos );
|
||||
size_t endpos = remainingStr.Find( "@>" );
|
||||
suffix = ParseTextFields( remainingStr.Mid( endpos + 2 ), &mContext );
|
||||
}
|
||||
|
||||
if( suffix.StartsWith( "mm" ) )
|
||||
{
|
||||
aKiCadDim->SetUnitsFormat( DIM_UNITS_FORMAT::BARE_SUFFIX );
|
||||
suffix = suffix.Mid( 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
aKiCadDim->SetUnitsFormat( DIM_UNITS_FORMAT::NO_SUFFIX );
|
||||
}
|
||||
|
||||
aKiCadDim->SetPrefix( prefix );
|
||||
aKiCadDim->SetSuffix( suffix );
|
||||
|
||||
if( aCadstarDim.LinearUnits == UNITS::DESIGN )
|
||||
{
|
||||
// For now we will hardcode the units as per the original CADSTAR design.
|
||||
|
|
|
@ -1472,7 +1472,8 @@ void CADSTAR_PCB_ARCHIVE_PARSER::DIMENSION::Parse( XNODE* aNode, PARSER_CONTEXT*
|
|||
}
|
||||
else if( !textParsed && cNodeName == wxT( "TEXT" ) )
|
||||
{
|
||||
Text.Parse( cNode, aContext );
|
||||
// Do not parse the fields in dimension text (will be done when loading, if required)
|
||||
Text.Parse( cNode, aContext, false );
|
||||
textParsed = true;
|
||||
}
|
||||
else if( cNodeName == wxT( "FIX" ) )
|
||||
|
|
Loading…
Reference in New Issue