// add a name to the upgrader lookup dict. static void soupgrader_add_to_namedict(const SbString & name) { assert(soupgrader_namedict); // Note: the SbString->SbName wrapping is necessary, or the const // char* will _not_ be valid upon the SbString going out of scope // (while SbName makes permanent const char* references). soupgrader_namedict->put(SbName(name.getString()).getString(), NULL); // Create lookup both with and without the "So" prefix. This is // necessary for the hash lookup in soupgrader_exists() to match // with both permutations. SbString tmp; if (name.compareSubString("So") == 0) { tmp = name.getSubString(2); } else { tmp = "So"; tmp += name; } // Note: the SbString->SbName wrapping is necessary, see above // comment. soupgrader_namedict->put(SbName(tmp.getString()).getString(), NULL); }
void SoXipDicomExaminer::GLRender( SoGLRenderAction* action ) { if (mViewAll) { SoXipDataImage* xipImage = ((SoXipSFDataImage *)mImage->getField(SbName("image")))->getValue(); if( !xipImage ) return ; SbXipImage* image = xipImage->get(); if( image ) adjustCamera( action, image->getModelMatrix() ); // Store the information of the current displayed image mImageModelMatrix = image->getModelMatrix(); mViewAll = FALSE; } if( mViewBoundingBox ) { adjustCamera( action, boundingBox.getValue() ); mViewBoundingBox = false; } // Set the Dicom Element setElement( action ); mImageSwitch->enableNotify( FALSE ); ((SoSFInt32 *)mImageSwitch->getField(SbName("whichChild")))->setValue( drawImage.getValue() ? 0 : -1 ); mImageSwitch->enableNotify( TRUE ); SoXipKit::GLRender( action ); }
void SoXipDicomExaminer::updateCamera() { SoXipDataImage* xipImage = ((SoXipSFDataImage *)mImage->getField(SbName("image")))->getValue(); if( !xipImage ) return ; SbXipImage* image = xipImage->get(); if( image ) { SbVec3f newImagePos = image->getModelMatrix()[3]; SbVec3f oldImagePos = mImageModelMatrix[3]; SbVec3f cameraTranslation = (newImagePos - oldImagePos); getCamera()->position.setValue( getCamera()->position.getValue() + cameraTranslation ); mImageModelMatrix = image->getModelMatrix(); SbVec3f t, s, normal; SbRotation r, so; mImageModelMatrix.getTransform(t, r, s, so); normal = SbVec3f(mImageModelMatrix[2][0], mImageModelMatrix[2][1], mImageModelMatrix[2][2]); normal.normalize(); SbPlane plane ( normal, t ); planeSlice.setValue ( plane ) ; } }
// Documented in superclass. Overridden to pass GL state to the // previous element. void SoGLMultiTextureImageElement::pop(SoState * state, const SoElement * prevTopElement) { inherited::pop(state, prevTopElement); SoGLMultiTextureImageElement * prev = (SoGLMultiTextureImageElement*) prevTopElement; SoGLShaderProgram * prog = SoGLShaderProgramElement::get(state); SbString str; const int maxunits = SbMax(PRIVATE(prev)->unitdata.getLength(), PRIVATE(this)->unitdata.getLength()); for (int i = 0; i < maxunits; i++) { const GLUnitData & prevud = (i < PRIVATE(prev)->unitdata.getLength()) ? PRIVATE(prev)->unitdata[i] : PRIVATE(prev)->defaultdata; const GLUnitData & thisud = (i < PRIVATE(this)->unitdata.getLength()) ? PRIVATE(this)->unitdata[i] : PRIVATE(this)->defaultdata; if (thisud.glimage != prevud.glimage) this->updateGL(i); str.sprintf("coin_texunit%d_model", i); if (prog) prog->updateCoinParameter(state, SbName(str.getString()), thisud.glimage != NULL ? this->getUnitData(i).model : 0); } }
void SoMFName::setValue(const char *string) // //////////////////////////////////////////////////////////////////////// { setValue(SbName(string)); }
/*! Creates an instance of a suitable SoForeignFileKit subtype. Returns NULL on failure or a kit with refcount of 1 on success. */ static SoForeignFileKit *create_foreignfilekit(const char *filename, SbBool exhaust) { assert(SoForeignFileKitP::fileexts != NULL); const char * extptr = strrchr(filename, '.'); if (extptr) { extptr++; SbName ext(SbString(extptr).lower()); SoType handler = SoType::badType(); if (SoForeignFileKitP::fileexts->get(ext.getString(), handler)) { SoForeignFileKit * foreignfile = (SoForeignFileKit *)handler.createInstance(); foreignfile->ref(); if (foreignfile->canReadFile(filename)) { return foreignfile; } else { foreignfile->unref(); } } else { // We try to synthesize a classname from the extension (e.g. SoFBXFileKit), // and load it using the SoType autoloader feature. SbString filekitname; filekitname.sprintf("So%sFileKit", SbString(ext.getString()).upper().getString()); SoType filekittype = SoType::fromName(SbName(filekitname)); if (!filekittype.isBad()) return create_foreignfilekit(filename, exhaust); // FIXME: Some filekits supports more than one file format/extension (e.g. FBX). // We need a way of mapping extensions to library, or a way of loading // each external kit and testing for support. // FIXME: Temporary hack: Load SoFBXFileKit filekitname = "SoFBXFileKit"; filekittype = SoType::fromName(SbName(filekitname)); if (!filekittype.isBad()) return create_foreignfilekit(filename, exhaust); } } if (exhaust) { // FIXME: Implement // SoForeignFileKitP::fileexts->apply() } return NULL; }
/*! \COININTERNAL */ void SoGLCubeMapImage::initClass(void) { assert(SoGLCubeMapImageP::classTypeId.isBad()); SoGLCubeMapImageP::classTypeId = SoType::createType(SoGLImage::getClassTypeId(), SbName("GLCubeMapImage")); #ifdef COIN_THREADSAFE SoGLCubeMapImageP::mutex = new SbMutex; #endif // COIN_THREADSAFE coin_atexit((coin_atexit_f*)SoGLCubeMapImage::cleanupClass, CC_ATEXIT_NORMAL); }
/*! Sets the current texture. Id \a didapply is TRUE, it is assumed that the texture image already is the current GL texture. Do not use this feature unless you know what you're doing. */ void SoGLMultiTextureImageElement::set(SoState * const state, SoNode * const node, const int unit, SoGLImage * image, Model model, const SbColor & blendColor) { SoGLMultiTextureImageElement * elem = (SoGLMultiTextureImageElement*) state->getElement(classStackIndex); PRIVATE(elem)->ensureCapacity(unit); GLUnitData & ud = PRIVATE(elem)->unitdata[unit]; // FIXME: buggy. Find some solution to handle this. pederb, 2003-11-12 // if (ud.glimage && ud.glimage->getImage()) ud.glimage->getImage()->readUnlock(); if (image) { // keep SoMultiTextureImageElement "up-to-date" inherited::set(state, node, unit, SbVec3s(0,0,0), 0, NULL, multi_translateWrap(image->getWrapS()), multi_translateWrap(image->getWrapT()), multi_translateWrap(image->getWrapR()), model, blendColor); ud.glimage = image; // make sure image isn't changed while this is the active texture // FIXME: buggy. Find some solution to handle this. pederb, 2003-11-12 // if (image->getImage()) image->getImage()->readLock(); } else { ud.glimage = NULL; inherited::setDefault(state, node, unit); } elem->updateGL(unit); // FIXME: check if it's possible to support for other units as well if ((unit == 0) && image && image->isOfType(SoGLBigImage::getClassTypeId())) { SoShapeStyleElement::setBigImageEnabled(state, TRUE); } SoShapeStyleElement::setTransparentTexture(state, SoGLMultiTextureImageElement::hasTransparency(state)); SoGLShaderProgram * prog = SoGLShaderProgramElement::get(state); if (prog) { SbString str; str.sprintf("coin_texunit%d_model", unit); prog->updateCoinParameter(state, SbName(str.getString()), ud.glimage ? model : 0); } }
void QCtkXipSGWidget::initializeGL() { QGLWidget::initializeGL(); // init inventor if(!SoDB::isInitialized()) SoDB::init(); mRoot = new SoSeparator; // SoDB::createGlobalField("realTime", SoSFTime::getClassTypeId()); mSceneManager = new SoSceneManager; mSceneManager->setRenderCallback(renderSceneCBFunc, this); mSceneManager->setBackgroundColor(SbColor(0.0, 0.0, 0.0)); mSceneManager->getGLRenderAction()->setTransparencyType(SoGLRenderAction::DELAYED_BLEND); mSceneManager->setSceneGraph(mRoot); mSceneManager->activate(); mIsSceneManagerActive = true; mInteractingField = (SoSFInt32*) SoDB::getGlobalField(SbName("XipInteracting")); if(!mInteractingField) { mInteractingField = (SoSFInt32*) SoDB::createGlobalField(SbName("XipInteracting"), SoSFInt32::getClassTypeId()); mInteractingField->setValue(0); } glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_BLEND); }
SoRefXipMprExaminer::SoRefXipMprExaminer(QString nodeName) { fldOrientation = 0; triViewOrientation = 0; triViewAll = 0; SoNode* fldContainer = SoNode::getByName(SbName(nodeName.toAscii())); if (fldContainer) { CONNECTFIELD(fldContainer, "orientation", fldOrientation, SoSFEnum); CONNECTFIELD(fldContainer, "viewOrientation", triViewOrientation, SoSFTrigger); CONNECTFIELD(fldContainer, "viewAll", triViewAll, SoSFTrigger); } }
SoRefXipLut::SoRefXipLut(QString nodeName) { fldColorTop = 0; fldColorMiddle = 0; fldColorBottom = 0; SoNode* fldContainer = SoNode::getByName(SbName(nodeName.toAscii())); if (fldContainer) { CONNECTFIELD(fldContainer, "colorBottom", fldColorBottom, SoSFColor); CONNECTFIELD(fldContainer, "colorMiddle", fldColorMiddle, SoSFColor); CONNECTFIELD(fldContainer, "colorTop", fldColorTop, SoSFColor); CONNECTFIELD(fldContainer, "rampWidth", fldRampWidth, SoSFFloat); CONNECTFIELD(fldContainer, "rampCenter", fldRampCenter, SoSFFloat); } }
void QCtkXipSGWidget::updateCursor(bool fromScene) { if (fromScene) { if (!mCursorField) { mCursorField = SoDB::getGlobalField(SbName("MouseCursor")); } if (mCursorField) { SbString str; mCursorField->get(str); const char *handlePtr = strstr(str.getString(), "handle\t"); if (handlePtr) { void *handle = 0; if (sscanf(handlePtr, "handle\t%p", &handle) == 1) { if (handle) { #ifdef WIN32 setCursor(QCursor((HCURSOR) handle)); #endif /* WIN32 */ #ifdef linux setCursor(QCursor((Qt::HANDLE) handle)); #endif /* LINUX */ #ifdef DARWIN setCursor(QCursor()); // FIXME: We must create a handle for Mac OS X #endif /* DARWIN */ return; } } } } } setCursor(Qt::ArrowCursor); }
/** * Takes the name of the selected node and sets to de editor to display it. */ void NodeNameDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { const SceneModel* model = static_cast< const SceneModel* >( index.model() ); QString value = model->data(index, Qt::DisplayRole).toString(); QLineEdit *textEdit = static_cast<QLineEdit *>(editor); SoNode* coinNode = model->NodeFromIndex( index )->GetNode(); QString nodeName; if ( coinNode->getName() == SbName() ) nodeName = QString( coinNode->getTypeId().getName().getString() ); else nodeName = QString( coinNode->getName().getString() ); textEdit->setText( nodeName ); }
/*! Try creating a node of name \a name with Inventor version \a ivversion. Returns NULL if no such node exists. */ SoBase * SoUpgrader::tryCreateNode(const SbName & name, const float ivversion) { if ((ivversion == 1.0f) || (ivversion == 2.0f)) { soupgrader_init_classes(); SbString s(name.getString()); s += (ivversion == 1.0f) ? "V10" : "V20"; if (soupgrader_exists(s.getString())) { SoType type = SoType::fromName(SbName(s.getString())); if (type.canCreateInstance()) { SoBase * b = (SoBase*) type.createInstance(); if (SoInputP::debug()) { SoDebugError::postInfo("SoUpgrader::tryCreateNode", "name=='%s', ivversion==%f => SoBase==%p", name.getString(), ivversion, b); } return b; } } } return NULL; }
void ComponentHeliostatField::CreateHeliostatZones( std::vector< Point3D > heliostatCenterList, TSeparatorKit* parentNode, TTrackerFactory* heliostatTrackerFactory, Point3D aimingPoint, TSeparatorKit* heliostatComponentNode, int eje ) { SoType separatorType = SoType::fromName( SbName ( "TSeparatorKit" ) ); SoNodeKitListPart* heliostatsNodePartList = static_cast< SoNodeKitListPart* >( parentNode->getPart( "childList", true ) ); if( !heliostatsNodePartList ) return; int nHeliostatCenters = ( int ) heliostatCenterList.size(); if( nHeliostatCenters < 8 ) { for( int nHeliostat = 0; nHeliostat < nHeliostatCenters; nHeliostat++ ) { //TSeparatorKit* heliostatSeparator = new TSeparatorKit; TSeparatorKit* heliostatSeparator = static_cast< TSeparatorKit* > ( separatorType.createInstance() ); heliostatsNodePartList->addChild(heliostatSeparator); QString heliostatName = QString( QLatin1String( "Heliostat%1" ) ).arg( QString::number( nHeliostat ) ); heliostatSeparator->setName( heliostatName.toStdString().c_str() ); SoTransform* nodeTransform = dynamic_cast< SoTransform* >( heliostatSeparator->getPart( "transform", true ) ); nodeTransform->translation.setValue( heliostatCenterList[nHeliostat].x, heliostatCenterList[nHeliostat].y, heliostatCenterList[nHeliostat].z ); SoNodeKitListPart* heliostatPartList = static_cast< SoNodeKitListPart* >( heliostatSeparator->getPart( "childList", true ) ); if( !heliostatPartList ) return; //TSeparatorKit* heliostatTrackerNode= new TSeparatorKit; TSeparatorKit* heliostatTrackerNode = static_cast< TSeparatorKit* > ( separatorType.createInstance() ); heliostatPartList->addChild( heliostatTrackerNode ); heliostatTrackerNode->setName( "HeliostatTrackerNode" ); SoNodeKitListPart* heliostaTrackerNodetPartList = static_cast< SoNodeKitListPart* >( heliostatTrackerNode->getPart( "childList", true ) ); if( !heliostaTrackerNodetPartList ) return; TTracker* tracker = heliostatTrackerFactory->CreateTTracker(); heliostatTrackerNode->setPart( "tracker", tracker ); SoSFVec3f* aimingPointField = dynamic_cast< SoSFVec3f* > ( tracker->getField ( "aimingPoint" ) ); if( aimingPointField ) aimingPointField->setValue( SbVec3f( aimingPoint.x, aimingPoint.y, aimingPoint.z ) ); if( heliostatComponentNode ) heliostaTrackerNodetPartList->addChild( heliostatComponentNode ); } } else { //TSeparatorKit* heliostatSeparator1 = new TSeparatorKit; TSeparatorKit* heliostatSeparator1 = static_cast< TSeparatorKit* > ( separatorType.createInstance() ); heliostatsNodePartList->addChild(heliostatSeparator1); QString heliostatName1 = QString( QLatin1String( "DivisionPor%1_1" ) ).arg( ( eje == 3 )? QString( 'Z' ): QString( 'X' ) ); heliostatSeparator1->setName( heliostatName1.toStdString().c_str() ); //TSeparatorKit* heliostatSeparator2 = new TSeparatorKit; TSeparatorKit* heliostatSeparator2 = static_cast< TSeparatorKit* > ( separatorType.createInstance() ); heliostatsNodePartList->addChild(heliostatSeparator2); QString heliostatName2 = QString( QLatin1String( "DivisionPor%1_2" ) ).arg( ( eje == 3 )? QString( 'Z' ): QString( 'X' ) ); heliostatSeparator2->setName( heliostatName2.toStdString().c_str() ); if( fabs( eje - 3 ) < 0.001 ) { std::sort( heliostatCenterList.begin(), heliostatCenterList.end(), comparePuntosPorZ ); std::vector< Point3D >::iterator it; double zMin = heliostatCenterList[0].z; double zMax = heliostatCenterList[nHeliostatCenters-1].z; double splitPoint = zMin + ( 0.5 * ( zMax - zMin ) ); std::vector< Point3D > hCenterListPart1; double position = 0; while( ( position < heliostatCenterList.size() ) && ( heliostatCenterList[position].z < splitPoint ) ) { hCenterListPart1.push_back( heliostatCenterList[position] ); position++; } std::vector< Point3D > hCenterListPart2; while( position < heliostatCenterList.size() ) { hCenterListPart2.push_back( heliostatCenterList[position] ); position++; } CreateHeliostatZones( hCenterListPart1, heliostatSeparator1, heliostatTrackerFactory, aimingPoint, heliostatComponentNode, 1 ); CreateHeliostatZones( hCenterListPart2, heliostatSeparator2, heliostatTrackerFactory, aimingPoint, heliostatComponentNode, 1 ); } else { std::sort( heliostatCenterList.begin(), heliostatCenterList.end(), comparePuntosPorX ); double xMin = heliostatCenterList[0].x; double xMax = heliostatCenterList[nHeliostatCenters-1].x; double splitPoint = xMin + ( 0.5 * ( xMax - xMin ) ); std::vector< Point3D > hCenterListPart1; double position = 0; while( ( position < heliostatCenterList.size() ) && ( heliostatCenterList[position].x < splitPoint ) ) { hCenterListPart1.push_back( heliostatCenterList[position] ); position++; } std::vector< Point3D > hCenterListPart2; while( position < heliostatCenterList.size() ) { hCenterListPart2.push_back( heliostatCenterList[position] ); position++; } CreateHeliostatZones( hCenterListPart1, heliostatSeparator1, heliostatTrackerFactory, aimingPoint, heliostatComponentNode, 3 ); CreateHeliostatZones( hCenterListPart2, heliostatSeparator2, heliostatTrackerFactory, aimingPoint, heliostatComponentNode, 3 ); } } }
void SoXipDicomExaminer::setElement( SoAction* action ) { int numImages = images.getNum(); int currentImage = imageIndex.getValue(); if( numImages && currentImage >= 0 && currentImage < numImages ) { SoXipDataDicom* dicomData = images[ currentImage ]; int currentSlice = sliceIndex.getValue(); SoXipDataDicomElement::set( action->getState(), dicomData, currentSlice ); SoXipDataImageElement::set( action->getState(), ((SoXipSFDataImage *)mImage->getField(SbName("image")))->getValue() ); } }
void QCtkXipSGWidget::paintGL() { static bool testHack = true; if(testHack) { QStringList test; test.append("xipivcored.dll"); test.append("xipivcoregld.dll"); test.append("xipivdicomd.dll"); test.append("xipivoverlayd.dll"); test.append("xipivrendererd.dll"); test.append("xipivextrad.dll"); loadIVExtensions(test); loadIvFile("../vtkIvPropProject/simpleXIP/TestSceneGraph_Opaque_Transparent_Annotations.iv"); // loadIvFile("scenegraphs/cone.iv"); testHack = false; SoMFUInt32 *swapBuffersInfo = (SoMFUInt32 *) SoDB::getGlobalField("SwapBuffersInfo"); if(swapBuffersInfo) swapBuffersInfo = (SoMFUInt32 *) SoDB::createGlobalField(SbName("SwapBuffersInfo"), SoMFUInt32::getClassTypeId()); } processDelayQueue(); #ifdef WIN32 // FIXME: Make it work on Unix quint64 countAfterSwap; #endif /* WIN32 */ SbXipPerformanceTimer timer; renderScene(mSceneManager); float timeOfRenderPass = timer.elapsed() / 1000.0f; SbXipPerformanceTimer swapTime; swapBuffers(); gTimings[1] = swapTime.elapsed(); // swap time #ifdef WIN32 // FIXME: Make it work on Unix // Measure perf counter right after swap QueryPerformanceCounter((LARGE_INTEGER*) &countAfterSwap); #endif /* WIN32 */ float timeSinceLastRenderPass = mTimeSinceLastRenderPass.elapsed() / 1000.0f; mTimeSinceLastRenderPass.reset(); char tmp[100]; if (timeSinceLastRenderPass < (timeOfRenderPass + 100)) { // continues updates, print both current render time and time since last update int freq = 1000 / timeSinceLastRenderPass; sprintf(tmp, timeOfRenderPass >= 100 ? "%dx%d, %0.f ms, %d Hz" : "%dx%d, %0.1f ms, %d Hz", width(), height(), timeOfRenderPass, freq); } else { // only print current render time sprintf(tmp, timeOfRenderPass >= 100 ? "%dx%d, %0.f ms" : "%dx%d, %0.1f ms", width(), height(), timeOfRenderPass); } // store timings gTimings[0] = timer.elapsed(); // total time #ifdef WIN32 // FIXME: Make it work on Unix *((quint64*)&gTimings[2]) = countAfterSwap; // counter after swap SoMFUInt32 *swapBuffersInfo = (SoMFUInt32 *) SoDB::getGlobalField("SwapBuffersInfo"); //SoDebugError::postInfo("Radbuilder::renderCallback", "%d *** gTimings[2]: %d, field[2]: %d\n", (unsigned int) c4, gTimings[2], (*swapBuffersInfo)[2]); if ( swapBuffersInfo ) { swapBuffersInfo->setNum(6); swapBuffersInfo->setValues(0, 6, gTimings); } #endif /* WIN32 */ update(); }
SoXipDicomExaminer::SoXipDicomExaminer() { SO_NODE_CONSTRUCTOR( SoXipDicomExaminer ); SO_XIP_KIT_ADD_ENTRY( mCamera, SoOrthographicCamera, this ); SO_XIP_KIT_ADD_ENTRY( mImageSwitch, SoSwitch, this ); SO_XIP_KIT_ADD_ENTRY( mImage, SoXipImage, mImageSwitch ); SO_NODE_DEFINE_ENUM_VALUE( ModeType, NONE ); SO_NODE_DEFINE_ENUM_VALUE( ModeType, PANZOOM ); SO_NODE_DEFINE_ENUM_VALUE( ModeType, SHIFT ); SO_NODE_DEFINE_ENUM_VALUE( ModeType, SCROLL ); SO_NODE_DEFINE_ENUM_VALUE( ModeType, SHIFTSCROLL ); SO_NODE_SET_SF_ENUM_TYPE( mode, ModeType ); SO_NODE_ADD_FIELD( drawImage, (TRUE) ); SO_NODE_ADD_FIELD( images, (0) ); SO_NODE_ADD_FIELD( imageIndex, (0) ); SO_NODE_ADD_FIELD( previousImage, () ); SO_NODE_ADD_FIELD( nextImage, () ); SO_NODE_ADD_FIELD( sliceIndex, (-1) ); SO_NODE_ADD_FIELD( previousSlice, () ); SO_NODE_ADD_FIELD( nextSlice, () ); SO_NODE_ADD_FIELD( viewAll, () ); SO_NODE_ADD_FIELD( viewAllScale, (0.8) ); SO_NODE_ADD_FIELD( mode, (NONE) ); SO_NODE_ADD_FIELD( boundingBox, (SbMatrix::identity()) ); SO_NODE_ADD_FIELD( viewBoundingBox, ()); SO_NODE_ADD_FIELD( planeSlice, (SbPlane(SbVec3f(1, 0, 0), 0))); SoField* fields[8] = { &viewAll, &viewBoundingBox, &nextImage, &previousImage, &nextSlice, &previousSlice, &images, &mode }; for( int i = 0; i < 8; ++ i ) { mFieldSensors[i] = new SoFieldSensor( &fieldSensorCB, this ); mFieldSensors[i]->attach( fields[i] ); } mSelectionEngine = new SoXipConvertMFDicomToSFDicom; mSelectionEngine->ref(); mDicomExtract = new SoXipDicomExtractSlice; mDicomExtract->ref(); mSelectionEngine->input.connectFrom(&images); mSelectionEngine->index.connectFrom(&imageIndex); mDicomExtract->image.connectFrom(&mSelectionEngine->output); mDicomExtract->sliceIndex.connectFrom(&sliceIndex); numSlices.connectFrom( &mDicomExtract->numSlices ); ((SoXipSFDataImage *)mImage->getField(SbName("image")))->connectFrom(&mDicomExtract->output); // Create a field sensor on the internal image to update the camera mImageSensor = new SoFieldSensor( &fieldSensorCB, this ); mImageSensor->attach( (SoXipSFDataImage *)mImage->getField(SbName("image")) ); mImageSensor->setPriority(0); // Initialize the animation members to null mAnimate = FALSE; mAnimateHStep = 0; mAnimateHPosition = 0; mAnimateVStep = 0; mAnimateVPosition = 0; mAnimateChange = 0; mAnimationSensor = 0; mViewAll = TRUE; mPan = FALSE; mViewBoundingBox = FALSE; }
void SoXipDicomExaminer::inputChanged( SoField* whichField ) { // Displayed image (or image used to configure the camera) if( whichField == (SoXipSFDataImage *)mImage->getField(SbName("image")) ) { // After switching to a different image, reposition the camera updateCamera(); } // Images field else if( whichField == &images ) { int numImages = images.getNum(); if( numImages <= 0 ) { imageIndex.setValue(-1); sliceIndex.setValue(-1); } else { int prevImageId = imageIndex.getValue(); int prevSliceId = sliceIndex.getValue(); if( prevImageId < 0 || prevImageId >= numImages ) imageIndex.setValue(0); int numOfSlices = numSlices.getValue(); if( prevSliceId < 0 || prevSliceId >= numOfSlices ) sliceIndex.setValue(0); mViewAll = TRUE; } } // View all flag else if( whichField == &viewAll ) { mViewAll = TRUE; } // View bounding box flag else if( whichField == &viewBoundingBox ) { mViewBoundingBox = TRUE; } // Previous image sensor else if( whichField == &previousImage ) { decreaseImageIndex(1); } // Next image sensor else if( whichField == &nextImage ) { increaseImageIndex(1); } // Previous slice sensor else if( whichField == &previousSlice ) { decreaseSliceIndex(1); } // Next slice sensor else if( whichField == &nextSlice ) { increaseSliceIndex(1); } // Stop the animation when user switches between modes else if( whichField == &mode ) { if( mAnimate ) stopAnimation(); } }
void QXipIvWidget::updateCursor(bool fromScene) { if (fromScene) { if (!m_cursorField) { m_cursorField = dynamic_cast<SoMFString*>(SoDB::getGlobalField(SbName("XipCursor"))); } if (m_cursorField) { SbString newCursor; m_cursorField->get1(0, newCursor); if (strcmp(newCursor.getString(), "\"MOVE_LINE\"") == 0) setCursor(Qt::SizeAllCursor); else if (strcmp(newCursor.getString(), "\"MOVE\"") == 0) setCursor(Qt::SizeAllCursor); else if (strcmp(newCursor.getString(), "\"ROTATE_INPLANE\"") == 0) setCursor(Qt::OpenHandCursor); else if (strcmp(newCursor.getString(), "\"ROTATE_NORMAL_VR\"") == 0) setCursor(Qt::OpenHandCursor); else if (strcmp(newCursor.getString(), "\"SEL_ROTATE\"") == 0) setCursor(Qt::ArrowCursor); else if (strcmp(newCursor.getString(), "\"SEL_ROTATE_VR\"") == 0) setCursor(Qt::ArrowCursor); else if (strcmp(newCursor.getString(), "\"SEL_ZOOM\"") == 0) setCursor(Qt::SizeVerCursor); else if (strcmp(newCursor.getString(), "\"SEL_PAN\"") == 0) setCursor(Qt::ArrowCursor); else { setCursor(Qt::ArrowCursor); // qDebug() << newCursor.getString(); } } // const char* handlePtr = strstr(str.getString(), "handle\t"); // if (handlePtr) // { // void* handle = 0; // if (sscanf(handlePtr, "handle\t%p", &handle) == 1) // { // if (handle) // { //#ifdef WIN32 // setCursor(QCursor((HCURSOR) handle)); //#endif /* WIN32 */ // //#ifdef linux // setCursor(QCursor((Qt::HANDLE) handle)); //#endif /* LINUX */ // //#ifdef DARWIN // setCursor(QCursor()); // FIXME: We must create a handle for Mac OS X //#endif /* DARWIN */ // // return; // } // } // } // } } //setCursor(Qt::ArrowCursor); }
TSeparatorKit* ComponentHeliostatField::CreateField() { //Define heliostat tracker for the field QVector< TTrackerFactory* > trackersFactoryList = m_pPluginManager->GetTrackerFactories(); if( trackersFactoryList.size() == 0 ) { QMessageBox::warning( 0, QString( "Campo Heliostatos" ), QString( "No se ha encontrado plugins de tipo tracker." ) ); return 0; } QVector< QString > trackerNames; for( int i = 0; i < trackersFactoryList.size(); i++ ) trackerNames<< trackersFactoryList[i]->TTrackerName(); int selectedTracker = trackerNames.indexOf( QLatin1String( "Heliostat_tracker" ) ); if( selectedTracker < 0 ) { QMessageBox::warning( 0, QString( "Campo Heliostatos" ), QString( "No se ha encontrado el plugin de tipo 'Heliostat_tracker' " ) ); return 0; } TTrackerFactory* heliostatTrackerFactory = trackersFactoryList[ selectedTracker ]; HeliostatFieldWizard wizard; if( !wizard.exec() ) { QMessageBox::information( 0, QString( "Campo Heliostatos" ), QString( "The field has not been created." ) ); return 0; } //Aiming point Point3D aimingPoint = wizard.GetHeliostatsAimingPoint(); //Read heliostat component //TSeparatorKit::initClass(); TSeparatorKit* heliostatComponentNode = OpenHeliostatComponent( wizard.GetHeliostatComponentFile() ); if( !heliostatComponentNode ) { QMessageBox::information( 0, QString( "Campo Heliostatos" ), QString( "Error al leer el componente para los heliostatos." ) ); return 0; } QFile coordinatesFile( wizard.GetCoordinatesFile() ); if( !coordinatesFile.open( QIODevice::ReadOnly ) ) { QMessageBox::information( 0, QString( "Campo Heliostatos" ), QString( "Error al leer el archivo de coordenadas de los heliostatos." ) ); return 0; } QTextStream coordIn( &coordinatesFile ); std::vector< Point3D > hCenterList; while( !coordIn.atEnd() ) { QString inLine = coordIn.readLine(); QStringList heliostat = inLine.split(QRegExp("[\\t,;]"), QString::SkipEmptyParts); if( heliostat.count() >=3 ) hCenterList.push_back( Point3D( heliostat[0].toDouble(), heliostat[1].toDouble(), heliostat[2].toDouble() ) ); } SoType separatorType = SoType::fromName( SbName ( "TSeparatorKit" ) ); /*TSeparatorKit* rootSeparator = static_cast< TSeparatorKit* > ( separatorType.createInstance() ); //TSeparatorKit* rootSeparator = new TSeparatorKit; rootSeparator->setName( "CampoHeliostatos" ); rootSeparator->ref(); SoNodeKitListPart* rootPartList = static_cast< SoNodeKitListPart* >( rootSeparator->getPart( "childList", true ) ); if( !rootPartList ) return 0; */ TSeparatorKit* heliostatsNodeSeparator = static_cast< TSeparatorKit* > ( separatorType.createInstance() ); //TSeparatorKit* heliostatsNodeSeparator = new TSeparatorKit; //rootPartList->addChild(heliostatsNodeSeparator); heliostatsNodeSeparator->setName( "Heliostatos" ); heliostatsNodeSeparator->ref(); CreateHeliostatZones( hCenterList, heliostatsNodeSeparator, heliostatTrackerFactory, aimingPoint, heliostatComponentNode, 1 ); return heliostatsNodeSeparator; }
void SoRefXipMprExaminer::setOrientation(QString newOrientation) { if (!fldOrientation) return; fldOrientation->setValue(SbName(newOrientation.toAscii())); }
SbBool SoUnknownNode::readInstance(SoInput *in, unsigned short flags) // //////////////////////////////////////////////////////////////////////// { int i; // This is mostly the normal SoGroup reading code, but we look for // an alternateRep field after reading and move our public // children onto the hidden children list: hasChildren = (!in->isBinary() || (flags & IS_GROUP)); SbBool result; if (hasChildren) { result = SoGroup::readInstance(in, flags); // If read ASCII AND didn't read any children, set hasChildren // to FALSE: if (!in->isBinary() && getNumChildren() == 0) hasChildren = FALSE; // Add all kids to hiddenChildren, then remove them all from the // regular (SoGroup) list for (i = 0; i < getNumChildren(); i++) { hiddenChildren.append(getChild(i)); } removeAllChildren(); } else { result = SoNode::readInstance(in, flags); } // Check to see if an alternate representation was read and // store a pointer to it if one is found. int num = instanceFieldData->getNumFields(); SbBool haveAlternateRep = FALSE; for (i=0; i<num; i++) { if (instanceFieldData->getFieldName(i) == SbName("alternateRep")) { SoField *f = instanceFieldData->getField(this, i); if (f->isOfType(SoSFNode::getClassTypeId())) { haveAlternateRep = TRUE; SoSFNode *alternateRepField = (SoSFNode *)f; SoNode *n = alternateRepField->getValue(); if (n != NULL) addChild(n); } break; } } // If no alternateRep was specified, look for a field named "isA" // of type MFString and try to automatically create an // alternateRep: if (!haveAlternateRep) for (i=0; i<num; i++) { if (instanceFieldData->getFieldName(i) == SbName("isA")) { SoField *f = instanceFieldData->getField(this, i); if (f->isOfType(SoMFString::getClassTypeId())) { createFromIsA((SoMFString *)f); } } } return result; }
void doClipping(SbVec3f trans, SbRotation rot) { SbMatrix mat; SbVec3f normal; mat.setTransform(trans, rot, SbVec3f(1,1,1)); mat.multDirMatrix(SbVec3f(0, -1, 0), normal); SbPlane plane(normal, trans); const float coords[][3] = { {-5,-5,-5}, {5,-5,-5}, {5,5,-5}, {-5,5,-5}, {-5,-5,5}, {5,-5,5}, {5,5,5}, {-5,5,5} }; const int indices[] = { 0,3,2,1,-1, 0,1,5,4,-1, 2,6,5,1,-1, 3,7,6,2,-1, 3,0,4,7,-1, 7,4,5,6,-1 }; // Clip box against plane SbClip clip; SoMFVec3f * globalVerts = (SoMFVec3f *)SoDB::getGlobalField(SbName("globalVerts")); SoMFVec3f * globalTVerts = (SoMFVec3f *)SoDB::getGlobalField(SbName("globalTVerts")); SoMFInt32 * globalnv = (SoMFInt32 *)SoDB::getGlobalField(SbName("globalnv")); globalVerts->startEditing(); globalVerts->setNum(0); globalTVerts->startEditing(); globalTVerts->setNum(0); globalnv->startEditing(); globalnv->setNum(0); int i; for (i = 0;i<6*5;i++) { if (indices[i] == -1) { clip.clip(plane); int numVerts = clip.getNumVertices(); if (numVerts > 0) { for (int j = 0;j<numVerts;j++) { SbVec3f v; clip.getVertex(j, v); globalVerts->set1Value(globalVerts->getNum(), v); v += SbVec3f(5, 5, 5); v /= 10.0; globalTVerts->set1Value(globalTVerts->getNum(), v); } globalnv->set1Value(globalnv->getNum(), numVerts); } clip.reset(); } else clip.addVertex(coords[indices[i]]); } globalVerts->finishEditing(); globalTVerts->finishEditing(); globalnv->finishEditing(); // Close hole in clipped box by clipping against all 6 planes const SbVec3f planecoords[] = { SbVec3f(-10,0,-10), SbVec3f(10,0,-10), SbVec3f(10,0,10), SbVec3f(-10,0,10) }; clip.reset(); for (i = 0;i<4;i++) { SbVec3f v; mat.multVecMatrix(planecoords[i], v); clip.addVertex(v); } for (i = 0;i<6*5;i+=5) { SbPlane p(coords[indices[i+2]], coords[indices[i+1]], coords[indices[i]]); clip.clip(p); } int numVerts = clip.getNumVertices(); SoMFVec3f * planeVerts = (SoMFVec3f *)SoDB::getGlobalField(SbName("planeVerts")); SoMFVec3f * planeTVerts = (SoMFVec3f *)SoDB::getGlobalField(SbName("planeTVerts")); planeVerts->startEditing(); planeVerts->setNum(0); planeTVerts->startEditing(); planeTVerts->setNum(0); for (i = 0;i<numVerts;i++) { SbVec3f v; clip.getVertex(i, v); planeVerts->set1Value(planeVerts->getNum(), v); v += SbVec3f(5, 5, 5); v /= 10.0; planeTVerts->set1Value(planeTVerts->getNum(), v); } planeVerts->finishEditing(); planeTVerts->finishEditing(); }