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