source: Sophya/trunk/SophyaPI/PIext/pintuple.cc@ 327

Last change on this file since 327 was 326, checked in by ercodmgr, 26 years ago

1/ NTupleInterface mis ds Outils++ et complete -
2/ Les PINtuple et PINtup3D utilisent maintenant NTupleInterface
3/ Debut modification interface NObjMgr - Reza 23/6/99

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