This file is indexed.

/usr/share/pyshared/mayavi/modules/text3d.py is in mayavi2 4.1.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
""" This module allows the user to place text in 3D at a location on the
scene.

Unlike the 'Text' module, this module positions text in 3D in the scene,
and in 2D on the screen. As a result the text resizes with the figure,
and can be masked by objects in the foreground.
"""
# Author: Gael Varoquaux <gael dot varoquaux at normalesup dot org>
# Copyright (c) 2009, Enthought, Inc.
# License: BSD Style.

# Enthought library imports.
from traits.api import Instance, Str, CArray, Bool
from traitsui.api import View, Group, Item

# Local imports
from tvtk.api import tvtk
from mayavi.core.module import Module
from mayavi.core.pipeline_info import PipelineInfo
from mayavi.components.actor import Actor

######################################################################
# `Text3D` class.
######################################################################

class Text3D(Module):
    # The version of this class.  Used for persistence.
    __version__ = 0

    # The Mayavi Actor.
    actor = Instance(Actor, allow_none=False, record=True)

    # And the text source
    vector_text = Instance(tvtk.VectorText, allow_none=False, record=True)

    # The text to be displayed.
    text = Str('Text', desc='the text to be displayed',
                       enter_set=True, auto_set=False)

    # The position of the actor
    position = CArray(value=(0., 0., 0.), cols=3,
                      desc='the world coordinates of the text',
                      enter_set=True, auto_set=False)

    # The scale of the actor
    scale = CArray(value=(1., 1., 1.), cols=3,
                      desc='the scale of the text',
                      enter_set=True, auto_set=False)

    # The orientation of the actor
    orientation = CArray(value=(0., 0., 0.), cols=3,
                      desc='the orientation angles of the text',
                      enter_set=True, auto_set=False)

    # Orient actor to camera
    orient_to_camera = Bool(True,
                      desc='if the text is kept facing the camera')

    input_info = PipelineInfo(datasets=['any'],
                              attribute_types=['any'],
                              attributes=['any'])

    ########################################
    # The view of this object.

    view = View(Group(Item(name='text'),
                      Group(Item(name='position'),
                        show_labels=False, show_border=True,
                        label='Position'),
                      Group(Item(name='scale'),
                        show_labels=False, show_border=True,
                        label='Scale'),
                      Group(
                           Item(name='orient_to_camera'),
                           Item(name='orientation',
                                 label='Angles'),
                        show_border=True,
                        label='Orientation'),
                      label='Text',
                      ),
                  Group(Item(name='actor', style='custom',
                             show_label=False),
                      label='Actor'),
                )

    ######################################################################
    # `Module` interface
    ######################################################################
    def setup_pipeline(self):
        """Override this method so that it *creates* the tvtk
        pipeline.

        This method is invoked when the object is initialized via
        `__init__`.  Note that at the time this method is called, the
        tvtk data pipeline will *not* yet be setup.  So upstream data
        will not be available.  The idea is that you simply create the
        basic objects and setup those parts of the pipeline not
        dependent on upstream sources and filters.  You should also
        set the `actors` attribute up at this point.
        """
        self.vector_text = tvtk.VectorText(text=self.text)
        self.outputs = [self.vector_text.output]
        self.actor = Actor()
        self._text_changed(self.text)


    def update_pipeline(self):
        """Override this method so that it *updates* the tvtk pipeline
        when data upstream is known to have changed.

        This method is invoked (automatically) when any of the inputs
        sends a `pipeline_changed` event.
        """
        self.pipeline_changed = True


    ######################################################################
    # Non-public interface
    ######################################################################
    def _text_changed(self, value):
        vector_text = self.vector_text
        if vector_text is None:
            return
        vector_text.text = str(value)
        self.render()


    def _actor_changed(self, old, new):
        new.scene = self.scene
        new.inputs = [self]
        self._change_components(old, new)
        old_actor = None
        if old is not None:
            old_actor = old.actor
        new.actor = self._get_actor_or_follower(old=old_actor)
        self.actors = new.actors
        self.render()


    def _orient_to_camera_changed(self):
        self.actor.actor = \
                    self._get_actor_or_follower(old=self.actor.actor)


    def _get_actor_or_follower(self, old=None):
        """ Get a tvtk.Actor or a tvtk.Follower for the actor of the
            object and wire the callbacks to it.
            If old is given, it is the old actor, to remove its
            callbacks.
        """
        if self.orient_to_camera:
            new = tvtk.Follower()
            if self.scene is not None:
                new.camera = self.scene.camera
        else:
            new = tvtk.Actor()
        if old is not None:
            self.sync_trait('position', old, 'position', remove=True)
            self.sync_trait('scale', old, 'scale', remove=True)
            self.sync_trait('orientation', old, 'orientation', remove=True)

        self.sync_trait('position', new, 'position')
        self.sync_trait('scale', new, 'scale')
        self.sync_trait('orientation', new, 'orientation')
        return new


    def _scene_changed(self, old, new):
        super(Text3D, self)._scene_changed(old, new)
        if new is not None and self.orient_to_camera:
            self.actor.actor.camera = new.camera