source: Sophya/trunk/SophyaPI/PIext/pistlist.cc@ 2092

Last change on this file since 2092 was 2092, checked in by cmv, 23 years ago

intro PERC_GARDE pour localiser les pb cmv 14/7/2002

File size: 4.6 KB
Line 
1// Classe traceur de StarList 97-99
2// CEA-DAPNIA LAL-IN2P3/CNRS
3
4#include <stdio.h>
5#include "pistlist.h"
6
7#define PERC_GARDE 0.02
8
9//++
10// Class PIStarList
11// Lib PIext
12// include pistlist.h
13//
14// Classe traceur d'objets de la classe *StarList*
15//--
16//++
17// Links Parents
18// PIDrawer
19//--
20//++
21// Titre Constructeur
22//--
23
24//++
25// PIStarList(StarList* stl, bool ad)
26// Constructeur. Si "ad == true", l'objet "stl" est détruit par
27// le destructeur de l'objet "PIStarList"
28// Note : "stl" doit être créé par new
29//--
30
31/* --Methode-- */
32PIStarList::PIStarList(StarList* stl, bool ad)
33: PIDrawer(), mStL(stl)
34{
35 mAdDO = ad;
36 if (stl == NULL) return;
37 SetFluxLimits(1., -1.);
38}
39
40PIStarList::~PIStarList()
41{
42 if (mAdDO && mStL) delete mStL;
43}
44
45//++
46// Titre Méthodes
47//--
48//++
49// void SetFluxLimits(float min=1., float max=-1., int nl=5, bool dispflx=false, bool refr=false)
50// Modifie les paramètres de visualisation (limites en flux). Si "dispflx==true"
51// les valeurs de flux sont affichées pour chaque étoile.
52// StarList* StList()
53// Retourne l'objet "StarList" associé.
54// float FluxMin()
55// Retourne le paramètre de visualisation flux minimum
56// float FluxMax()
57// Retourne le paramètre de visualisation flux maximum
58//--
59
60/* --Methode-- */
61void PIStarList::SetFluxLimits(float fmin, float fmax, int nl, bool dispflx, bool refr)
62{
63 if (!mStL) return;
64 if (fmin < fmax) { mFmin = fmin; mFmax = fmax; }
65 else mStL->CalcFluxLimits(mFmin, mFmax);
66 if (mFmin < 1.e-10) mFmin = 1.e-10;
67 if (mFmax <= mFmin) mFmax = 1.5*mFmin;
68 mDLgF = log10((double)mFmax/(double)mFmin);
69 if (mDLgF < 1.e-10) mDLgF = 1.e-10;
70 mF0 = mFmin;
71 if (nl < 1) nl = 1;
72 if (nl > 20) nl = 20;
73 mNLev = nl;
74 mDspFV = dispflx;
75 if (refr) Refresh();
76 return;
77}
78
79
80/* --Methode-- */
81void PIStarList::UpdateLimits()
82{
83 if (!mStL) return;
84
85 // Commencer par trouver nos limites
86 double dx, dy;
87 double x1, x2, y1, y2;
88 mStL->CalcXYLimits(x1, x2, y1, y2);
89
90 dx = PERC_GARDE*(x2-x1);
91 dy = PERC_GARDE*(y2-y1);
92
93 SetLimits(x1-dx, x2+dx, y1-dy, y2+dy);
94 SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
95}
96
97
98/* --Methode-- */
99void PIStarList::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
100{
101BStar *sti;
102double xp,yp;
103float flx;
104int sz;
105char buff[128];
106int nok, nl2;
107
108if (!mStL) return;
109
110PIGrCoord uxmin, uxmax, uymin, uymax;
111g->GetGrSpace(uxmin, uxmax, uymin, uymax);
112double xmin2 = uxmin;
113double ymin2 = uymin;
114double xmax2 = uxmax;
115double ymax2 = uymax;
116
117// int msz = mMSz; //OP
118int msz = GetGraphicAtt().GetMarkerSz();
119
120if (msz < 1) msz = 1;
121//PIMarker mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_FCircleMarker; //OP
122PIMarker mmrk = GetGraphicAtt().GetMarker();
123PIMarker mrk = (mmrk != PI_NotDefMarker) ? mmrk : PI_FCircleMarker;
124
125// g->SelFont();
126nok = 0; nl2 = mNLev*2-1;
127for (int i=0; i<mStL->NbStars(); i++) {
128 sti = mStL->Star(i);
129 if ( !(sti->Nice(BStar::flagOK)) ) continue;
130 flx = sti->Flux();
131 if ( (flx < mFmin) || (flx > mFmax) ) continue;
132 xp = sti->PosX(); yp = sti->PosY();
133 if ( (xp < xmin2) || (xp > xmax2) || (yp < ymin2) || (yp > ymax2) ) continue;
134 nok++;
135 if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue;
136 sz = (int)((log10((double)flx/mF0))/mDLgF*(double)nl2-0.01) + msz;
137 if (sz < 2) g->SelMarker(sz, PI_DotMarker);
138 else g->SelMarker(sz, mrk);
139 g->DrawMarker((double)xp,(double)yp );
140 if (mDspFV) {
141 sprintf(buff," F=%g", flx);
142 double dx,dy;
143 g->DGrC2UC(sz, 4, dx, dy);
144 g->DrawString(xp+dx, yp-dy, buff);
145 }
146 }
147
148/*
149sprintf(buff, "StarList: NbStars= %d NDisp= %d", (int)mStL->NbStars(), nok);
150g->BaseGraphic()->DrawString(15,15,buff);
151sprintf(buff, "FMin= %g FMax= %g Nl= %d Sz0= %d", mFmin, mFmax, mNLev, mMSz0);
152g->BaseGraphic()->DrawString(15,30,buff);
153*/
154
155}
156
157/* --Methode-- */
158void PIStarList::AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax)
159{
160BStar *sti;
161double xp,yp;
162double flx,fnd;
163char buff[128];
164int ncnt = 0;
165sprintf(buff,"PIStarList: NStars %d \n", mStL->NbStars() );
166info += buff;
167info += " Num: XPos YPos Flux Fond \n";
168for (int i=0; i<mStL->NbStars(); i++) {
169 sti = mStL->Star(i);
170 if ( !(sti->Nice(BStar::flagOK)) ) continue;
171 flx = sti->Flux();
172 if ( (flx < mFmin) || (flx > mFmax) ) continue;
173 xp = sti->PosX(); yp = sti->PosY();
174 if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue;
175 ncnt++;
176 if (ncnt > 101) continue;
177 fnd = sti->Fond();
178 sprintf(buff,"%6d: %8.3g %8.3g %8.3g %8.3g \n", i, xp, yp, flx, fnd);
179 info += buff;
180 }
181if (ncnt >= 101) info += " .... \n";
182sprintf(buff," %d stars inside selected region \n", ncnt);
183info += buff;
184return;
185}
Note: See TracBrowser for help on using the repository browser.