| [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
 | 
|---|
| [1905] | 255 | if (GetGraphicAtt().GetLineAtt() == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
 | 
|---|
| [165] | 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 | //++
 | 
|---|
| [1884] | 353 | void PIHisto2D::GetClickInfo(string& info,double x,double y,double x0,double y0,bool fgdiff)
 | 
|---|
| [1880] | 354 | //
 | 
|---|
 | 355 | //      Info specifique du drawer pour la position x,y
 | 
|---|
 | 356 | //--
 | 
|---|
 | 357 | {
 | 
|---|
| [1884] | 358 | Histo2D* h = Histogram();
 | 
|---|
 | 359 | if(h == NULL) return;
 | 
|---|
| [1880] | 360 | 
 | 
|---|
| [1884] | 361 | int i,j;
 | 
|---|
 | 362 | h->FindBin(x,y,i,j);
 | 
|---|
 | 363 | if(i>=0 && i<h->NBinX() && j>=0 && j<h->NBinY()) {
 | 
|---|
 | 364 |   char str[64];
 | 
|---|
 | 365 |   if(fgdiff) {
 | 
|---|
 | 366 |     int i0,j0;
 | 
|---|
 | 367 |     h->FindBin(x0,y0,i0,j0);
 | 
|---|
 | 368 |     if(i0>=0 && i0<h->NBinX() && j0>=0 && j0<h->NBinY()) {
 | 
|---|
 | 369 |       sprintf(str," DV=%g",(*h)(i,j)-(*h)(i0,j0));
 | 
|---|
 | 370 |       info += str;
 | 
|---|
 | 371 |     } else {
 | 
|---|
 | 372 |       info += " DV=?";
 | 
|---|
 | 373 |     }
 | 
|---|
| [1880] | 374 |   }
 | 
|---|
| [1884] | 375 |   sprintf(str," V=%g",(*h)(i,j));
 | 
|---|
 | 376 |   info += str;
 | 
|---|
 | 377 | } else {
 | 
|---|
 | 378 |   info += " V=?";
 | 
|---|
| [1880] | 379 | }
 | 
|---|
 | 380 | 
 | 
|---|
| [1884] | 381 | return;
 | 
|---|
 | 382 | }
 | 
|---|
 | 383 | 
 | 
|---|
| [1880] | 384 | //++
 | 
|---|
| [165] | 385 | void PIHisto2D::DrawStats(PIGraphicUC* g)
 | 
|---|
 | 386 | //
 | 
|---|
 | 387 | //      Dessin des informations statistiques de l'histogramme.
 | 
|---|
 | 388 | //--
 | 
|---|
 | 389 | {
 | 
|---|
| [1644] | 390 |   if (!mHisto) return;
 | 
|---|
| [1905] | 391 |   if (GetGraphicAtt().GetLineAtt() == PI_NotDefLineAtt)  g->SelLine(PI_ThinLine);
 | 
|---|
 | 392 |   g->SelFontSz((YMax() - YMin())/30);
 | 
|---|
| [1644] | 393 | 
 | 
|---|
 | 394 |   // La hauteur de la cellule
 | 
|---|
 | 395 |   PIGrCoord a, d;
 | 
|---|
| [1645] | 396 |   double cH = (double)g->GetFontHeight(a,d);
 | 
|---|
 | 397 |   double cellHeight = 1.2 * cH;
 | 
|---|
| [1644] | 398 | 
 | 
|---|
 | 399 |   // Les labels et leurs longueurs -> largeur de la cellule
 | 
|---|
| [1645] | 400 |   char label[64];
 | 
|---|
 | 401 |   sprintf(label,"N= %-g", mHisto->NData());
 | 
|---|
| [1644] | 402 |   double cellWidth =  1.1 * (double)g->CalcStringWidth(label);
 | 
|---|
 | 403 | 
 | 
|---|
| [1645] | 404 |   double xu, yu, cw;
 | 
|---|
| [1644] | 405 |   // Les limites du cadre
 | 
|---|
| [1645] | 406 |   xu = g->DeltaUCX(XMax(), -cellWidth);
 | 
|---|
 | 407 |   yu = g->DeltaUCY(YMax(), -cellHeight);
 | 
|---|
 | 408 |   g->DrawLine(xu,YMax(),xu,yu);
 | 
|---|
 | 409 |   g->DrawLine(xu,yu,XMax(),yu);
 | 
|---|
| [1644] | 410 | 
 | 
|---|
 | 411 |   // L'ecriture des labels
 | 
|---|
| [1645] | 412 |   cw = (g->isAxeXDirRtoL()) ? -0.05*cellWidth : -0.95*cellWidth;
 | 
|---|
 | 413 |   xu = g->DeltaUCX(XMax(),cw);
 | 
|---|
 | 414 |   cw = (g->isAxeYDirUpDown()) ? -0.1*cH : -1.1*cH;
 | 
|---|
 | 415 |   yu = g->DeltaUCY(YMax(),cw);
 | 
|---|
 | 416 |   g->DrawString(xu,yu,label);
 | 
|---|
 | 417 | 
 | 
|---|
| [1644] | 418 |   //  printf("H[%d,%d] Dynamique: [%g,%g] Frac [%g,%g]\n"
 | 
|---|
 | 419 |   //        ,mHisto->NBinX(),mHisto->NBinY(),HMin(),HMax(),FMin(),FMax());
 | 
|---|
| [165] | 420 | }
 | 
|---|
 | 421 | 
 | 
|---|
 | 422 | //++
 | 
|---|
 | 423 | char PIHisto2D::HPrint2(float f)
 | 
|---|
 | 424 | //
 | 
|---|
 | 425 | //      Codage des valeurs en caracteres (fct privee).
 | 
|---|
 | 426 | //| f entre [0,1] mappee entre valeur=[0,37]
 | 
|---|
 | 427 | //| si <0 alors =0, si >1 alors 1
 | 
|---|
 | 428 | //| Display 4   ==> 4<=valeur<5
 | 
|---|
 | 429 | //|         C   ==> 12<=valeur<13
 | 
|---|
 | 430 | //|             ==> valeur<=0
 | 
|---|
 | 431 | //|         *   ==> valeur>=1
 | 
|---|
 | 432 | //|         .   ==> 0<valeur<1
 | 
|---|
 | 433 | //|------------------------------------------
 | 
|---|
 | 434 | //|            C1111111111222222222233333333
 | 
|---|
 | 435 | //|  C01234567890123456789012345678901234567
 | 
|---|
 | 436 | //| " .+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*"
 | 
|---|
 | 437 | //|------------------------------------------
 | 
|---|
 | 438 | //--
 | 
|---|
 | 439 | {
 | 
|---|
 | 440 | char str[39] = " .+23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ*";
 | 
|---|
 | 441 | int i;
 | 
|---|
 | 442 | if(f<=0.) i = 0;
 | 
|---|
 | 443 | else if(f>=1.) i = 37;
 | 
|---|
 | 444 | else { i = (int) (f*36.); i++;}
 | 
|---|
 | 445 | if(i<0) i=0; else if (i>=38) i = 37;
 | 
|---|
 | 446 | return str[i];
 | 
|---|
 | 447 | }
 | 
|---|
 | 448 | 
 | 
|---|
 | 449 | //++
 | 
|---|
 | 450 | int PIHisto2D::NPixBin(PIGraphicUC* g)
 | 
|---|
 | 451 | //
 | 
|---|
 | 452 | //      Nombre de pixels ecran dans un bin d'histogramme
 | 
|---|
 | 453 | //      (fct privee).
 | 
|---|
 | 454 | //--
 | 
|---|
 | 455 | {
 | 
|---|
| [205] | 456 | double dx = mHisto->WBinX(),dy = mHisto->WBinY();
 | 
|---|
 | 457 | double dxg,dyg;
 | 
|---|
| [165] | 458 | g->DUC2GrC(dx,dy,dxg,dyg);
 | 
|---|
 | 459 | int np = (int) dxg * (int) dyg;
 | 
|---|
 | 460 | //printf("PIHisto2D::NPixBin H dx=%g dy=%g, G dx=%g dy=%g, np = %d\n"
 | 
|---|
 | 461 | //      ,dx,dy,dxg,dyg,np);
 | 
|---|
 | 462 | return np;
 | 
|---|
 | 463 | }
 | 
|---|
 | 464 | 
 | 
|---|
 | 465 | /////////////////////////////////////////////////////////////////
 | 
|---|
 | 466 | //  Classe H2WinArg
 | 
|---|
 | 467 | /////////////////////////////////////////////////////////////////
 | 
|---|
 | 468 | //++
 | 
|---|
| [537] | 469 | // Class        H2WinArg
 | 
|---|
 | 470 | // Lib          PIext
 | 
|---|
 | 471 | // include      pihisto2d.h
 | 
|---|
 | 472 | //
 | 
|---|
 | 473 | //      Fenêtre de dialogue pour le choix des options de tracé pour "PIHisto2D"
 | 
|---|
 | 474 | //      Classe de fenêtre de dialogue permettant de modifier interactivement
 | 
|---|
 | 475 | //      Les différents attributs de visualisation pour les *PIImage* .
 | 
|---|
| [165] | 476 | //--
 | 
|---|
| [537] | 477 | //++
 | 
|---|
 | 478 | // Links        Parents
 | 
|---|
 | 479 | // PIWindow
 | 
|---|
 | 480 | //--
 | 
|---|
 | 481 | //++
 | 
|---|
 | 482 | // Links        Voir aussi
 | 
|---|
 | 483 | // PIHisto2D
 | 
|---|
 | 484 | // PIH2DWdg
 | 
|---|
 | 485 | //--
 | 
|---|
| [165] | 486 | 
 | 
|---|
 | 487 | //++
 | 
|---|
| [537] | 488 | // Titre        Constructeur, méthodes
 | 
|---|
 | 489 | //--
 | 
|---|
 | 490 | 
 | 
|---|
| [1856] | 491 | PIBaseWdgGen* H2WinArg::mBWdg = NULL;
 | 
|---|
 | 492 | PIHisto2D* H2WinArg::mH2DDrw = NULL;
 | 
|---|
 | 493 | static H2WinArg* cur_h2winarg = NULL;
 | 
|---|
 | 494 | 
 | 
|---|
 | 495 | void H2WinArg::ShowPIHisto2DTools()
 | 
|---|
 | 496 | {
 | 
|---|
 | 497 |   if (cur_h2winarg == NULL)  cur_h2winarg = new H2WinArg(PIApplicationGetApp());
 | 
|---|
 | 498 |   cur_h2winarg->Show();
 | 
|---|
 | 499 | }
 | 
|---|
 | 500 | 
 | 
|---|
 | 501 | void H2WinArg::ShowPIHisto2DTools(PIBaseWdgGen* cbw)
 | 
|---|
 | 502 | {
 | 
|---|
 | 503 |   if (cur_h2winarg == NULL)  cur_h2winarg = new H2WinArg(PIApplicationGetApp());
 | 
|---|
 | 504 |   mBWdg = cbw;
 | 
|---|
 | 505 |   cur_h2winarg->Show();
 | 
|---|
 | 506 | }
 | 
|---|
 | 507 | 
 | 
|---|
 | 508 | void H2WinArg::HidePIHisto2DTools()
 | 
|---|
 | 509 | {
 | 
|---|
 | 510 |   if (cur_h2winarg != NULL)  cur_h2winarg->Hide();
 | 
|---|
 | 511 | }
 | 
|---|
 | 512 | 
 | 
|---|
 | 513 | void H2WinArg::SetCurrentBaseWdg(PIBaseWdgGen* cbw)
 | 
|---|
 | 514 | {
 | 
|---|
 | 515 |   mBWdg = cbw;
 | 
|---|
 | 516 | }
 | 
|---|
 | 517 | 
 | 
|---|
 | 518 | void H2WinArg::SetCurrentPIHisto2D(PIHisto2D* h2ddrw)
 | 
|---|
 | 519 | {
 | 
|---|
 | 520 |   mH2DDrw = h2ddrw;
 | 
|---|
 | 521 | }
 | 
|---|
 | 522 | 
 | 
|---|
 | 523 | PIBaseWdgGen* H2WinArg::GetCurrentBaseWdg()
 | 
|---|
 | 524 | {
 | 
|---|
 | 525 |   return(mBWdg);
 | 
|---|
 | 526 | }
 | 
|---|
 | 527 | 
 | 
|---|
 | 528 | PIHisto2D* H2WinArg::GetCurrentPIHisto2D()
 | 
|---|
 | 529 | {
 | 
|---|
 | 530 |   return(mH2DDrw);
 | 
|---|
 | 531 | }
 | 
|---|
 | 532 | 
 | 
|---|
| [537] | 533 | //++
 | 
|---|
| [1856] | 534 | H2WinArg::H2WinArg(PIMsgHandler* par)
 | 
|---|
| [165] | 535 | //
 | 
|---|
 | 536 | //      Creation de la fenetre de gestion des parametres
 | 
|---|
 | 537 | //      des dessins des histogrammes 2D. Cette fenetre de
 | 
|---|
 | 538 | //      dialogue est partagee par tous les widget de dessin
 | 
|---|
| [1862] | 539 | //      des histogrammes 2D. Pour faire apparaitre la fenetre
 | 
|---|
 | 540 | //      tapez ALT-O.
 | 
|---|
| [165] | 541 | //--
 | 
|---|
 | 542 | //++
 | 
|---|
 | 543 | //| - Menu 1: Choix du type de display
 | 
|---|
 | 544 | //|     Carres variables, nuages de points, caracteres a la hbook2
 | 
|---|
 | 545 | //|     et carres de tailles fixe (couleur ou niveauz de gris).
 | 
|---|
 | 546 | //| - Menu 2: Choix du type d'echelle
 | 
|---|
 | 547 | //|     Lineaire ou logarithmique
 | 
|---|
 | 548 | //| - Menu 3: Choix de la couleur
 | 
|---|
 | 549 | //|     noir et blanc, niveau de gris et couleurs diverses.
 | 
|---|
 | 550 | //| - Champ texte Dyn: Pour donner la dynamique, si min>=max
 | 
|---|
 | 551 | //|     alors prend le min et le max de l'histogramme
 | 
|---|
| [1645] | 552 | //|     (cf PIHisto2D::UseDyn)
 | 
|---|
| [165] | 553 | //| - Champ texte Frac: fraction mini et maxi
 | 
|---|
 | 554 | //|     (cf PIHisto2D::UseFrac)
 | 
|---|
 | 555 | //| - Champ texte LogScal: niveau de scaling pour le choix d'une
 | 
|---|
 | 556 | //|     echelle logarithmique (cf PIHisto2D::UseScale)
 | 
|---|
 | 557 | //--
 | 
|---|
 | 558 | //++
 | 
|---|
 | 559 | //| - Curseur interactif PerPt: pourcentage de points a dessiner
 | 
|---|
 | 560 | //|     dans chaque bin (cf PIHisto2D::UseDisplay)
 | 
|---|
 | 561 | //| - Bouton Apply: dessiner avec les options affichees
 | 
|---|
 | 562 | //| - Bouton Dismiss: fermeture de la fenetre de dialogue.
 | 
|---|
 | 563 | //| - Bouton Get: re-prendre les valeurs de display stoquees
 | 
|---|
 | 564 | //|     pour un histogramme donne.
 | 
|---|
 | 565 | //| - Bouton Print: Imprimer les caracteristiques du display
 | 
|---|
 | 566 | //|     et de l'histogramme.
 | 
|---|
 | 567 | //--
 | 
|---|
| [1850] | 568 | : PIWindow((PIMsgHandler *)par,"Options",PIWK_dialog,250,260,150,150)
 | 
|---|
 | 569 | , mFgCol(false), mCmap(CMAP_GREYINV32), mRevCmap(false)
 | 
|---|
 | 570 | , mTypScal(0)  , mLogScale(10.)
 | 
|---|
 | 571 | , mTypDisp(0)  , mFPoints(0.5)
 | 
|---|
 | 572 | , mHMin(1.)    , mHMax(-1.)
 | 
|---|
 | 573 | , mFracMin(0.1), mFracMax(0.9)
 | 
|---|
| [165] | 574 | {
 | 
|---|
| [1862] | 575 | if(dbg) printf("H2WinArg::H2WinArg %p par=%p\n",this,par);
 | 
|---|
| [165] | 576 | 
 | 
|---|
 | 577 | // Taille automatique
 | 
|---|
 | 578 | int bsx, bsy;
 | 
|---|
 | 579 | PIApplicationPrefCompSize(bsx, bsy);  // environ 6 lettres
 | 
|---|
 | 580 | int spx = (bsx>=10) ? bsx/10 : 1;  // intervalle entre lettres X
 | 
|---|
 | 581 | int spy = (bsy>=5) ? bsy/5 : 1;    // intervalle entre lettres Y
 | 
|---|
 | 582 | int wszx = 5*spx+bsx+int(2.5*bsx); // Taille fenetre en X
 | 
|---|
| [1850] | 583 | int wszy = 11*spy+int(8.5*bsy);    // Taille fenetre en Y
 | 
|---|
| [165] | 584 | SetSize(wszx, wszy);
 | 
|---|
 | 585 | 
 | 
|---|
| [1297] | 586 | // menu du style de display des bins
 | 
|---|
| [165] | 587 |   int cpx = 2*spx, cpy = 2*spy;
 | 
|---|
| [1850] | 588 | mOPop[0] = new PIOptMenu(this,"optmen-h2d-1",2*bsx,bsy,cpx,cpy);
 | 
|---|
 | 589 | mOPop[0]->AppendItem("Carres Var."  ,6101);
 | 
|---|
 | 590 | mOPop[0]->AppendItem("....."        ,6102);
 | 
|---|
 | 591 | mOPop[0]->AppendItem(".+12..Z*"     ,6103);
 | 
|---|
 | 592 | mOPop[0]->AppendItem("Carres Pleins",6104);
 | 
|---|
| [165] | 593 | mOPop[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 594 | 
 | 
|---|
| [1297] | 595 | // Menu du choix de la dynamique
 | 
|---|
| [165] | 596 |   cpy += bsy+spy;
 | 
|---|
| [1850] | 597 | mOPop[1] = new PIOptMenu(this,"optmen-h2d-2",2*bsx,bsy,cpx,cpy);
 | 
|---|
 | 598 | mOPop[1]->AppendItem("Lineaire",6201);
 | 
|---|
 | 599 | mOPop[1]->AppendItem("Log10"   ,6202);
 | 
|---|
| [165] | 600 | mOPop[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 601 | 
 | 
|---|
| [1297] | 602 | // Menu du choix des couleurs
 | 
|---|
| [165] | 603 |   cpy += bsy+spy;
 | 
|---|
| [1850] | 604 | mOPop[2] = new PIOptMenu(this,"optmen-h2d-3",2*bsx,bsy,cpx,cpy);
 | 
|---|
| [1297] | 605 | mOPop[2]->AppendItem("Black&White",7000);
 | 
|---|
| [1850] | 606 | mCasc[0] = new PIMenu(mOPop[2]->Menu(),"PIStd-128Col");
 | 
|---|
 | 607 | mCasc[1] = new PIMenu(mOPop[2]->Menu(),"MIDAS-CMap");
 | 
|---|
| [1297] | 608 | int kcc,nsct1=5,nsct2=9,nsct3=PIColorMap::NumberStandardColorMaps()-1;
 | 
|---|
 | 609 | for(kcc=0; kcc<nsct1; kcc++) 
 | 
|---|
 | 610 |   mOPop[2]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(),7001+kcc);
 | 
|---|
 | 611 | for(kcc=nsct1; kcc<nsct2; kcc++) 
 | 
|---|
 | 612 |   mCasc[0]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(),7001+kcc);
 | 
|---|
 | 613 | mOPop[2]->AppendPDMenu(mCasc[0]);
 | 
|---|
 | 614 | for(kcc=nsct2; kcc<nsct3; kcc++) 
 | 
|---|
 | 615 |   mCasc[1]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(),7001+kcc);
 | 
|---|
 | 616 | mOPop[2]->AppendPDMenu(mCasc[1]);
 | 
|---|
 | 617 | for(kcc=nsct3; kcc<PIColorMap::NumberStandardColorMaps(); kcc++) 
 | 
|---|
| [1850] | 618 |   mOPop[2]->AppendItem(PIColorMap::GetStandardColorMapName(kcc).c_str(),7001+kcc);
 | 
|---|
| [1862] | 619 | //mOPop[2]->SetValue(7000);
 | 
|---|
| [165] | 620 | mOPop[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 621 | 
 | 
|---|
| [1850] | 622 | // Reverse color map
 | 
|---|
 | 623 |   cpy += bsy+spy;
 | 
|---|
 | 624 | mCkb = new PICheckBox(this,"Reverse CMap",8001,2*bsx,bsy,cpx,cpy);
 | 
|---|
 | 625 | mCkb->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 626 | 
 | 
|---|
| [1297] | 627 | // Labels et zones de saisie texte
 | 
|---|
| [1850] | 628 |   cpy += bsy+spy;
 | 
|---|
 | 629 | mLab[0] = new PILabel(this,"     Dyn: ",bsx,bsy,cpx,cpy); 
 | 
|---|
| [165] | 630 | mLab[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
| [1850] | 631 | mText[0] = new PIText(this,"Dynamique",int(2.5*bsx),bsy,cpx+bsx+spx,cpy);
 | 
|---|
| [165] | 632 | mText[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 633 |   cpy += bsy+spy;
 | 
|---|
| [1850] | 634 | mLab[1] = new PILabel(this,"    Frac: ",bsx,bsy,cpx,cpy);
 | 
|---|
| [165] | 635 | mLab[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
| [1850] | 636 | mText[1] = new PIText(this,"Fraction",int(2.5*bsx),bsy,cpx+bsx+spx,cpy);
 | 
|---|
| [165] | 637 | mText[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 638 |   cpy += bsy+spy;
 | 
|---|
| [1850] | 639 | mLab[2] = new PILabel(this," LogScal: ",bsx,bsy,cpx,cpy);
 | 
|---|
| [165] | 640 | mLab[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
| [1850] | 641 | mText[2] = new PIText(this,"LogScale",int(2.5*bsx),bsy,cpx+bsx+spx,cpy);
 | 
|---|
| [165] | 642 | mText[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 643 | 
 | 
|---|
 | 644 | // Labels et curseur mobile
 | 
|---|
 | 645 | cpy += bsy+spy;
 | 
|---|
| [1850] | 646 | mLab[3] = new PILabel(this,"   PerPt: ",bsx,bsy,cpx,cpy+int(0.25*bsy));
 | 
|---|
| [165] | 647 | mLab[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 648 | mPScal = new PIScale(this,"FracPoints",6401,kSDirLtoR
 | 
|---|
| [1850] | 649 |                         ,int(2.5*bsx),int(1.25*bsy),cpx+bsx+spx,cpy);
 | 
|---|
| [1862] | 650 | mPScal->SetMinMax(0,100);
 | 
|---|
| [165] | 651 | mPScal->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
| [1862] | 652 | 
 | 
|---|
 | 653 | //
 | 
|---|
| [1850] | 654 | SetText();
 | 
|---|
| [1862] | 655 | //
 | 
|---|
| [165] | 656 | 
 | 
|---|
 | 657 | // Boutons
 | 
|---|
 | 658 |   cpx = 2*bsx+5*spx, cpy = 2*spy;
 | 
|---|
| [1850] | 659 | mBut[0] = new PIButton(this,"Apply",6001,bsx,bsy,cpx,cpy);
 | 
|---|
| [165] | 660 | mBut[0]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 661 |   cpy += bsy+spy;
 | 
|---|
| [1850] | 662 | mBut[1] = new PIButton(this,"Dismiss",6002,bsx,bsy,cpx,cpy);
 | 
|---|
| [165] | 663 | mBut[1]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 664 |   cpy += bsy+spy;
 | 
|---|
| [1850] | 665 | mBut[2] = new PIButton(this,"Get",6003,bsx,bsy,cpx,cpy);
 | 
|---|
| [165] | 666 | mBut[2]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 667 |   cpy += bsy+spy;
 | 
|---|
| [1850] | 668 | mBut[3] = new PIButton(this,"Print",6004,bsx,bsy,cpx,cpy);
 | 
|---|
| [165] | 669 | mBut[3]->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 | 
|---|
 | 670 | // FinishCreate();
 | 
|---|
 | 671 | }
 | 
|---|
 | 672 | 
 | 
|---|
 | 673 | //++
 | 
|---|
 | 674 | H2WinArg::~H2WinArg()
 | 
|---|
 | 675 | //
 | 
|---|
 | 676 | //      Destructeur.
 | 
|---|
 | 677 | //--
 | 
|---|
 | 678 | {
 | 
|---|
 | 679 | int i;
 | 
|---|
| [1862] | 680 | if(dbg) printf("H2WinArg::~H2WinArg %p\n",this);
 | 
|---|
| [1297] | 681 | for(i=0;i<2;i++) delete mCasc[i];
 | 
|---|
| [165] | 682 | for(i=0;i<3;i++) delete mOPop[i];
 | 
|---|
 | 683 | for(i=0;i<4;i++) delete mBut[i];
 | 
|---|
 | 684 | for(i=0;i<4;i++) delete mLab[i];
 | 
|---|
 | 685 | for(i=0;i<3;i++) delete mText[i];
 | 
|---|
| [1850] | 686 | delete mCkb;
 | 
|---|
| [165] | 687 | delete mPScal;
 | 
|---|
 | 688 | }
 | 
|---|
 | 689 | 
 | 
|---|
 | 690 | //++
 | 
|---|
| [1862] | 691 | void H2WinArg::Show()
 | 
|---|
 | 692 | //
 | 
|---|
 | 693 | //      Initialisation sur ouverture ALT-O
 | 
|---|
 | 694 | //--
 | 
|---|
 | 695 | {
 | 
|---|
 | 696 |  if(dbg) printf("H2WinArg::Show() mH2DDrw=%p\n",mH2DDrw);
 | 
|---|
 | 697 |  // Pour recuperer les valeurs du Drawer sur lequel on fait ALT-O
 | 
|---|
 | 698 |  /*
 | 
|---|
 | 699 |  if(mH2DDrw) {
 | 
|---|
 | 700 |    mFgCol = mH2DDrw->Color();
 | 
|---|
 | 701 |    mCmap = mH2DDrw->ColMap(); mRevCmap = mH2DDrw->IsColMapRev();
 | 
|---|
 | 702 |    mTypScal = mH2DDrw->TypScale(); mLogScale = mH2DDrw->LogScale();
 | 
|---|
 | 703 |    mTypDisp = mH2DDrw->TypDisplay(); mFPoints = mH2DDrw->FPoints();
 | 
|---|
 | 704 |    mHMin = mH2DDrw->HMin(); mHMax = mH2DDrw->HMax();
 | 
|---|
 | 705 |    mFracMin = mH2DDrw->FMin(); mFracMax = mH2DDrw->FMax();
 | 
|---|
 | 706 |    SetText();
 | 
|---|
 | 707 |  }
 | 
|---|
 | 708 |  */
 | 
|---|
 | 709 |  PIWindow::Show();
 | 
|---|
 | 710 |  return;
 | 
|---|
 | 711 | }
 | 
|---|
 | 712 | 
 | 
|---|
 | 713 | //++
 | 
|---|
| [165] | 714 | void H2WinArg::SetText()
 | 
|---|
 | 715 | //
 | 
|---|
| [1297] | 716 | //      Gestion des fenetres de saisie de texte et des pop-menus.
 | 
|---|
| [165] | 717 | //--
 | 
|---|
 | 718 | {
 | 
|---|
| [1862] | 719 | if(dbg) printf("H2WinArg::SetText()\n");
 | 
|---|
| [165] | 720 | string sdum;
 | 
|---|
 | 721 | char str[256];
 | 
|---|
| [1862] | 722 | 
 | 
|---|
| [165] | 723 | sprintf(str,"%g %g",mHMin,mHMax);
 | 
|---|
 | 724 | mText[0]->SetText(str);
 | 
|---|
| [1862] | 725 | 
 | 
|---|
| [165] | 726 | sprintf(str,"%g %g",mFracMin,mFracMax);
 | 
|---|
 | 727 | mText[1]->SetText(str);
 | 
|---|
| [1862] | 728 | 
 | 
|---|
| [165] | 729 | sprintf(str,"%g",mLogScale);
 | 
|---|
 | 730 | mText[2]->SetText(str);
 | 
|---|
| [1862] | 731 | if(mTypScal==1) mText[2]->SetSensitive();
 | 
|---|
 | 732 |   else          mText[2]->SetUnSensitive();
 | 
|---|
| [165] | 733 | 
 | 
|---|
| [1850] | 734 | if(mTypDisp==0)      {sdum="Carres Var.";   mOPop[0]->SetValueStr(sdum);}
 | 
|---|
 | 735 | else if(mTypDisp==1) {sdum=".....";         mOPop[0]->SetValueStr(sdum);}
 | 
|---|
 | 736 | else if(mTypDisp==2) {sdum=".+12..Z*";      mOPop[0]->SetValueStr(sdum);}
 | 
|---|
 | 737 | else if(mTypDisp==3) {sdum="Carres Pleins"; mOPop[0]->SetValueStr(sdum);}
 | 
|---|
| [165] | 738 | 
 | 
|---|
| [1850] | 739 | if(mTypScal==0)      {sdum="Lineaire"; mOPop[1]->SetValueStr(sdum);}
 | 
|---|
 | 740 | else if(mTypScal==1) {sdum="Log10";    mOPop[1]->SetValueStr(sdum);}
 | 
|---|
| [165] | 741 | 
 | 
|---|
| [1297] | 742 | if(!mFgCol) {mOPop[2]->SetValue(7000);}
 | 
|---|
| [165] | 743 | else {
 | 
|---|
| [1297] | 744 |   for(int kk=0;kk<PIColorMap::NumberStandardColorMaps();kk++)
 | 
|---|
 | 745 |     if(mCmap == PIColorMap::GetStandardColorMapId(kk))
 | 
|---|
 | 746 |       {mOPop[2]->SetValue(7001+kk); break;}
 | 
|---|
| [165] | 747 | }
 | 
|---|
| [1850] | 748 | mCkb->SetState(mRevCmap);
 | 
|---|
| [165] | 749 | 
 | 
|---|
| [1850] | 750 | mPScal->SetValue(int(mFPoints*100.));
 | 
|---|
| [1862] | 751 | if(mTypDisp==1) mPScal->SetSensitive();
 | 
|---|
 | 752 |   else          mPScal->SetUnSensitive();
 | 
|---|
| [165] | 753 | }
 | 
|---|
 | 754 | 
 | 
|---|
 | 755 | //++
 | 
|---|
 | 756 | void H2WinArg::Process(PIMessage msg, PIMsgHandler* sender, void*)
 | 
|---|
 | 757 | //
 | 
|---|
 | 758 | //      Gestions des messages.
 | 
|---|
 | 759 | //--
 | 
|---|
 | 760 | {
 | 
|---|
| [1862] | 761 | if(dbg) printf("H2WinArg::Process(%d-%d , %p ...) \n"
 | 
|---|
 | 762 |               ,(int)UserMsg(msg),(int)ModMsg(msg),sender);
 | 
|---|
| [165] | 763 | 
 | 
|---|
| [1856] | 764 | // if(!mH2Wdg) return;
 | 
|---|
 | 765 | if(!mBWdg) return;
 | 
|---|
 | 766 | // PIHisto2D* mpih = mH2Wdg->GetPIHisto();
 | 
|---|
 | 767 | PIHisto2D* mpih = mH2DDrw;
 | 
|---|
| [165] | 768 | if(!mpih) return;
 | 
|---|
 | 769 | 
 | 
|---|
 | 770 | int opt = UserMsg(msg);
 | 
|---|
| [1862] | 771 | 
 | 
|---|
| [1850] | 772 |      if(opt == 6101) {mTypDisp = 0;}
 | 
|---|
 | 773 | else if(opt == 6102) {mTypDisp = 1;}
 | 
|---|
 | 774 | else if(opt == 6103) {mTypDisp = 2;}
 | 
|---|
 | 775 | else if(opt == 6104) {mTypDisp = 3;}
 | 
|---|
| [165] | 776 | 
 | 
|---|
| [1850] | 777 | else if(opt == 6201) {mTypScal = 0;}
 | 
|---|
 | 778 | else if(opt == 6202) {mTypScal = 1;}
 | 
|---|
| [165] | 779 | 
 | 
|---|
| [1850] | 780 | else if(opt == 7000) {mFgCol = false;}
 | 
|---|
 | 781 | else if(opt >= 7001 && opt <8000) {
 | 
|---|
| [1297] | 782 |   int k  = opt-7001;
 | 
|---|
 | 783 |   mFgCol = true;
 | 
|---|
 | 784 |   mCmap  = PIColorMap::GetStandardColorMapId(k);
 | 
|---|
 | 785 | }
 | 
|---|
 | 786 | 
 | 
|---|
| [1850] | 787 | else if(opt == 8001) mRevCmap = mCkb->GetState();
 | 
|---|
| [165] | 788 | 
 | 
|---|
| [1850] | 789 | else if(opt == 6401) mFPoints = mPScal->GetValue()/100.;
 | 
|---|
 | 790 | 
 | 
|---|
 | 791 | else if(opt==6001) {
 | 
|---|
 | 792 |   sscanf(mText[0]->GetText().c_str(),"%g %g",&mHMin,&mHMax);
 | 
|---|
 | 793 |   sscanf(mText[1]->GetText().c_str(),"%g %g",&mFracMin,&mFracMax);
 | 
|---|
 | 794 |   sscanf(mText[2]->GetText().c_str(),"%g",&mLogScale);
 | 
|---|
 | 795 |   mpih->UseColors(mFgCol,mCmap,mRevCmap);
 | 
|---|
| [165] | 796 |   mpih->UseScale(mTypScal,mLogScale);
 | 
|---|
 | 797 |   mpih->UseDisplay(mTypDisp,mFPoints);
 | 
|---|
 | 798 |   mpih->UseDyn(mHMin,mHMax);
 | 
|---|
 | 799 |   mpih->UseFrac(mFracMin,mFracMax);
 | 
|---|
| [1856] | 800 |   mBWdg->Refresh();  // On rafraichit le dessin (tout le PIScDrawWdg)
 | 
|---|
| [165] | 801 | }
 | 
|---|
| [1850] | 802 | else if(opt==6002) this->Hide();
 | 
|---|
| [165] | 803 | else if (opt==6003) {
 | 
|---|
| [1850] | 804 |   mFgCol = mpih->Color(); mCmap = mpih->ColMap();
 | 
|---|
 | 805 |                           mRevCmap = mpih->IsColMapRev();
 | 
|---|
 | 806 |   mTypScal = mpih->TypScale(); mLogScale = mpih->LogScale();
 | 
|---|
 | 807 |   mTypDisp = mpih->TypDisplay(); mFPoints = mpih->FPoints();
 | 
|---|
 | 808 |   mHMin = mpih->HMin(); mHMax = mpih->HMax();
 | 
|---|
 | 809 |   mFracMin = mpih->FMin(); mFracMax = mpih->FMax();
 | 
|---|
| [165] | 810 | }
 | 
|---|
| [1850] | 811 | else if(opt==6004) mpih->Print(2);
 | 
|---|
| [165] | 812 | 
 | 
|---|
| [1862] | 813 | SetText();
 | 
|---|
 | 814 | 
 | 
|---|
| [165] | 815 | if(dbg) {
 | 
|---|
| [1850] | 816 |   printf("H2WinArg::Process opt=%d col=%d,%d,%d scal=%d disp=%d npt=%g\n"
 | 
|---|
 | 817 |         ,opt,(int)mFgCol,(int)mCmap,(int)mRevCmap,mTypScal,mTypDisp,mFPoints);
 | 
|---|
| [165] | 818 |   printf("                  min,max= %g,%g frac= %g,%g logsc= %g\n"
 | 
|---|
 | 819 |         ,mHMin,mHMax,mFracMin,mFracMax,mLogScale);
 | 
|---|
 | 820 | }
 | 
|---|
 | 821 | 
 | 
|---|
 | 822 | }
 | 
|---|