source: trunk/source/interfaces/common/src/G4Wt.cc @ 1026

Last change on this file since 1026 was 989, checked in by garnier, 15 years ago

fichiers manquants

File size: 6.3 KB
Line 
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//
27// $Id: G4Wt.cc,v 1.7 2007/11/15 18:24:28 lgarnier Exp $
28// GEANT4 tag $Name: HEAD $
29//
30// L. Garnier
31//#define G4INTY_BUILD_WT
32
33#if defined(G4INTY_BUILD_WT) || defined(G4INTY_USE_WT)
34
35#include <stdlib.h>
36#include <string.h>
37
38#include "G4ios.hh"
39
40#include "G4Wt.hh"
41
42#include <Wt/WApplication>
43#include <Wt/WEnvironment>
44
45
46
47G4Wt* G4Wt::instance    = NULL;
48
49static G4bool WtInited  = FALSE;
50
51#define NewString(str)  \
52 ((str) != NULL ? (strcpy((char*)malloc((unsigned)strlen(str) + 1), str)) : NULL)
53
54/***************************************************************************/
55// FIXME Should nevr eb called
56G4Wt* G4Wt::getInstance (
57 ) 
58/***************************************************************************/
59/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
60{
61  return G4Wt::getInstance (0,NULL,(char*)"Geant4");
62}
63/***************************************************************************/
64G4Wt* G4Wt::getInstance (
65 const Wt::WEnvironment& env
66) 
67/***************************************************************************/
68/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
69{
70  if (instance==NULL) {
71    instance = new G4Wt(env);
72  }
73  return instance;
74}
75/***************************************************************************/
76G4Wt::G4Wt (
77 const Wt::WEnvironment& env
78)
79/***************************************************************************/
80/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
81{
82#ifdef GEANT4_WT_DEBUG
83  printf("G4Wt::G4Wt try to inited Wt\n");
84#endif
85  // Check if Wt already init in another external app
86
87  int argn = (env.arguments()).size();
88
89  argn = 0;
90  char **argv = (char**)malloc(argn * sizeof(char*));
91  // =======================
92  // FIXME !!!!!!!!!!!!!!!!!!
93  // =======================
94
95//   if(argv!=NULL) {
96//     for(G4int argi=0;argi<argn;argi++) {
97//       // FIXME
98//       argv[argi] = (char*)NewString (env.arguments()[argi]);
99//     }
100//   }
101  if(wApp) {
102      WtInited  = TRUE;
103      //#if WT_VERSION < 0x040000
104      //      SetMainInteractor (&wApp);
105      //#else
106      SetMainInteractor (wApp);
107      //#endif
108      SetArguments      (argn,argv);
109#ifdef GEANT4_WT_DEBUG
110      printf("G4Wt::G4Wt alredy inited in external \n");
111#endif
112  } else {
113
114    if(WtInited==FALSE) {  //Wt should be Inited once !
115#ifdef GEANT4_WT_DEBUG
116      printf("G4Wt::G4Wt inited Wt\n");
117#endif
118// #if WT_VERSION < 0x040000
119
120//       wApp = new WApplication (env);
121//       //    WApplication wApp(a_argn, argv);
122//       //    if(&wApp == NULL) {
123// #else
124      new Wt::WApplication (env);
125// #endif
126      if(!wApp) {
127       
128        G4cout        << "G4Wt : Unable to init Wt." << G4endl;
129      } else {
130        WtInited  = TRUE;
131        //#if WT_VERSION < 0x040000
132        //      SetMainInteractor (&wApp);
133        //#else
134        SetMainInteractor (wApp);
135        //#endif
136        SetArguments      (argn,argv);
137#ifdef GEANT4_WT_DEBUG
138        printf("G4Wt::G4Wt inited Wt END\n");
139#endif
140      }
141    }
142  }
143#ifdef GEANT4_WT_DEBUG
144  if (wApp) {
145    printf("G4Wt::wApp exist\n");
146  }  else {
147    printf("G4Wt::wApp not exist\n");
148  }
149#endif
150  //  AddDispatcher     ((G4DispatchFunction)XtDispatchEvent);
151}
152/***************************************************************************/
153G4Wt::~G4Wt (
154) 
155/***************************************************************************/
156/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
157{
158  if(this==instance) {
159    instance = NULL;
160  }
161}
162/***************************************************************************/
163G4bool G4Wt::Inited (
164)
165/***************************************************************************/
166/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
167{
168  return WtInited;
169}
170/***************************************************************************/
171/**
172  Si j'ai bien compris, cette fonction ne sert à rien
173 */
174void* G4Wt::GetEvent (
175) 
176/***************************************************************************/
177/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
178{
179//FIXME
180//   G4cout        << "G4Wt : Rien compris a cette fonction G4Wt::GetEvent." << G4endl;
181//  static XEvent  event;
182//  if(appContext==NULL) return NULL;
183//  if(mainApp==NULL) return NULL;
184//  WtAppNextEvent (appContext, &event);
185//  return         &event;
186  printf("*");
187  return 0;
188}
189/***************************************************************************/
190void G4Wt::FlushAndWaitExecution (
191)
192/***************************************************************************/
193/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
194{
195  //  printf("G4Wt::FlushAndWaitExecution ::  Flush ....\n");
196  if(!wApp) return;
197  wApp->processEvents();
198}
199
200#endif
201
202
203
Note: See TracBrowser for help on using the repository browser.