38 #ifdef G4VIS_BUILD_OI_DRIVER
43 #include <Inventor/SoPickedPoint.h>
44 #include <Inventor/nodes/SoSeparator.h>
45 #include <Inventor/nodes/SoPickStyle.h>
46 #include <Inventor/nodes/SoDrawStyle.h>
47 #include <Inventor/nodes/SoSwitch.h>
48 #include <Inventor/nodes/SoMaterial.h>
49 #include <Inventor/nodes/SoUnits.h>
50 #include <Inventor/nodes/SoTransform.h>
51 #include <Inventor/nodes/SoEventCallback.h>
52 #include <Inventor/nodekits/SoSeparatorKit.h>
53 #include <Inventor/nodekits/SoShapeKit.h>
54 #include <Inventor/nodekits/SoAppearanceKit.h>
55 #include <Inventor/nodekits/SoNodeKitListPart.h>
56 #include <Inventor/nodekits/SoBaseKit.h>
57 #include <Inventor/nodes/SoTexture2Transform.h>
58 #include <Inventor/events/SoMouseButtonEvent.h>
59 #include <Inventor/actions/SoHandleEventAction.h>
79 SO_KIT_ADD_CATALOG_ENTRY ( topSeparator, SoSeparator,
FALSE,
this,\0,
FALSE);
80 SO_KIT_ADD_CATALOG_ENTRY ( pickStyle, SoSeparator,
TRUE , topSeparator,\0,
TRUE);
81 SO_KIT_ADD_CATALOG_ENTRY ( appearance, SoAppearanceKit,
TRUE, topSeparator ,\0,
TRUE);
82 SO_KIT_ADD_CATALOG_ENTRY ( units, SoUnits,
TRUE, topSeparator ,\0,
TRUE);
83 SO_KIT_ADD_CATALOG_ENTRY ( transform, SoTransform,
TRUE , topSeparator,\0,
TRUE);
84 SO_KIT_ADD_CATALOG_ENTRY (texture2Transform, SoTexture2Transform,
TRUE, topSeparator ,\0,
TRUE);
85 SO_KIT_ADD_CATALOG_ENTRY ( childList, SoSwitch,
FALSE, topSeparator,\0,
FALSE);
86 SO_KIT_ADD_CATALOG_ENTRY ( previewSeparator, SoSeparator,
FALSE, childList,\0,
TRUE);
87 SO_KIT_ADD_CATALOG_ENTRY ( fullSeparator, SoSeparator,
FALSE, childList,\0,
TRUE);
89 SO_KIT_INIT_INSTANCE();
102 void SoDetectorTreeKit::createInitialTree() {
104 SoEventCallback *myCallback =
new SoEventCallback();
105 myCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
106 SoDetectorTreeKit::expand,
108 myCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
109 SoDetectorTreeKit::contract ,
111 if(setPart(
"callbackList[0]",myCallback)==
FALSE) myCallback->unref();
113 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
114 theChildList->whichChild.setValue(0);
117 void SoDetectorTreeKit::expand(
void *
userData, SoEventCallback *eventCB){
121 if (eventCB->isHandled())
return;
122 const SoMouseButtonEvent *
event= (SoMouseButtonEvent *) eventCB->getEvent();
123 if (!SoMouseButtonEvent::isButtonPressEvent(event,SoMouseButtonEvent::BUTTON1))
return;
124 if (!event->wasCtrlDown())
return;
125 if (event->wasShiftDown())
return;
132 SoHandleEventAction *handleEventAction = eventCB->getAction();
133 const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint();
134 if (!pickedPoint)
return;
136 SoFullPath* path = (SoFullPath*)pickedPoint->getPath();
137 SoNode *ancestorNode=NULL;
138 for (
int i=0;i<path->getLength();i++) {
139 ancestorNode = path->getNodeFromTail(i);
140 if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId()))
break;
142 if (This!=ancestorNode)
return;
147 eventCB->setHandled();
151 void SoDetectorTreeKit::contract(
void *userData, SoEventCallback *eventCB){
154 if (eventCB->isHandled())
return;
155 const SoMouseButtonEvent *
event= (SoMouseButtonEvent *) eventCB->getEvent();
156 if (!SoMouseButtonEvent::isButtonPressEvent(event,SoMouseButtonEvent::BUTTON1))
return;
157 if (event->wasCtrlDown())
return;
158 if (!event->wasShiftDown())
return;
164 SoHandleEventAction *handleEventAction = eventCB->getAction();
165 const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint();
166 if (!pickedPoint)
return;
170 SoFullPath* path = (SoFullPath*)pickedPoint->getPath();
171 SoNode *ancestorNode=NULL;
172 SbBool firstTreeFound=
FALSE;
173 for (
int i=0;i<path->getLength();i++) {
174 ancestorNode = path->getNodeFromTail(i);
175 if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId())) {
176 if (!firstTreeFound) {
177 if (This!=ancestorNode)
return;
183 eventCB->setHandled();
191 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
193 theChildList->whichChild.setValue(0);
196 theChildList->whichChild.setValue(1);
201 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
202 if (theChildList->whichChild.getValue()==0)
return TRUE;
208 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
209 theChildList->whichChild.setValue(SO_SWITCH_ALL);
213 return (SoSeparator *) previewSeparator.getValue();
217 return (SoSeparator *) fullSeparator.getValue();
virtual void generateAlternateRep()
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData
#define SO_ALTERNATEREP_DO_ACTION(aAction)
virtual ~SoDetectorTreeKit()
virtual SoSeparator * getPreviewSeparator() const
virtual SbBool affectsState() const
virtual void doAction(SoAction *)
virtual SbBool getPreview() const
virtual SoSeparator * getFullSeparator() const
virtual void setPreview(SbBool Flag)
virtual void clearAlternateRep()