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