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 #include <gtk/gtk.h>
00083 #include "config.h"
00084 #include "gxsm/plugin.h"
00085
00086 using namespace std;
00087
00088
00089 static void findlocmax_init( void );
00090 static void findlocmax_about( void );
00091 static void findlocmax_configure( void );
00092 static void findlocmax_cleanup( void );
00093 static gboolean findlocmax_run( Scan *Src, Scan *Dest );
00094
00095 GxsmPlugin findlocmax_pi = {
00096 NULL,
00097 NULL,
00098 0,
00099 NULL,
00100 "Findlocmax-M1S-Misc",
00101 "+SARLS",
00102 NULL,
00103 "Nobody?, PZ",
00104 N_("_Math/_Misc/"),
00105 N_("Find Loc Max"),
00106 N_("Sorry, no help for findlocmax filter!"),
00107 "no more info",
00108 NULL,
00109 NULL,
00110 findlocmax_init,
00111 NULL,
00112 findlocmax_about,
00113 findlocmax_configure,
00114 NULL,
00115 findlocmax_cleanup
00116 };
00117
00118 GxsmMathOneSrcPlugin findlocmax_m1s_pi = {
00119 findlocmax_run
00120 };
00121
00122 static const char *about_text = N_("Gxsm Findlocmax Plugin\n\n"
00123 "Who has coded this one? -- PZ");
00124
00125 GxsmPlugin *get_gxsm_plugin_info ( void ){
00126 findlocmax_pi.description = g_strdup_printf(N_("Gxsm MathOneArg findlocmax plugin %s"), VERSION);
00127 return &findlocmax_pi;
00128 }
00129
00130 GxsmMathOneSrcPlugin *get_gxsm_math_one_src_plugin_info( void ) {
00131 return &findlocmax_m1s_pi;
00132 }
00133
00134 static void findlocmax_init(void)
00135 {
00136 PI_DEBUG (DBG_L2, "Findlocmax Plugin Init");
00137 }
00138
00139 static void findlocmax_about(void)
00140 {
00141 const gchar *authors[] = { findlocmax_pi.authors, NULL};
00142 gtk_widget_show(gnome_about_new ( findlocmax_pi.name,
00143 VERSION,
00144 N_("(C) 2000 the Free Software Foundation"),
00145 about_text,
00146 authors,
00147 NULL, NULL, NULL
00148 ));
00149 }
00150
00151 static void findlocmax_configure(void)
00152 {
00153 if(findlocmax_pi.app)
00154 findlocmax_pi.app->message("Findlocmax Plugin Configuration");
00155 }
00156
00157 static void findlocmax_cleanup(void)
00158 {
00159 PI_DEBUG (DBG_L2, "Findlocmax Plugin Cleanup");
00160 }
00161
00162 static gboolean findlocmax_run(Scan *Src, Scan *Dest)
00163 {
00164 findlocmax_pi.app->message("Sorry Findlocmax Plugin is buggy, fix it! PZ");
00165 return MATH_OK;
00166
00167
00168
00169
00170 int line,col,fokline,fokcol,fokxpoints,fokypoints;
00171 int peakx,peaky,newpeakx,newpeaky;
00172 double referenzpeak;
00173 ofstream f;
00174 int i;
00175 const char *fname;
00176 PI_DEBUG (DBG_L2, "Suche lokaler Maxima und Ausgabe in ASCII-Datei");
00177 fokxpoints=(int)(50000/Src->data.s.dx);
00178 if (fokxpoints==0) fokxpoints=1;
00179 fokypoints=(int)(50000/Src->data.s.dy);
00180 if (fokypoints==0) fokypoints=1;
00181
00182
00183
00184 for(line=0;line<Dest->data.s.ny;line++)
00185 for(col=0;col<Dest->data.s.nx;col++)
00186 Dest->mem2d->PutDataPkt(0,col, line);
00187
00188
00189
00190
00191 for(line=0;line<(Src->mem2d->GetNy()-fokypoints);line=line+(fokypoints/2))
00192 for(col=0;col<(Src->mem2d->GetNx()-fokxpoints);col=col+(fokxpoints/2)){
00193 peakx=col;
00194 peaky=line;
00195 referenzpeak=Src->mem2d->GetDataPkt(col,line);
00196 do{
00197 newpeakx=peakx; newpeaky=peaky;
00198 for(fokcol=(int)(newpeakx-fokxpoints); fokcol<=(newpeakx+fokxpoints); fokcol++)
00199 for(fokline=(int)(newpeaky-fokypoints); fokline<=(newpeaky+fokypoints); fokline++)
00200 if((fokcol>=0) && (fokcol<Src->mem2d->GetNx()) && (fokline>=0) && (fokline<Src->mem2d->GetNy())){
00201 if(referenzpeak<=(double)Src->mem2d->GetDataPkt(fokcol,fokline)){
00202 referenzpeak=Src->mem2d->GetDataPkt(fokcol,fokline);
00203 peakx=fokcol;
00204 peaky=fokline;
00205 }
00206 }
00207 }while(((newpeakx-peakx)!=0) && ((newpeaky-peaky)!=0));
00208 for(fokline=(newpeaky-fokypoints); fokline<=(newpeaky+fokypoints); fokline++)
00209 for(fokcol=(newpeakx-fokxpoints); fokcol<=(newpeakx+fokxpoints); fokcol++)
00210 if((fokcol>=0) && (fokcol<Dest->mem2d->GetNx()) && (fokline>=0) && (fokline<Dest->mem2d->GetNy()))
00211 if(0<Dest->mem2d->GetDataPkt(fokcol,fokline))
00212 referenzpeak=0;
00213 Dest->mem2d->PutDataPkt((SHT)referenzpeak,newpeakx,newpeaky);
00214 }
00215
00216
00217
00218 do{
00219 fname = findlocmax_pi.app->file_dialog("asc File to Save LOCAL MAXIMA","","*.asc","");
00220 if (fname == NULL) return 1;
00221 if (strncmp(fname+strlen(fname)-4,".asc",4))
00222 strcat((char*)fname, ".asc");
00223 PI_DEBUG (DBG_L2, "Save File: " << fname);
00224 i=2;
00225 f.open(fname, ios::in);
00226 if(f.good()){
00227 f.close();
00228 if((i=XSM_SHOW_CHOICE(WRN_WARNING, fname, WRN_FILEEXISTS, 3, L_CANCEL, L_OVERWRITE, L_RETRY, 1)) == 1)
00229 return 1;
00230 }
00231 }while(i!=2);
00232
00233 time_t t;
00234 time(&t);
00235 f.open(fname, ios::out | ios::trunc);
00236 if(!f.good()){
00237 XSM_SHOW_ALERT(ERR_SORRY, ERR_FILEWRITE,fname,1);
00238 return 1;
00239 }
00240 f << "# LOKALE MAXIMA ASCII-Data\n" << "# Date: " << ctime(&t) << "# " << fname << endl;
00241 f << "# Fokuspoints x = " << fokxpoints << endl;
00242 f << "# Fokuspoints y = " << fokypoints << endl;
00243 f << "# Datenpunktabstand [A] dx = " << Src->data.s.dx << endl;
00244 f << "# Datenpunktabstand [A] dy = " << Src->data.s.dy << endl;
00245 f << "# x y Intensität" << endl ;
00246
00247 for(line=0;line<Dest->data.s.ny;line++)
00248 for(col=0;col<Dest->data.s.nx;col++)
00249 if (Dest->mem2d->GetDataPkt(col, line)!=0)
00250 f << col << " " << line << " " << Dest->mem2d->GetDataPkt(col, line) << endl;
00251 f.close();
00252 return MATH_OK;
00253 }