1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471
|
##########################################################################
# Default Priority for this panel
#
# priority is from 0 to 10
# the lower the number, the quicker it will be bumped
# 10 cannot be bumped
# Panels will be loaded by the greater of 5 or their current priority
##########################################################################
############################################################################
# procedure to make main control area
###########################################################################
# Alex Shevlakov sixote@yahoo.com 02/2000
# functions added to handle postgres queries
###########################################################################
global WhatsHere Nv
set WhatsHere(first) 1
# Globals to track what's here attributes
set Nv_(what_mapname) 1
set Nv_(what_easting) 1
set Nv_(what_northing) 1
set Nv_(what_elevation) 1
set Nv_(what_colorcat) 1
set Nv_(what_xydiff) 0
set Nv_(what_xyzdiff) 0
set Nv_(what_surfdist) 1
set Nv_(what_exagsurfdist) 1
set Nv_(what_vect) 1
set Nv_(what_pipe) 0
set Nv_(what_pipe_text) "Pipe to: None"
set Nv_(obj_qry_text) "Query map: None"
set Nv_(obj_qry) ""
proc mkqueryPanel { BASE } {
global WhatsHere
global Nv_
catch {destroy $BASE}
# Initialize panel info
if [catch {set Nv_($BASE)}] {
set panel [St_create {window name size priority} $BASE "What's Here?" 1 5]
} else {
set panel $Nv_($BASE)
}
frame $BASE -relief groove -borderwidth 2
Nv_mkPanelname $BASE "What's Here Panel"
# Create frame, buttons, and attributes menu
frame $BASE.bf
checkbutton $BASE.bf.what -text "What's Here?" -relief raised \
-command whats_here -variable WhatsHere(on)
button $BASE.bf.seperate -text Reset -command do_seperate
button $BASE.bf.clear -text Clear -command clear_text
menubutton $BASE.bf.atts -text Attributes -menu $BASE.bf.atts.m -relief raised
menu $BASE.bf.atts.m
pack $BASE.bf.clear $BASE.bf.seperate $BASE.bf.atts -side right -expand 1
pack $BASE.bf.what -side left
# Add menu entries for menu
set theMenu $BASE.bf.atts.m
foreach i {{"Map Name" "mapname" 0} {"Easting" "easting" 0} {"Northing" "northing" 0} \
{"Elevation" "elevation" 1} {"Color Category" "colorcat" 0} \
{"XY Dist from Prev" "xydiff" 0} \
{"XYZ Dist from Prev" "xyzdiff" 2} {"Dist Along Surface" "surfdist" 0} \
{"Dist Along Exag Surface" "exagsurfdist" 5} {"Postgres" "postgres" 1}} {
$theMenu add checkbutton -label [lindex $i 0] -underline [lindex $i 2]\
-offvalue 0 -onvalue 1 -variable Nv_(what_[lindex $i 1])
}
pack $BASE.bf -side top -fill x
# frame for close button and saving output to a file
frame $BASE.cf
button $BASE.cf.close -text Close -command "Nv_closePanel $BASE" -anchor s
button $BASE.cf.output -textvariable Nv_(what_pipe_text) \
-command "whats_pipe_bind $BASE"
pack $BASE.cf.close $BASE.cf.output -side right -padx 2
pack $BASE.cf.output -side left
pack $BASE.cf -side bottom -fill x
# frame for map button
frame $BASE.gf -relief groove -borderwidth 2
button $BASE.gf.vect_qry -textvariable Nv_(obj_qry_text) \
-command "whats_obj_bind $BASE"
pack $BASE.gf.vect_qry -side left
pack $BASE.gf -side bottom -fill x
text $BASE.text -wrap word -relief sunken -bd 2 \
-yscrollcommand "$BASE.yscroll set" \
-width 40 -height 10
set WhatsHere(text) $BASE.text
# scrollbar $BASE.xscroll -orient horizontal -relief flat
# -activebackground gray80 -command "$BASE.text view"
scrollbar $BASE.yscroll -orient vertical -relief flat \
-command "$BASE.text yview" -activebackground gray80
pack $BASE.yscroll -side right -fill y
# pack $BASE.xscroll -side bottom -fill x
pack $BASE.text -expand yes -fill both
return $panel
}
proc whats_pipe_bind {BASE} {
global Nv_
# Allow the user to set a file for piping the output
set new_file [create_file_browser .whats_file 1 0]
if {$new_file == -1} then return
set Nv_(what_pipe) $new_file
set Nv_(what_pipe_text) "Pipe to: $new_file"
}
proc whats_here {} {
global WhatsHere Nv_
if {$WhatsHere(on)} {
if {$Nv_(what_vect)} {
bind $Nv_(TOP).canvas <Button> {whats_here_vect %x %y }
} else {
bind $Nv_(TOP).canvas <Button> {whats_here_info %x %y }
}
} else {
bind $Nv_(TOP).canvas <Button> {}
}
}
proc whats_here_info {x y} {
global WhatsHere
global Nv_
set y [expr $Nv_(height) - $y]
#puts "DEBUG $x $y"
set text $WhatsHere(text)
set tot_out ""
set list [Nget_point_on_surf $x $y]
if {[llength $list] < 4} {
$text insert end "Point not on surface\n"
append tot_out "Point not on surface\n"
$text yview -pickplace end
return
}
set x [lindex $list 0]
set y [lindex $list 1]
set z [lindex $list 2]
set id [lindex $list 3]
if {$Nv_(what_easting)} then {
set str [format "\teasting: %15.4f\n" $x]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$Nv_(what_northing)} then {
set str [format "\tnorthing: %15.4f\n" $y]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$Nv_(what_elevation)} then {
set str [format "\televation: %15.4f\n" $z]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$Nv_(what_mapname)} then {
set str [Nget_map_name [string range $id 5 end] surf]
$text insert end "Topo: $str"
append tot_out "Topo: $str"
set str [Nget_cat_at_xy $id topo $x $y]
$text insert end "\t$str\n"
append tot_out "\t$str\n"
set str [Nget_val_at_xy $id topo $x $y]
$text insert end "\t$str\n"
append tot_out "\t$str\n"
$text yview -pickplace end
}
if {$Nv_(what_colorcat)} then {
set map_name [$id get_att color]
if {[lindex $map_name 0] == "map"} then {
set str [lindex $map_name 1]
} else {
set str "constant"
}
$text insert end "Color: $str"
append tot_out "Color: $str"
set str [Nget_cat_at_xy $id color $x $y]
$text insert end "\t$str\n"
append tot_out "\t$str\n"
set str [Nget_val_at_xy $id color $x $y]
$text insert end "\t$str\n"
append tot_out "\t$str\n"
$text yview -pickplace end
}
if {$WhatsHere(first) == 0} {
set px $WhatsHere(px)
set py $WhatsHere(py)
set pz $WhatsHere(pz)
### NO-NO Change to use lib functions for distance!
if {$Nv_(what_xydiff)} then {
set val [expr sqrt(($px-$x)*($px-$x)+($py-$y)*($py-$y))]
set str [format "xy distance from previous: %15.4f\n" $val]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$Nv_(what_xyzdiff)} then {
set val [expr sqrt(($px-$x)*($px-$x)+($py-$y)*($py-$y)+($pz-$z)*($pz-$z))]
set str [format "xyz distance from previous: %15.4f\n" $val]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$WhatsHere(pid) == $id} {
if {$Nv_(what_surfdist)} then {
set dist [Nget_dist_along_surf $id $x $y $px $py 0]
set str [format "distance along surface: %15.4f\n" $dist]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
Nset_draw front
Ndraw_line_on_surf $id $x $y $px $py
Nset_draw back
}
if {$Nv_(what_exagsurfdist)} then {
set dist [Nget_dist_along_surf $id $x $y $px $py 1]
set str [format "distance along exag. surface: %15.4f\n" $dist]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
Nset_draw front
Ndraw_line_on_surf $id $x $y $px $py
Nset_draw back
}
}
}
$text insert end "\n"
set WhatsHere(px) $x
set WhatsHere(py) $y
set WhatsHere(pz) $z
set WhatsHere(pid) $id
set WhatsHere(first) 0
Nset_draw front
Ndraw_X $id $x $y
Nset_draw back
if {$Nv_(what_pipe) != 0} {
set out_file [open $Nv_(what_pipe) a]
puts $out_file $tot_out
close $out_file
}
}
proc whats_obj_bind {BASE} {
global Nv_
set new [create_map_browser .fbrowse vect 1]
if {$new == -1} then return
set Nv_(obj_qry) $new
set Nv_(obj_qry_text) "Query map:$new"
}
proc whats_here_vect {x y} {
global WhatsHere
global Nv_
set y [expr $Nv_(height) - $y]
puts "DEBUG: $x $y $Nv_(obj_qry)"
set text $WhatsHere(text)
set tot_out ""
set list [Nget_point_on_surf_vect $x $y $Nv_(obj_qry)]
if {[llength $list] < 5} {
$text insert end "Point not on surface\n"
append tot_out "Point not on surface\n"
$text yview -pickplace end
return
}
set x [lindex $list 0]
set y [lindex $list 1]
set z [lindex $list 2]
set id [lindex $list 3]
set ls [lindex $list 4]
if {$Nv_(what_easting)} then {
set str [format "easting: %15.4f\n" $x]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$Nv_(what_northing)} then {
set str [format "northing: %15.4f\n" $y]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$Nv_(what_elevation)} then {
set str [format "elevation: %15.4f\n" $z]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$Nv_(what_vect)} then {
set str [format "Vector:\n%s\n" $ls]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$Nv_(what_mapname)} then {
set str [Nget_map_name [string range $id 5 end] surf]
$text insert end "Topo: $str"
append tot_out "Topo: $str"
set str [Nget_cat_at_xy $id topo $x $y]
$text insert end "\t$str\n"
append tot_out "\t$str\n"
set str [Nget_val_at_xy $id topo $x $y]
$text insert end "\t$str\n"
append tot_out "\t$str\n"
$text yview -pickplace end
}
if {$Nv_(what_colorcat)} then {
set map_name [$id get_att color]
if {[lindex $map_name 0] == "map"} then {
set str [lindex $map_name 1]
} else {
set str "constant"
}
$text insert end "Color: $str"
append tot_out "Color: $str"
set str [Nget_cat_at_xy $id color $x $y]
$text insert end "\t$str\n"
append tot_out "\t$str\n"
set str [Nget_val_at_xy $id color $x $y]
$text insert end "\t$str\n"
append tot_out "\t$str\n"
$text yview -pickplace end
}
if {$WhatsHere(first) == 0} {
set px $WhatsHere(px)
set py $WhatsHere(py)
set pz $WhatsHere(pz)
### NO-NO Change to use lib functions for distance!
if {$Nv_(what_xydiff)} then {
set val [expr sqrt(($px-$x)*($px-$x)+($py-$y)*($py-$y))]
set str [format "xy distance from previous: %15.4f\n" $val]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$Nv_(what_xyzdiff)} then {
set val [expr sqrt(($px-$x)*($px-$x)+($py-$y)*($py-$y)+($pz-$z)*($pz-$z))]
set str [format "xyz distance from previous: %15.4f\n" $val]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
}
if {$WhatsHere(pid) == $id} {
if {$Nv_(what_surfdist)} then {
set dist [Nget_dist_along_surf $id $x $y $px $py 0]
set str [format "distance along surface: %15.4f\n" $dist]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
Nset_draw front
Ndraw_line_on_surf $id $x $y $px $py
Nset_draw back
}
if {$Nv_(what_exagsurfdist)} then {
set dist [Nget_dist_along_surf $id $x $y $px $py 1]
set str [format "distance along exag. surface: %15.4f\n" $dist]
$text insert end "$str"
append tot_out "$str"
$text yview -pickplace end
Nset_draw front
Ndraw_line_on_surf $id $x $y $px $py
Nset_draw back
}
}
}
$text insert end "\n"
set WhatsHere(px) $x
set WhatsHere(py) $y
set WhatsHere(pz) $z
set WhatsHere(pid) $id
set WhatsHere(first) 0
Nset_draw front
Ndraw_X $id $x $y
Nset_draw back
if {$Nv_(what_pipe) != 0} {
set out_file [open $Nv_(what_pipe) a]
puts $out_file $tot_out
close $out_file
}
}
proc do_seperate {} {
global WhatsHere Nv_
set text $WhatsHere(text)
$text insert end "___________________________________\n"
$text yview -pickplace end
if {$Nv_(what_pipe) != 0} {
set out_file [open $Nv_(what_pipe) a]
puts $out_file "___________________________________"
close $out_file
}
set WhatsHere(first) 1
}
proc clear_text {} {
global WhatsHere
set text $WhatsHere(text)
$text delete 1.0 end
$text yview -pickplace end
}
|