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 =to_float 00009 pluginmenuentry =to float 00010 menupath =Math/Convert/ 00011 entryplace =Convert 00012 shortentryplace =CV 00013 abouttext =Convert to float 00014 smallhelp =convert to float 00015 longhelp =Converts a scan to type float. 00016 * 00017 * Gxsm Plugin Name: to_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: to_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. 00056 00057 % PlugInUsage 00058 Call \GxsmMenu{Math/Convert/to float}. 00059 00060 % OptPlugInSources 00061 The active channel is used as data source. 00062 00063 % OptPlugInDest 00064 The conversion result is placed into an existing math channel, else 00065 into a new created math channel. 00066 00067 % EndPlugInDocuSection 00068 * -------------------------------------------------------------------------------- 00069 */ 00070 00071 #include <gtk/gtk.h> 00072 #include "config.h" 00073 #include "gxsm/plugin.h" 00074 00075 // Plugin Prototypes 00076 static void to_float_init( void ); 00077 static void to_float_about( void ); 00078 static void to_float_configure( void ); 00079 static void to_float_cleanup( void ); 00080 00081 // Define Type of math plugin here, only one line should be commented in!! 00082 #define GXSM_ONE_SRC_PLUGIN__DEF 00083 // #define GXSM_TWO_SRC_PLUGIN__DEF 00084 00085 // Math-Run-Function, use only one of (automatically done :=) 00086 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00087 // "OneSrc" Prototype 00088 static gboolean to_float_run( Scan *Src, Scan *Dest ); 00089 #else 00090 // "TwoSrc" Prototype 00091 static gboolean to_float_run( Scan *Src1, Scan *Src2, Scan *Dest ); 00092 #endif 00093 00094 // Fill in the GxsmPlugin Description here 00095 GxsmPlugin to_float_pi = { 00096 NULL, // filled in and used by Gxsm, don't touch ! 00097 NULL, // filled in and used by Gxsm, don't touch ! 00098 0, // filled in and used by Gxsm, don't touch ! 00099 NULL, // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 00100 // filled in here by Gxsm on Plugin load, 00101 // just after init() is called !!! 00102 // ---------------------------------------------------------------------- 00103 // Plugins Name, CodeStly is like: Name-M1S|M2S-BG|F1D|F2D|ST|TR|Misc 00104 "to_float-" 00105 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00106 "M1S" 00107 #else 00108 "M2S" 00109 #endif 00110 "-CV", 00111 // Plugin's Category - used to autodecide on Pluginloading or ignoring 00112 // NULL: load, else 00113 // example: "+noHARD +STM +AFM" 00114 // load only, if "+noHARD: no hardware" and Instrument is STM or AFM 00115 // +/-xxxHARD und (+/-INST or ...) 00116 NULL, 00117 // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details) 00118 "Converts a scan to type float.", 00119 // Author(s) 00120 "Percy Zahl", 00121 // Menupath to position where it is appendet to 00122 N_("_Math/_Convert/"), 00123 // Menuentry 00124 N_("to float"), 00125 // help text shown on menu 00126 N_("Converts a scan to type float."), 00127 // more info... 00128 "convert to float", 00129 NULL, // error msg, plugin may put error status msg here later 00130 NULL, // Plugin Status, managed by Gxsm, plugin may manipulate it too 00131 // init-function pointer, can be "NULL", 00132 // called if present at plugin load 00133 to_float_init, 00134 // query-function pointer, can be "NULL", 00135 // called if present after plugin init to let plugin manage it install itself 00136 NULL, // query should be "NULL" for Gxsm-Math-Plugin !!! 00137 // about-function, can be "NULL" 00138 // can be called by "Plugin Details" 00139 to_float_about, 00140 // configure-function, can be "NULL" 00141 // can be called by "Plugin Details" 00142 to_float_configure, 00143 // run-function, can be "NULL", if non-Zero and no query defined, 00144 // it is called on menupath->"plugin" 00145 NULL, // run should be "NULL" for Gxsm-Math-Plugin !!! 00146 // cleanup-function, can be "NULL" 00147 // called if present at plugin removeal 00148 to_float_cleanup 00149 }; 00150 00151 // special math Plugin-Strucure, use 00152 // GxsmMathOneSrcPlugin to_float_m1s_pi -> "OneSrcMath" 00153 // GxsmMathTwoSrcPlugin to_float_m2s_pi -> "TwoSrcMath" 00154 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00155 GxsmMathOneSrcPlugin to_float_m1s_pi 00156 #else 00157 GxsmMathTwoSrcPlugin to_float_m2s_pi 00158 #endif 00159 = { 00160 // math-function to run, see prototype(s) above!! 00161 to_float_run 00162 }; 00163 00164 // Text used in Aboutbox, please update!! 00165 static const char *about_text = N_("Gxsm to_float Plugin\n\n" 00166 "Convert to float"); 00167 00168 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 00169 // Essential Plugin Function!! 00170 GxsmPlugin *get_gxsm_plugin_info ( void ){ 00171 to_float_pi.description = g_strdup_printf(N_("Gxsm MathOneArg to_float plugin %s"), VERSION); 00172 return &to_float_pi; 00173 } 00174 00175 // Symbol "get_gxsm_math_one|two_src_plugin_info" is resolved by dlsym from Gxsm, 00176 // used to find out which Math Type the Plugin is!! 00177 // Essential Plugin Function!! 00178 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00179 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) { 00180 return &to_float_m1s_pi; 00181 } 00182 #else 00183 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 00184 return &to_float_m2s_pi; 00185 } 00186 #endif 00187 00188 /* Here we go... */ 00189 // init-Function 00190 static void to_float_init(void) 00191 { 00192 PI_DEBUG (DBG_L2, "to_float Plugin Init"); 00193 } 00194 00195 // about-Function 00196 static void to_float_about(void) 00197 { 00198 const gchar *authors[] = { to_float_pi.authors, NULL}; 00199 gtk_widget_show(gnome_about_new ( to_float_pi.name, 00200 VERSION, 00201 N_("(C) 2000 the Free Software Foundation"), 00202 about_text, 00203 authors, 00204 NULL, NULL, NULL 00205 )); 00206 } 00207 00208 // configure-Function 00209 static void to_float_configure(void) 00210 { 00211 if(to_float_pi.app) 00212 to_float_pi.app->message("to_float Plugin Configuration"); 00213 } 00214 00215 // cleanup-Function 00216 static void to_float_cleanup(void) 00217 { 00218 PI_DEBUG (DBG_L2, "to_float Plugin Cleanup"); 00219 } 00220 00221 // run-Function 00222 static gboolean to_float_run(Scan *Src, Scan *Dest) 00223 { 00224 Dest->mem2d->Resize (Dest->data.s.nx, Dest->data.s.ny, ZD_FLOAT); 00225 Dest->mem2d->ConvertFrom (Src->mem2d, 00226 0,0, 00227 0,0, 00228 Dest->mem2d->GetNx (), Dest->mem2d->GetNy ()); 00229 return MATH_OK; 00230 } 00231 00232