QCAD
Open Source 2D CAD
RGraphicsSceneDrawable.h
Go to the documentation of this file.
1 
20 #ifndef RGRAPHICSSCENEDRAWABLE_H
21 #define RGRAPHICSSCENEDRAWABLE_H
22 
23 #include "gui_global.h"
24 
25 #include "RPainterPath.h"
26 #include "RImageData.h"
27 #include "RTextBasedData.h"
28 
34 public:
35  enum Type {
40  };
41 
42  enum Mode {
43  NoMode = 0x0000,
44  NoPlot = 0x0001,
45  PixelUnit = 0x0002
46  };
47  Q_DECLARE_FLAGS(Modes, Mode)
48 
49 public:
50  RGraphicsSceneDrawable() : type(Invalid), modes(NoMode), painterPath(NULL), image(NULL), text(NULL) {}
52 
57 
62 
67 
69 
70  static RGraphicsSceneDrawable createFromPainterPath(const RPainterPath& pp, const RVector& offset = RVector::nullVector);
71  static RGraphicsSceneDrawable createFromImage(const RImageData& img, const RVector& offset = RVector::nullVector);
72  static RGraphicsSceneDrawable createFromText(const RTextBasedData& txt, const RVector& offset = RVector::nullVector);
73 
74  void uninit();
75 
77  return type;
78  }
79 
80  void setMode(RGraphicsSceneDrawable::Mode mode, bool on = true) {
81  if (on) {
82  modes |= mode;
83  } else {
84  modes &= ~mode;
85  }
86  }
88  return (modes & mode) == mode;
89  }
90 
91  void setNoPlot(bool on) {
92  setMode(RGraphicsSceneDrawable::NoPlot, on);
93  }
94  bool getNoPlot() const {
95  return getMode(RGraphicsSceneDrawable::NoPlot);
96  }
97 
98  void setPixelUnit(bool on) {
100  }
101  bool getPixelUnit() const {
102  return getMode(RGraphicsSceneDrawable::PixelUnit);
103  }
104 
106  Q_ASSERT(painterPath!=NULL);
107  return *painterPath;
108  }
109 
110  RImageData& getImage() const {
111  Q_ASSERT(image!=NULL);
112  return *image;
113  }
114 
116  Q_ASSERT(text!=NULL);
117  return *text;
118  }
119 
120  RVector getOffset() const {
121  return offset;
122  }
123 
124  void setOffset(const RVector& o) {
125  offset = o;
126  }
127 
128  void setSelected(bool on);
129  void setHighlighted(bool on);
130 
131  RGraphicsSceneDrawable& operator=(const RGraphicsSceneDrawable& other);
132 
133 protected:
136  Modes modes;
137 
138  //union {
142  //};
143 };
144 
145 QCADGUI_EXPORT QDebug operator<<(QDebug dbg, const RGraphicsSceneDrawable& d);
146 
152 
153 #endif
Insert text.
Definition: Text.js:18
Mode
Definition: RGraphicsSceneDrawable.h:42
RVector offset
Definition: RGraphicsSceneDrawable.h:135
unit interpreted as pixels
Definition: RGraphicsSceneDrawable.h:45
RTextBasedData * text
Definition: RGraphicsSceneDrawable.h:141
Represents a 3d vector (x/y/z).
Definition: RVector.h:46
#define QCADGUI_EXPORT
Definition: gui_global.h:10
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RGraphicsSceneDrawable.h:33
Copyright (c) 2011-2018 by Andrew Mustun.
Definition: RImageData.h:41
bool getPixelUnit() const
Definition: RGraphicsSceneDrawable.h:101
RPainterPath * painterPath
Definition: RGraphicsSceneDrawable.h:139
void setNoPlot(bool on)
Definition: RGraphicsSceneDrawable.h:91
void setMode(RGraphicsSceneDrawable::Mode mode, bool on=true)
Definition: RGraphicsSceneDrawable.h:80
RTextBasedData & getText() const
Definition: RGraphicsSceneDrawable.h:115
Type type
Definition: RGraphicsSceneDrawable.h:134
void setOffset(const RVector &o)
Definition: RGraphicsSceneDrawable.h:124
Stores and manages all data that defines the geometry and appearance of a text based entity (text...
Definition: RTextBasedData.h:44
bool getMode(RGraphicsSceneDrawable::Mode mode) const
Definition: RGraphicsSceneDrawable.h:87
Definition: RGraphicsSceneDrawable.h:36
Q_DECLARE_METATYPE(RMath *)
RVector getOffset() const
Definition: RGraphicsSceneDrawable.h:120
Modes modes
Definition: RGraphicsSceneDrawable.h:136
Extended painter path with a z-level and a pen.
Definition: RPainterPath.h:46
static const RVector nullVector
null vector
Definition: RVector.h:327
RGraphicsSceneDrawable::Type getType() const
Definition: RGraphicsSceneDrawable.h:76
QCADGUI_EXPORT QDebug operator<<(QDebug dbg, const RGraphicsSceneDrawable &d)
Definition: RGraphicsSceneDrawable.cpp:114
Type
Definition: RGraphicsSceneDrawable.h:35
Definition: RGraphicsSceneDrawable.h:37
not plotted (from not plottable layers)
Definition: RGraphicsSceneDrawable.h:44
RPainterPath & getPainterPath() const
Definition: RGraphicsSceneDrawable.h:105
Definition: RGraphicsSceneDrawable.h:38
RImageData & getImage() const
Definition: RGraphicsSceneDrawable.h:110
RImageData * image
Definition: RGraphicsSceneDrawable.h:140
bool getNoPlot() const
Definition: RGraphicsSceneDrawable.h:94
void setPixelUnit(bool on)
Definition: RGraphicsSceneDrawable.h:98