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