ATLAS Offline Software
Loading...
Searching...
No Matches
SoTransparency Class Reference

#include <SoTransparency.h>

Inheritance diagram for SoTransparency:
Collaboration diagram for SoTransparency:

Public Member Functions

 SoTransparency ()

Static Public Member Functions

static void initClass ()

Public Attributes

SoSFFloat transparency
SoSFBool relative

Protected Member Functions

virtual void GLRender (SoGLRenderAction *action)
virtual void callback (SoCallbackAction *action)
virtual void doAction (SoAction *action)

Private Member Functions

 SO_NODE_HEADER (SoTransparency)
virtual ~SoTransparency ()

Detailed Description

Definition at line 20 of file SoTransparency.h.

Constructor & Destructor Documentation

◆ SoTransparency()

SoTransparency::SoTransparency ( )

Definition at line 38 of file SoTransparency.cxx.

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}
SoSFFloat transparency

Member Function Documentation

◆ callback()

void SoTransparency::callback ( SoCallbackAction * action)
protectedvirtual

Definition at line 64 of file SoTransparency.cxx.

65{
67}
virtual void doAction(SoAction *action)

◆ doAction()

void SoTransparency::doAction ( SoAction * action)
protectedvirtual

Definition at line 70 of file SoTransparency.cxx.

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.0f )
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.0f, std::max<float>( 0.0f, ( isRelative ? ( 1.0 - (1.0 - transpVal) * (1.0 - STE->get(0)) ) : transpVal ) ) );
90
91 SoTransparencyElement::set(action->getState(), this, n, finalTransparency);
92
93}

◆ GLRender()

void SoTransparency::GLRender ( SoGLRenderAction * action)
protectedvirtual

Definition at line 55 of file SoTransparency.cxx.

56{
58 SoMaterialBundle mb(action);
59 mb.forceSend(0);
60}

◆ initClass()

void SoTransparency::initClass ( )
static

Definition at line 29 of file SoTransparency.cxx.

30{
31 [[maybe_unused]] static const bool didInit = [&]() {
32 SO_NODE_INIT_CLASS(SoTransparency, SoNode, "Node");
33 return true;
34 }();
35}

◆ SO_NODE_HEADER()

SoTransparency::SO_NODE_HEADER ( SoTransparency )
private

◆ ~SoTransparency()

SoTransparency::~SoTransparency ( )
privatevirtual

Definition at line 49 of file SoTransparency.cxx.

50{
51}

Member Data Documentation

◆ relative

SoSFBool SoTransparency::relative

Definition at line 28 of file SoTransparency.h.

◆ transparency

SoSFFloat SoTransparency::transparency

Definition at line 27 of file SoTransparency.h.


The documentation for this class was generated from the following files: