示例#1
0
/**
*	Constructor
**/
DkPageExtractionPlugin::DkPageExtractionPlugin(QObject* parent) : QObject(parent) {

	// create run IDs
	QVector<QString> runIds;
	runIds.resize(id_end);

	for (int idx = 0; idx < id_end; idx++)
		runIds[idx] = QUuid::createUuid().toString();
	mRunIDs = runIds.toList();

	// create menu actions
	QVector<QString> menuNames;
	menuNames.resize(id_end);
		
	menuNames[id_crop_to_page] = tr("Crop to Page");
	menuNames[id_crop_to_metadata] = tr("Crop to Metadata");
	menuNames[id_draw_to_page] = tr("Draw to Page");
	menuNames[id_eval_page] = tr("Evaluate Page");
	mMenuNames = menuNames.toList();

	// create menu status tips
	QVector<QString> statusTips;
	statusTips.resize(id_end);

	statusTips[id_crop_to_page] = tr("Finds a page in a document image and then crops the image to that page.");
	statusTips[id_crop_to_metadata] = tr("Finds a page in a document image and then saves the coordinates to the XMP metadata.");
	statusTips[id_draw_to_page] = tr("Finds a page in a document image and then draws the found document boundaries.");
	statusTips[id_eval_page] = tr("Loads GT and computes the Jaccard index.");
	mMenuStatusTips = statusTips.toList();

	QFileInfo resPath(QDir("D:/dmrz/numerical-results/"), "results-" + QDateTime::currentDateTime().toString("yyyy-MM-dd HH-mm-ss") + ".txt");
	mResultPath = resPath.absoluteFilePath();
}
示例#2
0
AudioManager::AudioManager()
    : m_fadeInTime      (4.f),
    m_currentFadeTime   (0.f),
    m_fxSounds          (SoundIds::Size),
    m_muted             (false)
{
    std::string resPath("");
    //if it's OS X, prepend the resourcePath
    #ifdef __APPLE__
    resPath = resourcePath();
    #endif
    
    m_musicPlayer.setVolume(0.f);
    m_musicPlayer.play(resPath + "assets/sound/background.ogg", true);

    m_soundPlayer.setVolume(0.f);
    auto files = FileSystem::listFiles(resPath + impactSoundPath);
    for (const auto& file : files)
    {
        if (FileSystem::getFileExtension(file) == ".wav")
        {
            m_impactSounds.emplace_back(sf::SoundBuffer());
            m_impactSounds.back().loadFromFile(resPath + impactSoundPath + file);
        }
    }
    
    m_fxSounds[SwitchFx].loadFromFile(resPath + "assets/sound/switch.wav");
    m_fxSounds[HealthLost].loadFromFile(resPath + "assets/sound/healthlost.wav");
    m_fxSounds[HealthGained].loadFromFile(resPath + "assets/sound/healthgained.wav");
    m_fxSounds[Eating].loadFromFile(resPath + "assets/sound/nomnom.wav");
    m_fxSounds[AteJelly].loadFromFile(resPath + "assets/sound/jelly_eat.wav");
    m_fxSounds[Spawned].loadFromFile(resPath + "assets/sound/player_spawn.wav");
}
示例#3
0
/// the 'add' command for copying a file from the physical fs to the current
/// working directory
/// example usage:
/// add file://path/to/file.txt
void com_add(teasafe::TeaSafe &theBfs, std::string const &parent, std::string const &fileResource)
{
    // add the file to the container
    // this removed the first several chars assumes to be "file://"
    std::string resPath(fileResource.begin() + 7, fileResource.end());
    teasafe::utility::copyFromPhysical(theBfs, parent, resPath, std::bind(operationCallback,
                                                                          std::placeholders::_1));
}
示例#4
0
std::istream*
BundleDirectory::GetResource(const std::string& path) const
{
  Poco::Path resPath(m_RootPath);
  std::string resStr = resPath.append(Path(path)).toString();
  //BERRY_INFO << "Getting resource: " << resStr << std::endl;
  try {
    return new Poco::FileInputStream(resStr);
  }
  catch (...)
  {}
  return 0;
}
示例#5
0
void Bundle::loadProperties()
{
	Path localPath(false);
	localPath.pushDirectory(_language.primaryTag());
	localPath.pushDirectory(_language.subTags());
	while (localPath.depth() > 0)
	{
		Path resPath(localPath, PROPERTIES_FILE);
		addProperties(resPath.toString(Path::PATH_UNIX));
		localPath.popDirectory();
	}
	addProperties(PROPERTIES_FILE);
}
示例#6
0
std::istream* Bundle::getLocalizedResource(const std::string& name, const LanguageTag& language) const
{
	Path localPath(false);
	localPath.pushDirectory(language.primaryTag());
	localPath.pushDirectory(language.subTags());
	Path resPath(localPath, name);
	std::istream* pStream = getResource(resPath.toString(Path::PATH_UNIX)); 
	while (!pStream && localPath.depth() > 0)
	{
		localPath.popDirectory();
		resPath = Path(localPath, name);
		pStream = getResource(resPath.toString(Path::PATH_UNIX));
	}
	return pStream;
}
示例#7
0
std::string Configurator::resourcePath(const std::string &path)
{
	std::string fullPath;
	std::string resPath(m_dataPath);

	if(path[0] != '/')
		resPath.append("/");

	resPath.append(path);


	if(m_dataPathRelative)
		fullPath = m_pSystem->exePath();

	m_pSystem->localizePath(resPath);

	fullPath.append(resPath);
	return fullPath;
}
示例#8
0
/**
 * Scans through the archive list for a specified file
 */
Common::ArchiveMemberPtr PackageManager::getArchiveMember(const Common::String &fileName) {
	// Loop through checking each archive
	Common::List<ArchiveEntry *>::iterator i;
	for (i = _archiveList.begin(); i != _archiveList.end(); ++i) {
		if (!fileName.hasPrefix((*i)->_mountPath)) {
			// The mount path is in different subtree. Skipping
			continue;
		}

		// Look into the archive for the desired file
		Common::Archive *archiveFolder = (*i)->archive;

		// Construct relative path
		Common::String resPath(&fileName.c_str()[(*i)->_mountPath.size()]);

		if (archiveFolder->hasFile(resPath)) {
			return archiveFolder->getMember(resPath);
		}
	}

	return Common::ArchiveMemberPtr();
}
示例#9
0
void AnimatedDrawable::loadAnimationData(const std::string& path)
{
    std::string resPath("");
    //if it's OS X, prepend the resourcePath
    #ifdef __APPLE__
    resPath = resourcePath();
    #endif
    
    std::ifstream file(resPath + path);
    if (!file.good() || !Util::File::validLength(file))
    {
        LOG("failed to open " + path + ", or file empty", Logger::Type::Error);
        file.close();
        return;
    }
    
    std::string jsonString;
    while (!file.eof())
    {
        std::string temp;
        file >> temp;
        jsonString += temp;
    }
    if (jsonString.empty())
    {
        LOG(path + "failed to read, or file empty", Logger::Type::Error);
        file.close();
        return;
    }
    file.close();
    
    picojson::value pv;
    auto err = picojson::parse(pv, jsonString);
    if (err.empty())
    {
        //get array of animations
        if (pv.get("Animations").is<picojson::array>())
        {
            const auto& anims = pv.get("Animations").get<picojson::array>();
            for (const auto& a : anims)
            {
                std::string name = (a.get("Name").is<std::string>()) ? a.get("Name").get<std::string>() : "";
                sf::Int16 start = (a.get("Start").is<double>()) ? static_cast<sf::Int16>(a.get("Start").get<double>()) : 0;
                sf::Int16 end = (a.get("End").is<double>()) ? static_cast<sf::Int16>(a.get("End").get<double>()) : 0;
                bool loop = (a.get("Loop").is<bool>()) ? a.get("Loop").get<bool>() : false;
                m_animations.emplace_back(name, start, end, loop);
            }
        }
    
        //properties
        if (pv.get("FrameCount").is<double>())
            m_frameCount = static_cast<sf::Uint8>(pv.get("FrameCount").get<double>());
        else
            Logger::Log(path + " missing frame count", Logger::Type::Error, Logger::Output::All);
    
        if (pv.get("FrameSize").is<std::string>())
            setFrameSize(Util::Vector::vec2FromString<int>(pv.get("FrameSize").get<std::string>()));
        else
            Logger::Log(path + " missing frame size", Logger::Type::Error, Logger::Output::All);
    
        if (pv.get("FrameRate").is<double>())
            m_frameRate = static_cast<float>(pv.get("FrameRate").get<double>());
        else
            Logger::Log(path + " missing frame rate", Logger::Type::Error, Logger::Output::All);
    }
    else
    {
        Logger::Log("Animated Sprite: " + err, Logger::Type::Error, Logger::Output::All);
    }

    setFrame(m_currentFrame);
}
示例#10
0
 virtual void DumpNode(int indent) { printf("%*sImage(%u) %-30s\t(%6.1f,%6.1f,%6.1f)\t%6.1f°\t[%3.1f,%3.1f]\t {%6.1f,%6.1f}\n", indent, " ", textureID, resPath().c_str(), position.pyGet().x, position.pyGet().y, position.pyGet().z, rotation.pyGet(), scaleX.pyGet(), scaleY.pyGet(), size.pyGet().x, size.pyGet().y);}
示例#11
0
    static void run(){
	IrrlichtDevice *device = createDevice( video::EDT_OPENGL, dimension2d<u32>(1024, 768), 32, false, false, true, 0);
	IVideoDriver* driver = device->getVideoDriver();
	ISceneManager* smgr = device->getSceneManager();

	smgr->addCameraSceneNodeFPS();

    const s32 randLength = 1024;
    srand(device->getTimer()->getRealTime());


    //Creating the grid for unit measure, etc
    u32 tileNumber = 128;
	IAnimatedMesh* groundMesh = smgr->addHillPlaneMesh("", dimension2d<float>(8,8),dimension2d<u32>(tileNumber,tileNumber),0,0.0f,dimension2df(0,0),dimension2df(tileNumber,tileNumber));
    IAnimatedMeshSceneNode * groundNode = smgr->addAnimatedMeshSceneNode(groundMesh);
    groundNode->setMaterialTexture(0,driver->getTexture(resPath("../../media/grid2.png")));
    groundNode->setMaterialFlag(EMF_LIGHTING,false);
    groundNode->setPosition(vector3df(0,-2,0));


    //obstacles for stuff
    EntityGroup obstacles;

    for(int i = 0; i < 20; i++)
    {
        ISceneNode* s = smgr->addSphereSceneNode(20);
        IrrlichtBaseEntity * e = new IrrlichtBaseEntity(s);
        s->setPosition(vector3df(rand()%randLength - (randLength/2),0,rand()%randLength - (randLength/2)));
        obstacles.push_back(e);
    }

    //Nodes for vehicles
    ISceneNode * cube = smgr->addCubeSceneNode(4);
    ISceneNode * cube2 = smgr->addCubeSceneNode(4);
    cube->setMaterialFlag(EMF_LIGHTING,false);
    cube->setMaterialTexture(0,driver->getTexture(resPath("../../media/v1-solid.png")));
    cube2->setMaterialFlag(EMF_LIGHTING,false);
    cube2->setMaterialTexture(0,driver->getTexture(resPath("../../media/v2-solid.png")));

    //Creating the actual vehicles
    IrrlichtMobileEntity * Entity1 = new IrrlichtMobileEntity(cube ,vector3df(0,0,0), 1, 60, 150);
    IrrlichtMobileEntity * Entity2 = new IrrlichtMobileEntity(cube2,vector3df(0,0,300), 1, 60, 150);

    //Creating the steering conrollers, constructor also sets steering on entity
    SimpleSteeringController* Entity1Steering = new SimpleSteeringController(Entity1);
    SimpleSteeringController * Entity2Steering = new SimpleSteeringController(Entity2);

    //Setting up other params for behaviors
    Entity1Steering->SetObstacles(obstacles);
    Entity1Steering->SetHideTarget(Entity2);
    Entity1Steering->SetBehaviorFlag(EBF_HIDE,true);
    Entity1Steering->SetBehaviorFlag(EBF_AVOID,true);

    Entity2Steering->SetObstacles(obstacles);
    Entity2Steering->SetPursuitTarget(Entity1);
    Entity2Steering->SetBehaviorFlag(EBF_PURSUIT,true);
    Entity2Steering->SetBehaviorFlag(EBF_AVOID,true);

    //vars for tracking time between frames. This allows framerate independent motion state updates.
    u32 then = device->getTimer()->getTime();
    float timeUpdate = 0;

    while(device->run())
	{
	    const u32 now = device->getTimer()->getTime();
        const float frameDeltaTime = (float)(now - then) / 1000.f; // Time in seconds
        then = now;
        timeUpdate += frameDeltaTime;

        if(timeUpdate > 1)
        {
            core::stringw str = L"desteer v0.0.1  FPS: ";
            str += (s32)driver->getFPS();
			device->setWindowCaption(str.c_str());
			timeUpdate = 0;
		}

        //Do behavior updates before the rendering.
        Entity1->Update(frameDeltaTime);
        Entity2->Update(frameDeltaTime);

        driver->beginScene(true, true, SColor(255,100,101,140));
            smgr->drawAll();
		driver->endScene();
	}
    //Clean up irrlicht.
	device->drop();
    }