Pb using vtkTkRenderWidget

Anabase at aol.com Anabase at aol.com
Fri Aug 13 12:11:15 EDT 1999


Hello VTK Users,

I'm a new by using vtk.

I would like to visualize data from a vtk file with the  DATASET 
UNSTRUCTURED_GRID into a vtkTkRenderWidget.

Unfortunately by running the following code I can't see no rendering in my 
application. If you have any suggestions ?

I'm using VTK 2.3 under W95 with Tcl/tk 8.0.5


Thank you all,

Philippe BOH
Anabase Developpement - anabase at aol.com
Cannes - France


Code starts here:




# loading vtktcl
catch {load vtktcl}


################################
# menubar definition && menu procs
################################

set visu(menu,project) {
    {New                   Ctrl+N       visu:new                   }
    {separator             {}           {}                         }
    {Open                  Ctrl+O       visu:open                  }
    {Save                  Ctrl+S       visu:save                  }
    {{Save As...}          {}           visu:save_as               }
    {Close                 Ctrl+W       visu:close                 }
    {separator             {}           {}                         }
    {Exit                  Ctrl+Q       ExitWMain                  }
}





proc visu:upper_first {string} {
    set s [string toupper [string range $string 0 0]]
    set l [string range $string 1 end]
    return "${s}${l}"
}



proc visu:menu:insert {menu name {root ""}} {
    global visu tcl_version
    if {$tcl_version >= 8} {
        set tab ""
    } else {
        set tab "\t"
    }
    if {$root != ""} {
        if {![winfo exists $root]} {
            menu $root
        }
        $root add cascade -label [visu:upper_first $name] -menu $menu
    }
    menu $menu -tearoff 0
    set visu(menu,$name,m) $menu
    foreach item $visu(menu,$name) {
        set txt [lindex $item 0]
        set acc [lindex $item 1]
        if {[llength $acc] > 1} {
            visu:menu:insert $menu.[lindex $acc 1] [lindex $acc 1] $menu
        } else {
            set cmd [lindex $item 2]
            if {$txt == "separator"} {
                $menu add separator
            } else {
                $menu add command -label $txt$tab -accel $acc -command $cmd
                set visu(menu,$name,widget) $menu
            }
        }
    }

}




###########################################################################
# Create top-level GUI
###########################################################################

set wMain .wMain
catch {destroy $wMain}
toplevel $wMain

wm withdraw .

wm title $wMain "Test vtkTkRenderWidget"

# menu bar
frame $wMain.menu -relief flat 
pack $wMain.menu -side top -expand 1 -fill x

$wMain conf -menu $wMain.m

# menu project 

foreach menu {project} {
    visu:menu:insert $wMain.m.$menu $menu $wMain.m
}

# Menu Help
$wMain.m add cascade -label Help -menu $wMain.m.help 
menu $wMain.m.help -tearoff 0
$wMain.m.help add command -label "Help" -command run_help


##############################################################################
##
# The rendering widget
##############################################################################
##

vtkRenderer Renderer
vtkTkRenderWidget $wMain.window -width 500 -height 500 

pack $wMain.window -side top -anchor nw -padx 3 -pady 3 -fill both -expand 1

set RenWin [$wMain.window GetRenderWindow]
$RenWin AddRenderer Renderer

# temp.vtk is a file which contains unstructuredGrid vtk data 
set filename "temp.vtk"

# try to read the file
vtkUnstructuredGridReader reader
  reader SetFileName $filename
  reader Update               

vtkDataSetMapper meshMapper
  meshMapper SetInput [reader GetOutput]
  meshMapper ScalarVisibilityOff

vtkActor meshActor
  meshActor SetMapper meshMapper

Renderer AddActor meshActor
$RenWin Render




###########################
# Procs
###########################


proc ExitWMain {} {

  exit

}




-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list