gmeyer_im_export.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: gmeyer_im_export.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: Import/Export of G.Meyer STM/AFM Dat files
00034 % PlugInName: gmeyer_im_export
00035 % PlugInAuthor: Percy Zahl
00036 % PlugInAuthorEmail: zahl@users.sf.net
00037 % PlugInMenuPath: File/Import/GMeyer Dat
00038 
00039 % PlugInDescription
00040 \label{plugins:gmeyer_im_export}
00041 The \GxsmEmph{gmeyer\_im\_export} plug-in supports reading and writing of
00042 Dat files used by the G.Meyer STM/AFM software.
00043 
00044 % PlugInUsage
00045 The plug-in is called by \GxsmMenu{File/Import/GME Dat}.
00046 
00047 % OptPlugInKnownBugs
00048 Not yet all very well tested.
00049 
00050 % EndPlugInDocuSection
00051  * -------------------------------------------------------------------------------- 
00052  */
00053 
00054 /* GME File Header
00055  * --------------------------------------------------
00056 [Parameter]
00057 Titel / Titel=DEFAULT
00058 Delta X / Delta X [Dac]=16
00059 Delta Y / Delta Y [Dac]=16
00060 Num.X / Num.X=256
00061 Num.Y / Num.Y=256
00062 Delay X+ / Delay X+=350
00063 Delay X- / Delay X-=300
00064 Delay Y / Delay Y=400
00065 D-DeltaX / D-DeltaX=4
00066 GainX / GainX=10
00067 GainY / GainY=10
00068 GainZ / GainZ=10
00069 Rotation / Rotation=0
00070 BiasVoltage / BiasVolt.[mV]=-3200
00071 Gainpreamp / GainPre 10^=6
00072 Chan(1,2,4) / Chan(1,2,4)=1
00073 PlanDx / PlanDx=0.0000
00074 PlanDy / PlanDy=0.0000
00075 Scanrotoffx / OffsetX=0.0
00076 Scanrotoffy / OffsetY=0.0
00077 MVolt_1 / MVolt_1=-20000
00078 MVolt_2 / MVolt_2=-20000
00079 MVolt_3 / MVolt_3=0
00080 MVolt_4 / MVolt_4=0
00081 MVolt_5 / MVolt_5=0
00082 MVolt_6 / MVolt_6=0
00083 RepeatRotinc / RepeatRotinc=0
00084 RptBVoltinc / RptBVoltinc=0
00085 Repeatinterval / Repeatinterval=0
00086 Repeatcounter / Repeatcounter=0
00087 RepeatXoffset / RepeatXoffset=0
00088 RepeatYoffset / RepeatYoffset=0
00089 Scantype / Scantype=1
00090 Scanmode / Scanmode=1
00091 Scancoarse / Scancoarse=1
00092 CHMode / CHMode=0
00093 Channels / Channels=1
00094 Preamptype / Preamptype=4
00095 Latmanmode=0
00096 LatmResist=1.000E+11
00097 LatmanVolt=1000
00098 Latmanlgi=1
00099 Latmangain=8
00100 Latmanddx=1
00101 Latmandelay=100
00102 Latm0Delay=2
00103 Latmanccdz=0
00104 Latmanextension=1.000
00105 TipForm_Volt=0
00106 TipForm_Z=0
00107 Tip_Delay=100
00108 Tip_Latddx=1
00109 Tip_LatDelay=100
00110 Vertmangain=8
00111 Vertmandelay=10
00112 Vpoint0.t=0
00113 Vpoint1.t=400
00114 Vpoint2.t=600
00115 Vpoint3.t=1024
00116 Vpoint0.V=0
00117 Vpoint1.V=-1000
00118 Vpoint2.V=-1000
00119 Vpoint3.V=0
00120 Zpoint0.t=0
00121 Zpoint1.t=400
00122 Zpoint2.t=600
00123 Zpoint3.t=1024
00124 Zpoint0.z=0
00125 Zpoint1.z=-100
00126 Zpoint2.z=-100
00127 Zpoint3.z=0
00128 Zoffset=0
00129 Zdrift=0
00130 VertSpecBack=0
00131 VertSpecAvrgnr=1
00132 VertRepeatCounter=1
00133 Imageframe=1
00134 Imagegrayfactor=0.999
00135 Zoom=2
00136 OrgPlanX=0.00000
00137 OrgPlanY=0.00000
00138 OrgPlanOff=0.00000
00139 Dacto[A]xy=0.03052
00140 Dacto[A]z=0.00610
00141 Planoff=0
00142 Planx=0
00143 Plany=0
00144 Plany2=0
00145 Planavrgnr=17
00146 Planoffset2=0
00147 Plano2start=0
00148 Imagebackoffset=0
00149 Frameimageoffset=1000
00150 YLineOFF=1
00151 YLineFAC=10
00152 DigZoomX=1.00000
00153 DigZoomZ=1.00000
00154 FBLogIset= 500.100
00155 FBRC=  0.000200
00156 FBLingain=-60000.0
00157 FBVoltRC=  0.000526
00158 FBVoltGain=    6.0
00159 CurrentRC= 0.010
00160 FBLog=1
00161 Imaxcurrent=100000.0
00162 Imaxdelay=   1000
00163 ImaxZret=  0.000
00164 SpecAvrgnr=1
00165 SpecFreq=10000.000
00166 SpecChan=1
00167 FFTPoints=1024
00168 LockinFreq=50
00169 LockinAmpl=200
00170 LockinPhase=0
00171 LockinPhase2=0
00172 LockinRC= 0.00010
00173 LockinMode=1
00174 DSP_Clock=50000
00175 SRS_Frequency=1000.000
00176 SRS_ModVoltage=  1.0000
00177 SRS_InpGain[V]=1.0E+00
00178 SRS_InpTimeC[s]=1.0E+00
00179 UserPreampCode=5:000000/6:000000/7:000000/8:000000/
00180 Upinc=50
00181 Upcount=200
00182 Downinc=50
00183 Downcount=200
00184 Rotinc=50
00185 Rotincquad=0
00186 Rotcount=200
00187 XYBurst=100
00188 RotBurst=100
00189 Aprologiset=  2.000
00190 Aprolimit=10000
00191 Aprodelay=300
00192 Aprorc= 0.00020
00193 Autolevel=1
00194 RPTcount=0
00195 RPTIncVolt=0
00196 RPTIncdz=0
00197 SDOrg%=1
00198 SdStatDiff%=0
00199 SDOffset=0
00200 SDBbeta=0
00201 CorrCheckSize=8
00202 CorrImageSize=8
00203 IslandLevel=0.50
00204 Scall-Number=
00205 VertSwitchLevel=0
00206 ADC_0=11
00207 ADC_1=-1
00208 ADC_2=2
00209 ADC_3=1
00210 VertMaxI=11000
00211 VertTreshimin=-20000
00212 VertTreshimax=20000
00213 RptCHMZinc=0
00214 CHModeZoffset=0
00215 CHModegainpreamp=6
00216 ScandVinc=0
00217 ScandIinc=0
00218 TrackingDx=1
00219 AltSpecCalc=0
00220 VStart=-1000
00221 Vend=1000
00222 ZStart=0
00223 ZMid=0
00224 ZEnd=0
00225 VoltReso=1
00226 SpecTime=1000
00227 MVolt_7=0
00228 MVolt_8=0
00229 MVolt_9=0
00230 MVolt_10=0
00231 MVolt_11=0
00232 MVolt_12=0
00233 MVolt_13=0
00234 MVolt_14=0
00235 MVolt_15=0
00236 MVolt_16=0
00237 MVolt_17=0
00238 MVolt_18=0
00239 MVolt_19=0
00240 MVolt_20=0
00241 VFBVLimit=5000
00242 Preampoffset=-335
00243 USBBufferFill=0
00244 FBAFMSetpoint=-1654
00245 FBAFMrc=0.0005260
00246 FBAFMgain=6
00247 THe[K]= 
00248 TSTM[K]= 
00249 TManip[K]= 
00250 PLoadLock= 
00251 PPraep= 
00252 TSample[C]= 
00253 TEvap[C]= 
00254 = 
00255 Z-Res. [A]: +/- =7.809
00256 Length x[A]=1250.0381
00257 Length y[A]=1250.0381
00258 Biasvolt[mV]=-3200
00259 Current[A]=5.0E-07
00260 Sec/line:=7.168
00261 Sec/Image:=3670.016
00262 ActGainXYZ=30 30 30
00263 Channels=1
00264 T-STM:=0.00000
00265 = 
00266 HP_Ch1=0.00000
00267 HP_Ch2=0.00000
00268 HP_Ch3=0.00000
00269 HP_Ch4=0.00000
00270 = 
00271 ZPiezoconst= 20.00
00272 Xpiezoconst=100.00
00273 YPiezoconst=100.00
00274 = 
00275 T_ADC2[K]=  0.000
00276 T_ADC3[K]=  0.000
00277 = 
00278 = 
00279 = 
00280 = 
00281 = 
00282 = 
00283 = 
00284 = 
00285 = 
00286 = 
00287 = 
00288 = 
00289 = 
00290 = 
00291 = 
00292 = 
00293 = 
00294 = 
00295 = 
00296 = 
00297 = 
00298 = 
00299 = 
00300 = 
00301 = 
00302 = 
00303 = 
00304 memo:0=CU(211) T=20K                       
00305 memo:1=  
00306 memo:2=g101010 i8 
00307 memo:3=0.585V
00308 
00309 ... junk ...
00310 DATA 2bytes junk
00311         start of short field(s)
00312 
00313  * End of GME File Header
00314  * --------------------------------------------------
00315  */
00316 
00317 
00318 #include <gtk/gtk.h>
00319 #include "config.h"
00320 #include "gxsm/plugin.h"
00321 #include "gxsm/dataio.h"
00322 #include "gxsm/action_id.h"
00323 
00324 #include <zlib.h>
00325 
00326 using namespace std;
00327 
00328 #define IMGMAXCOLORS 64
00329 
00330 // Plugin Prototypes
00331 static void gmeyer_im_export_init (void);
00332 static void gmeyer_im_export_query (void);
00333 static void gmeyer_im_export_about (void);
00334 static void gmeyer_im_export_configure (void);
00335 static void gmeyer_im_export_cleanup (void);
00336 
00337 static void gmeyer_im_export_filecheck_load_callback (gpointer data );
00338 static void gmeyer_im_export_filecheck_save_callback (gpointer data );
00339 
00340 static void gmeyer_im_export_import_callback (GtkWidget *w, void *data);
00341 static void gmeyer_im_export_export_callback (GtkWidget *w, void *data);
00342 
00343 // Fill in the GxsmPlugin Description here
00344 GxsmPlugin gmeyer_im_export_pi = {
00345   NULL,                   // filled in and used by Gxsm, don't touch !
00346   NULL,                   // filled in and used by Gxsm, don't touch !
00347   0,                      // filled in and used by Gxsm, don't touch !
00348   NULL,                   // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 
00349                           // filled in here by Gxsm on Plugin load, 
00350                           // just after init() is called !!!
00351   "Gmeyer_Im_Export",
00352   NULL,                   // PlugIn's Categorie, set to NULL for all, I just don't want this always to be loaded!
00353   // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details)
00354   "Im/Export of Dat files from G.Meyer software.",
00355   "Percy Zahl",
00356   N_("_File/_Import/,_File/_Export/"),
00357   N_("GME Dat,GME Dat"),
00358   N_("Import G.Meyer STMAFM data file,Export G.Meyer STMAFM data file"),
00359   N_("G.Meyer STMAFM software data file im/export."),
00360   NULL,          // error msg, plugin may put error status msg here later
00361   NULL,          // Plugin Status, managed by Gxsm, plugin may manipulate it too
00362   gmeyer_im_export_init,
00363   gmeyer_im_export_query,
00364   // about-function, can be "NULL"
00365   // can be called by "Plugin Details"
00366   gmeyer_im_export_about,
00367   // configure-function, can be "NULL"
00368   // can be called by "Plugin Details"
00369   gmeyer_im_export_configure,
00370   // run-function, can be "NULL", if non-Zero and no query defined, 
00371   // it is called on menupath->"plugin"
00372   NULL,
00373   // cleanup-function, can be "NULL"
00374   // called if present at plugin removeal
00375   gmeyer_im_export_cleanup
00376 };
00377 
00378 // Text used in Aboutbox, please update!!
00379 static const char *about_text = N_("Gxsm G.Meyer STMAFM Data File Import/Export Plugin\n\n"
00380                                    " "
00381         );
00382 
00383 static const char *file_mask = "*.dat";
00384 
00385 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 
00386 // Essential Plugin Function!!
00387 GxsmPlugin *get_gxsm_plugin_info ( void ){ 
00388   gmeyer_im_export_pi.description = g_strdup_printf(N_("Gxsm gmeyer_im_export plugin %s"), VERSION);
00389   return &gmeyer_im_export_pi; 
00390 }
00391 
00392 // Query Function, installs Plugin's in File/Import and Export Menupaths!
00393 // ----------------------------------------------------------------------
00394 // Import Menupath is "File/Import/GME Dat"
00395 // Export Menupath is "File/Export/GME Dat"
00396 // ----------------------------------------------------------------------
00397 // !!!! make sure the "gmeyer_im_export_cleanup()" function (see below) !!!!
00398 // !!!! removes the correct menuentries !!!!
00399 
00400 static void gmeyer_im_export_query(void)
00401 {
00402         gchar **path  = g_strsplit (gmeyer_im_export_pi.menupath, ",", 2);
00403         gchar **entry = g_strsplit (gmeyer_im_export_pi.menuentry, ",", 2);
00404         gchar **help  = g_strsplit (gmeyer_im_export_pi.help, ",", 2);
00405 
00406         static GnomeUIInfo menuinfo_i[] = { 
00407                 { GNOME_APP_UI_ITEM, NULL, NULL,
00408                   NULL, NULL,
00409                   NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN,
00410                   0, GDK_CONTROL_MASK, NULL },
00411                 GNOMEUIINFO_END
00412         };
00413         menuinfo_i[0].label  = entry[0];
00414         menuinfo_i[0].hint   = help[0];
00415         menuinfo_i[0].moreinfo  = (gpointer) gmeyer_im_export_import_callback; 
00416         menuinfo_i[0].user_data = gmeyer_im_export_pi.name;
00417 
00418         gnome_app_insert_menus (
00419                 GNOME_APP(gmeyer_im_export_pi.app->getApp()), 
00420                 path[0], 
00421                 menuinfo_i
00422                 );
00423         
00424 
00425         static GnomeUIInfo menuinfo_e[] = { 
00426                 { GNOME_APP_UI_ITEM, NULL, NULL,
00427                   NULL, NULL,
00428                   NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_SAVE,
00429                   0, GDK_CONTROL_MASK, NULL },
00430                 GNOMEUIINFO_END
00431         };
00432         menuinfo_e[0].label  = entry[1];
00433         menuinfo_e[0].hint   = help[1];
00434         menuinfo_e[0].moreinfo  = (gpointer) gmeyer_im_export_export_callback; 
00435         menuinfo_e[0].user_data = gmeyer_im_export_pi.name;
00436 
00437         gnome_app_insert_menus (
00438                 GNOME_APP(gmeyer_im_export_pi.app->getApp()), 
00439                 path[1],
00440                 menuinfo_e
00441                 );
00442 
00443         if(gmeyer_im_export_pi.status) g_free(gmeyer_im_export_pi.status); 
00444         gmeyer_im_export_pi.status = g_strconcat (
00445                 N_("Plugin query has attached "),
00446                 gmeyer_im_export_pi.name, 
00447                 N_(": File IO Filters are ready to use."),
00448                 NULL);
00449         
00450         // clean up
00451         g_strfreev (path);
00452         g_strfreev (entry);
00453         g_strfreev (help);
00454 
00455 // register this plugins filecheck functions with Gxsm now!
00456 // This allows Gxsm to check files from DnD, open, 
00457 // and cmdline sources against all known formats automatically - no explicit im/export is necessary.
00458         gmeyer_im_export_pi.app->ConnectPluginToLoadFileEvent (gmeyer_im_export_filecheck_load_callback);
00459         gmeyer_im_export_pi.app->ConnectPluginToSaveFileEvent (gmeyer_im_export_filecheck_save_callback);
00460 }
00461 
00462 
00463 // 5.) Start here with the plugins code, vars def., etc.... here.
00464 // ----------------------------------------------------------------------
00465 //
00466 
00467 
00468 // init-Function
00469 static void gmeyer_im_export_init(void)
00470 {
00471         PI_DEBUG (DBG_L2, "gmeyer_im_export Plugin Init");
00472 }
00473 
00474 // about-Function
00475 static void gmeyer_im_export_about(void)
00476 {
00477         const gchar *authors[] = { gmeyer_im_export_pi.authors, NULL};
00478         gtk_widget_show(gnome_about_new ( gmeyer_im_export_pi.name,
00479                                           VERSION,
00480                                           N_("(C) 2001 the Free Software Foundation"),
00481                                           about_text,
00482                                           authors,
00483                                           NULL, NULL, NULL
00484                                           ));
00485 }
00486 
00487 // configure-Function
00488 static void gmeyer_im_export_configure(void)
00489 {
00490         if(gmeyer_im_export_pi.app)
00491                 gmeyer_im_export_pi.app->message("gmeyer_im_export Plugin Configuration");
00492 }
00493 
00494 // cleanup-Function, make sure the Menustrings are matching those above!!!
00495 static void gmeyer_im_export_cleanup(void)
00496 {
00497         gchar **path  = g_strsplit (gmeyer_im_export_pi.menupath, ",", 2);
00498         gchar **entry = g_strsplit (gmeyer_im_export_pi.menuentry, ",", 2);
00499 
00500         gchar *tmp = g_strconcat (path[0], entry[0], NULL);
00501         gnome_app_remove_menus (GNOME_APP (gmeyer_im_export_pi.app->getApp()), tmp, 1);
00502         g_free (tmp);
00503 
00504         tmp = g_strconcat (path[1], entry[1], NULL);
00505         gnome_app_remove_menus (GNOME_APP (gmeyer_im_export_pi.app->getApp()), tmp, 1);
00506         g_free (tmp);
00507 
00508         g_strfreev (path);
00509         g_strfreev (entry);
00510 
00511         PI_DEBUG (DBG_L2, "Plugin Cleanup done.");
00512 }
00513 
00514 // make a new derivate of the base class "Dataio"
00515 class gmeyer_ImExportFile : public Dataio{
00516 public:
00517         gmeyer_ImExportFile(Scan *s, const char *n) : Dataio(s,n){ };
00518         virtual FIO_STATUS Read();
00519         virtual FIO_STATUS Write();
00520 private:
00521         FIO_STATUS import(const char *fname);
00522 };
00523 
00524 // d2d import :=)
00525 FIO_STATUS gmeyer_ImExportFile::Read(){
00526         FIO_STATUS ret;
00527         gchar *fname=NULL;
00528 
00529         fname = (gchar*)name;
00530 
00531         // name should have at least 4 chars: ".ext"
00532         if (fname == NULL || strlen(fname) < 4)
00533                 return  FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00534  
00535         // check for file exists and is OK !
00536         // else open File Dlg
00537         ifstream f;
00538         f.open(fname, ios::in);
00539         if(!f.good()){
00540                 PI_DEBUG (DBG_L2, "File Fehler");
00541                 return status=FIO_OPEN_ERR;
00542         }
00543         f.close();
00544 
00545         // Check all known File Types:
00546         
00547         // is this a GME Dat file?
00548         if ((ret=import (fname)) !=  FIO_NOT_RESPONSIBLE_FOR_THAT_FILE)
00549                 return ret;
00550 
00551         return  FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00552 }
00553 
00554 FIO_STATUS gmeyer_ImExportFile::import(const char *fname){
00555 
00556         // Am I resposible for that file, is it a "Gme-Dat" format ?
00557         ifstream f;
00558         gchar line[0x4000];
00559         GString *FileList=NULL;
00560         int datamode = 16;
00561 
00562         f.open(fname, ios::in);
00563         if (!f.good())
00564                 return status=FIO_OPEN_ERR;
00565 
00566         f.getline(line, 0x4000);
00567 
00568         if (strncmp (line, "[Parameter]", 11) != 0){
00569                 // check for 32 bit data version
00570                 if (strncmp (line, "[Paramco32]", 11) != 0){
00571                         f.close ();
00572                         return FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00573                 }
00574                 datamode = 32;
00575         }
00576         
00577         time_t t; // Scan - Startzeit eintragen 
00578         time(&t);
00579         gchar *tmp = g_strconcat ((ctime(&t)), " (Imported)", NULL); scan->data.ui.SetDateOfScan (tmp); g_free (tmp);
00580         scan->data.ui.SetName (fname);
00581         scan->data.ui.SetOriginalName (fname);
00582         scan->data.ui.SetType ("G.Meyer STMAFM"); 
00583 
00584 
00585         // this is mandatory.
00586         scan->data.s.ntimes  = 1;
00587         scan->data.s.nvalues = 1;
00588   
00589   
00590         // put some usefull values in the ui structure
00591         if(getlogin()){
00592                 scan->data.ui.SetUser (getlogin());
00593         }
00594         else{
00595                 scan->data.ui.SetUser ("unkonwn user");
00596         }
00597 
00598         // initialize scan structure -- this is a minimum example
00599         scan->data.s.nx = 1;
00600         scan->data.s.ny = 1;
00601         scan->data.s.dx = 1;
00602         scan->data.s.dy = 1;
00603         scan->data.s.dz = -1;
00604         scan->data.s.rx = scan->data.s.nx;
00605         scan->data.s.ry = scan->data.s.ny;
00606         scan->data.s.x0 = 0;
00607         scan->data.s.y0 = 0;
00608         scan->data.s.alpha = 0;
00609 
00610         // be nice and reset this to some defined state
00611         scan->data.display.cpshigh       = 1e3;
00612         scan->data.display.cpslow        = 1.;
00613         scan->data.display.cnttime       = 1.;
00614 
00615         // set the default view parameters
00616         scan->data.display.bright = 32.;
00617         scan->data.display.contrast = 1.0;
00618 
00619         // FYI: (PZ)
00620         //  scan->data.display.vrange_z  = ; // View Range Z in base ZUnits
00621         //  scan->data.display.voffset_z = 0; // View Offset Z in base ZUnits
00622         //  scan->AutoDisplay([...]); // may be used too...
00623   
00624 
00625         FileList = g_string_new ("Imported by Gxsm from G.Meyer STMAFM Dat file.\n");
00626         g_string_sprintfa (FileList, "Original Filename: %s\n", fname);
00627         g_string_append (FileList, "Original GME File Header follows:\n");
00628         
00629         int dxi=0, dyi=0;
00630         int chan=1, channels=1;
00631         double gx=1., gy=1., gz=1.;
00632         double pzAV_x=1., pzAV_y=1., pzAV_z=1.;
00633 
00634         int stop=0;
00635         for (; f.good ();){
00636                 f.getline (line, 0x4000);
00637                 //                  0        1         2         3         4
00638                 //                  1234567890123456789012345678901234567890
00639                 if (strncmp (line, "DATA", 4) == 0) // start of data
00640                         break;
00641                 if (strncmp (line, "Titel / Titel=", 14) == 0)
00642                         ;
00643                 if (strncmp (line, "Delta X / Delta X [Dac]=", 24) == 0)
00644                         dxi = atoi (&line[24]);
00645                 if (strncmp (line, "Delta Y / Delta Y [Dac]=", 24) == 0)
00646                         dyi = atoi (&line[24]);
00647                 if (strncmp (line, "Num.X / Num.X=", 14) == 0)
00648                         scan->data.s.nx = atoi (&line[14]);
00649                 if (strncmp (line, "Num.Y / Num.Y=", 14) == 0)
00650                         scan->data.s.ny = atoi (&line[14]);
00651                 if (strncmp (line, "Delay X+ / Delay X+=", 20) == 0)
00652                         ; // = atoi (&line[20]);
00653                 if (strncmp (line, "Delay X- / Delay X-=", 20) == 0)
00654                         ; // = atoi (&line[20]);
00655                 if (strncmp (line, "Delay Y / Delay Y=", 18) == 0)
00656                         ; // = atoi (&line[18]);
00657                 if (strncmp (line, "D-DeltaX / D-DeltaX=", 20) == 0)
00658                         ; // = atof (&line[20]);
00659                 if (strncmp (line, "GainX / GainX=", 14) == 0)
00660                         gx = atof (&line[14]);
00661                 if (strncmp (line, "GainY / GainY=", 14) == 0)
00662                         gy = atof (&line[14]);
00663                 if (strncmp (line, "GainZ / GainZ=", 14) == 0)
00664                         gz = atof (&line[14]);
00665                 if (strncmp (line, "Rotation / Rotation=", 20) == 0)
00666                         scan->data.s.alpha = atof (&line[20]);
00667                 if (strncmp (line, "BiasVoltage / BiasVolt.[mV]=", 28) == 0)
00668                         ; // = atof (&line[28]);
00669                 if (strncmp (line, "Gainpreamp / GainPre 10^=", 29) == 0)
00670                         ; // = atof (&line[29]);
00671                 if (strncmp (line, "Chan(1,2,4) / Chan(1,2,4)=", 26) == 0)
00672                         chan = atoi (&line[26]);
00673                 if (strncmp (line, "Scanrotoffx / OffsetX=", 22) == 0)
00674                         scan->data.s.x0 = atof (&line[22]);
00675                 if (strncmp (line, "Scanrotoffy / OffsetY=", 22) == 0)
00676                         scan->data.s.y0 = atof (&line[22]);
00677                 if (strncmp (line, "MVolt_1 / MVolt_1=", 18) == 0)
00678                         ; // = atof (&line[0]);
00679                 if (strncmp (line, "MVolt_2 / MVolt_2=", 18) == 0)
00680                         ; // = atof (&line[0]);
00681                 if (strncmp (line, "MVolt_3 / MVolt_3=", 18) == 0)
00682                         ; // = atof (&line[0]);
00683                 if (strncmp (line, "MVolt_4 / MVolt_4=", 18) == 0)
00684                         ; // = atof (&line[0]);
00685                 if (strncmp (line, "MVolt_5 / MVolt_5=", 18) == 0)
00686                         ; // = atof (&line[0]);
00687                 if (strncmp (line, "MVolt_6 / MVolt_6=", 18) == 0)
00688                         ; // = atof (&line[0]);
00689                 if (strncmp (line, "CHMode / CHMode=", 16) == 0)
00690                         ; // = atof (&line[0]);
00691                 if (strncmp (line, "Channels / Channels=", 20) == 0)
00692                         channels = atoi (&line[20]);
00693                 if (strncmp (line, "Preamptype / Preamptype=", 24) == 0)
00694                         ; // = atof (&line[0]);
00695 
00696                 if (strncmp (line, "Z-Res. [A]: +/- =", 17) == 0)
00697                         ; // = atof (&line[0]);
00698                 if (strncmp (line, "Length x[A]=", 12) == 0)
00699                         scan->data.s.rx = atof (&line[12]);
00700                 if (strncmp (line, "Length y[A]=", 12) == 0)
00701                         scan->data.s.ry = atof (&line[12]);
00702                 if (strncmp (line, "Biasvolt[mV]=", 13) == 0)
00703                         ; // = atof (&line[0]);
00704                 if (strncmp (line, "Current[A]=", 11) == 0)
00705                         ; // = atof (&line[0]);
00706                 if (strncmp (line, "ActGainXYZ=", 11) == 0)
00707                         ; // = atof (&line[0]);
00708 
00709                 if (strncmp (line, "Channels=", 9) == 0)
00710                         channels = atoi (&line[9]);
00711 
00712                 if (strncmp (line, "ZPiezoconst=", 12) == 0)
00713                         pzAV_z = atof (&line[12]);
00714                 if (strncmp (line, "Xpiezoconst=", 12) == 0)
00715                         pzAV_x = atof (&line[12]);
00716                 if (strncmp (line, "YPiezoconst=", 12) == 0)
00717                         pzAV_y = atof (&line[12]);
00718 
00719                 if (strncmp (line, "memo:", 5) == 0){
00720                         stop = 1;
00721                         g_string_append(FileList, line);
00722                         g_string_append(FileList, "\n");
00723                 }
00724                 if (!stop){
00725                         g_string_append(FileList, line);
00726                         g_string_append(FileList, "\n");
00727                 }
00728         }
00729 
00730         scan->data.ui.SetComment (FileList->str);
00731         g_string_free(FileList, TRUE); 
00732         FileList=NULL;
00733 
00734         scan->data.s.dx = scan->data.s.rx / scan->data.s.nx;
00735         scan->data.s.dy = scan->data.s.ry / scan->data.s.ny;
00736 
00737         // convert to Ang
00738         scan->data.s.x0 *= pzAV_x / 32767.*10. * gx ;
00739         scan->data.s.y0 *= pzAV_y / 32767.*10. * gy ;
00740 
00741 
00742         // Read Img Data.
00743         
00744         // skip 2 bytes after "\r\nDATA"
00745         // f.read(line, 2);
00746 
00747         switch (datamode){
00748         case 16:
00749                 scan->data.s.dz = pzAV_z / (1<<15) * 10.* gz; // adjust Z
00750                 f.seekg(0x4004, ios::beg);
00751                 scan->mem2d->Resize (scan->data.s.nx, scan->data.s.ny, ZD_SHORT);
00752                 scan->mem2d->DataRead (f, 1);
00753                 break;
00754         case 32: {
00755                 scan->data.s.dz = pzAV_z / (1<<19) * 10. * gz; // adjust Z
00756                 scan->mem2d->Resize (scan->data.s.nx, scan->data.s.ny, ZD_FLOAT);
00757                 gulong sz = scan->mem2d->GetNx () * scan->mem2d->GetNy ();
00758                 gfloat *zbuf = g_new (gfloat, sz);
00759                 gfloat *buf  = g_new (gfloat, sz);
00760                 gulong nb = sz * sizeof (gfloat);
00761                 memset ((void*) zbuf, 0, nb);
00762                 memset ((void*) buf, 0, nb);
00763 
00764                 // compute gzdata length from file length - headersize
00765                 f.seekg (0, ios::end);
00766                 gulong znb = (gulong) ((long)(f.tellg ()) - 0x4000);
00767 
00768                 // start of gzdata
00769                 f.seekg (0x4000, ios::beg);
00770                 f.read ((char*) zbuf, nb);
00771                 g_print ("GME32Z-Import: deflating Z data [%d] : zuffer-size:%d data-size:%d ratio:%g\%\n", 
00772                          uncompress ((Bytef *) buf, &nb, (Bytef *) zbuf, znb),
00773                          znb, nb, znb/nb*100.);
00774                 g_free (zbuf);
00775 
00776                 // convert to ZD_LONG
00777                 for (gint line = 0; line < scan->mem2d->GetNy (); ++line)
00778                         for (gint col = 0; col < scan->mem2d->GetNx (); ++col)
00779                                 scan->mem2d->PutDataPkt ((double) buf[col + line*scan->mem2d->GetNx ()], 
00780                                                          col, line);
00781                 g_free (buf);
00782         }
00783                 break;
00784         default:
00785                 break; // error!!
00786         }
00787 
00788         scan->data.orgmode = SCAN_ORG_MIDDLETOP;
00789         scan->mem2d->data->MkXLookup (-scan->data.s.rx/2., scan->data.s.rx/2.);
00790         scan->mem2d->data->MkYLookup (0., scan->data.s.ry);
00791 
00792         f.close ();
00793   
00794         // GME Dat read done.
00795         return FIO_OK; 
00796 }
00797 
00798 
00799 FIO_STATUS gmeyer_ImExportFile::Write(){
00800         gchar tmp[0x4004];
00801         const gchar *fname;
00802         ofstream f;
00803 
00804         memset (tmp, 0, sizeof (tmp));
00805 
00806         if(strlen(name)>0)
00807                 fname = (const char*)name;
00808         else
00809                 fname = gapp->file_dialog("File Export: GME-Dat"," ","*.dat","","GME-Dat write");
00810         if (fname == NULL) return FIO_NO_NAME;
00811 
00812         // check if we like to handle this
00813         if (strncmp(fname+strlen(fname)-4,".dat",4))
00814                 return FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00815 
00816 
00817         f.open(name, ios::out);
00818         if (!f.good())
00819                 return status=FIO_OPEN_ERR;
00820 
00821         f.write (tmp, 0x4004); // fill up with NULL
00822         f.seekp (0, ios::beg);
00823 
00824         // need to write scan size?
00825         // nx = scan->mem2d->GetNx(), ny = scan->mem2d->GetNy()
00826 
00827         // need some data like X scan range?
00828         // scan->data.s.rx, .ry
00829         // scan->data.s.dx, .dy, .dz
00830         // scan->data.s.x0, .y0
00831         // scan->data.s.alpha, ... see Gxsm/src/xsmtypes.h for a complete structure listing!
00832 
00833         f << "[Parameter]\r\n"
00834           << "Titel / Titel=DEFAULT\r\n"
00835           << "Delta X / Delta X [Dac]=" << scan->data.s.dx << "\r\n"
00836           << "Delta Y / Delta Y [Dac]=" << scan->data.s.dy << "\r\n"
00837           << "Num.X / Num.X=" << scan->mem2d->GetNx() << "\r\n"
00838           << "Num.Y / Num.Y=" << scan->mem2d->GetNy() << "\r\n";
00839 
00840         // Note: X- is only MV_nRegel if no retrace scan is done!
00841         f << "Delay X+ / Delay X+=" << 1 << "\r\n"
00842           << "Delay X- / Delay X-=" << 1 << "\r\n"
00843           << "Delay Y / Delay Y=" << 1 << "\r\n"
00844           << "D-DeltaX / D-DeltaX=" << 1 << "\r\n";
00845 
00846         /*
00847         f << "GainX / GainX=10\r\n"
00848           << "GainY / GainY=10\r\n"
00849           << "GainZ / GainZ=10\r\n";
00850         */
00851 
00852         f << "Rotation / Rotation=" << scan->data.s.alpha << "\r\n";
00853 
00854         f << "BiasVoltage / BiasVolt.[mV]=" << (int)(scan->data.s.Bias*1000) << "\r\n"
00855        // << "Gainpreamp / GainPre 10^=8\r\n"
00856           << "Chan(1,2,4) / Chan(1,2,4)=1\r\n"
00857           << "PlanDx / PlanDx=0.0000\r\n"
00858           << "PlanDy / PlanDy=0.0000\r\n";
00859 
00860         // Note: This is in [Ang]
00861         f << "Scanrotoffx / OffsetX=" << scan->data.s.x0 << "\r\n"
00862           << "Scanrotoffy / OffsetY=" << scan->data.s.y0 << "\r\n";
00863 
00864         /*
00865         f << "MVolt_1 / MVolt_1=-20000\r\n"
00866           << "MVolt_2 / MVolt_2=-20000\r\n"
00867           << "MVolt_3 / MVolt_3=0\r\n"
00868           << "MVolt_4 / MVolt_4=0\r\n"
00869           << "MVolt_5 / MVolt_5=0\r\n"
00870           << "MVolt_6 / MVolt_6=0\r\n"
00871           << "RepeatRotinc / RepeatRotinc=0\r\n"
00872           << "RptBVoltinc / RptBVoltinc=0\r\n"
00873           << "Repeatinterval / Repeatinterval=0\r\n"
00874           << "Repeatcounter / Repeatcounter=0\r\n"
00875           << "RepeatXoffset / RepeatXoffset=0\r\n"
00876           << "RepeatYoffset / RepeatYoffset=0\r\n"
00877           << "Scantype / Scantype=1\r\n"
00878           << "Scanmode / Scanmode=1\r\n"
00879           << "Scancoarse / Scancoarse=1\r\n";
00880         */
00881 
00882         f << "CHMode / CHMode=0\r\n";
00883         f << "Channels / Channels=1\r\n";
00884 
00885         /*
00886         f << "Preamptype / Preamptype=4\r\n"
00887           << "Latmanmode=0\r\n"
00888           << "LatmResist=1.000E+11\r\n"
00889           << "LatmanVolt=1000\r\n"
00890           << "Latmanlgi=1\r\n"
00891           << "Latmangain=8\r\n"
00892           << "Latmanddx=1\r\n"
00893           << "Latmandelay=100\r\n"
00894           << "Latm0Delay=2\r\n"
00895           << "Latmanccdz=0\r\n"
00896           << "Latmanextension=1.000\r\n"
00897           << "TipForm_Volt=0\r\n"
00898           << "TipForm_Z=0\r\n"
00899           << "Tip_Delay=100\r\n"
00900           << "Tip_Latddx=1\r\n"
00901           << "Tip_LatDelay=100\r\n"
00902           << "Vertmangain=8\r\n"
00903           << "Vertmandelay=10\r\n"
00904           << "Vpoint0.t=0\r\n"
00905           << "Vpoint1.t=400\r\n"
00906           << "Vpoint2.t=600\r\n"
00907           << "Vpoint3.t=1024\r\n"
00908           << "Vpoint0.V=0\r\n"
00909           << "Vpoint1.V=-1000\r\n"
00910           << "Vpoint2.V=-1000\r\n"
00911           << "Vpoint3.V=0\r\n"
00912           << "Zpoint0.t=0\r\n"
00913           << "Zpoint1.t=400\r\n"
00914           << "Zpoint2.t=600\r\n"
00915           << "Zpoint3.t=1024\r\n"
00916           << "Zpoint0.z=0\r\n"
00917           << "Zpoint1.z=-100\r\n"
00918           << "Zpoint2.z=-100\r\n"
00919           << "Zpoint3.z=0\r\n";
00920         */
00921 
00922         /*
00923         f << "Zoffset=0\r\n"
00924           << "Zdrift=0\r\n"
00925           << "VertSpecBack=0\r\n"
00926           << "VertSpecAvrgnr=1\r\n"
00927           << "VertRepeatCounter=1\r\n"
00928           << "Imageframe=1\r\n"
00929           << "Imagegrayfactor=0.999\r\n"
00930           << "Zoom=2\r\n"
00931           << "OrgPlanX=0.00000\r\n"
00932           << "OrgPlanY=0.00000\r\n"
00933           << "OrgPlanOff=0.00000\r\n";
00934         */
00935 
00936         /*
00937         f << "Dacto[A]xy=0.03052\r\n"
00938           << "Dacto[A]z=0.00610\r\n";
00939         */
00940 
00941         /*
00942         f << "Planoff=0\r\n"
00943           << "Planx=0\r\n"
00944           << "Plany=0\r\n"
00945           << "Plany2=0\r\n"
00946           << "Planavrgnr=17\r\n"
00947           << "Planoffset2=0\r\n"
00948           << "Plano2start=0\r\n"
00949           << "Imagebackoffset=0\r\n"
00950           << "Frameimageoffset=1000\r\n"
00951           << "YLineOFF=1\r\n"
00952           << "YLineFAC=10\r\n"
00953           << "DigZoomX=1.00000\r\n"
00954           << "DigZoomZ=1.00000\r\n";
00955         */
00956 
00957         /*
00958         f << "FBLogIset= 500.100\r\n"
00959           << "FBRC=  0.000200\r\n"
00960           << "FBLingain=-60000.0\r\n"
00961           << "FBVoltRC=  0.000526\r\n"
00962           << "FBVoltGain=    6.0\r\n"
00963           << "CurrentRC= 0.010\r\n"
00964           << "FBLog=1\r\n"
00965           << "Imaxcurrent=100000.0\r\n"
00966           << "Imaxdelay=   1000\r\n"
00967           << "ImaxZret=  0.000\r\n"
00968           << "SpecAvrgnr=1\r\n"
00969           << "SpecFreq=10000.000\r\n"
00970           << "SpecChan=1\r\n"
00971           << "FFTPoints=1024\r\n"
00972           << "LockinFreq=50\r\n"
00973           << "LockinAmpl=200\r\n"
00974           << "LockinPhase=0\r\n"
00975           << "LockinPhase2=0\r\n"
00976           << "LockinRC= 0.00010\r\n"
00977           << "LockinMode=1\r\n"
00978           << "DSP_Clock=50000\r\n"
00979           << "SRS_Frequency=1000.000\r\n"
00980           << "SRS_ModVoltage=  1.0000\r\n"
00981           << "SRS_InpGain[V]=1.0E+00\r\n"
00982           << "SRS_InpTimeC[s]=1.0E+00\r\n"
00983           << "UserPreampCode=5:000000/6:000000/7:000000/8:000000/\r\n"
00984           << "Upinc=50\r\n"
00985           << "Upcount=200\r\n"
00986           << "Downinc=50\r\n"
00987           << "Downcount=200\r\n"
00988           << "Rotinc=50\r\n"
00989           << "Rotincquad=0\r\n"
00990           << "Rotcount=200\r\n"
00991           << "XYBurst=100\r\n"
00992           << "RotBurst=100\r\n"
00993           << "Aprologiset=  2.000\r\n"
00994           << "Aprolimit=10000\r\n"
00995           << "Aprodelay=300\r\n"
00996           << "Aprorc= 0.00020\r\n"
00997           << "Autolevel=1\r\n"
00998           << "RPTcount=0\r\n"
00999           << "RPTIncVolt=0\r\n"
01000           << "RPTIncdz=0\r\n"
01001           << "SDOrg%=1\r\n"
01002           << "SdStatDiff%=0\r\n"
01003           << "SDOffset=0\r\n"
01004           << "SDBbeta=0\r\n"
01005           << "CorrCheckSize=8\r\n"
01006           << "CorrImageSize=8\r\n"
01007           << "IslandLevel=0.50\r\n"
01008           << "Scall-Number=\r\n"
01009           << "VertSwitchLevel=0\r\n";
01010         */
01011 
01012         /*
01013         f << "ADC_0=11\r\n"
01014           << "ADC_1=-1\r\n"
01015           << "ADC_2=2\r\n"
01016           << "ADC_3=1\r\n"
01017           << "VertMaxI=11000\r\n"
01018           << "VertTreshimin=-20000\r\n"
01019           << "VertTreshimax=20000\r\n"
01020           << "RptCHMZinc=0\r\n"
01021           << "CHModeZoffset=0\r\n"
01022           << "CHModegainpreamp=6\r\n"
01023           << "ScandVinc=0\r\n"
01024           << "ScandIinc=0\r\n"
01025           << "TrackingDx=1\r\n"
01026           << "AltSpecCalc=0\r\n"
01027           << "VStart=-1000\r\n"
01028           << "Vend=1000\r\n"
01029           << "ZStart=0\r\n"
01030           << "ZMid=0\r\n"
01031           << "ZEnd=0\r\n"
01032           << "VoltReso=1\r\n"
01033           << "SpecTime=1000\r\n"
01034           << "MVolt_7=0\r\n"
01035           << "MVolt_8=0\r\n"
01036           << "MVolt_9=0\r\n"
01037           << "MVolt_10=0\r\n"
01038           << "MVolt_11=0\r\n"
01039           << "MVolt_12=0\r\n"
01040           << "MVolt_13=0\r\n"
01041           << "MVolt_14=0\r\n"
01042           << "MVolt_15=0\r\n"
01043           << "MVolt_16=0\r\n"
01044           << "MVolt_17=0\r\n"
01045           << "MVolt_18=0\r\n"
01046           << "MVolt_19=0\r\n"
01047           << "MVolt_20=0\r\n";
01048         */
01049 
01050         /*
01051         f << "VFBVLimit=5000\r\n"
01052           << "Preampoffset=-335\r\n"
01053           << "USBBufferFill=0\r\n"
01054           << "FBAFMSetpoint=-1654\r\n"
01055           << "FBAFMrc=0.0005260\r\n"
01056           << "FBAFMgain=6\r\n"
01057           << "THe[K]= \r\n"
01058           << "TSTM[K]= \r\n"
01059           << "TManip[K]= \r\n"
01060           << "PLoadLock= \r\n"
01061           << "PPraep= \r\n"
01062           << "TSample[C]= \r\n"
01063           << "TEvap[C]= \r\n"
01064           << "= \r\n";
01065         */
01066 
01067         f << "Z-Res. [A]: +/- =" << scan->data.s.rz << "\r\n"
01068           << "Length x[A]=" << scan->data.s.rx << "\r\n"
01069           << "Length y[A]=" << scan->data.s.ry << "\r\n";
01070 
01071         /*
01072         f << "Biasvolt[mV]=-3200\r\n"
01073           << "Current[A]=5.0E-07\r\n";
01074         */
01075 
01076         /*
01077         f << "Sec/line:=7.168\r\n"
01078           << "Sec/Image:=3670.016\r\n"
01079           << "ActGainXYZ=30 30 30\r\n"
01080           << "Channels=1\r\n"
01081           << "T-STM:=0.00000\r\n"
01082           << "= \r\n"
01083           << "HP_Ch1=0.00000\r\n"
01084           << "HP_Ch2=0.00000\r\n"
01085           << "HP_Ch3=0.00000\r\n"
01086           << "HP_Ch4=0.00000\r\n"
01087           << "= \r\n";
01088         */
01089 
01090         /*
01091         f << "ZPiezoconst= 20.00\r\n"
01092           << "Xpiezoconst=100.00\r\n"
01093           << "YPiezoconst=100.00\r\n"
01094           << "= \r\n";
01095         */
01096 
01097         /*
01098         f << "T_ADC2[K]=  0.000\r\n"
01099           << "T_ADC3[K]=  0.000\r\n"
01100           << "= \r\n"
01101           << "= \r\n"
01102           << "= \r\n"
01103           << "= \r\n"
01104           << "= \r\n"
01105           << "= \r\n"
01106           << "= \r\n"
01107           << "= \r\n"
01108           << "= \r\n"
01109           << "= \r\n"
01110           << "= \r\n"
01111           << "= \r\n"
01112           << "= \r\n"
01113           << "= \r\n"
01114           << "= \r\n"
01115           << "= \r\n"
01116           << "= \r\n"
01117           << "= \r\n"
01118           << "= \r\n"
01119           << "= \r\n"
01120           << "= \r\n"
01121           << "= \r\n"
01122           << "= \r\n"
01123           << "= \r\n"
01124           << "= \r\n"
01125           << "= \r\n"
01126           << "= \r\n";
01127         */
01128 
01129         int i=0;
01130 
01131         f << "memo:" << i++ << "=" << "Gxsm Data Export to GME-Dat File from: " << scan->data.ui.name << "\r\n";
01132         f << "memo:" << i++ << "=" << "Originalname: " << scan->data.ui.originalname << "\r\n";
01133         f << "memo:" << i++ << "=" << "User: " << scan->data.ui.user << "\r\n";
01134         f << "memo:" << i++ << "=" << "Host: " << scan->data.ui.host << "\r\n";
01135         f << "memo:" << i++ << "=" << "Title: " << scan->data.ui.title << "\r\n";
01136         f << "memo:" << i++ << "=" << "DateOfScan: " << scan->data.ui.dateofscan << "\r\n";
01137         f << "memo:" << i++ << "=" << "Comment:" << "\r\n";
01138         
01139         gchar **memo = g_strsplit (scan->data.ui.comment, "\n", 64);
01140 
01141         for (int j=0; j<64 && memo[j]; ++j)
01142                 f << "memo:" << i++ << "=" << memo[j] << "\r\n";
01143 
01144         g_strfreev (memo);
01145 
01146         f.seekp (0x3ffa, ios::beg);
01147         f << "\r\nDATA";
01148 
01149         f.seekp (0x4004, ios::beg);
01150         scan->mem2d->DataWrite(f);
01151 
01152   return FIO_OK; 
01153 }
01154 
01155 // Plugin's Notify Cb's, registered to be called on file load/save to check file
01156 // return via filepointer, it is set to Zero or passed as Zero if file has been processed!
01157 // That's all fine, you should just change the Text Stings below...
01158 
01159 
01160 static void gmeyer_im_export_filecheck_load_callback (gpointer data ){
01161         gchar **fn = (gchar**)data;
01162         if (*fn){
01163                 PI_DEBUG (DBG_L2, 
01164                           "Check File: gmeyer_im_export_filecheck_load_callback called with >"
01165                           << *fn << "<" );
01166 
01167                 Scan *dst = gapp->xsm->GetActiveScan();
01168                 if(!dst){ 
01169                         gapp->xsm->ActivateFreeChannel();
01170                         dst = gapp->xsm->GetActiveScan();
01171                 }
01172                 gmeyer_ImExportFile fileobj (dst, *fn);
01173 
01174                 FIO_STATUS ret = fileobj.Read(); 
01175                 if (ret != FIO_OK){ 
01176                         // I'am responsible! (But failed)
01177                         if (ret != FIO_NOT_RESPONSIBLE_FOR_THAT_FILE)
01178                                 *fn=NULL;
01179                         // no more data: remove allocated and unused scan now, force!
01180                         gapp->xsm->SetMode(-1, ID_CH_M_OFF, TRUE); 
01181                         PI_DEBUG (DBG_L2, "Read Error " << ((int)ret) << "!!!!!!!!" );
01182                 }else{
01183                         // got it!
01184                         *fn=NULL;
01185 
01186                         // Now update gxsm main window data fields
01187                         gapp->xsm->ActiveScan->GetDataSet(gapp->xsm->data);
01188                         gapp->spm_update_all();
01189                         dst->draw();
01190                 }
01191         }else{
01192                 PI_DEBUG (DBG_L2, "gmeyer_im_export_filecheck_load: Skipping" );
01193         }
01194 }
01195 
01196 static void gmeyer_im_export_filecheck_save_callback (gpointer data ){
01197         gchar **fn = (gchar**)data;
01198         if (*fn){
01199                 Scan *src;
01200                 PI_DEBUG (DBG_L2,
01201                           "Check File: gmeyer_im_export_filecheck_save_callback called with >"
01202                           << *fn << "<" );
01203 
01204                 gmeyer_ImExportFile fileobj (src = gapp->xsm->GetActiveScan(), *fn);
01205 
01206                 FIO_STATUS ret;
01207                 ret = fileobj.Write(); 
01208 
01209                 if(ret != FIO_OK){
01210                         // I'am responsible! (But failed)
01211                         if (ret != FIO_NOT_RESPONSIBLE_FOR_THAT_FILE)
01212                                 *fn=NULL;
01213                         PI_DEBUG (DBG_L2, "Write Error " << ((int)ret) << "!!!!!!!!" );
01214                 }else{
01215                         // write done!
01216                         *fn=NULL;
01217                 }
01218         }else{
01219                 PI_DEBUG (DBG_L2, "gmeyer_im_export_filecheck_save: Skipping >" << *fn << "<" );
01220         }
01221 }
01222 
01223 // Menu Call Back Fkte
01224 
01225 static void gmeyer_im_export_import_callback(GtkWidget *w, void *data){
01226         gchar **help = g_strsplit (gmeyer_im_export_pi.help, ",", 2);
01227         gchar *dlgid = g_strconcat (gmeyer_im_export_pi.name, "-import", NULL);
01228         gchar *fn = gapp->file_dialog(help[0], NULL, file_mask, NULL, dlgid);
01229         g_strfreev (help); 
01230         g_free (dlgid);
01231         gmeyer_im_export_filecheck_load_callback (&fn );
01232 }
01233 
01234 static void gmeyer_im_export_export_callback(GtkWidget *w, void *data){
01235         gchar **help = g_strsplit (gmeyer_im_export_pi.help, ",", 2);
01236         gchar *dlgid = g_strconcat (gmeyer_im_export_pi.name, "-export", NULL);
01237         gchar *fn = gapp->file_dialog(help[1], NULL, file_mask, NULL, dlgid);
01238         g_strfreev (help); 
01239         g_free (dlgid);
01240         gmeyer_im_export_filecheck_save_callback (&fn );
01241 }

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