$Application ExitOnReturnOn

set pvWindow [$Application GetMainWindow]
set pv(vtkTemp43) [$pvWindow 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 kw(vtkTemp92) [$pv(vtkTemp43) GetRenderModuleUI]
            catch {$kw(vtkTemp92) SetCompositeThreshold 0}
        }
    }
} 

$pv(vtkTemp43) SetBackgroundColor 0 0 0

$pvWindow Open "$DataDir/Data/blow data.vtk"

set pvWarp [$pvWindow CreatePVSource WarpVector]
$pvWarp UpdateParameterWidgets
$pvWarp AcceptCallback

set warpOutput [$pvWarp GetPVOutput]
$warpOutput SetVisibility 0

set pvWindow [lindex [vtkPVWindow ListInstances] 0]
$pvWindow SetCurrentPVSourceCallback $pvWarp

set Ren1 [[[$Application GetMainWindow] GetMainView] GetRenderer]
set camera [$Ren1 GetActiveCamera]
$camera SetPosition 143.632 4.67034 -39.8384
$camera SetFocalPoint 2 12 4.1578e-15
$camera SetViewUp 0.270701 -0.00149368 0.962662
$camera SetViewAngle 30
$camera SetClippingRange 127.006 167.567

[$pvWarp GetPVWidget {Vectors}] SetValue displacement1
$pvWarp AcceptCallback

set RenWin1 [[[$Application GetMainWindow] GetMainView] GetRenderWindow]
$RenWin1 SetSize 300 300

for {set i 1} {$i <= 2} {incr i 1} {
	[$pvWarp GetPVWidget {Vectors}] SetValue displacement$i
        $pvWarp AcceptCallback
	#RenWin1 Render
	update

}

set warpOutput [$pvWarp GetPVOutput]

[$pvWarp GetPVWidget {Vectors}] SetValue displacement1
[$warpOutput GetColorMenu] SetValue "Point thickness1"
$warpOutput ColorByPointField thickness1 1
$pvWarp AcceptCallback

$warpOutput SetVisibility 1

for {set i 8} {$i <= 10} {incr i 1} {
    [$pvWarp GetPVWidget {Vectors}] SetValue displacement$i
    [$warpOutput GetColorMenu] SetValue "Point thickness$i"
    $warpOutput ColorByPointField thickness$i 1
    $pvWarp AcceptCallback
    #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
