OpendTect-6_4  6.4
odgraphicsitem.h
Go to the documentation of this file.
1 #ifndef odgraphicsitem_h
2 #define odgraphicsitem_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Nanne Hemstra
9  Date: April 2008
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include <QGraphicsItem>
16 #include <QPolygonF>
17 #include <QString>
18 #include <QTextOption>
19 #include <QMutex>
20 #include <QWaitCondition>
21 #include <QFont>
22 
23 #include "draw.h"
24 
25 class uiPixmap;
26 
27 static int ODGraphicsType = 100000;
28 
30 {
31 public:
32  virtual void highlight() {}
33  virtual void unHighlight() {}
34 
35  virtual void setQPen(const QPen&) {}
36 };
37 
38 
39 class ODGraphicsPointItem : public QAbstractGraphicsShapeItem
40 {
41 public:
43 
44  QRectF boundingRect() const;
45  void paint(QPainter*,const QStyleOptionGraphicsItem*,
46  QWidget*);
47 
48  void drawPoint(QPainter*);
49  void setHighLight( bool hl )
50  { highlight_ = hl ; }
51  void setColor( const Color& col )
52  { pencolor_ = col ; }
53 
54  virtual int type() const { return ODGraphicsType+1; }
55 
56 protected:
57  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
58  bool highlight_;
59  int penwidth_;
61 };
62 
63 
64 
65 class ODGraphicsMarkerItem : public QAbstractGraphicsShapeItem
66 {
67 public:
69  virtual ~ODGraphicsMarkerItem();
70 
71  QRectF boundingRect() const;
72  void paint(QPainter*,const QStyleOptionGraphicsItem*,
73  QWidget*);
74  static void drawMarker(QPainter&,MarkerStyle2D::Type,
75  float,float);
76 
77  void setMarkerStyle(const MarkerStyle2D&);
78  void setFill( bool fill ) { fill_ = fill; }
79  void setFillColor( const Color& col )
80  { fillcolor_ = col; }
81  void setSideLength( int side ) { side_ = side; }
82 
83  virtual int type() const { return ODGraphicsType+2; }
84  const MarkerStyle2D* getMarkerStyle() { return mstyle_; }
85 
86 protected:
87  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
88  QRectF boundingrect_;
91  bool fill_;
92  int side_;
93 };
94 
95 
96 class ODGraphicsPixmapItem : public QGraphicsPixmapItem
97 {
98 public:
101 
102  void paint(QPainter*,const QStyleOptionGraphicsItem*,
103  QWidget*);
104 
105  virtual int type() const { return ODGraphicsType+3; }
106  void setPaintInCenter(bool);
107 
108 protected:
109  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
110  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent*);
111  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent*);
112 
114 
115 };
116 
117 
118 class ODGraphicsArrowItem : public QAbstractGraphicsShapeItem
119 {
120 public:
122 
123  QRectF boundingRect() const;
124  void paint(QPainter*,const QStyleOptionGraphicsItem*,
125  QWidget*);
126 
127  void drawArrow(QPainter&);
128  double getAddedAngle(double,float);
129  QPoint getEndPoint(const QPoint&,double,double);
130  void drawArrowHead(QPainter&,const QPoint&,
131  const QPoint&);
132  void setArrowStyle( const ArrowStyle& arrowstyle )
133  { arrowstyle_ = arrowstyle ; }
134  void setArrowSize( const int arrowsz )
135  { arrowsz_ = arrowsz ; }
136  void setLineStyle(QPainter&,const OD::LineStyle&);
137 
138  virtual int type() const { return ODGraphicsType+4; }
139 
140 protected:
141  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
142 
144  int arrowsz_;
145 };
146 
147 
148 class ODGraphicsTextItem : public QAbstractGraphicsShapeItem
149 {
150 public:
152 
153  QRectF boundingRect() const;
154  void paint(QPainter*,const QStyleOptionGraphicsItem*,
155  QWidget*);
156 
157  void setText(const QString&);
158  void setFont(const QFont&);
159  QFont getFont() const;
160 
161  void setVAlignment(const Qt::Alignment&);
162  void setHAlignment(const Qt::Alignment&);
163 
164  virtual int type() const { return ODGraphicsType+5; }
165 
166 protected:
167  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
168  QPointF getAlignment() const;
169 
170  QFont font_;
171  QString text_;
172  Qt::Alignment hal_;
173  Qt::Alignment val_;
174 };
175 
176 
177 class ODGraphicsAdvancedTextItem : public QGraphicsTextItem
178 {
179 public:
181 
182 protected:
183  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
184 };
185 
186 
187 class ODGraphicsPathItem : public QGraphicsPathItem
188  , public ODGraphicsHighlightItem
189 {
190 public:
193 
194  void set(const QPainterPath&);
195  QPainterPath shape() const;
196 
197  void setQPen(const QPen& pen);
198  void highlight();
199  void unHighlight();
200 
201 protected:
202  QPainterPath path_;
203  QPen& mypen_;
204 };
205 
206 
207 class ODGraphicsPolyLineItem : public QAbstractGraphicsShapeItem
208  , public ODGraphicsHighlightItem
209 {
210 public:
213 
214  QRectF boundingRect() const;
215  void paint(QPainter*,const QStyleOptionGraphicsItem*,
216  QWidget*);
217  QPainterPath shape() const;
218 
219  void setPolyLine(const QPolygonF&,bool closed);
220  void setFillRule(Qt::FillRule);
221  bool isEmpty() const;
222  void setEmpty();
223 
224  void setQPen(const QPen& pen);
225  void highlight();
226  void unHighlight();
227 
228  virtual int type() const { return ODGraphicsType+6; }
229 
230 protected:
231  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
232 
233  bool closed_;
234  QPolygonF qpolygon_;
235  Qt::FillRule fillrule_;
236  QPainterPath path_;
237  QPen& mypen_;
238 };
239 
240 
241 class ODGraphicsMultiColorPolyLineItem : public QAbstractGraphicsShapeItem
242  , public ODGraphicsHighlightItem
243 {
244 public:
247 
248  QRectF boundingRect() const;
249  void paint(QPainter*,
250  const QStyleOptionGraphicsItem*,
251  QWidget*);
252  QPainterPath shape() const;
253 
254  void setPolyLine(const QPolygonF&);
255  void setQPens(const QVector<QPen>&);
256  void setPenWidth(int);
257 
258  void highlight() { highlight_ = true; }
259  void unHighlight() { highlight_ = false; }
260 
261  virtual int type() const { return ODGraphicsType+8; }
262 
263 protected:
264 
266  {
267  public:
268  QPolygonF qpolygon_;
269  QVector<QPen> qpens_;
270 
271  bool isEmpty() const;
272  void add(const QPointF&,
273  const QPen&);
274  void setWidth(int);
275  };
276 
277  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
278  void cleanupPolygon();
279 
281  QPolygonF inputqpolygon_;
282  QVector<QPen> inputqpens_;
283  QVector<ODLineSegment> odlinesegments_;
284  QRectF brect_;
285  QPainterPath path_;
286 };
287 
288 
289 class ODGraphicsItemGroup : public QGraphicsItemGroup
290 {
291 public:
293 
294  QRectF boundingRect() const;
295  void paint(QPainter*,const QStyleOptionGraphicsItem*,
296  QWidget*);
297 protected:
298  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
299 
300 };
301 
302 
303 class ODGraphicsDynamicImageItem : public QGraphicsItem, public CallBacker
304 {
305 public:
307 
308  QRectF boundingRect() const { return bbox_; }
309  void paint(QPainter*,const QStyleOptionGraphicsItem*,
310  QWidget*);
311 
312  void setImage(bool isdynamic,const QImage&,
313  const QRectF&);
314  bool updateResolution(const QPainter*);
315  const QRectF& wantedWorldRect() const;
316  const QSize& wantedScreenSize() const;
317 
318  virtual int type() const { return ODGraphicsType+7; }
319 
321  bool isSnapshot() const;
327 protected:
328  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent*);
329 
330  QRectF wantedwr_;
332 
333  QMutex imagelock_;
334  QWaitCondition imagecond_;
338  bool dynamicrev_[2];
340  QImage baseimage_;
341  QRectF bbox_;
342  bool baserev_[2];
344 
345  PtrMan<QPixmap> basepixmap_; //Only access in paint
346  PtrMan<QPixmap> dynamicpixmap_; //Only access in paint
347  QRectF dynamicpixmapbbox_; //Only access in paint
348 
349 };
350 
351 #endif
PtrMan< QPixmap > dynamicpixmap_
Definition: odgraphicsitem.h:346
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
virtual int type() const
Definition: odgraphicsitem.h:318
QPainterPath path_
Definition: odgraphicsitem.h:285
Color pencolor_
Definition: odgraphicsitem.h:60
int side_
Definition: odgraphicsitem.h:92
void setArrowStyle(const ArrowStyle &arrowstyle)
Definition: odgraphicsitem.h:132
Definition: odgraphicsitem.h:39
const MarkerStyle2D * getMarkerStyle()
Definition: odgraphicsitem.h:84
Definition: odgraphicsitem.h:118
QFont font_
Definition: odgraphicsitem.h:170
Definition: odgraphicsitem.h:241
void setFillColor(const Color &col)
Definition: odgraphicsitem.h:79
void setFill(bool fill)
Definition: odgraphicsitem.h:78
PtrMan< QPixmap > basepixmap_
Definition: odgraphicsitem.h:345
Definition: odgraphicsitem.h:96
QVector< QPen > qpens_
Definition: odgraphicsitem.h:269
Definition: draw.h:60
Definition: draw.h:118
bool paintincenter_
Definition: odgraphicsitem.h:113
QPen & mypen_
Definition: odgraphicsitem.h:237
Qt::Alignment val_
Definition: odgraphicsitem.h:173
Color fillcolor_
Definition: odgraphicsitem.h:90
QImage dynamicimage_
Definition: odgraphicsitem.h:336
QPolygonF inputqpolygon_
Definition: odgraphicsitem.h:281
void highlight()
Definition: odgraphicsitem.h:258
QRectF wantedwr_
Definition: odgraphicsitem.h:330
Notifier< ODGraphicsDynamicImageItem > wantsData
Definition: odgraphicsitem.h:320
void setSideLength(int side)
Definition: odgraphicsitem.h:81
QWaitCondition imagecond_
Definition: odgraphicsitem.h:334
Definition: odgraphicsitem.h:65
int penwidth_
Definition: odgraphicsitem.h:59
Definition: odgraphicsitem.h:177
QRectF boundingRect() const
Definition: odgraphicsitem.h:308
virtual void unHighlight()
Definition: odgraphicsitem.h:33
Definition: odgraphicsitem.h:265
QVector< QPen > inputqpens_
Definition: odgraphicsitem.h:282
void unHighlight()
Definition: odgraphicsitem.h:259
QPolygonF qpolygon_
Definition: odgraphicsitem.h:234
QRectF boundingrect_
Definition: odgraphicsitem.h:88
Definition: odgraphicsitem.h:289
void setArrowSize(const int arrowsz)
Definition: odgraphicsitem.h:134
virtual int type() const
Definition: odgraphicsitem.h:105
QPen & mypen_
Definition: odgraphicsitem.h:203
Qt::Alignment hal_
Definition: odgraphicsitem.h:172
virtual int type() const
Definition: odgraphicsitem.h:54
void setColor(const Color &col)
Definition: odgraphicsitem.h:51
virtual int type() const
Definition: odgraphicsitem.h:83
Definition: odgraphicsitem.h:148
bool updatebasepixmap_
Definition: odgraphicsitem.h:339
QSize wantedscreensz_
Definition: odgraphicsitem.h:331
QPainterPath path_
Definition: odgraphicsitem.h:202
Off-screen pixel-based paint device.
Definition: uipixmap.h:34
QImage baseimage_
Definition: odgraphicsitem.h:340
QRectF dynamicimagebbox_
Definition: odgraphicsitem.h:337
QPolygonF qpolygon_
Definition: odgraphicsitem.h:268
Definition: odgraphicsitem.h:207
int arrowsz_
Definition: odgraphicsitem.h:144
bool fill_
Definition: odgraphicsitem.h:91
QString text_
Definition: odgraphicsitem.h:171
Type
Definition: draw.h:64
QRectF dynamicpixmapbbox_
Definition: odgraphicsitem.h:347
void setHighLight(bool hl)
Definition: odgraphicsitem.h:49
virtual void setFont(const QFont &)
override Qt
Definition: i_uiobjqtbody.h:32
Definition: odgraphicsitem.h:303
Definition: draw.h:184
virtual int type() const
Definition: odgraphicsitem.h:164
Definition: odgraphicsitem.h:187
Definition: odgraphicsitem.h:29
virtual void highlight()
Definition: odgraphicsitem.h:32
static int ODGraphicsType
Definition: odgraphicsitem.h:27
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
bool closed_
Definition: odgraphicsitem.h:233
bool updatedynpixmap_
Definition: odgraphicsitem.h:335
bool issnapshot_
Definition: odgraphicsitem.h:343
virtual int type() const
Definition: odgraphicsitem.h:261
bool highlight_
Definition: odgraphicsitem.h:280
QVector< ODLineSegment > odlinesegments_
Definition: odgraphicsitem.h:283
bool isEmpty(const NLAModel *mdl)
bool highlight_
Definition: odgraphicsitem.h:58
QRectF bbox_
Definition: odgraphicsitem.h:341
virtual void setQPen(const QPen &)
Definition: odgraphicsitem.h:35
QMutex imagelock_
Definition: odgraphicsitem.h:333
QPainterPath path_
Definition: odgraphicsitem.h:236
QRectF brect_
Definition: odgraphicsitem.h:284
Qt::FillRule fillrule_
Definition: odgraphicsitem.h:235
virtual int type() const
Definition: odgraphicsitem.h:228
ArrowStyle arrowstyle_
Definition: odgraphicsitem.h:143
MarkerStyle2D * mstyle_
Definition: odgraphicsitem.h:89
virtual int type() const
Definition: odgraphicsitem.h:138

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019