~ubuntu-branches/debian/sid/mayavi2/sid

« back to all changes in this revision

Viewing changes to enthought/mayavi/tools/decorations.py

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath
  • Date: 2009-03-27 04:34:55 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090327043455-vs6ox32daj6ndw33
Tags: 3.2.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
# Enthought library imports.
12
12
import enthought.mayavi.modules.api as modules
13
13
from enthought.traits.api import String, CFloat, Instance, HasTraits, \
14
 
            Trait, CArray, true, Any
 
14
            Trait, CArray, true, Any, Range
15
15
import tools
16
16
from figure import draw, gcf
17
17
 
322
322
    zlabel = String(None, adapts='axes.z_label',
323
323
                help='the label of the z axis')
324
324
 
 
325
    nb_labels = Range(0, 50, 2, adapts='axes.number_of_labels',
 
326
                desc='The number of labels along each direction') 
 
327
 
325
328
    ranges = Trait(None, None, CArray(shape=(6,)),
326
329
                    help="""[xmin, xmax, ymin, ymax, zmin, zmax]
327
330
                            Ranges of the labels displayed on the axes.
348
351
        if self.ranges is None:
349
352
            axes.axes.ranges = \
350
353
                axes.module_manager.source.outputs[0].bounds
351
 
            axes.axes.use_ranges = True
352
354
 
353
355
    def _ranges_changed(self):
354
356
        if self.ranges is not None:
411
413
 
412
414
    _target = Instance(modules.OrientationAxes, ())
413
415
 
414
 
orientationaxes = make_function(OrientationAxesFactory)
 
416
orientation_axes = make_function(OrientationAxesFactory)
415
417
 
416
418
 
417
419
###############################################################################
422
424
        
423
425
            text(x, y, text, ...) 
424
426
 
425
 
        x, and y are the position of the origin of the text on the 2D 
426
 
        projection of the figure. If a z keyword argument is given, the
 
427
        x, and y are the position of the origin of the text. If no z
 
428
        keyword argument is given, x and y are the 2D projection of the 
 
429
        figure, they belong to [0, 1]. If a z keyword  argument is given, the 
427
430
        text is positionned in 3D, in figure coordinnates.
428
431
        """
429
432
 
436
439
 
437
440
    _target = Instance(modules.Text, ())
438
441
 
 
442
    opacity = CFloat(1, adapts="property.opacity",
 
443
                        help="""The opacity of the text.""")
 
444
 
439
445
    def __init__(self, x, y, text, **kwargs):
440
446
        """ Override init as for different positional arguments."""
441
447
        if 'z' in kwargs and kwargs['z'] is not None:
442
448
            self._target.z_position = kwargs['z']
443
449
            self._target.position_in_3d = True
 
450
        elif not (x<1. and x>0. and y>0. and y<1.):
 
451
            raise ValueError('Text positions should be in [0, 1] if no z'
 
452
                'position is given')
444
453
        super(Text, self).__init__(None, **kwargs)
445
454
        self._target.text       = text
446
455
        self._target.x_position = x
489
498
            self.name = kwargs['name'] = 'Title'
490
499
        super(Title, self).__init__(**kwargs)
491
500
        self._target.text = self._text
 
501
        # We need to set position after Text is initiated, as text will 
 
502
        # override these positions
 
503
        self._target.y_position = self.height
 
504
        self._size_changed()
 
505
 
492
506
 
493
507
title = make_function(Title)
494
508