[vtkusers] About using SetInteractorStyle

Zampini Samuele samuele.zampini at epfl.ch
Thu Oct 22 03:24:11 EDT 2009


Dear all,

I am trying to use the SetInteractorStyle in order to be able to act on only 1 object.

Actually, I do have to cones and I would like to be able to interact either 1st or 2nd one and not on the both of them.

Could you help?

Thanks a lot,

Samuele

PS: below the code (that's almost like the one you can find in the tutorial)


#! /usr/bin/python

try:
 	import gtk
   	import gtk.glade
except:
 	sys.exit(1)

from vmtk import pypes

import math

from gtk import gdk
import vtk

from vtk import *

# create a rendering window and renderer
ren = vtkRenderer()
renWin = vtkRenderWindow()
renWin.AddRenderer(ren)
renWin.SetSize(300,300)

iren = vtkRenderWindowInteractor()
# iren.SetRenderWindow(renWin)
iren.SetInteractorStyle(renWin)

# cone1
cone1 = vtk.vtkConeSource()
cone1.SetHeight(100)
cone1.SetRadius(50)
cone1.SetResolution(150)

# Map to graphics library
cone1_map = vtk.vtkPolyDataMapper()
cone1_map.SetInputConnection( cone1.GetOutputPort() )

# Actor coordinates geometry, properties, transformation
cone1_actor = vtk.vtkActor()
cone1_actor.SetMapper( cone1_map )
cone1_actor.SetPosition(0,3,0)
cone1_actor.GetProperty().SetColor(1,0,0)# cone1 is the
		                                              # red one
# Create a clipping plane to clip cone 1
plane1 = vtk.vtkPlane()
plane1.SetOrigin(0.05,0.0,0.0)# [*1]
plane1.SetNormal(-1.0,0.0,0.0)
cone1_map.AddClippingPlane( plane1 )
    
# self.ren_cones.AddActor(self.cone1_actor)
# self.ren_cones.ResetCamera() #(Original version)
ren.AddActor(cone1_actor)
ren.ResetCamera() #(Original version)


# cone2
cone2 = vtk.vtkConeSource()
cone2.SetHeight(100)
cone2.SetRadius(50)
cone2.SetResolution(150)
		
# Map to graphics library
cone2_map = vtk.vtkPolyDataMapper()
cone2_map.SetInput( cone2.GetOutput() )

# Actor coordinates geometry, properties, transfvaormation
cone2_actor = vtk.vtkActor()
cone2_actor.SetMapper(cone2_map)
cone2_actor.SetPosition(0,3,0)
# Cone_actor.RotateY(90)
cone2_actor.RotateZ(180)
cone2_actor.GetProperty().SetColor(1,0,0)# cone2 is the
                                         # black one
        
## Creating a clipping plane to clip cone 2
plane2 = vtk.vtkPlane()
plane2.SetOrigin(0.05,0.0,0.0)
plane2.SetNormal(1.0,0.0,0.0)
cone2_map.AddClippingPlane(plane2)

# self.ren_cones.AddActor(self.cone2_actor)
# self.ren_cones.ResetCamera() #(Original version)
ren.AddActor(cone2_actor)
ren.ResetCamera() #(Original version)

# enable user interface interactor
iren.Initialize()
iren.Start()


More information about the vtkusers mailing list