From 63abcc379d386a5c8913c0ef887f9abd3e7b7870 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Tue, 17 May 2016 11:08:24 +0600 Subject: [PATCH] DXF: export "actual measurement" for dimensions. The "actual measurement" DXF field contains the size of the dimension as scaled on the drawing, as opposed to the size as written on the label. --- extlib/libdxfrw | 2 +- src/exportvector.cpp | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/extlib/libdxfrw b/extlib/libdxfrw index 62e4a3cd..8d24e656 160000 --- a/extlib/libdxfrw +++ b/extlib/libdxfrw @@ -1 +1 @@ -Subproject commit 62e4a3cd8b19b2406af5a01c0bc45e77c9294068 +Subproject commit 8d24e656fbd293cb953828389d01d362f2a1a8e0 diff --git a/src/exportvector.cpp b/src/exportvector.cpp index 7662057f..dc450db8 100644 --- a/src/exportvector.cpp +++ b/src/exportvector.cpp @@ -306,7 +306,7 @@ public: Vector bp = SK.GetEntity(c->ptB)->PointGetNum(); Vector ref = ((ap.Plus(bp)).ScaledBy(0.5)).Plus(c->disp.offset); writeAlignedDimension(xfrm(ap), xfrm(bp), xfrm(ref), - xfrm(ref), c->Label(), c->GetStyle()); + xfrm(ref), c->Label(), c->GetStyle(), c->valA); break; } @@ -337,7 +337,8 @@ public: Vector xdl = xfrm(lB).Minus(xfrm(lA)); writeLinearDimension(xfrm(pt), xfrm(refClosest), xfrm(ref), xfrm(ref), c->Label(), - atan2(xdl.y, xdl.x) / PI * 180.0 + 90.0, 0.0, c->GetStyle()); + atan2(xdl.y, xdl.x) / PI * 180.0 + 90.0, 0.0, + c->GetStyle(), c->valA); break; } @@ -356,11 +357,11 @@ public: if(/*isRadius*/c->other) { writeRadialDimension( xfrm(center), xfrm(center.Plus(rad)), - xfrm(ref), c->Label(), c->GetStyle()); + xfrm(ref), c->Label(), c->GetStyle(), c->valA); } else { writeDiametricDimension( xfrm(center.Minus(rad)), xfrm(center.Plus(rad)), - xfrm(ref), c->Label(), c->GetStyle()); + xfrm(ref), c->Label(), c->GetStyle(), c->valA); } break; } @@ -386,7 +387,7 @@ public: writeAngularDimension( xfrm(a0), xfrm(a0.Plus(da)), xfrm(b0), xfrm(b0.Plus(db)), xfrm(ref), - xfrm(ref), c->Label(), c->GetStyle()); + xfrm(ref), c->Label(), c->GetStyle(), c->valA); break; } @@ -540,7 +541,7 @@ public: } void writeAlignedDimension(Vector def1, Vector def2, Vector dimp, - Vector textp, const std::string &text, hStyle hs) { + Vector textp, const std::string &text, hStyle hs, double actual) { DRW_DimAligned dim; assignDimensionDefaults(&dim, hs); dim.setDef1Point(toCoord(def1)); @@ -548,12 +549,13 @@ public: dim.setDimPoint(toCoord(dimp)); dim.setTextPoint(toCoord(textp)); dim.setText(text); + dim.setActualMeasurement(actual); dxf->writeDimension(&dim); } void writeLinearDimension(Vector def1, Vector def2, Vector dimp, Vector textp, const std::string &text, - double angle, double oblique, hStyle hs) { + double angle, double oblique, hStyle hs, double actual) { DRW_DimLinear dim; assignDimensionDefaults(&dim, hs); dim.setDef1Point(toCoord(def1)); @@ -563,33 +565,36 @@ public: dim.setText(text); dim.setAngle(angle); dim.setOblique(oblique); + dim.setActualMeasurement(actual); dxf->writeDimension(&dim); } void writeRadialDimension(Vector center, Vector radius, - Vector textp, const std::string &text, hStyle hs) { + Vector textp, const std::string &text, hStyle hs, double actual) { DRW_DimRadial dim; assignDimensionDefaults(&dim, hs); dim.setCenterPoint(toCoord(center)); dim.setDiameterPoint(toCoord(radius)); dim.setTextPoint(toCoord(textp)); dim.setText(text); + dim.setActualMeasurement(actual); dxf->writeDimension(&dim); } void writeDiametricDimension(Vector def1, Vector def2, - Vector textp, const std::string &text, hStyle hs) { + Vector textp, const std::string &text, hStyle hs, double actual) { DRW_DimDiametric dim; assignDimensionDefaults(&dim, hs); dim.setDiameter1Point(toCoord(def1)); dim.setDiameter2Point(toCoord(def2)); dim.setTextPoint(toCoord(textp)); dim.setText(text); + dim.setActualMeasurement(actual); dxf->writeDimension(&dim); } void writeAngularDimension(Vector fl1, Vector fl2, Vector sl1, Vector sl2, Vector dimp, - Vector textp, const std::string &text, hStyle hs) { + Vector textp, const std::string &text, hStyle hs, double actual) { DRW_DimAngular dim; assignDimensionDefaults(&dim, hs); dim.setFirstLine1(toCoord(fl1)); @@ -599,6 +604,7 @@ public: dim.setDimPoint(toCoord(dimp)); dim.setTextPoint(toCoord(textp)); dim.setText(text); + dim.setActualMeasurement(actual * PI / 180.0); dxf->writeDimension(&dim); }