source: trunk/geant4/interfaces/common/src/G4Qt.cc@ 612

Last change on this file since 612 was 610, checked in by garnier, 18 years ago

r661@mac-90108: laurentgarnier | 2007-11-22 18:10:43 +0100
en debug

  • Property svn:mime-type set to text/cpp
File size: 6.3 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#if defined(G4INTY_BUILD_QT) || defined(G4INTY_USE_QT)
33
34#define GEANT4_QT_DEBUG
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#include <qpushbutton.h> // EN TEST
45
46
47#define NewString(str) \
48 ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
49
50//static void XWidgetIconify (Widget);
51//static void XWidgetUniconify (Widget);
52//static void XDisplaySetWindowToNormalState (Display*,Window);
53
54G4Qt* G4Qt::instance = NULL;
55
56static G4bool QtInited = FALSE;
57//static int argn = 0;
58//static char** args = NULL;
59// static QtAppContext appContext = NULL;
60//static QApplication app = NULL;
61
62/***************************************************************************/
63G4Qt* G4Qt::getInstance (
64)
65/***************************************************************************/
66/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
67{
68 return G4Qt::getInstance (0,NULL,(char*)"Geant4");
69}
70/***************************************************************************/
71G4Qt* G4Qt::getInstance (
72 int a_argn
73,char** a_args
74,char* a_class
75)
76/***************************************************************************/
77/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
78{
79 if (instance==NULL) {
80 instance = new G4Qt(a_argn,a_args,a_class);
81 }
82 return instance;
83}
84/***************************************************************************/
85G4Qt::G4Qt (
86 int a_argn
87,char** a_args
88,char* a_class
89)
90/***************************************************************************/
91/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
92{
93#ifdef GEANT4_QT_DEBUG
94 printf("G4Qt::G4Qt try to inited Qt\n");
95#endif
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 // EN TEST 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#ifdef GEANT4_QT_DEBUG
124 // if (qApp) {
125 printf("G4Qt::qApp exist\n");
126 // =================== EN TEST ==============
127 new QApplication ( a_argn, a_args );
128
129 QPushButton hello( "Hello world!", 0 );
130 hello.resize( 100, 30 );
131
132 qApp->setMainWidget( &hello );
133 hello.show();
134 qApp->exec();
135 printf("G4Qt::qApp exist END\n");
136 // =================== EN TEST ==============
137 // } else {
138 // printf("G4Qt::qApp not exist\n");
139 // }
140#endif
141 // AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
142}
143/***************************************************************************/
144G4Qt::~G4Qt (
145)
146/***************************************************************************/
147/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
148{
149 if(this==instance) {
150 instance = NULL;
151 }
152}
153/***************************************************************************/
154G4bool G4Qt::Inited (
155)
156/***************************************************************************/
157/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
158{
159 return QtInited;
160}
161/***************************************************************************/
162/**
163 Si j'ai bien compris, cette fonction ne sert à rien
164 */
165void* G4Qt::GetEvent (
166)
167/***************************************************************************/
168/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
169{
170//FIXME
171// G4cout << "G4Qt : Rien compris a cette fonction G4Qt::GetEvent." << G4endl;
172// static XEvent event;
173// if(appContext==NULL) return NULL;
174// if(mainApp==NULL) return NULL;
175// QtAppNextEvent (appContext, &event);
176// return &event;
177 printf("*");
178 return 0;
179}
180/***************************************************************************/
181void G4Qt::FlushAndWaitExecution (
182)
183/***************************************************************************/
184/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
185{
186 // printf("G4Qt::FlushAndWaitExecution :: Flush ....\n");
187 if(!qApp) return;
188 qApp->processEvents();
189}
190
191#endif
192
193
194
Note: See TracBrowser for help on using the repository browser.