40#include <Inventor/SoPickedPoint.h>
41#include <Inventor/nodes/SoSeparator.h>
42#include <Inventor/nodes/SoPickStyle.h>
43#include <Inventor/nodes/SoDrawStyle.h>
44#include <Inventor/nodes/SoSwitch.h>
45#include <Inventor/nodes/SoMaterial.h>
46#include <Inventor/nodes/SoUnits.h>
47#include <Inventor/nodes/SoTransform.h>
48#include <Inventor/nodes/SoEventCallback.h>
49#include <Inventor/nodekits/SoSeparatorKit.h>
50#include <Inventor/nodekits/SoShapeKit.h>
51#include <Inventor/nodekits/SoAppearanceKit.h>
52#include <Inventor/nodekits/SoNodeKitListPart.h>
53#include <Inventor/nodekits/SoBaseKit.h>
54#include <Inventor/nodes/SoTexture2Transform.h>
55#include <Inventor/events/SoMouseButtonEvent.h>
56#include <Inventor/actions/SoHandleEventAction.h>
67 static bool first =
true;
80 SO_KIT_ADD_CATALOG_ENTRY ( topSeparator, SoSeparator,
FALSE,
this,\0,
FALSE);
81 SO_KIT_ADD_CATALOG_ENTRY ( pickStyle, SoSeparator,
TRUE , topSeparator,\0,
TRUE);
82 SO_KIT_ADD_CATALOG_ENTRY ( appearance, SoAppearanceKit,
TRUE, topSeparator ,\0,
TRUE);
83 SO_KIT_ADD_CATALOG_ENTRY ( units, SoUnits,
TRUE, topSeparator ,\0,
TRUE);
84 SO_KIT_ADD_CATALOG_ENTRY ( transform, SoTransform,
TRUE , topSeparator,\0,
TRUE);
85 SO_KIT_ADD_CATALOG_ENTRY (texture2Transform, SoTexture2Transform,
TRUE, topSeparator ,\0,
TRUE);
86 SO_KIT_ADD_CATALOG_ENTRY ( childList, SoSwitch,
FALSE, topSeparator,\0,
FALSE);
87 SO_KIT_ADD_CATALOG_ENTRY ( previewSeparator, SoSeparator,
FALSE, childList,\0,
TRUE);
88 SO_KIT_ADD_CATALOG_ENTRY ( fullSeparator, SoSeparator,
FALSE, childList,\0,
TRUE);
90 SO_KIT_INIT_INSTANCE();
103void SoDetectorTreeKit::createInitialTree() {
105 SoEventCallback *myCallback =
new SoEventCallback();
106 myCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
107 SoDetectorTreeKit::expand,
109 myCallback->addEventCallback(SoMouseButtonEvent::getClassTypeId(),
110 SoDetectorTreeKit::contract ,
112 if(setPart(
"callbackList[0]",myCallback)==
FALSE) myCallback->unref();
114 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
115 theChildList->whichChild.setValue(0);
118void SoDetectorTreeKit::expand(
void *userData, SoEventCallback *eventCB){
122 if (eventCB->isHandled())
return;
123 const SoMouseButtonEvent *
event= (SoMouseButtonEvent *) eventCB->getEvent();
124 if (!SoMouseButtonEvent::isButtonPressEvent(event,SoMouseButtonEvent::BUTTON1))
return;
125 if (!event->wasCtrlDown())
return;
126 if (event->wasShiftDown())
return;
133 SoHandleEventAction *handleEventAction = eventCB->getAction();
134 const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint();
135 if (!pickedPoint)
return;
137 SoFullPath* path = (SoFullPath*)pickedPoint->getPath();
138 SoNode *ancestorNode=NULL;
139 for (
int i=0;i<path->getLength();i++) {
140 ancestorNode = path->getNodeFromTail(i);
141 if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId()))
break;
143 if (This!=ancestorNode)
return;
148 eventCB->setHandled();
152void SoDetectorTreeKit::contract(
void *userData, SoEventCallback *eventCB){
155 if (eventCB->isHandled())
return;
156 const SoMouseButtonEvent *
event= (SoMouseButtonEvent *) eventCB->getEvent();
157 if (!SoMouseButtonEvent::isButtonPressEvent(event,SoMouseButtonEvent::BUTTON1))
return;
158 if (event->wasCtrlDown())
return;
159 if (!event->wasShiftDown())
return;
165 SoHandleEventAction *handleEventAction = eventCB->getAction();
166 const SoPickedPoint *pickedPoint = handleEventAction->getPickedPoint();
167 if (!pickedPoint)
return;
171 SoFullPath* path = (SoFullPath*)pickedPoint->getPath();
172 SoNode *ancestorNode=NULL;
173 SbBool firstTreeFound=
FALSE;
174 for (
int i=0;i<path->getLength();i++) {
175 ancestorNode = path->getNodeFromTail(i);
176 if (ancestorNode->isOfType(SoDetectorTreeKit::getClassTypeId())) {
177 if (!firstTreeFound) {
178 if (This!=ancestorNode)
return;
184 eventCB->setHandled();
192 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
194 theChildList->whichChild.setValue(0);
197 theChildList->whichChild.setValue(1);
202 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
203 if (theChildList->whichChild.getValue()==0)
return TRUE;
209 SoSwitch *theChildList = (SoSwitch *) childList.getValue();
210 theChildList->whichChild.setValue(SO_SWITCH_ALL);
214 return (SoSeparator *) previewSeparator.getValue();
218 return (SoSeparator *) fullSeparator.getValue();
240 SoBaseKit::doAction(aAction);
#define SO_ALTERNATEREP_DO_ACTION(aAction)
virtual ~SoDetectorTreeKit()
virtual void doAction(SoAction *)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
virtual void clearAlternateRep()
virtual void generateAlternateRep()
virtual void setPreview(SbBool Flag)
virtual SoSeparator * getPreviewSeparator() const
virtual SbBool getPreview() const
virtual SoSeparator * getFullSeparator() const
virtual SbBool affectsState() const