/******************************************************************************/
/* Copyright 1995 MBARI                                                       */
/******************************************************************************/
/* Summary  : CTD Data Display Graphics Module Definitions                    */
/* Filename : ctdDisplay.h                                                    */
/* Author   : Janice Tarrant                                                  */
/* Project  : Tiburon                                                         */
/* Version  : Version 1.0                                                     */
/* Created  : 02/02/95                                                        */
/* Modified :                                                                 */
/* Archived :                                                                 */
/******************************************************************************/
/* Modification History :                                                     */
/* $Header: /usr/tiburon/unix/gui/ctd/RCS/ctdDisplay.h,v 1.1 1998/03/12 17:53:02 oreilly Exp $
 * $Log: ctdDisplay.h,v $
 * Revision 1.1  1998/03/12 17:53:02  oreilly
 * Initial revision
 *
 *
 */
/******************************************************************************/
#include <stdio.h>

#ifndef TIBURON_CTD_DISPLAY_H
#define TIBURON_CTD_DISPLAY_H

#define VERIFY_ON            0			/* verify input on            */
#define TRACE_ON             0			/* trace writes on            */
#define DEBUG_ON             0			/* debug writes on            */

#define DATA_UPDATE_RATE     1.0		/* data update rate (Hz)      */
#define NUM_HOURS_OF_DATA    12			/* hours of data storage      */
#define MINUTES_PER_HOUR     60			/* minutes per hour           */
#define SECONDS_PER_MINUTE   60			/* seconds per minute         */
						/* seconds per hour           */
#define SECONDS_PER_HOUR     SECONDS_PER_MINUTE * MINUTES_PER_HOUR
						/* number of data points      */
#define NUM_DATA_POINTS      (Int32) (NUM_HOURS_OF_DATA * SECONDS_PER_HOUR * \
				      DATA_UPDATE_RATE)
#define BAD_DATA_VALUE       -99.9		/* bad data value             */
#define NO_PLOT_VALUE        -999		/* do not plot data           */
#define EPSILON              0.00001		/* float zero                 */

#define AXIS_LABEL_LENGTH    100		/* axis label length          */
#define COLOUR_NAME_LENGTH   30			/* colour name length         */
#define TICK_LABEL_LENGTH    10			/* tick mark label length     */
#define STRING_LENGTH        30         	/* default string length      */
#define DM_ITEM_NAME_LEN     60         	/* data mgr item name length  */
						/* mark file directory        */
#define MARK_FILE_DIR        "/usr/vw5.1.1/mbari/ctdDisplay/"

#define NUM_DISPLAY_ITEMS    17			/* number of display items    */
#define NUM_VARS             5			/* number of variables        */
#define NUM_X_VARS           4			/* number of x variables      */
#define NUM_STATUS_VARS      5			/* num status line variables  */
#define NUM_MARKS            100		/* number of mark values      */
#define NUM_DIVISIONS        50			/* number of divisions        */
#define NUM_TICKS            NUM_DIVISIONS+1	/* number of tick marks       */
#define NUM_COLOURS          7			/* number of colours          */
#define NUM_UNITS            3			/* number of units            */
#define NUM_Y_WORDS          4			/* number of y label words    */

#define NUM_SEGMENTS         6			/* number of axes segments    */
#define AXES_OFFSET1         40			/* display axes offset        */
#define AXES_OFFSET2         80			/* display axes offset        */
#define AXES_OFFSET3         5			/* display axes offset        */
#define AXES_OFFSET4         15			/* display axes offset        */
#define OFFSET_PER_CHAR      8			/* display label offset       */
#define COORD_CHAR_OFFSET    12			/* coordinate char offset     */

#define ERASE_ON             TRUE		/* erase flag on              */
#define ERASE_OFF            FALSE		/* erase flag off             */

						/* maximum macro              */
#define MAX(A, B)       ( (A) > (B) ? (A) : (B) )

						/* variable numbers           */
typedef enum { X1, X2, X3, X4, Y } varNum;

                                        	/* display variable options   */
typedef enum { BEAM_ATTENUATION, BEAM_PERCENT, CONDUCTIVITY,
               DEPTH,            OXYGEN,       OXYGEN_CURRENT,
               OXYGEN_TEMP,      PRESSURE,     SALINITY, 
               SCAN_NUMBER,      SIGMA_T,      SIGMA_THETA, 
               SOUND_VELOCITY,   TEMPERATURE,  THETA, 
               TIME,             TRANSMISSION,
               NO_VAR } itemVariables;

						/* display item parameters    */
typedef enum { LABEL, MIN_VALUE, MAX_VALUE, COLOUR,
	       MAJOR_DIVISIONS, TIME_UNITS } itemParameters;

						/* units of time              */
typedef enum { NO_UNITS, HOURS, MINUTES, SECONDS } unitsOfTime;

						/* display colours            */
typedef enum { NO_COLOUR, RED, GREEN, BLUE, CYAN,
	       YELLOW, MAGENTA, WHITE } displayColours;

						/* axes segment position      */
typedef enum { LEFT, RIGHT, TOP, BOTTOM, TOP2, BOTTOM2 } segmentPosition;

typedef struct					/* x display item parameters  */
{
    displayColours colour;			/* axis colour                */
    char           axisLabel[AXIS_LABEL_LENGTH];/* axis label                 */
    Flt32          minValue, maxValue;		/* max and min values         */
    Int16          majorDivisions;		/* number of major divisions  */
    char           colourName[COLOUR_NAME_LENGTH];/* axis colour name         */
} xItemParameters;

typedef struct					/* y display item parameters  */
{
    char         axisLabel[AXIS_LABEL_LENGTH];	/* axis label                 */
    Flt32        minValue, maxValue;		/* max and min values         */
    Int16        majorDivisions;		/* number of major divisions  */
    unitsOfTime  timeUnits;			/* time units                 */
} yItemParameters;

typedef struct					/* configuration parameters   */
{
    FILE            *markFilePtr;		/* mark file pointer          */
    char            configFilename[STRING_LENGTH]; /* configuration file name */
    char            markFilename[STRING_LENGTH];/* mark file name             */
    Flt32           graphicsDisplayRate;	/* graphics display rate      */
    Flt32           statusLineRate;		/* status line display rate   */
    MBool           lineDrawing;		/* lines/dots drawing flag    */
    MBool           showXY;			/* show xy coordinates flag   */
    MBool           scrolling;			/* display scrolling flag     */
    Int16           numXVariables;		/* number x variables selected*/
    Int16           numStatusLineVariables;	/* num status line variables  */
    itemVariables   items[NUM_VARS];		/* display items selected     */
						/* status line items selected */
    itemVariables   statusLineItems[NUM_STATUS_VARS];
    yItemParameters yVariable;			/* y item parameters          */
    xItemParameters xVariables[NUM_X_VARS];	/* x item parameters          */
} configurationParameters;

typedef struct					/* items update data          */
{
    Widget  w;					/* parent widget              */
						/* measured values            */
    DM_Item conductivity;               	/* conductivity (mMho)        */
    DM_Item oxygenCurrent;              	/* oxygen current (volts)     */
    DM_Item oxygenTemp;                 	/* oxygen temperature (volts) */
    DM_Item pressure;                   	/* pressure (dBar)            */
    DM_Item scanNumber;                 	/* scan number                */
    DM_Item temperature;                	/* temperature (degrees C)    */
    DM_Item time;                		/* time                       */
    DM_Item transmissometer;            	/* transmissometer (volts)    */
						/* derived values             */
    DM_Item beamAttenuation;            	/* beam attenuation           */
    DM_Item beamPercent;                	/* beam percent               */
    DM_Item depth;                      	/* depth (metres)             */
    DM_Item oxygen;                     	/* oxygen (ml/litre)          */
    DM_Item salinity;                   	/* salinity (psu)             */
    DM_Item sigmaT;                     	/* sigma T (kg/m3)            */
    DM_Item sigmaTheta;                 	/* sigma theta (kg/m3)        */
    DM_Item soundVelocity;              	/* sound velocity (m/s)       */
    DM_Item theta;                      	/* theta (degrees C)          */
    DM_Time sensorTime[NUM_DISPLAY_ITEMS];	/* sensor acquisition times   */
} itemsUpdateData;

typedef struct					/* display update data        */
{
    Widget display;                    		/* display widget             */
    Int16  xAxisStart, yAxisStart; 		/* x and y axis start         */
    Int16  xAxisEnd, yAxisEnd; 			/* x and y axis end           */
    Int16  xStatusLinePos, yStatusLinePos;	/* status line x-y position   */
    Flt32  minValues[NUM_VARS];			/* minimum axis values        */
    Flt32  maxValues[NUM_VARS];			/* maximum axis values        */
    Flt32  scales[NUM_VARS];			/* axis scales                */
    Pixel  colours[NUM_SEGMENTS-1];		/* segment colours            */
} displayUpdateData;

typedef struct					/* display axes parameters    */
{
    displayUpdateData displayData;		/* display update data        */
    Int16    xAxisLength; 			/* x axis length              */
    Int16    yAxisLength;			/* y axis length              */
    Int16    numSegments;			/* number of axis segments    */
    XSegment segments[NUM_SEGMENTS];		/* segment endpoints          */
    displayColours xColours[NUM_X_VARS];	/* x axis colours             */
    Int16    xLabelPosition[NUM_VARS];		/* x axis label position      */
    Int16    yLabelPosition[NUM_VARS];		/* x axis label position      */
    char     axisLabel[NUM_VARS][AXIS_LABEL_LENGTH];/* axis labels            */
    Int16    labelLength[NUM_VARS];		/* axis label string lengths  */
    Int16    numYWords;				/* number of words in y label */
    Int16    yLabelSpace[NUM_Y_WORDS];		/* space positions in y label */
    Int16    numTicks[NUM_VARS];		/* number of tick marks       */
    Int16    tickLength;			/* tick mark length           */
    XSegment tickMarks[NUM_VARS][NUM_TICKS];	/* tick mark positions        */
						/* tick mark labels           */
    char     firstTickLabel[NUM_VARS][TICK_LABEL_LENGTH];
    char     lastTickLabel[NUM_VARS][TICK_LABEL_LENGTH];
    Int16    firstTickLabelLength[NUM_VARS];	/* first tick label length    */
    Int16    lastTickLabelLength[NUM_VARS];	/* last tick label length     */
    Int16    xFirstTickLabelPos[NUM_VARS];	/* first tick label x position*/
    Int16    yFirstTickLabelPos[NUM_VARS];	/* first tick label y position*/
    Int16    xLastTickLabelPos[NUM_VARS];	/* last tick label x position */
    Int16    yLastTickLabelPos[NUM_VARS];	/* last tick label y position */
    Int16    majorDivisions[NUM_VARS];          /* number of major divisions  */
    Int16    numMarks;				/* number of marks            */
    Flt32    markValue[NUM_MARKS];		/* mark values                */
    MBool    inDisplayWindow;			/* in display window flag     */
    Int16    xCoordPosition;			/* x coordinate position      */
    Int16    yCoordPositions[NUM_X_VARS];	/* y coordinate positions     */
						/* xy coordinate strings      */
    char     coordString[NUM_X_VARS][STRING_LENGTH];
} plotParameters;

typedef struct					/* item list data             */
{
    Widget w;					/* list widget                */
    char   displayItems[NUM_DISPLAY_ITEMS][STRING_LENGTH];/* item strings     */
} itemListData;

						/* altered item parameters    */
typedef struct
{
    Widget         labelWidget;			/* axis label widget          */
    Widget         minWidget;			/* min value widget           */
    Widget         maxWidget;			/* max value widget           */
    Widget         colourWidget;		/* axis colour widget         */
    Widget         oldColourButton;		/* colour button widget       */
    Widget         divisionsWidget;		/* major divisions widget     */
    Widget         timeUnitsWidget;		/* time units widget          */
    Widget         oldTimeUnitsButton;		/* time units button widget   */
    MBool          labelChanged;		/* axis label changed flag    */
    MBool          minChanged;			/* min value changed flag     */
    MBool          maxChanged;			/* max value changed flag     */
    MBool          colourChanged;		/* axis colour changed flag   */
    MBool          divisionsChanged;		/* major divs changed flag    */
    MBool          timeUnitsChanged;		/* time units changed flag    */
    char           newLabel[AXIS_LABEL_LENGTH];	/* new axis label             */
    char           oldLabel[AXIS_LABEL_LENGTH];	/* old axis label             */
    char           newColourName[COLOUR_NAME_LENGTH];/* new colour name       */
    char           oldColourName[COLOUR_NAME_LENGTH];/* old colour name       */
    Flt32          newMin, oldMin;		/* old and new min values     */
    Flt32          newMax, oldMax;		/* old and new max values     */
    Pixel          newColour, oldColour;	/* old and new axis colour    */
    Int16          newDivisions, oldDivisions;	/* old and new major divs     */
    unitsOfTime    newTimeUnits, oldTimeUnits;	/* old and new time units     */
    itemParameters lastParam;			/* last parameter changed     */
} parametersAltered;

#endif
