Version: 9.15.0
SceneItem.hxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2025 CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef _SCENEITEM_HXX_
21 #define _SCENEITEM_HXX_
22 
23 #include <QGraphicsItem>
24 #include <QGraphicsTextItem>
25 #include <QGraphicsScene>
26 #include <QString>
27 #include <QPainter>
28 #include <QEvent>
29 
30 #include "guiObservers.hxx"
31 
32 namespace YACS
33 {
34  namespace HMI
35  {
36  typedef enum
37  {
42 
43  class Scene;
44 
45  class RootSceneItem: public GuiObserver
46  {
47  public:
49  virtual ~RootSceneItem();
50  virtual void update(GuiEvent event, int type, Subject* son);
51  protected:
52  void setNewRoot(YACS::HMI::Subject *root);
55  };
56 
57  // ----------------------------------------------------------------------------
58 
59  class SceneItem;
65  {
66  public:
68  QString label);
69  virtual ~AbstractSceneItem();
70 
71  virtual QRectF boundingRect() const = 0;
72  virtual void paint(QPainter *painter,
73  const QStyleOptionGraphicsItem *option,
74  QWidget *widget) = 0;
75 
76  virtual void setTopLeft(QPointF topLeft) = 0;
77  int getLevel();
78  void setLevel();
79  virtual void checkGeometryChange() = 0;
80  virtual void reorganize();
81  virtual QString getLabel();
82  virtual void addHeader();
83  virtual void addProgressItem();
84  virtual qreal getHeaderBottom();
85  qreal getWidth();
86  qreal getHeight();
87  virtual void setWidth(qreal width);
88  virtual void setHeight(qreal height);
89  virtual void popupMenu(QWidget *caller, const QPoint &globalPos) = 0;
90  virtual void activateSelection(bool selected);
91  virtual void setGeometryOptimization(bool optimize);
92  inline SceneItem* getParent() { return _parent; };
93 
94  protected:
95  virtual QRectF childBoundingRect(AbstractSceneItem *child) const;
96 
99  QString _label;
100  int _level;
101  qreal _width;
102  qreal _height;
103  qreal _incHeight;
104  QColor _penColor;
105  QColor _brushColor;
106  QColor _hiPenColor;
109  bool _optimize;
110  bool _dragable;
111  enum Qt::MouseButton _dragButton;
112  };
113 
114  // ----------------------------------------------------------------------------
115 
121  {
122  public:
123  SceneItem(QGraphicsScene *scene, SceneItem *parent,
124  QString label);
125  virtual ~SceneItem();
126 
127  virtual QRectF boundingRect() const;
128  virtual QRectF childrenBoundingRect () const;
129  virtual void paint(QPainter *painter,
130  const QStyleOptionGraphicsItem *option,
131  QWidget *widget);
132  virtual void setTopLeft(QPointF topLeft);
133  virtual void checkGeometryChange();
134  virtual void popupMenu(QWidget *caller, const QPoint &globalPos);
135  void setParent(SceneItem* parent);
136  virtual QString getToolTip();
137  void setEventPos(QPointF point);
138  virtual void updateChildItems();
139  virtual void updateLinks();
140  virtual void shrinkExpandLink(bool se);
141  virtual void shrinkExpandRecursive(bool isExpanding, bool fromHere, ShrinkMode theShrinkMode);
143  bool _blocX;
144  bool _blocY;
145 
146  protected:
147 // virtual bool sceneEvent(QEvent *event);
148  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
149  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
150  virtual void hoverMoveEvent(QGraphicsSceneHoverEvent * event);
151  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
152  virtual QColor getPenColor();
153  virtual QColor getBrushColor();
154  QColor hoverColor(QColor origColor);
155  bool _hover;
157  QPointF _eventPos;
158  };
159 
160  }
161 }
162 
163 #endif
virtual void popupMenu(QWidget *caller, const QPoint &globalPos)=0
virtual void setTopLeft(QPointF topLeft)=0
virtual void setGeometryOptimization(bool optimize)
Definition: SceneItem.cxx:185
virtual QRectF boundingRect() const =0
virtual void addProgressItem()
Definition: SceneItem.cxx:144
virtual void activateSelection(bool selected)
Definition: SceneItem.cxx:180
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)=0
virtual void checkGeometryChange()=0
virtual QRectF childBoundingRect(AbstractSceneItem *child) const
Definition: SceneItem.cxx:173
virtual qreal getHeaderBottom()
Definition: SceneItem.cxx:148
AbstractSceneItem(QGraphicsScene *scene, SceneItem *parent, QString label)
Definition: SceneItem.cxx:88
virtual void setWidth(qreal width)
AbstractSceneItem cannot be resized (only ComposedNodeItem can)
Definition: SceneItem.cxx:164
virtual QString getLabel()
Definition: SceneItem.cxx:135
virtual void setHeight(qreal height)
AbstractSceneItem cannot be resized (only ComposedNodeItem can)
Definition: SceneItem.cxx:169
YACS::HMI::Scene * _scene
Definition: SceneItem.hxx:98
enum Qt::MouseButton _dragButton
Definition: SceneItem.hxx:111
virtual void update(GuiEvent event, int type, Subject *son)
Definition: SceneItem.cxx:58
RootSceneItem(YACS::HMI::Subject *context)
Definition: SceneItem.cxx:48
void setNewRoot(YACS::HMI::Subject *root)
Definition: SceneItem.cxx:75
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
virtual void popupMenu(QWidget *caller, const QPoint &globalPos)
virtual void setTopLeft(QPointF topLeft)
Definition: SceneItem.cxx:241
virtual void shrinkExpandRecursive(bool isExpanding, bool fromHere, ShrinkMode theShrinkMode)
QColor hoverColor(QColor origColor)
SceneItem(QGraphicsScene *scene, SceneItem *parent, QString label)
Definition: SceneItem.cxx:191
virtual QRectF childrenBoundingRect() const
Definition: SceneItem.cxx:224
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event)
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
virtual QColor getBrushColor()
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition: SceneItem.cxx:229
void setParent(SceneItem *parent)
Definition: SceneItem.cxx:207
virtual void shrinkExpandLink(bool se)
virtual QColor getPenColor()
virtual void updateChildItems()
virtual QString getToolTip()
Definition: SceneItem.cxx:336
virtual void updateLinks()
virtual QRectF boundingRect() const
Definition: SceneItem.cxx:215
void setEventPos(QPointF point)
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event)
virtual void checkGeometryChange()
Definition: SceneItem.cxx:248
@ ElementaryNodes
Definition: SceneItem.hxx:40
@ ChildrenNodes
Definition: SceneItem.hxx:39