From: hennecke@microelectronic.e-technik.th-darmstadt.de (Marcus Hennecke)
Newsgroups: comp.soft-sys.khoros
Subject: Re: 2 questions - toolboxes & cantata programs
Date: 18 Aug 92 13:59:31 GMT

jason@tfs.com writes:
> 1:	Do I have to modify the repos/cantata/ panes to integrate a
> toolbox with cantata

No, according to FAQ, answer 45:

	Finally, you will want to make use of your new, modified cantata UIS 
	form instead of the original, using:

	% cantata -restore {toolbox name}/repos/cantata/cantata.form

	or by specifying this alternative cantata.form file in your
	.Xdefaults file, as in:

	cantata.Form: {toolbox name}/repos/cantata/cantata.form


> 2:	How do I used header information in a cantata program.
> 	In particular I often want to do some processing that needs
> 	to know the length/width of the image.
> 	I do it manually for each image now, but I would much rather
> 	be able to do it automatically.

I have written a program, vheader, which can store header information
in variables. These variables can then later be used when supplying
parameters for other programs. I frequently use it when I want to multiply
a signal with some function, but the number of bands or the size may vary.
It also allows you to change the comment. This is not a very nice solution.
The comment is passed on the command line as any other parameter. Thus, you
should enclose it in quotes. Below you will find the .pane file and the
.prog file. (Yes, my previous question about how to set a cantata variable
referred to exactly this program).

Hope this helps,

Marcus

Pane-file:

-F 4.2 1 0 170x7+10+20 +35+1 'CANTATA Visual Programming Environment for the KHOROS System' cantata
-M 1 1 100x40+10+20 +23+1 'This is a new subform.' subform1
-P 1 0 80x38+22+2 +0+0 'Add comment and extract header info' vheader
-I 1 0 0 1 0 0 50x1+2+2 +0+0 ' ' 'Input Image' 'input image' i
-O 1 0 1 0 0 0 50x1+2+3 +0+0 ' ' 'Output Image' 'resulting output image' o
-s 1 0 1 0 0 50x3+2+5 +0+0 ' ' 'Comment:' 'Comment string to be added' c
-b +2+8 'For each item, specify a data variable name'
-s 1 0 1 0 0 50x1+2+9 +0+0 ' ' 'File Type       ' 'File Type Variable' ftv
-s 1 0 1 0 0 50x1+2+10 +0+0 ' ' 'Release         ' 'Release Variable' rv
-s 1 0 1 0 0 50x1+2+11 +0+0 ' ' 'Version         ' 'Version Variable' vv
-s 1 0 1 0 0 50x1+2+12 +0+0 ' ' 'Machine Dep.    ' 'Machine Dependency Variable' mdv
-s 1 0 1 0 0 50x1+2+13 +0+0 ' ' 'Row Size        ' 'Row Size Variable' rsv
-s 1 0 1 0 0 50x1+2+14 +0+0 ' ' 'Column Size     ' 'Column Size Variable' csv
-s 1 0 1 0 0 50x1+2+15 +0+0 ' ' 'Subrow Size     ' 'Subrow Size Variable' ssv
-s 1 0 1 0 0 50x1+2+16 +0+0 ' ' 'Subimage x Loc. ' 'Subimage x-Location Variable' sxv
-s 1 0 1 0 0 50x1+2+17 +0+0 ' ' 'Subimage y Loc. ' 'Subimage y-Location Variable' syv
-s 1 0 1 0 0 50x1+2+18 +0+0 ' ' 'Pixel x-Size    ' 'Pixel x-Size Variable' pxv
-s 1 0 1 0 0 50x1+2+19 +0+0 ' ' 'Pixel y-Size    ' 'Pixel y-Size Variable' pyv
-s 1 0 1 0 0 50x1+2+20 +0+0 ' ' 'Location Type   ' 'Location Type Variable' ltv
-s 1 0 1 0 0 50x1+2+21 +0+0 ' ' 'Location Dim.   ' 'Location Dimension Variable' ldv
-s 1 0 1 0 0 50x1+2+22 +0+0 ' ' 'Num. of Images  ' 'Number of Images Variable' niv
-s 1 0 1 0 0 50x1+2+23 +0+0 ' ' 'Num. of Bands   ' 'Number of Data Bands Variable' nbv
-s 1 0 1 0 0 50x1+2+24 +0+0 ' ' 'Storage Type    ' 'Storage Type Variable' stv
-s 1 0 1 0 0 50x1+2+25 +0+0 ' ' 'Encoding Scheme ' 'Encoding Scheme Variable' esv
-s 1 0 1 0 0 50x1+2+26 +0+0 ' ' 'Map Scheme      ' 'Map Scheme Variable' msv
-s 1 0 1 0 0 50x1+2+27 +0+0 ' ' 'Map Storage Type' 'Map Storage Type Variable' mstv
-s 1 0 1 0 0 50x1+2+28 +0+0 ' ' 'Map Row Size    ' 'Map Row Size Variable' mrsv
-s 1 0 1 0 0 50x1+2+29 +0+0 ' ' 'Map Column Size ' 'Map Column Size Variable' mcsv
-s 1 0 1 0 0 50x1+2+30 +0+0 ' ' 'Map Subrow Size ' 'Map Subrow Size Variable' mssv
-s 1 0 1 0 0 50x1+2+31 +0+0 ' ' 'Map Enable      ' 'Map Enable Variable' mev
-s 1 0 1 0 0 50x1+2+32 +0+0 ' ' 'Maps per Cycle  ' 'Maps per Cycle Variable' mpcv
-s 1 0 1 0 0 50x1+2+33 +0+0 ' ' 'Color Space Mod.' 'Color Space Model Variable' csmv
-H 1  13x2+39+35 'Help !!' 'documentation for vheader' $DUESENTRIEB/doc/manpages/vheader.1
-R 1 0 4 13x2+1+35 'Execute' 'do operation' vheader
-E
-E
-E


Prog-File:

-authors
Marcus Hennecke
-authors_end

-short_prog_description
Adds comment text to header and extracts information from header.
-short_prog_description_end

-short_lib_description
-short_lib_description_end

-man1_long_description
.I vheader
allows the user to specify the comment text of a VIFF file and to copy information from the header to variables. For each item in the header a separate variable can be specified. The selected items will then be stored in the specified variables.
-man1_long_description_end

-man1_examples
vheader -i ball.xv -rsv row_size
.LP
Will store the row size of the image "ball.xv" in the variable "row_size".
-man1_examples_end

-man1_restrictions
Only such items can be selected as specified in the Khoros Programmer's Manual Version 1.0.
-man1_restrictions_end

-man1_see_also
KHOROS MANUAL, Volume II: Programmer's Manual, Release 1.0, Section 1.J for a detailed description of the header items.
-man1_see_also_end

-man3_long_description
-man3_long_description_end

-man3_restrictions
-man3_restrictions_end

-man3_see_also
-man3_see_also_end

-usage_additions
-usage_additions_end

-include_includes
-include_includes_end

-include_additions
-include_additions_end

-include_macros
-include_macros_end

-main_variable_list
    struct xvimage *image, *readimage();
-main_variable_list_end

-main_before_lib_call
    if (check_args()) exit(1);

    image = readimage(vheader->i_file);
    if (image == NULL)
      {
        fprintf(stderr,"vheader: readimage failed!\n");
        exit(1);
      }
-main_before_lib_call_end

-main_library_call
if(vheader->c_flag)    strcpy(image->comment,vheader->c_string);

if(vheader->ftv_flag)  printf("%s = %d\n",vheader->ftv_string,image->file_type);
if(vheader->rv_flag)   printf("%s = %d\n",vheader->rv_string,image->release);
if(vheader->vv_flag)   printf("%s = %d\n",vheader->vv_string,image->version);
if(vheader->mdv_flag)  printf("%s = %d\n",vheader->mdv_string,image->machine_dep);
if(vheader->rsv_flag)  printf("%s = %ld\n",vheader->rsv_string,image->row_size);
if(vheader->csv_flag)  printf("%s = %ld\n",vheader->csv_string,image->col_size);
if(vheader->ssv_flag)  printf("%s = %ld\n",vheader->ssv_string,image->subrow_size);
if(vheader->sxv_flag)  printf("%s = %ld\n",vheader->sxv_string,image->startx);
if(vheader->syv_flag)  printf("%s = %ld\n",vheader->syv_string,image->starty);
if(vheader->pxv_flag)  printf("%s = %g\n",vheader->pxv_string,image->pixsizx);
if(vheader->pyv_flag)  printf("%s = %g\n",vheader->pyv_string,image->pixsizy);
if(vheader->ltv_flag)  printf("%s = %ld\n",vheader->ltv_string,image->location_type);
if(vheader->ldv_flag)  printf("%s = %ld\n",vheader->ldv_string,image->location_dim);
if(vheader->niv_flag)  printf("%s = %ld\n",vheader->niv_string,image->num_of_images);
if(vheader->nbv_flag)  printf("%s = %ld\n",vheader->nbv_string,image->num_data_bands);
if(vheader->stv_flag)  printf("%s = %ld\n",vheader->stv_string,image->data_storage_type);
if(vheader->esv_flag)  printf("%s = %ld\n",vheader->esv_string,image->data_encode_scheme);
if(vheader->msv_flag)  printf("%s = %ld\n",vheader->msv_string,image->map_scheme);
if(vheader->mstv_flag) printf("%s = %ld\n",vheader->mstv_string,image->map_storage_type);
if(vheader->mrsv_flag) printf("%s = %ld\n",vheader->mrsv_string,image->map_row_size);
if(vheader->mcsv_flag) printf("%s = %ld\n",vheader->mcsv_string,image->map_col_size);
if(vheader->mssv_flag) printf("%s = %ld\n",vheader->mssv_string,image->map_subrow_size);
if(vheader->mev_flag)  printf("%s = %ld\n",vheader->mev_string,image->map_enable);
if(vheader->mpcv_flag) printf("%s = %ld\n",vheader->mpcv_string,image->maps_per_cycle);
if(vheader->csmv_flag) printf("%s = %ld\n",vheader->csmv_string,image->color_space_model);
-main_library_call_end

-main_after_lib_call
    if (vheader->o_flag)
      {
        (void) writeimage(vheader->o_file,image);
      }
-main_after_lib_call_end

-library_includes
-library_includes_end

-library_input
-library_input_end

-library_output
-library_output_end

-library_def
-library_def_end

-library_code
-library_code_end

-library_mods
-library_mods_end