Exemple #1
0
 CQTOpenGLUserFunctions* CQTOpenGLMainWindow::CreateUserFunctions(TConfigurationNode& t_tree) {
    /* Parse XML for user functions */
    if(NodeExists(t_tree, "user_functions")) {
       /* Use the passed user functions */
       /* Get data from XML */
       TConfigurationNode tNode = GetNode(t_tree, "user_functions");
       std::string strLabel, strLibrary;
       GetNodeAttribute(tNode, "label", strLabel);
       GetNodeAttribute(tNode, "library", strLibrary);
       /* Load the library taking care of the $ARGOSINSTALLDIR variable */
       void* ptUserFunctions = ::dlopen(ExpandARGoSInstallDir(strLibrary).c_str(),
                                        RTLD_LOCAL | RTLD_LAZY);
       if(ptUserFunctions == NULL) {
          THROW_ARGOSEXCEPTION("Failed opening QTOpenGL user function library \""
                               << strLibrary << "\": " << dlerror()
                               << std::endl);
       }
       /* Create the user functions */
       if(mapQTOpenGLUserFunctionFactory.find(strLabel) == mapQTOpenGLUserFunctionFactory.end()) {
          THROW_ARGOSEXCEPTION("Unknown QTOpenGL user function type \"" << strLabel
                               << "\", probably your user functions have been registered with a different name."
                               << std::endl);
       }
       return mapQTOpenGLUserFunctionFactory[strLabel]();
    }
    else {
       /* Use standard (empty) user functions */
       return new CQTOpenGLUserFunctions;
    }
 }
 void CFloorEntity::Init(TConfigurationNode& t_tree) {
    /* Init parent */
    CEntity::Init(t_tree);
    /* Get arena size */
    m_cFloorSize = CSimulator::GetInstance().GetSpace().GetArenaSize();
    /* Parse XML */
    GetNodeAttribute(t_tree, "source", m_strColorSource);
    if(m_strColorSource == "image") {
       std::string strPath;
       GetNodeAttribute(t_tree, "path", strPath);
       strPath = ExpandARGoSInstallDir(strPath);
       m_pcColorSource = new CFloorColorFromImageFile(strPath,
                                                      m_cFloorSize.GetX(),
                                                      m_cFloorSize.GetY());
    }
    else if(m_strColorSource == "loop_functions") {
       GetNodeAttribute(t_tree, "pixels_per_meter", m_unPixelsPerMeter);
       m_pcColorSource = new CFloorColorFromLoopFunctions(m_unPixelsPerMeter,
                                                          m_cFloorSize.GetX(),
                                                          m_cFloorSize.GetY());
    }
    else {
       THROW_ARGOSEXCEPTION("Unknown image source \"" <<
                            m_strColorSource <<
                            "\" for the floor entity \"" <<
                            GetId() <<
                            "\"");
    }
 }