source: Sophya/trunk/SophyaPI/PIext/servnobjm.cc@ 376

Last change on this file since 376 was 368, checked in by ercodmgr, 26 years ago

modifs Fenetre de fit et gestion repertoire /func Reza 9/8/99

File size: 40.5 KB
Line 
1#include <stdio.h>
2#include <stdlib.h>
3#include <ctype.h>
4
5#include <typeinfo>
6#include <iostream.h>
7#include <string>
8#include <list>
9#include <map>
10#if defined(__KCC__)
11using std::string ;
12#include <list.h>
13#include <map.h>
14#endif
15
16#include "strutil.h"
17
18#include "nobjmgr.h"
19#include "servnobjm.h"
20#include "nomgadapter.h"
21#include "pistdimgapp.h"
22
23#include "fct1dfit.h"
24#include "fct2dfit.h"
25
26#include "matrix.h"
27#include "cvector.h"
28#include "ntuple.h"
29#include "cimage.h"
30
31#include "histos.h"
32#include "histos2.h"
33#include "ntuple.h"
34#include "hisprof.h"
35
36#include "piscdrawwdg.h"
37#include "pisurfdr.h"
38
39#include "pintuple.h"
40#include "pintup3d.h"
41
42#include "pipodrw.h"
43
44
45
46/* --Methode-- */
47Services2NObjMgr::Services2NObjMgr(NamedObjMgr* omg, string& tmpdir)
48{
49TmpDir = tmpdir;
50PDynLinkMgr::SetTmpDir(tmpdir);
51mImgapp = NULL;
52mOmg = omg;
53dynlink = NULL;
54InitGrAttNames();
55}
56
57/* --Methode-- */
58Services2NObjMgr::~Services2NObjMgr()
59{
60CloseDLL();
61}
62
63/* --Methode-- */
64void Services2NObjMgr::RegisterClass(AnyDataObj* o, NObjMgrAdapter* oa)
65{
66ObjAdaptList::iterator it;
67for(it = objadaplist.begin(); it != objadaplist.end(); it++)
68 if (typeid(*o) == typeid(*((*it).obj))) THROW(dupIdErr);
69
70dataobj_adapter oba;
71oba.obj = o;
72oba.obja = oa;
73objadaplist.push_back(oba);
74}
75
76/* --Methode-- */
77NObjMgrAdapter* Services2NObjMgr::GetAdapter(AnyDataObj* o)
78{
79ObjAdaptList::iterator it;
80for(it = objadaplist.begin(); it != objadaplist.end(); it++)
81 if (typeid(*o) == typeid(*((*it).obj))) return((*it).obja->Clone(o));
82return(new NObjMgrAdapter(o));
83}
84
85/* --Methode-- */
86void Services2NObjMgr::PlotFunc(string const & expfunc, string & nom, double xmin, double xmax, int np, string dopt)
87{
88FILE *fip;
89string fname = TmpDir + "func1_pia_dl.c";
90string cmd;
91int rc;
92
93if (!mImgapp) return;
94
95cmd = "rm -f " + fname;
96rc = system(cmd.c_str());
97// printf("PlotFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
98
99if ((fip = fopen(fname.c_str(), "w")) == NULL) {
100 string sn = fname;
101 cout << "Services2NObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl;
102 return;
103 }
104
105// constitution du fichier a compiler
106fputs("#include <math.h> \n", fip);
107fputs("double func1_pia_dl_func(double x) \n{\n", fip);
108fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
109fclose(fip);
110
111string func = "func1_pia_dl_func";
112DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
113if (!f) return;
114PlotFunc(f, nom, xmin, xmax, np, dopt);
115CloseDLL();
116return;
117}
118
119/* --Methode-- */
120void Services2NObjMgr::PlotFunc2D(string const & expfunc, string & nom, double xmin, double xmax,
121 double ymin, double ymax, int npx, int npy, string dopt)
122{
123FILE *fip;
124string fname = TmpDir + "func2_pia_dl.c";
125string cmd;
126int rc;
127
128if (!mImgapp) return;
129
130cmd = "rm " + fname;
131rc = system(cmd.c_str());
132// printf("PlotFunc2D_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
133
134if ((fip = fopen(fname.c_str(), "w")) == NULL) {
135 string sn = fname;
136 cout << "Services2NObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl;
137 return;
138 }
139
140// constitution du fichier a compiler
141fputs("#include <math.h> \n", fip);
142fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
143fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
144fclose(fip);
145
146string func = "func2_pia_dl_func";
147DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
148if (!f) return;
149PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
150CloseDLL();
151return;
152}
153
154/* --Methode-- */
155void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, string & nom,
156 double xmin, double xmax, int np, string dopt)
157{
158DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
159if (!f) return;
160PlotFunc(f, nom, xmin, xmax, np, dopt);
161CloseDLL();
162return;
163}
164
165/* --Methode-- */
166void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, string & nom,
167 double xmin, double xmax, double ymin, double ymax, int npx, int npy, string dopt)
168{
169DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
170if (!f) return;
171PlotFunc2D(f, nom, xmin, xmax, ymin, ymax, npx, npy, dopt);
172CloseDLL();
173return;
174}
175
176/* --Methode-- */
177void Services2NObjMgr::PlotFunc(DlFunctionOfX f, string & nom, double xmin, double xmax, int np, string dopt)
178{
179if (!mImgapp) return;
180
181int k;
182if (np < 1) np = 1;
183if (xmax <= xmin) xmax = xmin+1.;
184Vector* vpy = new Vector(np);
185
186double xx;
187double dx = (xmax-xmin)/np;
188TRY {
189 for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
190} CATCH(merr) {
191 fflush(stdout);
192 cout << endl;
193 cerr << endl;
194 string es = PeidaExc(merr);
195 cerr << "Services2NObjMgr::PlotFunc() Exception :" << merr << es;
196 delete vpy;
197 vpy = NULL;
198 } ENDTRY;
199
200
201if (vpy) {
202 string titre;
203 if (nom.length() < 1) {
204 titre = "Function f(x)";
205 nom = "/func/f_x";
206 }
207 else titre = nom;
208
209 P1DArrayAdapter* vya = new POVectorAdapter(vpy, false);
210 vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
211 PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ;
212 bool fgsr = true;
213 dopt = "thinline," + dopt;
214 int opt = DecodeDispOption(dopt, fgsr);
215 int rsid = mImgapp->DispScDrawer(dr, titre, opt);
216 if (fgsr) mImgapp->RestoreGraphicAtt();
217 if (nom.length() > 0) {
218 mOmg->AddObj(vpy, nom);
219 mOmg->AddWRsId(nom, rsid);
220 }
221 }
222
223return;
224}
225
226/* --Methode-- */
227void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, string & nom, double xmin, double xmax, double ymin, double ymax,
228 int npx, int npy, string dopt)
229{
230if (!mImgapp) return;
231
232if (npx < 3) npx = 3;
233if (npy < 3) npy = 3;
234if (npx > 250) npx = 250;
235if (npy > 250) npy = 250;
236if (xmax <= xmin) xmax = xmin+1.;
237if (ymax <= ymin) ymax = ymin+1.;
238
239Matrix* mtx = new Matrix(npy, npx);
240
241int i,j;
242double xx, yy;
243double dx = (xmax-xmin)/npx;
244double dy = (ymax-ymin)/npy;
245// printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
246TRY {
247 for(j=0; j<npy; j++) {
248 yy = ymin+dy*j;
249 for(i=0; i<npx; i++) {
250 xx = xmin+dx*i;
251 (*mtx)(j, i) = f(xx, yy);
252 }
253 }
254} CATCH(merr) {
255 fflush(stdout);
256 cout << endl;
257 cerr << endl;
258 string es = PeidaExc(merr);
259 cerr << "Services2NObjMgr::PlotFunc2D() Exception :" << merr << es;
260 delete mtx; mtx = NULL;
261 } ENDTRY;
262
263if (mtx) {
264 string titre;
265 if (nom.length() < 1) {
266 titre = "Function f(x,y)";
267 nom = "/func/f2d_xy";
268 }
269 else titre = nom;
270 bool fgsr = true;
271 int opt = DecodeDispOption(dopt, fgsr);
272 P2DArrayAdapter* arr = new POMatrixAdapter(mtx, false);
273 arr->DefineXYCoordinates(xmin, ymin, dx, dy);
274 PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
275 int rsid = mImgapp->Disp3DDrawer(sdr, titre, opt);
276 if (fgsr) mImgapp->RestoreGraphicAtt();
277 if (nom.length() > 0) {
278 mOmg->AddObj(mtx, nom);
279 mOmg->AddWRsId(nom, rsid);
280 }
281 }
282
283return;
284}
285
286/* --Methode-- */
287void Services2NObjMgr::DisplayPoints2D(string& nom, string& expx, string& expy,
288 string& experrx, string& experry,
289 string& expcut, string dopt, string loop)
290{
291NObjMgrAdapter* obja=NULL;
292obja = mOmg->GetObjAdapter(nom);
293if (obja == NULL) {
294 cout << "Services2NObjMgr::DisplayPoints2D() Error , Pas d'objet de nom " << nom << endl;
295 return;
296 }
297if (!mImgapp) return;
298
299// Creation NTuple
300char* ntn[4] = {"expx","expy","expex","expey",};
301NTuple* nt = NULL;
302bool haserr = false;
303
304if ( (experrx.length() > 0 ) && (experry.length() > 0 ) ) { haserr = true; nt = new NTuple(4, ntn); }
305else { haserr = false; experrx = experry = "0."; nt = new NTuple(2, ntn); }
306
307ComputeExpressions(obja, expx, expy, experrx, experry, expcut, loop, nt, NULL, NULL);
308
309if (nt->NEntry() < 1) {
310 cout << "Services2NObjMgr::DisplayPoints2D() Warning Zero points satisfy cut !" << endl;
311 delete nt;
312 return;
313 }
314
315// nt->Show();
316// nt->Print(0,10);
317PINTuple* pin = new PINTuple(nt, true);
318pin->SelectXY(ntn[0], ntn[1]);
319if ( haserr ) pin->SelectErrBar(ntn[2], ntn[3]);
320
321bool fgsr = true;
322dopt = "defline," + dopt;
323int opt = DecodeDispOption(dopt, fgsr);
324string titre = nom + ":" + expy + "%" + expx;
325mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
326if (fgsr) mImgapp->RestoreGraphicAtt();
327return;
328}
329
330/* --Methode-- */
331void Services2NObjMgr::DisplayPoints3D(string& nom, string& expx, string& expy,
332 string& expz, string& expcut, string dopt, string loop)
333{
334NObjMgrAdapter* obja=NULL;
335obja = mOmg->GetObjAdapter(nom);
336if (obja == NULL) {
337 cout << "Services2NObjMgr::DisplayPoints3D() Error , Pas d'objet de nom " << nom << endl;
338 return;
339 }
340if (!mImgapp) return;
341
342char* ntn[3] = {"expx","expy","expz"};
343NTuple* nt = new NTuple(3,ntn); // Creation NTuple
344
345string expwt = "1.";
346ComputeExpressions(obja, expx, expy, expz, expwt, expcut, loop, nt, NULL, NULL);
347
348if (nt->NEntry() < 1) {
349 cout << "Services2NObjMgr::DisplayPoints3D() Warning Zero points satisfy cut !" << endl;
350 delete nt;
351 return;
352 }
353nt->Show();
354nt->Print(0,10);
355PINTuple3D* pin = new PINTuple3D(nt, true);
356pin->SelectXYZ(ntn[0], ntn[1], ntn[2]);
357bool fgsr = true;
358dopt = "defline," + dopt;
359int opt = DecodeDispOption(dopt, fgsr);
360
361// Pour plot a partir de DispScDrawer
362// string nomdisp = "_NT3D_";
363// mImgapp->DispScDrawer( (PIDrawer*)pin, nomdisp, opt);
364// Pour plot a partir de Disp3DDrawer
365string titre = nom + ":" + expy + "%" + expx;
366mImgapp->Disp3DDrawer(pin, titre, opt);
367
368if (fgsr) mImgapp->RestoreGraphicAtt();
369return;
370}
371
372/* --Methode-- */
373void Services2NObjMgr::DisplayPoints2DW(string& nom, string& expx, string& expy,
374 string& expwt, string& expcut, string dopt, string loop)
375{
376NObjMgrAdapter* obja=NULL;
377obja = mOmg->GetObjAdapter(nom);
378if (obja == NULL) {
379 cout << "Services2NObjMgr::DisplayPoints2DW() Error , Pas d'objet de nom " << nom << endl;
380 return;
381 }
382if (!mImgapp) return;
383
384char* ntn[3] = {"expx","expy","expw"};
385NTuple* nt = new NTuple(3,ntn); // Creation NTuple
386
387string exp = "1.";
388ComputeExpressions(obja, expx, expy, expwt, exp, expcut, loop, nt, NULL, NULL);
389
390if (nt->NEntry() < 1) {
391 cout << "Services2NObjMgr::DisplayPoints2DW() Warning Zero points satisfy cut !" << endl;
392 delete nt;
393 return;
394 }
395
396PINTuple* pin = new PINTuple(nt, true);
397pin->SelectXY(ntn[0], ntn[1]);
398pin->SelectWt(ntn[2]);
399
400bool fgsr = true;
401int opt = DecodeDispOption(dopt, fgsr);
402string titre = nom + ":" + expwt + "_" + expy + "%" + expx ;
403mImgapp->DispScDrawer( (PIDrawer*)pin, titre, opt);
404if (fgsr) mImgapp->RestoreGraphicAtt();
405return;
406}
407
408/* --Methode-- */
409void Services2NObjMgr::ProjectH1(string& nom, string& expx, string& expwt,
410 string& expcut, string& nomh1, string dopt, string loop)
411{
412NObjMgrAdapter* obja=NULL;
413obja = mOmg->GetObjAdapter(nom);
414if (obja == NULL) {
415 cout << "Services2NObjMgr::ProjectH1() Error , Pas d'objet de nom " << nom << endl;
416 return;
417 }
418if (!mImgapp) return;
419
420Histo* h1 = NULL;
421NTuple* nt = NULL;
422AnyDataObj* oh = NULL;
423if (nomh1.length() > 0) oh=mOmg->GetObj(nomh1);
424else nomh1 = "/tmp/projh1d";
425if ( (oh != NULL) && (typeid(*oh) == typeid(Histo)) ) h1 = (Histo*)oh; // Pas de remise a zero ! h1->Zero();
426else {
427 char* ntn[2]= {"hxval", "hwt"};
428 nt = new NTuple(2,ntn); // Creation NTuple
429 }
430string expz = "0.";
431ComputeExpressions(obja, expx, expwt, expz, expwt, expcut, loop, nt, h1, NULL);
432
433if ((!h1) && (!nt)) return;
434if (!h1) {
435 if (nt->NEntry() < 1) {
436 cout << "Services2NObjMgr::ProjectH1() Warning Zero points satisfy cut !" << endl;
437 delete nt;
438 return;
439 }
440 double xmin, xmax;
441 nt->GetMinMax(0, xmin, xmax);
442 h1 = new Histo(xmin, xmax, 100);
443 int k;
444 float* xn;
445 for(k=0; k<nt->NEntry(); k++) {
446 xn = nt->GetVec(k);
447 h1->Add(xn[0], xn[1]);
448 }
449 delete nt;
450 mOmg->AddObj(h1, nomh1);
451 }
452
453mOmg->DisplayObj(nomh1, dopt);
454return;
455}
456
457/* --Methode-- */
458void Services2NObjMgr::ProjectH2(string& nom, string& expx, string& expy, string& expwt,
459 string& expcut, string& nomh2, string dopt, string loop)
460{
461NObjMgrAdapter* obja=NULL;
462obja = mOmg->GetObjAdapter(nom);
463if (obja == NULL) {
464 cout << "Services2NObjMgr::ProjectH2() Error , Pas d'objet de nom " << nom << endl;
465 return;
466 }
467if (!mImgapp) return;
468
469Histo2D* h2 = NULL;
470NTuple* nt = NULL;
471AnyDataObj* oh = NULL;
472if (nomh2.length() > 0) oh=mOmg->GetObj(nomh2);
473else nomh2 = "/tmp/projh2d";
474if ( (oh != NULL) && (typeid(*oh) == typeid(Histo2D)) ) h2 = (Histo2D*)oh; // Pas de remise a zero ! h2->Zero();
475else {
476 char* ntn[3]= {"hxval", "hyval", "hwt"};
477 nt = new NTuple(3,ntn); // Creation NTuple
478 }
479string expz = "0.";
480ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, h2);
481
482if ((!h2) && (!nt)) return;
483if (!h2) {
484 if (nt->NEntry() < 1) {
485 cout << "Services2NObjMgr::ProjectH2() Warning Zero points satisfy cut !" << endl;
486 delete nt;
487 return;
488 }
489 double xmin, xmax, ymin, ymax;
490 nt->GetMinMax(0, xmin, xmax);
491 nt->GetMinMax(0, ymin, ymax);
492 h2 = new Histo2D(xmin, xmax, 50, ymin, ymax, 50);
493 int k;
494 float* xn;
495 for(k=0; k<nt->NEntry(); k++) {
496 xn = nt->GetVec(k);
497 h2->Add(xn[0], xn[1], xn[2]);
498 }
499 delete nt;
500 mOmg->AddObj(h2, nomh2);
501 }
502
503mOmg->DisplayObj(nomh2, dopt);
504return;
505
506}
507
508/* --Methode-- cmv 13/10/98 */
509void Services2NObjMgr::ProjectHProf(string& nom, string& expx, string& expy, string& expwt,
510 string& expcut, string& nomprof, string dopt, string loop)
511// Pour remplir un ``GeneralFitData'' a partir de divers objets:
512//| nom = nom de l'objet a projeter dans un HProf.
513//| expx = expression X de definition du bin.
514//| expy = expression Y a additionner dans le bin.
515//| expwt = expression W du poids a additionner.
516//| expcut = expression du test de selection.
517//| nomprof = nom du HProf engendre (optionnel). Si l'objet n'existe pas
518//| les limites Xmin,Xmax sont calculees automatiquement.
519//| sinon ce sont celles de l'objet preexistant.
520//| opt = options generales pour le display.
521{
522NObjMgrAdapter* obja=NULL;
523obja = mOmg->GetObjAdapter(nom);
524if (obja == NULL) {
525 cout << "Services2NObjMgr::ProjectHProf() Error , Pas d'objet de nom " << nom << endl;
526 return;
527 }
528if (!mImgapp) return;
529
530HProf* hprof = NULL;
531NTuple* nt = NULL;
532AnyDataObj* oh = NULL;
533if (nomprof.length() > 0) oh=mOmg->GetObj(nomprof);
534else nomprof = "/tmp/projprof";
535if( (oh!=NULL) && (typeid(*oh) == typeid(HProf)) ) hprof = (HProf*)oh;
536else {
537 char* ntn[3]= {"hxval", "hyval", "hwt"};
538 nt = new NTuple(3,ntn); // Creation NTuple
539}
540string expz = "0.";
541ComputeExpressions(obja, expx, expy, expwt, expwt, expcut, loop, nt, NULL, NULL, hprof);
542
543if((!hprof) && (!nt)) return;
544if(!hprof) {
545 if (nt->NEntry() < 1) {
546 cout << "Services2NObjMgr::ProjectHProf() Warning Zero points satisfy cut !" << endl;
547 delete nt;
548 return;
549 }
550 double xmin, xmax;
551 nt->GetMinMax(0, xmin, xmax);
552 hprof = new HProf(xmin, xmax, 100);
553 int k;
554 float* xn;
555 for(k=0; k<nt->NEntry(); k++) {
556 xn = nt->GetVec(k);
557 hprof->Add(xn[0], xn[1], xn[2]);
558 }
559 delete nt;
560 mOmg->AddObj(hprof, nomprof);
561 }
562hprof->UpdateHisto();
563
564mOmg->DisplayObj(nomprof, dopt);
565return;
566}
567
568
569/* --Methode-- */
570void Services2NObjMgr::FillVect(string& nom, string& expx, string& expv,
571 string& expcut, string& nomvec, string dopt, string loop)
572{
573NObjMgrAdapter* obja=NULL;
574obja = mOmg->GetObjAdapter(nom);
575if (obja == NULL) {
576 cout << "Services2NObjMgr::FillVect() Error , No such object: " << nom << endl;
577 return;
578 }
579if (!mImgapp) return;
580
581Vector* v1 = NULL;
582AnyDataObj* ov = NULL;
583ov=mOmg->GetObj(nomvec);
584if (ov != NULL) v1 = dynamic_cast<Vector *>(ov);
585if (v1 == NULL) {
586 cout << "Services2NObjMgr::FillVect() Error , No such object or not a vector: " << nomvec << endl;
587 return;
588 }
589
590char* ntn[2]= {"vi", "vv"};
591NTuple* nt = new NTuple(2,ntn); // Creation NTuple
592
593string expz = "0.";
594ComputeExpressions(obja, expx, expv, expz, expz, expcut, loop, nt);
595
596if (!nt) return;
597if (nt->NEntry() < 1) {
598 cout << "Services2NObjMgr::FillVect() Warning Zero points satisfy cut !" << endl;
599 delete nt;
600 return;
601 }
602
603 int i,k;
604 double* xn;
605 for(k=0; k<nt->NEntry(); k++) {
606 xn = nt->GetLineD(k);
607 i = xn[0]+0.5;
608 if ( (i < 0) || i >= v1->NElts() ) continue;
609 (*v1)(i) = xn[1];
610 }
611 delete nt;
612
613
614mOmg->DisplayObj(nomvec, dopt);
615return;
616}
617
618/* --Methode-- */
619void Services2NObjMgr::FillMatx(string& nom, string& expx, string& expy, string& expv,
620 string& expcut, string& nommtx, string dopt, string loop)
621{
622NObjMgrAdapter* obja=NULL;
623obja = mOmg->GetObjAdapter(nom);
624if (obja == NULL) {
625 cout << "Services2NObjMgr::FillMatx() Error , No such objet " << nom << endl;
626 return;
627 }
628if (!mImgapp) return;
629
630Matrix* mtx = NULL;
631AnyDataObj* om = NULL;
632om=mOmg->GetObj(nommtx);
633if (om != NULL) mtx = dynamic_cast<Matrix *>(om);
634if (mtx == NULL) {
635 cout << "Services2NObjMgr::FillMatx() Error , No such object or not a matrix " << nommtx << endl;
636 return;
637 }
638
639char* ntn[3]= {"mi", "mj", "mv"};
640NTuple* nt = new NTuple(3,ntn); // Creation NTuple
641
642string expz = "0.";
643ComputeExpressions(obja, expx, expy, expv, expz, expcut, loop, nt);
644
645if (!nt) return;
646if (nt->NEntry() < 1) {
647 cout << "Services2NObjMgr::FillMatx() Warning Zero points satisfy cut !" << endl;
648 delete nt;
649 return;
650 }
651
652 int ic, jl, k;
653 double* xn;
654 for(k=0; k<nt->NEntry(); k++) {
655 xn = nt->GetLineD(k);
656 ic = xn[0]+0.5;
657 jl = xn[1]+0.5;
658 if ( (ic < 0) || ic >= mtx->NCol() ) continue;
659 if ( (jl < 0) || jl >= mtx->NRows() ) continue;
660 (*mtx)(jl, ic) = xn[2];
661 }
662 delete nt;
663
664
665mOmg->DisplayObj(nommtx, dopt);
666return;
667
668}
669
670/* --Methode-- */
671void Services2NObjMgr::ExpressionToVector(string& nom, string& expx, string& expcut,
672 string& nomvec, string dopt, string loop)
673{
674NObjMgrAdapter* obja=NULL;
675obja = mOmg->GetObjAdapter(nom);
676if (obja == NULL) {
677 cout << "Services2NObjMgr::ExpressionToVector() Error , Pas d'objet de nom " << nom << endl;
678 return;
679 }
680if (!mImgapp) return;
681
682NTuple* nt = NULL;
683if (nomvec.length() < 1) nomvec = "/tmp/expvec";
684
685char* ntn[2]= {"vecval", "vecwt"};
686nt = new NTuple(1,ntn); // Creation NTuple
687
688string expwt = "1.";
689string expz = "0.";
690ComputeExpressions(obja, expx, expz, expz, expwt, expcut, loop, nt, NULL, NULL);
691
692if (!nt) return;
693if (nt->NEntry() < 1) {
694 cout << "Services2NObjMgr::ExpressionToVector() Warning Zero points satisfy cut !" << endl;
695 delete nt;
696 return;
697 }
698
699Vector* vec = new Vector(nt->NEntry());
700int k;
701float* xn;
702for(k=0; k<nt->NEntry(); k++) {
703 xn = nt->GetVec(k);
704 (*vec)(k) = xn[0];
705 }
706delete nt;
707mOmg->AddObj(vec, nomvec);
708mOmg->DisplayObj(nomvec, dopt);
709return;
710}
711
712/* --Methode-- */
713void Services2NObjMgr::FillNT(string& nom, string& expx, string& expy, string& expz,
714 string& expt, string& expcut, string& nomnt, string loop)
715{
716NObjMgrAdapter* obja=NULL;
717obja = mOmg->GetObjAdapter(nom);
718if (obja == NULL) {
719 cout << "Services2NObjMgr::FillNT() Error , Pas d'objet de nom " << nom << endl;
720 return;
721 }
722if (!mImgapp) return;
723
724bool fgnnt = false;
725NTuple* nt = NULL;
726AnyDataObj* oh = NULL;
727if (nomnt.length() > 0) oh=mOmg->GetObj(nomnt);
728else nomnt = "/tmp/fillnt";
729if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
730 nt = (NTuple*)oh;
731 if (nt->NVar() > 10) {
732 cout << "Services2NObjMgr::FillNT() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
733 nt = NULL;
734 }
735 }
736if (nt == NULL) {
737 char* ntn[4]= {"x", "y","z","t"};
738 nt = new NTuple(4,ntn); // Creation NTuple
739 fgnnt = true;
740 }
741
742ComputeExpressions(obja, expx, expy, expz, expt, expcut, loop, nt, NULL, NULL);
743
744if (fgnnt) mOmg->AddObj(nt, nomnt);
745return;
746
747}
748
749/* --Methode-- */
750void Services2NObjMgr::FillNTFrCFile(string & nom, string const & fname,
751 string const & funcname, string & nomnt, string loop)
752{
753if (!mImgapp) return;
754
755NObjMgrAdapter* obja=NULL;
756obja = mOmg->GetObjAdapter(nom);
757if (obja == NULL) {
758 cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No such object" <<endl;
759 return;
760 }
761bool adel = true;
762NTupleInterface* objnt = obja->GetNTupleInterface(adel);
763if (objnt == NULL) {
764 cout << "Services2NObjMgr::FillNTFrCFile( " << nom << "...) No NTupleInterface !" <<endl;
765 return;
766 }
767
768NTLoopExprFunc f = (NTLoopExprFunc)LinkFunctionFromFile(fname, funcname);
769if (!f) {
770 cerr << "Services2NObjMgr::FillNTFrCFile Error Creation NTLoopExprFunc" << endl;
771 if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
772 return;
773 }
774
775bool fgnnt = false;
776NTuple* nt = NULL;
777if (nomnt.length() > 0) {
778 AnyDataObj* oh = NULL;
779 oh=mOmg->GetObj(nomnt);
780 if ( (oh != NULL) && (typeid(*oh) == typeid(NTuple)) ) {
781 nt = (NTuple*)oh;
782 if (nt->NVar() > 10) {
783 cout << "Services2NObjMgr::FillNTFrCFile() Warning , Max 10 var ds NTuple -> new NTuple" << endl;
784 nt = NULL;
785 }
786 }
787 if (nt == NULL) {
788 char* ntn[4]= {"x", "y","z","t"};
789 nt = new NTuple(4,ntn); // Creation NTuple
790 fgnnt = true;
791 }
792 }
793
794double xnt[10];
795float fxnt[10];
796
797int i,k;
798for(i=0; i<10; i++) fxnt[i] = xnt[i] = 0.;
799
800
801// $CHECK$ A virer des que possible - Pb blocage application quand trop d'impression
802// redirige - On redirige la sortie sur le terminal
803bool red = mImgapp->HasRedirectedStdOutErr();
804mImgapp->RedirectStdOutErr(false);
805
806int k1,k2,dk;
807k1 = 0; k2 = objnt->NbLines(); dk = 1;
808DecodeLoopParameters(loop, k1, k2, dk);
809if (k1 < 0) k1 = 0;
810if (k2 < 0) k2 = objnt->NbLines();
811if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
812if (dk <= 0) dk = 1;
813
814TRY {
815 double* xn;
816 int kmax = k2;
817 for(k=k1; k<kmax; k+=dk) {
818 xn = objnt->GetLineD(k);
819 if (f(xn, xnt, xnt+1, xnt+2, xnt+3, k, kmax) != 0) {
820 if (nt) {
821 for(i=0; i<4; i++) fxnt[i] = xnt[i];
822 nt->Fill(fxnt);
823 }
824 }
825 }
826 }
827CATCH(merr) {
828 fflush(stdout);
829 cout << endl;
830 cerr << endl;
831 string es = PeidaExc(merr);
832 cerr << "Services2NObjMgr::FillNTFrCFile() Exception :" << merr << es;
833 } ENDTRY;
834
835if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
836CloseDLL();
837
838// $CHECK$ A virer des que possible On redirige la sortie sur la fenetre PIConsole
839mImgapp->RedirectStdOutErr(red);
840
841if (fgnnt) mOmg->AddObj(nt, nomnt);
842return;
843}
844
845/* --Methode-- */
846void Services2NObjMgr::PrepareNTExpressionCFile(string & nom, string const & fname,
847 string const & funcname)
848{
849NObjMgrAdapter* obja=NULL;
850obja = mOmg->GetObjAdapter(nom);
851if (obja == NULL) {
852 cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom << "...) No such object" <<endl;
853 return;
854 }
855bool adel = true;
856NTupleInterface* objnt = obja->GetNTupleInterface(adel);
857if (objnt == NULL) {
858 cout << "Services2NObjMgr::PrepareNTExpressionCFile( " << nom
859 << "...) No NTupleInterface !" <<endl;
860 return;
861 }
862string vardec = objnt->VarList_C("_xnti_");
863
864FILE *fip;
865if ((fip = fopen(fname.c_str(), "w")) == NULL) {
866 cout << "Services2NObjMgr::PrepareNTExpressionCFile()_Error: fopen " << fname << endl;
867 if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
868 return;
869 }
870
871// constitution du fichier des decalarations des variables de l'interface NTuple
872fputs("#include <stdlib.h> \n", fip);
873fputs("#include <stdio.h> \n", fip);
874fputs("#include <math.h> \n\n", fip);
875
876fputs("/* ------ Some random number generators --------- */ \n", fip);
877fputs("#define frand01() ( (float) drand48() ) \n", fip);
878fputs("#define drand01() drand48() \n", fip);
879fputs("#define rand01() drand48() \n", fip);
880fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
881fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
882fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
883fputs("double NorRand(void) \n", fip);
884fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
885fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
886fputs(" x = sqrt(-2.*log(A))*cos(2.*M_PI*B); \n", fip);
887fputs(" return(x); \n } \n", fip);
888fputs("#define GauRand() NorRand() \n", fip);
889fputs("#define gaurand() NorRand() \n\n", fip);
890
891fputs("/* NTupleInterface Variable declaration - Generated by piapp \n", fip);
892fputs(" -- Services2NObjMgr::PrepareNTExpressionCFile() -- */ \n\n", fip);
893fprintf(fip,"int %s(double* _xnti_, double* _rx_, double* _ry_, double* _rz_, \n",
894 funcname.c_str());
895fprintf(fip," double* _rt_, int _n_, int _nmax_) \n");
896fprintf(fip, "{ \n %s \n", vardec.c_str());
897fputs(" if (!1) { /* Cut Expression failed */ \n", fip);
898fputs(" *_rx_ = *_ry_ = *_rz_ = *_rt_ = 0.; return(0);", fip);
899fputs(" } \n /* Cut expression satisfied */ \n", fip);
900fputs(" *_rx_ = 1.; \n *_ry_ = 1.; \n *_rz_ = 1.; \n *_rt_ = 1.; \n", fip);
901fputs(" return(1); \n} \n", fip);
902
903fclose(fip);
904
905if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
906return;
907}
908
909
910/* --Methode-- cmv 13/10/98 */
911void Services2NObjMgr::FillGFD(string& nom, string& expx, string& expy, string& expz,
912 string& experr, string& expcut, string& nomgfd, string loop)
913// Pour remplir un ``GeneralFitData'' a partir de divers objets:
914//| nom = nom de l'objet a transcrire selon 1D: Z=f(X) ou 2D: Z=f(X,Y) .
915//| Vector,Matrix,Histo,HProf,Histo2D,Image<T>,StarList,NTuple,GeneralFitData
916//| expx = expression X du GeneralFitData (1er abscisse)
917//| expy = expression Y du GeneralFitData (2sd abscisse si non "", Z=f(X,Y))
918//| expz = expression Z du GeneralFitData (valeur de l'ordonnee)
919//| experr = expression de l'erreur sur l'ordonnee Z
920//| expcut = expression du test de selection
921//| nomgfd = nom du GeneralFitData engendre (optionnel)
922{
923NObjMgrAdapter* obja=NULL;
924obja = mOmg->GetObjAdapter(nom);
925if (obja == NULL) {
926 cout << "Services2NObjMgr::FillGFD() Error , Pas d'objet de nom "<<nom<<endl;
927 return;
928 }
929if(!mImgapp) return;
930
931// 2D ou 3D?
932int nvar = 2;
933if(expy.length()<=0) {nvar = 1; expy = "0.";}
934
935// Creation NTuple Buffer
936char* ntn[4]= {"x","y","f","e"};
937NTuple*nt = new NTuple(4,ntn);
938
939// Remplissage NTuple buffer
940ComputeExpressions(obja, expx, expy, expz, experr, expcut, loop, nt, NULL, NULL);
941if(nt->NEntry() < 1)
942 {cout<<"Services2NObjMgr::FillGFD() Warning Zero points satisfy cut !"<<endl;
943 delete nt; return;}
944
945//Remplissage de la structure GeneraFitData
946if (nt->NEntry() <= 0) {
947 cout<<"Services2NObjMgr::FillGFD() Warning - NData= " << nt->NEntry() << endl;
948 delete nt;
949 return;
950 }
951
952GeneralFitData* gfd = new GeneralFitData(nvar,nt->NEntry(),0);
953int k;
954float* xn;
955for(k=0; k<nt->NEntry(); k++) {
956 xn = nt->GetVec(k);
957 gfd->AddData(xn,xn[2],xn[3]);
958}
959
960// Menage et table d'objets
961delete nt;
962mOmg->AddObj(gfd, nomgfd);
963return;
964}
965
966
967/* --Methode-- */
968void Services2NObjMgr::ComputeExpressions(NObjMgrAdapter* obja, string& expx,
969 string& expy, string& expz, string& expt, string& expcut, string& loop,
970 NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
971{
972if (obja == NULL) return;
973bool adel = true;
974NTupleInterface* objnt = obja->GetNTupleInterface(adel);
975if (objnt == NULL) return;
976string vardec = objnt->VarList_C("_zz6qi_");
977
978PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expt, expcut);
979if (!f) {
980 cerr << "Services2NObjMgr::::ComputeExpressions() Error Creation PlotExprFunc " << endl;
981 if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
982 return;
983 }
984
985double xnt[10];
986float fxnt[10];
987
988int i,k;
989for(i=0; i<10; i++) xnt[i] = 0.;
990int k1,k2,dk;
991k1 = 0; k2 = objnt->NbLines(); dk = 1;
992DecodeLoopParameters(loop, k1, k2, dk);
993if (k1 < 0) k1 = 0;
994if (k2 < 0) k2 = objnt->NbLines();
995if (k2 > objnt->NbLines()) k2 = objnt->NbLines();
996if (dk <= 0) dk = 1;
997TRY {
998 double* xn;
999 for(k=k1; k<k2; k += dk) {
1000 xn = objnt->GetLineD(k);
1001 if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
1002 if (nt) {
1003 for(i=0; i<4; i++) fxnt[i] = xnt[i];
1004 nt->Fill(fxnt);
1005 }
1006 if (h1) h1->Add(xnt[0], xnt[3]);
1007 if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
1008 if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
1009 }
1010 }
1011 }
1012CATCH(merr) {
1013 fflush(stdout);
1014 cout << endl;
1015 cerr << endl;
1016 string es = PeidaExc(merr);
1017 cerr << "Services2NObjMgr::ComputeExpressions() Exception :" << merr << es;
1018 } ENDTRY;
1019
1020
1021if (adel) delete objnt; // Delete de l'objet NTupleInterface si necessaire
1022// Fermeture du fichier .so
1023CloseDLL();
1024return;
1025}
1026
1027
1028/* --Methode-- */
1029PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy,
1030 string& expz, string& expt, string& cut)
1031{
1032FILE *fip;
1033string fname = TmpDir + "expf_pia_dl.c";
1034string cmd;
1035int rc;
1036
1037cmd = "rm -f " + fname;
1038rc = system(cmd.c_str());
1039//DBG printf("LinkExprFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
1040
1041if ((fip = fopen(fname.c_str(), "w")) == NULL) {
1042 string sn = fname;
1043 cout << "Services2NObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl;
1044 return(NULL);
1045 }
1046
1047// constitution du fichier a compiler
1048fputs("#include <stdlib.h> \n", fip);
1049fputs("#include <math.h> \n", fip);
1050
1051fputs("/* ------ Some random number generators --------- */ \n", fip);
1052fputs("#define frand01() ( (float) drand48() ) \n", fip);
1053fputs("#define drand01() drand48() \n", fip);
1054fputs("#define rand01() drand48() \n", fip);
1055fputs("#define frandpm1() ( 2. * frand01() - 1.) \n", fip);
1056fputs("#define drandpm1() ( 2. * drand01() - 1.) \n", fip);
1057fputs("#define randpm1() ( 2. * drand01() - 1.) \n", fip);
1058fputs("double NorRand(void) \n", fip);
1059fputs(" { \n double x,A,B; \n LAB10: \n A = drand01(); \n", fip);
1060fputs(" if ( A == 0. ) goto LAB10; \n B = drand01(); \n", fip);
1061fputs(" x = sqrt(-2.*log(A))*cos(2.*M_PI*B); \n", fip);
1062fputs(" return(x); \n } \n", fip);
1063fputs("#define GauRand() NorRand() \n", fip);
1064fputs("#define gaurand() NorRand() \n\n", fip);
1065
1066fputs("int expf_pia_dl_func(double* _zz6qi_, double* _rx_6q_, double* _ry_6q_, double* _rz_6q_, double* _rt_6q_) \n{\n", fip);
1067fprintf(fip,"%s \n", vardec.c_str());
1068fprintf(fip, "if (!(%s)) { *_rx_6q_ = *_ry_6q_ = *_rz_6q_ = *_rt_6q_ = 0.; return(0); } \n", cut.c_str());
1069fprintf(fip, "*_rx_6q_ = %s ; \n", expx.c_str());
1070fprintf(fip, "*_ry_6q_ = %s ; \n", expy.c_str());
1071fprintf(fip, "*_rz_6q_ = %s ; \n", expz.c_str());
1072fprintf(fip, "*_rt_6q_ = %s ; \n", expt.c_str());
1073fputs("return(1); \n} \n", fip);
1074fclose(fip);
1075string func = "expf_pia_dl_func";
1076return((PlotExprFunc)LinkFunctionFromFile(fname, func));
1077}
1078
1079
1080/* --Methode-- */
1081DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
1082{
1083// Le link dynamique
1084CloseDLL();
1085dynlink = PDynLinkMgr::BuildFromCFile(fname);
1086if (dynlink == NULL) {
1087 cerr << "Services2NObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl;
1088 return(NULL);
1089 }
1090
1091DlFunction retfunc = dynlink->GetFunction(funcname);
1092if (retfunc == NULL) {
1093 string sn = funcname;
1094 cerr << "Services2NObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl;
1095 CloseDLL();
1096 return(NULL);
1097 }
1098else return(retfunc);
1099}
1100
1101/* --Methode-- */
1102void Services2NObjMgr::CloseDLL()
1103{
1104if (dynlink) delete dynlink; dynlink = NULL;
1105}
1106
1107// Fonction static
1108/* --Methode-- */
1109void Services2NObjMgr::DecodeLoopParameters(string& loop, int& i1, int& i2, int& di)
1110{
1111// Decode des paramatres de boucle for(int i=i1; i<i2; i+=di) specifies
1112// sous forme i1[:i2[:di]]
1113// cout << "LoopParam() " << loop << " I1=" << i1 << " I2=" << i2 << " DI=" << di;
1114size_t l = loop.length();
1115if (l < 1) return;
1116size_t p = loop.find(':');
1117if (p >= l) { i1 = atoi(loop.c_str()); return; }
1118i1 = atoi(loop.substr(0, p).c_str());
1119string aa = loop.substr(p+1);
1120p = aa.find(':');
1121if (p < aa.length() ) {
1122 i2 = atoi(aa.substr(0,p).c_str());
1123 di = atoi(aa.substr(p+1).c_str());
1124 }
1125else i2 = atoi(aa.c_str());
1126// cout << "-> I1= " << i1 << " I2= " << i2 << " DI= " << di << endl;
1127return;
1128}
1129
1130/* --Methode-- */
1131string Services2NObjMgr::FileName2Name(string const & fn)
1132{
1133
1134char fsep[2] = {FILESEP, '\0'};
1135char tsep[2] = {'.', '\0'};
1136size_t p = fn.find_last_of(fsep);
1137size_t l = fn.length();
1138if (p >= l) p = 0;
1139else p++;
1140size_t q = fn.find_first_of(tsep,p);
1141if (q < p) q = l;
1142return(fn.substr(p,q-p));
1143}
1144
1145
1146typedef vector<string> GraTok;
1147
1148/* --Methode-- */
1149int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
1150{
1151int ropt = Disp_Next;
1152if (!mImgapp) return(ropt);
1153
1154for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
1155
1156if (fgsrgr) mImgapp->SaveGraphicAtt();
1157
1158if ( (gratt == "def") || (gratt == "default") ) { // Remise aux valeurs par defaut = non defini
1159 mImgapp->SetColAtt();
1160 mImgapp->SetLineAtt();
1161 mImgapp->SetFontAtt();
1162 mImgapp->SetMarkerAtt();
1163 mImgapp->SetColMapId();
1164 mImgapp->SetZoomAtt();
1165 mImgapp->SetAxesAtt();
1166 mImgapp->SetXYLimits();
1167 mImgapp->UseXYLimits();
1168 return(ropt);
1169 }
1170
1171// On separe en mots separes par des virgules
1172gratt = ","+gratt;
1173size_t p = 0;
1174size_t q = 0;
1175size_t l = gratt.length();
1176string token;
1177
1178GraTok grt;
1179
1180while (q < l) {
1181 p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
1182 if (p>=l) break;
1183 q = gratt.find_first_of(" ,",p); // la fin du token;
1184 token = gratt.substr(p,q-p);
1185 grt.push_back(token);
1186 }
1187
1188
1189static GrAttNames::iterator it;
1190
1191int k;
1192bool fgcont = true;
1193fgsrgr = false;
1194
1195for(k=0; k<grt.size(); k++) {
1196// cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
1197
1198 // Decodage option affichage (win, next, etc
1199 fgcont = true;
1200 if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;
1201 else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;
1202 else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;
1203 else fgcont = false;
1204 if (fgcont) continue;
1205
1206 // Utilisation limites X-Y
1207 if ( grt[k] == "xylimits" ) { mImgapp->UseXYLimits(true); fgsrgr = true; continue; }
1208 // Si c'est une couleur
1209 it = GrAcolors.find(grt[k]);
1210 if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
1211 // Si c'est un attribut de lignes
1212 it = GrAlines.find(grt[k]);
1213 if (it != GrAlines.end()) { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1)); fgsrgr = true; continue; }
1214 // Si c'est un attribut de fontes
1215 it = GrAfonts.find(grt[k]);
1216 if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
1217 fgsrgr = true; continue; }
1218 // Si c'est un attribut de markers
1219 it = GrAmarkers.find(grt[k]);
1220 if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
1221 fgsrgr = true; continue; }
1222 // Si c'est un colormap
1223 it = GrAcmap.find(grt[k]);
1224 if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }
1225 // Si c'est un facteur de zoom
1226 it = GrAzoom.find(grt[k]);
1227 if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }
1228 // Si c'est un attribut d'axe
1229 it = GrAaxes.find(grt[k]);
1230 if (it != GrAaxes.end()) { mImgapp->SetAxesAtt( (*it).second.a1 ); fgsrgr = true; continue; }
1231
1232 }
1233
1234return(ropt);
1235}
1236
1237
1238
1239// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1240// Initialisation des chaines de caracteres designant les attributs graphiques
1241
1242/* --Methode-- */
1243void Services2NObjMgr::InitGrAttNames()
1244{
1245gratt_item gi;
1246// Les couleurs
1247gi.a2 = 0;
1248gi.a1 = PI_NotDefColor;
1249GrAcolors["defcol"] = gi;
1250gi.a1 = PI_Black;
1251GrAcolors["black"] = gi;
1252gi.a1 = PI_White;
1253GrAcolors["white"] = gi;
1254gi.a1 = PI_Grey;
1255GrAcolors["grey"] = gi;
1256gi.a1 = PI_Red;
1257GrAcolors["red"] = gi;
1258gi.a1 = PI_Blue;
1259GrAcolors["blue"] = gi;
1260gi.a1 = PI_Green;
1261GrAcolors["green"] = gi;
1262gi.a1 = PI_Yellow;
1263GrAcolors["yellow"] = gi;
1264gi.a1 = PI_Magenta;
1265GrAcolors["magenta"] = gi;
1266
1267gi.a1 = PI_Cyan;
1268GrAcolors["cyan"] = gi;
1269gi.a1 = PI_Turquoise;
1270GrAcolors["turquoise"] = gi;
1271gi.a1 = PI_NavyBlue;
1272GrAcolors["navyblue"] = gi;
1273gi.a1 = PI_Orange;
1274GrAcolors["orange"] = gi;
1275gi.a1 = PI_SiennaRed;
1276GrAcolors["siennared"] = gi;
1277gi.a1 = PI_Purple;
1278GrAcolors["purple"] = gi;
1279gi.a1 = PI_LimeGreen;
1280GrAcolors["limegreen"] = gi;
1281gi.a1 = PI_Gold;
1282GrAcolors["gold"] = gi;
1283
1284// Les attributs de lignes
1285gi.a2 = 0;
1286gi.a1 = PI_NotDefLineAtt;
1287GrAlines["defline"] = gi;
1288gi.a1 = PI_NormalLine;
1289GrAlines["normalline"] = gi;
1290gi.a1 = PI_ThinLine;
1291GrAlines["thinline"] = gi;
1292gi.a1 = PI_ThickLine;
1293GrAlines["thickline"] = gi;
1294gi.a1 = PI_DashedLine;
1295GrAlines["dashedline"] = gi;
1296gi.a1 = PI_ThinDashedLine;
1297GrAlines["thindashedline"] = gi;
1298gi.a1 = PI_ThickDashedLine;
1299GrAlines["thickdashedline"] = gi;
1300gi.a1 = PI_DottedLine;
1301GrAlines["dottedline"] = gi;
1302gi.a1 = PI_ThinDottedLine;
1303GrAlines["thindottedline"] = gi;
1304gi.a1 = PI_ThickDottedLine;
1305GrAlines["thickdottedline"] = gi;
1306
1307// Les fontes
1308gi.a2 = PI_NotDefFontSize;
1309gi.a1 = PI_NotDefFontAtt;
1310GrAfonts["deffont"] = gi;
1311
1312gi.a2 = PI_NormalSizeFont;
1313gi.a1 = PI_RomanFont;
1314GrAfonts["normalfont"] = gi;
1315gi.a1 = PI_BoldFont;
1316GrAfonts["boldfont"] = gi;
1317gi.a1 = PI_ItalicFont;
1318GrAfonts["italicfont"] = gi;
1319gi.a2 = PI_SmallSizeFont;
1320gi.a1 = PI_RomanFont;
1321GrAfonts["smallfont"] = gi;
1322gi.a1 = PI_BoldFont;
1323GrAfonts["smallboldfont"] = gi;
1324gi.a1 = PI_ItalicFont;
1325GrAfonts["smallitalicfont"] = gi;
1326gi.a2 = PI_BigSizeFont;
1327gi.a1 = PI_RomanFont;
1328GrAfonts["bigfont"] = gi;
1329gi.a1 = PI_BoldFont;
1330GrAfonts["bigboldfont"] = gi;
1331gi.a1 = PI_ItalicFont;
1332GrAfonts["bigitalicfont"] = gi;
1333gi.a2 = PI_HugeSizeFont;
1334gi.a1 = PI_RomanFont;
1335GrAfonts["hugefont"] = gi;
1336gi.a1 = PI_BoldFont;
1337GrAfonts["hugeboldfont"] = gi;
1338gi.a1 = PI_ItalicFont;
1339GrAfonts["hugeitalicfont"] = gi;
1340
1341
1342// Les markers
1343const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
1344 "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
1345 "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
1346PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
1347 PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
1348 PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
1349
1350gi.a2 = 0;
1351gi.a1 = PI_NotDefMarker;
1352GrAmarkers["defmarker"] = gi;
1353
1354for(int j=0; j<11; j++) {
1355 string smrk;
1356 char buff[16];
1357 for(int m=1; m<10; m+=2) {
1358 sprintf(buff,"%d",m);
1359 smrk = (string)mrkn[j] + (string)buff;
1360 gi.a1 = mrk[j]; gi.a2 = m;
1361 GrAmarkers[smrk] = gi;
1362 }
1363 }
1364
1365// Les tables de couleurs
1366gi.a2 = 0;
1367gi.a1 = CMAP_OTHER;
1368GrAcmap["defcmap"] = gi;
1369gi.a1 = CMAP_GREY32;
1370GrAcmap["grey32"] = gi;
1371gi.a1 = CMAP_GREYINV32;
1372GrAcmap["greyinv32"] = gi;
1373gi.a1 = CMAP_COLRJ32;
1374GrAcmap["colrj32"] = gi;
1375gi.a1 = CMAP_COLBR32;
1376GrAcmap["colbr32"] = gi;
1377gi.a1 = CMAP_GREY128;
1378GrAcmap["grey128"] = gi;
1379gi.a1 = CMAP_GREYINV128;
1380GrAcmap["greyinv128"] = gi;
1381gi.a1 = CMAP_COLRJ128;
1382GrAcmap["colrj128"] = gi;
1383gi.a1 = CMAP_COLBR128;
1384GrAcmap["colbr128"] = gi;
1385
1386// La valeur de zoom
1387gi.a2 = 0;
1388gi.a1 = 0;
1389GrAzoom["defzoom"] = gi;
1390gi.a1 = 1;
1391GrAzoom["zoomx1"] = gi;
1392gi.a1 = 2;
1393GrAzoom["zoomx2"] = gi;
1394gi.a1 = 3;
1395GrAzoom["zoomx3"] = gi;
1396gi.a1 = 4;
1397GrAzoom["zoomx4"] = gi;
1398gi.a1 = 5;
1399GrAzoom["zoomx5"] = gi;
1400gi.a1 = -2;
1401GrAzoom["zoom/2"] = gi;
1402gi.a1 = -3;
1403GrAzoom["zoom/3"] = gi;
1404gi.a1 = -4;
1405GrAzoom["zoom/4"] = gi;
1406gi.a1 = -5;
1407GrAzoom["zoom/5"] = gi;
1408
1409// Attributs d'axes
1410gi.a2 = 0;
1411gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
1412GrAaxes["stdaxes"] = gi;
1413GrAaxes["defaxes"] = gi;
1414GrAaxes["boxaxes"] = gi;
1415gi.a1 = (int)kAxesDflt;
1416GrAaxes["simpleaxes"] = gi;
1417gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
1418GrAaxes["boxaxesgrid"] = gi;
1419
1420gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
1421GrAaxes["fineaxes"] = gi;
1422 gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
1423GrAaxes["grid"] = gi;
1424GrAaxes["fineaxesgrid"] = gi;
1425
1426}
1427
1428
1429// SANS_EVOLPLANCK Attention !
1430#include "pclassids.h"
1431
1432/* --Methode-- */
1433char* Services2NObjMgr::PClassIdToClassName(int cid)
1434{
1435switch (cid) {
1436 case ClassId_Poly1 :
1437 return("Poly1");
1438 case ClassId_Poly2 :
1439 return("Poly2");
1440 case ClassId_Matrix :
1441 return("Matrix");
1442 case ClassId_Vector :
1443 return("Vector");
1444
1445 case ClassId_DVList :
1446 return("DVList");
1447
1448 case ClassId_Histo1D :
1449 return("Histo1D");
1450 case ClassId_Histo2D :
1451 return("Histo2D");
1452 case ClassId_HProf :
1453 return("HProf");
1454 case ClassId_NTuple :
1455 return("NTuple");
1456 case ClassId_XNTuple :
1457 return("XNTuple");
1458 case ClassId_GeneralFitData :
1459 return("GeneralFitData");
1460
1461 case ClassId_Image :
1462 return("RzImage");
1463 case ClassId_Image + kuint_1 :
1464 return("ImageU1");
1465 case ClassId_Image + kint_1 :
1466 return("ImageI1");
1467 case ClassId_Image + kuint_2 :
1468 return("ImageU2");
1469 case ClassId_Image + kint_2 :
1470 return("ImageI2");
1471 case ClassId_Image + kuint_4 :
1472 return("ImageU4");
1473 case ClassId_Image + kint_4 :
1474 return("ImageI4");
1475 case ClassId_Image + kr_4 :
1476 return("ImageR4");
1477 case ClassId_Image + kr_8 :
1478 return("ImageR8");
1479
1480 case ClassId_ZFidu :
1481 return("ZFidu");
1482
1483 case ClassId_StarList :
1484 return("StarList");
1485 case ClassId_Transfo :
1486 return("Transfo");
1487 case ClassId_PSF :
1488 return("PSF");
1489
1490
1491// - Ajout objet PPF
1492 default:
1493 return("AnyDataObj");
1494 }
1495}
1496
Note: See TracBrowser for help on using the repository browser.