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