<<<<<<<<<<<<<<<<<

image_manager(IVM) Interactive View and Measureimage_manager(IVM)

NAME

image_manager - control display of multiple images in a window

DESCRIPTION

The image_manager class controls partitioning of a window into multiple regions and display of multiple images in those regions. Unlike its predecessor class, ximage_manager, it operates on widgets, not X windows, and instead of carving the widget up itself, it creates instances of other widgets within the widget it is passed as the parent.

To use the image_manager, script programmers must give the name of a manager widget that is to be the parent of the widgets it will create, and the name of a class of widgets to instantiate.

Each image widget supports a stack of images, each image having up to three pixmaps, an image pixmap, and overlay pixmap and a clip mask. The image pixmap is copied in the image widget first. The overlay pixmap is then copied into the image widget, using the clip mask to restrict the copy.

SUPERCLASS

object

INSTANCE VARIABLES

dimension defines the number of images along each side of the window being managed.

index defines the current image being operated on. Addressing images is one-based. The upper left hand image is (1,1). By convention, a zero in an index indicates the entire row or column. Thus an address of (1,0) selects all of column 1, while and address of (0,0) selects the entire array.

parent is the name of a widget to place the images in. This is accomplished by tiling the widget with instances of the class named by the image_widget_class, so it must be a manager widget. The image_manager sets the x, y, width, and height resources of the image_widget_class instances, so the parent must allow placement by those means. This makes the motif_bulletin_board class the best candidate for the parent widget.

image_widget_class is the class from which the various image widgets will be instantiated. It defaults to

"motif_drawing_area".

MESSAGES

@(x,y) Set the current index to (x,y). Synonym for index= (x,y).

backward! Set the paging direction for the current image(s) to backward when in cine loop mode.

cine_loop! Set the paging mode to cine for the current image(s). In this mode, the current image is always paged in the same direction, either front-to-back or back-to-front.

clip_masks+(args) Add args (names of one or more xbitmap objects) to the list of clip masks for the current images. Note that if more than one image is selected, all args will be appended to all images' list of clip masks. They are not apportioned one-by-one to the selected images.

clip_masks=(args) Set the list of clip masks for the current images to args (names of one or more xbitmap objects). Note that if more than one image is selected, all images' list of clip masks will be set to args. They are not apportioned one-by-one to the selected images.

clip_masks? Return the set of clip masks for the currently selected images. The order in which they are returned on the stack is undefined.

dimension=(x,y) Set the dimension of the image_manager object. If (x,y) is different than the current dimension, all image information is lost and all image widgets are freed.

dimension? Return the current x and y dimensions.

display! Display the current images in all selected image widgets.

display_widgets? Returns the names of the image widgets created by the image_manager.

forward! Set the paging direction for the current image(s) to forward when in cine loop mode.

image_pixmaps+(args) Add args (names of one or more xpixmap objects) to the list of image pixmaps for the current images. Note that if more than one image is selected, all args will be appended to all images' list of image pixmaps. They are not apportioned one-by-one to the selected images.

image_pixmaps=(args) Set the list of image pixmaps for the current images to args (names of one or more xpixmap objects). Note that if more than one image is selected, all images' list of image pixmaps will be set to args. They are not apportioned one-by-one to the selected images.

image_pixmaps? Return the set of image pixmaps for the currently selected images. The order in which they are returned on the stack is undefined.

image_size? Return the size of the image widgets use to tile the parent widget.

image_widget_class= Set the name of the class that will be used to tile the parent widget. Note that this does nothing immediately. If the image widgets are already created, setting a new image widget class will not delete them. An initialize! message will have to be sent to effect a change.

image_widget_class? Return the name of the class whose instances are used to tile the parent widget.

increment! Advances the index to the next element. If a single image is selected, the next image is selected (in reading order, left-to-right, then top-to-bottom). If an entire row (column) is selected, the next row (column) becomes the current one.

index= Set the current index to (x,y). Synonym for @ (x,y).

index? Return the current index.

initialize! Initialize the image manager. Any existing image widgets and image information are deleted.

next_image! Advance to the next image pixmap in each selected image widget. The direction to advance is governed by the current direction (forward or backward).

overlay_pixmaps+ Add args (names of one or more xpixmap objects) to the list of overlay pixmaps for the current images. Note that if more than one image is selected, all args will be appended to all images' list of overlay pixmaps. They are not apportioned one-by-one to the selected images.

overlay_pixmaps= Set the list of overlay pixmaps for the current images to args (names of one or more xpixmap objects). Note that if more than one image is selected, all images' list of overlay pixmaps will be set to args. They are not apportioned one-by-one to the selected images.

overlay_pixmaps? Return the set of overlay pixmaps for the currently selected images. The order in which they are returned on the stack is undefined.

parent= Set the parent widget to be tiled and managed.

parent? Return the parent widget

rewind! Reset all image pixmaps, overlay pixmaps, and clip masks in selected image widgets to 1.

spatial_loop! Set the paging mode to spatial for the current image(s). In this mode, the current image is paged front-to-back, then back-to-front.

message1= arg1 arg2 etc describe your message and its arguments here. Be sure to include any special considerations that the user should know about. (Now repeat the .TP line, the .BI line and the description lines for the rest of your messages.)

EXAMPLE

<xinit

<xcursors <motifinit <colormap_editor.meta <image_database.meta

scalar new: `window_width' = 512; scalar new: `window_height' = 512;

motif application=`ImageManager' create! ;

motif_form new: form parent=`motif' create! ;

xpseudo_color_visual new: `vis' match!;

xcolormap new: `cmap' id = [xdisplay default_colormap?] visual= `vis' ;

xprivate_cells new: `cells' colormap=`cmap' number_of_colors=24 ;

colormap_editor new: `cmap_ed' parent=`form' cells=`cells' @ `topAttachment' : [motif_constants field# `XmATTACH_FORM' ?] @ `leftAttachment' : [motif_constants field# `XmATTACH_FORM' ?] color! number_entries= 24 create! ;

motif_bulletin_board new: bb parent=`form' @ `width' : [window_width push! * 2 pop?] @ `height' : window_height @ `resizePolicy' : [motif_constants field# `XmRESIZE_NONE' ?] @ `marginHeight' : 0 @ `marginWidth' : 0 @ `topAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `topWidget' : [cmap_ed id?] @ `leftAttachment' : [motif_constants field# `XmATTACH_FORM' ?] create! ;

image_manager new: im

parent=bb dimension= (1,2) @(0,0) spatial_loop! ;

motif_push_button new: cycle1 parent=`form' @ `labelString' : `Advance Image 2' @ `topAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `topWidget' : [bb id?] @ `leftAttachment' : [motif_constants field# `XmATTACH_FORM' ?] activate_action=`advance2' create! ;

actions new: `advance2' tick_actions=` im @(1,2) next_image! display! ; draw_cursor ref_args=(`left_win', oldx, oldy) call! ref_args=(`right_win', oldx, oldy) call! ; xdisplay flush!; ' ;

motif_push_button new: cycleall parent=`form' @ `labelString' : `Advance All' activate_action=`advanceall' @ `topAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `topWidget' : [bb id?] @ `leftAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `leftWidget' : [cycle1 id?] create! ;

actions new: `advanceall' tick_actions=` im @(0,0) next_image! display! ; draw_cursor ref_args=(`left_win', oldx, oldy) call! ref_args=(`right_win', oldx, oldy) call! ;

xdisplay flush!; ' ;

motif_push_button new: start parent=`form' @ `labelString' : `Start Loop' activate_action=`start_image_loop' @ `topAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `topWidget' : [bb id?] @ `leftAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `leftWidget' : [cycleall id?] create! ;

actions new: `start_image_loop' tick_actions=` image_loop start!; ' ;

motif_push_button new: stop parent=`form' @ `labelString' : `Stop Loop' activate_action=`stop_image_loop' @ `topAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `topWidget' : [bb id?] @ `leftAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `leftWidget' : [start id?] create! ;

actions new: `stop_image_loop' tick_actions=` image_loop end!; ' ;

motif_scene new: `image_loop' resolution= 1 start_actions=` timer new: `t' reset! start!; image_loop duration= 1; ' tick_actions=` im @(1,1) next_image! display! ; draw_cursor ref_args=(`left_win', oldx, oldy) call! ;

xdisplay flush!; image_loop duration+ 1; ' end_actions=` t stop!; scalar new: `images_per_second' = [image_loop duration?] / [t time?] print:`value' ; ' ;

motif_push_button new: `read' parent=`form' @ `labelString' : `Read Study' activate_action=`image_popup_on' @ `topAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `topWidget' : [bb id?] @ `leftAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `leftWidget' : [stop id?] create! ;

motif_toggle_button new: `color_mode' parent=`form' value_changed_action=`toggle_color' @ `labelString' : `Color/Grayscale' @ `set' : 1 @ `topAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `topWidget' : [bb id?] @ `leftAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `leftWidget' : [read id?] create! ;

motif_push_button new: pause parent=`form' @ `labelString' : `Pause' activate_action=`interact' @ `topAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `topWidget' : [bb id?] @ `leftAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `leftWidget' : [color_mode id?] create! ;

motif_push_button new: done parent=`form' @ `labelString' : `Quit' activate_action=`exit' @ `topAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `topWidget' : [bb id?] @ `leftAttachment' : [motif_constants field# `XmATTACH_WIDGET' ?] @ `leftWidget' : [pause id?]

create! ;

actions new: `toggle_color' tick_actions=` logic new! = [cmap_ed color_mode?] true:` cmap_ed grayscale!; ' false:` cmap_ed color!; ' free! ; ' ;

actions new: `do_grayscale' tick_actions=`! do gray cmap_ed grayscale!; ' ;

actions new: `exit' tick_actions=` parser exit!; ' ;

actions new: `interact' tick_actions=` parser interactive!; ' ;

procedure new: `redisplay' in_formals=`widget' call_actions=` set_cursor ref_args= widget call!; im @(0,0) display!; xdisplay flush!; ' ;

xgc new: black_gc foreground=[motif_color color=`Black' pixel?] change! ;

xgc new: red_gc foreground=[motif_color color=`red' pixel?] change! ;

xpixmap new: overlay gc=black_gc width= window_width height= window_height create! fill_rectangle:(0,0,window_width,window_height) gc=red_gc fill_rectangle:( [window_width push! / 2 - 25 pop?], [window_height push! / 2 - 20 pop?], 50,40 ) ;

xbitmap new: clip_mask width= window_width height= window_height create! ;

xgc new: clip_mask_gc drawable=clip_mask clear_valuemask! foreground=0 background=1 change! ;

clip_mask gc=clip_mask_gc fill_rectangle:(0,0,window_width,window_height) ;

clip_mask_gc clear_valuemask! foreground= 1 background= 0 change! ;

clip_mask fill_rectangle:( [window_width push! / 2 - 25 pop?], [window_height push! / 2 - 20 pop?], 50,40 ) ;

motif_form_dialog new: `image_popup' parent=`motif' create! ;

actions new: `image_popup_on'

tick_actions=` image_popup on!; ' ;

image_database new: `db' parent=`image_popup' load_actions=` db field# `server' compute_number_slices! ; read_study tick!; image_popup off!; ' cancel_actions=`image_popup off!;' create! host=`esopus' ;

ivm_mapper new: `mapper' auto_level_on! width= window_width height= window_height image= [db field# `server' name?] cells=`cells' ;

xz_pixmap new: `x_image' width= window_width height= window_height ;

actions new: `read_study' tick_actions=` read @ `sensitive' : 0; read update_display!; xdisplay flush!;

im @ (0,0) image_pixmaps=() overlay_pixmaps=() clip_masks=() display! ; string new: `pm';

motif_scene new: `read_data_loop' duration= [ scalar new! = [db field# `server' number_slices?] / 2 integerize! ? free!

] resolution= 1 start_actions=` mapper strip_connectivity_on!; db field# `server' slice= 1 mask=0x7fff flush! ; ' tick_actions=` db field# `server' read!;

-- odd slices db field# `server' gradients_off!; pm = [xpixmap new! generate_name! name?]; x_image data=[mapper data?] create!; object # pm width= window_width height= window_height create! @(0,0) put_image: x_image ; im @ (1,1) image_pixmaps+ pm next_image! display! ; xdisplay flush!;

-- even slices db field# `server' slice+ 1;

pm = [xpixmap new! generate_name! name?]; x_image data=[mapper data?] create!; object # pm width= window_width height= window_height create! @(0,0) put_image: x_image ; im @ (1,2) image_pixmaps+ pm overlay_pixmaps+ overlay clip_masks+ clip_mask next_image! display! ;

xdisplay flush!; db field# `server' slice+ 1; oldx = -1;

oldy = -1; ' start! ;

read @ `sensitive' : 1; ' ;

im @(0,0) display!;

xfont_cursor new: `crosshairs' shape= XC_crosshair create! ;

xset_window_attributes new: `crosshair_att' cursor= `crosshairs' ;

procedure new: `set_cursor' ref_formals=`da' call_actions=` xwindow new! id= [da window_id?] xset_window_attributes= `crosshair_att' change_window_attributes! free! ; ' ;

collection new! members=[bb children?] expose_action=`redisplay' input_action=`grab_input' /* pretty much destroy the default drawing area translations */ /* to restrict the behavior to just what we want */ compress_motion_on! translations+`#replace <Motion>: DrawingAreaInput()' free! ;

xbuttonevent new: `evda'; scalar new: oldx = -1; scalar new: oldy = -1; xgc new: cursor_gc function=[XGCFunctions field# `GXinvert' ?] foreground= [motif_color color=`Blue' pixel?] change! ;

string new: `win_init' = `';

xwindow new: `left_win'; xwindow new: `right_win';

procedure new: `draw_cursor' compile_on! ref_formals=(`win', `x', `y') call_actions=` win draw_line:(0,y,window_width,y) draw_line:(x,0,x,window_height) ; ' ;

procedure new: `grab_input' in_formals=(`widget',`cb_action',`event') call_actions=` logic new! equal:(`',win_init) true:` win_init = `initialized!'; left_win id=[object # [im @(1,1) display_widgets?] window_id?] gc= cursor_gc ; right_win id=[object # [im @(1,2) display_widgets?] window_id?] gc= cursor_gc ; ' free! ;

evda id=event; draw_cursor ref_args=(`left_win', oldx, oldy) call! ref_args=(`left_win',[evda x?], [evda y?]) call! ref_args=(`right_win', oldx, oldy) call! ref_args=(`right_win',[evda x?], [evda y?]) call! ; xdisplay flush!; oldx = [evda x?]; oldy = [evda y?]; ' ;

motif on! start!;

SEE ALSO

ximage_manager, motif_bulletin_board, morif_drawing_area,

mio, ivm_mapper


Please send comments and suggestions to
consult@rpi.edu