00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #include <gtk/gtk.h>
00062 #include "config.h"
00063 #include "gxsm/plugin.h"
00064
00065 static void shear_x_init( void );
00066 static void shear_x_about( void );
00067 static void shear_x_configure( void );
00068 static void shear_x_cleanup( void );
00069 static gboolean shear_x_run( Scan *Src, Scan *Dest );
00070
00071 GxsmPlugin shear_x_pi = {
00072 NULL,
00073 NULL,
00074 0,
00075 NULL,
00076 "Shear_X-M1S-TR",
00077 NULL,
00078 NULL,
00079 "Percy Zahl",
00080 N_("_Math/_Transformations/"),
00081 N_("Shear X"),
00082 N_("Sorry, no help for shear_x filter!"),
00083 "no more info",
00084 NULL,
00085 NULL,
00086 shear_x_init,
00087 NULL,
00088 shear_x_about,
00089 shear_x_configure,
00090 NULL,
00091 shear_x_cleanup
00092 };
00093
00094 GxsmMathOneSrcPlugin shear_x_m1s_pi = {
00095 shear_x_run
00096 };
00097
00098 static const char *about_text = N_("Gxsm Shear_X Plugin\n\n"
00099 "shear scan along X.");
00100
00101 GxsmPlugin *get_gxsm_plugin_info ( void ){
00102 shear_x_pi.description = g_strdup_printf(N_("Gxsm MathOneArg shear_x plugin %s"), VERSION);
00103 return &shear_x_pi;
00104 }
00105
00106 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) {
00107 return &shear_x_m1s_pi;
00108 }
00109
00110 static void shear_x_init(void)
00111 {
00112 PI_DEBUG (DBG_L2, "Shear_X Plugin Init");
00113 }
00114
00115 static void shear_x_about(void)
00116 {
00117 const gchar *authors[] = { shear_x_pi.authors, NULL};
00118 gtk_widget_show(gnome_about_new ( shear_x_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_x_configure(void)
00128 {
00129 if(shear_x_pi.app)
00130 shear_x_pi.app->message("Shear_X Plugin Configuration");
00131 }
00132
00133 static void shear_x_cleanup(void)
00134 {
00135 PI_DEBUG (DBG_L2, "Shear_X Plugin Cleanup");
00136 }
00137
00138 static gboolean shear_x_run(Scan *Src, Scan *Dest)
00139 {
00140 double phi = 45.;
00141 double tanphi;
00142 int line, len;
00143 PI_DEBUG (DBG_L2, "Shear Scan X");
00144
00145 shear_x_pi.app->ValueRequest("Enter Value", "angle", "I need the shear-X angle",
00146 shear_x_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 + (len = (int)((double)Src->mem2d->GetNx()*fabs(tanphi))+1);
00152 Dest->data.s.ny = Src->mem2d->GetNy();
00153 Dest->mem2d->Resize(Dest->data.s.nx+1, Dest->data.s.ny);
00154
00155
00156 Dest->data.s.rx = Dest->data.s.nx*Dest->data.s.dx;
00157 Dest->data.s.x0 -= (double)len*Dest->data.s.dx/2.;
00158 Dest->mem2d->data->MkXLookup(Dest->data.s.x0,Dest->data.s.x0+Dest->data.s.rx);
00159 Dest->data.s.ry = Dest->data.s.ny*Dest->data.s.dy;
00160
00161 if(tanphi>0.)
00162 for(line = 0; line < Dest->data.s.ny; line++)
00163 Dest->mem2d->CopyFrom(Src->mem2d, 0, line, (int)rint((double)line*tanphi), line, Src->mem2d->GetNx());
00164 else
00165 for(line = 0; line < Dest->data.s.ny; line++)
00166 Dest->mem2d->CopyFrom(Src->mem2d, 0, line, len+(int)rint((double)line*tanphi), line, Src->mem2d->GetNx());
00167
00168 return MATH_OK;
00169 }