ATLAS Offline Software
graphics
VP1
VP1HEPVis
src
SoTransparency.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
7
// //
8
// Header file for class SoTransparency //
9
// //
10
// Description: Custom node for VP1 which sets the absolute //
11
// or relative transparency of the current //
12
// state. //
13
// //
14
// Author: Troels Kofoed Jacobsen //
15
// Initial version: July 2008 //
16
// //
18
19
#include "
VP1HEPVis/nodes/SoTransparency.h
"
20
#include <Inventor/actions/SoCallbackAction.h>
21
#include <Inventor/actions/SoGLRenderAction.h>
22
#include <Inventor/bundles/SoMaterialBundle.h>
23
#include <Inventor/elements/SoTransparencyElement.h>
24
#include <algorithm>
//for min/max
25
26
SO_NODE_SOURCE(
SoTransparency
)
27
// Initializes the SoTransparency class.
28
void
29
SoTransparency::initClass
()
30
{
31
[[maybe_unused]]
static
const
bool
didInit = [&]() {
32
SO_NODE_INIT_CLASS(
SoTransparency
, SoNode,
"Node"
);
33
return
true
;
34
}();
35
}
36
37
// Constructor
38
SoTransparency::SoTransparency
()
39
{
40
SO_NODE_CONSTRUCTOR(
SoTransparency
);
41
42
SO_NODE_ADD_FIELD(
transparency
, (0.5));
43
SO_NODE_ADD_FIELD(
relative
, (
true
));
44
setNodeType(EXTENSION);
45
46
}
47
48
// Destructor
49
SoTransparency::~SoTransparency
()
50
{
51
}
52
53
// Implements GL render action.
54
void
55
SoTransparency::GLRender
(SoGLRenderAction *
action
)
56
{
57
SoTransparency::doAction
(
action
);
58
SoMaterialBundle
mb
(
action
);
59
mb
.forceSend(0);
60
}
61
62
// Implements callback action.
63
void
64
SoTransparency::callback
(SoCallbackAction *
action
)
65
{
66
SoTransparency::doAction
(
action
);
67
}
68
69
void
70
SoTransparency::doAction
(SoAction *
action
)
71
{
72
// Make sure the "transparency" field is not ignored. If it is,
73
// then we don't need to change anything in the state.
74
if
(
transparency
.isIgnored())
75
return
;
76
77
const
float
isRelative =
relative
.getValue();
78
const
float
transpVal =
transparency
.getValue();
79
if
( isRelative && transpVal<=0.0
f
)
80
return
;
//No effect
81
82
const
SoTransparencyElement * STE = SoTransparencyElement::getInstance(
action
->getState() );
83
const
int
n
= STE->getNum();
84
if
(
n
<=0)
85
return
;
//Nothing to modify
86
87
float
* finalTransparency =
new
float
[
n
];
//NB: Who takes care of deleting finalTransparency??
88
for
(
int
i
= 0;
i
<
n
;
i
++)
89
finalTransparency[
i
] = std::min<float>( 1.0
f
, std::max<float>( 0.0
f
, ( isRelative ? ( 1.0 - (1.0 - transpVal) * (1.0 - STE->get(0)) ) : transpVal ) ) );
90
91
SoTransparencyElement::set
(
action
->getState(),
this
,
n
, finalTransparency);
92
93
}
SoTransparency::doAction
virtual void doAction(SoAction *action)
Definition:
SoTransparency.cxx:70
SoTransparency::~SoTransparency
virtual ~SoTransparency()
Definition:
SoTransparency.cxx:49
SoTransparency
Definition:
SoTransparency.h:20
SoTransparency::relative
SoSFBool relative
Definition:
SoTransparency.h:28
SoTransparency::SoTransparency
SoTransparency()
Definition:
SoTransparency.cxx:38
SoTransparency.h
SoTransparency::callback
virtual void callback(SoCallbackAction *action)
Definition:
SoTransparency.cxx:64
SoTransparency::transparency
SoSFFloat transparency
Definition:
SoTransparency.h:27
SoTransparency::initClass
static void initClass()
Definition:
SoTransparency.cxx:29
lumiFormat.i
int i
Definition:
lumiFormat.py:85
beamspotman.n
n
Definition:
beamspotman.py:731
hist_file_dump.f
f
Definition:
hist_file_dump.py:135
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition:
bitmask.h:232
SoTransparency::GLRender
virtual void GLRender(SoGLRenderAction *action)
Definition:
SoTransparency.cxx:55
TRT_PAI_physicsConstants::mb
const double mb
1mb to cm2
Definition:
TRT_PAI_physicsConstants.h:15
python.CaloScaleNoiseConfig.action
action
Definition:
CaloScaleNoiseConfig.py:77
Generated on Thu Nov 7 2024 21:26:24 for ATLAS Offline Software by
1.8.18