| 1 | #include <stdio.h> | 
|---|
| 2 | #include "piapplgen.h" | 
|---|
| 3 | #include "pihisto2d.h" | 
|---|
| 4 | #include "nbrandom.h" | 
|---|
| 5 |  | 
|---|
| 6 | static int dbg = 0; | 
|---|
| 7 |  | 
|---|
| 8 | //++ | 
|---|
| 9 | // Class        PIHisto2D | 
|---|
| 10 | // Lib          PIext | 
|---|
| 11 | // include      pihisto2d.h | 
|---|
| 12 | // | 
|---|
| 13 | //      Classes de dessin des histogrammes a 2 dimensions pour | 
|---|
| 14 | //      objets *Histo2D* | 
|---|
| 15 | //-- | 
|---|
| 16 |  | 
|---|
| 17 | //++ | 
|---|
| 18 | // Links        Parents | 
|---|
| 19 | // PIDrawer | 
|---|
| 20 | //-- | 
|---|
| 21 |  | 
|---|
| 22 | //++ | 
|---|
| 23 | // Titre        Constructeur, méthodes | 
|---|
| 24 | //-- | 
|---|
| 25 |  | 
|---|
| 26 | //++ | 
|---|
| 27 | PIHisto2D::PIHisto2D(Histo2D* histo, bool ad) | 
|---|
| 28 | // | 
|---|
| 29 | //      Createur d'une classe de dessin pour l'histogramme 2D histo. | 
|---|
| 30 | //-- | 
|---|
| 31 | : PIDrawer(), mHisto(histo) | 
|---|
| 32 | { | 
|---|
| 33 | mAdDO = ad;     // Flag pour suppression automatique de mHisto | 
|---|
| 34 |  | 
|---|
| 35 | mLogScale = 10.; | 
|---|
| 36 | mFPoints = 0.5; | 
|---|
| 37 |  | 
|---|
| 38 | UseColors(); | 
|---|
| 39 | UseDisplay(); | 
|---|
| 40 | UseDyn(); | 
|---|
| 41 | UseFrac(); | 
|---|
| 42 | } | 
|---|
| 43 |  | 
|---|
| 44 | //++ | 
|---|
| 45 | PIHisto2D::~PIHisto2D() | 
|---|
| 46 | // | 
|---|
| 47 | //      Destructeur. | 
|---|
| 48 | //-- | 
|---|
| 49 | { | 
|---|
| 50 | if(mAdDO) delete mHisto; | 
|---|
| 51 | } | 
|---|
| 52 |  | 
|---|
| 53 | //++ | 
|---|
| 54 | void PIHisto2D::UseColors(bool fg, CMapId cmap) | 
|---|
| 55 | // | 
|---|
| 56 | //      Choix de la couleur si fg=true avec la color map cmap. | 
|---|
| 57 | //      (pour la couleur cmap cf picmap.h). | 
|---|
| 58 | //      Independamment du choix du display, la dynamique est | 
|---|
| 59 | //      codee sur la color map donnant ainsi une double | 
|---|
| 60 | //      information. Par exemple, carres de tailles variables | 
|---|
| 61 | //      en couleur. Cette option est incontournable dans le cas | 
|---|
| 62 | //      d'un display par des carres de taille fixe. | 
|---|
| 63 | //-- | 
|---|
| 64 | { | 
|---|
| 65 | mFgCol = fg; mCmap = cmap; | 
|---|
| 66 | } | 
|---|
| 67 |  | 
|---|
| 68 | //++ | 
|---|
| 69 | void PIHisto2D::UseScale(unsigned short type,float logscale) | 
|---|
| 70 | // | 
|---|
| 71 | //      Pour changer les echelles (lineaire ou logarithmique) | 
|---|
| 72 | //| Type = 0 : echelle lineaire | 
|---|
| 73 | //|      = 1 : echelle log10 | 
|---|
| 74 | //| -**- Explication du codage en type=0 (lineaire) : | 
|---|
| 75 | //|   1. [hmin,hmax] -> [0,1] | 
|---|
| 76 | //|           h      ->   f = (h-hmin)/(hmax-hmin) | 
|---|
| 77 | //|   2. codage de f=[0,1] sur la dynamique du display choisi | 
|---|
| 78 | //| -**- Explication du codage en type=1 (logarithmique base 10) : | 
|---|
| 79 | //|   1. map lineaire entre 0 et 1: | 
|---|
| 80 | //|      [hmin,hmax] -> [0,1] | 
|---|
| 81 | //|           h      ->   f = (h-hmin)/(hmax-hmin) | 
|---|
| 82 | //|   2. transformation logarithmique de base 10 : | 
|---|
| 83 | //|      [0,1] -> [0,1] | 
|---|
| 84 | //|        f   -> lf = log10(1.+f*(logscale-1))/log10(logscale) | 
|---|
| 85 | //|   3. codage de lf=[0,1] sur la dynamique du display choisi | 
|---|
| 86 | //-- | 
|---|
| 87 | { | 
|---|
| 88 | if(type==0) mTypScal = 0; | 
|---|
| 89 | if(type==1) { | 
|---|
| 90 | mTypScal = 1; | 
|---|
| 91 | if(logscale>1.) mLogScale = logscale; | 
|---|
| 92 | } else mTypScal = 0; | 
|---|
| 93 | } | 
|---|
| 94 |  | 
|---|
| 95 | //++ | 
|---|
| 96 | void PIHisto2D::UseDisplay(unsigned short type, float fnpt) | 
|---|
| 97 | // | 
|---|
| 98 | //      Type de Display | 
|---|
| 99 | //| Type = 0 : carres de tailles variables | 
|---|
| 100 | //| Type = 1 : nuages de points | 
|---|
| 101 | //|            Le nombre de points a utiliser est fnpt*N | 
|---|
| 102 | //|            ou N est le nombre de pixels ecran contenu | 
|---|
| 103 | //|            dans un bin de l'histogramme. | 
|---|
| 104 | //| Type = 2 : code a la "hbook2" " .+123...9AB...YZ*" | 
|---|
| 105 | //|            (cf detail PIHisto2D::HPrint2) | 
|---|
| 106 | //| Type = 3 : carres de taille fixe (couleur). | 
|---|
| 107 | //-- | 
|---|
| 108 | { | 
|---|
| 109 | if(fnpt<0.) fnpt=0; else if(fnpt>1.) fnpt=1.; | 
|---|
| 110 | if(type==0)        mTypDisp = 0; | 
|---|
| 111 | else if(type==1) { mTypDisp = 1; mFPoints = fnpt;} | 
|---|
| 112 | else if(type==2)   mTypDisp = 2; | 
|---|
| 113 | else if(type==3)   mTypDisp = 3; | 
|---|
| 114 | else               mTypDisp = 1; | 
|---|
| 115 | } | 
|---|
| 116 |  | 
|---|
| 117 | //++ | 
|---|
| 118 | void PIHisto2D::UseDyn(float hmin, float hmax) | 
|---|
| 119 | // | 
|---|
| 120 | //      Gestion de la dynamique a representer: | 
|---|
| 121 | //|  La dynamique va etre transformee de [hmin,hmax] vers [0,1] selon | 
|---|
| 122 | //|  [hmin,hmax] -> [0,1] | 
|---|
| 123 | //|       h      ->   f = (h-hmin)/(hmax-hmin) | 
|---|
| 124 | //|  Par la suite selon ce qui est demande, f va coder le display ou etre | 
|---|
| 125 | //|  transforme en une autre echelle [0,1]. | 
|---|
| 126 | //|  Si hmax<=hmin, ils sont forces a la dynamique totale de l'histo2D. | 
|---|
| 127 | //-- | 
|---|
| 128 | { | 
|---|
| 129 | if(hmin>=hmax) {hmin = mHisto->VMin(); hmax = mHisto->VMax();} | 
|---|
| 130 | if(hmin>=hmax) hmax = hmin+1.; | 
|---|
| 131 | mHMin = hmin; mHMax = hmax; | 
|---|
| 132 | } | 
|---|
| 133 |  | 
|---|
| 134 | //++ | 
|---|
| 135 | void PIHisto2D::UseFrac(float frmin, float frmax) | 
|---|
| 136 | // | 
|---|
| 137 | //      Pour definir la fraction de la dynamique a dessiner: | 
|---|
| 138 | //| Certains type de display (f=[0,1] cf PIHisto2D::UseDyn), | 
|---|
| 139 | //|  - on ne dessine rien si f <= frmin dans les cas de display avec | 
|---|
| 140 | //|    des nuages de points ou des carres de tailles variables. | 
|---|
| 141 | //|    Pour un display "a la hbook2" on force frmin = 0. | 
|---|
| 142 | //|  - frmax n'est utilise que pour la representation avec | 
|---|
| 143 | //|    des carres de tailles variables: c'est la taille | 
|---|
| 144 | //|    maximum que peut avoir le carre exprimee en unite | 
|---|
| 145 | //|    de la taille du bin (ex: si frmax=0.8 le carre | 
|---|
| 146 | //|    le + grand qui pourra etre dessine dans un bin | 
|---|
| 147 | //|    aura une taille egale a 0.8*(taille du bin)). | 
|---|
| 148 | //-- | 
|---|
| 149 | { | 
|---|
| 150 | if(frmax<=0. || frmax>1.) frmax = 1.; | 
|---|
| 151 | if(frmin>=frmax) {frmin=0.1; frmax=0.9;} | 
|---|
| 152 | mFracMin = frmin; mFracMax = frmax; | 
|---|
| 153 | } | 
|---|
| 154 |  | 
|---|
| 155 | //++ | 
|---|
| 156 | void PIHisto2D::Print(int lp) | 
|---|
| 157 | // | 
|---|
| 158 | //      Print de l'etat des options du display. | 
|---|
| 159 | //-- | 
|---|
| 160 | { | 
|---|
| 161 | printf("PIHisto2D::Print FgCol=%d Cmap=%d TypScal=%d TypDisp=%d (FPoints=%g)\n" | 
|---|
| 162 | ,(int)mFgCol,(int)mCmap,mTypScal,mTypDisp,mFPoints); | 
|---|
| 163 | printf("                 Dyn=%g,%g Frac=%g,%g LogSc=%g H=%lx\n" | 
|---|
| 164 | ,mHMin,mHMax,mFracMin,mFracMax,mLogScale,(long)mHisto); | 
|---|
| 165 | if(lp<1) return; | 
|---|
| 166 | mHisto->PrintStatus(); | 
|---|
| 167 | } | 
|---|
| 168 |  | 
|---|
| 169 | //++ | 
|---|
| 170 | void PIHisto2D::UpdateLimits() | 
|---|
| 171 | // | 
|---|
| 172 | //      Definition des tailles graphiques en fonction | 
|---|
| 173 | //      des caracteristiques de l'histogramme a dessiner. | 
|---|
| 174 | //-- | 
|---|
| 175 | { | 
|---|
| 176 | if(!mHisto) return; | 
|---|
| 177 | SetLimits(mHisto->XMin(), mHisto->XMax(), mHisto->YMin() , mHisto->YMax()); | 
|---|
| 178 | //  SetAxesFlags(kBoxAxes | kExtTicks | kLabels);   Ne pas faire - Reza 11/99 | 
|---|
| 179 | } | 
|---|
| 180 |  | 
|---|
| 181 | //++ | 
|---|
| 182 | void PIHisto2D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax) | 
|---|
| 183 | // | 
|---|
| 184 | //      Dessin de l'histogramme. | 
|---|
| 185 | //|  Code de dessin selon choix des options: | 
|---|
| 186 | //|  (detail voir UseColors UseScale UseDisplay UseDyn UseFrac) | 
|---|
| 187 | //|  [hmin,hmax] -> [0,1] [[ -> re-codage log10 entre [0,1] ]] -> f=[0,1] | 
|---|
| 188 | //|  Puis selon display: | 
|---|
| 189 | //|  0 carres variables : if(f>fracmin) taille carre = f*fracmax *taille_du_bin | 
|---|
| 190 | //|  1 nuage de points  : if(f>fracmin) npoints = f*PerPt *npoints_ecran_dans_bin | 
|---|
| 191 | //|  2 code hbook2      : if(f>0) map de f=]0,1] dans ".+...Z*" | 
|---|
| 192 | //|  3 carres fixes     : couleur = lut[f*nombre_d_entree_dans_la_lut] | 
|---|
| 193 | //-- | 
|---|
| 194 | { | 
|---|
| 195 |  | 
|---|
| 196 | if (axesFlags != kAxesNone) DrawAxes(g); | 
|---|
| 197 |  | 
|---|
| 198 | if(!mHisto) return; | 
|---|
| 199 | // Caracteristiques histogramme | 
|---|
| 200 | double dx = mHisto->WBinX(),dy = mHisto->WBinY(); | 
|---|
| 201 | double p1dx,p1dy; | 
|---|
| 202 | g->DGrC2UC(1.f,1.f,p1dx,p1dy); | 
|---|
| 203 |  | 
|---|
| 204 | // Gamme a representer entre [0,1] mais >=fracmin et scale fracmax | 
|---|
| 205 | float fracmin=FMin(), fracmax=FMax(); | 
|---|
| 206 | float llscale = (float) log10((double)LogScale()); | 
|---|
| 207 |  | 
|---|
| 208 | // gestion Couleurs. | 
|---|
| 209 | PIColorMap* cmap=NULL; | 
|---|
| 210 | PIColors coul = g->GetForeground(); | 
|---|
| 211 | int ncol = 0; | 
|---|
| 212 | if (mFgCol) { | 
|---|
| 213 | cmap = new PIColorMap(mCmap); ncol = cmap->NCol(); | 
|---|
| 214 | if(mTypDisp==3) fracmin=-1.; | 
|---|
| 215 | } | 
|---|
| 216 |  | 
|---|
| 217 | // gestion epaisseur de ligne | 
|---|
| 218 | if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine); | 
|---|
| 219 |  | 
|---|
| 220 | // gestion Markers ou plot avec des points. | 
|---|
| 221 | PIMarker Mk = g->GetMarker(); | 
|---|
| 222 | int MkSz = g->GetMarkerSize(); | 
|---|
| 223 | int npt = 1; | 
|---|
| 224 | if(mTypDisp==1) { | 
|---|
| 225 | g->SelMarker(1,PI_DotMarker); | 
|---|
| 226 | npt = (int) ((float)NPixBin(g)*FPoints()); if(npt<=0) npt = 2; | 
|---|
| 227 | } | 
|---|
| 228 |  | 
|---|
| 229 | // gestion Font. | 
|---|
| 230 | PIFontAtt FontAtt = g->GetFont().GetFontAtt(); | 
|---|
| 231 | int FontSize = g->GetFont().GetFontSize(); | 
|---|
| 232 | if(mTypDisp==2) { | 
|---|
| 233 | double dxg,dyg,dg; | 
|---|
| 234 | g->DUC2GrC(dx,dy,dxg,dyg); | 
|---|
| 235 | dg =(dxg<dyg) ? dxg : dyg; | 
|---|
| 236 | int npix = (int) (dg*0.9); if(npix<8) npix = 8; | 
|---|
| 237 | //printf("PIHisto2D::Draw_Font H dx=%g dy=%g, G dx=%g dy=%g, npix = %g,%d\n" | 
|---|
| 238 | //      ,dx,dy,dxg,dyg,dg,npix); | 
|---|
| 239 | g->SelFontSzPt(npix,PI_RomanFont); | 
|---|
| 240 | fracmin = 0; | 
|---|
| 241 | } | 
|---|
| 242 |  | 
|---|
| 243 | // Print(); | 
|---|
| 244 |  | 
|---|
| 245 | // Plot de l'histogramme | 
|---|
| 246 | for (int i=0; i<mHisto->NBinX(); i++) | 
|---|
| 247 | for (int j=0; j<mHisto->NBinY(); j++) { | 
|---|
| 248 |  | 
|---|
| 249 | r_8 left0,bottom0; | 
|---|
| 250 | mHisto->BinLowEdge(i,j,left0,bottom0); | 
|---|
| 251 |  | 
|---|
| 252 | // Gestion de la dynamique a dessiner | 
|---|
| 253 | float frac = ((*mHisto)(i,j)-HMin())/(HMax()-HMin()); | 
|---|
| 254 | if(frac<0.) continue; | 
|---|
| 255 | if(mTypScal==1) {              // echelle log10 | 
|---|
| 256 | frac = log10(1.+frac*(LogScale()-1.))/llscale; | 
|---|
| 257 | if(frac<0.) continue; | 
|---|
| 258 | } | 
|---|
| 259 | if(frac<=fracmin) continue; | 
|---|
| 260 | if(frac>1.) frac = 1.; | 
|---|
| 261 | float fracred = frac * fracmax; | 
|---|
| 262 |  | 
|---|
| 263 | // Gestion de la couleur | 
|---|
| 264 | int icol = 0; | 
|---|
| 265 | if (cmap) { | 
|---|
| 266 | icol = int( (float) ncol*frac ); | 
|---|
| 267 | if(icol>=ncol) icol = ncol-1; else if(icol<0) icol=0; | 
|---|
| 268 | g->SelForeground(*cmap,icol); | 
|---|
| 269 | } | 
|---|
| 270 |  | 
|---|
| 271 | // Pour ne pas dessiner en dehors des axes | 
|---|
| 272 | if ( (left0+dx/2. < xmin) || (left0+dx/2. > xmax) || | 
|---|
| 273 | (bottom0+dy/2. < ymin) || (bottom0+dy/2. > ymax) ) continue; | 
|---|
| 274 |  | 
|---|
| 275 | // Dessin proprement dit selon le choix graphique. | 
|---|
| 276 | if(mTypDisp==0) { | 
|---|
| 277 | //..... carres de tailles variables | 
|---|
| 278 | double left   = left0   + 0.5*(1.-fracred)*dx, width  = fracred*dx; | 
|---|
| 279 | double bottom = bottom0 + 0.5*(1.-fracred)*dy, height = fracred*dy; | 
|---|
| 280 | if (cmap) g->DrawFBox(left,bottom,width,height); | 
|---|
| 281 | else      g->DrawBox(left,bottom,width,height); | 
|---|
| 282 | } else if(mTypDisp==1) { | 
|---|
| 283 | //..... nuage de points ..... | 
|---|
| 284 | int ipt  = int( (float) npt *frac ); | 
|---|
| 285 | for(int k=0;k<ipt;k++) { | 
|---|
| 286 | double x = left0 + frand01()*dx; | 
|---|
| 287 | double y = bottom0 + frand01()*dy; | 
|---|
| 288 | g->DrawMarker(x,y); | 
|---|
| 289 | } | 
|---|
| 290 | } else if(mTypDisp==2) { | 
|---|
| 291 | //..... type hbook2/hprint .+23-Z* | 
|---|
| 292 | char c[2]; | 
|---|
| 293 | c[0] = HPrint2(frac); c[1]='\0'; | 
|---|
| 294 | double x = left0 + dx/2.; | 
|---|
| 295 | double y = bottom0 + dy/2.; | 
|---|
| 296 | g->DrawString(x,y,c); | 
|---|
| 297 | } else if(mTypDisp==3) { | 
|---|
| 298 | //..... carres de tailles fixes (avec gestion de continuite) | 
|---|
| 299 | if (cmap) g->DrawFBox(left0,bottom0,dx+p1dx,dy+p1dy); | 
|---|
| 300 | else      g->DrawBox(left0,bottom0,dx+p1dx,dy+p1dy); | 
|---|
| 301 | } | 
|---|
| 302 |  | 
|---|
| 303 | } | 
|---|
| 304 |  | 
|---|
| 305 | // Remise dans les conditions ulterieures pour la suite du graphique. | 
|---|
| 306 | g->SelMarker(MkSz,Mk); | 
|---|
| 307 | g->SelForeground(coul); | 
|---|
| 308 | g->SelFontSzPt(FontSize,FontAtt); | 
|---|
| 309 | if (cmap) delete cmap; | 
|---|
| 310 |  | 
|---|
| 311 | // Fin du dessin, ecriture de la statistique. | 
|---|
| 312 | DrawStats(g); | 
|---|
| 313 | } | 
|---|
| 314 |  | 
|---|
| 315 | //++ | 
|---|
| 316 | void PIHisto2D::DrawStats(PIGraphicUC* g) | 
|---|
| 317 | // | 
|---|
| 318 | //      Dessin des informations statistiques de l'histogramme. | 
|---|
| 319 | //-- | 
|---|
| 320 | { | 
|---|
| 321 | // Une boite dans le coin superieur droit | 
|---|
| 322 | if (mLAtt == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine); | 
|---|
| 323 | double cellHeight = (YMax() - YMin()) * 0.05; | 
|---|
| 324 | double cellWidth  = (XMax() - XMin()) * 0.23; | 
|---|
| 325 | g->DrawLine(XMax() - cellWidth, YMax(), | 
|---|
| 326 | XMax() - cellWidth, YMax() - cellHeight); | 
|---|
| 327 | g->DrawLine(XMax() - cellWidth, YMax() - cellHeight, | 
|---|
| 328 | XMax()            , YMax() - cellHeight); | 
|---|
| 329 | char label[50]; | 
|---|
| 330 | sprintf(label, "N = %.6g", mHisto->NData()); | 
|---|
| 331 | g->SelFontSz((YMax() - YMin())/30); | 
|---|
| 332 | g->DrawString(XMax() - cellWidth*0.9, YMax() - cellHeight*0.8, label); | 
|---|
| 333 | //  printf("H[%d,%d] Dynamique: [%g,%g] Frac [%g,%g]\n" | 
|---|
| 334 | //        ,mHisto->NBinX(),mHisto->NBinY(),HMin(),HMax(),FMin(),FMax()); | 
|---|
| 335 | } | 
|---|
| 336 |  | 
|---|
| 337 | //++ | 
|---|
| 338 | char PIHisto2D::HPrint2(float f) | 
|---|
| 339 | // | 
|---|
| 340 | //      Codage des valeurs en caracteres (fct privee). | 
|---|
| 341 | //| f entre [0,1] mappee entre valeur=[0,37] | 
|---|
| 342 | //| si <0 alors =0, si >1 alors 1 | 
|---|
| 343 | //| Display 4   ==> 4<=valeur<5 | 
|---|
| 344 | //|         C   ==> 12<=valeur<13 | 
|---|
| 345 | //|             ==> valeur<=0 | 
|---|
| 346 | //|         *   ==> valeur>=1 | 
|---|
| 347 | //|         .   ==> 0<valeur<1 | 
|---|
| 348 | //|------------------------------------------ | 
|---|
| 349 | //|            C1111111111222222222233333333 | 
|---|
| 350 | //|  C01234567890123456789012345678901234567 | 
|---|
| 351 | //| " .+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*" | 
|---|
| 352 | //|------------------------------------------ | 
|---|
| 353 | //-- | 
|---|
| 354 | { | 
|---|
| 355 | char str[39] = " .+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*"; | 
|---|
| 356 | int i; | 
|---|
| 357 | if(f<=0.) i = 0; | 
|---|
| 358 | else if(f>=1.) i = 37; | 
|---|
| 359 | else { i = (int) (f*36.); i++;} | 
|---|
| 360 | if(i<0) i=0; else if (i>=38) i = 37; | 
|---|
| 361 | return str[i]; | 
|---|
| 362 | } | 
|---|
| 363 |  | 
|---|
| 364 | //++ | 
|---|
| 365 | int PIHisto2D::NPixBin(PIGraphicUC* g) | 
|---|
| 366 | // | 
|---|
| 367 | //      Nombre de pixels ecran dans un bin d'histogramme | 
|---|
| 368 | //      (fct privee). | 
|---|
| 369 | //-- | 
|---|
| 370 | { | 
|---|
| 371 | double dx = mHisto->WBinX(),dy = mHisto->WBinY(); | 
|---|
| 372 | double dxg,dyg; | 
|---|
| 373 | g->DUC2GrC(dx,dy,dxg,dyg); | 
|---|
| 374 | int np = (int) dxg * (int) dyg; | 
|---|
| 375 | //printf("PIHisto2D::NPixBin H dx=%g dy=%g, G dx=%g dy=%g, np = %d\n" | 
|---|
| 376 | //      ,dx,dy,dxg,dyg,np); | 
|---|
| 377 | return np; | 
|---|
| 378 | } | 
|---|
| 379 |  | 
|---|
| 380 |  | 
|---|
| 381 | ///////////////////////////////////////////////////////////////// | 
|---|
| 382 | //  Classe PIH2DWdg | 
|---|
| 383 | ///////////////////////////////////////////////////////////////// | 
|---|
| 384 |  | 
|---|
| 385 | //++ | 
|---|
| 386 | // Class        PIH2DWdg | 
|---|
| 387 | // Lib          PIext | 
|---|
| 388 | // include      pihisto2d.h | 
|---|
| 389 | // | 
|---|
| 390 | //      Classe de composantes graphiques permettant la manipulation | 
|---|
| 391 | //      de traceur d'histos 2D ("PIHisto2D") | 
|---|
| 392 | //-- | 
|---|
| 393 | //++ | 
|---|
| 394 | // Links        Parents | 
|---|
| 395 | // PIScDrawWdg | 
|---|
| 396 | //-- | 
|---|
| 397 | //++ | 
|---|
| 398 | // Links        Voir aussi | 
|---|
| 399 | // PIHisto2D | 
|---|
| 400 | //-- | 
|---|
| 401 |  | 
|---|
| 402 | //++ | 
|---|
| 403 | // Titre        Constructeur, méthodes | 
|---|
| 404 | //-- | 
|---|
| 405 |  | 
|---|
| 406 | static H2WinArg* h2dWinArg=NULL; | 
|---|
| 407 | static int nb_h2dWinArg = 0; | 
|---|
| 408 |  | 
|---|
| 409 | //++ | 
|---|
| 410 | PIH2DWdg::PIH2DWdg(PIContainerGen *par, const char *nom, int sx, int sy, int px, int py) | 
|---|
| 411 | // | 
|---|
| 412 | //      Createur d'un Widget de dessin d'histogramme 2D. | 
|---|
| 413 | //      Le menu pour choisir les options d'affichage apparait | 
|---|
| 414 | //      suite au clic du bouton-3 de la souris (cf H2WinArg::H2WinArg). | 
|---|
| 415 | //-- | 
|---|
| 416 | : PIScDrawWdg(par,nom,sx,sy,px,py) | 
|---|
| 417 | { | 
|---|
| 418 | if (!h2dWinArg) h2dWinArg = new H2WinArg(this); | 
|---|
| 419 | nb_h2dWinArg++; | 
|---|
| 420 | if(dbg) printf("PIH2DWdg::PIH2DWdg %lx h2dWinArg=%lx %d\n" | 
|---|
| 421 | ,(long)this,(long)h2dWinArg,nb_h2dWinArg); | 
|---|
| 422 | mPih = NULL; | 
|---|
| 423 | // Pour afficher le menu option de trace | 
|---|
| 424 | ActivateButton(3); | 
|---|
| 425 | } | 
|---|
| 426 |  | 
|---|
| 427 | //++ | 
|---|
| 428 | PIH2DWdg::~PIH2DWdg() | 
|---|
| 429 | // | 
|---|
| 430 | //      Destructeur. | 
|---|
| 431 | //-- | 
|---|
| 432 | { | 
|---|
| 433 | nb_h2dWinArg--; | 
|---|
| 434 | if (nb_h2dWinArg == 0) { | 
|---|
| 435 | h2dWinArg->Hide(); | 
|---|
| 436 | delete h2dWinArg; | 
|---|
| 437 | h2dWinArg=NULL; | 
|---|
| 438 | } | 
|---|
| 439 | if(dbg) printf("PIH2DWdg::~PIH2DWdg h2dWinArg=%lx %d\n" | 
|---|
| 440 | ,(long)h2dWinArg,nb_h2dWinArg); | 
|---|
| 441 | if (mPih) delete mPih; | 
|---|
| 442 | } | 
|---|
| 443 |  | 
|---|
| 444 | //++ | 
|---|
| 445 | void PIH2DWdg::SetHisto(Histo2D* histo) | 
|---|
| 446 | // | 
|---|
| 447 | //      Pour connecter un histogramme 2D au Widget. | 
|---|
| 448 | //-- | 
|---|
| 449 | { | 
|---|
| 450 | if (!histo) return; | 
|---|
| 451 | if (mPih)  delete mPih; | 
|---|
| 452 | mPih = new PIHisto2D(histo, true); | 
|---|
| 453 | AddScDrawer(mPih); | 
|---|
| 454 | if(dbg) printf("PIH2DWdg::SetHisto mPih=%lx\n",(long)mPih); | 
|---|
| 455 | } | 
|---|
| 456 |  | 
|---|
| 457 | //++ | 
|---|
| 458 | void PIH2DWdg::SetPIHisto(PIHisto2D* pih2) | 
|---|
| 459 | // | 
|---|
| 460 | //      Pour connecter un traceur (Drawer) d'histo 2D au Widget. | 
|---|
| 461 | //-- | 
|---|
| 462 | { | 
|---|
| 463 | if (!pih2) return; | 
|---|
| 464 | if (mPih)  delete mPih; | 
|---|
| 465 | mPih = pih2; | 
|---|
| 466 | AddScDrawer(mPih); | 
|---|
| 467 | if(dbg) printf("PIH2DWdg::SetPIHisto mPih=%lx\n",(long)mPih); | 
|---|
| 468 | } | 
|---|
| 469 |  | 
|---|
| 470 | //++ | 
|---|
| 471 | string  PIH2DWdg::GetClickText(double x, double y) | 
|---|
| 472 | // | 
|---|
| 473 | //      Quand on click (and drag) le bouton-1, affichage | 
|---|
| 474 | //      des positions x,y et de la valeur du bin de l'histogramme 2D. | 
|---|
| 475 | //-- | 
|---|
| 476 | { | 
|---|
| 477 | int i,j; | 
|---|
| 478 | char str[128]; | 
|---|
| 479 |  | 
|---|
| 480 | if ((!mPih) || (!mPih->Histogram())) { | 
|---|
| 481 | sprintf(str,"X=%g Y=%g ???",x,y); | 
|---|
| 482 | return((string)str); | 
|---|
| 483 | } | 
|---|
| 484 |  | 
|---|
| 485 | Histo2D* h = mPih->Histogram(); | 
|---|
| 486 |  | 
|---|
| 487 | h->FindBin(x,y,i,j); | 
|---|
| 488 | if(i<0 || i>=h->NBinX() || j<0 || j>=h->NBinY()) | 
|---|
| 489 | sprintf(str,"x= %g y= %g ???",x,y); | 
|---|
| 490 | else sprintf(str,"x= %g y= %g v= %g",x,y,(*h)(i,j)); | 
|---|
| 491 |  | 
|---|
| 492 | return((string)str); | 
|---|
| 493 | } | 
|---|
| 494 |  | 
|---|
| 495 | //++ | 
|---|
| 496 | void PIH2DWdg::ActivateSpecializedControls() | 
|---|
| 497 | //      Pour activer les contrôles spécifiques pour l'affichage Histo-2D | 
|---|
| 498 | //-- | 
|---|
| 499 | { | 
|---|
| 500 | h2dWinArg->SetPIH2DWdg(this); | 
|---|
| 501 | h2dWinArg->SetMsgParent((PIMsgHandler*)this); | 
|---|
| 502 | if(!h2dWinArg->Visible()) h2dWinArg->Show(); | 
|---|
| 503 | } | 
|---|
| 504 |  | 
|---|
| 505 | //++ | 
|---|
| 506 | void PIH2DWdg::But3Press(int x, int y) | 
|---|
| 507 | // | 
|---|
| 508 | //      Gestion de l'utilisation du bouton-3 de la souris. | 
|---|
| 509 | //      Un seul objet est cree pour tous les histogrammes 2D. | 
|---|
| 510 | //      Il est connecte a un histogramme donnee par l'action du | 
|---|
| 511 | //      du bouton-3 de la souris dans la fenetre contenant | 
|---|
| 512 | //      le dessin de l'histogramme (cf H2WinArg::H2WinArg). | 
|---|
| 513 | //-- | 
|---|
| 514 | { | 
|---|
| 515 | ActivateSpecializedControls(); | 
|---|
| 516 | if(dbg) printf("PIH2DWdg::But3Press(%d,%d) h2dWinArg=%lx\n" | 
|---|
| 517 | ,x,y,(long)h2dWinArg); | 
|---|
| 518 | } | 
|---|
| 519 |  | 
|---|
| 520 |  | 
|---|
| 521 | ///////////////////////////////////////////////////////////////// | 
|---|
| 522 | //  Classe H2WinArg | 
|---|
| 523 | ///////////////////////////////////////////////////////////////// | 
|---|
| 524 | //++ | 
|---|
| 525 | // Class        H2WinArg | 
|---|
| 526 | // Lib          PIext | 
|---|
| 527 | // include      pihisto2d.h | 
|---|
| 528 | // | 
|---|
| 529 | //      Fenêtre de dialogue pour le choix des options de tracé pour "PIHisto2D" | 
|---|
| 530 | //      Classe de fenêtre de dialogue permettant de modifier interactivement | 
|---|
| 531 | //      Les différents attributs de visualisation pour les *PIImage* . | 
|---|
| 532 | //-- | 
|---|
| 533 | //++ | 
|---|
| 534 | // Links        Parents | 
|---|
| 535 | // PIWindow | 
|---|
| 536 | //-- | 
|---|
| 537 | //++ | 
|---|
| 538 | // Links        Voir aussi | 
|---|
| 539 | // PIHisto2D | 
|---|
| 540 | // PIH2DWdg | 
|---|
| 541 | //-- | 
|---|
| 542 |  | 
|---|
| 543 | //++ | 
|---|
| 544 | // Titre        Constructeur, méthodes | 
|---|
| 545 | //-- | 
|---|
| 546 |  | 
|---|
| 547 | //++ | 
|---|
| 548 | H2WinArg::H2WinArg(PIH2DWdg *par) | 
|---|
| 549 | // | 
|---|
| 550 | //      Creation de la fenetre de gestion des parametres | 
|---|
| 551 | //      des dessins des histogrammes 2D. Cette fenetre de | 
|---|
| 552 | //      dialogue est partagee par tous les widget de dessin | 
|---|
| 553 | //      des histogrammes 2D. Pour la faire apparaitre pour la | 
|---|
| 554 | //      faire apparaitre la premiere fois, cliquez avec le bouton | 
|---|
| 555 | //      numero 3 de la souris (bouton de droite) dans la fenetre | 
|---|
| 556 | //      de dessin de l'histogramme. Si elle est deja presente, | 
|---|
| 557 | //      pour la connecter a une autre fenetre de dessin cliquez avec | 
|---|
| 558 | //      le meme bouton dans cette fenetre. | 
|---|
| 559 | //-- | 
|---|
| 560 | //++ | 
|---|
| 561 | //| - Menu 1: Choix du type de display | 
|---|
| 562 | //|     Carres variables, nuages de points, caracteres a la hbook2 | 
|---|
| 563 | //|     et carres de tailles fixe (couleur ou niveauz de gris). | 
|---|
| 564 | //| - Menu 2: Choix du type d'echelle | 
|---|
| 565 | //|     Lineaire ou logarithmique | 
|---|
| 566 | //| - Menu 3: Choix de la couleur | 
|---|
| 567 | //|     noir et blanc, niveau de gris et couleurs diverses. | 
|---|
| 568 | //| - Champ texte Dyn: Pour donner la dynamique, si min>=max | 
|---|
| 569 | //|     alors prend le min et le max de l'histogramme | 
|---|
| 570 | //| - Champ texte Frac: fraction mini et maxi | 
|---|
| 571 | //|     (cf PIHisto2D::UseFrac) | 
|---|
| 572 | //| - Champ texte LogScal: niveau de scaling pour le choix d'une | 
|---|
| 573 | //|     echelle logarithmique (cf PIHisto2D::UseScale) | 
|---|
| 574 | //-- | 
|---|
| 575 | //++ | 
|---|
| 576 | //| - Curseur interactif PerPt: pourcentage de points a dessiner | 
|---|
| 577 | //|     dans chaque bin (cf PIHisto2D::UseDisplay) | 
|---|
| 578 | //| - Bouton Apply: dessiner avec les options affichees | 
|---|
| 579 | //| - Bouton Dismiss: fermeture de la fenetre de dialogue. | 
|---|
| 580 | //| - Bouton Get: re-prendre les valeurs de display stoquees | 
|---|
| 581 | //|     pour un histogramme donne. | 
|---|
| 582 | //| - Bouton Print: Imprimer les caracteristiques du display | 
|---|
| 583 | //|     et de l'histogramme. | 
|---|
| 584 | //-- | 
|---|
| 585 | : PIWindow((PIMsgHandler *)par, "Options", PIWK_dialog,250,260,150,150) | 
|---|
| 586 | { | 
|---|
| 587 | string sdum; | 
|---|
| 588 | if(dbg) printf("H2WinArg::H2WinArg %lx par=%lx\n",(long)this,(long)par); | 
|---|
| 589 |  | 
|---|
| 590 | mH2Wdg = NULL; | 
|---|
| 591 |  | 
|---|
| 592 | // Valeurs par defaut | 
|---|
| 593 | mFgCol    = false; | 
|---|
| 594 | mCmap     = CMAP_GREYINV32; | 
|---|
| 595 | mTypScal  = 0; | 
|---|
| 596 | mTypDisp  = 0; | 
|---|
| 597 | mFPoints  = 0.5; | 
|---|
| 598 | mHMin     = 1.; | 
|---|
| 599 | mHMax     = -1.; | 
|---|
| 600 | mFracMin  = 0.1; | 
|---|
| 601 | mFracMax  = 0.9; | 
|---|
| 602 | mLogScale = 10.; | 
|---|
| 603 |  | 
|---|
| 604 | // Taille automatique | 
|---|
| 605 | int bsx, bsy; | 
|---|
| 606 | PIApplicationPrefCompSize(bsx, bsy);  // environ 6 lettres | 
|---|
| 607 | int spx = (bsx>=10) ? bsx/10 : 1;  // intervalle entre lettres X | 
|---|
| 608 | int spy = (bsy>=5) ? bsy/5 : 1;    // intervalle entre lettres Y | 
|---|
| 609 | int wszx = 5*spx+bsx+int(2.5*bsx); // Taille fenetre en X | 
|---|
| 610 | int wszy = 11*spy+8.5*bsy;           // Taille fenetre en Y | 
|---|
| 611 | SetSize(wszx, wszy); | 
|---|
| 612 |  | 
|---|
| 613 | // menus bar | 
|---|
| 614 | int cpx = 2*spx, cpy = 2*spy; | 
|---|
| 615 | mOPop[0] = new PIOptMenu(this, "optmen-h2d-1" ,2*bsx,bsy,cpx,cpy); | 
|---|
| 616 | mOPop[0]->AppendItem("Carres Var."  , 6101); | 
|---|
| 617 | mOPop[0]->AppendItem("....."        , 6102); | 
|---|
| 618 | mOPop[0]->AppendItem(".+12..Z*"     , 6103); | 
|---|
| 619 | mOPop[0]->AppendItem("Carres Pleins", 6104); | 
|---|
| 620 | sdum = "Carres Var."; mOPop[0]->SetValueStr(sdum); | 
|---|
| 621 | mOPop[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 622 |  | 
|---|
| 623 | cpy += bsy+spy; | 
|---|
| 624 | mOPop[1] = new PIOptMenu(this, "optmen-h2d-2",2*bsx,bsy,cpx,cpy); | 
|---|
| 625 | mOPop[1]->AppendItem("Lineaire", 6201); | 
|---|
| 626 | mOPop[1]->AppendItem("Log10"   , 6202); | 
|---|
| 627 | sdum = "Lineaire"; mOPop[1]->SetValueStr(sdum); | 
|---|
| 628 | mOPop[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 629 |  | 
|---|
| 630 | cpy += bsy+spy; | 
|---|
| 631 | mOPop[2] = new PIOptMenu(this, "optmen-h2d-3",2*bsx,bsy,cpx,cpy); | 
|---|
| 632 | mOPop[2]->AppendItem("Black&White", 6301); | 
|---|
| 633 | mOPop[2]->AppendItem("Grey32"    , 6302); | 
|---|
| 634 | mOPop[2]->AppendItem("GreyInv32" , 6303); | 
|---|
| 635 | mOPop[2]->AppendItem("ColRJ32"   , 6304); | 
|---|
| 636 | mOPop[2]->AppendItem("ColBR32"   , 6305); | 
|---|
| 637 | mOPop[2]->AppendItem("ColRV32"   , 6306); | 
|---|
| 638 | mOPop[2]->AppendItem("Grey128"   , 6307); | 
|---|
| 639 | mOPop[2]->AppendItem("GreyInv128", 6308); | 
|---|
| 640 | mOPop[2]->AppendItem("ColRJ128"  , 6309); | 
|---|
| 641 | mOPop[2]->AppendItem("ColBR128"  , 6310); | 
|---|
| 642 | mOPop[2]->AppendItem("Col16"     , 6311); | 
|---|
| 643 | sdum = "Black&White"; mOPop[2]->SetValueStr(sdum); | 
|---|
| 644 | mOPop[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 645 |  | 
|---|
| 646 | // Labels et zone de saisie texte | 
|---|
| 647 | cpy += 2*(bsy+spy); | 
|---|
| 648 | mLab[0] = new PILabel(this, "     Dyn: ",bsx,bsy,cpx,cpy); | 
|---|
| 649 | mLab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 650 | mText[0] = new PIText(this, "Dynamique" ,int(2.5*bsx),bsy,cpx+bsx+spx,cpy); | 
|---|
| 651 | mText[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 652 | cpy += bsy+spy; | 
|---|
| 653 | mLab[1] = new PILabel(this, "    Frac: ",bsx,bsy,cpx,cpy); | 
|---|
| 654 | mLab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 655 | mText[1] = new PIText(this, "Fraction"  ,int(2.5*bsx),bsy,cpx+bsx+spx,cpy); | 
|---|
| 656 | mText[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 657 | cpy += bsy+spy; | 
|---|
| 658 | mLab[2] = new PILabel(this, " LogScal: ",bsx,bsy,cpx,cpy); | 
|---|
| 659 | mLab[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 660 | mText[2] = new PIText(this, "LogScale"  ,int(2.5*bsx),bsy,cpx+bsx+spx,cpy); | 
|---|
| 661 | mText[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 662 | SetText(); | 
|---|
| 663 |  | 
|---|
| 664 | // Labels et curseur mobile | 
|---|
| 665 | cpy += bsy+spy; | 
|---|
| 666 | mLab[3] = new PILabel(this, "   PerPt: ",bsx,bsy,cpx,cpy+0.25*bsy); | 
|---|
| 667 | mLab[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 668 | mPScal = new PIScale(this,"FracPoints",6401,kSDirLtoR | 
|---|
| 669 | ,int(2.5*bsx),1.25*bsy,cpx+bsx+spx,cpy); | 
|---|
| 670 | mPScal->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 671 | mPScal->SetMinMax(0,100); | 
|---|
| 672 | int imfp = mFPoints*100.f; mPScal->SetValue(imfp); | 
|---|
| 673 |  | 
|---|
| 674 | // Boutons | 
|---|
| 675 | cpx = 2*bsx+5*spx, cpy = 2*spy; | 
|---|
| 676 | mBut[0] = new PIButton(this, "Apply",  6001,bsx,bsy,cpx,cpy); | 
|---|
| 677 | mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 678 | cpy += bsy+spy; | 
|---|
| 679 | mBut[1] = new PIButton(this, "Dismiss",6002,bsx,bsy,cpx,cpy); | 
|---|
| 680 | mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 681 | cpy += bsy+spy; | 
|---|
| 682 | mBut[2] = new PIButton(this, "Get"  ,  6003,bsx,bsy,cpx,cpy); | 
|---|
| 683 | mBut[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 684 | cpy += bsy+spy; | 
|---|
| 685 | mBut[3] = new PIButton(this, "Print",  6004,bsx,bsy,cpx,cpy); | 
|---|
| 686 | mBut[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic); | 
|---|
| 687 | // FinishCreate(); | 
|---|
| 688 | } | 
|---|
| 689 |  | 
|---|
| 690 | //++ | 
|---|
| 691 | H2WinArg::~H2WinArg() | 
|---|
| 692 | // | 
|---|
| 693 | //      Destructeur. | 
|---|
| 694 | //-- | 
|---|
| 695 | { | 
|---|
| 696 | int i; | 
|---|
| 697 | if(dbg) printf("H2WinArg::~H2WinArg %lx\n",(long)this); | 
|---|
| 698 | for(i=0;i<3;i++) delete mOPop[i]; | 
|---|
| 699 | for(i=0;i<4;i++) delete mBut[i]; | 
|---|
| 700 | for(i=0;i<4;i++) delete mLab[i]; | 
|---|
| 701 | for(i=0;i<3;i++) delete mText[i]; | 
|---|
| 702 | delete mPScal; | 
|---|
| 703 | } | 
|---|
| 704 |  | 
|---|
| 705 | //++ | 
|---|
| 706 | void H2WinArg::SetText() | 
|---|
| 707 | // | 
|---|
| 708 | //      Gestion des fenetres de saisie de texte. | 
|---|
| 709 | //-- | 
|---|
| 710 | { | 
|---|
| 711 | string sdum; | 
|---|
| 712 | char str[256]; | 
|---|
| 713 | sprintf(str,"%g %g",mHMin,mHMax); | 
|---|
| 714 | mText[0]->SetText(str); | 
|---|
| 715 | sprintf(str,"%g %g",mFracMin,mFracMax); | 
|---|
| 716 | mText[1]->SetText(str); | 
|---|
| 717 | sprintf(str,"%g",mLogScale); | 
|---|
| 718 | mText[2]->SetText(str); | 
|---|
| 719 |  | 
|---|
| 720 | if(mTypDisp==0)      { sdum="Carres Var.";   mOPop[0]->SetValueStr(sdum);} | 
|---|
| 721 | else if(mTypDisp==1) { sdum=".....";         mOPop[0]->SetValueStr(sdum);} | 
|---|
| 722 | else if(mTypDisp==2) { sdum=".+12..Z*";      mOPop[0]->SetValueStr(sdum);} | 
|---|
| 723 | else if(mTypDisp==3) { sdum="Carres Pleins"; mOPop[0]->SetValueStr(sdum);} | 
|---|
| 724 |  | 
|---|
| 725 | if(mTypScal==0)      { sdum="Lineaire"; mOPop[1]->SetValueStr(sdum);} | 
|---|
| 726 | else if(mTypScal==1) { sdum="Log10";    mOPop[1]->SetValueStr(sdum);} | 
|---|
| 727 |  | 
|---|
| 728 | if(!mFgCol)                       { sdum="Black&White";mOPop[2]->SetValueStr(sdum);} | 
|---|
| 729 | else { | 
|---|
| 730 | if(mCmap==CMAP_GREY32)          { sdum="Grey32";     mOPop[2]->SetValueStr(sdum);} | 
|---|
| 731 | else if(mCmap==CMAP_GREYINV32)  { sdum="GreyInv32";  mOPop[2]->SetValueStr(sdum);} | 
|---|
| 732 | else if(mCmap==CMAP_COLRJ32)    { sdum="ColRJ32";    mOPop[2]->SetValueStr(sdum);} | 
|---|
| 733 | else if(mCmap==CMAP_COLBR32)    { sdum="ColBR32";    mOPop[2]->SetValueStr(sdum);} | 
|---|
| 734 | else if(mCmap==CMAP_COLRV32)    { sdum="ColRV32";    mOPop[2]->SetValueStr(sdum);} | 
|---|
| 735 | else if(mCmap==CMAP_GREY128)    { sdum="Grey128";    mOPop[2]->SetValueStr(sdum);} | 
|---|
| 736 | else if(mCmap==CMAP_GREYINV128) { sdum="GreyInv128"; mOPop[2]->SetValueStr(sdum);} | 
|---|
| 737 | else if(mCmap==CMAP_COLRJ128)   { sdum="ColRJ128";   mOPop[2]->SetValueStr(sdum);} | 
|---|
| 738 | else if(mCmap==CMAP_COLBR128)   { sdum="ColBR128";   mOPop[2]->SetValueStr(sdum);} | 
|---|
| 739 | else if(mCmap==CMAP_COL16)      { sdum="Col16";      mOPop[2]->SetValueStr(sdum);} | 
|---|
| 740 | } | 
|---|
| 741 |  | 
|---|
| 742 | if(dbg)printf("H2WinArg::SetText\n"); | 
|---|
| 743 | } | 
|---|
| 744 |  | 
|---|
| 745 | //++ | 
|---|
| 746 | void H2WinArg::GetText() | 
|---|
| 747 | // | 
|---|
| 748 | //      Gestion des fenetres de saisie de texte. | 
|---|
| 749 | //-- | 
|---|
| 750 | { | 
|---|
| 751 | sscanf(mText[0]->GetText().c_str(),"%g %g",&mHMin,&mHMax); | 
|---|
| 752 | sscanf(mText[1]->GetText().c_str(),"%g %g",&mFracMin,&mFracMax); | 
|---|
| 753 | sscanf(mText[2]->GetText().c_str(),"%g",&mLogScale); | 
|---|
| 754 | if(dbg) printf("H2WinArg::GetText\n"); | 
|---|
| 755 | } | 
|---|
| 756 |  | 
|---|
| 757 | //++ | 
|---|
| 758 | void H2WinArg::SetPIH2DWdg(PIH2DWdg* h2wdg) | 
|---|
| 759 | // | 
|---|
| 760 | //      Connexion du widget de representation d'un histogramme 2D | 
|---|
| 761 | //      avec la fenetre de gestion des parametres. | 
|---|
| 762 | //-- | 
|---|
| 763 | { | 
|---|
| 764 | mH2Wdg = h2wdg; | 
|---|
| 765 | if(dbg) printf("H2WinArg::SetPIH2DWdg mH2Wdg = %lx\n",(long)mH2Wdg); | 
|---|
| 766 | } | 
|---|
| 767 |  | 
|---|
| 768 | //++ | 
|---|
| 769 | void H2WinArg::Process(PIMessage msg, PIMsgHandler* sender, void*) | 
|---|
| 770 | // | 
|---|
| 771 | //      Gestions des messages. | 
|---|
| 772 | //-- | 
|---|
| 773 | { | 
|---|
| 774 | if(dbg) printf("PIH2DWdg::Process(%d-%d , %lx ...) \n" | 
|---|
| 775 | ,(int)UserMsg(msg),(int)ModMsg(msg), (long)sender); | 
|---|
| 776 |  | 
|---|
| 777 | if(!mH2Wdg) return; | 
|---|
| 778 | PIHisto2D* mpih = mH2Wdg->GetPIHisto(); | 
|---|
| 779 | if(!mpih) return; | 
|---|
| 780 |  | 
|---|
| 781 | int opt = UserMsg(msg); | 
|---|
| 782 | if (opt == 6101) { mTypDisp = 0; } | 
|---|
| 783 | else if (opt == 6102) { mTypDisp = 1; } | 
|---|
| 784 | else if (opt == 6103) { mTypDisp = 2; } | 
|---|
| 785 | else if (opt == 6104) { mTypDisp = 3; } | 
|---|
| 786 |  | 
|---|
| 787 | else if (opt == 6201) { mTypScal = 0; } | 
|---|
| 788 | else if (opt == 6202) { mTypScal = 1; } | 
|---|
| 789 |  | 
|---|
| 790 | else if (opt == 6301) { mFgCol = false; } | 
|---|
| 791 | else if (opt == 6302) { mFgCol = true;  mCmap = CMAP_GREY32; } | 
|---|
| 792 | else if (opt == 6303) { mFgCol = true;  mCmap = CMAP_GREYINV32; } | 
|---|
| 793 | else if (opt == 6304) { mFgCol = true;  mCmap = CMAP_COLRJ32; } | 
|---|
| 794 | else if (opt == 6305) { mFgCol = true;  mCmap = CMAP_COLBR32; } | 
|---|
| 795 | else if (opt == 6306) { mFgCol = true;  mCmap = CMAP_COLRV32; } | 
|---|
| 796 | else if (opt == 6307) { mFgCol = true;  mCmap = CMAP_GREY128; } | 
|---|
| 797 | else if (opt == 6308) { mFgCol = true;  mCmap = CMAP_GREYINV128; } | 
|---|
| 798 | else if (opt == 6309) { mFgCol = true;  mCmap = CMAP_COLRJ128; } | 
|---|
| 799 | else if (opt == 6310) { mFgCol = true;  mCmap = CMAP_COLBR128; } | 
|---|
| 800 | else if (opt == 6311) { mFgCol = true;  mCmap = CMAP_COL16; } | 
|---|
| 801 |  | 
|---|
| 802 | else if (opt == 6401) mFPoints = mPScal->GetValue()/100.; | 
|---|
| 803 |  | 
|---|
| 804 | else if (opt==6001) { | 
|---|
| 805 | GetText(); | 
|---|
| 806 | mpih->UseColors(mFgCol, mCmap); | 
|---|
| 807 | mpih->UseScale(mTypScal,mLogScale); | 
|---|
| 808 | mpih->UseDisplay(mTypDisp,mFPoints); | 
|---|
| 809 | mpih->UseDyn(mHMin,mHMax); | 
|---|
| 810 | mpih->UseFrac(mFracMin,mFracMax); | 
|---|
| 811 | mH2Wdg->Refresh();  // On rafraichit le dessin (tout le PIScDrawWdg) | 
|---|
| 812 | } | 
|---|
| 813 | else if (opt==6002) { | 
|---|
| 814 | this->Hide(); | 
|---|
| 815 | } | 
|---|
| 816 | else if (opt==6003) { | 
|---|
| 817 | mFgCol    = mpih->Color(); | 
|---|
| 818 | mCmap     = mpih->ColMap(); | 
|---|
| 819 | mTypScal  = mpih->TypScale(); | 
|---|
| 820 | mTypDisp  = mpih->TypDisplay(); | 
|---|
| 821 | mFPoints  = mpih->FPoints(); | 
|---|
| 822 | mHMin     = mpih->HMin(); | 
|---|
| 823 | mHMax     = mpih->HMax(); | 
|---|
| 824 | mFracMin  = mpih->FMin(); | 
|---|
| 825 | mFracMax  = mpih->FMax(); | 
|---|
| 826 | mLogScale = mpih->LogScale(); | 
|---|
| 827 | SetText(); | 
|---|
| 828 | } | 
|---|
| 829 | else if (opt==6004) { | 
|---|
| 830 | mpih->Print(2); | 
|---|
| 831 | } | 
|---|
| 832 |  | 
|---|
| 833 | if(dbg) { | 
|---|
| 834 | printf("H2WinArg::Process opt=%d col=%d,%d scal=%d disp=%d npt=%g\n" | 
|---|
| 835 | ,opt,(int) mFgCol,(int) mCmap,mTypScal,mTypDisp,mFPoints); | 
|---|
| 836 | printf("                  min,max= %g,%g frac= %g,%g logsc= %g\n" | 
|---|
| 837 | ,mHMin,mHMax,mFracMin,mFracMax,mLogScale); | 
|---|
| 838 | } | 
|---|
| 839 |  | 
|---|
| 840 | } | 
|---|