[165] | 1 | #include <stdio.h>
|
---|
| 2 | #include <stdlib.h>
|
---|
| 3 | #include <ctype.h>
|
---|
| 4 |
|
---|
[295] | 5 | #include <typeinfo>
|
---|
[165] | 6 | #include <iostream.h>
|
---|
| 7 | #include <string>
|
---|
| 8 | #include <list>
|
---|
| 9 | #include <map>
|
---|
| 10 | #if defined(__KCC__)
|
---|
| 11 | using std::string ;
|
---|
| 12 | #include <list.h>
|
---|
| 13 | #include <map.h>
|
---|
| 14 | #endif
|
---|
| 15 |
|
---|
| 16 | #include "strutil.h"
|
---|
| 17 |
|
---|
| 18 | #include "nobjmgr.h"
|
---|
| 19 | #include "servnobjm.h"
|
---|
[330] | 20 | #include "nomgadapter.h"
|
---|
[165] | 21 | #include "pistdimgapp.h"
|
---|
| 22 |
|
---|
| 23 | #include "histos.h"
|
---|
| 24 | #include "histos2.h"
|
---|
| 25 | #include "ntuple.h"
|
---|
| 26 | #include "hisprof.h"
|
---|
| 27 |
|
---|
[326] | 28 | #include "piscdrawwdg.h"
|
---|
| 29 | #include "pisurfdr.h"
|
---|
| 30 | #include "pipodrw.h"
|
---|
[165] | 31 |
|
---|
| 32 |
|
---|
[326] | 33 |
|
---|
[165] | 34 | /* --Methode-- */
|
---|
| 35 | Services2NObjMgr::Services2NObjMgr(PIStdImgApp* app, string& tmpdir)
|
---|
| 36 | {
|
---|
| 37 | TmpDir = tmpdir;
|
---|
[171] | 38 | PDynLinkMgr::SetTmpDir(tmpdir);
|
---|
[165] | 39 | mImgapp = app;
|
---|
[171] | 40 | dynlink = NULL;
|
---|
[165] | 41 | InitGrAttNames();
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | /* --Methode-- */
|
---|
| 45 | Services2NObjMgr::~Services2NObjMgr()
|
---|
| 46 | {
|
---|
| 47 | CloseDLL();
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | /* --Methode-- */
|
---|
[295] | 51 | void Services2NObjMgr::RegisterClass(AnyDataObj* o, NObjMgrAdapter* oa)
|
---|
[165] | 52 | {
|
---|
[295] | 53 | ObjAdaptList::iterator it;
|
---|
| 54 | for(it = objadaplist.begin(); it != objadaplist.end(); it++)
|
---|
| 55 | if (typeid(*o) == typeid(*((*it).obj))) THROW(dupIdErr);
|
---|
[165] | 56 |
|
---|
[295] | 57 | dataobj_adapter oba;
|
---|
| 58 | oba.obj = o;
|
---|
| 59 | oba.obja = oa;
|
---|
| 60 | objadaplist.push_back(oba);
|
---|
| 61 | }
|
---|
[165] | 62 |
|
---|
[295] | 63 | /* --Methode-- */
|
---|
| 64 | NObjMgrAdapter* Services2NObjMgr::GetAdapter(AnyDataObj* o)
|
---|
| 65 | {
|
---|
| 66 | ObjAdaptList::iterator it;
|
---|
| 67 | for(it = objadaplist.begin(); it != objadaplist.end(); it++)
|
---|
| 68 | if (typeid(*o) == typeid(*((*it).obj))) return((*it).obja->Clone(o));
|
---|
| 69 | return(new NObjMgrAdapter(o));
|
---|
| 70 | }
|
---|
[165] | 71 |
|
---|
[295] | 72 | /* --Methode-- */
|
---|
| 73 | void Services2NObjMgr::Nobj_ComputeExpressions(NObjMgrAdapter* obja, string& expx, string& expy, string& expz,
|
---|
| 74 | string& expwt, string& expcut, NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
|
---|
| 75 | {
|
---|
| 76 | if (obja == NULL) return;
|
---|
| 77 | NTupleInterface* objnt = obja->GetNTupleInterface();
|
---|
| 78 | if (objnt == NULL) return;
|
---|
| 79 | string vardec = objnt->VarList_C("_zz61qq_");
|
---|
[165] | 80 |
|
---|
| 81 | PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expwt, expcut);
|
---|
| 82 | if (!f) {
|
---|
| 83 | cerr << "NamedObjMgr_ComputeExpressions() Error Creation PlotExprFunc " << endl;
|
---|
| 84 | return;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
[295] | 87 | double xnt[10];
|
---|
| 88 | float fxnt[10];
|
---|
[165] | 89 |
|
---|
| 90 | int i,j,k;
|
---|
[295] | 91 | for(i=0; i<10; i++) xnt[i] = 0.;
|
---|
[165] | 92 |
|
---|
[295] | 93 | TRY {
|
---|
| 94 | double* xn;
|
---|
| 95 | for(k=0; k<objnt->NbLines(); k++) {
|
---|
| 96 | xn = objnt->GetLineD(k);
|
---|
| 97 | if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
|
---|
| 98 | if (nt) {
|
---|
| 99 | for(i=0; i<4; i++) fxnt[i] = xnt[i];
|
---|
| 100 | nt->Fill(fxnt);
|
---|
| 101 | }
|
---|
| 102 | if (h1) h1->Add(xnt[0], xnt[3]);
|
---|
| 103 | if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
|
---|
| 104 | if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
|
---|
[165] | 105 | }
|
---|
| 106 | }
|
---|
[295] | 107 | }
|
---|
| 108 | CATCH(merr) {
|
---|
[165] | 109 | fflush(stdout);
|
---|
| 110 | cout << endl;
|
---|
| 111 | cerr << endl;
|
---|
| 112 | string es = PeidaExc(merr);
|
---|
| 113 | cerr << "NamedObjMgr_ComputeExpressions() Exception :" << merr << es;
|
---|
| 114 | } ENDTRY;
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 | // Fermeture du fichier .so
|
---|
| 118 | CloseDLL();
|
---|
| 119 | return;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 |
|
---|
| 123 | /* --Methode-- */
|
---|
| 124 | PlotExprFunc Services2NObjMgr::LinkExprFunc(string& vardec, string& expx, string& expy, string& expz,
|
---|
| 125 | string& expwt, string& cut)
|
---|
| 126 | {
|
---|
| 127 | FILE *fip;
|
---|
| 128 | string fname = TmpDir + "expf_pia_dl.c";
|
---|
| 129 | string cmd;
|
---|
| 130 | int rc;
|
---|
| 131 |
|
---|
[293] | 132 | cmd = "rm -f " + fname;
|
---|
[165] | 133 | rc = system(cmd.c_str());
|
---|
| 134 | //DBG printf("LinkExprFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
| 135 |
|
---|
| 136 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 137 | string sn = fname;
|
---|
| 138 | cout << "NamedObjMgr/LinkExprFunc_Erreur: Pb. Ouverture " << sn << endl;
|
---|
| 139 | return(NULL);
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | // constitution du fichier a compiler
|
---|
| 143 | fputs("#include <math.h> \n", fip);
|
---|
[295] | 144 | fputs("int expf_pia_dl_func(double* _zz61qq_, double* _rx_61qq_, double* _ry_61qq_, double* _rz_61qq_, double* _wt_61qq_) \n{\n", fip);
|
---|
[165] | 145 | fprintf(fip,"%s \n", vardec.c_str());
|
---|
| 146 | fprintf(fip, "if (!(%s)) { *_rx_61qq_ = *_ry_61qq_ = *_rz_61qq_ = *_wt_61qq_ = 0.; return(0); } \n", cut.c_str());
|
---|
| 147 | fprintf(fip, "*_rx_61qq_ = %s ; \n", expx.c_str());
|
---|
| 148 | fprintf(fip, "*_ry_61qq_ = %s ; \n", expy.c_str());
|
---|
| 149 | fprintf(fip, "*_rz_61qq_ = %s ; \n", expz.c_str());
|
---|
| 150 | fprintf(fip, "*_wt_61qq_ = %s ; \n", expwt.c_str());
|
---|
| 151 | fputs("return(1); \n} \n", fip);
|
---|
| 152 | fclose(fip);
|
---|
[326] | 153 | string func = "expf_pia_dl_func";
|
---|
| 154 | return((PlotExprFunc)LinkFunctionFromFile(fname, func));
|
---|
[165] | 155 | }
|
---|
| 156 |
|
---|
| 157 |
|
---|
| 158 | /* --Methode-- */
|
---|
[326] | 159 | DlFunction Services2NObjMgr::LinkFunctionFromFile(string const & fname, string const & funcname)
|
---|
[165] | 160 | {
|
---|
| 161 | // Le link dynamique
|
---|
| 162 | CloseDLL();
|
---|
[171] | 163 | dynlink = PDynLinkMgr::BuildFromCFile(fname);
|
---|
| 164 | if (dynlink == NULL) {
|
---|
[326] | 165 | cerr << "NamedObjMgr/LinkFunctionFromFile_Erreur: Erreur creation/Ouverture SO " << endl;
|
---|
[165] | 166 | return(NULL);
|
---|
| 167 | }
|
---|
| 168 |
|
---|
[171] | 169 | DlFunction retfunc = dynlink->GetFunction(funcname);
|
---|
[165] | 170 | if (retfunc == NULL) {
|
---|
| 171 | string sn = funcname;
|
---|
| 172 | cerr << "NamedObjMgr/LinkExprFunc_Erreur: Erreur linking " << sn << endl;
|
---|
| 173 | CloseDLL();
|
---|
| 174 | return(NULL);
|
---|
| 175 | }
|
---|
| 176 | else return(retfunc);
|
---|
| 177 | }
|
---|
| 178 |
|
---|
| 179 | /* --Methode-- */
|
---|
| 180 | void Services2NObjMgr::CloseDLL()
|
---|
| 181 | {
|
---|
[171] | 182 | if (dynlink) delete dynlink; dynlink = NULL;
|
---|
[165] | 183 | }
|
---|
| 184 |
|
---|
| 185 | /* --Methode-- */
|
---|
[326] | 186 | void Services2NObjMgr::PlotFunc(string const & expfunc, float xmin, float xmax, int np, string dopt)
|
---|
| 187 | {
|
---|
| 188 | FILE *fip;
|
---|
| 189 | string fname = TmpDir + "func1_pia_dl.c";
|
---|
| 190 | string cmd;
|
---|
| 191 | int rc;
|
---|
| 192 |
|
---|
| 193 | if (!mImgapp) return;
|
---|
| 194 |
|
---|
| 195 | cmd = "rm -f " + fname;
|
---|
| 196 | rc = system(cmd.c_str());
|
---|
| 197 | // printf("PlotFunc_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
| 198 |
|
---|
| 199 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 200 | string sn = fname;
|
---|
| 201 | cout << "NamedObjMgr/PlotFunc_Erreur: Pb. Ouverture " << sn << endl;
|
---|
| 202 | return;
|
---|
| 203 | }
|
---|
| 204 |
|
---|
| 205 | // constitution du fichier a compiler
|
---|
| 206 | fputs("#include <math.h> \n", fip);
|
---|
| 207 | fputs("double func1_pia_dl_func(double x) \n{\n", fip);
|
---|
| 208 | fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
|
---|
| 209 | fclose(fip);
|
---|
| 210 |
|
---|
| 211 | string func = "func1_pia_dl_func";
|
---|
| 212 | DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
|
---|
| 213 | if (!f) return;
|
---|
| 214 | PlotFunc(f, xmin, xmax, np, dopt);
|
---|
| 215 | CloseDLL();
|
---|
| 216 | return;
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 | /* --Methode-- */
|
---|
| 220 | void Services2NObjMgr::PlotFunc2D(string const & expfunc, float xmin, float xmax, float ymin, float ymax,
|
---|
| 221 | int npx, int npy, string dopt)
|
---|
| 222 | {
|
---|
| 223 | FILE *fip;
|
---|
| 224 | string fname = TmpDir + "func2_pia_dl.c";
|
---|
| 225 | string cmd;
|
---|
| 226 | int rc;
|
---|
| 227 |
|
---|
| 228 | if (!mImgapp) return;
|
---|
| 229 |
|
---|
| 230 | cmd = "rm " + fname;
|
---|
| 231 | rc = system(cmd.c_str());
|
---|
| 232 | // printf("PlotFunc2D_Do> %s (Rc=%d)\n", cmd.c_str(), rc);
|
---|
| 233 |
|
---|
| 234 | if ((fip = fopen(fname.c_str(), "w")) == NULL) {
|
---|
| 235 | string sn = fname;
|
---|
| 236 | cout << "NamedObjMgr/PlotFunc2D_Erreur: Pb. Ouverture " << sn << endl;
|
---|
| 237 | return;
|
---|
| 238 | }
|
---|
| 239 |
|
---|
| 240 | // constitution du fichier a compiler
|
---|
| 241 | fputs("#include <math.h> \n", fip);
|
---|
| 242 | fputs("double func2_pia_dl_func(double x, double y) \n{\n", fip);
|
---|
| 243 | fprintf(fip,"return(%s); \n}\n", expfunc.c_str());
|
---|
| 244 | fclose(fip);
|
---|
| 245 |
|
---|
| 246 | string func = "func2_pia_dl_func";
|
---|
| 247 | DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
|
---|
| 248 | if (!f) return;
|
---|
| 249 | PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
|
---|
| 250 | CloseDLL();
|
---|
| 251 | return;
|
---|
| 252 | }
|
---|
| 253 |
|
---|
| 254 | /* --Methode-- */
|
---|
| 255 | void Services2NObjMgr::PlotFuncFrCFile(string const & fname, string const & func, float xmin, float xmax,
|
---|
| 256 | int np, string dopt)
|
---|
| 257 | {
|
---|
| 258 | DlFunctionOfX f = (DlFunctionOfX) LinkFunctionFromFile(fname, func);
|
---|
| 259 | if (!f) return;
|
---|
| 260 | PlotFunc(f, xmin, xmax, np, dopt);
|
---|
| 261 | CloseDLL();
|
---|
| 262 | return;
|
---|
| 263 | }
|
---|
| 264 |
|
---|
| 265 | /* --Methode-- */
|
---|
| 266 | void Services2NObjMgr::PlotFunc2DFrCFile(string const & fname, string const & func, float xmin, float xmax,
|
---|
| 267 | float ymin, float ymax, int npx, int npy, string dopt)
|
---|
| 268 | {
|
---|
| 269 | DlFunctionOfXY f = (DlFunctionOfXY) LinkFunctionFromFile(fname, func);
|
---|
| 270 | if (!f) return;
|
---|
| 271 | PlotFunc2D(f, xmin, xmax, ymin, ymax, npx, npy, dopt);
|
---|
| 272 | CloseDLL();
|
---|
| 273 | return;
|
---|
| 274 | }
|
---|
| 275 |
|
---|
| 276 | /* --Methode-- */
|
---|
| 277 | void Services2NObjMgr::PlotFunc(DlFunctionOfX f, float xmin, float xmax, int np, string dopt)
|
---|
| 278 | {
|
---|
| 279 | if (!mImgapp) return;
|
---|
| 280 |
|
---|
| 281 | int k;
|
---|
| 282 | if (np < 1) np = 1;
|
---|
| 283 | if (xmax <= xmin) xmax = xmin+1.;
|
---|
| 284 | Vector* vpy = new Vector(np);
|
---|
| 285 |
|
---|
| 286 | double xx;
|
---|
| 287 | double dx = (xmax-xmin)/np;
|
---|
| 288 | TRY {
|
---|
| 289 | for(k=0; k<np; k++) { xx = xmin+dx*k; (*vpy)(k) = f(xx); }
|
---|
| 290 | } CATCH(merr) {
|
---|
| 291 | fflush(stdout);
|
---|
| 292 | cout << endl;
|
---|
| 293 | cerr << endl;
|
---|
| 294 | string es = PeidaExc(merr);
|
---|
| 295 | cerr << "Services2NObjMgr::PlotFunc() Exception :" << merr << es;
|
---|
| 296 | delete vpy;
|
---|
| 297 | vpy = NULL;
|
---|
| 298 | } ENDTRY;
|
---|
| 299 |
|
---|
| 300 |
|
---|
| 301 | if (vpy) {
|
---|
| 302 | string nom = "Func";
|
---|
| 303 | P1DArrayAdapter* vya = new POVectorAdapter(vpy, true);
|
---|
| 304 | vya->DefineXCoordinate(xmin, (xmax-xmin)/np);
|
---|
| 305 | PIYfXDrawer* dr = new PIYfXDrawer(vya, NULL, true) ;
|
---|
| 306 | bool fgsr = true;
|
---|
| 307 | dopt = "thinline," + dopt;
|
---|
| 308 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
| 309 | int wrsid = mImgapp->DispScDrawer(dr, nom, opt);
|
---|
| 310 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
| 311 | }
|
---|
| 312 |
|
---|
| 313 | return;
|
---|
| 314 | }
|
---|
| 315 |
|
---|
| 316 | /* --Methode-- */
|
---|
| 317 | void Services2NObjMgr::PlotFunc2D(DlFunctionOfXY f, float xmin, float xmax, float ymin, float ymax,
|
---|
| 318 | int npx, int npy, string dopt)
|
---|
| 319 | {
|
---|
| 320 | if (!mImgapp) return;
|
---|
| 321 |
|
---|
| 322 | if (npx < 3) npx = 3;
|
---|
| 323 | if (npy < 3) npy = 3;
|
---|
| 324 | if (npx > 250) npx = 250;
|
---|
| 325 | if (npy > 250) npy = 250;
|
---|
| 326 | if (xmax <= xmin) xmax = xmin+1.;
|
---|
| 327 | if (ymax <= ymin) ymax = ymin+1.;
|
---|
| 328 |
|
---|
| 329 | Matrix* mtx = new Matrix(npy, npx);
|
---|
| 330 |
|
---|
| 331 | int i,j;
|
---|
| 332 | double xx, yy;
|
---|
| 333 | double dx = (xmax-xmin)/npx;
|
---|
| 334 | double dy = (ymax-ymin)/npy;
|
---|
| 335 | // printf(" -- DBG -- %d %d , %g %g , %g %g \n", npx, npy, xmin, xmax, ymin, ymax);
|
---|
| 336 | TRY {
|
---|
| 337 | for(j=0; j<npy; j++) {
|
---|
| 338 | yy = ymin+dy*j;
|
---|
| 339 | for(i=0; i<npx; i++) {
|
---|
| 340 | xx = xmin+dx*i;
|
---|
| 341 | (*mtx)(j, i) = f(xx, yy);
|
---|
| 342 | }
|
---|
| 343 | }
|
---|
| 344 | } CATCH(merr) {
|
---|
| 345 | fflush(stdout);
|
---|
| 346 | cout << endl;
|
---|
| 347 | cerr << endl;
|
---|
| 348 | string es = PeidaExc(merr);
|
---|
| 349 | cerr << "Services2NObjMgr::PlotFunc2D() Exception :" << merr << es;
|
---|
| 350 | delete mtx; mtx = NULL;
|
---|
| 351 | } ENDTRY;
|
---|
| 352 |
|
---|
| 353 | if (mtx) {
|
---|
| 354 | string nom = "Func2";
|
---|
| 355 | int wrsid = 0;
|
---|
| 356 | bool fgsr = true;
|
---|
| 357 | int opt = DecodeDispOption(dopt, fgsr);
|
---|
| 358 | P2DArrayAdapter* arr = new POMatrixAdapter(mtx, true);
|
---|
| 359 | arr->DefineXYCoordinates(xmin, ymin, dx, dy);
|
---|
| 360 | PISurfaceDrawer* sdr = new PISurfaceDrawer(arr, true, true, true);
|
---|
| 361 | wrsid = mImgapp->Disp3DDrawer(sdr, nom, opt);
|
---|
| 362 | if (fgsr) mImgapp->RestoreGraphicAtt();
|
---|
| 363 | }
|
---|
| 364 |
|
---|
| 365 | return;
|
---|
| 366 | }
|
---|
| 367 |
|
---|
| 368 | /* --Methode-- */
|
---|
[165] | 369 | string Services2NObjMgr::FileName2Name(string const & fn)
|
---|
| 370 | {
|
---|
| 371 |
|
---|
| 372 | char fsep[2] = {FILESEP, '\0'};
|
---|
| 373 | char tsep[2] = {'.', '\0'};
|
---|
| 374 | size_t p = fn.find_last_of(fsep);
|
---|
[194] | 375 | size_t l = fn.length();
|
---|
| 376 | if (p >= l) p = 0;
|
---|
| 377 | else p++;
|
---|
| 378 | size_t q = fn.find_first_of(tsep,p);
|
---|
| 379 | if (q < p) q = l;
|
---|
[165] | 380 | return(fn.substr(p,q-p));
|
---|
| 381 | }
|
---|
| 382 |
|
---|
| 383 |
|
---|
| 384 | typedef vector<string> GraTok;
|
---|
| 385 |
|
---|
| 386 | /* --Methode-- */
|
---|
| 387 | int Services2NObjMgr::DecodeDispOption(string& gratt, bool& fgsrgr)
|
---|
| 388 | {
|
---|
| 389 | int ropt = Disp_Next;
|
---|
| 390 | if (!mImgapp) return(ropt);
|
---|
| 391 |
|
---|
| 392 | for(int i=0; i<gratt.length(); i++) gratt[i] = tolower(gratt[i]);
|
---|
| 393 |
|
---|
| 394 | if (fgsrgr) mImgapp->SaveGraphicAtt();
|
---|
| 395 |
|
---|
[326] | 396 | if ( (gratt == "def") || (gratt == "default") ) { // Remise aux valeurs par defaut = non defini
|
---|
[165] | 397 | mImgapp->SetColAtt();
|
---|
| 398 | mImgapp->SetLineAtt();
|
---|
| 399 | mImgapp->SetFontAtt();
|
---|
| 400 | mImgapp->SetMarkerAtt();
|
---|
| 401 | mImgapp->SetColMapId();
|
---|
| 402 | mImgapp->SetZoomAtt();
|
---|
| 403 | return(ropt);
|
---|
| 404 | }
|
---|
| 405 |
|
---|
| 406 | // On separe en mots separes par des virgules
|
---|
| 407 | gratt = ","+gratt;
|
---|
| 408 | size_t p = 0;
|
---|
| 409 | size_t q = 0;
|
---|
| 410 | size_t l = gratt.length();
|
---|
| 411 | string token;
|
---|
| 412 |
|
---|
| 413 | GraTok grt;
|
---|
| 414 |
|
---|
| 415 | while (q < l) {
|
---|
| 416 | p = gratt.find_first_not_of(" ,",q+1); // au debut d'un token
|
---|
| 417 | if (p>=l) break;
|
---|
| 418 | q = gratt.find_first_of(" ,",p); // la fin du token;
|
---|
| 419 | token = gratt.substr(p,q-p);
|
---|
| 420 | grt.push_back(token);
|
---|
| 421 | }
|
---|
| 422 |
|
---|
| 423 |
|
---|
| 424 | static GrAttNames::iterator it;
|
---|
| 425 |
|
---|
| 426 | int k;
|
---|
| 427 | bool fgcont = true;
|
---|
| 428 | fgsrgr = false;
|
---|
| 429 |
|
---|
| 430 | for(k=0; k<grt.size(); k++) {
|
---|
| 431 | // cout << "--DBG--SetGraphicAttributes() " << grt[k] << endl;
|
---|
| 432 |
|
---|
| 433 | // Decodage option affichage (win, next, etc
|
---|
| 434 | fgcont = true;
|
---|
| 435 | if ( (grt[k] == "win") || (grt[k] == "w") ) ropt = Disp_Win;
|
---|
| 436 | else if ( (grt[k] == "same") || (grt[k] == "s") ) ropt = Disp_Same;
|
---|
| 437 | else if ( (grt[k] == "stack") || (grt[k] == "st") ) ropt = Disp_Stack;
|
---|
| 438 | else fgcont = false;
|
---|
| 439 | if (fgcont) continue;
|
---|
| 440 |
|
---|
| 441 | // Si c'est une couleur
|
---|
| 442 | it = GrAcolors.find(grt[k]);
|
---|
| 443 | if (it != GrAcolors.end()) { mImgapp->SetColAtt((PIColors)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
| 444 | // Si c'est un attribut de lignes
|
---|
| 445 | it = GrAlines.find(grt[k]);
|
---|
| 446 | if (it != GrAlines.end()) { mImgapp->SetLineAtt((PILineAtt)((*it).second.a1)); fgsrgr = true; continue; }
|
---|
| 447 | // Si c'est un attribut de fontes
|
---|
| 448 | it = GrAfonts.find(grt[k]);
|
---|
| 449 | if (it != GrAfonts.end()) { mImgapp->SetFontAtt((PIFontSize)((*it).second.a2), (PIFontAtt)((*it).second.a1) );
|
---|
| 450 | fgsrgr = true; continue; }
|
---|
| 451 | // Si c'est un attribut de markers
|
---|
| 452 | it = GrAmarkers.find(grt[k]);
|
---|
| 453 | if (it != GrAmarkers.end()) { mImgapp->SetMarkerAtt((*it).second.a2, (PIMarker)((*it).second.a1) );
|
---|
| 454 | fgsrgr = true; continue; }
|
---|
| 455 | // Si c'est un colormap
|
---|
| 456 | it = GrAcmap.find(grt[k]);
|
---|
| 457 | if (it != GrAcmap.end()) { mImgapp->SetColMapId( (CMapId)((*it).second.a1) ); fgsrgr = true; continue; }
|
---|
| 458 | // Si c'est un facteur de zoom
|
---|
| 459 | it = GrAzoom.find(grt[k]);
|
---|
| 460 | if (it != GrAzoom.end()) { mImgapp->SetZoomAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
[203] | 461 | // Si c'est un attribut d'axe
|
---|
| 462 | it = GrAaxes.find(grt[k]);
|
---|
| 463 | if (it != GrAaxes.end()) { mImgapp->SetAxesAtt( (*it).second.a1 ); fgsrgr = true; continue; }
|
---|
[165] | 464 |
|
---|
| 465 | }
|
---|
| 466 |
|
---|
| 467 | return(ropt);
|
---|
| 468 | }
|
---|
| 469 |
|
---|
| 470 |
|
---|
| 471 |
|
---|
| 472 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
| 473 | // Initialisation des chaines de caracteres designant les attributs graphiques
|
---|
| 474 |
|
---|
| 475 | /* --Methode-- */
|
---|
| 476 | void Services2NObjMgr::InitGrAttNames()
|
---|
| 477 | {
|
---|
| 478 | gratt_item gi;
|
---|
| 479 | // Les couleurs
|
---|
| 480 | gi.a2 = 0;
|
---|
| 481 | gi.a1 = PI_NotDefColor;
|
---|
| 482 | GrAcolors["defcol"] = gi;
|
---|
| 483 | gi.a1 = PI_Black;
|
---|
| 484 | GrAcolors["black"] = gi;
|
---|
| 485 | gi.a1 = PI_White;
|
---|
| 486 | GrAcolors["white"] = gi;
|
---|
| 487 | gi.a1 = PI_Grey;
|
---|
| 488 | GrAcolors["grey"] = gi;
|
---|
| 489 | gi.a1 = PI_Red;
|
---|
| 490 | GrAcolors["red"] = gi;
|
---|
| 491 | gi.a1 = PI_Blue;
|
---|
| 492 | GrAcolors["blue"] = gi;
|
---|
| 493 | gi.a1 = PI_Green;
|
---|
| 494 | GrAcolors["green"] = gi;
|
---|
| 495 | gi.a1 = PI_Yellow;
|
---|
| 496 | GrAcolors["yellow"] = gi;
|
---|
| 497 | gi.a1 = PI_Magenta;
|
---|
| 498 | GrAcolors["magenta"] = gi;
|
---|
| 499 |
|
---|
| 500 | gi.a1 = PI_Cyan;
|
---|
| 501 | GrAcolors["cyan"] = gi;
|
---|
| 502 | gi.a1 = PI_Turquoise;
|
---|
| 503 | GrAcolors["turquoise"] = gi;
|
---|
| 504 | gi.a1 = PI_NavyBlue;
|
---|
| 505 | GrAcolors["navyblue"] = gi;
|
---|
| 506 | gi.a1 = PI_Orange;
|
---|
| 507 | GrAcolors["orange"] = gi;
|
---|
| 508 | gi.a1 = PI_SiennaRed;
|
---|
| 509 | GrAcolors["siennared"] = gi;
|
---|
| 510 | gi.a1 = PI_Purple;
|
---|
| 511 | GrAcolors["purple"] = gi;
|
---|
| 512 | gi.a1 = PI_LimeGreen;
|
---|
| 513 | GrAcolors["limegreen"] = gi;
|
---|
| 514 | gi.a1 = PI_Gold;
|
---|
| 515 | GrAcolors["gold"] = gi;
|
---|
| 516 |
|
---|
| 517 | // Les attributs de lignes
|
---|
| 518 | gi.a2 = 0;
|
---|
| 519 | gi.a1 = PI_NotDefLineAtt;
|
---|
| 520 | GrAlines["defline"] = gi;
|
---|
| 521 | gi.a1 = PI_NormalLine;
|
---|
| 522 | GrAlines["normalline"] = gi;
|
---|
| 523 | gi.a1 = PI_ThinLine;
|
---|
| 524 | GrAlines["thinline"] = gi;
|
---|
| 525 | gi.a1 = PI_ThickLine;
|
---|
| 526 | GrAlines["thickline"] = gi;
|
---|
| 527 | gi.a1 = PI_DashedLine;
|
---|
| 528 | GrAlines["dashedline"] = gi;
|
---|
| 529 | gi.a1 = PI_ThinDashedLine;
|
---|
| 530 | GrAlines["thindashedline"] = gi;
|
---|
| 531 | gi.a1 = PI_ThickDashedLine;
|
---|
| 532 | GrAlines["thickdashedline"] = gi;
|
---|
[192] | 533 | gi.a1 = PI_DottedLine;
|
---|
| 534 | GrAlines["dottedline"] = gi;
|
---|
| 535 | gi.a1 = PI_ThinDottedLine;
|
---|
| 536 | GrAlines["thindottedline"] = gi;
|
---|
| 537 | gi.a1 = PI_ThickDottedLine;
|
---|
| 538 | GrAlines["thickdottedline"] = gi;
|
---|
[165] | 539 |
|
---|
[293] | 540 | // Les fontes
|
---|
[165] | 541 | gi.a2 = PI_NotDefFontSize;
|
---|
| 542 | gi.a1 = PI_NotDefFontAtt;
|
---|
| 543 | GrAlines["deffont"] = gi;
|
---|
| 544 |
|
---|
| 545 | gi.a2 = PI_NormalSizeFont;
|
---|
| 546 | gi.a1 = PI_RomanFont;
|
---|
| 547 | GrAlines["normalfont"] = gi;
|
---|
| 548 | gi.a1 = PI_BoldFont;
|
---|
| 549 | GrAlines["boldfont"] = gi;
|
---|
| 550 | gi.a1 = PI_ItalicFont;
|
---|
| 551 | GrAlines["italicfont"] = gi;
|
---|
| 552 | gi.a2 = PI_SmallSizeFont;
|
---|
| 553 | gi.a1 = PI_RomanFont;
|
---|
| 554 | GrAlines["smallfont"] = gi;
|
---|
| 555 | gi.a1 = PI_BoldFont;
|
---|
| 556 | GrAlines["smallboldfont"] = gi;
|
---|
| 557 | gi.a1 = PI_ItalicFont;
|
---|
| 558 | GrAlines["smallitalicfont"] = gi;
|
---|
| 559 | gi.a2 = PI_BigSizeFont;
|
---|
| 560 | gi.a1 = PI_RomanFont;
|
---|
| 561 | GrAlines["bigfont"] = gi;
|
---|
| 562 | gi.a1 = PI_BoldFont;
|
---|
| 563 | GrAlines["bigboldfont"] = gi;
|
---|
| 564 | gi.a1 = PI_ItalicFont;
|
---|
| 565 | GrAlines["bigitalicfont"] = gi;
|
---|
[192] | 566 | gi.a2 = PI_HugeSizeFont;
|
---|
| 567 | gi.a1 = PI_RomanFont;
|
---|
| 568 | GrAlines["hugefont"] = gi;
|
---|
| 569 | gi.a1 = PI_BoldFont;
|
---|
| 570 | GrAlines["hugeboldfont"] = gi;
|
---|
| 571 | gi.a1 = PI_ItalicFont;
|
---|
| 572 | GrAlines["hugeitalicfont"] = gi;
|
---|
[165] | 573 |
|
---|
| 574 |
|
---|
| 575 | // Les markers
|
---|
[176] | 576 | const char* mrkn[11] = { "dotmarker", "plusmarker", "crossmarker",
|
---|
| 577 | "circlemarker", "fcirclemarker", "boxmarker", "fboxmarker",
|
---|
| 578 | "trianglemarker", "ftrianglemarker", "starmarker", "fstarmarker"};
|
---|
[165] | 579 | PIMarker mrk[11] = { PI_DotMarker, PI_PlusMarker, PI_CrossMarker,
|
---|
| 580 | PI_CircleMarker, PI_FCircleMarker, PI_BoxMarker, PI_FBoxMarker,
|
---|
| 581 | PI_TriangleMarker, PI_FTriangleMarker, PI_StarMarker, PI_FStarMarker};
|
---|
| 582 |
|
---|
| 583 | gi.a2 = 0;
|
---|
| 584 | gi.a1 = PI_NotDefMarker;
|
---|
| 585 | GrAmarkers["defmarker"] = gi;
|
---|
| 586 |
|
---|
| 587 | for(int j=0; j<11; j++) {
|
---|
| 588 | string smrk;
|
---|
| 589 | char buff[16];
|
---|
| 590 | for(int m=1; m<10; m+=2) {
|
---|
| 591 | sprintf(buff,"%d",m);
|
---|
| 592 | smrk = (string)mrkn[j] + (string)buff;
|
---|
| 593 | gi.a1 = mrk[j]; gi.a2 = m;
|
---|
| 594 | GrAmarkers[smrk] = gi;
|
---|
| 595 | }
|
---|
| 596 | }
|
---|
| 597 |
|
---|
| 598 | // Les tables de couleurs
|
---|
| 599 | gi.a2 = 0;
|
---|
| 600 | gi.a1 = CMAP_OTHER;
|
---|
| 601 | GrAcmap["defcmap"] = gi;
|
---|
| 602 | gi.a1 = CMAP_GREY32;
|
---|
| 603 | GrAcmap["grey32"] = gi;
|
---|
| 604 | gi.a1 = CMAP_GREYINV32;
|
---|
| 605 | GrAcmap["greyinv32"] = gi;
|
---|
| 606 | gi.a1 = CMAP_COLRJ32;
|
---|
| 607 | GrAcmap["colrj32"] = gi;
|
---|
| 608 | gi.a1 = CMAP_COLBR32;
|
---|
| 609 | GrAcmap["colbr32"] = gi;
|
---|
| 610 | gi.a1 = CMAP_GREY128;
|
---|
| 611 | GrAcmap["grey128"] = gi;
|
---|
| 612 | gi.a1 = CMAP_GREYINV128;
|
---|
| 613 | GrAcmap["greyinv128"] = gi;
|
---|
| 614 | gi.a1 = CMAP_COLRJ128;
|
---|
| 615 | GrAcmap["colrj128"] = gi;
|
---|
| 616 | gi.a1 = CMAP_COLBR128;
|
---|
| 617 | GrAcmap["colbr128"] = gi;
|
---|
| 618 |
|
---|
[203] | 619 | // La valeur de zoom
|
---|
[165] | 620 | gi.a2 = 0;
|
---|
| 621 | gi.a1 = 0;
|
---|
| 622 | GrAzoom["defzoom"] = gi;
|
---|
| 623 | gi.a1 = 1;
|
---|
| 624 | GrAzoom["zoomx1"] = gi;
|
---|
| 625 | gi.a1 = 2;
|
---|
| 626 | GrAzoom["zoomx2"] = gi;
|
---|
| 627 | gi.a1 = 3;
|
---|
| 628 | GrAzoom["zoomx3"] = gi;
|
---|
| 629 | gi.a1 = 4;
|
---|
| 630 | GrAzoom["zoomx4"] = gi;
|
---|
| 631 | gi.a1 = 5;
|
---|
| 632 | GrAzoom["zoomx5"] = gi;
|
---|
| 633 | gi.a1 = -2;
|
---|
| 634 | GrAzoom["zoom/2"] = gi;
|
---|
| 635 | gi.a1 = -3;
|
---|
| 636 | GrAzoom["zoom/3"] = gi;
|
---|
| 637 | gi.a1 = -4;
|
---|
| 638 | GrAzoom["zoom/4"] = gi;
|
---|
| 639 | gi.a1 = -5;
|
---|
| 640 | GrAzoom["zoom/5"] = gi;
|
---|
[203] | 641 |
|
---|
| 642 | // Attributs d'axes
|
---|
| 643 | gi.a2 = 0;
|
---|
| 644 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels);
|
---|
| 645 | GrAaxes["stdaxes"] = gi;
|
---|
| 646 | GrAaxes["defaxes"] = gi;
|
---|
| 647 | GrAaxes["boxaxes"] = gi;
|
---|
| 648 | gi.a1 = (int)kAxesDflt;
|
---|
| 649 | GrAaxes["simpleaxes"] = gi;
|
---|
| 650 | gi.a1 = (int)(kBoxAxes | kExtTicks | kLabels | kGridOn);
|
---|
| 651 | GrAaxes["boxaxesgrid"] = gi;
|
---|
| 652 |
|
---|
| 653 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks);
|
---|
| 654 | GrAaxes["fineaxes"] = gi;
|
---|
| 655 | gi.a1 = (int)(kBoxAxes | kTicks | kLabels | kMinTicks | kMajTicks | kGridOn);
|
---|
| 656 | GrAaxes["grid"] = gi;
|
---|
| 657 | GrAaxes["fineaxesgrid"] = gi;
|
---|
| 658 |
|
---|
[165] | 659 | }
|
---|