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_complex 00009 pluginmenuentry =to complex 00010 menupath =Math/Convert/ 00011 entryplace =Convert 00012 shortentryplace =CV 00013 abouttext =Convert to complex 00014 smallhelp =convert to complex 00015 longhelp =Converts a scan to type complex. 00016 * 00017 * Gxsm Plugin Name: to_complex.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 complex 00049 % PlugInName: to_complex 00050 % PlugInAuthor: Percy Zahl 00051 % PlugInAuthorEmail: zahl@users.sf.net 00052 % PlugInMenuPath: Math/Convert/to complex 00053 00054 % PlugInDescription 00055 Convert scan data type to complex. Therefore layer 0 is used to hold 00056 the absolute value, layer 1 the real part and layer 2 for the imaginary part. A conversion to it 00057 will set the imaginary part to zero, a conversion from complex to a 00058 scalar type will compute the magnitude fom re and im, ignoring the possible existing abs value! 00059 00060 % PlugInUsage 00061 Call \GxsmMenu{Math/Convert/to complex}. 00062 00063 % OptPlugInSources 00064 The active channel is used as data source. 00065 00066 % OptPlugInDest 00067 The conversion result is placed into an existing math channel, else 00068 into a new created math channel. 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 to_complex_init( void ); 00080 static void to_complex_about( void ); 00081 static void to_complex_configure( void ); 00082 static void to_complex_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 to_complex_run( Scan *Src, Scan *Dest ); 00092 #else 00093 // "TwoSrc" Prototype 00094 static gboolean to_complex_run( Scan *Src1, Scan *Src2, Scan *Dest ); 00095 #endif 00096 00097 // Fill in the GxsmPlugin Description here 00098 GxsmPlugin to_complex_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 "to_complex-" 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 NULL, 00120 // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details) 00121 "Converts a scan to type complex.", 00122 // Author(s) 00123 "Percy Zahl", 00124 // Menupath to position where it is appendet to 00125 N_("_Math/_Convert/"), 00126 // Menuentry 00127 N_("to complex"), 00128 // help text shown on menu 00129 N_("Converts a scan to type complex."), 00130 // more info... 00131 "convert to complex", 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 to_complex_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 to_complex_about, 00143 // configure-function, can be "NULL" 00144 // can be called by "Plugin Details" 00145 to_complex_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 to_complex_cleanup 00152 }; 00153 00154 // special math Plugin-Strucure, use 00155 // GxsmMathOneSrcPlugin to_complex_m1s_pi -> "OneSrcMath" 00156 // GxsmMathTwoSrcPlugin to_complex_m2s_pi -> "TwoSrcMath" 00157 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00158 GxsmMathOneSrcPlugin to_complex_m1s_pi 00159 #else 00160 GxsmMathTwoSrcPlugin to_complex_m2s_pi 00161 #endif 00162 = { 00163 // math-function to run, see prototype(s) above!! 00164 to_complex_run 00165 }; 00166 00167 // Text used in Aboutbox, please update!! 00168 static const char *about_text = N_("Gxsm to_complex Plugin\n\n" 00169 "Convert to complex"); 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 to_complex_pi.description = g_strdup_printf(N_("Gxsm MathOneArg to_complex plugin %s"), VERSION); 00175 return &to_complex_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 &to_complex_m1s_pi; 00184 } 00185 #else 00186 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 00187 return &to_complex_m2s_pi; 00188 } 00189 #endif 00190 00191 /* Here we go... */ 00192 // init-Function 00193 static void to_complex_init(void) 00194 { 00195 PI_DEBUG (DBG_L2, "to_complex Plugin Init"); 00196 } 00197 00198 // about-Function 00199 static void to_complex_about(void) 00200 { 00201 const gchar *authors[] = { to_complex_pi.authors, NULL}; 00202 gtk_widget_show(gnome_about_new ( to_complex_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 to_complex_configure(void) 00213 { 00214 if(to_complex_pi.app) 00215 to_complex_pi.app->message("to_complex Plugin Configuration"); 00216 } 00217 00218 // cleanup-Function 00219 static void to_complex_cleanup(void) 00220 { 00221 PI_DEBUG (DBG_L2, "to_complex Plugin Cleanup"); 00222 } 00223 00224 // run-Function 00225 static gboolean to_complex_run(Scan *Src, Scan *Dest) 00226 { 00227 Dest->mem2d->Resize (Dest->data.s.nx, Dest->data.s.ny, ZD_COMPLEX); 00228 // set "Complex" layer param defaults 00229 Dest->data.s.nvalues=3; 00230 Dest->data.s.ntimes=1; 00231 Dest->mem2d->data->SetVLookup(0, 0); 00232 Dest->mem2d->data->SetVLookup(1, 1); 00233 // convert data 00234 Dest->mem2d->ConvertFrom (Src->mem2d, 00235 0,0, 00236 0,0, 00237 Dest->mem2d->GetNx (), Dest->mem2d->GetNy ()); 00238 return MATH_OK; 00239 } 00240 00241