source: trunk/source/interfaces/common/src/G4Qt.cc@ 875

Last change on this file since 875 was 874, checked in by garnier, 17 years ago

update to G4 DEBUG official messages

  • Property svn:mime-type set to text/cpp
File size: 6.9 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27// $Id: G4Qt.cc,v 1.10 2008/10/24 13:23:22 lgarnier Exp $
28// GEANT4 tag $Name: $
29//
30// L. Garnier
31
32#if defined(G4INTY_BUILD_QT) || defined(G4INTY_USE_QT)
33
34#include <stdlib.h>
35#include <string.h>
36
37#include "G4ios.hh"
38
39#include "G4Qt.hh"
40
41#include <qapplication.h>
42
43
44G4Qt* G4Qt::instance = NULL;
45
46static G4bool QtInited = FALSE;
47
48/***************************************************************************/
49G4Qt* G4Qt::getInstance (
50)
51/***************************************************************************/
52/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
53{
54 return G4Qt::getInstance (0,NULL,(char*)"Geant4");
55}
56/***************************************************************************/
57G4Qt* G4Qt::getInstance (
58 int a_argn
59,char** a_args
60,char* a_class
61)
62/***************************************************************************/
63/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
64{
65 if (instance==NULL) {
66 instance = new G4Qt(a_argn,a_args,a_class);
67 }
68 return instance;
69}
70/***************************************************************************/
71G4Qt::G4Qt (
72 int a_argn
73,char** a_args
74,char* a_class
75)
76/***************************************************************************/
77/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
78{
79#ifdef G4DEBUG
80 printf("G4Qt::G4Qt try to inited Qt\n");
81#endif
82 // Check if Qt already init in another external app
83 if(qApp) {
84 QtInited = TRUE;
85 //#if QT_VERSION < 0x040000
86 // SetMainInteractor (&qApp);
87 //#else
88 SetMainInteractor (qApp);
89 //#endif
90 SetArguments (a_argn,a_args);
91
92#ifdef G4DEBUG
93 printf("G4Qt::G4Qt alredy inited in external \n");
94#endif
95 } else {
96
97 if(QtInited==FALSE) { //Qt should be Inited once !
98 // Then two cases :
99 // - It is the first time we create G4UI (argc!=0)
100 // -> Inited and register
101 // - It is the first time we create G4VIS (arc == 0)
102 // -> Inited and NOT register
103
104 int argc;
105 char ** test;
106 if (a_argn != 0) {
107 SetArguments (a_argn,a_args);
108#ifdef G4DEBUG
109 printf("G4Qt::G4Qt inited, first time creating UI \n");
110#endif
111 } else { //argc = 0
112 test = GetArguments(&argc);
113
114#ifdef G4DEBUG
115
116 printf("G4Qt::G4Qt inited, create new QtVis\n");
117 printf("G4Qt::G4Qt arguments avant %s\n",a_args[0]);
118 printf("G4Qt::G4Qt arguments avant %s\n",a_args[1]);
119 printf("G4Qt::G4Qt arguments avant %s\n",a_args[2]);
120 printf("G4Qt::G4Qt arguments avant %s\n",a_args[3]);
121 printf("G4Qt::G4Qt arguments apres %d\n",argc);
122 printf("G4Qt::G4Qt arguments apres %s \n",test[0]);
123 printf("G4Qt::G4Qt arguments apres %s \n",test[1]);
124 printf("G4Qt::G4Qt arguments apres %s \n",test[2]);
125 printf("G4Qt::G4Qt arguments apres %s \n",test[3]);
126#endif
127 if (argc == 0) {
128 G4cout << "G4Qt : Unable to init Qt." << G4endl;
129 return;
130 }
131 }
132#if QT_VERSION < 0x040000
133 qApp = new QApplication (a_argn, a_args);
134 // QApplication qApp(a_argn, a_args);
135 // if(&qApp == NULL) {
136#else
137 new QApplication (a_argn, a_args);
138#endif
139
140 if(!qApp) {
141
142 G4cout << "G4Qt : Unable to init Qt." << G4endl;
143 } else {
144 if (a_argn != 0) {
145 SetMainInteractor (qApp);
146 SetArguments (a_argn,a_args);
147 }
148 QtInited = TRUE;
149#ifdef G4DEBUG
150 printf("G4Qt::G4Qt inited Qt END\n");
151#endif
152 }
153 }
154 }
155#ifdef G4DEBUG
156 if (qApp) {
157 printf("G4Qt::qApp exist\n");
158 } else {
159 printf("G4Qt::qApp not exist\n");
160 }
161#endif
162 // AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
163}
164/***************************************************************************/
165G4Qt::~G4Qt (
166)
167/***************************************************************************/
168/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
169{
170 if(this==instance) {
171 instance = NULL;
172 }
173}
174/***************************************************************************/
175G4bool G4Qt::Inited (
176)
177/***************************************************************************/
178/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
179{
180 return QtInited;
181}
182/***************************************************************************/
183/**
184 Si j'ai bien compris, cette fonction ne sert à rien
185 */
186void* G4Qt::GetEvent (
187)
188/***************************************************************************/
189/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
190{
191//FIXME
192// G4cout << "G4Qt : Rien compris a cette fonction G4Qt::GetEvent." << G4endl;
193// static XEvent event;
194// if(appContext==NULL) return NULL;
195// if(mainApp==NULL) return NULL;
196// QtAppNextEvent (appContext, &event);
197// return &event;
198 printf("*");
199 return 0;
200}
201/***************************************************************************/
202void G4Qt::FlushAndWaitExecution (
203)
204/***************************************************************************/
205/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
206{
207 // printf("G4Qt::FlushAndWaitExecution :: Flush ....\n");
208 if(!qApp) return;
209 qApp->processEvents();
210}
211
212#endif
213
214
215
Note: See TracBrowser for help on using the repository browser.