extra_scan_info.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: extra_scan_info.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 
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: Query Hardware/DSP software information
00035 % PlugInName: extra_scan_info
00036 % PlugInAuthor: Percy Zahl
00037 % PlugInAuthorEmail: zahl@users.sf.net
00038 % PlugInMenuPath: Tools/Hardware Info
00039 
00040 % PlugInDescription
00041 \label{plugin:extra_scan_info} 
00042 
00043 This plugin looks for a file named \GxsmFile{gxsm\_extra\_scan\_info} in the current
00044 working directory at each file save action. It's content is added to the NetCDF file
00045 as variable named extra\_scan\_info.
00046 
00047 
00048 % PlugInUsage
00049 Works automatic if loaded.
00050 
00051 % OptPlugInNotes
00052 
00053 % EndPlugInDocuSection
00054  * -------------------------------------------------------------------------------- 
00055  */
00056 
00057 
00058 #include <gtk/gtk.h>
00059 #include "config.h"
00060 #include "gxsm/plugin.h"
00061 #include "include/dsp-pci32/xsm/xsmcmd.h"
00062 
00063 using namespace std;
00064 
00065 
00066 // ========================================
00067 // Gxsm PlugIn Setup Part
00068 // ========================================
00069 
00070 static void extra_scan_info_init( void );
00071 static void extra_scan_info_query( void );
00072 static void extra_scan_info_cleanup( void );
00073 static void extra_scan_info_configure( void );
00074 static void extra_scan_info_about( void );
00075 static void extra_scan_info_run(GtkWidget *w, void *data);
00076 
00077 static void extra_scan_info_SaveValues_callback ( gpointer );
00078 static void extra_scan_info_LoadValues_callback ( gpointer );
00079 
00080                                                                                                                              
00081 GxsmPlugin extra_scan_info_pi = {
00082         NULL,
00083         NULL,
00084         0,
00085         NULL,
00086         "extra_scan_info",
00087         NULL,
00088         NULL,
00089         "Percy Zahl",
00090         N_("_Tools/"),
00091         N_("Extra Scan Info"),
00092         N_("Show, save and load extra scan informations"),
00093         "no more info",
00094         NULL,
00095         NULL,
00096         extra_scan_info_init,
00097         extra_scan_info_query,
00098         extra_scan_info_about,
00099         extra_scan_info_configure,
00100         extra_scan_info_run,
00101         extra_scan_info_cleanup
00102 };
00103 
00104 GxsmPlugin *get_gxsm_plugin_info ( void ){ 
00105         extra_scan_info_pi.description = g_strdup_printf(N_("extra_scan_info Plugin %s"), VERSION);
00106         return &extra_scan_info_pi; 
00107 }
00108 
00109 static void extra_scan_info_init(void){
00110         XsmRescourceManager xrm("extra_scan_info");
00111 //      ptr=xrm.Get ("info_0", "---");
00112         xrm.Put ("info_0", "extra scan info null");
00113 }
00114 
00115 static void extra_scan_info_query(void){
00116         PI_DEBUG (DBG_L4, "Extra Scan Info::Query, connecting callbacks\n");
00117         extra_scan_info_pi.app->ConnectPluginToCDFSaveEvent (extra_scan_info_SaveValues_callback);
00118         extra_scan_info_pi.app->ConnectPluginToCDFLoadEvent (extra_scan_info_LoadValues_callback);
00119 
00120         if (extra_scan_info_pi.status) 
00121                 g_free (extra_scan_info_pi.status);
00122 
00123         extra_scan_info_pi.status = g_strdup ("query::command=install_menus");
00124 }
00125 
00126 static void extra_scan_info_configure(void){
00127 }
00128 
00129 static void extra_scan_info_about(void){
00130         const gchar *authors[] = { "Percy Zahl", NULL};
00131         gtk_widget_show (
00132                 gnome_about_new ( extra_scan_info_pi.name,
00133                                   VERSION,
00134                                   N_("(C) 2000 the Free Software Foundation"),
00135                                   "This PlugIn does show, load and save handling of "
00136                                   "extra scan informations.",
00137                                   authors,
00138                                   NULL, NULL, NULL
00139                         ));
00140 }
00141 
00142 static void extra_scan_info_run(GtkWidget *w, void *data){
00143         PI_DEBUG (DBG_L4, "Extra Scan Info::ShowValues (run) callback\n");
00144         GString *gs_info=NULL;
00145         ifstream f_info;
00146         f_info.open("gxsm_extra_scan_info", ios::in);
00147         
00148         if(!f_info.good())
00149                 gs_info = g_string_new ("Extra Scan Info: N/A");
00150         else
00151                 gs_info = g_string_new ("Extra Scan Info: OK\n");
00152 
00153         while(f_info.good()){
00154                 gchar line[0x4000];
00155                 f_info.getline (line, 0x4000);
00156 
00157                 // append to comment
00158                 g_string_append (gs_info, line);
00159                 g_string_append (gs_info, "\n");
00160         }
00161 
00162         f_info.close ();
00163         PI_DEBUG (DBG_L4, gs_info->str);
00164 
00165         gapp->message (gs_info->str);
00166 
00167         g_string_free(gs_info, TRUE);
00168 }
00169 
00170 static void extra_scan_info_cleanup( void ){
00171 }
00172 
00173 static void extra_scan_info_SaveValues_callback ( gpointer gp_ncf ){
00174         GString *gs_info=NULL;
00175         NcFile *ncf = (NcFile *) gp_ncf;
00176         PI_DEBUG (DBG_L4, "Extra Scan Info::SaveValues_callback\n");
00177         ifstream f_info;
00178         f_info.open("gxsm_extra_scan_info", ios::in);
00179         
00180         if(!f_info.good())
00181                 gs_info = g_string_new ("Extra Scan Info: N/A");
00182         else
00183                 gs_info = g_string_new ("Extra Scan Info: OK\n");
00184 
00185         while(f_info.good()){
00186                 gchar line[0x4000];
00187                 f_info.getline (line, 0x4000);
00188 
00189                 // append to comment
00190                 g_string_append (gs_info, line);
00191                 g_string_append (gs_info, "\n");
00192         }
00193 
00194         f_info.close ();
00195 
00196         NcDim* infod  = ncf->add_dim("extra_scan_info_dim", strlen(gs_info->str));
00197         NcVar* info   = ncf->add_var("extra_scan_info", ncChar, infod);
00198         info->add_att("long_name", "extra scan information");
00199         info->put(gs_info->str, strlen(gs_info->str));
00200         g_string_free(gs_info, TRUE);
00201 }
00202 
00203  #define NC_GET_VARIABLE(VNAME, VAR) if(ncf->get_var(VNAME)) ncf->get_var(VNAME)->get(VAR)
00204 
00205 static void extra_scan_info_LoadValues_callback ( gpointer gp_ncf ){
00206         NcFile *ncf = (NcFile *) gp_ncf;
00207         PI_DEBUG (DBG_L4, "Extra Scan Info::LoadValues_callback\n");
00208         //load_values ((NcFile *) ncf);
00209 }

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