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 =mul_scan 00009 pluginmenuentry =Mul X 00010 menupath =Math/Arithmetic/ 00011 entryplace =Arithmetic 00012 shortentryplace =AR 00013 abouttext =Multiply Active and X channels 00014 smallhelp =My new Plugin does useful things 00015 longhelp =This is a detailed help for my Plugin. 00016 * 00017 * Gxsm Plugin Name: mul_scan.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: Multiply scans 00049 % PlugInName: mul_scan 00050 % PlugInAuthor: Percy Zahl 00051 % PlugInAuthorEmail: zahl@users.sf.net 00052 % PlugInMenuPath: Math/Arithmetic/Mul X 00053 00054 % PlugInDescription 00055 Multiplys the Z-values of two scans. 00056 00057 % PlugInUsage 00058 Call \GxsmMenu{Math/Arithmetic/Mul X}. 00059 00060 % OptPlugInSources 00061 The active channel is multiplied with the X-channel. 00062 00063 %% OptPlugInObjects 00064 %A optional rectangle is used for data extraction... 00065 00066 % OptPlugInDest 00067 The computation result is placed into an existing math channel, else 00068 into a new created math channel. The result is of type \GxsmEmph{float}. 00069 00070 % OptPlugInNotes 00071 Both scans are required to have the same size in pixels. 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 mul_scan_init( void ); 00083 static void mul_scan_about( void ); 00084 static void mul_scan_configure( void ); 00085 static void mul_scan_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 mul_scan_run( Scan *Src, Scan *Dest ); 00095 #else 00096 // "TwoSrc" Prototype 00097 static gboolean mul_scan_run( Scan *Src1, Scan *Src2, Scan *Dest ); 00098 #endif 00099 00100 // Fill in the GxsmPlugin Description here 00101 GxsmPlugin mul_scan_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 "mul_scan-" 00111 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00112 "M1S" 00113 #else 00114 "M2S" 00115 #endif 00116 "-AR", 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 "This is a detailed help for my Plugin.", 00125 // Author(s) 00126 "Percy Zahl", 00127 // Menupath to position where it is appendet to 00128 N_("_Math/_Arithmetic/"), 00129 // Menuentry 00130 N_("Mul X"), 00131 // help text shown on menu 00132 N_("multiply X and active"), 00133 // more info... 00134 "Multiplies X and active channel.", 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 mul_scan_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 mul_scan_about, 00146 // configure-function, can be "NULL" 00147 // can be called by "Plugin Details" 00148 mul_scan_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 mul_scan_cleanup 00155 }; 00156 00157 // special math Plugin-Strucure, use 00158 // GxsmMathOneSrcPlugin mul_scan_m1s_pi -> "OneSrcMath" 00159 // GxsmMathTwoSrcPlugin mul_scan_m2s_pi -> "TwoSrcMath" 00160 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00161 GxsmMathOneSrcPlugin mul_scan_m1s_pi 00162 #else 00163 GxsmMathTwoSrcPlugin mul_scan_m2s_pi 00164 #endif 00165 = { 00166 // math-function to run, see prototype(s) above!! 00167 mul_scan_run 00168 }; 00169 00170 // Text used in Aboutbox, please update!! 00171 static const char *about_text = N_("Gxsm mul_scan Plugin\n\n" 00172 "Multiplies the active and X channel."); 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 mul_scan_pi.description = g_strdup_printf(N_("Gxsm MathOneArg mul_scan plugin %s"), VERSION); 00178 return &mul_scan_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 &mul_scan_m1s_pi; 00187 } 00188 #else 00189 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 00190 return &mul_scan_m2s_pi; 00191 } 00192 #endif 00193 00194 /* Here we go... */ 00195 // init-Function 00196 static void mul_scan_init(void) 00197 { 00198 PI_DEBUG (DBG_L2, "mul_scan Plugin Init"); 00199 } 00200 00201 // about-Function 00202 static void mul_scan_about(void) 00203 { 00204 const gchar *authors[] = { mul_scan_pi.authors, NULL}; 00205 gtk_widget_show(gnome_about_new ( mul_scan_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 mul_scan_configure(void) 00216 { 00217 if(mul_scan_pi.app) 00218 mul_scan_pi.app->message("mul_scan Plugin Configuration"); 00219 } 00220 00221 // cleanup-Function 00222 static void mul_scan_cleanup(void) 00223 { 00224 PI_DEBUG (DBG_L2, "mul_scan Plugin Cleanup"); 00225 } 00226 00227 // run-Function 00228 static gboolean mul_scan_run(Scan *Src1, Scan *Src2, Scan *Dest) 00229 { 00230 if(Src1->data.s.nx != Src2->data.s.nx || Src1->data.s.ny != Src2->data.s.ny) 00231 return MATH_SELECTIONERR; 00232 00233 Dest->mem2d->Resize (Dest->data.s.nx, Dest->data.s.ny, ZD_FLOAT); 00234 00235 for(int v=0; v<Dest->mem2d->GetNv (); ++v) 00236 for(int line=0; line<Dest->mem2d->GetNy (); ++line) 00237 for(int col=0; col<Dest->mem2d->GetNx (); ++col) 00238 Dest->mem2d->PutDataPkt( 00239 Src1->mem2d->GetDataPkt (col, line) 00240 * Src2->mem2d->GetDataPkt (col, line), 00241 col, line, v); 00242 00243 return MATH_OK; 00244 } 00245 00246