Changeset 484 for trunk/geant4/interfaces/common/src
- Timestamp:
- Jun 5, 2007, 4:09:01 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/geant4/interfaces/common/src/G4Qt.cc
r481 r484 25 25 // 26 26 // 27 // $Id: G4 Xt.cc,v 1.11 2006/06/29 19:10:28 gunter Exp$27 // $Id: G4Qt.cc,v 1.11 2007/05/29 11:10:28 $ 28 28 // GEANT4 tag $Name: geant4-08-01 $ 29 29 // 30 // G.Barrand30 // L. Garnier 31 31 32 #if defined(G4INTY_BUILD_ XT) || defined(G4INTY_USE_XT)32 #if defined(G4INTY_BUILD_QT) || defined(G4INTY_USE_QT) 33 33 34 34 #include <stdlib.h> 35 35 #include <string.h> 36 36 37 #include <X11/Intrinsic.h>38 #include <X11/Shell.h>39 40 37 #include "G4ios.hh" 41 38 42 #include "G4 Xt.hh"39 #include "G4Qt.hh" 43 40 44 41 #define NewString(str) \ … … 49 46 //static void XDisplaySetWindowToNormalState (Display*,Window); 50 47 51 G4 Xt* G4Xt::instance = NULL;48 G4Qt* G4Qt::instance = NULL; 52 49 53 static G4bool XtInited = FALSE; 54 static int argn = 0; 55 static char** args = NULL; 56 static XtAppContext appContext = NULL; 57 static Widget topWidget = NULL; 50 static G4bool QtInited = FALSE; 51 //static int argn = 0; 52 //static char** args = NULL; 53 // static QtAppContext appContext = NULL; 54 static QMainWindow *mainWidget = NULL; 55 58 56 /***************************************************************************/ 59 G4 Xt* G4Xt::getInstance (57 G4Qt* G4Qt::getInstance ( 60 58 ) 61 59 /***************************************************************************/ 62 60 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ 63 61 { 64 return G4 Xt::getInstance (0,NULL,(char*)"Geant4");62 return G4Qt::getInstance (0,NULL,(char*)"Geant4"); 65 63 } 66 64 /***************************************************************************/ 67 G4 Xt* G4Xt::getInstance (65 G4Qt* G4Qt::getInstance ( 68 66 int a_argn 69 67 ,char** a_args … … 74 72 { 75 73 if (instance==NULL) { 76 instance = new G4 Xt(a_argn,a_args,a_class);74 instance = new G4Qt(a_argn,a_args,a_class); 77 75 } 78 76 return instance; 79 77 } 80 78 /***************************************************************************/ 81 G4 Xt::G4Xt (79 G4Qt::G4Qt ( 82 80 int a_argn 83 81 ,char** a_args … … 87 85 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ 88 86 { 89 if(XtInited==FALSE) { //Xt should be Inited once ! 90 if(a_argn!=0) { //Save args. 91 args = (char**)malloc(a_argn * sizeof(char*)); 92 if(args!=NULL) { 93 argn = a_argn; 94 for(int argi=0;argi<a_argn;argi++) { 95 args[argi] = (char*)NewString (a_args[argi]); 96 } 97 } 87 if(QtInited==FALSE) { //Qt should be Inited once ! 88 89 new QApplication (a_argn, a_args); 90 mainWidget = new QMainWindow(); 91 92 if(mainWidget==NULL) { 93 G4cout << "G4Qt : Unable to init Qt." << G4endl; 98 94 } 99 #if XtSpecificationRelease == 4 100 Cardinal narg; 101 narg = (Cardinal)a_argn; 102 #else 103 int narg; 104 narg = a_argn; 105 #endif 106 Arg xargs[1]; 107 XtSetArg (xargs[0],XtNgeometry,"100x100"); 108 topWidget = XtAppInitialize (&appContext,a_class, 109 NULL,(Cardinal)0, 110 &narg,a_args,NULL, 111 xargs,1); 112 if(topWidget==NULL) { 113 G4cout << "G4Xt : Unable to init Xt." << G4endl; 114 } 115 // Restore a_args. XtAppInitialize corrupts the given ones !!! 116 if( (a_argn!=0) && (args!=NULL)) { 117 for(int argi=0;argi<a_argn;argi++) { 118 if(args[argi]!=NULL) 119 strcpy(a_args[argi],args[argi]); 120 else 121 a_args[argi] = NULL; 122 } 123 } 124 // If topWidget not realized, pbs with Inventor shells. 125 XtSetMappedWhenManaged (topWidget,False); 126 XtRealizeWidget (topWidget); 127 XtInited = TRUE; 95 QtInited = TRUE; 96 mainWidget->show(); 97 qApp->exec(); 128 98 } 129 SetArguments (argn,args); 130 SetMainInteractor (topWidget); 131 AddDispatcher ((G4DispatchFunction)XtDispatchEvent); 99 // AddDispatcher ((G4DispatchFunction)QtDispatchEvent); // FIXME 132 100 } 133 101 /***************************************************************************/ 134 G4 Xt::~G4Xt (102 G4Qt::~G4Qt ( 135 103 ) 136 104 /***************************************************************************/ … … 142 110 } 143 111 /***************************************************************************/ 144 G4bool G4 Xt::Inited (112 G4bool G4Qt::Inited ( 145 113 ) 146 114 /***************************************************************************/ 147 115 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ 148 116 { 149 return XtInited;117 return QtInited; 150 118 } 151 119 /***************************************************************************/ 152 void* G4 Xt::GetEvent (120 void* G4Qt::GetEvent ( 153 121 ) 154 122 /***************************************************************************/ 155 123 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ 156 124 { 157 static XEvent event; 158 if(appContext==NULL) return NULL; 159 if(topWidget==NULL) return NULL; 160 XtAppNextEvent (appContext, &event); 161 return &event; 125 //FIXME 126 G4cout << "G4Qt : Rien compris a cette fonction G4Qt::GetEvent." << G4endl; 127 // static XEvent event; 128 // if(appContext==NULL) return NULL; 129 // if(mainApp==NULL) return NULL; 130 // QtAppNextEvent (appContext, &event); 131 // return &event; 162 132 } 163 133 /***************************************************************************/ 164 void G4Xt::PutStringInResourceDatabase ( 165 char* a_string 134 void G4Qt::FlushAndWaitExecution ( 166 135 ) 167 136 /***************************************************************************/ 168 137 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ 169 138 { 170 if(topWidget==NULL) return; 171 if(a_string==NULL) return; 172 Display* dpy = XtDisplay(topWidget); 173 XrmDatabase dbres = XrmGetStringDatabase (a_string); 174 if(dbres==NULL) return; 175 XrmDatabase database = XrmGetDatabase (dpy); 176 if(database!=NULL) { 177 XrmMergeDatabases (dbres,&database); 178 } else { 179 XrmSetDatabase (dpy,dbres); 180 } 181 } 182 /***************************************************************************/ 183 void G4Xt::FlushAndWaitExecution ( 184 ) 185 /***************************************************************************/ 186 /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ 187 { 188 if(topWidget==NULL) return; 189 XSync(XtDisplay(topWidget),False); 139 //FIXME 140 G4cout << "G4Qt : Rien compris a cette fonction G4Qt::FlushAndWaitExecution." << G4endl; 141 // if(mainApp==NULL) return; 142 // XSync(QtDisplay(mainApp),False); 190 143 } 191 144
Note: See TracChangeset
for help on using the changeset viewer.