$Application ExitOnReturnOn

set kw(vtkTemp1) [$Application GetMainWindow]
set kw(vtkTemp29) [$kw(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 [$kw(vtkTemp29) GetRenderModuleUI]
            catch {$rmui SetCompositeThreshold 0}
        }
    }
} 

# Test the option of cliping with scalars and a sphere.
    
$kw(vtkTemp29) SetBackgroundColor 0 0 0
set kw(vtkTemp224) [$kw(vtkTemp1) CreatePVSource RTAnalyticSource]
$kw(vtkTemp224) AcceptCallback
set kw(vtkTemp288) [$kw(vtkTemp1) CreatePVSource Clip]
set kw(vtkTemp303) [$kw(vtkTemp288) GetPVWidget {Clip Function}]
$kw(vtkTemp303) SetCurrentValue {Scalars}
set kw(vtkTemp999) [$kw(vtkTemp303) GetPVWidget {Scalars}]
set kw(vtkTemp313) [$kw(vtkTemp999) GetPVWidget {Scalars}]
$kw(vtkTemp313) SetValue {RTData}
set kw(vtkTemp314) [$kw(vtkTemp999) GetPVWidget {Offset}]
$kw(vtkTemp314) SetValue 200
$kw(vtkTemp288) AcceptCallback
[$kw(vtkTemp1) GetMainView] SetCameraState -33.506 28.392 54.140  0.000 0.000 0.000  0.071 0.901 -0.428
set kw(vtkTemp337) [$kw(vtkTemp1) CreatePVSource Clip]
set kw(vtkTemp351) [$kw(vtkTemp337) GetPVWidget {Clip Function}]
$kw(vtkTemp351) SetCurrentValue {Sphere}
set kw(vtkTemp358) [$kw(vtkTemp351) GetPVWidget {Sphere}]
$kw(vtkTemp358) SetCenter 10 0 0
$kw(vtkTemp337) AcceptCallback
$kw(vtkTemp358) SetRadius 10
$kw(vtkTemp337) AcceptCallback
set kw(vtkTemp389) [$kw(vtkTemp1) CreatePVSource DataSetSurfaceFilter]
$kw(vtkTemp389) AcceptCallback
[$kw(vtkTemp1) GetMainView] SetCameraState 53.415 25.363 36.925  0.000 0.000 0.000  -0.077 0.871 -0.486
[$kw(vtkTemp1) GetMainView] SetCameraState 32.613 15.486 22.545  -20.802 -9.878 -14.380  -0.077 0.871 -0.486

# 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



