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
8 from PyFoam.ThirdParty.six import iteritems
9
11 """Collects references to GeneralPlotLines objects"""
12
13 nr=1
14
17
21
28
30 """Makes sure that the data about the plots is to be transfered via XMLRPC"""
31 lst={}
32 for i,p in iteritems(self.plots):
33 lst[str(i)]={ "nr" : i,
34 "spec" : p.spec.getDict(),
35 "id" : p.spec.id,
36 "data" : p.data.lineNr }
37 return lst
38
39 _allPlots=PlotLinesRegistry()
40
43
44
46 """This class defines the interface for specific implementations of plotting
47
48 This class is moedelled after the Gnuplot-class from the Gnuplot-package"""
49
50 - def __init__(self,
51 timelines,
52 custom,
53 showWindow=True,
54 registry=None):
55 """@param timelines: The timelines object
56 @type timelines: TimeLineCollection
57 @param custom: A CustomplotInfo-object. Values in this object usually override the
58 other options
59 @param showWindow: whether or not to show a window. Doesn't affect all implementations
60 """
61
62 self.data=timelines
63 self.spec=custom
64
65 self.alternate=getattr(self.spec,"alternateAxis",[])
66 self.forbidden=getattr(self.spec,"forbidden",[])
67
68 self.showWindow=showWindow
69
70 if registry==None:
71 registry=allPlots()
72 self.nr=registry.add(self)
73
75 if name in self.alternate:
76 return True
77 if name.find("_slave")>0:
78 for a in self.alternate:
79 if name[:name.find("_slave")]==a:
80 return True
81 return False
82
84 """Get the names of the data items"""
85 names=[]
86 tmp=self.data.getValueNames()
87
88 for n in tmp:
89 addIt=True
90 for f in self.forbidden:
91 if n.find(f)>=0:
92 addIt=False
93 break
94 if addIt:
95 names.append(n)
96 return names
97
99 """Check whether this timeline contains any timesteps"""
100 return len(self.data.getTimes())>0
101
103 """Check whether there is any plotable data"""
104 return self.hasTimes() and len(self.getNames())>0
105
128
129 - def buildData(self,times,name,title,lastValid):
130 """Build the implementation specific data
131 @param times: The vector of times for which data exists
132 @param name: the name under which the data is stored in the timeline
133 @param title: the title under which this will be displayed
134 @param lastValid: wether the last data entry is valid"""
135
136 notImplemented(self,"buildData")
137
139 """Prepare the plotting window"""
140
141 notImplemented(self,"preparePlot")
142
143
145 """Replot the whole data"""
146
147 notImplemented(self,"doReplot")
148
150 """Sets the title"""
151
152 notImplemented(self,"actualSetTitle")
153
158
160 """Sets the label on the first Y-Axis"""
161
162 notImplemented(self,"setYLabel")
163
165 """Sets the label on the second Y-Axis"""
166
167 notImplemented(self,"setYLabel2")
168
170 """Write the contents of the plot to disk
171 @param filename: Name of the file without type extension
172 @param form: String describing the format"""
173
174 notImplemented(self,"doHardcopy")
175
176
177