spm_scancontrol.h

Go to the documentation of this file.
00001 /* Gnome gxsm - Gnome X Scanning Microscopy
00002  * universal STM/AFM/SARLS/SPALEED/... controlling and
00003  * data analysis software
00004  *
00005  * Gxsm Plugin Name: spm_scancontrol.h
00006  * ========================================
00007  * 
00008  * Copyright (C) 1999 The Free Software Foundation
00009  *
00010  * Authors: Percy Zahl <zahl@fkp.uni-hannover.de>
00011  * additional features: Andreas Klust <klust@fkp.uni-hannover.de>
00012  *
00013  * This program is free software; you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation; either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * This program is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program; if not, write to the Free Software
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00026  */
00027 
00028 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 8 c-style: "K&R" -*- */
00029 
00030 #ifndef __SPM_SCANCONTROL_H
00031 #define __SPM_SCANCONTROL_H
00032 
00033 typedef enum SCAN_DIR { SCAN_DIR_TOPDOWN, SCAN_DIR_TOPDOWN_BOTUP, SCAN_DIR_BOTUP };
00034 typedef enum SCAN_FLAG { SCAN_FLAG_READY, SCAN_FLAG_STOP,  SCAN_FLAG_PAUSE,  SCAN_FLAG_RUN };
00035 typedef enum SCAN_DT_TYPE { SCAN_LINESCAN, SCAN_FRAMECAPTURE };
00036 
00037 // Scan Control Class based on AppBase
00038 // -> AppBase provides a GtkWindow and some window handling basics used by Gxsm
00039 class SPM_ScanControl : public AppBase{
00040 public:
00041         SPM_ScanControl(); // create window and setup it contents, connect buttons, register cb's...
00042         virtual ~SPM_ScanControl(); // unregister cb's
00043         
00044         void update(); // window update (inputs, etc. -- here currently not really necessary)
00045 
00046         int free_scan_lists (); // clean up all old/previous scan lists
00047         
00048         int initialize_scan_lists (); /* this scans the current channel list (Channelselector)
00049                                          and sets up a list of all scans used for data storage.
00050                                       */
00051         int initialize_default_pid_src (); // not jet exsistent (plans to split off initialize_scan_lists).
00052         int initialize_pid_src (); // not jet exsistent.
00053         int initialize_daq_srcs (); // not jet exsistent.
00054 
00055         int prepare_to_start_scan (SCAN_DT_TYPE st=SCAN_LINESCAN); /* prepare to start a scan:
00056                                                                       set common scan parameters,
00057                                                                       signal "scan start event" to hardware,
00058                                                                       setup basic scan parameters and put to hardware,
00059                                                                       initialize scan lists,
00060                                                                       check for invalid parameters -- cancel in case of bad settings (return -1 if fails, 0 if OK)
00061                                                                    */
00062                                                                       
00063         int setup_scan (int ch, const gchar *titleprefix, 
00064                         const gchar *name, 
00065                         const gchar *unit, const gchar *label,
00066                         const gchar *vunit = NULL, const gchar *vlabel = NULL,
00067                         const gchar *prbsrcs = NULL, int prboutp = 0);
00068         /* configure a scan -- gets settings from channelselector/configuration */
00069         void do_scanline (int init=FALSE); // execute a single scan line -- or if "line == -1" a HS 2D Area Capture/Scan
00070         void run_probe (int ipx, int ipy); // run a local probe
00071         int do_scan (); // do a full scan, line by line
00072         int do_hscapture (); // do a full frame capute
00073         void set_subscan (int ix0=0, int num=0); /* setup for partial/sub scan, 
00074                                                     current line, start at x = ix0, num points = num
00075                                                  */
00076         void stop_scan () { 
00077                 if (scan_flag == SCAN_FLAG_RUN || scan_flag == SCAN_FLAG_PAUSE) 
00078                         scan_flag = SCAN_FLAG_STOP; 
00079         }; // interrupt/cancel a scan in progress
00080         int pause_scan () { 
00081                 if (scan_flag == SCAN_FLAG_RUN)
00082                         scan_flag = SCAN_FLAG_PAUSE; 
00083                 else
00084                         if (scan_flag == SCAN_FLAG_PAUSE)
00085                                 scan_flag = SCAN_FLAG_RUN; 
00086 
00087                 return scan_flag == SCAN_FLAG_PAUSE;
00088         }; // pause a scan in progress
00089         int scan_in_progress() { 
00090                 return scan_flag == SCAN_FLAG_RUN || scan_flag == SCAN_FLAG_PAUSE 
00091                         ? TRUE : FALSE; 
00092         }; // check if a scan is in progress
00093         int finish_scan (); /* finish the scan:
00094                                return to origin (center of first line (SPM)),
00095                                add some log info,
00096                                free scan lists
00097                              */
00098 
00099         double update_status_info (int reset=FALSE); // compute and show some scan status info
00100         void autosave_check (double sec, int initvalue=0); // check of autosave if requested
00101 
00102         int set_x_lookup_value (int i, double lv); // not jet used (future plans for remote...)
00103         int set_y_lookup_value (int i, double lv); // not jet used
00104         int set_l_lookup_value (int i, double lv); // not jet used
00105 
00106         // some helpers
00107         static void call_scan_start (Scan* sc, gpointer data){ sc->start (); };
00108         static void call_scan_draw_line (Scan* sc, gpointer data){
00109                 sc->draw (((SPM_ScanControl*)data)->line2update, ((SPM_ScanControl*)data)->line2update+1);
00110         };
00111         static void call_scan_stop (Scan* sc, gpointer data){ 
00112                 sc->stop (((SPM_ScanControl*)data)->scan_flag == SCAN_FLAG_STOP 
00113                           && ((SPM_ScanControl*)data)->last_scan_dir == SCAN_DIR_TOPDOWN,
00114                           ((SPM_ScanControl*)data)->line);
00115         };
00116 
00117         void SetScanDir (GtkWidget *w) { 
00118                 scan_dir = (SCAN_DIR) ((long) gtk_object_get_data ( GTK_OBJECT (w), "SCANDIR")); 
00119                 PI_DEBUG (DBG_L2, "SCM=" << scan_dir ); };
00120         void ClrScanDir (GtkWidget *w) { };
00121         int GetScanDir () {return last_scan_dir==SCAN_DIR_TOPDOWN?1:-1;};
00122 private:
00123         UnitObj *Unity; // Unit "1"
00124 
00125         Scan   *master_scan; // master "topo" scan -- needed as common parameter reference by probe
00126         Scan   *master_probescan; // master "probe" scan -- needed as common parameter reference by probe
00127 
00128         /* Scan and ProbeScan Lists: xp = X plus (-> dir), xm = X minus (<- dir) */
00129         GSList *xp_scan_list, *xp_2nd_scan_list, *xp_prbscan_list;
00130         GSList *xm_scan_list, *xm_2nd_scan_list, *xm_prbscan_list;
00131 
00132         /* xp/xm source mask (bit encoding of channels to aquire) */
00133         int    xp_srcs, xm_srcs;
00134         int    xp_2nd_srcs, xm_2nd_srcs;
00135 
00136         int YOriginTop; /* TRUE if the Y origin is the top (first) line (all SPM),
00137                            else FALSE (SPALEED uses the image center)
00138                         */
00139         
00140         int yline; /* current scanline moveto coordinare */
00141         
00142         int line, line2update; // current scan line and line to update in background
00143         int ix0off; // current X offset (in pixels) -- if in subscan mode
00144         SCAN_FLAG scan_flag; // scan status flag
00145         SCAN_DIR  scan_dir, last_scan_dir; // current and last scan direction
00146         gboolean      do_probe; // set if currently in probe mode
00147 };
00148 
00149 #endif

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