shear_y.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  * Gxsm Plugin Name: shear_y.C
00006  * ========================================
00007  * 
00008  * Copyright (C) 1999 The Free Software Foundation
00009  *
00010  * Authors: Percy Zahl <zahl@fkp.uni-hannover.de>
00011  * additional features: Andreas Klust <klust@fkp.uni-hannover.de>
00012  *
00013  * This program is free software; you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation; either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * This program is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program; if not, write to the Free Software
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00026  */
00027 
00028 /* Please do not change the Begin/End lines of this comment section!
00029  * this is a LaTeX style section used for auto generation of the PlugIn Manual 
00030  * Chapter. Add a complete PlugIn documentation inbetween the Begin/End marks!
00031  * All "% PlugInXXX" commentary tags are mandatory
00032  * All "% OptPlugInXXX" tags are optional
00033  * --------------------------------------------------------------------------------
00034 % BeginPlugInDocuSection
00035 % PlugInDocuCaption: Shear along Y
00036 % PlugInName: shear_y
00037 % PlugInAuthor: Percy Zahl
00038 % PlugInAuthorEmail: zahl@users.sf.net
00039 % PlugInMenuPath: Math/Transformation/Shear Y
00040 
00041 % PlugInDescription
00042 To shear a image along Y use this transformation.
00043 
00044 % PlugInUsage
00045 Call \GxsmMenu{Math/Transformation/Shear Y} and fill in the shear
00046 angle as prompted.
00047 
00048 % OptPlugInSources
00049 The active channel is used as data source.
00050 
00051 % OptPlugInDest
00052 The computation result is placed into an existing math channel, else into a new created math channel.
00053 
00054 %% OptPlugInConfig
00055 %
00056 
00057 % EndPlugInDocuSection
00058  * -------------------------------------------------------------------------------- 
00059  */
00060 
00061 #include <gtk/gtk.h>
00062 #include "config.h"
00063 #include "gxsm/plugin.h"
00064 
00065 static void shear_y_init( void );
00066 static void shear_y_about( void );
00067 static void shear_y_configure( void );
00068 static void shear_y_cleanup( void );
00069 static gboolean shear_y_run( Scan *Src, Scan *Dest );
00070 
00071 GxsmPlugin shear_y_pi = {
00072   NULL,
00073   NULL,
00074   0,
00075   NULL,
00076   "Shear_Y-M1S-TR",
00077   NULL,
00078   NULL,
00079   "Percy Zahl",
00080   N_("_Math/_Transformations/"),
00081   N_("Shear Y"),
00082   N_("Sorry, no help for shear_y filter!"),
00083   "no more info",
00084   NULL,
00085   NULL,
00086   shear_y_init,
00087   NULL,
00088   shear_y_about,
00089   shear_y_configure,
00090   NULL,
00091   shear_y_cleanup
00092 };
00093 
00094 GxsmMathOneSrcPlugin shear_y_m1s_pi = {
00095   shear_y_run
00096 };
00097 
00098 static const char *about_text = N_("Gxsm Shear_Y Plugin\n\n"
00099                                    "shear along Y axis.");
00100 
00101 GxsmPlugin *get_gxsm_plugin_info ( void ){ 
00102   shear_y_pi.description = g_strdup_printf(N_("Gxsm MathOneArg shear_y plugin %s"), VERSION);
00103   return &shear_y_pi; 
00104 }
00105 
00106 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) { 
00107   return &shear_y_m1s_pi; 
00108 }
00109 
00110 static void shear_y_init(void)
00111 {
00112   PI_DEBUG (DBG_L2, "Shear_Y Plugin Init");
00113 }
00114 
00115 static void shear_y_about(void)
00116 {
00117   const gchar *authors[] = { shear_y_pi.authors, NULL};
00118   gtk_widget_show(gnome_about_new ( shear_y_pi.name,
00119                                     VERSION,
00120                                     N_("(C) 2000 the Free Software Foundation"),
00121                                     about_text,
00122                                     authors,
00123                                     NULL, NULL, NULL
00124                                     ));
00125 }
00126 
00127 static void shear_y_configure(void)
00128 {
00129   if(shear_y_pi.app)
00130     shear_y_pi.app->message("Shear_Y Plugin Configuration");
00131 }
00132 
00133 static void shear_y_cleanup(void)
00134 {
00135   PI_DEBUG (DBG_L2, "Shear_Y Plugin Cleanup");
00136 }
00137 
00138 static gboolean shear_y_run(Scan *Src, Scan *Dest)
00139 {
00140   double phi = 45.;
00141   double tanphi;
00142   int row, len;
00143   PI_DEBUG (DBG_L2, "Shear Scan Y");
00144 
00145   shear_y_pi.app->ValueRequest("Enter Value", "angle", "I need the shear-Y angle",
00146                                shear_y_pi.app->xsm->ArcUnit, -70., 70., ".2f", &phi);
00147 
00148   tanphi = tan(phi*M_PI/180.);
00149 
00150   Dest->data.s.nx = Src->mem2d->GetNx();
00151   Dest->data.s.ny = Src->mem2d->GetNy() 
00152     + (len = (int)((double)Src->mem2d->GetNy()*fabs(tanphi))+1);
00153   Dest->mem2d->Resize(Dest->data.s.nx, Dest->data.s.ny);
00154 
00155   // Anpassen an nächstmöglichen Wert  
00156   Dest->data.s.rx = Dest->data.s.nx*Dest->data.s.dx;
00157   Dest->data.s.ry = Dest->data.s.ny*Dest->data.s.dy;
00158   Dest->data.s.y0 -= (double)len*Dest->data.s.dy/2.;
00159   Dest->mem2d->data->MkYLookup(Dest->data.s.y0,Dest->data.s.y0+Dest->data.s.ry);
00160 
00161   if(tanphi>0.)
00162     for(row = 0; row < Dest->data.s.nx; row++)
00163       Dest->mem2d->CopyFrom(Src->mem2d, row, 0, row, (int)rint((double)row*tanphi), 1, Src->mem2d->GetNy());
00164   else
00165     for(row = 0; row < Dest->data.s.nx; row++)
00166       Dest->mem2d->CopyFrom(Src->mem2d, row, 0, row, len+(int)rint((double)row*tanphi), 1, Src->mem2d->GetNy());
00167 
00168   return MATH_OK;
00169 }

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