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
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
[836]32#define GEANT4_QT_DEBUG
33
[484]34#if defined(G4INTY_BUILD_QT) || defined(G4INTY_USE_QT)
[481]35
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>
[593]44
45
[481]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
[484]53G4Qt* G4Qt::instance = NULL;
[481]54
[484]55static G4bool QtInited = FALSE;
56//static int argn = 0;
57//static char** args = NULL;
58// static QtAppContext appContext = NULL;
[496]59//static QApplication app = NULL;
[484]60
[481]61/***************************************************************************/
[484]62G4Qt* G4Qt::getInstance (
[481]63)
64/***************************************************************************/
65/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
66{
[484]67 return G4Qt::getInstance (0,NULL,(char*)"Geant4");
[481]68}
69/***************************************************************************/
[484]70G4Qt* G4Qt::getInstance (
[481]71 int a_argn
72,char** a_args
73,char* a_class
74)
75/***************************************************************************/
76/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
77{
78 if (instance==NULL) {
[484]79 instance = new G4Qt(a_argn,a_args,a_class);
[481]80 }
81 return instance;
82}
83/***************************************************************************/
[484]84G4Qt::G4Qt (
[481]85 int a_argn
86,char** a_args
87,char* a_class
88)
89/***************************************************************************/
90/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
91{
[608]92#ifdef GEANT4_QT_DEBUG
[571]93 printf("G4Qt::G4Qt try to inited Qt\n");
[608]94#endif
[484]95 if(QtInited==FALSE) { //Qt should be Inited once !
[608]96#ifdef GEANT4_QT_DEBUG
97#endif
[836]98 if(!qApp) {
[606]99#if QT_VERSION < 0x040000
[836]100 qApp = new QApplication (a_argn, a_args);
101 // QApplication qApp(a_argn, a_args);
102 // if(&qApp == NULL) {
[606]103#else
[836]104 new QApplication (a_argn, a_args);
[606]105#endif
[836]106 }
[608]107 if(!qApp) {
[484]108 G4cout << "G4Qt : Unable to init Qt." << G4endl;
[606]109 } else {
110 QtInited = TRUE;
111 SetMainInteractor (qApp);
112 SetArguments (a_argn,a_args);
[608]113#ifdef GEANT4_QT_DEBUG
[606]114 printf("G4Qt::G4Qt inited Qt END\n");
[608]115#endif
[481]116 }
117 }
[608]118#ifdef GEANT4_QT_DEBUG
[617]119 if (qApp) {
[606]120 printf("G4Qt::qApp exist\n");
[617]121 } else {
122 printf("G4Qt::qApp not exist\n");
123 }
[608]124#endif
[496]125 // AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
[481]126}
127/***************************************************************************/
[484]128G4Qt::~G4Qt (
[481]129)
130/***************************************************************************/
131/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
132{
133 if(this==instance) {
134 instance = NULL;
135 }
136}
137/***************************************************************************/
[484]138G4bool G4Qt::Inited (
[481]139)
140/***************************************************************************/
141/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
142{
[484]143 return QtInited;
[481]144}
145/***************************************************************************/
[836]146// Should do nothing in Qt
[484]147void* G4Qt::GetEvent (
[481]148)
149/***************************************************************************/
150/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
151{
[593]152 return 0;
[481]153}
154/***************************************************************************/
[484]155void G4Qt::FlushAndWaitExecution (
[481]156)
157/***************************************************************************/
158/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
159{
[578]160 if(!qApp) return;
161 qApp->processEvents();
[481]162}
163
164#endif
165
166
167
Note: See TracBrowser for help on using the repository browser.