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