[529] | 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 : |
---|
| 30 | #include <HEPVis/actions/SoAlternateRepAction.h> |
---|
| 31 | |
---|
| 32 | // Inventor : |
---|
| 33 | #include <Inventor/nodes/SoNode.h> |
---|
| 34 | #include <Inventor/elements/SoSwitchElement.h> |
---|
| 35 | #include <Inventor/elements/SoCoordinateElement.h> |
---|
| 36 | |
---|
| 37 | SO_ACTION_SOURCE(SoAlternateRepAction) |
---|
| 38 | |
---|
| 39 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 40 | void SoAlternateRepAction::initClass( |
---|
| 41 | ) |
---|
| 42 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 43 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 44 | { |
---|
| 45 | SO_ACTION_INIT_CLASS(SoAlternateRepAction,SoAction); |
---|
| 46 | |
---|
| 47 | SO_ENABLE(SoAlternateRepAction,SoSwitchElement); //SGI wants that. |
---|
| 48 | SO_ENABLE(SoAlternateRepAction,SoCoordinateElement); //For SoMarkerSet. |
---|
| 49 | |
---|
| 50 | SO_ACTION_ADD_METHOD(SoNode,nodeAction); |
---|
| 51 | } |
---|
| 52 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 53 | SoAlternateRepAction::SoAlternateRepAction( |
---|
| 54 | ) |
---|
| 55 | :fGenerate(FALSE) |
---|
| 56 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 57 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 58 | { |
---|
| 59 | SO_ACTION_CONSTRUCTOR(SoAlternateRepAction); |
---|
| 60 | } |
---|
| 61 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 62 | SoAlternateRepAction::~SoAlternateRepAction( |
---|
| 63 | ) |
---|
| 64 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 65 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 66 | { |
---|
| 67 | } |
---|
| 68 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 69 | void SoAlternateRepAction::setGenerate( |
---|
| 70 | SbBool aGenerate |
---|
| 71 | ) |
---|
| 72 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 73 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 74 | { |
---|
| 75 | fGenerate = aGenerate; |
---|
| 76 | } |
---|
| 77 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 78 | SbBool SoAlternateRepAction::getGenerate( |
---|
| 79 | ) const |
---|
| 80 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 81 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 82 | { |
---|
| 83 | return fGenerate; |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | // Inventor : |
---|
| 87 | #include <Inventor/nodes/SoNode.h> |
---|
| 88 | #include <Inventor/nodes/SoGroup.h> |
---|
| 89 | #include <Inventor/nodes/SoCoordinate3.h> |
---|
| 90 | |
---|
| 91 | // HEPVisUtils : |
---|
| 92 | //#include <HEPVis/nodes/SoHighlightMaterial.h> |
---|
| 93 | //#include <HEPVis/nodes/SoSplineCurve.h> |
---|
| 94 | |
---|
| 95 | #define IF_CLASS(aClass) \ |
---|
| 96 | if(aNode->isOfType(aClass::getClassTypeId())) {\ |
---|
| 97 | /*printf("debug : SoAlternateRepAction::nodeAction : %s generate %d\n",#aClass,This->fGenerate);*/\ |
---|
| 98 | aClass* node = (aClass*)aNode;\ |
---|
| 99 | if(This->fGenerate==TRUE) {\ |
---|
| 100 | if(node->alternateRep.getValue()==NULL) {\ |
---|
| 101 | node->generateAlternateRep();\ |
---|
| 102 | /* Then go down if needed : */\ |
---|
| 103 | SoNode* altRep = node->alternateRep.getValue();\ |
---|
| 104 | if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\ |
---|
| 105 | altRep->doAction(This);\ |
---|
| 106 | }\ |
---|
| 107 | } else {\ |
---|
| 108 | /* First go down if needed : */\ |
---|
| 109 | SoNode* altRep = node->alternateRep.getValue();\ |
---|
| 110 | if((altRep!=NULL) && altRep->isOfType(SoGroup::getClassTypeId()))\ |
---|
| 111 | altRep->doAction(This);\ |
---|
| 112 | /* Then clear : */\ |
---|
| 113 | node->clearAlternateRep();\ |
---|
| 114 | }\ |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 118 | void SoAlternateRepAction::nodeAction( |
---|
| 119 | SoAction* aThis |
---|
| 120 | ,SoNode* aNode |
---|
| 121 | ) |
---|
| 122 | ////////////////////////////////////////////////////////////////////////////// |
---|
| 123 | //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!// |
---|
| 124 | { |
---|
| 125 | /*printf("debug : SoAlternateRepAction::nodeAction : %s %s\n", |
---|
| 126 | aNode->getName().getString(), |
---|
| 127 | aNode->getTypeId().getName().getString());*/ |
---|
| 128 | //SoAlternateRepAction* This = (SoAlternateRepAction*)aThis; |
---|
| 129 | |
---|
| 130 | if(false) {} |
---|
| 131 | // HEPVisUtils : |
---|
| 132 | //else IF_CLASS(SoHighlightMaterial) |
---|
| 133 | //else IF_CLASS(SoSplineCurve) |
---|
| 134 | |
---|
| 135 | // Inventor : |
---|
| 136 | else if(aNode->isOfType(SoGroup::getClassTypeId())) { |
---|
| 137 | aNode->doAction(aThis); |
---|
| 138 | } |
---|
| 139 | else if(aNode->isOfType(SoCoordinate3::getClassTypeId())) { //For SoMakerSet. |
---|
| 140 | aNode->doAction(aThis); |
---|
| 141 | } |
---|
| 142 | // Else : |
---|
| 143 | else if(aNode->getField("alternateRep")!=NULL) { |
---|
| 144 | aNode->doAction(aThis); |
---|
| 145 | } |
---|
| 146 | |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | #endif |
---|