00001 /* Gnome gxsm - Gnome X Scanning Microscopy 00002 * universal STM/AFM/SARLS/SPALEED/... controlling and 00003 * data analysis software 00004 * 00005 * 00006 * Gxsm Plugin Name: rotate90.C 00007 * ======================================== 00008 * 00009 * Copyright (C) 1999 The Free Software Foundation 00010 * 00011 * Authors: Percy Zahl <zahl@fkp.uni-hannover.de> 00012 * additional features: Andreas Klust <klust@fkp.uni-hannover.de> 00013 * 00014 * This program is free software; you can redistribute it and/or modify 00015 * it under the terms of the GNU General Public License as published by 00016 * the Free Software Foundation; either version 2 of the License, or 00017 * (at your option) any later version. 00018 * 00019 * This program is distributed in the hope that it will be useful, 00020 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 * GNU General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU General Public License 00025 * along with this program; if not, write to the Free Software 00026 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 00027 */ 00028 00029 00030 /* Please do not change the Begin/End lines of this comment section! 00031 * this is a LaTeX style section used for auto generation of the PlugIn Manual 00032 * Chapter. Add a complete PlugIn documentation inbetween the Begin/End marks! 00033 * All "% PlugInXXX" commentary tags are mandatory 00034 * All "% OptPlugInXXX" tags are optional and can be removed or commented in 00035 * -------------------------------------------------------------------------------- 00036 % BeginPlugInDocuSection 00037 % PlugInDocuCaption: 90$^\circ$ clockwise rotation 00038 % PlugInName: rotate90 00039 % PlugInAuthor: Andreas Klust 00040 % PlugInAuthorEmail: klust@users.sf.net 00041 % PlugInMenuPath: _Math/Transformations/Rotate 90deg 00042 00043 % PlugInDescription 00044 This plug-in rotates the active scan clockwise by 90$^\circ$. 00045 00046 % PlugInUsage 00047 00048 00049 %% OptPlugInSection: replace this by the section caption 00050 %all following lines until next tag are going into this section 00051 %... 00052 00053 %% OptPlugInSubSection: replace this line by the subsection caption 00054 %all following lines until next tag are going into this subsection 00055 %... 00056 00057 %% you can repeat OptPlugIn(Sub)Sections multiple times! 00058 00059 %% OptPlugInSources 00060 %The active channel is used as data source. 00061 00062 %% OptPlugInObjects 00063 %A optional rectangle is used for data extraction... 00064 00065 %% OptPlugInDest 00066 %The computation result is placed into an existing math channel, else into a new created math channel. 00067 00068 %% OptPlugInConfig 00069 %describe the configuration options of your plug in here! 00070 00071 %% OptPlugInFiles 00072 %Does it uses, needs, creates any files? Put info here! 00073 00074 %% OptPlugInRefs 00075 %Any references? 00076 00077 %% OptPlugInKnownBugs 00078 %Are there known bugs? List! How to work around if not fixed? 00079 00080 %% OptPlugInNotes The plug-in was mainly written to facilitate 00081 background corrections such as line regression of scans with the scan 00082 direction up-down instead of left-right. Just rottate the scan and 00083 apply the usual background correction functions. 00084 00085 %% OptPlugInHints 00086 %Any tips and tricks? 00087 00088 % EndPlugInDocuSection 00089 * -------------------------------------------------------------------------------- 00090 */ 00091 00092 #include <gtk/gtk.h> 00093 #include "config.h" 00094 #include "gxsm/plugin.h" 00095 00096 // Plugin Prototypes 00097 static void rotate90_init( void ); 00098 static void rotate90_about( void ); 00099 static void rotate90_configure( void ); 00100 static void rotate90_cleanup( void ); 00101 00102 // Define Type of math plugin here, only one line should be commented in!! 00103 #define GXSM_ONE_SRC_PLUGIN__DEF 00104 // #define GXSM_TWO_SRC_PLUGIN__DEF 00105 00106 // Math-Run-Function, use only one of (automatically done :=) 00107 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00108 // "OneSrc" Prototype 00109 static gboolean rotate90_run( Scan *Src, Scan *Dest ); 00110 #else 00111 // "TwoSrc" Prototype 00112 static gboolean rotate90_run( Scan *Src1, Scan *Src2, Scan *Dest ); 00113 #endif 00114 00115 // Fill in the GxsmPlugin Description here 00116 GxsmPlugin rotate90_pi = { 00117 NULL, // filled in and used by Gxsm, don't touch ! 00118 NULL, // filled in and used by Gxsm, don't touch ! 00119 0, // filled in and used by Gxsm, don't touch ! 00120 NULL, // The Gxsm-App Class Ref.pointer (called "gapp" in Gxsm) is 00121 // filled in here by Gxsm on Plugin load, 00122 // just after init() is called !!! 00123 // ---------------------------------------------------------------------- 00124 // Plugins Name, CodeStly is like: Name-M1S|M2S-BG|F1D|F2D|ST|TR|Misc 00125 "rotate90-" 00126 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00127 "M1S" 00128 #else 00129 "M2S" 00130 #endif 00131 "-F2D", 00132 // Plugin's Category - used to autodecide on Pluginloading or ignoring 00133 // NULL: load, else 00134 // example: "+noHARD +STM +AFM" 00135 // load only, if "+noHARD: no hardware" and Instrument is STM or AFM 00136 // +/-xxxHARD und (+/-INST or ...) 00137 NULL, 00138 // Description, is shown by PluginViewer (Plugin: listplugin, Tools->Plugin Details) 00139 "Rotates the image 90deg clockwise.", 00140 // Author(s) 00141 "Andreas Klust", 00142 // Menupath to position where it is appendet to 00143 N_("_Math/Transformations/"), 00144 // Menuentry 00145 N_("Rotate 90deg"), 00146 // help text shown on menu 00147 N_("Rotates the image 90deg clockwise."), 00148 // more info... 00149 "Rotates the image 90deg clockwise.", 00150 NULL, // error msg, plugin may put error status msg here later 00151 NULL, // Plugin Status, managed by Gxsm, plugin may manipulate it too 00152 // init-function pointer, can be "NULL", 00153 // called if present at plugin load 00154 rotate90_init, 00155 // query-function pointer, can be "NULL", 00156 // called if present after plugin init to let plugin manage it install itself 00157 NULL, // query should be "NULL" for Gxsm-Math-Plugin !!! 00158 // about-function, can be "NULL" 00159 // can be called by "Plugin Details" 00160 rotate90_about, 00161 // configure-function, can be "NULL" 00162 // can be called by "Plugin Details" 00163 rotate90_configure, 00164 // run-function, can be "NULL", if non-Zero and no query defined, 00165 // it is called on menupath->"plugin" 00166 NULL, // run should be "NULL" for Gxsm-Math-Plugin !!! 00167 // cleanup-function, can be "NULL" 00168 // called if present at plugin removeal 00169 rotate90_cleanup 00170 }; 00171 00172 // special math Plugin-Strucure, use 00173 // GxsmMathOneSrcPlugin rotate90_m1s_pi -> "OneSrcMath" 00174 // GxsmMathTwoSrcPlugin rotate90_m2s_pi -> "TwoSrcMath" 00175 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00176 GxsmMathOneSrcPlugin rotate90_m1s_pi 00177 #else 00178 GxsmMathTwoSrcPlugin rotate90_m2s_pi 00179 #endif 00180 = { 00181 // math-function to run, see prototype(s) above!! 00182 rotate90_run 00183 }; 00184 00185 // Text used in Aboutbox, please update!! 00186 static const char *about_text = N_("Gxsm rotate90 Plugin\n\n" 00187 "Rotates the image 90deg clockwise."); 00188 00189 // Symbol "get_gxsm_plugin_info" is resolved by dlsym from Gxsm, used to get Plugin's info!! 00190 // Essential Plugin Function!! 00191 GxsmPlugin *get_gxsm_plugin_info ( void ){ 00192 rotate90_pi.description = g_strdup_printf(N_("Gxsm MathOneArg rotate90 plugin %s"), VERSION); 00193 return &rotate90_pi; 00194 } 00195 00196 // Symbol "get_gxsm_math_one|two_src_plugin_info" is resolved by dlsym from Gxsm, 00197 // used to find out which Math Type the Plugin is!! 00198 // Essential Plugin Function!! 00199 #ifdef GXSM_ONE_SRC_PLUGIN__DEF 00200 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) { 00201 return &rotate90_m1s_pi; 00202 } 00203 #else 00204 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) { 00205 return &rotate90_m2s_pi; 00206 } 00207 #endif 00208 00209 /* Here we go... */ 00210 // init-Function 00211 static void rotate90_init(void) 00212 { 00213 PI_DEBUG (DBG_L2, "Plugin Init" ); 00214 } 00215 00216 // about-Function 00217 static void rotate90_about(void) 00218 { 00219 const gchar *authors[] = { rotate90_pi.authors, NULL}; 00220 gtk_widget_show(gnome_about_new ( rotate90_pi.name, 00221 VERSION, 00222 N_("(C) 2000 the Free Software Foundation"), 00223 about_text, 00224 authors, 00225 NULL, NULL, NULL 00226 )); 00227 } 00228 00229 // configure-Function 00230 static void rotate90_configure(void) 00231 { 00232 if(rotate90_pi.app) 00233 rotate90_pi.app->message("rotate90 Plugin Configuration"); 00234 } 00235 00236 // cleanup-Function 00237 static void rotate90_cleanup(void) 00238 { 00239 PI_DEBUG (DBG_L2, "Plugin Cleanup"); 00240 } 00241 00242 // run-Function 00243 static gboolean rotate90_run(Scan *Src, Scan *Dest) 00244 { 00245 00246 Dest->mem2d->Resize(Src->mem2d->GetNy (), Src->mem2d->GetNx ()); 00247 00248 for(int line=0; line < Dest->mem2d->GetNy (); line++) 00249 for(int col=0; col < Dest->mem2d->GetNx (); col++) 00250 Dest->mem2d->PutDataPkt (Src->mem2d->GetDataPkt (line, col), col, line); 00251 00252 return MATH_OK; 00253 } 00254 00255