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

Last change on this file since 616 was 615, checked in by garnier, 18 years ago

Passage sur Windows Qt4 OK

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