BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
BesTView.cxx
Go to the documentation of this file.
1// @(#)root/base:$Name: BesVisLib-00-04-04 $:$Id: BesTView.cxx,v 1.3 2014/04/18 02:15:14 maqm Exp $
2// Author: Rene Brun, Nenad Buncic, Evgueni Tcherniaev, Olivier Couet 18/08/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12//#include "TVirtualUtil3D.h"
13#include "TVirtualPad.h"
14#include "BesVisLib/BesTView.h"
15#include "TAxis3D.h"
16#include "TPolyLine3D.h"
17#include "TVirtualX.h"
18#include "TROOT.h"
19#include "TClass.h"
20#include "TList.h"
21//#include "TFile.h"
22#include "TPluginManager.h"
23#include "TMath.h"
24
25// Remove when TViewer3DPad fix in ExecuteRotateView() is removed
26#include "TVirtualViewer3D.h"
27
29
30//const Int_t kPerspective = BIT(14);
31
32const Int_t kCARTESIAN = 1;
33const Int_t kPOLAR = 2;
34const Double_t kRad = 3.14159265358979323846/180.0;
35
36
37
38//____________________________________________________________________________
40{
41 // Default constructor
42
43 fSystem = 1;
44 fOutline = 0;
45 fDefaultOutline = kFALSE;
46 fAutoRange = kFALSE;
47 fChanged = kFALSE;
48 SetBit(kMustCleanup);
49 for (Int_t i=0;i<3;i++) {
50 fX1[i] = fX2[i] = fY1[i] = fY2[i] = fZ1[i] = fZ2[i] = 0;
51 }
52}
53
54//____________________________________________________________________________
56 :TView(tv),
57 fLatitude(tv.fLatitude),
58 fLongitude(tv.fLongitude),
59 fPsi(tv.fPsi),
60 fDview(tv.fDview),
61 fDproj(tv.fDproj),
62 fUpix(tv.fUpix),
63 fVpix(tv.fVpix),
64 fSystem(tv.fSystem),
65 fOutline(tv.fOutline),
66 fDefaultOutline(tv.fDefaultOutline),
67 fAutoRange(tv.fAutoRange),
68 fChanged(tv.fChanged)
69{
70 // Copy constructor.
71
72 for (Int_t i=0; i<16; i++) {
73 fTN[i]=tv.fTN[i];
74 fTB[i]=tv.fTB[i];
75 fTnorm[i]=tv.fTnorm[i];
76 fTback[i]=tv.fTback[i];
77 }
78 for(Int_t i=0; i<3; i++) {
79 fRmax[i]=tv.fRmax[i];
80 fRmin[i]=tv.fRmin[i];
81 fX1[i]=tv.fX1[i];
82 fX2[i]=tv.fX2[i];
83 fY1[i]=tv.fY1[i];
84 fY2[i]=tv.fY2[i];
85 fZ1[i]=tv.fZ1[i];
86 fZ2[i]=tv.fZ2[i];
87 }
88 for(Int_t i=0; i<4; i++)
89 fUVcoord[i]=tv.fUVcoord[i];
90}
91
92//____________________________________________________________________________
94{
95 // Assignment operator.
96
97 if (this!=&tv) {
98 TView::operator=(tv);
101 fPsi=tv.fPsi;
102 fDview=tv.fDview;
103 fDproj=tv.fDproj;
104 fUpix=tv.fUpix;
105 fVpix=tv.fVpix;
106 fSystem=tv.fSystem;
111 for(Int_t i=0; i<16; i++) {
112 fTN[i]=tv.fTN[i];
113 fTB[i]=tv.fTB[i];
114 fTnorm[i]=tv.fTnorm[i];
115 fTback[i]=tv.fTback[i];
116 }
117 for(Int_t i=0; i<3; i++) {
118 fRmax[i]=tv.fRmax[i];
119 fRmin[i]=tv.fRmin[i];
120 fX1[i]=tv.fX1[i];
121 fX2[i]=tv.fX2[i];
122 fY1[i]=tv.fY1[i];
123 fY2[i]=tv.fY2[i];
124 fZ1[i]=tv.fZ1[i];
125 fZ2[i]=tv.fZ2[i];
126 }
127 for(Int_t i=0; i<4; i++)
128 fUVcoord[i]=tv.fUVcoord[i];
129 }
130 return *this;
131}
132
133//____________________________________________________________________________
135{
136//*-*-*-*-*-*-*-*-*-*-*-*-*-*View default destructor*-*-*-*-*-*-*-*-*-*-*-*-*
137//*-* =======================
138
139 if (fOutline) fOutline->Delete();
140 delete fOutline;
141 fOutline = 0;
142}
143
144//____________________________________________________________________________
146{
147//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*View constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
148//*-* ================
149//*-* Creates a 3-D view in the current pad
150//*-* By default pad range in 3-D view is (-1,-1,1,1), so ...
151//*-*
152//*-* Before drawing a 3-D object in a pad, a 3-D view must be created.
153//*-* Note that a view is automatically created when drawing legos or surfaces.
154//*-*
155//*-* The coordinate system is selected via system:
156//*-* system = 1 Cartesian
157//*-* system = 2 Polar
158//*-* system = 3 Cylindrical
159//*-* system = 4 Spherical
160//*-* system = 5 PseudoRapidity/Phi
161//*-* system = 11 Perspective view
162//*-*
163//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
164 Int_t irep;
165
166 //create the 3d utility manager (a plugin)
167 if (!gROOT->GetListOfSpecials()->FindObject("R__TVirtualUtil3D")) {
168 TPluginHandler *h;
169 if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualUtil3D"))) {
170 if (h->LoadPlugin() == -1)
171 return;
172 h->ExecPlugin(0);
173 }
174 }
175
176 SetBit(kMustCleanup);
177
178 fSystem = system;
179 fOutline = 0;
180 fDefaultOutline = kFALSE;
181 fAutoRange = kFALSE;
182 fChanged = kFALSE;
183
184 if (system == kCARTESIAN || system == kPOLAR || system == 11) fPsi = 0;
185 else fPsi = 90;
186
187 //By default pad range in 3-D view is (-1,-1,1,1), so ...
188 if (gPad) {
189 gPad->Range(-1, -1, 1, 1);
190
191 Int_t i;
192 for (i = 0; i < 3; fRmin[i] = 0, fRmax[i] = 1, i++);
193 for (i=0;i<3;i++) {
194 fX1[i] = fX2[i] = fY1[i] = fY2[i] = fZ1[i] = fZ2[i] = 0;
195 }
196
197 fLongitude = -90 - gPad->GetPhi();
198 fLatitude = 90 - gPad->GetTheta();
200
201 gPad->SetView(this);
202 }
203 if (system == 11) SetPerspective();
204}
205
206
207//____________________________________________________________________________
208BesTView::BesTView(const Float_t *rmin, const Float_t *rmax, Int_t system)
209{
210//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*View constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
211//*-* ================
212//*-* Creates a 3-D view in the current pad
213//*-* rmin[3], rmax[3] are the limits of the object depending on
214//*-* the selected coordinate system
215//*-*
216//*-* Before drawing a 3-D object in a pad, a 3-D view must be created.
217//*-* Note that a view is automatically created when drawing legos or surfaces.
218//*-*
219//*-* The coordinate system is selected via system:
220//*-* system = 1 Cartesian
221//*-* system = 2 Polar
222//*-* system = 3 Cylindrical
223//*-* system = 4 Spherical
224//*-* system = 5 PseudoRapidity/Phi
225//*-*
226//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
227
228 Int_t irep;
229
230 //create the 3d utility manager (a plugin)
231 if (!gROOT->GetListOfSpecials()->FindObject("R__TVirtualUtil3D")) {
232 TPluginHandler *h;
233 if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualUtil3D"))) {
234 if (h->LoadPlugin() == -1)
235 return;
236 h->ExecPlugin(0);
237 }
238 }
239
240 SetBit(kMustCleanup);
241
242 fSystem = system;
243 fOutline = 0;
244 fDefaultOutline = kFALSE;
245 fChanged = kFALSE;
246
247 if (system == kCARTESIAN || system == kPOLAR || system == 11) fPsi = 0;
248 else fPsi = 90;
249
250 //By default pad range in 3-D view is (-1,-1,1,1), so ...
251 gPad->Range(-1, -1, 1, 1);
252 fAutoRange = kFALSE;
253
254 Int_t i;
255 for (i = 0; i < 3; fRmin[i] = rmin[i], fRmax[i] = rmax[i], i++);
256 for (i=0;i<3;i++) {
257 fX1[i] = fX2[i] = fY1[i] = fY2[i] = fZ1[i] = fZ2[i] = 0;
258 }
259
260 fLongitude = -90 - gPad->GetPhi();
261 fLatitude = 90 - gPad->GetTheta();
263
264 if (gPad) gPad->SetView(this);
265 if (system == 11) SetPerspective();
266}
267
268
269//____________________________________________________________________________
270BesTView::BesTView(const Double_t *rmin, const Double_t *rmax, Int_t system)
271{
272//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*View constructor*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
273//*-* ================
274//*-* Creates a 3-D view in the current pad
275//*-* rmin[3], rmax[3] are the limits of the object depending on
276//*-* the selected coordinate system
277//*-*
278//*-* Before drawing a 3-D object in a pad, a 3-D view must be created.
279//*-* Note that a view is automatically created when drawing legos or surfaces.
280//*-*
281//*-* The coordinate system is selected via system:
282//*-* system = 1 Cartesian
283//*-* system = 2 Polar
284//*-* system = 3 Cylindrical
285//*-* system = 4 Spherical
286//*-* system = 5 PseudoRapidity/Phi
287//*-*
288//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
289
290 Int_t irep;
291
292 //create the 3d utility manager (a plugin)
293 if (!gROOT->GetListOfSpecials()->FindObject("R__TVirtualUtil3D")) {
294 TPluginHandler *h;
295 if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualUtil3D"))) {
296 if (h->LoadPlugin() == -1)
297 return;
298 h->ExecPlugin(0);
299 }
300 }
301
302 SetBit(kMustCleanup);
303
304 fSystem = system;
305 fOutline = 0;
306 fDefaultOutline = kFALSE;
307 fChanged = kFALSE;
308
309 if (system == kCARTESIAN || system == kPOLAR || system == 11) fPsi = 0;
310 else fPsi = 90;
311
312 //By default pad range in 3-D view is (-1,-1,1,1), so ...
313 gPad->Range(-1, -1, 1, 1);
314 fAutoRange = kFALSE;
315
316 Int_t i;
317 for (i = 0; i < 3; fRmin[i] = rmin[i], fRmax[i] = rmax[i], i++);
318 for (i=0;i<3;i++) {
319 fX1[i] = fX2[i] = fY1[i] = fY2[i] = fZ1[i] = fZ2[i] = 0;
320 }
321
322 fLongitude = -90 - gPad->GetPhi();
323 fLatitude = 90 - gPad->GetTheta();
325
326 if (gPad) gPad->SetView(this);
327 if (system == 11) SetPerspective();
328}
329
330
331//______________________________________________________________________________
332void BesTView::AxisVertex(Double_t ang, Double_t *av, Int_t &ix1, Int_t &ix2, Int_t &iy1, Int_t &iy2, Int_t &iz1, Int_t &iz2)
333{
334//*-*-*-*-*-*-*-*-*-*-*-*-*Define axis vertices*-*-*-*-*-*-*-*-*-*-*-*-*-*
335//*-* ===================== *
336//*-* *
337//*-* Input ANG - angle between X and Y axis *
338//*-* *
339//*-* Output: AV(3,8) - axis vertixes *
340//*-* IX1 - 1st point of X-axis *
341//*-* IX2 - 2nd point of X-axis *
342//*-* IY1 - 1st point of Y-axis *
343//*-* IY2 - 2nd point of Y-axis *
344//*-* IZ1 - 1st point of Z-axis *
345//*-* IZ2 - 2nd point of Z-axis *
346//*-* *
347//*-* 8 6 *
348//*-* / \ /|\ *
349//*-* 5 / \ 7 5 / | \ 7 *
350//*-* |\ /| | | | *
351//*-* THETA < 90 | \6/ | THETA > 90 | /2\ | *
352//*-* (Top view) | | | (Bottom view) |/ \| *
353//*-* 1 \ | /3 1 \ /3 *
354//*-* \|/ \ / *
355//*-* 2 4 *
356//*-* *
357//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
358 /* Local variables */
359 Double_t cosa, sina;
360 Int_t i, k;
361 Double_t p[8] /* was [2][4] */;
362 Int_t i1, i2, i3, i4, ix, iy;
363 ix = 0;
364
365 /* Parameter adjustments */
366 av -= 4;
367
368 sina = TMath::Sin(ang*kRad);
369 cosa = TMath::Cos(ang*kRad);
370 p[0] = fRmin[0];
371 p[1] = fRmin[1];
372 p[2] = fRmax[0];
373 p[3] = fRmin[1];
374 p[4] = fRmax[0];
375 p[5] = fRmax[1];
376 p[6] = fRmin[0];
377 p[7] = fRmax[1];
378//*-*- F I N D T H E M O S T L E F T P O I N T */
379 i1 = 1;
380 if (fTN[0] < 0) i1 = 2;
381 if (fTN[0]*cosa + fTN[1]*sina < 0) i1 = 5 - i1;
382
383//*-*- S E T O T H E R P O I N T S */
384 i2 = i1 % 4 + 1;
385 i3 = i2 % 4 + 1;
386 i4 = i3 % 4 + 1;
387
388//*-*- S E T A X I S V E R T I X E S */
389
390 av[4] = p[(i1 << 1) - 2];
391 av[5] = p[(i1 << 1) - 1];
392 av[7] = p[(i2 << 1) - 2];
393 av[8] = p[(i2 << 1) - 1];
394 av[10] = p[(i3 << 1) - 2];
395 av[11] = p[(i3 << 1) - 1];
396 av[13] = p[(i4 << 1) - 2];
397 av[14] = p[(i4 << 1) - 1];
398 for (i = 1; i <= 4; ++i) {
399 av[i*3 + 3] = fRmin[2];
400 av[i*3 + 13] = av[i*3 + 1];
401 av[i*3 + 14] = av[i*3 + 2];
402 av[i*3 + 15] = fRmax[2];
403 }
404
405//*-*- S E T A X I S
406
407 if (av[4] == av[7]) ix = 2;
408 if (av[5] == av[8]) ix = 1;
409 iy = 3 - ix;
410//*-*- X - A X I S
411 ix1 = ix;
412 if (av[ix*3 + 1] > av[(ix + 1)*3 + 1]) ix1 = ix + 1;
413 ix2 = (ix << 1) - ix1 + 1;
414//*-*- Y - A X I S
415 iy1 = iy;
416 if (av[iy*3 + 2] > av[(iy + 1)*3 + 2]) iy1 = iy + 1;
417 iy2 = (iy << 1) - iy1 + 1;
418//*-*- Z - A X I S
419 iz1 = 1;
420 iz2 = 5;
421
422 if (fTN[10] >= 0) return;
423 k = (ix1 - 1)*3 + ix2;
424 if (k%2) return;
425 if (k == 2) {
426 ix1 = 4;
427 ix2 = 3;
428 }
429 if (k == 4) {
430 ix1 = 3;
431 ix2 = 4;
432 }
433 if (k == 6) {
434 ix1 = 1;
435 ix2 = 4;
436 }
437 if (k == 8) {
438 ix1 = 4;
439 ix2 = 1;
440 }
441
442 k = (iy1 - 1)*3 + iy2;
443 if (k%2) return;
444 if (k == 2) {
445 iy1 = 4;
446 iy2 = 3;
447 return;
448 }
449 if (k == 4) {
450 iy1 = 3;
451 iy2 = 4;
452 return;
453 }
454 if (k == 6) {
455 iy1 = 1;
456 iy2 = 4;
457 return;
458 }
459 if (k == 8) {
460 iy1 = 4;
461 iy2 = 1;
462 }
463}
464
465//______________________________________________________________________________
467{
468//*-*-*-*-*-*-*-*-*-*-*-*-*-*Define perspective view *-*-*-*-*-*-*-*-*-*-*
469//*-* ================================================ *
470//*-* *
471//*-* Compute transformation matrix from world coordinates *
472//*-* to normalised coordinates (-1 to +1) *
473// Input :
474// theta, phi - spherical angles giving the direction of projection
475// psi - screen rotation angle
476// cov[3] - center of view
477// dview - distance from COV to COP (center of projection)
478// umin, umax, vmin, vmax - view window in projection plane
479// dproj - distance from COP to projection plane
480// bcut, fcut - backward/forward range w.r.t projection plane (fcut<=0)
481// Output :
482// nper[16] - normalizing transformation
483// compute tr+rot to get COV in origin, view vector parallel to -Z axis, up vector
484// parallel to Y.
485// ^Yv UP ^ proj. plane
486// | | /|
487// | | / |
488// | dproj / x--- center of window (COW)
489// COV |----------|--x--|------------> Zv
490// / | VRP'z
491// / ---> | /
492// / VPN |/
493// Xv
494//
495// 1 - translate COP to origin of MARS : Tper = T(-copx, -copy, -copz)
496// 2 - rotate VPN : R = Rz(-psi)*Rx(-theta)*Rz(-phi) (inverse Euler)
497// 3 - left-handed screen reference to right-handed one of MARS : Trl
498//
499// T12 = Tper*R*Trl
500//
501 Double_t t12[16];
502 Double_t cov[3];
503 Int_t i;
504 for (i=0; i<3; i++) cov[i] = 0.5*(fRmax[i]+fRmin[i]);
505
506 Double_t c1 = TMath::Cos(fPsi*kRad);
507 Double_t s1 = TMath::Sin(fPsi*kRad);
508 Double_t c2 = TMath::Cos(fLatitude*kRad);
509 Double_t s2 = TMath::Sin(fLatitude*kRad);
510 Double_t s3 = TMath::Cos(fLongitude*kRad);
511 Double_t c3 = -TMath::Sin(fLongitude*kRad);
512
513 t12[0] = c1*c3 - s1*c2*s3;
514 t12[4] = c1*s3 + s1*c2*c3;
515 t12[8] = s1*s2;
516 t12[3] = 0;
517
518 t12[1] = -s1*c3 - c1*c2*s3;
519 t12[5] = -s1*s3 + c1*c2*c3;
520 t12[9] = c1*s2;
521 t12[7] = 0;
522
523 t12[2] = s2*s3;
524 t12[6] = -s2*c3;
525 t12[10] = c2; // contains Trl
526 t12[11] = 0;
527
528 // translate with -COP (before rotation):
529 t12[12] = -(cov[0]*t12[0]+cov[1]*t12[4]+cov[2]*t12[8]);
530 t12[13] = -(cov[0]*t12[1]+cov[1]*t12[5]+cov[2]*t12[9]);
531 t12[14] = -(cov[0]*t12[2]+cov[1]*t12[6]+cov[2]*t12[10]);
532 t12[15] = 1;
533
534 // translate with (0, 0, -dview) after rotation
535
536 t12[14] -= fDview;
537
538 // reflection on Z :
539 t12[2] *= -1;
540 t12[6] *= -1;
541 t12[10] *= -1;
542 t12[14] *= -1;
543
544 // Now we shear the center of window from (0.5*(umin+umax), 0.5*(vmin+vmax), dproj)
545 // to (0, 0, dproj)
546
547 Double_t a2 = -fUVcoord[0]/fDproj; // shear coef. on x
548 Double_t b2 = -fUVcoord[1]/fDproj; // shear coef. on y
549
550 // | 1 0 0 0 |
551 // SHz(a2,b2) = | 0 1 0 0 |
552 // | a2 b2 1 0 |
553 // | 0 0 0 1 |
554
555 fTnorm[0] = t12[0] + a2*t12[2];
556 fTnorm[1] = t12[1] + b2*t12[2];
557 fTnorm[2] = t12[2];
558 fTnorm[3] = 0;
559
560 fTnorm[4] = t12[4] + a2*t12[6];
561 fTnorm[5] = t12[5] + b2*t12[6];
562 fTnorm[6] = t12[6];
563 fTnorm[7] = 0;
564
565 fTnorm[8] = t12[8] + a2*t12[10];
566 fTnorm[9] = t12[9] + b2*t12[10];
567 fTnorm[10] = t12[10];
568 fTnorm[11] = 0;
569
570 fTnorm[12] = t12[12] + a2*t12[14];
571 fTnorm[13] = t12[13] + b2*t12[14];
572 fTnorm[14] = t12[14];
573 fTnorm[15] = 1;
574
575 // Scale so that the view volume becomes the canonical one
576 //
577 // Sper = (2/(umax-umin), 2/(vmax-vmin), 1/dproj
578 //
579 Double_t sz = 1./fDproj;
580 Double_t sx = 1./fUVcoord[2];
581 Double_t sy = 1./fUVcoord[3];
582
583 fTnorm[0] *= sx;
584 fTnorm[4] *= sx;
585 fTnorm[8] *= sx;
586 fTnorm[1] *= sy;
587 fTnorm[5] *= sy;
588 fTnorm[9] *= sy;
589 fTnorm[2] *= sz;
590 fTnorm[6] *= sz;
591 fTnorm[10] *= sz;
592 fTnorm[12] *= sx;
593 fTnorm[13] *= sy;
594 fTnorm[14] *= sz;
595}
596
597
598
599//______________________________________________________________________________
600void BesTView::DefineViewDirection(const Double_t *s, const Double_t *c,
601 Double_t cosphi, Double_t sinphi,
602 Double_t costhe, Double_t sinthe,
603 Double_t cospsi, Double_t sinpsi,
604 Double_t *tnorm, Double_t *tback)
605{
606//*-*-*-*-*-*-*-*-*Define view direction (in spherical coordinates)-*-*-*-*
607//*-* ================================================ *
608//*-* *
609//*-* Compute transformation matrix from world coordinates *
610//*-* to normalised coordinates (-1 to +1) *
611//*-* *
612//*-* Input: S(3) - scale factors *
613//*-* C(3) - centre of scope *
614//*-* COSPHI - longitude COS *
615//*-* SINPHI - longitude SIN *
616//*-* COSTHE - latitude COS (angle between +Z and view direc.) *
617//*-* SINTHE - latitude SIN *
618//*-* COSPSI - screen plane rotation angle COS *
619//*-* SINPSI - screen plane rotation angle SIN *
620//*-* *
621//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
622
623 if (IsPerspective()) {
625 return;
626 }
627 Int_t i, k;
628 Double_t tran[16] /* was [4][4] */, rota[16] /* was [4][4] */;
629 Double_t c1, c2, c3, s1, s2, s3, scalex, scaley, scalez;
630
631 /* Parameter adjustments */
632 tback -= 5;
633 tnorm -= 5;
634
635 scalex = s[0];
636 scaley = s[1];
637 scalez = s[2];
638
639//*-*- S E T T R A N S L A T I O N M A T R I X
640
641 tran[0] = 1 / scalex;
642 tran[1] = 0;
643 tran[2] = 0;
644 tran[3] = -c[0] / scalex;
645
646 tran[4] = 0;
647 tran[5] = 1 / scaley;
648 tran[6] = 0;
649 tran[7] = -c[1] / scaley;
650
651 tran[8] = 0;
652 tran[9] = 0;
653 tran[10] = 1 / scalez;
654 tran[11] = -c[2] / scalez;
655
656 tran[12] = 0;
657 tran[13] = 0;
658 tran[14] = 0;
659 tran[15] = 1;
660
661//*-*- S E T R O T A T I O N M A T R I X
662
663// ( C(PSI) S(PSI) 0) (1 0 0 ) ( C(90+PHI) S(90+PHI) 0)
664// (-S(PSI) C(PSI) 0) * (0 C(THETA) S(THETA)) * (-S(90+PHI) C(90+PHI) 0)
665// ( 0 0 1) (0 -S(THETA) C(THETA)) ( 0 0 1)
666
667 c1 = cospsi;
668 s1 = sinpsi;
669 c2 = costhe;
670 s2 = sinthe;
671 c3 = -sinphi;
672 s3 = cosphi;
673
674 rota[0] = c1*c3 - s1*c2*s3;
675 rota[1] = c1*s3 + s1*c2*c3;
676 rota[2] = s1*s2;
677 rota[3] = 0;
678
679 rota[4] = -s1*c3 - c1* c2*s3;
680 rota[5] = -s1*s3 + c1* c2*c3;
681 rota[6] = c1*s2;
682 rota[7] = 0;
683
684 rota[8] = s2*s3;
685 rota[9] = -s2*c3;
686 rota[10] = c2;
687 rota[11] = 0;
688
689 rota[12] = 0;
690 rota[13] = 0;
691 rota[14] = 0;
692 rota[15] = 1;
693
694//*-*- F I N D T R A N S F O R M A T I O N M A T R I X
695
696 for (i = 1; i <= 3; ++i) {
697 for (k = 1; k <= 4; ++k) {
698 tnorm[k + (i << 2)] = rota[(i << 2) - 4]*tran[k - 1] + rota[(i
699 << 2) - 3]*tran[k + 3] + rota[(i << 2) - 2]*tran[k +7]
700 + rota[(i << 2) - 1]*tran[k + 11];
701 }
702 }
703
704//*-*- S E T B A C K T R A N S L A T I O N M A T R I X
705
706 tran[0] = scalex;
707 tran[3] = c[0];
708
709 tran[5] = scaley;
710 tran[7] = c[1];
711
712 tran[10] = scalez;
713 tran[11] = c[2];
714
715//*-*- F I N D B A C K T R A N S F O R M A T I O N
716
717 for (i = 1; i <= 3; ++i) {
718 for (k = 1; k <= 4; ++k) {
719 tback[k + (i << 2)] = tran[(i << 2) - 4]*rota[(k << 2) - 4] +
720 tran[(i << 2) - 3]*rota[(k << 2) - 3] + tran[(i << 2) -2]
721 *rota[(k << 2) - 2] + tran[(i << 2) - 1]*rota[(k <<2) - 1];
722 }
723 }
724}
725
726
727//______________________________________________________________________________
728void BesTView::DrawOutlineCube(TList *outline, Double_t *rmin, Double_t *rmax)
729{
730 // Draw the outline of a cube while rotaing a 3-d object in the pad.
731
732 TPolyLine3D::DrawOutlineCube(outline,rmin,rmax);
733}
734
735
736//______________________________________________________________________________
737void BesTView::ExecuteEvent(Int_t event, Int_t px, Int_t py)
738{
739//*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*-*
740
741 ExecuteRotateView(event,px,py);
742}
743
744//______________________________________________________________________________
745void BesTView::ExecuteRotateView(Int_t event, Int_t px, Int_t py)
746{
747//*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*-*-*
748//*-* ========================================= *
749//*-* This member function is called when a object is clicked with the locator *
750//*-* *
751//*-* If Left button clicked in the object area, while the button is kept down *
752//*-* the cube representing the surrounding frame for the corresponding *
753//*-* new latitude and longitude position is drawn. *
754//*-* *
755//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
756 static Int_t system, framewasdrawn;
757 static Double_t xrange, yrange, xmin, ymin, longitude1, latitude1, longitude2, latitude2;
758 static Double_t newlatitude, newlongitude, oldlatitude, oldlongitude;
759 Double_t dlatitude, dlongitude, x, y;
760 Int_t irep = 0;
761 Double_t psideg;
762
763 // all coordinate transformation are from absolute to relative
764
765 if (!gPad->IsEditable()) return;
766 gPad->AbsCoordinates(kTRUE);
767
768 switch (event) {
769
770 case kKeyPress :
771 fChanged = kTRUE;
772 MoveViewCommand(Char_t(px), py);
773 break;
774
775 case kMouseMotion:
776 gPad->SetCursor(kRotate);
777 break;
778
779 case kButton1Down:
780
781 // remember position of the cube
782 xmin = gPad->GetX1();
783 ymin = gPad->GetY1();
784 xrange = gPad->GetX2() - xmin;
785 yrange = gPad->GetY2() - ymin;
786 x = gPad->PixeltoX(px);
787 y = gPad->PixeltoY(py);
788 system = GetSystem();
789 framewasdrawn = 0;
790 if (system == kCARTESIAN || system == kPOLAR || IsPerspective()) {
791 longitude1 = 180*(x-xmin)/xrange;
792 latitude1 = 90*(y-ymin)/yrange;
793 } else {
794 latitude1 = 90*(x-xmin)/xrange;
795 longitude1 = 180*(y-ymin)/yrange;
796 }
797 newlongitude = oldlongitude = -90 - gPad->GetPhi();
798 newlatitude = oldlatitude = 90 - gPad->GetTheta();
799 psideg = GetPsi();
800
801 // if outline isn't set, make it look like a cube
802 if(!fOutline)
804 break;
805
806 case kButton1Motion:
807 {
808 // draw the surrounding frame for the current mouse position
809 // first: Erase old frame
810 fChanged = kTRUE;
811 if (framewasdrawn) fOutline->Paint();
812 framewasdrawn = 1;
813 x = gPad->PixeltoX(px);
814 y = gPad->PixeltoY(py);
815 if (system == kCARTESIAN || system == kPOLAR || IsPerspective()) {
816 longitude2 = 180*(x-xmin)/xrange;
817 latitude2 = 90*(y-ymin)/yrange;
818 } else {
819 latitude2 = 90*(x-xmin)/xrange;
820 longitude2 = 180*(y-ymin)/yrange;
821 }
822 dlongitude = longitude2 - longitude1;
823 dlatitude = latitude2 - latitude1;
824 newlatitude = oldlatitude + dlatitude;
825 newlongitude = oldlongitude - dlongitude;
826 psideg = GetPsi();
827 ResetView(newlongitude, newlatitude, psideg, irep);
828 fOutline->Paint();
829
830 break;
831 }
832 case kButton1Up:
833 if (gROOT->IsEscaped()) {
834 gROOT->SetEscape(kFALSE);
835 break;
836 }
837
838 // Temporary fix for 2D drawing problems on pad. fOutline contains
839 // a TPolyLine3D object for the rotation box. This will be painted
840 // through a newly created TViewer3DPad instance, which is left
841 // behind on pad. This remaining creates 2D drawing problems.
842 //
843 // This is a TEMPORARY fix - will be removed when proper multiple viewers
844 // on pad problems are resolved.
845 if (gPad) {
846 TVirtualViewer3D *viewer = gPad->GetViewer3D();
847 if (viewer && !strcmp(viewer->IsA()->GetName(),"TView3Der3DPad")) {
848 gPad->ReleaseViewer3D();
849 delete viewer;
850 }
851 }
852 // End fix
853
854 // Recompute new view matrix and redraw
855 psideg = GetPsi();
856 SetView(newlongitude, newlatitude, psideg, irep);
857 gPad->SetPhi(-90-newlongitude);
858 gPad->SetTheta(90-newlatitude);
859 gPad->Modified(kTRUE);
860
861 // Set line color, style and width
862 gVirtualX->SetLineColor(-1);
863 gVirtualX->SetLineStyle(-1);
864 gVirtualX->SetLineWidth(-1);
865 break;
866 }
867
868 // set back to default transformation mode
869 gPad->AbsCoordinates(kFALSE);
870}
871
872
873//______________________________________________________________________________
874void BesTView::FindNormal(Double_t x, Double_t y, Double_t z, Double_t &zn)
875{
876//*-*-*-*-*-*-*Find Z component of NORMAL in normalized coordinates-*-*-*-*
877//*-* ==================================================== *
878//*-* *
879//*-* Input: X - X-component of NORMAL *
880//*-* Y - Y-component of NORMAL *
881//*-* Z - Z-component of NORMAL *
882//*-* *
883//*-* Output: ZN - Z-component of NORMAL in normalized coordinates *
884//*-* *
885//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
886
887 zn = x*(fTN[1] * fTN[6] - fTN[2] * fTN[5]) + y*(fTN[2] * fTN[4] -
888 fTN[0] * fTN[6]) + z*(fTN[0] * fTN[5] - fTN[1] * fTN[4]);
889}
890
891//______________________________________________________________________________
892void BesTView::FindPhiSectors(Int_t iopt, Int_t &kphi, Double_t *aphi, Int_t &iphi1, Int_t &iphi2)
893{
894//*-*-*-*-*-*-*-*-*-*-*-*-*Find critical PHI sectors*-*-*-*-*-*-*-*-*-*-*-*
895//*-* ========================= *
896//*-* *
897//*-* Input: IOPT - options: 1 - from BACK to FRONT 'BF' *
898//*-* 2 - from FRONT to BACK 'FB' *
899//*-* KPHI - number of phi sectors *
900//*-* APHI(*) - PHI separators (modified internally) *
901//*-* *
902//*-* Output: IPHI1 - initial sector *
903//*-* IPHI2 - final sector *
904//*-* *
905//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
906
907 Int_t iphi[2], i, k;
908 Double_t dphi;
909 Double_t x1, x2, z1, z2, phi1, phi2;
910
911 /* Parameter adjustments */
912 --aphi;
913
914 if (aphi[kphi + 1] == aphi[1]) aphi[kphi + 1] += 360;
915 dphi = TMath::Abs(aphi[kphi + 1] - aphi[1]);
916 if (dphi != 360) {
917 aphi[kphi + 2] = (aphi[1] + aphi[kphi + 1]) / (float)2. + 180;
918 aphi[kphi + 3] = aphi[1] + 360;
919 kphi += 2;
920 }
921
922 //*-*- F I N D C R I T I C A L S E C T O R S
923
924 k = 0;
925 for (i = 1; i <= kphi; ++i) {
926 phi1 = kRad*aphi[i];
927 phi2 = kRad*aphi[i + 1];
928 x1 = fTN[0]*TMath::Cos(phi1) + fTN[1]*TMath::Sin(phi1);
929 x2 = fTN[0]*TMath::Cos(phi2) + fTN[1]*TMath::Sin(phi2);
930 if (x1 >= 0 && x2 > 0) continue;
931 if (x1 <= 0 && x2 < 0) continue;
932 ++k;
933 if (k == 3) break;
934 iphi[k - 1] = i;
935 }
936 if (k != 2) {
937 Error("FindPhiSectors", "something strange: num. of critical sector not equal 2");
938 iphi1 = 1;
939 iphi2 = 2;
940 return;
941 }
942
943 //*-*- F I N D O R D E R O F C R I T I C A L S E C T O R S
944
945 phi1 = kRad*(aphi[iphi[0]] + aphi[iphi[0] + 1]) / (float)2.;
946 phi2 = kRad*(aphi[iphi[1]] + aphi[iphi[1] + 1]) / (float)2.;
947 z1 = fTN[8]*TMath::Cos(phi1) + fTN[9]*TMath::Sin(phi1);
948 z2 = fTN[8]*TMath::Cos(phi2) + fTN[9]*TMath::Sin(phi2);
949 if ((z1 <= z2 && iopt == 1) || (z1 > z2 && iopt == 2)) {
950 iphi1 = iphi[0];
951 iphi2 = iphi[1];
952 } else {
953 iphi1 = iphi[1];
954 iphi2 = iphi[0];
955 }
956}
957
958//______________________________________________________________________________
959void BesTView::FindThetaSectors(Int_t iopt, Double_t phi, Int_t &kth, Double_t *ath, Int_t &ith1, Int_t &ith2)
960{
961//*-*-*-*-*-*-*-Find critical THETA sectors for given PHI sector*-*-*-*-*-*
962//*-* ================================================ *
963//*-* *
964//*-* Input: IOPT - options: 1 - from BACK to FRONT 'BF' *
965//*-* 2 - from FRONT to BACK 'FB' *
966//*-* PHI - PHI sector *
967//*-* KTH - number of THETA sectors *
968//*-* ATH(*) - THETA separators (modified internally) *
969//*-* *
970//*-* Output: ITH1 - initial sector *
971//*-* ITH2 - final sector *
972//*-* *
973//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
974
975 Int_t i, k, ith[2];
976 Double_t z1, z2, cosphi, sinphi, tncons, th1, th2, dth;
977
978 /* Parameter adjustments */
979 --ath;
980
981 /* Function Body */
982 dth = TMath::Abs(ath[kth + 1] - ath[1]);
983 if (dth != 360) {
984 ath[kth + 2] = 0.5*(ath[1] + ath[kth + 1]) + 180;
985 ath[kth + 3] = ath[1] + 360;
986 kth += 2;
987 }
988
989 //*-*- F I N D C R I T I C A L S E C T O R S
990
991 cosphi = TMath::Cos(phi*kRad);
992 sinphi = TMath::Sin(phi*kRad);
993 k = 0;
994 for (i = 1; i <= kth; ++i) {
995 th1 = kRad*ath[i];
996 th2 = kRad*ath[i + 1];
997 FindNormal(TMath::Cos(th1)*cosphi, TMath::Cos(th1)*sinphi, -TMath::Sin(th1), z1);
998 FindNormal(TMath::Cos(th2)*cosphi, TMath::Cos(th2)*sinphi, -TMath::Sin(th2), z2);
999 if (z1 >= 0 && z2 > 0) continue;
1000 if (z1 <= 0 && z2 < 0) continue;
1001 ++k;
1002 if (k == 3) break;
1003 ith[k - 1] = i;
1004 }
1005 if (k != 2) {
1006 Error("FindThetaSectors", "Something strange: num. of critical sectors not equal 2");
1007 ith1 = 1;
1008 ith2 = 2;
1009 return;
1010 }
1011
1012 //*-*- F I N D O R D E R O F C R I T I C A L S E C T O R S
1013
1014 tncons = fTN[8]*TMath::Cos(phi*kRad) + fTN[9]*TMath::Sin(phi*kRad);
1015 th1 = kRad*(ath[ith[0]] + ath[ith[0] + 1]) / (float)2.;
1016 th2 = kRad*(ath[ith[1]] + ath[ith[1] + 1]) / (float)2.;
1017 z1 = tncons*TMath::Sin(th1) + fTN[10]*TMath::Cos(th1);
1018 z2 = tncons*TMath::Sin(th2) + fTN[10]*TMath::Cos(th2);
1019 if ((z1 <= z2 && iopt == 1) || (z1 > z2 && iopt == 2)) {
1020 ith1 = ith[0];
1021 ith2 = ith[1];
1022 } else {
1023 ith1 = ith[1];
1024 ith2 = ith[0];
1025 }
1026}
1027
1028
1029//______________________________________________________________________________
1030void BesTView::FindScope(Double_t *scale, Double_t *center, Int_t &irep)
1031{
1032//*-*-*-*-*-*-*-*Find centre of a MIN-MAX scope and scale factors-*-*-*-*-*
1033//*-* ================================================ *
1034//*-* *
1035//*-* Output: SCALE(3) - scale factors *
1036//*-* CENTER(3) - centre *
1037//*-* IREP - reply (-1 if error in min-max) *
1038//*-* *
1039//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1040
1041 irep = 0;
1042 Double_t sqrt3 = 0.5*TMath::Sqrt(3.0);
1043
1044 for (Int_t i = 0; i < 3; i++) {
1045 if (fRmin[i] >= fRmax[i]) { irep = -1; return;}
1046 scale[i] = sqrt3*(fRmax[i] - fRmin[i]);
1047 center[i] = 0.5*(fRmax[i] + fRmin[i]);
1048 }
1049}
1050
1051//______________________________________________________________________________
1052Int_t BesTView::GetDistancetoAxis(Int_t axis, Int_t px, Int_t py, Double_t &ratio)
1053{
1054//*-*-*-*-*-*-*-*-*-*-*-*-*Return distance to axis from point px,py*-*-*-*
1055//*-* ========================================
1056//*-*
1057//*-*
1058//*-* Algorithm:
1059//*-*
1060//*-* A(x1,y1) P B(x2,y2)
1061//*-* ------------------------------------------------
1062//*-* I
1063//*-* I
1064//*-* I
1065//*-* I
1066//*-* M(x,y)
1067//*-*
1068//*-* Let us call a = distance AM A=a**2
1069//*-* b = distance BM B=b**2
1070//*-* c = distance AB C=c**2
1071//*-* d = distance PM D=d**2
1072//*-* u = distance AP U=u**2
1073//*-* v = distance BP V=v**2 c = u + v
1074//*-*
1075//*-* D = A - U
1076//*-* D = B - V = B -(c-u)**2
1077//*-* ==> u = (A -B +C)/2c
1078//*-*
1079//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1080
1081 Double_t x1,y1,x2,y2;
1082 Double_t x = px;
1083 Double_t y = py;
1084 ratio = 0;
1085
1086 if (fSystem != 1) return 9998; // only implemented for Cartesian coordinates
1087 if (axis == 1) {
1088 x1 = gPad->XtoAbsPixel(fX1[0]);
1089 y1 = gPad->YtoAbsPixel(fX1[1]);
1090 x2 = gPad->XtoAbsPixel(fX2[0]);
1091 y2 = gPad->YtoAbsPixel(fX2[1]);
1092 } else if (axis == 2) {
1093 x1 = gPad->XtoAbsPixel(fY1[0]);
1094 y1 = gPad->YtoAbsPixel(fY1[1]);
1095 x2 = gPad->XtoAbsPixel(fY2[0]);
1096 y2 = gPad->YtoAbsPixel(fY2[1]);
1097 } else {
1098 x1 = gPad->XtoAbsPixel(fZ1[0]);
1099 y1 = gPad->YtoAbsPixel(fZ1[1]);
1100 x2 = gPad->XtoAbsPixel(fZ2[0]);
1101 y2 = gPad->YtoAbsPixel(fZ2[1]);
1102 }
1103 Double_t xx1 = x - x1;
1104 Double_t xx2 = x - x2;
1105 Double_t x1x2 = x1 - x2;
1106 Double_t yy1 = y - y1;
1107 Double_t yy2 = y - y2;
1108 Double_t y1y2 = y1 - y2;
1109 Double_t a = xx1*xx1 + yy1*yy1;
1110 Double_t b = xx2*xx2 + yy2*yy2;
1111 Double_t c = x1x2*x1x2 + y1y2*y1y2;
1112 if (c <= 0) return 9999;
1113 Double_t v = TMath::Sqrt(c);
1114 Double_t u = (a - b + c)/(2*v);
1115 Double_t d = TMath::Abs(a - u*u);
1116
1117 Int_t dist = Int_t(TMath::Sqrt(d) - 0.5);
1118 ratio = u/v;
1119 return dist;
1120}
1121
1122//______________________________________________________________________________
1123Double_t BesTView::GetExtent() const
1124{
1125//*-*-*-*-*-*-*-*-*-*-*-*-*-*Get maximum view extent-*-*-*-*-*-*-*-*-*-*-*-*-*
1126//*-* =======================
1127//*-*
1128 Double_t dx = 0.5*(fRmax[0]-fRmin[0]);
1129 Double_t dy = 0.5*(fRmax[1]-fRmin[1]);
1130 Double_t dz = 0.5*(fRmax[2]-fRmin[2]);
1131 Double_t extent = TMath::Sqrt(dx*dx+dy*dy+dz*dz);
1132 return extent;
1133}
1134
1135
1136//______________________________________________________________________________
1137void BesTView::GetRange(Float_t *min, Float_t *max)
1138{
1139//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*Get Range function-*-*-*-*-*-*-*-*-*-*-*-*-*
1140//*-* ==================
1141//*-*
1142 for (Int_t i = 0; i < 3; max[i] = fRmax[i], min[i] = fRmin[i], i++);
1143}
1144
1145
1146//______________________________________________________________________________
1147void BesTView::GetRange(Double_t *min, Double_t *max)
1148{
1149 // Get Range function.
1150
1151 for (Int_t i = 0; i < 3; max[i] = fRmax[i], min[i] = fRmin[i], i++) { }
1152}
1153
1154//______________________________________________________________________________
1155void BesTView::GetWindow(Double_t &u0, Double_t &v0, Double_t &du, Double_t &dv) const
1156{
1157// Get current window extent.
1158 u0 = fUVcoord[0];
1159 v0 = fUVcoord[1];
1160 du = fUVcoord[2];
1161 dv = fUVcoord[3];
1162}
1163
1164//______________________________________________________________________________
1165Bool_t BesTView::IsClippedNDC(Double_t *p) const
1166{
1167 //*-*-*-*-*-*-*Check if point is clipped in perspective view-*-*-*-*-*-*-*-*
1168 //*-* =============================================
1169 //*-*
1170 if (TMath::Abs(p[0])>p[2]) return kTRUE;
1171 if (TMath::Abs(p[1])>p[2]) return kTRUE;
1172 return kFALSE;
1173}
1174
1175//______________________________________________________________________________
1176void BesTView::NDCtoWC(const Float_t* pn, Float_t* pw)
1177{
1178 //*-*-*-*-*-*-*Transfer point from normalized to world coordinates*-*-*-*-*
1179 //*-* =================================================== *
1180 //*-* *
1181 //*-* Input: PN(3) - point in world coordinate system *
1182 //*-* PW(3) - point in normalized coordinate system *
1183 //*-* *
1184 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1185
1186 pw[0] = fTback[0]*pn[0] + fTback[1]*pn[1] + fTback[2]*pn[2] + fTback[3];
1187 pw[1] = fTback[4]*pn[0] + fTback[5]*pn[1] + fTback[6]*pn[2] + fTback[7];
1188 pw[2] = fTback[8]*pn[0] + fTback[9]*pn[1] + fTback[10]*pn[2] + fTback[11];
1189}
1190
1191//______________________________________________________________________________
1192void BesTView::NDCtoWC(const Double_t* pn, Double_t* pw)
1193{
1194 //*-*-*-*-*-*-*Transfer point from normalized to world coordinates*-*-*-*-*
1195 //*-* =================================================== *
1196 //*-* *
1197 //*-* Input: PN(3) - point in world coordinate system *
1198 //*-* PW(3) - point in normalized coordinate system *
1199 //*-* *
1200 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1201
1202 pw[0] = fTback[0]*pn[0] + fTback[1]*pn[1] + fTback[2]*pn[2] + fTback[3];
1203 pw[1] = fTback[4]*pn[0] + fTback[5]*pn[1] + fTback[6]*pn[2] + fTback[7];
1204 pw[2] = fTback[8]*pn[0] + fTback[9]*pn[1] + fTback[10]*pn[2] + fTback[11];
1205}
1206
1207//______________________________________________________________________________
1208void BesTView::NormalWCtoNDC(const Float_t *pw, Float_t *pn)
1209{
1210 //*-*-*Transfer vector of NORMAL from word to normalized coodinates-*-*-*-*
1211 //*-* ============================================================
1212 //*-*
1213 //*-* Input: PW(3) - vector of NORMAL in word coordinate system
1214 //*-* PN(3) - vector of NORMAL in normalized coordinate system
1215 //*-*
1216 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1217
1218 Double_t x, y, z, a1, a2, a3, b1, b2, b3, c1, c2, c3;
1219
1220 x = pw[0];
1221 y = pw[1];
1222 z = pw[2];
1223 a1 = fTnorm[0];
1224 a2 = fTnorm[1];
1225 a3 = fTnorm[2];
1226 b1 = fTnorm[4];
1227 b2 = fTnorm[5];
1228 b3 = fTnorm[6];
1229 c1 = fTnorm[8];
1230 c2 = fTnorm[9];
1231 c3 = fTnorm[10];
1232 pn[0] = x*(b2*c3 - b3*c2) + y*(b3*c1 - b1*c3) + z*(b1*c2 - b2*c1);
1233 pn[1] = x*(c2*a3 - c3*a2) + y*(c3*a1 - c1*a3) + z*(c1*a2 - c2*a1);
1234 pn[2] = x*(a2*b3 - a3*b2) + y*(a3*b1 - a1*b3) + z*(a1*b2 - a2*b1);
1235}
1236
1237//______________________________________________________________________________
1238void BesTView::NormalWCtoNDC(const Double_t *pw, Double_t *pn)
1239{
1240 //*-*-*Transfer vector of NORMAL from word to normalized coodinates-*-*-*-*
1241 //*-* ============================================================
1242 //*-*
1243 //*-* Input: PW(3) - vector of NORMAL in word coordinate system
1244 //*-* PN(3) - vector of NORMAL in normalized coordinate system
1245 //*-*
1246 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1247
1248 Double_t x, y, z, a1, a2, a3, b1, b2, b3, c1, c2, c3;
1249
1250 x = pw[0];
1251 y = pw[1];
1252 z = pw[2];
1253 a1 = fTnorm[0];
1254 a2 = fTnorm[1];
1255 a3 = fTnorm[2];
1256 b1 = fTnorm[4];
1257 b2 = fTnorm[5];
1258 b3 = fTnorm[6];
1259 c1 = fTnorm[8];
1260 c2 = fTnorm[9];
1261 c3 = fTnorm[10];
1262 pn[0] = x*(b2*c3 - b3*c2) + y*(b3*c1 - b1*c3) + z*(b1*c2 - b2*c1);
1263 pn[1] = x*(c2*a3 - c3*a2) + y*(c3*a1 - c1*a3) + z*(c1*a2 - c2*a1);
1264 pn[2] = x*(a2*b3 - a3*b2) + y*(a3*b1 - a1*b3) + z*(a1*b2 - a2*b1);
1265}
1266
1267//______________________________________________________________________________
1268void BesTView::PadRange(Int_t rback)
1269{
1270 //*-*-*-*-*Set the correct window size for lego and surface plots*-*-*-*-*
1271 //*-* ======================================================
1272 //*-*
1273 //*-* Set the correct window size for lego and surface plots.
1274 //*-* And draw the background if necessary.
1275 //*-*
1276 //*-* Input parameters:
1277 //*-*
1278 //*-* RBACK : Background colour
1279 //*-*
1280 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1281
1282 Int_t i, k;
1283 Double_t x, y, z, r1, r2, r3, xx, yy, smax[2];
1284 Double_t xgraf[6], ygraf[6];
1285
1286 for (i = 1; i <= 2; ++i) {
1287 smax[i - 1] = fTnorm[(i << 2) - 1];
1288 for (k = 1; k <= 3; ++k) {
1289 if (fTnorm[k + (i << 2) - 5] < 0) {
1290 smax[i - 1] += fTnorm[k + (i << 2) - 5]*fRmin[k-1];
1291 } else {
1292 smax[i - 1] += fTnorm[k + (i << 2) - 5]*fRmax[k-1];
1293 }
1294 }
1295 }
1296
1297 //*-*- Compute x,y range
1298 Double_t xmin = -smax[0];
1299 Double_t xmax = smax[0];
1300 Double_t ymin = -smax[1];
1301 Double_t ymax = smax[1];
1302 Double_t dx = xmax-xmin;
1303 Double_t dy = ymax-ymin;
1304 Double_t dxr = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
1305 Double_t dyr = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
1306
1307 // Range() could change the size of the pad pixmap and therefore should
1308 // be called before the other paint routines
1309 gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
1310 ymin - dyr*gPad->GetBottomMargin(),
1311 xmax + dxr*gPad->GetRightMargin(),
1312 ymax + dyr*gPad->GetTopMargin());
1313 gPad->RangeAxis(xmin, ymin, xmax, ymax);
1314
1315 //*-*- Draw the background if necessary
1316
1317 if (rback > 0) {
1318 r1 = -1;
1319 r2 = -1;
1320 r3 = -1;
1321 xgraf[0] = -smax[0];
1322 xgraf[1] = -smax[0];
1323 xgraf[2] = -smax[0];
1324 xgraf[3] = -smax[0];
1325 xgraf[4] = smax[0];
1326 xgraf[5] = smax[0];
1327 ygraf[0] = -smax[1];
1328 ygraf[1] = smax[1];
1329 ygraf[2] = -smax[1];
1330 ygraf[3] = smax[1];
1331 ygraf[5] = smax[1];
1332 ygraf[4] = -smax[1];
1333 for (i = 1; i <= 8; ++i) {
1334 x = 0.5*((1 - r1)*fRmin[0] + (r1 + 1)*fRmax[0]);
1335 y = 0.5*((1 - r2)*fRmin[1] + (r2 + 1)*fRmax[1]);
1336 z = 0.5*((1 - r3)*fRmin[2] + (r3 + 1)*fRmax[2]);
1337 xx = fTnorm[0]*x + fTnorm[1]*y + fTnorm[2]*z + fTnorm[3];
1338 yy = fTnorm[4]*x + fTnorm[5]*y + fTnorm[6]*z + fTnorm[7];
1339 if (TMath::Abs(xx - xgraf[1]) <= 1e-4) {
1340 if (ygraf[1] >= yy) ygraf[1] = yy;
1341 if (ygraf[2] <= yy) ygraf[2] = yy;
1342 }
1343 if (TMath::Abs(xx - xgraf[5]) <= 1e-4) {
1344 if (ygraf[5] >= yy) ygraf[5] = yy;
1345 if (ygraf[4] <= yy) ygraf[4] = yy;
1346 }
1347 if (TMath::Abs(yy - ygraf[0]) <= 1e-4) xgraf[0] = xx;
1348 if (TMath::Abs(yy - ygraf[3]) <= 1e-4) xgraf[3] = xx;
1349 r1 = -r1;
1350 if (i % 2 == 0) r2 = -r2;
1351 if (i >= 4) r3 = 1;
1352 }
1353 gPad->PaintFillArea(6, xgraf, ygraf);
1354 }
1355}
1356
1357//______________________________________________________________________________
1358void BesTView::SetAxisNDC(const Double_t *x1, const Double_t *x2, const Double_t *y1, const Double_t *y2, const Double_t *z1, const Double_t *z2)
1359{
1360 //*-*-*-*-*-*-*-*-*-*-*-*-*Store axis coordinates in the NDC system*-*-*-*
1361 //*-* ========================================
1362 //*-*
1363
1364 for (Int_t i=0;i<3;i++) {
1365 fX1[i] = x1[i];
1366 fX2[i] = x2[i];
1367 fY1[i] = y1[i];
1368 fY2[i] = y2[i];
1369 fZ1[i] = z1[i];
1370 fZ2[i] = z2[i];
1371 }
1372}
1373
1374//______________________________________________________________________________
1376{
1377 // Set default viewing window
1378 if (!gPad) return;
1379 Double_t screen_factor = 1.;
1380 Double_t du, dv;
1381 Double_t extent = GetExtent();
1382 fDview = 3*extent;
1383 fDproj = 0.5*extent;
1384
1385 // widh in pixels
1386 fUpix = gPad->GetWw()*gPad->GetAbsWNDC();
1387
1388 // height in pixels
1389 fVpix = gPad->GetWh()*gPad->GetAbsHNDC();
1390 du = 0.5*screen_factor*fDproj;
1391 dv = du*fVpix/fUpix; // keep aspect ratio
1392 SetWindow(0, 0, du, dv);
1393}
1394
1395//______________________________________________________________________________
1397{
1398 //*-*-*-*-*-*-*This is a function which creates default outline*-*-*-*-*-*
1399 //*-* ================================================ *
1400 //*-* *
1401 //*-* x = fRmin[0] X = fRmax[0] *
1402 //*-* y = fRmin[1] Y = fRmax[1] *
1403 //*-* z = fRmin[2] Z = fRmax[2] *
1404 //*-* *
1405 //*-* *
1406 //*-* (x,Y,Z) +---------+ (X,Y,Z) *
1407 //*-* / /| *
1408 //*-* / / | *
1409 //*-* / / | *
1410 //*-* (x,y,Z) +---------+ | *
1411 //*-* | | + (X,Y,z) *
1412 //*-* | | / *
1413 //*-* | | / *
1414 //*-* | |/ *
1415 //*-* +---------+ *
1416 //*-* (x,y,z) (X,y,z) *
1417 //*-* *
1418 //*-* *
1419 //*-* *
1420 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-**
1421
1422 if (!fOutline) {
1423 fDefaultOutline = kTRUE;
1424 fOutline = new TList();
1425 }
1427 //TVirtualUtil3D *util = (TVirtualUtil3D*)gROOT->GetListOfSpecials()->FindObject("R__TVirtualUtil3D");
1428 //if (util) util->DrawOutlineCube((TList*)fOutline,fRmin,fRmax);
1429}
1430
1431//______________________________________________________________________________
1433{
1434 //set the parallel option (default)
1435 if (!IsPerspective()) return;
1436 SetBit(kPerspective, kFALSE);
1437 Int_t irep;
1439}
1440
1441//______________________________________________________________________________
1443{
1444 //set perspective option
1445 if (IsPerspective()) return;
1446 SetBit(kPerspective, kTRUE);
1447 Int_t irep;
1450}
1451
1452//______________________________________________________________________________
1453void BesTView::SetRange(const Double_t *min, const Double_t *max)
1454{
1455 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*Set Range function-*-*-*-*-*-*-*-*-*-*-*-*-*
1456 //*-* ==================
1457 //*-*
1458 Int_t irep;
1459 for (Int_t i = 0; i < 3; fRmax[i] = max[i], fRmin[i] = min[i], i++) { }
1462 if(irep < 0)
1463 Error("SetRange", "problem setting view");
1465}
1466
1467
1468//______________________________________________________________________________
1469void BesTView::SetRange(Double_t x0, Double_t y0, Double_t z0, Double_t x1, Double_t y1, Double_t z1, Int_t flag)
1470{
1471 //*-*-*-*-*-*-*-*-*-*-*-*Set 3-D View range*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1472 //*-* ==================
1473 //*-*
1474 //*-* Input: x0, y0, z0 are minimum coordinates
1475 //*-* x1, y1, z1 are maximum coordinates
1476 //*-*
1477 //*-* flag values are: 0 (set always) <- default
1478 //*-* 1 (shrink view)
1479 //*-* 2 (expand view)
1480 //*-*
1481
1482
1483 Double_t rmax[3], rmin[3];
1484
1485 switch (flag) {
1486 case 2: // expand view
1487 GetRange(rmin, rmax);
1488 rmin[0] = x0 < rmin[0] ? x0 : rmin[0];
1489 rmin[1] = y0 < rmin[1] ? y0 : rmin[1];
1490 rmin[2] = z0 < rmin[2] ? z0 : rmin[2];
1491 rmax[0] = x1 > rmax[0] ? x1 : rmax[0];
1492 rmax[1] = y1 > rmax[1] ? y1 : rmax[1];
1493 rmax[2] = z1 > rmax[2] ? z1 : rmax[2];
1494 break;
1495
1496 case 1: // shrink view
1497 GetRange(rmin, rmax);
1498 rmin[0] = x0 > rmin[0] ? x0 : rmin[0];
1499 rmin[1] = y0 > rmin[1] ? y0 : rmin[1];
1500 rmin[2] = z0 > rmin[2] ? z0 : rmin[2];
1501 rmax[0] = x1 < rmax[0] ? x1 : rmax[0];
1502 rmax[1] = y1 < rmax[1] ? y1 : rmax[1];
1503 rmax[2] = z1 < rmax[2] ? z1 : rmax[2];
1504 break;
1505
1506 default:
1507 rmin[0] = x0; rmax[0] = x1;
1508 rmin[1] = y0; rmax[1] = y1;
1509 rmin[2] = z0; rmax[2] = z1;
1510 }
1511 SetRange(rmin, rmax);
1512}
1513
1514//______________________________________________________________________________
1515void BesTView::SetWindow(Double_t u0, Double_t v0, Double_t du, Double_t dv)
1516{
1517 // Set viewing window.
1518 fUVcoord[0] = u0;
1519 fUVcoord[1] = v0;
1520 fUVcoord[2] = du;
1521 fUVcoord[3] = dv;
1522}
1523
1524//______________________________________________________________________________
1525void BesTView::SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
1526{
1527 //set view parameters
1528
1529 ResetView(longitude, latitude, psi, irep);
1530}
1531
1532//______________________________________________________________________________
1534{
1535 // Recompute window for perspective view
1536
1537 if (!IsPerspective()) return;
1538 Double_t upix = fUpix;
1539 Double_t vpix = fVpix;
1540 // widh in pixels
1541 fUpix = gPad->GetWw()*gPad->GetAbsWNDC();
1542 // height in pixels
1543 fVpix = gPad->GetWh()*gPad->GetAbsHNDC();
1544 Double_t u0 = fUVcoord[0]*fUpix/upix;
1545 Double_t v0 = fUVcoord[1]*fVpix/vpix;
1546 Double_t du = fUVcoord[2]*fUpix/upix;
1547 Double_t dv = fUVcoord[3]*fVpix/vpix;
1548 SetWindow(u0, v0, du, dv);
1550}
1551
1552//______________________________________________________________________________
1553void BesTView::ResetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
1554{
1555 //*-*-*-*-*-*-*-*-*Set view direction (in spherical coordinates)*-*-*-*-*-*
1556 //*-* ============================================= *
1557 //*-* *
1558 //*-* Input PHI - longitude *
1559 //*-* THETA - latitude (angle between +Z and view direction) *
1560 //*-* PSI - rotation in screen plane *
1561 //*-* *
1562 //*-* Output: IREP - reply (-1 if error in min-max) *
1563 //*-* *
1564 //*-* Errors: error in min-max scope *
1565 //*-* *
1566 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1567
1568 Double_t scale[3], centre[3];
1569 Double_t c1, c2, c3, s1, s2, s3;
1570
1571 //*-*- F I N D C E N T E R O F S C O P E A N D
1572 //*-*- S C A L E F A C T O R S
1573
1574 FindScope(scale, centre, irep);
1575 if (irep < 0) {
1576 Error("ResetView", "Error in min-max scope");
1577 return;
1578 }
1579
1580 //*-*- S E T T R A N S F O R M A T I O N M A T R I C E S
1581
1582
1583 fLongitude = longitude;
1584 fPsi = psi;
1585 fLatitude = latitude;
1586
1587 if (IsPerspective()) {
1589 return;
1590 }
1591
1592 c1 = TMath::Cos(longitude*kRad);
1593 s1 = TMath::Sin(longitude*kRad);
1594 c2 = TMath::Cos(latitude*kRad);
1595 s2 = TMath::Sin(latitude*kRad);
1596 c3 = TMath::Cos(psi*kRad);
1597 s3 = TMath::Sin(psi*kRad);
1598 DefineViewDirection(scale, centre, c1, s1, c2, s2, c3, s3, fTnorm, fTback);
1599 c3 = 1;
1600 s3 = 0;
1601 DefineViewDirection(scale, centre, c1, s1, c2, s2, c3, s3, fTN, fTB);
1602}
1603
1604
1605//______________________________________________________________________________
1606void BesTView::WCtoNDC(const Float_t *pw, Float_t *pn)
1607{
1608 //*-*-*-*-*-*-*Transfer point from world to normalized coordinates*-*-*-*-*
1609 //*-* =================================================== *
1610 //*-* *
1611 //*-* Input: PW(3) - point in world coordinate system *
1612 //*-* PN(3) - point in normalized coordinate system *
1613 //*-* *
1614 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1615
1616 // perspective view
1617 if (IsPerspective()) {
1618 for (Int_t i=0; i<3; i++)
1619 pn[i] = pw[0]*fTnorm[i]+pw[1]*fTnorm[i+4]+pw[2]*fTnorm[i+8]+fTnorm[i+12];
1620 if (pn[2]>0) {
1621 pn[0] /= pn[2];
1622 pn[1] /= pn[2];
1623 } else {
1624 pn[0] *= 1000.;
1625 pn[1] *= 1000.;
1626 }
1627 return;
1628 }
1629 // parallel view
1630 pn[0] = fTnorm[0]*pw[0] + fTnorm[1]*pw[1] + fTnorm[2]*pw[2] + fTnorm[3];
1631 pn[1] = fTnorm[4]*pw[0] + fTnorm[5]*pw[1] + fTnorm[6]*pw[2] + fTnorm[7];
1632 pn[2] = fTnorm[8]*pw[0] + fTnorm[9]*pw[1] + fTnorm[10]*pw[2] + fTnorm[11];
1633}
1634
1635
1636//______________________________________________________________________________
1637void BesTView::WCtoNDC(const Double_t *pw, Double_t *pn)
1638{
1639 //*-*-*-*-*-*-*Transfer point from world to normalized coordinates*-*-*-*-*
1640 //*-* =================================================== *
1641 //*-* *
1642 //*-* Input: PW(3) - point in world coordinate system *
1643 //*-* PN(3) - point in normalized coordinate system *
1644 //*-* *
1645 //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
1646
1647 // perspective view
1648 if (IsPerspective()) {
1649 for (Int_t i=0; i<3; i++)
1650 pn[i] = pw[0]*fTnorm[i]+pw[1]*fTnorm[i+4]+pw[2]*fTnorm[i+8]+fTnorm[i+12];
1651 if (pn[2]>0) {
1652 pn[0] /= pn[2];
1653 pn[1] /= pn[2];
1654 } else {
1655 pn[0] *= 1000.;
1656 pn[1] *= 1000.;
1657 }
1658 return;
1659 }
1660 // parallel view
1661 pn[0] = fTnorm[0]*pw[0] + fTnorm[1]*pw[1] + fTnorm[2]*pw[2] + fTnorm[3];
1662 pn[1] = fTnorm[4]*pw[0] + fTnorm[5]*pw[1] + fTnorm[6]*pw[2] + fTnorm[7];
1663 pn[2] = fTnorm[8]*pw[0] + fTnorm[9]*pw[1] + fTnorm[10]*pw[2] + fTnorm[11];
1664}
1665
1666//_______________________________________________________________________________________
1667void BesTView::AdjustPad(TVirtualPad *pad)
1668{
1669 // Force the current pad to be updated
1670 TVirtualPad *thisPad = pad;
1671 if (!thisPad) thisPad = gPad;
1672 if (thisPad) {
1673 thisPad->Modified();
1674 thisPad->Update();
1675 }
1676}
1677//_______________________________________________________________________________________
1678void BesTView::RotateView(Double_t phi, Double_t theta, TVirtualPad *pad)
1679{
1680 // API to rotate view and adjust the pad provided it the current one.
1681
1682 Int_t iret;
1683 Double_t p = phi;
1684 Double_t t = theta;
1685 SetView(p, t, 0, iret);
1686
1687 // Adjust current pad too
1688 TVirtualPad *thisPad = pad;
1689 if (!thisPad) thisPad = gPad;
1690 if (thisPad) {
1691 thisPad->SetPhi(-90-p);
1692 thisPad->SetTheta(90-t);
1693 thisPad->Modified();
1694 thisPad->Update();
1695 }
1696}
1697
1698//_______________________________________________________________________________________
1699void BesTView::SideView(TVirtualPad *pad)
1700{
1701 // Set to side view.
1702 RotateView(0,90.0,pad);
1703}
1704//_______________________________________________________________________________________
1705void BesTView::FrontView(TVirtualPad *pad)
1706{
1707 // Set to front view.
1708 RotateView(270.0,90.0,pad);
1709}
1710//_______________________________________________________________________________________
1711void BesTView::TopView(TVirtualPad *pad)
1712{
1713 // Set to top view.
1714 RotateView(270.0,0.0,pad);
1715}
1716//_______________________________________________________________________________________
1717void BesTView::ToggleRulers(TVirtualPad *pad)
1718{
1719 // Turn on /off 3D axis
1720 //TVirtualUtil3D *util = (TVirtualUtil3D*)gROOT->GetListOfSpecials()->FindObject("R__TVirtualUtil3D");
1721 //if (util) util->ToggleRulers(pad);
1722 TAxis3D::ToggleRulers(pad);
1723}
1724
1725//_______________________________________________________________________________________
1726void BesTView::ToggleZoom(TVirtualPad *pad)
1727{
1728 // Turn on /off the interactive option to
1729 // Zoom / Move / Change attributes of 3D axis correspond this view
1730 //TVirtualUtil3D *util = (TVirtualUtil3D*)gROOT->GetListOfSpecials()->FindObject("R__TVirtualUtil3D");
1731 //if (util) util->ToggleZoom(pad);
1732 TAxis3D::ToggleZoom(pad);
1733}
1734
1735//_______________________________________________________________________________________
1736void BesTView::AdjustScales(TVirtualPad *pad)
1737{
1738 // Adjust all sides of view in respect of the biggest one
1739 Double_t min[3],max[3];
1740 GetRange(min,max);
1741 int i;
1742 Double_t maxSide = 0;
1743 // Find the largest side
1744 for (i=0;i<3; i++) maxSide = TMath::Max(maxSide,max[i]-min[i]);
1745 //Adjust scales:
1746 for (i=0;i<3; i++) max[i] += maxSide - (max[i]-min[i]);
1747 SetRange(min,max);
1748
1749 AdjustPad(pad);
1750}
1751
1752//_______________________________________________________________________________________
1753void BesTView::Centered3DImages(TVirtualPad *pad)
1754{
1755 // Move view into the center of the scene
1756
1757 Double_t min[3],max[3];
1758 GetRange(min,max);
1759 int i;
1760 for (i=0;i<3; i++) {
1761 if (max[i] > 0) min[i] = -max[i];
1762 else max[i] = -min[i];
1763 }
1764 SetRange(min,max);
1765 AdjustPad(pad);
1766}
1767
1768//_______________________________________________________________________________________
1769void BesTView::UnzoomView(TVirtualPad *pad,Double_t unZoomFactor )
1770{
1771 // unZOOM this view
1772 if (TMath::Abs(unZoomFactor) < 0.001) return;
1773 ZoomView(pad,1./unZoomFactor);
1774}
1775
1776//_______________________________________________________________________________________
1777void BesTView::ZoomView(TVirtualPad *pad,Double_t zoomFactor)
1778{
1779 // ZOOM this view
1780
1781 if (TMath::Abs(zoomFactor) < 0.001) return;
1782 Double_t min[3],max[3];
1783 GetRange(min,max);
1784 int i;
1785 for (i=0;i<3; i++) {
1786 // Find center
1787 Double_t c = (max[i]+min[i])/2;
1788 // Find a new size
1789 Double_t s = (max[i]-min[i])/(2*zoomFactor);
1790 // Set a new size
1791 max[i] = c + s;
1792 min[i] = c - s;
1793 }
1794 SetRange(min,max);
1795 AdjustPad(pad);
1796}
1797//___________
1798void BesTView::MoveFocus(Double_t *cov, Double_t dx, Double_t dy, Double_t dz, Int_t nsteps,
1799 Double_t dlong, Double_t dlat, Double_t dpsi)
1800{
1801 // Move focus to a different box position and extent in nsteps. Perform rotation
1802// with dlat,dlong,dpsi at each step.
1803 if (!IsPerspective()) return;
1804 if (nsteps<1) return;
1805 Double_t fc = 1./Double_t(nsteps);
1806 Double_t oc[3], od[3], dir[3];
1807 dir[0] = 0;
1808 dir[1] = 0;
1809 dir[2] = 1.;
1810 Int_t i, j;
1811 for (i=0; i<3; i++) {
1812 oc[i] = 0.5*(fRmin[i]+fRmax[i]);
1813 od[i] = 0.5*(fRmax[i]-fRmin[i]);
1814 }
1815 Double_t dox = cov[0]-oc[0];
1816 Double_t doy = cov[1]-oc[1];
1817 Double_t doz = cov[2]-oc[2];
1818
1819 Double_t dd = TMath::Sqrt(dox*dox+doy*doy+doz*doz);
1820 if (dd!=0) {;
1821 dir[0] = dox/dd;
1822 dir[1] = doy/dd;
1823 dir[2] = doz/dd;
1824 }
1825 dd *= fc;
1826 dox = fc*(dx-od[0]);
1827 doy = fc*(dy-od[1]);
1828 doz = fc*(dz-od[2]);
1829 for (i=0; i<nsteps; i++) {
1830 oc[0] += dd*dir[0];
1831 oc[1] += dd*dir[1];
1832 oc[2] += dd*dir[2];
1833 od[0] += dox;
1834 od[1] += doy;
1835 od[2] += doz;
1836 for (j=0; j<3; j++) {
1837 fRmin[j] = oc[j]-od[j];
1838 fRmax[j] = oc[j]+od[j];
1839 }
1841 fLatitude += dlat;
1842 fLongitude += dlong;
1843 fPsi += dpsi;
1845 if (gPad) {
1846 gPad->Modified();
1847 gPad->Update();
1848 }
1849 }
1850}
1851
1852//_______________________________________________________________________________________
1853void BesTView::MoveViewCommand(Char_t option, Int_t count)
1854{
1855 //
1856 //*-* 'a' //*-* increase scale factor (clip cube borders)
1857 //*-* 's' //*-* decrease scale factor (clip cube borders)
1858 //
1859 if (count <= 0) count = 1;
1860 switch (option) {
1861 case '+':
1862 ZoomView();
1863 break;
1864 case '-':
1865 UnzoomView();
1866 break;
1867 case 's':
1868 case 'S':
1869 UnzoomView();
1870 break;
1871 case 'a':
1872 case 'A':
1873 ZoomView();
1874 break;
1875 case 'l':
1876 case 'L':
1877 case 'h':
1878 case 'H':
1879 case 'u':
1880 case 'U':
1881 case 'i':
1882 case 'I':
1883 MoveWindow(option);
1884 break;
1885 case 'j':
1886 case 'J':
1887 ZoomIn();
1888 break;
1889 case 'k':
1890 case 'K':
1891 ZoomOut();
1892 break;
1893 default:
1894 break;
1895 }
1896}
1897
1898//_______________________________________________________________________________________
1899void BesTView::MoveWindow(Char_t option)
1900{
1901 // Move view window :
1902 // l,L - left
1903 // h,H - right
1904 // u,U - down
1905 // i,I - up
1906 if (!IsPerspective()) return;
1907 Double_t shiftu = 0.1*fUVcoord[2];
1908 Double_t shiftv = 0.1*fUVcoord[3];
1909 switch (option) {
1910 case 'l':
1911 case 'L':
1912 fUVcoord[0] += shiftu;
1913 break;
1914 case 'h':
1915 case 'H':
1916 fUVcoord[0] -= shiftu;
1917 break;
1918 case 'u':
1919 case 'U':
1920 fUVcoord[1] += shiftv;
1921 break;
1922 case 'i':
1923 case 'I':
1924 fUVcoord[1] -= shiftv;
1925 break;
1926 default:
1927 return;
1928 }
1930 if (gPad) {
1931 gPad->Modified();
1932 gPad->Update();
1933 }
1934}
1935
1936//_______________________________________________________________________________________
1938{
1939 // Zoom in.
1940 if (!IsPerspective()) return;
1941 Double_t extent = GetExtent();
1942 Double_t fc = 0.1;
1943 if (fDview<extent) {
1944 fDview -= fc*extent;
1945 } else {
1946 fDview /= 1.25;
1947 }
1949 if (gPad) {
1950 gPad->Modified();
1951 gPad->Update();
1952 }
1953}
1954
1955//_______________________________________________________________________________________
1957{
1958 // Zoom out.
1959 if (!IsPerspective()) return;
1960 Double_t extent = GetExtent();
1961 Double_t fc = 0.1;
1962 if (fDview<extent) {
1963 fDview += fc*extent;
1964 } else {
1965 fDview *= 1.25;
1966 }
1968 if (gPad) {
1969 gPad->Modified();
1970 gPad->Update();
1971 }
1972}
1973
1974//______________________________________________________________________________
1975void BesTView::Streamer(TBuffer &R__b)
1976{
1977 // Stream an object of class BesTView.
1978
1979 if (R__b.IsReading()) {
1980 UInt_t R__s, R__c;
1981 Version_t R__v = R__b.ReadVersion(&R__s, &R__c);
1982 if (R__v > 1) {
1983 //BesTView::Class()->ReadBuffer(R__b, this, R__v, R__s, R__c);
1984 R__b.ReadClassBuffer(TView::Class(), this, R__v, R__s, R__c);
1985 return;
1986 }
1987 //====process old versions before automatic schema evolution
1988 //unfortunately we forgot to increment the BesTView version number
1989 //when the class was upgraded to double precision in version 2.25.
1990 //we are forced to use the file version number to recognize old files.
1991 if (R__b.GetParent() && R__b.GetVersionOwner() < 22500) { //old version in single precision
1992 //TFile *file = (TFile*)R__b.GetParent();
1993 //if (file && file->GetVersion() < 22500) { //old version in single precision
1994 TObject::Streamer(R__b);
1995 TAttLine::Streamer(R__b);
1996 Float_t single, sa[12];
1997 Int_t i;
1998 R__b >> fSystem;
1999 R__b >> single; fLatitude = single;
2000 R__b >> single; fLongitude = single;
2001 R__b >> single; fPsi = single;
2002 R__b.ReadStaticArray(sa); for (i=0;i<12;i++) fTN[i] = sa[i];
2003 R__b.ReadStaticArray(sa); for (i=0;i<12;i++) fTB[i] = sa[i];
2004 R__b.ReadStaticArray(sa); for (i=0;i<3;i++) fRmax[i] = sa[i];
2005 R__b.ReadStaticArray(sa); for (i=0;i<3;i++) fRmin[i] = sa[i];
2006 R__b.ReadStaticArray(sa); for (i=0;i<12;i++) fTnorm[i] = sa[i];
2007 R__b.ReadStaticArray(sa); for (i=0;i<12;i++) fTback[i] = sa[i];
2008 R__b.ReadStaticArray(sa); for (i=0;i<3;i++) fX1[i] = sa[i];
2009 R__b.ReadStaticArray(sa); for (i=0;i<3;i++) fX2[i] = sa[i];
2010 R__b.ReadStaticArray(sa); for (i=0;i<3;i++) fY1[i] = sa[i];
2011 R__b.ReadStaticArray(sa); for (i=0;i<3;i++) fY2[i] = sa[i];
2012 R__b.ReadStaticArray(sa); for (i=0;i<3;i++) fZ1[i] = sa[i];
2013 R__b.ReadStaticArray(sa); for (i=0;i<3;i++) fZ2[i] = sa[i];
2014 R__b >> fOutline;
2015 R__b >> fDefaultOutline;
2016 R__b >> fAutoRange;
2017 } else {
2018 TObject::Streamer(R__b);
2019 TAttLine::Streamer(R__b);
2020 R__b >> fLatitude;
2021 R__b >> fLongitude;
2022 R__b >> fPsi;
2023 R__b.ReadStaticArray(fTN);
2024 R__b.ReadStaticArray(fTB);
2025 R__b.ReadStaticArray(fRmax);
2026 R__b.ReadStaticArray(fRmin);
2027 R__b.ReadStaticArray(fTnorm);
2028 R__b.ReadStaticArray(fTback);
2029 R__b.ReadStaticArray(fX1);
2030 R__b.ReadStaticArray(fX2);
2031 R__b.ReadStaticArray(fY1);
2032 R__b.ReadStaticArray(fY2);
2033 R__b.ReadStaticArray(fZ1);
2034 R__b.ReadStaticArray(fZ2);
2035 R__b >> fSystem;
2036 R__b >> fOutline;
2037 R__b >> fDefaultOutline;
2038 R__b >> fAutoRange;
2039 }
2040 //====end of old versions
2041
2042 } else {
2043 R__b.WriteClassBuffer(TView::Class(),this);
2044 //BesTView::Class()->WriteBuffer(R__b,this);
2045 }
2046}
ClassImp(BesTView) const Int_t kCARTESIAN
const Double_t kRad
Definition: BesTView.cxx:34
const Int_t kPOLAR
Definition: BesTView.cxx:33
Double_t phi2
Double_t x[10]
Double_t phi1
DOUBLE_PRECISION count[3]
XmlRpcServer s
Definition: HelloServer.cpp:11
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
virtual void FrontView(TVirtualPad *pad=0)
Definition: BesTView.cxx:1705
virtual Int_t GetDistancetoAxis(Int_t axis, Int_t px, Int_t py, Double_t &ratio)
Definition: BesTView.cxx:1052
virtual void TopView(TVirtualPad *pad=0)
Definition: BesTView.cxx:1711
virtual void SetOutlineToCube()
Definition: BesTView.cxx:1396
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)
Definition: BesTView.cxx:1606
virtual void UnzoomView(TVirtualPad *pad=0, Double_t unZoomFactor=1.25)
Definition: BesTView.cxx:1769
virtual void SetAxisNDC(const Double_t *x1, const Double_t *x2, const Double_t *y1, const Double_t *y2, const Double_t *z1, const Double_t *z2)
Definition: BesTView.cxx:1358
Bool_t IsClippedNDC(Double_t *p) const
Definition: BesTView.cxx:1165
virtual void FindNormal(Double_t x, Double_t y, Double_t z, Double_t &zn)
Definition: BesTView.cxx:874
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Definition: BesTView.cxx:737
virtual void AdjustScales(TVirtualPad *pad=0)
Definition: BesTView.cxx:1736
virtual void FindPhiSectors(Int_t iopt, Int_t &kphi, Double_t *aphi, Int_t &iphi1, Int_t &iphi2)
Definition: BesTView.cxx:892
void SetWindow(Double_t u0, Double_t v0, Double_t du, Double_t dv)
Definition: BesTView.cxx:1515
Double_t GetExtent() const
Definition: BesTView.cxx:1123
virtual void ToggleRulers(TVirtualPad *pad=0)
Definition: BesTView.cxx:1717
virtual void DefinePerspectiveView()
Definition: BesTView.cxx:466
virtual void ToggleZoom(TVirtualPad *pad=0)
Definition: BesTView.cxx:1726
virtual void Centered3DImages(TVirtualPad *pad=0)
Definition: BesTView.cxx:1753
virtual void NDCtoWC(const Float_t *pn, Float_t *pw)
Definition: BesTView.cxx:1176
void ResizePad()
Definition: BesTView.cxx:1533
virtual void AxisVertex(Double_t ang, Double_t *av, Int_t &ix1, Int_t &ix2, Int_t &iy1, Int_t &iy2, Int_t &iz1, Int_t &iz2)
Definition: BesTView.cxx:332
virtual void ZoomView(TVirtualPad *pad=0, Double_t zoomFactor=1.25)
Definition: BesTView.cxx:1777
virtual void SetRange(const Double_t *min, const Double_t *max)
Definition: BesTView.cxx:1453
virtual void RotateView(Double_t phi, Double_t theta, TVirtualPad *pad=0)
Definition: BesTView.cxx:1678
virtual void NormalWCtoNDC(const Float_t *pw, Float_t *pn)
Definition: BesTView.cxx:1208
static void AdjustPad(TVirtualPad *pad=0)
Definition: BesTView.cxx:1667
virtual void ZoomOut()
Definition: BesTView.cxx:1956
void MoveFocus(Double_t *center, Double_t dx, Double_t dy, Double_t dz, Int_t nsteps=10, Double_t dlong=0, Double_t dlat=0, Double_t dpsi=0)
Definition: BesTView.cxx:1798
virtual void PadRange(Int_t rback)
Definition: BesTView.cxx:1268
BesTView()
Definition: BesTView.cxx:39
virtual void SetParallel()
Definition: BesTView.cxx:1432
void SetDefaultWindow()
Definition: BesTView.cxx:1375
virtual void GetRange(Float_t *min, Float_t *max)
Definition: BesTView.cxx:1137
void ResetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
Definition: BesTView.cxx:1553
virtual void SideView(TVirtualPad *pad=0)
Definition: BesTView.cxx:1699
virtual void DefineViewDirection(const Double_t *s, const Double_t *c, Double_t cosphi, Double_t sinphi, Double_t costhe, Double_t sinthe, Double_t cospsi, Double_t sinpsi, Double_t *tnorm, Double_t *tback)
Definition: BesTView.cxx:600
virtual void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)
Definition: BesTView.cxx:1525
virtual void ExecuteRotateView(Int_t event, Int_t px, Int_t py)
Definition: BesTView.cxx:745
virtual void SetPerspective()
Definition: BesTView.cxx:1442
virtual void MoveViewCommand(Char_t chCode, Int_t count=1)
Definition: BesTView.cxx:1853
void MoveWindow(Char_t option)
Definition: BesTView.cxx:1899
virtual void ZoomIn()
Definition: BesTView.cxx:1937
virtual void DrawOutlineCube(TList *outline, Double_t *rmin, Double_t *rmax)
Definition: BesTView.cxx:728
virtual void FindThetaSectors(Int_t iopt, Double_t phi, Int_t &kth, Double_t *ath, Int_t &ith1, Int_t &ith2)
Definition: BesTView.cxx:959
void GetWindow(Double_t &u0, Double_t &v0, Double_t &du, Double_t &dv) const
Definition: BesTView.cxx:1155
virtual void FindScope(Double_t *scale, Double_t *center, Int_t &irep)
Definition: BesTView.cxx:1030
virtual ~BesTView()
Definition: BesTView.cxx:134
BesTView & operator=(const BesTView &)
Definition: BesTView.cxx:93
#define ix(i)
Definition: minoreval.cpp:387
int t()
Definition: t.c:1