//! Opens a file or URI with an applications the host operating system suggests. //! @see dataToCsv() void Window::openFileWithAssociatedProgram() const { QString filePath("file:///"); filePath += comboOutfile->currentText(); QUrl fileURI(filePath, QUrl::TolerantMode); QDesktopServices::openUrl(fileURI); }
void ShaderFXShaderExporter::exportSamplerAndSurfaceInner(const MString & filename) { EffectExporter & effectExporter = *mDocumentExporter.getEffectExporter(); EffectTextureExporter & textureExporter = *effectExporter.getTextureExporter(); // Take the filename for the unique image name URI fileURI(URI::nativePathToUri(filename.asChar())); if (fileURI.getScheme().empty()) fileURI.setScheme(COLLADASW::URI::SCHEME_FILE); String mayaImageId = DocumentExporter::mayaNameToColladaName(fileURI.getPathFileBase().c_str()); String colladaImageId = effectExporter.findColladaImageId(mayaImageId); if (colladaImageId.empty()) { // Generate a COLLADA id for the new image object colladaImageId = DocumentExporter::mayaNameToColladaName(fileURI.getPathFileBase().c_str()); // Make the id unique and store it in a map for refernences. colladaImageId = textureExporter.getImageIdList().addId(colladaImageId); textureExporter.getMayaIdColladaImageId()[mayaImageId] = colladaImageId; } // Export the image COLLADASW::Image* colladaImage = textureExporter.exportImage(mayaImageId, colladaImageId, fileURI); // Get the image id of the exported collada image colladaImageId = colladaImage->getImageId(); String samplerSid = colladaImageId + COLLADASW::Sampler::SAMPLER_SID_SUFFIX; String surfaceSid = colladaImageId + COLLADASW::Sampler::SURFACE_SID_SUFFIX; // Create the collada sampler object // TODO handle other sampler types COLLADASW::Sampler sampler(COLLADASW::Sampler::SAMPLER_TYPE_2D, samplerSid, surfaceSid); // TODO get wrap mode in ShaderFX graph //sampler.setWrapS(COLLADASW::Sampler::WRAP_MODE_WRAP); //sampler.setWrapT(COLLADASW::Sampler::WRAP_MODE_WRAP); //sampler.setWrapP(COLLADASW::Sampler::WRAP_MODE_WRAP); // No filtering option in ShaderFX. Default to linear. //sampler.setMinFilter(COLLADASW::Sampler::SAMPLER_FILTER_LINEAR); //sampler.setMagFilter(COLLADASW::Sampler::SAMPLER_FILTER_LINEAR); //sampler.setMipFilter(COLLADASW::Sampler::SAMPLER_FILTER_LINEAR); // Set the image reference sampler.setImageId(colladaImageId); sampler.setFormat(EffectTextureExporter::FORMAT); // Add the parameter. sampler.addInNewParam(&mStreamWriter); }
void ShaderFXShaderExporter::exportTexture(const MString & filename) { EffectExporter & effectExporter = *mDocumentExporter.getEffectExporter(); EffectTextureExporter & textureExporter = *effectExporter.getTextureExporter(); // Take the filename for the unique image name URI fileURI(URI::nativePathToUri(filename.asChar())); if (fileURI.getScheme().empty()) fileURI.setScheme(COLLADASW::URI::SCHEME_FILE); effectExporter.exportTexturedParameter(mEffectId, &mEffectProfile, mTextureIndex, fileURI); }
QString Collection::getFingerprint( const QString& filePath ) { QSqlQuery query( m_db ); query.prepare( "SELECT fpId FROM files WHERE uri = :uri" ); query.bindValue( ":uri", fileURI( filePath ) ); query.exec(); if ( query.lastError().isValid() ) { qDebug() << "SQL query failed:" << query.lastQuery() << endl << "SQL error was:" << query.lastError().databaseText() << endl << "SQL error type:" << query.lastError().type(); } else if ( query.next() ) return query.value( 0 ).toString(); return ""; }
bool Collection::setFingerprint( const QString& filePath, QString fpId ) { bool isNumeric; int intFpId = fpId.toInt( &isNumeric ); Q_ASSERT( isNumeric ); QSqlQuery query( m_db ); query.prepare( "REPLACE INTO files ( uri, track, fpId ) VALUES ( :uri, 0, :fpId )" ); query.bindValue( ":uri", fileURI( filePath ) ); query.bindValue( ":fpId", intFpId ); query.exec(); if ( query.lastError().isValid() ) { qDebug() << "SQL query failed:" << query.lastQuery() << endl << "SQL error was:" << query.lastError().databaseText() << endl << "SQL error type:" << query.lastError().type(); return false; } return true; }
// This function needs to be re-entrant, it can be called recursively from inside of resolveAll // to load files that the first file depends on. daeInt daeLIBXMLPlugin::read(daeURI& uri, daeString docBuffer) { // Make sure topMeta has been set before proceeding if (topMeta == NULL) { return DAE_ERR_BACKEND_IO; } // Generate a version of the URI with the fragment removed daeURI fileURI(uri.getURI(),true); // Create the right type of xmlTextReader on the stack so this function can be re-entrant xmlTextReaderPtr reader; if(docBuffer) { // Load from memory (experimental) #if 0 //debug stuff printf("Reading %s from memory buffer\n", fileURI.getURI()); #endif reader = xmlReaderForDoc((xmlChar*)docBuffer, fileURI.getURI(), NULL,0); } else { // Load from URI #if 0 //debug stuff printf("Opening %s\n", fileURI.getURI()); #endif reader = xmlReaderForFile(fileURI.getURI(), NULL,0); } if(!reader) { printf( "no libxml2 reader\n"); return DAE_ERR_BACKEND_IO; } // Start parsing the file daeElementRef domObject = startParse(topMeta, reader); // Parsing done, free the xmlReader and error check to make sure we got a valid DOM back xmlFreeTextReader(reader); if (!domObject) { #if defined(_DEBUG) && defined(WIN32) fprintf(stderr,"daeLIBXMLPlugin::read(%s) failed - XML Parse Failed\n", fileURI.getFile()); fflush(stdout); #endif printf("not able to load\n"); return DAE_ERR_BACKEND_IO; } // Insert the document into the database, the Database will keep a ref on the main dom, so it won't gets deleted // until we clear the database daeDocument *document = NULL; int res = database->insertDocument(fileURI.getURI(),domObject,&document); if (res!= DAE_OK) return res; // Make a vector to store a list of the integration items that need to be processed later // postProcessDom will fill this in for us (this should probably not be done in the IOPlugin) std::vector<INTEGRATION_ITEM> intItems; //insert the elements into the database, for this DB the elements are the Collada object which have //an ID. //this function will fill the _integrationItems array as well postProcessDom(document, domObject, intItems); database->validate(); daeElement::resolveAll(); //create the integration objects int size = (int)intItems.size(); int i; for (i=0;i<size;i++) intItems[i].intObject->createFromChecked(intItems[i].element); for (i=0;i<size;i++) intItems[i].intObject->fromCOLLADAChecked(); for (i=0;i<size;i++) intItems[i].intObject->fromCOLLADAPostProcessChecked(); //clear the temporary integration items array intItems.clear(); return DAE_OK; }
String WebInspectorProxy::inspectorBaseURL() const { GOwnPtr<gchar> fileURI(g_filename_to_uri(inspectorFilesBasePath(), 0, 0)); return WebCore::filenameToString(fileURI.get()); }
String WebInspectorProxy::inspectorPageURL() const { GOwnPtr<gchar> filePath(g_build_filename(inspectorFilesBasePath(), "inspector.html", NULL)); GOwnPtr<gchar> fileURI(g_filename_to_uri(filePath.get(), 0, 0)); return WebCore::filenameToString(fileURI.get()); }