00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
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
00305
00306
00307
00308
00309
00310
00311
00312
00313
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
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
00344 GxsmPlugin gmeyer_im_export_pi = {
00345 NULL,
00346 NULL,
00347 0,
00348 NULL,
00349
00350
00351 "Gmeyer_Im_Export",
00352 NULL,
00353
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,
00361 NULL,
00362 gmeyer_im_export_init,
00363 gmeyer_im_export_query,
00364
00365
00366 gmeyer_im_export_about,
00367
00368
00369 gmeyer_im_export_configure,
00370
00371
00372 NULL,
00373
00374
00375 gmeyer_im_export_cleanup
00376 };
00377
00378
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
00386
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
00393
00394
00395
00396
00397
00398
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
00451 g_strfreev (path);
00452 g_strfreev (entry);
00453 g_strfreev (help);
00454
00455
00456
00457
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
00464
00465
00466
00467
00468
00469 static void gmeyer_im_export_init(void)
00470 {
00471 PI_DEBUG (DBG_L2, "gmeyer_im_export Plugin Init");
00472 }
00473
00474
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
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
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
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
00525 FIO_STATUS gmeyer_ImExportFile::Read(){
00526 FIO_STATUS ret;
00527 gchar *fname=NULL;
00528
00529 fname = (gchar*)name;
00530
00531
00532 if (fname == NULL || strlen(fname) < 4)
00533 return FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00534
00535
00536
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
00546
00547
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
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
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;
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
00586 scan->data.s.ntimes = 1;
00587 scan->data.s.nvalues = 1;
00588
00589
00590
00591 if(getlogin()){
00592 scan->data.ui.SetUser (getlogin());
00593 }
00594 else{
00595 scan->data.ui.SetUser ("unkonwn user");
00596 }
00597
00598
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
00611 scan->data.display.cpshigh = 1e3;
00612 scan->data.display.cpslow = 1.;
00613 scan->data.display.cnttime = 1.;
00614
00615
00616 scan->data.display.bright = 32.;
00617 scan->data.display.contrast = 1.0;
00618
00619
00620
00621
00622
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
00638
00639 if (strncmp (line, "DATA", 4) == 0)
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 ;
00653 if (strncmp (line, "Delay X- / Delay X-=", 20) == 0)
00654 ;
00655 if (strncmp (line, "Delay Y / Delay Y=", 18) == 0)
00656 ;
00657 if (strncmp (line, "D-DeltaX / D-DeltaX=", 20) == 0)
00658 ;
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 ;
00669 if (strncmp (line, "Gainpreamp / GainPre 10^=", 29) == 0)
00670 ;
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 ;
00679 if (strncmp (line, "MVolt_2 / MVolt_2=", 18) == 0)
00680 ;
00681 if (strncmp (line, "MVolt_3 / MVolt_3=", 18) == 0)
00682 ;
00683 if (strncmp (line, "MVolt_4 / MVolt_4=", 18) == 0)
00684 ;
00685 if (strncmp (line, "MVolt_5 / MVolt_5=", 18) == 0)
00686 ;
00687 if (strncmp (line, "MVolt_6 / MVolt_6=", 18) == 0)
00688 ;
00689 if (strncmp (line, "CHMode / CHMode=", 16) == 0)
00690 ;
00691 if (strncmp (line, "Channels / Channels=", 20) == 0)
00692 channels = atoi (&line[20]);
00693 if (strncmp (line, "Preamptype / Preamptype=", 24) == 0)
00694 ;
00695
00696 if (strncmp (line, "Z-Res. [A]: +/- =", 17) == 0)
00697 ;
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 ;
00704 if (strncmp (line, "Current[A]=", 11) == 0)
00705 ;
00706 if (strncmp (line, "ActGainXYZ=", 11) == 0)
00707 ;
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
00738 scan->data.s.x0 *= pzAV_x / 32767.*10. * gx ;
00739 scan->data.s.y0 *= pzAV_y / 32767.*10. * gy ;
00740
00741
00742
00743
00744
00745
00746
00747 switch (datamode){
00748 case 16:
00749 scan->data.s.dz = pzAV_z / (1<<15) * 10.* gz;
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;
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
00765 f.seekg (0, ios::end);
00766 gulong znb = (gulong) ((long)(f.tellg ()) - 0x4000);
00767
00768
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
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;
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
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
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);
00822 f.seekp (0, ios::beg);
00823
00824
00825
00826
00827
00828
00829
00830
00831
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
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
00848
00849
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
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
00861 f << "Scanrotoffx / OffsetX=" << scan->data.s.x0 << "\r\n"
00862 << "Scanrotoffy / OffsetY=" << scan->data.s.y0 << "\r\n";
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882 f << "CHMode / CHMode=0\r\n";
00883 f << "Channels / Channels=1\r\n";
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
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
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
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
01156
01157
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
01177 if (ret != FIO_NOT_RESPONSIBLE_FOR_THAT_FILE)
01178 *fn=NULL;
01179
01180 gapp->xsm->SetMode(-1, ID_CH_M_OFF, TRUE);
01181 PI_DEBUG (DBG_L2, "Read Error " << ((int)ret) << "!!!!!!!!" );
01182 }else{
01183
01184 *fn=NULL;
01185
01186
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
01211 if (ret != FIO_NOT_RESPONSIBLE_FOR_THAT_FILE)
01212 *fn=NULL;
01213 PI_DEBUG (DBG_L2, "Write Error " << ((int)ret) << "!!!!!!!!" );
01214 }else{
01215
01216 *fn=NULL;
01217 }
01218 }else{
01219 PI_DEBUG (DBG_L2, "gmeyer_im_export_filecheck_save: Skipping >" << *fn << "<" );
01220 }
01221 }
01222
01223
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 }