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

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

Documentation PI - Reza 2/11/99

File size: 6.4 KB
RevLine 
[537]1// Peida Interactive - PI R. Ansari 97-99
2// Traceur3D (Drawer) pour NTupleInterface
3// LAL (Orsay) / IN2P3-CNRS DAPNIA/SPP (Saclay) / CEA
4
[165]5#include <stdio.h>
6#include "pintup3d.h"
7
[537]8//++
9// Class PINTuple3D
10// Lib PIext
11// include pintup3d.h
12//
13// Classe de traceur 3D à partir des données
14// d'un objet implémentant l'interface *NTupleInterface*.
15// Les objets "PINTuple3D" peuvent tracer des signes (markers)
16// éventuellement avec des barres d'erreur et une étiquette
17// pour chaque point. Si un attribut de ligne, autre que
18// "PI_NotDefLineAtt" est spécifié, les points sont connectés
19// par une ligne.
20//--
21//++
22// Links Parents
23// PIDrawer3D
24//--
25//++
26// Links Voir aussi
27// NTupleInterface
28// PINTuple
29//--
30
31//++
32// Titre Constructeur
33//--
34//++
35// PINTuple3D(NTupleInterface* nt, bool ad=false)
36// Constructeur. Si "ad == true", l'objet "nt" est détruit par
37// le destructeur de l'objet "PINTuple".
38// Note : nt doit être créé par new
39//--
40
[165]41
42/* --Methode-- */
[326]43PINTuple3D::PINTuple3D(NTupleInterface* nt, bool ad)
[165]44: PIDrawer3D()
45{
46 mNT = nt;
47 mAdDO = ad;
48 SelectXYZ(NULL, NULL, NULL);
[486]49 SelectWt(NULL, 1);
[165]50 SelectErrBar();
[486]51 SelectLabel(NULL);
[165]52}
53
54PINTuple3D::~PINTuple3D()
55{
56 if (mAdDO && mNT) delete mNT;
57}
58
[537]59//++
60// Titre Méthodes
61//--
62//++
63// void SelectXYZ(const char* px, const char* py, const char* pz)
64// Choix des noms de colonnes X,Y,Z définissant les coordonnées des points.
65// Ces trois colonnes doivent être spécifiées pour obtenir un tracé.
66// void SelectErrBar(const char* erbx=NULL, const char* erby=NULL, const char* erbz=NULL)
67// Choix des noms de colonnes pour le tracé des barres d'erreur.
68// void SelectWt(const char* pw=NULL, int nbins=10)
69// Choix du nom de colonne poids. Dans ce cas, la taille du signe
70// (marker) sera proportionnel à la valeur de cette colonne pour
71// chaque point.
72// void SelectLabel(const char* plabel)
73// Choix du nom de colonne correspondant à l'étiquette.
74//--
75
[165]76/* --Methode-- */
77void PINTuple3D::SelectXYZ(const char* px, const char* py, const char* pz)
78{
[326]79string name;
[165]80if (mNT == NULL) xK = yK = zK = -1;
81if (px == NULL) xK = -1;
[326]82else { name = px; xK = mNT->ColumnIndex(name); }
[165]83if (py == NULL) yK = -1;
[326]84else { name = py; yK = mNT->ColumnIndex(name); }
[165]85if (pz == NULL) zK = -1;
[326]86else { name = pz; zK = mNT->ColumnIndex(name); }
[165]87}
88
89/* --Methode-- */
[486]90void PINTuple3D::SelectWt(const char* pw, int nbins)
91{
92nWbins = (nbins > 0) ? nbins : 10;
93if (pw == NULL) wK = -1;
94else { string name = pw; wK = mNT->ColumnIndex(name); }
95
96if (wK >= 0) mNT->GetMinMax(wK, wMin, wMax);
97else { wMin = 0.; wMax = 1.; }
98}
99
100/* --Methode-- */
101void PINTuple3D::SelectLabel(const char* plabel)
102{
103if (plabel == NULL) lK = -1;
104else { string name = plabel; lK = mNT->ColumnIndex(name); }
105}
106
107/* --Methode-- */
[165]108void PINTuple3D::SelectErrBar(const char* erbx, const char* erby, const char* erbz)
109{
[326]110string name;
[165]111if (mNT == NULL) xebK = yebK = zebK = -1;
112if (erbx == NULL) xebK = -1;
[326]113else { name = erbx; xebK = mNT->ColumnIndex(name); }
[165]114if (erby == NULL) yebK = -1;
[326]115else { name = erby; yebK = mNT->ColumnIndex(name); }
[165]116if (erbz == NULL) zebK = -1;
[326]117else { name = erbz; zebK = mNT->ColumnIndex(name); }
[165]118}
119
120
121/* --Methode-- */
122void PINTuple3D::UpdateLimits()
123{
[326]124 if (!mNT) return;
125 if (mNT->NbLines() <= 0) return;
[165]126 if ( (xK < 0) || (yK < 0) || (zK < 0) ) return;
127
128 // Commencer par trouver nos limites
[326]129 double xmin, xmax, ymin, ymax, zmin, zmax;
[165]130 xmin = ymin = 9.e19;
131 xmax = ymax = -9.e19;
132 zmax = zmax = -9.e19;
133 mNT->GetMinMax(xK, xmin, xmax);
134 mNT->GetMinMax(yK, ymin, ymax);
135 mNT->GetMinMax(zK, zmin, zmax);
136
137// Centre du champ en C = (xmin+xmax)/2., (ymin+ymax)/2 (zmin+zmax)*0.5
138// Distance D = Max(xmax-xmin,ymin-ymax)*2
139// Observateur en O = X+D, Yc+2*D
[205]140 double D = xmax-xmin;
[165]141 if (D < (ymax-ymin)) D = ymax-ymin;
142 D *= 1.4;
143
144 Set3DView((xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)/2.,
[185]145 (xmin+xmax)/2.+D , (ymin+ymax)/2.-2.5*D , zmin+(zmax-zmin)*0.85, 0.25, 0.25);
[171]146
[185]147 x3Min = xmin; // - 0.05*(xmax-xmin);
148 x3Max = xmax; // + 0.05*(xmax-xmin);
149 y3Min = ymin; // - 0.05*(ymax-ymin);
150 y3Max = ymax; // + 0.05*(ymax-ymin);
151 z3Min = zmin; // - 0.05*(zmax-zmin);
152 z3Max = zmax; // + 0.05*(zmax-zmin);
[171]153
[326]154// printf("PINTuple3D::UpdateLimits() : %g .. %g %g .. %g %g .. %g (%g) \n", xmin,xmax,ymin,ymax,zmin,zmax,D);
[165]155// printf("PINTuple3D::UpdateLimits() : %g %g %g << %g %g %g \n",
156// (xmin+xmax)/2., (ymin+ymax)/2, (zmin+zmax)*0.5,
157// (xmin+xmax)/2.+D , (ymin+ymax)/2.+2.*D , zmin+(zmax-zmin)*0.1);
158}
159
160
161/* --Methode-- */
[205]162void PINTuple3D::Draw(PIGraphicUC* g, double xmin, double ymin, double xmax, double ymax)
[165]163{
[486]164double xp,yp,zp,wp,xer,yer,zer;
[326]165double xl,yl,zl;
[165]166int nok;
167
[185]168// On trace les axes - En attendant de faire mieux - Reza 8/12/98
169if (axesFlags != kAxesNone) DrawAxes(g);
170
[165]171if (!mNT) return;
172if ( (xK < 0) || (yK < 0) || (zK < 0) ) return;
173
[440]174#if defined(CC_HAS_RTTI_SUPPORT)
[165]175PIGraphic3D* g3 = dynamic_cast<PIGraphic3D*>(g);
176#else
177PIGraphic3D* g3 = (PIGraphic3D*)(g);
178#endif
179
180if (mLAtt == PI_NotDefLineAtt) g3->SelLine(PI_ThinLine);
181
[486]182// Pour tracer des markers avec taille fonction de Wt (poids)
183double dw = (wMax-wMin)/nWbins;
184if (dw < 1.e-19) dw = 1.e19;
185int msz,sz;
186
187PIMarker mrk;
188if (wK >= 0) mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_CircleMarker;
189else mrk = (mMrk != PI_NotDefMarker) ? mMrk : PI_DotMarker;
190msz = mMSz;
191if (msz < 1) msz = 1;
192g->SelMarker(msz, mrk);
193
[165]194nok = 0;
[326]195xp = yp = zp = xl = yl = zl = 0;
196for (int i=0; i<mNT->NbLines(); i++) {
197 xl = xp; yl = yp; zl = zp;
198 xp = mNT->GetCell(i, xK);
199 yp = mNT->GetCell(i, yK);
200 zp = mNT->GetCell(i, zK);
201 if ( (i > 0) && (mLAtt != PI_NotDefLineAtt) ) // On relie les points ...
202 g3->DrawLine3D(xl, yl, zl, xp, yp, zp);
[165]203 nok++;
204 if ( xebK >= 0 ) {
[326]205 xer = mNT->GetCell(i, xebK);
[165]206 g3->DrawLine3D(xp-xer, yp, zp, xp+xer, yp, zp);
207 }
208 if ( yebK >= 0 ) {
[326]209 yer = mNT->GetCell(i, yebK);
[165]210 g3->DrawLine3D(xp, yp-yer, zp, xp, yp+yer, zp);
211 }
212 if ( zebK >= 0 ) {
[326]213 zer = mNT->GetCell(i, zebK);
[165]214 g3->DrawLine3D(xp, yp, zp-zer, xp, yp, zp+zer);
215 }
[486]216 if (wK >= 0) { // Taille de marker en fonction du poids
217 wp = mNT->GetCell(i, wK);
218 sz = (int)((wp-wMin)/dw);
219 if (sz < 0) sz = 0;
220 if (sz > nWbins) sz = nWbins;
221 sz += msz;
222 if (sz < 2) g->SelMarker(sz, PI_DotMarker);
223 else g->SelMarker(sz, mrk);
224 }
225 // Trace du marker
226 if ((wK >= 0)||(lK < 0)||(mMrk != PI_NotDefMarker)) g3->DrawMarker3D(xp, yp, zp);
227 // Trace eventuel du label
228 if (lK >= 0) g3->DrawString3D(xp, yp, zp, mNT->GetCelltoString(i, lK).c_str());
[165]229}
230
231return;
232}
233
Note: See TracBrowser for help on using the repository browser.