37#include <Inventor/nodes/SoNode.h>
38#include <Inventor/nodes/SoGroup.h>
39#include <Inventor/nodes/SoSwitch.h>
40#include <Inventor/nodekits/SoBaseKit.h>
41#include <Inventor/elements/SoSwitchElement.h>
46 static bool first =
true;
53 SO_ACTION_ADD_METHOD(SoNode,SoCounterAction::actionMethod);
57:fCount(0),fLookFor(NODE),fType(),fCheckDerived(
TRUE) {
63 SoAction::beginTraversal(node);
65void SoCounterAction::actionMethod(SoAction* aThis,SoNode* aNode) {
69 if(This->fLookFor==NODE) {
71 }
else if(This->fLookFor==
TYPE) {
72 if(This->fCheckDerived==
TRUE) {
73 if(aNode->getTypeId().isDerivedFrom(This->fType)) This->fCount++;
75 if(aNode->getTypeId()==This->fType) This->fCount++;
77 }
else if(This->fLookFor==
NAME) {
78 if(This->fName==aNode->getName()) This->fCount++;
80 if(aNode->isOfType(SoSwitch::getClassTypeId())) {
81 SoSwitch* sw = (SoSwitch*)aNode;
82 SbBool flag = sw->whichChild.enableNotify(
FALSE);
83 int old = sw->whichChild.getValue();
84 sw->whichChild.setValue(SO_SWITCH_ALL);
85 aNode->doAction(aThis);
86 sw->whichChild.setValue(old);
87 sw->whichChild.enableNotify(flag);
88 }
else if(aNode->isOfType(SoGroup::getClassTypeId())) {
89 aNode->doAction(aThis);
90 }
else if(aNode->isOfType(SoBaseKit::getClassTypeId())) {
91 aNode->doAction(aThis);
99 fCheckDerived = aCheckDerived;
virtual void beginTraversal(SoNode *)
virtual ~SoCounterAction()
void setType(const SoType, SbBool=TRUE)