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


# I ran into a bug where the input to the calculator could not be set,
# (this was the trace).  I am adding the test to make sure it does 
# not happen again.

$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(vtkTemp182) [$pv(vtkTemp1) CreatePVSource Calculator]
set pv(vtkTemp668) [$pv(vtkTemp182) GetPVWidget {Equation}]
$pv(vtkTemp668) AddScalarVariable Normals_0 Normals 0
$pv(vtkTemp668) AddScalarVariable Normals_1 Normals 1
$pv(vtkTemp668) AddScalarVariable Normals_2 Normals 2
$pv(vtkTemp668) SetFunctionLabel {Normals_0+Normals_1+Normals_2}
$pv(vtkTemp182) AcceptCallback

set pv(vtkTemp211) [$pv(vtkTemp1) CreatePVSource CylinderSource]
set pv(vtkTemp232) [$pv(vtkTemp211) GetPVWidget {Center}]
$pv(vtkTemp232) SetValue 1 0 0
set pv(vtkTemp233) [$pv(vtkTemp211) GetPVWidget {Resolution}]
$pv(vtkTemp233) SetValue 12
$pv(vtkTemp211) AcceptCallback
$pv(vtkTemp1) ResetCameraCallback

set pv(vtkTemp247) [$pv(vtkTemp1) CreatePVSource ShrinkFilter]
$pv(vtkTemp247) AcceptCallback

set pv(vtkTemp999) [$pv(vtkTemp1) CreatePVSource DataSetSurfaceFilter]
$pv(vtkTemp999) AcceptCallback

$pv(vtkTemp1) SetCurrentPVSource $pv(vtkTemp182)
$pv(vtkTemp1) ShowCurrentSourceProperties
set pv(vtkTemp190) [$pv(vtkTemp182) GetPVWidget {Input}]
[$pv(vtkTemp190) GetCurrentValue] SetVisibility 1
$pv(vtkTemp190) SetCurrentValue $pv(vtkTemp999)
$pv(vtkTemp182) AcceptCallback

# 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


