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