$Application ExitOnReturnOn

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

proc decipadString { str before total } {
    set x [string first "." $str]
    if { $x == -1 } { 
	set str "${str}.0"
    }

    set x [string first "." $str]
    while { $x >= 0 && $x < $before } {
	set str " $str"
	set x [string first "." $str]
    }

    if { [string length $str] >= $total } {
        return [string range $str 0 [expr $total - 1]]
    }

    while { [string length $str] < $total } {
        set str "${str}0"
    }
    return $str
}


set pvSphere [$pvWindow CreatePVSource SphereSource]
[$pvSphere GetPVWidget {Theta Resolution}] SetValue 16
$pvSphere AcceptCallback

set pvShrink [$pvWindow CreatePVSource ShrinkFilter]
[$pvShrink GetPVWidget {ShrinkFactor}] SetValue 0.9
$pvShrink 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 250 250
$RenWin1 Render
$Application Exit



