[vtkusers] Help with modified cubeAxes.py example

Raashid Baig raashid.b at rediffmail.com
Tue Jun 2 08:23:34 EDT 2009


I have modified the VTK/Examples/Annotation/Python/cubeAxes.py example.
I have introduced the SetAutoAdjustCameraClippingRange(1) function of vtkInteractorStyleSwitch class.
But the camera view is not reset along the current view direction.
Can someone please take a look at the example and point what am I doing wrong ?

import vtk
from vtk.util.misc import vtkGetDataRoot
VTK_DATA_ROOT = vtkGetDataRoot()

fohe = vtk.vtkBYUReader()
fohe.SetGeometryFileName(VTK_DATA_ROOT + "/Data/teapot.g")

foheMapper = vtk.vtkPolyDataMapper()
foheMapper.SetInputConnection(fohe.GetOutputPort())
foheActor = vtk.vtkLODActor()
foheActor.SetMapper(foheMapper)

outline = vtk.vtkOutlineFilter()
outline.SetInputConnection(fohe.GetOutputPort())
mapOutline = vtk.vtkPolyDataMapper()
mapOutline.SetInputConnection(outline.GetOutputPort())
outlineActor = vtk.vtkActor()
outlineActor.SetMapper(mapOutline)
outlineActor.GetProperty().SetColor(0, 0, 0)

ren2 = vtk.vtkRenderer()
ren2.AddViewProp(foheActor)
ren2.AddViewProp(outlineActor)
ren2.SetBackground(0.1, 0.2, 0.4)

renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(ren2)
renWin.SetWindowName("VTK - Cube Axes")
renWin.SetSize(600, 300)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

istyle = vtk.vtkInteractorStyleSwitch()
istyle.SetAutoAdjustCameraClippingRange(1)
iren.SetInteractorStyle(istyle)

axes2 = vtk.vtkCubeAxesActor2D()
axes2.SetViewProp(foheActor)
axes2.SetCamera(ren2.GetActiveCamera())
axes2.SetLabelFormat("%6.4g")
axes2.SetFlyModeToClosestTriad()
axes2.SetFontFactor(0.8)
axes2.ScalingOff()
ren2.AddViewProp(axes2)

iren.Initialize()
renWin.Render()
iren.Start()


Thanks in advance.
Raashid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090602/6a9383f8/attachment.htm>


More information about the vtkusers mailing list