$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

# Delete before accept.
set pv(vtkTemp181) [$pv(vtkTemp1) CreatePVSource LoopSubdivisionFilter]
$pv(vtkTemp181) DeleteCallback

# Delete after accept
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp98)
$pv(vtkTemp1) ShowCurrentSourceProperties
set pv(vtkTemp110) [$pv(vtkTemp98) GetPVWidget {Center}]
$pv(vtkTemp110) SetValue 0.5 0 0
set pv(vtkTemp115) [$pv(vtkTemp98) GetPVWidget {Radius}]
$pv(vtkTemp115) SetValue 0.6
$pv(vtkTemp98) AcceptCallback

set pv(vtkTemp197) [$pv(vtkTemp1) CreatePVSource ShrinkFilter]
set pv(vtkTemp206) [$pv(vtkTemp197) GetPVWidget {Input}]
$pv(vtkTemp206) SetCurrentValue $pv(vtkTemp98)
set pv(vtkTemp211) [$pv(vtkTemp197) GetPVWidget {ShrinkFactor}]
$pv(vtkTemp211) SetValue 0.8
$pv(vtkTemp197) AcceptCallback
$pv(vtkTemp197) DeleteCallback
$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp98)
$pv(vtkTemp1) ShowCurrentSourceProperties

# Add a filter that we do not delete.
set pv(vtkTemp220) [$pv(vtkTemp1) CreatePVSource ElevationFilter]
set pv(vtkTemp999) [$pv(vtkTemp220) GetPVWidget {Line}]
$pv(vtkTemp999) SetPoint1 0 0 0
$pv(vtkTemp999) SetPoint2 0 0 1
set pv(vtkTemp229) [$pv(vtkTemp220) GetPVWidget {Input}]
$pv(vtkTemp229) SetCurrentValue $pv(vtkTemp98)
$pv(vtkTemp220) AcceptCallback

# 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
