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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /visualization/OpenInventor/src/SoDetectorTreeKit.cc (Version 11.3.0) and /visualization/OpenInventor/src/SoDetectorTreeKit.cc (Version 10.6.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 //                                                 27 //
 28 //                                                 28 //
 29 /*-----------------------------HEPVis---------     29 /*-----------------------------HEPVis----------------------------------------*/
 30 /*                                                 30 /*                                                                           */
 31 /* Node:             SoDetectorTreeKit             31 /* Node:             SoDetectorTreeKit                                       */
 32 /* Description:      Represents a single sided     32 /* Description:      Represents a single sided silicon strip detector        */
 33 /* Author:           Joe Boudreau Nov 11 1996      33 /* Author:           Joe Boudreau Nov 11 1996                                */
 34 /*                                                 34 /*                                                                           */
 35 /*--------------------------------------------     35 /*---------------------------------------------------------------------------*/
 36                                                    36 
                                                   >>  37 #ifdef G4VIS_BUILD_OI_DRIVER
                                                   >>  38 
 37 // this :                                          39 // this :
 38 #include "HEPVis/nodekits/SoDetectorTreeKit.h"     40 #include "HEPVis/nodekits/SoDetectorTreeKit.h"
 39                                                    41 
 40 #include <Inventor/SoPickedPoint.h>                42 #include <Inventor/SoPickedPoint.h>
 41 #include <Inventor/nodes/SoSeparator.h>            43 #include <Inventor/nodes/SoSeparator.h>
 42 #include <Inventor/nodes/SoPickStyle.h>            44 #include <Inventor/nodes/SoPickStyle.h>
 43 #include <Inventor/nodes/SoDrawStyle.h>            45 #include <Inventor/nodes/SoDrawStyle.h>
 44 #include <Inventor/nodes/SoSwitch.h>               46 #include <Inventor/nodes/SoSwitch.h>
 45 #include <Inventor/nodes/SoMaterial.h>             47 #include <Inventor/nodes/SoMaterial.h>
 46 #include <Inventor/nodes/SoUnits.h>                48 #include <Inventor/nodes/SoUnits.h>
 47 #include <Inventor/nodes/SoTransform.h>            49 #include <Inventor/nodes/SoTransform.h>
 48 #include <Inventor/nodes/SoEventCallback.h>        50 #include <Inventor/nodes/SoEventCallback.h>
 49 #include <Inventor/nodekits/SoSeparatorKit.h>      51 #include <Inventor/nodekits/SoSeparatorKit.h>
 50 #include <Inventor/nodekits/SoShapeKit.h>          52 #include <Inventor/nodekits/SoShapeKit.h>
 51 #include <Inventor/nodekits/SoAppearanceKit.h>     53 #include <Inventor/nodekits/SoAppearanceKit.h>
 52 #include <Inventor/nodekits/SoNodeKitListPart.     54 #include <Inventor/nodekits/SoNodeKitListPart.h>
 53 #include <Inventor/nodekits/SoBaseKit.h>           55 #include <Inventor/nodekits/SoBaseKit.h>
 54 #include <Inventor/nodes/SoTexture2Transform.h     56 #include <Inventor/nodes/SoTexture2Transform.h>
 55 #include <Inventor/events/SoMouseButtonEvent.h     57 #include <Inventor/events/SoMouseButtonEvent.h>
 56 #include <Inventor/actions/SoHandleEventAction     58 #include <Inventor/actions/SoHandleEventAction.h>
 57                                                    59 
 58 #include <HEPVis/actions/SoAlternateRepAction.     60 #include <HEPVis/actions/SoAlternateRepAction.h>
 59                                                    61 
 60 #include <cmath>                                   62 #include <cmath>
 61                                                    63 
 62 // This statement is required                      64 // This statement is required
 63 SO_KIT_SOURCE(SoDetectorTreeKit)                   65 SO_KIT_SOURCE(SoDetectorTreeKit)
 64                                                    66  
 65 // initClass                                       67 // initClass
 66 void SoDetectorTreeKit::initClass(){               68 void SoDetectorTreeKit::initClass(){
 67   static bool first = true;                    <<  69   SO_KIT_INIT_CLASS(SoDetectorTreeKit,SoBaseKit,"BaseKit");
 68   if (first) {                                 << 
 69     first = false;                             << 
 70     SO_KIT_INIT_CLASS(SoDetectorTreeKit,SoBase << 
 71   }                                            << 
 72 }                                                  70 }
 73                                                    71 
 74 // Constructor                                     72 // Constructor
 75 SoDetectorTreeKit::SoDetectorTreeKit() {           73 SoDetectorTreeKit::SoDetectorTreeKit() {
 76   SO_KIT_CONSTRUCTOR(SoDetectorTreeKit);           74   SO_KIT_CONSTRUCTOR(SoDetectorTreeKit);
 77                                                    75 
 78   SO_NODE_ADD_FIELD(alternateRep, (NULL));         76   SO_NODE_ADD_FIELD(alternateRep, (NULL));
 79                                                    77 
 80   SO_KIT_ADD_CATALOG_ENTRY     (     topSepara     78   SO_KIT_ADD_CATALOG_ENTRY     (     topSeparator,         SoSeparator, FALSE,          this,\0, FALSE);
 81   SO_KIT_ADD_CATALOG_ENTRY     (        pickSt     79   SO_KIT_ADD_CATALOG_ENTRY     (        pickStyle,         SoSeparator, TRUE ,  topSeparator,\0, TRUE);
 82   SO_KIT_ADD_CATALOG_ENTRY     (       appeara     80   SO_KIT_ADD_CATALOG_ENTRY     (       appearance,     SoAppearanceKit, TRUE,  topSeparator ,\0, TRUE);
 83   SO_KIT_ADD_CATALOG_ENTRY     (            un     81   SO_KIT_ADD_CATALOG_ENTRY     (            units,             SoUnits, TRUE,  topSeparator ,\0, TRUE);
 84   SO_KIT_ADD_CATALOG_ENTRY     (        transf     82   SO_KIT_ADD_CATALOG_ENTRY     (        transform,         SoTransform, TRUE ,  topSeparator,\0, TRUE);
 85   SO_KIT_ADD_CATALOG_ENTRY     (texture2Transf     83   SO_KIT_ADD_CATALOG_ENTRY     (texture2Transform, SoTexture2Transform, TRUE,  topSeparator ,\0, TRUE);
 86   SO_KIT_ADD_CATALOG_ENTRY     (        childL     84   SO_KIT_ADD_CATALOG_ENTRY     (        childList,            SoSwitch, FALSE,  topSeparator,\0, FALSE);
 87   SO_KIT_ADD_CATALOG_ENTRY     ( previewSepara     85   SO_KIT_ADD_CATALOG_ENTRY     ( previewSeparator,         SoSeparator, FALSE,     childList,\0, TRUE);
 88   SO_KIT_ADD_CATALOG_ENTRY     (    fullSepara     86   SO_KIT_ADD_CATALOG_ENTRY     (    fullSeparator,         SoSeparator, FALSE,     childList,\0, TRUE);
 89                                                    87 
 90   SO_KIT_INIT_INSTANCE();                          88   SO_KIT_INIT_INSTANCE();
 91   createInitialTree();                             89   createInitialTree();
 92 }                                                  90 }
 93                                                    91 
 94 // Destructor                                      92 // Destructor
 95 SoDetectorTreeKit::~SoDetectorTreeKit() {          93 SoDetectorTreeKit::~SoDetectorTreeKit() {
 96 }                                                  94 }
 97                                                    95 
 98                                                    96 
 99 SbBool SoDetectorTreeKit::affectsState() const     97 SbBool SoDetectorTreeKit::affectsState() const {
100   return FALSE;                                    98   return FALSE;
101 }                                                  99 }
102                                                   100 
103 void SoDetectorTreeKit::createInitialTree() {     101 void SoDetectorTreeKit::createInitialTree() {
104                                                   102 
105   SoEventCallback *myCallback = new SoEventCal    103   SoEventCallback *myCallback = new SoEventCallback();
106   myCallback->addEventCallback(SoMouseButtonEv    104   myCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
107                                SoDetectorTreeK    105                                SoDetectorTreeKit::expand,
108                                this);             106                                this);
109   myCallback->addEventCallback(SoMouseButtonEv    107   myCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
110                                SoDetectorTreeK    108                                SoDetectorTreeKit::contract  ,
111                                this);             109                                this);
112   if(setPart("callbackList[0]",myCallback)==FA    110   if(setPart("callbackList[0]",myCallback)==FALSE) myCallback->unref(); 
113                                                   111 
114   SoSwitch *theChildList = (SoSwitch *) childL    112   SoSwitch *theChildList = (SoSwitch *) childList.getValue();
115   theChildList->whichChild.setValue(0);           113   theChildList->whichChild.setValue(0);
116 }                                                 114 }
117                                                   115 
118 void SoDetectorTreeKit::expand(void *userData,    116 void SoDetectorTreeKit::expand(void *userData, SoEventCallback *eventCB){
119                                                   117 
120   // Was the event previously handled? Is it t    118   // Was the event previously handled? Is it the right kind?
121                                                   119 
122   if (eventCB->isHandled()) return;               120   if (eventCB->isHandled()) return;
123   const SoMouseButtonEvent *event= (SoMouseBut    121   const SoMouseButtonEvent *event= (SoMouseButtonEvent *) eventCB->getEvent();
124   if (!SoMouseButtonEvent::isButtonPressEvent(    122   if (!SoMouseButtonEvent::isButtonPressEvent(event,SoMouseButtonEvent::BUTTON1)) return;
125   if (!event->wasCtrlDown()) return;              123   if (!event->wasCtrlDown()) return;
126   if (event->wasShiftDown()) return;              124   if (event->wasShiftDown()) return;
127                                                   125 
128   // Which Detector is this being called for?     126   // Which Detector is this being called for?
129   SoDetectorTreeKit* This = (SoDetectorTreeKit    127   SoDetectorTreeKit* This = (SoDetectorTreeKit *) userData;
130                                                   128 
131   // Find out whether that's the one that has     129   // Find out whether that's the one that has been picked.  
132   // "This' is the lowest detector tree kit in    130   // "This' is the lowest detector tree kit in the hierarchy.
133   SoHandleEventAction *handleEventAction = eve    131   SoHandleEventAction *handleEventAction = eventCB->getAction();
134   const SoPickedPoint *pickedPoint = handleEve    132   const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint();
135   if (!pickedPoint) return;                       133   if (!pickedPoint) return;
136                                                   134 
137   SoFullPath* path = (SoFullPath*)pickedPoint-    135   SoFullPath* path = (SoFullPath*)pickedPoint->getPath();
138   SoNode *ancestorNode=NULL;                      136   SoNode *ancestorNode=NULL;
139   for (int i=0;i<path->getLength();i++) {         137   for (int i=0;i<path->getLength();i++) {
140     ancestorNode  = path->getNodeFromTail(i);     138     ancestorNode  = path->getNodeFromTail(i);
141     if (ancestorNode->isOfType(SoDetectorTreeK    139     if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId()))  break;
142   }                                               140   }
143   if (This!=ancestorNode) return;                 141   if (This!=ancestorNode) return;
144   //  if (!ancestorNode->isOfType(SoDetectorTr    142   //  if (!ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId())) return;
145                                                   143  
146   // Deactivate the Preview                       144   // Deactivate the Preview
147   This->setPreview(FALSE);                        145   This->setPreview(FALSE);
148   eventCB->setHandled();                          146   eventCB->setHandled();
149                                                   147      
150 }                                                 148 }
151                                                   149 
152 void SoDetectorTreeKit::contract(void *userDat    150 void SoDetectorTreeKit::contract(void *userData, SoEventCallback *eventCB){
153                                                   151 
154   // Was the event previously handled? Is it t    152   // Was the event previously handled? Is it the right kind?
155   if (eventCB->isHandled()) return;               153   if (eventCB->isHandled()) return;
156   const SoMouseButtonEvent *event= (SoMouseBut    154   const SoMouseButtonEvent *event= (SoMouseButtonEvent *) eventCB->getEvent();
157   if (!SoMouseButtonEvent::isButtonPressEvent(    155   if (!SoMouseButtonEvent::isButtonPressEvent(event,SoMouseButtonEvent::BUTTON1)) return;
158   if (event->wasCtrlDown()) return;               156   if (event->wasCtrlDown()) return;
159   if (!event->wasShiftDown()) return;             157   if (!event->wasShiftDown()) return;
160                                                   158 
161   // Which Detector is this being called for?     159   // Which Detector is this being called for?
162   SoDetectorTreeKit* This = (SoDetectorTreeKit    160   SoDetectorTreeKit* This = (SoDetectorTreeKit *) userData;
163                                                   161 
164   // Find out whether that's the one that has     162   // Find out whether that's the one that has been picked
165   SoHandleEventAction *handleEventAction = eve    163   SoHandleEventAction *handleEventAction = eventCB->getAction();
166   const SoPickedPoint *pickedPoint = handleEve    164   const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint();
167   if (!pickedPoint) return;                       165   if (!pickedPoint) return;
168                                                   166  
169   // Find out whether that's the one that has     167   // Find out whether that's the one that has been picked.  
170   // "This" is the lowest detector tree kit in    168   // "This" is the lowest detector tree kit in the hierarchy.
171   SoFullPath* path = (SoFullPath*)pickedPoint-    169   SoFullPath* path = (SoFullPath*)pickedPoint->getPath();
172   SoNode *ancestorNode=NULL;                      170   SoNode *ancestorNode=NULL;
173   SbBool firstTreeFound=FALSE;                    171   SbBool firstTreeFound=FALSE;
174   for (int i=0;i<path->getLength();i++) {         172   for (int i=0;i<path->getLength();i++) {
175     ancestorNode  = path->getNodeFromTail(i);     173     ancestorNode  = path->getNodeFromTail(i);
176     if (ancestorNode->isOfType(SoDetectorTreeK    174     if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId())) {
177       if (!firstTreeFound) {                      175       if (!firstTreeFound) {
178         if (This!=ancestorNode) return;           176         if (This!=ancestorNode) return;
179         firstTreeFound=TRUE;                      177         firstTreeFound=TRUE;
180       }                                           178       }
181       SoDetectorTreeKit *That = (SoDetectorTre    179       SoDetectorTreeKit *That = (SoDetectorTreeKit *) ancestorNode;
182       if (!That->getPreview()) {                  180       if (!That->getPreview()) {
183         That->setPreview(TRUE);                   181         That->setPreview(TRUE);
184         eventCB->setHandled();                    182         eventCB->setHandled();
185         return;                                   183         return;
186       }                                           184       }
187     }                                             185     }
188   }                                               186   }
189 }                                                 187 }
190                                                   188 
191 void SoDetectorTreeKit::setPreview(SbBool Flag    189 void SoDetectorTreeKit::setPreview(SbBool Flag) {
192   SoSwitch *theChildList = (SoSwitch *) childL    190   SoSwitch *theChildList = (SoSwitch *) childList.getValue();
193   if (Flag) {                                     191   if (Flag) {
194     theChildList->whichChild.setValue(0);         192     theChildList->whichChild.setValue(0);
195   }                                               193   }
196   else {                                          194   else {
197     theChildList->whichChild.setValue(1);         195     theChildList->whichChild.setValue(1);
198   }                                               196   }
199 }                                                 197 }
200                                                   198 
201 SbBool SoDetectorTreeKit::getPreview() const {    199 SbBool SoDetectorTreeKit::getPreview() const {
202   SoSwitch *theChildList = (SoSwitch *) childL    200   SoSwitch *theChildList = (SoSwitch *) childList.getValue();
203   if (theChildList->whichChild.getValue()==0)     201   if (theChildList->whichChild.getValue()==0) return TRUE;
204   return FALSE;                                   202   return FALSE;
205 }                                                 203 }
206                                                   204 
207                                                   205 
208 void SoDetectorTreeKit::setPreviewAndFull() {     206 void SoDetectorTreeKit::setPreviewAndFull() {
209   SoSwitch *theChildList = (SoSwitch *) childL    207   SoSwitch *theChildList = (SoSwitch *) childList.getValue();
210   theChildList->whichChild.setValue(SO_SWITCH_    208   theChildList->whichChild.setValue(SO_SWITCH_ALL);
211 }                                                 209 }
212                                                   210 
213 SoSeparator *SoDetectorTreeKit::getPreviewSepa    211 SoSeparator *SoDetectorTreeKit::getPreviewSeparator() const {
214   return (SoSeparator *) previewSeparator.getV    212   return (SoSeparator *) previewSeparator.getValue();
215 }                                                 213 }
216                                                   214 
217 SoSeparator *SoDetectorTreeKit::getFullSeparat    215 SoSeparator *SoDetectorTreeKit::getFullSeparator() const {
218   return (SoSeparator *) fullSeparator.getValu    216   return (SoSeparator *) fullSeparator.getValue();
219 }                                                 217 }
220                                                   218 
221                                                   219 
222                                                   220 
223                                                   221 
224 // generateAlternateRep                           222 // generateAlternateRep
225 void SoDetectorTreeKit::generateAlternateRep()    223 void SoDetectorTreeKit::generateAlternateRep() {
226   alternateRep.setValue(topSeparator.getValue(    224   alternateRep.setValue(topSeparator.getValue());
227 }                                                 225 }
228                                                   226 
229 void SoDetectorTreeKit::clearAlternateRep() {     227 void SoDetectorTreeKit::clearAlternateRep() {
230   alternateRep.setValue(NULL);                    228   alternateRep.setValue(NULL);
231 }                                                 229 }
232 //////////////////////////////////////////////    230 //////////////////////////////////////////////////////////////////////////////
233 void SoDetectorTreeKit::doAction(                 231 void SoDetectorTreeKit::doAction(
234  SoAction* aAction                                232  SoAction* aAction
235 )                                                 233 )
236 //////////////////////////////////////////////    234 //////////////////////////////////////////////////////////////////////////////
237 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!    235 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
238 {                                                 236 {
239   SO_ALTERNATEREP_DO_ACTION(aAction)              237   SO_ALTERNATEREP_DO_ACTION(aAction)
240   SoBaseKit::doAction(aAction);                   238   SoBaseKit::doAction(aAction);
241 }                                                 239 }
                                                   >> 240 
                                                   >> 241 #endif
242                                                   242