Fix notches.

This commit is contained in:
Roman Telezhynskyi 2023-04-06 18:21:24 +03:00
parent 6e295f7172
commit 9cd31f1dd7
3 changed files with 33 additions and 24 deletions

View File

@ -234,9 +234,6 @@ class DRW_Point : public DRW_Entity {
SETENTFRIENDS SETENTFRIENDS
public: public:
DRW_Point() DRW_Point()
: basePoint(),
thickness(0),
extPoint(DRW_Coord(0, 0, 1))
{ {
eType = DRW::POINT; eType = DRW::POINT;
} }
@ -247,9 +244,9 @@ protected:
bool parseCode(int code, dxfReader *reader) override; bool parseCode(int code, dxfReader *reader) override;
public: public:
DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */ DRW_Coord basePoint{}; /*!< base point, code 10, 20 & 30 */
double thickness; /*!< thickness, code 39 */ double thickness{0}; /*!< thickness, code 39 */
DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */ 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 // TNick: we're not handling code 50 - Angle of the X axis for
// the UCS in effect when the point was drawn // the UCS in effect when the point was drawn
}; };

View File

@ -640,7 +640,10 @@ bool dxfRW::writeASTMNotch(DRW_ASTMNotch *ent)
{ {
writePoint(ent); writePoint(ent);
writer->writeDouble(50, ent->angle); 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; return true;
} }

View File

@ -847,13 +847,16 @@ void VDxfEngine::ExportAAMANotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
const QVector<VLayoutPassmark> passmarks = detail.GetMappedPassmarks(); const QVector<VLayoutPassmark> passmarks = detail.GetMappedPassmarks();
for(const auto &passmark : passmarks) for(const auto &passmark : passmarks)
{ {
for (const auto &line : passmark.lines) std::unique_ptr<DRW_ASTMNotch> notch(new DRW_ASTMNotch());
{ const QPointF center = passmark.baseLine.p1();
if (DRW_Entity *e = AAMALine(line, *layer4))
{ notch->basePoint = DRW_Coord(FromPixel(center.x(), m_varInsunits),
detailBlock->ent.push_back(e); 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<dx_ifaceBlock> &detailBloc
|| label.Type() == PlaceLabelType::Circle) || label.Type() == PlaceLabelType::Circle)
{ {
const QPointF center = detail.GetMatrix().map(label.Center()); 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<DRW_Point> 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 // 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)); // detailBlock->ent.push_back(AAMAText(pos, category, *layer13));
} }
} }
@ -1160,34 +1170,33 @@ void VDxfEngine::ExportASTMNotch(const QSharedPointer<dx_ifaceBlock> &detailBloc
notch->layer = *layer4; notch->layer = *layer4;
} }
else if (passmark.type == PassmarkLineType::VMark || passmark.type == PassmarkLineType::VMark2) else if (passmark.type == PassmarkLineType::VMark || passmark.type == PassmarkLineType::VMark2)
{ { // V-Notch
QLineF boundaryLine(ConstFirst(passmark.lines).p2(), ConstLast(passmark.lines).p2()); QLineF boundaryLine(ConstFirst(passmark.lines).p2(), ConstLast(passmark.lines).p2());
notch->thickness = FromPixel(boundaryLine.length(), m_varInsunits); // width notch->thickness = FromPixel(boundaryLine.length(), m_varInsunits); // width
notch->layer = *layer4; notch->layer = *layer4;
} }
else if (passmark.type == PassmarkLineType::TMark) else if (passmark.type == PassmarkLineType::TMark)
{ { // T-Notch
qreal width = FromPixel(ConstLast(passmark.lines).length(), m_varInsunits); notch->thickness = FromPixel(ConstLast(passmark.lines).length(), m_varInsunits); // width
notch->thickness = FromPixel(width, m_varInsunits);
notch->layer = *layer80; notch->layer = *layer80;
} }
else if (passmark.type == PassmarkLineType::BoxMark) else if (passmark.type == PassmarkLineType::BoxMark)
{ { // Castle Notch
QPointF start = ConstFirst(passmark.lines).p1(); QPointF start = ConstFirst(passmark.lines).p1();
QPointF end = ConstLast(passmark.lines).p2(); QPointF end = ConstLast(passmark.lines).p2();
notch->layer = *layer81; 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) else if (passmark.type == PassmarkLineType::UMark)
{ { // U-Notch
QPointF start = ConstFirst(passmark.lines).p1(); QPointF start = ConstFirst(passmark.lines).p1();
QPointF end = ConstLast(passmark.lines).p2(); 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; notch->layer = *layer83;
} }