$Application ExitOnReturnOn

set pv(vtkTemp1) [$Application GetMainWindow]
set pv(vtkTemp43) [$pv(vtkTemp1) GetMainView]

if {[info exists argc]} { 
    set argcm1 [expr $argc - 1]
    for {set i 0} {$i < $argcm1} {incr i} {
        if {[lindex $argv $i] == "-D" && $i < $argcm1} {
		set DataDir [lindex $argv [expr $i + 1]]
        }
        if {[lindex $argv $i] == "-UC" && $i < $argcm1} {
            set rmui [$pv(vtkTemp43) GetRenderModuleUI]
            catch {$rmui SetCompositeThreshold 0}
        }
    }
} 


set pv(vtkTemp89) [$pv(vtkTemp1) GetPVSource GlyphSources Arrow0]
set pv(vtkTemp93) [$pv(vtkTemp1) GetPVSource GlyphSources Cone0]
set pv(vtkTemp97) [$pv(vtkTemp1) GetPVSource GlyphSources Sphere0]

[ $pv(vtkTemp43) GetHeaderEntry ] SetValue "ProbePoint"
[ $pv(vtkTemp43) GetHeaderButton ] SetState 1
[ $pv(vtkTemp43) GetCornerAnnotation ] SetCornerText "0" 0
[ $pv(vtkTemp43) GetCornerAnnotation ] SetCornerText "1" 1
[ $pv(vtkTemp43) GetCornerAnnotation ] SetCornerText "2" 2
[ $pv(vtkTemp43) GetCornerAnnotation ] SetCornerText "3" 3
[ $pv(vtkTemp43) GetCornerAnnotation ] SetVisibility 1
$pv(vtkTemp43) SetHeaderTextColor 1 .5 .8
$pv(vtkTemp43) SetHeaderTextColor 1 1 1
$pv(vtkTemp43) SetHeaderTextColor 1 1 1
$pv(vtkTemp43) GetHeaderTextColor
$pv(vtkTemp43) HeaderChanged
$pv(vtkTemp43) OnDisplayHeader

$pv(vtkTemp1) Open "$DataDir/Data/vox8_bin.vtk"
set pv(vtkTemp100) [$pv(vtkTemp1) GetCurrentPVSource]
set pv(vtkTemp101) [$pv(vtkTemp100) GetPVOutput]
$pv(vtkTemp101) DrawWireframe
$pv(vtkTemp101) ColorByProperty
set pv(vtkTemp138) [$pv(vtkTemp1) CreatePVSource Probe]
set pv(vtkTemp341) [$pv(vtkTemp138) GetPVWidget {Probe object}]
$pv(vtkTemp341) SetCurrentValue {Point}
set pv(vtkTemp280) [$pv(vtkTemp341) GetPVWidget {Point}]
[ $pv(vtkTemp280) GetPointWidget ] SetPosition 1.0 1.0 1.0
[ $pv(vtkTemp280) GetRadiusWidget ] SetValue 0
[ $pv(vtkTemp280) GetNumberOfPointsWidget ] SetValue 1
$pv(vtkTemp138) AcceptCallback
set pv(vtkTemp179) [$pv(vtkTemp1) CreatePVSource Glyph]
set pv(vtkTemp187) [$pv(vtkTemp179) GetPVWidget {Input}]
$pv(vtkTemp187) SetCurrentValue $pv(vtkTemp138)
set pv(vtkTemp188) [$pv(vtkTemp179) GetPVWidget {Glyph}]
$pv(vtkTemp188) SetCurrentValue $pv(vtkTemp97)
set pv(vtkTemp201) [$pv(vtkTemp179) GetPVWidget {OrientScale}]
$pv(vtkTemp201) SetScaleMode "Scalar"
$pv(vtkTemp201) SetScaleFactor .5
$pv(vtkTemp179) AcceptCallback
set pv(vtkTemp180) [$pv(vtkTemp179) GetPVOutput]
$pv(vtkTemp180) ColorByPointField "scalars" 1

foreach a {bmp tif ppm png  jpg} {
    $pv(vtkTemp43) SaveAsImage vtkParaViewWriteTest.$a
    file delete -force vtkParaViewWriteTest.$a
}

# Retrace
update
$Application StopRecordingScript
[ $Application GetMainWindow ] DeleteAllSources
# Source the trace to regenerate the sources.
if {[catch {set channel [open test.tmp w]}] == 0 } {
   close $channel
   file delete -force test.tmp
   source "[$Application GetTraceFileName]"
}

# Fix the size of the image.
set RenWin1 [[[$Application GetMainWindow] GetMainView] GetRenderWindow]
$RenWin1 SetSize 300 300
$RenWin1 Render
update

for {set i  1} {$i < [expr $argc - 1]} {incr i} {
    if {[lindex $argv $i] == "-C"} {
	source [lindex $argv [expr $i + 1]]
	$Application SetExitStatus [CompareImage [[$Application GetMainWindow] GetMainView]]
    }
}

$Application Exit
