[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 | // |
---|
[606] | 27 | // $Id: G4Qt.cc,v 1.5 2007/11/15 10:10:02 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 | |
---|
| 34 | #include <stdlib.h> |
---|
| 35 | #include <string.h> |
---|
| 36 | |
---|
| 37 | #include "G4ios.hh" |
---|
| 38 | |
---|
[484] | 39 | #include "G4Qt.hh" |
---|
[481] | 40 | |
---|
[595] | 41 | #include <qapplication.h> |
---|
[593] | 42 | |
---|
| 43 | |
---|
[481] | 44 | #define NewString(str) \ |
---|
| 45 | ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL) |
---|
| 46 | |
---|
| 47 | //static void XWidgetIconify (Widget); |
---|
| 48 | //static void XWidgetUniconify (Widget); |
---|
| 49 | //static void XDisplaySetWindowToNormalState (Display*,Window); |
---|
| 50 | |
---|
[484] | 51 | G4Qt* G4Qt::instance = NULL; |
---|
[481] | 52 | |
---|
[484] | 53 | static G4bool QtInited = FALSE; |
---|
| 54 | //static int argn = 0; |
---|
| 55 | //static char** args = NULL; |
---|
| 56 | // static QtAppContext appContext = NULL; |
---|
[496] | 57 | //static QApplication app = NULL; |
---|
[484] | 58 | |
---|
[481] | 59 | /***************************************************************************/ |
---|
[484] | 60 | G4Qt* G4Qt::getInstance ( |
---|
[481] | 61 | ) |
---|
| 62 | /***************************************************************************/ |
---|
| 63 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 64 | { |
---|
[484] | 65 | return G4Qt::getInstance (0,NULL,(char*)"Geant4"); |
---|
[481] | 66 | } |
---|
| 67 | /***************************************************************************/ |
---|
[484] | 68 | G4Qt* G4Qt::getInstance ( |
---|
[481] | 69 | int a_argn |
---|
| 70 | ,char** a_args |
---|
| 71 | ,char* a_class |
---|
| 72 | ) |
---|
| 73 | /***************************************************************************/ |
---|
| 74 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 75 | { |
---|
| 76 | if (instance==NULL) { |
---|
[484] | 77 | instance = new G4Qt(a_argn,a_args,a_class); |
---|
[481] | 78 | } |
---|
| 79 | return instance; |
---|
| 80 | } |
---|
| 81 | /***************************************************************************/ |
---|
[484] | 82 | G4Qt::G4Qt ( |
---|
[481] | 83 | int a_argn |
---|
| 84 | ,char** a_args |
---|
| 85 | ,char* a_class |
---|
| 86 | ) |
---|
| 87 | /***************************************************************************/ |
---|
| 88 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 89 | { |
---|
[571] | 90 | printf("G4Qt::G4Qt try to inited Qt\n"); |
---|
[484] | 91 | if(QtInited==FALSE) { //Qt should be Inited once ! |
---|
[571] | 92 | printf("G4Qt::G4Qt inited Qt\n"); |
---|
[606] | 93 | #if QT_VERSION < 0x040000 |
---|
| 94 | qApp = new QApplication (a_argn, a_args); |
---|
| 95 | // QApplication qApp(a_argn, a_args); |
---|
| 96 | #else |
---|
[484] | 97 | new QApplication (a_argn, a_args); |
---|
[606] | 98 | #endif |
---|
[484] | 99 | |
---|
[496] | 100 | if(qApp==NULL) { |
---|
[484] | 101 | G4cout << "G4Qt : Unable to init Qt." << G4endl; |
---|
[606] | 102 | } else { |
---|
| 103 | QtInited = TRUE; |
---|
| 104 | SetMainInteractor (qApp); |
---|
| 105 | SetArguments (a_argn,a_args); |
---|
| 106 | printf("G4Qt::G4Qt inited Qt END\n"); |
---|
[481] | 107 | } |
---|
| 108 | } |
---|
[606] | 109 | if (qApp) |
---|
| 110 | printf("G4Qt::qApp exist\n"); |
---|
| 111 | else |
---|
| 112 | printf("G4Qt::qApp not exist\n"); |
---|
[496] | 113 | // AddDispatcher ((G4DispatchFunction)XtDispatchEvent); |
---|
[481] | 114 | } |
---|
| 115 | /***************************************************************************/ |
---|
[484] | 116 | G4Qt::~G4Qt ( |
---|
[481] | 117 | ) |
---|
| 118 | /***************************************************************************/ |
---|
| 119 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 120 | { |
---|
| 121 | if(this==instance) { |
---|
| 122 | instance = NULL; |
---|
| 123 | } |
---|
| 124 | } |
---|
| 125 | /***************************************************************************/ |
---|
[484] | 126 | G4bool G4Qt::Inited ( |
---|
[481] | 127 | ) |
---|
| 128 | /***************************************************************************/ |
---|
| 129 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 130 | { |
---|
[484] | 131 | return QtInited; |
---|
[481] | 132 | } |
---|
| 133 | /***************************************************************************/ |
---|
[496] | 134 | /** |
---|
| 135 | Si j'ai bien compris, cette fonction ne sert à rien |
---|
| 136 | */ |
---|
[484] | 137 | void* G4Qt::GetEvent ( |
---|
[481] | 138 | ) |
---|
| 139 | /***************************************************************************/ |
---|
| 140 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 141 | { |
---|
[484] | 142 | //FIXME |
---|
[496] | 143 | // G4cout << "G4Qt : Rien compris a cette fonction G4Qt::GetEvent." << G4endl; |
---|
[484] | 144 | // static XEvent event; |
---|
| 145 | // if(appContext==NULL) return NULL; |
---|
| 146 | // if(mainApp==NULL) return NULL; |
---|
| 147 | // QtAppNextEvent (appContext, &event); |
---|
| 148 | // return &event; |
---|
[506] | 149 | printf("*"); |
---|
[593] | 150 | return 0; |
---|
[481] | 151 | } |
---|
| 152 | /***************************************************************************/ |
---|
[484] | 153 | void G4Qt::FlushAndWaitExecution ( |
---|
[481] | 154 | ) |
---|
| 155 | /***************************************************************************/ |
---|
| 156 | /*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/ |
---|
| 157 | { |
---|
[595] | 158 | // printf("G4Qt::FlushAndWaitExecution :: Flush ....\n"); |
---|
[578] | 159 | if(!qApp) return; |
---|
| 160 | qApp->processEvents(); |
---|
[481] | 161 | } |
---|
| 162 | |
---|
| 163 | #endif |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | |
---|