QCAD
Open Source 2D CAD
RDxfServices.h
Go to the documentation of this file.
1 
20 #ifndef RDXFSERVICES_H
21 #define RDXFSERVICES_H
22 
23 #include <QString>
24 
25 #include "dxf_global.h"
26 
27 #include "RS.h"
28 #include "RColor.h"
29 #include "RLineweight.h"
30 #include "RLinetypePattern.h"
31 
40 public:
41  enum Type {
44  Int,
46  Vector
47  };
48 
49 public:
50  RDxfServices();
51 
52  void reset();
53 
54  static QString getSafeBlockName(QString& blockName);
55 
56  void fixBlockName(QString& blockName);
57  void fixLayerName(QString& layerName);
58  QString fixFontName(const QString& fontName) const;
59 
60  void fixVersion2String(QString& str) const;
61  void fixDimensionLabel(QString& text, QString& uTol, QString& lTol) const;
62  void detectVersion2Format(const QString& fileName);
63 
64  bool hasDIMZIN() const {
65  return version2GotDIMZIN;
66  }
67  bool hasDIMAZIN() const {
68  return version2GotDIMAZIN;
69  }
70  bool hasInvalidEllipse() const {
71  return version2GotInvalidEllipse;
72  }
73  bool getVersion2Compatibility() const {
74  return dxflibMajorVersion==2;
75  }
77  return (dxflibMajorVersion==3 && dxflibMinorVersion==0) ||
78  (dxflibMajorVersion==3 && dxflibMinorVersion==1 && dxflibPatchVersion==0);
79  }
80  int getMajorVersion() const {
81  return dxflibMajorVersion;
82  }
83  int getMinorVersion() const {
84  return dxflibMinorVersion;
85  }
86  int getPatchVersion() const {
87  return dxflibPatchVersion;
88  }
89 
90  QString getVersion2LayerName(const QString& layerName) const;
91  QString getVersionBlockName(const QString& blockName) const;
92  QString getVersion2Font(const QString& handle) const;
93  QString getVersion2DimensionLabel(const QString& handle) const;
94 
95  QString collectVersion2Info(const QString& fileName);
96 
97  double getVersion2PatternAngle(double angle, const QString& patternName) const;
98  double getVersion2PatternScale(double scale, const QString& patternName) const;
99  QString getVersion2PatternName(const QString& patternName) const;
100 
101  void fixVersion2HatchData(QString& patternName, double& angle, double& scale, bool solid) const;
102 
103  QTextCodec* getCodec() const {
104  return codec;
105  }
106 
107  void setCodec(QTextCodec* codec) {
108  this->codec = codec;
109  }
110 
114  static RColor attributesToColor(int color, int color24, const double dxfColors[][3], bool forLayer=false);
118  static RColor numberToColor(int num, const double dxfColors[][3], bool comp=false, bool forLayer=false);
119  static RColor numberToColor24(int num);
120  static RLineweight::Lineweight numberToWeight(int num);
121 
122  static int widthToNumber(RLineweight::Lineweight w);
123  static int colorToNumber24(const RColor& col);
127  static int colorToNumber(const RColor& col, const double dxfColors[][3]);
128 
129  static RS::KnownVariable stringToVariable(const QString& s);
130  static QString variableToString(RS::KnownVariable v);
131  static int getCodeForVariable(RS::KnownVariable v);
132  static RDxfServices::Type getTypeForVariable(RS::KnownVariable v);
133  static bool isVariable2D(RS::KnownVariable v);
134 
135  static QString escapeUnicode(const QString& str);
136  static QString parseUnicode(const QString& str);
137 
138  static void autoFixLinetypePattern(RLinetypePattern& pattern);
139 
140 private:
147 
148  QMap<QString, QString> version2BlockMapping;
149  QMap<QString, QString> version2LayerMapping;
150  QMap<QString, QString> version2TextFonts;
151  QMap<QString, QString> version2DimensionLabels;
152 
153  QTextCodec* codec;
154 };
155 
159 
160 #endif
int dxflibMinorVersion
Definition: RDxfServices.h:145
int getPatchVersion() const
Definition: RDxfServices.h:86
bool version2GotInvalidEllipse
Definition: RDxfServices.h:143
bool version2GotDIMZIN
Definition: RDxfServices.h:141
Definition: RDxfServices.h:42
QMap< QString, QString > version2BlockMapping
Definition: RDxfServices.h:148
void setCodec(QTextCodec *codec)
Definition: RDxfServices.h:107
Definition: RDxfServices.h:45
Type
Definition: RDxfServices.h:41
Definition: RDxfServices.h:43
#define QCADCORE_EXPORT
Definition: core_global.h:10
QTextCodec * getCodec() const
Definition: RDxfServices.h:103
bool hasDIMZIN() const
Definition: RDxfServices.h:64
int dxflibMajorVersion
Definition: RDxfServices.h:144
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RLinetypePattern.h:45
QMap< QString, QString > version2DimensionLabels
Definition: RDxfServices.h:151
Lineweight
Definition: RLineweight.h:46
bool getVersion3_1Compatibility() const
Definition: RDxfServices.h:76
Color.
Definition: RColor.h:44
QMap< QString, QString > version2LayerMapping
Definition: RDxfServices.h:149
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RDxfServices.h:39
bool hasDIMAZIN() const
Definition: RDxfServices.h:67
Q_DECLARE_METATYPE(RMath *)
int getMinorVersion() const
Definition: RDxfServices.h:83
bool getVersion2Compatibility() const
Definition: RDxfServices.h:73
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:95
KnownVariable
Well established document variables.
Definition: RS.h:381
const double dxfColors[][3]
Definition: dl_codes.h:109
int dxflibPatchVersion
Definition: RDxfServices.h:146
QTextCodec * codec
Definition: RDxfServices.h:153
int getMajorVersion() const
Definition: RDxfServices.h:80
QMap< QString, QString > version2TextFonts
Definition: RDxfServices.h:150
Definition: RDxfServices.h:44
bool version2GotDIMAZIN
Definition: RDxfServices.h:142
bool hasInvalidEllipse() const
Definition: RDxfServices.h:70