OpendTect-6_4  6.4
uigraphicsitem.h
Go to the documentation of this file.
1 #ifndef uigraphicsitem_h
2 #define uigraphicsitem_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: Nanne Hemstra
9  Date: January 2007
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "uibasemod.h"
16 #include "callback.h"
17 #include "keyenum.h"
18 #include "uigeom.h"
19 #include "manobjectset.h"
20 #include "uistring.h"
21 
22 class FillPattern;
23 class MouseCursor;
24 class MouseEvent;
25 class uiGraphicsScene;
26 namespace OD { class LineStyle; }
27 
28 mFDQtclass(QGraphicsItem)
29 mFDQtclass(QGraphicsItemGroup)
30 
31 mExpClass(uiBase) uiGraphicsItem : public CallBacker
32 {
33 public:
34  uiGraphicsItem();
35  ~uiGraphicsItem();
36 
37  mQtclass(QGraphicsItem*) qGraphicsItem() { return qgraphicsitem_; }
38  const mQtclass(QGraphicsItem*) qGraphicsItem()
39  const { return qgraphicsitem_; }
40 
41  void show();
42  void hide();
43 
44  virtual void setAcceptHoverEvents(bool);
45  virtual void setAcceptedMouseButtons(OD::ButtonState);
46  virtual void setFiltersChildEvents(bool);
47  virtual void setMovable(bool);
48  virtual void setSelectable(bool);
49  virtual void setSelected(bool);
50  virtual void setVisible(bool);
51 
52  virtual OD::ButtonState acceptedMouseButtonsEnabled() const;
53  virtual bool isFiltersChildEventsEnabled() const;
54  virtual bool isHoverEventsAccepted() const;
55  virtual bool isMovable() const;
56  virtual bool isSelectable() const;
57  virtual bool isSelected() const { return selected_; }
58  virtual bool isVisible() const;
59 
60  Geom::Point2D<float> getPos() const;
61  void setPos( const uiWorldPoint&);
62  void setPos( const uiPoint& p );
63  void setPos( const Geom::Point2D<float>& );
64  void setPos( float x, float y );
65  void moveBy(float x,float y);
66  float getRotation();
67  void getScale(float& sx,float& sy);
68  void setRotation(float angle);
69  void setScale(float sx,float sy);
70  void setZValue(int); //<! z value decides the stacking order
71 
72 
73  uiGraphicsItem* getChild(int);
74  bool isPresent(const uiGraphicsItem&) const;
75  int nrChildren() const;
76  void removeChild(uiGraphicsItem*,bool withdelete);
77  void removeAll(bool withdelete);
78  void addChild(uiGraphicsItem*);
79 
80  uiPoint transformToScenePos(const uiPoint& itmpos) const;
81  void setItemIgnoresTransformations(bool);
82  bool isItemIgnoresTransformationsEnabled() const;
83  virtual uiRect boundingRect() const;
84 
85  virtual void setPenStyle(const OD::LineStyle&,bool usetransp=false);
86  virtual void setPenColor(const Color&,bool usetransp=false);
87  virtual void setFillColor(const Color&,bool usetransp=false);
88  virtual void setFillPattern(const FillPattern&);
89  virtual void setTransparency(float);
96  void setCursor(const MouseCursor&);
97  void setToolTip(const uiString&);
98 
99  virtual void setScene(uiGraphicsScene*);
100  virtual uiGraphicsItem* findItem(QGraphicsItem*);
101 
102  int id() const { return id_; }
103  int getZValue() const;
104 
105  //Old, will be remove once all dep code is changed
106  void rotate(float angle) { setRotation(angle); }
107  void scale(float sx,float sy) { setScale( sx, sy ); }
108 
109  virtual void translateText();
110 
113 protected:
114 
115  uiGraphicsItem(QGraphicsItem*);
116 
117  mQtclass(QGraphicsItem*) qgraphicsitem_;
118 
119  virtual mQtclass(QGraphicsItem*) mkQtObj() { return 0; }
120  bool selected_; // Remove when things in Qt works
121  mQtclass(uiGraphicsScene*) scene_;
122  ObjectSet<uiGraphicsItem> children_;
123  uiGraphicsItem* parent_;
124 
125  virtual void stPos(float,float);
126 
127 private:
128 
129  void updateTransform();
130 
131  static int getNewID();
132  const int id_;
133 
134  uiString tooltip_;
135 
136  uiWorldPoint translation_;
137  uiWorldPoint scale_;
138  double angle_;
139 };
140 
141 
142 mExpClass(uiBase) uiGraphicsItemSet : public ManagedObjectSet<uiGraphicsItem>
143 {
144 public:
146 
147  void add( uiGraphicsItem* itm ) { (*this) += itm; }
148  uiGraphicsItem* get( int idx ) { return (*this)[idx]; }
149  const uiGraphicsItem* get( int idx ) const { return (*this)[idx]; }
150 
151  void setZValue(int); //<! z value decides the stacking order
152  void setVisible(bool yn);
153 };
154 
155 
156 
157 mExpClass(uiBase) uiGraphicsItemGroup : public uiGraphicsItem
158 {
159 public:
160  uiGraphicsItemGroup(bool owner=false);
164 
165  void setScene(uiGraphicsScene*);
166 
167  void setIsOwner( bool own ) { owner_ = own; }
168  bool isOwner() const { return owner_; }
169 
170  void add(uiGraphicsItem*);
171  void remove(uiGraphicsItem*,bool withdelete);
172  void removeAll(bool withdelete);
173  bool isEmpty() const { return items_.isEmpty(); }
174  int size() const { return items_.size(); }
175  uiGraphicsItem* getUiItem( int idx ) { return gtItm(idx); }
176  const uiGraphicsItem* getUiItem( int idx ) const { return gtItm(idx); }
177  bool isPresent(const uiGraphicsItem&) const;
178  virtual uiGraphicsItem* findItem(QGraphicsItem*);
179 
180  virtual bool isVisible() const;
181  virtual void setVisible(bool);
182  virtual uiRect boundingRect() const;
183  mQtclass(QGraphicsItemGroup*) qGraphicsItemGroup()
184  { return qgraphicsitemgrp_; }
185 
186 protected:
187 
188  void translateText();
189 
190  mQtclass(QGraphicsItem*) mkQtObj();
191 
192  bool owner_;
194  mQtclass(QGraphicsItemGroup*) qgraphicsitemgrp_;
195  ObjectSet<uiGraphicsItem> items_;
196  ObjectSet<uiGraphicsItem> items2bdel_;
197 
198  uiGraphicsItem* gtItm( int idx ) const
199  { return !items_.validIdx(idx) ? 0
200  : const_cast<uiGraphicsItemGroup*>(this)->items_[idx]; }
201 };
202 
203 
204 #endif
#define mExpClass(module)
Definition: commondefs.h:160
To be able to send and/or receive CallBacks, inherit from this class.
Definition: callback.h:272
Definition: uigeom.h:42
uiGraphicsItemSet()
Definition: uigraphicsitem.h:145
Definition: draw.h:146
Definition of a mouse cursor, can be either a predefined shape (from the enum, or a file...
Definition: mousecursor.h:26
#define mQtclass(cls)
Definition: commondefs.h:229
Definition: draw.h:118
const uiGraphicsItem * getUiItem(int idx) const
Definition: uigraphicsitem.h:176
#define private
Definition: winstreambuf.h:13
bool isOwner() const
Definition: uigraphicsitem.h:168
void hide(const char *, bool yn)
only Windows
int size() const
Definition: uigraphicsitem.h:174
Definition: uistring.h:89
FixedString LineStyle()
Definition: keystrs.h:80
Set of pointers to objects.
Definition: commontypes.h:32
bool owner_
Definition: uigraphicsitem.h:192
ButtonState
Definition: keyenum.h:20
void removeAll()
Definition: uigraphicsitem.h:157
bool isEmpty() const
Definition: uigraphicsitem.h:173
#define mFDQtclass(cls)
Definition: commondefs.h:228
mQtclass(QGraphicsItemGroup *) qGraphicsItemGroup()
Definition: uigraphicsitem.h:183
Definition: uigraphicsitem.h:142
bool isvisible_
Definition: uigraphicsitem.h:193
void setIsOwner(bool own)
Definition: uigraphicsitem.h:167
virtual bool validIdx(int64_t) const
Definition: objectset.h:302
OpendTect.
Definition: commontypes.h:29
Notifier with automatic capsule creation.
Definition: callback.h:395
Color is an RGB color object, with a transparancy. The storage is in a 4-byte integer, similar to Qt.
Definition: color.h:26
void add(uiGraphicsItem *itm)
Definition: uigraphicsitem.h:147
ObjectSet where the objects contained are owned by this set.
Definition: manobjectset.h:23
Definition: mouseevent.h:73
uiGraphicsItem * getUiItem(int idx)
Definition: uigraphicsitem.h:175
Definition: uigraphicsscene.h:39

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