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