$Application ExitOnReturnOn

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

$kw(vtkTemp1) Open "$DataDir/Data/iron protein.vtk"
set kw(vtkTemp285) [$kw(vtkTemp1) GetCurrentPVSource]

set kw(vtkTemp318) [$kw(vtkTemp1) CreatePVSource ImageClip]
set kw(vtkTemp330) [$kw(vtkTemp318) GetPVWidget {OutputWholeExtent}]
$kw(vtkTemp330) SetValue 10 20 10 20 10 20
$kw(vtkTemp318) AcceptCallback
$kw(vtkTemp21) SetCameraState 5.750 74.300 261.766  33.500 33.500 33.500  0.497 0.863 -0.094
$kw(vtkTemp1) ResetCameraCallback
$kw(vtkTemp21) SetCameraState 0.249 39.452 34.987  15.000 15.000 15.000  0.580 0.696 -0.423
set kw(vtkTemp349) [$kw(vtkTemp1) CreatePVSource Contour]
set kw(vtkTemp355) [$kw(vtkTemp349) GetPVWidget {Scalars}]
$kw(vtkTemp355) SetValue {scalars}
set kw(vtkTemp358) [$kw(vtkTemp349) GetPVWidget {Contour Values}]
$kw(vtkTemp358) RemoveAllValues
$kw(vtkTemp358) AddValue 1.000000
$kw(vtkTemp358) AddValue 10.000000
set kw(vtkTemp1029) [$kw(vtkTemp349) GetPVWidget {Compute Scalars}]
$kw(vtkTemp1029) SetState 1
set kw(vtkTemp1169) [$kw(vtkTemp349) GetPVWidget {Compute Normals}]
$kw(vtkTemp1169) SetState 0
$kw(vtkTemp349) AcceptCallback
$kw(vtkTemp21) SetCameraState -15.223 0.904 4.858  15.000 15.000 15.000  -0.409 0.911 -0.046
$kw(vtkTemp21) SetCameraState 6.136 -18.690 13.825  15.000 15.000 15.000  -0.213 0.090 -0.973
$kw(vtkTemp21) SetCameraState -1.614 -13.040 2.643  15.000 15.000 15.000  0.231 0.274 -0.933
$kw(vtkTemp358) RemoveAllValues
$kw(vtkTemp358) AddValue 1.000000
$kw(vtkTemp358) AddValue 10.000000
$kw(vtkTemp358) AddValue 25.000000
$kw(vtkTemp349) AcceptCallback
$kw(vtkTemp21) SetCameraState 24.265 -6.315 -10.977  15.000 15.000 15.000  0.363 0.780 -0.510
$kw(vtkTemp358) RemoveAllValues
$kw(vtkTemp358) AddValue 1.000000
$kw(vtkTemp358) AddValue 10.000000
$kw(vtkTemp358) AddValue 20.000000
$kw(vtkTemp349) AcceptCallback
$kw(vtkTemp21) SetCameraState 30.660 -1.254 -11.562  15.000 15.000 15.000  0.331 0.879 -0.343
$kw(vtkTemp358) RemoveAllValues
$kw(vtkTemp358) AddValue 1.000000
$kw(vtkTemp358) AddValue 10.000000
$kw(vtkTemp358) AddValue 20.000000
$kw(vtkTemp358) AddValue 0.500000
$kw(vtkTemp349) AcceptCallback
$kw(vtkTemp21) SetCameraState 21.508 20.843 48.741  15.000 15.000 15.000  0.399 0.888 -0.231
$kw(vtkTemp21) SetCameraState 25.643 11.695 48.027  15.000 15.000 15.000  0.454 0.889 -0.057
set kw(vtkTemp400) [$kw(vtkTemp1) CreatePVSource Glyph]
set kw(vtkTemp142) [$kw(vtkTemp1) GetPVSource GlyphSources Arrow0]
set kw(vtkTemp427) [$kw(vtkTemp400) GetPVWidget {Glyph}]
$kw(vtkTemp427) SetCurrentValue $kw(vtkTemp142)
$kw(vtkTemp400) AcceptCallback
$kw(vtkTemp21) SetCameraState 39.338 4.455 37.614  15.000 15.000 15.000  -0.619 0.201 0.760
$kw(vtkTemp427) SetCurrentValue $kw(vtkTemp142)
$kw(vtkTemp21) SetCameraState -19.041 13.331 7.694  15.000 15.000 15.000  0.066 0.862 -0.503
$kw(vtkTemp1) SetCurrentPVSourceCallback $kw(vtkTemp349)
$kw(vtkTemp21) SetCameraState 44.193 3.649 -0.294  15.000 15.000 15.000  0.143 0.906 -0.399
$kw(vtkTemp21) SetCameraState 49.583 19.329 15.491  15.000 15.000 15.000  -0.125 0.985 0.117
$kw(vtkTemp1) SetCurrentPVSourceCallback $kw(vtkTemp400)
$kw(vtkTemp1) SetCurrentPVSourceCallback $kw(vtkTemp349)
set kw(vtkTemp366) [$kw(vtkTemp349) GetPVWidget {Compute Gradients}]
$kw(vtkTemp366) SetState 1
$kw(vtkTemp349) AcceptCallback
[$kw(vtkTemp349) GetPVOutput] SetColorRange 0 255
$kw(vtkTemp21) SetCameraState -4.208 17.411 -13.986  15.000 15.000 15.000  0.631 0.687 -0.361
$kw(vtkTemp21) SetCameraState 4.397 21.006 -17.657  15.000 15.000 15.000  0.743 0.658 -0.120
$kw(vtkTemp1) SetCurrentPVSourceCallback $kw(vtkTemp400)
set kw(vtkTemp411) [$kw(vtkTemp400) GetPVWidget {OrientScale}]
$kw(vtkTemp411) SetScaleMode "Vector Magnitude"
$kw(vtkTemp400) AcceptCallback
$kw(vtkTemp21) SetCameraState 33.941 -12.690 24.459  15.000 15.000 15.000  0.777 0.598 0.197
$kw(vtkTemp411) SetScaleMode "Scalar"
$kw(vtkTemp400) AcceptCallback
$kw(vtkTemp411) SetScaleMode "Data Scaling Off"
$kw(vtkTemp411) SetScaleFactor 1
$kw(vtkTemp400) AcceptCallback
$kw(vtkTemp21) SetCameraState -6.310 29.823 38.262  15.000 15.000 15.000  0.267 0.905 -0.332
$kw(vtkTemp21) SetCameraState 4.621 22.219 26.330  25.931 7.397 3.067  0.267 0.905 -0.332
$kw(vtkTemp21) SetCameraState 4.645 8.097 26.547  25.905 22.270 2.839  -0.295 0.913 0.282
# 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]]
    }
}

