#include <OnXSvc/Win32.h>
#include "SoDetConverter.h"
#include <Inventor/SbColor.h>
#include <Inventor/SoPickedPoint.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoTransform.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoLightModel.h>
#include <Inventor/nodes/SoEventCallback.h>
#include <Inventor/events/SoMouseButtonEvent.h>
#include <HEPVis/SbMath.h>
#include <HEPVis/SbPolyhedron.h>
#include <HEPVis/misc/SoStyleCache.h>
#include <HEPVis/nodes/SoPolyhedron.h>
#include <HEPVis/nodekits/SoDetectorTreeKit.h>
#include <Lib/smanip.h>
#include <Lib/Interfaces/ISession.h>
#include <GaudiKernel/Transform3DTypes.h>
#include <OnXSvc/ISoConversionSvc.h>
#include <OnXSvc/IUserInterfaceSvc.h>
#include <OnXSvc/ClassID.h>
#include <GaudiKernel/MsgStream.h>
#include <GaudiKernel/ISvcLocator.h>
#include <DetDesc/Material.h>
#include <DetDesc/ILVolume.h>
#include <DetDesc/IPVolume.h>
#include <DetDesc/ISolid.h>
#include <DetDesc/Solids.h>
#include <VisSvc/IVisualizationSvc.h>
Include dependency graph for SoDetConverter.cpp:
Go to the source code of this file.
Classes | |
class | SoDetTreeKit |
Defines | |
#define | None (-1) |
Functions | |
void | expand (void *userData, SoEventCallback *eventCB) |
void | contract (void *userData, SoEventCallback *eventCB) |
#define None (-1) |
Definition at line 72 of file SoDetConverter.cpp.
void expand | ( | void * | userData, | |
SoEventCallback * | eventCB | |||
) |
Definition at line 822 of file SoDetConverter.cpp.
00822 { 00823 if (eventCB->isHandled()) return; 00824 00825 const SoMouseButtonEvent* event = (SoMouseButtonEvent*)eventCB->getEvent(); 00826 // SO_MOUSE_PRESS_EVENT clashes with SoDragger controls : 00827 if (!SO_MOUSE_RELEASE_EVENT(event,BUTTON1)) return; 00828 if (!event->wasCtrlDown()) return; 00829 if (event->wasShiftDown()) return; 00830 00831 SoHandleEventAction* handleEventAction = eventCB->getAction(); 00832 const SoPickedPoint* pickedPoint = handleEventAction->getPickedPoint(); 00833 if (!pickedPoint) return; 00834 SoFullPath* path = (SoFullPath*)pickedPoint->getPath(); 00835 SoNode* ancestorNode = NULL; 00836 for (int i=0;i<path->getLength();i++) { 00837 ancestorNode = path->getNodeFromTail(i); 00838 if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId())) break; 00839 } 00840 00841 SoDetTreeKit* This = (SoDetTreeKit*)userData; 00842 00843 if(This!=ancestorNode) return; 00844 00845 SoDetConverter* soConverter = This->soConverter(); 00846 const ILVolume& volume = This->lvolume(); 00847 00848 /* 00849 if (event->wasShiftDown()) { 00850 // Ctrl + Shift : dump picked volume name : 00851 (*soConverter->out()) 00852 << MSG::INFO 00853 << " LVolume : " << volume.name() 00854 << endreq; 00855 const ISolid* solid = volume.solid(); 00856 if(solid) 00857 (*soConverter->out()) 00858 << MSG::INFO 00859 << solid 00860 << endreq; 00861 else 00862 (*soConverter->out()) 00863 << MSG::INFO 00864 << " no solid associated." 00865 << endreq; 00866 return; 00867 } 00868 */ 00869 00870 (*soConverter->out()) << MSG::DEBUG << 00871 " expand : dtk expanded ? " << This->expanded() << endreq; 00872 00873 if(This->expanded()) { 00874 This->setPreview(FALSE); 00875 } else { 00876 // Detector expansion logic : 00877 This->setExpanded(true); 00878 SoSeparator* fullSeparator = 00879 (SoSeparator*)This->getPart("fullSeparator",TRUE); 00880 SbBool preview = TRUE; 00881 int childn = volume.noPVolumes(); 00882 for(int count=0;count<childn;count++) { 00883 const IPVolume* pvolume = volume[count]; 00884 if (!pvolume) { 00885 (*soConverter->out()) 00886 << MSG::ERROR << "found a null pvolume in " << volume.name() 00887 << " at index " << count 00888 << ". Check the name of the logical volume associated to it" 00889 << endreq; 00890 } else { 00891 if(!pvolume->lvolume()) { 00892 (*soConverter->out()) 00893 << MSG::ERROR << "pvolume with a null lvolume." << endreq; 00894 } else { 00895 SoNode* node = soConverter->volumeToSoDetectorTreeKit 00896 (*(pvolume->lvolume()),pvolume->matrix()); 00897 if (node) { 00898 (*soConverter->out()) << MSG::DEBUG << 00899 " expand, add a node." << endreq; 00900 fullSeparator->addChild(node); 00901 preview = FALSE; 00902 } 00903 } 00904 } 00905 } 00906 This->setPreview(preview); 00907 } 00908 eventCB->setHandled(); 00909 }
void contract | ( | void * | userData, | |
SoEventCallback * | eventCB | |||
) |
Definition at line 911 of file SoDetConverter.cpp.
00911 { 00912 00913 // Was the event previously handled? Is it the right kind? 00914 if (eventCB->isHandled()) return; 00915 00916 const SoMouseButtonEvent* event = (SoMouseButtonEvent*)eventCB->getEvent(); 00917 // SO_MOUSE_PRESS_EVENT clashes with SoDragger controls : 00918 if (!SO_MOUSE_RELEASE_EVENT(event,BUTTON1)) return; 00919 if(event->wasCtrlDown()) return; 00920 if(!event->wasShiftDown()) return; 00921 00922 // Find out whether that's the one that has been picked 00923 SoHandleEventAction *handleEventAction = eventCB->getAction(); 00924 const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint(); 00925 if (!pickedPoint) return; 00926 00927 // Which detector is this being called for 00928 SoDetTreeKit* This = (SoDetTreeKit*)userData; 00929 SoDetConverter* soConverter = This->soConverter(); 00930 00931 // Find out whether that's the one that has been picked. 00932 // "This" is the lowest detector tree kit in the hierarchy. 00933 SoFullPath* path = (SoFullPath*)pickedPoint->getPath(); 00934 SoNode* ancestorNode = NULL; 00935 SbBool firstTreeFound = FALSE; 00936 for (int i=0;i<path->getLength();i++) { 00937 ancestorNode = path->getNodeFromTail(i); 00938 if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId())) { 00939 if (!firstTreeFound) { 00940 if (This!=ancestorNode) return; 00941 firstTreeFound=TRUE; 00942 } 00943 SoDetTreeKit* That = (SoDetTreeKit*)ancestorNode; 00944 if (!That->getPreview()) { 00945 // Have to contract : 00946 SoSeparator* previewSep = 00947 (SoSeparator*)That->getPart("previewSeparator",TRUE); 00948 if(previewSep->getNumChildren()) { 00949 // To optimize memory, delete "full" children 00950 // (that will be not seen) : 00951 SoSeparator* fullSeparator = 00952 (SoSeparator*)That->getPart("fullSeparator",TRUE); 00953 fullSeparator->removeAllChildren(); 00954 That->setExpanded(false); 00955 (*soConverter->out()) << MSG::DEBUG << 00956 " contract & delete. " << endreq; 00957 That->setPreview(TRUE); 00958 eventCB->setHandled(); 00959 return; 00960 } 00961 } 00962 } 00963 } 00964 }