#!/usr/bin
set pothome /mnt/dd3/ebook/tech/opengl/pot
source /mnt/dd3/ebook/tech/opengl/pot/tkheader.h
tk_bisque
wm geometry . 600x300$winX$winY

wm title . "Chapter3 - Drawing Geometric Objects"
. configure -background white
createframe .c3menubar 2 
# call procedure createframe and create a frame for the menus available
# in chapter3. we call this menu frame .c3menubar and give it a width
# of 2 units.
   
createtextwidget "-adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1" blue white 0 0 nw

menubutton .c3menubar.menu -text "Concepts" -underline 0 \
-menu .c3menubar.menu.conceptMenu

# next we create a menubutton in this frame (.c3menubar) and call it
# .c3menubar.menu.  We also assign it some text - Concepts and 
# underline the letter C.

set m [	menu .c3menubar.menu.conceptMenu ]
# create an concept menu on the menubar .c3menubar.menu and add options to it

$m add cascade -label "1 - A Drawing Survival Kit" -menu $m.drawingMenu
set m1 [ menu $m.drawingMenu]
$m1 add command -label "1.1 - Window Clearing"\
-command {catch {exec kill $pid}
        killprocess c3Process	
	displaytext "$pothome/CHAP3/TEXT_FILES/WindowClear.txt"
        greentag .textdisplay 1.0 1.55
        redtag .textdisplay 3.0 3.55
        bluetag .textdisplay 6.0 6.55
        functag .textdisplay 21.0 22.55
        functag .textdisplay 27.13 27.22
        functag .textdisplay 40.13 40.32
        functag .textdisplay 55.12 55.21
        functag .textdisplay 56.0 56.55
}
$m1 add command -label "1.2 - Specifying a Color"\
-command {catch {exec kill $pid}
        killprocess c3Process	
	displaytext "$pothome/CHAP3/TEXT_FILES/SpecifyColor.txt"
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        functag .textdisplay 16.32 16.43

}

$m add separator
$m add cascade -label "2 - Points, Lines & Polygons." -menu $m.descrbMenu
set m2 [ menu $m.descrbMenu ]
$m2 add command -label "2.1 - Points & Lines" \
		-command { catch {exec kill $pid}
                          killprocess c3Process	
                          displaytext "$pothome/CHAP3/TEXT_FILES/Points.txt"
                          greentag .textdisplay 1.0 1.55
                          redtag .textdisplay 3.0 3.55
                          bluetag .textdisplay 6.0 6.55
                          bluetag .textdisplay 11.0 11.55
                          bluetag .textdisplay 18.0 18.55
 }

$m2 add command -label "2.2 - Polygons" \
		-command { catch {exec kill $pid}
                           killprocess c3Process	
                           set pid [ exec $pothome/CHAP3/PROG_FILES/Polygon & ]
                           procfile $pid c3Process
      	                   displaytext "$pothome/CHAP3/TEXT_FILES/Polygon.txt"
                           greentag .textdisplay 1.0 3.55
                           redtag .textdisplay 5.0 5.55
                           bluetag .textdisplay 8.0 8.55
                           bluetag .textdisplay 24.0 24.55 }
$m add separator
$m add cascade -label "3 - Drawing Primitives." -menu $m.drawMenu
set m3 [menu $m.drawMenu ]
$m3 add command -label "3.1 - Specifying Vertices" \
	        -command {catch {exec kill $pid}
                killprocess c3Process	
                displaytext "$pothome/CHAP3/TEXT_FILES/Vertices.txt"
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                functag .textdisplay 12.0 12.55
                bluetag .textdisplay 20.0 20.55 }
$m3 add separator
$m3 add cascade -label "3.2 - Primitives." -menu $m3.primitivesMenu
set m3a [ menu $m3.primitivesMenu]

$m3a add command -label "3.2a - GL_POINTS." \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/Points.tk & ]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/drawPoints.txt"
        greentag .textdisplay 1.0 1.55
        redtag .textdisplay 3.0 3.55
        bluetag .textdisplay 6.0 6.55
        bluetag .textdisplay 12.0 12.55
        functag .textdisplay 9.20 9.38
        functag .textdisplay 9.43 9.50 
 }
$m3a add command -label "3.2b - GL_LINES." \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/Lines.tk & ]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/Lines.txt"
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        bluetag .textdisplay 13.0 13.55
        bluetag .textdisplay 18.0 18.55
        functag .textdisplay 10.34 10.52
        functag .textdisplay 11.4 11.11


}
$m3a add command -label "3.2c - GL_LINE_STRIP." \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/LineStrip.tk & ]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/LineStrip.txt" 
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        functag .textdisplay 10.25 10.39
        functag .textdisplay 11.12 11.28
        functag .textdisplay 14.10 14.23
        bluetag .textdisplay 23.0 23.55 }

$m3a add command -label "3.2d - GL_LINE_LOOP." \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/LineLoop.tk & ]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/LineLoop.txt"
        greentag .textdisplay 1.0 1.55
        redtag .textdisplay 3.0 3.55
        bluetag .textdisplay 6.0 6.55
        functag .textdisplay 8.16 8.30
        functag .textdisplay 9.16 9.37 }
$m3a add command -label "3.2e - GL_TRIANGLES." \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/Triangles.tk & ]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/Triangles.txt"
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        functag .textdisplay 9.16 9.29
        functag .textdisplay 12.0 12.15
        bluetag .textdisplay 18.0 18.55  


}
$m3a add command -label "3.2f - GL_TRIANGLE_STRIP." \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/TriangleStrip.tk & ]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/TriangleStrip.txt"
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        functag .textdisplay 9.16 9.33
        functag .textdisplay 12.5 12.31

}
$m3a add command -label "3.2g - GL_TRIANGLE_FAN." \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/TriangleFan.tk & ]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/TriangleFan.txt"
        greentag .textdisplay 1.0 1.55
        redtag .textdisplay 3.0 3.55
        bluetag .textdisplay 6.0 6.55
        functag .textdisplay 8.16 8.31
        functag .textdisplay 10.8 10.25
        bluetag .textdisplay 14.0 14.55

}
$m3a add command -label "3.2h - GL_QUADS." \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/Quads.tk & ]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/Quads.txt"
        greentag .textdisplay 1.0 3.55
        redtag .textdisplay 5.0 5.55
        bluetag .textdisplay 8.0 8.55
        functag .textdisplay 10.16 10.24
        functag .textdisplay 11.10 11.27
        bluetag .textdisplay 17.0 17.55
}
$m3a add command -label "3.2i - GL_QUAD_STRIP." \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/QuadStrip.tk & ]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/QuadStrip.txt"
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        functag .textdisplay 9.16 9.29
        functag .textdisplay 12.10 12.32
        bluetag .textdisplay 17.0 17.55
}
$m3a add command -label "3.2j - GL_POLYGON." \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/Polyrender.tk & ]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/glPolygon.txt"
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        functag .textdisplay 9.16 9.27
        functag .textdisplay 10.0 10.55
        bluetag .textdisplay 19.0 19.55
        
}

$m add separator


$m add command -label "4 - Polygon Stippling."\
	-command { catch {exec kill $pid}
        killprocess c3Process	
        set pid [ exec $pothome/CHAP3/PROG_FILES/Stipple.tk &]
        procfile $pid c3Process
        displaytext "$pothome/CHAP3/TEXT_FILES/Stipple.txt"
        greentag .textdisplay 1.0 2.55
        redtag .textdisplay 4.0 4.55
        bluetag .textdisplay 7.0 7.55
        functag .textdisplay 12.25 12.38
        bluetag .textdisplay 35.0 35.55
}

$m add separator
$m add cascade -label "5 - Triangulation" -menu $m.triangulateMenu
set m4 [ menu $m.triangulateMenu ]
$m4 add command -label "5.1 - Theory" \
	-command {catch {exec kill $pid}
        killprocess c3Process	
        displaytext "$pothome/CHAP3/TEXT_FILES/Triangulate.txt"
        greentag .textdisplay 1.0 3.55
        redtag .textdisplay 5.0 5.55
        bluetag .textdisplay 8.0 8.55
        bluetag .textdisplay 15.0 15.55
        bluetag .textdisplay 55.0 55.55
}

$m4 add command -label "5.2 - A simple Example" \
	-command {catch {exec kill $pid}
                  killprocess c3Process	
                  set pid [exec $pothome/CHAP3/PROG_FILES/Annulus.tk & ]
               
                  procfile $pid c3Process
                  displaytext "$pothome/CHAP3/TEXT_FILES/Annulus.txt"
                  greentag .textdisplay 1.0 2.55
                  redtag .textdisplay 4.0 4.55
                  bluetag .textdisplay 7.0 7.55
                  bluetag .textdisplay 16.0 16.55
                  bluetag .textdisplay 24.0 24.55
                  functag .textdisplay 36.23 36.43
                  bluetag .textdisplay 38.0 38.55
                  functag .textdisplay 45.17 45.29
}

button .c3menubar.unpack -relief flat -text "Unpack" -underline 0 
		
button .c3menubar.pack -relief flat -text "Pack" -underline 0 



button .c3menubar.exit -relief flat -text "Exit" -underline 1 \
	-command {
		     catch { exec kill $pid }
                     killprocess c3Process	
		     catch { send main wm deiconify . }
		     exit}
pack .c3menubar.menu .c3menubar.unpack .c3menubar.pack .c3menubar.exit -side left

bind .c3menubar.unpack <1> {
set cwd [ pwd ]
cd $pothome/CHAP3/PROG_FILES
catch { exec make >& /dev/tty }
cd $cwd


}
bind .c3menubar.pack <1> {
set cwd [ pwd ]
cd $pothome/CHAP3/PROG_FILES
catch { exec make clean  >& /dev/tty }
cd $cwd
}



displaytext  "$pothome/CHAP3/TEXT_FILES/Main.txt" 
greentag .textdisplay 1.0 1.55
redtag .textdisplay 3.0 3.55
bluetag .textdisplay 12.0 14.55
bluetag .textdisplay 19.0 21.55
bluetag .textdisplay 25.0 26.55

#set $cmd {lappend pid_list [expr 1 * $pid]} 
#send Tutorial.tk {eval $cmd }
#send Tutorial.tk {lappend pid_list  [expr 1 * $pid] }
































































































