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