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