invert_z.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          =Percy Zahl
00007 email                   =zahl@users.sf.net
00008 pluginname              =invert_z
00009 pluginmenuentry         =Invert
00010 menupath                =Math/Arithmetic/
00011 entryplace              =Arithmetic
00012 shortentryplace =AR
00013 abouttext               =Inverts Z
00014 smallhelp               =invert Z
00015 longhelp                =Inverts Z values.
00016  * 
00017  * Gxsm Plugin Name: invert_z.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: Invert Z
00049 % PlugInName: invert_z
00050 % PlugInAuthor: Percy Zahl
00051 % PlugInAuthorEmail: zahl@users.sf.net
00052 % PlugInMenuPath: Math/Arithmetic/Invert
00053 
00054 % PlugInDescription
00055 Invert the Z values of a scan. \[ Z_{\text{math}} = -Z_{\text{active}} \]
00056 
00057 % PlugInUsage
00058 Call \GxsmMenu{Math/Arithmetic/Invert}.
00059 
00060 % OptPlugInSources
00061 The active channel is used as data source.
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.
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 invert_z_init( void );
00080 static void invert_z_about( void );
00081 static void invert_z_configure( void );
00082 static void invert_z_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 invert_z_run( Scan *Src, Scan *Dest );
00092 #else
00093 // "TwoSrc" Prototype
00094  static gboolean invert_z_run( Scan *Src1, Scan *Src2, Scan *Dest );
00095 #endif
00096 
00097 // Fill in the GxsmPlugin Description here
00098 GxsmPlugin invert_z_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   "invert_z-"
00108 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00109   "M1S"
00110 #else
00111   "M2S"
00112 #endif
00113   "-AR",
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   "Inverts Z values.",                   
00122   // Author(s)
00123   "Percy Zahl",
00124   // Menupath to position where it is appendet to
00125   N_("_Math/_Arithmetic/"),
00126   // Menuentry
00127   N_("Invert"),
00128   // help text shown on menu
00129   N_("Inverts Z values."),
00130   // more info...
00131   "invert Z",
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   invert_z_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   invert_z_about,
00143   // configure-function, can be "NULL"
00144   // can be called by "Plugin Details"
00145   invert_z_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   invert_z_cleanup
00152 };
00153 
00154 // special math Plugin-Strucure, use
00155 // GxsmMathOneSrcPlugin invert_z_m1s_pi -> "OneSrcMath"
00156 // GxsmMathTwoSrcPlugin invert_z_m2s_pi -> "TwoSrcMath"
00157 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00158  GxsmMathOneSrcPlugin invert_z_m1s_pi
00159 #else
00160  GxsmMathTwoSrcPlugin invert_z_m2s_pi
00161 #endif
00162  = {
00163    // math-function to run, see prototype(s) above!!
00164    invert_z_run
00165  };
00166 
00167 // Text used in Aboutbox, please update!!
00168 static const char *about_text = N_("Gxsm invert_z Plugin\n\n"
00169                                    "Inverts Z");
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   invert_z_pi.description = g_strdup_printf(N_("Gxsm MathOneArg invert_z plugin %s"), VERSION);
00175   return &invert_z_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 &invert_z_m1s_pi; 
00184 }
00185 #else
00186 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 
00187   return &invert_z_m2s_pi; 
00188 }
00189 #endif
00190 
00191 /* Here we go... */
00192 // init-Function
00193 static void invert_z_init(void)
00194 {
00195   PI_DEBUG (DBG_L2, "invert_z Plugin Init");
00196 }
00197 
00198 // about-Function
00199 static void invert_z_about(void)
00200 {
00201   const gchar *authors[] = { invert_z_pi.authors, NULL};
00202   gtk_widget_show(gnome_about_new ( invert_z_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 invert_z_configure(void)
00213 {
00214         if(invert_z_pi.app)
00215                 invert_z_pi.app->message("invert_z Plugin Configuration");
00216 }
00217 
00218 // cleanup-Function
00219 static void invert_z_cleanup(void)
00220 {
00221         PI_DEBUG (DBG_L2, "invert_z Plugin Cleanup");
00222 }
00223 
00224 // run-Function
00225 static gboolean invert_z_run(Scan *Src, Scan *Dest)
00226 {
00227         Dest->mem2d->ConvertFrom(
00228                 Src->mem2d, 
00229                 0, 0, 
00230                 0, 0, 
00231                 Dest->mem2d->GetNx(), Dest->mem2d->GetNy()
00232                 );
00233 
00234 
00235         for (int line = 0; line < Src->mem2d->GetNy(); line++)
00236                 for (int col = 0; col < Src->mem2d->GetNx(); col++)
00237                         Dest->mem2d->data->Zmul(-1., col, line);
00238 
00239         return MATH_OK;
00240 }

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