1 | #include <stdio.h>
|
---|
2 | #include <stdlib.h>
|
---|
3 | #include <ctype.h>
|
---|
4 |
|
---|
5 | #include <dlfcn.h>
|
---|
6 |
|
---|
7 | #include <iostream.h>
|
---|
8 | #include <string>
|
---|
9 | #include <list>
|
---|
10 | #include <map>
|
---|
11 | #if defined(__KCC__)
|
---|
12 | using std::string ;
|
---|
13 | #include <list.h>
|
---|
14 | #include <map.h>
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #include "strutil.h"
|
---|
18 | #include "datatypes.h"
|
---|
19 |
|
---|
20 | #include "nobjmgr.h"
|
---|
21 | #include "servnobjm.h"
|
---|
22 | #include "pistdimgapp.h"
|
---|
23 |
|
---|
24 | #include "pclassids.h"
|
---|
25 | #include "histos.h"
|
---|
26 | #include "histos2.h"
|
---|
27 | #include "ntuple.h"
|
---|
28 | #include "hisprof.h"
|
---|
29 | #include "generaldata.h"
|
---|
30 |
|
---|
31 | #include "cimage.h"
|
---|
32 | #include "cvector.h"
|
---|
33 | #include "matrix.h"
|
---|
34 |
|
---|
35 | // Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...
|
---|
36 | #ifndef SANS_StarReco
|
---|
37 | #include "stlist.h"
|
---|
38 | #include "star.h"
|
---|
39 | #endif
|
---|
40 |
|
---|
41 |
|
---|
42 | /* --Methode-- */
|
---|
43 | Services2NObjMgr::Services2NObjMgr(PIStdImgApp* app, string& tmpdir)
|
---|
44 | {
|
---|
45 | TmpDir = tmpdir;
|
---|
46 | mImgapp = app;
|
---|
47 | dlhandle = NULL;
|
---|
48 | InitGrAttNames();
|
---|
49 | }
|
---|
50 |
|
---|
51 | /* --Methode-- */
|
---|
52 | Services2NObjMgr::~Services2NObjMgr()
|
---|
53 | {
|
---|
54 | CloseDLL();
|
---|
55 | }
|
---|
56 |
|
---|
57 | /* --Methode-- */
|
---|
58 | void Services2NObjMgr::Nobj_ComputeExpressions(PPersist* obj, string& expx, string& expy, string& expz,
|
---|
59 | string& expwt, string& expcut, NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
|
---|
60 | {
|
---|
61 | int cid = obj->ClassId();
|
---|
62 |
|
---|
63 | string vardec;
|
---|
64 | switch (cid) {
|
---|
65 | case ClassId_Vector :
|
---|
66 | vardec = "double i,val; \n";
|
---|
67 | vardec += "i = _zz61qq_[0]; val = _zz61qq_[1]; \n";
|
---|
68 | break;
|
---|
69 |
|
---|
70 | case ClassId_Matrix :
|
---|
71 | vardec = "double i,j,val; \n";
|
---|
72 | vardec += "i = _zz61qq_[0]; j = _zz61qq_[1]; val = _zz61qq_[2]; \n";
|
---|
73 | break;
|
---|
74 |
|
---|
75 | case ClassId_Histo1D :
|
---|
76 | case ClassId_HProf :
|
---|
77 | vardec = "double i,x,val,err; \n";
|
---|
78 | vardec += "i = _zz61qq_[0]; x = _zz61qq_[1]; val = _zz61qq_[2]; err = _zz61qq_[3]; \n";
|
---|
79 | break;
|
---|
80 |
|
---|
81 | case ClassId_Histo2D :
|
---|
82 | vardec = "double i,j,x,y,val,err; \n";
|
---|
83 | vardec += "i = _zz61qq_[0]; j = _zz61qq_[1]; \n";
|
---|
84 | vardec += "x = _zz61qq_[2]; y = _zz61qq_[3]; \n";
|
---|
85 | vardec += "val = _zz61qq_[4]; err = _zz61qq_[5]; \n";
|
---|
86 | break;
|
---|
87 |
|
---|
88 | case ClassId_Image :
|
---|
89 | case ClassId_Image + kuint_1 :
|
---|
90 | case ClassId_Image + kint_1 :
|
---|
91 | case ClassId_Image + kr_8 :
|
---|
92 | case ClassId_Image + kuint_4 :
|
---|
93 | case ClassId_Image + kuint_2 :
|
---|
94 | case ClassId_Image + kint_2 :
|
---|
95 | case ClassId_Image + kint_4 :
|
---|
96 | case ClassId_Image + kr_4 :
|
---|
97 | vardec = "double x,y,pix,i,j,val; \n";
|
---|
98 | vardec += "x = i = _zz61qq_[0]; y = j = _zz61qq_[1]; pix = val = _zz61qq_[2]; \n";
|
---|
99 | break;
|
---|
100 |
|
---|
101 | #ifndef SANS_StarReco
|
---|
102 | case ClassId_StarList :
|
---|
103 | vardec = "double x,y,flux,fond; \n";
|
---|
104 | vardec += "x = _zz61qq_[0]; y = _zz61qq_[1]; flux = _zz61qq_[2]; fond = _zz61qq_[3]; \n";
|
---|
105 | break;
|
---|
106 | #endif
|
---|
107 |
|
---|
108 | case ClassId_NTuple :
|
---|
109 | vardec = ((NTuple*)obj)->VarList_C("_zz61qq_");
|
---|
110 | break;
|
---|
111 |
|
---|
112 | case ClassId_GeneralFitData :
|
---|
113 | vardec = ((GeneralFitData*)obj)->VarList_C("_zz61qq_");
|
---|
114 | break;
|
---|
115 |
|
---|
116 | default :
|
---|
117 | cerr << "NamedObjMgr_ComputeExpressions() Error , N/A to " << PClassIdToClassName(cid) << endl;
|
---|
118 | return;
|
---|
119 | }
|
---|
120 |
|
---|
121 | PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expwt, expcut);
|
---|
122 | if (!f) {
|
---|
123 | cerr << "NamedObjMgr_ComputeExpressions() Error Creation PlotExprFunc " << endl;
|
---|
124 | return;
|
---|
125 | }
|
---|
126 |
|
---|
127 | float x[10], xnt[10];
|
---|
128 |
|
---|
129 | int i,j,k;
|
---|
130 | for(i=0; i<10; i++) x[i] = xnt[i] = 0.;
|
---|
131 |
|
---|
132 | TRY {
|
---|
133 | switch (cid) {
|
---|
134 | case ClassId_Vector :
|
---|
135 | {
|
---|
136 | Vector* vv = (Vector*)obj;
|
---|
137 | for(k=0; k<vv->NElts(); k++) {
|
---|
138 | x[0] = k; x[1] = (*vv)(k);
|
---|
139 | if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
140 | if (nt) nt->Fill(xnt);
|
---|
141 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
142 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
143 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
144 | }
|
---|
145 | }
|
---|
146 | }
|
---|
147 | break;
|
---|
148 |
|
---|
149 | case ClassId_Matrix :
|
---|
150 | {
|
---|
151 | Matrix* mm = (Matrix*)obj;
|
---|
152 | for(j=0; j<mm->NCol(); j++)
|
---|
153 | for(i=0; i<mm->NRows(); i++) {
|
---|
154 | x[0] = i; x[1] = j; x[2] = (*mm)(i,j);
|
---|
155 | if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
156 | if (nt) nt->Fill(xnt);
|
---|
157 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
158 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
159 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
160 | }
|
---|
161 | }
|
---|
162 | }
|
---|
163 | break;
|
---|
164 |
|
---|
165 | case ClassId_Histo1D :
|
---|
166 | case ClassId_HProf :
|
---|
167 | {
|
---|
168 | Histo* hh = (Histo*)obj;
|
---|
169 | for(k=0; k<hh->NBins(); k++) {
|
---|
170 | x[0] = k; x[1] = hh->BinCenter(k);
|
---|
171 | x[2] = (*hh)(k); x[3] = hh->Error(k);
|
---|
172 | if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
173 | if (nt) nt->Fill(xnt);
|
---|
174 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
175 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
176 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
177 | }
|
---|
178 | }
|
---|
179 | }
|
---|
180 | break;
|
---|
181 |
|
---|
182 | case ClassId_Histo2D :
|
---|
183 | {
|
---|
184 | Histo2D* hh = (Histo2D*)obj;
|
---|
185 | for(j=0; j<hh->NBinY(); j++)
|
---|
186 | for(i=0; i<hh->NBinX(); i++) {
|
---|
187 | x[0] = i; x[1] = j;
|
---|
188 | hh->BinCenter(i,j,x[2],x[3]);
|
---|
189 | x[4] = (*hh)(i,j); x[5] = hh->Error(i, j);
|
---|
190 | if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
191 | if (nt) nt->Fill(xnt);
|
---|
192 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
193 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
194 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
195 | }
|
---|
196 | }
|
---|
197 | }
|
---|
198 | break;
|
---|
199 |
|
---|
200 |
|
---|
201 | case ClassId_Image :
|
---|
202 | case ClassId_Image + kuint_1 :
|
---|
203 | case ClassId_Image + kint_1 :
|
---|
204 | case ClassId_Image + kr_8 :
|
---|
205 | case ClassId_Image + kuint_4 :
|
---|
206 | case ClassId_Image + kuint_2 :
|
---|
207 | case ClassId_Image + kint_2 :
|
---|
208 | case ClassId_Image + kint_4 :
|
---|
209 | case ClassId_Image + kr_4 :
|
---|
210 | {
|
---|
211 | RzImage* img = (RzImage*)obj;
|
---|
212 | for(j=0; j<img->YSize(); j++)
|
---|
213 | for(i=0; i<img->XSize(); i++) {
|
---|
214 | x[0] = i; x[1] = j; x[2] = img->FValue(i, j);
|
---|
215 | if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
216 | if (nt) nt->Fill(xnt);
|
---|
217 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
218 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
219 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
220 | }
|
---|
221 | }
|
---|
222 | }
|
---|
223 | break;
|
---|
224 |
|
---|
225 | #ifndef SANS_StarReco
|
---|
226 | case ClassId_StarList :
|
---|
227 | {
|
---|
228 | StarList* stl = (StarList*)obj;
|
---|
229 | BStar *sti;
|
---|
230 | for(k=0; k<stl->NbStars(); k++) {
|
---|
231 | sti = stl->Star(k);
|
---|
232 | if ( (!sti) || !(sti->Nice(BStar::flagOK)) ) continue;
|
---|
233 | x[0] = sti->PosX(); x[1] = sti->PosY();
|
---|
234 | x[2] = sti->Flux(); x[3] = sti->Fond();
|
---|
235 | if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
236 | if (nt) nt->Fill(xnt);
|
---|
237 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
238 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
239 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
240 | }
|
---|
241 | }
|
---|
242 | }
|
---|
243 | break;
|
---|
244 | #endif
|
---|
245 |
|
---|
246 | case ClassId_NTuple :
|
---|
247 | {
|
---|
248 | NTuple* ntp = (NTuple*)obj;
|
---|
249 | r_4* xn;
|
---|
250 | for(k=0; k<ntp->NEntry(); k++) {
|
---|
251 | xn = ntp->GetVec(k);
|
---|
252 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
253 | if (nt) nt->Fill(xnt);
|
---|
254 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
255 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
256 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
257 | }
|
---|
258 | }
|
---|
259 | }
|
---|
260 | break;
|
---|
261 |
|
---|
262 | case ClassId_GeneralFitData :
|
---|
263 | {
|
---|
264 | GeneralFitData* data = (GeneralFitData*)obj;
|
---|
265 | r_4* xn;
|
---|
266 | int iok = 2*data->NVar()+2;
|
---|
267 | for(k=0; k<data->NData(); k++) {
|
---|
268 | xn = data->GetVecR4(k);
|
---|
269 | if(xn[iok]<0.001) continue;
|
---|
270 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
271 | if (nt) nt->Fill(xnt);
|
---|
272 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
273 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
274 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
275 | }
|
---|
276 | }
|
---|
277 | }
|
---|
278 | break;
|
---|
279 |
|
---|
280 | default :
|
---|
281 | cout << "NamedObjMgr_ComputeExpressions() Erreur: N/A to " << PClassIdToClassName(cid) << endl;
|
---|
282 | return;
|
---|
283 | }
|
---|
284 | } CATCH(merr) {
|
---|
285 | fflush(stdout);
|
---|
286 | cout << endl;
|
---|
287 | cerr << endl;
|
---|
288 | string es = PeidaExc(merr);
|
---|
289 | cerr << "NamedObjMgr_ComputeExpressions() Exception :" << merr << es;
|
---|
290 | } ENDTRY;
|
---|
291 |
|
---|
292 |
|
---|
293 | // Fermeture du fichier .so
|
---|
294 | CloseDLL();
|
---|
295 | return;
|
---|
296 | }
|
---|
297 |
|
---|
298 |
|
---|
299 | /* --Methode-- */
|
---|
300 | PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy, string& expz,
|
---|
301 | string& expwt, string& cut)
|
---|
302 | {
|
---|
303 | FILE *fip;
|
---|
304 | string fname = TmpDir + "expf_pia_dl.c";
|
---|
305 | string fnamer = TmpDir + "expf_pia_dl";
|
---|
306 | string cmd;
|
---|
307 | int rc;
|
---|
308 |
|
---|
309 | cmd = "rm " + fname;
|
---|
310 | rc = system(cmd.c_str());
|
---|
311 | //DBG printf("LinkExprFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
312 |
|
---|
313 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
314 | string sn = fname;
|
---|
315 | cout << "NamedObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl;
|
---|
316 | return(NULL);
|
---|
317 | }
|
---|
318 |
|
---|
319 | // constitution du fichier a compiler
|
---|
320 | fputs("#include <math.h> \n", fip);
|
---|
321 | fputs("int expf_pia_dl_func(float* _zz61qq_, float* _rx_61qq_, float* _ry_61qq_, float* _rz_61qq_, float* _wt_61qq_) \n{\n", fip);
|
---|
322 | fprintf(fip,"%s \n", vardec.c_str());
|
---|
323 | fprintf(fip, "if (!(%s)) { *_rx_61qq_ = *_ry_61qq_ = *_rz_61qq_ = *_wt_61qq_ = 0.; return(0); } \n", cut.c_str());
|
---|
324 | fprintf(fip, "*_rx_61qq_ = %s ; \n", expx.c_str());
|
---|
325 | fprintf(fip, "*_ry_61qq_ = %s ; \n", expy.c_str());
|
---|
326 | fprintf(fip, "*_rz_61qq_ = %s ; \n", expz.c_str());
|
---|
327 | fprintf(fip, "*_wt_61qq_ = %s ; \n", expwt.c_str());
|
---|
328 | fputs("return(1); \n} \n", fip);
|
---|
329 | fclose(fip);
|
---|
330 |
|
---|
331 | return((PlotExprFunc)LinkFunctionFromFile(fnamer, "expf_pia_dl_func"));
|
---|
332 | }
|
---|
333 |
|
---|
334 |
|
---|
335 | /* --Methode-- */
|
---|
336 | DlFunction Services2NObjMgr::LinkFunctionFromFile(string& fnamer, char* funcname)
|
---|
337 | {
|
---|
338 | string fname = fnamer + ".c" ;
|
---|
339 | string fnameobj = fnamer + ".o" ;
|
---|
340 | string fnameso = fnamer + ".so";
|
---|
341 | string cmd;
|
---|
342 | int rc;
|
---|
343 |
|
---|
344 |
|
---|
345 | // Compilation du fichier
|
---|
346 | cmd = "cc -c -o " + fnameobj + " " + fname;
|
---|
347 | rc = system(cmd.c_str());
|
---|
348 |
|
---|
349 | if (rc != 0) {
|
---|
350 | printf("LinkFunctionFromFile_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
351 | return(NULL);
|
---|
352 | }
|
---|
353 | #if defined(OSF1)
|
---|
354 | cmd = "ld -shared -o " + fnameso + " -all " + fnameobj + " -none -lm -lc";
|
---|
355 | #else
|
---|
356 | cmd = "ld -shared -o " + fnameso + " " + fnameobj + " -lm -lc";
|
---|
357 | #endif
|
---|
358 | rc = system(cmd.c_str());
|
---|
359 | if (rc != 0 ) {
|
---|
360 | printf("LinkFunctionFromFile_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
361 | return(NULL);
|
---|
362 | }
|
---|
363 |
|
---|
364 | // Le link dynamique
|
---|
365 | CloseDLL();
|
---|
366 | dlhandle = dlopen(fnameso.c_str(), RTLD_NOW);
|
---|
367 | if (dlhandle == NULL) {
|
---|
368 | string sn = fnameso;
|
---|
369 | cerr << "NamedObjMgr/FunctionFromFile_Erreur: Erreur ouverture SO " << sn << endl;
|
---|
370 | sn = dlerror();
|
---|
371 | cerr << "Loader Error (dlerror()) :" << sn;
|
---|
372 | return(NULL);
|
---|
373 | }
|
---|
374 |
|
---|
375 | DlFunction retfunc = (DlFunction) dlsym(dlhandle, funcname);
|
---|
376 | if (retfunc == NULL) {
|
---|
377 | string sn = funcname;
|
---|
378 | cerr << "NamedObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl;
|
---|
379 | CloseDLL();
|
---|
380 | return(NULL);
|
---|
381 | }
|
---|
382 | else return(retfunc);
|
---|
383 | }
|
---|
384 |
|
---|
385 | /* --Methode-- */
|
---|
386 | void Services2NObjMgr::CloseDLL()
|
---|
387 | {
|
---|
388 | if (dlhandle) dlclose(dlhandle); dlhandle = NULL;
|
---|
389 | }
|
---|
390 |
|
---|
391 | /* --Methode-- */
|
---|
392 | string Services2NObjMgr::FileName2Name(string const & fn)
|
---|
393 | {
|
---|
394 |
|
---|
395 | char fsep[2] = {FILESEP, '\0'};
|
---|
396 | char tsep[2] = {'.', '\0'};
|
---|
397 | size_t p = fn.find_last_of(fsep);
|
---|
398 | size_t q = fn.find_last_of(tsep);
|
---|
399 | if (p < 0) p = 0;
|
---|
400 | p++;
|
---|
401 | if (q < p) q = fn.length();
|
---|
402 | return(fn.substr(p,q-p));
|
---|
403 | }
|
---|
404 |
|
---|
405 |
|
---|
406 | typedef vector<string> GraTok;
|
---|
407 |
|
---|
408 | /* --Methode-- */
|
---|
409 | int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
|
---|
410 | {
|
---|
411 | int ropt = Disp_Next;
|
---|
412 | if (!mImgapp) return(ropt);
|
---|
413 |
|
---|
414 | for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
|
---|
415 |
|
---|
416 | if (fgsrgr) mImgapp->SaveGraphicAtt();
|
---|
417 |
|
---|
418 | if (gratt.substr(0,3) == "def") { // Remise aux valeurs par defaut = non defini
|
---|
419 | mImgapp->SetColAtt();
|
---|
420 | mImgapp->SetLineAtt();
|
---|
421 | mImgapp->SetFontAtt();
|
---|
422 | mImgapp->SetMarkerAtt();
|
---|
423 | mImgapp->SetColMapId();
|
---|
424 | mImgapp->SetZoomAtt();
|
---|
425 | return(ropt);
|
---|
426 | }
|
---|
427 |
|
---|
428 | // On separe en mots separes par des virgules
|
---|
429 | gratt = ","+gratt;
|
---|
430 | size_t p = 0;
|
---|
431 | size_t q = 0;
|
---|
432 | size_t l = gratt.length();
|
---|
433 | string token;
|
---|
434 |
|
---|
435 | GraTok grt;
|
---|
436 |
|
---|
437 | while (q < l) {
|
---|
438 | p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
|
---|
439 | if (p>=l) break;
|
---|
440 | q = gratt.find_first_of(" ,",p); // la fin du token;
|
---|
441 | token = gratt.substr(p,q-p);
|
---|
442 | grt.push_back(token);
|
---|
443 | }
|
---|
444 |
|
---|
445 |
|
---|
446 | static GrAttNames::iterator it;
|
---|
447 |
|
---|
448 | int k;
|
---|
449 | bool fgcont = true;
|
---|
450 | fgsrgr = false;
|
---|
451 |
|
---|
452 | for(k=0; k<grt.size(); k++) {
|
---|
453 | // cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
|
---|
454 |
|
---|
455 | // Decodage option affichage (win, next, etc
|
---|
456 | fgcont = true;
|
---|
457 | if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;
|
---|
458 | else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;
|
---|
459 | else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;
|
---|
460 | else fgcont = false;
|
---|
461 | if (fgcont) continue;
|
---|
462 |
|
---|
463 | // Si c'est une couleur
|
---|
464 | it = GrAcolors.find(grt[k]);
|
---|
465 | if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
466 | // Si c'est un attribut de lignes
|
---|
467 | it = GrAlines.find(grt[k]);
|
---|
468 | if (it != GrAlines.end()) { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
469 | // Si c'est un attribut de fontes
|
---|
470 | it = GrAfonts.find(grt[k]);
|
---|
471 | if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
|
---|
472 | fgsrgr = true; continue; }
|
---|
473 | // Si c'est un attribut de markers
|
---|
474 | it = GrAmarkers.find(grt[k]);
|
---|
475 | if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
|
---|
476 | fgsrgr = true; continue; }
|
---|
477 | // Si c'est un colormap
|
---|
478 | it = GrAcmap.find(grt[k]);
|
---|
479 | if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }
|
---|
480 | // Si c'est un facteur de zoom
|
---|
481 | it = GrAzoom.find(grt[k]);
|
---|
482 | if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
483 |
|
---|
484 | }
|
---|
485 |
|
---|
486 | return(ropt);
|
---|
487 | }
|
---|
488 |
|
---|
489 | /* --Methode-- */
|
---|
490 | char* Services2NObjMgr::PClassIdToClassName(int cid)
|
---|
491 | {
|
---|
492 | switch (cid) {
|
---|
493 | case ClassId_Poly1 :
|
---|
494 | return("Poly1");
|
---|
495 | case ClassId_Poly2 :
|
---|
496 | return("Poly2");
|
---|
497 | case ClassId_Matrix :
|
---|
498 | return("Matrix");
|
---|
499 | case ClassId_Vector :
|
---|
500 | return("Vector");
|
---|
501 |
|
---|
502 | case ClassId_DVList :
|
---|
503 | return("DVList");
|
---|
504 |
|
---|
505 | case ClassId_Histo1D :
|
---|
506 | return("Histo1D");
|
---|
507 | case ClassId_Histo2D :
|
---|
508 | return("Histo2D");
|
---|
509 | case ClassId_HProf :
|
---|
510 | return("HProf");
|
---|
511 | case ClassId_NTuple :
|
---|
512 | return("NTuple");
|
---|
513 | case ClassId_GeneralFitData :
|
---|
514 | return("GeneralFitData");
|
---|
515 |
|
---|
516 | case ClassId_Image :
|
---|
517 | return("RzImage");
|
---|
518 | case ClassId_Image + kuint_1 :
|
---|
519 | return("ImageU1");
|
---|
520 | case ClassId_Image + kint_1 :
|
---|
521 | return("ImageI1");
|
---|
522 | case ClassId_Image + kuint_2 :
|
---|
523 | return("ImageU2");
|
---|
524 | case ClassId_Image + kint_2 :
|
---|
525 | return("ImageI2");
|
---|
526 | case ClassId_Image + kuint_4 :
|
---|
527 | return("ImageU4");
|
---|
528 | case ClassId_Image + kint_4 :
|
---|
529 | return("ImageI4");
|
---|
530 | case ClassId_Image + kr_4 :
|
---|
531 | return("ImageR4");
|
---|
532 | case ClassId_Image + kr_8 :
|
---|
533 | return("ImageR8");
|
---|
534 |
|
---|
535 | case ClassId_ZFidu :
|
---|
536 | return("ZFidu");
|
---|
537 |
|
---|
538 | #ifndef SANS_StarReco
|
---|
539 | case ClassId_StarList :
|
---|
540 | return("StarList");
|
---|
541 | case ClassId_Transfo :
|
---|
542 | return("Transfo");
|
---|
543 | case ClassId_PSF :
|
---|
544 | return("PSF");
|
---|
545 |
|
---|
546 | case ClassId_Star + BStar_Type :
|
---|
547 | return("BStar");
|
---|
548 | case ClassId_Star + RzStar_Type :
|
---|
549 | return("RzStar");
|
---|
550 | case ClassId_Star + PSFStar_Type :
|
---|
551 | return("PSFStar");
|
---|
552 | case ClassId_Star + MCStar_Type :
|
---|
553 | return("MCStar");
|
---|
554 | case ClassId_Star + CircRFixStar_Type :
|
---|
555 | return("CircRFixStar");
|
---|
556 | case ClassId_Star + PSFDHStar_Type :
|
---|
557 | return("PSFDHStar");
|
---|
558 | case ClassId_Star + PSFSEStar_Type :
|
---|
559 | return("PSFSEStar");
|
---|
560 | case ClassId_Star + MCDHStar_Type :
|
---|
561 | return("MCDHStar");
|
---|
562 | #endif
|
---|
563 |
|
---|
564 | // - Ajout objet PPF
|
---|
565 | default:
|
---|
566 | return("Unknown");
|
---|
567 | }
|
---|
568 | }
|
---|
569 |
|
---|
570 | /* --Methode-- */
|
---|
571 | char* Services2NObjMgr::PClassIdToShortClassName(int cid)
|
---|
572 | {
|
---|
573 | switch (cid) {
|
---|
574 | case ClassId_Poly1 :
|
---|
575 | case ClassId_Poly2 :
|
---|
576 | return("Poly");
|
---|
577 | case ClassId_Matrix :
|
---|
578 | return("Mtx");
|
---|
579 | case ClassId_Vector :
|
---|
580 | return("Vec");
|
---|
581 | case ClassId_DVList :
|
---|
582 | return("Dvl");
|
---|
583 |
|
---|
584 | case ClassId_Histo1D :
|
---|
585 | return("H1D");
|
---|
586 | case ClassId_Histo2D :
|
---|
587 | return("H2D");
|
---|
588 | case ClassId_HProf :
|
---|
589 | return("HPF");
|
---|
590 | case ClassId_NTuple :
|
---|
591 | return("NT");
|
---|
592 | case ClassId_GeneralFitData :
|
---|
593 | return("GFD");
|
---|
594 |
|
---|
595 | case ClassId_Image :
|
---|
596 | case ClassId_Image + kuint_1 :
|
---|
597 | case ClassId_Image + kint_1 :
|
---|
598 | case ClassId_Image + kuint_2 :
|
---|
599 | case ClassId_Image + kint_2 :
|
---|
600 | case ClassId_Image + kuint_4 :
|
---|
601 | case ClassId_Image + kint_4 :
|
---|
602 | case ClassId_Image + kr_4 :
|
---|
603 | case ClassId_Image + kr_8 :
|
---|
604 | return("Img");
|
---|
605 |
|
---|
606 | case ClassId_ZFidu :
|
---|
607 | return("Fidu");
|
---|
608 |
|
---|
609 | #ifndef SANS_StarReco
|
---|
610 | case ClassId_StarList :
|
---|
611 | return("Stl");
|
---|
612 | case ClassId_Transfo :
|
---|
613 | return("Tr");
|
---|
614 | case ClassId_PSF :
|
---|
615 | return("PSF");
|
---|
616 |
|
---|
617 | case ClassId_Star + BStar_Type :
|
---|
618 | case ClassId_Star + RzStar_Type :
|
---|
619 | case ClassId_Star + PSFStar_Type :
|
---|
620 | case ClassId_Star + MCStar_Type :
|
---|
621 | case ClassId_Star + CircRFixStar_Type :
|
---|
622 | case ClassId_Star + PSFDHStar_Type :
|
---|
623 | case ClassId_Star + PSFSEStar_Type :
|
---|
624 | case ClassId_Star + MCDHStar_Type :
|
---|
625 | return("Star");
|
---|
626 | #endif
|
---|
627 |
|
---|
628 | // - Ajout objet PPF
|
---|
629 | default:
|
---|
630 | return("U");
|
---|
631 | }
|
---|
632 | }
|
---|
633 |
|
---|
634 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
635 | // Initialisation des chaines de caracteres designant les attributs graphiques
|
---|
636 |
|
---|
637 | /* --Methode-- */
|
---|
638 | void Services2NObjMgr::InitGrAttNames()
|
---|
639 | {
|
---|
640 | gratt_item gi;
|
---|
641 | // Les couleurs
|
---|
642 | gi.a2 = 0;
|
---|
643 | gi.a1 = PI_NotDefColor;
|
---|
644 | GrAcolors["defcol"] = gi;
|
---|
645 | gi.a1 = PI_Black;
|
---|
646 | GrAcolors["black"] = gi;
|
---|
647 | gi.a1 = PI_White;
|
---|
648 | GrAcolors["white"] = gi;
|
---|
649 | gi.a1 = PI_Grey;
|
---|
650 | GrAcolors["grey"] = gi;
|
---|
651 | gi.a1 = PI_Red;
|
---|
652 | GrAcolors["red"] = gi;
|
---|
653 | gi.a1 = PI_Blue;
|
---|
654 | GrAcolors["blue"] = gi;
|
---|
655 | gi.a1 = PI_Green;
|
---|
656 | GrAcolors["green"] = gi;
|
---|
657 | gi.a1 = PI_Yellow;
|
---|
658 | GrAcolors["yellow"] = gi;
|
---|
659 | gi.a1 = PI_Magenta;
|
---|
660 | GrAcolors["magenta"] = gi;
|
---|
661 |
|
---|
662 | gi.a1 = PI_Cyan;
|
---|
663 | GrAcolors["cyan"] = gi;
|
---|
664 | gi.a1 = PI_Turquoise;
|
---|
665 | GrAcolors["turquoise"] = gi;
|
---|
666 | gi.a1 = PI_NavyBlue;
|
---|
667 | GrAcolors["navyblue"] = gi;
|
---|
668 | gi.a1 = PI_Orange;
|
---|
669 | GrAcolors["orange"] = gi;
|
---|
670 | gi.a1 = PI_SiennaRed;
|
---|
671 | GrAcolors["siennared"] = gi;
|
---|
672 | gi.a1 = PI_Purple;
|
---|
673 | GrAcolors["purple"] = gi;
|
---|
674 | gi.a1 = PI_LimeGreen;
|
---|
675 | GrAcolors["limegreen"] = gi;
|
---|
676 | gi.a1 = PI_Gold;
|
---|
677 | GrAcolors["gold"] = gi;
|
---|
678 |
|
---|
679 | // Les attributs de lignes
|
---|
680 | gi.a2 = 0;
|
---|
681 | gi.a1 = PI_NotDefLineAtt;
|
---|
682 | GrAlines["defline"] = gi;
|
---|
683 | gi.a1 = PI_NormalLine;
|
---|
684 | GrAlines["normalline"] = gi;
|
---|
685 | gi.a1 = PI_ThinLine;
|
---|
686 | GrAlines["thinline"] = gi;
|
---|
687 | gi.a1 = PI_ThickLine;
|
---|
688 | GrAlines["thickline"] = gi;
|
---|
689 | gi.a1 = PI_DashedLine;
|
---|
690 | GrAlines["dashedline"] = gi;
|
---|
691 | gi.a1 = PI_ThinDashedLine;
|
---|
692 | GrAlines["thindashedline"] = gi;
|
---|
693 | gi.a1 = PI_ThickDashedLine;
|
---|
694 | GrAlines["thickdashedline"] = gi;
|
---|
695 |
|
---|
696 | // Les fontes (a faire)
|
---|
697 | gi.a2 = PI_NotDefFontSize;
|
---|
698 | gi.a1 = PI_NotDefFontAtt;
|
---|
699 | GrAlines["deffont"] = gi;
|
---|
700 |
|
---|
701 | gi.a2 = PI_NormalSizeFont;
|
---|
702 | gi.a1 = PI_RomanFont;
|
---|
703 | GrAlines["normalfont"] = gi;
|
---|
704 | gi.a1 = PI_BoldFont;
|
---|
705 | GrAlines["boldfont"] = gi;
|
---|
706 | gi.a1 = PI_ItalicFont;
|
---|
707 | GrAlines["italicfont"] = gi;
|
---|
708 | gi.a2 = PI_SmallSizeFont;
|
---|
709 | gi.a1 = PI_RomanFont;
|
---|
710 | GrAlines["smallfont"] = gi;
|
---|
711 | gi.a1 = PI_BoldFont;
|
---|
712 | GrAlines["smallboldfont"] = gi;
|
---|
713 | gi.a1 = PI_ItalicFont;
|
---|
714 | GrAlines["smallitalicfont"] = gi;
|
---|
715 | gi.a2 = PI_BigSizeFont;
|
---|
716 | gi.a1 = PI_RomanFont;
|
---|
717 | GrAlines["bigfont"] = gi;
|
---|
718 | gi.a1 = PI_BoldFont;
|
---|
719 | GrAlines["bigboldfont"] = gi;
|
---|
720 | gi.a1 = PI_ItalicFont;
|
---|
721 | GrAlines["bigitalicfont"] = gi;
|
---|
722 |
|
---|
723 |
|
---|
724 | // Les markers
|
---|
725 | char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
|
---|
726 | "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
|
---|
727 | "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
|
---|
728 | PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
|
---|
729 | PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
|
---|
730 | PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
|
---|
731 |
|
---|
732 | gi.a2 = 0;
|
---|
733 | gi.a1 = PI_NotDefMarker;
|
---|
734 | GrAmarkers["defmarker"] = gi;
|
---|
735 |
|
---|
736 | for(int j=0; j<11; j++) {
|
---|
737 | string smrk;
|
---|
738 | char buff[16];
|
---|
739 | for(int m=1; m<10; m+=2) {
|
---|
740 | sprintf(buff,"%d",m);
|
---|
741 | smrk = (string)mrkn[j] + (string)buff;
|
---|
742 | gi.a1 = mrk[j]; gi.a2 = m;
|
---|
743 | GrAmarkers[smrk] = gi;
|
---|
744 | }
|
---|
745 | }
|
---|
746 |
|
---|
747 | // Les tables de couleurs
|
---|
748 | gi.a2 = 0;
|
---|
749 | gi.a1 = CMAP_OTHER;
|
---|
750 | GrAcmap["defcmap"] = gi;
|
---|
751 | gi.a1 = CMAP_GREY32;
|
---|
752 | GrAcmap["grey32"] = gi;
|
---|
753 | gi.a1 = CMAP_GREYINV32;
|
---|
754 | GrAcmap["greyinv32"] = gi;
|
---|
755 | gi.a1 = CMAP_COLRJ32;
|
---|
756 | GrAcmap["colrj32"] = gi;
|
---|
757 | gi.a1 = CMAP_COLBR32;
|
---|
758 | GrAcmap["colbr32"] = gi;
|
---|
759 | gi.a1 = CMAP_GREY128;
|
---|
760 | GrAcmap["grey128"] = gi;
|
---|
761 | gi.a1 = CMAP_GREYINV128;
|
---|
762 | GrAcmap["greyinv128"] = gi;
|
---|
763 | gi.a1 = CMAP_COLRJ128;
|
---|
764 | GrAcmap["colrj128"] = gi;
|
---|
765 | gi.a1 = CMAP_COLBR128;
|
---|
766 | GrAcmap["colbr128"] = gi;
|
---|
767 |
|
---|
768 | // Les tables de couleurs
|
---|
769 | gi.a2 = 0;
|
---|
770 | gi.a1 = 0;
|
---|
771 | GrAzoom["defzoom"] = gi;
|
---|
772 | gi.a1 = 1;
|
---|
773 | GrAzoom["zoomx1"] = gi;
|
---|
774 | gi.a1 = 2;
|
---|
775 | GrAzoom["zoomx2"] = gi;
|
---|
776 | gi.a1 = 3;
|
---|
777 | GrAzoom["zoomx3"] = gi;
|
---|
778 | gi.a1 = 4;
|
---|
779 | GrAzoom["zoomx4"] = gi;
|
---|
780 | gi.a1 = 5;
|
---|
781 | GrAzoom["zoomx5"] = gi;
|
---|
782 | gi.a1 = -2;
|
---|
783 | GrAzoom["zoom/2"] = gi;
|
---|
784 | gi.a1 = -3;
|
---|
785 | GrAzoom["zoom/3"] = gi;
|
---|
786 | gi.a1 = -4;
|
---|
787 | GrAzoom["zoom/4"] = gi;
|
---|
788 | gi.a1 = -5;
|
---|
789 | GrAzoom["zoom/5"] = gi;
|
---|
790 |
|
---|
791 | }
|
---|