1 | #include <stdio.h>
|
---|
2 | #include "pintuple.h"
|
---|
3 |
|
---|
4 |
|
---|
5 | /* --Methode-- */
|
---|
6 | PINTuple::PINTuple(NTuple* nt, bool ad)
|
---|
7 | : PIDrawer()
|
---|
8 | {
|
---|
9 | mNT = nt;
|
---|
10 | mAdDO = ad;
|
---|
11 | SelectXY(NULL, NULL);
|
---|
12 | SelectErrBar();
|
---|
13 | }
|
---|
14 |
|
---|
15 | PINTuple::~PINTuple()
|
---|
16 | {
|
---|
17 | if (mAdDO && mNT) delete mNT;
|
---|
18 | }
|
---|
19 |
|
---|
20 | /* --Methode-- */
|
---|
21 | void PINTuple::SelectXY(const char* px, const char* py)
|
---|
22 | {
|
---|
23 | if (mNT == NULL) xK = yK = -1;
|
---|
24 | if (px == NULL) xK = -1;
|
---|
25 | else xK = mNT->IndexNom(px);
|
---|
26 | if (py == NULL) yK = -1;
|
---|
27 | else yK = mNT->IndexNom(py);
|
---|
28 | }
|
---|
29 |
|
---|
30 | /* --Methode-- */
|
---|
31 | void PINTuple::SelectErrBar(const char* erbx, const char* erby)
|
---|
32 | {
|
---|
33 | if (mNT == NULL) xebK = yebK = -1;
|
---|
34 | if (erbx == NULL) xebK = -1;
|
---|
35 | else xebK = mNT->IndexNom(erbx);
|
---|
36 | if (erby == NULL) yebK = -1;
|
---|
37 | else yebK = mNT->IndexNom(erby);
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 | /* --Methode-- */
|
---|
42 | void PINTuple::UpdateLimits()
|
---|
43 | {
|
---|
44 | if (!mNT) return;
|
---|
45 | if (mNT->NEntry() <= 0) return;
|
---|
46 | if ( (xK < 0) || (yK < 0) ) return;
|
---|
47 |
|
---|
48 | // Commencer par trouver nos limites
|
---|
49 | float dx, dy;
|
---|
50 | float xmin, xmax, ymin, ymax;
|
---|
51 | xmin = ymin = 9.e19;
|
---|
52 | xmax = ymax = -9.e19;
|
---|
53 | mNT->GetMinMax(xK, xmin, xmax);
|
---|
54 | mNT->GetMinMax(yK, ymin, ymax);
|
---|
55 |
|
---|
56 | dx = 0.02*(xmax-xmin);
|
---|
57 | dy = 0.02*(ymax-ymin);
|
---|
58 |
|
---|
59 | SetLimits(xmin-dx, xmax+dx, ymin-dy, ymax+dy);
|
---|
60 | SetAxesFlags(kBoxAxes | kExtTicks | kLabels);
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | /* --Methode-- */
|
---|
65 | void PINTuple::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
|
---|
66 | {
|
---|
67 | double xp,yp,xer,yer;
|
---|
68 | int nok;
|
---|
69 |
|
---|
70 | if (!mNT) return;
|
---|
71 | if ( (xK < 0) || (yK < 0) ) return;
|
---|
72 | if (mLAtt == PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
|
---|
73 | nok = 0;
|
---|
74 | for (int i=0; i<mNT->NEntry(); i++) {
|
---|
75 | xp = mNT->GetVal(i, xK);
|
---|
76 | yp = mNT->GetVal(i, yK);
|
---|
77 | if ( (xp < xmin) || (xp > xmax) || (yp < ymin) || (yp > ymax) ) continue;
|
---|
78 | nok++;
|
---|
79 | if ( xebK >= 0 ) {
|
---|
80 | xer = mNT->GetVal(i, xebK);
|
---|
81 | if(xer>0.) g->DrawLine(xp-xer, yp, xp+xer, yp);
|
---|
82 | }
|
---|
83 | if ( yebK >= 0 ) {
|
---|
84 | yer = mNT->GetVal(i, yebK);
|
---|
85 | if(yer>0.) g->DrawLine(xp, yp-yer, xp, yp+yer);
|
---|
86 | }
|
---|
87 | g->DrawMarker(xp, yp);
|
---|
88 | }
|
---|
89 |
|
---|
90 | /*
|
---|
91 | sprintf(buff, "NTuple: NEntry= %d NDisp= %d", (int)mNT->NEntry(), nok);
|
---|
92 | g->BaseGraphic()->DrawString(15,15,buff);
|
---|
93 | */
|
---|
94 | return;
|
---|
95 | }
|
---|
96 |
|
---|