Package pyfeyn :: Module diagrams
[hide private]
[frames] | no frames]

Source Code for Module pyfeyn.diagrams

 1  """Diagramming classes - currently just FeynDiagram""" 
 2   
 3  import pyx 
 4  import re 
 5   
 6  ## Diagram class 
7 -class FeynDiagram:
8 """The main PyFeyn diagram class.""" 9 10 currentDiagram = None 11 currentCanvas = None 12 options = None 13 14 "Objects for holding a set of Feynman diagram components"
15 - def __init__(self, objects = []):
16 self.__objs = objects 17 FeynDiagram.currentCanvas = pyx.canvas.canvas() 18 FeynDiagram.currentDiagram = self
19
20 - def add(self, *objs):
21 for obj in objs: 22 if FeynDiagram.options.DEBUG: 23 print "#objs = %d" % len(self.__objs) 24 self.__objs.append(obj)
25
26 - def draw(self, file):
27 if FeynDiagram.options.DEBUG: 28 print "Final #objs = %d" % len(self.__objs) 29 if FeynDiagram.options.VDEBUG: 30 print "Running in visual debug mode" 31 ## TODO: order of drawing... 32 drawingobjs = self.__objs 33 for obj in drawingobjs: 34 obj.draw(FeynDiagram.currentCanvas) 35 FeynDiagram.currentCanvas.writetofile(file)
36