void SoFCCSysDragger::finishDragCB(void *data, SoDragger *) { SoFCCSysDragger *sudoThis = reinterpret_cast<SoFCCSysDragger *>(data); // note: when creating a second view of the document and then closing // the first viewer it deletes the camera. However, the attached field // of the cameraSensor will be detached automatically. SoField* field = sudoThis->cameraSensor.getAttachedField(); if (field) { SoCamera* camera = static_cast<SoCamera*>(field->getContainer()); if (camera->getTypeId() == SoPerspectiveCamera::getClassTypeId()) cameraCB(sudoThis, nullptr); } }
int main(void) { SoDB::init(); SoNodeKit::init(); SoInteraction::init(); SoTypeList tl; const unsigned int n = SoType::getAllDerivedFrom(SoNode::getClassTypeId(), tl); for (unsigned int i=0; i < n; i++) { (void)fprintf(stdout, "%s", tl[i].getName().getString()); SoFieldContainer * fc = (SoFieldContainer *) (tl[i].canCreateInstance() ? tl[i].createInstance() : NULL); if (fc == NULL) { (void)fprintf(stdout, " (abstract)\n"); continue; } (void)fprintf(stdout, "\n"); SoFieldList fl; const unsigned int nrf = fc->getAllFields(fl); for (unsigned int j=0; j < nrf; j++) { SoField * f = fl[j]; SoType ftype = f->getTypeId(); SbName fname; f->getContainer()->getFieldName(f, fname); (void)fprintf(stdout, " %s (%s)\n", fname.getString(), ftype.getName().getString()); if (ftype.isDerivedFrom(SoSFEnum::getClassTypeId())) { list_enums((SoSFEnum *)f); } else if (ftype.isDerivedFrom(SoMFEnum::getClassTypeId())) { list_enums((SoMFEnum *)f); } } } return 0; }
void SoFCCSysDragger::idleCB(void *data, SoSensor *) { SoFCCSysDragger *sudoThis = reinterpret_cast<SoFCCSysDragger *>(data); SoField* field = sudoThis->cameraSensor.getAttachedField(); if (field) { SoCamera* camera = static_cast<SoCamera*>(field->getContainer()); SbMatrix localToWorld = sudoThis->getLocalToWorldMatrix(); SbVec3f origin; localToWorld.multVecMatrix(SbVec3f(0.0, 0.0, 0.0), origin); SbViewVolume viewVolume = camera->getViewVolume(); float radius = sudoThis->draggerSize.getValue() / 2.0; float localScale = viewVolume.getWorldToScreenScale(origin, radius); SbVec3f scaleVector(localScale, localScale, localScale); SoScale *localScaleNode = SO_GET_ANY_PART(sudoThis, "scaleNode", SoScale); localScaleNode->scaleFactor.setValue(scaleVector); sudoThis->autoScaleResult.setValue(localScale); } }