00001 /****************************************************************************** 00002 * SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3 * 00003 * (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify it * 00006 * under the terms of the GNU General Public License as published by the Free * 00007 * Software Foundation; either version 2 of the License, or (at your option) * 00008 * any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, but WITHOUT * 00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * 00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * 00013 * more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License along * 00016 * with this program; if not, write to the Free Software Foundation, Inc., 51 * 00017 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 00018 ******************************************************************************* 00019 * SOFA :: Applications * 00020 * * 00021 * Authors: M. Adam, J. Allard, B. Andre, P-J. Bensoussan, S. Cotin, C. Duriez,* 00022 * H. Delingette, F. Falipou, F. Faure, S. Fonteneau, L. Heigeas, C. Mendoza, * 00023 * M. Nesme, P. Neumann, J-P. de la Plata Alcade, F. Poyer and F. Roy * 00024 * * 00025 * Contact information: contact@sofa-framework.org * 00026 ******************************************************************************/ 00027 #ifndef SOFA_GUI_SOFAGUI_H 00028 #define SOFA_GUI_SOFAGUI_H 00029 00030 #include <sofa/simulation/common/Node.h> 00031 00032 #include <list> 00033 //class QWidget; 00034 00035 namespace sofa 00036 { 00037 00038 namespace gui 00039 { 00040 00041 class SofaGUI 00042 { 00043 00044 public: 00045 00048 00049 static void SetProgramName(const char* argv0); 00050 00051 static const char* GetProgramName(); 00052 00053 static std::vector<std::string> ListSupportedGUI(); 00054 static std::string ListSupportedGUI(char separator); 00055 00056 static const char* GetGUIName(); 00057 00058 static void SetGUIName(const char* name=""); 00059 static void AddGUIOption(const char* option); 00060 00061 static int Init(); 00062 00063 static int Init(const char* argv0, const char* name = "") 00064 { 00065 SetProgramName(argv0); 00066 SetGUIName(name); 00067 return Init(); 00068 } 00069 00070 static int MainLoop(sofa::simulation::Node* groot = NULL, const char* filename = NULL); 00071 00072 00073 00074 static SofaGUI* CurrentGUI(); 00075 00076 static void Redraw(); 00077 00078 static sofa::simulation::Node* CurrentSimulation(); 00079 00080 00081 00083 00084 public: 00085 00088 00089 SofaGUI(); 00090 00091 virtual int mainLoop()=0; 00092 virtual void redraw()=0; 00093 virtual int closeGUI()=0; 00094 00095 virtual sofa::simulation::Node* currentSimulation()=0; 00096 00098 00101 00102 typedef int InitGUIFn(const char* name, const std::vector<std::string>& options); 00103 typedef SofaGUI* CreateGUIFn(const char* name, const std::vector<std::string>& options, sofa::simulation::Node* groot, const char* filename); 00104 static int RegisterGUI(const char* name, CreateGUIFn* creator, InitGUIFn* init=NULL, int priority=0); 00105 00107 00108 protected: 00110 virtual ~SofaGUI(); 00111 00112 static const char* programName; 00113 static std::string guiName; 00114 static std::vector<std::string> guiOptions; 00115 static SofaGUI* currentGUI; 00116 00117 struct GUICreator 00118 { 00119 const char* name; 00120 InitGUIFn* init; 00121 CreateGUIFn* creator; 00122 int priority; 00123 }; 00124 //static std::list<GUICreator> guiCreators; 00125 static std::list<GUICreator>& guiCreators(); 00126 00127 static GUICreator* GetGUICreator(const char* name = NULL); 00128 }; 00129 00130 } // namespace gui 00131 00132 } // namespace sofa 00133 00134 #endif
1.5.7.1