12 variable reference_actor
14 variable actual_plane -1
27 proc u_mpr::reset { parent } {
29 # For programming facilities
30 upvar u_mpr::widgets widgets
32 set widgets(base) "$parent"
33 set widgets(work3D) "$parent\.mpr"
34 set widgets(controls) "$parent\.mprControls"
35 set widgets(type) "$parent\.mprControls.type"
36 set widgets(btnSagital) "$parent\.mprControls.type.btnSagital"
37 set widgets(btnAxial) "$parent\.mprControls.type.btnAxial"
38 set widgets(btnCoronal) "$parent\.mprControls.type.btnCoronal"
39 set widgets(lbl001) "$parent\.mprControls.lbl001"
40 set widgets(lbl002) "$parent\.mprControls.lbl002"
41 set widgets(sclMPR) "$parent\.mprControls.sclMPR"
42 set widgets(frMeasure) "$parent\.mprControls.frMeasure"
43 set widgets(lblMeasure) "$parent\.mprControls.frMeasure.01"
44 set widgets(edtMeasure) "$parent\.mprControls.frMeasure.02"
48 proc u_mpr::create { parent } {
50 # For programming facilities
51 upvar u_mpr::widgets widgets
52 upvar u_mpr::select_first select_first
57 frame $widgets(controls) -borderwidth 1 -height 75 -relief groove -width 191
58 frame $widgets(type) -borderwidth 2 -height 75 -relief groove -width 125
59 frame $widgets(frMeasure) -height 30 -width 30
62 entry $widgets(edtMeasure) -cursor {}
65 radiobutton $widgets(btnSagital) -text $string_table::str_sagital -variable show_type -value 1 -command { u_mpr::set_probe $show_type #ff0000 }
66 radiobutton $widgets(btnAxial) -text $string_table::str_axial -variable show_type -value 2 -command { u_mpr::set_probe $show_type #00ff00 }
67 radiobutton $widgets(btnCoronal) -text $string_table::str_coronal -variable show_type -value 3 -command { u_mpr::set_probe $show_type #0000ff }
70 label $widgets(lbl001) -borderwidth 0 -text $string_table::str_mpr_controls
71 label $widgets(lbl002) -borderwidth 0 -text $string_table::str_mpr_type
72 label $widgets(lblMeasure) -anchor w -borderwidth 0 -text $string_table::str_distance
74 scale $widgets(sclMPR) -label $string_table::str_slices -orient horizontal
78 proc u_mpr::positionate { } {
80 # For programming facilities
81 upvar u_mpr::widgets widgets
83 pack $widgets(work3D) -anchor nw -expand 1 -fill both -side left
84 pack $widgets(controls) -anchor nw -expand 0 -fill both -side left
85 place $widgets(type) -x 10 -y 80 -width 175 -height 100 -anchor nw -bordermode ignore
86 place $widgets(btnSagital) -x 5 -y 5 -anchor nw -bordermode ignore
87 place $widgets(btnAxial) -x 5 -y 35 -anchor nw -bordermode ignore
88 place $widgets(btnCoronal) -x 5 -y 65 -anchor nw -bordermode ignore
89 place $widgets(lbl001) -x 55 -y 25 -anchor nw -bordermode ignore
90 place $widgets(lbl002) -x 15 -y 70 -anchor nw -bordermode ignore
91 place $widgets(sclMPR) -x 5 -y 245 -width 178 -height 59 -anchor nw -bordermode ignore
92 place $widgets(frMeasure) -x 5 -y 430 -width 180 -height 25 -anchor nw -bordermode ignore
93 pack $widgets(lblMeasure) -anchor center -expand 0 -fill none -padx 2 -pady 2 -side left
94 pack $widgets(edtMeasure) -anchor center -expand 1 -fill x -padx 2 -pady 2 -side right
98 proc u_mpr::forget { } {
100 # For programming facilities
101 upvar u_mpr::widgets widgets
103 pack forget $widgets(edtMeasure)
104 pack forget $widgets(lblMeasure)
105 place forget $widgets(frMeasure)
106 place forget $widgets(sclMPR)
107 place forget $widgets(lbl002)
108 place forget $widgets(lbl001)
109 place forget $widgets(btnCoronal)
110 place forget $widgets(btnAxial)
111 place forget $widgets(btnSagital)
112 place forget $widgets(type)
113 pack forget $widgets(controls)
114 pack forget $widgets(work3D)
118 proc u_mpr::set_data { } {
120 # For programming facilities
121 upvar u_mpr::widgets widgets
122 upvar u_mpr::reference_actor reference_actor
123 upvar u_mpr::mpr_data mpr_data
124 upvar u_mpr::actual_plane actual_plane
125 upvar u_mpr::bounds bounds
126 upvar u_mpr::intRange intRange
127 upvar u_mpr::select_first select_first
129 set resample [ GetVTKVolume_dll ]
130 set bounds [ $resample GetBounds ]
133 catch { renderer_$widgets(work3D) RemoveActor outlineActor_$widgets(work3D) }
134 catch { outlineActor_$widgets(work3D) Delete }
135 catch { outlineMapper_$widgets(work3D) Delete }
136 catch { outlineSource_$widgets(work3D) Delete }
137 catch { lookup_$widgets(work3D) Delete }
140 destroy $widgets(work3D)
141 vtkTkRenderWidget $widgets(work3D) -width 30 -height 30
144 bindBasicEvents $widgets(work3D)
147 bind $widgets(work3D) <Double-Button-1> "u_mpr::ev_dbl_select_st_point %x %y"
148 bind $widgets(work3D) <Double-Button-3> "u_mpr::ev_dbl_select_point %x %y"
149 $widgets(edtMeasure) delete 0 end
151 catch { renderer_$widgets(work3D) Delete }
152 vtkRenderer renderer_$widgets(work3D)
153 renderer_$widgets(work3D) SetBackground 0 0 0
154 #renderer_$widgets(work3D) SetBackground 1 1 1
155 set render [ $widgets(work3D) GetRenderWindow ]
156 $render AddRenderer renderer_$widgets(work3D)
159 set u_mpr::stPoint {}
161 for { set i 0 } { $i < 3 } { incr i } {
163 catch { renderer_$widgets(work3D) RemoveActor outline_actor_{$widgets(work3D)}_{$i} }
164 catch { renderer_$widgets(work3D) RemoveActor plane_{$widgets(work3D)}_{$i} }
165 catch { plane_{$widgets(work3D)}_{$i} Delete }
166 catch { mapper_{$widgets(work3D)}_{$i} Delete }
167 catch { strip_{$widgets(work3D)}_{$i} Delete }
168 catch { triangle_{$widgets(work3D)}_{$i} Delete }
169 catch { cast_{$widgets(work3D)}_{$i} Delete }
170 catch { probe_filter_{$widgets(work3D)}_{$i} Delete }
171 catch { outline_actor_{$widgets(work3D)}_{$i} Delete }
172 catch { outline_mapper_{$widgets(work3D)}_{$i} Delete }
173 catch { outline_filter_{$widgets(work3D)}_{$i} Delete }
174 catch { trans_filter_{$widgets(work3D)}_{$i} Delete }
175 catch { transform_{$widgets(work3D)}_{$i} Delete }
176 catch { source_{$widgets(work3D)}_{$i} Delete }
180 vtkCubeSource outlineSource_$widgets(work3D)
181 outlineSource_$widgets(work3D) SetXLength [ expr [ lindex $bounds 1 ] - [ lindex $bounds 0 ] ]
182 outlineSource_$widgets(work3D) SetYLength [ expr [ lindex $bounds 3 ] - [ lindex $bounds 2 ] ]
183 outlineSource_$widgets(work3D) SetZLength [ expr [ lindex $bounds 5 ] - [ lindex $bounds 4 ] ]
184 outlineSource_$widgets(work3D) SetCenter \
185 [ expr ( [ lindex $bounds 0 ] + [ lindex $bounds 1 ] ) / 2 ] \
186 [ expr ( [ lindex $bounds 2 ] + [ lindex $bounds 3 ] ) / 2 ] \
187 [ expr ( [ lindex $bounds 4 ] + [ lindex $bounds 5 ] ) / 2 ]
189 vtkPolyDataMapper outlineMapper_$widgets(work3D)
190 outlineMapper_$widgets(work3D) SetInput [ outlineSource_$widgets(work3D) GetOutput ]
191 outlineMapper_$widgets(work3D) ImmediateModeRenderingOn
193 vtkActor outlineActor_$widgets(work3D)
194 outlineActor_$widgets(work3D) SetMapper outlineMapper_$widgets(work3D)
195 [ outlineActor_$widgets(work3D) GetProperty ] SetRepresentationToWireframe
196 [ outlineActor_$widgets(work3D) GetProperty ] SetColor 0.7 0.0 0.9
197 [ outlineActor_$widgets(work3D) GetProperty ] SetAmbient 1
198 [ outlineActor_$widgets(work3D) GetProperty ] SetDiffuse 0
199 [ outlineActor_$widgets(work3D) GetProperty ] SetSpecular 0
201 renderer_$widgets(work3D) AddActor outlineActor_$widgets(work3D)
204 set range [ GetImageRange_dll ]
205 set xdiff [ lindex [ split [ expr [ lindex $bounds 1 ] - [ lindex $bounds 0 ] ] . ] 0 ]
206 set ydiff [ lindex [ split [ expr [ lindex $bounds 3 ] - [ lindex $bounds 2 ] ] . ] 0 ]
207 set zdiff [ lindex [ split [ expr [ lindex $bounds 5 ] - [ lindex $bounds 4 ] ] . ] 0 ]
209 vtkWindowLevelLookupTable lookup_$widgets(work3D)
210 lookup_$widgets(work3D) SetHueRange 0.0 1.0
211 lookup_$widgets(work3D) SetNumberOfColors [ lindex [ split [ expr [ lindex $range 1 ] - [ lindex $range 0 ] + 1 ] . ] 0 ]
212 lookup_$widgets(work3D) SetTableRange [ lindex $range 0 ] [ lindex $range 1 ]
213 lookup_$widgets(work3D) SetSaturationRange 0 0
214 lookup_$widgets(work3D) SetValueRange 0 1
215 lookup_$widgets(work3D) SetAlphaRange 1 1
216 lookup_$widgets(work3D) Build
218 for { set i 0 } { $i < 3 } { incr i } {
220 vtkPlaneSource source_{$widgets(work3D)}_{$i}
221 source_{$widgets(work3D)}_{$i} SetResolution [ expr ( $i == 0 )? $zdiff: $xdiff ] [ expr ( $i == 1 )? $zdiff: $ydiff ]
223 vtkTransform transform_{$widgets(work3D)}_{$i}
224 transform_{$widgets(work3D)}_{$i} Identity
225 transform_{$widgets(work3D)}_{$i} Translate \
226 [ expr ( $xdiff / 2 ) + [ lindex $bounds 0 ] ] \
227 [ expr ( $ydiff / 2 ) + [ lindex $bounds 2 ] ] \
228 [ expr ( $zdiff / 2 ) + [ lindex $bounds 4 ] ]
229 transform_{$widgets(work3D)}_{$i} Scale $xdiff $ydiff $zdiff
230 if { $i == 0 } { transform_{$widgets(work3D)}_{$i} RotateY 90 }
231 if { $i == 1 } { transform_{$widgets(work3D)}_{$i} RotateX 90 }
233 vtkTransformPolyDataFilter trans_filter_{$widgets(work3D)}_{$i}
234 trans_filter_{$widgets(work3D)}_{$i} SetInput [ source_{$widgets(work3D)}_{$i} GetOutput ]
235 trans_filter_{$widgets(work3D)}_{$i} SetTransform transform_{$widgets(work3D)}_{$i}
237 vtkOutlineFilter outline_filter_{$widgets(work3D)}_{$i}
238 outline_filter_{$widgets(work3D)}_{$i} SetInput [ trans_filter_{$widgets(work3D)}_{$i} GetOutput ]
240 vtkPolyDataMapper outline_mapper_{$widgets(work3D)}_{$i}
241 outline_mapper_{$widgets(work3D)}_{$i} SetInput [ outline_filter_{$widgets(work3D)}_{$i} GetOutput ]
243 vtkActor outline_actor_{$widgets(work3D)}_{$i}
244 outline_actor_{$widgets(work3D)}_{$i} SetMapper outline_mapper_{$widgets(work3D)}_{$i}
245 [ outline_actor_{$widgets(work3D)}_{$i} GetProperty ] SetRepresentationToWireframe
246 [ outline_actor_{$widgets(work3D)}_{$i} GetProperty ] SetColor 0.7 0.0 0.9
247 [ outline_actor_{$widgets(work3D)}_{$i} GetProperty ] SetAmbient 1
248 [ outline_actor_{$widgets(work3D)}_{$i} GetProperty ] SetDiffuse 0
249 [ outline_actor_{$widgets(work3D)}_{$i} GetProperty ] SetSpecular 0
251 vtkProbeFilter probe_filter_{$widgets(work3D)}_{$i}
252 probe_filter_{$widgets(work3D)}_{$i} SetInput [ trans_filter_{$widgets(work3D)}_{$i} GetOutput ]
253 probe_filter_{$widgets(work3D)}_{$i} SetSource $resample
255 vtkCastToConcrete cast_{$widgets(work3D)}_{$i}
256 cast_{$widgets(work3D)}_{$i} SetInput [ probe_filter_{$widgets(work3D)}_{$i} GetOutput ]
258 vtkTriangleFilter triangle_{$widgets(work3D)}_{$i}
259 triangle_{$widgets(work3D)}_{$i} SetInput [ cast_{$widgets(work3D)}_{$i} GetPolyDataOutput ]
261 vtkStripper strip_{$widgets(work3D)}_{$i}
262 strip_{$widgets(work3D)}_{$i} SetInput [ triangle_{$widgets(work3D)}_{$i} GetOutput ]
264 vtkPolyDataMapper mapper_{$widgets(work3D)}_{$i}
265 mapper_{$widgets(work3D)}_{$i} SetInput [ strip_{$widgets(work3D)}_{$i} GetOutput ]
266 mapper_{$widgets(work3D)}_{$i} SetLookupTable lookup_$widgets(work3D)
267 mapper_{$widgets(work3D)}_{$i} SetScalarRange [ lindex $range 0 ] [ lindex $range 1 ]
268 mapper_{$widgets(work3D)}_{$i} ImmediateModeRenderingOn
270 vtkActor plane_{$widgets(work3D)}_{$i}
271 plane_{$widgets(work3D)}_{$i} SetMapper mapper_{$widgets(work3D)}_{$i}
272 [ plane_{$widgets(work3D)}_{$i} GetProperty ] SetOpacity 1.0
276 [ $widgets(work3D) GetRenderWindow ] Render
278 $widgets(btnSagital) deselect
279 $widgets(btnAxial) deselect
280 $widgets(btnCoronal) deselect
282 $widgets(btnCoronal) invoke
284 global_window::active_controls [ expr \
285 $global_window::en_open | \
286 $global_window::en_load | \
287 $global_window::en_params | \
288 $global_window::en_rotate | \
289 $global_window::en_pan | \
290 $global_window::en_bright | \
291 $global_window::en_zoom \
296 proc u_mpr::set_probe { typ col } {
298 # For programming facilities
299 upvar u_mpr::widgets widgets
300 upvar u_mpr::reference_actor reference_actor
301 upvar u_mpr::mpr_data mpr_data
302 upvar u_mpr::actual_plane actual_plane
303 upvar u_mpr::bounds bounds
304 upvar u_mpr::intRange intRange
306 catch { renderer_$widgets(work3D) RemoveActor outline_actor_{$widgets(work3D)}_{$actual_plane} }
307 catch { renderer_$widgets(work3D) RemoveActor plane_{$widgets(work3D)}_{$actual_plane} }
308 catch { renderer_$widgets(work3D) RemoveActor [ GetSphereActorName sphere_1_$widgets(work3D) ] }
309 DeleteSphere sphere_1_$widgets(work3D)
310 catch { renderer_$widgets(work3D) RemoveActor [ GetSphereActorName sphere_2_$widgets(work3D) ] }
311 DeleteSphere sphere_2_$widgets(work3D)
312 catch { renderer_$widgets(work3D) RemoveActor textActor_$widgets(work3D) }
313 catch { textActor_$widgets(work3D) Delete }
314 catch { textMapper_$widgets(work3D) Delete }
315 catch { textSource_$widgets(work3D) Delete }
316 catch { tmp_picker_$widgets(work3D) Delete }
318 if { $actual_plane == 1 } {
320 [ renderer_$widgets(work3D) GetActiveCamera ] Elevation -90.0
321 [ renderer_$widgets(work3D) GetActiveCamera ] OrthogonalizeViewUp
324 if { $actual_plane == 0 } {
326 [ renderer_$widgets(work3D) GetActiveCamera ] Azimuth -90.0
327 [ renderer_$widgets(work3D) GetActiveCamera ] OrthogonalizeViewUp
330 [ $widgets(work3D) GetRenderWindow ] Render
331 set actual_plane [ expr $typ - 1 ]
332 if { $actual_plane == 0 || $actual_plane == 1 || $actual_plane == 2 } {
334 set r [ expr "0x[ string index $col 1 ][ string index $col 2 ]" / 255.0 ]
335 set g [ expr "0x[ string index $col 3 ][ string index $col 4 ]" / 255.0 ]
336 set b [ expr "0x[ string index $col 5 ][ string index $col 6 ]" / 255.0 ]
337 [ outline_actor_{$widgets(work3D)}_{$actual_plane} GetProperty ] SetColor $r $g $b
338 renderer_$widgets(work3D) AddActor outline_actor_{$widgets(work3D)}_{$actual_plane}
339 renderer_$widgets(work3D) AddActor plane_{$widgets(work3D)}_{$actual_plane}
341 [ $widgets(work3D) GetRenderWindow ] Render
343 set resample [ GetVTKVolume_dll ]
344 set bounds [ $resample GetBounds ]
345 $widgets(sclMPR) configure \
346 -from [ lindex $bounds [ expr ( $actual_plane == 0 )? 0: ( $actual_plane == 1 )? 2: 4 ] ] \
347 -to [ lindex $bounds [ expr ( $actual_plane == 0 )? 1: ( $actual_plane == 1 )? 3: 5 ] ] \
351 bind $widgets(sclMPR) <Any-ButtonRelease>
352 bind $widgets(sclMPR) <Any-ButtonRelease> "u_mpr::ev_change_slice 0"
353 u_mpr::ev_change_slice 1
355 [ $widgets(work3D) GetRenderWindow ] Render
357 set xc [ expr ( [ lindex $bounds 1 ] + [ lindex $bounds 0 ] ) / 2 ]
358 set yc [ expr ( [ lindex $bounds 3 ] + [ lindex $bounds 2 ] ) / 2 ]
359 set zc [ expr ( [ lindex $bounds 5 ] + [ lindex $bounds 4 ] ) / 2 ]
363 set zc [ expr $zc + 15 * [ expr [ lindex $bounds 5 ] - [ lindex $bounds 4 ] ] ]
364 #[ renderer_$widgets(work3D) GetActiveCamera ] SetFocalPoint $xf $yf $zf
365 #[ renderer_$widgets(work3D) GetActiveCamera ] SetPosition $xc $yc $zc
367 if { $actual_plane == 0 } {
369 [ renderer_$widgets(work3D) GetActiveCamera ] Azimuth 90.0
370 [ renderer_$widgets(work3D) GetActiveCamera ] OrthogonalizeViewUp
372 } elseif { $actual_plane == 1 } {
374 [ renderer_$widgets(work3D) GetActiveCamera ] Elevation 90.0
375 [ renderer_$widgets(work3D) GetActiveCamera ] OrthogonalizeViewUp
379 [ $widgets(work3D) GetRenderWindow ] Render
385 proc u_mpr::ev_change_slice { typ } {
387 # For programming facilities
388 upvar u_mpr::widgets widgets
389 upvar u_mpr::reference_actor reference_actor
390 upvar u_mpr::mpr_data mpr_data
391 upvar u_mpr::actual_plane actual_plane
392 upvar u_mpr::bounds bounds
393 upvar u_mpr::intRange intRange
395 catch { renderer_$widgets(work3D) RemoveActor [ GetSphereActorName sphere_1_$widgets(work3D) ] }
396 DeleteSphere sphere_1_$widgets(work3D)
397 catch { renderer_$widgets(work3D) RemoveActor [ GetSphereActorName sphere_2_$widgets(work3D) ] }
398 DeleteSphere sphere_2_$widgets(work3D)
399 catch { renderer_$widgets(work3D) RemoveActor textActor_$widgets(work3D) }
400 catch { textActor_$widgets(work3D) Delete }
401 catch { textMapper_$widgets(work3D) Delete }
402 catch { textSource_$widgets(work3D) Delete }
403 catch { tmp_picker_$widgets(work3D) Delete }
404 if { $actual_plane == 0 || $actual_plane == 1 || $actual_plane == 2 } {
408 set slc [ expr ( [ $widgets(sclMPR) cget -to ] + [ $widgets(sclMPR) cget -from ] ) / 2 ]
409 $widgets(sclMPR) set $slc
411 } else { set slc [ $widgets(sclMPR) get ] }
413 set resample [ GetVTKVolume_dll ]
414 set bounds [ $resample GetBounds ]
415 set xdiff [ expr [ lindex $bounds 1 ] - [ lindex $bounds 0 ] ];
416 set ydiff [ expr [ lindex $bounds 3 ] - [ lindex $bounds 2 ] ];
417 set zdiff [ expr [ lindex $bounds 5 ] - [ lindex $bounds 4 ] ];
419 transform_{$widgets(work3D)}_{$actual_plane} Identity
420 transform_{$widgets(work3D)}_{$actual_plane} Translate \
421 [ expr ( $actual_plane == 0 )? $slc: ( $xdiff / 2 ) + [ lindex $bounds 0 ] ] \
422 [ expr ( $actual_plane == 1 )? $slc: ( $ydiff / 2 ) + [ lindex $bounds 2 ] ] \
423 [ expr ( $actual_plane == 2 )? $slc: ( $zdiff / 2 ) + [ lindex $bounds 4 ] ]
424 transform_{$widgets(work3D)}_{$actual_plane} Scale $xdiff $ydiff $zdiff
425 if { $actual_plane == 0 } { transform_{$widgets(work3D)}_{$actual_plane} RotateY 90 }
426 if { $actual_plane == 1 } { transform_{$widgets(work3D)}_{$actual_plane} RotateX 90 }
427 [ $widgets(work3D) GetRenderWindow ] Render
433 proc u_mpr::set_mouse_events { bright_type } {
435 # For programming facilities
436 upvar u_mpr::widgets widgets
437 upvar u_mpr::reference_actor reference_actor
438 upvar u_mpr::mpr_data mpr_data
439 upvar u_mpr::actual_plane actual_plane
440 upvar u_mpr::bounds bounds
441 upvar u_mpr::intRange intRange
443 if { $bright_type == 0 } {
445 bind $widgets(work3D) <Any-ButtonPress>
446 bind $widgets(work3D) <B1-Motion>
449 bindBasicEvents $widgets(work3D)
450 bindZoomEvents $widgets(work3D) 0
454 bind $widgets(work3D) <Any-ButtonPress>
455 bind $widgets(work3D) <B1-Motion>
461 proc u_mpr::ev_start_window_level { x y } {
463 # For programming facilities
464 upvar u_mpr::widgets widgets
465 upvar u_mpr::reference_actor reference_actor
466 upvar u_mpr::mpr_data mpr_data
467 upvar u_mpr::actual_plane actual_plane
468 upvar u_mpr::bounds bounds
469 upvar u_mpr::intRange intRange
470 upvar u_mpr::initX initX
471 upvar u_mpr::initY initY
472 upvar u_mpr::initWindow initWindow
473 upvar u_mpr::initLevel initLevel
478 set initWindow [ lookup_$widgets(work3D) GetWindow ]
479 set initLevel [ lookup_$widgets(work3D) GetLevel ]
483 proc u_mpr::ev_window_level { x y } {
485 # For programming facilities
486 upvar u_mpr::widgets widgets
487 upvar u_mpr::reference_actor reference_actor
488 upvar u_mpr::mpr_data mpr_data
489 upvar u_mpr::actual_plane actual_plane
490 upvar u_mpr::bounds bounds
491 upvar u_mpr::intRange intRange
492 upvar u_mpr::initX initX
493 upvar u_mpr::initY initY
494 upvar u_mpr::initWindow initWindow
495 upvar u_mpr::initLevel initLevel
497 # get the widgets dimensions
498 set width [ lindex [ $widgets(work3D) configure -width ] 4 ]
499 set height [ lindex [ $widgets(work3D) configure -height ] 4 ]
501 # compute normalized delta
502 set dx [ expr 4.0 * ( $x - $initX ) / $width ]
503 set dy [ expr 4.0 * ( $initY - $y ) / $height ]
505 # scale by current values
506 set dx [ expr $dx * $initWindow ]
507 set dy [ expr $dy * $initLevel ]
509 # abs so that direction does not flip
510 if { $initWindow < 0.0 } { set dx [ expr 0 - $dx ] }
511 if { $initLevel < 0.0 } { set dy [ expr 0 - $dy ] }
513 # compute new window level
514 set window [ expr $dx + $initWindow ]
516 set level [ expr $dy + $initLevel ]
518 set level [ expr $initLevel - $dy ]
521 if { $window < 0.0 } { set dy [ expr 0 - $dy ] }
523 lookup_$widgets(work3D) SetWindow $window
524 lookup_$widgets(work3D) SetLevel $level
526 [ $widgets(work3D) GetRenderWindow ] Render
530 proc u_mpr::ev_dbl_select_point { x y } {
532 # For programming facilities
533 upvar u_mpr::widgets widgets
534 upvar u_mpr::actual_plane actual_plane
535 upvar u_mpr::select_first select_first
537 set y [ expr [ lindex [ $widgets(work3D) configure -height ] 4 ] - $y - 1 ]
539 if { $select_first == 1 } {
541 catch { renderer_$widgets(work3D) RemoveActor [ GetSphereActorName sphere_1_$widgets(work3D) ] }
542 DeleteSphere sphere_1_$widgets(work3D)
543 catch { renderer_$widgets(work3D) RemoveActor [ GetSphereActorName sphere_2_$widgets(work3D) ] }
544 DeleteSphere sphere_2_$widgets(work3D)
545 catch { tmp_picker_$widgets(work3D) Delete }
547 vtkWorldPointPicker tmp_picker_$widgets(work3D)
548 set pickWP [ tmp_picker_$widgets(work3D) Pick $x $y 0 renderer_$widgets(work3D) ]
549 set pickWPPos [ tmp_picker_$widgets(work3D) GetPickPosition ]
551 set xc [ lindex $pickWPPos 0 ]
552 set yc [ lindex $pickWPPos 1 ]
553 set zc [ lindex $pickWPPos 2 ]
554 set resample [ GetVTKVolume_dll ]
556 set indP [ [ probe_filter_{$widgets(work3D)}_{$actual_plane} GetOutput ] FindPoint $xc $yc $zc ]
557 set coordsP [ [ probe_filter_{$widgets(work3D)}_{$actual_plane} GetOutput ] GetPoint $indP ]
559 renderer_$widgets(work3D) AddActor [ \
561 sphere_1_$widgets(work3D) \
563 [ lindex $coordsP 0 ] [ lindex $coordsP 1 ] [ lindex $coordsP 2 ] \
571 catch { tmp_picker_$widgets(work3D) Delete }
573 vtkWorldPointPicker tmp_picker_$widgets(work3D)
574 set pickWP [ tmp_picker_$widgets(work3D) Pick $x $y 0 renderer_$widgets(work3D) ]
575 set pickWPPos [ tmp_picker_$widgets(work3D) GetPickPosition ]
577 set xc [ lindex $pickWPPos 0 ]
578 set yc [ lindex $pickWPPos 1 ]
579 set zc [ lindex $pickWPPos 2 ]
580 set resample [ GetVTKVolume_dll ]
582 set indP [ [ probe_filter_{$widgets(work3D)}_{$actual_plane} GetOutput ] FindPoint $xc $yc $zc ]
583 set coordsP [ [ probe_filter_{$widgets(work3D)}_{$actual_plane} GetOutput ] GetPoint $indP ]
585 renderer_$widgets(work3D) AddActor [ \
587 sphere_2_$widgets(work3D) \
589 [ lindex $coordsP 0 ] [ lindex $coordsP 1 ] [ lindex $coordsP 2 ] \
595 set c1 [ sphere_1_$widgets(work3D) GetCenter ]
596 set c2 [ sphere_2_$widgets(work3D) GetCenter ]
597 set dist [ DistPoints \
606 $widgets(edtMeasure) delete 0 end
607 $widgets(edtMeasure) insert 0 "$dist"
610 [ $widgets(work3D) GetRenderWindow ] Render
614 proc u_mpr::ev_dbl_select_st_point { x y } {
616 # For programming facilities
617 upvar u_mpr::widgets widgets
618 upvar u_mpr::actual_plane actual_plane
619 upvar u_mpr::select_first select_first
621 set y [ expr [ lindex [ $widgets(work3D) configure -height ] 4 ] - $y - 1 ]
623 catch { renderer_$widgets(work3D) RemoveActor [ GetSphereActorName sphere_st_$widgets(work3D) ] }
624 DeleteSphere sphere_st_$widgets(work3D)
625 catch { tmp_picker_$widgets(work3D) Delete }
627 vtkWorldPointPicker tmp_picker_$widgets(work3D)
628 set pickWP [ tmp_picker_$widgets(work3D) Pick $x $y 0 renderer_$widgets(work3D) ]
629 set pickWPPos [ tmp_picker_$widgets(work3D) GetPickPosition ]
631 set xc [ lindex $pickWPPos 0 ]
632 set yc [ lindex $pickWPPos 1 ]
633 set zc [ lindex $pickWPPos 2 ]
634 set resample [ GetVTKVolume_dll ]
636 set indP [ [ probe_filter_{$widgets(work3D)}_{$actual_plane} GetOutput ] FindPoint $xc $yc $zc ]
637 set coordsP [ [ probe_filter_{$widgets(work3D)}_{$actual_plane} GetOutput ] GetPoint $indP ]
639 renderer_$widgets(work3D) AddActor [ \
641 sphere_st_$widgets(work3D) \
643 [ lindex $coordsP 0 ] [ lindex $coordsP 1 ] [ lindex $coordsP 2 ] \
646 set u_mpr::stPoint "[ lindex $coordsP 0 ] [ lindex $coordsP 1 ] [ lindex $coordsP 2 ]"
648 [ $widgets(work3D) GetRenderWindow ] Render
652 proc u_mpr::set_mouse_left_events { mask } {
654 # For programming facilities
655 upvar u_mpr::widgets widgets
658 catch { bind $widgets(work3D) <Any-ButtonPress> { ev_startMotion %W %x %y } }
659 catch { bind $widgets(work3D) <Any-ButtonRelease> { ev_endMotion %W %x %y } }
661 catch { bind $widgets(work3D) <B1-Motion> { evz_pan %W %x %y } }
665 proc u_mpr::set_mouse_right_events { mask } {
667 # For programming facilities
668 upvar u_mpr::widgets widgets
670 if { [ expr $mask & 0x4 ] == 0x4 } {
672 catch { bind $widgets(work3D) <ButtonPress-3> { ev_startMotion %W %x %y } }
673 catch { bind $widgets(work3D) <ButtonRelease-3> { ev_endMotion %W %x %y } }
674 catch { bind $widgets(work3D) <B3-Motion> { evz_zoom %W %x %y } }
677 if { [ expr $mask & 0x8 ] == 0x8 } {
679 catch { bind $widgets(work3D) <ButtonPress-3> { u_mpr::ev_start_window_level %x %y } }
680 catch { bind $widgets(work3D) <ButtonRelease-3> { } }
681 catch { bind $widgets(work3D) <B3-Motion> { u_mpr::ev_window_level %x %y } }