uto_float.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  * plugin_helper reports your answers as
00006 author          =Percy Zahl
00007 email                   =zahl@users.sf.net
00008 pluginname              =uto_float
00009 pluginmenuentry         =uto float
00010 menupath                =Math/Convert/
00011 entryplace              =Convert
00012 shortentryplace =CV
00013 abouttext               =Convert U to float
00014 smallhelp               =convert U to float
00015 longhelp                =Converts a scan to type float by fixing signed unsigned short import.
00016  * 
00017  * Gxsm Plugin Name: uto_float.C
00018  * ========================================
00019  * 
00020  * Copyright (C) 1999 The Free Software Foundation
00021  *
00022  * Authors: Percy Zahl <zahl@fkp.uni-hannover.de>
00023  * additional features: Andreas Klust <klust@fkp.uni-hannover.de>
00024  *
00025  * This program is free software; you can redistribute it and/or modify
00026  * it under the terms of the GNU General Public License as published by
00027  * the Free Software Foundation; either version 2 of the License, or
00028  * (at your option) any later version.
00029  *
00030  * This program is distributed in the hope that it will be useful,
00031  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00032  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00033  * GNU General Public License for more details.
00034  *
00035  * You should have received a copy of the GNU General Public License
00036  * along with this program; if not, write to the Free Software
00037  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00038  */
00039 
00040 
00041 /* Please do not change the Begin/End lines of this comment section!
00042  * this is a LaTeX style section used for auto generation of the PlugIn Manual 
00043  * Chapter. Add a complete PlugIn documentation inbetween the Begin/End marks!
00044  * All "% PlugInXXX" commentary tags are mandatory
00045  * All "% OptPlugInXXX" tags are optional and can be removed or commented in
00046  * --------------------------------------------------------------------------------
00047 % BeginPlugInDocuSection
00048 % PlugInDocuCaption: Convert to float
00049 % PlugInName: uto_float
00050 % PlugInAuthor: Percy Zahl
00051 % PlugInAuthorEmail: zahl@users.sf.net
00052 % PlugInMenuPath: Math/Convert/to float
00053 
00054 % PlugInDescription
00055 Convert scan data type to float. While converting a unsigned short in signed short type is expected and corrected.
00056 This is a hack for fixing imported data.
00057 
00058 The transformation used, applied to all data in H:
00059 
00060 \[if Z < 0 then Z' = Z + 2^16 else Z' = Z\]
00061 
00062 
00063 % PlugInUsage
00064 Call \GxsmMenu{Math/Convert/U to float}.
00065 
00066 % OptPlugInSources
00067 The active channel is used as data source.
00068 
00069 % OptPlugInDest
00070 The conversion result is placed into an existing math channel, else
00071 into a new created math channel.
00072 
00073 % EndPlugInDocuSection
00074  * -------------------------------------------------------------------------------- 
00075  */
00076 
00077 #include <gtk/gtk.h>
00078 #include "config.h"
00079 #include "gxsm/plugin.h"
00080 
00081 // Plugin Prototypes
00082 static void uto_float_init( void );
00083 static void uto_float_about( void );
00084 static void uto_float_configure( void );
00085 static void uto_float_cleanup( void );
00086 
00087 // Define Type of math plugin here, only one line should be commented in!!
00088 #define GXSM_ONE_SRC_PLUGIN__DEF
00089 // #define GXSM_TWO_SRC_PLUGIN__DEF
00090 
00091 // Math-Run-Function, use only one of (automatically done :=)
00092 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00093 // "OneSrc" Prototype
00094  static gboolean uto_float_run( Scan *Src, Scan *Dest );
00095 #else
00096 // "TwoSrc" Prototype
00097  static gboolean uto_float_run( Scan *Src1, Scan *Src2, Scan *Dest );
00098 #endif
00099 
00100 // Fill in the GxsmPlugin Description here
00101 GxsmPlugin uto_float_pi = {
00102   NULL,                   // filled in and used by Gxsm, don't touch !
00103   NULL,                   // filled in and used by Gxsm, don't touch !
00104   0,                      // filled in and used by Gxsm, don't touch !
00105   NULL,                   // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 
00106                           // filled in here by Gxsm on Plugin load, 
00107                           // just after init() is called !!!
00108   // ----------------------------------------------------------------------
00109   // Plugins Name, CodeStly is like: Name-M1S|M2S-BG|F1D|F2D|ST|TR|Misc
00110   "uto_float-"
00111 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00112   "M1S"
00113 #else
00114   "M2S"
00115 #endif
00116   "-CV",
00117   // Plugin's Category - used to autodecide on Pluginloading or ignoring
00118   // NULL: load, else
00119   // example: "+noHARD +STM +AFM"
00120   // load only, if "+noHARD: no hardware" and Instrument is STM or AFM
00121   // +/-xxxHARD und (+/-INST or ...)
00122   NULL,
00123   // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details)
00124   "Converts a scan to type float.",                   
00125   // Author(s)
00126   "Percy Zahl",
00127   // Menupath to position where it is appendet to
00128   N_("_Math/_Convert/"),
00129   // Menuentry
00130   N_("U to float"),
00131   // help text shown on menu
00132   N_("Converts a usht-plain to type float."),
00133   // more info...
00134   "convert uint to float",
00135   NULL,          // error msg, plugin may put error status msg here later
00136   NULL,          // Plugin Status, managed by Gxsm, plugin may manipulate it too
00137   // init-function pointer, can be "NULL", 
00138   // called if present at plugin load
00139   uto_float_init,  
00140   // query-function pointer, can be "NULL", 
00141   // called if present after plugin init to let plugin manage it install itself
00142   NULL, // query should be "NULL" for Gxsm-Math-Plugin !!!
00143   // about-function, can be "NULL"
00144   // can be called by "Plugin Details"
00145   uto_float_about,
00146   // configure-function, can be "NULL"
00147   // can be called by "Plugin Details"
00148   uto_float_configure,
00149   // run-function, can be "NULL", if non-Zero and no query defined, 
00150   // it is called on menupath->"plugin"
00151   NULL, // run should be "NULL" for Gxsm-Math-Plugin !!!
00152   // cleanup-function, can be "NULL"
00153   // called if present at plugin removeal
00154   uto_float_cleanup
00155 };
00156 
00157 // special math Plugin-Strucure, use
00158 // GxsmMathOneSrcPlugin uto_float_m1s_pi -> "OneSrcMath"
00159 // GxsmMathTwoSrcPlugin uto_float_m2s_pi -> "TwoSrcMath"
00160 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00161  GxsmMathOneSrcPlugin uto_float_m1s_pi
00162 #else
00163  GxsmMathTwoSrcPlugin uto_float_m2s_pi
00164 #endif
00165  = {
00166    // math-function to run, see prototype(s) above!!
00167    uto_float_run
00168  };
00169 
00170 // Text used in Aboutbox, please update!!
00171 static const char *about_text = N_("Gxsm uto_float Plugin\n\n"
00172                                    "Convert to float");
00173 
00174 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 
00175 // Essential Plugin Function!!
00176 GxsmPlugin *get_gxsm_plugin_info ( void ){ 
00177   uto_float_pi.description = g_strdup_printf(N_("Gxsm MathOneArg uto_float plugin %s"), VERSION);
00178   return &uto_float_pi; 
00179 }
00180 
00181 // Symbol "get_gxsm_math_one|two_src_plugin_info" is resolved by dlsym from Gxsm, 
00182 // used to find out which Math Type the Plugin is!! 
00183 // Essential Plugin Function!!
00184 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00185 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) {
00186   return &uto_float_m1s_pi; 
00187 }
00188 #else
00189 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 
00190   return &uto_float_m2s_pi; 
00191 }
00192 #endif
00193 
00194 /* Here we go... */
00195 // init-Function
00196 static void uto_float_init(void)
00197 {
00198   PI_DEBUG (DBG_L2, "uto_float Plugin Init");
00199 }
00200 
00201 // about-Function
00202 static void uto_float_about(void)
00203 {
00204   const gchar *authors[] = { uto_float_pi.authors, NULL};
00205   gtk_widget_show(gnome_about_new ( uto_float_pi.name,
00206                                     VERSION,
00207                                     N_("(C) 2000 the Free Software Foundation"),
00208                                     about_text,
00209                                     authors,
00210                                     NULL, NULL, NULL
00211                                     ));
00212 }
00213 
00214 // configure-Function
00215 static void uto_float_configure(void)
00216 {
00217         if(uto_float_pi.app)
00218                 uto_float_pi.app->message("uto_float Plugin Configuration");
00219 }
00220 
00221 // cleanup-Function
00222 static void uto_float_cleanup(void)
00223 {
00224         PI_DEBUG (DBG_L2, "uto_float Plugin Cleanup");
00225 }
00226 
00227 // run-Function
00228 static gboolean uto_float_run(Scan *Src, Scan *Dest)
00229 {
00230         Dest->mem2d->Resize (Dest->data.s.nx, Dest->data.s.ny, ZD_FLOAT);
00231         Dest->mem2d->ConvertFrom (Src->mem2d, 
00232                                   0,0, 
00233                                   0,0,
00234                                   Dest->mem2d->GetNx (), Dest->mem2d->GetNy ());
00235 
00236        for(int v=0; v<Dest->mem2d->GetNv (); ++v)
00237                 for(int line=0; line<Dest->mem2d->GetNy (); ++line)
00238                         for(int col=0; col<Dest->mem2d->GetNx (); ++col)
00239                                 if (Dest->mem2d->GetDataPkt (col, line) < 0.)
00240                                         Dest->mem2d->PutDataPkt(
00241                                                 65536.+Dest->mem2d->GetDataPkt (col, line),
00242                                                 col, line, v);
00243 
00244         return MATH_OK;
00245 }
00246 
00247 

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