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

Last change on this file since 872 was 867, checked in by garnier, 17 years ago

see history

  • Property svn:mime-type set to text/cpp
File size: 5.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.9 2008/10/15 09:09:47 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 GEANT4_QT_DEBUG
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#ifdef GEANT4_QT_DEBUG
92 printf("G4Qt::G4Qt alredy inited in external \n");
93#endif
94 } else {
95
96 if(QtInited==FALSE) { //Qt should be Inited once !
97#ifdef GEANT4_QT_DEBUG
98 printf("G4Qt::G4Qt inited Qt\n");
99#endif
100#if QT_VERSION < 0x040000
101 qApp = new QApplication (*a_argn, a_args);
102 // QApplication qApp(a_argn, a_args);
103 // if(&qApp == NULL) {
104#else
105 new QApplication (*a_argn, a_args);
106#endif
107 if(!qApp) {
108
109 G4cout << "G4Qt : Unable to init Qt." << G4endl;
110 } else {
111 QtInited = TRUE;
112 //#if QT_VERSION < 0x040000
113 // SetMainInteractor (&qApp);
114 //#else
115 SetMainInteractor (qApp);
116 //#endif
117 SetArguments (*a_argn,a_args);
118#ifdef GEANT4_QT_DEBUG
119 printf("G4Qt::G4Qt inited Qt END\n");
120#endif
121 }
122 }
123 }
124#ifdef GEANT4_QT_DEBUG
125 if (qApp) {
126 printf("G4Qt::qApp exist\n");
127 } else {
128 printf("G4Qt::qApp not exist\n");
129 }
130#endif
131 // AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
132}
133/***************************************************************************/
134G4Qt::~G4Qt (
135)
136/***************************************************************************/
137/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
138{
139 if(this==instance) {
140 instance = NULL;
141 }
142}
143/***************************************************************************/
144G4bool G4Qt::Inited (
145)
146/***************************************************************************/
147/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
148{
149 return QtInited;
150}
151/***************************************************************************/
152/**
153 Si j'ai bien compris, cette fonction ne sert à rien
154 */
155void* G4Qt::GetEvent (
156)
157/***************************************************************************/
158/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
159{
160//FIXME
161// G4cout << "G4Qt : Rien compris a cette fonction G4Qt::GetEvent." << G4endl;
162// static XEvent event;
163// if(appContext==NULL) return NULL;
164// if(mainApp==NULL) return NULL;
165// QtAppNextEvent (appContext, &event);
166// return &event;
167 printf("*");
168 return 0;
169}
170/***************************************************************************/
171void G4Qt::FlushAndWaitExecution (
172)
173/***************************************************************************/
174/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
175{
176 // printf("G4Qt::FlushAndWaitExecution :: Flush ....\n");
177 if(!qApp) return;
178 qApp->processEvents();
179}
180
181#endif
182
183
184
Note: See TracBrowser for help on using the repository browser.