void GlutDisplaySystem::setup(Setting& setting) 
{
	String sCfg;
	setting.lookupValue("config", sCfg);

	int width;
	int height;
	myFov = 60;
	myNearz = 1.0f;
	myFarz = 100;

	libconfig::ArgumentHelper ah;
	ah.newInt("width", "Resolution width", width);
	ah.newInt("height", "Resolution width", height);
	ah.newNamedInt('f', "fov", "fov", "field of view", myFov);
	ah.newNamedDouble('z', "nearz", "nearZ", "near Z clipping plane", myNearz);
	ah.newNamedDouble('Z', "farz", "farZ", "far Z clipping plane", myFarz);
	ah.process(sCfg.c_str());

	myResolution[0] = width;
	myResolution[1] = height;
	myAspect = (float)width / height;

	mySetting = &setting;
}
Exemple #2
0
int ClientExec::addInstance(const Setting &instance)
{
    int ret;
    ClientInstance *ci = new ClientInstance();
    string testbed_ip;
    string labelconf;
    string cmd_line;
    string epoch;
 
    if (instance.lookupValue("testbed_ip", testbed_ip)) {
        cout << "This instance will be deployed on " << testbed_ip << endl;
	ci->testbed_ip = testbed_ip;
    } else {
        cerr << "error no testbed_ip - don't know where to deploy this instance" << endl;
	return -1;
    }
    if (instance.lookupValue("labelconf", labelconf)) {
        ci->labelconf = labelconf;
    } else {
        cerr << "labelconf is missing from node and is mandatory for stdout file naming" << endl;
        return -1;
    }
    if (instance.lookupValue("cmd_line", cmd_line)) {
	ci->cmd_line = cmd_line;
    } else {
	cerr << "cmd_line is mandatory, what am i deploying?" << endl; 
    }
    if (instance.lookupValue("epoch", epoch)) {
	ci->epoch = atoi(epoch.c_str());
    } else {
	cerr << "epoch is mandatory " << endl; 
    }
 
    instances.push_back(ci);
    return 0;


}
Exemple #3
0
bool sHotKeyOpts::Read(Setting& cProfile)
{
	std::string hk("Start");
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_RecordStart.m_vKey);
		s.lookupValue("Mod", m_RecordStart.m_fsMod);
	}
	hk = "End";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_RecordEnd.m_vKey);
		s.lookupValue("Mod", m_RecordEnd.m_fsMod);
	}
	hk = "Cancel";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_RecordCancel.m_vKey);
		s.lookupValue("Mod", m_RecordCancel.m_fsMod);
	}
	hk = "Next";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_Next.m_vKey);
		s.lookupValue("Mod", m_Next.m_fsMod);
	}
	hk = "Prev";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_Prev.m_vKey);
		s.lookupValue("Mod", m_Prev.m_fsMod);
	}
	hk = "Layout";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_ShowLayout.m_vKey);
		s.lookupValue("Mod", m_ShowLayout.m_fsMod);
	}
	hk = "Zoom";
	if(cProfile.exists(hk)) {
		const Setting& s = cProfile[hk];
		s.lookupValue("Key", m_Zoom.m_vKey);
		s.lookupValue("Mod", m_Zoom.m_fsMod);
	}
	bool pass = false;
	cProfile.lookupValue("PassThrough", pass);
	setPassThrough(pass); // see hook.cpp
	return true;
}
Exemple #4
0
void ReadTA(Setting& s, TextAttributes& taResult)
{
	s.lookupValue("position", (int&)taResult.position);
	s.lookupValue("posType", (int&)taResult.posType);
	s.lookupValue("xPosRatio", taResult.xPosRatio);
	s.lookupValue("yPosRatio", taResult.yPosRatio);
	std::string text;
	s.lookupValue("text", text);
	taResult.text = text.c_str();
	s.lookupValue("backgroundColor", (int&)taResult.backgroundColor);
	s.lookupValue("textColor", (int&)taResult.textColor);
	s.lookupValue("isFontSelected", taResult.isFontSelected);
	if (s.exists("Font"))
		ReadFont(s["Font"], taResult.logfont);
}
Exemple #5
0
void ReadIA(Setting& s, ImageAttributes& iaResult)
{
	s.lookupValue("Brightness", (int&)iaResult.m_lBrightness);
	s.lookupValue("Contrast", (int&)iaResult.m_lContrast);
	s.lookupValue("Position", (int&)iaResult.position);
	s.lookupValue("PosType", (int&)iaResult.posType);
	s.lookupValue("xPosRatio", iaResult.xPosRatio);
	s.lookupValue("yPosRatio", iaResult.yPosRatio);
	std::string text;
	if (s.lookupValue("text", text))
		iaResult.text = text.c_str();
}
//------------------------------------------------------------------------------
UniformResize::UniformResize(const Setting &setting, Domain *domain):
    Modifier(domain),
    relaxInterval( getSetting(setting, {"relaxInterval"}) )
{
    const Scaling & scaling = domain->scaling();
    startTime = getSetting(setting, {"startTime"});
    endTime = checkEndtime( getSetting(setting, {"endTime"}) );
    double n = double(endTime - startTime)/relaxInterval;
    string axis;
    setting.lookupValue("axis", axis);
    double sf = 1.0;

    //--------------------------------------
    // If velocity is used for the scaling:
    //--------------------------------------
    try
    {
        const Setting &cfg = domain->getConfigurationSettings();
        double dt = getSetting(cfg, {"integrator", "dt"});
        double v = setting["v0"];
        if(scaling.dimensionlessScaling)
        {
            dt /= scaling.T;
            v /= scaling.V;
        }
        double L = 1;
        const VEC3 & domainLength = domain->getDomainLength();
        if(axis == "X")
            L = domainLength[X];
        else if(axis == "Y")
            L = domainLength[Y];
        else if(axis == "Z")
            L = domainLength[Z];
        else
        {
            std::cerr << "When using a velocity scaling in 'ScaleBoundaries'"
                      << " only one axis can be scaled" << std::endl;
            exit(EXIT_FAILURE);
        }

        double L_ = L + v*(endTime - startTime)*dt;
        sf = L_/L;
    }
    catch(const SettingNotFoundException &nfex)
    {
        //--------------------------------------
        // If scaling parameter is used
        //--------------------------------------
        try
        {
            sf = setting["scaleFactor"];
        }
        catch(const SettingNotFoundException &nfex)
        {
            std::cerr << "In 'ScaleBoundaries' either a 'v0'' or 'scaleFactor'' "
                      << "must be supplied in the config file" << std::endl;
            exit(EXIT_FAILURE);
        }
    }

    //--------------------------------------
    // Finding the scale per iteration
    sf = pow(sf, 1.0/n);

    scalefactor = {1,1,1};
    if(axis == "X"){
        scalefactor[0] = sf;
        scaleAxis.push_back(X);
    }
    if(axis == "Y"){
        scalefactor[1] = sf;
        scaleAxis.push_back(Y);
    }

    if(axis == "Z"){
        scalefactor[2] = sf;
        scaleAxis.push_back(Z);
    }

    if(axis == "XY"){
        scalefactor[X] = sf;
        scalefactor[Y] = sf;
        scaleAxis.push_back(X);
        scaleAxis.push_back(Y);
    }

    if(axis == "YZ"){
        scalefactor[Y] = sf;
        scalefactor[Z] = sf;
        scaleAxis.push_back(Y);
        scaleAxis.push_back(Z);
    }

    if(axis == "XZ"){
        scalefactor[X] = sf;
        scalefactor[Z] = sf;
        scaleAxis.push_back(X);
        scaleAxis.push_back(Z);
    }

    if(axis == "XYZ"){
        scalefactor[X] = sf;
        scalefactor[Y] = sf;
        scalefactor[Z] = sf;
        scaleAxis.push_back(X);
        scaleAxis.push_back(Y);
        scaleAxis.push_back(Z);
    }
}
void PluginManager::load_plugin(const Setting& plugin_config) {
	string name, library, config_file;
	bool enabled = true;

	/* Lookup the name and library config items. Both are required. */
	if(!plugin_config.lookupValue("name", name)) {
		LOG_CRITICAL("Missing required plugin 'name' configuration option.\n");
	}
	if(!plugin_config.lookupValue("library", library)) {
		LOG_CRITICAL("Missing required plugin 'name' configuration option.\n");
	}
	
	/* Lookup the optional config and enabled config items. */
	plugin_config.lookupValue("config", config_file);
	plugin_config.lookupValue("enabled", enabled);

	boost::filesystem::path plugin_library_name();
	boost::filesystem::path plugin_config_full_path();
	boost::filesystem::path plugin_config_name();

	/* The path to the library works as follows:
	   1. If an absolute path, use as is.
	   2. If a relative path, build as follows:
	     a. Start with the path to the 'npsgate' executable
		 b. Append the 'plugindir' path from the main config file
		 c. Append the 'library' option for this plugin
	*/
	boost::filesystem::path plugin_library_path(library);
	if(plugin_library_path.is_absolute()) {
		// use as is, path is absolute
	} else {
		plugin_library_path = context.npsgate_execute_path;
		plugin_library_path /= context.plugin_dir;
		plugin_library_path /= library;
	}

	/* The path to the config file works as follows:
	   1. If an absolute path, use as is.
	   2. If a relative path, build as follows:
	     a. Start with the path to the main config file
		 b. Append the 'plugin_conf_dir' path from the main config file
		 c. Append the 'config' option for this plugin
	*/
	boost::filesystem::path plugin_config_file(config_file);
	if(plugin_config_file.is_absolute()) {
		// use as is, path is absolute
	} else {
		plugin_config_file = context.main_config_path;
		plugin_config_file /= context.plugin_config_dir;
		plugin_config_file /= config_file;
	}


	library = plugin_library_path.native();
	config_file = plugin_config_file.native();

	if(enabled) {
		PluginCore* p = new PluginCore(context, name);
		p->load(library, config_file);
		p->init();
		plugins[name] = p;
		plugin_threads[p->thread_id] = name;
	}

	LOG_INFO("Plugin Loaded: %s\n", name.c_str());
	LOG_INFO("  Library: %s\n", library.c_str());
	LOG_INFO("  Config: %s\n", config_file.c_str());
	LOG_INFO("  Enabled: %u\n", enabled);

}
Exemple #8
0
void ReadFont(Setting& s, LOGFONT& f)
{
	unsigned tmp;
	if (s.lookupValue("CharSet", tmp))
		f.lfCharSet = tmp;
	if (s.lookupValue("ClipPrecision", tmp))
		f.lfClipPrecision = tmp;
	s.lookupValue("Escapement", (int&)f.lfEscapement);
	std::string text;
	if (s.lookupValue("FaceName", text))
		strncpy(f.lfFaceName, text.c_str(), 32);
	s.lookupValue("Height", (int&)f.lfHeight);
	if (s.lookupValue("Italic", tmp))
		f.lfItalic = tmp;
	s.lookupValue("Orientation", (int&)f.lfOrientation);
	if (s.lookupValue("OutPrecision", tmp))
		f.lfOutPrecision = tmp;
	if (s.lookupValue("PitchAndFamily", tmp))
		f.lfPitchAndFamily = tmp;
	if (s.lookupValue("Quality", tmp))
		f.lfQuality = tmp;
	if (s.lookupValue("StrikeOut", tmp))
		f.lfStrikeOut = tmp;
	if (s.lookupValue("Underline", tmp))
		f.lfUnderline = tmp;
	s.lookupValue("Weight", (int&)f.lfWeight);
	s.lookupValue("Width", (int&)f.lfWidth);
}