source: Sophya/trunk/SophyaPI/PIext/basexecut.cc@ 353

Last change on this file since 353 was 349, checked in by ercodmgr, 26 years ago

A/ ajout des blocs foreach et ameliorations gestion des variables ($x)
pour l'interpreteur piacmd.
B/ Ajout PIStdImgApp::AddText et corrections diverses

Reza 05/08/99

File size: 35.8 KB
Line 
1#include "piacmd.h"
2
3#include <stdio.h>
4#include <stdlib.h>
5#include <math.h>
6
7#include "basexecut.h"
8
9#include "pdlmgr.h"
10#include "ctimer.h"
11// #include "dlftypes.h"
12
13#include "pistdimgapp.h"
14#include "nobjmgr.h"
15#include "servnobjm.h"
16
17#include "histos.h"
18#include "histos2.h"
19#include "hisprof.h"
20#include "ntuple.h"
21#include "generaldata.h"
22#include "cvector.h"
23
24
25
26/* --Methode-- */
27PIABaseExecutor::PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app)
28{
29mpiac = piac;
30mObjMgr = omg;
31mImgApp = app;
32dynlink = NULL;
33RegisterCommands();
34}
35
36PIABaseExecutor::~PIABaseExecutor()
37{
38}
39
40
41
42/* --Methode-- */
43int PIABaseExecutor::Execute(string& kw, vector<string>& tokens)
44{
45Services2NObjMgr* srvo = mObjMgr->GetServiceObj();
46// >>>>> Chargement de modules
47if (kw == "loadmodule") {
48 if (tokens.size() < 2) { cout << "Usage: loadmodule fnameso modulename" << endl; return(0); }
49 mpiac->LoadModule(tokens[0], tokens[1]);
50 }
51// >>>>>>>>>>> Fenetre graphique , changement d'attributs graphiques
52else if (kw == "zone") {
53 if (tokens.size() < 2) { cout << "Usage: zone nx ny" << endl; return(0); }
54 int nx, ny;
55 nx = ny = 1;
56 nx = atoi(tokens[0].c_str()); ny = atoi(tokens[1].c_str());
57 mObjMgr->SetGraphicWinZone(nx, ny, false);
58 }
59else if (kw == "newwin") {
60 if (tokens.size() < 2) { cout << "Usage: newwin nx ny" << endl; return(0); }
61 int nx, ny;
62 nx = ny = 1;
63 nx = atoi(tokens[0].c_str()); ny = atoi(tokens[1].c_str());
64 mObjMgr->SetGraphicWinZone(nx, ny, true);
65 }
66else if (kw == "stacknext") mImgApp->StackWinNext();
67else if (kw == "gratt") {
68 if (tokens.size() < 1) { cout << "Usage: gratt attributes_list (att=def->defaut)" << endl; return(0); }
69 mObjMgr->SetGraphicAttributes(tokens[0]);
70 }
71else if (kw == "setxylimits") {
72 if (tokens.size() < 4) { cout << "Usage: setxylimits xmin xmax ymin ymax" << endl; return(0); }
73 double xmin = atof(tokens[0].c_str());
74 double xmax = atof(tokens[1].c_str());
75 double ymin = atof(tokens[2].c_str());
76 double ymax = atof(tokens[3].c_str());
77 mImgApp->SetXYLimits(xmin, xmax, ymin, ymax);
78 }
79else if (kw == "addtext") {
80 if (tokens.size() < 4) { cout << "Usage: addtext x y colfontatt txt" << endl; return(0); }
81 double xp = atof(tokens[0].c_str());
82 double yp = atof(tokens[1].c_str());
83 bool fgsr = true;
84 string txt = tokens[3];
85 for(int k=4; k<tokens.size(); k++) txt += (' ' + tokens[k]);
86 int opt = mObjMgr->GetServiceObj()->DecodeDispOption(tokens[2], fgsr);
87 mImgApp->AddText(txt, xp, yp);
88 if (fgsr) mImgApp->RestoreGraphicAtt();
89 }
90
91// >>>>>>>>>>> Link dynamique de fonctions C++
92else if (kw == "link" ) {
93 if (tokens.size() < 2) { cout << "Usage: link fnameso f1 [f2 f3]" << endl; return(0); }
94 string sph = "";
95 for(int gg=0; gg<5; gg++) tokens.push_back(sph);
96 int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3]);
97 if (rc == 0) cout << "PIABaseExecutor: Link from " << tokens[0] << " OK " << endl;
98}
99else if (kw == "call" ) {
100 if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl; return(0); }
101 UsFmap::iterator it = usfmap.find(tokens[0]);
102 if (it == usfmap.end()) {
103 cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl;
104 return(0);
105 }
106 cout << "PIABaseExecutor: Call " << tokens[0] << "( ... )" << endl;
107// on est oblige de faire un cast etant donne qu'on
108// utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
109 DlUserProcFunction fuf = (DlUserProcFunction)(*it).second;
110// On redirige la sortie sur le terminal
111 bool red = mImgApp->HasRedirectedStdOutErr();
112 mImgApp->RedirectStdOutErr(false);
113 TRY {
114 tokens.erase(tokens.begin());
115 fuf(tokens);
116 } CATCH(merr) {
117 fflush(stdout);
118 cout << endl;
119 cerr << endl;
120 string es = PeidaExc(merr);
121 cerr << "PIABaseExecutor: Call UserFunc Exception :" << merr << es;
122 }
123 mImgApp->RedirectStdOutErr(red);
124}
125
126// >>>>>>>>>>> lecture/ecriture des objets, gestion des objets
127else if (kw == "openfits" ) {
128 if (tokens.size() < 1) { cout << "Usage: openfits file " << endl; return(0); }
129 else { string nomobj = ""; mObjMgr->ReadFits(tokens[0], nomobj); }
130}
131else if (kw == "savefits" ) {
132 if (tokens.size() < 2) { cout << "Usage: savefits nameobj filename " << endl; return(0); }
133 else mObjMgr->SaveFits(tokens[0], tokens[1]);
134}
135else if (kw == "openppf" ) {
136 if (tokens.size() < 1) { cout << "Usage: openppf file " << endl; return(0); }
137 mObjMgr->ReadAll(tokens[0]);
138}
139else if (kw == "saveobjs" ) {
140 if (tokens.size() < 2) { cout << "Usage: saveobjs patt filename " << endl; return(0); }
141 mObjMgr->SaveObjects(tokens[0], tokens[1]);
142}
143else if (kw == "saveall" ) {
144 if (tokens.size() < 1) { cout << "Usage: saveall file " << endl; return(0); }
145 mObjMgr->SaveAll(tokens[0]);
146}
147else if (kw == "print" ) {
148 if (tokens.size() < 1) { cout << "Usage: print nameobj " << endl; return(0); }
149 mObjMgr->PrintObj(tokens[0]);
150}
151else if ( (kw == "rename" ) || (kw == "mv") ) {
152 if (tokens.size() < 2) { cout << "Usage: rename nameobj namenew" << endl; return(0); }
153 mObjMgr->RenameObj(tokens[0], tokens[1]);
154}
155else if ( (kw == "del" ) || (kw == "rm") ) {
156 if (tokens.size() < 1) { cout << "Usage: del nameobj " << endl; return(0); }
157 mObjMgr->DelObj(tokens[0]);
158}
159else if (kw == "delobjs" ) {
160 if (tokens.size() < 1) { cout << "Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
161 mObjMgr->DelObjects(tokens[0]);
162}
163else if ( (kw == "listobjs") || (kw == "ls") ) {
164 if (tokens.size() < 1) tokens.push_back("*");
165 mObjMgr->ListObjs(tokens[0]);
166}
167// Gestion des repertoires
168else if (kw == "mkdir" ) {
169 if (tokens.size() < 1) { cout << "Usage: mkdir dirname [true]" << endl; return(0); }
170 bool crd = mObjMgr->CreateDir(tokens[0]);
171 if ( crd && (tokens.size() > 1) && (tokens[1] == "true") )
172 mObjMgr->SetKeepOldDirAtt(tokens[0], true);
173 }
174else if (kw == "rmdir" ) {
175 if (tokens.size() < 1) { cout << "Usage: rmdir dirname " << endl; return(0); }
176 mObjMgr->DeleteDir(tokens[0]);
177 }
178else if (kw == "cd") {
179 if (tokens.size() < 1) tokens.push_back("home");
180 mObjMgr->SetCurrentDir(tokens[0]);
181 }
182else if (kw == "pwd") {
183 string dirn;
184 mObjMgr->GetCurrentDir(dirn);
185 cout << "CurrentDirectory: " << dirn << endl;
186 }
187else if (kw == "listdirs") {
188 if (tokens.size() < 1) tokens.push_back("*");
189 mObjMgr->ListDirs(tokens[0]);
190 }
191
192// >>>>>>>>>>> Creation d'histos 1D-2D
193else if (kw == "newh1d") {
194 if (tokens.size() < 4) { cout << "Usage: newh1d name xmin xmax nbin" << endl; return(0); }
195 int nbx;
196 float xmin, xmax;
197 nbx = 100;
198 xmin = 0.; xmax = 1.;
199 nbx = atoi(tokens[3].c_str());
200 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
201 Histo* h = new Histo(xmin, xmax, nbx);
202 mObjMgr->AddObj(h, tokens[0]);
203 }
204else if (kw == "newh2d") {
205 if (tokens.size() < 7) {
206 cout << "Usage: newh2d name xmin xmax nbinx ymin ymax nbiny" << endl;
207 return(0);
208 }
209 int nbx, nby;
210 float xmin, xmax;
211 float ymin, ymax;
212 nbx = nby = 50;
213 xmin = 0.; xmax = 1.;
214 ymin = 0.; ymax = 1.;
215 nbx = atoi(tokens[3].c_str());
216 nby = atoi(tokens[6].c_str());
217 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
218 ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());
219 Histo2D* h = new Histo2D(xmin, xmax, nbx, ymin, ymax, nby);
220 mObjMgr->AddObj(h, tokens[0]);
221 }
222else if (kw == "newprof") {
223 if (tokens.size() < 4)
224 { cout << "Usage: newprof name xmin xmax nbin [ymin ymax]" << endl; return(0); }
225 int nbx;
226 float xmin, xmax, ymin = 1., ymax = -1.;
227 if(tokens.size() > 5)
228 {ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());}
229 nbx = 100;
230 xmin = 0.; xmax = 1.;
231 nbx = atoi(tokens[3].c_str());
232 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
233 HProf* h = new HProf(xmin, xmax, nbx, ymin, ymax);
234 mObjMgr->AddObj(h, tokens[0]);
235 }
236else if (kw == "newgfd") {
237 if (tokens.size() < 3)
238 { cout << "Usage: newgfd nvar nalloc [errx(0/1)]" << endl; return(0); }
239 int nvar, nalloc, errx=0;
240 if (tokens.size() > 3)
241 { errx = atoi(tokens[3].c_str()); if(errx>0) errx=1; else errx = 0;}
242 nvar = atoi(tokens[1].c_str()); nalloc = atoi(tokens[2].c_str());
243 if(nvar>0 && nalloc>0) {
244 GeneralFitData* gfd = new GeneralFitData(nvar,nalloc,errx);
245 mObjMgr->AddObj(gfd, tokens[0]);
246 }
247 }
248
249// Creation/remplissage de vecteur et de matrice
250else if (kw == "newvec") {
251 if (tokens.size() < 2) {
252 cout << "Usage: newvec name size [f(i) dopt] " << endl; return(0);
253 }
254 int n = atoi(tokens[1].c_str());
255 double xmin, xmax;
256 xmin = 0.; xmax = n;
257 if (tokens.size() < 3) tokens.push_back("0.");
258 if (tokens.size() < 4) tokens.push_back("n");
259 mObjMgr->GetServiceObj()->PlotFunc(tokens[2], tokens[0], xmin, xmax, n, tokens[3]);
260 }
261else if (kw == "newmtx") {
262 if (tokens.size() < 3) {
263 cout << "Usage: newvec name sizeX sizeY [f(i,j) dopt] " << endl; return(0);
264 }
265 int nx = atoi(tokens[1].c_str());
266 int ny = atoi(tokens[2].c_str());
267 double xmin, xmax, ymin, ymax;
268 xmin = 0.; xmax = nx;
269 ymin = 0.; ymax = ny;
270 if (tokens.size() < 4) tokens.push_back("0.");
271 if (tokens.size() < 5) tokens.push_back("n");
272 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax,
273 nx, ny, tokens[4]);
274 }
275
276// >>>>>>>>>>> Affichage des objets
277else if ( (kw == "disp") || (kw == "surf") || (kw == "imag") ) {
278 if (tokens.size() < 1) { cout << "Usage: disp/surf/imag nameobj [opt]" << endl; return(0); }
279 string opt = "n";
280 if (tokens.size() > 1) opt = tokens[1];
281 if (kw == "disp") mObjMgr->DisplayObj(tokens[0], opt);
282 else if (kw == "surf") mObjMgr->DisplaySurf3D(tokens[0], opt);
283 else if (kw == "imag") mObjMgr->DisplayImage(tokens[0], opt);
284 }
285
286else if (kw == "nt2d") {
287 if (tokens.size() < 5) { cout << "Usage: nt2d nameobj varx vary errx erry opt" << endl; return(0); }
288 string opt = "n";
289 if (tokens.size() > 5) opt = tokens[5];
290 string ph = "";
291 mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], ph, tokens[3], tokens[4], ph, opt);
292 }
293else if (kw == "nt2dw") {
294 if (tokens.size() < 6) { cout << "Usage: nt2dw nameobj varx vary varz errx erry opt" << endl; return(0); }
295 string opt = "n";
296 if (tokens.size() > 6) opt = tokens[6];
297 string ph = "";
298 mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], ph, opt, false);
299 }
300else if (kw == "nt3d") {
301 if (tokens.size() < 7) { cout << "Usage: nt3d nameobj varx vary varz errx erry errz opt" << endl; return(0); }
302 string opt = "n";
303 if (tokens.size() > 7) opt = tokens[7];
304 mObjMgr->DisplayNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], opt, true);
305 }
306
307// Obsolete : ne pas virer SVP, cmv 26/7/99
308else if (kw == "gfd2d") {
309 cout<<"----- gfd2d OBSOLETE: utilisez nt2d -----"<<endl;
310 if(tokens.size()<2)
311 {cout<<"Usage: gfd2d nomobj numvarx erreur=(x y xy) opt"<<endl;
312 return(0);}
313 string numvary = "";
314 string err = "";
315 string opt = "n";
316 if(tokens.size()>2) err = tokens[2];
317 if(tokens.size()>3) opt = tokens[3];
318 mObjMgr->DisplayGFD(tokens[0],tokens[1],numvary,err,opt);
319 }
320else if (kw == "gfd3d") {
321 cout<<"----- gfd3d OBSOLETE: utilisez nt3d -----"<<endl;
322 if(tokens.size()<3)
323 {cout<<"Usage: gfd3d nameobj numvarx numvary erreur=(x y z xy xz yz xyz) opt"<<endl;
324 return(0);}
325 string err = "";
326 string opt = "n";
327 if(tokens.size()>3) err = tokens[3];
328 if(tokens.size()>4) opt = tokens[4];
329 mObjMgr->DisplayGFD(tokens[0],tokens[1],tokens[2],err,opt);
330 }
331
332// >>>>>>>>>>> Trace de fonctions
333else if ( (kw == "func") ) {
334 if (tokens.size() < 4) { cout << "Usage: func f(x) xmin xmax npt [opt]" << endl; return(0); }
335 string opt = "n";
336 if (tokens.size() > 4) opt = tokens[4];
337 int np;
338 double xmin, xmax;
339 np = 100;
340 xmin = 0.; xmax = 1.;
341 np = atoi(tokens[3].c_str());
342 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
343 string nom = "";
344 mObjMgr->GetServiceObj()->PlotFunc(tokens[0], nom, xmin, xmax, np, opt);
345 }
346else if ( (kw == "funcff") ) {
347 if (tokens.size() < 5) { cout << "Usage: funcff C-filename f(x)-name xmin xmax npt [opt]" << endl; return(0); }
348 string opt = "n";
349 if (tokens.size() > 5) opt = tokens[5];
350 int np;
351 double xmin, xmax;
352 np = 100;
353 xmin = 0.; xmax = 1.;
354 np = atoi(tokens[4].c_str());
355 xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str());
356 string nom = "";
357 mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], nom, xmin, xmax, np, opt);
358 }
359else if ( (kw == "func2d") ) {
360 if (tokens.size() < 7) {
361 cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty opt" << endl;
362 return(0);
363 }
364 int npx, npy;
365 double xmin, xmax;
366 double ymin, ymax;
367 npx = npy = 50;
368 xmin = 0.; xmax = 1.;
369 ymin = 0.; ymax = 1.;
370 npx = atoi(tokens[3].c_str());
371 npy = atoi(tokens[6].c_str());
372 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
373 ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());
374 string opt = "n";
375 if (tokens.size() > 7) opt = tokens[7];
376 string nom = "";
377 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
378 }
379else if ( (kw == "func2dff") ) {
380 if (tokens.size() < 8) {
381 cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty opt" << endl;
382 return(0);
383 }
384 int npx, npy;
385 double xmin, xmax;
386 double ymin, ymax;
387 npx = npy = 50;
388 xmin = 0.; xmax = 1.;
389 ymin = 0.; ymax = 1.;
390 npx = atoi(tokens[4].c_str());
391 npy = atoi(tokens[7].c_str());
392 xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str());
393 ymin = atof(tokens[5].c_str()); ymax = atof(tokens[6].c_str());
394 string opt = "n";
395 if (tokens.size() > 8) opt = tokens[8];
396 string nom = "";
397 mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
398 }
399
400// >>>>>>>>>>> Trace d'expressions de N_Tuple, StarList, etc ...
401else if (kw == "plot2d" ) {
402 if (tokens.size() < 4) {
403 cout << "Usage: plot2d nameobj expx expy [experrx experry] expcut [opt]" << endl;
404 return(0);
405 }
406 string errx = ""; string erry = ""; string ecut = "1";
407 string opt = "n";
408 if (tokens.size() < 6) { // Plot sans les erreurs
409 ecut = tokens[3];
410 if (tokens.size() > 4) opt = tokens[4];
411 }
412 else { // Plot avec les erreurs
413 errx = tokens[3]; erry = tokens[4]; ecut = tokens[5];
414 if (tokens.size() > 6) opt = tokens[6];
415 }
416 srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,ecut,opt);
417 }
418
419else if (kw == "plot2dw" ) {
420 if (tokens.size() < 5) {
421 cout << "Usage: plot2dw nomobj expx expy expwt expcut opt" << endl;
422 return(0);
423 }
424 string opt = "n";
425 if (tokens.size() > 5) opt = tokens[5];
426 srvo->DisplayPoints2DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
427 }
428else if (kw == "plot3d" ) {
429 if (tokens.size() < 5) {
430 cout << "Usage: plot3d nomobj expx expy expz expcut opt" << endl;
431 return(0);
432 }
433 string opt = "n";
434 if (tokens.size() > 5) opt = tokens[5];
435 srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], opt);
436 }
437
438else if (kw == "projh1d" ) {
439 if (tokens.size() < 5) {
440 cout << "Usage: projh1d nomobj expx expwt expcut nomh1 opt" << endl;
441 return(0);
442 }
443 string opt = "n";
444 if (tokens.size() > 5) opt = tokens[5];
445 srvo->ProjectH1(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], opt);
446 }
447
448else if (kw == "projh2d" ) {
449 if (tokens.size() < 6) {
450 cout << "Usage: projh2 nomobj expx expy expwt expcut nomh2 opt" << endl;
451 return(0);
452 }
453 string opt = "n";
454 if (tokens.size() > 6) opt = tokens[6];
455
456 srvo->ProjectH2(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
457 }
458
459else if (kw == "projprof" ) {
460 if (tokens.size() < 6) {
461 cout << "Usage: projprof nomobj expx expy expwt expcut nomprof opt" << endl;
462 return(0);
463 }
464 string opt = "n";
465 if (tokens.size() > 6) opt = tokens[6];
466
467 srvo->ProjectHProf(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], opt);
468 }
469
470else if (kw == "fillnt" ) {
471 if (tokens.size() < 6) {
472 cout << "Usage: fillnt nameobj expx expy expz expt expcut [ntname]" << endl;
473 return(0);
474 }
475 if (tokens.size() < 7) tokens.push_back("");
476 srvo->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6] );
477 }
478
479else if (kw == "ntloop" ) {
480 if (tokens.size() < 3) {
481 cout << "Usage: ntloop nameobj fname funcname [ntname [N1 N2] ]" << endl;
482 return(0);
483 }
484 if (tokens.size() < 4) tokens.push_back("");
485 if (tokens[3] == "!") tokens[3] = "";
486 int nl1 = -1;
487 int nl2 = -1;
488 if (tokens.size() > 5) {
489 nl1 = atoi(tokens[4].c_str());
490 nl2 = atoi(tokens[5].c_str());
491 }
492 srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], nl1, nl2);
493 }
494
495else if (kw == "ntexpcfile" ) {
496 if (tokens.size() < 3) {
497 cout << "Usage: ntexpcfile nameobj fname funcname" << endl;
498 return(0);
499 }
500 srvo->PrepareNTExpressionCFile(tokens[0],tokens[1], tokens[2]);
501 }
502
503else if (kw == "fillvec" ) {
504 if (tokens.size() < 4) {
505 cout << "Usage: fillvec nameobj expx expcut nomvec opt" << endl;
506 return(0);
507 }
508 string opt = "n";
509 if (tokens.size() > 4) opt = tokens[4];
510 srvo->FillVect(tokens[0],tokens[1],tokens[2], tokens[3], opt);
511 }
512
513else if (kw == "fillgd1" ) {
514 if (tokens.size() < 5) {
515 cout << "Usage: fillgd1 nomobj expx expy experry expcut nomgfd" << endl;
516 return(0);
517 }
518 string nomgfd = "";
519 if (tokens.size() > 5) nomgfd = tokens[5];
520 string expy = "";
521 srvo->FillGFD(tokens[0],tokens[1], expy, tokens[2], tokens[3], tokens[4],nomgfd);
522 }
523
524else if (kw == "fillgd2" ) {
525 if (tokens.size() < 6) {
526 cout << "Usage: fillgd2 nomobj expx expy expz experrz expcut nomgfd" << endl;
527 return(0);
528 }
529 string nomgfd = "";
530 if (tokens.size() > 6) nomgfd = tokens[6];
531 srvo->FillGFD(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5],nomgfd);
532 }
533
534
535// Fit 1D sur objets 1D. Egalement Fit 2D sur objets 2D.
536else if (kw == "fit") {
537 if (tokens.size() < 2) {
538 cout <<"Usage:fit nomobj func \n"
539 <<" [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]\n";
540 return(0);
541 }
542 string p=""; string s=""; string m=""; string M=""; string O="";
543 if (tokens.size()>2)
544 for(int ip=2;ip<tokens.size();ip++) {
545 if(tokens[ip].length()<=2) continue;
546 const char *c = tokens[ip].c_str();
547 if(c[1]!=':') continue;
548 if(c[0]=='p') p=c+2;
549 else if(c[0]=='s') s=c+2;
550 else if(c[0]=='m') m=c+2;
551 else if(c[0]=='M') M=c+2;
552 else if(c[0]=='o') {O += ","; O += c+2;}
553 }
554 srvo->Fit12D(tokens[0],tokens[1],p,s,m,M,O);
555}
556
557
558else {
559 cerr << "PIABaseExecutor::Do() Erreur - Commande " << kw << " inconuue ! " << endl;
560 return(-1);
561 }
562
563return(0);
564}
565
566/* --Methode-- */
567void PIABaseExecutor::RegisterCommands()
568{
569string kw, usage;
570kw = "loadmodule";
571usage = "To load and initialize modules \n Usage: loadmodule fnameso modulename";
572usage += "\n Related commands: link";
573mpiac->RegisterCommand(kw, usage, this, "External Modules");
574kw = "link";
575usage = "Dynamic linking of compiled user functions \n Usage: link fnameso f1 [f2 f3]";
576usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
577usage += "\n Related commands: call loadmodule";
578mpiac->RegisterCommand(kw, usage, this, "External Modules");
579kw = "call";
580usage = "Dynamically linked user function call \n Usage: call userf [arg1 arg2 ...]";
581usage += "\n User function : f(vector<string>& args)";
582usage += "\n Related commands: link";
583mpiac->RegisterCommand(kw, usage, this, "External Modules");
584
585kw = "zone";
586usage = "To Divide the Graphic window \n Usage: zone nx ny";
587mpiac->RegisterCommand(kw, usage, this, "Graphics");
588kw = "newwin";
589usage = "To Create a New Graphic window, with zones \n Usage: newwin nx ny";
590mpiac->RegisterCommand(kw, usage, this, "Graphics");
591kw = "stacknext";
592usage = "Displays the next widget on stack window \n Usage: stacknext";
593mpiac->RegisterCommand(kw, usage, this, "Graphics");
594
595kw = "gratt";
596usage = "To change default graphic options \n Usage: gratt att_list \n";
597usage += "att_list=def back to default values, Example: gratt red,circlemarker5";
598usage += "\n ------------------ Graphic attribute list ------------------ \n";
599usage += ">> Colors: defcol black white grey red blue green yellow magenta cyan \n";
600usage += " turquoise navyblue orange siennared purple limegreen gold \n";
601usage += ">> Lines: defline normalline thinline thickline dashedline thindashedline \n";
602usage += " thickdashedline dottedline thindottedline thickdottedline \n";
603usage += ">> Fonts: deffont normalfont boldfont italicfont smallfont smallboldfont \n";
604usage += " smallitalicfont bigfont bigboldfont bigitalicfont \n";
605usage += " hugefont hugeboldfont hugeitalicfont \n";
606usage += ">> Marker: dotmarker<T> plusmarker<T> crossmarker<T> circlemarker <T> \n";
607usage += " fcirclemarker<T> boxmarker<T> fboxmarker<T> trianglemarker<T> \n";
608usage += " ftrianglemarker<T> starmarker<T> fstarmarker<T> \n";
609usage += " with <T> = 1 3 5 7 9 , Example fboxmarker5 , plusmarker9 ... \n";
610usage += ">> ColorTables: defcmap grey32 greyinv32 colrj32 colbr32 \n";
611usage += " grey128 greyinv128 colrj128 colbr128 \n";
612usage += ">> ZoomFactors: defzoom zoomx1 zoomx2 zoomx3 zoomx4 zoomx5 \n";
613usage += " zoom/2 zoom/3 zoom/4 zoom/5 \n";
614usage += ">> Axes: stdaxes=defaxes=boxaxes simpleaxes boxaxesgrid \n";
615usage += " fineaxes grid=fineaxesgrid \n";
616usage += ">> XYLimits : xylimits -> Forces X-Y limits in 2-D plots \n";
617usage += ">> DisplayWindow: next same win stack \n";
618usage += " Related commands: setxylimits";
619mpiac->RegisterCommand(kw, usage, this, "Graphics");
620
621kw = "setxylimits";
622usage = "Define 2-D plot limits \n Usage: setxylimits xmin xmax ymin ymax";
623usage += "\n Related commands: gratt";
624mpiac->RegisterCommand(kw, usage, this, "Graphics");
625
626kw = "addtext";
627usage = "Adds a text string to the current graphic object";
628usage += "\n at the specified position (Gr-Object Coordinate) with graphic attribute specification";
629usage += "\n Usage: addtext x y ColFontAtt TextString";
630usage += "\n Related commands: gratt";
631mpiac->RegisterCommand(kw, usage, this, "Graphics");
632
633kw = "openfits";
634usage = "Loads a FITS file into an Image<T> \n Usage: openfits filename";
635usage += "\n Related commands: savefits openppf";
636mpiac->RegisterCommand(kw, usage, this, "FileIO");
637kw = "savefits";
638usage = "Save an object into a FITS file \n Usage: savefits nameobj filename";
639usage += "\n Related commands: openfits saveall";
640mpiac->RegisterCommand(kw, usage, this, "FileIO");
641kw = "openppf";
642usage = "Reads all objects from a PPF file \n Usage: openppf filename";
643usage += "\n Related commands: saveall openfits";
644mpiac->RegisterCommand(kw, usage, this, "FileIO");
645kw = "saveobjs";
646usage = "Saves objects with names matching a pattern (x?y*) into a PPF file \n";
647usage += "Usage: saveall nameobjpattern filename";
648usage += "\n Related commands: saveall openppf savefits";
649mpiac->RegisterCommand(kw, usage, this, "FileIO");
650kw = "saveall";
651usage = "Saves all objects into a PPF file \n Usage: saveall filename";
652usage += "\n Related commands: saveobj openppf savefits";
653mpiac->RegisterCommand(kw, usage, this, "FileIO");
654
655kw = "print";
656usage = "Prints an object \n Usage: print nameobj";
657mpiac->RegisterCommand(kw, usage, this, "FileIO");
658
659kw = "mkdir";
660usage = "Create a directory";
661usage += "\n Usage: mkdir dirname [true]";
662usage += "\n if second argument==true, the directory's KeepOld attribute is set to true";
663mpiac->RegisterCommand(kw, usage, this, "Object Managment");
664kw = "rmdir";
665usage = "Removes an empty directory";
666usage += "\n Usage: remove dirname";
667mpiac->RegisterCommand(kw, usage, this, "Object Managment");
668kw = "cd";
669usage = "Change current directory";
670usage += "\n Usage: cd [dirname]";
671mpiac->RegisterCommand(kw, usage, this, "Object Managment");
672kw = "pwd";
673usage = "Prints current directory";
674usage += "\n Usage: pwd";
675mpiac->RegisterCommand(kw, usage, this, "Object Managment");
676kw = "listdirs";
677usage = "Prints the list of directories";
678usage += "\n Usage: listdirs [patt=*] \n patt : * , ? ";
679mpiac->RegisterCommand(kw, usage, this, "Object Managment");
680kw = "listobjs";
681usage = "Prints the list of objects (Alias: ls)";
682 usage += "\n Usage: listobjs [patt=*] \n patt : /*/x?y* ... ";
683mpiac->RegisterCommand(kw, usage, this, "Object Managment");
684kw = "rename";
685usage = "Rename an object (Alias: mv) \n Usage: rename nameobj namenew";
686usage += "\n Related commands: del delobjs";
687mpiac->RegisterCommand(kw, usage, this, "Object Managment");
688kw = "del";
689usage = "Deletes an object (Alias: rm) \n Usage: del nameobj";
690usage += "\n Related commands: delobjs rename";
691mpiac->RegisterCommand(kw, usage, this, "Object Managment");
692kw = "delobjs";
693usage = "Delete a set of objects with names matching a pattern (x?y*)";
694usage += "\n Usage: delobjs nameobjpattern \n";
695usage += "\n Related commands: del rename";
696mpiac->RegisterCommand(kw, usage, this, "Object Managment");
697
698kw = "newh1d";
699usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
700usage += "\n Related commands: newh2d newprof newgfd ";
701mpiac->RegisterCommand(kw, usage, this, "Objects");
702kw = "newh2d";
703usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
704usage += "\n Related commands: newh1d newprof newgfd ";
705mpiac->RegisterCommand(kw, usage, this, "Objects");
706kw = "newprof";
707usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
708usage += "\n Related commands: newh1d newh2d newgfd ";
709mpiac->RegisterCommand(kw, usage, this, "Objects");
710kw = "newgfd";
711usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
712usage += "\n Related commands: newh1d newh2d newprof ";
713mpiac->RegisterCommand(kw, usage, this, "Objects");
714kw = "newvec";
715usage = "Creates (and fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
716usage += "\n Related commands: newmtx";
717mpiac->RegisterCommand(kw, usage, this, "Objets");
718kw = "newmtx";
719usage = "Creates (and fills) a matrix \n Usage: newvec name sizeX sizeY [f(i,j) [dopt] ] ";
720usage += "\n Related commands: newvec";
721mpiac->RegisterCommand(kw, usage, this, "Objets");
722
723kw = "disp";
724usage = "Displays an object \n Usage: disp nameobj [graphic_attributes]";
725usage += "\n Related commands: surf nt2d nt3d ";
726mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
727kw = "imag";
728usage = "Displays an object as an image \n Usage: imag nameobj [graphic_attributes]";
729usage += "\n Related commands: disp surf nt2d nt3d ";
730mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
731kw = "surf";
732usage = "Displays an object as a 3D surface \n Usage: surf nameobj [graphic_attributes]";
733usage += "\n Related commands: disp nt2d nt3d ";
734mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
735kw = "nt2d";
736usage = "Displays Points (X-Y) [with error-bars] from an NTuple ";
737usage += "\n Usage : nt2d nameobj varx vary [errx erry] [graphic_attributes]";
738usage += "\n Related commands: disp surf nt2dw nt3d gfd2d ";
739mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
740kw = "nt2dw";
741usage = "Displays Points (X-Y) with weight [with error-bars] from an NTuple ";
742usage += "\n Usage : nt2d nameobj varx vary varz [errx erry] [graphic_attributes]";
743usage += "\n Related commands: disp surf nt2d nt3d gfd2d ";
744mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
745kw = "nt3d";
746usage = "Displays 3D-Points (X-Y-Z) [with error-bars] from an NTuple ";
747usage += "\n Usage : nt3d nameobj varx vary varz [errx erry errz] [graphic_attributes]";
748usage += "\n Related commands: disp surf nt2d nt2dw gfd3d ";
749usage += "\n Related commands: disp surf nt2d nt2dw ";
750mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
751
752// Ceci est maintenant obsolete, on garde pour info.
753kw = "gfd2d";
754usage = "Displays Points (X-Y) with error-bars from a GeneralFit Data ";
755usage += "\n Usage : gfd2d nameobj numvarx erreur=(x y xy) [graphic_attributes]";
756usage += "\n Related commands: gfd3d nt2d nt3d ";
757usage += "\n ----- OBSOLETE: utilisez nt2d -----";
758mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
759kw = "gfd3d";
760usage = "Displays 3D-Points (X-Y-Z) with error-bars from a GeneralFit Data ";
761usage += "\n Usage : gfd3d nameobj numvarx numvary erreur=(x y z xy xz yz xyz) [graphic_attributes]";
762usage += "\n Related commands: gfd2d nt2d nt3d ";
763usage += "\n ----- OBSOLETE: utilisez nt3d -----";
764mpiac->RegisterCommand(kw, usage, this, "Obj. Display");
765
766kw = "func";
767usage = "Displays a function y=f(x) (Fills a vector with function values)";
768usage += "\n Usage: func f(x) xmin xmax npt [graphic_attributes]";
769usage += "\n Related commands: funcff func2d func2dff ";
770mpiac->RegisterCommand(kw, usage, this, "Func Plot");
771kw = "funcff";
772usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)";
773usage += "\n Usage: funcff C-FileName FunctionName xmin xmax npt [graphic_attributes]";
774usage += "\n Related commands: func func2d func2dff ";
775mpiac->RegisterCommand(kw, usage, this, "Func Plot");
776kw = "func2d";
777usage = "Displays a function z=f(x,y) (Fills a matrix with function values)";
778usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]";
779usage += "\n Related commands: func";
780mpiac->RegisterCommand(kw, usage, this, "Func Plot");
781kw = "func2dff";
782usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)";
783usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]";
784usage += "\n Related commands: func funcff func2d ";
785mpiac->RegisterCommand(kw, usage, this, "Func Plot");
786
787kw = "plot2d";
788usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :";
789usage += "\nNTuple varnames - Histo1D/HProf: i,x,val,err - Histo2D: i,j,x,y,val,err";
790usage += "\nVector: i,val - Matrix: i,j,val - Image: x=i,y=j, pix=val";
791usage += "\n Usage: plot2d nameobj f_X() g_Y() [ f_ErrX() f_ErrY() ] f_Cut() [graphic_attributes]";
792usage += "\n Related commands: plot2dw plot3d projh1d projh2d projprof fillnt fillvec fillgd1 ";
793mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
794kw = "plot2dw";
795usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Weight W=h(Object) ";
796usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() Cut() [graphic_attributes]";
797usage += "\n Related commands: plot2d projh1d projh2d projprof fillnt fillvec ";
798mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
799kw = "plot3d";
800usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) vs ";
801usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() Cut() [graphic_attributes]";
802usage += "\n Related commands: plot2d plot2dw projh1d projh2d projprof fillnt fillvec ";
803mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
804
805kw = "projh1d";
806usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram ";
807usage += "\n Usage: projh1d nameobj f_X() h_WT() Cut() nameh1d [graphic_attributes]";
808usage += "\n Histo1D nameh1d is created if necessary ";
809usage += "\n Related commands: plot2d projh2d projprof fillnt fillvec ";
810mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
811kw = "projh2d";
812usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram ";
813usage += "\n Usage: projh2d nameobj f_X() g_Y() h_WT() Cut() nameh2d [graphic_attributes]";
814usage += "\n Histo2D nameh2d is created if necessary ";
815usage += "\n Related commands: plot2d projh1d projprof ";
816mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
817kw = "projprof";
818usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram ";
819usage += "\n Usage: projh2d nameobj f_X() g_Y() h_WT() Cut() nameprof [graphic_attributes]";
820usage += "\n HProf nameprof is created if necessary ";
821usage += "\n Related commands: plot2d projh2d ";
822mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
823
824kw = "fillnt";
825usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
826usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() Cut() nameNt";
827usage += "\n Related commands: ntloop plot2d projh1d projh2d projprof ";
828mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
829kw = "ntloop";
830usage = "Loops over an Object NTupleInterface calling a function from a C-file \n";
831usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
832usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName [N1 N2] ]";
833usage += "\n Or: ntloop nameobj CFileName FuncName ! N1 N2 ";
834usage += "\n Related commands: ntexpcfile fillnt";
835mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
836kw = "ntexpcfile";
837usage = "Creates a C-File with declarations suitable to be used for ntloop";
838usage += "\n Usage: ntexpcfile nameobj CFileName FuncName ";
839usage += "\n Related commands: ntloop";
840mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
841
842kw = "fillvec";
843usage = "Creates and Fills a Vector with X=f(Object)";
844usage += "\n Usage: fillvec nameobj f_X() Cut() nameVec [graphic_attributes]";
845usage += "\n Related commands: plot2d projh1d fillnt ";
846mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
847kw = "fillgd1";
848usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))";
849usage += "\n Usage: fillgd1 nameobj f_X() g_Y() h_ErrY() Cut() nameGfd";
850usage += "\n Related commands: plot2d fillnt ";
851mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
852kw = "fillgd2";
853usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)";
854usage += "\n Usage: fillgd1 nameobj f_X() g_Y() h_Z() k_ErrZ() Cut() nameGfd";
855usage += "\n Related commands: plot2d fillgd2 ";
856mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
857
858kw = "fit";
859usage = "Fitting function to DataObjects (Histo, Histo2D, Vector, ...)";
860usage += "\n Usage: fit nomobj func [Options]";
861usage += "\n [p:p1,...,pn s:s1,...,sn m:m1,...,mn M:M1,...,Mn o:... o:...]";
862mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
863
864}
865
866/* --Methode-- */
867int PIABaseExecutor::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
868// string& func4, string& func5)
869{
870string cmd;
871
872if (dynlink) delete dynlink; dynlink = NULL;
873usfmap.clear();
874
875dynlink = new PDynLinkMgr(fnameso, true);
876if (dynlink == NULL) {
877 string sn = fnameso;
878 cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl;
879 return(2);
880 }
881
882int nok=0;
883// on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
884// DlUserProcFunction f = NULL;
885DlFunction f = NULL;
886if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
887// f = (DlUserProcFunction) dlsym(dlhandle, func1.c_str());
888f = dynlink->GetFunction(func1);
889if (f) { nok++; usfmap[func1] = f; }
890else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
891
892if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
893// f = (DlUserProcFunction) dlsym(dlhandle, func2.c_str());
894f = dynlink->GetFunction(func2);
895if (f) { nok++; usfmap[func2] = f; }
896else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
897
898if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
899// f = (DlUserProcFunction) dlsym(dlhandle, func3.c_str());
900f = dynlink->GetFunction(func3);
901if (f) { nok++; usfmap[func3] = f; }
902else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
903
904/* Pb compile g++ 2.7.2
905if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") ) goto fin;
906// f = (DlUserProcFunction) dlsym(dlhandle, func4.c_str());
907f = dynlink->GetFunction(func4);
908if (f) { nok++; usfmap[func4] = f; }
909else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
910
911if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") ) goto fin;
912// f = (DlUserProcFunction) dlsym(dlhandle, func5.c_str());
913f = dynlink->GetFunction(func5);
914if (f) { nok++; usfmap[func5] = f; }
915else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
916*/
917fin:
918if (nok < 1) { if (dynlink) delete dynlink; dynlink = NULL; return(3); }
919else return(0);
920}
921
Note: See TracBrowser for help on using the repository browser.