UK2k_import.C

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: UK2k_import.C
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 /* Please do not change the Begin/End lines of this comment section!
00029  * this is a LaTeX style section used for auto generation of the PlugIn Manual 
00030  * Chapter. Add a complete PlugIn documentation inbetween the Begin/End marks!
00031  * --------------------------------------------------------------------------------
00032 % BeginPlugInDocuSection
00033 % PlugInDocuCaption: UK2000 v3.4 import plug-in
00034 
00035 % PlugInName: UK2k_import
00036 
00037 % PlugInAuthor: Juan de la Figuera
00038 
00039 % PlugInAuthorEmail: juan.delafiguera@uam.es
00040 
00041 % PlugInMenuPath: File/Import/Uk2k import
00042 
00043 % PlugInDescription
00044 
00045 This plugin is responsible for reading UK2000 v3.4 images, with the
00046 following limitations so far: only topography, and only the forward
00047 scan. To add support for the back scan would be pretty simple, if
00048 someone is interested. This STM electronics is a DSP based system with
00049 transputers as CPUs (yes, it has several). It was made by Uwe Knipping
00050 from Arizona State University and sold by CVS (Custom Vacuum Systems
00051 Ltd.). There are a few systems around, still running after more than
00052 10 years. The PC version of the electronics are the basis of the DSP
00053 STM unit sold (and further developed) by Molecular Imaging.
00054 
00055 The files are an ASCII file with the scan details (extension .stp),
00056 and an 16bit binary dump of the image (extension .std).
00057 
00058 % PlugInUsage
00059 Registers itself for loading files with the filename suffix ".std".
00060 
00061 % EndPlugInDocuSection
00062  * -------------------------------------------------------------------------------- */
00063 
00064 #include <gtk/gtk.h>
00065 #include "config.h"
00066 #include "gxsm/plugin.h"
00067 #include "gxsm/dataio.h"
00068 #include "gxsm/action_id.h"
00069 #include "gxsm/util.h"
00070 
00071 #ifndef WORDS_BIGENDIAN 
00072 #define WORDS_BIGENDIAN 0
00073 #endif
00074  
00075 using namespace std;
00076 
00077 
00078 // Plugin Prototypes
00079 static void UK2k_import_init (void);
00080 static void UK2k_import_query (void);
00081 static void UK2k_import_about (void);
00082 static void UK2k_import_configure (void);
00083 static void UK2k_import_cleanup (void);
00084 
00085 static void UK2k_import_filecheck_load_callback (gpointer data );
00086 //static void UK2k_import_filecheck_save_callback (gpointer data );
00087 
00088 static void UK2k_import_import_callback (GtkWidget *w, void *data);
00089 //static void UK2k_import_export_callback (GtkWidget *w, void *data);
00090 
00091 // Fill in the GxsmPlugin Description here
00092 GxsmPlugin UK2k_import_pi = {
00093   NULL,                   // filled in and used by Gxsm, don't touch !
00094   NULL,                   // filled in and used by Gxsm, don't touch !
00095   0,                      // filled in and used by Gxsm, don't touch !
00096   NULL,                   // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 
00097                           // filled in here by Gxsm on Plugin load, 
00098                           // just after init() is called !!!
00099   "UK2k_import",
00100   NULL,                // PlugIn's Categorie, set to NULL for all, I just don't want this always to be loaded!
00101   // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details)
00102   "Import of UK2k data format.",
00103   "Juan de la Figuera",
00104   N_("File/Import"),
00105   N_("..."),
00106   NULL,
00107   "This plugin is respnsible for reading UK2000 v3.4 images, so far no spectroscopy, and only one image",
00108   NULL,          // error msg, plugin may put error status msg here later
00109   NULL,          // Plugin Status, managed by Gxsm, plugin may manipulate it too
00110   UK2k_import_init,  
00111   UK2k_import_query,  
00112   // about-function, can be "NULL"
00113   // can be called by "Plugin Details"
00114   UK2k_import_about,
00115   // configure-function, can be "NULL"
00116   // can be called by "Plugin Details"
00117   UK2k_import_configure,
00118   // run-function, can be "NULL", if non-Zero and no query defined, 
00119   // it is called on menupath->"plugin"
00120   NULL,
00121   // cleanup-function, can be "NULL"
00122   // called if present at plugin removeal
00123   UK2k_import_cleanup
00124 };
00125 
00126 // Text used in Aboutbox, please update!!
00127 static const char *about_text = N_("Gxsm UK2k Data File Import Plugin\n\n"
00128                                    "This plugin reads in UK2k datafiles."
00129         );
00130 
00131 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 
00132 // Essential Plugin Function!!
00133 GxsmPlugin *get_gxsm_plugin_info ( void ){
00134   UK2k_import_pi.description = g_strdup_printf(N_("Gxsm UK2k_import plugin %s"), VERSION);
00135   return &UK2k_import_pi; 
00136 }
00137 
00138 // Query Function, installs Plugin's in File/Import and Export Menupaths!
00139 // ----------------------------------------------------------------------
00140 // Import Menupath is "File/Import/UK2k import"
00141 // Export Menupath is "File/Export/UK2k import"
00142 // ----------------------------------------------------------------------
00143 // !!!! make sure the "UK2k_import_cleanup()" function (see below) !!!!
00144 // !!!! removes the correct menuentries !!!!
00145 
00146 static void UK2k_import_query(void)
00147 {
00148   static GnomeUIInfo menuinfo_Import[] = { 
00149     { GNOME_APP_UI_ITEM, 
00150       N_("UK2k Import"), N_("Import of the UK2k format"),
00151       (gpointer) UK2k_import_import_callback, NULL,
00152       NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN,
00153       0, GDK_CONTROL_MASK, NULL },
00154     GNOMEUIINFO_END
00155   };
00156 
00157   gnome_app_insert_menus (
00158           GNOME_APP(UK2k_import_pi.app->getApp()), 
00159           N_("File/Import/"),
00160           menuinfo_Import
00161           );
00162 
00163 //  static GnomeUIInfo menuinfo_Export[] = {
00164 //    { GNOME_APP_UI_ITEM,
00165 //      N_("UK2k Export"), N_("Export of the UK2k format"),
00166 //      (gpointer) UK2k_import_export_callback, NULL,
00167 //      NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE,
00168 //      0, GDK_CONTROL_MASK, NULL },
00169 //    GNOMEUIINFO_END
00170 //  };
00171 
00172 //  gnome_app_insert_menus (
00173 //        GNOME_APP(UK2k_import_pi.app->getApp()),
00174 //        N_("File/Export/"),
00175 //        menuinfo_Export
00176 //        );
00177 
00178   if(UK2k_import_pi.status) g_free(UK2k_import_pi.status);
00179   UK2k_import_pi.status = g_strconcat (
00180           N_("Plugin query has attached "),
00181           UK2k_import_pi.name,
00182           N_(": File IO Filters are ready to use"),
00183           NULL);
00184 
00185 // register this plugins filecheck functions with Gxsm now!
00186 // This allows Gxsm to check files from DnD, open,
00187 // and cmdline sources against all known formats automatically - no explicit im/export is necessary.
00188   UK2k_import_pi.app->ConnectPluginToLoadFileEvent (UK2k_import_filecheck_load_callback);
00189 //  UK2k_import_pi.app->ConnectPluginToSaveFileEvent (UK2k_import_filecheck_save_callback);
00190 }
00191 
00192 
00193 // 5.) Start here with the plugins code, vars def., etc.... here.
00194 // ----------------------------------------------------------------------
00195 //
00196 
00197 
00198 // init-Function
00199 static void UK2k_import_init(void)
00200 {
00201   PI_DEBUG (DBG_L2, "UK2k_import Plugin Init" );
00202 }
00203 
00204 // about-Function
00205 static void UK2k_import_about(void)
00206 {
00207   const gchar *authors[] = { UK2k_import_pi.authors, NULL};
00208   gtk_widget_show(gnome_about_new ( UK2k_import_pi.name,
00209                                     VERSION,
00210                                     N_("(C) 2001 the Free Software Foundation"),
00211                                     about_text,
00212                                     authors,
00213                                     NULL, NULL, NULL
00214                                     ));
00215 }
00216 
00217 // configure-Function
00218 static void UK2k_import_configure(void)
00219 {
00220   if(UK2k_import_pi.app)
00221     UK2k_import_pi.app->message("UK2k_import Plugin Configuration");
00222 }
00223 
00224 // cleanup-Function, make sure the Menustrings are matching those above!!!
00225 static void UK2k_import_cleanup(void)
00226 {
00227   PI_DEBUG (DBG_L2, "UK2k_import Plugin Cleanup" );
00228   gnome_app_remove_menus (GNOME_APP (UK2k_import_pi.app->getApp()),
00229                           N_("File/Import/UK2k Import"), 1);
00230 //s export is not available
00231 //s  gnome_app_remove_menus (GNOME_APP (UK2k_import_pi.app->getApp()),
00232 //s                       N_("File/Export/UK2k Export"), 1);
00233 }
00234 
00235 // make a new derivate of the base class "Dataio"
00236 class UK2k_ImExportFile : public Dataio{
00237  public:
00238   UK2k_ImExportFile(Scan *s, const char *n) : Dataio(s,n){ };
00239   virtual FIO_STATUS Read();
00240   virtual FIO_STATUS Write();
00241  private:
00242   // Binary data read
00243   FIO_STATUS spmReadDat(const char *fname);
00244  // Parses ASCII parameter files
00245   FIO_STATUS spmReadPar(const gchar *fname, const gchar *fsuffix);
00246 };
00247 
00248 // d2d import :=)
00249 FIO_STATUS UK2k_ImExportFile::Read(){
00250 
00251         FIO_STATUS ret = FIO_OK;
00252         gchar *fdatname = (gchar*) name;
00253         gchar *fparname=NULL;
00254         gchar *fbasename=NULL;
00255         gchar *fsuffix=NULL;
00256 
00257         // name should have at least 4 chars: ".ext"
00258         if (fdatname == NULL || strlen(fdatname) < 4) {
00259                 PI_DEBUG (DBG_L2, "UK2k: problem with filename lenght " << strlen(fdatname) );
00260                 return  FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00261         }
00262         // Check all known File Types:
00263 
00264         // split filename in basename and suffix,
00265         // generate parameter file name
00266         fbasename = g_strndup (name, strlen(name)-4);
00267         fsuffix = g_strdup (name+strlen(name)-4);
00268         fparname = g_strconcat (fbasename, ".stp", NULL);
00269 
00270         if (!strncmp(fsuffix,".STD",4))
00271                 fparname= g_strconcat(fbasename,".STP",NULL);
00272         // check for known file types
00273         // accepting topography forward (*.STP, *.stp) files
00274         if ( strncmp(fsuffix,".STD", 4) && strncmp(fsuffix,".std", 4)  ) {
00275                 PI_DEBUG (DBG_L2, "UK2k: problem with extension " << fsuffix );
00276                 ret = FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00277         }
00278         else{
00279 
00280                 // check for data and par file exists and is OK
00281                 std::ifstream f;
00282                 f.open(fdatname, std::ios::in | std::ios::binary);
00283                 if(!f.good()){
00284                         PI_DEBUG (DBG_L2, "UK2k_ImExportFile::Read: data file error" );
00285                         ret = status = FIO_OPEN_ERR;
00286                 }
00287                 f.close();
00288                 f.open(fparname, std::ios::in);
00289                 if(!f.good()){
00290                         PI_DEBUG (DBG_L2, "Uk2k_ImExportFile::Read: parameter file error" );
00291                         ret = status = FIO_OPEN_ERR;
00292                 }
00293                 f.close();
00294 
00295                 PI_DEBUG (DBG_L2, "UK2k_ImExportFile::Read: " << fdatname <<
00296                         " is a UK2000 File!" );
00297 
00298 
00299                 // parse parameter file
00300                 if ( ret == FIO_OK )
00301                         ret = spmReadPar (fparname, fsuffix);
00302 
00303                 // read the binary data
00304                 if ( ret == FIO_OK ) {
00305                   PI_DEBUG (DBG_L2, "UK2k: Read parameter file OK!" );
00306                   if ( scan->data.s.nvalues == 1 )
00307                         ret = spmReadDat (fdatname);
00308                 }
00309         }
00310 
00311         g_free (fbasename);
00312         g_free (fparname);
00313         g_free (fsuffix);
00314 
00315         scan->mem2d->data->MkYLookup(scan->data.s.y0, scan->data.s.y0+scan->data.s.ry);
00316         scan->mem2d->data->MkXLookup(scan->data.s.x0-scan->data.s.rx/2., scan->data.s.x0+scan->data.s.rx/2.);
00317         scan->mem2d->data->MkVLookup (-10., 10.);
00318 
00319         return ret;
00320 }
00321 
00322 
00323 FIO_STATUS UK2k_ImExportFile::spmReadDat(const gchar *fname)
00324 {
00325         // handle scan name
00326         scan->data.ui.SetName (fname);
00327         scan->data.ui.SetOriginalName (fname);
00328 
00329         // lets make a scan, and SPM files are of type short!
00330         scan->mem2d->Resize (
00331                 scan->data.s.nx,
00332                 scan->data.s.ny,
00333                 ZD_SHORT
00334                 );
00335 
00336         PI_DEBUG (DBG_L2, "UK2k_ImExportFile: Resize done." );
00337 
00338 
00339         // prepare buffer
00340         short *buf;
00341         if(!(buf = g_new(short, scan->data.s.nx*scan->data.s.ny)))
00342                 return FIO_NO_MEM;
00343 
00344         // read the actual data
00345         ifstream f;
00346         f.open(fname, ios::in | ios::binary);
00347         if(f.good())
00348                 f.read((char*)buf, sizeof(short) * scan->data.s.nx * scan->data.s.ny);
00349         else {
00350                 g_free(buf);
00351                 return FIO_OPEN_ERR;
00352         }
00353         f.close();
00354 
00355         // and put the data into mem2d
00356         short *pt = buf;
00357         char *cpt, low;
00358         for (int j=0; j < scan->data.s.ny; ++j)
00359           for (int i=0; i < scan->data.s.nx; ++i, ++pt) {
00360           // UK2000 files are stored using small endian format
00361             if (WORDS_BIGENDIAN)  {
00362               cpt = (char*)pt;
00363               low = cpt[0];
00364               cpt[0] = cpt[1];
00365               cpt[1] = low;
00366             }
00367         if (*pt>0) {*pt-=32767;}
00368                 else { *pt+=32767;} // Unsigned instead of signed... Oh well.
00369             // Attention: Omicron seems to save last line first!
00370             scan->mem2d->PutDataPkt ((double)*pt, i, scan->data.s.ny-j-1);
00371           }
00372 
00373         g_free (buf);
00374 
00375         PI_DEBUG (DBG_L2, "UK2k_ImExportFile: Import done." );
00376 
00377         // read done.
00378         return FIO_OK;
00379 }
00380 
00381 
00382 FIO_STATUS UK2k_ImExportFile::spmReadPar(const gchar *fname, const gchar *fsuffix)
00383 {
00384   char valid = FALSE; 
00385         char idate[80],itime[80];
00386 
00387   // first set some default parameters...
00388 
00389   // this is mandatory.
00390   scan->data.s.ntimes  = 1;
00391   scan->data.s.nvalues = 1;
00392 
00393   // put some usefull values in the ui structure
00394   if(getlogin()){
00395     scan->data.ui.SetUser (getlogin());
00396   }
00397   else{
00398     scan->data.ui.SetUser ("unkonwn user");
00399   }
00400 
00401 
00402   scan->data.ui.SetType ("UK2000 v3.4 Type: SHT ");
00403 
00404  gchar *comm = g_strconcat ("Imported by UK2k  import plugin from: ",
00405                                  fname,
00406                                  NULL);
00407       scan->data.ui.SetComment (comm);
00408       g_free (comm);
00409       PI_DEBUG (DBG_L2, " comment: " << scan->data.ui.comment );
00410 
00411   // initialize scan structure -- this is a minimum example
00412   scan->data.s.dx = 1;
00413   scan->data.s.dy = 1;
00414   scan->data.s.dz = 1;
00415   scan->data.s.rx = scan->data.s.nx;
00416   scan->data.s.ry = scan->data.s.ny;
00417   scan->data.s.x0 = 0;
00418   scan->data.s.y0 = 0;
00419   scan->data.s.alpha = 0;
00420 
00421   // be nice and reset this to some defined state
00422   scan->data.display.cpshigh       = 1e3;
00423   scan->data.display.cpslow        = 1.;
00424   scan->data.display.cnttime       = 1.;
00425 
00426 
00427   // start the real thing:
00428 
00429   // open the parameter file
00430   std::ifstream f;
00431   f.open(fname, std::ios::in);
00432   if(!f.good())
00433     return FIO_OPEN_ERR;
00434 
00435 
00436   // read the par file line-by-line
00437   gchar linebuf[100];
00438   while (!f.eof()) {
00439 
00440     f.getline (linebuf, 100);
00441 
00442 
00443   if (!strncmp (linebuf, "software      Uscan2000  3.4",24)) {
00444           valid=TRUE;
00445     }
00446 
00447   if (!strncmp (linebuf, "date",4)) {
00448         sscanf (linebuf, "%*[^0-9]%80s", idate);
00449         PI_DEBUG (DBG_L2, "UK2k date:" << idate );
00450     }
00451 
00452     if (!strncmp (linebuf, "time",4)) {
00453         sscanf (linebuf, "%*[^0-9]%80s", itime);
00454         PI_DEBUG (DBG_L2, "UK2k time: " << itime );
00455     }
00456 
00457 
00458     // range: x
00459     if ( !strncmp (linebuf, "length_x", 8) ) {
00460       double rx;
00461       sscanf (linebuf, "%*[^0-9]%lf", &rx);
00462       scan->data.s.rx = rx;
00463       PI_DEBUG (DBG_L2, "UK2k rx = " << scan->data.s.rx );
00464     }
00465 
00466     // range: y
00467     if ( !strncmp (linebuf, "length_y", 8) ) {
00468       double ry;
00469       sscanf (linebuf, "%*[^0-9]%lf", &ry);
00470       scan->data.s.ry = ry;
00471       PI_DEBUG (DBG_L2, "UK2k ry = " << scan->data.s.ry );
00472     }
00473 
00474     // scan size: nx
00475     if ( !strncmp (linebuf, "samples_x", 9) ) {
00476       int nx;
00477       sscanf (linebuf, "%*[^0-9]%d", &nx);
00478       scan->data.s.nx = nx;
00479       PI_DEBUG (DBG_L2, "UK2k nx = " << scan->data.s.nx );
00480     }
00481 
00482     // scan size: ny
00483     if ( !strncmp (linebuf, "samples_y", 9) ) {
00484       int ny;
00485       sscanf (linebuf, "%*[^0-9]%d", &ny);
00486       scan->data.s.ny = ny;
00487       PI_DEBUG (DBG_L2, "UK2k ny = " << scan->data.s.ny );
00488     }
00489 
00490 
00491     // scan angle
00492     if ( !strncmp (linebuf, "scan_rot", 8) ) {
00493       double alf;
00494       sscanf (linebuf, "%*[^0-9-]%lf", &alf);
00495       scan->data.s.alpha = alf;
00496       PI_DEBUG (DBG_L2, "UK2k alpha = " << scan->data.s.alpha );
00497     }
00498 
00499     // offset: x
00500     if ( !strncmp (linebuf, "start_x", 7) ) {
00501       double x0;
00502       sscanf (linebuf, "%*[^0-9-]%lf", &x0);
00503       scan->data.s.x0 = x0;
00504       PI_DEBUG (DBG_L2, "UK2k x0 = " << scan->data.s.x0 );
00505     }
00506 
00507     // offset: y
00508     if ( !strncmp (linebuf, "start_y", 7) ) {
00509       double y0;
00510       sscanf (linebuf, "%*[^0-9-]%lf", &y0);
00511       scan->data.s.y0 = y0;
00512       PI_DEBUG (DBG_L2, "UK2k y0 = " << scan->data.s.y0 );
00513     }
00514 
00515     // topo channel information
00516     if ( !strncmp (linebuf, "servo_range", 11) ) {
00517       double dz;
00518         sscanf (linebuf, "%*[^0-9-]%lf", &dz);
00519         // Actually, the servo_range is the full range in nm, converted into 12 bits
00520         dz/=16384;
00521         PI_DEBUG (DBG_L2, "UK2k z unit: nm" );
00522         PI_DEBUG (DBG_L2, "UK2k dz:" << dz );
00523         UnitObj *zu = gapp->xsm->MakeUnit ("nm","nm");
00524         scan->data.s.dz = zu->Usr2Base(dz);
00525         scan->data.SetZUnit(zu);
00526         delete zu;
00527     }
00528 
00529     // gap voltage
00530     if ( !strncmp (linebuf, "z_bias", 6) ) {
00531       double ugap;
00532         sscanf (linebuf, "%*[^0-9-]%lf", &ugap);
00533         scan->data.s.Bias = ugap/1000.0;
00534         PI_DEBUG (DBG_L2, "UK2k ugap = " << scan->data.s.Bias );
00535     }
00536 
00537     // current feedback setpoint
00538     // missing unit support!
00539     if ( !strncmp (linebuf, "setpoint", 8) ) {
00540       double iset;
00541       sscanf (linebuf, "%*[^0-9-]%lf", &iset);
00542       scan->data.s.Current = iset;
00543       PI_DEBUG (DBG_L2, "UK2k iset = " << scan->data.s.Current );
00544     }
00545 
00546   }
00547 
00548   f.close();
00549 
00550  gchar *tmp=g_strconcat (itime, " ", idate, NULL);
00551   scan->data.ui.SetDateOfScan (tmp);
00552   g_free (tmp);
00553 
00554 // step size: x
00555    scan->data.s.dx = scan->data.s.rx / scan->data.s.nx;
00556    PI_DEBUG (DBG_L2, " dx = " << scan->data.s.dx );
00557 
00558 // step size: y
00559    scan->data.s.dy = scan->data.s.ry/scan->data.s.ny;
00560    PI_DEBUG (DBG_L2, " dy = " << scan->data.s.dy );
00561 
00562   // test for various errors:
00563 //  if (!valid) return FIO_INVALID_FILE;
00564 //  if (!valid return FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00565 
00566   return FIO_OK;
00567 }
00568 
00569 
00570 
00571 
00572 FIO_STATUS UK2k_ImExportFile::Write()
00573 {
00574   return FIO_OK;
00575 }
00576 
00577 
00578 // Plugin's Notify Cb's, registered to be called on file load/save to check file
00579 // return via filepointer, it is set to Zero or passed as Zero if file has been processed!
00580 // That's all fine, you should just change the Text Stings below...
00581 
00582 
00583 static void UK2k_import_filecheck_load_callback (gpointer data ){
00584         gchar **fn = (gchar**)data;
00585         if (*fn){
00586                 PI_DEBUG (DBG_L2, "Check File: UK2k_import_filecheck_load_callback called with >"
00587                      << *fn << "<" );
00588 
00589                 Scan *dst = gapp->xsm->GetActiveScan();
00590                 if(!dst){
00591                         gapp->xsm->ActivateFreeChannel();
00592                         dst = gapp->xsm->GetActiveScan();
00593                 }
00594                 UK2k_ImExportFile fileobj (dst, *fn);
00595 
00596                 FIO_STATUS ret = fileobj.Read();
00597                 if (ret != FIO_OK){
00598                         // I'am responsible! (But failed)
00599                         if (ret != FIO_NOT_RESPONSIBLE_FOR_THAT_FILE) {
00600                                 *fn=NULL;
00601                                 PI_DEBUG (DBG_L2, "UK2k: Read Error " << ((int)ret) << "!!!!!!!!" );
00602                         } else 
00603                                 PI_DEBUG (DBG_L2, "UK2k: Not a UK2k file!" );
00604                         // no more data: remove allocated and unused scan now, force!
00605                         gapp->xsm->SetMode(-1, ID_CH_M_OFF, TRUE);
00606                 }else{
00607                         // got it!
00608                         *fn=NULL;
00609 
00610                         // Now update gxsm main window data fields
00611                         gapp->xsm->ActiveScan->GetDataSet(gapp->xsm->data);
00612                         gapp->spm_update_all();
00613                         dst->draw();
00614                 }
00615         }else{
00616                 PI_DEBUG (DBG_L2, "UK2k_import_filecheck_load: Skipping" );
00617         }
00618 }
00619 
00620 //static void UK2k_import_filecheck_save_callback (gpointer data ){
00621 //      gchar **fn = (gchar**)data;
00622 //      if (*fn){
00623 //              Scan *src;
00624 //              PI_DEBUG (DBG_L2, "Check File: UK2k_import_filecheck_save_callback called with >"
00625 //                   << *fn << "<" );
00626 
00627 //              UK2k_ImExportFile fileobj (src = gapp->xsm->GetActiveScan(), *fn);
00628 
00629 //              FIO_STATUS ret;
00630 //              ret = fileobj.Write();
00631 
00632 //              if(ret != FIO_OK){
00633                         // I'am responsible! (But failed)
00634 //                      if (ret != FIO_NOT_RESPONSIBLE_FOR_THAT_FILE)
00635 //                              *fn=NULL;
00636 //                      PI_DEBUG (DBG_L2, "Write Error " << ((int)ret) << "!!!!!!!!" );
00637 //              }else{
00638 //                      // write done!
00639 //                      *fn=NULL;
00640 //              }
00641 //      }else{
00642 //              PI_DEBUG (DBG_L2, "UK2k_import_filecheck_save: Skipping >" << *fn << "<" );
00643 //      }
00644 //}
00645 
00646 // Menu Call Back Fkte
00647 
00648 static void UK2k_import_import_callback(GtkWidget *w, void *data){
00649 //                                "known extensions: std, stp, STD, STP",
00650         gchar *fn = gapp->file_dialog("UK2k Import", NULL,
00651                                   "*.std",
00652                                   NULL, "UK2k-Import");
00653 
00654     PI_DEBUG (DBG_L2, "FLDLG-IM::" << fn );
00655     UK2k_import_filecheck_load_callback (&fn );
00656 }
00657 
00658 
00659 //static void UK2k_import_export_callback(GtkWidget *w, void *data){
00660 //                                    "known extensions: std, stp, STD, STP",
00661 //      gchar *fn = gapp->file_dialog("UK2k Export", NULL,
00662 //                                    "*.std",
00663 //                                    "","UK2k-Export");
00664 
00665 //    PI_DEBUG (DBG_L2, "FLDLG-EX::" << fn );
00666 //   UK2k_import_filecheck_save_callback (&fn );
00667 //}

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