00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __SCAN_EVENT_H
00029 #define __SCAN_EVENT_H
00030
00031 #ifndef __XSMTYPES_H
00032 #include "xsmtypes.h"
00033 #endif
00034
00035 #ifndef __XSMMASKS_H
00036 #include "xsmmasks.h"
00037 #endif
00038
00039 #ifndef __XSMDEBUG_H
00040 #include "xsmdebug.h"
00041 #endif
00042
00043 #include <config.h>
00044 #include <libgnome/libgnome.h>
00045 #include <gdk/gdk.h>
00046
00047 #include <netcdf.hh>
00048
00049 class ScanEvent;
00050
00058 class EventEntry{
00059 public:
00060 EventEntry (gchar *Name, time_t Time);
00061 virtual ~EventEntry ();
00062
00063 virtual void add (double *value) {};
00064 virtual void add (gchar *message) {};
00065 virtual double get (int n, int j) { return 0.; };
00066 virtual time_t get_time ();
00067 virtual gchar* get_str_time ();
00068 virtual gchar* get (int n) { return NULL; };
00069 virtual void print () {};
00070
00071 gchar* description () { return name; };
00072 gchar description_id () { return name[0]; };
00073
00074 protected:
00075 gchar *name;
00076 time_t time;
00077 private:
00078 };
00079
00080 class ProbeEntry : public EventEntry{
00081 public:
00082 ProbeEntry (gchar *Name, time_t Time, GPtrArray *Labels, GPtrArray *Unitssymbols, int Chunk_size);
00083 ProbeEntry (gchar *Name, NcFile *ncf, int p_index, NcVar* &evdata_var, NcVar* &evcoords_var, ScanEvent* &se, int num, int &count, ProbeEntry *pe=NULL);
00084 virtual ~ProbeEntry ();
00085 virtual void add (double *value){ g_array_append_vals (data, (gconstpointer)value, chunk_size); ++num_sets; };
00086 virtual double get (int n, int j){
00087 if (j < 0)
00088 return (double)n;
00089 return g_array_index (data, double, n*chunk_size+j);
00090 };
00091 virtual void print ();
00092
00093 int get_num_sets () { return num_sets; };
00094 int get_chunk_size () { return chunk_size; };
00095 gchar *get_label (int j);
00096 gchar *get_unit_symbol (int j);
00097
00098 int write_nc_variable_set (NcFile* ncf, int p_index, NcVar* &evdata_var, NcVar* &evcoords_var, int total_count);
00099 int write_nc_data (NcVar* evdata_var, NcVar* evcoords_var, ScanEvent *se, int count);
00100
00101 private:
00102 GPtrArray *labels;
00103 GPtrArray *unitssymbols;
00104 int chunk_size;
00105 int num_sets;
00106 GArray *data;
00107 };
00108
00109 class UserEntry : public EventEntry{
00110 public:
00111 UserEntry (gchar *Name, time_t Time, GPtrArray *Messages=NULL, int num=0);
00112 UserEntry (gchar *Name, NcFile *ncf, int u_index, ScanEvent* &se);
00113 ~UserEntry ();
00114 virtual void add (gchar *message){ g_ptr_array_add (data, (gpointer) message); ++num_sets; };
00115 virtual gchar* get (int n){ return (gchar*) g_ptr_array_index (data, n); };
00116 int get_num_sets () { return num_sets; };
00117 virtual void print ();
00118
00119 int store_event_to_nc (NcFile* ncf, int u_index, ScanEvent *se);
00120
00121 private:
00122 int num_sets;
00123 GPtrArray *data;
00124 };
00125
00126 class ScanEvent{
00127 public:
00128 ScanEvent (double xPos, double yPos, double Val=0.);
00129 ~ScanEvent ();
00130 static void eeremove(EventEntry *entry, gpointer from);
00131 static void eeprint(EventEntry *entry, int *w);
00132
00133 void add_event (EventEntry *ee);
00134 double get_position (double &x, double &y) { x=xpos; y=ypos; return val; };
00135 double distance (double *xy) { double dx=xpos-xy[0]; double dy=ypos-xy[1]; return sqrt(dx*dx+dy*dy); };
00136 double distance2 (double *xy) { double dx=xpos-xy[0]; double dy=ypos-xy[1]; return (dx*dx+dy*dy); };
00137 guint get_event_count() { return g_slist_length (event_list); };
00138
00139 void print () {
00140 std::cout << "ScanEvent at " << xpos << "Ang, " << ypos << "Ang" << std::endl;
00141 g_slist_foreach(event_list, (GFunc) ScanEvent::eeprint, NULL);
00142 };
00143
00144 GSList *event_list;
00145 gint flag;
00146 private:
00147 double xpos, ypos, val;
00148 };
00149
00150
00151 #endif
00152
00153
00154