Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
SoAlternateRepAction.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26#ifdef G4VIS_BUILD_OI_DRIVER
27
28
29// this :
31
32// Inventor :
33#include <Inventor/nodes/SoNode.h>
34#include <Inventor/elements/SoSwitchElement.h>
35#include <Inventor/elements/SoCoordinateElement.h>
36
37SO_ACTION_SOURCE(SoAlternateRepAction)
38
39//////////////////////////////////////////////////////////////////////////////
41)
42//////////////////////////////////////////////////////////////////////////////
43//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
44{
45 static bool first = true;
46 if (first) {
47 first = false;
48 SO_ACTION_INIT_CLASS(SoAlternateRepAction,SoAction);
49
50 SO_ENABLE(SoAlternateRepAction,SoSwitchElement); //SGI wants that.
51 SO_ENABLE(SoAlternateRepAction,SoCoordinateElement); //For SoMarkerSet.
52
53 SO_ACTION_ADD_METHOD(SoNode,nodeAction);
54 }
55}
56//////////////////////////////////////////////////////////////////////////////
58)
59:fGenerate(FALSE)
60//////////////////////////////////////////////////////////////////////////////
61//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
62{
63 SO_ACTION_CONSTRUCTOR(SoAlternateRepAction);
64}
65//////////////////////////////////////////////////////////////////////////////
67)
68//////////////////////////////////////////////////////////////////////////////
69//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
70{
71}
72//////////////////////////////////////////////////////////////////////////////
74 SbBool aGenerate
75)
76//////////////////////////////////////////////////////////////////////////////
77//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
78{
79 fGenerate = aGenerate;
80}
81//////////////////////////////////////////////////////////////////////////////
83) const
84//////////////////////////////////////////////////////////////////////////////
85//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
86{
87 return fGenerate;
88}
89
90// Inventor :
91#include <Inventor/nodes/SoNode.h>
92#include <Inventor/nodes/SoGroup.h>
93#include <Inventor/nodes/SoCoordinate3.h>
94
95// HEPVisUtils :
96//#include <HEPVis/nodes/SoHighlightMaterial.h>
97//#include <HEPVis/nodes/SoSplineCurve.h>
98
99#define IF_CLASS(aClass) \
100 if(aNode->isOfType(aClass::getClassTypeId())) {\
101 /*printf("debug : SoAlternateRepAction::nodeAction : %s generate %d\n",#aClass,This->fGenerate);*/\
102 aClass* node = (aClass*)aNode;\
103 if(This->fGenerate==TRUE) {\
104 if(node->alternateRep.getValue()==NULL) {\
105 node->generateAlternateRep();\
106 /* Then go down if needed : */\
107 SoNode* altRep = node->alternateRep.getValue();\
108 if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\
109 altRep->doAction(This);\
110 }\
111 } else {\
112 /* First go down if needed : */\
113 SoNode* altRep = node->alternateRep.getValue();\
114 if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\
115 altRep->doAction(This);\
116 /* Then clear : */\
117 node->clearAlternateRep();\
118 }\
119 }
120
121//////////////////////////////////////////////////////////////////////////////
122void SoAlternateRepAction::nodeAction(
123 SoAction* aThis
124,SoNode* aNode
125)
126//////////////////////////////////////////////////////////////////////////////
127//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
128{
129 /*printf("debug : SoAlternateRepAction::nodeAction : %s %s\n",
130 aNode->getName().getString(),
131 aNode->getTypeId().getName().getString());*/
132 //SoAlternateRepAction* This = (SoAlternateRepAction*)aThis;
133
134 if(false) {}
135 // HEPVisUtils :
136 //else IF_CLASS(SoHighlightMaterial)
137 //else IF_CLASS(SoSplineCurve)
138
139 // Inventor :
140 else if(aNode->isOfType(SoGroup::getClassTypeId())) {
141 aNode->doAction(aThis);
142 }
143 else if(aNode->isOfType(SoCoordinate3::getClassTypeId())) { //For SoMakerSet.
144 aNode->doAction(aThis);
145 }
146 // Else :
147 else if(aNode->getField("alternateRep")!=NULL) {
148 aNode->doAction(aThis);
149 }
150
151}
152
153#endif
#define FALSE
Definition: Globals.hh:23
void setGenerate(SbBool)
static void initClass(void)
virtual ~SoAlternateRepAction()
SbBool getGenerate() const