1 | #include <stdio.h>
|
---|
2 | #include "pistlist.h"
|
---|
3 |
|
---|
4 |
|
---|
5 | /* --Methode-- */
|
---|
6 | PIStarList::PIStarList(StarList* stl, bool ad)
|
---|
7 | : PIDrawer(), mStL(stl)
|
---|
8 | {
|
---|
9 | mAdDO = ad;
|
---|
10 | if (stl == NULL) return;
|
---|
11 | SetFluxLimits(1., -1.);
|
---|
12 | }
|
---|
13 |
|
---|
14 | PIStarList::~PIStarList()
|
---|
15 | {
|
---|
16 | if (mAdDO && mStL) delete mStL;
|
---|
17 | }
|
---|
18 |
|
---|
19 | /* --Methode-- */
|
---|
20 | void PIStarList::SetFluxLimits(float fmin, float fmax, int nl, bool dispflx, bool refr)
|
---|
21 | {
|
---|
22 | if (!mStL) return;
|
---|
23 | if (fmin < fmax) { mFmin = fmin; mFmax = fmax; }
|
---|
24 | else mStL->CalcFluxLimits(mFmin, mFmax);
|
---|
25 | if (mFmin < 1.e-10) mFmin = 1.e-10;
|
---|
26 | if (mFmax <= mFmin) mFmax = 1.5*mFmin;
|
---|
27 | mDLgF = log10((double)mFmax/(double)mFmin);
|
---|
28 | if (mDLgF < 1.e-10) mDLgF = 1.e-10;
|
---|
29 | mF0 = mFmin;
|
---|
30 | if (nl < 1) nl = 1;
|
---|
31 | if (nl > 20) nl = 20;
|
---|
32 | mNLev = nl;
|
---|
33 | mDspFV = dispflx;
|
---|
34 | if (refr) Refresh();
|
---|
35 | return;
|
---|
36 | }
|
---|
37 |
|
---|
38 |
|
---|
39 | /* --Methode-- */
|
---|
40 | void PIStarList::UpdateLimits()
|
---|
41 | {
|
---|
42 | if (!mStL) return;
|
---|
43 |
|
---|
44 | // Commencer par trouver nos limites
|
---|
45 | double dx, dy;
|
---|
46 | double x1, x2, y1, y2;
|
---|
47 | mStL->CalcXYLimits(x1, x2, y1, y2);
|
---|
48 |
|
---|
49 | dx = 0.02*(x2-x1);
|
---|
50 | dy = 0.02*(y2-y1);
|
---|
51 |
|
---|
52 | SetLimits(x1-dx, x2+dx, y1-dy, y2+dy);
|
---|
53 | SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
|
---|
54 | }
|
---|
55 |
|
---|
56 |
|
---|
57 | /* --Methode-- */
|
---|
58 | void PIStarList::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
|
---|
59 | {
|
---|
60 | BStar *sti;
|
---|
61 | double xp,yp;
|
---|
62 | float flx;
|
---|
63 | int sz;
|
---|
64 | char buff[128];
|
---|
65 | int nok, nl2;
|
---|
66 |
|
---|
67 | if (!mStL) return;
|
---|
68 |
|
---|
69 | int msz = mMSz;
|
---|
70 | if (msz < 1) msz = 1;
|
---|
71 | PIMarker mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_FCircleMarker;
|
---|
72 | // g->SelFont();
|
---|
73 | nok = 0; nl2 = mNLev*2-1;
|
---|
74 | for (int i=0; i<mStL->NbStars(); i++) {
|
---|
75 | sti = mStL->Star(i);
|
---|
76 | if ( !(sti->Nice(BStar::flagOK)) ) continue;
|
---|
77 | flx = sti->Flux();
|
---|
78 | if ( (flx < mFmin) || (flx > mFmax) ) continue;
|
---|
79 | xp = sti->PosX(); yp = sti->PosY();
|
---|
80 | if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue;
|
---|
81 | nok++;
|
---|
82 | sz = (int)((log10((double)flx/mF0))/mDLgF*(double)nl2-0.01) + msz;
|
---|
83 | if (sz < 2) g->SelMarker(sz, PI_DotMarker);
|
---|
84 | else g->SelMarker(sz, mrk);
|
---|
85 | g->DrawMarker((double)xp,(double)yp );
|
---|
86 | if (mDspFV) {
|
---|
87 | sprintf(buff," F=%g", flx);
|
---|
88 | double dx,dy;
|
---|
89 | g->DGrC2UC(sz, 4, dx, dy);
|
---|
90 | g->DrawString(xp+dx, yp-dy, buff);
|
---|
91 | }
|
---|
92 | }
|
---|
93 |
|
---|
94 | /*
|
---|
95 | sprintf(buff, "StarList: NbStars= %d NDisp= %d", (int)mStL->NbStars(), nok);
|
---|
96 | g->BaseGraphic()->DrawString(15,15,buff);
|
---|
97 | sprintf(buff, "FMin= %g FMax= %g Nl= %d Sz0= %d", mFmin, mFmax, mNLev, mMSz0);
|
---|
98 | g->BaseGraphic()->DrawString(15,30,buff);
|
---|
99 | */
|
---|
100 |
|
---|
101 | }
|
---|
102 |
|
---|
103 | /* --Methode-- */
|
---|
104 | void PIStarList::AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax)
|
---|
105 | {
|
---|
106 | BStar *sti;
|
---|
107 | double xp,yp;
|
---|
108 | double flx,fnd;
|
---|
109 | char buff[128];
|
---|
110 | int ncnt = 0;
|
---|
111 | sprintf(buff,"PIStarList: NStars \n", mStL->NbStars() );
|
---|
112 | info += buff;
|
---|
113 | info += " Num: XPos YPos Flux Fond \n";
|
---|
114 | for (int i=0; i<mStL->NbStars(); i++) {
|
---|
115 | sti = mStL->Star(i);
|
---|
116 | if ( !(sti->Nice(BStar::flagOK)) ) continue;
|
---|
117 | flx = sti->Flux();
|
---|
118 | if ( (flx < mFmin) || (flx > mFmax) ) continue;
|
---|
119 | xp = sti->PosX(); yp = sti->PosY();
|
---|
120 | if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue;
|
---|
121 | ncnt++;
|
---|
122 | if (ncnt > 101) continue;
|
---|
123 | fnd = sti->Fond();
|
---|
124 | sprintf(buff,"%6d: %8.3g %8.3g %8.3g %8.3g \n", i, xp, yp, flx, fnd);
|
---|
125 | info += buff;
|
---|
126 | }
|
---|
127 | if (ncnt >= 101) info += " .... \n";
|
---|
128 | sprintf(buff," %d stars inside selected region \n", ncnt);
|
---|
129 | info += buff;
|
---|
130 | return;
|
---|
131 | }
|
---|