Version: 9.16.0
SceneHeaderItem.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 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#include "SceneHeaderItem.hxx"
22#include "SceneTextItem.hxx"
23#include "Scene.hxx"
24#include <QGraphicsSceneMouseEvent>
25
26#include "Resource.hxx"
27
28// #include "QtGuiContext.hxx"
29// #include "Menus.hxx"
30// #include <QGraphicsSceneHoverEvent>
31// #include <QPointF>
32
33#include <cassert>
34
35//#define _DEVDEBUG_
36#include "YacsTrace.hxx"
37
38using namespace std;
39using namespace YACS::ENGINE;
40using namespace YACS::HMI;
41
42
43SceneHeaderItem::SceneHeaderItem(QGraphicsScene *scene, SceneItem *parent,
44 QString label)
45 : SceneItem(scene, parent, label)
46{
50 _text=0;
55}
56
58{
59}
60
62{
63 return QRectF(x(), y(), 5, _height);
64}
65
66void SceneHeaderItem::paint(QPainter *painter,
67 const QStyleOptionGraphicsItem *option,
68 QWidget *widget)
69{
70// DEBTRACE("SceneHeaderItem::paint");
71}
72
73void SceneHeaderItem::setText(QString label)
74{
75 if (!_text)
76 _text = new SceneTextItem(_scene, this, label);
77 else
78 _text->setPlainTextTrunc(label);
79 QGraphicsItem::update();
80}
81
82void SceneHeaderItem::popupMenu(QWidget *caller, const QPoint &globalPos)
83{
84 if (_parent) _parent->popupMenu(caller, globalPos);
85}
86
88{
89 prepareGeometryChange();
91 update();
92}
93
95{
96QColor color = _penColor;
97 if (getParent())
98 if(getParent()->getParent())
99 if (getParent()->getParent()->isSelected())
100 color = _hiPenColor;
101 return color;
102}
103
105{
106 QColor color = _brushColor;
107 if (dynamic_cast<SceneHeaderNodeItem*>(this))
108 if (getParent()->isSelected())
109 color = _hiBrushColor;
110 if (_hover)
111 color = hoverColor(color);
112 return color;
113}
114
115void SceneHeaderItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
116{
117 event->ignore();
118}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
YACS::HMI::Scene * _scene
Definition: SceneItem.hxx:98
static int DataPort_Width
Definition: Resource.hxx:305
static QColor Header_brush
Definition: Resource.hxx:283
static int Corner_Margin
Definition: Resource.hxx:318
static int CtrlPort_Width
Definition: Resource.hxx:303
static int CtrlPort_Height
Definition: Resource.hxx:304
static int Space_Margin
Definition: Resource.hxx:311
static QColor Header_hiPen
Definition: Resource.hxx:286
static QColor Header_pen
Definition: Resource.hxx:285
static QColor Header_hiBrush
Definition: Resource.hxx:284
virtual void setText(QString label)
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
virtual QRectF getMinimalBoundingRect() const
virtual void popupMenu(QWidget *caller, const QPoint &globalPos)
virtual void popupMenu(QWidget *caller, const QPoint &globalPos)
QColor hoverColor(QColor origColor)
virtual void setPlainTextTrunc(QString label)