#!/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
##############################################################################
# The following procedure creates a screen for chapter 1 of the tutorial.

wm title . "Chapter2 - The OGL View - This bird's view"
. configure -background white
createframe .c2menubar 2 
# call procedure createframe and create a frame for the menus available
# in chapter2. we call this menu frame .c2menubar 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 .c2menubar.menu -text "Concepts" -underline 0 \
-menu .c2menubar.menu.conceptMenu

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

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

$m add cascade -label "1 - Modelling Trans." -menu $m.modelMenu
set m2 [ menu $m.modelMenu ]

$m2 add command -label "1.1 - Translation" \
	         -command {catch {exec kill $pid}
                 killprocess c2Process
		 set pid [ exec $pothome/CHAP2/PROG_FILES/Translate.tk &]
                 procfile $pid c2Process
		 displaytext "$pothome/CHAP2/TEXT_FILES/Translate.txt"
		 greentag .textdisplay 1.0 1.55
		 redtag .textdisplay 3.0 3.55
		 bluetag .textdisplay 6.0 6.55
		 functag .textdisplay 8.26 8.48
		 bluetag .textdisplay 13.0 13.55
		 
		  }
$m2 add separator
$m2 add command -label "1.2 - Multiple Translations" \
	         -command {catch {exec kill $pid}
                 killprocess c2Process
		 set pid [ exec $pothome/CHAP2/PROG_FILES/MultTranslate.tk &]
		 procfile $pid c2Process
                 displaytext "$pothome/CHAP2/TEXT_FILES/MultTranslate.txt"
		 greentag .textdisplay 1.0 1.55
		 redtag .textdisplay 3.0 3.55
		 bluetag .textdisplay 6.0 6.55
		 functag .textdisplay 8.11 8.33
		 bluetag .textdisplay 11.0 11.55
		 
		  }
$m2 add separator
$m2 add command -label "1.3 - Translating Multiple Objects" \
	         -command {catch {exec kill $pid}
                 killprocess c2Process
		 set pid [ exec $pothome/CHAP2/PROG_FILES/MultObjTrans.tk &]
		 procfile $pid c2Process
                 displaytext "$pothome/CHAP2/TEXT_FILES/MultObjTrans.txt"
		 greentag .textdisplay 1.0 2.55
		 redtag .textdisplay 4.0 4.55
		 bluetag .textdisplay 7.0 7.55
		 functag .textdisplay 9.11 9.33
		 bluetag .textdisplay 14.0 14.55
		 
		  }


$m2 add separator

$m2 add command -label "1.4 - Of Pushes and Pops" \
	         -command {catch {exec kill $pid}
                 killprocess c2Process
		 set pid [ exec $pothome/CHAP2/PROG_FILES/PushPop.tk &]
		 procfile $pid c2Process
                 displaytext "$pothome/CHAP2/TEXT_FILES/PushPop.txt"
		 greentag .textdisplay 1.0 2.55
		 redtag .textdisplay 4.0 4.55
		 bluetag .textdisplay 7.0 7.55
		 functag .textdisplay 24.0 24.13
                 functag .textdisplay 24.19 24.33
                 functag .textdisplay 25.16 25.32
                 functag .textdisplay 27.0 27.13
                 functag .textdisplay 28.10 28.25
                 functag .textdisplay 29.4 29.17
		 bluetag .textdisplay 31.0 31.55
                 functag .textdisplay 34.33 34.49
                 functag .textdisplay 35.34 35.47
		 
		  
}
$m2 add separator
$m2 add command -label "1.5 - Rotation" \
	-command {catch {exec kill $pid}
                 killprocess c2Process
		 set pid [ exec $pothome/CHAP2/PROG_FILES/Rotate.tk &]
		 procfile $pid c2Process
                 displaytext "$pothome/CHAP2/TEXT_FILES/Rotate.txt"
		 greentag .textdisplay 1.0 2.55
		 redtag .textdisplay 4.0 4.55
		 bluetag .textdisplay 7.0 7.55
		 functag .textdisplay 9.0 9.25
		 bluetag .textdisplay 20.0 20.55
		 bluetag .textdisplay 26.0 26.55
		 functag .textdisplay 30.15 30.48
}
$m2 add separator
$m2 add command -label "1.6 - Combining Trans. & Rot."\
	         -command {catch {exec kill $pid}
                 killprocess c2Process
		 set pid [ exec $pothome/CHAP2/PROG_FILES/Combine.tk &]
		 procfile $pid c2Process
                 displaytext "$pothome/CHAP2/TEXT_FILES/Combine.txt"
		 greentag .textdisplay 1.0 3.55
		 redtag .textdisplay 5.0 5.55
		 bluetag .textdisplay 8.0 8.55
		 functag .textdisplay 12.15 12.46
		 bluetag .textdisplay 15.0 15.55
		 functag .textdisplay 17.25 17.39
		 functag .textdisplay 18.0 18.15
}

$m2 add separator
$m2 add command -label "1.7 - Order of Transformations I" \
                  -command {catch {exec kill $pid}
                  killprocess c2Process
		  set pid [exec $pothome/CHAP2/PROG_FILES/Order.tk & ]
		  procfile $pid c2Process
                  displaytext "$pothome/CHAP2/TEXT_FILES/Order.txt" 
		  greentag .textdisplay 1.0 2.55
		  redtag .textdisplay 3.0 3.55
		  bluetag .textdisplay 6.0 6.55
		  bluetag .textdisplay 13.0 13.55
		  bluetag .textdisplay 25.0 25.55
		  bluetag .textdisplay 30.0 30.55
		 }


$m2 add separator
$m2 add command -label "1.8 - Order of Transformations II" \
	        -command {catch {exec kill $pid}
                killprocess c2Process
		set pid [exec $pothome/CHAP2/PROG_FILES/TRexample.tk & ]
		procfile $pid c2Process
                displaytext "$pothome/CHAP2/TEXT_FILES/TRexample.txt" 
		greentag .textdisplay 1.0 2.55
		redtag .textdisplay 4.0 4.55
		redtag .textdisplay 5.0 5.55
		bluetag .textdisplay 8.0 8.55
		bluetag .textdisplay 35.0 35.55
		 }

$m2 add separator
$m2 add command -label "1.9 - Proof of The Pudding - Eat It!"\
                -command {catch { exec kill $pid}
                killprocess c2Process
                set pid [exec $pothome/CHAP2/PROG_FILES/Store.tk & ]
                procfile $pid c2Process
                displaytext "$pothome/CHAP2/TEXT_FILES/Store.txt "
                greentag .textdisplay 1.0 2.55
                redtag .textdisplay 4.0 4.55
                bluetag .textdisplay 7.0 7.55
                bluetag .textdisplay 14.0 14.55


}


$m2 add separator
$m2 add command -label "1.10 Scaling" \
		-command { catch {exec kill $pid}
                killprocess c2Process
		set pid [ exec $pothome/CHAP2/PROG_FILES/Scale.tk & ]
		procfile $pid c2Process
                displaytext "$pothome/CHAP2/TEXT_FILES/Scale.txt" 
		greentag .textdisplay 1.0 2.55
		redtag .textdisplay 4.0 4.55
		bluetag .textdisplay 7.0 7.55
		functag .textdisplay 9.27 9.44
		bluetag .textdisplay 13.0 13.55
		bluetag .textdisplay 19.0 19.55             
}  
$m2 add separator


$m2 add command -label "1.11 - Theory of Transformations" \
	-command {catch {exec kill $pid}
                 killprocess c2Process
		 set pid [ exec $pothome/CHAP2/PROG_FILES/ModelTheory.tk & ] 
		 displaytext "$pothome/CHAP2/TEXT_FILES/ModelTheory.txt"
		 procfile $pid c2Process
                 greentag .textdisplay 1.0 2.55
		 redtag .textdisplay 4.0 4.55
		 bluetag .textdisplay 7.0 7.55
		 functag .textdisplay 15.0 15.26
		 functag .textdisplay 17.20 17.48
		 functag .textdisplay 19.11 19.27
                 bluetag .textdisplay 26.0 26.55
		 functag .textdisplay 35.0 35.30 
		  }
$m2 add separator
$m2 add command -label "1.12 - Specifying Matrices" \
	-command {catch {exec kill $pid}
                 killprocess c2Process
		 set pid [ exec $pothome/CHAP2/PROG_FILES/OwnMatrix.tk & ] 
		 procfile $pid c2Process
                 displaytext "$pothome/CHAP2/TEXT_FILES/OwnMatrix.txt"
		 greentag .textdisplay 1.0 2.55
		 redtag .textdisplay 4.0 4.55
		 bluetag .textdisplay 7.0 7.55
		 bluetag .textdisplay 14.0 14.55
		 bluetag .textdisplay 67.0 67.55
		 bluetag .textdisplay 93.0 93.55
}
$m2 add separator

$m2 add command -label "1.13 - Animation - A Detour" \
	-command {catch {exec kill $pid}
        killprocess c2Process
	set pid [ exec $pothome/CHAP2/PROG_FILES/animation.tk &]
        procfile $pid c2Process
	displaytext "$pothome/CHAP2/TEXT_FILES/animation.txt"
	greentag .textdisplay 1.0 2.55
	redtag .textdisplay 4.0 4.55
	bluetag .textdisplay 7.0 7.55
	bluetag .textdisplay 14.0 14.55
	functag .textdisplay 23.0 23.36
	functag .textdisplay 25.8 25.27

	bluetag .textdisplay 31.0 31.55
	functag .textdisplay 35.13 35.32
	bluetag .textdisplay 40.0 40.55
	functag .textdisplay 45.37 45.51
	functag .textdisplay 46.29 46.43
}
$m2 add separator
$m2 add command -label "1.14 - A Rotation Around the Sun" \
		-command {catch {exec kill $pid}
	        killprocess c2Process
        	set pid [exec $pothome/CHAP2/PROG_FILES/Solar.tk &]
        	procfile $pid c2Process
        	displaytext "$pothome/CHAP2/TEXT_FILES/Solar.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 19.0 19.55
		greentag .textdisplay 21.0 21.55
		    }
$m2 add separator
$m2 add command -label "1.15 - The Magic box" \
	          -command { catch {exec kill $pid}
                  killprocess c2Process
	          set pid [exec $pothome/CHAP2/PROG_FILES/Magicbox.tk &]
		  procfile $pid c2Process
                  displaytext "$pothome/CHAP2/TEXT_FILES/Magicbox.txt"
		  greentag .textdisplay 1.0 2.55
		  redtag .textdisplay 4.0 4.55
		  bluetag .textdisplay 7.0 7.55
		  bluetag .textdisplay 15.0 15.55
		  bluetag .textdisplay 48.0 48.55
}
	       
$m add separator
$m add cascade -label "2 - To see and be seen!" -menu $m.lookMenu
set m3 [ menu $m.lookMenu ]
$m3 add command -label "2.1 - A look at gluLookAt"\
                     -command { catch {exec kill $pid}
                     killprocess c2Process
	             set pid [ exec $pothome/CHAP2/PROG_FILES/Prog1.tk & ]
		     procfile $pid c2Process
                     displaytext "$pothome/CHAP2/TEXT_FILES/Prog1.txt"
		     greentag .textdisplay 1.0 2.55
		     redtag .textdisplay 4.0 4.55
		     bluetag .textdisplay 7.0 7.55
		     functag .textdisplay 11.0 12.55
		     bluetag .textdisplay 21.0 21.55
		     bluetag .textdisplay 41.0 41.55
		     bluetag .textdisplay 53.0 53.55
}
$m3 add separator
$m3 add command -label "2.2 - gluLookAt Transformed"\
           -command { catch {exec kill $pid}
           killprocess c2Process
	   set pid [ exec $pothome/CHAP2/PROG_FILES/Prog1a.tk & ]
           procfile $pid c2Process
           displaytext "$pothome/CHAP2/TEXT_FILES/Prog1a.txt"
	   greentag .textdisplay 1.0 3.55
	   redtag .textdisplay 5.0 5.55
	   bluetag .textdisplay 8.0 8.55
	   bluetag .textdisplay 18.0 18.55
	   bluetag .textdisplay 38.0 38.55
	   bluetag .textdisplay 44.0 44.55    
}
    
$m add separator
$m add cascade -label "3 - Projection Trans." -menu $m.projectionMenu
set m2 [ menu $m.projectionMenu ]
$m2 add command -label "3.1 - Frustrating Frustum" \
		-command { catch {exec kill $pid}
                killprocess c2Process
		set pid [ exec $pothome/CHAP2/PROG_FILES/Frustumintro & ]
                procfile $pid c2Process
                displaytext "$pothome/CHAP2/TEXT_FILES/Frustumintro.txt" 
		greentag .textdisplay 1.0 2.55
		redtag .textdisplay 4.0 4.55
		functag .textdisplay 20.0 20.55
		bluetag .textdisplay 7.0 7.55
}
$m2 add separator
$m2 add command -label "3.2 - ForeShortening" \
		-command { catch {exec kill $pid}
                killprocess c2Process		
	        displaytext "$pothome/CHAP2/TEXT_FILES/Foreshort.txt" 
		greentag .textdisplay 1.0 1.55
		redtag .textdisplay 3.0 3.55
} 
$m2 add separator
$m2 add command -label "3.3 - Perspective" \
		-command { catch {exec kill $pid}
                killprocess c2Process	
	        set pid [ exec $pothome/CHAP2/PROG_FILES/Frustum.tk & ]
	        procfile $pid c2Process
		displaytext "$pothome/CHAP2/TEXT_FILES/Frustum.txt"
		greentag .textdisplay 1.0 1.55
		redtag .textdisplay 3.0 4.55
		bluetag .textdisplay 7.0 7.55
		bluetag .textdisplay 17.0 17.55
		bluetag .textdisplay 32.0 32.55
		bluetag .textdisplay 49.0 49.55
                functag .textdisplay 11.0 11.27
                functag .textdisplay 12.0 12.11
                functag .textdisplay 52.0 52.16
                functag .textdisplay 53.0 53.11
                functag .textdisplay 55.0 55.42
                bluetag .textdisplay 60.0 60.55

 }

$m2 add separator

$m2 add command -label "3.4 - Orthographic " \
                -command { catch {exec kill $pid}
                killprocess c2Process                
                set pid [exec $pothome/CHAP2/PROG_FILES/Ortho.tk &]
                procfile $pid c2Process
                displaytext "$pothome/CHAP2/TEXT_FILES/Ortho.txt"
                greentag .textdisplay 1.0 3.55
		redtag .textdisplay 5.0 5.55
		bluetag .textdisplay 8.0 8.55
		bluetag .textdisplay 25.0 25.55
		functag .textdisplay 10.0 10.9
		functag .textdisplay 15.0 15.55
}
$m2 add separator
$m2 add command -label "3.5 - Orthographic vs. Perspective" \
		-command { catch {exec kill $pid}
                killprocess c2Process
                set pid [ exec $pothome/CHAP2/PROG_FILES/Orthographic.tk & ]
                procfile $pid c2Process
		displaytext "$pothome/CHAP2/TEXT_FILES/Orthographic.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 19.0 19.55
		
 }
$m add separator
$m add command -label "4 - Viewport Trans."\
	           -command { catch {exec kill $pid}
                   killprocess c2Process		
                   set pid [ exec $pothome/CHAP2/PROG_FILES/Viewport.tk &]
                   procfile $pid c2Process
		   displaytext "$pothome/CHAP2/TEXT_FILES/Viewport.txt"
		   greentag .textdisplay 1.0 2.55
		   redtag .textdisplay 4.0 4.55
		   bluetag .textdisplay 7.0 7.55
                   bluetag .textdisplay 13.0 13.36
		   bluetag .textdisplay 19.0 19.36
		  
}

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

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

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


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



displaytext  "$pothome/CHAP2/TEXT_FILES/Main.txt" 
greentag .textdisplay 1.0 2.55
redtag .textdisplay 4.0 4.55
bluetag .textdisplay 15.6 15.55
functag .textdisplay 17.6 17.55
functag .textdisplay 18.6 18.55
functag .textdisplay 19.6 19.55
bluetag .textdisplay 21.6 21.55
functag .textdisplay 23.6 23.55
bluetag .textdisplay 25.6 25.55
functag .textdisplay 28.0 28.55
functag .textdisplay 29.0 29.55
functag .textdisplay 32.0 32.55
bluetag .textdisplay 34.6 34.55
functag .textdisplay 36.6 36.55
#set $cmd {lappend pid_list [expr 1 * $pid]} 
#send Tutorial.tk {eval $cmd }
#send Tutorial.tk {lappend pid_list  [expr 1 * $pid] }
































































































