Changeset 664
- Timestamp:
- Dec 4, 2009 5:09:57 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/browsecif.tcl
- Property rcs:date changed from 2002/09/24 20:49:58 to 2002/12/30 17:00:34
- Property rcs:lines changed from +8 -1 to +76 -20
- Property rcs:rev changed from 1.4 to 1.5
r654 r664 292 292 293 293 # tell'em what is happening 294 proc pleasewait {{message {}} } {294 proc pleasewait {{message {}} {statusvar {}} {parent .} {button ""}} { 295 295 catch {destroy .msg} 296 296 toplevel .msg 297 297 wm transient .msg [winfo toplevel .] 298 298 pack [frame .msg.f -bd 4 -relief groove] -padx 5 -pady 5 299 pack [message .msg.f.m -text "Please wait $message"] 299 pack [message .msg.f.m -text "Please wait $message"] -side top 300 if {$statusvar != ""} { 301 pack [label .msg.f.status -textvariable $statusvar] -side top 302 } 303 if {$button != ""} { 304 pack [button .msg.f.button -text [lindex $button 0] \ 305 -command [lindex $button 1]] -side top 306 } 300 307 wm withdraw .msg 301 308 update idletasks 302 # place the message on top of the mainwindow303 set x [expr [winfo x .] + [winfo width .]/2 - \304 [winfo reqwidth .msg]/2 - [winfo vrootx .]]309 # place the message on top of the parent window 310 set x [expr [winfo x $parent] + [winfo width $parent]/2 - \ 311 [winfo reqwidth .msg]/2 - [winfo vrootx $parent]] 305 312 if {$x < 0} {set x 0} 306 set y [expr [winfo y .] + [winfo height .]/2 - \307 [winfo reqheight .msg]/2 - [winfo vrooty .]]313 set y [expr [winfo y $parent] + [winfo height $parent]/2 - \ 314 [winfo reqheight .msg]/2 - [winfo vrooty $parent]] 308 315 if {$y < 0} {set y 0} 309 316 wm geom .msg +$x+$y … … 389 396 #------------------------------------------------------------------------------ 390 397 391 #------------------------------------------------------------------------------# ParseCIF reads and parses a CIF file putting the contents of 398 #------------------------------------------------------------------------------ 399 # ParseCIF reads and parses a CIF file putting the contents of 392 400 # each block into arrays block1, block2,... in the caller's level 393 401 # the name of the block is saved as blockN(data_) … … 431 439 } 432 440 441 # maximum size of file 442 set maxvalues 0 443 catch { 444 set maxvalues $CIF(maxvalues) 445 } 433 446 434 447 set CIF(undolist) {} … … 447 460 # loop over tokens 448 461 while {$EOF} { 462 if {$CIF(markcount) % 1000 == 0} { 463 $txt see $pos 464 set CIF(status) "($CIF(markcount) values read.)" 465 update 466 # are we over the limit? 467 if {$maxvalues > 0 && $CIF(markcount) > $maxvalues} { 468 donewait 469 set msg "Too many data values to parse; stopping at $CIF(markcount), line [lindex [split $pos .] 0].\n\nIf your computer has sufficient memory to read more, increase CIF(maxvalues) in cifedit.tcl" 470 set ans [MyMessageBox -parent . -title "CIF Too big" \ 471 -message $msg -icon error -type "{Stop Parsing}" \ 472 -default "stop parsing"] 473 474 return $blocks 475 } 476 } 449 477 # skip forward to the first non-blank character 450 set pos [$txt search -regexp {[^[:space:]]} $pos end]478 set npos [$txt search -regexp {[^[:space:]]} $pos end] 451 479 # is this the end? 452 if {$pos == ""} { 480 if {$npos == "" || \ 481 [lindex [split $npos .] 0] < [lindex [split $pos .] 0] } { 453 482 set EOF 0 454 483 break 484 } else { 485 set pos $npos 455 486 } 456 487 … … 463 494 # find end of token 464 495 set epos [$txt search -regexp {[[:space:]]} $pos "$pos lineend"] 465 if {$epos == ""} {set epos [$txt index "$pos lineend"]} 496 if {$epos == ""} { 497 set epos [$txt index "$pos lineend"] 498 } 466 499 467 500 set token [$txt get $pos $epos] … … 683 716 } 684 717 } 718 $txt see 1.0 685 719 return $blocks 686 720 } 687 721 688 #------------------------------------------------------------------------------# Create a CIF browser/editor 722 #------------------------------------------------------------------------------ 723 # Create a CIF browser/editor 689 724 # $txt is a text widget with the entire CIF loaded 690 725 # blocklist contains the list of defined blocks (by #) … … 695 730 toplevel $frame 696 731 wm title $frame "CIF Browser" 697 CIF BrowserWindow$frame732 CIFOpenBrowser $frame 698 733 CIFBrowser $txt $blocklist $selected $frame 699 734 grid [button $frame.c -text Close -command "destroy $frame"] -column 0 -row 1 … … 785 820 # (where $frame is a frame or toplevel) 786 821 # note that the BWidget package is required 787 proc CIF BrowserWindow{frame} {822 proc CIFOpenBrowser {frame} { 788 823 global CIF 789 824 if [catch {package require BWidget}] { … … 878 913 879 914 global CIF 880 set pointer [$CIF(tree) itemcget $name -data] 881 set dataname [lindex [$CIF(tree) itemcget $name -text] 0] 882 set CIF(lastShownTreeID) $name 883 showCIFbyDataname $pointer $dataname 915 # code to allow multiple selection within loops 916 #set loopname [lindex [$CIF(tree) itemcget $name -data] 1] 917 #set addtolist 1 918 #if {$loopname == "" || $loopname == "loop"} {set addtolist 0} 919 #foreach n $CIF(treeSelectedList) { 920 #if {$loopname != [lindex [$CIF(tree) itemcget $n -data] 1]} { 921 # set addtolist 0 922 # break 923 #} 924 #} 925 #if {$addtolist} { 926 #catch {$CIF(tree) itemconfigure $name -fill red} 927 #lappend CIF(treeSelectedList) $name 928 #} else { 929 foreach n $CIF(treeSelectedList) { 930 catch {$CIF(tree) itemconfigure $n -fill black} 931 } 932 set CIF(treeSelectedList) $name 933 catch {$CIF(tree) itemconfigure $name -fill red} 934 set CIF(lastShownTreeID) $name 935 set pointer [$CIF(tree) itemcget $name -data] 936 set dataname [lindex [$CIF(tree) itemcget $name -text] 0] 937 showCIFbyDataname $pointer $dataname 938 #} 884 939 } 885 940 … … 901 956 return 902 957 } 903 # create list of defined widgets958 # create list of widgets defined here 904 959 set CIF(widgetlist) {} 905 960 … … 1509 1564 # if this widget is a label, the info above will not be defined & checks are not needed 1510 1565 if {$dataname == ""} {return 0} 1566 if {$dataname == "errors"} {return 0} 1511 1567 1512 1568 global ${block}
Note: See TracChangeset
for help on using the changeset viewer.