/[escript]/trunk/pyvisi/py_src/plot.py
ViewVC logotype

Annotation of /trunk/pyvisi/py_src/plot.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 600 - (hide annotations)
Fri Mar 17 05:53:59 2006 UTC (13 years, 8 months ago) by gross
File MIME type: text/x-python
File size: 15413 byte(s)
some renaming
1 cochrane 337 # Copyright (C) 2004-2005 Paul Cochrane
2     #
3     # This program is free software; you can redistribute it and/or
4     # modify it under the terms of the GNU General Public License
5     # as published by the Free Software Foundation; either version 2
6     # of the License, or (at your option) any later version.
7     #
8     # This program is distributed in the hope that it will be useful,
9     # but WITHOUT ANY WARRANTY; without even the implied warranty of
10     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11     # GNU General Public License for more details.
12     #
13     # You should have received a copy of the GNU General Public License
14     # along with this program; if not, write to the Free Software
15     # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16    
17     # $Id: plot.py,v 1.19 2005/11/02 04:52:07 paultcochrane Exp $
18    
19     ## @file plot.py
20    
21     """
22     Base class and functions associated with a pyvisi Plot objects
23     """
24    
25     # generic imports
26     from pyvisi.common import debugMsg, overrideWarning
27    
28     from pyvisi.item import Item
29    
30     __revision__ = '$Revision: 1.19 $'
31    
32     class Plot(Item):
33     """
34     Abstract plot class
35    
36     This is the abstract base class of all Plot objects. Renderer
37     modules must inherit and override the methods defined here.
38     """
39     def __init__(self, scene):
40     """
41     Initialisation of abstract Plot class
42    
43     @param scene: the scene with which to associate the Plot
44     @type scene: Scene object
45     """
46     Item.__init__(self)
47     debugMsg("Called Plot.__init__()")
48    
49     if scene is None:
50     raise ValueError, "You must specify a scene object"
51    
52     self.title = None
53     self.xlabel = None
54     self.ylabel = None
55     self.zlabel = None
56    
57     def setData(self, *dataList):
58     """
59     Set data to Plot
60    
61     @param dataList: the data to set to the plot
62     @type dataList: tuple
63     """
64     debugMsg("Called setData() in Plot()")
65    
66     if dataList is None:
67     raise ValueError, "You must specify a data list"
68    
69     # print a warning message if get to here
70     overrideWarning("Plot.setData")
71    
72     return
73    
74     def setTitle(self, title):
75     """
76     Set the plot title
77    
78     @param title: the string holding the title to the plot
79     @type title: string
80     """
81     debugMsg("Called Plot.setTitle()")
82    
83     self.title = title
84    
85     return
86    
87     def setXLabel(self, label):
88     """
89     Set the label of the x-axis
90    
91     @param label: the string holding the label of the x-axis
92     @type label: string
93     """
94     debugMsg("Called Plot.setXLabel()")
95    
96     self.xlabel = label
97    
98     return
99    
100     def setYLabel(self, label):
101     """
102     Set the label of the y-axis
103    
104     @param label: the string holding the label of the y-axis
105     @type label: string
106     """
107     debugMsg("Called Plot.setYLabel()")
108    
109     self.ylabel = label
110    
111     return
112    
113     def setZLabel(self, label):
114     """
115     Set the label of the z-axis
116    
117     @param label: the string holding the label of the z-axis
118     @type label: string
119     """
120     debugMsg("Called Plot.setZLabel()")
121    
122     self.zlabel = label
123    
124     return
125    
126     def setLabel(self, axis, label):
127     """
128     Set the label of a given axis
129    
130     @param axis: string (Axis object maybe??) of the axis (e.g. x, y, z,)
131     @type axis: string or Axis object
132    
133     @param label: string of the label to set for the axis
134     @type label: string
135     """
136     debugMsg("Called Plot.setLabel()")
137    
138     # string-wise implementation
139     if axis == 'x' or axis == 'X':
140     self.xlabel = label
141     elif axis == 'y' or axis == 'Y':
142     self.ylabel = label
143     elif axis == 'z' or axis == 'Z':
144     self.zlabel = label
145     else:
146     raise ValueError, "axis must be x or y or z"
147    
148     return
149    
150     class ArrowPlot(Plot):
151     """
152     Arrow field plot
153    
154     This is the abstract base class of all ArrowPlot objects. Renderer
155     modules must inherit and override the methods defined here.
156     """
157     def __init__(self, scene):
158     """
159     Initialisation of ArrowPlot class
160    
161     @param scene: the scene with which to associate the ArrowPlot
162     @type scene: Scene object
163     """
164     Plot.__init__(self, scene)
165     debugMsg("Called ArrowPlot.__init__()")
166    
167     if scene is None:
168     raise ValueError, "You must specify a scene object"
169    
170     def setData(self, *dataList):
171     """
172     Set data to ArrowPlot
173    
174     @param dataList: the data to set to the plot
175     @type dataList: tuple
176     """
177     debugMsg("Called setData() in ArrowPlot()")
178    
179     if dataList is None:
180     raise ValueError, "You must specify a data list"
181    
182     # print a warning message if get to here
183     overrideWarning("ArrowPlot.setData")
184    
185     return
186    
187     class BallPlot(Plot):
188     """
189     Ball plot
190    
191     This is the abstract base class of all BallPlot objects. Renderer
192     modules must inherit and override the methods defined here.
193     """
194     def __init__(self, scene):
195     """
196     Initialisation of BallPlot class
197    
198     @param scene: the scene with which to associate the BallPlot
199     @type scene: Scene object
200     """
201     Plot.__init__(self, scene)
202     debugMsg("Called BallPlot.__init__()")
203    
204     if scene is None:
205     raise ValueError, "You must specify a scene object"
206    
207     def setData(self, *dataList):
208     """
209     Set data to BallPlot
210    
211     @param dataList: the data to set to the plot
212     @type dataList: tuple
213     """
214     debugMsg("Called setData() in BallPlot()")
215    
216     if dataList is None:
217     raise ValueError, "You must specify a data list"
218    
219     # print a warning message if get to here
220     overrideWarning("BallPlot.setData")
221    
222     return
223    
224     class ContourPlot(Plot):
225     """
226     Contour plot
227    
228     This is the abstract base class of all ContourPlot objects. Renderer
229     modules must inherit and override the methods defined here.
230     """
231     def __init__(self, scene):
232     """
233     Initialisation of ContourPlot class
234    
235     @param scene: the scene with which to associate the ContourPlot
236     @type scene: Scene object
237     """
238     Plot.__init__(self, scene)
239     debugMsg("Called ContourPlot.__init__()")
240    
241     if scene is None:
242     raise ValueError, "You must specify a scene object"
243    
244     def setData(self, *dataList):
245     """
246     Set data to ContourPlot
247    
248     @param dataList: the data to set to the plot
249     @type dataList: tuple
250     """
251     debugMsg("Called setData() in ContourPlot()")
252    
253     if dataList is None:
254     raise ValueError, "You must specify a data list"
255    
256     # print a warning message if get to here
257     overrideWarning("ContourPlot.setData")
258    
259     return
260    
261     class EllipsoidPlot(Plot):
262     """
263     Ellipsoid plot
264    
265     This is the abstract base class of all EllipsoidPlot objects. Renderer
266     modules must inherit and override the methods defined here.
267     """
268     def __init__(self, scene):
269     """
270     Initialisation of EllipsoidPlot class
271    
272     @param scene: the scene with which to associate the EllipsoidPlot
273     @type scene: Scene object
274     """
275     Plot.__init__(self, scene)
276     debugMsg("Called EllipsoidPlot.__init__()")
277    
278     if scene is None:
279     raise ValueError, "You must specify a scene object"
280    
281     def setData(self, *dataList):
282     """
283     Set data to EllipsoidPlot
284    
285     @param dataList: the data to set to the plot
286     @type dataList: tuple
287     """
288     debugMsg("Called setData() in EllipsoidPlot()")
289    
290     if dataList is None:
291     raise ValueError, "You must specify a data list"
292    
293     # print a warning message if get to here
294     overrideWarning("EllipsoidPlot.setData")
295    
296     return
297    
298     class IsosurfacePlot(Plot):
299     """
300     Isosurface plot
301    
302     This is the abstract base class of all IsosurfacePlot objects. Renderer
303     modules must inherit and override the methods defined here.
304     """
305     def __init__(self, scene):
306     """
307     Initialisation of IsosurfacePlot class
308    
309     @param scene: the scene with which to associate the IsosurfacePlot
310     @type scene: Scene object
311     """
312     Plot.__init__(self, scene)
313     debugMsg("Called IsosurfacePlot.__init__()")
314    
315     if scene is None:
316     raise ValueError, "You must specify a scene object"
317    
318     def setData(self, *dataList):
319     """
320     Set data to IsosurfacePlot
321    
322     @param dataList: the data to set to the plot
323     @type dataList: tuple
324     """
325     debugMsg("Called setData() in IsosurfacePlot()")
326    
327     if dataList is None:
328     raise ValueError, "You must specify a data list"
329    
330     # print a warning message if get to here
331     overrideWarning("IsosurfacePlot.setData")
332    
333     return
334    
335     class LinePlot(Plot):
336     """
337     Line plot
338    
339     This is the abstract base class of all LinePlot objects. Renderer
340     modules must inherit and override the methods defined here.
341     """
342     def __init__(self, scene):
343     """
344     Initialisation of LinePlot class
345    
346     @param scene: the scene with which to associate the LinePlot
347     @type scene: Scene object
348     """
349     Plot.__init__(self, scene)
350     debugMsg("Called LinePlot.__init__()")
351    
352     self.renderer = scene.renderer
353    
354     if scene is None:
355     raise ValueError, "You must specify a scene object"
356    
357     self.title = None
358     self.xlabel = None
359     self.ylabel = None
360     self.zlabel = None
361    
362     self.linestyle = None # pyvisi-defined linestyle
363     self._linestyle = None # renderer-specific linestyle
364    
365     def setData(self, *dataList):
366     """
367     Sets the data to the given plot object.
368    
369     @param dataList: list of data objects to plot
370     @type dataList: tuple
371     """
372     debugMsg("Called setData() in LinePlot()")
373    
374     if dataList is None:
375     raise ValueError, "You must specify a data list"
376    
377     # print a warning message if get to here
378     overrideWarning("LinePlot.setData")
379    
380     return
381    
382     def render(self):
383     """
384     Does LinePlot object specific (pre) rendering stuff
385     """
386     debugMsg("Called LinePlot.render()")
387    
388     # print a warning message if get to here
389     overrideWarning("LinePlot.render")
390    
391     return
392    
393     def setLineStyle(self, linestyle):
394     """
395     Sets the linestyle of the LinePlot
396    
397     Linestyles may be either a word in the Gnuplot style, or a symbol
398     shortcut in the Matlab style. Some of the options do not have a
399     Matlab equivalent but do have a Gnuplot equivalent, or vice versa.
400    
401     What this method does, is take the linestyles possible as defined by
402     PyVisi, and then does some conversion as best it can to get the
403     relevant output from (in this case) gnuplot.
404    
405     Possible linestyles are:
406     1. lines ('-')
407     2. points ('o')
408     3. linespoints ('-o')
409     4. dots ('.')
410     5. dotted (':')
411     6. dashes ('--')
412     7. dotdashes ('-.')
413    
414     @param linestyle: the style to use for the lines
415     @type linestyle: string
416     """
417     debugMsg("Called LinePlot.setLineStyle()")
418    
419     self.linestyle = linestyle
420    
421     # print a warning if get to here
422     overrideWarning("LinePlot.setLineStyle")
423    
424     return
425    
426     def getLineStyle(self):
427     """
428     Gets the current linestyle of the LinePlot
429    
430     @return: the linestyle as a string
431     """
432     debugMsg("Called LinePlot.getLineStyle()")
433    
434     return self.linestyle
435    
436     class ScatterPlot(Plot):
437     """
438     Scatter plot
439    
440     This is the abstract base class of all ScatterPlot objects. Renderer
441     modules must inherit and override the methods defined here.
442     """
443     def __init__(self, scene):
444     """
445     Initialisation of ScatterPlot class
446    
447     @param scene: the scene with which to associate the ScatterPlot
448     @type scene: Scene object
449     """
450     Plot.__init__(self, scene)
451     debugMsg("Called ScatterPlot.__init__()")
452    
453     if scene is None:
454     raise ValueError, "You must specify a scene object"
455    
456     def setData(self, *dataList):
457     """
458     Set data to ScatterPlot
459    
460     @param dataList: the data to set to the plot
461     @type dataList: tuple
462     """
463     debugMsg("Called ScatterPlot.setData()")
464    
465     if dataList is None:
466     raise ValueError, "You must specify a data list"
467    
468     # print a warning message if get to here
469     overrideWarning("ScatterPlot.setData")
470    
471     return
472    
473     class ScatterPlot3D(Plot):
474     """
475     Three dimensional scatter plot
476    
477     This is the abstract base class of all ScatterPlot3D objects. Renderer
478     modules must inherit and override the methods defined here.
479     """
480    
481     def __init__(self, scene):
482     """
483     Intialisation of ScatterPlot3D class
484    
485     @param scene: the scene with which to associate the ScatterPlot3D
486     @type scene: Scene object
487     """
488     debugMsg("Called ScatterPlot3D.__init__()")
489     Plot.__init__(self, scene)
490    
491     if scene is None:
492     raise ValueError, "You must specify a scene object"
493    
494     def setData(self, *dataList):
495     """
496     Set data to a ScatterPlot3D
497    
498     @param dataList: the data to set to the plot
499     @type dataList: tuple
500     """
501     debugMsg("Called ScatterPlot3D.setData()")
502    
503     if dataList is None:
504     raise ValueError, "You must specify a data list"
505    
506     # print a warning message if get to here
507     overrideWarning("ScatterPlot3D.setData")
508    
509     return
510    
511     def render(self):
512     """
513     Perform ScatterPlot3D specific rendering stuff
514     """
515     debugMsg("Called ScatterPlot3D.render()")
516    
517     # print a warning message if get to here
518     overrideWarning("ScatterPlot3D.render")
519    
520     return
521    
522     class SurfacePlot(Plot):
523     """
524     Surface plot
525    
526     This is the abstract base class of all SurfacePlot objects. Renderer
527     modules must inherit and override the methods defined here.
528     """
529    
530     def __init__(self, scene):
531     """
532     Intialisation of SurfacePlot class
533    
534     @param scene: the scene with which to associate the SurfacePlot
535     @type scene: Scene object
536     """
537     debugMsg("Called SurfacePlot.__init__()")
538     Plot.__init__(self, scene)
539    
540     if scene is None:
541     raise ValueError, "You must specify a scene object"
542    
543     def setData(self, *dataList):
544     """
545     Set data to a SurfacePlot
546    
547     @param dataList: the data to set to the plot
548     @type dataList: tuple
549     """
550     debugMsg("Called SufracePlot.setData()")
551    
552     if dataList is None:
553     raise ValueError, "You must specify a data list"
554    
555     # print a warning message if get to here
556     overrideWarning("SurfacePlot.setData")
557    
558     return
559    
560     def render(self):
561     """
562     Perform SurfacePlot specific rendering stuff
563     """
564     debugMsg("Called SurfacePlot.render()")
565    
566     # print a warning message if get to here
567     overrideWarning("SurfacePlot.render")
568    
569     return
570    
571     # vim: expandtab shiftwidth=4:
572    

  ViewVC Help
Powered by ViewVC 1.1.26