diff --git a/src/libs/vdxf/libdxfrw/drw_entities.h b/src/libs/vdxf/libdxfrw/drw_entities.h index bba4282b4..b197a8cc1 100644 --- a/src/libs/vdxf/libdxfrw/drw_entities.h +++ b/src/libs/vdxf/libdxfrw/drw_entities.h @@ -234,9 +234,6 @@ class DRW_Point : public DRW_Entity { SETENTFRIENDS public: DRW_Point() - : basePoint(), - thickness(0), - extPoint(DRW_Coord(0, 0, 1)) { eType = DRW::POINT; } @@ -247,9 +244,9 @@ protected: bool parseCode(int code, dxfReader *reader) override; public: - DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */ - double thickness; /*!< thickness, code 39 */ - DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ + DRW_Coord basePoint{}; /*!< base point, code 10, 20 & 30 */ + double thickness{0}; /*!< thickness, code 39 */ + DRW_Coord extPoint{DRW_Coord(0, 0, 1)}; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ // TNick: we're not handling code 50 - Angle of the X axis for // the UCS in effect when the point was drawn }; diff --git a/src/libs/vdxf/libdxfrw/libdxfrw.cpp b/src/libs/vdxf/libdxfrw/libdxfrw.cpp index 96289dc1f..28e18ec81 100644 --- a/src/libs/vdxf/libdxfrw/libdxfrw.cpp +++ b/src/libs/vdxf/libdxfrw/libdxfrw.cpp @@ -640,7 +640,10 @@ bool dxfRW::writeASTMNotch(DRW_ASTMNotch *ent) { writePoint(ent); writer->writeDouble(50, ent->angle); - writer->writeDouble(39, ent->thickness); // Defined, but not used in point + if (not qFuzzyIsNull(ent->thickness)) + { + writer->writeDouble(39, ent->thickness); // Defined, but not used in point + } return true; } diff --git a/src/libs/vdxf/vdxfengine.cpp b/src/libs/vdxf/vdxfengine.cpp index c5eb71828..ce4a7697b 100644 --- a/src/libs/vdxf/vdxfengine.cpp +++ b/src/libs/vdxf/vdxfengine.cpp @@ -847,13 +847,16 @@ void VDxfEngine::ExportAAMANotch(const QSharedPointer &detailBloc const QVector passmarks = detail.GetMappedPassmarks(); for(const auto &passmark : passmarks) { - for (const auto &line : passmark.lines) - { - if (DRW_Entity *e = AAMALine(line, *layer4)) - { - detailBlock->ent.push_back(e); - } - } + std::unique_ptr notch(new DRW_ASTMNotch()); + const QPointF center = passmark.baseLine.p1(); + + notch->basePoint = DRW_Coord(FromPixel(center.x(), m_varInsunits), + FromPixel(GetSize().height() - center.y(), m_varInsunits), + FromPixel(passmark.baseLine.length(), m_varInsunits)); + notch->angle = passmark.baseLine.angle(); + notch->layer = *layer4; + + detailBlock->ent.push_back(notch.release()); } } } @@ -1128,10 +1131,17 @@ void VDxfEngine::ExportASTMDrill(const QSharedPointer &detailBloc || label.Type() == PlaceLabelType::Circle) { const QPointF center = detail.GetMatrix().map(label.Center()); - detailBlock->ent.push_back(AAMAPoint(center, *layer13)); + QLineF diameter = detail.GetMatrix().map(QLineF(label.Box().bottomLeft(), label.Box().topRight())); + + std::unique_ptr point(new DRW_Point()); + point->basePoint = DRW_Coord(FromPixel(center.x(), m_varInsunits), + FromPixel(GetSize().height() - center.y(), m_varInsunits), + FromPixel(diameter.length(), m_varInsunits)); + point->layer = *layer13; + detailBlock->ent.push_back(point.release()); // TODO. Investigate drill category -// QPointF pos(center.x(), center.y() - ToPixel(AAMATextHeight, varInsunits)); +// QPointF pos(center.x(), center.y() - ToPixel(AAMATextHeight, m_varInsunits)); // detailBlock->ent.push_back(AAMAText(pos, category, *layer13)); } } @@ -1160,34 +1170,33 @@ void VDxfEngine::ExportASTMNotch(const QSharedPointer &detailBloc notch->layer = *layer4; } else if (passmark.type == PassmarkLineType::VMark || passmark.type == PassmarkLineType::VMark2) - { + { // V-Notch QLineF boundaryLine(ConstFirst(passmark.lines).p2(), ConstLast(passmark.lines).p2()); notch->thickness = FromPixel(boundaryLine.length(), m_varInsunits); // width notch->layer = *layer4; } else if (passmark.type == PassmarkLineType::TMark) - { - qreal width = FromPixel(ConstLast(passmark.lines).length(), m_varInsunits); - notch->thickness = FromPixel(width, m_varInsunits); + { // T-Notch + notch->thickness = FromPixel(ConstLast(passmark.lines).length(), m_varInsunits); // width notch->layer = *layer80; } else if (passmark.type == PassmarkLineType::BoxMark) - { + { // Castle Notch QPointF start = ConstFirst(passmark.lines).p1(); QPointF end = ConstLast(passmark.lines).p2(); notch->layer = *layer81; - notch->thickness = FromPixel(QLineF(start, end).length(), m_varInsunits); + notch->thickness = FromPixel(QLineF(start, end).length(), m_varInsunits); // width } else if (passmark.type == PassmarkLineType::UMark) - { + { // U-Notch QPointF start = ConstFirst(passmark.lines).p1(); QPointF end = ConstLast(passmark.lines).p2(); - notch->thickness = FromPixel(QLineF(start, end).length(), m_varInsunits); + notch->thickness = FromPixel(QLineF(start, end).length(), m_varInsunits); // width notch->layer = *layer83; }