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_OBJECT_DATA_H
00029 #define __SCAN_OBJECT_DATA_H
00030
00037 typedef void (*scan_object_ixy_func) (int, double&, double&);
00038
00052 class scan_object_data{
00053 public:
00054 scan_object_data(int _id,
00055 const gchar *_name,
00056 const gchar *_text,
00057 int _np,
00058 scan_object_ixy_func f_ixy){
00059 id = _id;
00060 np = _np;
00061 xy = new double[np*2];
00062 ixy = new double[np*2];
00063 for (int i=0; i<np; ++i){
00064 (*f_ixy)(i, xy[2*i], xy[2*i+1]);
00065 (*f_ixy)(-i-1, ixy[2*i], ixy[2*i+1]);
00066 }
00067 name = g_strdup (_name);
00068 text = g_strdup (_text);
00069 };
00070 ~scan_object_data(){
00071 delete [] xy;
00072 delete [] ixy;
00073 g_free (name);
00074 g_free (text);
00075
00076 };
00077
00083 void dump(){
00084 XSM_DEBUG (DBG_L2,
00085 "Objectid = " << id << std::endl
00086 << "Name = " << name << std::endl
00087 << "Text = " << text << std::endl
00088 << "NumP = " << np );
00089 for (int i=0; i<np; ++i)
00090 XSM_DEBUG (DBG_L2, "P[" << i << "] = Ang:("
00091 << xy[i*2] << ", "
00092 << xy[i*2+1] << "), Pix:("
00093 << ixy[i*2] << ", "
00094 << ixy[i*2+1] << ")"
00095 );
00096 };
00097
00106 void update (const gchar *_name,
00107 const gchar *_text,
00108 scan_object_ixy_func f_ixy){
00109 for (int i=0; i<np; ++i){
00110 (*f_ixy)(i, xy[2*i], xy[2*i+1]);
00111 (*f_ixy)(-i-1, ixy[2*i], ixy[2*i+1]);
00112 }
00113 g_free (name);
00114 name = g_strdup (_name);
00115 g_free (text);
00116 text = g_strdup (_text);
00117 };
00118
00127 void get_xy (int i, double &x, double &y) {
00128 if (i<np) { x=xy[2*i]; y=xy[2*i+1]; }
00129 };
00130
00131 void get_xy_pixel (int i, double &x, double &y) {
00132 if (i<np) { x=ixy[2*i]; y=ixy[2*i+1]; }
00133 };
00134
00142 gchar *get_name () { return name; };
00143
00151 gchar *get_text () { return text; };
00152
00160 int get_num_points () { return np; };
00161
00169 int get_id () { return id; };
00170
00171 private:
00172 int id;
00173 gchar *name;
00174 gchar *text;
00175 int np;
00176 double *xy;
00177 double *ixy;
00178 };
00179
00180 #endif