def __widget_dict_default(self):
     """Default value for source dict."""
     w = {'Box':tvtk.BoxWidget(place_factor = 0.9),
          'Sphere':tvtk.SphereWidget(place_factor = 0.9),
          'Plane':tvtk.PlaneWidget(place_factor = 0.9),
          'ImplicitPlane':
             tvtk.ImplicitPlaneWidget(place_factor=0.9,
                                      draw_plane=False)}
     return w
예제 #2
0
 def _actor_type_changed(self, value):
     if value == 'cone':
         a = actors.cone_actor()
         self.actor_map = {'cone': a}
     elif value == 'sphere':
         a = actors.sphere_actor()
         self.actor_map = {'sphere': a}
     elif value == 'plane_widget':
         w = tvtk.PlaneWidget()
         self.actor_map = {'plane_widget': w}
     elif value == 'box_widget':
         w = tvtk.BoxWidget()
         self.actor_map = {'box_widget': w}
예제 #3
0
 def _actor_type_changed(self, value):
     scene = self.scene
     if self._current_actor is not None:
         scene.remove_actors(self._current_actor)
     if value == 'cone':
         a = actors.cone_actor()
         scene.add_actors(a)
     elif value == 'sphere':
         a = actors.sphere_actor()
         scene.add_actors(a)
     elif value == 'plane_widget':
         a = tvtk.PlaneWidget()
         scene.add_actors(a)
     elif value == 'box_widget':
         a = tvtk.BoxWidget()
         scene.add_actors(a)
     self._current_actor = a
예제 #4
0
파일: simple.py 프로젝트: victorliun/mayavi
# Create the actor and set its mapper.
a = tvtk.Actor(mapper=m)

# Create a Renderer, add the actor and set its background color.
ren = tvtk.Renderer(background=(0.1, 0.2, 0.4))
ren.add_actor(a)

# Create a RenderWindow, add the renderer and set its size.
rw = tvtk.RenderWindow(size=(300, 300))
rw.add_renderer(ren)

# Create the RenderWindowInteractor
rwi = tvtk.RenderWindowInteractor(render_window=rw)

# Setup a box widget.
bw = tvtk.BoxWidget(interactor=rwi, place_factor=1.25, prop3d=a)
bw.place_widget()


def callback(widget, event):
    """This callback sets the transformation of the cone using that
    setup by the the box."""
    t = tvtk.Transform()
    bw.get_transform(t)
    bw.prop3d.user_transform = t


# Add an observer
bw.add_observer("InteractionEvent", callback)

# Turn on the box interaction.  The default is off and can be toggled
예제 #5
0
 def setup_pipeline(self):
     self._transform = tvtk.Transform()
     self.widget = tvtk.BoxWidget(place_factor=1.1)
     self.filter = tvtk.TransformFilter()
     super(TransformData, self).setup_pipeline()
# Create a Renderer, add the actor and set its background color.
ren = tvtk.Renderer()
ren.add_actor(a)
ren.background = (0.1, 0.2, 0.4)

# Create a RenderWindow, add the renderer and set its size.
rw = tvtk.RenderWindow()
rw.add_renderer(ren)
rw.size = (300, 300)

# Create the RenderWindowInteractor
rwi = tvtk.RenderWindowInteractor()
rwi.render_window = rw

# Setup a box widget.
bw = tvtk.BoxWidget()
bw.interactor = rwi
bw.place_factor = 1.25
bw.prop3d = a
bw.place_widget()


def callback(widget, event):
    """This callback sets the transformation of the cone using that
    setup by the the box."""
    t = tvtk.Transform()
    bw.get_transform(t)
    bw.prop3d.user_transform = t


# Add an observer