nanoimport.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  * 
00006  * Gxsm Plugin Name: nanoimport.C
00007  * ========================================
00008  * 
00009  * Copyright (C) 1999 The Free Software Foundation
00010  *
00011  * Authors: Percy Zahl <zahl@fkp.uni-hannover.de>
00012  * additional features: Andreas Klust <klust@fkp.uni-hannover.de>
00013  *
00014  * This program is free software; you can redistribute it and/or modify
00015  * it under the terms of the GNU General Public License as published by
00016  * the Free Software Foundation; either version 2 of the License, or
00017  * (at your option) any later version.
00018  *
00019  * This program is distributed in the hope that it will be useful,
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00022  * GNU General Public License for more details.
00023  *
00024  * You should have received a copy of the GNU General Public License
00025  * along with this program; if not, write to the Free Software
00026  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00027  */
00028 
00029 /* Please do not change the Begin/End lines of this comment section!
00030  * this is a LaTeX style section used for auto generation of the PlugIn Manual 
00031  * Chapter. Add a complete PlugIn documentation inbetween the Begin/End marks!
00032  * --------------------------------------------------------------------------------
00033 % BeginPlugInDocuSection
00034 % PlugInDocuCaption: Import of Digital Instruments Nanoscope files
00035 % PlugInName: nanoimport
00036 % PlugInAuthor: Percy Zahl
00037 % PlugInAuthorEmail: zahl@users.sf.net
00038 % PlugInMenuPath: File/Import/Nano Scope
00039 
00040 % PlugInDescription
00041 The \GxsmEmph{nanoimport} plug-in supports reading files of Digital
00042 Instruments' Nanoscope systems (Veeco Metrology Group).
00043 
00044 This plugin can import original Nanoscope-data files, for older
00045 versions below 0x04300000 (Version: 0x04220200 tested) single channel
00046 data is assumed, for all newer versions (Version: 0x04320003,
00047 0x04430006 tested) multiple channels of data can be present and are
00048 all imported at once using different channels in GXSM. Version below
00049 0x03000000 are rejected (do not know about). The channel type is shown
00050 as scan title. The full ASCII header is appended to the comment.
00051 
00052 % PlugInUsage
00053 The plug-in is called by \GxsmMenu{File/Import/Nano Scope}.
00054 
00055 % OptPlugInKnownBugs
00056 In some cases the Z-scaling is wrong. The reason for that is, I did
00057 not yet figured out the correct way how to interpret several numbers
00058 given in the di-file header. Any help to fix it is welcome! -- I
00059 changed the calculation once more, look OK for newew files and is
00060 still off for some others, I hate it\dots
00061 
00062 According to the manual (V4.1):
00063 \[ H_z = \frac{\text{DAC-value}}{65536} Z_{\text{scale value}} \]
00064 
00065 % EndPlugInDocuSection
00066  * -------------------------------------------------------------------------------- 
00067  */
00068 
00069 
00070 #include <gtk/gtk.h>
00071 #include "config.h"
00072 #include "gxsm/plugin.h"
00073 #include "gxsm/dataio.h"
00074 #include "gxsm/action_id.h"
00075 
00076 using namespace std;
00077 
00078 // Plugin Prototypes
00079 static void nanoimport_init( void );
00080 static void nanoimport_about( void );
00081 static void nanoimport_configure( void );
00082 static void nanoimport_cleanup( void );
00083 
00084 static void nanoimport_run(GtkWidget *w, void *data);
00085 
00086 static void nano_import_filecheck_load_callback (gpointer data); // gchar **fn
00087 
00088 
00089 // Fill in the GxsmPlugin Description here
00090 GxsmPlugin nanoimport_pi = {
00091         NULL,                   // filled in and used by Gxsm, don't touch !
00092         NULL,                   // filled in and used by Gxsm, don't touch !
00093         0,                      // filled in and used by Gxsm, don't touch !
00094         NULL,                   // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 
00095         // filled in here by Gxsm on Plugin load, 
00096         // just after init() is called !!!
00097         // ----------------------------------------------------------------------
00098         // Plugins Name, CodeStly is like: Name-M1S|M2S-BG|F1D|F2D|ST|TR|Misc
00099         "Nanoimport",
00100         // Plugin's Category - used to autodecide on Pluginloading or ignoring
00101         // NULL: load, else
00102         // example: "+noHARD +STM +AFM"
00103         // load only, if "+noHARD: no hardware" and Instrument is STM or AFM
00104         // +/-xxxHARD und (+/-INST or ...)
00105         NULL,
00106         // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details)
00107         "Imports from Nanoscope Data",                   
00108         // Author(s)/* Gnome gxsm - Gnome X Scanning Microscopy
00109         "Percy Zahl",
00110         // Menupath to position where it is appendet to
00111         N_("_File/_Import/"),
00112         // Menuentry
00113         N_("Nano Scope"),
00114         // help text shown on menu
00115         N_("Import Digital NanoScope File"),
00116         // more info...
00117         "no more info",
00118         NULL,          // error msg, plugin may put error status msg here later
00119         NULL,          // Plugin Status, managed by Gxsm, plugin may manipulate it too
00120         // init-function pointer, can be "NULL", 
00121         // called if present at plugin load
00122         nanoimport_init,  
00123         // query-function pointer, can be "NULL", 
00124         // called if present after plugin init to let plugin manage it install itself
00125         NULL, // query should be "NULL" for Gxsm-Math-Plugin !!!
00126         // about-function, can be "NULL"
00127         // can be called by "Plugin Details"
00128         nanoimport_about,
00129         // configure-function, can be "NULL"
00130         // can be called by "Plugin Details"
00131         nanoimport_configure,
00132         // run-function, can be "NULL", if non-Zero and no query defined, 
00133         // it is called on menupath->"plugin"
00134         nanoimport_run, // run should be "NULL" for Gxsm-Math-Plugin !!!
00135         // cleanup-function, can be "NULL"
00136         // called if present at plugin removeal
00137         nanoimport_cleanup
00138 };
00139 
00140 // Text used in Aboutbox, please update!!
00141 static const char *about_text = N_("Gxsm NanoScope Data Import Plugin\n\n"
00142                                    "This plugin reads in a orig. Data File\n"
00143                                    "from Digital Nano Scope to Gxsm.");
00144 
00145 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 
00146 // Essential Plugin Function!!
00147 GxsmPlugin *get_gxsm_plugin_info ( void ){ 
00148         nanoimport_pi.description = g_strdup_printf(N_("Gxsm MathOneArg nanoimport plugin %s"), VERSION);
00149         return &nanoimport_pi; 
00150 }
00151 
00152 // 5.) Start here with the plugins code, vars def., etc.... here.
00153 // ----------------------------------------------------------------------
00154 //
00155 
00156 
00157 // init-Function
00158 static void nanoimport_init(void)
00159 {
00160         PI_DEBUG (DBG_L2, "Nanoimport Plugin Init" );
00161         PI_DEBUG (DBG_L2, "-> connecting to load list" );
00162         gapp->ConnectPluginToLoadFileEvent (nano_import_filecheck_load_callback);
00163 }
00164 
00165 // about-Function
00166 static void nanoimport_about(void)
00167 {
00168         const gchar *authors[] = { nanoimport_pi.authors, NULL};
00169         gtk_widget_show(gnome_about_new ( nanoimport_pi.name,
00170                                           VERSION,
00171                                           N_("(C) 2000 the Free Software Foundation"),
00172                                           about_text,
00173                                           authors,
00174                                           NULL, NULL, NULL
00175                                 ));
00176 }
00177 
00178 // configure-Function
00179 static void nanoimport_configure(void)
00180 {
00181         if(nanoimport_pi.app)
00182                 nanoimport_pi.app->message("Nanoimport Plugin Configuration");
00183 
00184 }
00185 
00186 // cleanup-Function
00187 static void nanoimport_cleanup(void)
00188 {
00189         PI_DEBUG (DBG_L2, "Nanoimport Plugin Cleanup" );
00190 }
00191 
00192 class NanoScopeFile : public Dataio{
00193 public:
00194         NanoScopeFile(Scan *s, const char *n, int i=0) : Dataio(s,n){ imgindex=i; DIversion=0x00; };
00195         void  SetIndex(int i){ imgindex=i; };
00196         int   MultiImage(){ return DIversion < 0x04300000 ? 0:1; }
00197         virtual FIO_STATUS Read();
00198         virtual FIO_STATUS Write(){ return FIO_OK; };
00199 private:
00200         int imgindex;
00201         int DIversion;
00202 };
00203 
00204 FIO_STATUS NanoScopeFile::Read(){
00205         size_t offset=0, length=0;
00206         gchar *line=NULL;
00207         double Zscale=1., Zmag=1.;
00208         double ZSens_V_to_nm=14.;
00209         double ZDAtoVolt=0.006713867;
00210         double CurrentSens_V_to_nA = 10.;
00211         int bps=2;
00212         int imgno=0;
00213 
00214         ifstream f;
00215         GString *FileList=NULL;
00216 
00217         f.open(name, ios::in);
00218         if(!f.good())
00219                 return status=FIO_OPEN_ERR;
00220 
00221         // Initialize with default!
00222         scan->data.LoadValues(gapp->xsm->Inst, gapp->xsm->hardware);
00223 
00224         scan->data.ui.SetName (strrchr(name,'/')?strrchr(name,'/')+1:name);
00225         scan->data.ui.SetOriginalName ("--NA--");
00226         scan->data.ui.SetUser ("somebody@nanoscope");
00227         FileList = g_string_new("Import from Nanoscope Data\n");
00228         g_string_sprintfa(FileList, "Channel No: %d\n", imgindex+1);
00229         g_string_append(FileList, "Original File Info Header follows:\n");
00230 
00231         scan->data.s.rx = 1.;
00232         scan->data.s.ry = 1.;
00233         scan->data.s.nx = 1;
00234         scan->data.s.ny = 1;
00235         scan->data.s.x0 = 0.;
00236         scan->data.s.y0 = 0.;
00237         scan->data.s.alpha = 0.;
00238 
00239         // you may want to calc this from some Header data...
00240         scan->data.display.bright = 32.;
00241         scan->data.display.contrast = 0.01;
00242 
00243         // old: \Version: 0x04220200
00244 
00245         // new: \Version: 0x04320003
00246 
00247         // Get Basic Info
00248         for(; f.good();){
00249                 gchar tmpline[256];
00250                 f.getline(tmpline, 255);
00251                 g_free (line);
00252                 line = g_strstrip (g_strdup (tmpline));
00253                 if (!line) continue;
00254                 if (strlen(line) < 2) continue;
00255                 g_string_append(FileList, line);
00256                 g_string_append(FileList, "\n");
00257 
00258                 if(strncmp(line, "\\Version: 0x", 12) == 0){
00259                         sscanf(&line[12],"%x", &DIversion);
00260                         continue;
00261                 }
00262                 if(strncmp(line, "\\Date: ", 6) == 0){
00263                         scan->data.ui.SetDateOfScan (&line[6]);
00264                         continue;
00265                 }
00266                 if(strncmp(line, "\\Scan size: ",11) == 0){ // assumed in nm
00267                         scan->data.s.rx = scan->data.s.ry = 10.*atof(&line[11]);
00268                         continue;
00269                 }
00270                 if(strncmp(line, "\\Samps/line: ",12) == 0){
00271                         scan->data.s.nx = atoi(&line[12]);
00272                         continue;
00273                 }
00274                 if(strncmp(line, "\\Lines: ",7) == 0){
00275                         scan->data.s.ny = atoi(&line[7]);
00276                         continue;
00277                 }
00278                 if(strncmp(line, "\\X offset: ",10) == 0){
00279                         scan->data.s.x0 = atof(&line[10]);
00280                         continue;
00281                 }
00282                 if(strncmp(line, "\\Y offset: ",10) == 0){
00283                         scan->data.s.y0 = atof(&line[10]);
00284                         continue;
00285                 }
00286                 if(strncmp(line, "\\Rotate Ang.: ",13) == 0){
00287                         scan->data.s.alpha = 180./M_PI*atof(&line[13]);
00288                         continue;
00289                 }
00290                 if(strncmp(line, "\\@Sens. Zscan: V ",16) == 0){
00291                         ZSens_V_to_nm = atof(&line[16]);
00292                         g_string_sprintfa(FileList, "--->got ZSens: %fV/nm\n", ZSens_V_to_nm);
00293                         continue;
00294                 }
00295                 if(strncmp(line, "\\@Sens. Current: V ",18) == 0){
00296                         CurrentSens_V_to_nA = atof(&line[18]);
00297                         g_string_sprintfa(FileList, "--->got CurrentSens: %fV/nA\n", CurrentSens_V_to_nA);
00298                         continue;
00299                 }
00300                 if(strncmp(line, "\\@1:Z limit: V [Sens. Zscan] (",30) == 0){
00301                         ZDAtoVolt = atof(&line[30]); // 0.006713867V/LSB , 440V (+16bit)
00302                         g_string_sprintfa(FileList, "--->got ZDAtoVolt: %fV/LSB\n", ZDAtoVolt);
00303                         continue;
00304                 }
00305 
00306                 // until \*Ciao image list
00307                 if(strncmp(line, "\\*Ciao image list",16) == 0){
00308                         break;
00309                 }
00310                 if(strncmp(line, "\\*File list end ",15) == 0){
00311                         break;
00312                 }
00313         }
00314         g_free (line);
00315         line = NULL;
00316 
00317         scan->data.s.dx = scan->data.s.rx/(double)scan->data.s.nx;
00318         scan->data.s.dy = scan->data.s.ry/(double)scan->data.s.ny;
00319         scan->data.s.ntimes  = 1;
00320         scan->data.s.nvalues = 1;
00321 
00322         if (DIversion < 0x03000000 || !f.good()) // no Nanoscope file or bad/unsupported file format
00323                 return FIO_INVALID_FILE;
00324 
00325         if (DIversion < 0x04300000){
00326                 // Get Img Offset, Length, Bpp
00327                 // Get Basic Info
00328                 g_string_append(FileList, "----------\nImage Information (DI Version < 0x04300000) follows:\n");
00329                 // reopen file
00330                 f.close();
00331                 f.open(name, ios::in);
00332                 for(; f.good();){
00333                         gchar tmpline[256];
00334                         f.getline(tmpline, 255);
00335                         g_free (line);
00336                         line = g_strstrip (g_strdup (tmpline));
00337                         if (!line) continue;
00338                         if (strlen(line) < 2) continue;
00339                         g_string_append(FileList, line);
00340                         g_string_append(FileList, "\n");
00341       
00342                         if(strncmp(line, "\\Data offset: ",13) == 0){
00343                                 offset = (size_t)atoi(&line[13]);
00344                                 continue;
00345                         }
00346                         if(strncmp(line, "\\Data length: ",13) == 0){
00347                                 length = (size_t)atoi(&line[13]);
00348                                 continue;
00349                         }
00350                         if(strncmp(line, "\\Z magnify image: ",17) == 0){
00351                                 Zmag = atof(&line[17]);
00352                                 continue;
00353                         }
00354                         if(strncmp(line, "\\Z scale: ",9) == 0){
00355                                 Zscale = atof(&line[9]);
00356                                 g_string_append(FileList, "----------\n got Z scale, stopping here reading Header.\n");
00357                                 break;
00358                         }
00359                         if(strncmp(line, "\\*File list end ",15) == 0)
00360                                 break;
00361                 }
00362                 g_free (line); 
00363                 line = NULL;
00364                 g_string_append(FileList, "----------\nEnd of File List.\n");
00365                 g_string_append(FileList, 
00366                                 "** Note: I'm unsure about the Z-scale, I use:\n"
00367                                 "** Z scale * Z magnify * 0.1 = 1DA/Angstroem\n");
00368                 // may be wrong in this way, I don't know...
00369                 g_string_sprintfa(FileList, "--->Z magn. = %f\n", Zmag);
00370                 g_string_sprintfa(FileList, "--->Z scale = %f\n", Zscale);
00371                 //    scan->data.s.dz = 0.1*Zscale*Zmag; // in Ang/DA
00372                 scan->data.s.dz = 10.*Zscale/65536.; // in Ang/DA
00373 
00374         }else{
00375 
00376                 // skip to wanted Get Image (imgindex)
00377                 while(imgno < imgindex && f.good()){
00378                         gchar tmpline[256];
00379                         f.getline(tmpline, 255);
00380                         g_free (line);
00381                         line = g_strstrip (g_strdup (tmpline));
00382                         if(strncmp(line, "\\*Ciao image list",16) == 0)
00383                                 ++imgno;
00384                         if(strncmp(line, "\\*File list end ",15) == 0) 
00385                                 break;
00386                 }
00387                 g_free (line); 
00388                 line = NULL;
00389 
00390                 if( imgno < imgindex ){
00391                         f.close();
00392                         g_string_free(FileList, TRUE); 
00393                         FileList=NULL;
00394                         return status=FIO_READ_ERR;
00395                 }
00396     
00397                 // Get Img Offset, Length, Bpp
00398                 // Get Basic Info
00399                 g_string_append(FileList, "----------\nImage Channel Information follows:\n");
00400                 for(; f.good();){
00401                         gchar tmpline[256];
00402                         f.getline(tmpline, 255);
00403                         g_free (line);
00404                         line = g_strstrip (g_strdup (tmpline));
00405                         if (!line) continue;
00406                         if (strlen(line) < 2) continue;
00407                         g_string_append(FileList, line);
00408                         g_string_append(FileList, "\n");
00409       
00410                         if(strncmp(line, "\\Data offset: ",13) == 0){
00411                                 offset = (size_t)atoi(&line[13]);
00412                                 continue;
00413                         }
00414                         if(strncmp(line, "\\Data length: ",13) == 0){
00415                                 length = (size_t)atoi(&line[13]);
00416                                 continue;
00417                         }
00418                         if(strncmp(line, "\\Bytes/pixel: ",13) == 0){
00419                                 bps = (size_t)atoi(&line[13]);
00420                                 continue;
00421                         }
00422                         if(strncmp(line, "\\Valid data start: ",18) == 0){
00423                                 continue;
00424                         }
00425                         if(strncmp(line, "\\Valid data len X: ",18) == 0){
00426                                 continue;
00427                         }
00428                         if(strncmp(line, "\\Valid data len Y: ",18) == 0){
00429                                 continue;
00430                         }
00431                         if(strncmp(line, "\\@2:Image Data: ",15) == 0){
00432                                 continue; // Image Data Type/Name
00433                         }
00434                         if(strncmp(line, "\\@2:Z scale: V [Sens.",21) == 0){
00435                                 gchar *pos = strchr(&line[22], ']');
00436                                 if(pos){
00437                                         *pos = 0;
00438                                         gchar *ScanInfo = g_strdup(&line[22]);
00439                                         g_string_sprintfa(FileList, "--->got ZScan Info: %s\n", ScanInfo);
00440                                         scan->data.ui.SetBaseName (scan->data.ui.name);
00441                                         ZDAtoVolt = atof(pos+3); // 0.006713867V/LSB , 440V (+16bit)
00442                                         g_string_sprintfa(FileList, "--->got ZScan Sens: %fV/LSB\n", ZDAtoVolt);
00443           
00444                                         gchar *nameext = g_strdup_printf("%s[%d]%s", 
00445                                                                          scan->data.ui.name, 
00446                                                                          imgindex+1, 
00447                                                                          ScanInfo);
00448                                         scan->data.ui.SetName (nameext);
00449                                         scan->data.ui.SetBaseName (nameext);
00450                                         g_free(nameext);
00451                                         g_free(ScanInfo);
00452                                 }
00453                                 else
00454                                         g_string_sprintfa(FileList, "---> Error finding matching ']'!\n");
00455                                 continue;
00456                         }
00457       
00458                         if(strncmp(line, "\\*Ciao image list",16) == 0)
00459                                 break;
00460                         if(strncmp(line, "\\*File list end ",15) == 0) 
00461                                 break;
00462                 }
00463                 g_free (line);
00464                 line = NULL;
00465                 g_string_append(FileList, "----------\nEnd of File List.\n");
00466 // --buggy--
00467 // dZ-calculation, this is really strange, see above for tokens read from header.
00468 //              scan->data.s.dz = 0.1*ZSens_V_to_nm*ZDAtoVolt; // in Ang/DA
00469                 scan->data.s.dz = 10.*ZSens_V_to_nm*ZDAtoVolt; // in Ang/DA
00470 //              scan->data.s.dz = 10.*ZSens_V_to_nm/65536.; // in Ang/DA
00471     
00472         }
00473   
00474         g_string_sprintfa(FileList, "--->Calculated dz = %f Ang/DAunit\n", scan->data.s.dz);
00475 
00476         // fix ugly ASCII in place... conversion below fails otherwise
00477         for(gchar *p=FileList->str; *p; ++p)
00478                 if (*p == 'º') *p='d';
00479 
00480         gsize br, bw;
00481         GError *error = NULL;
00482 //      gchar *utf8_text = g_convert_with_fallback (FileList->str, -1, "UTF-8", "US-ASCII", "?",
00483 //                                                  &br, &bw, &error);
00484         gchar *utf8_text = g_convert (FileList->str, -1, "UTF-8", "ISO-8859-1", 
00485                             &br, &bw, &error);
00486 
00487         if (error != NULL){
00488                 gchar *info = g_strdup_printf (
00489                         "Nanoscope header to comment conversion failed:\n"
00490                         "Sorry, an ISO-8859-1 to UTF-8 conversion error occured,\n"
00491                         "g_convert retured an error code.\n"
00492                         "Bytes read: %d, written: %d",
00493                         br, bw
00494                         );
00495                 scan->data.ui.SetComment (info);
00496                 g_free (info);
00497                 g_error_free (error);
00498         } else
00499                 scan->data.ui.SetComment (utf8_text);
00500 
00501         g_free (utf8_text);
00502         g_string_free(FileList, TRUE); 
00503         FileList=NULL;
00504 
00505         // Read Img Data.
00506     
00507         f.seekg(offset, ios::beg);
00508     
00509         scan->mem2d->Resize (scan->data.s.nx, scan->data.s.ny);
00510         scan->mem2d->DataRead (f, -1);
00511         scan->mem2d->data->MkXLookup (-scan->data.s.rx/2., scan->data.s.rx/2.);
00512         scan->mem2d->data->MkYLookup (-scan->data.s.ry/2., scan->data.s.ry/2.);
00513   
00514         if(f.fail()){
00515                 f.close();
00516                 return status=FIO_READ_ERR; 
00517         }
00518         f.close();
00519         return status=FIO_OK; 
00520 }
00521 
00522 
00523 static void nano_import_filecheck_load_callback (gpointer data){
00524         gchar **fn = (gchar**)data;
00525         if (*fn){
00526                 Scan *dst;
00527                 int ret, ret0;
00528                 PI_DEBUG (DBG_L2, "Check File: nano_import_filecheck_load_calback >"
00529                           << *fn << "<" );
00530 
00531 
00532                 gapp->xsm->ActivateFreeChannel();
00533                 NanoScopeFile NanoFile(dst = gapp->xsm->GetActiveScan(), *fn);
00534                 for(int i=0; i<3; ++i){
00535                         if(!dst){
00536                                 gapp->xsm->ActivateFreeChannel();
00537                                 dst = gapp->xsm->GetActiveScan();
00538                         }
00539                         NanoFile.SetIndex(i);
00540                         NanoFile.SetScan(dst);
00541                         if((ret=NanoFile.Read()) != FIO_OK){ 
00542                                 // no more data: remove allocated and unused scan now, force!
00543                                 if(i==0) ret0 = ret;
00544                                 gapp->xsm->SetMode(-1, ID_CH_M_OFF, TRUE); 
00545                                 break; 
00546                         }
00547                         if(i==0) ret0 = ret;
00548                         gapp->xsm->ActiveScan->GetDataSet(gapp->xsm->data);
00549                         gapp->xsm->AutoDisplay ();
00550                         gapp->spm_update_all();
00551                         dst->draw();
00552                         dst=NULL;
00553                         if(! NanoFile.MultiImage() ) break;
00554                 }
00555 
00556                 if (ret != FIO_OK){ 
00557                         // I'am responsible! (But failed)
00558                         if (ret != FIO_NOT_RESPONSIBLE_FOR_THAT_FILE)
00559                                 *fn=NULL;
00560                         // no more data: remove allocated and unused scan now, force!
00561                         gapp->xsm->SetMode(-1, ID_CH_M_OFF, TRUE); 
00562                         PI_DEBUG (DBG_L2, "Read Error " << ((int)ret) << "!!!!!!!!" );
00563                 }else{
00564                         // got it!
00565                         *fn=NULL;
00566                         // Now update
00567 
00568                         gapp->xsm->ActiveScan->GetDataSet(gapp->xsm->data);
00569                         gapp->xsm->AutoDisplay ();
00570                         gapp->spm_update_all();
00571                         dst->draw();
00572                 }
00573         }else{
00574                 PI_DEBUG (DBG_L2, "nano_import_filecheck_load: Skipping" );
00575         }
00576 }
00577 
00578 // run-Function
00579 static void nanoimport_run(GtkWidget *w, void *data)
00580 {
00581         Scan *dst;
00582         gchar *nfname = gapp->file_dialog("NanoScope file to load", NULL, 
00583                                           "*", NULL, "NanoImport");
00584         if( !nfname ) return;
00585 
00586         gapp->xsm->ActivateFreeChannel();
00587         NanoScopeFile NanoFile(dst = gapp->xsm->GetActiveScan(), nfname);
00588         for(int i=0; i<3; ++i){
00589                 if(!dst){
00590                         gapp->xsm->ActivateFreeChannel();
00591                         dst = gapp->xsm->GetActiveScan();
00592                 }
00593                 NanoFile.SetIndex(i);
00594                 NanoFile.SetScan(dst);
00595                 if(NanoFile.Read() != FIO_OK){ 
00596                         // no more data: remove allocated and unused scan now, force!
00597                         gapp->xsm->SetMode(-1, ID_CH_M_OFF, TRUE); 
00598                         break; 
00599                 }
00600                 gapp->xsm->ActiveScan->GetDataSet(gapp->xsm->data);
00601                 gapp->xsm->AutoDisplay ();
00602                 gapp->spm_update_all();
00603                 dst->draw();
00604                 dst=NULL;
00605                 if(! NanoFile.MultiImage() ) break;
00606         }
00607 }

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