Handle Altium dimension angles and non-unit suffixes.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/13751

(cherry picked from commit 97cf7c874e)
This commit is contained in:
Jeff Young 2023-06-02 18:25:31 +01:00
parent 4060ec3038
commit 6fbdf8f0e2
1 changed files with 13 additions and 8 deletions

View File

@ -1284,10 +1284,10 @@ void ALTIUM_PCB::HelperParseDimensions6Linear( const ADIMENSION6& aElem )
* intersect it with REFERENCE1POINT pointing the same direction as REFERENCE0POINT -> XY1. * intersect it with REFERENCE1POINT pointing the same direction as REFERENCE0POINT -> XY1.
* This should give us a valid measurement point where we can place the drawsegment. * This should give us a valid measurement point where we can place the drawsegment.
*/ */
VECTOR2I direction = aElem.xy1 - referencePoint0; VECTOR2I direction = aElem.xy1 - referencePoint0;
VECTOR2I directionNormalVector = VECTOR2I( -direction.y, direction.x ); VECTOR2I directionNormalVector = VECTOR2I( -direction.y, direction.x );
SEG segm1( referencePoint0, referencePoint0 + directionNormalVector ); SEG segm1( referencePoint0, referencePoint0 + directionNormalVector );
SEG segm2( referencePoint1, referencePoint1 + direction ); SEG segm2( referencePoint1, referencePoint1 + direction );
OPT_VECTOR2I intersection( segm1.Intersect( segm2, true, true ) ); OPT_VECTOR2I intersection( segm1.Intersect( segm2, true, true ) );
if( !intersection ) if( !intersection )
@ -1297,7 +1297,7 @@ void ALTIUM_PCB::HelperParseDimensions6Linear( const ADIMENSION6& aElem )
int height = static_cast<int>( EuclideanNorm( direction ) ); int height = static_cast<int>( EuclideanNorm( direction ) );
if( direction.x <= 0 && direction.y <= 0 ) // TODO: I suspect this is not always correct if( ( direction.x > 0 || direction.y < 0 ) != ( aElem.angle >= 180.0 ) )
height = -height; height = -height;
dimension->SetHeight( height ); dimension->SetHeight( height );
@ -1309,11 +1309,16 @@ void ALTIUM_PCB::HelperParseDimensions6Linear( const ADIMENSION6& aElem )
dimension->SetLineThickness( aElem.linewidth ); dimension->SetLineThickness( aElem.linewidth );
dimension->SetUnitsFormat( DIM_UNITS_FORMAT::NO_SUFFIX );
dimension->SetPrefix( aElem.textprefix ); dimension->SetPrefix( aElem.textprefix );
// Suffix normally holds the units // Suffix normally (but not always) holds the units
dimension->SetUnitsFormat( aElem.textsuffix.IsEmpty() ? DIM_UNITS_FORMAT::NO_SUFFIX wxRegEx units( wxS( "(mm)|(in)|(mils)|(thou)|(')|(\")" ), wxRE_ADVANCED );
: DIM_UNITS_FORMAT::BARE_SUFFIX );
if( units.Matches( aElem.textsuffix ) )
dimension->SetUnitsFormat( DIM_UNITS_FORMAT::BARE_SUFFIX );
else
dimension->SetSuffix( aElem.textsuffix );
dimension->SetTextThickness( aElem.textlinewidth ); dimension->SetTextThickness( aElem.textlinewidth );
dimension->SetTextSize( VECTOR2I( aElem.textheight, aElem.textheight ) ); dimension->SetTextSize( VECTOR2I( aElem.textheight, aElem.textheight ) );