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