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