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