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
RevLine 
[481]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//
[867]27// $Id: G4Qt.cc,v 1.9 2008/10/15 09:09:47 lgarnier Exp $
28// GEANT4 tag $Name: $
[481]29//
[484]30// L. Garnier
[481]31
[484]32#if defined(G4INTY_BUILD_QT) || defined(G4INTY_USE_QT)
[481]33
34#include <stdlib.h>
35#include <string.h>
36
37#include "G4ios.hh"
38
[484]39#include "G4Qt.hh"
[481]40
[595]41#include <qapplication.h>
[593]42
43
[484]44G4Qt* G4Qt::instance = NULL;
[481]45
[484]46static G4bool QtInited = FALSE;
47
[481]48/***************************************************************************/
[484]49G4Qt* G4Qt::getInstance (
[481]50)
51/***************************************************************************/
52/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
53{
[484]54 return G4Qt::getInstance (0,NULL,(char*)"Geant4");
[481]55}
56/***************************************************************************/
[484]57G4Qt* G4Qt::getInstance (
[867]58 int* a_argn
[481]59,char** a_args
60,char* a_class
61)
62/***************************************************************************/
63/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
64{
65 if (instance==NULL) {
[484]66 instance = new G4Qt(a_argn,a_args,a_class);
[481]67 }
68 return instance;
69}
70/***************************************************************************/
[484]71G4Qt::G4Qt (
[867]72 int* a_argn
[481]73,char** a_args
74,char* a_class
75)
76/***************************************************************************/
77/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
78{
[608]79#ifdef GEANT4_QT_DEBUG
[571]80 printf("G4Qt::G4Qt try to inited Qt\n");
[608]81#endif
[856]82 // Check if Qt already init in another external app
83 if(qApp) {
[606]84 QtInited = TRUE;
[850]85 //#if QT_VERSION < 0x040000
86 // SetMainInteractor (&qApp);
87 //#else
[606]88 SetMainInteractor (qApp);
[850]89 //#endif
[867]90 SetArguments (*a_argn,a_args);
[608]91#ifdef GEANT4_QT_DEBUG
[856]92 printf("G4Qt::G4Qt alredy inited in external \n");
[608]93#endif
[856]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
[867]101 qApp = new QApplication (*a_argn, a_args);
[856]102 // QApplication qApp(a_argn, a_args);
103 // if(&qApp == NULL) {
104#else
[867]105 new QApplication (*a_argn, a_args);
[856]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
[867]117 SetArguments (*a_argn,a_args);
[856]118#ifdef GEANT4_QT_DEBUG
119 printf("G4Qt::G4Qt inited Qt END\n");
120#endif
121 }
[481]122 }
123 }
[608]124#ifdef GEANT4_QT_DEBUG
[617]125 if (qApp) {
[606]126 printf("G4Qt::qApp exist\n");
[617]127 } else {
128 printf("G4Qt::qApp not exist\n");
129 }
[608]130#endif
[496]131 // AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
[481]132}
133/***************************************************************************/
[484]134G4Qt::~G4Qt (
[481]135)
136/***************************************************************************/
137/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
138{
139 if(this==instance) {
140 instance = NULL;
141 }
142}
143/***************************************************************************/
[484]144G4bool G4Qt::Inited (
[481]145)
146/***************************************************************************/
147/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
148{
[484]149 return QtInited;
[481]150}
151/***************************************************************************/
[850]152/**
153 Si j'ai bien compris, cette fonction ne sert à rien
154 */
[484]155void* G4Qt::GetEvent (
[481]156)
157/***************************************************************************/
158/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
159{
[850]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("*");
[593]168 return 0;
[481]169}
170/***************************************************************************/
[484]171void G4Qt::FlushAndWaitExecution (
[481]172)
173/***************************************************************************/
174/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
175{
[850]176 // printf("G4Qt::FlushAndWaitExecution :: Flush ....\n");
[578]177 if(!qApp) return;
178 qApp->processEvents();
[481]179}
180
181#endif
182
183
184
Note: See TracBrowser for help on using the repository browser.