deltanll_hypotest::deltanll_hypotest(const theta::Configuration & cfg):
        ParameterDependentProducer(cfg), init(false) {
    Setting s = cfg.setting;
    minimizer = theta::PluginManager<Minimizer>::build(theta::Configuration(cfg, s["minimizer"]));
    s_plus_b = theta::PluginManager<Distribution>::build(theta::Configuration(cfg, s["signal-plus-background-distribution"]));
    b_only = theta::PluginManager<Distribution>::build(theta::Configuration(cfg, s["background-only-distribution"]));
    if(s.exists("restrict_poi")){
        boost::shared_ptr<VarIdManager> vm = cfg.pm->get<VarIdManager>();
        restrict_poi = vm->get_par_id(s["restrict_poi"]);
        par_ids.insert(*restrict_poi);
        default_poi_value = NAN;
        if(s.exists("default_poi_value")) default_poi_value = s["default_poi_value"];
        poi_value = default_poi_value;
    }
    fill_mode_support(s_plus_b_mode, s_plus_b_support, *s_plus_b);
    fill_mode_support(b_only_mode, b_only_support, *b_only);
    if(not (s_plus_b->get_parameters()==b_only->get_parameters())){
        throw ConfigurationException("parameters of the distributions 'signal-plus-background' and 'background-only' do not match");
    }
    c_nll_b = products_sink->declare_product(*this, "nll_b", theta::typeDouble);
    c_nll_sb = products_sink->declare_product(*this, "nll_sb", theta::typeDouble);
    c_nll_diff = products_sink->declare_product(*this, "nll_diff", theta::typeDouble);
    if(restrict_poi){
       c_poi = products_sink->declare_product(*this, "poi", theta::typeDouble);
    }
}
Exemple #2
0
void VRPNService::setup(Setting& settings)
{
    if(settings.exists("serverIP"))
    {
        server_ip =  (const char*)settings["serverIP"];
    }

    if(settings.exists("objects"))
    {
        Setting& strs = settings["objects"];
        for(int i = 0; i < strs.getLength(); i++)
        {
            Setting& str = strs[i];
            TrackerInfo trackerInfo;
            trackerInfo.object_name = (const char*)str["name"];
            if( str.exists("serverIP") ){
                trackerInfo.server_ip = (const char*)str["serverIP"]; // Use object specified IP
            } else {
                trackerInfo.server_ip = server_ip; // Use global IP
            }

            if(str.exists("userId"))
            {
                unsigned int uid = (unsigned int)str["userId"];
                trackerInfo.userId = (unsigned short)uid;
				ofmsg("Tracker %1% user ID %2%", %trackerInfo.object_name %uid);
            }
            else
            {
Exemple #3
0
void PQService::setup(Setting& settings)
{
	if(settings.exists("serverIP"))
	{
		server_ip =  (const char*)settings["serverIP"];
	}
	if(settings.exists("maxBlobSize"))
	{
		maxBlobSize =  settings["maxBlobSize"];
	}
	if(settings.exists("serverX"))
	{
		serverX =  settings["serverX"];
		printf("PQService: ServerX set to %d\n", serverX);
	}
	if(settings.exists("serverY"))
	{
		serverY =  settings["serverY"];
		printf("PQService: ServerY set to %d\n", serverY);
	}
	if(settings.exists("screenX"))
	{
		screenX =  settings["screenX"];
		printf("PQService: ScreenX set to %d\n", screenX);
	}
	if(settings.exists("screenY"))
	{
		screenY =  settings["screenY"];
		printf("PQService: ScreenY set to %d\n", screenY);
	}
	if(settings.exists("screenOffsetX"))
	{
		screenOffsetX =  settings["screenOffsetX"];
		printf("PQService: ScreenOffsetX set to %d\n", screenOffsetX);
	}
	if(settings.exists("screenOffsetY"))
	{
		screenOffsetY =  settings["screenOffsetY"];
		printf("PQService: ScreenOffsetY set to %d\n", screenOffsetY);
	}
	if(settings.exists("moveThreshold"))
	{
		move_threshold =  settings["moveThreshold"];
		printf("PQService: move threshold set to %d\n", move_threshold);
	}
	if(settings.exists("useGestureManager"))
	{
		useGestureManager = settings["useGestureManager"];
		if( useGestureManager )
			printf("PQService: Gesture Manager Enabled\n");
	}
}
Exemple #4
0
bool sHotKeyOpts::Write(Setting& cProfile)
{
	Setting* s;
	std::string hk("Start");
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_RecordStart.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_RecordStart.m_fsMod, Setting::TypeInt);

	hk = "End";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_RecordEnd.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_RecordEnd.m_fsMod, Setting::TypeInt);

	hk = "Cancel";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_RecordCancel.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_RecordCancel.m_fsMod, Setting::TypeInt);

	hk = "Next";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_Next.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_Next.m_fsMod, Setting::TypeInt);

	hk = "Prev";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_Prev.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_Prev.m_fsMod, Setting::TypeInt);

	hk = "Layout";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_ShowLayout.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_ShowLayout.m_fsMod, Setting::TypeInt);

	hk = "Zoom";
	if(cProfile.exists(hk)) {
		s = &(cProfile[hk]);
	} else
		s = &(cProfile.add(hk, Setting::TypeGroup));
	UpdateSetting(*s, "Key", (int&)m_Zoom.m_vKey, Setting::TypeInt);
	UpdateSetting(*s, "Mod", (int&)m_Zoom.m_fsMod, Setting::TypeInt);
	return true;
}
minimizer_chain::minimizer_chain(const theta::Configuration & cfg) {
    Setting s = cfg.setting;
    const size_t n = s["minimizers"].size();
    minimizers.reserve(n);
    size_t n_minimizers = 0;
    for(size_t i=0; i<n; ++i) {
        minimizers.push_back(PluginManager<Minimizer>::build(Configuration(cfg, s["minimizers"][i])));
        ++n_minimizers;
    }
    if(s.exists("last_minimizer")) {
        last_minimizer = PluginManager<Minimizer>::build(Configuration(cfg, s["last_minimizer"]));
        ++n_minimizers;
    }
    if(n_minimizers==0) throw ConfigurationException("no minimizers specified; required is at least one (counting last_minimizer)");
}
Exemple #6
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 #7
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 #8
0
void WriteTA(Setting& s, TextAttributes& taResult)
{
	UpdateSetting(s,"position", (int&)taResult.position, Setting::TypeInt);
	UpdateSetting(s,"posType", (int&)taResult.posType, Setting::TypeInt);
	UpdateSetting(s,"xPosRatio", taResult.xPosRatio, Setting::TypeInt);
	UpdateSetting(s,"yPosRatio", taResult.yPosRatio, Setting::TypeInt);
	std::string text(taResult.text);
	UpdateSetting(s,"text", text, Setting::TypeString);
	UpdateSetting(s,"backgroundColor", (int&)taResult.backgroundColor, Setting::TypeInt);
	UpdateSetting(s,"textColor", (int&)taResult.textColor, Setting::TypeInt);
	UpdateSetting(s,"isFontSelected", taResult.isFontSelected, Setting::TypeInt);
	Setting* sf;
	if (s.exists("Font"))
		sf = &(s["Font"]);
	else
		sf = &(s.add("Font", Setting::TypeGroup));
	WriteFont(*sf, taResult.logfont);
}
Exemple #9
0
void Camera::setup(Setting& s)
{
    //set position of camera
    Vector3f camPos = Config::getVector3fValue("position", s, getPosition()); 
    setPosition(camPos);

    //set orientation of camera
    // NOTE: we want to either read orientation from the config or keep the default one.
    // Since orientation is expressed in yaw, pitch roll in the config file but there is no
    // way to get that from the camera (rotation is only as a quaternion) we cannot use the default
    // value in the Config::getVector3fValue.
    if(s.exists("orientation"))
    {
        Vector3f camOri = Config::getVector3fValue("orientation", s); 
        setPitchYawRoll(camOri * Math::DegToRad);
    }
    
    myTrackerSourceId = Config::getIntValue("trackerSourceId", s, -1);
    if(myTrackerSourceId != -1) myTrackingEnabled = true;

    //setup camera controller.  The camera needs to be setup before this otherwise its values will be rewritten

    String controllerName;
    controllerName = Config::getStringValue("controller", s);
    StringUtils::toLowerCase(controllerName);

    if(controllerName != "")
    {
        CameraController* controller = NULL;
        ofmsg("Camera controller: %1%", %controllerName);
        if(controllerName == "keyboardmouse") controller = new KeyboardMouseCameraController();
        if(controllerName == "mouse") controller = new MouseCameraController();
        if(controllerName == "wand") controller = new WandCameraController();
        if(controllerName == "gamepad") controller = new GamepadCameraController();

        setController(controller);
        if(myController != NULL) 
        {
            myController->setup(s);
            setControllerEnabled(true);
        }
    }
mcmc_posterior_histo::mcmc_posterior_histo(const theta::Configuration & cfg): Producer(cfg), init(false), smooth(false){
    Setting s = cfg.setting;
    boost::shared_ptr<VarIdManager> vm = cfg.pm->get<VarIdManager>();
    size_t n = s["parameters"].size();
    for(size_t i=0; i<n; ++i){
        string parameter_name = s["parameters"][i];
        parameter_names.push_back(parameter_name);
        parameters.push_back(vm->get_par_id(parameter_name));
        nbins.push_back(static_cast<unsigned int>(s["histo_" + parameter_name]["nbins"]));
        lower.push_back(s["histo_" + parameter_name]["range"][0]);
        upper.push_back(s["histo_" + parameter_name]["range"][1]);
    }
    mcmc_strategy = construct_mcmc_strategy(cfg);
    if(s.exists("smooth")){
        smooth = s["smooth"];
    }
    for(size_t i=0; i<parameters.size(); ++i){
        columns.push_back(products_sink->declare_product(*this, "posterior_" + parameter_names[i], theta::typeHisto));
    }
}
Exemple #11
0
void DisplayTileConfig::parseConfig(const Setting& sTile, DisplayConfig& cfg)
{
    settingData = &sTile;

    DisplayTileConfig* tc = this;

    tc->name = sTile.getName();

    String sm = Config::getStringValue("stereoMode", sTile, "default");
    StringUtils::toLowerCase(sm);
    if(sm == "default") tc->stereoMode = DisplayTileConfig::Default;
    else if(sm == "mono") tc->stereoMode = DisplayTileConfig::Mono;
        // 'interleaved' defaults to row interleaved
    else if(sm == "interleaved") tc->stereoMode = DisplayTileConfig::LineInterleaved;
    else if(sm == "rowinterleaved") tc->stereoMode = DisplayTileConfig::LineInterleaved;
    else if(sm == "columninterleaved") tc->stereoMode = DisplayTileConfig::ColumnInterleaved;
    else if(sm == "sidebyside") tc->stereoMode = DisplayTileConfig::SideBySide;
                
    tc->invertStereo = Config::getBoolValue("invertStereo", sTile);
    tc->enabled = Config::getBoolValue("enabled", sTile);
                
    //tc.index = index;
    //tc.interleaved = Config::getBoolValue("interleaved", sTile);
    tc->device = Config::getIntValue("device", sTile);

    tc->center = Config::getVector3fValue("center", sTile, Vector3f::Zero());
    tc->yaw = Config::getFloatValue("yaw", sTile, 0);
    tc->pitch = Config::getFloatValue("pitch", sTile, 0);

    tc->position = Config::getVector2iValue("position", sTile);
    tc->disableScene = Config::getBoolValue("disableScene", sTile);

    tc->offscreen = Config::getBoolValue("offscreen", sTile, false);
    tc->borderless = Config::getBoolValue("borderless", sTile, cfg.borderless);

    tc->disableMouse = Config::getBoolValue("disableMouse", sTile, false);

    tc->isHMD = Config::getBoolValue("isHMD", sTile, false);

    //tc->viewport = Config::getVector4fValue("viewport", sTile, tc->viewport);

    // If the tile config contains a size entry use it, oterwise use the default tile and bezel size data
    if(sTile.exists("size"))
    {
        tc->size = Config::getVector2fValue("size", sTile);
    }
    else
    {
        tc->size = cfg.tileSize - cfg.bezelSize;
    }

    if(sTile.exists("resolution"))
    {
        tc->pixelSize = Config::getVector2iValue("resolution", sTile);
    }
    else
    {
        tc->pixelSize = cfg.tileResolution;
    }

    if(sTile.exists("offset"))
    {
        tc->offset = Config::getVector2iValue("offset", sTile);
    }
    else
    {
        std::vector<std::string> args = StringUtils::split(String(sTile.getName()), "xt");
        Vector2i index = Vector2i(atoi(args[0].c_str()), atoi(args[1].c_str()));
        tc->offset = index.cwiseProduct(tc->pixelSize);
        cfg.tileGrid[index[0]][index[1]] = tc;
    }

    // Parse custom grid options
    tc->isInGrid = Config::getBoolValue("isInGrid", sTile, false);
    if(tc->isInGrid)
    {
        tc->gridX = Config::getIntValue("gridX", sTile, 0);
        tc->gridY = Config::getIntValue("gridY", sTile, 0);
        cfg.tileGrid[tc->gridX][tc->gridY] = tc;
    }

    // Custom camera
    tc->cameraName = Config::getStringValue("cameraName", sTile, "");

    // Compute default values for this tile corners. These values may be overwritted by display config generators applied later on.
    computeTileCorners();
}
Exemple #12
0
    void _apply(Setting& root, Setting& source, LockList* lockList)
    {
        Setting* s = nullptr;

        if (!source.isRoot()) {
            const char* name = source.getName();
            if (name != nullptr) {
                if (root.exists(name)) {
                    s = &root[name];

                    if (_isLocked(*s, true, lockList)) {
                        LogWarn("Ignored updating configuration '%s' to value "
                                "'%s'. Setting locked to value '%s'.",
                                s->getPath().c_str(),
                                settingToString(source).c_str(),
                                settingToString(*s).c_str());

                        return;
                    }

                    if (!s->isGroup()) {
                        root.remove(s->getIndex());
                        s = &root.add(name, source.getType());
                    }
                } else {
                    s = &root.add(name, source.getType());

                    if (_isLocked(*s, false, lockList)) {
                        LogWarn("Ignored creating configuration '%s' with "
                                "value '%s'. Setting locked.",
                                s->getPath().c_str(),
                                settingToString(*s).c_str());

                        root.remove(s->getIndex());
                        return;
                    }
                }
            } else {
                // List or array elements
                s = &root.add(source.getType());
            }
        } else {
            s = &root;
        }

        switch (source.getType())
        {
            case Setting::Type::TypeInt: {
                *s = (int)source;
                break;
            }

            case Setting::Type::TypeInt64: {
                *s = (long long)source;
                break;
            }

            case Setting::Type::TypeString: {
                *s = (const char*)source;
                break;
            }

            case Setting::Type::TypeBoolean: {
                *s = (bool)source;
                break;
            }

            case Setting::Type::TypeArray:
            case Setting::Type::TypeList:
            case Setting::Type::TypeGroup: {
                for (int i = 0; i < source.getLength(); ++i) {
                    _apply(*s, source[i], lockList);
                }
                break;
            }

            default: {
                assert(false);
                break;
            }
        }
    }