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
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//
[608]27// $Id: G4Qt.cc,v 1.7 2007/11/15 18:24:28 lgarnier Exp $
[593]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
[610]34#define GEANT4_QT_DEBUG
35
[481]36#include <stdlib.h>
37#include <string.h>
38
39#include "G4ios.hh"
40
[484]41#include "G4Qt.hh"
[481]42
[595]43#include <qapplication.h>
[610]44#include <qpushbutton.h> // EN TEST
[593]45
46
[481]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
[484]54G4Qt* G4Qt::instance = NULL;
[481]55
[484]56static G4bool QtInited = FALSE;
57//static int argn = 0;
58//static char** args = NULL;
59// static QtAppContext appContext = NULL;
[496]60//static QApplication app = NULL;
[484]61
[481]62/***************************************************************************/
[484]63G4Qt* G4Qt::getInstance (
[481]64)
65/***************************************************************************/
66/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
67{
[484]68 return G4Qt::getInstance (0,NULL,(char*)"Geant4");
[481]69}
70/***************************************************************************/
[484]71G4Qt* G4Qt::getInstance (
[481]72 int a_argn
73,char** a_args
74,char* a_class
75)
76/***************************************************************************/
77/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
78{
79 if (instance==NULL) {
[484]80 instance = new G4Qt(a_argn,a_args,a_class);
[481]81 }
82 return instance;
83}
84/***************************************************************************/
[484]85G4Qt::G4Qt (
[481]86 int a_argn
87,char** a_args
88,char* a_class
89)
90/***************************************************************************/
91/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
92{
[608]93#ifdef GEANT4_QT_DEBUG
[571]94 printf("G4Qt::G4Qt try to inited Qt\n");
[608]95#endif
[484]96 if(QtInited==FALSE) { //Qt should be Inited once !
[608]97#ifdef GEANT4_QT_DEBUG
[571]98 printf("G4Qt::G4Qt inited Qt\n");
[608]99#endif
[606]100#if QT_VERSION < 0x040000
[610]101 // EN TEST qApp = new QApplication (a_argn, a_args);
[606]102 // QApplication qApp(a_argn, a_args);
[608]103 // if(&qApp == NULL) {
[606]104#else
[484]105 new QApplication (a_argn, a_args);
[606]106#endif
[608]107 if(!qApp) {
[484]108
109 G4cout << "G4Qt : Unable to init Qt." << G4endl;
[606]110 } else {
111 QtInited = TRUE;
[608]112 //#if QT_VERSION < 0x040000
113 // SetMainInteractor (&qApp);
114 //#else
[606]115 SetMainInteractor (qApp);
[608]116 //#endif
[606]117 SetArguments (a_argn,a_args);
[608]118#ifdef GEANT4_QT_DEBUG
[606]119 printf("G4Qt::G4Qt inited Qt END\n");
[608]120#endif
[481]121 }
122 }
[608]123#ifdef GEANT4_QT_DEBUG
[610]124 // if (qApp) {
[606]125 printf("G4Qt::qApp exist\n");
[610]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 // }
[608]140#endif
[496]141 // AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
[481]142}
143/***************************************************************************/
[484]144G4Qt::~G4Qt (
[481]145)
146/***************************************************************************/
147/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
148{
149 if(this==instance) {
150 instance = NULL;
151 }
152}
153/***************************************************************************/
[484]154G4bool G4Qt::Inited (
[481]155)
156/***************************************************************************/
157/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
158{
[484]159 return QtInited;
[481]160}
161/***************************************************************************/
[496]162/**
163 Si j'ai bien compris, cette fonction ne sert à rien
164 */
[484]165void* G4Qt::GetEvent (
[481]166)
167/***************************************************************************/
168/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
169{
[484]170//FIXME
[496]171// G4cout << "G4Qt : Rien compris a cette fonction G4Qt::GetEvent." << G4endl;
[484]172// static XEvent event;
173// if(appContext==NULL) return NULL;
174// if(mainApp==NULL) return NULL;
175// QtAppNextEvent (appContext, &event);
176// return &event;
[506]177 printf("*");
[593]178 return 0;
[481]179}
180/***************************************************************************/
[484]181void G4Qt::FlushAndWaitExecution (
[481]182)
183/***************************************************************************/
184/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
185{
[595]186 // printf("G4Qt::FlushAndWaitExecution :: Flush ....\n");
[578]187 if(!qApp) return;
188 qApp->processEvents();
[481]189}
190
191#endif
192
193
194
Note: See TracBrowser for help on using the repository browser.