scan_object_data.h

Go to the documentation of this file.
00001 /* Gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  * 
00005  * Copyright (C) 1999,2000,2001,2002,2003 Percy Zahl
00006  *
00007  * Authors: Percy Zahl <zahl@users.sf.net>
00008  * additional features: Andreas Klust <klust@users.sf.net>
00009  * WWW Home: http://gxsm.sf.net
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00024  */
00025 
00026 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */
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

Generated on Sat Apr 1 09:04:04 2006 for GXSM by  doxygen 1.4.6