source: Sophya/trunk/SophyaPI/PIext/pihisto2d.cc@ 3559

Last change on this file since 3559 was 3559, checked in by ansari, 17 years ago

Amelioration gestion taille de fonte ds PIHisto, PINTuple ... en utilisant le flag AutoFontSize mis ds la classe PIDrawer (attributs autofontsize=, fixedfontsize), Reza 24/12/2008

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