QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
RDxfServices.h
Go to the documentation of this file.
1
20#ifndef RDXFSERVICES_H
21#define RDXFSERVICES_H
22
23#include <QString>
24
25#if QT_VERSION >= 0x060000
26#include <QStringDecoder>
27#endif
28
29#include "dxf_global.h"
30
31#include "RS.h"
32#include "RColor.h"
33#include "RLineweight.h"
34
35
36class RDocument;
38
47public:
48 enum Type {
53 Vector
54 };
55
56public:
59
60 void reset();
61
62 static QString getSafeBlockName(QString& blockName);
63
64 void fixBlockName(QString& blockName);
65 void fixLayerName(QString& layerName);
66 QString fixFontName(const QString& fontName) const;
67
68 void fixVersion2String(QString& str) const;
69 void fixDimensionLabel(QString& text, QString& uTol, QString& lTol) const;
70 void detectVersion2Format(const QString& fileName);
71
72 bool hasDIMZIN() const {
73 return version2GotDIMZIN;
74 }
75 bool hasDIMAZIN() const {
76 return version2GotDIMAZIN;
77 }
78 bool hasInvalidEllipse() const {
79 return version2GotInvalidEllipse;
80 }
82 return dxflibMajorVersion==2;
83 }
85 return (dxflibMajorVersion==3 && dxflibMinorVersion==0) ||
86 (dxflibMajorVersion==3 && dxflibMinorVersion==1 && dxflibPatchVersion==0);
87 }
88 int getMajorVersion() const {
89 return dxflibMajorVersion;
90 }
91 int getMinorVersion() const {
92 return dxflibMinorVersion;
93 }
94 int getPatchVersion() const {
95 return dxflibPatchVersion;
96 }
97
98 QString getVersion2LayerName(const QString& layerName) const;
99 QString getVersionBlockName(const QString& blockName) const;
100 QString getVersion2Font(const QString& handle) const;
101 QString getVersion2DimensionLabel(const QString& handle) const;
102
103 QString collectVersion2Info(const QString& fileName);
104
105 double getVersion2PatternAngle(double angle, const QString& patternName) const;
106 double getVersion2PatternScale(double scale, const QString& patternName) const;
107 QString getVersion2PatternName(const QString& patternName) const;
108
109 void fixVersion2HatchData(QString& patternName, double& angle, double& scale, bool solid) const;
110
111#if QT_VERSION >= 0x060000
115 QStringDecoder* getCodec() const {
116 return codec;
117 }
118
122 void setCodec(QStringDecoder* codec) {
123 this->codec = codec;
124 }
125#else
126 QTextCodec* getCodec() const {
127 return codec;
128 }
129
130 void setCodec(QTextCodec* codec) {
131 this->codec = codec;
132 }
133#endif
134
138 static RColor attributesToColor(int color, int color24, const double dxfColors[][3], bool forLayer=false);
142 static RColor numberToColor(int num, const double dxfColors[][3], bool comp=false, bool forLayer=false);
143 static RColor numberToColor24(int num);
144 static RLineweight::Lineweight numberToWeight(int num);
145
146 static int widthToNumber(RLineweight::Lineweight w);
147 static int colorToNumber24(const RColor& col);
151 static int colorToNumber(const RColor& col, const double dxfColors[][3]);
152
153 static RS::KnownVariable stringToVariable(const QString& s);
154 static QString variableToString(RS::KnownVariable v);
155 static int getCodeForVariable(RS::KnownVariable v);
156 static RDxfServices::Type getTypeForVariable(RS::KnownVariable v);
157 static bool isVariable2D(RS::KnownVariable v);
158
159 static QString escapeUnicode(const QString& str);
160 static QString parseUnicode(const QString& str);
161
162 static void autoFixLinetypePattern(RLinetypePattern& pattern);
163
164 static int getFileQCADVersion(const RDocument& doc);
165
166 static void initAci();
167 static int getAci(const RColor& col);
168 static RColor getColor(unsigned int index);
169
170private:
177
182
185
186#if QT_VERSION >= 0x060000
187 QStringDecoder* codec;
188#else
189 QTextCodec* codec;
190#endif
191};
192
196
197#endif
Q_DECLARE_METATYPE(RMath *)
Definition RDebug.h:38
Color.
Definition RColor.h:43
A graphics document contains and owns entities, layers, user coordinate systems, variables,...
Definition RDocument.h:78
DXF support tools, mainly for QCAD 2 DXF imports.
Definition RDxfServices.h:46
bool getVersion2Compatibility() const
Definition RDxfServices.h:81
QMap< QString, QString > version2LayerMapping
Definition RDxfServices.h:179
int dxflibPatchVersion
Definition RDxfServices.h:176
QTextCodec * codec
Definition RDxfServices.h:189
QMap< QString, QString > version2DimensionLabels
Definition RDxfServices.h:181
void setCodec(QTextCodec *codec)
Definition RDxfServices.h:130
QMap< QString, QString > version2TextFonts
Definition RDxfServices.h:180
int getMajorVersion() const
Definition RDxfServices.h:88
bool hasInvalidEllipse() const
Definition RDxfServices.h:78
static QMap< unsigned int, QRgb > aci
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RDxfServices.h:183
static QMap< QRgb, unsigned int > revAci
Definition RDxfServices.h:184
bool version2GotDIMZIN
Definition RDxfServices.h:171
int dxflibMajorVersion
Definition RDxfServices.h:174
int getMinorVersion() const
Definition RDxfServices.h:91
QTextCodec * getCodec() const
Definition RDxfServices.h:126
Type
Definition RDxfServices.h:48
@ Int
Definition RDxfServices.h:51
@ String
Definition RDxfServices.h:50
@ Float
Definition RDxfServices.h:52
@ Unknown
Definition RDxfServices.h:49
bool hasDIMZIN() const
Definition RDxfServices.h:72
int dxflibMinorVersion
Definition RDxfServices.h:175
bool getVersion3_1Compatibility() const
Definition RDxfServices.h:84
bool hasDIMAZIN() const
Definition RDxfServices.h:75
bool version2GotInvalidEllipse
Definition RDxfServices.h:173
QMap< QString, QString > version2BlockMapping
Definition RDxfServices.h:178
bool version2GotDIMAZIN
Definition RDxfServices.h:172
int getPatchVersion() const
Definition RDxfServices.h:94
Copyright (c) 2011-2018 by Andrew Mustun.
Definition RLinetypePattern.h:42
Lineweight
Definition RLineweight.h:44
KnownVariable
Well established document variables.
Definition RS.h:501
#define QCADCORE_EXPORT
Definition core_global.h:10
const double dxfColors[][3]
Definition dl_codes.h:109
void scale(void e, void factor, void focusPoint)
Scales the given entity or shape by the given factor with the given focus point.
Definition simple_modify.js:15
char s
Definition opennurbs_string.cpp:32