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