# # Copyright 2003 (c) Pointwise, Inc. # All rights reserved. # # This sample Gridgen script is not supported by Pointwise, Inc. # It is provided freely for demonstration purposes only. # SEE THE WARRANTY DISCLAIMER AT THE BOTTOM OF THIS FILE. # gg::tkLoad catch { set scriptDir [file dirname [info script]] set logoFile [file join $scriptDir pwiLogo.glf] source $logoFile } #Set the defaults for the boxes set t [gg::dispViewCenter] set orix [lindex $t 0] set oriy [lindex $t 1] set oriz [lindex $t 2] set lastx $orix set lasty $oriy set lastz $oriz set x [lindex $t 0] set y [lindex $t 1] set z [lindex $t 2] proc setStatus {} { global x y z catch { if { [string is double $x] != 1 } { .inputs.x.entx configure -background "#FFCCCC" } else { .inputs.x.entx configure -background "#FFFFFF" } if { [string is double $y] != 1 } { .inputs.y.enty configure -background "#FFCCCC" } else { .inputs.y.enty configure -background "#FFFFFF" } if { [string is double $z] != 1 } { .inputs.z.entz configure -background "#FFCCCC" } else { .inputs.z.entz configure -background "#FFFFFF" } set bool [expr [expr [string is double $x]==1]&&[expr [string is double $y]==1]&&[expr [string is double $z]==1]] if [ expr $bool==1 ] { .commands.go configure -state normal } else { .commands.go configure -state disabled if { [string is double $x] != 1 } { focus .inputs.x.entx; return 0; } if { [string is double $y] != 1 } { focus .inputs.y.enty; return 0; } if { [string is double $z] != 1 } { focus .inputs.z.entz; return 0; } } } } #Function to set the current view position proc orient { x y z } { global orix oriy oriz if [ expr [string compare "$x" ""]==0 ] { set tx $orix } else { set tx $x } if [ expr [string compare "$y" ""]==0 ] { set ty $oriy } else { set ty $y } if [ expr [string compare "$z" ""]==0 ] { set tz $oriz } else { set tz $z } if { [string is double $x] != 1 } { focus .inputs.x.entx; return 0 } if { [string is double $y] != 1 } { focus .inputs.y.enty; return 0 } if { [string is double $z] != 1 } { focus .inputs.z.entz; return 0 } gg::dispViewCenter "$tx $ty $tz" } #Will re-orient if the values are the same proc updateConditional { value box } { if [ expr [string compare [focus] .inputs.$box.ent$box]==0 ] { global x y z set cond "\$$box==$value" catch { if { [expr "$cond"] } { orient $x $y $z } } } } #Function to make the TK interface proc makeWindow {} { global x y z label .title -text "Type In Rotation Point" set font [.title cget -font] .title configure -font [font create -family [font actual $font -family] -weight bold] pack .title -expand 1 -side top frame .hr1 -bd 1 -height 2 -relief sunken pack .hr1 -side top -fill x -expand 0 -pady 2 frame .inputs foreach t {x y z} { frame .inputs.$t label .inputs.$t.lbl$t -text "$t:" entry .inputs.$t.ent$t -textvariable $t -width 7 -validate focusout -validatecommand { if [ expr [string is double %P]!=1 ] { orient $x $y $z; return 1; }; return 0; } -invcmd { focus %W; bell; after idle {%W config -validate focusout}; } pack .inputs.$t.lbl$t -side left -expand 0 -padx 4 pack .inputs.$t.ent$t -side right -expand 0 -padx 4 pack .inputs.$t -pady 3 -padx 5 -side left bind .inputs.$t.ent$t { orient $x $y $z } } pack .inputs -fill x button .inputs.restore -text "Reset" -command { set x $lastx; set y $lasty; set z $lastz; orient $x $y $z; focus .inputs.x.entx; .inputs.x.entx selection range 0 100; } pack .inputs.restore -side right -padx 3 frame .commands button .commands.apply -text "Apply" -command { set lastx $x; set lasty $y; set lastz $z; orient $x $y $z; focus .inputs.x.entx } button .commands.go -text "OK" -command { orient $x $y $z; exit } button .commands.exit -text "Cancel" -command { orient $orix $oriy $oriz; exit } frame .hr2 -bd 1 -height 2 -relief sunken pack .hr2 -side top -fill x -expand 0 -pady 2 if {![catch {pwiLogoCreate .commands.logo 1} b]} { $b configure -bd 0 -relief flat pack $b -side left -padx 5 -fill y } pack .commands -fill x -side bottom pack .commands.apply .commands.exit .commands.go -padx 2 -pady 1 -side right bind .commands.go { orient $x $y $z; exit } bind .commands.apply { orient $x $y $z; focus .inputs.x.entx } bind .commands.exit { orient $orix $oriy $oriz; exit } bind .inputs.restore { set x $orix; set y $oriy; set z $oriz; orient $x $y $z; focus .inputs.x.entx; .inputs.x.entx selection range 0 100; } bind .inputs.x.entx { if { [string is double $x] != 1 } { setStatus } else { setStatus; after 500 updateConditional \"$x\" x } } bind .inputs.y.enty { if { [string is double $y] != 1 } { setStatus } else { setStatus; after 500 updateConditional \"$y\" y } } bind .inputs.z.entz { if { [string is double $z] != 1 } { setStatus } else { setStatus; after 500 updateConditional \"$z\" z } } bind .inputs.x.entx { .inputs.x.entx selection range 0 100; if { [string is double $x] != 1 } { setStatus } } bind .inputs.y.enty { .inputs.y.enty selection range 0 100; if { [string is double $y] != 1 } { setStatus } } bind .inputs.z.entz { .inputs.z.entz selection range 0 100; if { [string is double $z] != 1 } { setStatus } } } makeWindow focus .inputs.x.entx gg::tkLoop # # DISCLAIMER: # TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, POINTWISE DISCLAIMS # ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED # TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR # PURPOSE, WITH REGARD TO THIS SCRIPT. TO THE MAXIMUM EXTENT PERMITTED # BY APPLICABLE LAW, IN NO EVENT SHALL POINTWISE BE LIABLE TO ANY PARTY # FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES # WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF # BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE # USE OF OR INABILITY TO USE THIS SCRIPT EVEN IF POINTWISE HAS BEEN # ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND REGARDLESS OF THE # FAULT OR NEGLIGENCE OF POINTWISE. #