mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
Properly align imported dimensions
The height depends on which direction the dimension is being pulled. Also try to mimic Altium's automatic arrow in/out style Fixes https://gitlab.com/kicad/code/kicad/-/issues/21329
This commit is contained in:
parent
5fb40f152c
commit
e8219c4300
@ -1600,7 +1600,8 @@ void ALTIUM_PCB::HelperParseDimensions6Linear( const ADIMENSION6& aElem )
|
||||
* This should give us a valid measurement point where we can place the drawsegment.
|
||||
*/
|
||||
VECTOR2I direction = aElem.xy1 - referencePoint0;
|
||||
VECTOR2I directionNormalVector = VECTOR2I( -direction.y, direction.x );
|
||||
VECTOR2I referenceDiff = referencePoint1 - referencePoint0;
|
||||
VECTOR2I directionNormalVector = direction.Perpendicular();
|
||||
SEG segm1( referencePoint0, referencePoint0 + directionNormalVector );
|
||||
SEG segm2( referencePoint1, referencePoint1 + direction );
|
||||
OPT_VECTOR2I intersection( segm1.Intersect( segm2, true, true ) );
|
||||
@ -1612,7 +1613,7 @@ void ALTIUM_PCB::HelperParseDimensions6Linear( const ADIMENSION6& aElem )
|
||||
|
||||
int height = direction.EuclideanNorm();
|
||||
|
||||
if( ( direction.x > 0 || direction.y < 0 ) != ( aElem.angle >= 180.0 ) )
|
||||
if( direction.Cross( referenceDiff ) > 0 )
|
||||
height = -height;
|
||||
|
||||
dimension->SetHeight( height );
|
||||
@ -1627,6 +1628,12 @@ void ALTIUM_PCB::HelperParseDimensions6Linear( const ADIMENSION6& aElem )
|
||||
dimension->SetUnitsFormat( DIM_UNITS_FORMAT::NO_SUFFIX );
|
||||
dimension->SetPrefix( aElem.textprefix );
|
||||
|
||||
|
||||
int dist = ( dimension->GetEnd() - dimension->GetStart() ).EuclideanNorm();
|
||||
|
||||
if( dist < 3 * dimension->GetArrowLength() )
|
||||
dimension->SetArrowDirection( DIM_ARROW_DIRECTION::INWARD );
|
||||
|
||||
// Suffix normally (but not always) holds the units
|
||||
wxRegEx units( wxS( "(mm)|(in)|(mils)|(thou)|(')|(\")" ), wxRE_ADVANCED );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user