37#ifdef G4VIS_BUILD_OI_DRIVER
42#include <Inventor/SoPickedPoint.h>
43#include <Inventor/nodes/SoSeparator.h>
44#include <Inventor/nodes/SoPickStyle.h>
45#include <Inventor/nodes/SoDrawStyle.h>
46#include <Inventor/nodes/SoSwitch.h>
47#include <Inventor/nodes/SoMaterial.h>
48#include <Inventor/nodes/SoUnits.h>
49#include <Inventor/nodes/SoTransform.h>
50#include <Inventor/nodes/SoEventCallback.h>
51#include <Inventor/nodekits/SoSeparatorKit.h>
52#include <Inventor/nodekits/SoShapeKit.h>
53#include <Inventor/nodekits/SoAppearanceKit.h>
54#include <Inventor/nodekits/SoNodeKitListPart.h>
55#include <Inventor/nodekits/SoBaseKit.h>
56#include <Inventor/nodes/SoTexture2Transform.h>
57#include <Inventor/events/SoMouseButtonEvent.h>
58#include <Inventor/actions/SoHandleEventAction.h>
69 static bool first =
true;
80 SO_NODE_ADD_FIELD(alternateRep, (NULL));
82 SO_KIT_ADD_CATALOG_ENTRY ( topSeparator, SoSeparator,
FALSE,
this,\0,
FALSE);
83 SO_KIT_ADD_CATALOG_ENTRY ( pickStyle, SoSeparator,
TRUE , topSeparator,\0,
TRUE);
84 SO_KIT_ADD_CATALOG_ENTRY ( appearance, SoAppearanceKit,
TRUE, topSeparator ,\0,
TRUE);
85 SO_KIT_ADD_CATALOG_ENTRY ( units, SoUnits,
TRUE, topSeparator ,\0,
TRUE);
86 SO_KIT_ADD_CATALOG_ENTRY ( transform, SoTransform,
TRUE , topSeparator,\0,
TRUE);
87 SO_KIT_ADD_CATALOG_ENTRY (texture2Transform, SoTexture2Transform,
TRUE, topSeparator ,\0,
TRUE);
88 SO_KIT_ADD_CATALOG_ENTRY ( childList, SoSwitch,
FALSE, topSeparator,\0,
FALSE);
89 SO_KIT_ADD_CATALOG_ENTRY ( previewSeparator, SoSeparator,
FALSE, childList,\0,
TRUE);
90 SO_KIT_ADD_CATALOG_ENTRY ( fullSeparator, SoSeparator,
FALSE, childList,\0,
TRUE);
92 SO_KIT_INIT_INSTANCE();
105void SoDetectorTreeKit::createInitialTree() {
107 SoEventCallback *myCallback =
new SoEventCallback();
108 myCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
109 SoDetectorTreeKit::expand,
111 myCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
112 SoDetectorTreeKit::contract ,
114 if(setPart(
"callbackList[0]",myCallback)==
FALSE) myCallback->unref();
116 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
117 theChildList->whichChild.setValue(0);
120void SoDetectorTreeKit::expand(
void *
userData, SoEventCallback *eventCB){
124 if (eventCB->isHandled())
return;
125 const SoMouseButtonEvent *
event= (SoMouseButtonEvent *) eventCB->getEvent();
126 if (!SoMouseButtonEvent::isButtonPressEvent(event,SoMouseButtonEvent::BUTTON1))
return;
127 if (!event->wasCtrlDown())
return;
128 if (event->wasShiftDown())
return;
135 SoHandleEventAction *handleEventAction = eventCB->getAction();
136 const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint();
137 if (!pickedPoint)
return;
139 SoFullPath* path = (SoFullPath*)pickedPoint->getPath();
140 SoNode *ancestorNode=NULL;
141 for (
int i=0;i<path->getLength();i++) {
142 ancestorNode = path->getNodeFromTail(i);
143 if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId()))
break;
145 if (This!=ancestorNode)
return;
150 eventCB->setHandled();
154void SoDetectorTreeKit::contract(
void *
userData, SoEventCallback *eventCB){
157 if (eventCB->isHandled())
return;
158 const SoMouseButtonEvent *
event= (SoMouseButtonEvent *) eventCB->getEvent();
159 if (!SoMouseButtonEvent::isButtonPressEvent(event,SoMouseButtonEvent::BUTTON1))
return;
160 if (event->wasCtrlDown())
return;
161 if (!event->wasShiftDown())
return;
167 SoHandleEventAction *handleEventAction = eventCB->getAction();
168 const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint();
169 if (!pickedPoint)
return;
173 SoFullPath* path = (SoFullPath*)pickedPoint->getPath();
174 SoNode *ancestorNode=NULL;
175 SbBool firstTreeFound=
FALSE;
176 for (
int i=0;i<path->getLength();i++) {
177 ancestorNode = path->getNodeFromTail(i);
178 if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId())) {
179 if (!firstTreeFound) {
180 if (This!=ancestorNode)
return;
186 eventCB->setHandled();
194 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
196 theChildList->whichChild.setValue(0);
199 theChildList->whichChild.setValue(1);
204 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
205 if (theChildList->whichChild.getValue()==0)
return TRUE;
211 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
212 theChildList->whichChild.setValue(SO_SWITCH_ALL);
216 return (SoSeparator *) previewSeparator.getValue();
220 return (SoSeparator *) fullSeparator.getValue();
242 SoBaseKit::doAction(aAction);
#define SO_ALTERNATEREP_DO_ACTION(aAction)
virtual SoSeparator * getPreviewSeparator() const
virtual SoSeparator * getFullSeparator() const
virtual ~SoDetectorTreeKit()
virtual SbBool getPreview() const
virtual SbBool affectsState() const
virtual void generateAlternateRep()
virtual void doAction(SoAction *)
virtual void clearAlternateRep()
virtual void setPreview(SbBool Flag)