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

Last change on this file since 175 was 165, checked in by ercodmgr, 27 years ago

Creation du module PIext en regroupant des fichiers de Drawer/Wdg pour
Objets ds PEIDA/Outils++, Images++, ... et des classes de ProgPI,
lie a piapp (PIStdImgApp, NamedObjMgr, ...) Reza 18/12/98

File size: 2.3 KB
Line 
1#include <stdio.h>
2#include "pistlist.h"
3
4
5/* --Methode-- */
6PIStarList::PIStarList(StarList* stl, bool ad)
7: PIDrawer(), mStL(stl)
8{
9 mAdDO = ad;
10 if (stl == NULL) return;
11 SetFluxLimits(1., -1.);
12}
13
14PIStarList::~PIStarList()
15{
16 if (mAdDO && mStL) delete mStL;
17}
18
19/* --Methode-- */
20void 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-- */
40void PIStarList::UpdateLimits()
41{
42 if (!mStL) return;
43
44 // Commencer par trouver nos limites
45 float 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-- */
58void PIStarList::Draw(PIGraphicUC* g, float xmin, float ymin, float xmax, float ymax)
59{
60BStar *sti;
61float xp,yp,flx;
62int sz;
63char buff[128];
64int nok, nl2;
65
66if (!mStL) return;
67
68int msz = mMSz;
69if (msz < 1) msz = 1;
70PIMarker mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_FCircleMarker;
71// g->SelFont();
72nok = 0; nl2 = mNLev*2-1;
73for (int i=0; i<mStL->NbStars(); i++) {
74 sti = mStL->Star(i);
75 if ( !(sti->Nice(BStar::flagOK)) ) continue;
76 flx = sti->Flux();
77 if ( (flx < mFmin) || (flx > mFmax) ) continue;
78 xp = sti->PosX(); yp = sti->PosY();
79 if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue;
80 nok++;
81 sz = (int)((log10((double)flx/mF0))/mDLgF*(double)nl2-0.01) + msz;
82 if (sz < 2) g->SelMarker(sz, PI_DotMarker);
83 else g->SelMarker(sz, mrk);
84 g->DrawMarker((double)xp,(double)yp );
85 if (mDspFV) {
86 sprintf(buff," F=%g", flx);
87 float dx,dy;
88 g->DGrC2UC(sz, 4, dx, dy);
89 g->DrawString(xp+dx, yp-dy, buff);
90 }
91 }
92
93/*
94sprintf(buff, "StarList: NbStars= %d NDisp= %d", (int)mStL->NbStars(), nok);
95g->BaseGraphic()->DrawString(15,15,buff);
96sprintf(buff, "FMin= %g FMax= %g Nl= %d Sz0= %d", mFmin, mFmax, mNLev, mMSz0);
97g->BaseGraphic()->DrawString(15,30,buff);
98*/
99
100}
101
Note: See TracBrowser for help on using the repository browser.