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 00028 #include "RealGUI.h" 00029 #include "Main.h" 00030 00031 00032 00033 #include <sofa/simulation/tree/Simulation.h> 00034 00035 #include <iostream> 00036 #include <qapplication.h> 00037 #include <qpushbutton.h> 00038 #include <qcheckbox.h> 00039 #include <qlineedit.h> 00040 #include <qtabwidget.h> 00041 #ifndef SOFA_QT4 00042 #include <qlistview.h> 00043 #include <qheader.h> 00044 #endif 00045 00046 00047 00048 00049 namespace sofa 00050 { 00051 00052 namespace gui 00053 { 00054 00055 namespace qt 00056 { 00057 00058 RealGUI* gui = NULL; 00059 QApplication* application = NULL; 00060 00061 const char* progname=""; 00062 00063 using sofa::simulation::tree::GNode; 00064 /* 00065 void dumpGraph(GNode* node, Q3ListViewItem* item) 00066 { 00067 if (std::string(node->getName(),0,7) != "default") 00068 item->setText(0, node->getName().c_str()); 00069 Q3ListViewItem* last = NULL; 00070 for(GNode::ObjectIterator it = node->object.begin(); it != node->object.end(); ++it) 00071 { 00072 core::objectmodel::BaseObject* o = *it; 00073 Q3ListViewItem* child = (last = new Q3ListViewItem(item, last)); 00074 std::string name = sofa::helper::gettypename(typeid(*o)); 00075 std::string::size_type pos = name.find('<'); 00076 if (pos != std::string::npos) 00077 name.erase(pos); 00078 if (std::string(o->getName(),0,7) != "default") 00079 { 00080 name += " "; 00081 name += o->getName(); 00082 } 00083 child->setText(0, name.c_str()); 00084 } 00085 for(GNode::ChildIterator it = node->child.begin(); it != node->child.end(); ++it) 00086 { 00087 dumpGraph(*it, (last = new Q3ListViewItem(item, last))); 00088 } 00089 item->setOpen(true); 00090 } 00091 */ 00092 // --------------------------------------------------------------------- 00093 // --- 00094 // --------------------------------------------------------------------- 00095 00096 int MainLoop(const char* pname, sofa::simulation::tree::GNode* groot, const char* filename) 00097 { 00098 progname = pname; 00099 { 00100 int argc=1; 00101 char* argv[1]; 00102 argv[0] = strdup(progname); 00103 application = new QApplication(argc,argv); 00104 free(argv[0]); 00105 } 00106 // create interface 00107 gui = new RealGUI("qt"); 00108 if (groot) 00109 gui->setScene(groot, filename); 00110 //((RealGUI*) gui)->setTitle(filename); 00111 //gui->viewer->SwitchToPresetView(); 00112 00113 application->setMainWidget( gui ); 00114 00115 00116 // show the gui 00117 gui->show(); 00118 00119 00120 return application->exec(); 00121 } 00122 00123 bool InsertTab(QWidget* tab, const char* name) 00124 { 00125 if (gui==NULL) return false; 00126 gui->tabs->insertTab(tab,name); 00127 gui->tabs->showPage(tab); 00128 return true; 00129 } 00130 00131 00132 00133 //********************************************************************************** 00134 //TODO!!!!!!!!!!! 00135 void Redraw() 00136 { 00137 00138 if (gui==NULL) return; 00139 gui->viewer->getQWidget()->update(); 00140 } 00141 00142 sofa::simulation::tree::GNode* CurrentSimulation() 00143 { 00144 00145 if (gui==NULL) return NULL; 00146 00147 00148 return gui->viewer->getScene(); 00149 } 00150 00151 00152 } // namespace qt 00153 00154 } // namespace gui 00155 00156 } // namespace sofa
1.5.7.1