Пример #1
0
int GUIManager::Init(const char* argv0, const char* name /* = "" */)
{
  SofaGUI::SetProgramName(argv0);
  sofa::component::init();
  sofa::simulation::xml::initXml();
  GUICreator* creator;

  if (currentGUI)
    return 0; // already initialized
  
  if (guiCreators.empty())
  {
        std::cerr << "ERROR(SofaGUI): No GUI registered."<<std::endl;
        return 1;
  }

  if( strcmp(name,"") == 0 || name == NULL){
    name = GetValidGUIName(); // get the default gui name
  }
  creator = GetGUICreator(name);
  if(!creator){
    return 1;
  }
  valid_guiname = name; // at this point we must have a valid name for the gui.
  
  if (creator->init)
    return (*creator->init)(valid_guiname, guiOptions);
  else
    return 0;
}
Пример #2
0
int GUIManager::createGUI(sofa::simulation::Node::SPtr groot, const char* filename)
{
    if (!currentGUI)
    {
        GUICreator* creator = GetGUICreator(valid_guiname);
        if (!creator)
        {
            return 1;
        }
        currentGUI = (*creator->creator)(valid_guiname, guiOptions, groot, filename);
        if (!currentGUI)
        {
            std::cerr << "ERROR(GUIManager): GUI "<<valid_guiname<<" creation failed."<<std::endl;
            return 1;
        }
    }
	return 0;
}
Пример #3
0
int GUIManager::Init(const char* argv0, const char* name)
{
    BaseGUI::SetProgramName(argv0);
    BaseGUI::SetArgumentParser(currentArgumentParser);
    sofa::simulation::common::init();

    static bool first = true;
    if (first)
    {
        sofa::component::initComponentBase();
        sofa::component::initComponentCommon();
        sofa::component::initComponentGeneral();
        sofa::component::initComponentAdvanced();
        sofa::component::initComponentMisc();

        first = false;
    }

    if (currentGUI)
        return 0; // already initialized

    if (guiCreators.empty())
    {
        msg_error("GUIManager") << "No GUI registered.";
        return 1;
    }

    if( name == NULL || strcmp(name,"") == 0 )
    {
        name = GetValidGUIName(); // get the default gui name
    }
    GUICreator *creator = GetGUICreator(name);
    if(!creator)
    {
        return 1;
    }
    valid_guiname = name; // at this point we must have a valid name for the gui.

    return 0;
}
Пример #4
0
int GUIManager::createGUI(sofa::simulation::Node::SPtr groot, const char* filename)
{
    if (!currentGUI)
    {
        GUICreator* creator = GetGUICreator(valid_guiname);
        if (!creator)
        {
            return 1;
        }
        currentGUI = (*creator->creator)(valid_guiname, groot, filename);
        if (!currentGUI)
        {
            msg_error("GUIManager") << "GUI '"<<valid_guiname<<"' creation failed." ;
            return 1;
        }
        //Save this GUI type as the last used GUI
        const std::string lastGuiFilePath = BaseGUI::getConfigDirectoryPath() + "/lastUsedGUI.ini";
        std::ofstream out(lastGuiFilePath.c_str(),std::ios::out);
        out << valid_guiname << std::endl;
        out.close();
    }
    return 0;
}