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