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 #include <gtk/gtk.h>
00077 #include <locale.h>
00078
00079 #include "config.h"
00080 #include "gxsm/plugin.h"
00081 #include "gxsm/dataio.h"
00082 #include "gxsm/action_id.h"
00083 #include "gxsm/mem2d.h"
00084 #include "gxsm/unit.h"
00085
00086 #ifndef WORDS_BIGENDIAN
00087 # define WORDS_BIGENDIAN 0
00088 #endif
00089
00090 using namespace std;
00091
00092
00093
00094 static void omicron_io_init (void);
00095 static void omicron_io_query (void);
00096 static void omicron_io_about (void);
00097 static void omicron_io_configure (void);
00098 static void omicron_io_cleanup (void);
00099
00100 static void omicron_io_filecheck_load_callback (gpointer data );
00101 static void omicron_io_filecheck_save_callback (gpointer data );
00102
00103 static void omicron_io_import_callback (GtkWidget *w, void *data);
00104
00105
00106
00107
00108
00109
00110
00111 GxsmPlugin omicron_io_pi = {
00112 NULL,
00113 NULL,
00114 0,
00115 NULL,
00116
00117
00118 "Omicron_IO",
00119 NULL,
00120
00121 "Im/Export of Omicron SPM files.",
00122 "Andreas Klust",
00123 N_("_File/Im,Export"),
00124 N_("..."),
00125 NULL,
00126 "This plug-in is responsible for the im/export of data in the file format used by Omicron's SCALA software.",
00127 NULL,
00128 NULL,
00129 omicron_io_init,
00130 omicron_io_query,
00131
00132
00133 omicron_io_about,
00134
00135
00136 omicron_io_configure,
00137
00138
00139 NULL,
00140
00141
00142 omicron_io_cleanup
00143 };
00144
00145
00146
00147
00148
00149 static const char *about_text = N_("Gxsm data file import/export plugin\n\n"
00150 "This plugin reads Omicron SCALA SPM files."
00151 );
00152
00153
00154
00155
00156
00157
00158
00159 GxsmPlugin *get_gxsm_plugin_info ( void ){
00160 omicron_io_pi.description = g_strdup_printf(N_("Gxsm omicron_io plugin %s"), VERSION);
00161 return &omicron_io_pi;
00162 }
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 static void omicron_io_query(void)
00177 {
00178 static GnomeUIInfo menuinfo_Import[] = {
00179 { GNOME_APP_UI_ITEM,
00180 N_("Omicron SPM Import"), N_("Import of the Omicron SPM format"),
00181 (gpointer) omicron_io_import_callback, NULL,
00182 NULL, GNOME_APP_PIXMAP_STOCK, GNOME_STOCK_MENU_OPEN,
00183 0, GDK_CONTROL_MASK, NULL },
00184 GNOMEUIINFO_END
00185 };
00186
00187 gnome_app_insert_menus (
00188 GNOME_APP(omicron_io_pi.app->getApp()),
00189 N_("_File/Import/"),
00190 menuinfo_Import
00191 );
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 if(omicron_io_pi.status) g_free(omicron_io_pi.status);
00209 omicron_io_pi.status = g_strconcat (
00210 N_("Plugin query has attached "),
00211 omicron_io_pi.name,
00212 N_(": File IO Filters are ready to use"),
00213 NULL);
00214
00215
00216
00217
00218 omicron_io_pi.app->ConnectPluginToLoadFileEvent (omicron_io_filecheck_load_callback);
00219 omicron_io_pi.app->ConnectPluginToSaveFileEvent (omicron_io_filecheck_save_callback);
00220 }
00221
00222
00223
00224
00225
00226
00227 static void omicron_io_init(void)
00228 {
00229 PI_DEBUG (DBG_L2, "omicron_io Plugin Init" );
00230 }
00231
00232
00233
00234
00235
00236
00237
00238 static void omicron_io_about(void)
00239 {
00240 const gchar *authors[] = { omicron_io_pi.authors, NULL};
00241 gtk_widget_show(gnome_about_new ( omicron_io_pi.name,
00242 VERSION,
00243 N_("(C) 2001 the Free Software Foundation"),
00244 about_text,
00245 authors,
00246 NULL, NULL, NULL
00247 ));
00248 }
00249
00250
00251
00252
00253
00254
00255
00256 static void omicron_io_configure(void)
00257 {
00258 if(omicron_io_pi.app)
00259 omicron_io_pi.app->message("omicron_io Plugin Configuration");
00260 }
00261
00262
00263
00264
00265
00266
00267
00268 static void omicron_io_cleanup(void)
00269 {
00270 PI_DEBUG (DBG_L2, "omicron_io Plugin Cleanup" );
00271 gnome_app_remove_menus (GNOME_APP (omicron_io_pi.app->getApp()),
00272 N_("File/Import/Omicron SPM Import"), 1);
00273
00274
00275 }
00276
00277
00278
00279
00280
00281
00282
00283 class Omicron_SPM_ImExportFile : public Dataio{
00284 public:
00285 Omicron_SPM_ImExportFile(Scan *s, const char *n) : Dataio(s,n){ };
00286 virtual FIO_STATUS Read();
00287 virtual FIO_STATUS Write();
00288 private:
00289
00290 FIO_STATUS spmReadDat(const gchar *fname);
00291
00292 FIO_STATUS spmReadGridSpecDat(const gchar *fname);
00293
00294 FIO_STATUS spmReadPar(const gchar *fname, const gchar *fsuffix);
00295
00296 };
00297
00298
00299
00300
00301 FIO_STATUS Omicron_SPM_ImExportFile::Read(){
00302 FIO_STATUS ret = FIO_OK;
00303 gchar *fdatname = (gchar*) name;
00304 gchar *fparname=NULL;
00305 gchar *fbasename=NULL;
00306 gchar *fsuffix=NULL;
00307
00308
00309 if (name == NULL || strlen(name) < 4){
00310 ret = FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00311 return ret;
00312 }
00313
00314
00315
00316 fbasename = g_strndup (name, strlen(name)-4);
00317 fsuffix = g_strdup (name+strlen(name)-4);
00318 fparname = g_strconcat (fbasename, ".par", NULL);
00319
00320
00321
00322
00323 if ( strncmp(fsuffix,".tf", 3) && strncmp(fsuffix,".tb", 3) && \
00324 strncmp(fsuffix,".sf", 3) && strncmp(fsuffix,".sb", 3) )
00325 ret = FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00326 else{
00327
00328
00329 std::ifstream f;
00330 f.open(fdatname, std::ios::in | std::ios::binary);
00331 if(!f.good()){
00332 PI_DEBUG (DBG_L2, "Omicron_SPM_ImExportFile::Read: data file error" );
00333 ret = status = FIO_OPEN_ERR;
00334 }
00335 f.close();
00336 f.open(fparname, std::ios::in);
00337 if(!f.good()){
00338 PI_DEBUG (DBG_L2, "Omicron_SPM_ImExportFile::Read: parameter file error" );
00339 ret = status = FIO_OPEN_ERR;
00340 }
00341 f.close();
00342
00343
00344 PI_DEBUG (DBG_L2, "Omicron_SPM_ImExportFile::Read: " << fdatname <<
00345 " is a Omicron SPM File!" );
00346
00347
00348
00349 if ( ret == FIO_OK )
00350 ret = spmReadPar (fparname, fsuffix);
00351
00352
00353 if ( ret == FIO_OK ) {
00354 if ( scan->data.s.nvalues == 1 )
00355 ret = spmReadDat (fdatname);
00356 else
00357 ret = spmReadGridSpecDat (fdatname);
00358 }
00359 }
00360
00361 g_free (fbasename);
00362 g_free (fparname);
00363 g_free (fsuffix);
00364
00365 scan->mem2d->data->MkYLookup(scan->data.s.y0, scan->data.s.y0+scan->data.s.ry);
00366 scan->mem2d->data->MkXLookup(scan->data.s.x0-scan->data.s.rx/2., scan->data.s.x0+scan->data.s.rx/2.);
00367 scan->mem2d->data->MkVLookup (-10., 10.);
00368
00369 return ret;
00370 }
00371
00372
00373 FIO_STATUS Omicron_SPM_ImExportFile::spmReadDat(const gchar *fname)
00374 {
00375
00376 scan->data.ui.SetName (fname);
00377 scan->data.ui.SetOriginalName (fname);
00378
00379
00380 scan->mem2d->Resize (
00381 scan->data.s.nx,
00382 scan->data.s.ny,
00383 ZD_SHORT
00384 );
00385
00386 PI_DEBUG (DBG_L2, "Omicron_SPM_ImExportFile: Resize done." );
00387
00388
00389
00390 short *buf;
00391 if(!(buf = g_new(short, scan->data.s.nx*scan->data.s.ny)))
00392 return FIO_NO_MEM;
00393
00394
00395 std::ifstream f;
00396 f.open(fname, std::ios::in | std::ios::binary);
00397 if(f.good())
00398 f.read((char*)buf, sizeof(short) * scan->data.s.nx * scan->data.s.ny);
00399 else {
00400 g_free(buf);
00401 return FIO_OPEN_ERR;
00402 }
00403 f.close();
00404
00405
00406 short *pt = buf;
00407 char *cpt, low;
00408 for (int j=0; j < scan->data.s.ny; ++j)
00409 for (int i=0; i < scan->data.s.nx; ++i, ++pt) {
00410
00411 if (!WORDS_BIGENDIAN) {
00412 cpt = (char*)pt;
00413 low = cpt[0];
00414 cpt[0] = cpt[1];
00415 cpt[1] = low;
00416 }
00417
00418
00419 scan->mem2d->PutDataPkt ((double)*pt, i, scan->data.s.ny-j-1);
00420 }
00421
00422 g_free (buf);
00423
00424 PI_DEBUG (DBG_L2, "Omicron_SPM_ImExportFile: Import done." );
00425
00426
00427 return FIO_OK;
00428 }
00429
00430
00431 FIO_STATUS Omicron_SPM_ImExportFile::spmReadGridSpecDat(const gchar *fname)
00432 {
00433
00434 scan->data.ui.SetName (fname);
00435 scan->data.ui.SetOriginalName (fname);
00436
00437
00438 scan->mem2d->Resize (
00439 scan->data.s.nx,
00440 scan->data.s.ny,
00441 scan->data.s.nvalues,
00442 ZD_SHORT
00443 );
00444
00445 PI_DEBUG (DBG_L2, "Omicron_SPM_ImExportFile: Resize done." );
00446
00447
00448 short *buf;
00449 if(!(buf = g_new(short, scan->data.s.nx*scan->data.s.ny)))
00450 return FIO_NO_MEM;
00451
00452
00453
00454 ifstream f;
00455 f.open(fname, ios::in | ios::binary);
00456 for (int v=0; v < scan->data.s.nvalues; ++v) {
00457 if(f.good())
00458 f.read((char*)buf, sizeof(short) * scan->data.s.nx * scan->data.s.ny);
00459 else {
00460 g_free(buf);
00461 return FIO_OPEN_ERR;
00462 }
00463
00464
00465 short *pt = buf;
00466 char *cpt, low;
00467 for (int j=0; j < scan->data.s.ny; ++j)
00468 for (int i=0; i < scan->data.s.nx; ++i, ++pt) {
00469
00470 if (!WORDS_BIGENDIAN) {
00471 cpt = (char*)pt;
00472 low = cpt[0];
00473 cpt[0] = cpt[1];
00474 cpt[1] = low;
00475 }
00476
00477
00478 scan->mem2d->PutDataPkt ((double)*pt, i, scan->data.s.ny-j-1, v);
00479 }
00480
00481 }
00482 f.close();
00483
00484 g_free (buf);
00485
00486 PI_DEBUG (DBG_L2, "Omicron_SPM_ImExportFile: Import done." );
00487
00488
00489 return FIO_OK;
00490 }
00491
00492
00493
00494
00495 FIO_STATUS Omicron_SPM_ImExportFile::spmReadPar(const gchar *fname, const gchar *fsuffix)
00496 {
00497 char valid = FALSE, spectro = FALSE, spectrogrid = FALSE, dualmode = FALSE;
00498 int xspecpoints, yspecpoints;
00499 GString *comment = g_string_new(NULL);
00500
00501
00502 setlocale(LC_NUMERIC, "C");
00503
00504
00505 scan->data.s.ntimes = 1;
00506 scan->data.s.nvalues = 1;
00507
00508
00509 if(getlogin()){
00510 scan->data.ui.SetUser (getlogin());
00511 }
00512 else{
00513 scan->data.ui.SetUser ("unknown user");
00514 }
00515
00516
00517
00518
00519
00520
00521 scan->data.ui.SetType ("Omicron SPM Type: SHT ");
00522
00523
00524
00525
00526
00527
00528
00529
00530 scan->data.s.dx = 1;
00531 scan->data.s.dy = 1;
00532 scan->data.s.dz = 1;
00533 scan->data.s.rx = scan->data.s.nx;
00534 scan->data.s.ry = scan->data.s.ny;
00535 scan->data.s.x0 = 0;
00536 scan->data.s.y0 = 0;
00537 scan->data.s.alpha = 0;
00538
00539
00540 scan->data.display.cpshigh = 1e3;
00541 scan->data.display.cpslow = 1.;
00542 scan->data.display.cnttime = 1.;
00543
00544
00545
00546
00547
00548 std::ifstream f;
00549 f.open(fname, std::ios::in);
00550 if(!f.good())
00551 return FIO_OPEN_ERR;
00552
00553 UnitObj *xu = gapp->xsm->MakeUnit ("nm", "X");
00554 scan->data.SetXUnit(xu);
00555 delete xu;
00556
00557 UnitObj *yu = gapp->xsm->MakeUnit ("nm", "Y");
00558 scan->data.SetYUnit(yu);
00559 delete yu;
00560
00561
00562 gchar linebuf[100];
00563 while (!f.eof()) {
00564
00565 f.getline (linebuf, 100);
00566
00567
00568 if ( !strncmp (linebuf, "Date", 4)) {
00569 gchar scandate[11];
00570 gchar scantime[6];
00571 sscanf (linebuf, "%*[^0-9]%10s %6s", scandate, scantime);
00572 scan->data.ui.SetDateOfScan ( g_strconcat(scandate, " ", scantime, NULL) );
00573 }
00574
00575
00576 if ( !strncmp (linebuf, "User", 4) ) {
00577 char user[80];
00578 sscanf (linebuf, "%*[^:]: %80s", user);
00579 scan->data.ui.SetUser (user);
00580 PI_DEBUG (DBG_L2, " user: " << scan->data.ui.user );
00581 }
00582
00583
00584 if ( !strncmp (linebuf, "Comment", 7) ) {
00585
00586 gchar c[100];
00587 sscanf (linebuf, "%*[^:]: %[^\n]100s", c);
00588 g_string_append(comment, c);
00589
00590 f.getline(linebuf,100);
00591 while (strncmp (linebuf,";",1) != 0) {
00592 sscanf(linebuf,"%*[ ]%[^\n]100s",linebuf);
00593 g_string_append (comment, linebuf);
00594 f.getline(linebuf,100);
00595 }
00596 scan->data.ui.SetComment (comment->str);
00597 g_string_free(comment, TRUE);
00598 PI_DEBUG (DBG_L2, " comment: " << scan->data.ui.comment );
00599 }
00600
00601
00602 if ( !strncmp (linebuf, "Field X Size in nm", 18) ) {
00603 double rx;
00604 sscanf (linebuf, "%*[^0-9]%lf", &rx);
00605 scan->data.s.rx = rx * 10;
00606 PI_DEBUG (DBG_L2, " rx = " << scan->data.s.rx );
00607 }
00608
00609
00610 if ( !strncmp (linebuf, "Field Y Size in nm", 18) ) {
00611 double ry;
00612 sscanf (linebuf, "%*[^0-9]%lf", &ry);
00613 scan->data.s.ry = ry * 10;
00614 PI_DEBUG (DBG_L2, " ry = " << scan->data.s.ry );
00615 }
00616
00617
00618 if ( !strncmp (linebuf, "Image Size in X", 15) ) {
00619 int nx;
00620 sscanf (linebuf, "%*[^0-9]%d", &nx);
00621 scan->data.s.nx = nx;
00622 PI_DEBUG (DBG_L2, " nx = " << scan->data.s.nx );
00623 }
00624
00625
00626 if ( !strncmp (linebuf, "Image Size in Y", 15) ) {
00627 int ny;
00628 sscanf (linebuf, "%*[^0-9]%d", &ny);
00629 scan->data.s.ny = ny;
00630 PI_DEBUG (DBG_L2, " ny = " << scan->data.s.ny );
00631 }
00632
00633
00634 if ( !strncmp (linebuf, "Increment X", 11) ) {
00635 double dx;
00636 sscanf (linebuf, "%*[^0-9]%lf", &dx);
00637 scan->data.s.dx = dx * 10;
00638 PI_DEBUG (DBG_L2, " dx = " << scan->data.s.dx );
00639 }
00640
00641
00642 if ( !strncmp (linebuf, "Increment Y", 11) ) {
00643 double dy;
00644 sscanf (linebuf, "%*[^0-9]%lf", &dy);
00645 scan->data.s.dy = dy * 10;
00646 PI_DEBUG (DBG_L2, " dy = " << scan->data.s.dy );
00647 }
00648
00649
00650 if ( !strncmp (linebuf, "Scan Angle", 10) ) {
00651 double alf;
00652 sscanf (linebuf, "%*[^0-9-]%lf", &alf);
00653 scan->data.s.alpha = alf;
00654 PI_DEBUG (DBG_L2, " alpha = " << scan->data.s.alpha );
00655 }
00656
00657
00658 if ( !strncmp (linebuf, "X Offset", 8) ) {
00659 double x0;
00660 sscanf (linebuf, "%*[^0-9-]%lf", &x0);
00661 scan->data.s.x0 = x0 * 10;
00662 PI_DEBUG (DBG_L2, " x0 = " << scan->data.s.x0 );
00663 }
00664
00665
00666 if ( !strncmp (linebuf, "Y Offset", 8) ) {
00667 double y0;
00668 sscanf (linebuf, "%*[^0-9-]%lf", &y0);
00669 scan->data.s.y0 = y0 * 10;
00670 PI_DEBUG (DBG_L2, " y0 = " << scan->data.s.y0 );
00671 }
00672
00673
00674
00675 if ( !strncmp (linebuf, "Topographic Channel", 19) ) {
00676 double dz;
00677 double lrz, urz;
00678 char fn[100], zunit[3], zlabel[2];
00679 gchar scantype[20], datatype[5];
00680 gchar *fs;
00681
00682 f.getline (linebuf, 100);
00683 sscanf(linebuf, "%*[ ]%8s",scantype);
00684 f.getline (linebuf, 100);
00685 f.getline (linebuf, 100);
00686
00687 f.getline (linebuf, 100);
00688 sscanf (linebuf, " %lf", &lrz);
00689 f.getline (linebuf, 100);
00690 sscanf (linebuf, " %lf", &urz);
00691 f.getline (linebuf, 100);
00692 sscanf (linebuf, " %lf", &dz);
00693 f.getline (linebuf, 100);
00694 sscanf (linebuf, "%*[ ]%2s", zunit);
00695 f.getline (linebuf, 100);
00696 sscanf (linebuf, " %100s", fn);
00697 f.getline (linebuf, 100);
00698 sscanf (linebuf, "%*[ ]%5s", datatype);
00699
00700
00701 fs = g_strdup (fn+strlen(fn)-4);
00702 if (!strcmp(fs,fsuffix)) {
00703 valid = TRUE;
00704 scan->data.ui.SetType(g_strconcat(scantype, " ", datatype));
00705
00706 if (strcmp(zunit,"nm") == 0) {
00707 scan->data.s.rz = (abs(lrz) + abs(urz))*10;
00708 scan->data.s.dz = dz*10;
00709 strcpy(zunit, "AA");
00710 strcpy(zlabel, "Z");
00711 }
00712 else {
00713 scan->data.s.rz = (abs(lrz) + abs(urz));
00714 scan->data.s.dz = dz;
00715 strcpy(zlabel, "I");
00716 }
00717
00718 PI_DEBUG (DBG_L2, " z unit: " << zunit );
00719 UnitObj *zu = gapp->xsm->MakeUnit (zunit, zlabel);
00720 scan->data.SetZUnit(zu);
00721 delete zu;
00722 }
00723 }
00724
00725
00726
00727 if ( !strncmp (linebuf, "Spectroscopy Channel", 20) ) {
00728 double ds;
00729 char fn[100], zunit[6], vunit[6];
00730 gchar *fs;
00731 int nv;
00732
00733 f.getline (linebuf, 100);
00734 f.getline (linebuf, 100);
00735 f.getline (linebuf, 100);
00736 f.getline (linebuf, 100);
00737 f.getline (linebuf, 100);
00738 f.getline (linebuf, 100);
00739 f.getline (linebuf, 100);
00740 sscanf (linebuf, " %lf", &ds);
00741 f.getline (linebuf, 100);
00742 sscanf (linebuf, " %5s", zunit);
00743 f.getline (linebuf, 100);
00744 sscanf (linebuf, "%*[^0-9]%d", &nv);
00745 f.getline (linebuf, 100);
00746 f.getline (linebuf, 100);
00747 f.getline (linebuf, 100);
00748 f.getline (linebuf, 100);
00749 f.getline (linebuf, 100);
00750 f.getline (linebuf, 100);
00751 f.getline (linebuf, 100);
00752 sscanf (linebuf, " %100s", fn);
00753 f.getline (linebuf, 100);
00754
00755
00756 fs = g_strdup (fn+strlen(fn)-4);
00757 if (!strcmp(fs,fsuffix)) {
00758 valid = TRUE;
00759 spectro = TRUE;
00760
00761 scan->data.s.nvalues = nv;
00762
00763 PI_DEBUG (DBG_L2, " zunit: " << zunit );
00764 UnitObj *zu = gapp->xsm->MakeUnit (zunit, "I");
00765 scan->data.SetZUnit(zu);
00766 scan->data.s.dz = zu->Usr2Base(ds);
00767 delete zu;
00768 }
00769 }
00770
00771
00772 if ( !strncmp (linebuf, "Spectroscopy Points in X", 24) ) {
00773 sscanf (linebuf, "%*[^0-9]%d", &xspecpoints);
00774 PI_DEBUG (DBG_L2, " xspecpoints: " << xspecpoints );
00775 }
00776
00777
00778 if ( !strncmp (linebuf, "Spectroscopy Lines in Y", 23) ) {
00779 sscanf (linebuf, "%*[^0-9]%d", &yspecpoints);
00780 PI_DEBUG (DBG_L2, " yspecpoints: " << yspecpoints );
00781 }
00782
00783
00784 if ( !strncmp (linebuf, "Dual mode", 9) ) {
00785 char buf[4];
00786 sscanf (linebuf, "%*[^:]: %3s", buf);
00787 if ( !strncmp (buf, "On", 2) ) dualmode = TRUE;
00788 }
00789
00790
00791 if ( !strncmp (linebuf, "Gap Voltage", 11) ) {
00792 double ugap;
00793 if (!dualmode || fsuffix[2] == 'f')
00794 sscanf (linebuf, "%*[^0-9-]%lf", &ugap);
00795 else {
00796 f.getline (linebuf, 100);
00797 sscanf (linebuf, "%*[^0-9-]%lf", &ugap);
00798 }
00799 scan->data.s.Bias = ugap;
00800 PI_DEBUG (DBG_L2, " ugap = " << scan->data.s.Bias );
00801 }
00802
00803
00804
00805 if ( !strncmp (linebuf, "Feedback Set", 12) ) {
00806 double iset;
00807
00808 sscanf (linebuf, "%*[^0-9-]%lf", &iset);
00809 scan->data.s.Current = iset;
00810
00811
00812
00813
00814
00815
00816
00817 PI_DEBUG (DBG_L2, " iset = " << scan->data.s.Current );
00818 }
00819
00820 }
00821
00822 f.close();
00823
00824
00825
00826 if (spectro && xspecpoints > 0 && yspecpoints > 0 && \
00827 scan->data.s.nvalues > 1) {
00828 spectrogrid = TRUE;
00829 scan->data.s.nx = xspecpoints;
00830 scan->data.s.ny = yspecpoints;
00831 scan->data.s.dx = scan->data.s.rx / scan->data.s.nx;
00832 scan->data.s.dy = scan->data.s.ry / scan->data.s.ny;
00833 }
00834
00835
00836 if (!valid) return FIO_INVALID_FILE;
00837
00838 if (spectro && !spectrogrid) return FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00839
00840 return FIO_OK;
00841 }
00842
00843
00844
00845 FIO_STATUS Omicron_SPM_ImExportFile::Write()
00846 {
00847
00848
00849 return FIO_NOT_RESPONSIBLE_FOR_THAT_FILE;
00850 }
00851
00852
00853
00854
00855
00856
00857 static void omicron_io_filecheck_load_callback (gpointer data){
00858 gchar **fn = (gchar**)data;
00859 if (*fn){
00860 PI_DEBUG (DBG_L2, "Check File: omicron_io_filecheck_load_callback called with >"
00861 << *fn << "<" );
00862
00863 Scan *dst = gapp->xsm->GetActiveScan();
00864 if(!dst){
00865 gapp->xsm->ActivateFreeChannel();
00866 dst = gapp->xsm->GetActiveScan();
00867 }
00868 Omicron_SPM_ImExportFile fileobj (dst, *fn);
00869
00870 FIO_STATUS ret = fileobj.Read();
00871 if (ret != FIO_OK){
00872
00873 if (ret != FIO_NOT_RESPONSIBLE_FOR_THAT_FILE){
00874 *fn=NULL;
00875 PI_DEBUG (DBG_L2, "Read Error " << ((int)ret) << "!!!!!!!!" );
00876 }else{
00877 PI_DEBUG (DBG_L2, "No Omicron Scala File!" );
00878 }
00879
00880 gapp->xsm->SetMode(-1, ID_CH_M_OFF, TRUE);
00881 }else{
00882
00883 *fn=NULL;
00884
00885
00886 gapp->xsm->ActiveScan->GetDataSet(gapp->xsm->data);
00887 gapp->xsm->AutoDisplay ();
00888 gapp->spm_update_all();
00889 dst->draw();
00890 }
00891 }else{
00892 PI_DEBUG (DBG_L2, "omicron_io_filecheck_load: Skipping" );
00893 }
00894 }
00895
00896
00897
00898 static void omicron_io_filecheck_save_callback ( gpointer data ){
00899 gchar **fn = (gchar**)data;
00900 if (*fn){
00901 Scan *src;
00902 PI_DEBUG (DBG_L2, "Check File: omicron_io_filecheck_save_callback called with >"
00903 << *fn << "<" );
00904
00905 Omicron_SPM_ImExportFile fileobj (src = gapp->xsm->GetActiveScan(), *fn);
00906
00907 FIO_STATUS ret;
00908 ret = fileobj.Write();
00909
00910 if(ret != FIO_OK){
00911
00912 if (ret != FIO_NOT_RESPONSIBLE_FOR_THAT_FILE)
00913 *fn=NULL;
00914 PI_DEBUG (DBG_L2, "Write Error " << ((int)ret) << "!!!!!!!!" );
00915 }else{
00916
00917 *fn=NULL;
00918 }
00919 }else{
00920 PI_DEBUG (DBG_L2, "omicron_io_filecheck_save: Skipping >" << *fn << "<" );
00921 }
00922 }
00923
00924
00925
00926
00927 static void omicron_io_import_callback(GtkWidget *w, void *data)
00928 {
00929 gchar *fn = gapp->file_dialog("Omicron SPM Import", NULL,
00930 "*.*",
00931 NULL, "SPM-Import");
00932
00933 PI_DEBUG (DBG_L2, "FLDLG-IM::" << fn );
00934 omicron_io_filecheck_load_callback (&fn );
00935 }
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947