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