TSP: The Transport Sample Protocol



Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

gdisp_pointArray.h

00001 /* GTK - The GIMP Toolkit
00002  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
00018  */
00019 
00020 #ifndef __POINT_ARRAY_H__
00021 #define __POINT_ARRAY_H__
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif /* __cplusplus */
00026   
00027 /*
00028  * I Could only use an array of Y, with betting,
00029  * I can compute X with index * FREQ.
00030  * But I'm not sure of :
00031  *  - How to take care of data loss (hole in the array ?),
00032  *  - On the fly changes in sampling,
00033  *  - Many Variables with differents frequency on the same widget,
00034  *  => So I use a (x,Y) structure.
00035  */
00036      
00037 typedef struct _DoublePoint
00038 {
00039 
00040   gdouble x,y;    // Use for storage of physical values.
00041 
00042 } DoublePoint_T;
00043 
00044 typedef struct _ShortPoint
00045 {
00046 
00047   gshort x,y;   // Use for storage of pixel values.
00048 
00049 } ShortPoint_T;
00050   
00051 typedef struct _DoublePointArray
00052 {
00053 
00054   DoublePoint_T *samples;     // pointer on samples,
00055   guint          nbSamples;   // number of samples currently in array,
00056   guint          current;     // index on current position,
00057   guint          first;       // index on first position,
00058   guint          marker;      // index on a position used by upper level,
00059   guint          maxSamples;  // maximum samples possible to be added.
00060 
00061 } DoublePointArray_T;
00062 
00063 /*
00064  * Return a DoublePoint sample element form an Array and an index.
00065  */
00066 #define DP_ARRAY_GET_SAMPLE_FROM_FIRST(pArray,i) \
00067         ((pArray)->samples[ (i + (pArray)->first) % (pArray)->nbSamples ])
00068 
00069 DoublePoint_T  dparray_getSample    (DoublePointArray_T *pArray, int index);
00070 DoublePoint_T* dparray_getSamplePtr (DoublePointArray_T *pArray, int index);
00071 
00072 
00073 /*
00074  * Sets the fields to default values and allocate a sample buffer.
00075  */
00076 DoublePointArray_T *dparray_newSampleArray (guint maxSamples);
00077 
00078 /*
00079  * Destroy all memory allocated for this array.
00080  */
00081 void dparray_freeSampleArray (DoublePointArray_T *pArray);
00082 
00083 /*
00084  * Add an array sample element.
00085  */
00086 void dparray_addSample (DoublePointArray_T *pArray, DoublePoint_T *pt);
00087 
00088 /*
00089  * Accessors on data.
00090  */
00091 guint dparray_getFirstIndex   (DoublePointArray_T *pArray);
00092 guint dparray_getCurrentIndex (DoublePointArray_T *pArray);
00093 guint dparray_getNbSamples    (DoublePointArray_T *pArray);
00094 
00095 /*
00096  * Set/Get on marker, used by upper level to remember a specific position.
00097  */
00098 guint dparray_getMarkerIndex (DoublePointArray_T *pArray);
00099 void  dparray_setMarkerIndex (DoublePointArray_T *pArray, guint index);
00100 
00101 /*
00102  * Get the samples available from specific position in circular array.
00103  */
00104 guint dparray_getLeftSamplesFromPos (DoublePointArray_T *pArray, guint index);
00105 
00106 /*
00107  * Debug : Dump the values of the pointer.
00108  */
00109 void dparray_printFields (DoublePointArray_T *pArray);
00110 
00111 
00112 #ifdef __cplusplus
00113 }
00114 #endif /* __cplusplus */
00115 
00116 #endif /* __POINT_ARRAY_H__ */
Framework Home Page.

Beware !! TSP wave is coming...