1
2 """Plots a collection of timelines. General superclass for te other implementations"""
3
4 from PyFoam.Basics.CustomPlotInfo import readCustomPlotInfo,CustomPlotInfo
5
6 from PyFoam.Error import notImplemented
7
9 """Collects references to GeneralPlotLines objects"""
10
11 nr=1
12
15
22
24 """Makes sure that the data about the plots is to be transfered via XMLRPC"""
25 lst={}
26 for i,p in self.plots.iteritems():
27 lst[str(i)]={ "nr" : i,
28 "spec" : p.spec.getDict(),
29 "id" : p.spec.id,
30 "data" : p.data.lineNr }
31 return lst
32
33 _allPlots=PlotLinesRegistry()
34
37
38
40 """This class defines the interface for specific implementations of plotting
41
42 This class is moedelled after the Gnuplot-class from the Gnuplot-package"""
43
44 - def __init__(self,
45 timelines,
46 custom,
47 showWindow=True,
48 registry=None):
49 """@param timelines: The timelines object
50 @type timelines: TimeLineCollection
51 @param custom: A CustomplotInfo-object. Values in this object usually override the
52 other options
53 @param showWindow: whether or not to show a window. Doesn't affect all implementations
54 """
55
56 self.data=timelines
57 self.spec=custom
58
59 self.alternate=getattr(self.spec,"alternateAxis",[])
60 self.forbidden=getattr(self.spec,"forbidden",[])
61
62 self.showWindow=showWindow
63
64 if registry==None:
65 registry=allPlots()
66 self.nr=registry.add(self)
67
69 """Get the names of the data items"""
70 names=[]
71 tmp=self.data.getValueNames()
72
73 for n in tmp:
74 addIt=True
75 for f in self.forbidden:
76 if n.find(f)>=0:
77 addIt=False
78 break
79 if addIt:
80 names.append(n)
81 return names
82
84 """Check whether this timeline contains any timesteps"""
85 return len(self.data.getTimes())>0
86
88 """Check whether there is any plotable data"""
89 return self.hasTimes() and len(self.getNames())>0
90
113
114 - def buildData(self,times,name,title,lastValid):
115 """Build the implementation specific data
116 @param times: The vector of times for which data exists
117 @param name: the name under which the data is stored in the timeline
118 @param title: the title under which this will be displayed
119 @param lastValid: wether the last data entry is valid"""
120
121 notImplemented(self,"buildData")
122
124 """Prepare the plotting window"""
125
126 notImplemented(self,"preparePlot")
127
128
130 """Replot the whole data"""
131
132 notImplemented(self,"doReplot")
133
135 """Sets the title"""
136
137 notImplemented(self,"actualSetTitle")
138
143
145 """Sets the label on the first Y-Axis"""
146
147 notImplemented(self,"setYLabel")
148
150 """Sets the label on the second Y-Axis"""
151
152 notImplemented(self,"setYLabel2")
153
155 """Sets the label on the second Y-Axis"""
156
157 notImplemented(self,"setYLabel2")
158
160 """Write the contents of the plot to disk
161 @param filename: Name of the file without type extension
162 @param form: String describing the format"""
163
164 notImplemented(self,"doHardcopy")
165