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