[537] | 1 | // Peida Interactive - PI R. Ansari 97-99
|
---|
| 2 | // Traceur (Drawer) pour NTupleInterface
|
---|
| 3 | // LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
|
---|
| 4 |
|
---|
[165] | 5 | #include <stdio.h>
|
---|
[2517] | 6 | #include <stdlib.h>
|
---|
| 7 | #include <iostream>
|
---|
| 8 | #include <math.h>
|
---|
[165] | 9 | #include "pintuple.h"
|
---|
| 10 |
|
---|
[537] | 11 | //++
|
---|
| 12 | // Class PINTuple
|
---|
| 13 | // Lib PIext
|
---|
| 14 | // include pintuple.h
|
---|
| 15 | //
|
---|
| 16 | // Classe de traceur 2D (dans un plan) à partir des données
|
---|
| 17 | // d'un objet implémentant l'interface *NTupleInterface*.
|
---|
| 18 | // Les objets "PINTuple" peuvent tracer des signes (markers)
|
---|
| 19 | // éventuellement avec des barres d'erreur et une étiquette
|
---|
[2373] | 20 | // pour chaque point. Si un nom de colonne poids est spécifié,
|
---|
| 21 | // la taille et/ou la couleur des signes (markers) sera fonction
|
---|
| 22 | // de la valeur de poids.
|
---|
[537] | 23 | //--
|
---|
| 24 | //++
|
---|
| 25 | // Links Parents
|
---|
| 26 | // PIDrawer
|
---|
| 27 | //--
|
---|
| 28 | //++
|
---|
| 29 | // Links Voir aussi
|
---|
| 30 | // NTupleInterface
|
---|
| 31 | // PINTuple3D
|
---|
| 32 | //--
|
---|
| 33 |
|
---|
| 34 | //++
|
---|
| 35 | // Titre Constructeur
|
---|
| 36 | //--
|
---|
| 37 | //++
|
---|
| 38 | // PINTuple(NTupleInterface* nt, bool ad)
|
---|
[544] | 39 | // Constructeur. Si "ad == true", l'objet "nt" est détruit par
|
---|
[537] | 40 | // le destructeur de l'objet "PINTuple"
|
---|
[2373] | 41 | // Note : "nt" doit être créé par new dans ce cas.
|
---|
[537] | 42 | //--
|
---|
[165] | 43 |
|
---|
| 44 | /* --Methode-- */
|
---|
[326] | 45 | PINTuple::PINTuple(NTupleInterface* nt, bool ad)
|
---|
[165] | 46 | : PIDrawer()
|
---|
| 47 | {
|
---|
| 48 | mNT = nt;
|
---|
| 49 | mAdDO = ad;
|
---|
[544] | 50 | SetStats(true);
|
---|
[2383] | 51 | SetStatPosOffset();
|
---|
[2350] | 52 | ConnectPoints(false);
|
---|
[2373] | 53 | UseSizeScale(true, 5);
|
---|
| 54 | UseColorScale(true);
|
---|
[165] | 55 | SelectXY(NULL, NULL);
|
---|
[2373] | 56 | SelectWt(NULL);
|
---|
[165] | 57 | SelectErrBar();
|
---|
[486] | 58 | SelectLabel(NULL);
|
---|
[1856] | 59 | SetName("NTupleDrw");
|
---|
[2517] | 60 | NptDraw = 0;
|
---|
| 61 |
|
---|
[165] | 62 | }
|
---|
| 63 |
|
---|
| 64 | PINTuple::~PINTuple()
|
---|
| 65 | {
|
---|
| 66 | if (mAdDO && mNT) delete mNT;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
[537] | 69 | //++
|
---|
| 70 | // Titre Méthodes
|
---|
| 71 | //--
|
---|
| 72 | //++
|
---|
| 73 | // void SelectXY(const char* px, const char* py)
|
---|
| 74 | // Choix des noms de colonnes X,Y définissant les coordonnées des points.
|
---|
| 75 | // Ces deux colonnes doivent être spécifiées pour obtenir un tracé.
|
---|
| 76 | // void SelectErrBar(const char* erbx=NULL, const char* erby=NULL)
|
---|
| 77 | // Choix des noms de colonnes pour le tracé des barres d'erreur.
|
---|
| 78 | // void SelectWt(const char* pw=NULL, int nbins=10)
|
---|
| 79 | // Choix du nom de colonne poids. Dans ce cas, la taille du signe
|
---|
| 80 | // (marker) sera proportionnel à la valeur de cette colonne pour
|
---|
| 81 | // chaque point.
|
---|
| 82 | // void SelectLabel(const char* plabel=NULL)
|
---|
| 83 | // Choix du nom de colonne correspondant à l'étiquette.
|
---|
| 84 | //--
|
---|
| 85 |
|
---|
[165] | 86 | /* --Methode-- */
|
---|
| 87 | void PINTuple::SelectXY(const char* px, const char* py)
|
---|
| 88 | {
|
---|
[326] | 89 | string name;
|
---|
[165] | 90 | if (mNT == NULL) xK = yK = -1;
|
---|
| 91 | if (px == NULL) xK = -1;
|
---|
[326] | 92 | else { name = px; xK = mNT->ColumnIndex(name); }
|
---|
[165] | 93 | if (py == NULL) yK = -1;
|
---|
[326] | 94 | else { name = py; yK = mNT->ColumnIndex(name); }
|
---|
[165] | 95 | }
|
---|
| 96 |
|
---|
| 97 | /* --Methode-- */
|
---|
[2373] | 98 | void PINTuple::SelectWt(const char* pw)
|
---|
[333] | 99 | {
|
---|
| 100 | if (pw == NULL) wK = -1;
|
---|
| 101 | else { string name = pw; wK = mNT->ColumnIndex(name); }
|
---|
| 102 |
|
---|
| 103 | if (wK >= 0) mNT->GetMinMax(wK, wMin, wMax);
|
---|
| 104 | else { wMin = 0.; wMax = 1.; }
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | /* --Methode-- */
|
---|
[486] | 108 | void PINTuple::SelectLabel(const char* plabel)
|
---|
| 109 | {
|
---|
| 110 | if (plabel == NULL) lK = -1;
|
---|
| 111 | else { string name = plabel; lK = mNT->ColumnIndex(name); }
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | /* --Methode-- */
|
---|
[165] | 115 | void PINTuple::SelectErrBar(const char* erbx, const char* erby)
|
---|
| 116 | {
|
---|
[326] | 117 | string name;
|
---|
[165] | 118 | if (mNT == NULL) xebK = yebK = -1;
|
---|
| 119 | if (erbx == NULL) xebK = -1;
|
---|
[326] | 120 | else { name = erbx; xebK = mNT->ColumnIndex(name); }
|
---|
[165] | 121 | if (erby == NULL) yebK = -1;
|
---|
[326] | 122 | else { name = erby; yebK = mNT->ColumnIndex(name); }
|
---|
[165] | 123 | }
|
---|
| 124 |
|
---|
| 125 |
|
---|
| 126 | /* --Methode-- */
|
---|
| 127 | void PINTuple::UpdateLimits()
|
---|
| 128 | {
|
---|
| 129 | if (!mNT) return;
|
---|
[326] | 130 | if (mNT->NbLines() <= 0) return;
|
---|
[165] | 131 | if ( (xK < 0) || (yK < 0) ) return;
|
---|
| 132 |
|
---|
| 133 | // Commencer par trouver nos limites
|
---|
[326] | 134 | double xmin, xmax, ymin, ymax;
|
---|
[165] | 135 | xmin = ymin = 9.e19;
|
---|
| 136 | xmax = ymax = -9.e19;
|
---|
| 137 | mNT->GetMinMax(xK, xmin, xmax);
|
---|
| 138 | mNT->GetMinMax(yK, ymin, ymax);
|
---|
[2115] | 139 | PIAxes::ReSizeMinMax(isLogScaleX(),xmin,xmax);
|
---|
| 140 | PIAxes::ReSizeMinMax(isLogScaleY(),ymin,ymax);
|
---|
| 141 | SetLimits(xmin,xmax,ymin,ymax);
|
---|
[548] | 142 | // SetAxesFlags(kBoxAxes | kExtTicks | kLabels); Ne pas faire - Reza 11/99
|
---|
[165] | 143 | }
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | /* --Methode-- */
|
---|
[2469] | 147 | #define NMXMULTP_LOCAL 30 // Pour multipoint sans new
|
---|
[205] | 148 | void PINTuple::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
|
---|
[165] | 149 | {
|
---|
[333] | 150 | double xp,yp,xer,yer,wp;
|
---|
[326] | 151 | double xl,yl;
|
---|
[2469] | 152 | int nok,npolyg;
|
---|
[165] | 153 |
|
---|
| 154 | if (!mNT) return;
|
---|
[548] | 155 | if (axesFlags != kAxesNone) DrawAxes(g);
|
---|
[165] | 156 | if ( (xK < 0) || (yK < 0) ) return;
|
---|
[1905] | 157 | if (GetGraphicAtt().GetLineAtt() == PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
|
---|
[326] | 158 |
|
---|
[333] | 159 | // Pour tracer des markers avec taille fonction de Wt (poids)
|
---|
| 160 | double dw = (wMax-wMin)/nWbins;
|
---|
[2373] | 161 | if (dw < 1.e-19) dw = 1.e-19;
|
---|
| 162 |
|
---|
| 163 | // Pour tracer des markers avec couleur en fonction de Wt (poids)
|
---|
| 164 | PIColorMap * cmap = NULL;
|
---|
| 165 | double dwc = 1.;
|
---|
[2469] | 166 | int nwc = 1;
|
---|
[2373] | 167 | bool revcmap;
|
---|
| 168 | CMapId mcmapid = GetGraphicAtt().GetColMapId(revcmap);
|
---|
| 169 | if( colorScale && (wK >= 0) && (mcmapid != CMAP_OTHER) ) {
|
---|
| 170 | cmap = new PIColorMap(mcmapid);
|
---|
| 171 | cmap->ReverseColorIndex(revcmap);
|
---|
| 172 | nwc = cmap->NCol();
|
---|
[2469] | 173 | dwc = (wMax-wMin)/(double)nwc;
|
---|
[2373] | 174 | }
|
---|
| 175 |
|
---|
[333] | 176 | int msz,sz;
|
---|
| 177 |
|
---|
[1905] | 178 | PIMarker mmrk = GetGraphicAtt().GetMarker();
|
---|
[333] | 179 | PIMarker mrk;
|
---|
[1905] | 180 | if (wK >= 0) mrk = (mmrk != PI_NotDefMarker) ? mmrk : PI_CircleMarker;
|
---|
| 181 | else mrk = (mmrk != PI_NotDefMarker) ? mmrk : PI_DotMarker;
|
---|
[2373] | 182 | msz = GetGraphicAtt().GetMarkerSz();
|
---|
[333] | 183 | if (msz < 1) msz = 1;
|
---|
[344] | 184 | g->SelMarker(msz, mrk);
|
---|
[333] | 185 |
|
---|
[685] | 186 | PIGrCoord uxmin, uxmax, uymin, uymax;
|
---|
| 187 | g->GetGrSpace(uxmin, uxmax, uymin, uymax);
|
---|
| 188 | double xmin2 = uxmin;
|
---|
| 189 | double ymin2 = uymin;
|
---|
| 190 | double xmax2 = uxmax;
|
---|
| 191 | double ymax2 = uymax;
|
---|
| 192 |
|
---|
[165] | 193 | nok = 0;
|
---|
[326] | 194 | xp = yp = xl = yl = 0;
|
---|
[2469] | 195 | PIGrCoord xpolyg[NMXMULTP_LOCAL], ypolyg[NMXMULTP_LOCAL];
|
---|
[2517] | 196 | npolyg = 0;
|
---|
| 197 | NptDraw = 0;
|
---|
[2115] | 198 | for (long i=0; i<(long)mNT->NbLines(); i++) {
|
---|
[2469] | 199 | xl = xp; yl = yp;
|
---|
[326] | 200 | xp = mNT->GetCell(i, xK);
|
---|
| 201 | yp = mNT->GetCell(i, yK);
|
---|
[686] | 202 | if ( (xp < xmin2) || (xp > xmax2) || (yp < ymin2) || (yp > ymax2) ) continue;
|
---|
| 203 | nok++;
|
---|
[165] | 204 | if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue;
|
---|
[2373] | 205 |
|
---|
[2517] | 206 | NptDraw++;
|
---|
[2373] | 207 | // Taille - couleur de marker en fonction du poids
|
---|
| 208 | if (wK >= 0) wp = mNT->GetCell(i, wK);
|
---|
| 209 | if (mrkSzScale && (wK >= 0)) { // Changement de taille
|
---|
| 210 | sz = (int)((wp-wMin)/dw);
|
---|
| 211 | if (sz < 0) sz = 0;
|
---|
| 212 | if (sz > nWbins) sz = nWbins;
|
---|
| 213 | sz += msz;
|
---|
| 214 | if (sz < 2) g->SelMarker(sz, PI_DotMarker);
|
---|
| 215 | else g->SelMarker(sz, mrk);
|
---|
| 216 | }
|
---|
| 217 | // Couleur du marker en fonction du poids
|
---|
| 218 | if( colorScale && (wK >= 0) && cmap ) {
|
---|
| 219 | int cid = (int)((wp-wMin)/dwc);
|
---|
| 220 | if (cid < 0) cid = 0;
|
---|
| 221 | if (cid >= nwc) cid = nwc-1;
|
---|
| 222 | g->SelForeground(*cmap, cid);
|
---|
| 223 | }
|
---|
| 224 |
|
---|
[2469] | 225 | // Trace d'une ligne reliant les points
|
---|
| 226 | if( connectPts ) {
|
---|
| 227 | if(npolyg==0) {xpolyg[0]=xl; ypolyg[0]=yl; npolyg=1;}
|
---|
| 228 | if(npolyg<NMXMULTP_LOCAL)
|
---|
| 229 | {xpolyg[npolyg]=xp; ypolyg[npolyg]=yp; npolyg++;}
|
---|
| 230 | if(npolyg==NMXMULTP_LOCAL)
|
---|
| 231 | {g->DrawPolygon(xpolyg,ypolyg,npolyg,false); npolyg=0;}
|
---|
| 232 | }
|
---|
| 233 |
|
---|
| 234 | // Trace des erreurs selon X et Y
|
---|
[165] | 235 | if ( xebK >= 0 ) {
|
---|
[326] | 236 | xer = mNT->GetCell(i, xebK);
|
---|
[165] | 237 | if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp);
|
---|
| 238 | }
|
---|
| 239 | if ( yebK >= 0 ) {
|
---|
[326] | 240 | yer = mNT->GetCell(i, yebK);
|
---|
[165] | 241 | if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
|
---|
| 242 | }
|
---|
[2469] | 243 |
|
---|
[486] | 244 | // Trace du marker
|
---|
[1905] | 245 | if ((wK >= 0)||(lK < 0)||(mmrk != PI_NotDefMarker)) g->DrawMarker(xp, yp);
|
---|
[2469] | 246 |
|
---|
[486] | 247 | // Trace eventuel du label
|
---|
| 248 | if (lK >= 0) g->DrawString(xp, yp, mNT->GetCelltoString(i, lK).c_str());
|
---|
| 249 |
|
---|
[165] | 250 | }
|
---|
| 251 |
|
---|
[2469] | 252 | // Fin du trace d'une ligne reliant les points si necessaire
|
---|
| 253 | if( connectPts && npolyg>1 )
|
---|
| 254 | {g->DrawPolygon(xpolyg,ypolyg,npolyg,false); npolyg=0;}
|
---|
| 255 |
|
---|
[544] | 256 | if (stats) { // Trace de stats
|
---|
[1905] | 257 | g->SelFontSz((YMax() - YMin())/30);
|
---|
[1645] | 258 | // La hauteur de la cellule
|
---|
[544] | 259 | PIGrCoord a,d;
|
---|
| 260 | double cH = (double)g->GetFontHeight(a,d);
|
---|
[1645] | 261 | double cellHeight = 1.2 * cH;
|
---|
| 262 | // Les labels et leurs longueurs -> largeur de la cellule
|
---|
| 263 | char label[64];
|
---|
[2383] | 264 | sprintf(label, "N=%d (/%d)", nok, mNT->NbLines());
|
---|
[1644] | 265 | double cellWidth = 1.1 * (double)g->CalcStringWidth(label);
|
---|
[1645] | 266 | double xu, yu, cw;
|
---|
[2383] | 267 | double ofpx = spoX*(XMax()-XMin());
|
---|
| 268 | double ofpy = spoY*(YMax()-YMin());
|
---|
[1645] | 269 | // Les limites du cadre
|
---|
[548] | 270 | xu = g->DeltaUCX(XMax(), - cellWidth);
|
---|
| 271 | yu = g->DeltaUCY(YMax(), - cellHeight);
|
---|
[2383] | 272 | double recw = XMax()-xu;
|
---|
| 273 | double rech = YMax()-yu;
|
---|
| 274 | xu += ofpx; yu += ofpy;
|
---|
| 275 | g->DrawBox(xu, yu, recw, rech);
|
---|
[1645] | 276 | // L'ecriture des labels (attention aux inversions possibles des axes!)
|
---|
| 277 | cw = (g->isAxeXDirRtoL()) ? -0.05*cellWidth : -0.95*cellWidth;
|
---|
| 278 | xu = g->DeltaUCX(XMax(),cw);
|
---|
| 279 | cw = (g->isAxeYDirUpDown()) ? -0.1*cH : -1.1*cH;
|
---|
| 280 | yu = g->DeltaUCY(YMax(),cw);
|
---|
[2383] | 281 | xu += ofpx; yu += ofpy;
|
---|
[1645] | 282 | g->DrawString(xu,yu,label);
|
---|
[544] | 283 | }
|
---|
| 284 |
|
---|
[2373] | 285 | if (cmap) delete cmap;
|
---|
[165] | 286 | return;
|
---|
| 287 | }
|
---|
[2469] | 288 | #undef NMXMULTP_LOCAL
|
---|
[165] | 289 |
|
---|
[344] | 290 | /* --Methode-- */
|
---|
| 291 | void PINTuple::AppendTextInfo(string& info, double xmin, double ymin, double xmax, double ymax)
|
---|
| 292 | {
|
---|
| 293 | if (!mNT) return;
|
---|
| 294 | if ( (xK < 0) || (yK < 0) ) return;
|
---|
| 295 |
|
---|
| 296 | int ncnt = 0;
|
---|
| 297 | double xp,yp;
|
---|
| 298 | char buff[128];
|
---|
| 299 | sprintf(buff,"PINTuple: NLines= %d NCol= %d \n", mNT->NbLines(), mNT->NbColumns());
|
---|
| 300 | info += buff;
|
---|
| 301 | info += mNT->LineHeaderToString();
|
---|
[2115] | 302 | for(long i=0; i<(long)mNT->NbLines(); i++) {
|
---|
[344] | 303 | xp = mNT->GetCell(i, xK);
|
---|
| 304 | yp = mNT->GetCell(i, yK);
|
---|
| 305 | if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue;
|
---|
| 306 | ncnt++;
|
---|
| 307 | if (ncnt > 101) continue;
|
---|
| 308 | info += mNT->LineToString(i);
|
---|
| 309 | }
|
---|
| 310 | if (ncnt >= 101) info += " .... \n";
|
---|
| 311 | sprintf(buff," %d points inside selected region \n", ncnt);
|
---|
| 312 | info += buff;
|
---|
| 313 | // printf("PINTuple::AppendTextInfo()-DBG %g %g %g %g - %d\n", xmin, ymin, xmax, ymax, ncnt);
|
---|
| 314 | return;
|
---|
| 315 | }
|
---|
[1971] | 316 |
|
---|
| 317 | /* La methode DecodeOptionString permet de decoder un ensemble d'options
|
---|
| 318 | et de parametre d'affichage specifie sous forme d'un vecteur de string.
|
---|
| 319 | Si rmdecopt == true, les options decodees sont supprimees du vecteur
|
---|
| 320 | de string fourni en entree - ce qui permet l'enchainement eventuel
|
---|
| 321 | de plusieurs decodages de string.
|
---|
| 322 | Les options peuvent etre sous forme de flag : "stat" "nostat"
|
---|
| 323 | ou plus complexes, par exemple "dynamic=-3,3"
|
---|
| 324 | Rc: La methode renvoie le nombre d'options decodees
|
---|
| 325 | */
|
---|
| 326 |
|
---|
| 327 | /* --Methode-- */
|
---|
| 328 | int PINTuple::DecodeOptionString(vector<string> & opt, bool rmdecopt)
|
---|
| 329 | {
|
---|
[2229] | 330 | int optsz1 = opt.size();
|
---|
| 331 | if(optsz1<1) return(0);
|
---|
[1971] | 332 | // On appelle d'abord le decodage de la classe PIDrawer de laquelle
|
---|
| 333 | // on herite. (Pas obligatoire) on decode donc ici les attributs de
|
---|
| 334 | // couleur, fontes ...
|
---|
| 335 | int ndec1 = PIDrawer::DecodeOptionString(opt, rmdecopt);
|
---|
[2229] | 336 | if(optsz1-ndec1<1) return(ndec1); // si tout a ete decode
|
---|
[1971] | 337 |
|
---|
| 338 | vector<string> udopt; // On gardera ici les options non decodees
|
---|
| 339 | unsigned int k = 0;
|
---|
| 340 | int ndec = opt.size();
|
---|
| 341 | for( k=0; k<opt.size(); k++ ) {
|
---|
| 342 | string opts = opt[k];
|
---|
[2229] | 343 | if(opts=="sta" || opts=="stat" || opts=="stats") SetStats(true);
|
---|
| 344 | else if( opts=="nsta" || opts=="nstat"
|
---|
| 345 | || opts=="nostat" || opts=="nostats") SetStats(false);
|
---|
[2383] | 346 | else if(opts.substr(0,11) == "statposoff=") {
|
---|
| 347 | float xo=0., yo=0.;
|
---|
| 348 | sscanf(opts.substr(11).c_str(),"%g,%g",&xo, &yo);
|
---|
| 349 | SetStatPosOffset(xo, yo);
|
---|
| 350 | }
|
---|
[2350] | 351 | else if (opts == "connectpoints") ConnectPoints(true);
|
---|
| 352 | else if (opts == "noconnectpoints") ConnectPoints(false);
|
---|
[2373] | 353 | else if (opts == "colorscale") UseColorScale(true);
|
---|
| 354 | else if (opts == "nocolorscale") UseColorScale(false);
|
---|
| 355 | else if (opts == "sizescale") UseSizeScale(true);
|
---|
| 356 | else if (opts == "nosizescale") UseSizeScale(false);
|
---|
| 357 | else if (opts.substr(0,10) == "sizescale=") {
|
---|
| 358 | int nbn = atoi(opts.substr(10).c_str());
|
---|
| 359 | UseSizeScale(true, nbn);
|
---|
| 360 | }
|
---|
[2383] | 361 |
|
---|
[1971] | 362 | else {
|
---|
| 363 | // Si option non decode
|
---|
| 364 | ndec--;
|
---|
| 365 | // S'il faut supprimer les options decodees
|
---|
| 366 | if (rmdecopt) udopt.push_back(opts);
|
---|
| 367 | }
|
---|
| 368 | }
|
---|
| 369 | // S'il faut supprimer les options decodees, on remplace l'argument opt
|
---|
| 370 | // par le vecteur des options non decodees.
|
---|
| 371 | if (rmdecopt) opt = udopt;
|
---|
| 372 | return(ndec+ndec1);
|
---|
| 373 | }
|
---|
[1975] | 374 |
|
---|
[2524] | 375 | int PINTuple::OptionToString(vector<string> & opt) const
|
---|
| 376 | {
|
---|
| 377 | PIDrawer::OptionToString(opt);
|
---|
| 378 |
|
---|
| 379 | char str[256];
|
---|
| 380 |
|
---|
| 381 | if(stats) opt.push_back("stat"); else opt.push_back("nstat");
|
---|
| 382 |
|
---|
| 383 | sprintf(str,"statposoff=%g,%g",spoX,spoY); opt.push_back(str);
|
---|
| 384 |
|
---|
| 385 | if(connectPts) opt.push_back("connectpoints");
|
---|
| 386 | else opt.push_back("noconnectpoints");
|
---|
| 387 |
|
---|
| 388 | if(colorScale) opt.push_back("colorscale");
|
---|
| 389 | else opt.push_back("nocolorscale");
|
---|
| 390 |
|
---|
| 391 | if(mrkSzScale) {
|
---|
| 392 | if(nWbins>0) {sprintf(str,"sizescale=%d",nWbins); opt.push_back(str);}
|
---|
| 393 | else opt.push_back("sizescale");
|
---|
| 394 | } else opt.push_back("nosizescale");
|
---|
| 395 |
|
---|
| 396 | return 1;
|
---|
| 397 | }
|
---|
| 398 |
|
---|
[1975] | 399 | /* La methode GetOptionsHelpInfo(string& info) renvoie une chaine
|
---|
| 400 | avec la description des options comprises par ce drawer
|
---|
| 401 | Note: Il est preferable de ne pas initialiser la chaine
|
---|
| 402 | string info au depart, afin de permettre de mettre bout a
|
---|
| 403 | bout les aides de differents Drawer */
|
---|
| 404 |
|
---|
| 405 | /* --Methode-- */
|
---|
| 406 | void PINTuple::GetOptionsHelpInfo(string& info)
|
---|
| 407 | {
|
---|
[2229] | 408 | info += " ---- PINTuple options help info : \n" ;
|
---|
[2350] | 409 | info += " sta,stat,stats: activate statistic display\n";
|
---|
[2229] | 410 | info += " nsta,nstat,nostat,nostats: deactivate statistic display\n";
|
---|
[2383] | 411 | info += " statposoff=OffsetX,OffsetY : Position offset for Stats drawing \n";
|
---|
| 412 | info += " as a fraction of total size \n";
|
---|
[2350] | 413 | info += " connectpoints: The points are connected by a line \n";
|
---|
| 414 | info += " noconnectpoints (this is the default) \n";
|
---|
[2373] | 415 | info += " colorscale/nocolorscale (Use color scale for weight) \n";
|
---|
| 416 | info += " sizescale/sizescale=nbins/nosizescale (Use marker size for weight) \n";
|
---|
[2383] | 417 | info += " (and usual color/line/marker/... attribute decoding) \n";
|
---|
[2388] | 418 | // On recupere ensuite la chaine info de la classe de base
|
---|
| 419 | PIDrawer::GetOptionsHelpInfo(info);
|
---|
[2229] | 420 | return;
|
---|
[1975] | 421 | }
|
---|
[2373] | 422 |
|
---|
| 423 |
|
---|
[2517] | 424 | /* --Methode-- */
|
---|
| 425 | double PINTuple::GetDistanceToPoint(double x, double y)
|
---|
| 426 | {
|
---|
| 427 | if(!mNT) return 1.e+9;
|
---|
| 428 | if( xK<0 || yK<0 ) return 1.e+9;
|
---|
[2373] | 429 |
|
---|
[2517] | 430 | const int nessai = 100;
|
---|
| 431 | long inc = (NptDraw>nessai) ? (long)(NptDraw/nessai)+1 : 1;
|
---|
| 432 |
|
---|
| 433 | double dist = -1.e+18;
|
---|
| 434 | long n = 0;
|
---|
| 435 | for(long i=0; i<(long)mNT->NbLines(); i++) {
|
---|
| 436 | double xp=mNT->GetCell(i,xK);
|
---|
| 437 | if(xp<XMin() || xp>XMax()) continue;
|
---|
| 438 | double yp=mNT->GetCell(i,yK);
|
---|
| 439 | if(yp<YMin() || yp>YMax()) continue;
|
---|
| 440 | if(n%inc==0) {
|
---|
| 441 | xp = (xp-x)/(XMax()-XMin())/0.5;
|
---|
| 442 | yp = (yp-y)/(YMax()-YMin())/0.5;
|
---|
| 443 | xp = xp*xp+yp*yp;
|
---|
| 444 | if(dist<0. || xp<dist) dist = xp;
|
---|
| 445 | }
|
---|
| 446 | n++;
|
---|
| 447 | }
|
---|
| 448 | dist=sqrt(fabs(dist));
|
---|
| 449 | //cout<<"PINTuple: xlim="<<XMin()<<","<<XMax()<<" ylim="<<YMin()<<","<<YMax()
|
---|
| 450 | // <<" NbLines="<<mNT->NbLines()<<" inc="<<inc<<endl;
|
---|
| 451 | //cout<<"....d="<<dist<<" x="<<x<<" y="<<y<<" NptDraw="<<NptDraw<<endl;
|
---|
| 452 |
|
---|
| 453 | return dist;
|
---|
| 454 | }
|
---|