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 =quenchscan 00009 pluginmenuentry =Quench Scan 00010 menupath =Math/Transformations/ 00011 entryplace =Transformations 00012 shortentryplace =TR 00013 abouttext =Down size scan by factor of two, averages 2x2 points for resulting pixel. 00014 smallhelp =Half size of scan. 00015 longhelp =This is a detailed help for my Plugin. 00016 * 00017 * Gxsm Plugin Name: quenchscan.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: Quench Scan 00049 % PlugInName: quenchscan 00050 % PlugInAuthor: Percy Zahl 00051 % PlugInAuthorEmail: zahl@users.sf.net 00052 % PlugInMenuPath: Math/Transformations/Quench Scan 00053 00054 % PlugInDescription 00055 This filter quenches the scan to half size, therefor 2x2 pixels are 00056 averaged. 00057 00058 % PlugInUsage 00059 Call \GxsmMenu{Math/Transformation/Quench Scan}. 00060 00061 % OptPlugInSources 00062 The active channel is used as data source. 00063 00064 %% OptPlugInObjects 00065 00066 % OptPlugInDest 00067 The computation result is placed into an existing math channel, else 00068 into a new created math channel. 00069 00070 %% OptPlugInConfig 00071 %describe the configuration options of your plug in here! 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 quenchscan_init( void ); 00083 static void quenchscan_about( void ); 00084 static void quenchscan_configure( void ); 00085 static void quenchscan_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 quenchscan_run( Scan *Src, Scan *Dest ); 00095 #else 00096 // "TwoSrc" Prototype 00097 static gboolean quenchscan_run( Scan *Src1, Scan *Src2, Scan *Dest ); 00098 #endif 00099 00100 // Fill in the GxsmPlugin Description here 00101 GxsmPlugin quenchscan_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 "quenchscan-" 00111 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00112 "M1S" 00113 #else 00114 "M2S" 00115 #endif 00116 "-TR", 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/_Transformations/"), 00129 // Menuentry 00130 N_("Quench Scan"), 00131 // help text shown on menu 00132 N_("This is a detailed help for my Plugin."), 00133 // more info... 00134 "Half size of scan.", 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 quenchscan_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 quenchscan_about, 00146 // configure-function, can be "NULL" 00147 // can be called by "Plugin Details" 00148 quenchscan_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 quenchscan_cleanup 00155 }; 00156 00157 // special math Plugin-Strucure, use 00158 // GxsmMathOneSrcPlugin quenchscan_m1s_pi -> "OneSrcMath" 00159 // GxsmMathTwoSrcPlugin quenchscan_m2s_pi -> "TwoSrcMath" 00160 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00161 GxsmMathOneSrcPlugin quenchscan_m1s_pi 00162 #else 00163 GxsmMathTwoSrcPlugin quenchscan_m2s_pi 00164 #endif 00165 = { 00166 // math-function to run, see prototype(s) above!! 00167 quenchscan_run 00168 }; 00169 00170 // Text used in Aboutbox, please update!! 00171 static const char *about_text = N_("Gxsm quenchscan Plugin\n\n" 00172 "Down size scan by factor of two, averages 2x2 points for resulting pixel."); 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 quenchscan_pi.description = g_strdup_printf(N_("Gxsm MathOneArg quenchscan plugin %s"), VERSION); 00178 return &quenchscan_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 &quenchscan_m1s_pi; 00187 } 00188 #else 00189 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 00190 return &quenchscan_m2s_pi; 00191 } 00192 #endif 00193 00194 /* Here we go... */ 00195 // init-Function 00196 static void quenchscan_init(void) 00197 { 00198 PI_DEBUG (DBG_L2, "quenchscan Plugin Init"); 00199 } 00200 00201 // about-Function 00202 static void quenchscan_about(void) 00203 { 00204 const gchar *authors[] = { quenchscan_pi.authors, NULL}; 00205 gtk_widget_show(gnome_about_new ( quenchscan_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 quenchscan_configure(void) 00216 { 00217 if(quenchscan_pi.app) 00218 quenchscan_pi.app->message("quenchscan Plugin Configuration"); 00219 } 00220 00221 // cleanup-Function 00222 static void quenchscan_cleanup(void) 00223 { 00224 PI_DEBUG (DBG_L2, "quenchscan Plugin Cleanup"); 00225 } 00226 00227 // run-Function 00228 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00229 static gboolean quenchscan_run(Scan *Src, Scan *Dest) 00230 #else 00231 static gboolean quenchscan_run(Scan *Src1, Scan *Src2, Scan *Dest) 00232 #endif 00233 { 00234 long col, line; 00235 ZData *SrcZ, *SrcZn, *DestZ; 00236 double val; 00237 PI_DEBUG (DBG_L2, "Quench Scan"); 00238 00239 SrcZ = Src->mem2d->data; 00240 00241 DestZ = Dest->mem2d->data; 00242 00243 Dest->data.s.nx = (Src->data.s.nx/2) & ~1; 00244 Dest->data.s.dx = Src->data.s.dx*2.; 00245 Dest->data.s.ny = (Src->data.s.ny/2) & ~1; 00246 Dest->data.s.dy = Src->data.s.dy*2.; 00247 Dest->mem2d->Resize(Dest->data.s.nx, Dest->data.s.ny); 00248 00249 Mem2d NextLine(Src->mem2d->GetNx(), 1, Src->mem2d->GetTyp()); 00250 SrcZn = NextLine.data; 00251 for(line = 0; line < Dest->data.s.ny; line++){ 00252 NextLine.CopyFrom(Src->mem2d, 0,2*line+1, 0,0, Src->mem2d->GetNx()); 00253 DestZ->SetPtr(0, line); 00254 SrcZ ->SetPtr(0, 2*line); 00255 SrcZn->SetPtr(0, 0); 00256 for(col = 0; col < Dest->data.s.nx; col++){ 00257 val = SrcZ ->GetNext(); 00258 val += SrcZ ->GetNext(); 00259 val += SrcZn->GetNext(); 00260 val += SrcZn->GetNext(); 00261 val /= 4.; 00262 DestZ->SetNext(val); 00263 } 00264 } 00265 return MATH_OK; 00266 } 00267 00268