Version: 9.15.0
SceneHeaderItem.cxx
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
#include "
SceneHeaderItem.hxx
"
21
#include "
SceneHeaderNodeItem.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
38
using namespace
std;
39
using namespace
YACS::ENGINE
;
40
using namespace
YACS::HMI
;
41
42
43
SceneHeaderItem::SceneHeaderItem(
QGraphicsScene
*scene,
SceneItem
*parent,
44
QString label)
45
:
SceneItem
(scene, parent, label)
46
{
47
YASSERT
(
_parent
);
48
_width
= 2*
Resource::DataPort_Width
- 2*
Resource::CtrlPort_Width
-
Resource::Space_Margin
;
49
_height
=
Resource::CtrlPort_Height
;
50
_text
=0;
51
_brushColor
=
Resource::Header_brush
;
52
_hiBrushColor
=
Resource::Header_hiBrush
;
53
_penColor
=
Resource::Header_pen
;
54
_hiPenColor
=
Resource::Header_hiPen
;
55
}
56
57
SceneHeaderItem::~SceneHeaderItem
()
58
{
59
}
60
61
QRectF
SceneHeaderItem::getMinimalBoundingRect
()
const
62
{
63
return
QRectF(x(), y(), 5,
_height
);
64
}
65
66
void
SceneHeaderItem::paint
(QPainter *painter,
67
const
QStyleOptionGraphicsItem *option,
68
QWidget
*widget)
69
{
70
// DEBTRACE("SceneHeaderItem::paint");
71
}
72
73
void
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
82
void
SceneHeaderItem::popupMenu
(
QWidget
*caller,
const
QPoint &globalPos)
83
{
84
if
(
_parent
)
_parent
->
popupMenu
(caller, globalPos);
85
}
86
87
void
SceneHeaderItem::adjustGeometry
()
88
{
89
prepareGeometryChange();
90
_width
=
_parent
->
getWidth
() - 2*
Resource::Corner_Margin
- 2*
Resource::Space_Margin
- 2*
Resource::CtrlPort_Width
;
91
update();
92
}
93
94
QColor
SceneHeaderItem::getPenColor
()
95
{
96
QColor color =
_penColor
;
97
if
(
getParent
())
98
if
(
getParent
()->
getParent
())
99
if
(
getParent
()->
getParent
()->isSelected())
100
color =
_hiPenColor
;
101
return
color;
102
}
103
104
QColor
SceneHeaderItem::getBrushColor
()
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
115
void
SceneHeaderItem::mousePressEvent
(QGraphicsSceneMouseEvent *event)
116
{
117
event
->ignore();
118
}
Resource.hxx
SceneHeaderItem.hxx
SceneHeaderNodeItem.hxx
SceneTextItem.hxx
Scene.hxx
YacsTrace.hxx
YASSERT
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition:
YacsTrace.hxx:59
QGraphicsScene
QWidget
YACS::HMI::AbstractSceneItem::_height
qreal _height
Definition:
SceneItem.hxx:102
YACS::HMI::AbstractSceneItem::_width
qreal _width
Definition:
SceneItem.hxx:101
YACS::HMI::AbstractSceneItem::_hiPenColor
QColor _hiPenColor
Definition:
SceneItem.hxx:106
YACS::HMI::AbstractSceneItem::getWidth
qreal getWidth()
Definition:
SceneItem.cxx:153
YACS::HMI::AbstractSceneItem::_parent
SceneItem * _parent
Definition:
SceneItem.hxx:97
YACS::HMI::AbstractSceneItem::getParent
SceneItem * getParent()
Definition:
SceneItem.hxx:92
YACS::HMI::AbstractSceneItem::_penColor
QColor _penColor
Definition:
SceneItem.hxx:104
YACS::HMI::AbstractSceneItem::_brushColor
QColor _brushColor
Definition:
SceneItem.hxx:105
YACS::HMI::AbstractSceneItem::_hiBrushColor
QColor _hiBrushColor
Definition:
SceneItem.hxx:107
YACS::HMI::AbstractSceneItem::_scene
YACS::HMI::Scene * _scene
Definition:
SceneItem.hxx:98
YACS::HMI::Resource::DataPort_Width
static int DataPort_Width
Definition:
Resource.hxx:305
YACS::HMI::Resource::Header_brush
static QColor Header_brush
Definition:
Resource.hxx:283
YACS::HMI::Resource::Corner_Margin
static int Corner_Margin
Definition:
Resource.hxx:318
YACS::HMI::Resource::CtrlPort_Width
static int CtrlPort_Width
Definition:
Resource.hxx:303
YACS::HMI::Resource::CtrlPort_Height
static int CtrlPort_Height
Definition:
Resource.hxx:304
YACS::HMI::Resource::Space_Margin
static int Space_Margin
Definition:
Resource.hxx:311
YACS::HMI::Resource::Header_hiPen
static QColor Header_hiPen
Definition:
Resource.hxx:286
YACS::HMI::Resource::Header_pen
static QColor Header_pen
Definition:
Resource.hxx:285
YACS::HMI::Resource::Header_hiBrush
static QColor Header_hiBrush
Definition:
Resource.hxx:284
YACS::HMI::SceneHeaderItem::~SceneHeaderItem
virtual ~SceneHeaderItem()
Definition:
SceneHeaderItem.cxx:57
YACS::HMI::SceneHeaderItem::adjustGeometry
virtual void adjustGeometry()
Definition:
SceneHeaderItem.cxx:87
YACS::HMI::SceneHeaderItem::setText
virtual void setText(QString label)
Definition:
SceneHeaderItem.cxx:73
YACS::HMI::SceneHeaderItem::paint
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition:
SceneHeaderItem.cxx:66
YACS::HMI::SceneHeaderItem::getPenColor
QColor getPenColor()
Definition:
SceneHeaderItem.cxx:94
YACS::HMI::SceneHeaderItem::_text
SceneTextItem * _text
Definition:
SceneHeaderItem.hxx:49
YACS::HMI::SceneHeaderItem::mousePressEvent
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Definition:
SceneHeaderItem.cxx:115
YACS::HMI::SceneHeaderItem::getBrushColor
QColor getBrushColor()
Definition:
SceneHeaderItem.cxx:104
YACS::HMI::SceneHeaderItem::getMinimalBoundingRect
virtual QRectF getMinimalBoundingRect() const
Definition:
SceneHeaderItem.cxx:61
YACS::HMI::SceneHeaderItem::popupMenu
virtual void popupMenu(QWidget *caller, const QPoint &globalPos)
Definition:
SceneHeaderItem.cxx:82
YACS::HMI::SceneHeaderNodeItem
Definition:
SceneHeaderNodeItem.hxx:35
YACS::HMI::SceneItem
Definition:
SceneItem.hxx:121
YACS::HMI::SceneItem::popupMenu
virtual void popupMenu(QWidget *caller, const QPoint &globalPos)
YACS::HMI::SceneItem::hoverColor
QColor hoverColor(QColor origColor)
YACS::HMI::SceneItem::_hover
bool _hover
Definition:
SceneItem.hxx:155
YACS::HMI::SceneTextItem
Definition:
SceneTextItem.hxx:30
YACS::HMI::SceneTextItem::setPlainTextTrunc
virtual void setPlainTextTrunc(QString label)
Definition:
SceneTextItem.cxx:77
YACS::ENGINE
Definition:
AbstractPoint.hxx:37
YACS::HMI
Definition:
commands.hxx:37
src
genericgui
SceneHeaderItem.cxx
Copyright © 2006-2024 CEA, EDF