[1919] | 1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
| 2 | // Classe d'interface avec le code de GNUplot
|
---|
| 3 | // pour calculer les contours & classe de trace de contours
|
---|
| 4 | // O. Perdereau
|
---|
| 5 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
| 6 |
|
---|
[1829] | 7 | #include "machdefs.h"
|
---|
| 8 | #include <stdio.h>
|
---|
| 9 | #include <stdlib.h>
|
---|
[2254] | 10 | #include <assert.h>
|
---|
[1829] | 11 | #include <iostream.h>
|
---|
| 12 | #include <math.h>
|
---|
| 13 |
|
---|
| 14 | #include "histos.h"
|
---|
| 15 | #include "ntuple.h"
|
---|
| 16 |
|
---|
[1838] | 17 | #include "nbtri.h"
|
---|
[1829] | 18 |
|
---|
| 19 | #include "picntools.h"
|
---|
| 20 | #include "pigncont.h"
|
---|
| 21 |
|
---|
[1857] | 22 | #include <sys/time.h>
|
---|
| 23 | #include <sys/resource.h>
|
---|
| 24 |
|
---|
[1919] | 25 | //++
|
---|
| 26 | // Class GNUPlotContour
|
---|
| 27 | // Lib PIGcont
|
---|
| 28 | // include pigncont.h
|
---|
| 29 | //
|
---|
| 30 | // Classe d'interface avec le code de GNUplot qui calcule les courbes de niveaux
|
---|
| 31 | // GNUplot part d'une grille (structure iso_curve) qui est remplie par les
|
---|
| 32 | // createurs
|
---|
| 33 | // Les parametres du calcul sont modifiable a partir de la fenetre d'options
|
---|
| 34 | // du traceur de contour (classe PIContourDrawer)
|
---|
| 35 | // Options (reconnues dans un enum t_contour_kind dans GNUplot)
|
---|
| 36 | // 1) nombre de courbes et et niveaux determines automatiquement par le programme (defaut)
|
---|
| 37 | // En general, 5 courbes sont tracees LEVELS_AUTO
|
---|
| 38 | //
|
---|
| 39 | // 2) nombre de niveaux fixe par l'utilisateur. Les niveaux sont equidistants entre
|
---|
| 40 | // le min et le max de la surface LEVELS_NUM
|
---|
| 41 | //
|
---|
| 42 | // 3) nombre et hauteurs des niveaux fixes par l'utilisateur. Les niveaux sont passes
|
---|
| 43 | // dans un tableau LEVELS_DISCRETE
|
---|
| 44 | //
|
---|
| 45 | // 4) nombre niveau min et ecart entre niveaux fixe par l'utilisateur LEVELS_INCREMENTAL
|
---|
| 46 | //
|
---|
| 47 | // Les contours sont traces en interpolant entre les points de la grille.
|
---|
| 48 | // On peut choisir 3 algorithmes d'interpolation a travers p.ex. les options
|
---|
| 49 | // de PIContourDrawer
|
---|
| 50 | // (enum t_contour_levels_kind ds GNUplot)
|
---|
| 51 | // a) interpolation simple CONTOUR_KIND_LINEAR
|
---|
| 52 | // b) spline cubique CONTOUR_KIND_CUBIC_SPL
|
---|
| 53 | // c) B-spline CONTOUR_KIND_BSPLINE
|
---|
| 54 | //
|
---|
| 55 | //--
|
---|
| 56 | //++
|
---|
| 57 | // Links Voir aussi
|
---|
| 58 | // PIContourDrawer
|
---|
| 59 | // PIcntools
|
---|
| 60 | //--
|
---|
| 61 | //++
|
---|
| 62 | // Titre Constructeurs et Méthodes
|
---|
| 63 | //--
|
---|
| 64 | //++
|
---|
| 65 | // GNUPlotContour(struct iso_curve * iso) :
|
---|
| 66 | // constructeur a partir d'une structure iso_curve
|
---|
| 67 | // (structure de GNUplot)
|
---|
| 68 | //--
|
---|
[1829] | 69 |
|
---|
[1919] | 70 |
|
---|
[1829] | 71 | GNUPlotContour::GNUPlotContour(struct iso_curve * iso){
|
---|
| 72 | int k=0;
|
---|
| 73 | iso1 = iso;
|
---|
| 74 | struct iso_curve *iso_cur = iso ;
|
---|
| 75 | struct iso_curve *iso_old;
|
---|
| 76 | _xmin = 1.e37;
|
---|
| 77 | _ymin = 1.e37;
|
---|
| 78 | _xmax = -1.e37;
|
---|
| 79 | _ymax = -1.e37;
|
---|
| 80 | _myiso = NULL;
|
---|
| 81 | _zmin = 1.e37;
|
---|
| 82 | _zmax = -1.e37;
|
---|
| 83 | while(iso_cur){
|
---|
| 84 | k++;
|
---|
| 85 | iso_cur = iso_cur->next;
|
---|
| 86 | _ny = iso_cur->p_count;
|
---|
| 87 | for(int k=0 ; k<_ny ; k++){
|
---|
| 88 | double xx=iso->points[k].x;
|
---|
| 89 | double yy=iso->points[k].y;
|
---|
| 90 | double zz=iso->points[k].z;
|
---|
| 91 | if(xx<_xmin) _xmin = xx;
|
---|
| 92 | if(xx>_xmax) _xmax = xx;
|
---|
| 93 | if(yy<_ymin) _ymin = yy;
|
---|
| 94 | if(yy>_ymax) _ymax = yy;
|
---|
| 95 | if(zz<_zmin) _zmin = zz;
|
---|
| 96 | if(zz>_zmax) _zmax = zz;
|
---|
| 97 |
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | _nx = k;
|
---|
| 102 | _contours = NULL;
|
---|
| 103 | My_Levels = NULL;
|
---|
| 104 |
|
---|
| 105 | _npolys=-1;
|
---|
| 106 | _Dxp =_Dyp =1.;
|
---|
| 107 | _Exy =_Invy =_Invy = FALSE ;
|
---|
| 108 |
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 |
|
---|
[1919] | 112 | //++
|
---|
| 113 | // GNUPlotContour(NTupleInterface *nt,int *nz=NULL,double *z=NULL,double *dz=NULL):
|
---|
| 114 | // constructeur a partir d'un NTupleInterface
|
---|
| 115 | // la structure iso_curve est remplie par le constructeur
|
---|
| 116 | //Inputs
|
---|
| 117 | //| NTupleInterface *nt
|
---|
| 118 | //| double *nz nombre de contours (optionnel)
|
---|
| 119 | //| double *z tabelau avec les niveaux des contours (optionnel)
|
---|
| 120 | //| double *dz increment entre contours (optionnel)
|
---|
| 121 | //--
|
---|
[1829] | 122 | GNUPlotContour::GNUPlotContour(NTupleInterface *nt,int *nz=NULL,double *z=NULL,double *dz=NULL){
|
---|
| 123 | _xmin = 1.e37;
|
---|
| 124 | _ymin = 1.e37;
|
---|
| 125 | _xmax = -1.e37;
|
---|
| 126 | _ymax = -1.e37;
|
---|
| 127 | _zmin = 1.e37;
|
---|
| 128 | _zmax = -1.e37;
|
---|
| 129 | char *nom[4]={"x","y","z","niso"};
|
---|
| 130 | _myiso = new NTuple(4,nom);
|
---|
| 131 | //_myiso->Show();
|
---|
| 132 | float xnt[4];
|
---|
| 133 | double mn,mx;
|
---|
| 134 |
|
---|
| 135 | nt->GetMinMax(0,_xmin,_xmax);
|
---|
| 136 | nt->GetMinMax(1,_ymin,_ymax);
|
---|
| 137 | nt->GetMinMax(2,_zmin,_zmax);
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | struct iso_curve *istmp = NULL ;
|
---|
| 141 | struct iso_curve *iso = NULL ;
|
---|
| 142 | struct iso_curve *iso_old = NULL ;
|
---|
| 143 | double x,y;
|
---|
| 144 | int nen = nt->NbLines();
|
---|
| 145 |
|
---|
| 146 | // histo des y
|
---|
| 147 | for(int k= 0 ; k<1000 ; k++){
|
---|
| 148 | istmp = iso_alloc(100);
|
---|
| 149 | iso_free(istmp);
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | #define NUMPTMIN 25
|
---|
| 153 | #define MAXISO 100
|
---|
| 154 | #define MINISO 5
|
---|
| 155 |
|
---|
| 156 | Histo prep(_ymin,_ymax,nen);
|
---|
| 157 | for(int ix=0 ; ix<nen ; ix++) prep.Add(nt->GetCell(ix,1),1.);
|
---|
| 158 | Histo Intg = prep;
|
---|
| 159 | Intg.HInteg(0);
|
---|
| 160 | //prep.Print();
|
---|
| 161 | //Intg.Print();
|
---|
| 162 | float *bin;
|
---|
| 163 | int *cnt;
|
---|
| 164 |
|
---|
| 165 | int niso = sqrt( (double)nen);
|
---|
| 166 | bin = new float[niso+1];
|
---|
| 167 | cnt = new int[niso+1];
|
---|
| 168 |
|
---|
[1842] | 169 | int i;
|
---|
| 170 | for(i=0 ; i<niso ; i++){
|
---|
[1829] | 171 | bin[i] = prep.BinHighEdge(prep.BinPercent( ((double)i)/(double)niso));
|
---|
| 172 | cnt[i] = Intg(prep.BinPercent( ((double)i)/(double)niso));
|
---|
| 173 | }
|
---|
| 174 |
|
---|
| 175 | bin[niso]=_ymax;
|
---|
| 176 |
|
---|
| 177 | cnt[niso] = prep.NEntries();
|
---|
| 178 | int numx = 0;
|
---|
| 179 | int numi = 9999;
|
---|
[1842] | 180 | for(i=0;i<niso ; i++){
|
---|
[1829] | 181 | int numy = cnt[i+1]-cnt[i];
|
---|
| 182 |
|
---|
| 183 | if(numy>0){
|
---|
| 184 | numx = numx>numy ? numx : numy ;
|
---|
| 185 | numi = numy>numi ? numi : numy ;
|
---|
| 186 | }
|
---|
| 187 | }
|
---|
| 188 |
|
---|
| 189 |
|
---|
| 190 | if (numi<=0) {
|
---|
| 191 |
|
---|
| 192 | return;
|
---|
| 193 | }
|
---|
| 194 | _nx = 0;
|
---|
| 195 |
|
---|
[1842] | 196 | for(i=0;i<niso ; i++){
|
---|
[1829] | 197 | double ymi = bin[i];
|
---|
| 198 | double ymx = bin[i+1];
|
---|
| 199 | int numy = cnt[i+1]-cnt[i];
|
---|
| 200 |
|
---|
| 201 | if(numy<=0) continue;
|
---|
| 202 | double *xp;
|
---|
| 203 | xp = new double[numy];
|
---|
| 204 |
|
---|
| 205 | int *indx;
|
---|
| 206 | indx = new int[numy];
|
---|
| 207 |
|
---|
| 208 | istmp = iso_alloc(numy) ; // structure temporaire
|
---|
| 209 |
|
---|
| 210 | int ip=0;
|
---|
[1842] | 211 | int ix;
|
---|
| 212 | for(ix=0 ; ix<nen ; ix++){
|
---|
[1829] | 213 |
|
---|
| 214 | if(nt->GetCell(ix,1)>=ymi&&nt->GetCell(ix,1)<ymx){
|
---|
| 215 |
|
---|
| 216 |
|
---|
| 217 | istmp->points[ip].type = INRANGE;
|
---|
| 218 | istmp->points[ip].x = nt->GetCell(ix,0);
|
---|
| 219 | istmp->points[ip].y = nt->GetCell(ix,1);
|
---|
| 220 | istmp->points[ip].z = nt->GetCell(ix,2);
|
---|
| 221 | indx[ip] = ip;
|
---|
| 222 | xp[ip++] = nt->GetCell(ix,0);
|
---|
| 223 | }
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | // tri des points de l'iso_curve
|
---|
| 227 | //
|
---|
| 228 | istmp->p_count = ip;
|
---|
| 229 |
|
---|
| 230 | tri_double(xp,indx,ip);
|
---|
| 231 |
|
---|
| 232 | // remplissage structure finale
|
---|
| 233 |
|
---|
| 234 | iso = iso_alloc(numx) ;
|
---|
| 235 | if( _nx == 0 ) iso1 = iso; //premiere structure remplie
|
---|
| 236 | if (iso_old) iso_old->next = iso;
|
---|
[1842] | 237 | for(ix=0 ; ix<numy ; ix++){
|
---|
[1829] | 238 | int jx = indx[ix];
|
---|
| 239 |
|
---|
| 240 |
|
---|
| 241 | iso->points[ix].type = INRANGE ;
|
---|
| 242 | iso->points[ix].x = istmp->points[jx].x ;
|
---|
| 243 | iso->points[ix].y = istmp->points[jx].y ;
|
---|
| 244 | iso->points[ix].z = istmp->points[jx].z ;
|
---|
| 245 | xnt[0] = iso->points[ix].x;
|
---|
| 246 | xnt[1] = iso->points[ix].y;
|
---|
| 247 | xnt[2] = iso->points[ix].z;
|
---|
| 248 | xnt[3] = _nx;
|
---|
| 249 | //cout << " fill avec "<<xnt[0]<<" "<<xnt[1] <<" "<<xnt[2] << " "<<xnt[3]<<endl;
|
---|
| 250 | // _myiso->Show();
|
---|
| 251 |
|
---|
| 252 | _myiso->Fill(xnt);
|
---|
| 253 | }
|
---|
| 254 | //cout << " completion "<<ip<<" =>> "<<numx<<endl;
|
---|
| 255 | // on complete
|
---|
[1842] | 256 | for(ix=ip; ix<numx ; ix++ ){
|
---|
[1829] | 257 | int jmx = indx[ip-1];
|
---|
| 258 | iso->points[ix].type = INRANGE ;
|
---|
| 259 | iso->points[ix].x = istmp->points[jmx].x ;
|
---|
| 260 | iso->points[ix].y = istmp->points[jmx].y ;
|
---|
| 261 | iso->points[ix].z = istmp->points[jmx].z ;
|
---|
| 262 | xnt[0] = iso->points[ix].x;
|
---|
| 263 | xnt[1] = iso->points[ix].y;
|
---|
| 264 | xnt[2] = iso->points[ix].z;
|
---|
| 265 | xnt[3] = _nx;
|
---|
| 266 | //cout << " fill avec "<<xnt[0]<<" "<<xnt[1] <<" "<<xnt[2] << " "<<xnt[3]<<endl;
|
---|
| 267 | _myiso->Fill(xnt);
|
---|
| 268 | //_myiso->Show();
|
---|
| 269 | }
|
---|
| 270 |
|
---|
| 271 | iso->p_count = numx;
|
---|
| 272 |
|
---|
| 273 | iso_old = iso;
|
---|
| 274 | _nx++;
|
---|
| 275 | //cout << " destruction structure tempo "<<_nx <<endl;
|
---|
| 276 | if(istmp){
|
---|
| 277 | iso_free( istmp );// destruction de la structure temporaire
|
---|
| 278 | istmp = NULL;
|
---|
| 279 | }
|
---|
| 280 | if(xp){delete[] xp ; xp=NULL;}
|
---|
| 281 | if(indx) {delete[] indx ; indx = NULL;}
|
---|
| 282 |
|
---|
| 283 | }
|
---|
| 284 | //if(_myiso!=NULL)_myiso->Write("myiso.ppf");
|
---|
| 285 | //cout << " fin du remplissage des iso_curves xmin,max "<< _xmin<<","<<_xmax<<" ymin,max "<<_ymin<<","<<_ymax<<endl;
|
---|
| 286 | _contours = NULL;
|
---|
| 287 | My_Levels = NULL;
|
---|
| 288 | _npolys=-1;
|
---|
| 289 | Contour_Levels_kind = LEVELS_AUTO ;
|
---|
| 290 | Contour_kind = CONTOUR_KIND_LINEAR ;
|
---|
| 291 | set_contour_kind(Contour_kind);
|
---|
| 292 | Contour_Levels = 5;
|
---|
| 293 | set_contour_levels(Contour_Levels);
|
---|
| 294 | set_contour_levels_kind(Contour_Levels_kind);
|
---|
| 295 |
|
---|
| 296 |
|
---|
| 297 | if(dz!=NULL){
|
---|
| 298 | My_Levels = new double[2];
|
---|
| 299 | Contour_Levels = *nz;
|
---|
| 300 | My_Levels[0] = *z ;
|
---|
| 301 | My_Levels[1] = *dz;
|
---|
| 302 | Contour_Levels_kind = LEVELS_INCREMENTAL ;
|
---|
| 303 | set_contour_levels(Contour_Levels);
|
---|
| 304 | set_contour_levels_kind(Contour_Levels_kind);
|
---|
| 305 | set_contour_levels_list(My_Levels);//,2);
|
---|
| 306 |
|
---|
| 307 | }else if(nz!=NULL){
|
---|
| 308 |
|
---|
| 309 | Contour_Levels = *nz;
|
---|
| 310 | Contour_Levels_kind = LEVELS_NUM ;
|
---|
| 311 | set_contour_levels(Contour_Levels);
|
---|
| 312 | set_contour_levels_kind(Contour_Levels_kind);
|
---|
| 313 | }
|
---|
| 314 |
|
---|
| 315 | }
|
---|
| 316 |
|
---|
[1919] | 317 | //++
|
---|
| 318 | // GNUPlotContour(P2DArrayAdapter*arr,int *nz=NULL,double *z=NULL,double *dz=NULL):
|
---|
| 319 | // constructeur a partir d'un P2DArrayAdapter
|
---|
| 320 | // la structure iso_curve est remplie par le constructeur
|
---|
| 321 | //Inputs
|
---|
| 322 | //| P2DArrayAdapter* arr
|
---|
| 323 | //| double *nz nombre de contours (optionnel)
|
---|
| 324 | //| double *z tabelau avec les niveaux des contours (optionnel)
|
---|
| 325 | //| double *dz increment entre contours (optionnel)
|
---|
| 326 | //--
|
---|
| 327 |
|
---|
| 328 | GNUPlotContour::GNUPlotContour(P2DArrayAdapter* arr,int *nz=NULL,double *z=NULL,double *dz=NULL){
|
---|
[1829] | 329 | _xmin = 1.e37;
|
---|
| 330 | _ymin = 1.e37;
|
---|
| 331 | _xmax = -1.e37;
|
---|
| 332 | _ymax = -1.e37;
|
---|
| 333 | _zmin = 1.e37;
|
---|
| 334 | _zmax = -1.e37;
|
---|
| 335 | // _nx = arr->XSize()-1;
|
---|
| 336 | // _ny = arr->YSize()-1;
|
---|
| 337 | _nx = arr->XSize() ;
|
---|
| 338 | _ny = arr->YSize() ;
|
---|
| 339 | //cout << " size x,y "<<_nx<<" , "<<_ny <<endl;
|
---|
| 340 | char *nom[4]={"x","y","z","niso"};
|
---|
| 341 |
|
---|
| 342 | _myiso = new NTuple(4,nom);
|
---|
| 343 | float xnt[4];
|
---|
| 344 | struct iso_curve *iso =NULL ;
|
---|
| 345 | struct iso_curve *iso_old =NULL ;
|
---|
| 346 | double x,y;
|
---|
| 347 | // Calcul de la taille en X et en Y d'un pixel
|
---|
| 348 | double dxp, dyp;
|
---|
| 349 | double x1,y1;
|
---|
| 350 | arr->XYfromxy(0,0,x,y);
|
---|
| 351 | arr->XYfromxy(1,1,x1,y1);
|
---|
| 352 | _Dxp = (x1-x);
|
---|
| 353 | _Dyp = (y1-y);
|
---|
| 354 | double zz;
|
---|
| 355 | for(int ix=0 ; ix<_nx ; ix++){
|
---|
| 356 | iso = iso_alloc(_ny) ;
|
---|
| 357 | if(ix==0) iso1 = iso;
|
---|
| 358 | if (iso_old) iso_old->next = iso;
|
---|
| 359 | for(int iy = 0 ; iy<_ny ; iy++){
|
---|
| 360 | /*i = ix*100+iy;*/
|
---|
| 361 | arr->XYfromxy(ix,iy,x,y);
|
---|
| 362 |
|
---|
| 363 | iso->points[iy].type = INRANGE;
|
---|
| 364 | iso->points[iy].x = x + _Dxp/2.;
|
---|
| 365 | iso->points[iy].y = y + _Dyp/2.;
|
---|
| 366 | zz=arr->Value(ix,iy);
|
---|
| 367 | iso->points[iy].z = zz;
|
---|
| 368 | //iso->points[iy].z = ((x-25)*(x-25) + (y-25)*(y-25))*.05 ;
|
---|
| 369 | if(x <_xmin) _xmin = x;
|
---|
| 370 | if(x >_xmax) _xmax = x;
|
---|
| 371 | if(y <_ymin) _ymin = y;
|
---|
| 372 | if(y >_ymax) _ymax = y;
|
---|
| 373 | if(zz <_zmin) _zmin = zz;
|
---|
| 374 | if(zz >_zmax) _zmax = zz;
|
---|
| 375 | //printf("ix=%d iy=%d x=%f y=%f z=%f \n",ix,iy,iso->points[iy].x,iso->points[iy].y,iso->points[iy].z);
|
---|
| 376 | xnt[0] = iso->points[iy].x;
|
---|
| 377 | xnt[1] = iso->points[iy].y;
|
---|
| 378 | xnt[2] = iso->points[iy].z;
|
---|
| 379 | xnt[3] = _nx;
|
---|
| 380 |
|
---|
| 381 | _myiso->Fill(xnt);
|
---|
| 382 | }
|
---|
| 383 | iso->p_count = _ny;
|
---|
| 384 | iso_old = iso;
|
---|
| 385 | /*printf(" remplissage %lx old %lx old next %lx \n",iso,iso_old,iso->next,iso_old->next);*/
|
---|
| 386 | /*iso->next = iso ;*/
|
---|
| 387 | }
|
---|
| 388 | //cout << " fin du remplissage des iso_curves xmin,max "<< _xmin<<","<<_xmax<<" ymin,max "<<_ymin<<","<<_ymax<<endl;
|
---|
| 389 | _contours = NULL;
|
---|
| 390 | My_Levels = NULL;
|
---|
| 391 | _npolys=-1;
|
---|
| 392 | Contour_kind = CONTOUR_KIND_LINEAR ;
|
---|
| 393 | set_contour_kind(Contour_kind);
|
---|
| 394 | Contour_Levels_kind = LEVELS_AUTO ;
|
---|
| 395 | Contour_Levels = 5;
|
---|
| 396 | set_contour_levels(Contour_Levels);
|
---|
| 397 | set_contour_levels_kind(Contour_Levels_kind);
|
---|
| 398 |
|
---|
| 399 |
|
---|
| 400 | if(dz!=NULL){
|
---|
| 401 | My_Levels = new double[2];
|
---|
| 402 | Contour_Levels = *nz;
|
---|
| 403 | My_Levels[0] = *z ;
|
---|
| 404 | My_Levels[1] = *dz;
|
---|
| 405 | Contour_Levels_kind = LEVELS_INCREMENTAL ;
|
---|
| 406 | set_contour_levels(Contour_Levels);
|
---|
| 407 | set_contour_levels_kind(Contour_Levels_kind);
|
---|
| 408 | set_contour_levels_list(My_Levels);//,2);
|
---|
| 409 |
|
---|
| 410 | }else if(nz!=NULL){
|
---|
| 411 | Contour_Levels = *nz;
|
---|
| 412 | Contour_Levels_kind = LEVELS_NUM ;
|
---|
| 413 | set_contour_levels(Contour_Levels);
|
---|
| 414 | set_contour_levels_kind(Contour_Levels_kind);
|
---|
| 415 | }
|
---|
| 416 |
|
---|
| 417 | }
|
---|
| 418 |
|
---|
[1919] | 419 |
|
---|
| 420 | //++
|
---|
| 421 | // ~GNUPlotContour()
|
---|
| 422 | //
|
---|
| 423 | // Destructeur
|
---|
| 424 | //
|
---|
| 425 | //--
|
---|
[1829] | 426 | GNUPlotContour::~GNUPlotContour(){
|
---|
| 427 | cout << " destructeur de GNUPlotContour "<<endl;
|
---|
| 428 |
|
---|
| 429 | struct iso_curve *iso_cur;
|
---|
| 430 | struct iso_curve *iso_nx;
|
---|
| 431 | iso_cur = iso1;
|
---|
| 432 |
|
---|
| 433 | while(iso_cur){
|
---|
| 434 | // cout << " ~GNUPlotContour() : destruction de iso1 "<< iso_cur << endl;
|
---|
| 435 | iso_nx = iso_cur->next;
|
---|
| 436 | iso_free(iso_cur);iso_cur = NULL;
|
---|
| 437 |
|
---|
| 438 | iso_cur = iso_nx;
|
---|
| 439 |
|
---|
| 440 | }
|
---|
| 441 |
|
---|
| 442 | iso1 = NULL;
|
---|
| 443 |
|
---|
| 444 | struct gnuplot_contours *cntcur = _contours;
|
---|
[1857] | 445 | /*****
|
---|
[1829] | 446 | struct gnuplot_contours *cntold;
|
---|
| 447 |
|
---|
[1857] | 448 | while(cntcur) {
|
---|
[1829] | 449 | //cout << " ~GNUPlotContour() : destruction de _contours" << _contours <<endl;
|
---|
[1857] | 450 | cntold = cntcur;
|
---|
| 451 | cntcur = cntold->next;
|
---|
| 452 | gp_free(cntold);
|
---|
| 453 | cntold=NULL;
|
---|
| 454 | }
|
---|
| 455 | *******/
|
---|
| 456 | contour_free(cntcur);
|
---|
[1829] | 457 | _contours = NULL;
|
---|
| 458 |
|
---|
| 459 | if(My_Levels) {
|
---|
| 460 | //cout << " ~GNUPlotContour() : destruction de MyLevels "<<My_Levels <<endl;
|
---|
| 461 | delete[] My_Levels; My_Levels=NULL;}
|
---|
| 462 |
|
---|
| 463 | if(_myiso!=NULL){ delete _myiso; _myiso=NULL;}
|
---|
| 464 |
|
---|
| 465 | }
|
---|
| 466 |
|
---|
[1919] | 467 |
|
---|
| 468 | //++
|
---|
| 469 | // void CalcContour()
|
---|
| 470 | // Methode de calcul des courbes de niveaux
|
---|
| 471 | // par appel a la routine de GNUplot
|
---|
| 472 | //
|
---|
| 473 | //--
|
---|
[1829] | 474 | void GNUPlotContour::CalcContour(){
|
---|
[1857] | 475 | //cout << " GNUPlotContour::CalcContour(): determination des contours "<<endl;
|
---|
[1829] | 476 |
|
---|
[1857] | 477 | struct rusage r_usage;
|
---|
| 478 | int rcus;
|
---|
| 479 |
|
---|
[1829] | 480 | set_contour_kind(Contour_kind);
|
---|
| 481 | if(Contour_Levels_kind == LEVELS_INCREMENTAL){
|
---|
| 482 |
|
---|
| 483 | set_contour_levels(Contour_Levels);
|
---|
| 484 | set_contour_levels_kind(Contour_Levels_kind);
|
---|
| 485 | //free_contour_levels_list();
|
---|
| 486 | set_contour_levels_list(My_Levels);//,2);
|
---|
| 487 |
|
---|
| 488 | }else if(Contour_Levels_kind == LEVELS_DISCRETE ){
|
---|
| 489 | set_contour_levels(Contour_Levels);
|
---|
| 490 | set_contour_levels_kind(Contour_Levels_kind);
|
---|
| 491 | //free_contour_levels_list();
|
---|
| 492 | set_contour_levels_list(My_Levels);//,Contour_Levels);
|
---|
| 493 |
|
---|
| 494 | }else if(Contour_Levels_kind == LEVELS_NUM ){
|
---|
| 495 |
|
---|
| 496 | set_contour_levels(Contour_Levels);
|
---|
| 497 | set_contour_levels_kind(Contour_Levels_kind);
|
---|
| 498 | }else if(Contour_Levels_kind == LEVELS_AUTO){
|
---|
| 499 | Contour_Levels = 5;
|
---|
| 500 | set_contour_levels(Contour_Levels);
|
---|
| 501 | set_contour_levels_kind(Contour_Levels_kind);
|
---|
| 502 | }
|
---|
| 503 |
|
---|
[1857] | 504 |
|
---|
[1919] | 505 | //rcus = getrusage( RUSAGE_SELF , &r_usage);
|
---|
[1857] | 506 |
|
---|
| 507 | //if(rcus==0)
|
---|
| 508 | // cout << " rusage -> "<< r_usage.ru_maxrss <<" , "<< r_usage.ru_ixrss <<" , "<< r_usage.ru_ixrss <<endl;
|
---|
| 509 | //else
|
---|
| 510 | // perror("1er appel");
|
---|
| 511 |
|
---|
[1829] | 512 | if(_contours) {
|
---|
[1857] | 513 | cout << " GNUPlotContour::CalcContour(): destruction des contours "<<_contours<<endl;
|
---|
[1829] | 514 | struct gnuplot_contours *cntcur = _contours;
|
---|
[1857] | 515 | /******
|
---|
| 516 | struct gnuplot_contours *cntold;
|
---|
| 517 | while(cntcur) {
|
---|
| 518 | cout << " GNUPlotContour::CalcContour(): destruction des contours "<< cntcur<<endl;
|
---|
| 519 | cntold = cntcur;
|
---|
| 520 | cntcur = cntold->next;
|
---|
| 521 | gp_free(cntold);
|
---|
| 522 | cntold = NULL;
|
---|
| 523 | }
|
---|
| 524 | ******/
|
---|
| 525 | contour_free(cntcur);
|
---|
[1829] | 526 | _contours = NULL;
|
---|
| 527 |
|
---|
| 528 | }
|
---|
| 529 |
|
---|
[1857] | 530 | //struct gnuplot_contours *cntcur;
|
---|
[1829] | 531 | //struct gnuplot_contours *cntold;
|
---|
| 532 |
|
---|
[1857] | 533 |
|
---|
| 534 | //rcus = getrusage( RUSAGE_SELF , &r_usage);
|
---|
| 535 | //if(rcus==0)
|
---|
| 536 | // cout << " rusage -> "<< r_usage.ru_maxrss <<" , "<< r_usage.ru_ixrss <<" , "<< r_usage.ru_ixrss <<endl;
|
---|
| 537 | //else
|
---|
| 538 | // perror("2d appel");
|
---|
| 539 |
|
---|
| 540 |
|
---|
[1829] | 541 | _contours = contour (_nx,iso1);
|
---|
[1857] | 542 |
|
---|
| 543 |
|
---|
| 544 | //rcus = getrusage( RUSAGE_SELF , &r_usage);
|
---|
| 545 | //if(rcus==0)
|
---|
| 546 | // cout << " rusage -> "<< r_usage.ru_maxrss <<" , "<< r_usage.ru_ixrss <<" , "<< r_usage.ru_ixrss <<endl;
|
---|
| 547 | //else
|
---|
| 548 | // perror("3ieme appel");
|
---|
| 549 |
|
---|
[1829] | 550 | //free_contour_levels_list();
|
---|
| 551 |
|
---|
[1857] | 552 |
|
---|
[1829] | 553 | }
|
---|
[1919] | 554 | //++
|
---|
| 555 | // void SetMyLevels(double *ptr,int k)
|
---|
| 556 | // Setting du tableau des niveaux des contours
|
---|
| 557 | //Inputs
|
---|
| 558 | //| int k : nombre de niveaux
|
---|
| 559 | //| double *ptr : adresse du tableau des niveaux
|
---|
| 560 | //--
|
---|
[1829] | 561 | void
|
---|
| 562 | GNUPlotContour::SetMyLevels(double *ptr,int k){
|
---|
| 563 |
|
---|
| 564 | if(My_Levels!=NULL) delete My_Levels;
|
---|
| 565 | My_Levels = new double[k];
|
---|
| 566 | for(int i=0 ; i<k ; i++)My_Levels[i] = ptr[i];
|
---|
| 567 | }
|
---|
[2250] | 568 | //++
|
---|
| 569 | // void SetMyLevels(vector<double>vec)
|
---|
| 570 | // Setting du tableau des niveaux des contours
|
---|
| 571 | //Inputs
|
---|
| 572 | //|
|
---|
| 573 | //| vector <double> vec : vecteur des niveaux
|
---|
| 574 | //--
|
---|
| 575 | void
|
---|
| 576 | GNUPlotContour::SetMyLevels(vector <double> vec){
|
---|
| 577 |
|
---|
| 578 | if(My_Levels!=NULL) delete My_Levels;
|
---|
| 579 | int sz = vec.size();
|
---|
| 580 | assert (sz>0);
|
---|
[1829] | 581 |
|
---|
[2250] | 582 | My_Levels = new double[sz];
|
---|
| 583 | for(int i=0 ; i<sz ; i++)
|
---|
| 584 | My_Levels[i] = vec[i];
|
---|
| 585 | }
|
---|
| 586 |
|
---|
[1919] | 587 | //++
|
---|
| 588 | // Class PIContourDrawer
|
---|
| 589 | // Lib PIGcont
|
---|
| 590 | // include pigncont.h
|
---|
| 591 | //
|
---|
| 592 | // Classe de traceur de contour qui herite de PIDrawer et de GNUPlotContour
|
---|
| 593 | // elle gere les options graphiques generales (couleurs, lignes, fontes,...)
|
---|
| 594 | // les contours peuvent etre traces avec des lignes ou des markers
|
---|
| 595 | // on peut afficher les valeurs des niveaux des contours
|
---|
| 596 | // on peut demander a utiliser une table de couleur
|
---|
| 597 | // tout ca a travers la fenetre de controle associee (PICntools)
|
---|
| 598 | //
|
---|
| 599 | //
|
---|
| 600 | //--
|
---|
| 601 | //++
|
---|
| 602 | // Links Parents
|
---|
| 603 | // PIDrawer
|
---|
| 604 | // GNUPlotContour
|
---|
| 605 | //--
|
---|
| 606 | //++
|
---|
| 607 | // Links Voir aussi
|
---|
| 608 | // PIcntools
|
---|
| 609 | //--
|
---|
| 610 | //++
|
---|
| 611 | // Titre Constructeurs et Méthodes
|
---|
| 612 | //--
|
---|
| 613 | //++
|
---|
| 614 | // PIContourDrawer(P2DArrayAdapter* arr,bool autodel,int *nz,double *z0,double *dz )
|
---|
| 615 | // Constructeur a partir d'un P2DArrayAdapter* - voir le createur de GNUPlotContour
|
---|
| 616 | //
|
---|
| 617 | //--
|
---|
| 618 |
|
---|
[1829] | 619 | PIContourDrawer::PIContourDrawer(P2DArrayAdapter* arr,bool autodel,int *nz,double *z0,double *dz )
|
---|
| 620 | :GNUPlotContour(arr,nz,z0,dz)
|
---|
| 621 |
|
---|
| 622 | {
|
---|
| 623 | _arr = arr;
|
---|
| 624 | _nti = NULL;
|
---|
| 625 | _nz=5;
|
---|
| 626 | if(nz!=NULL)_nz = *nz;
|
---|
| 627 | _autodel = autodel;
|
---|
[1853] | 628 |
|
---|
| 629 | // This drawer has specific control tools
|
---|
| 630 | mFgSpecContWind = true;
|
---|
[1829] | 631 | InitAtts();
|
---|
| 632 | }
|
---|
| 633 |
|
---|
[1919] | 634 | //++
|
---|
| 635 | // PIContourDrawer(NTupleInterface* nti,bool autodel,int *nz,double *z0,double *dz )
|
---|
| 636 | // Constructeur a partir d'un NTupleInterface* - voir le createur de GNUPlotContour
|
---|
| 637 | //
|
---|
| 638 | //--
|
---|
[1829] | 639 | PIContourDrawer::PIContourDrawer(NTupleInterface* nti,bool autodel,int *nz,double *z0,double *dz )
|
---|
| 640 | :GNUPlotContour(nti,nz,z0,dz)
|
---|
| 641 |
|
---|
| 642 | {
|
---|
| 643 | _arr = NULL;
|
---|
| 644 | _nti = nti;
|
---|
| 645 | _nz=5;
|
---|
| 646 | if(nz!=NULL)_nz = *nz;
|
---|
| 647 | _autodel = autodel;
|
---|
| 648 | InitAtts();
|
---|
| 649 | }
|
---|
| 650 |
|
---|
| 651 |
|
---|
| 652 |
|
---|
| 653 | /* --Methode-- */
|
---|
| 654 | PIContourDrawer::~PIContourDrawer()
|
---|
| 655 | {
|
---|
| 656 | if(_autodel){
|
---|
| 657 | if(_arr!=NULL){delete _arr; _arr=NULL;}
|
---|
| 658 | if(_nti!=NULL){delete _nti ; _nti=NULL;}
|
---|
| 659 | }
|
---|
[2250] | 660 | DeactivateControlWindow(NULL);
|
---|
[1829] | 661 | //if (mColorMap!=NULL){delete mColorMap; mColorMap=NULL;}
|
---|
| 662 | }
|
---|
| 663 |
|
---|
| 664 | /* --Methode-- */
|
---|
| 665 | void PIContourDrawer::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
|
---|
| 666 | {
|
---|
| 667 | // double xmin, double ymin, double xmax, double ymax LIMITES DE LA ZONE A REFRESHER
|
---|
| 668 | //PIGrCoord * xx = new PIGrCoord[10];
|
---|
| 669 | //PIGrCoord * yy = new PIGrCoord[10];
|
---|
| 670 | PIGrCoord * xx =NULL;
|
---|
| 671 | PIGrCoord * yy =NULL;
|
---|
| 672 | PIGrCoord xa;
|
---|
| 673 | PIGrCoord ya;
|
---|
| 674 | char buff[64];
|
---|
| 675 | // On met les bons attributs graphiques
|
---|
| 676 | //SelGraAtt(g);
|
---|
| 677 | g->SaveGraphicAtt();
|
---|
| 678 | struct gnuplot_contours *cntcur;
|
---|
| 679 | struct gnuplot_contours *cntold;
|
---|
| 680 | cntcur = _contours;
|
---|
| 681 |
|
---|
| 682 | double a,b;
|
---|
| 683 | int tot=0;
|
---|
| 684 | bool Invx, Invy, Exy;
|
---|
| 685 | PIColorMap * cmap = NULL;
|
---|
[1905] | 686 | CMapId mcmapid = GetGraphicAtt().GetColMapId();
|
---|
| 687 | if(mcmapid !=CMAP_OTHER ){
|
---|
| 688 | cmap = new PIColorMap(mcmapid);
|
---|
[1829] | 689 | }
|
---|
| 690 | int numdr = 0;
|
---|
| 691 | while(cntcur){
|
---|
| 692 | int npts = cntcur->num_pts ;
|
---|
| 693 | if(npts<0) continue;
|
---|
| 694 |
|
---|
| 695 | xx = new PIGrCoord[npts];
|
---|
| 696 | yy = new PIGrCoord[npts];
|
---|
| 697 | double lev = (cntcur->coords)[0].z ;
|
---|
| 698 | for(int l=0 ; l< npts ; l++){
|
---|
| 699 | a = (cntcur->coords)[l].x;
|
---|
| 700 | b = (cntcur->coords)[l].y;
|
---|
| 701 |
|
---|
| 702 | xx[l] = a ;
|
---|
| 703 | yy[l] = b ;
|
---|
| 704 |
|
---|
| 705 | }
|
---|
| 706 |
|
---|
| 707 | // choix de la couleur
|
---|
| 708 |
|
---|
[1905] | 709 | g->SelForeground(GetGraphicAtt().GetFgColor());
|
---|
| 710 | if(mcmapid !=CMAP_OTHER ){
|
---|
[1829] | 711 | if(_zmax-_zmin!=0){
|
---|
| 712 | int kc = ((lev - _zmin)/(_zmax-_zmin))*cmap->NCol();
|
---|
| 713 |
|
---|
| 714 | g->SelForeground(*cmap,kc);
|
---|
| 715 | }
|
---|
| 716 | }
|
---|
| 717 | // traitement des des markers
|
---|
| 718 | if(IsMarkOn()==true){
|
---|
| 719 |
|
---|
[1905] | 720 | g->SelMarker(GetGraphicAtt().GetMarkerSz(), GetGraphicAtt().GetMarker());
|
---|
[1829] | 721 | g->DrawMarkers(xx,yy,npts);
|
---|
| 722 | }
|
---|
| 723 | // traitement des lignes
|
---|
| 724 | if(mLineOn==true){
|
---|
| 725 |
|
---|
[1905] | 726 | g->SelLine(GetGraphicAtt().GetLineAtt());
|
---|
[1829] | 727 | g->DrawPolygon(xx,yy,npts,false);
|
---|
| 728 | }
|
---|
| 729 | // traitement des labels
|
---|
| 730 | // SIMPLISTE POUR L'INSTANT : UN AFFICHAGE
|
---|
| 731 | if(mLabelOn==true){
|
---|
| 732 | //
|
---|
| 733 |
|
---|
| 734 | char strg[10];
|
---|
| 735 | sprintf(strg,"%g",lev);
|
---|
[1905] | 736 | PIFont myfont(GetGraphicAtt().GetFont());
|
---|
[1829] | 737 |
|
---|
| 738 | g->SelFont(myfont);
|
---|
| 739 | double px,py;
|
---|
| 740 | px = (cntcur->coords)[0].x+2*(Xmax()-Xmin())/100.;
|
---|
| 741 | py = (cntcur->coords)[0].y;
|
---|
| 742 | g->DrawString(px,py,strg, PI_HorizontalCenter&&PI_VerticalCenter );
|
---|
| 743 |
|
---|
| 744 | }
|
---|
| 745 | numdr++;
|
---|
| 746 | delete[] xx;
|
---|
| 747 | xx=NULL;
|
---|
| 748 | delete[] yy;
|
---|
| 749 | yy=NULL;
|
---|
| 750 | cntcur = cntcur->next;
|
---|
| 751 | tot++;
|
---|
| 752 | }
|
---|
| 753 |
|
---|
| 754 | //cout << "PIContourDrawer::Draw fin de trace des "<<tot<< " polygones "<<endl;
|
---|
| 755 |
|
---|
| 756 | //
|
---|
| 757 | if(cmap !=NULL)delete cmap;
|
---|
| 758 |
|
---|
| 759 | g->RestoreGraphicAtt();
|
---|
| 760 | }
|
---|
| 761 |
|
---|
| 762 | /* --Methode-- */
|
---|
| 763 | void PIContourDrawer::UpdateLimits()
|
---|
| 764 | {
|
---|
| 765 | // Doit calculer les limites
|
---|
| 766 |
|
---|
| 767 | double xmn = _xmin;
|
---|
| 768 | double xmx = _xmax;
|
---|
| 769 | double ymn = _ymin;
|
---|
| 770 | double ymx = _ymax;
|
---|
| 771 |
|
---|
| 772 | SetLimits(xmn, xmx, ymn, ymx);
|
---|
| 773 | }
|
---|
| 774 |
|
---|
| 775 |
|
---|
| 776 | /* --Methode-- */
|
---|
| 777 | void PIContourDrawer::ShowControlWindow(PIBaseWdgGen* wdg)
|
---|
| 778 | {
|
---|
| 779 | PICnTools::SetCurrentBaseWdg(wdg);
|
---|
| 780 | PICnTools::SetCurrentCnDrw(this);
|
---|
| 781 | PICnTools::ShowPICnTools();
|
---|
| 782 | }
|
---|
| 783 |
|
---|
[2250] | 784 | //++
|
---|
| 785 | void PIContourDrawer::DeactivateControlWindow(PIBaseWdgGen* wdg)
|
---|
| 786 | //
|
---|
| 787 | // Desactivation de la fenetre de controle specialisee
|
---|
| 788 | //--
|
---|
| 789 | {
|
---|
| 790 | // si wdg != NULL, c'est un Detach (Drawer detache du PIBaseWdg
|
---|
| 791 | // si wdg == NULL, c'est un delete du PIHisto2D (du PIDrawer)
|
---|
| 792 |
|
---|
| 793 | PICnTools::SetCurrentBaseWdg(NULL);
|
---|
| 794 | PICnTools::SetCurrentCnDrw(NULL);
|
---|
| 795 | PICnTools::HidePICnTools();
|
---|
[1829] | 796 |
|
---|
[2250] | 797 | return;
|
---|
| 798 | }
|
---|
| 799 |
|
---|
| 800 |
|
---|
[1829] | 801 | /* --Methode-- */
|
---|
| 802 | bool PIContourDrawer::IsLabelOn(){
|
---|
| 803 | return (mLabelOn);
|
---|
| 804 | }
|
---|
| 805 |
|
---|
| 806 | bool PIContourDrawer::IsLineOn(){
|
---|
| 807 | return (mLineOn);
|
---|
| 808 | }
|
---|
| 809 |
|
---|
| 810 | bool PIContourDrawer::IsMarkOn(){
|
---|
| 811 | return (mMarkOn);
|
---|
| 812 | }
|
---|
| 813 |
|
---|
| 814 | void PIContourDrawer::SetLabelOn(bool state){
|
---|
| 815 | mLabelOn = state;
|
---|
| 816 | }
|
---|
| 817 |
|
---|
| 818 | void PIContourDrawer::SetMarkOn(bool state){
|
---|
| 819 | mMarkOn = state;
|
---|
| 820 | }
|
---|
| 821 |
|
---|
| 822 | void PIContourDrawer::SetLineOn(bool state){
|
---|
| 823 | mLineOn = state;
|
---|
| 824 | }
|
---|
| 825 |
|
---|
| 826 | void PIContourDrawer::InitAtts(){
|
---|
[1919] | 827 | mLineOn = true;
|
---|
| 828 | mMarkOn = false;
|
---|
[1829] | 829 | mLabelOn = false;
|
---|
| 830 | }
|
---|
| 831 |
|
---|
[2250] | 832 | int PIContourDrawer::DecodeOptionString(vector<string> & opt, bool rmdecopt)
|
---|
| 833 | {
|
---|
| 834 | // inspire de int PINTuple::DecodeOptionString
|
---|
| 835 | // OP 11/2002 LAL Orsay
|
---|
| 836 |
|
---|
| 837 | int ndec = opt.size();
|
---|
| 838 | if (ndec < 1) return(0);
|
---|
[1829] | 839 |
|
---|
[2250] | 840 |
|
---|
| 841 | cout << " PIDrawer::DecodeOptionString : ndec = "<< ndec <<endl;
|
---|
| 842 | // On appelle d'abord le decodage de la classe PIDrawer de laquelle
|
---|
| 843 | // on herite. (Pas obligatoire) on decode donc ici les attributs de
|
---|
| 844 | // couleur, fontes ...
|
---|
| 845 | int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
|
---|
| 846 | cout << " PIDrawer::DecodeOptionString apres PIDrawer::DecodeOptionString : ndec = "
|
---|
| 847 | << ndec1 <<"<>" << ndec <<endl;
|
---|
| 848 | if( ndec - ndec1 < 1 ) return(ndec1); // si tout a ete decode
|
---|
| 849 |
|
---|
| 850 | vector<string> udopt; // On gardera ici les options non decodees
|
---|
| 851 | int iopt = 0;
|
---|
| 852 | ndec = opt.size();
|
---|
| 853 | int recalc = 0;
|
---|
| 854 | for (iopt = 0 ; iopt<ndec ; iopt++){
|
---|
| 855 |
|
---|
| 856 | string sopt = opt[iopt];
|
---|
| 857 | if( sopt.find_first_of("=") != string::npos ){
|
---|
| 858 | // options avec =
|
---|
| 859 | string deb = sopt.substr(0,sopt.find_first_of("="));
|
---|
| 860 | cout << " option avec = : "<<deb<<" "<<sopt<<endl;
|
---|
| 861 | if( (deb =="ncont") || (deb =="nc") ){ // # de contours
|
---|
| 862 | string fin = sopt.substr(sopt.find_first_of("=")+1 , string::npos);
|
---|
| 863 | cout <<" fin "<<fin<<endl;
|
---|
| 864 | int nlev = atoi(fin.c_str());
|
---|
| 865 | this->SetNLevel(nlev);
|
---|
| 866 | this->SetCntLevelKind(LEVELS_NUM);
|
---|
| 867 | recalc =1;
|
---|
| 868 | }else if(deb=="niv"||deb=="lev"){ // hauteur des niveaux
|
---|
| 869 | string fin = sopt.substr(sopt.find_first_of("=")+1 , string::npos);
|
---|
| 870 | char * buff = strdup(fin.c_str());
|
---|
| 871 | char *tmp;
|
---|
| 872 | tmp = strtok(buff,",");
|
---|
| 873 |
|
---|
| 874 | if(tmp==NULL){
|
---|
| 875 | cerr<< " PICOntourDrawer::DecodeOptionString ERREUR decodage des niveaux impossible " << buff <<endl;
|
---|
| 876 |
|
---|
| 877 | }else {
|
---|
| 878 |
|
---|
| 879 | vector <double> ztmp;
|
---|
| 880 | while(tmp!=NULL){
|
---|
| 881 | ztmp.push_back(atof(tmp));
|
---|
| 882 | tmp = strtok(NULL,",");
|
---|
| 883 | }
|
---|
| 884 | int nlev = ztmp.size();
|
---|
| 885 | cout << " PICOntourDrawer::DecodeOptionString "<<nlev<<" niveaux decodes "<<endl;
|
---|
| 886 | this->SetCntLevelKind(LEVELS_DISCRETE);
|
---|
| 887 | this->SetNLevel(nlev);
|
---|
| 888 | this->SetMyLevels(ztmp);
|
---|
| 889 | recalc =1;
|
---|
| 890 | }
|
---|
| 891 | }else if(deb=="lstep" ){ // niveaux incrementaux : args = nombre,depart,pas
|
---|
| 892 | string fin = sopt.substr(sopt.find_first_of("=")+1 , string::npos);
|
---|
| 893 | char * buff = strdup(fin.c_str());
|
---|
| 894 | char *tmp;
|
---|
| 895 | tmp = strtok(buff,",");
|
---|
| 896 |
|
---|
| 897 | if(tmp==NULL){
|
---|
| 898 | cerr<< " PICOntourDrawer::DecodeOptionString ERREUR decodage nvx/incr. impossible " << buff <<endl;
|
---|
| 899 | }else{
|
---|
| 900 |
|
---|
| 901 | vector <double> ztmp;
|
---|
| 902 | while(tmp!=NULL){
|
---|
| 903 | ztmp.push_back(atof(tmp));
|
---|
| 904 | tmp = strtok(NULL,",");
|
---|
| 905 | }
|
---|
| 906 | if(ztmp.size() !=2) {
|
---|
| 907 | cerr<< " PICOntourDrawer::DecodeOptionString ERREUR nb params incorrect(incr) " << buff <<endl;
|
---|
| 908 | }else{
|
---|
| 909 | vector <double> zlev;
|
---|
| 910 | zlev.push_back(ztmp[1]);
|
---|
| 911 | zlev.push_back(ztmp[2]);
|
---|
| 912 | this->SetCntLevelKind(LEVELS_INCREMENTAL);
|
---|
| 913 | this->SetNLevel( (int) ztmp[0]);
|
---|
| 914 | this->SetMyLevels(zlev);
|
---|
| 915 | recalc=1;
|
---|
| 916 | }
|
---|
| 917 | }
|
---|
| 918 |
|
---|
| 919 | }else{
|
---|
| 920 | cout<<"PICOntourDrawer::DecodeOptionString ERREUR option "<<sopt<<" non reconnue "<<endl;
|
---|
| 921 | ndec--;
|
---|
| 922 | if (rmdecopt) udopt.push_back( sopt );
|
---|
| 923 | }
|
---|
| 924 | }else{ //options sans "="
|
---|
| 925 | if( sopt == "labon" )
|
---|
| 926 | this->SetLabelOn();
|
---|
| 927 | else if (sopt == "bspline" ){
|
---|
| 928 | this->SetCntKind(CONTOUR_KIND_BSPLINE);
|
---|
| 929 | recalc = 1;
|
---|
| 930 | }else if (sopt == "3spl" ){
|
---|
| 931 | this->SetCntKind(CONTOUR_KIND_CUBIC_SPL);
|
---|
| 932 | recalc = 1;
|
---|
| 933 | }
|
---|
| 934 | else{
|
---|
| 935 | cout<<"PICOntourDrawer::DecodeOptionString ERREUR option "<<sopt<<" non reconnue "<<endl;
|
---|
| 936 | ndec--;
|
---|
| 937 | if (rmdecopt) udopt.push_back(sopt);
|
---|
| 938 | }
|
---|
| 939 | }
|
---|
| 940 |
|
---|
| 941 | }// FIN DE LA BOUCLE SUR LES OPTIONS
|
---|
| 942 |
|
---|
| 943 | if(recalc==1){
|
---|
| 944 | // il faut (re)calculer les contours
|
---|
| 945 | cout << " PICOntourDrawer::DecodeOptionString(re)calcul des contours "<<endl;
|
---|
| 946 | this->CalcContour();
|
---|
| 947 | }
|
---|
| 948 | this->Refresh();
|
---|
| 949 |
|
---|
| 950 |
|
---|
| 951 | //
|
---|
| 952 |
|
---|
| 953 | // S'il faut supprimer les options decodees, on remplace l'argument opt
|
---|
| 954 | // par le vecteur des options non decodees.
|
---|
| 955 | if (rmdecopt) opt = udopt;
|
---|
| 956 |
|
---|
| 957 | return(ndec+ndec1);
|
---|
| 958 |
|
---|
| 959 | }
|
---|
| 960 |
|
---|
| 961 |
|
---|
| 962 |
|
---|