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

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

flag KCC -> namespace std et CC_HAS_RTTI_SUPPORT Reza 26/9/99

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