generated by zdoc.tcl on Thu Feb 14 16:15:15 MET 2002

tclGraphics3D.tcl



graphics3D
Comments  
Arguments  
Used by  
Uses  

}


graphics3D::TextureScaleDialog
Comments  
Arguments rect
color
Used by  
Uses  
proc graphics3D::TextureScaleDialog  { rect color  } {
    set root .textScale
    if ![winfo exists $root] {
    toplevel $root  -bg $color
    frame $root.f -bg $color
    label $root.f.l -text "Texture Scale" -bg $color
    scale $root.f.s -from 0.1 -to 5.0 -resolution 0.1 -orient horizontal -bg $color -fg black
    scan [ eval "$rect -textureScale" ] "%f %f" s t
    $root.f.s set $s
    scale $root.f.t -from 0.1 -to 5.0 -resolution 0.1 -orient horizontal -bg $color -fg black
    $root.f.t set $t
    pack $root.f.l $root.f.s  $root.f.t -side left
    frame $root.buttons -bg $color
    button $root.buttons.apply -text Apply -command "evaluate \"$rect -textureScale \[$root.f.s get \] \[$root.f.t get \]\"" -bg $color
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $color
    pack $root.buttons.apply $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.f $root.buttons -expand true -fill both
    }
}


graphics3D::changeFOV
Comments  
Arguments cam
color
Used by  
Uses  
proc graphics3D::changeFOV  { cam color  } {
    set root .fovCam3D
    if ![winfo exists $root] {
    toplevel $root  -bg $color
    frame $root.f -bg $color
    label $root.f.l -text "Field Of View (in Degrees)" -bg $color
    scale $root.f.s -from 5.0 -to 130.0 -resolution 0.5 -orient horizontal -bg $color -fg black
    $root.f.s set [ $cam -fieldOfView]
    pack $root.f.l $root.f.s -side left
    frame $root.buttons -bg $color
    button $root.buttons.apply -text Apply -command "evaluate \"$cam -fieldOfView \[$root.f.s get \]\"" -bg $color
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $color
    pack $root.buttons.apply $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.f $root.buttons -expand true -fill both
    }
}


graphics3D::changeMaxFrameRate
Comments  
Arguments cam
color
Used by  
Uses  
proc graphics3D::changeMaxFrameRate { cam color  } {
    set root .maxFrameRate3D
    if ![winfo exists $root] {
    toplevel $root  -bg $color
    frame $root.f -bg $color
    label $root.f.l -text "Maximum Frame Rate (in Hz)" -bg $color
    scale $root.f.s -from 5.0 -to 80.0 -resolution 0.5 -orient horizontal -bg $color -fg black
    $root.f.s set [ [ $cam -scene ] -maxFrameRate ]
    pack $root.f.l $root.f.s -side left
    frame $root.buttons -bg $color
    button $root.buttons.apply -text Apply -command "evaluate \"[ $cam -scene ] -maxFrameRate \[$root.f.s get \]\"" -bg $color
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $color
    pack $root.buttons.apply $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.f $root.buttons -expand true -fill both
    }
}


graphics3D::create1DTextureDialog
Comments  
Arguments color
Used by  
Uses  
proc graphics3D::create1DTextureDialog  { color  } {
set root .create1DTexture
    if ![winfo exists $root] {
    toplevel $root  -bg $color
    frame $root.f1 -bg $color
    label $root.f1.l -text "Texture Size" -bg $color
    scale $root.f1.s -from 1 -to 512 -resolution 1 -orient horizontal -bg $color -fg black
    pack $root.f1.l $root.f1.s -side left
    $root.f1.s set 256
    
    frame $root.f2 -bg $color
    foreach i {temperature activation} {
        radiobutton $root.f2.$i -text "Texture $i" -value $i -relief flat -variable text -bg $color
        pack  $root.f2.$i -side top -pady 2 -anchor w
    }
    set text temperature

    frame $root.buttons -bg $color
    button $root.buttons.apply -text Apply -command "evaluate \"new text1D \$text  \[$root.f1.s get \] \";destroy $root" -bg $color
    button $root.buttons.destroy -text "Destroy" -command "destroy $root" -bg $color
    pack $root.buttons.apply $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.f1  $root.f2      $root.buttons -expand true -fill both
    }
}


graphics3D::installRectangle3DMenu
Comments  
Arguments parent
camera
object
color
Used by  
Uses graphics3D::materialoptions
modules::selectColorStr
graphics3D::renderoptions
graphics3D::textureoptions
proc graphics3D::installRectangle3DMenu {parent camera object color } {
    global selectedTexture
    menubutton $parent.context.graphics -text "Display" -menu $parent.context.graphics.mn -bg $color
    set menu [menu $parent.context.graphics.mn -bg $color -postcommand "set graphics3D::v$object \[$object -render\]"]
    graphics3D::renderoptions $menu $object
    $menu add separator
    $menu add command -label "Flip Normals" -command "evaluate \"$object -flipNormals\""
    $menu add command -label "Line color..." -command "evaluate \"$object -color \[ modules::selectColorStr  \[ $object -color\] \]\""
    $menu add cascade -label "Material Definition" -menu $menu.material
    menu $menu.material -bg $color -tearoff 0
    $menu.material add command -label "Material..." -command "graphics3D::material $object $color"
    $menu.material add command -label "Selected Material..." -command "graphics3D::materialBasic $object $color \"-selectedMaterial\""
    graphics3D::materialoptions $menu.material $object    
    graphics3D::textureoptions $menu $object $color
    $menu add command -label "Texture Scale..." -command "graphics3D::TextureScaleDialog $object $color"
    pack $parent.context.graphics -side left    
}


graphics3D::installSelectedObjectMenu
Comments  
Arguments viewer
camera
object
Used by  
Uses  
proc graphics3D::installSelectedObjectMenu { viewer camera object } {
    set bg #90C090
    menubutton $viewer.context.default -text "Default $object menu" -menu $viewer.context.default.m -anchor w -bg $bg
    set mfile [menu $viewer.context.default.m -bg $bg]
    $mfile add command -label "Default entry"

    pack $viewer.context.default -side left
}


graphics3D::installSphereMenu
Comments  
Arguments parent
camera
object
color
Used by  
Uses graphics3D::textureoptions
modules::selectColorStr
graphics3D::rendermenu
proc graphics3D::installSphereMenu { parent camera object color } {
    menubutton $parent.context.object -text "Object" -menu $parent.context.object.mn -bg $color
    set menu [menu $parent.context.object.mn -bg $color]
    $menu add command -label destroy -command "evaluate \"$object -destroy\""

    menubutton $parent.context.render -text "Render" -menu $parent.context.render.mn -bg $color
    graphics3D::rendermenu $parent.context.render $color $object
    $menu add separator
    graphics3D::textureoptions $menu $object $color

    menubutton $parent.context.material -text "Material" -menu $parent.context.material.mn -bg $color
    set menu [menu $parent.context.material.mn -bg $color]
    $menu add command -label "color..." -command "evaluate \"$object -color \[ modules::selectColorStr  \[ $object -color\] \]\""
    $menu add command -label "material..." -command "graphics3D::material $object $color"

    pack $parent.context.object $parent.context.render $parent.context.material -side left
}


graphics3D::iterationParameters
Comments  
Arguments scene
bg
scolor
Used by  
Uses  
proc graphics3D::iterationParameters { scene bg scolor } {
    global sliceGeom
    set root .iterationParameters
    if {![winfo exists $root]} {
    toplevel $root -bg $bg
    wm title $root "Iteration Parameters"
    
    frame $root.f -bg $bg
    
    frame $root.f.step -bd 2 -bg $bg
    entry $root.f.step.entry -relief sunken -width 10 -bg $bg
    $root.f.step.entry delete 0 10
    $root.f.step.entry insert 0 [$scene -iteration step]
    label $root.f.step.label -text "Number of calls per Step" -bg $bg
    pack $root.f.step.entry -side right -padx 20
    pack $root.f.step.label -side left -padx 20
    
    frame $root.f.call -bd 2 -bg $bg
    entry $root.f.call.entry -relief sunken -width 10 -bg $bg
    $root.f.call.entry delete 0 10
    $root.f.call.entry insert 0 [$scene -iteration call]
    label $root.f.call.label -text "Number of Iterations per Call" -bg $bg
    pack $root.f.call.entry -side right -padx 20
    pack $root.f.call.label -side left -padx 20
    
    pack  $root.f.call  $root.f.step -side top -fill x
    pack $root.f -expand true -fill both
    
    frame $root.buttons -bg $scolor
    button $root.buttons.applyDismiss -text "Apply & Dismiss" -command "evaluate \"$scene -iteration step \[$root.f.step.entry get\]\";evaluate \"$scene -iteration call \[$root.f.call.entry get\]\";destroy $root" -bg $scolor
    button $root.buttons.destroy -text "Dismiss" -command "destroy $root" -bg $bg
    pack $root.buttons.applyDismiss  $root.buttons.destroy -side left -expand true -fill both -padx 20 -pady 10
    pack $root.buttons -expand true -fill both
    }
}


graphics3D::lightRgbScales
Comments  
Arguments frame
light
name
color
rv
gv
bv
Used by  
Uses  
proc graphics3D::lightRgbScales { frame light name color rv gv bv} {
    label $frame.l -relief raised -text $name -bg $color

    scale $frame.r -from 0 -to 1 -resolution 0.01 -orient horizontal -bg red -fg yellow -command "$light -params $name \[$frame.r get\] \[$frame.g get\] \[$frame.b get\]"
    bind $frame.r <Enter> "focus $frame.r"
    $frame.r set $rv
    scale $frame.g -from 0 -to 1 -resolution 0.01 -orient horizontal -bg green -fg black -command "$light -params $name \[$frame.r get\] \[$frame.g get\] \[$frame.b get\]"
    bind $frame.g <Enter> "focus $frame.g"
    $frame.g set $gv
    scale $frame.b -from 0 -to 1 -resolution 0.01 -orient horizontal -bg blue -fg white -command "$light -params $name \[$frame.r get\] \[$frame.g get\] \[$frame.b get\]"
    bind $frame.b <Enter> "focus $frame.b"
    $frame.b set $bv

    pack $frame.l $frame.r $frame.g $frame.b -fill x -expand true
}


graphics3D::material
Comments  
Arguments object
color
Used by  
Uses  
proc graphics3D::material { object color } {
    set name ""
    foreach i [split $object] { set name $name$i }
    variable emission
    variable scn
    variable cam
    variable sph
    variable alpha
    set w .material$name

    if ![winfo exists $w] {
    toplevel $w -bg $color
    wm title $w "$object material"

    frame $w.f -bg $color
    frame $w.f.f -bg $color
    frame $w.f.f.fa -bg $color
    frame $w.f.f.fd -bg $color
    frame $w.f.f.fs -bg $color
    frame $w.f.f.fe -bg $color
    frame $w.f.fsh -bg $color

    scan [eval "$object -material"] "ambient %f %f %f %f diffuse %f %f %f %f specular %f %f %f %f shininess %f emission %s %f %f %f %f" ar ag ab aa dr dg db graphics3D::alpha sr sg sb sa sh graphics3D::emission er eg eb ea
    scale $w.f.fsh.s -from 0 -to 128 -resolution 0.1 -orient horizontal -bg $color -label shininess
    bind $w.f.fsh.s <Enter> "focus $w.f.fsh.s"
    $w.f.fsh.s set $sh
    frame $w.tst -bg $color
    pack $w.tst -fill both -expand true
    set graphics3D::scn [new scn3D]
    set graphics3D::cam [new cam3D -scene $graphics3D::scn -in $w.tst]
    set graphics3D::sph [new sphere -scene $graphics3D::scn]

    $graphics3D::sph -render solid

    rgbScales $w.f.f.fa $graphics3D::sph ambient $color none $ar $ag $ab graphics3D::alpha
    rgbScales $w.f.f.fd $graphics3D::sph diffuse $color none $dr $dg $db graphics3D::alpha
    rgbScales $w.f.f.fs $graphics3D::sph specular $color none $sr $sg $sb graphics3D::alpha
    rgbScales $w.f.f.fe $graphics3D::sph emission $color graphics3D::emission $er $eg $eb graphics3D::alpha
    $w.f.fsh.s configure -command "$graphics3D::sph -material shininess \[$w.f.fsh.s get\]"
    
    if ![string compare [eval "$object -render"] transparency] {
        set transparency true
        $graphics3D::sph -render transparency
    } else {
        set transparency false
    }
    checkbutton $w.f.fsh.tr -text "transparency"  -onvalue true -offvalue false -variable transparency -bg $color -command "if !\[string compare \$transparency true\] { $w.f.fsh.alpha configure -state normal; $graphics3D::sph -render transparency } else { $w.f.fsh.alpha configure -state disabled; $graphics3D::sph -render solid }"
    scale $w.f.fsh.alpha -from 0 -to 1 -resolution 0.01 -orient horizontal -bg $color -command "$graphics3D::sph -material ambient \[$w.f.f.fa.r get\] \[$w.f.f.fa.g get\] \[$w.f.f.fa.b get\] \[$w.f.fsh.alpha get\] diffuse \[$w.f.f.fd.r get\] \[$w.f.f.fd.g get\] \[$w.f.f.fd.b get\] \[$w.f.fsh.alpha get\] specular \[$w.f.f.fs.r get\] \[$w.f.f.fs.g get\] \[$w.f.f.fs.b get\] \[$w.f.fsh.alpha get\] emission \$graphics3D::emission \[$w.f.f.fe.r get\] \[$w.f.f.fe.g get\] \[$w.f.f.fe.b get\] \[$w.f.fsh.alpha get\]"
    bind $w.f.fsh.alpha <Enter> "focus $w.f.fsh.alpha"
    $w.f.fsh.alpha set $graphics3D::alpha
    pack $w.f.fsh.s $w.f.fsh.tr $w.f.fsh.alpha -fill x -expand true

    pack $w.f.f.fa $w.f.f.fd $w.f.f.fs $w.f.f.fe -side left -fill both -padx 5 -pady 5 -expand true
    pack $w.f.f $w.f.fsh -fill both -expand true
    
    frame $w.b -bg $color
    button $w.b.ok -text "Apply" -command "if !\[string compare \$transparency true\]  { eval \"$object -render transparency\"; set alpha \[$w.f.fsh.alpha get\] } else { set alpha 1.0; if !\[string compare \[eval \"$object -render\"\] transparency\] {eval \"$object -render solid\"} }; evaluate \"$object -material ambient \[$w.f.f.fa.r get\] \[$w.f.f.fa.g get\] \[$w.f.f.fa.b get\] \$alpha diffuse \[$w.f.f.fd.r get\] \[$w.f.f.fd.g get\] \[$w.f.f.fd.b get\] \$alpha specular \[$w.f.f.fs.r get\] \[$w.f.f.fs.g get\] \[$w.f.f.fs.b get\] \$alpha shininess \[$w.f.fsh.s get\] emission \$graphics3D::emission \[$w.f.f.fe.r get\] \[$w.f.f.fe.g get\] \[$w.f.f.fe.b get\] \$alpha\"" -bg $color
    button $w.b.cancel -text "Dismiss" -command "\$graphics3D::cam -destroy; \$graphics3D::scn -destroy; destroy $w" -bg $color
    pack $w.b.ok $w.b.cancel -padx 10 -pady 5 -side left -fill x -expand true

    pack $w.f $w.tst -fill both -expand true
    pack $w.b -fill x -expand true
    }
}


graphics3D::materialBasic
Comments  
Arguments object
color
option
Used by  
Uses  
proc graphics3D::materialBasic { object color {option "-material"}} {
    set name ""
    foreach i [split $object] { set name $name$i }
    variable emission
    variable scn
    variable cam
    variable sph
    variable alpha
    set w .material$name

    if ![winfo exists $w] {
    toplevel $w -bg $color
    wm title $w "$object material"

    frame $w.f -bg $color
    frame $w.f.f -bg $color
    frame $w.f.f.fa -bg $color
    frame $w.f.f.fd -bg $color
    frame $w.f.f.fs -bg $color
    frame $w.f.f.fe -bg $color
    frame $w.f.fsh -bg $color

    scan [eval "$object $option"] "ambient %f %f %f %f diffuse %f %f %f %f specular %f %f %f %f shininess %f emission %s %f %f %f %f" ar ag ab aa dr dg db graphics3D::alpha sr sg sb sa sh graphics3D::emission er eg eb ea

    scale $w.f.fsh.s -from 0 -to 128 -resolution 0.1 -orient horizontal -bg $color -label shininess
    bind $w.f.fsh.s <Enter> "focus $w.f.fsh.s"
    $w.f.fsh.s set $sh

    frame $w.tst -bg $color
    set graphics3D::scn [new scn3D]
    set graphics3D::cam [new cam3D -scene $graphics3D::scn -in $w.tst]
    set graphics3D::sph [new sphere -scene $graphics3D::scn]
    $graphics3D::sph -render solid

    rgbScales $w.f.f.fa $graphics3D::sph ambient $color none $ar $ag $ab graphics3D::alpha
    rgbScales $w.f.f.fd $graphics3D::sph diffuse $color none $dr $dg $db graphics3D::alpha
    rgbScales $w.f.f.fs $graphics3D::sph specular $color none $sr $sg $sb graphics3D::alpha
    rgbScales $w.f.f.fe $graphics3D::sph emission $color graphics3D::emission $er $eg $eb graphics3D::alpha
    $w.f.fsh.s configure -command "$graphics3D::sph -material shininess \[$w.f.fsh.s get\]"
    
    set transparency false
    set alpha 1.0

    checkbutton $w.f.fsh.tr -text "transparency"  -onvalue true -offvalue false -variable transparency -bg $color -command "if !\[string compare \$transparency true\] { $w.f.fsh.alpha configure -state normal; $graphics3D::sph -render transparency } else { $w.f.fsh.alpha configure -state disabled; $graphics3D::sph -render solid }"
    scale $w.f.fsh.alpha -from 0 -to 1 -resolution 0.01 -orient horizontal -bg $color -command "$graphics3D::sph -material ambient \[$w.f.f.fa.r get\] \[$w.f.f.fa.g get\] \[$w.f.f.fa.b get\] \[$w.f.fsh.alpha get\] diffuse \[$w.f.f.fd.r get\] \[$w.f.f.fd.g get\] \[$w.f.f.fd.b get\] \[$w.f.fsh.alpha get\] specular \[$w.f.f.fs.r get\] \[$w.f.f.fs.g get\] \[$w.f.f.fs.b get\] \[$w.f.fsh.alpha get\] emission \$graphics3D::emission \[$w.f.f.fe.r get\] \[$w.f.f.fe.g get\] \[$w.f.f.fe.b get\] \[$w.f.fsh.alpha get\]"
    bind $w.f.fsh.alpha <Enter> "focus $w.f.fsh.alpha"
    $w.f.fsh.alpha set $graphics3D::alpha
    pack $w.f.fsh.s $w.f.fsh.tr $w.f.fsh.alpha -fill x -expand true

    pack $w.f.f.fa $w.f.f.fd $w.f.f.fs $w.f.f.fe -side left -fill both -padx 5 -pady 5 -expand true
    pack $w.f.f $w.f.fsh -fill both -expand true
    
    frame $w.b -bg $color
    button $w.b.ok -text "Apply" -command "set alpha 1.0;evaluate \"$object $option ambient \[$w.f.f.fa.r get\] \[$w.f.f.fa.g get\] \[$w.f.f.fa.b get\] \$alpha diffuse \[$w.f.f.fd.r get\] \[$w.f.f.fd.g get\] \[$w.f.f.fd.b get\] \$alpha specular \[$w.f.f.fs.r get\] \[$w.f.f.fs.g get\] \[$w.f.f.fs.b get\] \$alpha shininess \[$w.f.fsh.s get\] emission \$graphics3D::emission \[$w.f.f.fe.r get\] \[$w.f.f.fe.g get\] \[$w.f.f.fe.b get\] \$alpha\"" -bg $color
    button $w.b.cancel -text "Dismiss" -command "\$graphics3D::cam -destroy; \$graphics3D::scn -destroy; destroy $w" -bg $color
    pack $w.b.ok $w.b.cancel -padx 10 -pady 5 -side left -fill x -expand true

    pack $w.f $w.tst -fill both -expand true
    pack $w.b -fill x -expand true
    }
}


graphics3D::materialoptions
Comments  
Arguments menu
object
Used by SM2::selectZone
graphics3D::installRectangle3DMenu
tetrahedrisation::installTetra3DDisplayMenu
tetrahedrisation::installSurfaceZone3DMenu
triangulation::installMainTriangulation3DMenu
triangulation::installZone3DMenu
SM2::installSM2
Uses  
proc graphics3D::materialoptions { menu object } {
    global graphics3D::v$object
    set name ""
    foreach i [split $object] { set name $name$i }

    $menu add command -label red -command "evaluate \"$object -material ambient 0.8 0.5 0.5 diffuse 1.0 0.2 0.2 specular 1.0 0.2 0.3 shininess 30\"" -background red -foreground white
    $menu add command -label green -command "evaluate \"$object -material ambient 0.5 0.8 0.5 diffuse 0.2 1.0 0.2 specular 0.3 0.9 0.3 shininess 30\"" -background green -foreground black
    $menu add command -label blue -command "evaluate \"$object -material ambient 0.8 0.4 0.5 diffuse 0.2 0.3 1.0 specular 0.3 0.4 1.0 shininess 30\"" -background blue -foreground white
    $menu add command -label yellow -command "evaluate \"$object -material ambient 0.9 0.9 0.6 diffuse 0.9 0.9 0.2 specular 0.9 0.9 0.2 shininess 30\"" -background yellow -foreground black
    $menu add command -label orange -command "evaluate \"$object -material ambient 1.0 0.3 0.7 diffuse 1.0 0.6 0.1 specular 0.9 0.5 0.9 shininess 30\"" -background orange -foreground black
    $menu add command -label purple -command "evaluate \"$object -material ambient 0.8 0.5 0.8 diffuse 1.0 0.6 1.0 specular 0.8 0.0 0.8 shininess 30\"" -background purple -foreground white
    $menu add command -label grey -command "evaluate \"$object -material ambient 0.5 0.5 0.5 diffuse 0.4 0.4 0.4 specular 0.4 0.4 0.4 shininess 30\"" -background grey -foreground black
    $menu add command -label white -command "evaluate \"$object -material ambient 1.0 1.0 1.0 diffuse 1.0 1.0 1.0 specular 0.9 0.9 0.9 shininess 30\"" -background white -foreground black
    $menu add command -label black -command "evaluate \"$object -material ambient 0.1 0.1 0.1 diffuse 0.0 0.0 0.0 specular 0.5 0.5 0.5 shininess 30\"" -background black -foreground white
}


graphics3D::rendermenu
Comments  
Arguments name
color
object
Used by graphics3D::installSphereMenu
Uses  
proc graphics3D::rendermenu { name color object } {
    set menu [menu $name.mn -bg $color -postcommand "set graphics3D::v$object \[$object -render\]"]
    renderoptions $menu $object
    #       secondaryrenderlists $menu $color $object
    return $menu
}


graphics3D::renderoptions
Comments  
Arguments menu
object
subobject
Used by SM2::installSM2
simulation::installActiveTubeMenu
graphics3D::installRectangle3DMenu
SM2::selectZone
triangulation::installMainTriangulation3DMenu
tetrahedrisation::installTetra3DDisplayMenu
Uses  
proc graphics3D::renderoptions { menu object {subobject "none"}} {
    global graphics3D::v$object
    set name $object
    #       foreach i [split $object] { set name $name$i }
    if {[string match {none} $subobject]} {
    foreach f [$object -renderOption] {
        $menu add radiobutton -label [lindex $f 0] -command "evaluate \"$object -render [ lindex $f 1]\""  -variable graphics3D::v$name -value [lindex $f 1]}
    }       else {
    foreach f [$object $subobject -renderOption] {$menu add radiobutton -label [lindex $f 0] -command "evaluate \"$object $subobject -render [ lindex $f 1]\""   -variable graphics3D::v$name -value [lindex $f 1]}
    }
}


graphics3D::rgbScales
Comments  
Arguments frame
object
name
color
check
rv
gv
bv
alphavar
Used by  
Uses  
proc graphics3D::rgbScales { frame object name color check rv gv bv alphavar} {
    if ![string compare $check none] {
    label $frame.l -relief raised -text $name -bg $color
    } else {
    checkbutton $frame.l -variable $check -onvalue true -offvalue false  -text $name -bg $color -relief raised -command "$object -material $name \[set $check\] \[$frame.r get\] \[$frame.g get\] \[$frame.b get\] \[set $alphavar\]"
    }
    scale $frame.r -from 0 -to 1 -resolution 0.01 -orient horizontal -bg red -fg yellow
    bind $frame.r <Enter> "focus $frame.r"
    $frame.r set $rv
    scale $frame.g -from 0 -to 1 -resolution 0.01 -orient horizontal -bg green -fg black
    bind $frame.g <Enter> "focus $frame.g"
    $frame.g set $gv
    scale $frame.b -from 0 -to 1 -resolution 0.01 -orient horizontal -bg blue -fg white
    bind $frame.b <Enter> "focus $frame.b"
    $frame.b set $bv

    if ![string compare $check none] {
    $frame.r configure -command "$object -material $name \[$frame.r get\] \[$frame.g get\] \[$frame.b get\] \[set $alphavar\]"
    $frame.g configure -command "$object -material $name \[$frame.r get\] \[$frame.g get\] \[$frame.b get\] \[set $alphavar\]"
    $frame.b configure -command "$object -material $name \[$frame.r get\] \[$frame.g get\] \[$frame.b get\] \[set $alphavar\]"
    } else {
    $frame.r configure -command "$object -material $name \[set $check\] \[$frame.r get\] \[$frame.g get\] \[$frame.b get\] \[set $alphavar\]"
    $frame.g configure -command "$object -material $name \[set $check\] \[$frame.r get\] \[$frame.g get\] \[$frame.b get\] \[set $alphavar\]"
    $frame.b configure -command "$object -material $name \[set $check\] \[$frame.r get\] \[$frame.g get\] \[$frame.b get\] \[set $alphavar\]"
    }

    pack $frame.l $frame.r $frame.g $frame.b -fill x -expand true
}


graphics3D::secondaryrenderlists
Comments  
Arguments menu
color
object
Used by  
Uses  
proc graphics3D::secondaryrenderlists { menu color object } {
    #       global graphics3D::renderlist$object
    foreach f [$object -secondaryRenderOption] {secondaryrenderoptions $menu $color $object [lindex $f 0] [lindex $f 1]}

    return $menu
}


graphics3D::secondaryrenderoptions
Comments  
Arguments menu
color
object
listname
optionname
Used by  
Uses  
proc graphics3D::secondaryrenderoptions { menu color object listname optionname } {
    global graphics3D::renderlist$object.$optionname

    $menu add cascade -label $listname -menu $menu.$optionname
    set sublist [menu  $menu.$optionname -tearoff 0 -bg $color -postcommand "set graphics3D::renderlist$object.$optionname \[$object -secondaryRender $optionname\]"]

    foreach f [$object -secondaryRenderOption $optionname] {$menu.$optionname add radiobutton -label [lindex $f 0] -command "evaluate \"$object -secondaryRender $optionname [ lindex $f 1]\""  -variable graphics3D::renderlist$object.$optionname -value [lindex $f 1]}
}


graphics3D::setLight
Comments  
Arguments light
color
radius
Used by  
Uses  
proc graphics3D::setLight { light color {radius 1}} {
    variable dirpos
    variable cutoff
    variable spot

    set w .light$light
    if ![winfo exists $w] {
    toplevel $w -bg $color
    wm title $w "$light properties"

    set str [$light -params]
    scan $str "ambient %f %f %f %*f diffuse %f %f %f %*f specular %f %f %f %*f position %f %f %f %f direction %f %f %f" ar ag ab dr dg db sr sg sb px py pz pw dx dy dz
    set str [string range $str [string first exponent $str] end]
    scan $str "exponent %f cutoff %f attenuation %f %f %f" exp co ac al aq

    frame $w.f1 -bg $color
    frame $w.f1.fa -bg $color
    frame $w.f1.fd -bg $color
    frame $w.f1.fs -bg $color
    lightRgbScales $w.f1.fa $light ambient $color $ar $ag $ab
    lightRgbScales $w.f1.fd $light diffuse $color $dr $dg $db
    lightRgbScales $w.f1.fs $light specular $color $sr $sg $sb

    pack $w.f1.fa $w.f1.fd $w.f1.fs -fill both -expand true -side left -padx 5 -pady 5

    frame $w.f2 -bg $color
    frame $w.f2.l -bg $color
    frame $w.f2.r -bg $color
    frame $w.f2.a -bg $color

    set min [expr -5.0 * $radius]
    set max [expr 5.0 * $radius]
    set res [expr $max / 500.0]

    radiobutton $w.f2.l.dir -text "directional light" -bg $color  -variable graphics3D::dirpos -value dir -relief raised -command "$w.f2.r.x configure -state disabled -command {}; $w.f2.r.y configure -state disabled -command {}; $w.f2.r.z configure -state disabled -command {}; $w.f2.r.cutoff configure -state disabled -command {}; $w.f2.r.cos configure -state disabled -command {}; $w.f2.l.x configure -state normal -command \"$light -params position \\\[$w.f2.l.x get\\\] \\\[$w.f2.l.y get\\\] \\\[$w.f2.l.z get\\\] 0.0\"; $w.f2.l.y configure -state normal -command \"$light -params position \\\[$w.f2.l.x get\\\] \\\[$w.f2.l.y get\\\] \\\[$w.f2.l.z get\\\] 0.0\"; $w.f2.l.z configure -state normal -command \"$light -params position \\\[$w.f2.l.x get\\\] \\\[$w.f2.l.y get\\\] \\\[$w.f2.l.z get\\\] 0.0\"; $light -params position \[$w.f2.l.x get\] \[$w.f2.l.y get\] \[$w.f2.l.z get\] 0.0"
    scale $w.f2.l.x -label X -from $min -to $max -orient horizontal -bg $color -resolution $res
    bind $w.f2.l.x <Enter> "focus $w.f2.l.x"
    scale $w.f2.l.y -label Y -from $min -to $max -orient horizontal -bg $color -resolution $res
    bind $w.f2.l.y <Enter> "focus $w.f2.l.y"
    scale $w.f2.l.z -label Z -from $min -to $max -orient horizontal -bg $color -resolution $res
    bind $w.f2.l.z <Enter> "focus $w.f2.l.z"
    $w.f2.l.x set $px
    $w.f2.l.y set $py
    $w.f2.l.z set $pz

    pack $w.f2.l.dir $w.f2.l.x $w.f2.l.y $w.f2.l.z -fill x

    set min [expr -20.0 * $radius]
    set max [expr 20.0 * $radius]
    set res [expr $max / 500.0]

    radiobutton $w.f2.r.pos -text "spot light" -bg $color  -variable graphics3D::dirpos -value pos -relief raised -command "$w.f2.l.x configure -state disabled -command {}; $w.f2.l.y configure -state disabled -command {}; $w.f2.l.z configure -state disabled -command {}; $w.f2.r.x configure -state normal -command \"$light -params position \\\[$w.f2.r.x get\\\] \\\[$w.f2.r.y get\\\] \\\[$w.f2.r.z get\\\] 1.0\"; $w.f2.r.y configure -state normal -command \"$light -params position \\\[$w.f2.r.x get\\\] \\\[$w.f2.r.y get\\\] \\\[$w.f2.r.z get\\\] 1.0\"; $w.f2.r.z configure -state normal -command \"$light -params position \\\[$w.f2.r.x get\\\] \\\[$w.f2.r.y get\\\] \\\[$w.f2.r.z get\\\] 1.0\"; $light -params position \[$w.f2.r.x get\] \[$w.f2.r.y get\] \[$w.f2.r.z get\] 1.0; $w.f2.r.cutoff configure -state normal -command \"if !\\\[string compare \\\$cutoff true\\\] {$w.f2.r.cos configure -state normal; $light -params cutoff \\\[$w.f2.r.cos get\\\]} else {$w.f2.r.cos configure -state disabled; $light -params cutoff 180.0}\"; $w.f2.r.cos configure -command \"$light -params cutoff \\\[$w.f2.r.cos get\\\]\""
    scale $w.f2.r.x -label X -from $min -to $max -orient horizontal -bg $color -resolution $res
    bind $w.f2.r.x <Enter> "focus $w.f2.r.x"
    scale $w.f2.r.y -label Y -from $min -to $max -orient horizontal -bg $color -resolution $res
    bind $w.f2.r.y <Enter> "focus $w.f2.r.y"
    scale $w.f2.r.z -label Z -from $min -to $max -orient horizontal -bg $color -resolution $res
    bind $w.f2.r.z <Enter> "focus $w.f2.r.z"
    $w.f2.r.x set $px
    $w.f2.r.y set $py
    $w.f2.r.z set $pz

    if { $co == 180 } {
        set cutoff false
    } else {
        set cutoff true
    }
    checkbutton $w.f2.r.cutoff -text "cutoff" -variable cutoff -onvalue true -offvalue false -bg $color  -command "if !\[string compare $cutoff false\] { $light -params cutoff 180.0 } else { $light -params cutoff \[$w.f2.r.cos get\] }"
    scale $w.f2.r.cos -from 0 -to 90 -orient horizontal -bg $color -resolution 0.01
    bind $w.f2.r.cos <Enter> "focus $w.f2.r.cos"
    scale $w.f2.r.dx -label "X direction" -from -10 -to 10 -orient horizontal -bg $color -resolution 0.01 -command "$light -params direction \[$w.f2.r.dx get\] \[$w.f2.r.dy get\] \[$w.f2.r.dz get\]"
    bind $w.f2.r.dx <Enter> "focus $w.f2.r.dx"
    scale $w.f2.r.dy -label "Y direction" -from -10 -to 10 -orient horizontal -bg $color -resolution 0.01 -command "$light -params direction \[$w.f2.r.dx get\] \[$w.f2.r.dy get\] \[$w.f2.r.dz get\]"
    bind $w.f2.r.dy <Enter> "focus $w.f2.r.dy"
    scale $w.f2.r.dz -label "Z direction" -from -10 -to 10 -orient horizontal -bg $color -resolution 0.01 -command "$light -params direction \[$w.f2.r.dx get\] \[$w.f2.r.dy get\] \[$w.f2.r.dz get\]"
    bind $w.f2.r.dz <Enter> "focus $w.f2.r.dz"
    $w.f2.r.cos set $co
    $w.f2.r.dx set $dx
    $w.f2.r.dy set $dy
    $w.f2.r.dz set $dz

    set spot [$light -show]
    checkbutton $w.f2.r.show -text "show spot" -variable spot -onvalue true -offvalue false -bg $color  -command "$light -show \$spot"

    pack $w.f2.r.pos $w.f2.r.x $w.f2.r.y $w.f2.r.z $w.f2.r.cutoff $w.f2.r.cos $w.f2.r.dx $w.f2.r.dy $w.f2.r.dz $w.f2.r.show -fill x

    label $w.f2.a.l -text "attenuation" -bg $color -relief raised
    scale $w.f2.a.exp -label "exponent" -from 0 -to 128 -resolution 0.01 -bg $color -orient horizontal -command "$light -params exponent \[$w.f2.a.exp get\]"
    bind $w.f2.a.exp <Enter> "focus $w.f2.a.exp"
    scale $w.f2.a.cst -label "constant attenuation" -from 0 -to 10 -resolution 0.01 -bg $color -orient horizontal -command "$light -params attenuation \[$w.f2.a.cst get\] \[$w.f2.a.lin get\] \[$w.f2.a.quad get\]"
    bind $w.f2.a.cst <Enter> "focus $w.f2.a.cst"
    scale $w.f2.a.lin -label "linear attenuation" -from 0 -to 3 -resolution 0.01 -bg $color -orient horizontal -command "$light -params attenuation \[$w.f2.a.cst get\] \[$w.f2.a.lin get\] \[$w.f2.a.quad get\]"
    bind $w.f2.a.lin <Enter> "focus $w.f2.a.lin"
    scale $w.f2.a.quad -label "quadratic attenuation" -from 0 -to 3 -resolution 0.01 -bg $color -orient horizontal -command "$light -params attenuation \[$w.f2.a.cst get\] \[$w.f2.a.lin get\] \[$w.f2.a.quad get\]"
    bind $w.f2.a.quad <Enter> "focus $w.f2.a.quad"
    $w.f2.a.exp set $exp
    $w.f2.a.cst set $ac
    $w.f2.a.lin set $al
    $w.f2.a.quad set $aq

    pack $w.f2.a.l $w.f2.a.exp $w.f2.a.cst $w.f2.a.lin $w.f2.a.quad -fill x

    pack $w.f2.l $w.f2.r $w.f2.a -fill both -expand true -side left -padx 5
    
    if { $pw == 0 } {
        $w.f2.l.dir select
        eval [$w.f2.l.dir cget -command]
    } else {
        $w.f2.r.pos select
        eval [$w.f2.r.pos cget -command]
    }

    frame $w.b -bg $color
    button $w.b.cancel -text "Dismiss" -command "destroy $w" -bg $color
    pack $w.b.cancel -padx 10 -pady 5 -side left -fill x -expand true

    pack $w.f1 $w.f2 -fill both -expand true
    pack $w.b -fill x -expand true
    }
}


graphics3D::startRecording
Comments  
Arguments menu
cam
color
scolor
Used by  
Uses  
proc graphics3D::startRecording { menu cam color scolor } {
    variable simu scene

    if ![winfo exists .recording] {
    toplevel .recording -bg $color
    frame .recording.f1 -bg $color
    frame .recording.f4 -bg $color
    frame .recording.f5 -bg $color
    frame .recording.f6 -bg $color
    frame .recording.f3 -bg $color
    frame .recording.f2 -bg $color

    label .recording.f1.l -text "base file name:" -bg $color
    entry .recording.f1.e -width 30 -bg white
    .recording.f1.e insert 0 dump
    pack .recording.f1.l .recording.f1.e -side left -pady 5

    label .recording.f4.l -text "Mpeg Encoding Command:" -bg $color
    entry .recording.f4.e -width 30 -bg white
    .recording.f4.e insert 0 mpeg_encode
    pack .recording.f4.l .recording.f4.e -side left -pady 5

    label .recording.f5.l -text "Mpeg Playing Command:" -bg $color
    entry .recording.f5.e -width 30 -bg white
    .recording.f5.e insert 0 xanim
    pack .recording.f5.l .recording.f5.e -side left -pady 5

    label .recording.f6.l -text "Repeat Frames:" -bg $color
    entry .recording.f6.e -width 5 -bg white
    .recording.f6.e insert 0 1
    pack .recording.f6.l .recording.f6.e -side left -pady 5

    radiobutton .recording.f3.simu -variable graphics3D::simu -value scene  -text "At simulation rate" -bg $color -anchor w
    radiobutton .recording.f3.cam -variable graphics3D::simu -value camera -text "At frame rate" -bg $color -anchor w
    pack .recording.f3.simu .recording.f3.cam -fill x -expand true

    button .recording.f2.start -text start -bg $scolor -command "
        if \[string compare \[.recording.f1.e get\] {}\] {
            .recording.f1.e configure -state disabled
            .recording.f3.simu configure -state disabled
            .recording.f3.cam configure -state disabled
            .recording.f2.start configure -state disabled
            .recording.f2.stop configure -state normal
            if \[string compare \$graphics3D::simu scene\] {
            .recording.f2.pause configure -state normal
            evaluate \"$cam -record frame \[.recording.f1.e get\]\"
            } else {
            .recording.f2.pause configure -state disabled
            evaluate \"$cam -record simulation \[.recording.f1.e get\]\"
            }
        }"
    button .recording.f2.pause -text pause -bg $scolor -state disabled -command "
        if \[string compare \[.recording.f2.pause cget -text\] pause\] {
            .recording.f2.pause configure -text pause
            evaluate \"$cam -record pause\"
        } else {
            .recording.f2.pause configure -text restart
            evaluate \"$cam -record pause\"
        }"
    button .recording.f2.stop -state disabled -text stop -bg $scolor -command "
        evaluate \"$cam -record stop\"
        .recording.f1.e configure -state normal
        .recording.f3.simu configure -state normal
        .recording.f3.cam configure -state normal
        .recording.f2.start configure -state normal
        .recording.f2.mpeg configure -state normal
        .recording.f2.pause configure -state disabled
        .recording.f2.stop configure -state disabled"
    button .recording.f2.mpeg -text mpeg -bg $scolor -state disabled -command "
                 evaluate \"modules::mpeg \[.recording.f1.e get\].xwd  \[.recording.f4.e get\]  \[.recording.f5.e get\] \[.recording.f6.e get\]\""
    button .recording.f2.dismiss -text dismiss -bg $scolor -command {destroy .recording}
    pack .recording.f2.start .recording.f2.pause .recording.f2.stop .recording.f2.mpeg .recording.f2.dismiss -side left -padx 5 -pady 5

    pack .recording.f1 .recording.f4  .recording.f5 .recording.f6  .recording.f3  .recording.f2 -fill x -pady 5
    }
}


graphics3D::startViewer3D
Comments  
Arguments parent
cam
Used by  
Uses  
proc graphics3D::startViewer3D { parent cam} {
    $parent.start configure -text "Stop Computation" -command "evaluate \"[$cam -scene] -computation false\""
}


graphics3D::stopViewer3D
Comments  
Arguments parent
cam
Used by graphics3D::viewer3DButtons
Uses  
proc graphics3D::stopViewer3D { parent cam } {
    $parent.start configure -text "Start Computation"  -command "evaluate \"[$cam -scene] -computation true\""
}


graphics3D::textureoptions
Comments  
Arguments menu
object
color
Used by triangulation::installZone3DMenu
graphics3D::installSphereMenu
SM2::selectZone
tetrahedrisation::installTetra3DDisplayMenu
tetrahedrisation::installSurfaceZone3DMenu
triangulation::installMainTriangulation3DMenu
graphics3D::installRectangle3DMenu
Uses  
proc graphics3D::textureoptions { menu object color } {
    $menu add cascade -label "Texture Highlight" -menu $menu.highlight
    menu $menu.highlight -bg $color -tearoff 0
    $menu.highlight add command -label "Create Highlight" -command "evaluate {$object -highlightTexture \[ new text2D gaussian 64 0.2 \] }"
    $menu.highlight add command -label "Edit Highlight..."
    $menu.highlight add cascade -label "Set Texture" -menu $menu.highlight.set
    menu $menu.highlight.set -bg $color -tearoff 0 -postcommand "
       set selectedHighlightTexture \[ $object -highlightTexture \]  
       $menu.highlight.set delete 0 last
        foreach {i} \[which text2D\] {
        $menu.highlight.set add radiobutton  -variable selectedHighlightTexture -label \$i -command \"evaluate \\\"$object -highlightTexture \$i \\\"\"
        }"
    $menu.highlight add cascade -label "Use Highlight" -menu $menu.highlight.use
    menu $menu.highlight.use -bg $color -tearoff 0 -postcommand "
       set highlightUse \[ $object -texture2DOption useHighlightTexture \]
       $menu.highlight.use delete 0 last
       $menu.highlight.use add radiobutton  -variable highlightUse -label \"true\" -command {evaluate \" $object -texture2DOption useHighlightTexture true\"}
       $menu.highlight.use add radiobutton  -variable highlightUse -label \"false\" -command {evaluate \" $object -texture2DOption useHighlightTexture false\"}"


    $menu add cascade -label "Add 2D Texture" -menu $menu.texture
    menu $menu.texture -bg $color -tearoff 0 -postcommand "
       set selectedTexture \[ $object -texture2D \]  
       $menu.texture delete 0 last
        foreach {i} \[which text2D\] {
        $menu.texture add radiobutton  -variable selectedTexture -label \$i -command \"evaluate \\\"$object -texture2D \$i\\\"\"
        }"

    $menu add cascade -label "2D Texture Option" -menu $menu.textOption
    menu $menu.textOption -bg $color -tearoff 0  
    $menu.textOption add cascade -label "Use 2D Texture" -menu $menu.textOption.use
    menu $menu.textOption.use -bg $color -tearoff 0 -postcommand "
       set selectedUse \[ $object -texture2DOption use \]
       $menu.textOption.use delete 0 last
       $menu.textOption.use add radiobutton  -variable selectedUse -label \"true\" -command {evaluate \" $object -texture2DOption use true\"}
       $menu.textOption.use add radiobutton  -variable selectedUse -label \"false\" -command {evaluate \" $object -texture2DOption use false\"}"
    $menu.textOption add cascade -label "Mode" -menu $menu.textOption.mode
    menu $menu.textOption.mode -bg $color -tearoff 0 -postcommand "
       set selectedMode \[ $object -texture2DOption mode \]
       $menu.textOption.mode delete 0 last
       $menu.textOption.mode add radiobutton -variable selectedMode -label \"coordinates\" -command {evaluate \" $object -texture2DOption mode coordinates\"}
       $menu.textOption.mode add radiobutton  -variable selectedMode -label \"spherical\" -command  {evaluate \" $object -texture2DOption mode spherical\"}
       $menu.textOption.mode add radiobutton  -variable selectedMode -label \"planar\" -command  {evaluate \" $object -texture2DOption mode planar\"}
       $menu.textOption.mode add radiobutton  -variable selectedMode -label \"camera\" -command  {evaluate \" $object -texture2DOption mode camera\"}"
    $menu.textOption add cascade -label "Replace Lighting" -menu $menu.textOption.light
    menu $menu.textOption.light -bg $color -tearoff 0 -postcommand "
       set replaceLight \[ $object -texture2DOption replaceLighting \]
       $menu.textOption.light delete 0 last
       $menu.textOption.light add radiobutton  -variable replaceLight -label \"true\" -command {evaluate \" $object -texture2DOption replaceLighting true\"}
       $menu.textOption.light add radiobutton  -variable replaceLight -label \"false\" -command {evaluate \" $object -texture2DOption replaceLighting false\"}"
    $menu.textOption add cascade -label "Interpolation" -menu $menu.textOption.inter
    menu $menu.textOption.inter -bg $color -tearoff 0 -postcommand "
       set selectedInterpolation \[ $object -texture2DOption interpolation \]
       $menu.textOption.inter delete 0 last
       $menu.textOption.inter add radiobutton  -variable selectedInterpolation -label \"nearest\" -command  {evaluate \" $object -texture2DOption interpolation nearest\"}
       $menu.textOption.inter add radiobutton  -variable selectedInterpolation -label \"linear\" -command  {evaluate \" $object -texture2DOption interpolation linear\"}"
    $menu.textOption add cascade -label "Extrapolation" -menu $menu.textOption.extra
    menu $menu.textOption.extra -bg $color -tearoff 0 -postcommand "
       set selectedExtrapolation \[ $object -texture2DOption extrapolation \]
       $menu.textOption.extra delete 0 last
       $menu.textOption.extra add radiobutton  -variable selectedExtrapolation -label \"clamp\" -command  {evaluate \" $object -texture2DOption extrapolation clamp\"}
       $menu.textOption.extra add radiobutton  -variable selectedExtrapolation -label \"repeat\" -command  {evaluate \" $object -texture2DOption extrapolation repeat\"}"
    $menu.textOption add cascade -label "Define Plane" -menu $menu.textOption.plane
    menu $menu.textOption.plane -bg $color -tearoff 0 -postcommand "
       $menu.textOption.plane delete 0 last
       foreach {i}  \[which rect3D\]   {
           $menu.textOption.plane add command -label \$i -command  {evaluate \" $object -texture2DOption sparam \[ \$i -direction X \]; $object -texture2DOption tparam \[ \$i -direction Y \]\"}
       }"

    $menu add cascade -label "Add 1D Texture" -menu $menu.text1D
    menu $menu.text1D -bg $color -tearoff 0 -postcommand "
       set selectedTexture \[ $object -texture1D \]  
       $menu.text1D delete 0 last
        foreach {i} \[which text1D\] {
        $menu.text1D add radiobutton -variable selectedTexture -label \$i -command \"evaluate \\\"$object -texture1D \$i\\\"\"
        }"

    $menu add cascade -label "1D Texture Option" -menu $menu.text1DOption
    menu $menu.text1DOption -bg $color -tearoff 0  
    $menu.text1DOption add cascade -label "Use 1D Texture" -menu $menu.text1DOption.use
    menu $menu.text1DOption.use -bg $color -tearoff 0 -postcommand "
       set selectedUse \[ $object -texture1DOption use \]
       $menu.text1DOption.use delete 0 last
       $menu.text1DOption.use add radiobutton  -variable selectedUse -label \"true\" -command {evaluate \" $object -texture1DOption use true\"}
       $menu.text1DOption.use add radiobutton  -variable selectedUse -label \"false\" -command {evaluate \" $object -texture1DOption use false\"}"
    $menu.text1DOption add cascade -label "Mode" -menu $menu.text1DOption.mode
    menu $menu.text1DOption.mode -bg $color -tearoff 0 -postcommand "
       set selectedMode \[ $object -texture1DOption mode \]
       $menu.text1DOption.mode delete 0 last
       $menu.text1DOption.mode add radiobutton  -variable selectedMode -label \"coordinates\" -command {evaluate \" $object -texture1DOption mode coordinates\"}
       $menu.text1DOption.mode add radiobutton  -variable selectedMode -label \"spherical\" -command  {evaluate \" $object -texture1DOption mode spherical\"}
       $menu.text1DOption.mode add radiobutton  -variable selectedMode -label \"planar\" -command  {evaluate \" $object -texture1DOption mode planar\"}
       $menu.text1DOption.mode add radiobutton  -variable selectedMode -label \"camera\" -command  {evaluate \" $object -texture1DOption mode camera\"}"
    $menu.text1DOption add cascade -label "Replace Lighting" -menu $menu.text1DOption.light
    menu $menu.text1DOption.light -bg $color -tearoff 0 -postcommand "
       set replaceLight \[ $object -texture2DOption replaceLighting \]
       $menu.text1DOption.light delete 0 last
       $menu.text1DOption.light add radiobutton -variable replaceLight -label \"true\" -command {evaluate \" $object -texture2DOption replaceLighting true\"}
       $menu.text1DOption.light add radiobutton  -variable replaceLight -label \"false\" -command {evaluate \" $object -texture2DOption replaceLighting false\"}"
    $menu.text1DOption add cascade -label "Interpolation" -menu $menu.text1DOption.inter
    menu $menu.text1DOption.inter -bg $color -tearoff 0 -postcommand "
       set selectedInterpolation \[ $object -texture1DOption interpolation \]
       $menu.text1DOption.inter delete 0 last
       $menu.text1DOption.inter add radiobutton  -variable selectedInterpolation -label \"nearest\" -command  {evaluate \" $object -texture1DOption interpolation nearest\"}
       $menu.text1DOption.inter add radiobutton  -variable selectedInterpolation -label \"linear\" -command  {evaluate \" $object -texture1DOption interpolation linear\"}"
    $menu.text1DOption add cascade -label "Extrapolation" -menu $menu.text1DOption.extra
    menu $menu.text1DOption.extra -bg $color -tearoff 0 -postcommand "
       set selectedExtrapolation \[ $object -texture1DOption extrapolation \]
       $menu.text1DOption.extra delete 0 last
       $menu.text1DOption.extra add radiobutton  -variable selectedExtrapolation -label \"clamp\" -command  {evaluate \" $object -texture1DOption extrapolation clamp\"}
       $menu.text1DOption.extra add radiobutton  -variable selectedExtrapolation -label \"repeat\" -command  {evaluate \" $object -texture1DOption extrapolation repeat\"}"
    $menu.text1DOption add cascade -label "Define Plane" -menu $menu.text1DOption.plane
    menu $menu.text1DOption.plane -bg $color -tearoff 0 -postcommand "
       $menu.text1DOption.plane delete 0 last
       foreach {i}  \[which rect3D\]   {
           $menu.text1DOption.plane add command -label \$i -command  {evaluate \" $object -texture1DOption sparam \[ \$i -direction X \]; $object -texture1DOption tparam \[ \$i -direction Y \]\"}
       }"
}


graphics3D::topViewer3D
Comments  
Arguments nb
Used by  
Uses  
proc graphics3D::topViewer3D { nb } {
    variable parent .viewer3D$nb
    toplevel $parent
    wm title $parent "OpenGL Camera ($nb)"

    set color #A0D0A0
    set scolor #90C090

    # menu frame
    frame $parent.menu -bg $color
    pack $parent.menu -fill x
    frame $parent.submenu -bg $scolor
    pack $parent.submenu -expand true -fill both
    viewer3DMenu $nb $parent.menu $parent.submenu $color $scolor

    viewer3D $nb $parent

    # down button row
    frame $parent.buttons -bg $color
    pack $parent.buttons  -fill x
    viewer3DButtons $nb $parent.buttons $color
}


graphics3D::uninstallRectangle3DMenu
Comments  
Arguments viewer
camera
line
Used by  
Uses  
proc graphics3D::uninstallRectangle3DMenu { viewer camera line} {
    # remove frame children
    set list [winfo children $viewer.context]
    foreach w $list { destroy $w}
    pack $viewer.context -fill x
}


graphics3D::uninstallSelectedObjectMenu
Comments  
Arguments viewer
camera
object
Used by  
Uses  
proc graphics3D::uninstallSelectedObjectMenu { viewer camera object } {
    set list [winfo children $viewer.context]
    foreach w $list { destroy $w}
    pack $viewer.context -fill x
}


graphics3D::uninstallSphereMenu
Comments  
Arguments parent
camera
object
Used by  
Uses  
proc graphics3D::uninstallSphereMenu { parent camera object } {
    destroy $parent.context.object $parent.context.render $parent.context.material
}


graphics3D::viewer3D
Comments  
Arguments nb
parent
Used by  
Uses  
proc graphics3D::viewer3D { nb parent } {
    # OpenGL widget
    togl $parent.view -rgba true -double true -depth true -ident Double
    
    # bindings
    bind $parent.view <Control-ButtonPress-1> "$nb -ctrlButton1Pressed %x %y"
    bind $parent.view <ButtonRelease-1> "$nb -button1Released %x %y"
    bind $parent.view <Control-ButtonRelease-1> "$nb -button1Released %x %y"
    
    bind $parent.view <ButtonPress-1> "$nb -button1Pressed %x %y"
    bind $parent.view <ButtonPress-2> "$nb -button2Pressed %x %y"

    bind $parent.view <Shift-ButtonPress-2> "$nb -shiftButton2Pressed %x %y"
    bind $parent.view <Control-ButtonPress-2> "$nb -ctrlButton2Pressed %x %y"
    bind $parent.view <ButtonRelease-2> "$nb -button2Released %x %y"
    
    bind $parent.view <plus> "$nb -keyPlus"
    bind $parent.view <minus> "$nb -keyMinus"
    bind $parent.view <Up> "$nb -keyUp"
    bind $parent.view <Down> "$nb -keyDown"
    bind $parent.view <Left> "$nb -keyLeft"
    bind $parent.view <Right> "$nb -keyRight"
    bind $parent.view <c> "$nb -key c"
    bind $parent.view <f> "$nb -key f"

    bind $parent <Enter> "focus $parent.view"
    pack $parent.view -fill both -expand true
    
    #    $nb -bindMotion
}


graphics3D::viewer3DButtons
Comments  
Arguments nb
parent
color
Used by  
Uses graphics3D::stopViewer3D
proc graphics3D::viewer3DButtons { nb parent color } {
    button $parent.start -text "Start Computation" -anchor w -justify center -command "evaluate \"[$nb -scene] -computation true\"" -bg $color
    button $parent.iter -text "Step" -anchor w -justify center -command "if { !\[string compare \[ \[$nb -scene \] -computation \] true \] } {evaluate \"[$nb -scene] -computation false\"; graphics3D::stopViewer3D $parent $nb}; evaluate \"[$nb -scene] -iteration\"" -bg $color
    pack $parent.start $parent.iter -expand true -side left -pady 3
}


graphics3D::viewer3DMenu
Comments  
Arguments nb
menu
smenu
color
scolor
Used by  
Uses modules::selectColor
proc graphics3D::viewer3DMenu { nb menu smenu color scolor } {
    global selectedObject showBBox
    variable fog
    variable render
    variable stencilBuffer
    variable specularity
    variable i

    # menu frame
    frame $smenu.context -height 26 -bg $scolor
    label $smenu.name -text "no selected object" -anchor e -bg $scolor
    pack $smenu.context -side left -expand true -fill x
    pack $smenu.name -side right
    
    # File menu
    menubutton $menu.file -text "File" -menu $menu.file.m -anchor w -bg $color
    set mfile [menu $menu.file.m -bg $color ]
    $mfile add command -label "Load File" -command  "[$nb -scene] -load \[tk_getOpenFile -filetypes {{\"All\" {* } } } -parent . -title {Select a File}\] "
    $mfile add cascade -label "Create Object From File" -menu $mfile.load
    set mnew [menu $mfile.load -tearoff 0 -bg $color]
    foreach i [scn3D -which file] "$mnew add command -label \[scn3D -realName \$i \] -command {set name  \[tk_getOpenFile -filetypes {{$i {[scn3D -suffix $i]}} {All *}}\]; if \[string compare \$name {}\] {evaluate \"new $i \$name\"}}"
    $mfile add cascade -label "Create Object" -menu $mfile.new
    set mnew [menu $mfile.new -tearoff 0 -bg $color]
    foreach i [scn3D -which none] "$mnew add command -label \[scn3D -realName \$i \] -command {evaluate \"new $i\"}"
    foreach i [scn3D -which camera] "$mnew add command -label \[scn3D -realName \$i \] -command {evaluate \"new $i -camera $nb\"}"
    $mfile add command -label "Iteration Parameters..." -command "graphics3D::iterationParameters \[$nb -scene\] $color $scolor"
    $mfile add command -label "Record..." -command "graphics3D::startRecording $mfile $nb $color $scolor"
    $mfile add separator
    $mfile add command -label "Script Dialog" -command "if {!\[winfo exists .yav\]} {loadSource tclModules.tcl; loadSource yav++.tcl;yav::interface}"
    $mfile add separator
    $mfile add command -label "Spawn new camera" -command "evaluate \"new cam3D -scene [$nb -scene]\""
    $mfile add command -label "Destroy camera" -command "evaluate \"$nb -destroy\""

    pack $menu.file -side left
    
    # Display menu
    menubutton $menu.display -text "Display" -menu $menu.display.m -anchor w -bg $color
    set mdisplay [menu $menu.display.m -bg $color -postcommand "set showBBox \[$nb -boundingBoxDisplay\]; set graphics3D::fog \[$nb -fog\]; set graphics3D::specularity \[$nb -specularity\];set graphics3D::stencilBuffer \[$nb -stencilBuffer\]; set graphics3D::render \[$nb -frontAndBack\]; " ]
    $mdisplay add command -label "Focus on Scene" -command "$nb -focus"
    $mdisplay add command -label "Change Background Color..." -command "set col \[ modules::selectColor  \[ $nb -bgcolor\] \]; $nb -bgcolor \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\] "
    $mdisplay add command -label "Save as Postcript File" -command ""

    #Bounding Box          
    $mdisplay add cascade -label "Display Two Sides" -menu $mdisplay.twoSides
    menu $mdisplay.twoSides -bg $color -tearoff 0 -postcommand "
        set useTwoSides \[$nb -useTwoSides\]
        $mdisplay.twoSides delete 0 last
        $mdisplay.twoSides add radiobutton  -selectcolor black -variable useTwoSides -label \"true\" -command \" $nb -useTwoSides true\"
        $mdisplay.twoSides add radiobutton  -selectcolor black -variable useTwoSides -label \"false\" -command \" $nb -useTwoSides false\" "
    $mdisplay add command -label "Field of View..." -command "graphics3D::changeFOV $nb $color"
    $mdisplay add command -label "Maximum Frame Rate" -command "graphics3D::changeMaxFrameRate $nb $color"
    $mdisplay add separator
    $mdisplay add checkbutton -selectcolor "black" -label "Show Bounding Box" -variable showBBox -onvalue true -offvalue false -command "$nb -boundingBoxDisplay \$showBBox"
    $mdisplay add command -label "Bounding Box Color..." -command "set col \[ modules::selectColor  \[ $nb -boundingBoxColor\] \]; evaluate \"$nb -boundingBoxColor \[lindex \$col 0\] \[lindex \$col 1\] \[lindex \$col 2\]\""
    $mdisplay add cascade -label "Bounding Box Width" -menu $mdisplay.sub2
    set m2 [menu  $mdisplay.sub2 -tearoff 0 -bg $color]
    $m2 add command -label "1" -command "evaluate \"$nb -boundingBoxWidth 1\""
    $m2 add command -label "2" -command "evaluate \"$nb -boundingBoxWidth 2\""
    $m2 add command -label "3" -command "evaluate \"$nb -boundingBoxWidth 3\""

    # fog
    $mdisplay add separator
    $mdisplay add check -label "fog" -variable graphics3D::fog -command "evaluate \"$nb -fog \$graphics3D::fog\"" -onvalue true -offvalue false
    $mdisplay add check -label "render front and back" -variable graphics3D::render -onvalue true -offvalue false  -command "evaluate \"$nb -frontAndBack \$graphics3D::render\""
    $mdisplay add checkbutton -label "compute true specularity" -variable graphics3D::specularity -onvalue true -offvalue false -command "evaluate \"$nb -specularity \$graphics3D::specularity\""
    pack $menu.display -side left
    
    # Stencil Buffer
    $mdisplay add separator
    $mdisplay add checkbutton -label "use StencilBuffer" -variable graphics3D::stencilBuffer -onvalue true -offvalue false  -command "evaluate \"$nb -stencilBuffer \$graphics3D::stencilBuffer\""
    

    # mouse
    menubutton $menu.mouse -text "Mouse" -menu $menu.mouse.m -anchor w -bg $color
    menu $menu.mouse.m -bg $color
    $menu.mouse.m add radio  -label "move camera" -variable graphics3D::movemode -value camera -command "evaluate \"$nb -motionMode camera\""
    $menu.mouse.m add radio -label "move object" -variable graphics3D::movemode -value object -command "evaluate \"$nb -motionMode object\""
    set graphics3D::movemode camera
    pack $menu.mouse -side left

    # Select menu
    menubutton $menu.objects -text "Select" -menu $menu.objects.m -anchor w -bg $color
    menu $menu.objects.m -bg $color -postcommand "
        set selectedObject \[ $nb -select \]
        $menu.objects.m delete 0 last
        foreach {i} \[$nb -objects\] {
        $menu.objects.m add radiobutton -selectcolor black -variable selectedObject -label \$i -command \"$nb -select \$i\"
        }
        $menu.objects.m add separator
        foreach {i} \[$nb -clippingPlanes\] {
        $menu.objects.m add radiobutton -selectcolor black -variable selectedObject -label \$i -command \"$nb -select \$i\"
        }
        $menu.objects.m add separator
        foreach {i} \[$nb -lights\] {
        $menu.objects.m add radiobutton -selectcolor black -variable selectedObject -label \$i -command \"$nb -select \$i\"
        }
        $menu.objects.m add separator
        $menu.objects.m add radiobutton -selectcolor black -variable selectedObject -label none -command \"$nb -select none\""
    pack $menu.objects -side left

    # Clipping planes
    menubutton $menu.clip -text "Clipping planes" -menu $menu.clip.m -anchor w -bg $color
    menu $menu.clip.m -bg $color -postcommand "
        $menu.clip.m delete 0 last
        $menu.clip.m add command -label new -command {evaluate \"new clip $nb\"}
        $menu.clip.m add separator
        foreach {i} \[$nb -clippingPlanes\] {
             set graphics3D::clipVar(\$i) \[\$i -active\]
        $menu.clip.m  add checkbutton -selectcolor black -variable graphics3D::clipVar(\$i) -onvalue true -offvalue false -label \$i -command \"\$i -active \\\$graphics3D::clipVar(\$i)\"
        }"
    pack $menu.clip -side left

    # Lights
    menubutton $menu.lights -text "Lights" -menu $menu.lights.m -anchor w -bg $color
    menu $menu.lights.m -bg $color -postcommand "
        $menu.lights.m delete 0 last
        $menu.lights.m add command -label new -command {evaluate \"new light $nb\"}
        $menu.lights.m add separator
        foreach {i} \[$nb -lights\] {
             set graphics3D::lightVar(\$i) \[\$i -active\]
        $menu.lights.m  add checkbutton -selectcolor black -variable graphics3D::lightVar(\$i) -onvalue true -offvalue false -label \$i -command \"\$i -active \\\$graphics3D::lightVar(\$i)\"
        }"
    pack $menu.lights -side left
    # Texture
    menubutton $menu.texture -text "Texture" -menu $menu.texture.m -anchor w -bg $color
    set mtexture [  menu $menu.texture.m -bg $color ]
    $mtexture add command -label "Create 1D Texture" -command "graphics3D::create1DTextureDialog $color"
    pack $menu.texture -side left
    

    # Display help
    menubutton $menu.help -text "Help" -menu $menu.help.m -anchor w -fg red -bg $color
    set mhelp [menu $menu.help.m -bg $color ]
    $mhelp add command -label "Mouse Bindings" -command "tk_messageBox -icon info -message \" Main Mouse Bindings :\n =================\n\n Left Button : Select Object or object-dependent selection mode\n Middle Button : Rotate Camera \n Right Button : pop-up menu\n Ctrl + Left Button : Scale Camera\n Ctrl + Middle Button : Pan camera in X and Y direction\n Shift + Middle Button : Pan camera in the Z direction  \""
    $mhelp add command -label "Key Bindings" -command "tk_messageBox -icon info -message \" Main Key Bindings :\n ===============\n\n c  : Toggle display of copyright\n f : Toggle display of frame rate \""
    pack $menu.help -side right
}