average_profile.C

Go to the documentation of this file.
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          =pzahl
00007 email                   =zahl@gxsm.sf.net
00008 pluginname              =average_profile
00009 pluginmenuentry         =Average X Profile
00010 menupath                =_Math/_Statistics/
00011 entryplace              =_Statistics
00012 shortentryplace =ST
00013 abouttext               =Compute the average X profile
00014 smallhelp               =computes the average X profile
00015 longhelp                =This Plugin computes the average X profile for all scanlines.
00016  * 
00017  * Gxsm Plugin Name: average_profile.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: Math/Statistics/Average X Profile replace this with a intuitive and short caption!
00049 % PlugInName: average_profile
00050 % PlugInAuthor: P. Zahl
00051 % PlugInAuthorEmail: zahl@gxsm.sf.net
00052 % PlugInMenuPath: Math/Statistics/Average X Profile
00053 
00054 % PlugInDescription
00055 Compute the average X profile of all scanlines.
00056 
00057 %% PlugInUsage
00058 
00059 
00060 %% OptPlugInSection: replace this by the section caption
00061 %all following lines until next tag are going into this section
00062 %...
00063 
00064 %% OptPlugInSubSection: replace this line by the subsection caption
00065 %all following lines until next tag are going into this subsection
00066 %...
00067 
00068 %% you can repeat OptPlugIn(Sub)Sections multiple times!
00069 
00070 %% OptPlugInSources
00071 %The active channel is used as data source.
00072 
00073 %% OptPlugInObjects
00074 %A optional rectangle is used for data extraction...
00075 
00076 %% OptPlugInDest
00077 %The computation result is placed into an existing math channel, else into a new created math channel.
00078 
00079 %% OptPlugInConfig
00080 %describe the configuration options of your plug in here!
00081 
00082 %% OptPlugInFiles
00083 %Does it uses, needs, creates any files? Put info here!
00084 
00085 %% OptPlugInRefs
00086 %Any references?
00087 
00088 %% OptPlugInKnownBugs
00089 %Are there known bugs? List! How to work around if not fixed?
00090 
00091 %% OptPlugInNotes
00092 %If you have any additional notes
00093 
00094 %% OptPlugInHints
00095 %Any tips and tricks?
00096 
00097 % EndPlugInDocuSection
00098  * -------------------------------------------------------------------------------- 
00099  */
00100 
00101 #include <gtk/gtk.h>
00102 #include "config.h"
00103 #include "gxsm/plugin.h"
00104 #include "gxsm/action_id.h"
00105 #include "gxsm/app_profile.h"
00106 
00107 // Plugin Prototypes
00108 static void average_profile_init( void );
00109 static void average_profile_about( void );
00110 static void average_profile_configure( void );
00111 static void average_profile_cleanup( void );
00112 
00113 // Math-Run-Function, use only one of (automatically done :=)
00114  static gboolean average_profile_run( Scan *Src);
00115 
00116 // Fill in the GxsmPlugin Description here
00117 GxsmPlugin average_profile_pi = {
00118   NULL,                   // filled in and used by Gxsm, don't touch !
00119   NULL,                   // filled in and used by Gxsm, don't touch !
00120   0,                      // filled in and used by Gxsm, don't touch !
00121   NULL,                   // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 
00122                           // filled in here by Gxsm on Plugin load, 
00123                           // just after init() is called !!!
00124   // ----------------------------------------------------------------------
00125   // Plugins Name, CodeStly is like: Name-M1S|M2S-BG|F1D|F2D|ST|TR|Misc
00126   "average_profile-"
00127   "M1S-ST",
00128   // Plugin's Category - used to autodecide on Pluginloading or ignoring
00129   // NULL: load, else
00130   // example: "+noHARD +STM +AFM"
00131   // load only, if "+noHARD: no hardware" and Instrument is STM or AFM
00132   // +/-xxxHARD und (+/-INST or ...)
00133   NULL,
00134   // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details)
00135   "This Plugin computes the average X profile for all scanlines.",                   
00136   // Author(s)
00137   "pzahl",
00138   // Menupath to position where it is appendet to
00139   N_("_Math/_Statistics/"),
00140   // Menuentry
00141   N_("Average X Profile"),
00142   // help text shown on menu
00143   N_("This Plugin computes the average X profile for all scanlines."),
00144   // more info...
00145   "computes the average X profile",
00146   NULL,          // error msg, plugin may put error status msg here later
00147   NULL,          // Plugin Status, managed by Gxsm, plugin may manipulate it too
00148   // init-function pointer, can be "NULL", 
00149   // called if present at plugin load
00150   average_profile_init,  
00151   // query-function pointer, can be "NULL", 
00152   // called if present after plugin init to let plugin manage it install itself
00153   NULL, // query should be "NULL" for Gxsm-Math-Plugin !!!
00154   // about-function, can be "NULL"
00155   // can be called by "Plugin Details"
00156   average_profile_about,
00157   // configure-function, can be "NULL"
00158   // can be called by "Plugin Details"
00159   average_profile_configure,
00160   // run-function, can be "NULL", if non-Zero and no query defined, 
00161   // it is called on menupath->"plugin"
00162   NULL, // run should be "NULL" for Gxsm-Math-Plugin !!!
00163   // cleanup-function, can be "NULL"
00164   // called if present at plugin removeal
00165   average_profile_cleanup
00166 };
00167 
00168 // special math Plugin-Strucure, use
00169  GxsmMathOneSrcNoDestPlugin average_profile_m1s_pi
00170  = {
00171    // math-function to run, see prototype(s) above!!
00172    average_profile_run
00173  };
00174 
00175 // Text used in Aboutbox, please update!!
00176 static const char *about_text = N_("Gxsm average_profile Plugin\n\n"
00177                                    "Compute the average X profile");
00178 
00179 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 
00180 // Essential Plugin Function!!
00181 GxsmPlugin *get_gxsm_plugin_info ( void ){ 
00182   average_profile_pi.description = g_strdup_printf(N_("Gxsm MathOneArg average_profile plugin %s"), VERSION);
00183   return &average_profile_pi; 
00184 }
00185 
00186 
00187 GxsmMathOneSrcNoDestPlugin *get_gxsm_math_one_src_no_dest_plugin_info( void ) {
00188   return &average_profile_m1s_pi; 
00189 }
00190 
00191 
00192 /* Here we go... */
00193 // init-Function
00194 static void average_profile_init(void)
00195 {
00196   PI_DEBUG (DBG_L2, "Plugin Init" );
00197 }
00198 
00199 // about-Function
00200 static void average_profile_about(void)
00201 {
00202   const gchar *authors[] = { average_profile_pi.authors, NULL};
00203   gtk_widget_show(gnome_about_new ( average_profile_pi.name,
00204                                     VERSION,
00205                                     N_("(C) 2000 the Free Software Foundation"),
00206                                     about_text,
00207                                     authors,
00208                                     NULL, NULL, NULL
00209                                     ));
00210 }
00211 
00212 // configure-Function
00213 static void average_profile_configure(void)
00214 {
00215   if(average_profile_pi.app)
00216     average_profile_pi.app->message("average_profile Plugin Configuration");
00217 }
00218 
00219 // cleanup-Function
00220 static void average_profile_cleanup(void)
00221 {
00222   PI_DEBUG (DBG_L2, "Plugin Cleanup");
00223 }
00224 
00225 // run-Function
00226  static gboolean average_profile_run(Scan *Src)
00227 {
00228         gchar *txt = g_strdup_printf ("Average X Profile of %d lines", Src->mem2d->GetNy ());
00229         ProfileControl *pc = new ProfileControl (txt, 
00230                                                  Src->mem2d->GetNx (), 
00231                                                  Src->data.Xunit, Src->data.Zunit, 
00232                                                  Src->mem2d->data->GetXLookup(0), Src->mem2d->data->GetXLookup( Src->mem2d->GetNx ()-1), "XavProfile");
00233         g_free (txt);
00234 
00235         for(int i = 0; i < Src->mem2d->GetNx (); i++)
00236                 pc->SetPoint (i, 0.);
00237 
00238         for(int line=0; line < Src->mem2d->GetNy (); line++)
00239                 for(int col=0; col < Src->mem2d->GetNx (); col++)
00240                         pc->AddPoint (col, Src->mem2d->GetDataPkt (col, line));
00241 
00242         for(int col=0; col < Src->mem2d->GetNx (); col++)
00243                 pc->MulPoint (col, 1./Src->mem2d->GetNy ());
00244 
00245         pc->drawScans();
00246 
00247         average_profile_pi.app->xsm->AddProfile (pc); // give it to Surface, it takes care about removing it...
00248         pc->unref (); // nothing depends on it, so decrement refcount
00249 
00250         return MATH_OK;
00251 }
00252 

Generated on Sat Apr 1 09:04:22 2006 for GXSM by  doxygen 1.4.6