00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #ifdef G4VIS_BUILD_OI_DRIVER
00027 
00028 
00029 
00030 #include <HEPVis/actions/SoAlternateRepAction.h>
00031 
00032 
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); 
00048   SO_ENABLE(SoAlternateRepAction,SoCoordinateElement); 
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 
00087 #include <Inventor/nodes/SoNode.h>
00088 #include <Inventor/nodes/SoGroup.h>
00089 #include <Inventor/nodes/SoCoordinate3.h>
00090 
00091 
00092 
00093 
00094 
00095 #define IF_CLASS(aClass) \
00096   if(aNode->isOfType(aClass::getClassTypeId())) {\
00097     \
00098     aClass* node = (aClass*)aNode;\
00099     if(This->fGenerate==TRUE) {\
00100       if(node->alternateRep.getValue()==NULL) {\
00101         node->generateAlternateRep();\
00102         \
00103         SoNode* altRep = node->alternateRep.getValue();\
00104         if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\
00105           altRep->doAction(This);\
00106       }\
00107     } else {\
00108       \
00109       SoNode* altRep = node->alternateRep.getValue();\
00110       if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\
00111         altRep->doAction(This);\
00112       \
00113       node->clearAlternateRep();\
00114     }\
00115   }
00116 
00118 void SoAlternateRepAction::nodeAction(
00119  SoAction* aThis
00120 ,SoNode* aNode
00121 ) 
00122 
00123 
00124 {
00125   
00126 
00127 
00128   
00129 
00130   if(false) {}
00131   
00132   
00133   
00134 
00135   
00136   else if(aNode->isOfType(SoGroup::getClassTypeId())) {
00137     aNode->doAction(aThis);
00138   }
00139   else if(aNode->isOfType(SoCoordinate3::getClassTypeId())) { 
00140     aNode->doAction(aThis);
00141   }
00142   
00143   else if(aNode->getField("alternateRep")!=NULL) {
00144     aNode->doAction(aThis);
00145   }
00146 
00147 }
00148 
00149 #endif