$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}
        }
    }
} 


$pv(vtkTemp43) SetBackgroundColor 0 0 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]
set pv(vtkTemp98) [$pv(vtkTemp1) CreatePVSource SphereSource]
$pv(vtkTemp98) AcceptCallback
set pv(vtkTemp118) [$pv(vtkTemp98) GetPVWidget {Theta Resolution}]
$pv(vtkTemp118) SetValue 16
set pv(vtkTemp127) [$pv(vtkTemp98) GetPVWidget {Phi Resolution}]
$pv(vtkTemp127) SetValue 16
$pv(vtkTemp98) AcceptCallback
set pv(vtkTemp180) [$pv(vtkTemp1) CreatePVSource ElevationFilter]
set pv(vtkTemp199) [$pv(vtkTemp180) GetPVWidget {Line}]
$pv(vtkTemp199) SetPoint1 0 0 0
$pv(vtkTemp199) SetPoint2 1 1 1
$pv(vtkTemp180) AcceptCallback
set pv(vtkTemp215) [$pv(vtkTemp1) CreatePVSource Threshold]
set pv(vtkTemp229) [$pv(vtkTemp215) GetPVWidget {MinMax}]
$pv(vtkTemp229) SetMinValue 0.069000
$pv(vtkTemp229) SetMaxValue 0.255880
$pv(vtkTemp215) AcceptCallback
$pv(vtkTemp229) SetMinValue 0.023000
$pv(vtkTemp229) SetMaxValue 0.255880
$pv(vtkTemp215) AcceptCallback
[$pv(vtkTemp215) GetPVOutput] DrawSurface

# 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
