Exemple #1
0
std::string mui::Helpers::muiPath( std::string path ){
	// pretty much copy&pasted from OF
	Poco::Path outputPath;
	Poco::Path inputPath(path);
	string strippedDataPath = mui::MuiConfig::dataPath.toString();
	strippedDataPath = ofFilePath::removeTrailingSlash(strippedDataPath);
	if (inputPath.toString().find(strippedDataPath) != 0) {
		outputPath = mui::MuiConfig::dataPath;
		outputPath.resolve(inputPath);
	} else {
		outputPath = inputPath;
	}
	
	if( !ofFile(outputPath.absolute().toString(), ofFile::Reference).exists() ){
		// maybe in the data dir?
		string dataFile = ofToDataPath(path, true);
		if( ofFile(dataFile,ofFile::Reference).exists() ){
			outputPath = Poco::Path(dataFile);
		}
	}
	
	if( mui::MuiConfig::logLevel <= OF_LOG_NOTICE ){
		cout << "loading path: " << outputPath.toString() << " || " << outputPath.absolute().toString() << " || " << path << endl;
	}
	return outputPath.absolute().toString();
}
CameraImageToDisplayImagePass::CameraImageToDisplayImagePass(Poco::Path shader_dir,
                                                             osg::ref_ptr<osg::Texture> live_camera_texture,
                                                             std::string p2c_filename,
															 bool UseHDR) :
	_live_camera_texture(live_camera_texture), _UseHDR(UseHDR)
{
	double scale_width = live_camera_texture->getTextureWidth();
	double scale_height = live_camera_texture->getTextureHeight();
	osg::ref_ptr<osg::Image> image = load_exr( p2c_filename, _display_width, _display_height, scale_width, scale_height );
	_p2c_texture = new osg::Texture2D;
	_p2c_texture->setTextureSize( _display_width, _display_height);
	_p2c_texture->setInternalFormat(GL_RGB32F);
	_p2c_texture->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
	_p2c_texture->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);

	_p2c_texture->setImage(image);

	create_output_texture();
	_camera = new osg::Camera;
	setup_camera();
	osg::ref_ptr<osg::Group> g = create_input_geometry();
	_camera->addChild( g.get() );

	_top = new osg::Group;
	_top->addDescription("CameraImageToDisplayImagePass top node");
	_top->addChild( _camera );
	set_shader( shader_dir.absolute().append("CameraImageToDisplayImagePass.vert").toString(),
				shader_dir.absolute().append("CameraImageToDisplayImagePass.frag").toString() );

}
Exemple #3
0
void Pothos::PluginLoader::loadModules(void)
{
    Poco::Path libPath = Pothos::System::getRootPath();
    libPath.append("lib@LIB_SUFFIX@");
    libPath.append("Pothos");
    libPath.append("modules");
    const auto paths = getModulePaths(libPath.absolute());

    //TODO load user built modules -- when we have a comprehension for them

    //spawn futures and wait for completion of load
    std::vector<std::future<void>> futures;
    for (const auto &path : paths)
    {
        futures.push_back(std::async(std::launch::async, &loadModuleAtPath, path.toString()));
    }
    for (auto &future : futures) future.wait();
}
Exemple #4
0
    int CStatsUtil::DoImportGameScripts()
    {
        //Validate output + input paths
        Poco::Path inpath(m_inputPath);
        Poco::Path outpath;

        if( m_outputPath.empty() )
            throw runtime_error("CStatsUtil::DoImportGameScripts() : Output path is empty!");
            
        if( !utils::isFolder( m_outputPath ) )
            throw runtime_error("CStatsUtil::DoImportGameScripts() : Output path doesn't exist, or isn't a directory!");

        outpath = Poco::Path(m_outputPath);

        //Setup the script handler
        GameScripts scripts( outpath.absolute().toString() );

        //Import from XML
        scripts.ImportScriptsFromXML( inpath.absolute().toString() );

        return 0;
    }
/**
 * Determine the location of the collection and cache files.
 */
void MantidHelpWindow::determineFileLocs()
{
    // determine collection file location
    string binDir = Mantid::Kernel::ConfigService::Instance().getDirectoryOfExecutable();
    this->findCollectionFile(binDir);
    if (m_collectionFile.empty())
    {
        // clear out the other filenames
        m_cacheFile = "";
        return;
    }
    g_log.debug() << "Using collection file \"" << m_collectionFile << "\"\n";

    // determine cache file location
    m_cacheFile = COLLECTION_FILE.toStdString();
    QString dataLoc = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
    if (dataLoc.endsWith("mantidproject"))
    {
        Poco::Path path (dataLoc.toStdString(), m_cacheFile);
        m_cacheFile = path.absolute().toString();
    }
    else if (dataLoc.endsWith("MantidPlot")) // understood to end in "Mantid/MantidPlot"
    {
        Poco::Path path(dataLoc.toStdString());
        path = path.parent(); // drop off "MantidPlot"
        path = path.parent(); // drop off "Mantid"
        path = Poco::Path(path, "mantidproject");
        path = Poco::Path(path, m_cacheFile);
        m_cacheFile = path.absolute().toString();
    }
    else
    {
        g_log.debug() << "Failed to determine help cache file location\n"; // REMOVE
        Poco::Path path(dataLoc.toStdString(), "mantidproject");
        path = Poco::Path(path, COLLECTION_FILE.toStdString());
        m_cacheFile = path.absolute().toString();
    }
}
Exemple #6
0
void mui_init(){
	#if TARGET_OS_IPHONE
	if( mui::MuiConfig::detectRetina ){
		ofAppiOSWindow * w = ofAppiOSWindow::getInstance();
		if( w->isRetinaEnabled() ){
			mui::MuiConfig::scaleFactor = 2;
			mui::MuiConfig::useRetinaAssets = true;
		}
	}
	#endif
	//TODO: allow retina in osx too!
	
	Poco::Path appPath;
	#if TARGET_OS_IPHONE
		// http://www.cocoabuilder.com/archive/cocoa/193451-finding-out-executable-location-from-c-program.html
		CFBundleRef bundle = CFBundleGetMainBundle();
		CFURLRef    url  = CFBundleCopyExecutableURL(bundle); // CFBundleCopyResourcesDirectoryURL(bundle);
		CFURLRef absolute = CFURLCopyAbsoluteURL(url);
		CFStringRef path  = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
		CFIndex    maxLength = CFStringGetMaximumSizeOfFileSystemRepresentation(path);
		char        *result = (char*)malloc(maxLength);
		
		if(result) {
			if(!CFStringGetFileSystemRepresentation(path,result, maxLength)) {
				free(result);
				result = NULL;
			}
		}
		
		CFRelease(path);
		CFRelease(url);
		CFRelease(absolute);
		appPath = Poco::Path(result);
		appPath = appPath.parent();
	#elif TARGET_OS_MAC
		// http://www.cocoabuilder.com/archive/cocoa/193451-finding-out-executable-location-from-c-program.html
		CFBundleRef bundle = CFBundleGetMainBundle();
		CFURLRef    url  = CFBundleCopyExecutableURL(bundle); // CFBundleCopyResourcesDirectoryURL(bundle);
		CFURLRef absolute = CFURLCopyAbsoluteURL(url);
		CFStringRef path  = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle);
		CFIndex    maxLength = CFStringGetMaximumSizeOfFileSystemRepresentation(path);
		char        *result = (char*)malloc(maxLength);
		
		if(result) {
			if(!CFStringGetFileSystemRepresentation(path,result, maxLength)) {
				free(result);
				result = NULL;
			}
		}
		
		CFRelease(path);
		CFRelease(url);
		CFRelease(absolute);
		appPath = Poco::Path(result);
		appPath = appPath.parent().parent().pushDirectory("Resources");
	
		if( mui::MuiConfig::detectRetina ){
			ofAppGLFWWindow * window = dynamic_cast<ofAppGLFWWindow*>(ofGetWindowPtr());
			if( window != NULL ){
				mui::MuiConfig::scaleFactor = window->getPixelScreenCoordScale();
			}
		}
	#else
		appPath = Poco::Path(ofToDataPath("", true));
	#endif
	
	mui::MuiConfig::dataPath = appPath.absolute();
}