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

Last change on this file since 2011 was 1920, checked in by perderos, 24 years ago

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