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

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

import all except CVS

  • Property svn:mime-type set to text/cpp
File size: 5.4 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.7 2007/11/15 18:24:28 lgarnier Exp $
28// GEANT4 tag $Name: $
29//
30// L. Garnier
31
32#define GEANT4_QT_DEBUG
33
34#if defined(G4INTY_BUILD_QT) || defined(G4INTY_USE_QT)
35
36#include <stdlib.h>
37#include <string.h>
38
39#include "G4ios.hh"
40
41#include "G4Qt.hh"
42
43#include <qapplication.h>
44
45
46#define NewString(str) \
47 ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
48
49//static void XWidgetIconify (Widget);
50//static void XWidgetUniconify (Widget);
51//static void XDisplaySetWindowToNormalState (Display*,Window);
52
53G4Qt* G4Qt::instance = NULL;
54
55static G4bool QtInited = FALSE;
56//static int argn = 0;
57//static char** args = NULL;
58// static QtAppContext appContext = NULL;
59//static QApplication app = NULL;
60
61/***************************************************************************/
62G4Qt* G4Qt::getInstance (
63)
64/***************************************************************************/
65/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
66{
67 return G4Qt::getInstance (0,NULL,(char*)"Geant4");
68}
69/***************************************************************************/
70G4Qt* G4Qt::getInstance (
71 int a_argn
72,char** a_args
73,char* a_class
74)
75/***************************************************************************/
76/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
77{
78 if (instance==NULL) {
79 instance = new G4Qt(a_argn,a_args,a_class);
80 }
81 return instance;
82}
83/***************************************************************************/
84G4Qt::G4Qt (
85 int a_argn
86,char** a_args
87,char* a_class
88)
89/***************************************************************************/
90/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
91{
92#ifdef GEANT4_QT_DEBUG
93 printf("G4Qt::G4Qt try to inited Qt\n");
94#endif
95 if(QtInited==FALSE) { //Qt should be Inited once !
96#ifdef GEANT4_QT_DEBUG
97#endif
98 if(!qApp) {
99#if QT_VERSION < 0x040000
100 qApp = new QApplication (a_argn, a_args);
101 // QApplication qApp(a_argn, a_args);
102 // if(&qApp == NULL) {
103#else
104 new QApplication (a_argn, a_args);
105#endif
106 }
107 if(!qApp) {
108 G4cout << "G4Qt : Unable to init Qt." << G4endl;
109 } else {
110 QtInited = TRUE;
111 SetMainInteractor (qApp);
112 SetArguments (a_argn,a_args);
113#ifdef GEANT4_QT_DEBUG
114 printf("G4Qt::G4Qt inited Qt END\n");
115#endif
116 }
117 }
118#ifdef GEANT4_QT_DEBUG
119 if (qApp) {
120 printf("G4Qt::qApp exist\n");
121 } else {
122 printf("G4Qt::qApp not exist\n");
123 }
124#endif
125 // AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
126}
127/***************************************************************************/
128G4Qt::~G4Qt (
129)
130/***************************************************************************/
131/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
132{
133 if(this==instance) {
134 instance = NULL;
135 }
136}
137/***************************************************************************/
138G4bool G4Qt::Inited (
139)
140/***************************************************************************/
141/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
142{
143 return QtInited;
144}
145/***************************************************************************/
146// Should do nothing in Qt
147void* G4Qt::GetEvent (
148)
149/***************************************************************************/
150/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
151{
152 return 0;
153}
154/***************************************************************************/
155void G4Qt::FlushAndWaitExecution (
156)
157/***************************************************************************/
158/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
159{
160 if(!qApp) return;
161 qApp->processEvents();
162}
163
164#endif
165
166
167
Note: See TracBrowser for help on using the repository browser.