
/* >h.image */
/*
   This file contains the image format and should be included
   in all AIM subroutines performing image processing tasks.

   The maximal image size is IMSIZEX * IMSIZEY.
   It consists of pixels of the type PIXEL.

   Within this image there is a window defined, on which the
   operations are performed.
   The dimension of this window is WINDOWX * WINDOWY.
   The window equals the image in the current version.

   Note: all subroutines should use these variables !
*/

#ifndef __image_h
#define __image_h 1



#define MAXSIG 100  /* maximum aantal signalen */

#define MIN_N 7   /* Minimale lengte van een record = 256 */
#define MAX_N 12  /* Maximale lengte van een record = 4096 */

#define DIAGRAM_SIZE  8096 /* grootte van het diagram */

#define DATA_PIXEL_FORMAT 0
#define DATA_FILE_SEQ 0

#define TIME 0
#define FREQ 1
#define AMPL 2
#define MAGN 3
#define PHAS 4



#define REAL 0
#define IMAG 1
#define COMP 2

#define REAL_M 0       /* Mode van het te plotten signal */
#define IMAG_M 1
#define HIST_M 2
#define MAGN_M 3
#define PHAS_M 4
#define BODE_M 5



#define ASM_ID_STRING "ASM version 1.00 User-File DOS Machine"

#define BPS_CHAR      8
#define BPS_SHORT    16
#define BPS_INT      32
#define BPS_FLOAT  3232
#define BPS_DOUBLE 6464
#define BPS_SAMPLE 6464

#define BOOL int

typedef double ASM_SAMPLE;


typedef struct diag {
	char *data;
	int  length;
	int  size;
} __attribute__ ((packed)) diag;

typedef struct
    { 
	unsigned short  pixel_format;   /* 0 = unpacked 1 = packed */
	unsigned short length;          /* Aantal samples per record */
	unsigned short n_channels;      /* Aantal channels */
	unsigned short file_seq;        /* File sequence number = 0 */
	unsigned short bits_p_samp;     /* bps 8, 16, 32, 3232, 6464 */
	unsigned short n_records;       /* Aantal records */
	unsigned short domain_id;       /* 0=time, 1=freq, 2=ampl, 3=magnitude, 4= fase */
	unsigned short datatype_id;     /* 0=real, 1=imaginair, 2= complex */
	ASM_SAMPLE *real_data;              /* pointer to real data */
	ASM_SAMPLE *imag_data;              /* pointer to imaginary data */
	unsigned short sample_rate;     /* Sample-rate in 10 Hz */
	unsigned short  reserved[19];   /* Gereserveerd */
	double numerical[24];
	char asm_id_string[74];
	char signal_name[32];
	char user_text[46];
	char date[30];
	char description[74];
} __attribute__ ((packed)) asm_header;




typedef struct Venster
{
	asm_header      header;
	unsigned int    alloc_size;              /* Geheugengrootte gereserveerd voor data */
	int             Wlenx;                   /* x - dimension        */
	int             Wleny;                   /* y - dimension       */
	int             display_mode;            /* don, <1-5>   */
	double          vscale;                  /* vertikale scale factor */
	double          hscale;                  /* horizontale scale factor */
	double          maximum;                 /* maximale waarde van een array  */
	double          minimum;                 /* minimale waarde van een array  */
	char            Name[40];                /* window name */
	char            filename[256];
	int             log;                      /* log axis ? */
	unsigned short  record_nr;               /* number of displayed record */
	unsigned short  channel_nr;              /* number of displayed channel */
	int             Mode;                    /* window containes real,imag,bode,phase,magn */
	BOOL            filled;                  /* window is used */
	int             image;                   /* window handle */
	diag            diagram;                 /* diagram structure */
} __attribute__ ((packed)) VENSTER;

#define  DataPixelFormat(vp)          (vp) -> header.pixel_format
#define  DataReal(vp)                 (vp) -> header.real_data
#define  DataImag(vp)                 (vp) -> header.imag_data
#define  DataBits_p_s(vp)             (vp) -> header.bits_p_samp
#define  DataChannels(vp)             (vp) -> header.n_channels
#define  DataSampleRate(vp)           (vp) -> header.sample_rate
#define  DataLength(vp)               (vp) -> header.length
#define  DataRecords(vp)              (vp) -> header.n_records
#define  DataFileSeq(vp)              (vp) -> header.file_seq
#define  DataDomain(vp)               (vp) -> header.domain_id
#define  DataType(vp)                 (vp) -> header.datatype_id
#define  DataNumerical(vp)            (vp) -> header.numerical
#define  DataRealMax(vp)              (vp) -> header.numerical[0]
#define  DataImagMax(vp)              (vp) -> header.numerical[1]
#define  DataRealMin(vp)              (vp) -> header.numerical[2]
#define  DataImagMin(vp)              (vp) -> header.numerical[3]
#define  DataIdString(vp)             (vp) -> header.asm_id_string
#define  DataSignalName(vp)           (vp) -> header.signal_name
#define  DataUserText(vp)             (vp) -> header.user_text
#define  DataDate(vp)                 (vp) -> header.date
#define  DataDescription(vp)          (vp) -> header.description
#define  DataReserved(vp)             (vp) -> header.reserved

#define  DataAllocSize(vp)            (vp) -> alloc_size
#define  Window_DispM(vp)             (vp) -> display_mode
#define  Window_Name(vp)              (vp) -> Name

#define  Window_Width(vp)             (vp) -> Wlenx
#define  Window_Height(vp)            (vp) -> Wleny
#define  Window_InUse(vp)             (vp) -> filled
#define  Window_File(vp)              (vp) -> filename
#define  Window_Mode(vp)              (vp) -> Mode
#define  Window_Handle(vp)            (vp) -> image
#define  Window_Diag(vp)              (vp) -> diagram
#define  Window_HistHandle(vp)        (vp) -> hist_wnd
#define  Window_HistData(vp)  (long *)(vp) -> hgram.Hdata
#define  Window_HistElem(vp)          (vp) -> hgram.Hlen
#define  Window_VScale(vp)            (vp) -> vscale
#define  Window_HScale(vp)            (vp) -> hscale
#define  Window_Max(vp)               (vp) -> maximum
#define  Window_Min(vp)               (vp) -> minimum
#define  Window_Log(vp)               (vp) -> log
#define  Window_Record(vp)            (vp) -> record_nr
#define  Window_Channel(vp)           (vp) -> channel_nr


/* Image types                    */

#define AIM 3
#define DEGAS 0
#define DEGASH 2
#define NEO 1
#define IMA 4
#define IFF 5
#define IMG 6
#define TIFF 7

#endif
