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  void fixBlockName(QString& blockName);
55  void fixLayerName(QString& layerName);
56  QString fixFontName(const QString& fontName) const;
57 
58  void fixVersion2String(QString& str) const;
59  void fixDimensionLabel(QString& text, QString& uTol, QString& lTol) const;
60  void detectVersion2Format(const QString& fileName);
61 
62  bool hasDIMZIN() const {
63  return version2GotDIMZIN;
64  }
65  bool hasDIMAZIN() const {
66  return version2GotDIMAZIN;
67  }
68  bool hasInvalidEllipse() const {
69  return version2GotInvalidEllipse;
70  }
71  bool getVersion2Compatibility() const {
72  return dxflibMajorVersion==2;
73  }
75  return (dxflibMajorVersion==3 && dxflibMinorVersion==0) ||
76  (dxflibMajorVersion==3 && dxflibMinorVersion==1 && dxflibPatchVersion==0);
77  }
78  int getMajorVersion() const {
79  return dxflibMajorVersion;
80  }
81  int getMinorVersion() const {
82  return dxflibMinorVersion;
83  }
84  int getPatchVersion() const {
85  return dxflibPatchVersion;
86  }
87 
88  QString getVersion2LayerName(const QString& layerName) const;
89  QString getVersionBlockName(const QString& blockName) const;
90  QString getVersion2Font(const QString& handle) const;
91  QString getVersion2DimensionLabel(const QString& handle) const;
92 
93  QString collectVersion2Info(const QString& fileName);
94 
95  double getVersion2PatternAngle(double angle, const QString& patternName) const;
96  double getVersion2PatternScale(double scale, const QString& patternName) const;
97  QString getVersion2PatternName(const QString& patternName) const;
98 
99  void fixVersion2HatchData(QString& patternName, double& angle, double& scale, bool solid) const;
100 
101  QTextCodec* getCodec() const {
102  return codec;
103  }
104 
105  void setCodec(QTextCodec* codec) {
106  this->codec = codec;
107  }
108 
112  static RColor attributesToColor(int color, int color24, const double dxfColors[][3], bool forLayer=false);
116  static RColor numberToColor(int num, const double dxfColors[][3], bool comp=false, bool forLayer=false);
117  static RColor numberToColor24(int num);
118  static RLineweight::Lineweight numberToWeight(int num);
119 
120  static int widthToNumber(RLineweight::Lineweight w);
121  static int colorToNumber24(const RColor& col);
125  static int colorToNumber(const RColor& col, const double dxfColors[][3]);
126 
127  static RS::KnownVariable stringToVariable(const QString& s);
128  static QString variableToString(RS::KnownVariable v);
129  static int getCodeForVariable(RS::KnownVariable v);
130  static RDxfServices::Type getTypeForVariable(RS::KnownVariable v);
131  static bool isVariable2D(RS::KnownVariable v);
132 
133  static QString escapeUnicode(const QString& str);
134  static QString parseUnicode(const QString& str);
135 
136  static void autoFixLinetypePattern(RLinetypePattern& pattern);
137 
138 private:
145 
146  QMap<QString, QString> version2BlockMapping;
147  QMap<QString, QString> version2LayerMapping;
148  QMap<QString, QString> version2TextFonts;
149  QMap<QString, QString> version2DimensionLabels;
150 
151  QTextCodec* codec;
152 };
153 
157 
158 #endif
int dxflibMinorVersion
Definition: RDxfServices.h:143
int getPatchVersion() const
Definition: RDxfServices.h:84
bool version2GotInvalidEllipse
Definition: RDxfServices.h:141
bool version2GotDIMZIN
Definition: RDxfServices.h:139
Definition: RDxfServices.h:42
QMap< QString, QString > version2BlockMapping
Definition: RDxfServices.h:146
void setCodec(QTextCodec *codec)
Definition: RDxfServices.h:105
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:101
bool hasDIMZIN() const
Definition: RDxfServices.h:62
int dxflibMajorVersion
Definition: RDxfServices.h:142
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RLinetypePattern.h:45
QMap< QString, QString > version2DimensionLabels
Definition: RDxfServices.h:149
Lineweight
Definition: RLineweight.h:42
bool getVersion3_1Compatibility() const
Definition: RDxfServices.h:74
Color.
Definition: RColor.h:42
QMap< QString, QString > version2LayerMapping
Definition: RDxfServices.h:147
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RDxfServices.h:39
bool hasDIMAZIN() const
Definition: RDxfServices.h:65
Q_DECLARE_METATYPE(RMath *)
int getMinorVersion() const
Definition: RDxfServices.h:81
bool getVersion2Compatibility() const
Definition: RDxfServices.h:71
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:71
KnownVariable
Well established document variables.
Definition: RS.h:329
const double dxfColors[][3]
Definition: dl_codes.h:109
int dxflibPatchVersion
Definition: RDxfServices.h:144
QTextCodec * codec
Definition: RDxfServices.h:151
int getMajorVersion() const
Definition: RDxfServices.h:78
QMap< QString, QString > version2TextFonts
Definition: RDxfServices.h:148
Definition: RDxfServices.h:44
bool version2GotDIMAZIN
Definition: RDxfServices.h:140
bool hasInvalidEllipse() const
Definition: RDxfServices.h:68