stressui 6.66 KB
#!/usr/IRIXpro/bin/wishx -f
#
#  User interface for stress application
#
#
wm title . "Stress Control"


#
# This procedure is invoked whenever a mode word changes.
# The t variable indicates whether trap has been selected or not.
# The modes are sent to the application running on the R4300
# via driverd.
#
proc varChanged {t args} {
  global  enDither  enAA 
  global  enTexBilerp enTexPersp enBFcull  
  global  scene
  global  mountains pool orb clock altimeter

  set mode $enAA
  set mode [expr $mode | [expr $enBFcull << 1]]
  set mode [expr $mode | [expr $enDither << 2]]
  set mode [expr $mode | [expr $enTexBilerp << 3]]
  set mode [expr $mode | [expr $enTexPersp << 4]]

  set display $mountains
  set display [expr $display | [expr $pool << 1]]
  set display [expr $display | [expr $orb << 2]]
  set display [expr $display | [expr $clock << 3]]
  set display [expr $display | [expr $altimeter << 4]]

  StressTclMode $t $mode $scene $display
}

proc scenechanged {t args} {
  set_fly  
  varChanged "0"
}

proc do_trap { } {
    set traps 1
    catch {destroy .dialog}
    toplevel .dialog -class Dialog
    wm title .dialog "Trap"
    wm iconname .dialog Dialog
    frame .dialog.top -relief raised -bd 1
    pack .dialog.top -side top -fill both
    frame .dialog.bot -relief raised -bd 1
    pack .dialog.bot -side bottom -fill both

    label .dialog.msg -text "Enter number of frames to trap: "
    entry .dialog.entry -width 5 -relief sunken -bd 2
    .dialog.entry insert 0 "1"
    bind .dialog.entry <Return> { set traps [.dialog.entry get] }
    button .dialog.done -text "Apply" -command "set traps [.dialog.entry get]"
    pack .dialog.msg .dialog.entry -side left -in .dialog.top
    pack .dialog.done -fill x -in .dialog.bot

    set oldFocus [focus]
    grab .dialog 
    tkwait variable traps

    varChanged $traps
    focus $oldFocus
    destroy .dialog 
}

#-------------------------------------------------------
#   Set up the main window and menu.
# 
# 
#-------------------------------------------------------

frame .menu -relief raised -borderwidth 1
message .msg -font -Adobe-times-medium-r-normal--*-100* -relief raised -width 300 \
  -borderwidth 1 \
  -text "This window controls top-level attributes for the stress\
 application.  The Modes menu\
 contains switches for turning attributes on and off.  To run a frame\
 through the RSP simulator and dump files to run through the RDP\
 simulator, select 'trap' under the File menu.


 To exit this application, select 'quit' under the File menu." 

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

#-------------------------------------------------------
# The code below creates all the menus
#-------------------------------------------------------

menubutton .menu.file -text "File" -menu .menu.file.m -underline 0
menu .menu.file.m
.menu.file.m add command -label "Trap" -command {do_trap}
.menu.file.m add command -label "Quit" -command "destroy ."

set enAA 	1
set enDither 	1
set enBFcull 	1
set enTexBilerp	1
set enTexPersp 	1

menubutton .menu.modes -text "Modes" -menu .menu.modes.m -underline 0
menu .menu.modes.m
.menu.modes.m add check -label "Anti-Alias En" -variable enAA
.menu.modes.m add check -label "Cull Backfaces" -variable enBFcull
.menu.modes.m add check -label "Dither En" -variable enDither
.menu.modes.m add check -label "Texture Bilerp En" -variable enTexBilerp
.menu.modes.m add check -label "Texture Persp En" -variable enTexPersp

set scene 0
menubutton .menu.pos -text "Position" -menu .menu.pos.m -underline 0
menu .menu.pos.m
.menu.pos.m add radiobutton -label "Scene 0" -variable scene -value 0
.menu.pos.m add radiobutton -label "Scene 1" -variable scene -value 1
.menu.pos.m add radiobutton -label "Scene 2" -variable scene -value 2
.menu.pos.m add radiobutton -label "Scene 3" -variable scene -value 3
.menu.pos.m add radiobutton -label "Scene 4" -variable scene -value 4

set mountains 1
set pool 1
set orb 1
set clock 1
set altimeter 1
menubutton .menu.disp -text "Display" -menu .menu.disp.m -underline 0
menu .menu.disp.m
.menu.disp.m add check -label "Mountains" -variable mountains -command {varChanged "0"}
.menu.disp.m add check -label "Pool" -variable pool -command {varChanged "0"}
.menu.disp.m add check -label "Orb" -variable orb -command {varChanged "0"}
.menu.disp.m add check -label "Clock" -variable clock -command {varChanged "0"}
.menu.disp.m add check -label "Altimeter" -variable altimeter -command {varChanged "0"}

set enTexture 1
set enTexPersp 1
set enBFcull 1
set enShade 1
set enZbuf 1

trace variable enTexture "w" {varChanged "0"}
trace variable enTexPersp "w" {varChanged "0"}
trace variable enBFcull "w" {varChanged "0"}
trace variable enShade "w" {varChanged "0"}
trace variable enZbuf "w" {varChanged "0"}
trace variable scene "w" {scenechanged "0"}
trace variable enAA "w" {varChanged "0"}
trace variable enDither "w" {varChanged "0"}
trace variable enBFcull "w" {varChanged "0"}
trace variable enTexBilerp "w" {varChanged "0"}
trace variable enTexPersp "w" {varChanged "0"}

pack .menu.file .menu.modes .menu.pos .menu.disp -side left
tk_menuBar .menu .menu.file .menu.modes .menu.pos .menu.disp


#-------------------------------------------------------
# Create flying controls
#-------------------------------------------------------
scale .velocity -label "Velocity" -from -100 -to 100 \
	-orient horiz -command update_vel -showvalue true
scale .roll -label "Roll" -from -180 -to 180 \
	-orient horiz -command update_roll -showvalue true
scale .pitch -label "Pitch" -from -180 -to 180 \
	-orient horiz -command update_pitch -showvalue true
scale .yaw -label "Yaw" -from -180 -to 180 \
	-orient horiz -command update_yaw -showvalue true
button .flyreset -text "Reset controls" -command set_fly -foreground red

pack .flyreset .yaw .pitch .roll .velocity -side bottom -fill x

proc set_fly { } {
  global velocity roll pitch yaw
  set velocity 0
  set roll 0
  set pitch 0
  set yaw 0
  .velocity set $velocity
  .roll set $roll
  .pitch set $pitch
  .yaw set $yaw
}

proc update_vel { vel } {
  global velocity roll pitch yaw
  set velocity $vel
  StressTclFly $velocity $roll $pitch $yaw
}

proc update_roll { r } {
  global velocity roll pitch yaw
  set roll $r
  StressTclFly $velocity $roll $pitch $yaw
}

proc update_pitch { p } {
  global velocity roll pitch yaw
  set pitch $p
  StressTclFly $velocity $roll $pitch $yaw
}

proc update_yaw { y } {
  global velocity roll pitch yaw
  set yaw $y
  StressTclFly $velocity $roll $pitch $yaw
}


#-------------------------------------------------------
# Open library for talking to hardware
#-------------------------------------------------------
set stressdso [lindex $argv 0]
dlopen $stressdso init StressTclInit
StressTclConnect [lindex $argv 1] [lindex $argv 2]
set_fly