[vtkusers] vtkGenericRenderWindowInteractor

Joseph Melnyk JMelnyk at pile.com
Fri Mar 11 08:36:43 EST 2011


Looks like you just need to do an initial render before starting your interactor.


From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of LOUIS-JORDAN DEERING (RIT Student)
Sent: Thursday, March 10, 2011 8:23 PM
To: vtkusers at vtk.org
Subject: [vtkusers] vtkGenericRenderWindowInteractor


Hello All,

When I try to link the vtkGenericRenderWindowInteractor to the renWin, the window doesn't render until I click inside of it. How do I fix this? I need the Interactor to perform certain functions, but I need the window to render. If don't link the two together, the window renders correctly. They commented out block below is where I'm having trouble. Any suggestions? Thank you!

Luzjadi

---------------------

package require vtk
package require vtkinteraction

#Create the window to place the rendering object in.
vtkRenderWindow renWin
toplevel .top
wm title .top "Impeller Analyzer"

frame .top.frame

vtkTkRenderWidget .top.frame.r1
pack .top.frame.r1 -side left -padx 1 -pady 1 -fill both -expand t
pack .top.frame -fill both -expand t

# Create and bind renderer to the widget window.
set renWin [.top.frame.r1 GetRenderWindow]
vtkRenderer ren1
$renWin AddRenderer ren1
::vtk::bind_tk_render_widget .top.frame.r1

# Set rendering window properties.
ren1 SetBackground 1 1 1
renWin SetSize 500 500

#Create a toolbar menu.
menu .tbar
.top config -menu .tbar

#Create menu bar buttons.
.tbar add cascade -label "File"
.tbar add cascade -label "Help"

# Set the mouse interaction mode to trackball.
vtkGenericRenderWindowInteractor iren
        iren SetRenderWindow $renWin
vtkInteractorStyleTrackballCamera tball
        iren SetInteractorStyle tball
        iren Initialize


# Import the impeller object data files.
vtkDataSetReader impReader
        impReader SetFileName "Data/bladeDataXYZ.vtk"
        impReader Update
vtkDataSetReader hubReader
        hubReader SetFileName "Data/hubData.vtk"
        hubReader Update
vtkDataSetReader shroudReader
        shroudReader SetFileName "Data/shroudData.vtk"
        shroudReader Update

# Create the outline of the impeller blade.
vtkStructuredGridOutlineFilter impOutline
        impOutline SetInputConnection [impReader GetOutputPort]
vtkPolyDataMapper impOutlineMapper
        impOutlineMapper SetInputConnection [impOutline GetOutputPort]
vtkActor impOutlineActor
        impOutlineActor SetMapper impOutlineMapper
        [impOutlineActor GetProperty] SetColor 0 0 0

# Create the outline of the hub.
vtkStructuredGridOutlineFilter hubOutline
        hubOutline SetInputConnection [hubReader GetOutputPort]
vtkPolyDataMapper hubOutlineMapper
        hubOutlineMapper SetInputConnection [hubOutline GetOutputPort]
vtkActor hubOutlineActor
        hubOutlineActor SetMapper hubOutlineMapper
        [hubOutlineActor GetProperty] SetColor 0 0 0

# Create the outline of the shroud.
vtkStructuredGridOutlineFilter shroudOutline
        shroudOutline SetInputConnection [shroudReader GetOutputPort]
vtkPolyDataMapper shroudOutlineMapper
        shroudOutlineMapper SetInputConnection [shroudOutline GetOutputPort]
vtkActor shroudOutlineActor
        shroudOutlineActor SetMapper shroudOutlineMapper
        [shroudOutlineActor GetProperty] SetColor 0 0 0

# Create the solid geometry of the impeller blade.
vtkStructuredGridGeometryFilter impSolid
        impSolid SetInputConnection [impReader GetOutputPort]
vtkPolyDataMapper impSolidMapper
        impSolidMapper SetInputConnection [impSolid GetOutputPort]
vtkActor impSolidActor
        impSolidActor SetMapper impSolidMapper
        [impSolidActor GetProperty] SetColor 0.8 0.8 0.8

# Create the solid geometry of the hub.
vtkStructuredGridGeometryFilter hubSolid
        hubSolid SetInputConnection [hubReader GetOutputPort]
vtkPolyDataMapper hubSolidMapper
        hubSolidMapper SetInputConnection [hubSolid GetOutputPort]
vtkActor hubSolidActor
        hubSolidActor SetMapper hubSolidMapper
        [hubSolidActor GetProperty] SetColor 0.8 0.8 0.8
        [hubSolidActor GetProperty] SetOpacity 0.1

# Create the solid geometry of the shroud.
vtkStructuredGridGeometryFilter shroudSolid
        shroudSolid SetInputConnection [shroudReader GetOutputPort]
vtkPolyDataMapper shroudSolidMapper
        shroudSolidMapper SetInputConnection [shroudSolid GetOutputPort]
vtkActor shroudSolidActor
        shroudSolidActor SetMapper shroudSolidMapper
        [shroudSolidActor GetProperty] SetColor 0.8 0.8 0.8
        [shroudSolidActor GetProperty] SetOpacity 0.1

# Add impeller objects to the rendering window.
#ren1 AddActor impOutlineActor
ren1 AddActor impSolidActor
#ren1 AddActor hubOutlineActor
ren1 AddActor hubSolidActor
#ren1 AddActor shroudOutlineActor
ren1 AddActor shroudSolidActor
ren1 ResetCamera

#Tell the window manager to completely close the program.
wm protocol .top WM_DELETE_WINDOW ::vtk::cb_exit

#Remove the VTK window upon startup.
wm withdraw .

__Scanned by MessageLabs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110311/d1c73ab2/attachment.htm>


More information about the vtkusers mailing list