#!/usr/bin/wish -f


# mkText w
#
# Create a top-level window that displays text
#
# Arguments:
#    w -	Name to use for new top-level window.

proc mkText { w file } {
    catch {destroy $w}
    toplevel $w
#    dpos $w
    wm title $w "Help"
    wm iconname $w "Help"
    button $w.ok -text OK -command "destroy $w"
    text $w.t -relief raised -bd 2 -yscrollcommand "$w.s set" -setgrid true \
	    -width 60 -height 28 \
	    -font "-Adobe-Helvetica-Bold-R-Normal-*-120-*"
    scrollbar $w.s -relief flat -command "$w.t yview"
    pack $w.ok -side bottom -fill x
    pack $w.s -side right -fill y
    pack $w.t -expand yes -fill both

    # Set up display styles

#    if {[tk colormodel $w] == "color"} {
#	set bold "-foreground red"
#	set normal "-foreground {}"
#    } else {
#	set bold "-foreground white -background black"
#	set normal "-foreground {} -background {}"
#    }
    $w.t insert 0.0 [ exec cat $file ] 
}


wm title . "TAGL demos"

frame .menu -relief raised -borderwidth 1
message .msg -font -Adobe-times-medium-r-normal--*-180* -relief raised -width 500 \
-borderwidth 1 -text "Here are a few sample programs \
that demonstrate TAGL rendering functions. \
Left button rotates object. \
Middle button pans. \
Right button rotates light source. \
Press \'q\' to quit a demo. \
You can resize the rendering window.

To exit this demonstration, invoke the \"Quit\" entry in the \"File\" menu."

pack .menu -side top -fill x
pack .msg -side bottom -expand yes -fill both

menubutton .menu.file -text "File" -menu .menu.file.m
menu .menu.file.m
.menu.file.m add command -label "Quit" -command "destroy ." 

menubutton .menu.samples -text "Samples" -menu .menu.samples.m
menu .menu.samples.m
.menu.samples.m add command -label "Info" -command "mkText .help \
                        ../examples/Samples/README"
.menu.samples.m add command -label "Compile samples" -command "
puts \" Please Wait ... \" ;
exec sh -c \"cd ..; make Samples\"; 
puts \"End of compilation\" "
.menu.samples.m add separator

.menu.samples.m add command -label "Simple" -command "exec ../bin/simple &"
.menu.samples.m add command -label "RGB triangle" -command "exec ../bin/rgbtri &"
.menu.samples.m add command -label "Fractional index" -command "exec ../bin/fractidx &"
.menu.samples.m add command -label "Halftoning" -command "exec ../bin/halftone &"
.menu.samples.m add command -label "Mouse input" -command "exec ../bin/mouse &"
.menu.samples.m add command -label "Cube" -command "exec ../bin/cube &"
.menu.samples.m add command -label "RGB Cube" -command "exec ../bin/rgbcube &"
.menu.samples.m add command -label "ZBuffer" -command "exec ../bin/zcubes &"
.menu.samples.m add command -label "Depth cue" -command "exec ../bin/depthcue &"
.menu.samples.m add command -label "Contexts" -command "exec ../bin/contexts &"
.menu.samples.m add command -label "X11 bindind" -command "exec ../bin/xcontexts &"
.menu.samples.m add command -label "Texture" -command "exec ../bin/texcube textures/3.tga &"

.menu.samples.m add separator

.menu.samples.m add command -label "display Simple source ..." \
   -command "mkText .source ../examples/Samples/simple.cc"
.menu.samples.m add command -label "display RGB tri source ..." \
   -command "mkText .source ../examples/Samples/rgbtri.cc"
.menu.samples.m add command -label "display fract idx source ..." \
   -command "mkText .source ../examples/Samples/fractidx.cc"
.menu.samples.m add command -label "display halftoning source ..." \
   -command "mkText .source ../examples/Samples/halftone.cc"
.menu.samples.m add command -label "display mouse source ..." \
   -command "mkText .source ../examples/Samples/mouse.cc"
.menu.samples.m add command -label "display cube source ..." \
   -command "mkText .source ../examples/Samples/cube.cc"
.menu.samples.m add command -label "display RGB cube source ..." \
   -command "mkText .source ../examples/Samples/rgbcube.cc"
.menu.samples.m add command -label "display Zcubes source ..." \
   -command "mkText .source ../examples/Samples/zcubes.cc"
.menu.samples.m add command -label "display depthcue source ..." \
   -command "mkText .source ../examples/Samples/depthcue.cc"
.menu.samples.m add command -label "display contexts source ..." \
   -command "mkText .source ../examples/Samples/contexts.cc"
.menu.samples.m add command -label "display X11 binding source ..." \
   -command "mkText .source ../examples/Samples/xcontexts.cc"
.menu.samples.m add command -label "display texture source ..." \
   -command "mkText .source ../examples/Samples/texcube.cc"


menubutton .menu.wire   -text "WireFrame"      -menu .menu.wire.m
menu .menu.wire.m
.menu.wire.m add command -label "Flip TAGL logo" -command "exec ../bin/rotate \
      -geom objects/tagl.geom -exec 'aws789...20' &"
.menu.wire.m add command -label "Flip x29" -command "exec ../bin/rotate \
      -geom objects/x29.geom -exec 'aws' &"
.menu.wire.m add command -label "Flip Volkswagen" -command "exec ../bin/rotate \
      -geom objects/vw.geom -exec 'aws' &"
.menu.wire.m add command -label "Flip Doll" -command "exec ../bin/rotate \
      -geom objects/babem.geom -exec 'aws' &"
.menu.wire.m add command -label "Flip Foot bones" -command "exec ../bin/rotate \
      -geom objects/foot_bones.geom -exec 'aws' &"
.menu.wire.m add command -label "Flip Teapot" -command "exec ../bin/rotate \
      -geom objects/teapot.geom -exec 'aws' &"

menubutton .menu.solid   -text "Solid"      -menu .menu.solid.m 
menu .menu.solid.m
.menu.solid.m add command -label "Flip TAGL logo" -command "exec ../bin/rotate \
      -geom objects/tagl.geom -exec 's789...20' &"
.menu.solid.m add command -label "Flip x29" -command "exec ../bin/rotate \
      -geom objects/x29.geom -exec 's' &"
.menu.solid.m add command -label "Flip Volkswagen" -command "exec ../bin/rotate \
      -geom objects/vw.geom -exec 's' &"
.menu.solid.m add command -label "Flip Doll" -command "exec ../bin/rotate \
      -geom objects/babem.geom -exec 's' &"
.menu.solid.m add command -label "Flip Foot bones" -command "exec ../bin/rotate \
      -geom objects/foot_bones.geom -exec 's' &"
.menu.solid.m add command -label "Flip Teapot" -command "exec ../bin/rotate \
      -geom objects/teapot.geom -exec 's' &"

menubutton .menu.smooth  -text "Smooth"     -menu .menu.smooth.m
menu .menu.smooth.m
.menu.smooth.m add command -label "Flip TAGL logo" -command "exec ../bin/rotate \
      -geom objects/tagl.geom -exec 'sw789...20' &"
.menu.smooth.m add command -label "Flip x29" -command "exec ../bin/rotate \
      -geom objects/x29.geom -exec 'sw' &"
.menu.smooth.m add command -label "Flip Volkswagen" -command "exec ../bin/rotate \
      -geom objects/vw.geom -exec 'sw' &"
.menu.smooth.m add command -label "Flip Doll" -command "exec ../bin/rotate \
      -geom objects/babem.geom -exec 'sw' &"
.menu.smooth.m add command -label "Flip Foot bones" -command "exec ../bin/rotate \
      -geom objects/foot_bones.geom -exec 'sw' &"
.menu.smooth.m add command -label "Flip Teapot" -command "exec ../bin/rotate \
      -geom objects/teapot.geom -exec 'sw' &"

menubutton .menu.color   -text "Color"      -menu .menu.color.m
menu .menu.color.m
.menu.color.m add command -label "Flip x29" -command "exec ../bin/rotate \
      -geom objects/x29.geom -col objects/x29.ipcol -exec 'Cswhhh' &"
.menu.color.m add command -label "Flip Volkswagen" -command "exec ../bin/rotate \
      -geom objects/vw.geom -col objects/vw.ipcol -exec 'Cswhhh' &"
.menu.color.m add command -label "Flip Foot bones" -command "exec ../bin/rotate \
      -geom objects/foot_bones.geom -col objects/foot_bones.ipcol -exec 'Cswhhh' &"
.menu.color.m add command -label "Flip Apple" -command "exec ../bin/rotate \
      -geom objects/apple_logo.geom -col objects/apple_logo.ipcol -exec 'Cswhhh' &"

menubutton .menu.texture -text "Texture"    -menu .menu.texture.m
menu .menu.texture.m
.menu.texture.m add command -label "Flip TAGL Logo(1)" -command "exec ../bin/rotate \
         -geom objects/tagl.geom -tex textures/1.tga -exec 'Cst789...20UU' &"
.menu.texture.m add command -label "Flip TAGL Logo(2)" -command "exec ../bin/rotate \
         -geom objects/tagl.geom -tex textures/evrgreen.tga -exec 'Cst789...20uu' &"	 
.menu.texture.m add command -label "Flip TAGL Logo(3)" -command "exec ../bin/rotate \
         -geom objects/tagl.geom -tex textures/meditdn.tga -exec 'Cst789...20uu' &"
.menu.texture.m add command -label "Flip x29(1)" -command "exec ../bin/rotate \
         -geom objects/x29.geom -tex textures/1.tga -exec 'CstUU' &"
.menu.texture.m add command -label "Flip x29(2)" -command "exec ../bin/rotate \
         -geom objects/x29.geom -tex textures/evrgreen.tga -exec 'Cstuu' &"
.menu.texture.m add command -label "Flip x29(3)" -command "exec ../bin/rotate \
         -geom objects/x29.geom -tex textures/meditdn.tga -exec 'Cstuu' &"	 
.menu.texture.m add command -label "Flip Volkswagen(1)" -command "exec ../bin/rotate \
         -geom objects/vw.geom -tex textures/1.tga -exec 'Cst999UU0' &"
.menu.texture.m add command -label "Flip Volkswagen(2)" -command "exec ../bin/rotate \
         -geom objects/vw.geom -tex textures/evrgreen.tga -exec 'Cst999uu0' &"
.menu.texture.m add command -label "Flip Volkswagen(3)" -command "exec ../bin/rotate \
         -geom objects/vw.geom -tex textures/meditdn.tga -exec 'Cst999uu0' &"	 
.menu.texture.m add command -label "Flip Teapot(1)" -command "exec ../bin/rotate \
         -geom objects/teapot.geom -tex textures/1.tga -exec 'CstUU' &"
.menu.texture.m add command -label "Flip Teapot(2)" -command "exec ../bin/rotate \
         -geom objects/teapot.geom -tex textures/evrgreen.tga -exec 'Cstuu' &"
.menu.texture.m add command -label "Flip Teapot(3)" -command "exec ../bin/rotate \
         -geom objects/teapot.geom -tex textures/meditdn.tga -exec 'Cstuu' &"	 

menubutton .menu.environ -text "EnvironMap" -menu .menu.environ.m
menu .menu.environ.m
.menu.environ.m add command -label "Flip TAGL Logo" -command "exec ../bin/rotate \
         -geom objects/tagl.geom -tex textures/refmap.tga -exec 'CstT789...20' &"
.menu.environ.m add command -label "Flip Sticks" -command "exec ../bin/rotate \
         -geom objects/sticks.geom -tex textures/2.tga -exec 'nCstT' &"
.menu.environ.m add command -label "Flip Pear" -command "exec ../bin/rotate \
         -geom objects/pear.geom -tex textures/2.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip Apple" -command "exec ../bin/rotate \
         -geom objects/apple_logo.geom -tex textures/sunset2.tga -exec 'CstT' &"	 
.menu.environ.m add command -label "Flip Teapot(1)" -command "exec ../bin/rotate \
         -geom objects/teapot.geom -tex textures/2.tga -exec 'CstT' &"	 
.menu.environ.m add command -label "Flip Teapot(2)" -command "exec ../bin/rotate \
         -geom objects/teapot.geom -tex textures/refmap.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip Teapot(3)" -command "exec ../bin/rotate \
         -geom objects/teapot.geom -tex textures/cldsmap.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip Teapot(4)" -command "exec ../bin/rotate \
         -geom objects/teapot.geom -tex textures/sunset2.tga -exec 'CstT' &"	 
.menu.environ.m add command -label "Flip Head(1)" -command "exec ../bin/rotate \
         -geom objects/head.geom -tex textures/2.tga -exec 'CstT' &"	 
.menu.environ.m add command -label "Flip Head(2)" -command "exec ../bin/rotate \
         -geom objects/head.geom -tex textures/refmap.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip Head(3)" -command "exec ../bin/rotate \
         -geom objects/head.geom -tex textures/cldsmap.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip Head(4)" -command "exec ../bin/rotate \
         -geom objects/head.geom -tex textures/sunset2.tga -exec 'CstT' &"	 
.menu.environ.m add command -label "Flip Knot(1)" -command "exec ../bin/rotate \
         -geom objects/tref.geom -tex textures/2.tga -exec 'nCstT' &"
.menu.environ.m add command -label "Flip Knot(2)" -command "exec ../bin/rotate \
         -geom objects/tref.geom -tex textures/refmap.tga -exec 'nCstT' &"
.menu.environ.m add command -label "Flip Knot(3)" -command "exec ../bin/rotate \
         -geom objects/tref.geom -tex textures/cldsmap.tga -exec 'nCstT' &"
.menu.environ.m add command -label "Flip Knot(4)" -command "exec ../bin/rotate \
         -geom objects/tref.geom -tex textures/sunset2.tga -exec 'nCstT' &"	 
.menu.environ.m add command -label "Flip Volkswagen" -command "exec ../bin/rotate \
         -geom objects/vw.geom -tex textures/refmap.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip Dragon" -command "exec ../bin/rotate \
         -geom objects/dragon.geom -tex textures/refmap.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip Glass(1)" -command "exec ../bin/rotate \
         -geom objects/glass4.geom -tex textures/2.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip Glass(2)" -command "exec ../bin/rotate \
         -geom objects/glass4.geom -tex textures/refmap.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip T1000\'s head" -command "exec ../bin/rotate \
         -geom objects/head.geom -tex textures/refmap.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip T1000\'s foot" -command "exec ../bin/rotate \
         -geom objects/foot_bones.geom -tex textures/refmap.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip T1000\'s wife" -command "exec ../bin/rotate \
         -geom objects/babem.geom -tex textures/refmap.tga -exec 'CstT' &"
.menu.environ.m add command -label "Flip raytrace pear" -command "exec ../bin/rotate \
         -geom objects/pear.geom -tex textures/raytrace.tga -exec 'CstT' &"	 
	 

menubutton .menu.images -text "Images" -menu .menu.images.m
menu .menu.images.m
.menu.images.m add command -label "bricks" -command "exec ../bin/vtga textures/1.tga &"
.menu.images.m add command -label "flowers" -command "exec ../bin/vtga textures/2.tga &"
.menu.images.m add command -label "cindy" -command "exec ../bin/vtga textures/3.tga &"
.menu.images.m add command -label "clouds" -command "exec ../bin/vtga textures/cldsmap.tga &"
.menu.images.m add command -label "trees" -command "exec ../bin/vtga textures/evrgreen.tga &"
.menu.images.m add command -label "checker" -command "exec ../bin/vtga textures/meditdn.tga &"
.menu.images.m add command -label "metal" -command "exec ../bin/vtga textures/refmap.tga &"
.menu.images.m add command -label "shiny metal" -command  "exec ../bin/vtga \
    textures/sunset2.tga &"
.menu.images.m add command -label "raytrace" -command  "exec ../bin/vtga \
    textures/raytrace.tga &"    
.menu.images.m add separator
.menu.images.m add command -label "display image viewer source ..." \
   -command "mkText .source ../examples/vtga/vtga.cc"

menubutton .menu.help -text "Help" -menu .menu.help.m
menu .menu.help.m
.menu.help.m add command -label "General info" -command "mkText .help \
                                                general_info.txt"
.menu.help.m add command -label "Rotate" -command "mkText .help \
                                               ../doc/rotate.doc"
.menu.help.m add command -label "Samples" -command "mkText .help \
                        ../examples/Samples/README"
.menu.help.m add command -label "TAGL" -command "mkText .help tagl.txt"
.menu.help.m add command -label "Reflection mapping" -command "mkText \
.help ../doc/refmap.txt"


pack .menu.file .menu.samples .menu.wire .menu.solid \
     .menu.smooth .menu.color .menu.texture \
     .menu.environ .menu.images -side left
     
pack .menu.help -side right


