QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
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 "RTextBasedData.h"
27
28class RImageData;
29class RTransform;
30class RDocument;
31
32
38public:
49
50 enum Mode {
51 NoMode = 0x0000,
52 NoPlot = 0x0001,
53 PixelUnit = 0x0002,
54 WorkingSet = 0x0004
55 };
56 Q_DECLARE_FLAGS(Modes, Mode)
57
58public:
59 RGraphicsSceneDrawable() : type(Invalid), modes(NoMode), painterPath(NULL), image(NULL), text(NULL), transform(NULL) {}
61
66
71
76
81
85 RGraphicsSceneDrawable(const Type& t, const RVector& os = RVector::nullVector);
86
88
89 static RGraphicsSceneDrawable createFromPainterPath(const RPainterPath& pp, const RVector& offset = RVector::nullVector);
90 static RGraphicsSceneDrawable createFromImage(const RImageData& img, const RVector& offset = RVector::nullVector);
91 static RGraphicsSceneDrawable createFromText(const RTextBasedData& txt, const RVector& offset = RVector::nullVector);
92 static RGraphicsSceneDrawable createFromTransform(const RTransform& transform, const RVector& offset = RVector::nullVector);
93 static RGraphicsSceneDrawable createEndTransform(const RVector& offset);
94
95 void uninit();
96
98 return type;
99 }
100
102 return type==PainterPath || type==PainterPathRay || type==PainterPathXLine;
103 }
104
105 bool isText() {
106 return type==Text;
107 }
108
109 bool isImage() {
110 return type==Image;
111 }
112
113 void setMode(RGraphicsSceneDrawable::Mode mode, bool on = true) {
114 if (on) {
115 modes |= mode;
116 } else {
117 modes &= ~mode;
118 }
119 }
121 return (modes & mode) == mode;
122 }
123
124 void setNoPlot(bool on) {
126 }
127 bool getNoPlot() const {
128 return getMode(RGraphicsSceneDrawable::NoPlot);
129 }
130
131 void setPixelUnit(bool on) {
133 }
134 bool getPixelUnit() const {
135 return getMode(RGraphicsSceneDrawable::PixelUnit);
136 }
137
138 void setWorkingSet(bool on) {
140 }
141 bool isWorkingSet() const {
143 }
144
146 Q_ASSERT(painterPath!=NULL);
147 return *painterPath;
148 }
149
151 Q_ASSERT(image!=NULL);
152 return *image;
153 }
154
156 Q_ASSERT(text!=NULL);
157 return *text;
158 }
159
161 Q_ASSERT(transform!=NULL);
162 return *transform;
163 }
164
166 return offset;
167 }
168
169 void setOffset(const RVector& o) {
170 offset = o;
171 }
172
173 RDocument* getDocument() const;
174
175 void setSelected(bool on);
176 void setHighlighted(bool on);
177
178 RGraphicsSceneDrawable& operator=(const RGraphicsSceneDrawable& other);
179
180protected:
183 Modes modes;
184
185 //union {
190 //};
191};
192
193QCADGUI_EXPORT QDebug operator<<(QDebug dbg, const RGraphicsSceneDrawable& d);
194
200
201#endif
QCADGUI_EXPORT QDebug operator<<(QDebug dbg, const RGraphicsSceneDrawable &d)
Definition RGraphicsSceneDrawable.cpp:174
Q_DECLARE_METATYPE(RMath *)
@ Image
Definition RSMetaType.h:34
A graphics document contains and owns entities, layers, user coordinate systems, variables,...
Definition RDocument.h:78
Definition RGraphicsSceneDrawable.h:37
bool isPainterPath()
Definition RGraphicsSceneDrawable.h:101
RVector offset
Definition RGraphicsSceneDrawable.h:182
bool isText()
Definition RGraphicsSceneDrawable.h:105
RImageData * image
Definition RGraphicsSceneDrawable.h:187
RImageData & getImage() const
Definition RGraphicsSceneDrawable.h:150
void setPixelUnit(bool on)
Definition RGraphicsSceneDrawable.h:131
RTextBasedData & getText() const
Definition RGraphicsSceneDrawable.h:155
RTextBasedData * text
Definition RGraphicsSceneDrawable.h:188
RPainterPath * painterPath
Definition RGraphicsSceneDrawable.h:186
RTransform & getTransform() const
Definition RGraphicsSceneDrawable.h:160
Type
Definition RGraphicsSceneDrawable.h:39
@ Text
Definition RGraphicsSceneDrawable.h:45
@ PainterPathRay
Definition RGraphicsSceneDrawable.h:42
@ PainterPathXLine
Definition RGraphicsSceneDrawable.h:43
@ Invalid
Definition RGraphicsSceneDrawable.h:40
@ Transform
Definition RGraphicsSceneDrawable.h:46
@ PainterPath
Definition RGraphicsSceneDrawable.h:41
@ Image
Definition RGraphicsSceneDrawable.h:44
RTransform * transform
Definition RGraphicsSceneDrawable.h:189
RPainterPath & getPainterPath() const
Definition RGraphicsSceneDrawable.h:145
bool isWorkingSet() const
Definition RGraphicsSceneDrawable.h:141
bool getMode(RGraphicsSceneDrawable::Mode mode) const
Definition RGraphicsSceneDrawable.h:120
void setOffset(const RVector &o)
Definition RGraphicsSceneDrawable.h:169
RVector getOffset() const
Definition RGraphicsSceneDrawable.h:165
void setNoPlot(bool on)
Definition RGraphicsSceneDrawable.h:124
bool getNoPlot() const
Definition RGraphicsSceneDrawable.h:127
void setMode(RGraphicsSceneDrawable::Mode mode, bool on=true)
Definition RGraphicsSceneDrawable.h:113
Type type
Definition RGraphicsSceneDrawable.h:181
RGraphicsSceneDrawable()
Definition RGraphicsSceneDrawable.h:59
bool isImage()
Definition RGraphicsSceneDrawable.h:109
bool getPixelUnit() const
Definition RGraphicsSceneDrawable.h:134
void setWorkingSet(bool on)
Definition RGraphicsSceneDrawable.h:138
Modes modes
Definition RGraphicsSceneDrawable.h:183
RGraphicsSceneDrawable::Type getType() const
Definition RGraphicsSceneDrawable.h:97
Mode
Definition RGraphicsSceneDrawable.h:50
@ NoPlot
not plotted (from not plottable layers)
Definition RGraphicsSceneDrawable.h:52
@ WorkingSet
in current working set
Definition RGraphicsSceneDrawable.h:54
@ PixelUnit
unit interpreted as pixels
Definition RGraphicsSceneDrawable.h:53
Stores and manages all data that defines the geometry and appearance of a raster image entity.
Definition RImageData.h:41
Extended painter path with a z-level and a pen.
Definition RPainterPath.h:48
Stores and manages all data that defines the geometry and appearance of a text based entity (text,...
Definition RTextBasedData.h:68
Copyright (c) 2011-2020 by Andrew Mustun.
Definition RTransform.h:37
Represents a 3d vector (x/y/z).
Definition RVector.h:47
static const RVector nullVector
null vector
Definition RVector.h:340
Insert text.
Definition Text.js:19
void getDocument()
Returns the current RDocument or undefined.
Definition simple.js:63
#define QCADGUI_EXPORT
Definition gui_global.h:10
#define NULL
Definition opennurbs_system.h:256