blob: 78b339b53d7a82965919b0940f8f648069f879dd (
plain) (
blame)
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
|
# IMBROWSE.GUI -- Image browser user interface.
reset-server
appInitialize imbrowse Imbrowse {
*objects: \
toplevel Paned panel \
\
panel Box statusBox \
statusBox MenuButton dirSelect \
statusBox AsciiText dirName \
statusBox Command imageButton \
statusBox Command helpButton \
statusBox Command quitButton \
\
panel Viewport objView \
objView List objList \
\
panel Form controlForm \
controlForm Label buttonHelp \
controlForm Label templateLabel \
controlForm AsciiText templateText \
controlForm Command prevButton \
controlForm Command nextButton \
controlForm Command headerButton \
controlForm Command displayButton \
\
panel AsciiText headerText \
\
panel Box sectionBox \
sectionBox Label sectionLabel \
sectionBox AsciiText sectionText \
\
toplevel TopLevelShell imageShell \
imageShell Form imageForm \
imageForm Label imageTitle \
imageForm Gterm imageWindow \
\
toplevel Parameter imbrowse \
imbrowse Parameter template \
imbrowse Parameter section \
imbrowse Parameter directory \
imbrowse Parameter subdirs \
imbrowse Parameter files \
imbrowse Parameter image_title \
imbrowse Parameter header \
imbrowse Parameter errormsg \
*panel.orientation: vertical
*displayCaret: false
*background: LightSkyBlue
*shapeStyle: Rectangle
*beNiceToColormap: False
*Label*shadowWidth: 2
*statusBox.orientation: horizontal
*statusBox.showGrip: False
*statusBox.skipAdjust: True
! *statusBox.background: gray61
*dirSelect.label: Directory:
*dirSelect.menuName: dirMenu
*dirName*background: #a7eeff
*dirName.width: 403
*dirName*displayCaret: True
*dirName*editType: edit
*imageButton.label: Image
*helpButton.label: Help
*helpButton.sensitive: False
*quitButton.label: Quit
*objView.allowHoriz: False
*objView.allowVert: True
*objView.forceBars: True
*objView.min: 60
*objView*background: #a7eeff
! *objList*height: 100
*objList*verticalList: True
*controlForm.showGrip: True
*controlForm.skipAdjust: True
*buttonHelp.borderWidth: 0
*buttonHelp.width: 613
*templateLabel.label: Images:
*templateLabel.fromVert: buttonHelp
*templateLabel.borderWidth: 0
*templateText*background: #a7eeff
*templateText*font: 7x13bold
*templateText*width: 230
*templateText.fromHoriz: templateLabel
*templateText.fromVert: buttonHelp
*templateText*displayCaret: True
*templateText*editType: edit
*prevButton.label: PrevIm
*prevButton.fromHoriz: templateText
*prevButton.fromVert: buttonHelp
*nextButton.label: NextIm
*nextButton.fromHoriz: prevButton
*nextButton.fromVert: buttonHelp
*headerButton.label: Show Header
*headerButton.fromHoriz: nextButton
*headerButton.fromVert: buttonHelp
*displayButton.label: Display Image
*displayButton.fromHoriz: headerButton
*displayButton.fromVert: buttonHelp
*headerText.showGrip: False
*headerText.skipAdjust: False
*headerText.min: 100
! *headerText.height: 100
*headerText.scrollVertical: always
*headerText.scrollHorizontal: whenNeeded
*headerText*font: 7x13
*headerText*background: #a7eeff
*sectionBox.orientation: horizontal
*sectionBox.showGrip: False
*sectionBox.skipAdjust: True
*sectionLabel.label: Display image section:
*sectionLabel.borderWidth: 0
*sectionText*background: #a7eeff
*sectionText.width: 460
*sectionText*font: 7x13bold
*sectionText*displayCaret: True
*sectionText*editType: edit
*imageTitle.borderWidth: 0
*imageTitle.width: 512
*imageWindow.cmapName: image
*imageWindow.ginmodeCursor: circle
*imageWindow.width: 512
*imageWindow.height: 512
*imageWindow.fromVert: imageTitle
*imageWindow.translations: \
<Btn1Down>: m_create() \n\
!Shift <Btn2Down>: crosshair(on) \n\
!Shift <Btn2Motion>: crosshair(on) \n\
<Btn2Up>: crosshair(off) \n\
<Btn2Down>: call(zoom,$x,$y) \n\
<Btn3Down>: call(windowColormap,$x,$y) \n\
<Btn3Motion>: call(windowColormap,$x,$y) \n\
<EnterWindow>: enter-window() \n\
<LeaveWindow>: leave-window() \n\
<KeyPress>: graphics-input() \n\
<Motion>: track-cursor()
}
# Start up the GUI.
createObjects
send imageShell realize
send imageWindow setGterm
activate
# Global variables.
set version "Imbrowse 0.1 - Alpha Test Version"
# Display the program version number on startup.
send buttonHelp set label $version
#proc reactivate {} {
#}; send server postActivateCallback reactivate
# Callbacks for client state variables (UI parameter objects). When the
# client's state changes it updates a UI parameter to reflect the change.
# This produces a callback to one or more of the callbacks defined below,
# used to update the GUI to reflect the changing state of the client.
proc setTemplate {param old new} {
send templateText set string $new
}; send template addCallback setTemplate
proc setSection {param old new} {
send sectionText set string $new
}; send section addCallback setSection
proc setDirectory {param old new} {
send dirName set string $new
}; send directory addCallback setDirectory
proc setImageTitle {param old new} {
send imageTitle set label $new
}; send image_title addCallback setImageTitle
proc setFiles {param old new} {
send objList setList $new resize
}; send files addCallback setFiles
proc setSubdirs {param old new} {
foreach dir $new {
lappend itemList "$dir f.exec \{ send client gcmd chdir $dir \}"
}
createMenu dirMenu dirSelect $itemList
}; send subdirs addCallback setSubdirs
proc setErrormsg {param old new} {
send buttonHelp set label $new
}; send errormsg addCallback setErrormsg
proc setHeaderText {param old new} {
send headerText set string $new
}; send header addCallback setHeaderText
# List widget callback.
proc select {widget cbtype item index} {
set subdirs [send subdirs getValue]
if [expr [lsearch $subdirs $item] != -1] {
send client gcmd chdir $item
}
}; send objList addCallback select
# Command callbacks.
proc image args {send imageShell map}
send imageButton addCallback image
proc help args { }
send helpButton addCallback help
proc quit args {
#send imageShell unmap; send client gkey q; deactivate unmap
send client gkey q; deactivate unmap
}; send quitButton addCallback quit
proc next args {
send objList getItem itemno
if {$itemno == "none"} {
send objList highlight 0
} else {
send objList highlight [expr "$itemno + 1"]
}
}; send nextButton addCallback next
proc prev args {
send objList getItem itemno
if {$itemno == "none"} {
send objList highlight 0
} else {
set itemno [expr "$itemno - 1"]
if {$itemno >= 0} {
send objList highlight $itemno
}
}
}; send prevButton addCallback prev
proc headerCallback args {
set image [send objList getItem itemno]
if {$itemno != "none"} {
printHeader $image
}
}; send headerButton addCallback headerCallback
proc printHeader {image} {
send client gcmd header $image
}
proc displayCallback args {
set image [send objList getItem itemno]
if {$itemno != "none"} {
displayImage $image
}
}; send displayButton addCallback displayCallback
proc displayImage {image} {
send imageShell map
send imageWindow setGterm
send client gcmd display $image
}
proc directoryCallback {widget cbtype text} {
send client gcmd chdir $text
}; send dirName addCallback directoryCallback
proc templateCallback {widget cbtype text} {
send client gcmd template $text
}; send templateText addCallback templateCallback
proc sectionCallback {widget cbtype text} {
send client gcmd section $text
}; send sectionText addCallback sectionCallback
# Window the displayed image.
proc windowColormap {x y} \
{
set winWidth [send imageWindow get width]
set winHeight [send imageWindow get height]
send imageWindow loadColormap 1 \
[expr "$x.0 / $winWidth"] \
[expr "($y.0 - $winHeight / 2.0) / $winHeight * 10.0"]
}
# ZOOM and PAN.
set xcen 0
set ycen 0
# Zoom or pan image at given center.
proc zoom {x y} \
{
global xcen ycen
# Convert raw screen coordinates to frame buffer raster coordinates.
send imageWindow unmapPixel $x $y raster rx ry
# Select a pixel.
set rx [expr "int ($rx)"]
set ry [expr "int ($ry)"]
# If the pointer did not move (much) zoom the image, otherwise
# pan it.
if {sqrt(pow($rx-$xcen, 2) + pow($ry-$ycen, 2)) < 4} {
send client gkey Z
} else {
send client gkey M
}
set xcen $rx
set ycen $ry
}
# Button help feature.
set help(dirName) "current directory"
set help(dirSelect) "press to get directory selection menu"
set help(displayButton) "press to display currently selected image"
set help(templateLabel) "list of image file templates"
set help(templateText) "enter new list of image templates and press return"
set help(headerButton) "press to list header of currently selected image"
set help(headerText) "the image header is displayed here"
set help(helpButton) "press to get help for imbrowse"
set help(nextButton) "advance to next image"
set help(objList) "images in current directory are listed here"
set help(prevButton) "back up to previous image"
set help(quitButton) "press to exit the imbrowse application"
set help(sectionLabel) "image section for displaying image"
set help(sectionText) "enter new image section and press return"
set widgets {
dirSelect dirName helpButton quitButton objList templateLabel
templateText nextButton prevButton headerButton displayButton
headerText sectionLabel sectionText
}
proc helpCallback { widget event args } {
global help
if {$event == "enterNotify"} {
send buttonHelp set label $help($widget)
}
}
foreach widget $widgets {
send $widget addEventHandler helpCallback enterWindowMask
}
#set timerId 0
#set timerState 0
#proc timer args {
# global timerId timerState
# if {$timerState} {
# send quitButton set background red
# set timerState 0
# } else {
# send quitButton set background blue
# set timerState 1
# }
# set timerId [postTimedCallback timer 1000]
#}; set timerId [postTimedCallback timer 1000]
|