[658] | 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 | #ifdef SANS_EVOLPLANCK
|
---|
| 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 | #ifdef SANS_EVOLPLANCK
|
---|
| 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 | #ifdef SANS_EVOLPLANCK
|
---|
| 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 l = fn.length();
|
---|
| 373 | if (p >= l) p = 0;
|
---|
| 374 | else p++;
|
---|
| 375 | size_t q = fn.find_first_of(tsep,p);
|
---|
| 376 | if (q < p) q = l;
|
---|
| 377 | return(fn.substr(p,q-p));
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 |
|
---|
| 381 | typedef vector<string> GraTok;
|
---|
| 382 |
|
---|
| 383 | /* --Methode-- */
|
---|
| 384 | int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
|
---|
| 385 | {
|
---|
| 386 | int ropt = Disp_Next;
|
---|
| 387 | if (!mImgapp) return(ropt);
|
---|
| 388 |
|
---|
| 389 | for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
|
---|
| 390 |
|
---|
| 391 | if (fgsrgr) mImgapp->SaveGraphicAtt();
|
---|
| 392 |
|
---|
| 393 | if (gratt.substr(0,3) == "def") { // Remise aux valeurs par defaut = non defini
|
---|
| 394 | mImgapp->SetColAtt();
|
---|
| 395 | mImgapp->SetLineAtt();
|
---|
| 396 | mImgapp->SetFontAtt();
|
---|
| 397 | mImgapp->SetMarkerAtt();
|
---|
| 398 | mImgapp->SetColMapId();
|
---|
| 399 | mImgapp->SetZoomAtt();
|
---|
| 400 | return(ropt);
|
---|
| 401 | }
|
---|
| 402 |
|
---|
| 403 | // On separe en mots separes par des virgules
|
---|
| 404 | gratt = ","+gratt;
|
---|
| 405 | size_t p = 0;
|
---|
| 406 | size_t q = 0;
|
---|
| 407 | size_t l = gratt.length();
|
---|
| 408 | string token;
|
---|
| 409 |
|
---|
| 410 | GraTok grt;
|
---|
| 411 |
|
---|
| 412 | while (q < l) {
|
---|
| 413 | p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
|
---|
| 414 | if (p>=l) break;
|
---|
| 415 | q = gratt.find_first_of(" ,",p); // la fin du token;
|
---|
| 416 | token = gratt.substr(p,q-p);
|
---|
| 417 | grt.push_back(token);
|
---|
| 418 | }
|
---|
| 419 |
|
---|
| 420 |
|
---|
| 421 | static GrAttNames::iterator it;
|
---|
| 422 |
|
---|
| 423 | int k;
|
---|
| 424 | bool fgcont = true;
|
---|
| 425 | fgsrgr = false;
|
---|
| 426 |
|
---|
| 427 | for(k=0; k<grt.size(); k++) {
|
---|
| 428 | // cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
|
---|
| 429 |
|
---|
| 430 | // Decodage option affichage (win, next, etc
|
---|
| 431 | fgcont = true;
|
---|
| 432 | if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;
|
---|
| 433 | else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;
|
---|
| 434 | else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;
|
---|
| 435 | else fgcont = false;
|
---|
| 436 | if (fgcont) continue;
|
---|
| 437 |
|
---|
| 438 | // Si c'est une couleur
|
---|
| 439 | it = GrAcolors.find(grt[k]);
|
---|
| 440 | if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
| 441 | // Si c'est un attribut de lignes
|
---|
| 442 | it = GrAlines.find(grt[k]);
|
---|
| 443 | if (it != GrAlines.end()) { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
| 444 | // Si c'est un attribut de fontes
|
---|
| 445 | it = GrAfonts.find(grt[k]);
|
---|
| 446 | if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
|
---|
| 447 | fgsrgr = true; continue; }
|
---|
| 448 | // Si c'est un attribut de markers
|
---|
| 449 | it = GrAmarkers.find(grt[k]);
|
---|
| 450 | if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
|
---|
| 451 | fgsrgr = true; continue; }
|
---|
| 452 | // Si c'est un colormap
|
---|
| 453 | it = GrAcmap.find(grt[k]);
|
---|
| 454 | if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }
|
---|
| 455 | // Si c'est un facteur de zoom
|
---|
| 456 | it = GrAzoom.find(grt[k]);
|
---|
| 457 | if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
| 458 | // Si c'est un attribut d'axe
|
---|
| 459 | it = GrAaxes.find(grt[k]);
|
---|
| 460 | if (it != GrAaxes.end()) { mImgapp->SetAxesAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
| 461 |
|
---|
| 462 | }
|
---|
| 463 |
|
---|
| 464 | return(ropt);
|
---|
| 465 | }
|
---|
| 466 |
|
---|
| 467 | /* --Methode-- */
|
---|
| 468 | char* Services2NObjMgr::PClassIdToClassName(int cid)
|
---|
| 469 | {
|
---|
| 470 | switch (cid) {
|
---|
| 471 | case ClassId_Poly1 :
|
---|
| 472 | return("Poly1");
|
---|
| 473 | case ClassId_Poly2 :
|
---|
| 474 | return("Poly2");
|
---|
| 475 | case ClassId_Matrix :
|
---|
| 476 | return("Matrix");
|
---|
| 477 | case ClassId_Vector :
|
---|
| 478 | return("Vector");
|
---|
| 479 |
|
---|
| 480 | case ClassId_DVList :
|
---|
| 481 | return("DVList");
|
---|
| 482 |
|
---|
| 483 | case ClassId_Histo1D :
|
---|
| 484 | return("Histo1D");
|
---|
| 485 | case ClassId_Histo2D :
|
---|
| 486 | return("Histo2D");
|
---|
| 487 | case ClassId_HProf :
|
---|
| 488 | return("HProf");
|
---|
| 489 | case ClassId_NTuple :
|
---|
| 490 | return("NTuple");
|
---|
| 491 | case ClassId_GeneralFitData :
|
---|
| 492 | return("GeneralFitData");
|
---|
| 493 |
|
---|
| 494 | case ClassId_Image :
|
---|
| 495 | return("RzImage");
|
---|
| 496 | case ClassId_Image + kuint_1 :
|
---|
| 497 | return("ImageU1");
|
---|
| 498 | case ClassId_Image + kint_1 :
|
---|
| 499 | return("ImageI1");
|
---|
| 500 | case ClassId_Image + kuint_2 :
|
---|
| 501 | return("ImageU2");
|
---|
| 502 | case ClassId_Image + kint_2 :
|
---|
| 503 | return("ImageI2");
|
---|
| 504 | case ClassId_Image + kuint_4 :
|
---|
| 505 | return("ImageU4");
|
---|
| 506 | case ClassId_Image + kint_4 :
|
---|
| 507 | return("ImageI4");
|
---|
| 508 | case ClassId_Image + kr_4 :
|
---|
| 509 | return("ImageR4");
|
---|
| 510 | case ClassId_Image + kr_8 :
|
---|
| 511 | return("ImageR8");
|
---|
| 512 |
|
---|
| 513 | case ClassId_ZFidu :
|
---|
| 514 | return("ZFidu");
|
---|
| 515 |
|
---|
| 516 | #ifdef SANS_EVOLPLANCK
|
---|
| 517 | case ClassId_StarList :
|
---|
| 518 | return("StarList");
|
---|
| 519 | case ClassId_Transfo :
|
---|
| 520 | return("Transfo");
|
---|
| 521 | case ClassId_PSF :
|
---|
| 522 | return("PSF");
|
---|
| 523 |
|
---|
| 524 | case ClassId_Star + BStar_Type :
|
---|
| 525 | return("BStar");
|
---|
| 526 | case ClassId_Star + RzStar_Type :
|
---|
| 527 | return("RzStar");
|
---|
| 528 | case ClassId_Star + PSFStar_Type :
|
---|
| 529 | return("PSFStar");
|
---|
| 530 | case ClassId_Star + MCStar_Type :
|
---|
| 531 | return("MCStar");
|
---|
| 532 | case ClassId_Star + CircRFixStar_Type :
|
---|
| 533 | return("CircRFixStar");
|
---|
| 534 | case ClassId_Star + PSFDHStar_Type :
|
---|
| 535 | return("PSFDHStar");
|
---|
| 536 | case ClassId_Star + PSFSEStar_Type :
|
---|
| 537 | return("PSFSEStar");
|
---|
| 538 | case ClassId_Star + MCDHStar_Type :
|
---|
| 539 | return("MCDHStar");
|
---|
| 540 | #endif
|
---|
| 541 |
|
---|
| 542 | // - Ajout objet PPF
|
---|
| 543 | default:
|
---|
| 544 | return("Unknown");
|
---|
| 545 | }
|
---|
| 546 | }
|
---|
| 547 |
|
---|
| 548 | /* --Methode-- */
|
---|
| 549 | char* Services2NObjMgr::PClassIdToShortClassName(int cid)
|
---|
| 550 | {
|
---|
| 551 | switch (cid) {
|
---|
| 552 | case ClassId_Poly1 :
|
---|
| 553 | case ClassId_Poly2 :
|
---|
| 554 | return("Poly");
|
---|
| 555 | case ClassId_Matrix :
|
---|
| 556 | return("Mtx");
|
---|
| 557 | case ClassId_Vector :
|
---|
| 558 | return("Vec");
|
---|
| 559 | case ClassId_DVList :
|
---|
| 560 | return("Dvl");
|
---|
| 561 |
|
---|
| 562 | case ClassId_Histo1D :
|
---|
| 563 | return("H1D");
|
---|
| 564 | case ClassId_Histo2D :
|
---|
| 565 | return("H2D");
|
---|
| 566 | case ClassId_HProf :
|
---|
| 567 | return("HPF");
|
---|
| 568 | case ClassId_NTuple :
|
---|
| 569 | return("NT");
|
---|
| 570 | case ClassId_GeneralFitData :
|
---|
| 571 | return("GFD");
|
---|
| 572 |
|
---|
| 573 | case ClassId_Image :
|
---|
| 574 | case ClassId_Image + kuint_1 :
|
---|
| 575 | case ClassId_Image + kint_1 :
|
---|
| 576 | case ClassId_Image + kuint_2 :
|
---|
| 577 | case ClassId_Image + kint_2 :
|
---|
| 578 | case ClassId_Image + kuint_4 :
|
---|
| 579 | case ClassId_Image + kint_4 :
|
---|
| 580 | case ClassId_Image + kr_4 :
|
---|
| 581 | case ClassId_Image + kr_8 :
|
---|
| 582 | return("Img");
|
---|
| 583 |
|
---|
| 584 | case ClassId_ZFidu :
|
---|
| 585 | return("Fidu");
|
---|
| 586 |
|
---|
| 587 | #ifdef SANS_EVOLPLANCK
|
---|
| 588 | case ClassId_StarList :
|
---|
| 589 | return("Stl");
|
---|
| 590 | case ClassId_Transfo :
|
---|
| 591 | return("Tr");
|
---|
| 592 | case ClassId_PSF :
|
---|
| 593 | return("PSF");
|
---|
| 594 |
|
---|
| 595 | case ClassId_Star + BStar_Type :
|
---|
| 596 | case ClassId_Star + RzStar_Type :
|
---|
| 597 | case ClassId_Star + PSFStar_Type :
|
---|
| 598 | case ClassId_Star + MCStar_Type :
|
---|
| 599 | case ClassId_Star + CircRFixStar_Type :
|
---|
| 600 | case ClassId_Star + PSFDHStar_Type :
|
---|
| 601 | case ClassId_Star + PSFSEStar_Type :
|
---|
| 602 | case ClassId_Star + MCDHStar_Type :
|
---|
| 603 | return("Star");
|
---|
| 604 | #endif
|
---|
| 605 |
|
---|
| 606 | // - Ajout objet PPF
|
---|
| 607 | default:
|
---|
| 608 | return("U");
|
---|
| 609 | }
|
---|
| 610 | }
|
---|
| 611 |
|
---|
| 612 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
| 613 | // Initialisation des chaines de caracteres designant les attributs graphiques
|
---|
| 614 |
|
---|
| 615 | /* --Methode-- */
|
---|
| 616 | void Services2NObjMgr::InitGrAttNames()
|
---|
| 617 | {
|
---|
| 618 | gratt_item gi;
|
---|
| 619 | // Les couleurs
|
---|
| 620 | gi.a2 = 0;
|
---|
| 621 | gi.a1 = PI_NotDefColor;
|
---|
| 622 | GrAcolors["defcol"] = gi;
|
---|
| 623 | gi.a1 = PI_Black;
|
---|
| 624 | GrAcolors["black"] = gi;
|
---|
| 625 | gi.a1 = PI_White;
|
---|
| 626 | GrAcolors["white"] = gi;
|
---|
| 627 | gi.a1 = PI_Grey;
|
---|
| 628 | GrAcolors["grey"] = gi;
|
---|
| 629 | gi.a1 = PI_Red;
|
---|
| 630 | GrAcolors["red"] = gi;
|
---|
| 631 | gi.a1 = PI_Blue;
|
---|
| 632 | GrAcolors["blue"] = gi;
|
---|
| 633 | gi.a1 = PI_Green;
|
---|
| 634 | GrAcolors["green"] = gi;
|
---|
| 635 | gi.a1 = PI_Yellow;
|
---|
| 636 | GrAcolors["yellow"] = gi;
|
---|
| 637 | gi.a1 = PI_Magenta;
|
---|
| 638 | GrAcolors["magenta"] = gi;
|
---|
| 639 |
|
---|
| 640 | gi.a1 = PI_Cyan;
|
---|
| 641 | GrAcolors["cyan"] = gi;
|
---|
| 642 | gi.a1 = PI_Turquoise;
|
---|
| 643 | GrAcolors["turquoise"] = gi;
|
---|
| 644 | gi.a1 = PI_NavyBlue;
|
---|
| 645 | GrAcolors["navyblue"] = gi;
|
---|
| 646 | gi.a1 = PI_Orange;
|
---|
| 647 | GrAcolors["orange"] = gi;
|
---|
| 648 | gi.a1 = PI_SiennaRed;
|
---|
| 649 | GrAcolors["siennared"] = gi;
|
---|
| 650 | gi.a1 = PI_Purple;
|
---|
| 651 | GrAcolors["purple"] = gi;
|
---|
| 652 | gi.a1 = PI_LimeGreen;
|
---|
| 653 | GrAcolors["limegreen"] = gi;
|
---|
| 654 | gi.a1 = PI_Gold;
|
---|
| 655 | GrAcolors["gold"] = gi;
|
---|
| 656 |
|
---|
| 657 | // Les attributs de lignes
|
---|
| 658 | gi.a2 = 0;
|
---|
| 659 | gi.a1 = PI_NotDefLineAtt;
|
---|
| 660 | GrAlines["defline"] = gi;
|
---|
| 661 | gi.a1 = PI_NormalLine;
|
---|
| 662 | GrAlines["normalline"] = gi;
|
---|
| 663 | gi.a1 = PI_ThinLine;
|
---|
| 664 | GrAlines["thinline"] = gi;
|
---|
| 665 | gi.a1 = PI_ThickLine;
|
---|
| 666 | GrAlines["thickline"] = gi;
|
---|
| 667 | gi.a1 = PI_DashedLine;
|
---|
| 668 | GrAlines["dashedline"] = gi;
|
---|
| 669 | gi.a1 = PI_ThinDashedLine;
|
---|
| 670 | GrAlines["thindashedline"] = gi;
|
---|
| 671 | gi.a1 = PI_ThickDashedLine;
|
---|
| 672 | GrAlines["thickdashedline"] = gi;
|
---|
| 673 | gi.a1 = PI_DottedLine;
|
---|
| 674 | GrAlines["dottedline"] = gi;
|
---|
| 675 | gi.a1 = PI_ThinDottedLine;
|
---|
| 676 | GrAlines["thindottedline"] = gi;
|
---|
| 677 | gi.a1 = PI_ThickDottedLine;
|
---|
| 678 | GrAlines["thickdottedline"] = gi;
|
---|
| 679 |
|
---|
| 680 | // Les fontes (a faire)
|
---|
| 681 | gi.a2 = PI_NotDefFontSize;
|
---|
| 682 | gi.a1 = PI_NotDefFontAtt;
|
---|
| 683 | GrAlines["deffont"] = gi;
|
---|
| 684 |
|
---|
| 685 | gi.a2 = PI_NormalSizeFont;
|
---|
| 686 | gi.a1 = PI_RomanFont;
|
---|
| 687 | GrAlines["normalfont"] = gi;
|
---|
| 688 | gi.a1 = PI_BoldFont;
|
---|
| 689 | GrAlines["boldfont"] = gi;
|
---|
| 690 | gi.a1 = PI_ItalicFont;
|
---|
| 691 | GrAlines["italicfont"] = gi;
|
---|
| 692 | gi.a2 = PI_SmallSizeFont;
|
---|
| 693 | gi.a1 = PI_RomanFont;
|
---|
| 694 | GrAlines["smallfont"] = gi;
|
---|
| 695 | gi.a1 = PI_BoldFont;
|
---|
| 696 | GrAlines["smallboldfont"] = gi;
|
---|
| 697 | gi.a1 = PI_ItalicFont;
|
---|
| 698 | GrAlines["smallitalicfont"] = gi;
|
---|
| 699 | gi.a2 = PI_BigSizeFont;
|
---|
| 700 | gi.a1 = PI_RomanFont;
|
---|
| 701 | GrAlines["bigfont"] = gi;
|
---|
| 702 | gi.a1 = PI_BoldFont;
|
---|
| 703 | GrAlines["bigboldfont"] = gi;
|
---|
| 704 | gi.a1 = PI_ItalicFont;
|
---|
| 705 | GrAlines["bigitalicfont"] = gi;
|
---|
| 706 | gi.a2 = PI_HugeSizeFont;
|
---|
| 707 | gi.a1 = PI_RomanFont;
|
---|
| 708 | GrAlines["hugefont"] = gi;
|
---|
| 709 | gi.a1 = PI_BoldFont;
|
---|
| 710 | GrAlines["hugeboldfont"] = gi;
|
---|
| 711 | gi.a1 = PI_ItalicFont;
|
---|
| 712 | GrAlines["hugeitalicfont"] = gi;
|
---|
| 713 |
|
---|
| 714 |
|
---|
| 715 | // Les markers
|
---|
| 716 | const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
|
---|
| 717 | "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
|
---|
| 718 | "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
|
---|
| 719 | PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
|
---|
| 720 | PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
|
---|
| 721 | PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
|
---|
| 722 |
|
---|
| 723 | gi.a2 = 0;
|
---|
| 724 | gi.a1 = PI_NotDefMarker;
|
---|
| 725 | GrAmarkers["defmarker"] = gi;
|
---|
| 726 |
|
---|
| 727 | for(int j=0; j<11; j++) {
|
---|
| 728 | string smrk;
|
---|
| 729 | char buff[16];
|
---|
| 730 | for(int m=1; m<10; m+=2) {
|
---|
| 731 | sprintf(buff,"%d",m);
|
---|
| 732 | smrk = (string)mrkn[j] + (string)buff;
|
---|
| 733 | gi.a1 = mrk[j]; gi.a2 = m;
|
---|
| 734 | GrAmarkers[smrk] = gi;
|
---|
| 735 | }
|
---|
| 736 | }
|
---|
| 737 |
|
---|
| 738 | // Les tables de couleurs
|
---|
| 739 | gi.a2 = 0;
|
---|
| 740 | gi.a1 = CMAP_OTHER;
|
---|
| 741 | GrAcmap["defcmap"] = gi;
|
---|
| 742 | gi.a1 = CMAP_GREY32;
|
---|
| 743 | GrAcmap["grey32"] = gi;
|
---|
| 744 | gi.a1 = CMAP_GREYINV32;
|
---|
| 745 | GrAcmap["greyinv32"] = gi;
|
---|
| 746 | gi.a1 = CMAP_COLRJ32;
|
---|
| 747 | GrAcmap["colrj32"] = gi;
|
---|
| 748 | gi.a1 = CMAP_COLBR32;
|
---|
| 749 | GrAcmap["colbr32"] = gi;
|
---|
| 750 | gi.a1 = CMAP_GREY128;
|
---|
| 751 | GrAcmap["grey128"] = gi;
|
---|
| 752 | gi.a1 = CMAP_GREYINV128;
|
---|
| 753 | GrAcmap["greyinv128"] = gi;
|
---|
| 754 | gi.a1 = CMAP_COLRJ128;
|
---|
| 755 | GrAcmap["colrj128"] = gi;
|
---|
| 756 | gi.a1 = CMAP_COLBR128;
|
---|
| 757 | GrAcmap["colbr128"] = gi;
|
---|
| 758 |
|
---|
| 759 | // La valeur de zoom
|
---|
| 760 | gi.a2 = 0;
|
---|
| 761 | gi.a1 = 0;
|
---|
| 762 | GrAzoom["defzoom"] = gi;
|
---|
| 763 | gi.a1 = 1;
|
---|
| 764 | GrAzoom["zoomx1"] = gi;
|
---|
| 765 | gi.a1 = 2;
|
---|
| 766 | GrAzoom["zoomx2"] = gi;
|
---|
| 767 | gi.a1 = 3;
|
---|
| 768 | GrAzoom["zoomx3"] = gi;
|
---|
| 769 | gi.a1 = 4;
|
---|
| 770 | GrAzoom["zoomx4"] = gi;
|
---|
| 771 | gi.a1 = 5;
|
---|
| 772 | GrAzoom["zoomx5"] = gi;
|
---|
| 773 | gi.a1 = -2;
|
---|
| 774 | GrAzoom["zoom/2"] = gi;
|
---|
| 775 | gi.a1 = -3;
|
---|
| 776 | GrAzoom["zoom/3"] = gi;
|
---|
| 777 | gi.a1 = -4;
|
---|
| 778 | GrAzoom["zoom/4"] = gi;
|
---|
| 779 | gi.a1 = -5;
|
---|
| 780 | GrAzoom["zoom/5"] = gi;
|
---|
| 781 |
|
---|
| 782 | // Attributs d'axes
|
---|
| 783 | gi.a2 = 0;
|
---|
| 784 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
|
---|
| 785 | GrAaxes["stdaxes"] = gi;
|
---|
| 786 | GrAaxes["defaxes"] = gi;
|
---|
| 787 | GrAaxes["boxaxes"] = gi;
|
---|
| 788 | gi.a1 = (int)kAxesDflt;
|
---|
| 789 | GrAaxes["simpleaxes"] = gi;
|
---|
| 790 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
|
---|
| 791 | GrAaxes["boxaxesgrid"] = gi;
|
---|
| 792 |
|
---|
| 793 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
|
---|
| 794 | GrAaxes["fineaxes"] = gi;
|
---|
| 795 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
|
---|
| 796 | GrAaxes["grid"] = gi;
|
---|
| 797 | GrAaxes["fineaxesgrid"] = gi;
|
---|
| 798 |
|
---|
| 799 | }
|
---|