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
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 #include <gtk/gtk.h>
00096 #include "config.h"
00097 #include "gxsm/plugin.h"
00098
00099
00100 static void OctoCorr_init( void );
00101 static void OctoCorr_about( void );
00102 static void OctoCorr_configure( void );
00103 static void OctoCorr_cleanup( void );
00104
00105
00106 #define GXSM_ONE_SRC_PLUGIN__DEF
00107
00108
00109
00110 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00111
00112 static gboolean OctoCorr_run( Scan *Src, Scan *Dest );
00113 #else
00114
00115 static gboolean OctoCorr_run( Scan *Src1, Scan *Src2, Scan *Dest );
00116 #endif
00117
00118
00119 GxsmPlugin OctoCorr_pi = {
00120 NULL,
00121 NULL,
00122 0,
00123 NULL,
00124
00125
00126
00127
00128 "OctoCorr-"
00129 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00130 "M1S"
00131 #else
00132 "M2S"
00133 #endif
00134 "-TR",
00135
00136
00137
00138
00139
00140 NULL,
00141
00142 " Octopole Correction, use for SPA-LEED image geometry correction",
00143
00144 "Percy Zahl",
00145
00146 N_("_Math/_Transformations/"),
00147
00148 N_("OctoCorr"),
00149
00150 N_("for SPA-LEED: to correct octopole distorsions"),
00151
00152 "no more info",
00153 NULL,
00154 NULL,
00155
00156
00157 OctoCorr_init,
00158
00159
00160 NULL,
00161
00162
00163 OctoCorr_about,
00164
00165
00166 OctoCorr_configure,
00167
00168
00169 NULL,
00170
00171
00172 OctoCorr_cleanup
00173 };
00174
00175
00176
00177
00178 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00179 GxsmMathOneSrcPlugin OctoCorr_m1s_pi
00180 #else
00181 GxsmMathTwoSrcPlugin OctoCorr_m2s_pi
00182 #endif
00183 = {
00184
00185 OctoCorr_run
00186 };
00187
00188
00189 static const char *about_text = N_("Gxsm OctoCorr Plugin\n\n"
00190 "The SPA-LEED octopole causes a cushion distorsion\n"
00191 "of the electron deflection.\n"
00192 "This pluging applies the inverse of this distorsion to\n"
00193 "any image.\n"
00194 "Input parameters are:\n"
00195 " Energy, Stepsize and Origin (invariant Point)\n"
00196 " Free parameter \"b\" (distorsion strength)\n"
00197 );
00198
00199
00200
00201 GxsmPlugin *get_gxsm_plugin_info ( void ){
00202 OctoCorr_pi.description = g_strdup_printf(N_("Gxsm MathOneArg OctoCorr plugin %s"), VERSION);
00203 return &OctoCorr_pi;
00204 }
00205
00206
00207
00208
00209 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00210 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) {
00211 return &OctoCorr_m1s_pi;
00212 }
00213 #else
00214 GxsmMathTwoSrcPlugin *get_gxsm_math_two_src_plugin_info( void ) {
00215 return &OctoCorr_m2s_pi;
00216 }
00217 #endif
00218
00219
00220
00221
00222
00223
00224
00225 static void OctoCorr_init(void)
00226 {
00227 PI_DEBUG (DBG_L2, "OctoCorr Plugin Init");
00228 }
00229
00230
00231 static void OctoCorr_about(void)
00232 {
00233 const gchar *authors[] = { OctoCorr_pi.authors, NULL};
00234 gtk_widget_show(gnome_about_new ( OctoCorr_pi.name,
00235 VERSION,
00236 N_("(C) 2000 the Free Software Foundation"),
00237 about_text,
00238 authors,
00239 NULL, NULL, NULL
00240 ));
00241 }
00242
00243
00244 static void OctoCorr_configure(void)
00245 {
00246 if(OctoCorr_pi.app)
00247 OctoCorr_pi.app->message("OctoCorr Plugin Configuration");
00248 }
00249
00250
00251 static void OctoCorr_cleanup(void)
00252 {
00253 PI_DEBUG (DBG_L2, "OctoCorr Plugin Cleanup");
00254 }
00255
00256
00257
00258 #ifdef GXSM_ONE_SRC_PLUGIN__DEF
00259 static gboolean OctoCorr_run(Scan *Src, Scan *Dest)
00260 #else
00261 static gboolean OctoCorr_run(Scan *Src1, Scan *Src2, Scan *Dest)
00262 #endif
00263 {
00264
00265 int i,j;
00266 double jj,ii;
00267 double Ux, Uy, U, E, s, a, b;
00268 double Ldx, Ldy, nX0, nY0, Ux0, Uy0;
00269
00270 E = Src->data.s.Energy;
00271 OctoCorr_pi.app->ValueRequest("Enter Value", "Energy",
00272 "I need the scan Energy.",
00273 OctoCorr_pi.app->xsm->EnergyUnit,
00274 0.1, 500., ".2f", &E);
00275 Ldx = Src->data.s.dx;
00276 OctoCorr_pi.app->ValueRequest("Enter Value", "Ldx",
00277 "dx, X step size.",
00278 OctoCorr_pi.app->xsm->VoltUnit,
00279 1e-5, 10., ".2f", &Ldx);
00280 Ldy = Src->data.s.dy;
00281 OctoCorr_pi.app->ValueRequest("Enter Value", "Ldy",
00282 "dy, Y step size.",
00283 OctoCorr_pi.app->xsm->VoltUnit,
00284 1e-5, 10., ".2f", &Ldy);
00285
00286 if(Src->PktVal == 1){
00287 nX0 = Src->Pkt2d[0].x;
00288 nY0 = Src->Pkt2d[0].y;
00289 }else{
00290 nX0 = Src->data.s.x0/Ldx;
00291 nY0 = Src->data.s.y0/Ldy;
00292 OctoCorr_pi.app->ValueRequest("Enter Value", "X index",
00293 "invariant Point (can use Point Obj!)",
00294 OctoCorr_pi.app->xsm->Unity,
00295 -1000, 1000., ".2f", &nX0);
00296
00297 OctoCorr_pi.app->ValueRequest("Enter Value", "Y index",
00298 "invariant Point (can use Point Obj!)",
00299 OctoCorr_pi.app->xsm->Unity,
00300 -1000., 1000., ".2f", &nY0);
00301 }
00302
00303 Ux0 = ((double)nX0-(double)Src->data.s.nx/2.)*Ldx;
00304 Uy0 = ((double)nY0-(double)Src->data.s.ny/2.)*Ldy;
00305
00306 #define xMap(I) (Ux0+((double)(I)-(double)Src->data.s.nx/2.)*Ldx)
00307 #define yMap(I) (Uy0+((double)(I)-(double)Src->data.s.ny/2.)*Ldy)
00308
00309
00310 b = -0.4;
00311
00312 OctoCorr_pi.app->ValueRequest("Enter Value", "b (strength)",
00313 "may not be changed!",
00314 OctoCorr_pi.app->xsm->Unity,
00315 -2., 2., ".2f", &b);
00316
00317 Ux = xMap(Src->data.s.nx); Uy=yMap(Src->data.s.ny);
00318 U = sqrt(Ux*Ux + Uy*Uy);
00319 a = 1. - b*U/E;
00320 for(i=0; i<Dest->mem2d->GetNy(); i++){
00321 Uy = yMap(i);
00322 for(j=0; j<Dest->mem2d->GetNx(); j++){
00323 Ux = xMap(j);
00324 U = sqrt(Ux*Ux + Uy*Uy);
00325 s = a + b*sqrt(U/E);
00326 jj = (double)(j-nX0)*s + nX0;
00327 ii = (double)(i-nY0)*s + nY0;
00328 if(ii >= (double)(Dest->mem2d->GetNy()-1)
00329 || jj >= (double)(Dest->mem2d->GetNx()-1) || ii < 1. || jj < 1.)
00330 Dest->mem2d->PutDataPkt(0., j,i);
00331 else
00332 Dest->mem2d->PutDataPkt(Src->mem2d->GetDataPktInterpol(jj,ii), j,i);
00333 }
00334 }
00335
00336 return MATH_OK;
00337 }
00338