Bsoft  1.9
Bernard's software package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AppMain.tcl
Go to the documentation of this file.
1 #!/bin/sh
2 # the next line restarts using wish \
3 exec wish "$0" "$@" -visual "truecolor 24"
4 
5 #----------------------------------------------------------------
6 # bshow - An image display script
7 #
8 # Bernard Heymann 19990723 - 20030816
9 #----------------------------------------------------------------
10 
11 set debug(enabled) 1
12 set font12 {Helvetica 12}
13 set font12 {-*-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-*}
14 set font14 {Helvetica 14}
15 eval destroy [winfo child .]
16 wm title . "Bshow"
17 wm minsize . 200 200
18 menu .menuBar -tearoff 0
19 
20 #----------------------------------------------------------------
21 # Interpreting the arguments - only file name input supported
22 # The conditional is to work around a Tru64 oddity when no file name is given
23 #----------------------------------------------------------------
24 set filename $argv
25 if { $filename == "{}" } {
26  set filename ""
27 }
28 if { [string match -* $filename] } {
29  set filename ""
30 }
31 set imgdir [pwd]
32 if { [string length $filename] > 0 } {
33  set imgdir [file dirname $filename]
34 }
35 
36 #----------------------------------------------------------------
37 # The path to the source code and libraries
38 #----------------------------------------------------------------
39 set Bsoft [exec printenv BSOFT]
40 if { [string length $Bsoft] < 2 } {
41  set Bsoft /usr/local/bsoft
42 }
43 set bshow_script $Bsoft/tcltk
44 set bshow_lib $Bsoft/lib
45 
46 #----------------------------------------------------------------
47 # The help file
48 #----------------------------------------------------------------
49 set helpfile "$bshow_script/bshow.hlp"
50 
51 #----------------------------------------------------------------
52 # Loading required shared object libraries
53 #----------------------------------------------------------------
54 load $bshow_lib/libbsoft.so Bsoft_tcl
55 load $bshow_lib/tcltk_bimage.so Bimage
56 load $bshow_lib/tcltk_bmg.so Bmg
57 
58 #----------------------------------------------------------------
59 # Loading procedures in other script files
60 #----------------------------------------------------------------
61 source $bshow_script/bshow_file.tcl
62 source $bshow_script/bshow_param.tcl
63 source $bshow_script/bshow_scales.tcl
64 source $bshow_script/bshow_markers.tcl
65 source $bshow_script/bshow_boxes.tcl
66 source $bshow_script/bshow_filament.tcl
67 source $bshow_script/bshow_ctf.tcl
68 source $bshow_script/bshow_tomo.tcl
69 source $bshow_script/bshow_misc.tcl
70 
71 # aboutBox
72 #
73 # Pops up a message box with an "about" message
74 #
75 proc aboutBox {} {
76  tk_messageBox -icon info -type ok -title "About bshow" -message \
77 "Bshow\n\
78 Image display in Tcl/Tk\n\
79 using the Bsoft library\n\
80 Bernard Heymann\n2003-08-16"
81 }
82 
83 # Update
84 #
85 # A general updating procedure for this script
86 #
87 proc Update { } {
88  global filename
89  global c
90  global g
91  global amode
92  if { [string length $filename] < 1 } { return}
93  set scale [.scale.scale get]
94  set slice_num [.slice.scale get]
95  set img_num [.image.scale get]
96 # puts "This is in Update"
97  if ![winfo exists .wctf] { $c delete ellipse}
98  Bimage show theimg $img_num $slice_num $scale
99  if { $amode == "mark" } {
100  redrawAllMarkers $c
101  }
102  if [winfo exists .wbox] {
103  redrawAllBoxes $c
104  }
105  if { $amode == "fil" } {
106  redrawAllNodes $c
107  }
108 # if { $amode == "ctf" } {
109  if [winfo exists .wctf] {
110  drawEllipse $c
111  drawCTF $g
112  saveCTFparam
113  }
114 # }
115  if { $amode == "tomo" } {
116  redrawAllGold $c
117  }
118 }
119 
120 #################################################################
121 # Main script
122 #################################################################
123 
124 #----------------------------------------------------------------
125 # The code below creates the main window, consisting of a menu bar,
126 # a canvas widget for the image, and a status bar.
127 #----------------------------------------------------------------
128 set datatype "unknown"
129 set old_scale 1.0
130 set amode "none"
131 set imgtype "mg_file"
132 
133 set c .frame.c
134 frame .frame
135 pack .frame -side left -fill both -expand yes
136 
137 . configure -menu .menuBar
138 
139 canvas $c -width 200 -height 200 \
140  -relief sunken -borderwidth 2 \
141  -xscrollcommand ".frame.hscroll set" \
142  -yscrollcommand ".frame.vscroll set"
143 scrollbar .frame.vscroll -orient vertical -command "$c yview"
144 scrollbar .frame.hscroll -orient horiz -command "$c xview"
145 
146 bind $c <Motion> "showCoords %W %x %y"
147 $c bind marker <Any-Enter> "$c itemconfig current -outline red"
148 $c bind marker <Any-Leave> "$c itemconfig current -outline yellow"
149 bind . <Return> { Update }
150 bind . <ButtonRelease> { Update }
151 #bind . <KeyPress> {puts %K}
152 
153 #$c config -cursor {crosshair black yellow}
154 $c config -cursor {crosshair #ffffff #ffff00}
155 
156 grid $c -in .frame \
157  -row 0 -column 0 -rowspan 1 -columnspan 1 -sticky news
158 grid .frame.vscroll \
159  -row 0 -column 1 -rowspan 1 -columnspan 1 -sticky news
160 grid .frame.hscroll \
161  -row 1 -column 0 -rowspan 1 -columnspan 1 -sticky news
162 grid rowconfig .frame 0 -weight 1 -minsize 0
163 grid columnconfig .frame 0 -weight 1 -minsize 0
164 
165 # Create a photo image object and place it at {0,0}
166 image create photo theimg
167 $c create image 0 0 -image theimg -anchor nw -tags theimage
168 
169 frame .mode
170 radiobutton .mode.mark -text "Markers" -variable amode \
171  -relief flat -value "mark" -command { Markers $c }
172 radiobutton .mode.part -text "Particles" -variable amode \
173  -relief flat -value "part" -command { Particles $c }
174 radiobutton .mode.fil -text "Filaments" -variable amode \
175  -relief flat -value "fil" -command { Filaments $c }
176 radiobutton .mode.ctf -text "CTF" -variable amode \
177  -relief flat -value "ctf" -command { CTF $c }
178 radiobutton .mode.tomo -text "Tomography" -variable amode \
179  -relief flat -value "tomo" -command { Tomography $c }
180 
181 frame .pixel
182 label .pixel.xtag -font $font12 -text "x"
183 label .pixel.x -text "0" -relief sunken -bd 1 -width 8 \
184  -font $font12 -anchor w
185 label .pixel.ytag -font $font12 -text "y"
186 label .pixel.y -text "0" -relief sunken -bd 1 -width 8 \
187  -font $font12 -anchor w
188 label .pixel.vtag -font $font12 -text "value"
189 label .pixel.value -text "0" -relief sunken -bd 1 -width 16 \
190  -font $font12 -anchor w
191 
192 frame .pixel_size
193 label .pixel_size.tag -font $font12 -text "Pixel size (A)"
194 entry .pixel_size.entry -width 10
195 .pixel_size.entry insert 0 1
196 
197 pack .mode -side top -pady 2
198 pack .mode.mark .mode.part .mode.fil .mode.ctf .mode.tomo -side top -pady 2 -anchor w
199 
200 pack .pixel.xtag .pixel.x .pixel.ytag .pixel.y .pixel.vtag .pixel.value \
201  -side left -pady 2 -padx 2
202 
203 pack .pixel_size.tag .pixel_size.entry -side left -pady 5
204 
205 pack .pixel .pixel_size .image .slice .scale .min .max -side top -fill x -pady 2
206 
207 #puts [ info commands B* ]
208 
209 if { [string first ".star" $filename] > -1 } {
210  set paramfile $filename
211  Bmg read $paramfile
213 } else {
214  loadImage $filename -1
215 }
216 
217 #---------------------------- The End ---------------------------
218