Version: 8.3.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
SceneHeaderItem.cxx
Go to the documentation of this file.
1
// Copyright (C) 2006-2016 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
#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
}
src
genericgui
SceneHeaderItem.cxx
Copyright © 2006-2017 CEA/DEN, EDF R&D