source: Sophya/trunk/SophyaPI/PIext/pintup3d.cc@ 486

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

Adapatation a NTupleInterface::GetCelltoString() et ajout trace Label ds PINTuple/3D et Wt ds PINtuple3D - Reza 21/10/99

File size: 4.8 KB
RevLine 
[165]1#include <stdio.h>
2#include "pintup3d.h"
3
4
5/* --Methode-- */
[326]6PINTuple3D::PINTuple3D(NTupleInterface* nt, bool ad)
[165]7: PIDrawer3D()
8{
9 mNT = nt;
10 mAdDO = ad;
11 SelectXYZ(NULL, NULL, NULL);
[486]12 SelectWt(NULL, 1);
[165]13 SelectErrBar();
[486]14 SelectLabel(NULL);
[165]15}
16
17PINTuple3D::~PINTuple3D()
18{
19 if (mAdDO && mNT) delete mNT;
20}
21
22/* --Methode-- */
23void PINTuple3D::SelectXYZ(const char* px, const char* py, const char* pz)
24{
[326]25string name;
[165]26if (mNT == NULL) xK = yK = zK = -1;
27if (px == NULL) xK = -1;
[326]28else { name = px; xK = mNT->ColumnIndex(name); }
[165]29if (py == NULL) yK = -1;
[326]30else { name = py; yK = mNT->ColumnIndex(name); }
[165]31if (pz == NULL) zK = -1;
[326]32else { name = pz; zK = mNT->ColumnIndex(name); }
[165]33}
34
35/* --Methode-- */
[486]36void PINTuple3D::SelectWt(const char* pw, int nbins)
37{
38nWbins = (nbins > 0) ? nbins : 10;
39if (pw == NULL) wK = -1;
40else { string name = pw; wK = mNT->ColumnIndex(name); }
41
42if (wK >= 0) mNT->GetMinMax(wK, wMin, wMax);
43else { wMin = 0.; wMax = 1.; }
44}
45
46/* --Methode-- */
47void PINTuple3D::SelectLabel(const char* plabel)
48{
49if (plabel == NULL) lK = -1;
50else { string name = plabel; lK = mNT->ColumnIndex(name); }
51}
52
53/* --Methode-- */
[165]54void PINTuple3D::SelectErrBar(const char* erbx, const char* erby, const char* erbz)
55{
[326]56string name;
[165]57if (mNT == NULL) xebK = yebK = zebK = -1;
58if (erbx == NULL) xebK = -1;
[326]59else { name = erbx; xebK = mNT->ColumnIndex(name); }
[165]60if (erby == NULL) yebK = -1;
[326]61else { name = erby; yebK = mNT->ColumnIndex(name); }
[165]62if (erbz == NULL) zebK = -1;
[326]63else { name = erbz; zebK = mNT->ColumnIndex(name); }
[165]64}
65
66
67/* --Methode-- */
68void PINTuple3D::UpdateLimits()
69{
[326]70 if (!mNT) return;
71 if (mNT->NbLines() <= 0) return;
[165]72 if ( (xK < 0) || (yK < 0) || (zK < 0) ) return;
73
74 // Commencer par trouver nos limites
[326]75 double xmin, xmax, ymin, ymax, zmin, zmax;
[165]76 xmin = ymin = 9.e19;
77 xmax = ymax = -9.e19;
78 zmax = zmax = -9.e19;
79 mNT->GetMinMax(xK, xmin, xmax);
80 mNT->GetMinMax(yK, ymin, ymax);
81 mNT->GetMinMax(zK, zmin, zmax);
82
83// Centre du champ en C = (xmin+xmax)/2., (ymin+ymax)/2 (zmin+zmax)*0.5
84// Distance D = Max(xmax-xmin,ymin-ymax)*2
85// Observateur en O = X+D, Yc+2*D
[205]86 double D = xmax-xmin;
[165]87 if (D < (ymax-ymin)) D = ymax-ymin;
88 D *= 1.4;
89
90 Set3DView((xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)/2.,
[185]91 (xmin+xmax)/2.+D , (ymin+ymax)/2.-2.5*D , zmin+(zmax-zmin)*0.85, 0.25, 0.25);
[171]92
[185]93 x3Min = xmin; // - 0.05*(xmax-xmin);
94 x3Max = xmax; // + 0.05*(xmax-xmin);
95 y3Min = ymin; // - 0.05*(ymax-ymin);
96 y3Max = ymax; // + 0.05*(ymax-ymin);
97 z3Min = zmin; // - 0.05*(zmax-zmin);
98 z3Max = zmax; // + 0.05*(zmax-zmin);
[171]99
[326]100// printf("PINTuple3D::UpdateLimits() : %g .. %g %g .. %g %g .. %g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
[165]101// printf("PINTuple3D::UpdateLimits() : %g %g %g << %g %g %g \n",
102// (xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)*0.5,
103// (xmin+xmax)/2.+D , (ymin+ymax)/2.+2.*D , zmin+(zmax-zmin)*0.1);
104}
105
106
107/* --Methode-- */
[205]108void PINTuple3D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
[165]109{
[486]110double xp,yp,zp,wp,xer,yer,zer;
[326]111double xl,yl,zl;
[165]112int nok;
113
[185]114// On trace les axes - En attendant de faire mieux - Reza 8/12/98
115if (axesFlags != kAxesNone) DrawAxes(g);
116
[165]117if (!mNT) return;
118if ( (xK < 0) || (yK < 0) || (zK < 0) ) return;
119
[440]120#if defined(CC_HAS_RTTI_SUPPORT)
[165]121PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
122#else
123PIGraphic3D* g3 = (PIGraphic3D*)(g);
124#endif
125
126if (mLAtt == PI_NotDefLineAtt) g3->SelLine(PI_ThinLine);
127
[486]128// Pour tracer des markers avec taille fonction de Wt (poids)
129double dw = (wMax-wMin)/nWbins;
130if (dw < 1.e-19) dw = 1.e19;
131int msz,sz;
132
133PIMarker mrk;
134if (wK >= 0) mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_CircleMarker;
135else mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_DotMarker;
136msz = mMSz;
137if (msz < 1) msz = 1;
138g->SelMarker(msz, mrk);
139
[165]140nok = 0;
[326]141xp = yp = zp = xl = yl = zl = 0;
142for (int i=0; i<mNT->NbLines(); i++) {
143 xl = xp; yl = yp; zl = zp;
144 xp = mNT->GetCell(i, xK);
145 yp = mNT->GetCell(i, yK);
146 zp = mNT->GetCell(i, zK);
147 if ( (i > 0) && (mLAtt != PI_NotDefLineAtt) ) // On relie les points ...
148 g3->DrawLine3D(xl, yl, zl, xp, yp, zp);
[165]149 nok++;
150 if ( xebK >= 0 ) {
[326]151 xer = mNT->GetCell(i, xebK);
[165]152 g3->DrawLine3D(xp-xer, yp, zp, xp+xer, yp, zp);
153 }
154 if ( yebK >= 0 ) {
[326]155 yer = mNT->GetCell(i, yebK);
[165]156 g3->DrawLine3D(xp, yp-yer, zp, xp, yp+yer, zp);
157 }
158 if ( zebK >= 0 ) {
[326]159 zer = mNT->GetCell(i, zebK);
[165]160 g3->DrawLine3D(xp, yp, zp-zer, xp, yp, zp+zer);
161 }
[486]162 if (wK >= 0) { // Taille de marker en fonction du poids
163 wp = mNT->GetCell(i, wK);
164 sz = (int)((wp-wMin)/dw);
165 if (sz < 0) sz = 0;
166 if (sz > nWbins) sz = nWbins;
167 sz += msz;
168 if (sz < 2) g->SelMarker(sz, PI_DotMarker);
169 else g->SelMarker(sz, mrk);
170 }
171 // Trace du marker
172 if ((wK >= 0)||(lK < 0)||(mMrk != PI_NotDefMarker)) g3->DrawMarker3D(xp, yp, zp);
173 // Trace eventuel du label
174 if (lK >= 0) g3->DrawString3D(xp, yp, zp, mNT->GetCelltoString(i, lK).c_str());
[165]175}
176
177return;
178}
179
Note: See TracBrowser for help on using the repository browser.