The "viewimg" Package

These routines are meant to provide a high level mechanism to create and manipulate viewable images (2-dimensional slices of Karma data structures). These viewable images utilise the world canvases available in the canvas package, hence the resulting code is device independent.

Library: karmagraphics
Link With: -lkarmagraphics

Functions

viewimg_colourbar_createCreate a colourbar world canvas for another world canvas.
viewimg_create_drag_and_zoom_interfaceCreate a drag and zoom user interface for a canvas.
viewimg_draw_edit_listDraw edit list into array associated with viewable image.
viewimg_draw_edit_objectDraw edit object into array associated with viewable image.
viewimg_header_position_funcPosition event callback.
viewimg_initInitialise the package for a particular canvas.
viewimg_create_restrCreate viewable image from 2D slice with restrictions.
viewimg_createCreate viewable image from 2D slice.
viewimg_create_from_iarrayCreate a viewable image from an Intelligent Array.
viewimg_create_sequenceCreate a sequence of viewable images from a 3D slice.
viewimg_create_sequence_from_iarrayCreate a sequence of viewable images from an Intelligent Array.
viewimg_create_rgbCreate a TrueColour viewable image.
viewimg_create_rgb2Create a TrueColour viewable image.
viewimg_create_rgb_sequenceCreate sequence of TrueColour viewable images from 3D slice.
viewimg_create_rgb_sequence2Create sequence of TrueColour viewable images from 3D slice.
viewimg_make_activeMake viewable image active and possibly refresh.
viewimg_set_activeMake viewable image active with controlled refresh.
viewimg_register_data_changeNotify data for viewable image has changed.
viewimg_destroyDestroy viewable image.
viewimg_get_activeGet the active ViewableImage associated with a world canvas.
viewimg_test_activeTest if viewable image is active.
viewimg_register_position_event_funcRegister position event callback.
viewimg_register_destroy_funcRegister destroy callback.
viewimg_fill_ellipseDraw an ellipse into an array associated with a viewable image.
viewimg_fill_polygonDraw a polygon into an array associated with a viewable image.
viewimg_get_canvas_attributesGet the viewable image attributes for a world canvas.
viewimg_set_canvas_attributesSet the viewable image attributes for a world canvas.
viewimg_get_attributesGet the attributes for a viewable image.
viewimg_set_attributesSet the attributes for a viewable image.
viewimg_set_array_attributesSet the attributes for an array of viewable images.
viewimg_partial_refreshPerform a partial refresh of a canvas.
viewimg_get_worldcanvasGet the world canvas for a viewable image.
viewimg_statistics_position_funcPosition event callback.
viewimg_statistics_geom_funcProcess a geometry editor event on a pixel canvas.
viewimg_statistics_computeCompute and display statistics for a subimage.
viewimg_track_computeCompute track strings.
viewimg_values_position_funcPosition event callback.
viewimg_values_geom_funcProcess a geometry editor event on a pixel canvas.
viewimg_values_displayCompute and display values for a subimage.

Prototype Functions

viewimg_PROTO_position_funcPosition event callback.
viewimg_PROTO_destroy_funcProcess a destroy event on a ViewableImage.

Tables

viewimg_CANVAS_ATTRIBUTESList of canvas attributes for viewable images
viewimg_VIMAGE_ATTRIBUTESList of attributes for viewable images


Functions


EXPERIMENTAL FUNCTION: subject to change without notice

KWorldCanvas viewimg_colourbar_create (KWorldCanvas main_wc)

Create a colourbar world canvas for another world canvas.

Parameters:

Returns: The colourbar world canvas on success, else NULL. This will be automatically destroyed when the main world canvas is destroyed.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

KPixCanvasEditorContext viewimg_create_drag_and_zoom_interface (KWorldCanvas canvas)

This routine will create a drag and zoom user interface for a world canvas. When the user presses the left mouse button in the canvas and moves the mouse with the button still pressed a rubber-band box will be drawn on the canvas. When the left mouse button is released the image in the rubber-banded box is zoomed to fill as much of the canvas as is possible, depending on the zoom policy.

Parameters:

Returns: The KPixCanvasEditorContext created for rubber-banding. Extra key bindings may be added to this context.
Multithreading Level: Unsafe


flag viewimg_draw_edit_list (ViewableImage vimage, KImageEditList ilist)

This routine will draw a list of edit objects to the 2-dimensional data associated with a viewable image object.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag viewimg_draw_edit_object (ViewableImage vimage, char *object)

This routine will draw one edit object to the 2-dimensional data associated with a viewable image object.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag viewimg_header_position_func (ViewableImage vimage, double x, double y, void *value, unsigned int event_code, void *e_info, void **f_info, double x_lin, double y_lin, unsigned int value_type)

This routine is a position event consumer for a world canvas which has a number of ViewableImage objects associated with it.

Parameters:

Returns: TRUE if the event was consumed, else FALSE indicating that the event is still to be processed.
Multithreading Level: Unsafe


void viewimg_init (KWorldCanvas canvas)

This routine will initialise the viewimg package for a particular world canvas. Calling this routine causes a number of callback routines internal to the package to be registered with the canvas (such as refresh and position event callbacks). The use of this routine is optional at the moment: the routines which create viewable images perform this function automatically. In version 2.0 of Karma, this use of this routine before creating viewable images will become mandatory.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


ViewableImage viewimg_create_restr (KWorldCanvas canvas, multi_array *multi_desc, array_desc *arr_desc, char *slice, unsigned int hdim, unsigned int vdim, unsigned int elem_index, unsigned num_restr, CONST char **restr_names, CONST double *restr_values)

This routine will create a PseudoColour viewable image object from a 2-dimensional slice of a Karma data structure. At a later time, this viewable image may be made visible. This routine will not cause the canvas to be refreshed.

Parameters:

Returns: A viewable image on success, else NULL.
Multithreading Level: Unsafe
Note:


ViewableImage viewimg_create (KWorldCanvas canvas, multi_array *multi_desc, array_desc *arr_desc, char *slice, unsigned int hdim, unsigned int vdim, unsigned int elem_index)

This routine will create a PseudoColour viewable image object from a 2-dimensional slice of a Karma data structure. At a later time, this viewable image may be made visible. This routine will not cause the canvas to be refreshed.

Parameters:

Returns: A viewable image on success, else NULL.
Multithreading Level: Unsafe
Note:


ViewableImage viewimg_create_from_iarray (KWorldCanvas canvas, iarray array, flag swap)

This routine will create a viewable image object from a 2-dimensional Intelligent Array. At a later time, this viewable image may be made visible. This routine will not cause the canvas to be refreshed. Many viewable images may be associated with a single canvas.

Parameters:

Returns: A viewable image on success, else NULL.
Multithreading Level: Unsafe
Note:


ViewableImage * viewimg_create_sequence (KWorldCanvas canvas, multi_array *multi_desc, array_desc *arr_desc, char *cube, unsigned int hdim, unsigned int vdim, unsigned int fdim, unsigned int elem_index)

This routine will create a sequence of viewable image objects from a 3-dimensional cube of a Karma data structure. At a later time, this sequence of viewable images may be made visible in any order. This routine will not cause the canvas to be refreshed.

Parameters:

Returns: A pointer to a dynamically allocated array of viewable image objects on success, else NULL.
Multithreading Level: Unsafe
Note:


ViewableImage * viewimg_create_sequence_from_iarray (KWorldCanvas canvas, iarray array, unsigned int hdim, unsigned int vdim, unsigned int fdim)

This routine will create a sequence of viewable image objects from a 3-dimensional Intelligent Array. At a later time, this sequence of viewable images may be made visible in any order. This routine will not cause the canvas to be refreshed.

Parameters:

Returns: A pointer to a dynamically allocated array of viewable image objects on success, else NULL.
Multithreading Level: Unsafe
Note:


ViewableImage viewimg_create_rgb (KWorldCanvas canvas, multi_array *multi_desc, array_desc *arr_desc, char *slice, unsigned int hdim, unsigned int vdim, unsigned int red_index, unsigned int green_index, unsigned int blue_index, unsigned num_restr, CONST char **restr_names, CONST double *restr_values)

This routine will create a TrueColour viewable image object from a 2-dimensional slice of a Karma data structure. At a later time, this viewable image may be made visible. This routine will not cause the canvas to be refreshed.

Parameters:

Returns: A viewable image on success, else NULL.
Multithreading Level: Unsafe
Note:


EXPERIMENTAL FUNCTION: subject to change without notice

ViewableImage viewimg_create_rgb2 (KWorldCanvas canvas, multi_array *multi_desc, array_desc *arr_desc, array_pointer *arrayp, char *slice, unsigned int hdim, unsigned int vdim, unsigned int red_index, unsigned int green_index, unsigned int blue_index, unsigned num_restr, CONST char **restr_names, CONST double *restr_values)

This routine will create a TrueColour viewable image object from a 2-dimensional slice of a Karma data structure. At a later time, this viewable image may be made visible. This routine will not cause the canvas to be refreshed.

Parameters:

Returns: A viewable image on success, else NULL.
Multithreading Level: Unsafe
Note:


ViewableImage * viewimg_create_rgb_sequence (KWorldCanvas canvas, multi_array *multi_desc, array_desc *arr_desc, char *cube, unsigned int hdim, unsigned int vdim, unsigned int fdim, unsigned int red_index, unsigned int green_index, unsigned int blue_index, unsigned num_restr, CONST char **restr_names, CONST double *restr_values)

This routine will create a sequence of TrueColour viewable image objects from a 3-dimensional cube of a Karma data structure. At a later time, this sequence of viewable images may be made visible in any order. This routine will not cause the canvas to be refreshed.

Parameters:

Returns: A viewable image on success, else NULL.
Multithreading Level: Unsafe
Note:


ViewableImage * viewimg_create_rgb_sequence2 (KWorldCanvas canvas, multi_array *multi_desc, array_desc *arr_desc, array_pointer *arrayp, char *cube, unsigned int hdim, unsigned int vdim, unsigned int fdim, unsigned int red_index, unsigned int green_index, unsigned int blue_index, unsigned num_restr, CONST char **restr_names, CONST double *restr_values)

This routine will create a sequence of TrueColour viewable image objects from a 3-dimensional cube of a Karma data structure. At a later time, this sequence of viewable images may be made visible in any order. This routine will not cause the canvas to be refreshed.

Parameters:

Returns: A viewable image on success, else NULL.
Multithreading Level: Unsafe
Note:


flag viewimg_make_active (ViewableImage vimage)

This routine will make a viewable image the active image for its associated world canvas. The canvas is then refreshed (possibly resized), provided that the new viewable image was not already active.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
See Also: viewimg_set_active.


flag viewimg_set_active (ViewableImage vimage, flag refresh)

This routine will make a viewable image the active image for its associated world canvas.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe
See Also: viewimg_make_active.


flag viewimg_register_data_change (ViewableImage vimage)

This routine will register a change in the Karma data structure associated with a viewable image. If the viewable image is active, it will be immediately redrawn on its canvas.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


void viewimg_destroy (ViewableImage vimage)

This routine will destroy a viewable image. If this is not called prior to process exit, shared memory segments could remain after the process exits.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe
Note:


ViewableImage viewimg_get_active (KWorldCanvas canvas)

Get the active ViewableImage associated with a world canvas.

Parameters:

Returns: The active viewable image on success, else NULL (indicating no viewable image is active for the canvas).
Multithreading Level: Unsafe


flag viewimg_test_active (ViewableImage vimage)

This routine will test if a viewable image is the active image for its associated world canvas.

Parameters:

Returns: TRUE if the viewable image is actice, else FALSE.
Multithreading Level: Unsafe


KCallbackFunc viewimg_register_position_event_func (KWorldCanvas canvas, flag (*func) (), void *f_info)

This routine will register a position event function for a world canvas which has a number of ViewableImage objects associated with it. The position event function will be called whenever a position event on the canvas has not been consumed. Many position event functions may be registered per canvas. The first function registered is the first function called upon a position event.

Parameters:

Returns: A handle to a KCallbackFunc object.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

KCallbackFunc viewimg_register_destroy_func (ViewableImage vimage, void (*func) (), void *info)

This routine will register a destroy function for a viewable image. The function will be called when the viewable image is destroyed. Many destroy functions may be registered per vimage. The first function registered is the first function called upon destruction.

Parameters:

Returns: A KCallbackFunc object. On failure, the process aborts.
Multithreading Level: Unsafe


flag viewimg_fill_ellipse (ViewableImage vimage, double centre_x, double centre_y, double radius_x, double radius_y, double value[2])

This routine will draw a filled ellipse into a 2 dimensional slice of data associated with a viewable image.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


flag viewimg_fill_polygon (ViewableImage vimage, edit_coord *coords, unsigned int num_vertices, double value[2])

This routine will draw a filled polygon into a 2 dimensional slice of data associated with a viewable image.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


void viewimg_get_canvas_attributes (KWorldCanvas canvas, ...)

Get the viewable image attributes for a world canvas.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void viewimg_set_canvas_attributes (KWorldCanvas canvas, ...)

This routine will control the autoscaling options used when viewable images are displayed on their associated world canvas.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe
Note:


void viewimg_get_attributes (ViewableImage vimage, ...)

Get the attributes for a viewable image.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void viewimg_set_attributes (ViewableImage vimage, ...)

Set the attributes for a viewable image.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


void viewimg_set_array_attributes (ViewableImage *vimages, unsigned int len, ...)

Set the attributes for an array of viewable images.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag viewimg_partial_refresh (KWorldCanvas canvas, unsigned int num_areas, KPixCanvasRefreshArea *areas)

This routine will perform a partial refresh of a canvas. This call is similar to kwin_partial_refresh except that areas are not cleared prior to drawing if they lie within the image boundary.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


KWorldCanvas viewimg_get_worldcanvas (ViewableImage vimage)

Get the world canvas for a viewable image.

Parameters:

Returns: The KWorldCanvas object.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag viewimg_statistics_position_func (ViewableImage vimage, double x, double y, void *value, unsigned int event_code, void *e_info, void **f_info, double x_lin, double y_lin, unsigned int value_type, double x_im, double y_im, int x_pix, int y_pix)

This routine is a position event consumer for a world canvas which has a number of ViewableImage objects associated with it.

Parameters:

Returns: TRUE if the event was consumed, else FALSE indicating that the event is still to be processed.
Multithreading Level: Unsafe
Note:


EXPERIMENTAL FUNCTION: subject to change without notice

flag viewimg_statistics_geom_func (KPixCanvasEditorContext context, KPixCanvas canvas, unsigned int object_type, unsigned int num_coords, CONST int *x, CONST int *y, unsigned int raw_event_code, void *raw_e_info, void **f_info)

Process a geometry editor event on a pixel canvas.

Parameters:

Returns: TRUE if the event was consumed, else FALSE indicating that the event is still to be processed.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag viewimg_statistics_compute (ViewableImage vimage, double lx0, double ly0, double lx1,double ly1)

Compute and display statistics for a subimage.

Parameters:

Returns: TRUE on success, else FALSE.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

void viewimg_track_compute (ViewableImage vimage, void *value, unsigned int value_type, double x, double y, double x_im, double y_im, char pix_string[STRING_LENGTH], char world_string[STRING_LENGTH], char extra_string[STRING_LENGTH])

Compute track strings.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag viewimg_values_position_func (ViewableImage vimage, double x, double y, void *value, unsigned int event_code, void *e_info, void **f_info, double x_lin, double y_lin, unsigned int value_type, double x_im, double y_im, int x_pix, int y_pix)

This routine is a position event consumer for a world canvas which has a number of ViewableImage objects associated with it.

Parameters:

Returns: TRUE if the event was consumed, else FALSE indicating that the event is still to be processed.
Multithreading Level: Unsafe
Note:


EXPERIMENTAL FUNCTION: subject to change without notice

flag viewimg_values_geom_func (KPixCanvasEditorContext context, KPixCanvas canvas, unsigned int object_type, unsigned int num_coords, CONST int *x, CONST int *y, unsigned int raw_event_code, void *raw_e_info, void **f_info)

Process a geometry editor event on a pixel canvas.

Parameters:

Returns: TRUE if the event was consumed, else FALSE indicating that the event is still to be processed.
Multithreading Level: Unsafe


EXPERIMENTAL FUNCTION: subject to change without notice

flag viewimg_values_display (ViewableImage vimage, flag scaled, flag force, double lx0, double ly0, double lx1,double ly1)

Compute and display values for a subimage.

Parameters:

Returns: TRUE on success, else FALSE (too many values).
Multithreading Level: Unsafe


Prototype Functions


flag viewimg_PROTO_position_func (ViewableImage vimage, double x, double y, void *value, unsigned int event_code, void *e_info, void **f_info, double x_lin, double y_lin, unsigned int value_type, double x_im, double y_im, int x_pix, int y_pix)

This routine is a position event consumer for a world canvas which has a number of ViewableImage objects associated with it. Most co-ordinate values are quantised to the nearest image pixel centre.

Parameters:

Returns: TRUE if the event was consumed, else FALSE indicating that the event is still to be processed.
Multithreading Level: Unsafe
Note:


void viewimg_PROTO_destroy_func (void *info)

Process a destroy event on a ViewableImage.

Parameters:

Returns: Nothing.
Multithreading Level: Unsafe


Tables


viewimg_CANVAS_ATTRIBUTES List of canvas attributes for viewable images

Name Type Meaning
VIEWIMG_ATT_END End of varargs list
VIEWIMG_ATT_AUTO_X flag Enable automatic horizontal scaling
VIEWIMG_ATT_AUTO_Y flag Enable automatic vertical scaling
VIEWIMG_ATT_AUTO_V flag Enable automatic intensity scaling
VIEWIMG_ATT_INT_X flag Force integer horizontal zoom-in/zoom-out factor
VIEWIMG_ATT_INT_Y flag Force integer vertical zoom-in/zoom-out factor
VIEWIMG_ATT_MAINTAIN_ASPECT flag Maintain data image aspect ratio
VIEWIMG_ATT_ALLOW_TRUNCATION flag Allow shrunken images to be truncated
VIEWIMG_ATT_ENABLE_PANNING flag Enable panning mode
VIEWIMG_ATT_PAN_CENTRE_X flag Horizontal panning centre
VIEWIMG_ATT_PAN_CENTRE_Y flag Horizontal panning centre
VIEWIMG_ATT_PAN_CENTRE_Y flag Vertical panning centre
VIEWIMG_ATT_PAN_MAGNIFICATION unsigned int Panner magnification


viewimg_VIMAGE_ATTRIBUTES List of attributes for viewable images

Name Get Type Set Type Meaning
VIEWIMG_VATT_END End of varargs list
VIEWIMG_VATT_TRUECOLOUR flag * Image is TrueColour
VIEWIMG_VATT_ARRAY_DESC array_desc ** The array descriptor for the image
VIEWIMG_VATT_SLICE char ** Start of the image data
VIEWIMG_VATT_HDIM unsigned int * The horizontal dimension
VIEWIMG_VATT_VDIM unsigned int * The vertical dimension
VIEWIMG_VATT_PSEUDO_INDEX unsigned int * The PseudoColour element index
VIEWIMG_VATT_RED_INDEX unsigned int * The TrueColour red element index
VIEWIMG_VATT_GREEN_INDEX unsigned int * The TrueColour green element index
VIEWIMG_VATT_BLUE_INDEX unsigned int * The TrueColour blue element index
VIEWIMG_VATT_MULTI_ARRAY multi_array ** The multi_array descriptor
VIEWIMG_VATT_DATA_SCALE double * double PsueodoColour data multiplier
VIEWIMG_VATT_DATA_OFFSET double * double PsueodoColour data offset
VIEWIMG_VATT_VALUE_MIN double * double PseudoColour minimum value override
VIEWIMG_VATT_VALUE_MAX double * double PseudoColour maximum value override


Back to Karma Home Page
Contact: Richard Gooch
Web Development: Ariel Internet Services