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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26