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_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
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 }