Salome HOME
04db6a69ec02fae7ad6c397325a7d6467505c450
[modules/yacs.git] / src / genericgui / SceneNodeItem.hxx
1 // Copyright (C) 2006-2023  CEA/DEN, EDF R&D
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 _SCENENODEITEM_HXX_
21 #define _SCENENODEITEM_HXX_
22
23 #include "SceneObserverItem.hxx"
24
25 #include <QString>
26
27 namespace YACS
28 {
29   namespace HMI
30   {
31     typedef enum
32       {
33         expandShown,
34         shrinkShown,
35         shrinkHidden
36       } shownState;
37     
38     class SceneHeaderItem;
39     class SceneHeaderNodeItem;
40     class SceneComposedNodeItem;
41     class ScenePortItem;
42     class SceneProgressItem;
43
44     class SceneNodeItem: public SceneObserverItem
45     {
46     public:
47       SceneNodeItem(QGraphicsScene *scene, SceneItem *parent,
48                     QString label, Subject *subject);
49       virtual ~SceneNodeItem();
50
51       virtual void setWidth(qreal width);
52       virtual void setHeight(qreal height);
53       virtual void addHeader();
54       virtual SceneHeaderItem* getHeader();
55       virtual void addProgressItem();
56       virtual SceneProgressItem* getProgressItem() { return _progressItem; };
57       virtual void paint(QPainter *painter,
58                          const QStyleOptionGraphicsItem *option,
59                          QWidget *widget);
60       virtual void update(GuiEvent event, int type, Subject* son);
61       virtual qreal getHeaderBottom();
62       virtual void autoPosNewPort(AbstractSceneItem *item, int nbPorts);
63       virtual void popupMenu(QWidget *caller, const QPoint &globalPos);
64       virtual SceneComposedNodeItem* getParent();
65       virtual void removeInPortFromList(AbstractSceneItem* inPort);
66       virtual void removeOutPortFromList(AbstractSceneItem* outPort);
67       virtual void setMoving(bool moving);
68       virtual void setTopLeft(QPointF topLeft);
69       virtual void adjustHeader();
70       virtual ScenePortItem* getCtrlInPortItem();
71       virtual ScenePortItem* getCtrlOutPortItem();
72       virtual void updateName();
73       virtual void arrangeNodes(bool isRecursive);
74       virtual void arrangeChildNodes();
75       virtual void reorganizeShrinkExpand(ShrinkMode theShrinkMode);
76       virtual void updateChildItems();
77       virtual void shrinkExpandLink(bool se);
78       virtual void showOutScopeLinks();
79       virtual void updateLinks();
80       virtual void setShownState(shownState ss);
81       bool isExpanded() { return _expanded; };
82       void setExpanded(bool e){ _expanded = e; };
83       void setExpandedPos(QPointF epos) { _expandedPos = epos; };
84       qreal getExpandedX() { return _expandedPos.x(); };
85       qreal getExpandedY() { return _expandedPos.y(); };
86       void setExpandedWH() {_expandedWidth = _width; _expandedHeight = _height; };
87       void setExpandedWH(qreal w, qreal h) {_expandedWidth = w; _expandedHeight = h; };
88       qreal getExpandedWidth() { return _expandedWidth; };
89       qreal getExpandedHeight() { return _expandedHeight; };
90       shownState getShownState() {return _shownState; };
91       bool hasProgressBar() const;
92
93     protected:
94       virtual QString getMimeFormat();
95       virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
96       virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
97       virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
98       virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
99       virtual void updateState();
100       virtual void setExecState(int execState);
101
102       QString getHeaderLabel();
103
104       std::list<AbstractSceneItem*> _inPorts;
105       std::list<AbstractSceneItem*> _outPorts;    
106       SceneHeaderNodeItem *_header;
107       SceneProgressItem *_progressItem;
108       int _execState;
109       bool _moving;
110       bool _moved;
111       bool _expanded;
112       QPointF _prevPos;
113       QPointF _expandedPos;
114       qreal _expandedWidth;
115       qreal _expandedHeight;
116       shownState _shownState;
117     };
118   }
119 }
120
121 #endif