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 =flip_diagonal 00009 pluginmenuentry =Flip Diagonal 00010 menupath =Math/Transformations/ 00011 entryplace =Transformations 00012 shortentryplace =TR 00013 abouttext =Flips an image along it's diagonale. 00014 smallhelp =Flips an image diagonal 00015 longhelp =This is a detailed help for my Plugin. 00016 * 00017 * Gxsm Plugin Name: flip_diagonal.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: Flip diagonal 00049 % PlugInName: flip_diagonal 00050 % PlugInAuthor: A. Klust, P. Zahl 00051 % PlugInAuthorEmail: zahl@users.sf.net 00052 % PlugInMenuPath: Math/Transformations/Flip Diagonal 00053 00054 % PlugInDescription 00055 Flips an image along it's diagonale. 00056 00057 % PlugInUsage 00058 Call \GxsmMenu{Math/Transformations/Flip Diagonal}. 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 into a new created math channel. 00068 00069 %% OptPlugInConfig 00070 %describe the configuration options of your plug in here! 00071 00072 % EndPlugInDocuSection 00073 * -------------------------------------------------------------------------------- 00074 */ 00075 00076 #include <gtk/gtk.h> 00077 #include "config.h" 00078 #include "gxsm/plugin.h" 00079 00080 // Plugin Prototypes 00081 static void flip_diagonal_init( void ); 00082 static void flip_diagonal_about( void ); 00083 static void flip_diagonal_configure( void ); 00084 static void flip_diagonal_cleanup( void ); 00085 00086 // Define Type of math plugin here, only one line should be commented in!! 00087 #define GXSM_ONE_SRC_PLUGIN__DEF 00088 // #define GXSM_TWO_SRC_PLUGIN__DEF 00089 00090 // Math-Run-Function, use only one of (automatically done :=) 00091 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00092 // "OneSrc" Prototype 00093 static gboolean flip_diagonal_run( Scan *Src, Scan *Dest ); 00094 #else 00095 // "TwoSrc" Prototype 00096 static gboolean flip_diagonal_run( Scan *Src1, Scan *Src2, Scan *Dest ); 00097 #endif 00098 00099 // Fill in the GxsmPlugin Description here 00100 GxsmPlugin flip_diagonal_pi = { 00101 NULL, // filled in and used by Gxsm, don't touch ! 00102 NULL, // filled in and used by Gxsm, don't touch ! 00103 0, // filled in and used by Gxsm, don't touch ! 00104 NULL, // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 00105 // filled in here by Gxsm on Plugin load, 00106 // just after init() is called !!! 00107 // ---------------------------------------------------------------------- 00108 // Plugins Name, CodeStly is like: Name-M1S|M2S-BG|F1D|F2D|ST|TR|Misc 00109 "flip_diagonal-" 00110 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00111 "M1S" 00112 #else 00113 "M2S" 00114 #endif 00115 "-TR", 00116 // Plugin's Category - used to autodecide on Pluginloading or ignoring 00117 // NULL: load, else 00118 // example: "+noHARD +STM +AFM" 00119 // load only, if "+noHARD: no hardware" and Instrument is STM or AFM 00120 // +/-xxxHARD und (+/-INST or ...) 00121 NULL, 00122 // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details) 00123 "This is a detailed help for my Plugin.", 00124 // Author(s) 00125 "Percy Zahl", 00126 // Menupath to position where it is appendet to 00127 N_("_Math/_Transformations/"), 00128 // Menuentry 00129 N_("Flip Diagonal"), 00130 // help text shown on menu 00131 N_("This is a detailed help for my Plugin."), 00132 // more info... 00133 "Flips an image diagonal", 00134 NULL, // error msg, plugin may put error status msg here later 00135 NULL, // Plugin Status, managed by Gxsm, plugin may manipulate it too 00136 // init-function pointer, can be "NULL", 00137 // called if present at plugin load 00138 flip_diagonal_init, 00139 // query-function pointer, can be "NULL", 00140 // called if present after plugin init to let plugin manage it install itself 00141 NULL, // query should be "NULL" for Gxsm-Math-Plugin !!! 00142 // about-function, can be "NULL" 00143 // can be called by "Plugin Details" 00144 flip_diagonal_about, 00145 // configure-function, can be "NULL" 00146 // can be called by "Plugin Details" 00147 flip_diagonal_configure, 00148 // run-function, can be "NULL", if non-Zero and no query defined, 00149 // it is called on menupath->"plugin" 00150 NULL, // run should be "NULL" for Gxsm-Math-Plugin !!! 00151 // cleanup-function, can be "NULL" 00152 // called if present at plugin removeal 00153 flip_diagonal_cleanup 00154 }; 00155 00156 // special math Plugin-Strucure, use 00157 // GxsmMathOneSrcPlugin flip_diagonal_m1s_pi -> "OneSrcMath" 00158 // GxsmMathTwoSrcPlugin flip_diagonal_m2s_pi -> "TwoSrcMath" 00159 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00160 GxsmMathOneSrcPlugin flip_diagonal_m1s_pi 00161 #else 00162 GxsmMathTwoSrcPlugin flip_diagonal_m2s_pi 00163 #endif 00164 = { 00165 // math-function to run, see prototype(s) above!! 00166 flip_diagonal_run 00167 }; 00168 00169 // Text used in Aboutbox, please update!! 00170 static const char *about_text = N_("Gxsm flip_diagonal Plugin\n\n" 00171 "Flips an image along it's diagonale."); 00172 00173 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 00174 // Essential Plugin Function!! 00175 GxsmPlugin *get_gxsm_plugin_info ( void ){ 00176 flip_diagonal_pi.description = g_strdup_printf(N_("Gxsm MathOneArg flip_diagonal plugin %s"), VERSION); 00177 return &flip_diagonal_pi; 00178 } 00179 00180 // Symbol "get_gxsm_math_one|two_src_plugin_info" is resolved by dlsym from Gxsm, 00181 // used to find out which Math Type the Plugin is!! 00182 // Essential Plugin Function!! 00183 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00184 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) { 00185 return &flip_diagonal_m1s_pi; 00186 } 00187 #else 00188 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 00189 return &flip_diagonal_m2s_pi; 00190 } 00191 #endif 00192 00193 /* Here we go... */ 00194 // init-Function 00195 static void flip_diagonal_init(void) 00196 { 00197 PI_DEBUG (DBG_L2, "flip_diagonal Plugin Init"); 00198 } 00199 00200 // about-Function 00201 static void flip_diagonal_about(void) 00202 { 00203 const gchar *authors[] = { flip_diagonal_pi.authors, NULL}; 00204 gtk_widget_show(gnome_about_new ( flip_diagonal_pi.name, 00205 VERSION, 00206 N_("(C) 2000 the Free Software Foundation"), 00207 about_text, 00208 authors, 00209 NULL, NULL, NULL 00210 )); 00211 } 00212 00213 // configure-Function 00214 static void flip_diagonal_configure(void) 00215 { 00216 if(flip_diagonal_pi.app) 00217 flip_diagonal_pi.app->message("flip_diagonal Plugin Configuration"); 00218 } 00219 00220 // cleanup-Function 00221 static void flip_diagonal_cleanup(void) 00222 { 00223 PI_DEBUG (DBG_L2, "flip_diagonal Plugin Cleanup"); 00224 } 00225 00226 // run-Function 00227 static gboolean flip_diagonal_run(Scan *Src, Scan *Dest) 00228 { 00229 Dest->mem2d->Resize (Src->mem2d->GetNy (), Src->mem2d->GetNx ()); 00230 Dest->data.s.nx = Dest->mem2d->GetNx (); 00231 Dest->data.s.ny = Dest->mem2d->GetNy (); 00232 Dest->data.s.rx = Src->data.s.ry; 00233 Dest->data.s.dx = Src->data.s.dy; 00234 Dest->data.s.ry = Src->data.s.rx; 00235 Dest->data.s.dy = Src->data.s.dx; 00236 00237 for (int col = 0; col < Dest->mem2d->GetNx (); col++) 00238 for (int line = 0; line < Dest->mem2d->GetNy (); line++) 00239 Dest->mem2d->PutDataPkt (Src->mem2d->GetDataPkt (line, col), 00240 col, line); 00241 00242 return MATH_OK; 00243 } 00244 00245