OpendTect-6_4  6.4
uigraphicsitemimpl.h
Go to the documentation of this file.
1 #ifndef uigraphicsitemimpl_h
2 #define uigraphicsitemimpl_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 "uibasemod.h"
16 #include "uigraphicsitem.h"
17 #include "uigeom.h"
18 #include "draw.h"
19 
20 class uiPixmap;
21 class uiFont;
22 class uiGroup;
23 class uiObject;
24 class uiSize;
25 class uiRGBArray;
26 class FontData;
27 
28 class QGraphicsItem;
29 class QGraphicsEllipseItem;
30 class QGraphicsLineItem;
31 class QGraphicsPathItem;
32 class QGraphicsPixmapItem;
33 class QGraphicsProxyWidget;
34 class QGraphicsRectItem;
35 class QPainterPath;
36 class QPolygonF;
37 class QSize;
38 
42 class ODGraphicsPathItem;
48 class ODGraphicsTextItem;
49 template <class T> class ODPolygon;
50 
51 
52 mExpClass(uiBase) uiObjectItem : public uiGraphicsItem
53 {
54 public:
55  uiObjectItem(uiObject* obj);
56  uiObjectItem(uiGroup* obj);
57  ~uiObjectItem();
58 
59  uiObject* getObject();
60  void setObject(uiObject*);
61 
62  uiGroup* getGroup();
63  void setGroup(uiGroup*);
64 
65  virtual void setObjectSize(int,int);
66  const uiSize objectSize() const;
67 
68  QGraphicsProxyWidget* qWidgetItem() { return qwidgetitem_; }
69 
70 protected:
71 
72  QGraphicsItem* mkQtObj();
73  QGraphicsProxyWidget* qwidgetitem_;
76 };
77 
78 
79 mExpClass(uiBase) uiEllipseItem : public uiGraphicsItem
80 {
81 public:
82  uiEllipseItem();
83  uiEllipseItem(const uiSize&);
84  uiEllipseItem(const uiPoint& center,
85  const uiSize&);
86  ~uiEllipseItem();
87 
88  QGraphicsEllipseItem* qEllipseItem() { return qellipseitem_; }
89  void setSize(const uiSize&);
90 
91 protected:
92 
93  QGraphicsItem* mkQtObj();
94  QGraphicsEllipseItem* qellipseitem_;
95 };
96 
97 
99 {
100 public:
101  uiCircleItem();
102  uiCircleItem(int r);
103  uiCircleItem(const uiPoint& center,int r);
104 
105  void setRadius(int);
106 };
107 
108 
109 
110 mExpClass(uiBase) uiLineItem : public uiGraphicsItem
111 {
112 public:
113  uiLineItem();
114  uiLineItem(int x1,int y1,int x2,int y2);
115  uiLineItem(float x1,float y1,float x2,float y2);
116  uiLineItem(const uiPoint& start,const uiPoint& stop);
117  uiLineItem(const uiPoint&,float angle,float len);
118  ~uiLineItem();
119 
120  QGraphicsLineItem* qLineItem() { return qlineitem_; }
121  void setPenStyle(const OD::LineStyle&,bool withalpha=false);
122  void setPenColor(const Color&,bool withalpha=false);
123  void setLine(const uiPoint& start,const uiPoint& end);
124  void setLine(const uiWorldPoint&,const uiWorldPoint&);
125  void setLine(int x1,int y1,int x2,int y2);
126  void setLine(float x1,float y1,float x2,float y2);
127  void setLine(const Geom::Point2D<float>&,
128  const Geom::Point2D<float>&);
129  void setLine(const Geom::Point2D<float>& centerpos,
130  float dx1,float dy1,float dx2,float dy2);
131  void setLine(const Geom::Point2D<int>& centerpos,
132  int dx1,int dy1,int dx2,int dy2);
133  uiRect lineRect() const;
134 
135 protected:
136 
137  QGraphicsItem* mkQtObj();
138  QGraphicsLineItem* qlineitem_;
139 };
140 
141 
147 mExpClass(uiBase) uiDynamicImageItem : public uiGraphicsItem
148 {
149 public:
152 
153  void setImage(bool dynamic,const uiRGBArray&,
154  const uiWorldRect&);
157  NotifierAccess& wantsData();
158  bool isSnapshot() const;
163  uiWorldRect wantedWorldRect() const;
164  uiSize wantedScreenSize() const;
165 
166 protected:
167  QGraphicsItem* mkQtObj();
169 };
170 
171 
172 mExpClass(uiBase) uiPixmapItem : public uiGraphicsItem
173 {
174 public:
175  uiPixmapItem();
176  uiPixmapItem(const uiPixmap&);
177  uiPixmapItem(const uiPoint&,const uiPixmap&);
178  ~uiPixmapItem();
179 
180  ODGraphicsPixmapItem* qPixmapItem() { return qpixmapitem_; }
181  void setOffset(int left,int top);
182  void setPixmap(const uiPixmap&);
183  void setPaintInCenter(bool);
184 
185 protected:
186 
187  QGraphicsItem* mkQtObj();
189 };
190 
191 
192 mExpClass(uiBase) uiPolygonItem : public uiGraphicsItem
193 {
194 public:
195  uiPolygonItem();
196  uiPolygonItem(const TypeSet<uiPoint>&,bool fill);
198  bool fill);
199  uiPolygonItem(const ODPolygon<int>&,bool fill);
200  ~uiPolygonItem();
201 
202  void fill();
203  void setPolygon(const TypeSet<uiPoint>&);
204  void setPolygon(const TypeSet<uiWorldPoint>&);
205  void setPolygon(const ODPolygon<int>&);
206 
207 protected:
208 
209  QGraphicsItem* mkQtObj();
211 };
212 
213 
214 mExpClass(uiBase) uiPolyLineItem : public uiGraphicsItem
215 {
216 public:
217  uiPolyLineItem();
220  ~uiPolyLineItem();
221 
222  void setPolyLine(const TypeSet<uiPoint>&);
223  void setPolyLine(const TypeSet<uiWorldPoint>&);
224 
225 protected:
226 
227  QGraphicsItem* mkQtObj();
229 };
230 
231 
232 mExpClass(uiBase) uiMultiColorPolyLineItem : public uiGraphicsItem
233 {
234 public:
239 
240  void setPolyLine(const TypeSet<uiPoint>&);
241  void setPolyLine(const TypeSet<uiWorldPoint>&);
242  void setColors(const TypeSet<Color>&,bool usetransp=false);
243 
244  void setPenWidth(int);
245  int getPenWidth() const;
246 
247 protected:
248 
249  QGraphicsItem* mkQtObj();
252 };
253 
254 
255 mExpClass(uiBase) uiRectItem : public uiGraphicsItem
256 {
257 public:
258  uiRectItem();
259  uiRectItem(int x,int y,int width,int height);
260  uiRectItem(QGraphicsRectItem*);
261  ~uiRectItem();
262 
263  QGraphicsRectItem* qRectItem() { return qrectitem_; }
264  void setRect(int x,int y,int width,int height);
265 
266 protected:
267 
268  QGraphicsItem* mkQtObj();
269  QGraphicsRectItem* qrectitem_;
270 };
271 
272 
273 mExpClass(uiBase) uiTextItem : public uiGraphicsItem
274 {
275 public:
276  uiTextItem();
277  uiTextItem(const uiString&,
278  const Alignment& al=Alignment());
279  uiTextItem(const uiPoint&,const uiString&,
280  const Alignment& al=Alignment());
281  ~uiTextItem();
282 
283  void setFont(const uiFont&);
284  void setFontData(const FontData&);
285  const uiString getText() const;
286  uiSize getTextSize() const;
287  void setAlignment(const Alignment&);
288  void setText(const uiString&);
289  void setTextColor(const Color&);
290 
291 protected:
292  uiTextItem(QGraphicsItem*);
293  void translateText();
294 
295  ODGraphicsTextItem* mkODObj();
298 
299  virtual void stPos(float,float);
300 };
301 
302 
303 mExpClass(uiBase) uiAdvancedTextItem : public uiGraphicsItem
304 {
305 public:
306  uiAdvancedTextItem(bool centered=false);
308  const Alignment& =
309  Alignment(Alignment::Left,Alignment::Top),
310  bool centered=false);
312 
313  Alignment getAlignment() const;
314  Color getDefaultTextColor() const;
315  uiFont& getFont() const;
316  uiString getPlainText() const;
317  float getTextWidth() const;
318 
319  void setAlignment(const Alignment&);
320  void setDefaultTextColor(const Color&);
321  void setFont(const FontData&);
322  void setPlainText(const uiString&);
323  void setTextWidth(float);
324 
325  void setTextIteraction(bool);
326 
327 protected:
330  QGraphicsItem* mkQtObj();
332 
333  virtual void stPos(float,float);
334 };
335 
336 
337 mExpClass(uiBase) uiMarkerItem : public uiGraphicsItem
338 {
339 public:
340  uiMarkerItem(bool fill=true);
342  bool fill=true);
343  uiMarkerItem(const uiPoint&,
344  const MarkerStyle2D&,
345  bool fill=true);
346  ~uiMarkerItem();
347 
348  ODGraphicsMarkerItem* qMarkerItem() { return qmarkeritem_; }
349  void setMarkerStyle(const MarkerStyle2D&);
350  void setFill(bool);
351  void setFillColor(const Color&,bool withalpha=false);
352  const MarkerStyle2D* getMarkerStyle();
353 
354 protected:
355 
356  QGraphicsItem* mkQtObj();
358 };
359 
360 
361 mExpClass(uiBase) uiPointItem : public uiGraphicsItem
362 {
363 public:
364  uiPointItem();
365  uiPointItem(const uiPoint&);
366  ~uiPointItem();
367 
368  ODGraphicsPointItem* qPointItem() { return qpointitem_; }
369 
370 protected:
371 
372  QGraphicsItem* mkQtObj();
374 };
375 
376 
377 mExpClass(uiBase) uiArrowItem : public uiGraphicsItem
378 {
379 public:
380  uiArrowItem();
381  uiArrowItem(const uiPoint& tail,
382  const uiPoint& head,
383  const ArrowStyle&);
385  ~uiArrowItem();
386 
387  void setHeadPos(const uiPoint&);
388  void setTailPos(const uiPoint&);
389  void setTailHeadPos(const uiPoint& tail,
390  const uiPoint& head);
391  void setArrowStyle(const ArrowStyle&);
392  void setArrowSize(int);
393 
394  ODGraphicsArrowItem* qArrowItem() { return qarrowitem_; }
395 
396 protected:
397 
398  QGraphicsItem* mkQtObj();
400 
403 
404  void update();
405 };
406 
407 
408 mExpClass(uiBase) uiCurvedItem : public uiGraphicsItem
409 {
410 public:
411  uiCurvedItem(const uiPoint& startpt);
412  uiCurvedItem(const Geom::Point2D<float>& startpt);
413  ~uiCurvedItem();
414 
416  {
417  public:
418  ArcSpec( const uiPoint& c, float r,
419  const Interval<float>& angs )
420  : center_((float)c.x,(float)c.y), radius_(r)
421  , angles_(angs), yratio_(1.0f) {}
422  ArcSpec( const Geom::Point2D<float>& c, float r,
423  const Interval<float>& angs )
424  : center_(c), radius_(r)
425  , angles_(angs), yratio_(1.0f) {}
426 
428  float radius_;
430  float yratio_;
431  };
432 
434  {
435  public:
436  SplineSpec( const uiPoint& endp, const uiPoint& cp )
437  : end_((float)endp.x,(float)endp.y)
438  , cp1_((float)cp.x,(float)cp.y)
439  , cubic_(false) {}
441  const Geom::Point2D<float>& cp )
442  : end_(endp), cp1_(cp), cubic_(false) {}
443  SplineSpec( const uiPoint& endp, const uiPoint& p1,
444  const uiPoint& p2 )
445  : end_((float)endp.x,(float)endp.y)
446  , cp1_((float)p1.x,(float)p1.y)
447  , cp2_((float)p2.x,(float)p2.y), cubic_(true) {}
449  const Geom::Point2D<float>& p1,
450  const Geom::Point2D<float>& p2 )
451  : end_(endp), cp1_(p1), cp2_(p2), cubic_(true) {}
452 
456  bool cubic_;
457  };
458 
459  void drawTo(const ArcSpec&);
460  void drawTo(const SplineSpec&);
461  void drawTo(const Geom::Point2D<float>&);
462  void drawTo(const uiPoint&);
463 
464  void closeCurve();
465 
466  QGraphicsPathItem* qGraphicsPathItem() { return qpathitem_; }
467  QPainterPath* qPainterPath() { return qppath_; }
468 
469 protected:
470 
471  QGraphicsItem* mkQtObj();
472  QGraphicsPathItem* qpathitem_;
473  QPainterPath* qppath_;
474 
475 };
476 
477 
478 #endif
Definition: uigroup.h:54
uiPoint headpos_
Definition: uigraphicsitemimpl.h:402
#define mExpClass(module)
Definition: commondefs.h:160
ArcSpec(const uiPoint &c, float r, const Interval< float > &angs)
Definition: uigraphicsitemimpl.h:418
ODGraphicsArrowItem * qArrowItem()
Definition: uigraphicsitemimpl.h:394
uiPoint tailpos_
Definition: uigraphicsitemimpl.h:401
Definition: odgraphicsitem.h:39
Definition: uigeom.h:42
uiObject * obj_
Definition: uigraphicsitemimpl.h:74
QGraphicsPathItem * qpathitem_
Definition: uigraphicsitemimpl.h:472
Definition: odgraphicsitem.h:118
Definition: draw.h:21
SplineSpec(const uiPoint &endp, const uiPoint &cp)
Definition: uigraphicsitemimpl.h:436
Definition: odgraphicsitem.h:241
QGraphicsPathItem * qGraphicsPathItem()
Definition: uigraphicsitemimpl.h:466
Definition: odgraphicsitem.h:96
QGraphicsRectItem * qRectItem()
Definition: uigraphicsitemimpl.h:263
Interface class for Notifier. See comments there.
Definition: callback.h:161
uiString text_
Definition: uigraphicsitemimpl.h:297
Definition: draw.h:60
Definition: uigraphicsitemimpl.h:377
Definition: draw.h:118
Definition: uigraphicsitemimpl.h:408
Definition: i_layout.h:28
QGraphicsRectItem * qrectitem_
Definition: uigraphicsitemimpl.h:269
Definition: uigraphicsitemimpl.h:192
(Closed) sequence of connected 2-D coordinates.
Definition: polygon.h:27
Definition: uifont.h:39
Interval< float > angles_
Definition: uigraphicsitemimpl.h:429
ODGraphicsTextItem * qtextitem_
Definition: uigraphicsitemimpl.h:296
bool textiscentered_
Definition: uigraphicsitemimpl.h:329
Definition: uigraphicsitemimpl.h:303
Definition: uigraphicsitemimpl.h:232
ODGraphicsPointItem * qPointItem()
Definition: uigraphicsitemimpl.h:368
ArcSpec(const Geom::Point2D< float > &c, float r, const Interval< float > &angs)
Definition: uigraphicsitemimpl.h:422
The base class for most UI elements.
Definition: uiobj.h:38
Definition: uistring.h:89
Definition: uigraphicsitemimpl.h:415
ODGraphicsMarkerItem * qmarkeritem_
Definition: uigraphicsitemimpl.h:357
Definition: uigraphicsitemimpl.h:337
Geom::Point2D< float > center_
Definition: uigraphicsitemimpl.h:427
ODGraphicsMultiColorPolyLineItem * odmulticoloritem_
Definition: uigraphicsitemimpl.h:250
QPainterPath * qppath_
Definition: uigraphicsitemimpl.h:473
float yratio_
< 1 means: X size > Y size
Definition: uigraphicsitemimpl.h:430
Data needed to make an actual font.
Definition: fontdata.h:20
Definition: odgraphicsitem.h:65
Alignment al_
Definition: uigraphicsitemimpl.h:328
Definition: uigraphicsitemimpl.h:361
Definition: odgraphicsitem.h:177
Definition: uigeom.h:25
void setLine(uiLineItem &, const LineParameters< float > &, const uiAxisHandler &xah, const uiAxisHandler &yah, const Interval< float > *xvalrg=0)
draws line not outside box defined by X and Y value ranges
ODGraphicsPixmapItem * qpixmapitem_
Definition: uigraphicsitemimpl.h:188
QGraphicsProxyWidget * qWidgetItem()
Definition: uigraphicsitemimpl.h:68
ODGraphicsDynamicImageItem * item_
Definition: uigraphicsitemimpl.h:168
ODGraphicsPolyLineItem * qpolygonitem_
Definition: uigraphicsitemimpl.h:210
bool cubic_
otherwise quadratic
Definition: uigraphicsitemimpl.h:456
QGraphicsLineItem * qlineitem_
Definition: uigraphicsitemimpl.h:138
SplineSpec(const Geom::Point2D< float > &endp, const Geom::Point2D< float > &cp)
Definition: uigraphicsitemimpl.h:440
Definition: uigraphicsitemimpl.h:52
Set of (small) copyable elements.
Definition: commontypes.h:30
QGraphicsLineItem * qLineItem()
Definition: uigraphicsitemimpl.h:120
Geom::Point2D< float > end_
Definition: uigraphicsitemimpl.h:453
Geom::Point2D< float > cp2_
only for cubic_
Definition: uigraphicsitemimpl.h:455
uiGroup * grp_
Definition: uigraphicsitemimpl.h:75
ODGraphicsPointItem * qpointitem_
Definition: uigraphicsitemimpl.h:373
SplineSpec(const Geom::Point2D< float > &endp, const Geom::Point2D< float > &p1, const Geom::Point2D< float > &p2)
Definition: uigraphicsitemimpl.h:448
int penwidth_
Definition: uigraphicsitemimpl.h:251
Definition: odgraphicsitem.h:148
Definition: uigraphicsitemimpl.h:255
Off-screen pixel-based paint device.
Definition: uipixmap.h:34
Definition: odgraphicsitem.h:207
Definition: uigraphicsitemimpl.h:433
QGraphicsEllipseItem * qEllipseItem()
Definition: uigraphicsitemimpl.h:88
Definition: uigraphicsitemimpl.h:98
Definition: draw.h:26
SplineSpec(const uiPoint &endp, const uiPoint &p1, const uiPoint &p2)
Definition: uigraphicsitemimpl.h:443
float radius_
X radius. Yrad = radius_ * yratio_.
Definition: uigraphicsitemimpl.h:428
ODGraphicsArrowItem * qarrowitem_
Definition: uigraphicsitemimpl.h:399
Definition: uigraphicsitemimpl.h:214
ODGraphicsPathItem * odgraphicspath_
Definition: uigraphicsitemimpl.h:228
ODGraphicsPixmapItem * qPixmapItem()
Definition: uigraphicsitemimpl.h:180
virtual void setFont(const QFont &)
override Qt
Definition: i_uiobjqtbody.h:32
Definition: odgraphicsitem.h:303
Definition: uigraphicsitemimpl.h:79
Definition: draw.h:184
Definition: odgraphicsitem.h:187
Definition: uigraphicsitemimpl.h:172
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
QPainterPath * qPainterPath()
Definition: uigraphicsitemimpl.h:467
Geom::Point2D< float > cp1_
Definition: uigraphicsitemimpl.h:454
Definition: uigraphicsitemimpl.h:273
QGraphicsProxyWidget * qwidgetitem_
Definition: uigraphicsitemimpl.h:73
QGraphicsEllipseItem * qellipseitem_
Definition: uigraphicsitemimpl.h:94
ODGraphicsMarkerItem * qMarkerItem()
Definition: uigraphicsitemimpl.h:348
Definition: uigraphicsitemimpl.h:110
ODGraphicsAdvancedTextItem * qtextitem_
Definition: uigraphicsitemimpl.h:331
Definition: uigraphicsitemimpl.h:147

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