[544] | 1 | // Classe traceur de StarList 97-99
|
---|
| 2 | // CEA-DAPNIA LAL-IN2P3/CNRS
|
---|
| 3 |
|
---|
[165] | 4 | #include <stdio.h>
|
---|
| 5 | #include "pistlist.h"
|
---|
| 6 |
|
---|
[544] | 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 |
|
---|
[165] | 29 | /* --Methode-- */
|
---|
| 30 | PIStarList::PIStarList(StarList* stl, bool ad)
|
---|
| 31 | : PIDrawer(), mStL(stl)
|
---|
| 32 | {
|
---|
| 33 | mAdDO = ad;
|
---|
| 34 | if (stl == NULL) return;
|
---|
| 35 | SetFluxLimits(1., -1.);
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | PIStarList::~PIStarList()
|
---|
| 39 | {
|
---|
| 40 | if (mAdDO && mStL) delete mStL;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
[544] | 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 |
|
---|
[165] | 58 | /* --Methode-- */
|
---|
| 59 | void 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-- */
|
---|
| 79 | void PIStarList::UpdateLimits()
|
---|
| 80 | {
|
---|
| 81 | if (!mStL) return;
|
---|
| 82 |
|
---|
| 83 | // Commencer par trouver nos limites
|
---|
[2115] | 84 | double x1,x2,y1,y2;
|
---|
[165] | 85 | mStL->CalcXYLimits(x1, x2, y1, y2);
|
---|
[2115] | 86 | PIAxes::ReSizeMinMax(isLogScaleX(),x1,x2);
|
---|
| 87 | PIAxes::ReSizeMinMax(isLogScaleY(),y1,y2);
|
---|
| 88 | SetLimits(x1,x2,y1,y2);
|
---|
[165] | 89 | SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 |
|
---|
| 93 | /* --Methode-- */
|
---|
[205] | 94 | void PIStarList::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
|
---|
[165] | 95 | {
|
---|
| 96 | BStar *sti;
|
---|
[205] | 97 | double xp,yp;
|
---|
| 98 | float flx;
|
---|
[165] | 99 | int sz;
|
---|
| 100 | char buff[128];
|
---|
| 101 | int nok, nl2;
|
---|
| 102 |
|
---|
| 103 | if (!mStL) return;
|
---|
| 104 |
|
---|
[685] | 105 | PIGrCoord uxmin, uxmax, uymin, uymax;
|
---|
| 106 | g->GetGrSpace(uxmin, uxmax, uymin, uymax);
|
---|
| 107 | double xmin2 = uxmin;
|
---|
| 108 | double ymin2 = uymin;
|
---|
| 109 | double xmax2 = uxmax;
|
---|
| 110 | double ymax2 = uymax;
|
---|
| 111 |
|
---|
[1920] | 112 | // int msz = mMSz; //OP
|
---|
| 113 | int msz = GetGraphicAtt().GetMarkerSz();
|
---|
| 114 |
|
---|
[165] | 115 | if (msz < 1) msz = 1;
|
---|
[1920] | 116 | //PIMarker mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_FCircleMarker; //OP
|
---|
| 117 | PIMarker mmrk = GetGraphicAtt().GetMarker();
|
---|
| 118 | PIMarker mrk = (mmrk != PI_NotDefMarker) ? mmrk : PI_FCircleMarker;
|
---|
| 119 |
|
---|
[165] | 120 | // g->SelFont();
|
---|
| 121 | nok = 0; nl2 = mNLev*2-1;
|
---|
| 122 | for (int i=0; i<mStL->NbStars(); i++) {
|
---|
| 123 | sti = mStL->Star(i);
|
---|
| 124 | if ( !(sti->Nice(BStar::flagOK)) ) continue;
|
---|
| 125 | flx = sti->Flux();
|
---|
| 126 | if ( (flx < mFmin) || (flx > mFmax) ) continue;
|
---|
| 127 | xp = sti->PosX(); yp = sti->PosY();
|
---|
[685] | 128 | if ( (xp < xmin2) || (xp > xmax2) || (yp < ymin2) || (yp > ymax2) ) continue;
|
---|
[165] | 129 | nok++;
|
---|
[686] | 130 | if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue;
|
---|
[165] | 131 | sz = (int)((log10((double)flx/mF0))/mDLgF*(double)nl2-0.01) + msz;
|
---|
| 132 | if (sz < 2) g->SelMarker(sz, PI_DotMarker);
|
---|
| 133 | else g->SelMarker(sz, mrk);
|
---|
| 134 | g->DrawMarker((double)xp,(double)yp );
|
---|
| 135 | if (mDspFV) {
|
---|
| 136 | sprintf(buff," F=%g", flx);
|
---|
[205] | 137 | double dx,dy;
|
---|
[165] | 138 | g->DGrC2UC(sz, 4, dx, dy);
|
---|
| 139 | g->DrawString(xp+dx, yp-dy, buff);
|
---|
| 140 | }
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 | /*
|
---|
| 144 | sprintf(buff, "StarList: NbStars= %d NDisp= %d", (int)mStL->NbStars(), nok);
|
---|
| 145 | g->BaseGraphic()->DrawString(15,15,buff);
|
---|
| 146 | sprintf(buff, "FMin= %g FMax= %g Nl= %d Sz0= %d", mFmin, mFmax, mNLev, mMSz0);
|
---|
| 147 | g->BaseGraphic()->DrawString(15,30,buff);
|
---|
| 148 | */
|
---|
| 149 |
|
---|
| 150 | }
|
---|
| 151 |
|
---|
[344] | 152 | /* --Methode-- */
|
---|
| 153 | void PIStarList::AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax)
|
---|
| 154 | {
|
---|
| 155 | BStar *sti;
|
---|
| 156 | double xp,yp;
|
---|
| 157 | double flx,fnd;
|
---|
| 158 | char buff[128];
|
---|
| 159 | int ncnt = 0;
|
---|
[685] | 160 | sprintf(buff,"PIStarList: NStars %d \n", mStL->NbStars() );
|
---|
[344] | 161 | info += buff;
|
---|
[2185] | 162 | info += " Num: XPos YPos Flux Fond \n";
|
---|
[344] | 163 | for (int i=0; i<mStL->NbStars(); i++) {
|
---|
| 164 | sti = mStL->Star(i);
|
---|
| 165 | if ( !(sti->Nice(BStar::flagOK)) ) continue;
|
---|
| 166 | flx = sti->Flux();
|
---|
[2185] | 167 | fnd = sti->Fond();
|
---|
[344] | 168 | if ( (flx < mFmin) || (flx > mFmax) ) continue;
|
---|
| 169 | xp = sti->PosX(); yp = sti->PosY();
|
---|
| 170 | if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue;
|
---|
| 171 | ncnt++;
|
---|
| 172 | if (ncnt > 101) continue;
|
---|
| 173 | fnd = sti->Fond();
|
---|
| 174 | sprintf(buff,"%6d: %8.3g %8.3g %8.3g %8.3g \n", i, xp, yp, flx, fnd);
|
---|
| 175 | info += buff;
|
---|
| 176 | }
|
---|
| 177 | if (ncnt >= 101) info += " .... \n";
|
---|
| 178 | sprintf(buff," %d stars inside selected region \n", ncnt);
|
---|
| 179 | info += buff;
|
---|
| 180 | return;
|
---|
| 181 | }
|
---|