source: trunk/environments/g4py/examples/education/lesson1/Lesson1Wx.py @ 1354

Last change on this file since 1354 was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 21.0 KB
Line 
1#!/usr/bin/python
2
3from Geant4 import *
4import g4py.NISTmaterials
5import g4py.ezgeom
6from g4py.ezgeom import G4EzVolume
7import g4py.ExN03pl
8import g4py.ParticleGun
9from time import *
10import sys
11from subprocess import *
12import os
13
14# ==================================================================
15# intialize
16# ==================================================================
17def Configure():
18  # ------------------------------------------------------------------
19  # setup for materials
20  # ------------------------------------------------------------------
21  # simple materials for Qgeom
22  g4py.NISTmaterials.Construct()
23
24  # ------------------------------------------------------------------
25  # setup for geometry
26  # ------------------------------------------------------------------
27  g4py.ezgeom.Construct()  # initialize
28
29  # ------------------------------------------------------------------
30  # setup for physics list of N03
31  # ------------------------------------------------------------------
32  g4py.ExN03pl.Construct()
33
34  # ------------------------------------------------------------------
35  # setup for primary generator action
36  # ------------------------------------------------------------------
37  g4py.ParticleGun.Construct()
38  gControlExecute("gun.mac")
39
40# ==================================================================
41# constructing geometry
42# ==================================================================
43def ConstructGeom():
44
45  print "* Constructing geometry..."
46  # reset world material
47  global absorber
48  air= G4Material.GetMaterial("G4_AIR", 1)
49  galactic = G4Material.GetMaterial("G4_Galactic", 1)
50  absorber = {}  # material's dictionary to be used by a radiobutton
51  aluminum = G4Material.GetMaterial("G4_Al", 1)
52  iron   = G4Material.GetMaterial("G4_Fe", 1)
53  silver = G4Material.GetMaterial("G4_Ag", 1)
54  gold = G4Material.GetMaterial("G4_Au", 1)
55  lead = G4Material.GetMaterial("G4_Pb", 1)
56  water = G4Material.GetMaterial("G4_WATER", 1)
57  absorber = {"air":air, "aluminum":aluminum, "iron":iron, "lead":lead, "water":water, "gold":gold
58}
59  g4py.ezgeom.SetWorldMaterial(galactic)
60  g4py.ezgeom.ResizeWorld(120.*cm, 120.*cm, 100.*cm)
61  # water phantom
62  global water_phantom, water_phantom_pv
63
64  water_phantom= G4EzVolume("WaterPhantom")
65  water_phantom.CreateBoxVolume(water, 110.*cm, 110.*cm, 10.*cm)
66  water_phantom_pv = water_phantom.PlaceIt(G4ThreeVector(0.,0.,0.*cm))
67
68# ==================================================================
69# main
70# ==================================================================
71# ------------------------------------------------------------------
72# randum number
73# ------------------------------------------------------------------
74#print "Random numbers..."
75rand_engine= Ranlux64Engine()
76HepRandom.setTheEngine(rand_engine)
77HepRandom.setTheSeed(20050830L)
78
79# setup...
80
81Configure()
82ConstructGeom()
83
84# ------------------------------------------------------------------
85# go...
86# ------------------------------------------------------------------
87gRunManager.Initialize()
88
89
90
91global commandDic, commandList
92commandDic = {}
93commandList = []
94
95def DumpTree(atree):
96
97  ntree= atree.GetTreeEntry()
98  ncommand= atree.GetCommandEntry()
99  for i in range(1, ncommand+1):
100    icommand= atree.GetCommand(i)
101    command = str( icommand.GetCommandPath())
102    commandList.append(command)
103    nparameter= icommand.GetParameterEntries()
104    pguide = ""
105    for j in range(0, nparameter):
106      iparam= icommand.GetParameter(j)
107      pguide = pguide + "Parameter: " + str(iparam.GetParameterName())+ "   Type: " +           str(iparam.GetParameterType()) + '\n'
108    guide = str(icommand.GetTitle()) + '\n' + pguide
109    commandDic[command] = guide
110
111  for i in range(1, ntree+1):
112    itree= atree.GetTree(i)
113    DumpTree(itree)
114
115root_tree= gUImanager.GetTree()
116DumpTree(root_tree)
117
118# visualization
119# OGLSX, VRML and HEPREP sceneHandlers are all created with names
120gApplyUICommand("/vis/sceneHandler/create OGLSX OGLSX")
121gApplyUICommand("/vis/sceneHandler/create VRML2FILE VRML")
122gApplyUICommand("/vis/sceneHandler/create HepRepFile HEPREP")
123
124
125#  OGLSX is the default so, viewer is created and volume is drawn
126gApplyUICommand("/vis/viewer/create OGLSX oglsxviewer")
127gApplyUICommand("/vis/viewer/select  oglsxviewer")
128gApplyUICommand("/vis/drawVolume")
129gApplyUICommand("/vis/scene/add/trajectories")
130
131gApplyUICommand("/tracking/storeTrajectory 1")
132gApplyUICommand("/vis/scene/endOfEventAction accumulate")
133gApplyUICommand("/vis/scene/endOfRunAction accumulate")
134
135gApplyUICommand("/vis/viewer/set/viewpointThetaPhi 90. 0.")
136gApplyUICommand("/vis/viewer/set/style s")
137
138# viewers VRML and Wired are tested by their envs vars
139# if their envs var are set, then viewers are created and drawVolume
140
141global heprepViewer, heprepDir, heprepName, vrmlViewer
142heprepViewer = os.environ.get("G4HEPREPFILE_VIEWER")
143heprepDir = os.environ.get("G4HEPREPFILE_DIR")
144heprepName = os.environ.get("G4HEPREPFILE_NAME")
145if heprepViewer is not None:
146  gApplyUICommand("/vis/viewer/create HEPREP wired")
147#  gApplyUICommand("/vis/drawVolume")
148
149# VRML viewers name is user defined
150vrmlDir = os.environ.get("G4VRML_DEST_DIR")
151vrmlViewer = os.environ.get("G4VRMLFILE_VIEWER")
152if vrmlViewer is not None:
153  gApplyUICommand("/vis/viewer/create VRML vrmlviewer")
154#  gApplyUICommand("/vis/drawVolume")
155
156###############################
157######  wxPython GUI ##########
158###############################
159
160import wx
161
162class ComPanel(wx.Panel):
163  def __init__(self, parent):
164    wx.Panel.__init__(self, parent, -1)
165
166    self.g4comText = wx.TextCtrl(parent, -1, "enter Command", pos=(10,10), size=(300, 30))
167
168    self.g4comExec = wx.Button(parent, -1, "Execute", pos=(320,10), size=(60,30))
169    self.g4comExec.Bind(wx.EVT_BUTTON, self.ExecuteCommand, self.g4comExec)
170
171    self.comListBox = wx.ListBox(parent, -1, pos=(10,50), size=(300,200), choices=commandList, style=wx.LB_SINGLE)
172    self.comListBox.SetSelection(1)
173    self.comListBox.Bind(wx.EVT_LISTBOX, self.ShowGuide, self.comListBox)
174   
175    self.guide = wx.TextCtrl(parent, -1, "guidance", pos=(320,50), size=(300, 200), style =wx.TE_MULTILINE)
176    self.guide.Bind(wx.EVT_LISTBOX, self.ShowGuide, self.guide)
177
178
179  def ShowGuide(self, event):
180    self.guide.Clear() # how to cleat the whole text before showing the next
181    g4com =str(self.comListBox.GetStringSelection())
182    self.guide.WriteText( commandDic[g4com])
183    self.g4comText.SetValue(g4com)
184
185  def ExecuteCommand(self, event):
186    gApplyUICommand(str(self.g4comText.GetValue()))
187
188
189class VisPanel(wx.Panel):
190  def __init__(self, parent):
191    wx.Panel.__init__(self, parent, -1)
192
193    self.visZoomIn = wx.Button(parent, -1, "Zoom In", pos=(10,100), size=(80,30))
194    self.visZoomOut = wx.Button(parent, -1, "Zoom out", pos=(100,100), size=(80,30))
195    self.visUp = wx.Button(parent, -1, "Up", pos=(190,100), size=(80,30))
196    self.visDown = wx.Button(parent, -1, "Down", pos=(270,100), size=(80,30))
197    self.visLeft = wx.Button(parent, -1, "Left", pos=(360,100), size=(80,30))
198    self.visRight = wx.Button(parent, -1, "Left", pos=(450,100), size=(80,30))
199
200    viewerList = ["OpenGL", "VRML", "Wired"]
201    self.viewer = wx.RadioBox(self, -1, "Viewer", pos=(10,10),
202                             size=(210,60), choices=viewerList, majorDimension=1, style=wx.RA_SPECIFY_ROWS)
203    self.viewer.Bind(wx.EVT_RADIOBOX, self.ViewerSelected, self.viewer)
204    self.viewer.SetToolTip(wx.ToolTip("Select one"))
205    self.viewer.SetSelection(0)
206    if vrmlViewer == None: self.viewer.EnableItem(1, False)
207    if heprepViewer == None: self.viewer.EnableItem(2, False)
208
209    self.visZoomIn.Bind(wx.EVT_BUTTON, self.cmdExpand, self.visZoomIn)
210    self.visZoomOut.Bind(wx.EVT_BUTTON, self.cmdShrink, self.visZoomOut)
211    self.visUp.Bind(wx.EVT_BUTTON, self.cmdUp, self.visUp)
212    self.visDown.Bind(wx.EVT_BUTTON, self.cmdDown, self.visDown)
213    self.visRight.Bind(wx.EVT_BUTTON, self.cmdRight, self.visRight)
214    self.visLeft.Bind(wx.EVT_BUTTON, self.cmdLeft, self.visLeft)
215
216
217  def cmdExpand(self, event):
218    gApplyUICommand("/vis/viewer/zoom 1.2")
219  def cmdShrink(self, event):
220    gApplyUICommand("/vis/viewer/zoom 0.8")
221  def cmdUp(self, event):
222    gApplyUICommand("/vis/viewer/pan "   + " 0.  10. mm")
223  def cmdDown(self, event):
224    gApplyUICommand("/vis/viewer/pan " +  " 0. -10.  mm")
225  def cmdRight(self, event):
226    gApplyUICommand("/vis/viewer/pan " +  " -1. 0.  mm")
227  def cmdLeft(self, event):
228    gApplyUICommand("/vis/viewer/pan "   + " 1. 0. mm")
229
230  def ViewerSelected(self, event):
231    self.viewerName = event.GetString()
232
233    if self.viewerName == "OpenGL":
234      gApplyUICommand("/vis/viewer/select oglsxviewer")
235      gApplyUICommand("/vis/drawVolume")
236      gApplyUICommand("/vis/scene/add/trajectories")
237
238      gApplyUICommand("/tracking/storeTrajectory 1")
239      gApplyUICommand("/vis/scene/endOfEventAction accumulate")
240      gApplyUICommand("/vis/scene/endOfRunAction accumulate")
241
242    if self.viewerName == "VRML":
243      gApplyUICommand("/vis/viewer/select vrmlviewer")
244
245      gApplyUICommand("/vis/viewer/set/viewpointThetaPhi 90. 0.")
246      gApplyUICommand("/vis/viewer/set/style s")
247      gApplyUICommand("/vis/drawVolume")     
248      gApplyUICommand("/vis/scene/add/trajectories")
249
250      gApplyUICommand("/tracking/storeTrajectory 1")
251      gApplyUICommand("/vis/scene/endOfEventAction accumulate")
252      gApplyUICommand("/vis/scene/endOfRunAction accumulate")
253
254    if self.viewerName == "Wired":
255
256      gApplyUICommand("/vis/viewer/select wired")
257
258      gApplyUICommand("/vis/viewer/set/viewpointThetaPhi 90. 0.")
259      gApplyUICommand("/vis/viewer/set/style s")
260      gApplyUICommand("/vis/drawVolume")
261      gApplyUICommand("/vis/scene/add/trajectories")
262
263      gApplyUICommand("/tracking/storeTrajectory 1")
264      gApplyUICommand("/vis/scene/endOfEventAction accumulate")
265      gApplyUICommand("/vis/scene/endOfRunAction accumulate")
266
267# everytime wired is chosen, a new instance of wired is created
268# to reuse single wired, g4pipe.poll() must be checked BEFORE the SECOND Popen
269#      if g4pipe.poll() == None:
270      g4pipe=Popen(heprepViewer+ " -file " + heprepDir+"/" +heprepName +".heprep", shell=True)
271
272
273# not used
274class MyText(wx.StaticText):
275    def __init__(self, parent, Text):
276        wx.StaticText.__init__(self, parent, -1, Text, pos=(20,20))
277        self.Bind(wx.EVT_LEFT_UP, self.ChangeColor)
278         
279    def ChangeColor(self, event):
280        TheColour = self.GetForegroundColour()
281        if TheColour == (0,0,0):
282             self.SetLabel("Simulation is running!")
283             self.SetForegroundColour("red")
284        else:
285             self.SetLabel("Click me to start a run")
286             self.SetForegroundColour("black")
287
288# to be used to choose materials and particles
289# myList is a list of keys() of a dictionary
290# f.e., materials are Python objects with their names as their keys
291class SelectOne(wx.RadioBox):
292    def __init__(self, parent, myTitle, myList):
293        wx.RadioBox.__init__(self, parent, -1, myTitle, wx.DefaultPosition,
294                             wx.DefaultSize, myList, 3, wx.RA_SPECIFY_ROWS)
295#        self.Bind(wx.EVT_RADIOBOX, self.Selected)
296        self.SetToolTip(wx.ToolTip("Select one"))
297        self.SetSelection(0)
298#    used only to test  Bind and getValue
299#    def Selected(self, event):
300#        self.selected = event.GetString()
301
302
303# used to %3.3f floating point number
304# energy and length unit is given by unitList which must be a dictionary
305#           with units of Python objects and their name as their keys
306
307class FloatCounter(wx.Panel):
308    def __init__(self, parent, myTitle, unitList):
309        wx.Panel.__init__(self, parent, -1)
310
311        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
312        self.sizer.Add((10, -1))               
313        self.sizer.Add(wx.StaticText(parent, -1, myTitle, wx.DefaultPosition, (100, -1)))
314
315        self.intPart = wx.SpinCtrl(parent, -1, "", wx.DefaultPosition, (60,-1))
316        self.intPart.SetRange(0,999)
317        self.intPart.SetValue(1)
318        self.intPart.Bind(wx.EVT_SPINCTRL, self.SetFloat)
319
320        self.manPart = wx.SpinCtrl(parent, -1, "", wx.DefaultPosition, (50, -1))
321        self.manPart.SetRange(0,999)
322        self.manPart.SetValue(0)
323        self.manPart.Bind(wx.EVT_SPINCTRL, self.SetFloat)
324
325        self.unitSel = wx.Choice(parent, -1, wx.DefaultPosition, (90, -1),  unitList)
326        self.unitSel.Bind(wx.EVT_CHOICE, self.SetFloat, self.unitSel)
327        self.unitSel.SetSelection(2)
328
329        self.valAndUnit = wx.TextCtrl(parent, -1, "value unset", wx.DefaultPosition, (150, -1))
330
331        self.sizer.Add(self.valAndUnit)
332        self.sizer.Add((10, -1))       
333        self.sizer.Add(wx.StaticText(parent, -1, "  ", wx.DefaultPosition, (30, -1)))       
334        self.sizer.Add(self.intPart)
335        self.sizer.Add(wx.StaticText(parent, -1, ".", wx.DefaultPosition, (10, -1)))
336        self.sizer.Add(self.manPart)
337        self.sizer.Add((5,-1))
338        self.sizer.Add(self.unitSel)
339        self.SetSizer(self.sizer)
340
341    def SetFloat(self, event):
342#        self.theValue = str(self.intPart.GetValue()) + "." + str(self.manPart.GetValue()) + "  "
343        self.theValue = float (self.intPart.GetValue()) + float(self.manPart.GetValue())/ 1000.
344        self.theUnit =  self.unitSel.GetStringSelection()
345        theText = "%.3f" % (self.theValue) + " " + self.theUnit
346        self.valAndUnit.SetValue(theText)
347# user may edit the Entry, so finnaly this value must be got
348#        but it doesn't work for length but work for energy (gApplyUIcommnd)
349
350
351# special class for this example to set/unset processes
352class Processes(wx.Panel):
353    def __init__(self, parent, myTitle, myList):
354        wx.Panel.__init__(self, parent, -1)
355        self.processCheck = {}
356        self.sizer = wx.FlexGridSizer(rows=3)
357        self.sizer.AddGrowableRow(1)
358        for item in myList:
359            self.processCheck[item] = wx.CheckBox(parent, -1, item)
360            self.processCheck[item].SetValue(True)
361#            self.processCheck[item].Bind(wx.EVT_CHECKBOX, self.CheckedProcess)
362            self.sizer.Add(self.processCheck[item],0,wx.EXPAND)
363
364        self.SetSizer(self.sizer)
365        self.SetBackgroundColour('green')
366        self.processState = {}
367        self.myList = myList
368
369# test only
370#    def CheckedProcess(self, event):
371#        self.processName = event.GetEventObject().GetLabel()
372#        self.processState = event.GetEventObject().GetValue()
373
374
375# slider to set an integer value
376# title is shown
377class Adjuster(wx.Panel):
378    def __init__(self, parent, myTitle, minVal, maxVal, initVal):
379        wx.Panel.__init__(self, parent, -1)
380        self.sizer = wx.BoxSizer(wx.HORIZONTAL)
381        self.sizer.Add((10, -1))
382        self.sizer.Add(wx.StaticText(parent, -1, myTitle, wx.DefaultPosition, (100, -1)))
383        self.slider = wx.Slider(parent, -1, initVal, minVal, maxVal,
384                           wx.DefaultPosition, (300, -1),
385                           wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS)
386        self.slider.SetPageSize(1)
387        self.sizer.Add(self.slider)
388        self.SetSizer(self.sizer)
389
390# test only       
391#        self.Bind(wx.EVT_SLIDER, self.Adjusted)
392
393#    def Adjusted(self, event):
394#        print self.GetValue()
395
396
397########################## no use now
398class Counter(wx.SpinCtrl):
399    def __init__(self, parent, myTitle, minVal, maxVal, initVal):
400        wx.SpinCtrl.__init__(self, parent, -1, "", wx.DefaultPosition, wx.DefaultSize, wx.TE_RIGHT)
401        self.SetRange(minVal, maxVal)
402        self.SetValue(initVal)
403        self.Bind(wx.EVT_SPINCTRL, self.Adjusted)
404    def Adjusted(self, event):
405        print self.GetValue()
406
407############################
408
409
410############################
411# WxPython Application class
412############################
413
414# main class to instantiate the above classes and pack them using nested sizers
415       
416class MyApp(wx.Frame):
417    def __init__(self):
418         wx.Frame.__init__(self, None, -1,  "Geant4Py", wx.DefaultPosition, size=(650,500))
419         self.nb = wx.Notebook(self, -1, wx.DefaultPosition, size=(650,500),
420                             style=
421                             wx.NB_TOP # | wx.NB_MULTILINE
422                             #wx.NB_BOTTOM
423                             #wx.NB_LEFT
424                             #wx.NB_RIGHT
425                             )
426         self.nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
427         self.nb.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGING, self.OnPageChanging)
428       
429         panel = wx.Panel(self.nb)
430         self.nb.AddPage(panel, "Lesson1")
431
432         commandPanel = wx.Panel(self.nb)
433         self.nb.AddPage(commandPanel, "Geant4 Commands")
434         comP = ComPanel(commandPanel)
435         gxsizer = wx.BoxSizer(wx.HORIZONTAL)
436         gxsizer.Add(comP)
437         commandPanel.SetSizer(gxsizer)
438
439         visualizationPanel = wx.Panel(self.nb)
440         self.nb.AddPage(visualizationPanel, "Vis Commands")         
441         visP = VisPanel(visualizationPanel)
442         vxsizer = wx.BoxSizer(wx.HORIZONTAL)
443         vxsizer.Add(visP)
444         visualizationPanel.SetSizer(vxsizer)
445
446         
447#  outmost sizer in the vertical direction
448         bxsizer = wx.BoxSizer(wx.VERTICAL)
449#   nested sizer in the horizontal direction
450         bysizer = wx.BoxSizer(wx.HORIZONTAL)
451
452         self.runStart = wx.Button(panel, -1, "  Run Start", pos=(30,10), size=(80,30))
453         self.Bind(wx.EVT_BUTTON, self.RunStart, self.runStart)
454         bxsizer.Add(self.runStart, 0, wx.ALL)
455# widgets
456         
457
458         materialList = absorber.keys()
459         self.theMaterial = SelectOne(panel, "Materials", materialList)
460 
461         particleList = ['gamma', 'e-', 'proton']
462         self.theParticle = SelectOne(panel, "Particles", particleList)
463
464         self.processList = ["phot", "compt", "conv", "msc", "eIoni", "eBrem", "annihil", "hIoni"]
465         self.theProcesses = Processes(panel, "Processes", self.processList)
466
467         self.eventNo = Adjuster(panel, "Number of Events", 1 , 100 , 1)
468
469         self.lengthUnit = {'micrometer':micrometer, 'mm':mm, 'cm':cm, 'm':m}
470         self.thickSpin = FloatCounter(panel, "absorber thickness", self.lengthUnit.keys())
471
472         self.energyUnit = { 'keV':keV, 'MeV':MeV, 'GeV':GeV, 'TeV':TeV, 'PeV':PeV}
473         self.energySpin = FloatCounter(panel, "incident beam energy", self.energyUnit.keys())
474
475# now sizers
476
477         bxsizer.Add(wx.StaticLine(panel), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5)
478         bysizer.Add((10, -1))
479         bysizer.Add(self.theMaterial, 0, wx.EXPAND, 10)
480         bysizer.Add((10, -1))
481         bysizer.Add(self.theParticle, 0, wx.EXPAND, 10)
482         bysizer.Add((10, -1))         
483         bysizer.Add(self.theProcesses.sizer, 0, wx.EXPAND, 10)
484         
485         bxsizer.Add(bysizer, 0, wx.EXPAND)
486
487         bxsizer.Add(wx.StaticLine(panel), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5)
488         bxsizer.Add(self.energySpin.sizer, 0, wx.EXPAND)
489         bxsizer.Add(wx.StaticLine(panel), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5)         
490         bxsizer.Add(self.thickSpin.sizer, 0, wx.EXPAND)         
491         
492         bxsizer.Add(wx.StaticLine(panel), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5)
493         bxsizer.Add(self.eventNo.sizer, 0, wx.EXPAND)
494
495         self.solid = g4py.ezgeom.G4EzVolume.GetSold(water_phantom)
496         
497         panel.SetSizer(bxsizer)
498         bxsizer.Fit(self)
499         bxsizer.SetSizeHints(self)
500
501    def OnPageChanged(self, event):
502        old = event.GetOldSelection()
503        new = event.GetSelection()
504        sel = self.nb.GetSelection()
505        event.Skip()
506
507    def OnPageChanging(self, event):
508        old = event.GetOldSelection()
509        new = event.GetSelection()
510        sel = self.nb.GetSelection()
511        event.Skip()
512
513
514###### Run Action
515
516
517    def RunStart(self, event):
518         materialChosen =  str( self.theMaterial.GetStringSelection() ) 
519         water_phantom.SetMaterial(absorber[materialChosen])
520         if materialChosen == "water":
521             water_phantom.SetColor(0., 0.9, 1.0)
522         if materialChosen == "air":
523             water_phantom.SetColor(0.9, 0.9, 1.0)
524         if materialChosen == "lead":
525             water_phantom.SetColor(0.2, 0.2, 0.2)
526         if materialChosen == "iron":
527             water_phantom.SetColor(0.7, 0.5, 0.7)
528         if materialChosen == "aluminum":
529             water_phantom.SetColor(.7, 0.9, 1.0)
530         if materialChosen == "gold":
531             water_phantom.SetColor(1., 0.9, .0)
532
533         self.solid.SetZHalfLength(  self.thickSpin.theValue * self.lengthUnit[self.thickSpin.theUnit] / 2.0 )
534
535#
536         gApplyUICommand("/vis/scene/add/text 0 610 610 mm 20 0 0  " + "Geant4Py in Action")
537         gApplyUICommand("/vis/viewer/flush")
538         gApplyUICommand("/gun/particle " +  str ( self.theParticle.GetStringSelection() ) )
539         for i in self.processList:
540#             print i, self.theProcesses.processCheck[i].GetValue()
541             gProcessTable.SetProcessActivation(i, 1)
542             if  self.theProcesses.processCheck[i].GetValue()  != True:
543                 gProcessTable.SetProcessActivation(i, 0)
544                 
545         gApplyUICommand("/gun/energy  " + str ( self.energySpin.valAndUnit.GetValue() ) )
546
547         eventNum = self.eventNo.slider.GetValue()
548         for i in range(eventNum):
549             gunYZpos = str(i-eventNum/2) + ". -50. cm"
550             gApplyUICommand("/gun/position 0. " + gunYZpos)
551             gRunManager.BeamOn(1)
552# next line is necessary for vrml to draw trajectories
553         gApplyUICommand("/vis/viewer/update")
554
555app = wx.PySimpleApp(False)
556MyApp().Show()
557app.MainLoop()
Note: See TracBrowser for help on using the repository browser.