void SoVRMLAudioClipP::loadUrl() { #ifdef HAVE_THREADS SbThreadAutoLock autoLock(&this->syncmutex); #endif this->unloadUrl(); for (int i=0; i<PUBLIC(this)->url.getNum(); i++) { const char * str = PUBLIC(this)->url[i].getString(); if ( (str == NULL) || (strlen(str)==0) ) continue; // ignore empty url SbString filename = SoInput::searchForFile(SbString(str), SoInput::getDirectories(), SoVRMLAudioClip::getSubdirectories()); if (filename.getLength() <= 0) { SoDebugError::postWarning("SoVRMLAudioClipP::loadUrl(index)", "File not found: '%s'", str); continue; // ignore invalid file } this->playlist.append(filename); } }
SbString SoGLARBShaderProgram::getSourceHint(void) const { SbString result; if (this->fragmentShader && this->fragmentShader->isActive()) { SbString str = this->fragmentShader->sourceHint; if (str.getLength() > 0) str += " "; result += str; } if (this->vertexShader && this->vertexShader->isActive()) { SbString str = this->vertexShader->sourceHint; if (str.getLength() > 0) str += " "; result += str; } return result; }
void SoXipImageOverlayManager::addOverlays() { const SoNode** nodes = overlays.getValues(0); for( int i = 0; i < overlays.getNum(); ++ i ) { const SoXipShapeList* shapeList = (const SoXipShapeList *) nodes[i]; if( !shapeList->isOfType( SoXipShapeList::getClassTypeId() ) ) { SoDebugError::post( __FILE__, "Child not supported" ); return ; } int sliceIndex; if( sscanf( shapeList->label.getValue().getString(), "%d", &sliceIndex ) != 1 ) { SoDebugError::post( __FILE__, "Invalid label found '%s'", shapeList->label.getValue().getString() ); return ; } SoXipShapeList* sliceShapeList = mSliceMap[ sliceIndex ]; if( !sliceShapeList ) { sliceShapeList = new SoXipShapeList; sliceShapeList->label.setValue( SbString( sliceIndex ) ); mShapeSwitch->addChild( sliceShapeList ); mSliceMap[ sliceIndex ] = sliceShapeList; } int numShapes = shapeList->getNumChildren(); for( int i = 0; i < numShapes; ++ i ) { // Copy to string to force removing of the connections SoNode* copyNode = shapeList->getChild (i)->copy(); copyNode->ref(); SbString str = XipOverlayUtils::saveNodeToString( copyNode ); copyNode->unref(); // Reload copy node from this string SoNode* readNode = XipOverlayUtils::loadNodeFromString( str.getString(), str.getLength() ); ((SoXipShape *) readNode)->updateGeometries(); sliceShapeList->addChild( readNode ); } } }
void SoXipData::setProperty(const SbString &key, const SbString &value) { if (key.getLength() == 0) { SoDebugError::postWarning("SoXipData::setProperty", "Key is empty! The value cannot be stored."); return; } if (!mProperties) { mProperties = new SbXipDataPropertyMap; if (!mProperties) { SoMemoryError::post("SbXipDataPropertyMap"); return; } } (*mProperties)[key] = value; }
// Write SbString value to output stream. Used from SoSFString and // SoMFString. void sosfstring_write_value(const SoField * f, SoOutput * out, const SbString & val) { // VRML97 needs backslashes themselves to be backslash-quoted (like // in e.g. C strings), which is taken care of here instead of // downstream, as this is the last place we can find out whether or // not we're writing a VRML97 node. const SoFieldContainer * fc = f->getContainer(); if (fc && fc->isOfType(SoNode::getClassTypeId()) && (coin_assert_cast<const SoNode *>(fc)->getNodeType() & SoNode::VRML2)) { // FIXME: SbString should have had a replaceAll() method, so we // wouldn't have to spell out the iteration loop below. 20040614 mortene. SbString ws; for (int i = 0; i < val.getLength(); i++) { if (val[i] == '\\') { ws += '\\'; } ws += val[i]; } out->write(ws); } else { // *Not* a VRML97 node, so write backslashes verbatim, as // dictated by the Inventor file format: out->write(val); } }
void SoXipImageOverlayManager::loadOverlays() { // When the patient changes clearClipboard(); // Remove all the geometries from the switch mShapeSwitch->removeAllChildren(); mShapeSwitch->whichChild.setValue(-1); mCurrentSlice = -1; if( mImageData ) { SbString overlayStr = mImageData->getProperty( "overlays" ); SoNodeList nodes = XipOverlayUtils::loadOverlaysFromString( overlayStr.getString(), overlayStr.getLength(), TRUE ); for( int i = 0; i < nodes.getLength(); ++ i ) { if( !nodes[i]->isOfType( SoXipShapeList::getClassTypeId() ) ) { SoDebugError::post( __FILE__, "Invalid overlay node found in Dicom. Ignored." ); continue ; } mShapeSwitch->addChild( nodes[i] ); } } updateSliceMap(); }
MFieldEditor::MFieldEditor(SoMField *field, QWidget *p, Qt::WindowFlags f) : QDialog(p,f) { QString S; Ui.setupUi(this); //Indicamos que no estamos listos para actualizar current_mfield = NULL; //Leemos el tipo de este campo SoType tipo=field->getTypeId(); const char*nombre_tipo = tipo.getName(); //Damos a la tabla el numero de filas adecuado //Dejamos una fila libre para añadir nuevos valores int numFilas=field->getNum(); Ui.table->setRowCount(numFilas+1); Ui.sizeLabel->setText(S.setNum(numFilas) + " " + tr("elements")); //Numeramos las filas a partir de cero, y añadimos una fila para nuevos elementos QStringList vh, hh; for (int i=0; i<numFilas; i++) vh << S.setNum(i); vh << tr("new"); Ui.table->setVerticalHeaderLabels(vh); //Tratamiento de campos SoMFColor if (!strcmp(nombre_tipo, "MFColor")) { //Columnas para R, G, B Ui.table->setColumnCount(3); hh << "R" << "G" << "B"; Ui.table->setHorizontalHeaderLabels(hh); //Rellenamos la tabla SbColor color; const SbColor *values = ((SoMFColor *)field)->getValues(0); for (int i=0; i<numFilas; i++) { color= values[i].getValue(); Ui.table->setItem(i,0, new QTableWidgetItem(S.setNum(color[0],'g',2))); Ui.table->setItem(i,1, new QTableWidgetItem(S.setNum(color[1],'g',2))); Ui.table->setItem(i,2, new QTableWidgetItem(S.setNum(color[2],'g',2))); } } //Tratamiento de campos SoMFVec2f else if (!strcmp(nombre_tipo, "MFVec2f")) { //Cabecera de las columnas Ui.table->setColumnCount(2); hh << "X" << "Y"; Ui.table->setHorizontalHeaderLabels(hh); //Rellenamos la tabla const SbVec2f *values = ((SoMFVec2f *)field)->getValues(0); float x, y; for (int i=0; i<numFilas; i++) { values[i].getValue(x,y); Ui.table->setItem(i,0, new QTableWidgetItem(S.setNum(x,'g',5))); Ui.table->setItem(i,1, new QTableWidgetItem(S.setNum(y,'g',5))); } } //Tratamiento de campos SoMFVec3f else if (!strcmp(nombre_tipo, "MFVec3f")) { //Cabecera de las columnas Ui.table->setColumnCount(3); hh << "X" << "Y" << "Z"; Ui.table->setHorizontalHeaderLabels(hh); //Rellenamos la tabla const SbVec3f *values = ((SoMFVec3f *)field)->getValues(0); float x, y, z; for (int i=0; i<numFilas; i++) { values[i].getValue(x,y,z); Ui.table->setItem(i,0, new QTableWidgetItem(S.setNum(x,'g',5))); Ui.table->setItem(i,1, new QTableWidgetItem(S.setNum(y,'g',5))); Ui.table->setItem(i,2, new QTableWidgetItem(S.setNum(z,'g',5))); /* Esto tambien funciona, pero tal vez es menos eficiente //Leemos el campo y lo partimos en valores SbString valueString; field->get1(i, valueString); QStringList vv = QString(valueString.getString()).split(" "); //Insertamos cada valor en la tabla for(int j=0;j<vv.size(); j++) Ui.table->setItem(i,j, new QTableWidgetItem(vv[j])); */ } } //Tratamiento de campos SoMFVec4f else if (!strcmp(nombre_tipo, "MFVec4f")) { //Cabecera de las columnas Ui.table->setColumnCount(4); hh << "X" << "Y" << "Z" << "T"; Ui.table->setHorizontalHeaderLabels(hh); //Rellenamos la tabla const SbVec4f *values = ((SoMFVec4f *)field)->getValues(0); float x, y, z, t; for (int i=0; i<numFilas; i++) { values[i].getValue(x,y,z,t); Ui.table->setItem(i,0, new QTableWidgetItem(S.setNum(x,'g',5))); Ui.table->setItem(i,1, new QTableWidgetItem(S.setNum(y,'g',5))); Ui.table->setItem(i,2, new QTableWidgetItem(S.setNum(z,'g',5))); Ui.table->setItem(i,3, new QTableWidgetItem(S.setNum(t,'g',5))); } } //Tratamiento de campos SoMFFloat, SoMFUInt32, SoMFInt32 else if (!strcmp(nombre_tipo, "MFFloat") || !strcmp(nombre_tipo, "MFUInt32") || !strcmp(nombre_tipo, "MFShort") || !strcmp(nombre_tipo, "MFInt32") || !strcmp(nombre_tipo, "MFDouble") || !strcmp(nombre_tipo, "MFBool") || !strcmp(nombre_tipo, "MFUShort") || !strcmp(nombre_tipo, "MFName") ) { //Hace falta una columna Ui.table->setColumnCount(1); hh << tr("Value"); Ui.table->setHorizontalHeaderLabels(hh); //Rellenamos la tabla usando la funcion get1 de coin SbString valueString; for (int i=0; i<numFilas; i++) { field->get1(i, valueString); Ui.table->setItem(i,0, new QTableWidgetItem(valueString.getString())); } } //Tratamiento de campos SoMFString else if (!strcmp(nombre_tipo, "MFString")) { //Hace falta una columna Ui.table->setColumnCount(1); hh << tr("Value"); Ui.table->setHorizontalHeaderLabels(hh); //Rellenamos la tabla usando la funcion get1 de coin SbString valueString; for (int i=0; i<numFilas; i++) { field->get1(i, valueString); //Eliminamos las comillas valueString.deleteSubString(0,0); int ln = valueString.getLength(); valueString.deleteSubString(ln-1,ln-1); Ui.table->setItem(i,0, new QTableWidgetItem(valueString.getString())); }//for } else { qDebug("Falta soporte para tipo %s\n", nombre_tipo); } //Creamos los items para la ultima fila for (int j=0; j<Ui.table->columnCount(); j++) { Ui.table->setItem(Ui.table->rowCount()-1,j, new QTableWidgetItem()); } //Conectamos las señales de la tabla //connect(Ui.table, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(on_table_customContextMenuRequested(QPoint))); //connect(Ui.table, SIGNAL(cellChanged(int, int)), this, SLOT(on_table_cellChanged(int, int))); //Salvamos una copia del puntero current_mfield = field; }