Port changes from libdxfrw mainstream.

This commit is contained in:
Roman Telezhynskyi 2023-08-21 17:24:10 +03:00
parent df888f2f5d
commit c2fea54864
3 changed files with 1018 additions and 914 deletions

View File

@ -14,21 +14,22 @@
#ifndef DRW_ENTITIES_H
#define DRW_ENTITIES_H
#include "drw_base.h"
#include <QtGlobal>
#include <algorithm>
#include <list>
#include <string>
#include <vector>
#include <list>
#include <QtGlobal>
#include "drw_base.h"
#include <algorithm>
class dxfReader;
class DRW_Polyline;
namespace DRW {
namespace DRW
{
//! Entity's type.
enum ETYPE {
enum ETYPE
{
E3DFACE,
// E3DSOLID, //encripted propietry data
// ACAD_PROXY_ENTITY,
@ -86,7 +87,7 @@ namespace DRW {
UNKNOWN
};
}
} // namespace DRW
// only in DWG: MINSERT, 5 types of vertex, 4 types of polylines: 2d, 3d, pface & mesh
// shape, dictionary, MLEADER, MLEADERSTYLE
@ -97,8 +98,10 @@ namespace DRW {
* Base class for entities
* @author Rallaz
*/
class DRW_Entity {
class DRW_Entity
{
SETENTFRIENDS
public:
// initializes default values
DRW_Entity()
@ -126,7 +129,8 @@ public:
extAxisX(),
extAxisY(),
curr(nullptr)
{}
{
}
DRW_Entity(const DRW_Entity &e)
: eType(e.eType),
@ -154,19 +158,22 @@ public:
extAxisY(),
curr(nullptr /*e.curr*/)
{
for (std::vector<DRW_Variant*>::const_iterator it=e.extData.begin(); it!=e.extData.end(); ++it){
for (std::vector<DRW_Variant *>::const_iterator it = e.extData.begin(); it != e.extData.end(); ++it)
{
extData.push_back(new DRW_Variant(*(*it)));
}
}
virtual ~DRW_Entity() {
virtual ~DRW_Entity()
{
for (std::vector<DRW_Variant *>::iterator it = extData.begin(); it != extData.end(); ++it)
delete *it;
extData.clear();
}
void reset(){
void reset()
{
for (std::vector<DRW_Variant *>::iterator it = extData.begin(); it != extData.end(); ++it)
delete *it;
extData.clear();
@ -174,12 +181,15 @@ public:
virtual void applyExtrusion() = 0;
void setWidthMm(double millimeters) {
if(millimeters < 0.0) {
void setWidthMm(double millimeters)
{
if (millimeters < 0.0)
{
lWeight = DRW_LW_Conv::widthByLayer;
return;
}
if(millimeters > 2.11) millimeters = 2.11;
if (millimeters > 2.11)
millimeters = 2.11;
lWeight = DRW_LW_Conv::dxfInt2lineWidth(int(floor(millimeters * 100.0)));
}
@ -224,19 +234,17 @@ private:
DRW_Variant *curr;
};
//! Class to handle point entity
/*!
* Class to handle point entity
* @author Rallaz
*/
class DRW_Point : public DRW_Entity {
SETENTFRIENDS
public:
DRW_Point()
class DRW_Point : public DRW_Entity
{
eType = DRW::POINT;
}
SETENTFRIENDS
public:
DRW_Point() { eType = DRW::POINT; }
void applyExtrusion() override {}
@ -251,14 +259,12 @@ public:
// the UCS in effect when the point was drawn
};
class DRW_ASTMNotch : public DRW_Point {
SETENTFRIENDS
public:
DRW_ASTMNotch()
class DRW_ASTMNotch : public DRW_Point
{
eType = DRW::ASTMNOTCH;
}
SETENTFRIENDS
public:
DRW_ASTMNotch() { eType = DRW::ASTMNOTCH; }
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
@ -272,8 +278,10 @@ public:
* Class to handle line entity
* @author Rallaz
*/
class DRW_Line : public DRW_Point {
class DRW_Line : public DRW_Point
{
SETENTFRIENDS
public:
DRW_Line()
: secPoint()
@ -295,12 +303,12 @@ public:
* Class to handle ray entity
* @author Rallaz
*/
class DRW_Ray : public DRW_Line {
class DRW_Ray : public DRW_Line
{
SETENTFRIENDS
public:
DRW_Ray() {
eType = DRW::RAY;
}
DRW_Ray() { eType = DRW::RAY; }
};
//! Class to handle xline entity
@ -308,11 +316,10 @@ public:
* Class to handle xline entity
* @author Rallaz
*/
class DRW_Xline : public DRW_Ray {
class DRW_Xline : public DRW_Ray
{
public:
DRW_Xline() {
eType = DRW::XLINE;
}
DRW_Xline() { eType = DRW::XLINE; }
};
//! Class to handle circle entity
@ -320,8 +327,10 @@ public:
* Class to handle circle entity
* @author Rallaz
*/
class DRW_Circle : public DRW_Point {
class DRW_Circle : public DRW_Point
{
SETENTFRIENDS
public:
DRW_Circle()
: radious()
@ -343,8 +352,10 @@ public:
* Class to handle arc entity
* @author Rallaz
*/
class DRW_Arc : public DRW_Circle {
class DRW_Arc : public DRW_Circle
{
SETENTFRIENDS
public:
DRW_Arc()
: staangle(),
@ -386,8 +397,10 @@ public:
* for hatch boundary are in degrees
* @author Rallaz
*/
class DRW_Ellipse : public DRW_Line {
class DRW_Ellipse : public DRW_Line
{
SETENTFRIENDS
public:
DRW_Ellipse()
: ratio(),
@ -420,8 +433,10 @@ public:
* Class to handle trace entity
* @author Rallaz
*/
class DRW_Trace : public DRW_Line {
class DRW_Trace : public DRW_Line
{
SETENTFRIENDS
public:
DRW_Trace()
: thirdPoint(),
@ -445,12 +460,12 @@ public:
* Class to handle solid entity
* @author Rallaz
*/
class DRW_Solid : public DRW_Trace {
class DRW_Solid : public DRW_Trace
{
SETENTFRIENDS
public:
DRW_Solid() {
eType = DRW::SOLID;
}
DRW_Solid() { eType = DRW::SOLID; }
public:
//! first corner (2D)
@ -460,7 +475,7 @@ public:
//! third corner (2D)
auto thirdCorner() const -> const DRW_Coord & { return thirdPoint; }
//! fourth corner (2D)
auto fourthCorner() const -> const DRW_Coord & { return thirdPoint; }
auto fourthCorner() const -> const DRW_Coord & { return fourPoint; }
//! thickness
auto thick() const -> double { return thickness; }
//! elevation
@ -474,10 +489,13 @@ public:
* Class to handle 3dface entity
* @author Rallaz
*/
class DRW_3Dface : public DRW_Trace {
class DRW_3Dface : public DRW_Trace
{
SETENTFRIENDS
public:
enum InvisibleEdgeFlags {
enum InvisibleEdgeFlags
{
NoEdge = 0x00,
FirstEdge = 0x01,
SecodEdge = 0x02,
@ -511,7 +529,6 @@ protected:
public:
int invisibleflag; /*!< invisible edge flag, code 70 */
};
//! Class to handle block entries
@ -519,8 +536,10 @@ public:
* Class to handle block entries
* @author Rallaz
*/
class DRW_Block : public DRW_Point {
class DRW_Block : public DRW_Point
{
SETENTFRIENDS
public:
DRW_Block()
: name("*U0"),
@ -540,14 +559,15 @@ public:
int flags; /*!< block type, code 70 */
};
//! Class to handle insert entries
/*!
* Class to handle insert entries
* @author Rallaz
*/
class DRW_Insert : public DRW_Point {
class DRW_Insert : public DRW_Point
{
SETENTFRIENDS
public:
DRW_Insert()
: name(),
@ -583,8 +603,10 @@ public:
* Class to handle lwpolyline entity
* @author Rallaz
*/
class DRW_LWPolyline : public DRW_Entity {
class DRW_LWPolyline : public DRW_Entity
{
SETENTFRIENDS
public:
DRW_LWPolyline()
: vertexnum(),
@ -615,11 +637,14 @@ public:
this->vertlist.push_back(new DRW_Vertex2D(*(p.vertlist.at(i))));
}
~DRW_LWPolyline() {
for(DRW_Vertex2D *item : vertlist) delete item;
~DRW_LWPolyline()
{
for (DRW_Vertex2D *item : vertlist)
delete item;
}
void applyExtrusion() override;
void addVertex (DRW_Vertex2D v) {
void addVertex(DRW_Vertex2D v)
{
DRW_Vertex2D *vert = new DRW_Vertex2D();
vert->x = v.x;
vert->y = v.y;
@ -650,6 +675,7 @@ public:
DRW_Coord extPoint; /*!< Dir extrusion normal vector, code 210, 220 & 230 */
DRW_Vertex2D *vertex; /*!< current vertex to add data */
std::vector<DRW_Vertex2D *> vertlist; /*!< vertex list */
private:
auto operator=(const DRW_LWPolyline &) -> DRW_LWPolyline &Q_DECL_EQ_DELETE;
};
@ -659,11 +685,14 @@ private:
* Class to handle insert entries
* @author Rallaz
*/
class DRW_Text : public DRW_Line {
class DRW_Text : public DRW_Line
{
SETENTFRIENDS
public:
//! Vertical alignments.
enum VAlign {
enum VAlign
{
VBaseLine = 0, /*!< Top = 0 */
VBottom, /*!< Bottom = 1 */
VMiddle, /*!< Middle = 2 */
@ -671,7 +700,8 @@ public:
};
//! Horizontal alignments.
enum HAlign {
enum HAlign
{
HLeft = 0, /*!< Left = 0 */
HCenter, /*!< Centered = 1 */
HRight, /*!< Right = 2 */
@ -716,11 +746,14 @@ public:
* Class to handle insert entries
* @author Rallaz
*/
class DRW_MText : public DRW_Text {
class DRW_MText : public DRW_Text
{
SETENTFRIENDS
public:
//! Attachments.
enum Attach {
enum Attach
{
TopLeft = 1,
TopCenter,
TopRight,
@ -747,6 +780,7 @@ protected:
public:
double interlin; /*!< width factor, code 44 */
private:
bool hasXAxisVec;
};
@ -756,8 +790,10 @@ private:
* Class to handle vertex for polyline entity
* @author Rallaz
*/
class DRW_Vertex final : public DRW_Point {
class DRW_Vertex final : public DRW_Point
{
SETENTFRIENDS
public:
DRW_Vertex()
: stawidth(0),
@ -813,8 +849,10 @@ public:
* Class to handle polyline entity
* @author Rallaz
*/
class DRW_Polyline : public DRW_Point {
class DRW_Polyline : public DRW_Point
{
SETENTFRIENDS
public:
DRW_Polyline()
: flags(0),
@ -853,10 +891,13 @@ public:
this->vertlist.push_back(new DRW_Vertex(*(p.vertlist.at(i))));
}
~DRW_Polyline() {
for(DRW_Vertex *item : vertlist) delete item;
~DRW_Polyline()
{
for (DRW_Vertex *item : vertlist)
delete item;
}
void addVertex (DRW_Vertex v) {
void addVertex(DRW_Vertex v)
{
DRW_Vertex *vert = new DRW_Vertex();
vert->basePoint.x = v.basePoint.x;
vert->basePoint.y = v.basePoint.y;
@ -866,9 +907,7 @@ public:
vert->bulge = v.bulge;
vertlist.push_back(vert);
}
void appendVertex (DRW_Vertex *v) {
vertlist.push_back(v);
}
void appendVertex(DRW_Vertex *v) { vertlist.push_back(v); }
protected:
auto parseCode(int code, dxfReader *reader) -> bool override;
@ -892,14 +931,15 @@ private:
duint32 lastEH; // handle of last entity, only in pre-2004
};
//! Class to handle spline entity
/*!
* Class to handle spline entity
* @author Rallaz
*/
class DRW_Spline : public DRW_Entity {
class DRW_Spline : public DRW_Entity
{
SETENTFRIENDS
public:
DRW_Spline()
: normalVec(),
@ -953,9 +993,12 @@ public:
[](DRW_Coord *v) { return new DRW_Coord(*v); });
}
~DRW_Spline() {
for(DRW_Coord *item : controllist) delete item;
for(DRW_Coord *item : fitlist) delete item;
~DRW_Spline()
{
for (DRW_Coord *item : controllist)
delete item;
for (DRW_Coord *item : fitlist)
delete item;
}
void applyExtrusion() override {}
@ -1000,22 +1043,24 @@ private:
* Class to handle hatch loop
* @author Rallaz
*/
class DRW_HatchLoop {
class DRW_HatchLoop
{
public:
explicit DRW_HatchLoop(int t)
: type(t),
numedges(0),
objlist()
{}
{
}
~DRW_HatchLoop() {
~DRW_HatchLoop()
{
// for(DRW_LWPolyline *item : pollist) delete item;
for(DRW_Entity *item : objlist) delete item;
for (DRW_Entity *item : objlist)
delete item;
}
void update() {
numedges = static_cast<int>(objlist.size());
}
void update() { numedges = static_cast<int>(objlist.size()); }
public:
int type; /*!< boundary path type, code 92, polyline=2, default=0 */
@ -1031,8 +1076,10 @@ public:
* @author Rallaz
*/
// TODO: handle lwpolylines, splines and ellipses
class DRW_Hatch : public DRW_Point {
class DRW_Hatch : public DRW_Point
{
SETENTFRIENDS
public:
DRW_Hatch()
: name(),
@ -1061,13 +1108,13 @@ public:
clearEntities();
}
~DRW_Hatch() {
for(DRW_HatchLoop *item : looplist) delete item;
~DRW_Hatch()
{
for (DRW_HatchLoop *item : looplist)
delete item;
}
void appendLoop (DRW_HatchLoop *v) {
looplist.push_back(v);
}
void appendLoop(DRW_HatchLoop *v) { looplist.push_back(v); }
void applyExtrusion() override {}
@ -1091,7 +1138,8 @@ public:
private:
// cppcheck-suppress unknownMacro
Q_DISABLE_COPY_MOVE(DRW_Hatch) // NOLINT
void clearEntities(){
void clearEntities()
{
pt = line = nullptr;
pline = nullptr;
arc = nullptr;
@ -1100,33 +1148,41 @@ private:
plvert = nullptr;
}
void addLine() {
void addLine()
{
clearEntities();
if (loop) {
if (loop)
{
pt = line = new DRW_Line;
loop->objlist.push_back(line);
}
}
void addArc() {
void addArc()
{
clearEntities();
if (loop) {
if (loop)
{
pt = arc = new DRW_Arc;
loop->objlist.push_back(arc);
}
}
void addEllipse() {
void addEllipse()
{
clearEntities();
if (loop) {
if (loop)
{
pt = ellipse = new DRW_Ellipse;
loop->objlist.push_back(ellipse);
}
}
void addSpline() {
void addSpline()
{
clearEntities();
if (loop) {
if (loop)
{
pt = nullptr;
spline = new DRW_Spline;
loop->objlist.push_back(spline);
@ -1149,8 +1205,10 @@ private:
* Class to handle image entity
* @author Rallaz
*/
class DRW_Image : public DRW_Line {
class DRW_Image : public DRW_Line
{
SETENTFRIENDS
public:
DRW_Image()
: ref(),
@ -1182,17 +1240,17 @@ public:
int brightness; /*!< Brightness value, code 281, (0-100) default 50 */
int contrast; /*!< Brightness value, code 282, (0-100) default 50 */
int fade; /*!< Brightness value, code 283, (0-100) default 0 */
};
//! Base class for dimension entity
/*!
* Base class for dimension entity
* @author Rallaz
*/
class DRW_Dimension : public DRW_Entity {
class DRW_Dimension : public DRW_Entity
{
SETENTFRIENDS
public:
DRW_Dimension()
: type(0),
@ -1289,7 +1347,11 @@ public:
void setName(const std::string &s) { name = s; }
// int getType(){ return type;} /*!< Dimension type, code 70 */
auto hasActualMeasurement() const -> bool { return hasActual; }
void setActualMeasurement(double value) { hasActual = true; actual = value; }
void setActualMeasurement(double value)
{
hasActual = true;
actual = value;
}
auto getActualMeasurement() const -> double { return actual; }
protected:
@ -1312,8 +1374,10 @@ protected:
void setOb52(const double d) { oblique = d; }
auto getRa40() const -> double { return length; } /*!< Leader length, code 40 */
void setRa40(const double d) { length = d; }
public:
int type; /*!< Dimension type, code 70 */
private:
auto operator=(const DRW_Dimension &) -> DRW_Dimension &Q_DECL_EQ_DELETE;
std::string name; /*!< Name of the block that contains the entities, code 2 */
@ -1341,16 +1405,18 @@ private:
double actual; /*!< Actual measurement (optional; read-only value), code 42 */
};
//! Class to handle aligned dimension entity
/*!
* Class to handle aligned dimension entity
* @author Rallaz
*/
class DRW_DimAligned : public DRW_Dimension {
class DRW_DimAligned : public DRW_Dimension
{
SETENTFRIENDS
public:
DRW_DimAligned(){
DRW_DimAligned()
{
eType = DRW::DIMALIGNED;
type = 1;
}
@ -1372,7 +1438,6 @@ public:
void setDef1Point(const DRW_Coord &p) { setPt3(p); }
auto getDef2Point() const -> DRW_Coord { return getPt4(); } /*!< Definition point 2, code 14, 24 & 34 */
void setDef2Point(const DRW_Coord &p) { setPt4(p); }
};
//! Class to handle linear or rotated dimension entity
@ -1380,9 +1445,11 @@ public:
* Class to handle linear or rotated dimension entity
* @author Rallaz
*/
class DRW_DimLinear : public DRW_DimAligned {
class DRW_DimLinear : public DRW_DimAligned
{
public:
DRW_DimLinear() {
DRW_DimLinear()
{
eType = DRW::DIMLINEAR;
type = 0;
}
@ -1406,10 +1473,13 @@ public:
* Class to handle aligned, linear or rotated dimension entity
* @author Rallaz
*/
class DRW_DimRadial : public DRW_Dimension {
class DRW_DimRadial : public DRW_Dimension
{
SETENTFRIENDS
public:
DRW_DimRadial() {
DRW_DimRadial()
{
eType = DRW::DIMRADIAL;
type = 4;
}
@ -1428,7 +1498,6 @@ public:
void setDiameterPoint(const DRW_Coord &p) { setPt5(p); }
auto getLeaderLength() const -> double { return getRa40(); } /*!< Leader length, code 40 */
void setLeaderLength(const double d) { setRa40(d); }
};
//! Class to handle radial dimension entity
@ -1436,10 +1505,13 @@ public:
* Class to handle aligned, linear or rotated dimension entity
* @author Rallaz
*/
class DRW_DimDiametric : public DRW_Dimension {
class DRW_DimDiametric : public DRW_Dimension
{
SETENTFRIENDS
public:
DRW_DimDiametric() {
DRW_DimDiametric()
{
eType = DRW::DIMDIAMETRIC;
type = 3;
}
@ -1461,7 +1533,6 @@ public:
void setDiameter2Point(const DRW_Coord &p) { setDefPoint(p); }
auto getLeaderLength() const -> double { return getRa40(); } /*!< Leader length, code 40 */
void setLeaderLength(const double d) { setRa40(d); }
};
//! Class to handle angular dimension entity
@ -1469,14 +1540,18 @@ public:
* Class to handle angular dimension entity
* @author Rallaz
*/
class DRW_DimAngular : public DRW_Dimension {
class DRW_DimAngular : public DRW_Dimension
{
SETENTFRIENDS
public:
DRW_DimAngular() {
DRW_DimAngular()
{
eType = DRW::DIMANGULAR;
type = 2;
}
explicit DRW_DimAngular(const DRW_Dimension& d): DRW_Dimension(d)
explicit DRW_DimAngular(const DRW_Dimension &d)
: DRW_Dimension(d)
{
eType = DRW::DIMANGULAR;
}
@ -1494,23 +1569,25 @@ public:
void setSecondLine2(const DRW_Coord &p) { setDefPoint(p); }
auto getDimPoint() const -> DRW_Coord { return getPt6(); } /*!< Dimension definition point, code 16, 26 & 36 */
void setDimPoint(const DRW_Coord &p) { setPt6(p); }
};
//! Class to handle angular 3p dimension entity
/*!
* Class to handle angular 3p dimension entity
* @author Rallaz
*/
class DRW_DimAngular3p : public DRW_Dimension {
class DRW_DimAngular3p : public DRW_Dimension
{
SETENTFRIENDS
public:
DRW_DimAngular3p() {
DRW_DimAngular3p()
{
eType = DRW::DIMANGULAR3P;
type = 5;
}
explicit DRW_DimAngular3p(const DRW_Dimension& d): DRW_Dimension(d)
explicit DRW_DimAngular3p(const DRW_Dimension &d)
: DRW_Dimension(d)
{
eType = DRW::DIMANGULAR3P;
}
@ -1523,7 +1600,6 @@ public:
void SetVertexPoint(const DRW_Coord &p) { setPt5(p); }
auto getDimPoint() const -> DRW_Coord { return getDefPoint(); } /*!< Dimension definition point, code 10, 20 & 30 */
void setDimPoint(const DRW_Coord &p) { setDefPoint(p); }
};
//! Class to handle ordinate dimension entity
@ -1531,10 +1607,13 @@ public:
* Class to handle ordinate dimension entity
* @author Rallaz
*/
class DRW_DimOrdinate : public DRW_Dimension {
class DRW_DimOrdinate : public DRW_Dimension
{
SETENTFRIENDS
public:
DRW_DimOrdinate() {
DRW_DimOrdinate()
{
eType = DRW::DIMORDINATE;
type = 6;
}
@ -1550,17 +1629,17 @@ public:
void setFirstLine(const DRW_Coord &p) { setPt3(p); }
auto getSecondLine() const -> DRW_Coord { return getPt4(); } /*!< Leader end point, code 14, 24 & 34 */
void setSecondLine(const DRW_Coord &p) { setPt4(p); }
};
//! Class to handle leader entity
/*!
* Class to handle leader entity
* @author Rallaz
*/
class DRW_Leader : public DRW_Entity {
class DRW_Leader : public DRW_Entity
{
SETENTFRIENDS
public:
DRW_Leader()
: style(),
@ -1583,8 +1662,10 @@ public:
{
eType = DRW::LEADER;
}
~DRW_Leader() {
for(DRW_Coord *item : vertexlist) delete item;
~DRW_Leader()
{
for (DRW_Coord *item : vertexlist)
delete item;
}
void applyExtrusion() override {}
@ -1621,8 +1702,10 @@ private:
* Class to handle viewport entity
* @author Rallaz
*/
class DRW_Viewport : public DRW_Point {
class DRW_Viewport : public DRW_Point
{
SETENTFRIENDS
public:
DRW_Viewport()
: pswidth(205),
@ -1676,7 +1759,8 @@ public:
private:
duint32 frozenLyCount;
};//RLZ: missing 15,25, 72, 331, 90, 340, 1, 281, 71, 74, 110, 120, 130, 111, 121,131, 112,122, 132, 345,346, and more...
}; // RLZ: missing 15,25, 72, 331, 90, 340, 1, 281, 71, 74, 110, 120, 130, 111, 121,131, 112,122, 132, 345,346, and
// more...
// used //DRW_Coord basePoint; /*!< base point, code 10, 20 & 30 */

View File

@ -411,7 +411,12 @@ auto dxfRW::writeLayer(DRW_Layer *ent) -> bool
auto dxfRW::writeTextstyle(DRW_Textstyle *ent) -> bool
{
writer->writeString(0, "STYLE");
// stringstream cause crash in OS/X, bug#3597944
std::string name = ent->name;
transform(name.begin(), name.end(), name.begin(), toupper);
if (!dimstyleStd)
{
if (name == "STANDARD")
{
// stringstream cause crash in OS/X, bug#3597944
std::string name = ent->name;
@ -419,9 +424,11 @@ auto dxfRW::writeTextstyle(DRW_Textstyle *ent) -> bool
if (name == "STANDARD")
dimstyleStd = true;
}
}
if (version > DRW::AC1009)
{
writer->writeString(5, toHexStr(++entCount));
textStyleMap[name] = entCount;
}
if (version > DRW::AC1012)
@ -555,12 +562,10 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
if (name == "STANDARD")
dimstyleStd = true;
}
if (version > DRW::AC1009)
{
writer->writeString(105, toHexStr(++entCount));
}
if (version > DRW::AC1012)
{
writer->writeString(330, "A");
@ -574,15 +579,15 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
else
writer->writeUtf8Caps(2, ent->name);
writer->writeInt16(70, ent->flags);
if (version <= DRW::AC1009 || !(ent->dimpost.empty()))
if (version == DRW::AC1009 || !(ent->dimpost.empty()))
writer->writeUtf8String(3, ent->dimpost);
if (version <= DRW::AC1009 || !(ent->dimapost.empty()))
if (version == DRW::AC1009 || !(ent->dimapost.empty()))
writer->writeUtf8String(4, ent->dimapost);
if (version <= DRW::AC1009 || !(ent->dimblk.empty()))
if (version == DRW::AC1009 || !(ent->dimblk.empty()))
writer->writeUtf8String(5, ent->dimblk);
if (version <= DRW::AC1009 || !(ent->dimblk1.empty()))
if (version == DRW::AC1009 || !(ent->dimblk1.empty()))
writer->writeUtf8String(6, ent->dimblk1);
if (version <= DRW::AC1009 || !(ent->dimblk2.empty()))
if (version == DRW::AC1009 || !(ent->dimblk2.empty()))
writer->writeUtf8String(7, ent->dimblk2);
writer->writeDouble(40, ent->dimscale);
writer->writeDouble(41, ent->dimasz);
@ -593,6 +598,8 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
writer->writeDouble(46, ent->dimdle);
writer->writeDouble(47, ent->dimtp);
writer->writeDouble(48, ent->dimtm);
if (version > DRW::AC1018 || !qFuzzyIsNull(ent->dimfxl))
writer->writeDouble(49, ent->dimfxl);
writer->writeDouble(140, ent->dimtxt);
writer->writeDouble(141, ent->dimcen);
writer->writeDouble(142, ent->dimtsz);
@ -664,16 +671,28 @@ auto dxfRW::writeDimstyle(DRW_Dimstyle *ent) -> bool
{
writer->writeInt16(289, ent->dimatfit);
}
if (version > DRW::AC1009 && !ent->dimtxsty.empty())
if (version > DRW::AC1018 && ent->dimfxlon != 0)
writer->writeInt16(290, ent->dimfxlon);
if (version > DRW::AC1009)
{
writer->writeUtf8String(340, ent->dimtxsty);
std::string txstyname = ent->dimtxsty;
std::transform(txstyname.begin(), txstyname.end(), txstyname.begin(), ::toupper);
if (textStyleMap.count(txstyname) > 0)
{
int txstyHandle = (*(textStyleMap.find(txstyname))).second;
writer->writeUtf8String(340, toHexStr(txstyHandle));
}
}
if (version > DRW::AC1014)
{
writer->writeUtf8String(341, ent->dimldrblk);
if (blockMap.count(ent->dimldrblk) > 0)
{
int blkHandle = (*(blockMap.find(ent->dimldrblk))).second;
writer->writeUtf8String(341, toHexStr(blkHandle));
writer->writeInt16(371, ent->dimlwd);
writer->writeInt16(372, ent->dimlwe);
}
}
return true;
}

View File

@ -158,6 +158,7 @@ private:
bool writingBlock;
int elParts; /*!< parts number when convert ellipse to polyline */
std::unordered_map<std::string, int> blockMap;
std::unordered_map<std::string, int> textStyleMap;
std::vector<DRW_ImageDef *> imageDef; /*!< imageDef list */
int currHandle;