SoAlternateRepAction.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 #ifdef G4VIS_BUILD_OI_DRIVER
00027 
00028 
00029 // this :
00030 #include <HEPVis/actions/SoAlternateRepAction.h>
00031 
00032 // Inventor :
00033 #include <Inventor/nodes/SoNode.h>
00034 #include <Inventor/elements/SoSwitchElement.h>
00035 #include <Inventor/elements/SoCoordinateElement.h>
00036 
00037 SO_ACTION_SOURCE(SoAlternateRepAction)
00038 
00039 
00040 void SoAlternateRepAction::initClass(
00041 )
00044 {
00045   SO_ACTION_INIT_CLASS(SoAlternateRepAction,SoAction);
00046 
00047   SO_ENABLE(SoAlternateRepAction,SoSwitchElement); //SGI wants that.
00048   SO_ENABLE(SoAlternateRepAction,SoCoordinateElement); //For SoMarkerSet.
00049 
00050   SO_ACTION_ADD_METHOD(SoNode,nodeAction);
00051 }
00053 SoAlternateRepAction::SoAlternateRepAction(
00054 )
00055 :fGenerate(FALSE)
00058 {
00059   SO_ACTION_CONSTRUCTOR(SoAlternateRepAction);
00060 }
00062 SoAlternateRepAction::~SoAlternateRepAction(
00063 )
00066 {
00067 }
00069 void SoAlternateRepAction::setGenerate(
00070  SbBool aGenerate
00071 )
00074 {
00075   fGenerate = aGenerate;
00076 }
00078 SbBool SoAlternateRepAction::getGenerate(
00079 ) const
00082 {
00083   return fGenerate;
00084 }
00085 
00086 // Inventor :
00087 #include <Inventor/nodes/SoNode.h>
00088 #include <Inventor/nodes/SoGroup.h>
00089 #include <Inventor/nodes/SoCoordinate3.h>
00090 
00091 // HEPVisUtils :
00092 //#include <HEPVis/nodes/SoHighlightMaterial.h>
00093 //#include <HEPVis/nodes/SoSplineCurve.h>
00094 
00095 #define IF_CLASS(aClass) \
00096   if(aNode->isOfType(aClass::getClassTypeId())) {\
00097     /*printf("debug : SoAlternateRepAction::nodeAction : %s generate %d\n",#aClass,This->fGenerate);*/\
00098     aClass* node = (aClass*)aNode;\
00099     if(This->fGenerate==TRUE) {\
00100       if(node->alternateRep.getValue()==NULL) {\
00101         node->generateAlternateRep();\
00102         /* Then go down if needed : */\
00103         SoNode* altRep = node->alternateRep.getValue();\
00104         if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\
00105           altRep->doAction(This);\
00106       }\
00107     } else {\
00108       /* First go down if needed : */\
00109       SoNode* altRep = node->alternateRep.getValue();\
00110       if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\
00111         altRep->doAction(This);\
00112       /* Then clear : */\
00113       node->clearAlternateRep();\
00114     }\
00115   }
00116 
00118 void SoAlternateRepAction::nodeAction(
00119  SoAction* aThis
00120 ,SoNode* aNode
00121 ) 
00122 
00123 
00124 {
00125   /*printf("debug : SoAlternateRepAction::nodeAction : %s %s\n",
00126     aNode->getName().getString(),
00127     aNode->getTypeId().getName().getString());*/
00128   //SoAlternateRepAction* This = (SoAlternateRepAction*)aThis;
00129 
00130   if(false) {}
00131   // HEPVisUtils :
00132   //else IF_CLASS(SoHighlightMaterial)
00133   //else IF_CLASS(SoSplineCurve)
00134 
00135   // Inventor :
00136   else if(aNode->isOfType(SoGroup::getClassTypeId())) {
00137     aNode->doAction(aThis);
00138   }
00139   else if(aNode->isOfType(SoCoordinate3::getClassTypeId())) { //For SoMakerSet.
00140     aNode->doAction(aThis);
00141   }
00142   // Else :
00143   else if(aNode->getField("alternateRep")!=NULL) {
00144     aNode->doAction(aThis);
00145   }
00146 
00147 }
00148 
00149 #endif

Generated on Mon May 27 17:50:34 2013 for Geant4 by  doxygen 1.4.7