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