QCAD Application Framework
CAD Application Development and Automation.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RTextRenderer.h
Go to the documentation of this file.
1 #ifndef RTEXTRENDERER_H
2 #define RTEXTRENDERER_H
3 
4 #include <QTextLayout>
5 
6 #include "RDocument.h"
7 #include "REntityData.h"
8 #include "RPainterPath.h"
9 #include "RPainterPathSource.h"
10 #include "RTextData.h"
11 #include "RVector.h"
12 
13 class QTextDocument;
14 
22 public:
23  enum Target {
24  PainterPaths = 0x01,
25  RichText = 0x02
26  };
27 
28 public:
30 
31  void renderSimple();
32  void render();
33 
34  QList<RPainterPath> getPainterPaths() const {
35  return painterPaths;
36  }
37 
38  RBox getBoundingBox() const {
39  return boundingBox;
40  }
41 
42  double getHeight() const {
43  return height;
44  }
45 
46  double getWidth() const {
47  return width;
48  }
49 
50  QString getRichText() const {
51  return richText;
52  }
53 
54 private:
55  QList<RPainterPath> getPainterPathsForBlock(
56  const QString& blockText,
57  const QList<QTextLayout::FormatRange>& formats,
58  double& horizontalAdvance,
59  double& horizontalAdvanceNoSpacing,
60  double& ascent,
61  double& descent);
62 
63  QList<RPainterPath> getPainterPathsForBlockTtf(
64  const QString& blockText,
65  const QList<QTextLayout::FormatRange>& formats,
66  double& horizontalAdvance,
67  double& horizontalAdvanceNoSpacing,
68  double& ascent,
69  double& descent);
70 
71  QList<RPainterPath> getPainterPathsForBlockCad(
72  const QString& blockText,
73  const QList<QTextLayout::FormatRange>& formats,
74  double& horizontalAdvance,
75  double& horizontalAdvanceNoSpacing,
76  double& ascent,
77  double& descent);
78 
79  QRectF getCharacterRect(const QString& fontName, const QChar& ch) const;
80  QRectF getCharacterRect(const QFont& font, const QChar& ch) const;
81 
82  QString getRichTextForBlock(const QString& blockText,
83  const QList<QTextLayout::FormatRange>& formats);
84 
85 public:
86  static QString rxLineFeed;
87  static QString rxParagraphFeed;
88  static QString rxHeightChange;
89  //static QString rxRelativeHeightChange;
90  static QString rxStackedText;
91  static QString rxColorChangeIndex;
92  static QString rxColorChangeCustom;
93  static QString rxNonBreakingSpace;
94  static QString rxOverlineOn;
95  static QString rxOverlineOff;
96  static QString rxUnderlineOn;
97  static QString rxUnderlineOff;
98  static QString rxWidthChange;
99  static QString rxObliqueAngleChange;
100  static QString rxTrackChange;
101  static QString rxAlignmentChange;
102  static QString rxFontChangeCad;
103  static QString rxFontChangeTtf;
104  static QString rxBeginBlock;
105  static QString rxEndBlock;
106  static QString rxBackslash;
107  static QString rxCurlyOpen;
108  static QString rxCurlyClose;
109  static QString rxDegree;
110  static QString escDegree;
111  static QString rxPlusMinus;
112  static QString escPlusMinus;
113  static QString rxDiameter;
114  static QString escDiameter;
115  static QString rxUnicode;
116 
117  static QString rxAll;
118 
119  static QChar chDegree;
120  static QChar chPlusMinus;
121  static QChar chDiameter;
122 
123 private:
125 
127  QList<RPainterPath> painterPaths;
129  double height;
130  double width;
131  bool draft;
132  QString richText;
134 
135  QStack<bool> useCadFont;
136  QStack<QTextCharFormat> currentFormat;
137  QStack<double> blockHeight;
138  QStack<QString> blockFont;
139  QStack<bool> blockBold;
140  QStack<bool> blockItalic;
141  QStack<QStringList> openTags;
142 };
143 
147 
148 #endif