Geant4-11
Public Member Functions | Data Fields | Private Attributes
emcalc_gui.MainWindow Class Reference

Public Member Functions

def __init__ (self)
 
def cb_close_dialog (self, widget, data=None)
 
def cb_select_material (self, widget, data=None)
 
def cb_select_particle (self, widget, data=None)
 
def cb_show_plot (self, widget, data=None)
 
def cb_show_textview (self, widget, data=None)
 
def create_action_box (self)
 
def create_header (self)
 
def create_material_frame (self)
 
def create_particle_frame (self)
 

Data Fields

 error_dialog
 
 mainwindow
 
 material
 
 material_combo
 
 material_list
 
 particle
 
 textview
 

Private Attributes

 __margin
 

Detailed Description

Definition at line 122 of file emcalc_gui.py.

Constructor & Destructor Documentation

◆ __init__()

def emcalc_gui.MainWindow.__init__ (   self)

Definition at line 123 of file emcalc_gui.py.

123 def __init__(self) :
124 self.__margin = 8
125
126 # main window
127 self.mainwindow = gtk.Window(gtk.WINDOW_TOPLEVEL)
128 self.mainwindow.set_title('Em Calculator')
129 self.mainwindow.set_position(gtk.WIN_POS_MOUSE)
130 self.mainwindow.set_default_size(500, 300)
131 self.mainwindow.connect('delete-event', lambda w,d: gtk.main_quit())
132 self.mainwindow.connect('destroy-event',lambda w,d: gtk.main_quit())
133
134 # components
135 header = self.create_header()
136
137 particle_frame = self.create_particle_frame()
138 particle_frame.set_border_width(self.__margin)
139
140 material_frame = self.create_material_frame()
141 material_frame.set_border_width(self.__margin)
142
143 separator = gtk.HSeparator()
144
145 action_box = self.create_action_box()
146 action_box.set_border_width(self.__margin)
147
148 # layout
149 vbox = gtk.VBox()
150 vbox.pack_start(header)
151 vbox.pack_start(particle_frame)
152 vbox.pack_start(material_frame)
153 vbox.pack_start(separator)
154 vbox.pack_start(action_box)
155
156 self.mainwindow.add(vbox)
157 self.mainwindow.show_all()
158
159 # text view
160 self.textview = TextView()
161
162 # error dialog
163 self.error_dialog = gtk.MessageDialog(parent=self.mainwindow,
164 buttons=gtk.BUTTONS_CLOSE, type=gtk.MESSAGE_ERROR,
165 message_format="Material is not defined in G4Nist materials")
166 self.error_dialog.connect("response", self.cb_close_dialog)
167
def connect(endpoint="tcp://127.0.0.1:5555")
Definition: g4zmq.py:15

Member Function Documentation

◆ cb_close_dialog()

def emcalc_gui.MainWindow.cb_close_dialog (   self,
  widget,
  data = None 
)

Definition at line 295 of file emcalc_gui.py.

295 def cb_close_dialog(self, widget, data=None) :
296 widget.hide_all()
297
298
299# -------------------------------------------------------------------
300# text view
301# -------------------------------------------------------------------

◆ cb_select_material()

def emcalc_gui.MainWindow.cb_select_material (   self,
  widget,
  data = None 
)

Definition at line 276 of file emcalc_gui.py.

276 def cb_select_material(self, widget, data=None) :
277 entry = widget.get_child()
278 self.material = entry.get_text()
279

References emcalc_gui.MainWindow.material, GFlashHomoShowerParameterisation.material, G4EmCorrections.material, and G4EmElementSelector.material.

◆ cb_select_particle()

def emcalc_gui.MainWindow.cb_select_particle (   self,
  widget,
  data = None 
)

◆ cb_show_plot()

def emcalc_gui.MainWindow.cb_show_plot (   self,
  widget,
  data = None 
)

Definition at line 280 of file emcalc_gui.py.

280 def cb_show_plot(self, widget, data=None) :
281 g4mate = gNistManager.FindOrBuildMaterial(self.material)
282 if (g4mate == None) :
283 self.error_dialog.show_all()
284 return
285
286 if (self.material_list.count(self.material) == 0) :
287 self.material_combo.append_text(self.material)
288
289 if (self.particle == "gamma" ) :
290 plot_gamma(self.material)
291 else :
292 plot_charged(self.material, self.particle)
293 self.textview.textbuffer.set_text(mycout.getvalue())
294
def plot_gamma(material)
Definition: emcalc_gui.py:69
def plot_charged(material, pname)
Definition: emcalc_gui.py:27

References emcalc_gui.MainWindow.error_dialog, emcalc_gui.MainWindow.material, GFlashHomoShowerParameterisation.material, G4EmCorrections.material, G4EmElementSelector.material, emcalc_gui.MainWindow.material_combo, emcalc_gui.MainWindow.material_list, emcalc_gui.MainWindow.particle, MedicalBeam.particle, G4UrbanAdjointMscModel.particle, G4eeToPGammaModel.particle, G4MuBetheBlochModel.particle, G4MuBremsstrahlungModel.particle, G4MuPairProductionModel.particle, G4AtimaEnergyLossModel.particle, G4AtimaFluctuations.particle, G4BetheBlochModel.particle, G4BraggIonModel.particle, G4BraggModel.particle, G4eBremParametrizedModel.particle, G4eCoulombScatteringModel.particle, G4eSingleCoulombScatteringModel.particle, G4GoudsmitSaundersonMscModel.particle, G4hCoulombScatteringModel.particle, G4ICRU73QOModel.particle, G4IonCoulombCrossSection.particle, G4IonCoulombScatteringModel.particle, G4IonFluctuations.particle, G4LindhardSorensenIonModel.particle, G4MollerBhabhaModel.particle, G4ScreeningMottCrossSection.particle, G4UniversalFluctuation.particle, G4UrbanMscModel.particle, G4WentzelOKandVIxSection.particle, G4WentzelVIModel.particle, G4EmCorrections.particle, G4EmModelManager.particle, G4VEmProcess.particle, G4VEnergyLossProcess.particle, G4ParticleInelasticXS.particle, G4HadronicProcessStore.particle, G4INCL::ConsideredPartner.particle, G4VPreCompoundFragment.particle, emcalc_gui.plot_charged(), emcalc_gui.plot_gamma(), and emcalc_gui.MainWindow.textview.

Referenced by emcalc_gui.MainWindow.create_action_box().

◆ cb_show_textview()

def emcalc_gui.MainWindow.cb_show_textview (   self,
  widget,
  data = None 
)

Definition at line 269 of file emcalc_gui.py.

269 def cb_show_textview(self, widget, data=None) :
270 window = self.textview.get_window()
271 window.show_all()
272

References emcalc_gui.MainWindow.textview.

Referenced by emcalc_gui.MainWindow.create_action_box().

◆ create_action_box()

def emcalc_gui.MainWindow.create_action_box (   self)

Definition at line 250 of file emcalc_gui.py.

250 def create_action_box(self) :
251 box = gtk.HButtonBox()
252 box.set_layout(gtk.BUTTONBOX_END)
253 box.set_spacing(self.__margin)
254
255 exec_button = gtk.Button(stock = gtk.STOCK_EXECUTE)
256 text_button = gtk.Button("Text View")
257 quit_button = gtk.Button(stock = gtk.STOCK_QUIT)
258 box.add(exec_button)
259 box.add(text_button)
260 box.add(quit_button)
261
262 exec_button.connect("clicked", self.cb_show_plot)
263 text_button.connect("clicked", self.cb_show_textview)
264 quit_button.connect("clicked", lambda w: gtk.main_quit())
265
266 return box
267

References emcalc_gui.MainWindow.__margin, emcalc_gui.TextView.__margin, emcalc_gui.MainWindow.cb_show_plot(), and emcalc_gui.MainWindow.cb_show_textview().

◆ create_header()

def emcalc_gui.MainWindow.create_header (   self)

Definition at line 168 of file emcalc_gui.py.

168 def create_header(self) :
169 hbox = gtk.HBox()
170
171 label = gtk.Label()
172 label.set_markup("<big><b>EM Calculator</b></big>")
173 hbox.pack_start(label)
174
175 label = gtk.Label()
176 text = """
177
178Shows
179 - stopping power for e/mu/proton
180 - cross sections for gamma
181"""
182 label.set_markup(text)
183 hbox.pack_start(label)
184
185 return hbox
186

◆ create_material_frame()

def emcalc_gui.MainWindow.create_material_frame (   self)

Definition at line 227 of file emcalc_gui.py.

227 def create_material_frame(self) :
228 frame = gtk.Frame("Material (G4Nist)")
229
230 hbox = gtk.HBox()
231 frame.add(hbox)
232 hbox.set_border_width(self.__margin)
233
234 self.material_list = [ "G4_Al", "G4_Si", "G4_Ar", "G4_Cu", "G4_Fe",
235 "G4_Ge", "G4_Ag", "G4_W", "G4_Au", "G4_Pb",
236 "G4_AIR", "G4_Galactic", "G4_WATER", "G4_CESIUM_IODIDE",
237 "G4_SODIUM_IODIDE", "G4_PLASTIC_SC_VINYLTOLUENE",
238 "G4_MYLAR" ]
239
240 self.material_combo = gtk.combo_box_entry_new_text()
241 hbox.pack_start(self.material_combo)
242 for name in self.material_list :
243 self.material_combo.append_text(name)
244 self.material_combo.set_active(0)
245 self.material = self.material_list[0]
246 self.material_combo.connect("changed", self.cb_select_material)
247
248 return frame
249

References emcalc_gui.MainWindow.__margin, and emcalc_gui.TextView.__margin.

◆ create_particle_frame()

def emcalc_gui.MainWindow.create_particle_frame (   self)

Definition at line 187 of file emcalc_gui.py.

187 def create_particle_frame(self) :
188 frame = gtk.Frame("Particle")
189
190 hbox = gtk.HBox()
191 frame.add(hbox)
192 hbox.set_border_width(self.__margin)
193
194 button = gtk.RadioButton(None, "electron")
195 button.connect("toggled", self.cb_select_particle, "e-")
196 hbox.pack_start(button, True, True, 0)
197 button.show()
198 self.particle = "e-"
199
200 button = gtk.RadioButton(button, "positron")
201 button.connect("toggled", self.cb_select_particle, "e+")
202 hbox.pack_start(button, True, True, 0)
203 button.show()
204
205 button = gtk.RadioButton(button, "mu-")
206 button.connect("toggled", self.cb_select_particle, "mu-")
207 hbox.pack_start(button, True, True, 0)
208 button.show()
209
210 button = gtk.RadioButton(button, "mu+")
211 button.connect("toggled", self.cb_select_particle, "mu+")
212 hbox.pack_start(button, True, True, 0)
213 button.show()
214
215 button = gtk.RadioButton(button, "proton")
216 button.connect("toggled", self.cb_select_particle, "proton")
217 hbox.pack_start(button, True, True, 0)
218 button.show()
219
220 button = gtk.RadioButton(button, "gamma")
221 button.connect("toggled", self.cb_select_particle, "gamma")
222 hbox.pack_start(button, True, True, 0)
223 button.show()
224
225 return frame
226

References emcalc_gui.MainWindow.__margin, emcalc_gui.TextView.__margin, and emcalc_gui.MainWindow.cb_select_particle().

Field Documentation

◆ __margin

emcalc_gui.MainWindow.__margin
private

◆ error_dialog

emcalc_gui.MainWindow.error_dialog

Definition at line 163 of file emcalc_gui.py.

Referenced by emcalc_gui.MainWindow.cb_show_plot().

◆ mainwindow

emcalc_gui.MainWindow.mainwindow

Definition at line 127 of file emcalc_gui.py.

◆ material

emcalc_gui.MainWindow.material

◆ material_combo

emcalc_gui.MainWindow.material_combo

Definition at line 240 of file emcalc_gui.py.

Referenced by emcalc_gui.MainWindow.cb_show_plot().

◆ material_list

emcalc_gui.MainWindow.material_list

Definition at line 234 of file emcalc_gui.py.

Referenced by emcalc_gui.MainWindow.cb_show_plot().

◆ particle

emcalc_gui.MainWindow.particle

◆ textview

emcalc_gui.MainWindow.textview

The documentation for this class was generated from the following file: