source: Sophya/trunk/Poubelle/PIext/pintuple.cc@ 657

Last change on this file since 657 was 223, checked in by ansari, 26 years ago

Creation module DPC/PIext Reza 09/04/99

File size: 2.0 KB
Line 
1#include <stdio.h>
2#include "pintuple.h"
3
4
5/* --Methode-- */
6PINTuple::PINTuple(NTuple* 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{
23if (mNT == NULL) xK = yK = -1;
24if (px == NULL) xK = -1;
25else xK = mNT->IndexNom(px);
26if (py == NULL) yK = -1;
27else yK = mNT->IndexNom(py);
28}
29
30/* --Methode-- */
31void PINTuple::SelectErrBar(const char* erbx, const char* erby)
32{
33if (mNT == NULL) xebK = yebK = -1;
34if (erbx == NULL) xebK = -1;
35else xebK = mNT->IndexNom(erbx);
36if (erby == NULL) yebK = -1;
37else yebK = mNT->IndexNom(erby);
38}
39
40
41/* --Methode-- */
42void 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-- */
65void PINTuple::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
66{
67double xp,yp,xer,yer;
68int nok;
69
70if (!mNT) return;
71if ( (xK < 0) || (yK < 0) ) return;
72if (mLAtt == PI_NotDefLineAtt) g->SelLine(PI_ThinLine);
73nok = 0;
74for (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/*
91sprintf(buff, "NTuple: NEntry= %d NDisp= %d", (int)mNT->NEntry(), nok);
92g->BaseGraphic()->DrawString(15,15,buff);
93*/
94return;
95}
96
Note: See TracBrowser for help on using the repository browser.