Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4Wt.cc
Go to the documentation of this file.
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//
28// L. Garnier
29
30#if defined(G4INTY_BUILD_WT) || defined(G4INTY_USE_WT)
31
32#include <stdlib.h>
33#include <string.h>
34
35#include "G4ios.hh"
36
37#include "G4Wt.hh"
38
39#include <Wt/WApplication>
40#include <Wt/WEnvironment>
41
42
43G4Wt* G4Wt::instance = NULL;
44
45static G4bool WtInited = FALSE;
46
47/***************************************************************************/
48G4Wt* G4Wt::getInstance (
49 )
50/***************************************************************************/
51/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
52{
53 return G4Wt::getInstance (0,NULL,(char*)"Geant4");
54}
55
56/***************************************************************************/
57G4Wt* G4Wt::getInstance (
58 int a_argn
59,char** a_args
60,char* a_class
61)
62/***************************************************************************/
63/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
64{
65 if (instance==NULL) {
66 instance = new G4Wt(a_argn,a_args,a_class);
67 }
68 return instance;
69}
70/***************************************************************************/
71G4Wt::G4Wt (
72 int a_argn
73,char** a_args
74 ,char* /*a_class */
75)
76/***************************************************************************/
77/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
78{
79 argn = 0;
80 args = NULL;
81
82#ifdef G4DEBUG_INTERFACES_COMMON
83 printf("G4Wt::G4Wt try to inited Wt\n");
84#endif
85 // Check if Wt already init in another external app
86 if(wApp) {
87 WtInited = TRUE;
88 SetMainInteractor (wServer);
89 //#endif
90 SetArguments (a_argn,a_args);
91
92#ifdef G4DEBUG_INTERFACES_COMMON
93 printf("G4Wt::G4Wt alredy inited in external \n");
94#endif
95 } else {
96
97 if(WtInited==FALSE) { //Wt should be Inited once !
98 // Then two cases :
99 // - It is the first time we create G4UI (argc!=0)
100 // -> Inited and register
101 // - It is the first time we create G4VIS (argc == 0)
102 // -> Inited and NOT register
103
104 if (a_argn != 0) {
105 argn = a_argn;
106 args = a_args;
107
108 } else { //argc = 0
109
110 // FIXME : That's not the good arguments, but I don't know how to get args from other Interactor.
111 // Ex: How to get them from G4Xt ?
112 argn = 1;
113 args = (char **)malloc( 1 * sizeof(char *) );
114 args[0] = (char *)malloc(10 * sizeof(char));
115 strncpy(args[0], "my_app \0", 9);
116 }
117
118 int *p_argn = (int*)malloc(sizeof(int));
119 *p_argn = argn;
120#ifdef G4DEBUG_INTERFACES_COMMON
121 printf("G4Wt::G4Wt WAppl \n");
122#endif
123 Wt::WApplication:: instance();
124 ////
125 //WApplication (*p_argn, args);
126
127 if(!wApp) {
128
129 G4cout << "G4Wt : Unable to init Wt." << G4endl;
130 } else {
131 WtInited = TRUE;
132 if (a_argn != 0) {
133#ifdef G4DEBUG_INTERFACES_COMMON
134 printf("G4Wt::G4Wt SetMainInteractor\n");
135#endif
136 // SetMainInteractor ();
137 }
138 SetArguments (a_argn,a_args);
139#ifdef G4DEBUG_INTERFACES_COMMON
140 printf("G4Wt::G4Wt inited Wt END\n");
141#endif
142 }
143 }
144 }
145#ifdef G4DEBUG_INTERFACES_COMMON
146 if (wApp) {
147 printf("G4Wt::wApp already exist\n");
148 } else {
149 printf("G4Wt::wApp not exist\n");
150 }
151#endif
152 // AddDispatcher ((G4DispatchFunction)XtDispatchEvent);
153
154
155 DisableSecondaryLoop ();
156}
157/***************************************************************************/
158G4Wt::~G4Wt (
159)
160/***************************************************************************/
161/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
162{
163 if(this==instance) {
164 instance = NULL;
165 }
166}
167/***************************************************************************/
168G4bool G4Wt::Inited (
169)
170/***************************************************************************/
171/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
172{
173 return WtInited;
174}
175/***************************************************************************/
176void* G4Wt::GetEvent (
177)
178/***************************************************************************/
179/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
180{
181//FIXME
182// G4cout << "G4Wt : Rien compris a cette fonction G4Wt::GetEvent." << G4endl;
183// static XEvent event;
184// if(appContext==NULL) return NULL;
185// if(mainApp==NULL) return NULL;
186// WtAppNextEvent (appContext, &event);
187// return &event;
188 printf("*");
189 return 0;
190}
191/***************************************************************************/
192void G4Wt::FlushAndWaitExecution (
193)
194/***************************************************************************/
195/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
196{
197 // printf("G4Wt::FlushAndWaitExecution :: Flush ....\n");
198 if(!wApp) return;
199 // wApp->processEvents();
200}
201
202#endif
203
204
205
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
#define TRUE
Definition: Globals.hh:27
#define FALSE
Definition: Globals.hh:23