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 """Get the names of the data items"""
72 names=[]
73 tmp=self.data.getValueNames()
74
75 for n in tmp:
76 addIt=True
77 for f in self.forbidden:
78 if n.find(f)>=0:
79 addIt=False
80 break
81 if addIt:
82 names.append(n)
83 return names
84
86 """Check whether this timeline contains any timesteps"""
87 return len(self.data.getTimes())>0
88
90 """Check whether there is any plotable data"""
91 return self.hasTimes() and len(self.getNames())>0
92
115
116 - def buildData(self,times,name,title,lastValid):
117 """Build the implementation specific data
118 @param times: The vector of times for which data exists
119 @param name: the name under which the data is stored in the timeline
120 @param title: the title under which this will be displayed
121 @param lastValid: wether the last data entry is valid"""
122
123 notImplemented(self,"buildData")
124
126 """Prepare the plotting window"""
127
128 notImplemented(self,"preparePlot")
129
130
132 """Replot the whole data"""
133
134 notImplemented(self,"doReplot")
135
137 """Sets the title"""
138
139 notImplemented(self,"actualSetTitle")
140
145
147 """Sets the label on the first Y-Axis"""
148
149 notImplemented(self,"setYLabel")
150
152 """Sets the label on the second Y-Axis"""
153
154 notImplemented(self,"setYLabel2")
155
157 """Write the contents of the plot to disk
158 @param filename: Name of the file without type extension
159 @param form: String describing the format"""
160
161 notImplemented(self,"doHardcopy")
162
163
164