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 =Stefan 00007 pluginname =stepcount 00008 pluginmenuentry =Stepcounter 00009 menupath =Math/Statistics/ 00010 entryplace =Statistics 00011 shortentryplace =ST 00012 abouttext =Stepcounter 00013 smallhelp =Stepcounter - counts step of height 256 00014 longhelp =Step counter 00015 * 00016 * Gxsm Plugin Name: stepcount.C 00017 * ======================================== 00018 * 00019 * Copyright (C) 1999 The Free Software Foundation 00020 * 00021 * Authors: Percy Zahl <zahl@fkp.uni-hannover.de> 00022 * additional features: Andreas Klust <klust@fkp.uni-hannover.de> 00023 * 00024 * This program is free software; you can redistribute it and/or modify 00025 * it under the terms of the GNU General Public License as published by 00026 * the Free Software Foundation; either version 2 of the License, or 00027 * (at your option) any later version. 00028 * 00029 * This program is distributed in the hope that it will be useful, 00030 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00031 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00032 * GNU General Public License for more details. 00033 * 00034 * You should have received a copy of the GNU General Public License 00035 * along with this program; if not, write to the Free Software 00036 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 00037 */ 00038 /* Please do not change the Begin/End lines of this comment section! 00039 * this is a LaTeX style section used for auto generation of the PlugIn Manual 00040 * Chapter. Add a complete PlugIn documentation inbetween the Begin/End marks! 00041 * All "% PlugInXXX" commentary tags are mandatory 00042 * All "% OptPlugInXXX" tags are optional 00043 * -------------------------------------------------------------------------------- 00044 % BeginPlugInDocuSection 00045 % PlugInDocuCaption: Stepcount 00046 % PlugInName: baseinfo 00047 % PlugInAuthor: Stefan Schr\"oder 00048 % PlugInAuthorEmail: stefan_fkp@users.sf.net 00049 % PlugInMenuPath: Math/Statistics/stepcounter 00050 00051 % PlugInDescription 00052 This is a primitive plugin for the analysis of artificially 00053 generated scans. It counts the number of steps in x-direction, 00054 higher than 255 counts. 00055 00056 % PlugInUsage 00057 Use with 00058 active scan or a selected rectangle within the active scan. 00059 00060 % OptPlugInSources 00061 You need one active scan. 00062 00063 % OptPlugInObjects 00064 If a rectangle is selected the calculated information applies to the 00065 content of the rectangle. Otherwise, the whole scan is analyzed. 00066 00067 % OptPlugInDest 00068 The result is printed on the console, so you better have one open! 00069 00070 % OptPlugInConfig 00071 None. 00072 00073 % OptPlugInKnownBugs 00074 None 00075 00076 % OptPlugInNotes 00077 Is there interest in a more general approach? 00078 00079 % EndPlugInDocuSection 00080 * 00081 -------------------------------------------------------------------------------- 00082 */ 00083 00084 #include <gtk/gtk.h> 00085 #include "config.h" 00086 #include "gxsm/plugin.h" 00087 00088 // Plugin Prototypes 00089 static void stepcount_init( void ); 00090 static void stepcount_about( void ); 00091 static void stepcount_configure( void ); 00092 static void stepcount_cleanup( void ); 00093 00094 // Define Type of math plugin here, only one line should be commented in!! 00095 #define GXSM_ONE_SRC_PLUGIN__DEF 00096 // #define GXSM_TWO_SRC_PLUGIN__DEF 00097 00098 // Math-Run-Function, use only one of (automatically done :=) 00099 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00100 // "OneSrc" Prototype 00101 static gboolean stepcount_run( Scan *Src, Scan *Dest ); 00102 #else 00103 // "TwoSrc" Prototype 00104 static gboolean stepcount_run( Scan *Src1, Scan *Src2, Scan *Dest ); 00105 #endif 00106 00107 // Fill in the GxsmPlugin Description here 00108 GxsmPlugin stepcount_pi = { 00109 NULL, // filled in and used by Gxsm, don't touch ! 00110 NULL, // filled in and used by Gxsm, don't touch ! 00111 0, // filled in and used by Gxsm, don't touch ! 00112 NULL, // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 00113 // filled in here by Gxsm on Plugin load, 00114 // just after init() is called !!! 00115 // ---------------------------------------------------------------------- 00116 // Plugins Name, CodeStly is like: Name-M1S|M2S-BG|F1D|F2D|ST|TR|Misc 00117 "stepcount-" 00118 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00119 "M1S" 00120 #else 00121 "M2S" 00122 #endif 00123 "-ST", 00124 // Plugin's Category - used to autodecide on Pluginloading or ignoring 00125 // NULL: load, else 00126 // example: "+noHARD +STM +AFM" 00127 // load only, if "+noHARD: no hardware" and Instrument is STM or AFM 00128 // +/-xxxHARD und (+/-INST or ...) 00129 NULL, 00130 // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details) 00131 "Step counter", 00132 // Author(s) 00133 "Stefan", 00134 // Menupath to position where it is appendet to 00135 N_("_Math/_Statistics/"), 00136 // Menuentry 00137 N_("Stepcounter"), 00138 // help text shown on menu 00139 N_("Step counter"), 00140 // more info... 00141 "Stepcounter - counts step of height 256", 00142 NULL, // error msg, plugin may put error status msg here later 00143 NULL, // Plugin Status, managed by Gxsm, plugin may manipulate it too 00144 // init-function pointer, can be "NULL", 00145 // called if present at plugin load 00146 stepcount_init, 00147 // query-function pointer, can be "NULL", 00148 // called if present after plugin init to let plugin manage it install itself 00149 NULL, // query should be "NULL" for Gxsm-Math-Plugin !!! 00150 // about-function, can be "NULL" 00151 // can be called by "Plugin Details" 00152 stepcount_about, 00153 // configure-function, can be "NULL" 00154 // can be called by "Plugin Details" 00155 stepcount_configure, 00156 // run-function, can be "NULL", if non-Zero and no query defined, 00157 // it is called on menupath->"plugin" 00158 NULL, // run should be "NULL" for Gxsm-Math-Plugin !!! 00159 // cleanup-function, can be "NULL" 00160 // called if present at plugin removeal 00161 stepcount_cleanup 00162 }; 00163 00164 // special math Plugin-Strucure, use 00165 // GxsmMathOneSrcPlugin stepcount_m1s_pi -> "OneSrcMath" 00166 // GxsmMathTwoSrcPlugin stepcount_m2s_pi -> "TwoSrcMath" 00167 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00168 GxsmMathOneSrcPlugin stepcount_m1s_pi 00169 #else 00170 GxsmMathTwoSrcPlugin stepcount_m2s_pi 00171 #endif 00172 = { 00173 // math-function to run, see prototype(s) above!! 00174 stepcount_run 00175 }; 00176 00177 // Text used in Aboutbox, please update!! 00178 static const char *about_text = N_("Gxsm stepcount Plugin\n\n" 00179 "Stepcounter"); 00180 00181 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 00182 // Essential Plugin Function!! 00183 GxsmPlugin *get_gxsm_plugin_info ( void ){ 00184 stepcount_pi.description = g_strdup_printf(N_("Gxsm MathOneArg stepcount plugin %s"), VERSION); 00185 return &stepcount_pi; 00186 } 00187 00188 // Symbol "get_gxsm_math_one|two_src_plugin_info" is resolved by dlsym from Gxsm, 00189 // used to find out which Math Type the Plugin is!! 00190 // Essential Plugin Function!! 00191 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00192 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) { 00193 return &stepcount_m1s_pi; 00194 } 00195 #else 00196 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 00197 return &stepcount_m2s_pi; 00198 } 00199 #endif 00200 00201 /* Here we go... */ 00202 // init-Function 00203 static void stepcount_init(void) 00204 { 00205 PI_DEBUG (DBG_L2, "stepcount Plugin Init"); 00206 } 00207 00208 // about-Function 00209 static void stepcount_about(void) 00210 { 00211 const gchar *authors[] = { stepcount_pi.authors, NULL}; 00212 gtk_widget_show(gnome_about_new ( stepcount_pi.name, 00213 VERSION, 00214 N_("(C) 2000 the Free Software Foundation"), 00215 about_text, 00216 authors, 00217 NULL, NULL, NULL 00218 )); 00219 } 00220 00221 // configure-Function 00222 static void stepcount_configure(void) 00223 { 00224 if(stepcount_pi.app) 00225 stepcount_pi.app->message("stepcount Plugin Configuration"); 00226 } 00227 00228 // cleanup-Function 00229 static void stepcount_cleanup(void) 00230 { 00231 PI_DEBUG (DBG_L2, "stepcount Plugin Cleanup"); 00232 } 00233 00234 // run-Function 00235 static gboolean stepcount_run(Scan *Src, Scan *Dest) 00236 { 00237 int akt, nachbar, line, col; 00238 int sumsteps_up, sumsteps_down; 00239 int left, right, top, bottom; 00240 00241 MOUSERECT msr; 00242 MkMausSelect(Src->Pkt2d, &msr, Src->mem2d->GetNx(), Src->mem2d->GetNy()); 00243 00244 if( msr.xSize < 1 || msr.ySize < 1){ 00245 left = 0; 00246 right = Src->mem2d->GetNx(); 00247 top = 0; 00248 bottom = Src->mem2d->GetNy(); 00249 } 00250 else{ 00251 left = msr.xLeft; 00252 right = msr.xRight; 00253 top = msr.yTop; 00254 bottom = msr.yBottom; 00255 } 00256 sumsteps_up = sumsteps_down = 0; 00257 00258 for(col = left; col < (right-1); col++){ 00259 for(line = top; line < (bottom-1); line++){ 00260 00261 akt = (int)Src->mem2d->GetDataPkt(col, line); 00262 nachbar = (int)Src->mem2d->GetDataPkt(col+1, line); 00263 00264 if(nachbar - akt > 256){ 00265 sumsteps_up ++; 00266 } 00267 if(akt - nachbar > 256){ 00268 sumsteps_down ++; 00269 } 00270 } 00271 } 00272 PI_DEBUG (DBG_L2, "Summe der Stufen (auf) = " << sumsteps_up ); 00273 PI_DEBUG (DBG_L2, "Summe der Stufen (ab ) = " << sumsteps_down ); 00274 00275 return MATH_OK; 00276 } 00277