[IMP]Support Horiz/Vert Dims in DXF export
This commit is contained in:
@@ -758,7 +758,7 @@ void ImpExpDxfWrite::exportText(const char* text, Base::Vector3d position1, Base
|
||||
|
||||
void ImpExpDxfWrite::exportLinearDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1Start, Base::Vector3d extLine2Start,
|
||||
char* dimText)
|
||||
char* dimText, int type)
|
||||
{
|
||||
double text[3] = {0,0,0};
|
||||
text[0] = textLocn.x;
|
||||
@@ -776,7 +776,7 @@ void ImpExpDxfWrite::exportLinearDim(Base::Vector3d textLocn, Base::Vector3d lin
|
||||
ext2[0] = extLine2Start.x;
|
||||
ext2[1] = extLine2Start.y;
|
||||
ext2[2] = extLine2Start.z;
|
||||
writeLinearDim(text, line, ext1,ext2,dimText);
|
||||
writeLinearDim(text, line, ext1,ext2,dimText, type);
|
||||
}
|
||||
|
||||
void ImpExpDxfWrite::exportAngularDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Import
|
||||
void exportText(const char* text, Base::Vector3d position1, Base::Vector3d position2, double size, int just);
|
||||
void exportLinearDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1Start, Base::Vector3d extLine2Start,
|
||||
char* dimText);
|
||||
char* dimText, int type);
|
||||
void exportAngularDim(Base::Vector3d textLocn, Base::Vector3d lineLocn,
|
||||
Base::Vector3d extLine1Start, Base::Vector3d extLine2Start,
|
||||
Base::Vector3d apexPoint,
|
||||
|
||||
@@ -1059,9 +1059,12 @@ void CDxfWrite::putArrow(Base::Vector3d arrowPos, Base::Vector3d barb1Pos, Base:
|
||||
//***************************
|
||||
//writeLinearDim
|
||||
//added by Wandererfan 2018 (wandererfan@gmail.com) for FreeCAD project
|
||||
#define ALIGNED 0
|
||||
#define HORIZONTAL 1
|
||||
#define VERTICAL 2
|
||||
void CDxfWrite::writeLinearDim(const double* textMidPoint, const double* lineDefPoint,
|
||||
const double* extLine1, const double* extLine2,
|
||||
const char* dimText)
|
||||
const char* dimText, int type)
|
||||
{
|
||||
(*m_ssEntity) << " 0" << endl;
|
||||
(*m_ssEntity) << "DIMENSION" << endl;
|
||||
@@ -1093,8 +1096,15 @@ void CDxfWrite::writeLinearDim(const double* textMidPoint, const double* lineDef
|
||||
(*m_ssEntity) << textMidPoint[1] << endl;
|
||||
(*m_ssEntity) << " 31" << endl;
|
||||
(*m_ssEntity) << textMidPoint[2] << endl;
|
||||
(*m_ssEntity) << " 70" << endl;
|
||||
(*m_ssEntity) << 1 << endl; // dimType1 = Aligned
|
||||
if (type == ALIGNED) {
|
||||
(*m_ssEntity) << " 70" << endl;
|
||||
(*m_ssEntity) << 1 << endl; // dimType1 = Aligned
|
||||
}
|
||||
if ( (type == HORIZONTAL) ||
|
||||
(type == VERTICAL) ) {
|
||||
(*m_ssEntity) << " 70" << endl;
|
||||
(*m_ssEntity) << 32 << endl; // dimType0 = Aligned + 32 (bit for unique block)?
|
||||
}
|
||||
// (*m_ssEntity) << " 71" << endl; // not R12
|
||||
// (*m_ssEntity) << 1 << endl; // attachPoint ??1 = topleft
|
||||
(*m_ssEntity) << " 1" << endl;
|
||||
@@ -1118,11 +1128,22 @@ void CDxfWrite::writeLinearDim(const double* textMidPoint, const double* lineDef
|
||||
(*m_ssEntity) << extLine2[1] << endl;
|
||||
(*m_ssEntity) << " 34" << endl;
|
||||
(*m_ssEntity) << extLine2[2] << endl;
|
||||
if (m_version > 12) {
|
||||
if (type == VERTICAL) {
|
||||
(*m_ssEntity) << " 50" << endl;
|
||||
(*m_ssEntity) << "90" << endl;
|
||||
}
|
||||
if ( (type == HORIZONTAL) ||
|
||||
(type == VERTICAL) ) {
|
||||
(*m_ssEntity) << "100" << endl;
|
||||
(*m_ssEntity) << "AcDbRotatedDimension" << endl;
|
||||
}
|
||||
}
|
||||
|
||||
writeDimBlockPreamble();
|
||||
writeLinearDimBlock(textMidPoint,lineDefPoint,
|
||||
extLine1, extLine2,
|
||||
dimText);
|
||||
dimText, type);
|
||||
writeBlockTrailer();
|
||||
}
|
||||
|
||||
@@ -1419,7 +1440,7 @@ void CDxfWrite::writeBlockTrailer(void)
|
||||
//added by Wandererfan 2018 (wandererfan@gmail.com) for FreeCAD project
|
||||
void CDxfWrite::writeLinearDimBlock(const double* textMidPoint, const double* dimLine,
|
||||
const double* e1Start, const double* e2Start,
|
||||
const char* dimText)
|
||||
const char* dimText, int type)
|
||||
{
|
||||
Base::Vector3d e1S(e1Start[0],e1Start[1],e1Start[2]);
|
||||
Base::Vector3d e2S(e2Start[0],e2Start[1],e2Start[2]);
|
||||
@@ -1431,6 +1452,40 @@ void CDxfWrite::writeLinearDimBlock(const double* textMidPoint, const double* di
|
||||
Base::Vector3d X(1.0,0.0,0.0);
|
||||
double angle = para.GetAngle(X);
|
||||
angle = angle * 180.0 / M_PI;
|
||||
if (type == ALIGNED) {
|
||||
//NOP
|
||||
} else if (type == HORIZONTAL) {
|
||||
double x = e1Start[0];
|
||||
double y = dimLine[1];
|
||||
e1E = Base::Vector3d(x, y, 0.0);
|
||||
x = e2Start[0];
|
||||
e2E = Base::Vector3d(x, y, 0.0);
|
||||
perp = Base::Vector3d(0, -1, 0); //down
|
||||
para = Base::Vector3d(1, 0, 0); //right
|
||||
if (dimLine[1] > e1Start[1]) {
|
||||
perp = Base::Vector3d(0, 1, 0); //up
|
||||
}
|
||||
if (e1Start[0] > e2Start[0]) {
|
||||
para = Base::Vector3d(-1, 0, 0); //left
|
||||
}
|
||||
angle = 0;
|
||||
} else if (type == VERTICAL) {
|
||||
double x = dimLine[0];
|
||||
double y = e1Start[1];
|
||||
e1E = Base::Vector3d(x, y, 0.0);
|
||||
y = e2Start[1];
|
||||
e2E = Base::Vector3d(x, y, 0.0);
|
||||
perp = Base::Vector3d(1, 0, 0);
|
||||
para = Base::Vector3d(0, 1, 0);
|
||||
if (dimLine[0] < e1Start[0]) {
|
||||
perp = Base::Vector3d(-1, 0, 0);
|
||||
}
|
||||
if (e1Start[1] > e2Start[1]) {
|
||||
para = Base::Vector3d(0, -1, 0);
|
||||
}
|
||||
angle = 90;
|
||||
}
|
||||
|
||||
double arrowLen = 5.0; //magic number
|
||||
double arrowWidth = arrowLen/6.0/2.0; //magic number calc!
|
||||
|
||||
|
||||
@@ -201,10 +201,10 @@ public:
|
||||
const double height, const int horizJust);
|
||||
void writeLinearDim(const double* textMidPoint, const double* lineDefPoint,
|
||||
const double* extLine1, const double* extLine2,
|
||||
const char* dimText);
|
||||
const char* dimText, int type);
|
||||
void writeLinearDimBlock(const double* textMidPoint, const double* lineDefPoint,
|
||||
const double* extLine1, const double* extLine2,
|
||||
const char* dimText);
|
||||
const char* dimText, int type);
|
||||
void writeAngularDim(const double* textMidPoint, const double* lineDefPoint,
|
||||
const double* startExt1, const double* endExt1,
|
||||
const double* startExt2, const double* endExt2,
|
||||
|
||||
Reference in New Issue
Block a user