Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGeoPainter.cxx
Go to the documentation of this file.
1// @(#)root/geompainter:$Id: 58726ead32989b65bb2cbff2af4235fe9c6b12ae $
2// Author: Andrei Gheata 05/03/02
3/*************************************************************************
4 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11/** \class TGeoPainter
12\ingroup Geometry_painter
13
14Class implementing all draw interfaces for a generic 3D viewer
15using TBuffer3D mechanism.
16*/
17
18#include <map>
19#include "TROOT.h"
20#include "TClass.h"
21#include "TColor.h"
22#include "TPoint.h"
23#include "TView.h"
24#include "TAttLine.h"
25#include "TAttFill.h"
26#include "TVirtualPad.h"
27#include "TStopwatch.h"
28#include "TCanvas.h"
29#include "TCanvasImp.h"
30#include "TF1.h"
31#include "TGraph.h"
32#include "TPluginManager.h"
33#include "TVirtualPadEditor.h"
34
35#include "TPolyMarker3D.h"
36
37#include "TGeoAtt.h"
38#include "TGeoVolume.h"
39#include "TGeoNode.h"
40#include "TGeoElement.h"
41#include "TGeoManager.h"
42#include "TGeoTrack.h"
43#include "TGeoOverlap.h"
44#include "TGeoPhysicalNode.h"
45#include "TGeoPolygon.h"
46#include "TGeoCompositeShape.h"
47#include "TGeoShapeAssembly.h"
48#include "TGeoPainter.h"
49#include "TMath.h"
50#include "TVirtualGeoChecker.h"
51
52#include "X3DBuffer.h"
53
54#include "TBuffer3D.h"
55#include "TBuffer3DTypes.h"
56#include "TVirtualViewer3D.h"
57#include "TVirtualX.h"
58
60
61////////////////////////////////////////////////////////////////////////////////
62/// Default constructor.
63
65{
67 if (manager)
69 else {
70 Error("ctor", "No geometry loaded");
71 return;
72 }
74 fNVisNodes = 0;
75 fBombX = 1.3;
76 fBombY = 1.3;
77 fBombZ = 1.3;
78 fBombR = 1.3;
82 fVisBranch = "";
83 fVolInfo = "";
88 fPlugin = nullptr;
89 fVisVolumes = new TObjArray();
90 fOverlap = nullptr;
91 fGlobal = new TGeoHMatrix();
92 fBuffer = new TBuffer3D(TBuffer3DTypes::kGeneric, 20, 3 * 20, 0, 0, 0, 0);
93 fClippingShape = nullptr;
94 fLastVolume = nullptr;
95 fTopVolume = nullptr;
97 memset(&fCheckedBox[0], 0, 6 * sizeof(Double_t));
98
101 DefineColors();
102}
103////////////////////////////////////////////////////////////////////////////////
104/// Default destructor.
105
107{
108 delete fVisVolumes;
109 delete fGlobal;
110 delete fBuffer;
111 if (fPlugin)
112 delete fPlugin;
113}
114////////////////////////////////////////////////////////////////////////////////
115/// Add numpoints, numsegs, numpolys to the global 3D size.
116
118{
119 gSize3D.numPoints += numpoints;
120 gSize3D.numSegs += numsegs;
121 gSize3D.numPolys += numpolys;
122}
123////////////////////////////////////////////////////////////////////////////////
124/// Create a primary TGeoTrack.
125
130
131////////////////////////////////////////////////////////////////////////////////
132/// Average center of view of all painted tracklets and compute view box.
133
135{
136 static Int_t npoints = 0;
137 static Double_t xmin[3] = {0, 0, 0};
138 static Double_t xmax[3] = {0, 0, 0};
139 Int_t i;
140 if (reset) {
141 memset(box, 0, 6 * sizeof(Double_t));
142 memset(xmin, 0, 3 * sizeof(Double_t));
143 memset(xmax, 0, 3 * sizeof(Double_t));
144 npoints = 0;
145 return;
146 }
147 if (npoints == 0) {
148 for (i = 0; i < 3; i++)
149 xmin[i] = xmax[i] = 0;
150 npoints++;
151 }
152 npoints++;
154 for (i = 0; i < 3; i++) {
155 box[i] += ninv * (point[i] - box[i]);
156 if (point[i] < xmin[i])
157 xmin[i] = point[i];
158 if (point[i] > xmax[i])
159 xmax[i] = point[i];
160 box[i + 3] = 0.5 * (xmax[i] - xmin[i]);
161 }
162}
163
164////////////////////////////////////////////////////////////////////////////////
165/// Get the new 'bombed' translation vector according current exploded view mode.
166
168{
169 memcpy(bombtr, tr, 3 * sizeof(Double_t));
170 switch (fExplodedView) {
171 case kGeoNoBomb: return;
172 case kGeoBombXYZ:
173 bombtr[0] *= fBombX;
174 bombtr[1] *= fBombY;
175 bombtr[2] *= fBombZ;
176 return;
177 case kGeoBombCyl:
178 bombtr[0] *= fBombR;
179 bombtr[1] *= fBombR;
180 bombtr[2] *= fBombZ;
181 return;
182 case kGeoBombSph:
183 bombtr[0] *= fBombR;
184 bombtr[1] *= fBombR;
185 bombtr[2] *= fBombR;
186 return;
187 default: return;
188 }
189}
190
191////////////////////////////////////////////////////////////////////////////////
192/// Clear the list of visible volumes
193/// reset the kVisOnScreen bit for volumes previously in the list
194
196{
197 if (!fVisVolumes)
198 return;
199 TIter next(fVisVolumes);
200 TGeoVolume *vol;
201 while ((vol = (TGeoVolume *)next())) {
203 }
205}
206
207////////////////////////////////////////////////////////////////////////////////
208/// Define 100 colors with increasing light intensities for each basic color (1-7)
209/// Register these colors at indexes starting with 1000.
210
212{
213 static Int_t color = 0;
214 if (!color) {
216 for (auto icol = 1; icol < 10; ++icol)
217 color = GetColor(icol, 0.5);
218 }
219}
220
221////////////////////////////////////////////////////////////////////////////////
222/// Get index of a base color with given light intensity (0,1)
223
225{
226 using IntMap_t = std::map<Int_t, Int_t>;
227 constexpr Int_t ncolors = 100;
228 constexpr Float_t lmin = 0.25;
229 constexpr Float_t lmax = 0.75;
230 static IntMap_t colmap;
231 Int_t color = base;
232 // Search color in the map
233 auto it = colmap.find(base);
234 if (it != colmap.end())
235 return (it->second + light * (ncolors - 1));
236 // Get color pointer if stored
237 TColor *col_base = gROOT->GetColor(base);
238 if (!col_base) {
239 // If color not defined, use gray palette
240 it = colmap.find(kBlack);
241 if (it != colmap.end())
242 return (it->second + light * (ncolors - 1));
243 col_base = gROOT->GetColor(kBlack);
244 color = 1;
245 }
246 // Create a color palette for col_base
247 Float_t r = 0., g = 0., b = 0., h = 0., l = 0., s = 0.;
248 Double_t red[2], green[2], blue[2];
249 Double_t stop[] = {0., 1.0};
250
251 if (col_base)
252 col_base->GetRGB(r, g, b);
253 TColor::RGB2HLS(r, g, b, h, l, s);
254 TColor::HLS2RGB(h, lmin, s, r, g, b);
255 red[0] = r;
256 green[0] = g;
257 blue[0] = b;
258 TColor::HLS2RGB(h, lmax, s, r, g, b);
259 red[1] = r;
260 green[1] = g;
261 blue[1] = b;
263 colmap[color] = color_map_idx;
264 return (color_map_idx + light * (ncolors - 1));
265}
266
267////////////////////////////////////////////////////////////////////////////////
268/// Get currently drawn volume.
269
271{
272 if (!gPad)
273 return nullptr;
274 return fTopVolume;
275}
276
277////////////////////////////////////////////////////////////////////////////////
278/// Compute the closest distance of approach from point px,py to a volume.
279
281{
282 const Int_t big = 9999;
283 const Int_t inaxis = 7;
284 const Int_t maxdist = 5;
285
286 if (fTopVolume != volume)
287 fTopVolume = volume;
288 TView *view = gPad->GetView();
289 if (!view)
290 return big;
291 TGeoBBox *box;
292 fGlobal->Clear();
294
295 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
296 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
297 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
298 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
299 // return if point not in user area
300 if (px < puxmin - inaxis)
301 return big;
302 if (py > puymin + inaxis)
303 return big;
304 if (px > puxmax + inaxis)
305 return big;
306 if (py < puymax - inaxis)
307 return big;
308
310 gPad->SetSelected(view);
311 Int_t dist = big;
312 // Int_t id;
313
314 if (fPaintingOverlaps) {
318 dist = crt->GetShape()->DistancetoPrimitive(px, py);
319 if (dist < maxdist) {
320 gPad->SetSelected(crt);
321 box = (TGeoBBox *)crt->GetShape();
322 fGlobal->LocalToMaster(box->GetOrigin(), &fCheckedBox[0]);
323 fCheckedBox[3] = box->GetDX();
324 fCheckedBox[4] = box->GetDY();
325 fCheckedBox[5] = box->GetDZ();
326 return 0;
327 }
330 dist = crt->GetShape()->DistancetoPrimitive(px, py);
331 if (dist < maxdist) {
332 gPad->SetSelected(crt);
333 box = (TGeoBBox *)crt->GetShape();
334 fGlobal->LocalToMaster(box->GetOrigin(), &fCheckedBox[0]);
335 fCheckedBox[3] = box->GetDX();
336 fCheckedBox[4] = box->GetDY();
337 fCheckedBox[5] = box->GetDZ();
338 return 0;
339 }
340 return big;
341 }
342 // Compute distance to the right edge
343 if ((puxmax + inaxis - px) < 40) {
344 if ((py - puymax + inaxis) < 40) {
345 // when the mouse points to the (40x40) right corner of the pad, the manager class is selected
346 gPad->SetSelected(fGeoManager);
348 box = (TGeoBBox *)volume->GetShape();
349 memcpy(fCheckedBox, box->GetOrigin(), 3 * sizeof(Double_t));
350 fCheckedBox[3] = box->GetDX();
351 fCheckedBox[4] = box->GetDY();
352 fCheckedBox[5] = box->GetDZ();
353 return 0;
354 }
355 // when the mouse points to the (40 pix) right edge of the pad, the top volume is selected
356 gPad->SetSelected(volume);
357 fVolInfo = volume->GetName();
358 box = (TGeoBBox *)volume->GetShape();
359 memcpy(fCheckedBox, box->GetOrigin(), 3 * sizeof(Double_t));
360 fCheckedBox[3] = box->GetDX();
361 fCheckedBox[4] = box->GetDY();
362 fCheckedBox[5] = box->GetDZ();
363 return 0;
364 }
365
366 TGeoVolume *vol = volume;
367 Bool_t vis = vol->IsVisible();
368 // Bool_t drawDaughters = kTRUE;
369 // Do we need to check a branch only?
370 if (volume->IsVisBranch()) {
371 if (!fGeoManager->IsClosed())
372 return big;
375 while (fGeoManager->GetLevel()) {
378 dist = vol->GetShape()->DistancetoPrimitive(px, py);
379 if (dist < maxdist) {
381 box = (TGeoBBox *)vol->GetShape();
382 fGeoManager->LocalToMaster(box->GetOrigin(), &fCheckedBox[0]);
385 gPad->SetSelected(fCheckedNode);
386 else
387 gPad->SetSelected(vol);
388 fCheckedBox[3] = box->GetDX();
389 fCheckedBox[4] = box->GetDY();
390 fCheckedBox[5] = box->GetDZ();
392 return 0;
393 }
394 fGeoManager->CdUp();
395 }
397 return dist;
398 }
399
400 // Do I need to look for the top volume ?
401 if ((fTopVisible && vis) || !vol->GetNdaughters() || !vol->IsVisDaughters() || vol->IsVisOnly()) {
402 dist = vol->GetShape()->DistancetoPrimitive(px, py);
403 if (dist < maxdist) {
404 fVolInfo = vol->GetName();
405 gPad->SetSelected(vol);
406 box = (TGeoBBox *)vol->GetShape();
407 memcpy(fCheckedBox, box->GetOrigin(), 3 * sizeof(Double_t));
408 fCheckedBox[3] = box->GetDX();
409 fCheckedBox[4] = box->GetDY();
410 fCheckedBox[5] = box->GetDZ();
411 return 0;
412 }
413 if (vol->IsVisOnly() || !vol->GetNdaughters() || !vol->IsVisDaughters())
414 return dist;
415 }
416
417 // Iterate the volume content
418 TGeoIterator next(vol);
419 next.SetTopName(TString::Format("%s_1", vol->GetName()));
421
422 Int_t level, nd;
423 Bool_t last;
424
425 while ((daughter = next())) {
426 vol = daughter->GetVolume();
427 level = next.GetLevel();
428 nd = daughter->GetNdaughters();
429 vis = daughter->IsVisible();
430 if (volume->IsVisContainers()) {
431 if (vis && level <= fVisLevel) {
432 *fGlobal = next.GetCurrentMatrix();
433 dist = vol->GetShape()->DistancetoPrimitive(px, py);
434 if (dist < maxdist) {
435 next.GetPath(fVolInfo);
436 box = (TGeoBBox *)vol->GetShape();
437 fGlobal->LocalToMaster(box->GetOrigin(), &fCheckedBox[0]);
440 gPad->SetSelected(fCheckedNode);
441 else
442 gPad->SetSelected(vol);
443 fCheckedBox[3] = box->GetDX();
444 fCheckedBox[4] = box->GetDY();
445 fCheckedBox[5] = box->GetDZ();
447 return 0;
448 }
449 }
450 // Check if we have to skip this branch
451 if (level == fVisLevel || !daughter->IsVisDaughters()) {
452 next.Skip();
453 continue;
454 }
455 } else if (volume->IsVisLeaves()) {
456 last = ((nd == 0) || (level == fVisLevel) || (!daughter->IsVisDaughters())) ? kTRUE : kFALSE;
457 if (vis && last) {
458 *fGlobal = next.GetCurrentMatrix();
459 dist = vol->GetShape()->DistancetoPrimitive(px, py);
460 if (dist < maxdist) {
461 next.GetPath(fVolInfo);
462 box = (TGeoBBox *)vol->GetShape();
463 fGlobal->LocalToMaster(box->GetOrigin(), &fCheckedBox[0]);
466 gPad->SetSelected(fCheckedNode);
467 else
468 gPad->SetSelected(vol);
469 fCheckedBox[3] = box->GetDX();
470 fCheckedBox[4] = box->GetDY();
471 fCheckedBox[5] = box->GetDZ();
473 return 0;
474 }
475 }
476 // Check if we have to skip the branch
477 if (last || !daughter->IsVisDaughters())
478 next.Skip();
479 }
480 }
481 return dist;
482}
483
484////////////////////////////////////////////////////////////////////////////////
485/// Set default angles for the current view.
486
488{
489 if (gPad) {
490 Int_t irep;
491 TView *view = gPad->GetView();
492 if (!view)
493 return;
494 view->SetView(-206, 126, 75, irep);
495 ModifiedPad();
496 }
497}
498
499////////////////////////////////////////////////////////////////////////////////
500/// Set default volume colors according to tracking media
501
503{
505 TGeoVolume *vol;
506 while ((vol = (TGeoVolume *)next()))
508 ModifiedPad();
509}
510
511////////////////////////////////////////////////////////////////////////////////
512/// Count number of visible nodes down to a given level.
513
515{
516 TGeoVolume *vol = volume;
517 Int_t count = 0;
518 Bool_t vis = vol->IsVisible();
519 // Do I need to look for the top volume ?
520 if ((fTopVisible && vis) || !vol->GetNdaughters() || !vol->IsVisDaughters() || vol->IsVisOnly())
521 count++;
522 // Is this the only volume?
523 if (volume->IsVisOnly())
524 return count;
525
526 // Do we need to check a branch only?
527 if (volume->IsVisBranch()) {
530 count = fGeoManager->GetLevel() + 1;
532 return count;
533 }
534 // Iterate the volume content
535 TGeoIterator next(vol);
537 Int_t level, nd;
538 Bool_t last;
539
540 while ((daughter = next())) {
541 // vol = daughter->GetVolume();
542 level = next.GetLevel();
543 nd = daughter->GetNdaughters();
544 vis = daughter->IsVisible();
545 if (volume->IsVisContainers()) {
546 if (vis && level <= rlevel)
547 count++;
548 // Check if we have to skip this branch
549 if (level == rlevel || !daughter->IsVisDaughters()) {
550 next.Skip();
551 continue;
552 }
553 } else if (volume->IsVisLeaves()) {
554 last = ((nd == 0) || (level == rlevel) || (!daughter->IsVisDaughters())) ? kTRUE : kFALSE;
555 if (vis && last)
556 count++;
557 // Check if we have to skip the branch
558 if (last)
559 next.Skip();
560 }
561 }
562 return count;
563}
564
565////////////////////////////////////////////////////////////////////////////////
566/// Count total number of visible nodes.
567
569{
571 Int_t vislevel = fGeoManager->GetVisLevel();
572 // TGeoVolume *top = fGeoManager->GetTopVolume();
573 TGeoVolume *top = fTopVolume;
574 if (maxnodes <= 0 && top) {
575 fNVisNodes = CountNodes(top, vislevel);
576 SetVisLevel(vislevel);
577 return fNVisNodes;
578 }
579 // if (the total number of nodes of the top volume is less than maxnodes
580 // we can visualize everything.
581 // recompute the best visibility level
582 if (!top) {
583 SetVisLevel(vislevel);
584 return 0;
585 }
586 fNVisNodes = -1;
588 for (Int_t level = 1; level < 20; level++) {
589 vislevel = level;
590 Int_t nnodes = CountNodes(top, level);
591 if (top->IsVisOnly() || top->IsVisBranch()) {
592 vislevel = fVisLevel;
594 break;
595 }
596 if (nnodes > maxnodes) {
597 vislevel--;
598 break;
599 }
600 if (nnodes == fNVisNodes) {
601 if (again)
602 break;
603 again = kTRUE;
604 }
606 }
607 SetVisLevel(vislevel);
608 return fNVisNodes;
609}
610
611////////////////////////////////////////////////////////////////////////////////
612/// Check if Ged library is loaded and load geometry editor classe.
613
615{
616 if (fIsEditable)
617 return;
618 if (!TClass::GetClass("TGedEditor"))
619 return;
621 if ((h = gROOT->GetPluginManager()->FindHandler("TGeoManagerEditor"))) {
622 if (h->LoadPlugin() == -1)
623 return;
624 h->ExecPlugin(0);
625 }
627}
628
629////////////////////////////////////////////////////////////////////////////////
630/// Start the geometry editor.
631
633{
634 if (!gPad)
635 return;
636 if (!fIsEditable) {
637 if (!option[0])
638 gPad->GetCanvas()->GetCanvasImp()->ShowEditor();
639 else
641 CheckEdit();
642 }
643 gPad->SetSelected(fGeoManager);
644 gPad->GetCanvas()->Selected(gPad, fGeoManager, kButton1Down);
645}
646
647////////////////////////////////////////////////////////////////////////////////
648/// Draw method.
649
654
655////////////////////////////////////////////////////////////////////////////////
656/// Draw the time evolution of a radionuclide.
657
659{
660 Int_t ncoeff = sol->GetNcoeff();
661 if (!ncoeff)
662 return;
663 Double_t tlo = 0., thi = 0.;
664 Double_t cn = 0., lambda = 0.;
665 Int_t i;
666 sol->GetRange(tlo, thi);
667 Bool_t autorange = (thi == 0.) ? kTRUE : kFALSE;
668
669 // Try to find the optimum range in time.
670 if (autorange)
671 tlo = 0.;
672 sol->GetCoeff(0, cn, lambda);
673 Double_t lambdamin = lambda;
674 TString formula = "";
675 for (i = 0; i < ncoeff; i++) {
676 sol->GetCoeff(i, cn, lambda);
677 formula += TString::Format("%g*exp(-%g*x)", cn, lambda);
678 if (i < ncoeff - 1)
679 formula += "+";
681 lambdamin = lambda;
682 }
683 if (autorange)
684 thi = 10. / lambdamin;
685 // Create a function
686 TF1 *func = new TF1(TString::Format("conc%s", sol->GetElement()->GetName()), formula.Data(), tlo, thi);
687 func->SetTitle(formula + ";time[s]" + TString::Format(";Concentration_of_%s", sol->GetElement()->GetName()));
688 func->SetMinimum(1.e-3);
689 func->SetMaximum(1.25 * TMath::Max(sol->Concentration(tlo), sol->Concentration(thi)));
690 func->SetLineColor(sol->GetLineColor());
691 func->SetLineStyle(sol->GetLineStyle());
692 func->SetLineWidth(sol->GetLineWidth());
693 func->SetMarkerColor(sol->GetMarkerColor());
694 func->SetMarkerStyle(sol->GetMarkerStyle());
695 func->SetMarkerSize(sol->GetMarkerSize());
696 func->Draw(option);
697}
698
699////////////////////////////////////////////////////////////////////////////////
700/// Draw a polygon in 3D.
701
703{
704 Int_t nvert = poly->GetNvert();
705 if (!nvert) {
706 Error("DrawPolygon", "No vertices defined");
707 return;
708 }
709 Int_t nconv = poly->GetNconvex();
710 Double_t *x = new Double_t[nvert + 1];
711 Double_t *y = new Double_t[nvert + 1];
712 poly->GetVertices(x, y);
713 x[nvert] = x[0];
714 y[nvert] = y[0];
715 TGraph *g1 = new TGraph(nvert + 1, x, y);
716 g1->SetTitle(Form("Polygon with %d vertices (outscribed %d)", nvert, nconv));
717 g1->SetLineColor(kRed);
718 g1->SetMarkerColor(kRed);
719 g1->SetMarkerStyle(4);
720 g1->SetMarkerSize(0.8);
721 delete[] x;
722 delete[] y;
723 Double_t *xc = nullptr;
724 Double_t *yc = nullptr;
725 TGraph *g2 = nullptr;
726 if (nconv && !poly->IsConvex()) {
727 xc = new Double_t[nconv + 1];
728 yc = new Double_t[nconv + 1];
729 poly->GetConvexVertices(xc, yc);
730 xc[nconv] = xc[0];
731 yc[nconv] = yc[0];
732 g2 = new TGraph(nconv + 1, xc, yc);
733 g2->SetLineColor(kBlue);
734 g2->SetLineColor(kBlue);
735 g2->SetMarkerColor(kBlue);
736 g2->SetMarkerStyle(21);
737 g2->SetMarkerSize(0.4);
738 delete[] xc;
739 delete[] yc;
740 }
741 if (!gPad) {
742 gROOT->MakeDefCanvas();
743 }
744 g1->Draw("ALP");
745 if (g2)
746 g2->Draw("LP");
747}
748
749////////////////////////////////////////////////////////////////////////////////
750/// Draw method.
751
753{
754 fTopVolume = vol;
755 fLastVolume = nullptr;
757 // if (fVisOption==kGeoVisOnly ||
758 // fVisOption==kGeoVisBranch) fGeoManager->SetVisOption(kGeoVisLeaves);
760 TString opt = option;
761 opt.ToLower();
763 fOverlap = nullptr;
764
765 if (fVisLock) {
768 }
769 Bool_t has_pad = (gPad == nullptr) ? kFALSE : kTRUE;
770 // Clear pad if option "same" not given
771 if (!gPad) {
772 gROOT->MakeDefCanvas();
773 }
774 if (!opt.Contains("same"))
775 gPad->Clear();
776 // append this volume to pad
778
779 // Create a 3-D view
780 TView *view = gPad->GetView();
781 if (!view) {
782 view = TView::CreateView(11, nullptr, nullptr);
783 // Set the view to perform a first autorange (frame) draw.
784 // TViewer3DPad will revert view to normal painting after this
785 view->SetAutoRange(kTRUE);
786 if (has_pad)
787 gPad->Update();
788 }
789 if (!opt.Contains("same"))
790 Paint("range");
791 else
792 Paint(opt);
793 view->SetAutoRange(kFALSE);
794 // If we are drawing into the pad, then the view needs to be
795 // set to perspective
796 // if (!view->IsPerspective()) view->SetPerspective();
797
799
800 // Create a 3D viewer to paint us
801 gPad->GetViewer3D(option);
802}
803
804////////////////////////////////////////////////////////////////////////////////
805/// Draw a shape.
806
808{
809 TString opt = option;
810 opt.ToLower();
812 fOverlap = nullptr;
814
815 Bool_t has_pad = (gPad == nullptr) ? kFALSE : kTRUE;
816 // Clear pad if option "same" not given
817 if (!gPad) {
818 gROOT->MakeDefCanvas();
819 }
820 if (!opt.Contains("same"))
821 gPad->Clear();
822 // append this shape to pad
823 shape->AppendPad(option);
824
825 // Create a 3-D view
826 TView *view = gPad->GetView();
827 if (!view) {
828 view = TView::CreateView(11, nullptr, nullptr);
829 // Set the view to perform a first autorange (frame) draw.
830 // TViewer3DPad will revert view to normal painting after this
831 view->SetAutoRange(kTRUE);
832 if (has_pad)
833 gPad->Update();
834 }
835 PaintShape(shape, "range");
836 view->SetAutoRange(kFALSE);
837 view->SetPerspective();
838 // Create a 3D viewer to paint us
839 gPad->GetViewer3D(option);
840}
841
842////////////////////////////////////////////////////////////////////////////////
843/// Draw an overlap.
844
846{
847 TString opt = option;
850 if (!overlap)
851 return;
852
855 opt.ToLower();
856 if (fVisLock) {
859 }
860 Bool_t has_pad = (gPad == nullptr) ? kFALSE : kTRUE;
861 // Clear pad if option "same" not given
862 if (!gPad) {
863 gROOT->MakeDefCanvas();
864 }
865 if (!opt.Contains("same"))
866 gPad->Clear();
867 // append this volume to pad
868 overlap->AppendPad(option);
869
870 // Create a 3-D view
871 // Create a 3D viewer to paint us
872 gPad->GetViewer3D(option);
873 TView *view = gPad->GetView();
874 if (!view) {
875 view = TView::CreateView(11, nullptr, nullptr);
876 // Set the view to perform a first autorange (frame) draw.
877 // TViewer3DPad will revert view to normal painting after this
878 view->SetAutoRange(kTRUE);
879 PaintOverlap(ovlp, "range");
880 overlap->GetPolyMarker()->Draw("SAME");
881 if (has_pad)
882 gPad->Update();
883 }
884
885 // If we are drawing into the pad, then the view needs to be
886 // set to perspective
887 // if (!view->IsPerspective()) view->SetPerspective();
888 fVisLock = kTRUE;
889}
890
891////////////////////////////////////////////////////////////////////////////////
892/// Draw only one volume.
893
895{
896 TString opt = option;
897 opt.ToLower();
898 if (fVisLock) {
901 }
904 Bool_t has_pad = (gPad == nullptr) ? kFALSE : kTRUE;
905 // Clear pad if option "same" not given
906 if (!gPad) {
907 gROOT->MakeDefCanvas();
908 }
909 if (!opt.Contains("same"))
910 gPad->Clear();
911 // append this volume to pad
914
915 // Create a 3-D view
916 TView *view = gPad->GetView();
917 if (!view) {
918 view = TView::CreateView(11, nullptr, nullptr);
919 // Set the view to perform a first autorange (frame) draw.
920 // TViewer3DPad will revert view to normal painting after this
921 view->SetAutoRange(kTRUE);
923 if (has_pad)
924 gPad->Update();
925 }
926
927 // If we are drawing into the pad, then the view needs to be
928 // set to perspective
929 // if (!view->IsPerspective()) view->SetPerspective();
930 fVisLock = kTRUE;
931}
932
933////////////////////////////////////////////////////////////////////////////////
934/// Draw current point in the same view.
935
937{
938 if (!gPad)
939 return;
940 if (!gPad->GetView())
941 return;
943 pm->SetMarkerColor(color);
944 const Double_t *point = fGeoManager->GetCurrentPoint();
945 pm->SetNextPoint(point[0], point[1], point[2]);
946 pm->SetMarkerStyle(8);
947 pm->SetMarkerSize(0.5);
948 pm->Draw("SAME");
949}
950
951////////////////////////////////////////////////////////////////////////////////
952
954
955////////////////////////////////////////////////////////////////////////////////
956/// Draw all volumes for a given path.
957
967
968////////////////////////////////////////////////////////////////////////////////
969/// Estimate camera movement between tmin and tmax for best track display
970
972{
973 if (!gPad)
974 return;
975 TIter next(gPad->GetListOfPrimitives());
977 TObject *obj;
978 Int_t ntracks = 0;
979 Double_t *point = nullptr;
980 AddTrackPoint(point, start, kTRUE);
981 while ((obj = next())) {
982 if (strcmp(obj->ClassName(), "TGeoTrack"))
983 continue;
984 track = (TVirtualGeoTrack *)obj;
985 ntracks++;
986 track->PaintCollect(tmin, start);
987 }
988
989 if (!ntracks)
990 return;
991 next.Reset();
992 AddTrackPoint(point, end, kTRUE);
993 while ((obj = next())) {
994 if (strcmp(obj->ClassName(), "TGeoTrack"))
995 continue;
996 track = (TVirtualGeoTrack *)obj;
997 if (!track)
998 continue;
999 track->PaintCollect(tmax, end);
1000 }
1001}
1002
1003////////////////////////////////////////////////////////////////////////////////
1004/// Execute mouse actions on a given volume.
1005
1006void TGeoPainter::ExecuteManagerEvent(TGeoManager * /*geom*/, Int_t event, Int_t /*px*/, Int_t /*py*/)
1007{
1008 if (!gPad)
1009 return;
1010 gPad->SetCursor(kPointer);
1011 switch (event) {
1012 case kButton1Down:
1013 if (!fIsEditable)
1014 CheckEdit();
1015 }
1016}
1017
1018////////////////////////////////////////////////////////////////////////////////
1019/// Execute mouse actions on a given shape.
1020
1021void TGeoPainter::ExecuteShapeEvent(TGeoShape * /*shape*/, Int_t event, Int_t /*px*/, Int_t /*py*/)
1022{
1023 if (!gPad)
1024 return;
1025 gPad->SetCursor(kHand);
1026 switch (event) {
1027 case kButton1Down:
1028 if (!fIsEditable)
1029 CheckEdit();
1030 }
1031}
1032
1033////////////////////////////////////////////////////////////////////////////////
1034/// Execute mouse actions on a given volume.
1035
1036void TGeoPainter::ExecuteVolumeEvent(TGeoVolume * /*volume*/, Int_t event, Int_t /*px*/, Int_t /*py*/)
1037{
1038 if (!gPad)
1039 return;
1040 if (!fIsEditable)
1041 CheckEdit();
1042 // if (fIsRaytracing) return;
1043 // Bool_t istop = (volume==fTopVolume)?kTRUE:kFALSE;
1044 // if (istop) gPad->SetCursor(kHand);
1045 // else gPad->SetCursor(kPointer);
1046 gPad->SetCursor(kHand);
1047 // static Int_t width, color;
1048 switch (event) {
1049 case kMouseEnter:
1050 // width = volume->GetLineWidth();
1051 // color = volume->GetLineColor();
1052 break;
1053
1054 case kMouseLeave:
1055 // volume->SetLineWidth(width);
1056 // volume->SetLineColor(color);
1057 break;
1058
1059 case kButton1Down:
1060 // volume->SetLineWidth(3);
1061 // volume->SetLineColor(2);
1062 // gPad->Modified();
1063 // gPad->Update();
1064 break;
1065
1066 case kButton1Up:
1067 // volume->SetLineWidth(width);
1068 // volume->SetLineColor(color);
1069 // gPad->Modified();
1070 // gPad->Update();
1071 break;
1072
1073 case kButton1Double:
1074 gPad->SetCursor(kWatch);
1075 GrabFocus();
1076 break;
1077 }
1078}
1079
1080////////////////////////////////////////////////////////////////////////////////
1081/// Get some info about the current selected volume.
1082
1083const char *TGeoPainter::GetVolumeInfo(const TGeoVolume *volume, Int_t /*px*/, Int_t /*py*/) const
1084{
1085 static TString info;
1086 info = "";
1087 if (!gPad)
1088 return info;
1089 if (fPaintingOverlaps) {
1090 if (!fOverlap) {
1091 info = "wrong overlapping flag";
1092 return info;
1093 }
1095 if (fOverlap->IsExtrusion())
1096 ovtype = "EXTRUSION";
1097 else
1098 ovtype = "OVERLAP";
1099 if (volume == fOverlap->GetFirstVolume())
1100 name = volume->GetName();
1101 else
1103 info = TString::Format("%s: %s of %g", name.Data(), ovtype.Data(), fOverlap->GetOverlap());
1104 return info;
1105 } else
1106 info = TString::Format("%s, shape=%s", fVolInfo.Data(), volume->GetShape()->ClassName());
1107 return info;
1108}
1109
1110////////////////////////////////////////////////////////////////////////////////
1111/// Get the current view angles.
1112
1114{
1115 if (!gPad)
1116 return;
1117 TView *view = gPad->GetView();
1118 if (!view)
1119 return;
1120 longitude = view->GetLongitude();
1121 latitude = view->GetLatitude();
1122 psi = view->GetPsi();
1123}
1124
1125////////////////////////////////////////////////////////////////////////////////
1126/// Move focus to current volume
1127
1129{
1130 if (!gPad)
1131 return;
1132 TView *view = gPad->GetView();
1133 if (!view)
1134 return;
1136 printf("Woops!!!\n");
1138 memcpy(&fCheckedBox[0], box->GetOrigin(), 3 * sizeof(Double_t));
1139 fCheckedBox[3] = box->GetDX();
1140 fCheckedBox[4] = box->GetDY();
1141 fCheckedBox[5] = box->GetDZ();
1142 }
1143 view->SetPerspective();
1145 Int_t nframes = nfr;
1146 if (nfr == 0) {
1147 nframes = 1;
1148 if (nvols < 1500)
1149 nframes = 10;
1150 if (nvols < 1000)
1151 nframes = 20;
1152 if (nvols < 200)
1153 nframes = 50;
1154 if (nvols < 100)
1155 nframes = 100;
1156 }
1158}
1159
1160////////////////////////////////////////////////////////////////////////////////
1161/// Convert a local vector according view rotation matrix
1162
1164{
1165 for (Int_t i = 0; i < 3; i++)
1166 master[i] = -local[0] * fMat[i] - local[1] * fMat[i + 3] - local[2] * fMat[i + 6];
1167}
1168
1169////////////////////////////////////////////////////////////////////////////////
1170/// Check if a pad and view are present and send signal "Modified" to pad.
1171
1173{
1174 if (!gPad)
1175 return;
1176 if (update) {
1177 gPad->Update();
1178 return;
1179 }
1180 TView *view = gPad->GetView();
1181 if (!view)
1182 return;
1183 view->SetViewChanged();
1184 gPad->Modified();
1185 if (gROOT->FromPopUp())
1186 gPad->Update();
1187}
1188
1189////////////////////////////////////////////////////////////////////////////////
1190/// Paint current geometry according to option.
1191
1193{
1194 if (!fGeoManager || !fTopVolume)
1195 return;
1197 if (gPad)
1198 is_padviewer = (!strcmp(gPad->GetViewer3D()->ClassName(), "TViewer3DPad")) ? kTRUE : kFALSE;
1199
1203 else if (fTopVolume->IsVisLeaves())
1205 else if (fTopVolume->IsVisOnly())
1207 else if (fTopVolume->IsVisBranch())
1209
1210 if (!fIsRaytracing || !is_padviewer) {
1211 if (fGeoManager->IsDrawingExtra()) {
1212 // loop the list of physical volumes
1213 fGeoManager->CdTop();
1215 Int_t nnodes = nodeList->GetEntriesFast();
1216 Int_t inode;
1217 TGeoPhysicalNode *node;
1218 for (inode = 0; inode < nnodes; inode++) {
1219 node = (TGeoPhysicalNode *)nodeList->UncheckedAt(inode);
1221 }
1222 } else {
1224 }
1225 fVisLock = kTRUE;
1226 }
1227 // Check if we have to raytrace (only in pad)
1229 Raytrace();
1230}
1231
1232////////////////////////////////////////////////////////////////////////////////
1233/// Paint an overlap.
1234
1236{
1237 if (!fGeoManager)
1238 return;
1240 if (!overlap)
1241 return;
1242 Int_t color, transparency;
1243 if (fOverlap != overlap)
1244 fOverlap = overlap;
1247 TGeoVolume *vol;
1248 TGeoVolume *vol1 = overlap->GetFirstVolume();
1249 TGeoVolume *vol2 = overlap->GetSecondVolume();
1250 TGeoHMatrix *matrix1 = overlap->GetFirstMatrix();
1251 TGeoHMatrix *matrix2 = overlap->GetSecondMatrix();
1252 //
1253 vol = vol1;
1254 *hmat = matrix1;
1255 fGeoManager->SetMatrixReflection(matrix1->IsReflection());
1256 if (!fVisLock)
1257 fVisVolumes->Add(vol);
1259 color = vol->GetLineColor();
1261 vol->SetLineColor(kGreen);
1262 vol->SetTransparency(40);
1263 if (!strstr(option, "range"))
1264 ((TAttLine *)vol)->Modify();
1265 PaintShape(*(vol->GetShape()), option);
1266 vol->SetLineColor(color);
1268 vol = vol2;
1269 *hmat = matrix2;
1270 fGeoManager->SetMatrixReflection(matrix2->IsReflection());
1271 if (!fVisLock)
1272 fVisVolumes->Add(vol);
1274 color = vol->GetLineColor();
1276 vol->SetLineColor(kBlue);
1277 vol->SetTransparency(40);
1278 if (!strstr(option, "range"))
1279 ((TAttLine *)vol)->Modify();
1280 PaintShape(*(vol->GetShape()), option);
1281 vol->SetLineColor(color);
1284 fVisLock = kTRUE;
1285}
1286
1287////////////////////////////////////////////////////////////////////////////////
1288/// Paint recursively a node and its content according to visualization options.
1289
1294
1295////////////////////////////////////////////////////////////////////////////////
1296/// Paint recursively a node and its content according to visualization options.
1297
1299{
1300 if (fTopVolume != top) {
1302 fVisLock = kFALSE;
1303 }
1304 fTopVolume = top;
1305 if (!fVisLevel)
1306 return;
1307 TGeoVolume *vol = top;
1308 if (global)
1309 *fGlobal = *global;
1310 else
1311 fGlobal->Clear();
1314 Bool_t vis = (top->IsVisible() && !top->IsAssembly());
1315 Int_t transparency = 0;
1316
1317 // Update pad attributes in case we need to paint VOL
1318 if (!strstr(option, "range"))
1319 ((TAttLine *)vol)->Modify();
1320
1321 // Do we need to draw a branch ?
1322 if (top->IsVisBranch()) {
1325 // while (fGeoManager->GetLevel()) {
1327 if (!fVisLock) {
1328 fVisVolumes->Add(vol);
1330 }
1333 vol->SetTransparency(40);
1334 if (!strstr(option, "range"))
1335 ((TAttLine *)vol)->Modify();
1336 if (global) {
1337 *fGlobal = *global;
1339 } else {
1341 }
1343 PaintShape(*(vol->GetShape()), option);
1345 fGeoManager->CdUp();
1346 // }
1347 fVisLock = kTRUE;
1350 return;
1351 }
1352
1353 // Do I need to draw the top volume ?
1354 if ((fTopVisible && vis) || !top->GetNdaughters() || !top->IsVisDaughters() || top->IsVisOnly()) {
1357 PaintShape(*(vol->GetShape()), option);
1358 if (!fVisLock && !vol->TestAttBit(TGeoAtt::kVisOnScreen)) {
1359 fVisVolumes->Add(vol);
1361 }
1362 if (top->IsVisOnly() || !top->GetNdaughters() || !top->IsVisDaughters()) {
1363 fVisLock = kTRUE;
1364 return;
1365 }
1366 }
1367
1368 // Iterate the volume content
1369 TGeoIterator next(vol);
1370 if (fPlugin)
1371 next.SetUserPlugin(fPlugin);
1373 // TGeoMatrix *glmat;
1374 Int_t level, nd;
1375 Bool_t last;
1376 Int_t line_color = 0, line_width = 0, line_style = 0;
1377 while ((daughter = next())) {
1378 vol = daughter->GetVolume();
1380 level = next.GetLevel();
1381 nd = daughter->GetNdaughters();
1382 vis = daughter->IsVisible();
1384 if (top->IsVisContainers()) {
1385 if (vis && level <= fVisLevel) {
1386 if (fPlugin) {
1387 line_color = vol->GetLineColor();
1388 line_width = vol->GetLineWidth();
1389 line_style = vol->GetLineStyle();
1392 }
1393 if (!strstr(option, "range"))
1394 ((TAttLine *)vol)->Modify();
1395 if (global) {
1396 *fGlobal = *global;
1397 *fGlobal *= *next.GetCurrentMatrix();
1398 } else {
1399 *fGlobal = next.GetCurrentMatrix();
1400 }
1403 if (fPlugin) {
1408 }
1409 if (!fVisLock && !daughter->IsOnScreen()) {
1410 fVisVolumes->Add(vol);
1412 }
1413 }
1414 // Check if we have to skip this branch
1415 if (!drawDaughters || level == fVisLevel || !daughter->IsVisDaughters()) {
1416 next.Skip();
1417 continue;
1418 }
1419 } else if (top->IsVisLeaves()) {
1420 last = ((nd == 0) || (level == fVisLevel) || (!daughter->IsVisDaughters())) ? kTRUE : kFALSE;
1421 if (vis && last) {
1422 if (fPlugin) {
1423 line_color = vol->GetLineColor();
1424 line_width = vol->GetLineWidth();
1425 line_style = vol->GetLineStyle();
1428 }
1429 if (!strstr(option, "range"))
1430 ((TAttLine *)vol)->Modify();
1431 if (global) {
1432 *fGlobal = *global;
1433 *fGlobal *= *next.GetCurrentMatrix();
1434 } else {
1435 *fGlobal = next.GetCurrentMatrix();
1436 }
1439 if (fPlugin) {
1444 }
1445 if (!fVisLock && !daughter->IsOnScreen()) {
1446 fVisVolumes->Add(vol);
1448 }
1449 }
1450 // Check if we have to skip the branch
1451 if (!drawDaughters || last || !daughter->IsVisDaughters())
1452 next.Skip();
1453 }
1454 }
1455 if (fPlugin)
1456 fPlugin->SetIterator(nullptr);
1458 fVisLock = kTRUE;
1459}
1460
1461////////////////////////////////////////////////////////////////////////////////
1462/// Paint the supplied shape into the current 3D viewer
1463
1465{
1467
1468 TVirtualViewer3D *viewer = gPad->GetViewer3D();
1469
1470 if (!viewer || shape.IsA() == TGeoShapeAssembly::Class()) {
1471 return addDaughters;
1472 }
1473
1474 // For non-composite shapes we are the main paint method & perform the negotiation
1475 // with the viewer here
1476 if (!shape.IsComposite()) {
1477 // Does viewer prefer local frame positions?
1478 Bool_t localFrame = viewer->PreferLocalFrame();
1479 // Perform first fetch of buffer from the shape and try adding it
1480 // to the viewer
1481 const TBuffer3D &buffer =
1483 Int_t reqSections = viewer->AddObject(buffer, &addDaughters);
1484
1485 // If the viewer requires additional sections fetch from the shape (if possible)
1486 // and add again
1489 viewer->AddObject(buffer, &addDaughters);
1490 }
1491 }
1492 // Composite shapes have their own internal hierarchy of shapes, each
1493 // of which generate a filled TBuffer3D. Therefore we can't pass up a
1494 // single buffer to here. So as a special case the TGeoCompositeShape
1495 // performs it's own painting & negotiation with the viewer.
1496 else {
1497 const TGeoCompositeShape *composite = static_cast<const TGeoCompositeShape *>(&shape);
1498
1499 // We need the addDaughters flag returned from the viewer from paint
1500 // so can't use the normal TObject::Paint()
1501 // TGeoHMatrix *matrix = (TGeoHMatrix*)TGeoShape::GetTransform();
1502 // if (viewer->PreferLocalFrame()) matrix->Clear();
1503 addDaughters = composite->PaintComposite(option);
1504 }
1505
1506 return addDaughters;
1507}
1508
1509////////////////////////////////////////////////////////////////////////////////
1510/// Paint an overlap.
1511
1519
1520////////////////////////////////////////////////////////////////////////////////
1521/// Paints a physical node associated with a path.
1522
1524{
1525 if (!node->IsVisible())
1526 return;
1527 Int_t level = node->GetLevel();
1528 Int_t i, col, wid, sty;
1529 TGeoShape *shape;
1533 if (!node->IsVisibleFull()) {
1534 // Paint only last node in the branch
1535 vcrt = node->GetVolume();
1536 if (!strstr(option, "range"))
1537 ((TAttLine *)vcrt)->Modify();
1538 shape = vcrt->GetShape();
1539 *matrix = node->GetMatrix();
1540 fGeoManager->SetMatrixReflection(matrix->IsReflection());
1542 if (!node->IsVolAttributes() && !strstr(option, "range")) {
1543 col = vcrt->GetLineColor();
1544 wid = vcrt->GetLineWidth();
1545 sty = vcrt->GetLineStyle();
1546 vcrt->SetLineColor(node->GetLineColor());
1547 vcrt->SetLineWidth(node->GetLineWidth());
1548 vcrt->SetLineStyle(node->GetLineStyle());
1549 ((TAttLine *)vcrt)->Modify();
1550 PaintShape(*shape, option);
1551 vcrt->SetLineColor(col);
1552 vcrt->SetLineWidth(wid);
1553 vcrt->SetLineStyle(sty);
1554 } else {
1555 PaintShape(*shape, option);
1556 }
1557 } else {
1558 // Paint full branch, except top node
1559 for (i = 1; i <= level; i++) {
1560 vcrt = node->GetVolume(i);
1561 if (!strstr(option, "range"))
1562 ((TAttLine *)vcrt)->Modify();
1563 shape = vcrt->GetShape();
1564 *matrix = node->GetMatrix(i);
1565 fGeoManager->SetMatrixReflection(matrix->IsReflection());
1567 if (!node->IsVolAttributes() && !strstr(option, "range")) {
1568 col = vcrt->GetLineColor();
1569 wid = vcrt->GetLineWidth();
1570 sty = vcrt->GetLineStyle();
1571 vcrt->SetLineColor(node->GetLineColor());
1572 vcrt->SetLineWidth(node->GetLineWidth());
1573 vcrt->SetLineStyle(node->GetLineStyle());
1574 ((TAttLine *)vcrt)->Modify();
1575 PaintShape(*shape, option);
1576 vcrt->SetLineColor(col);
1577 vcrt->SetLineWidth(wid);
1578 vcrt->SetLineStyle(sty);
1579 } else {
1580 PaintShape(*shape, option);
1581 }
1582 }
1583 }
1585}
1586
1587////////////////////////////////////////////////////////////////////////////////
1588/// Raytrace current drawn geometry
1589
1591{
1592 if (!gPad || gPad->IsBatch())
1593 return;
1594 TView *view = gPad->GetView();
1595 if (!view)
1596 return;
1599 if (top != fTopVolume)
1601 if (!view->IsPerspective())
1602 view->SetPerspective();
1603 gVirtualX->SetMarkerSize(1);
1604 gVirtualX->SetMarkerStyle(1);
1607 Double_t lat = view->GetLatitude();
1608 Double_t longit = view->GetLongitude();
1609 Double_t psi = view->GetPsi();
1616 fMat[0] = c1 * c3 - s1 * c2 * s3;
1617 fMat[1] = c1 * s3 + s1 * c2 * c3;
1618 fMat[2] = s1 * s2;
1619
1620 fMat[3] = -s1 * c3 - c1 * c2 * s3;
1621 fMat[4] = -s1 * s3 + c1 * c2 * c3;
1622 fMat[5] = c1 * s2;
1623
1624 fMat[6] = s2 * s3;
1625 fMat[7] = -s2 * c3;
1626 fMat[8] = c2;
1627 Double_t u0, v0, du, dv;
1628 view->GetWindow(u0, v0, du, dv);
1629 Double_t dview = view->GetDview();
1630 Double_t dproj = view->GetDproj();
1631 Double_t local[3] = {0, 0, 1};
1632 Double_t dir[3], normal[3];
1634 Double_t min[3], max[3];
1635 view->GetRange(min, max);
1636 Double_t cov[3];
1637 for (Int_t i = 0; i < 3; i++)
1638 cov[i] = 0.5 * (min[i] + max[i]);
1639 Double_t cop[3];
1640 for (Int_t i = 0; i < 3; i++)
1641 cop[i] = cov[i] - dir[i] * dview;
1642 fGeoManager->InitTrack(cop, dir);
1645 if (fClippingShape)
1647 Int_t px, py;
1650 pxmin = gPad->UtoAbsPixel(0);
1651 pxmax = gPad->UtoAbsPixel(1);
1652 pymin = gPad->VtoAbsPixel(1);
1653 pymax = gPad->VtoAbsPixel(0);
1654 TGeoNode *next = nullptr;
1655 TGeoNode *nextnode = nullptr;
1656 Double_t step, steptot;
1657 Double_t *norm;
1658 const Double_t *point = fGeoManager->GetCurrentPoint();
1659 Double_t *ppoint = (Double_t *)point;
1660 Double_t tosource[3];
1661 Double_t calf;
1662 Double_t phi = 45. * krad;
1663 tosource[0] = -dir[0] * TMath::Cos(phi) + dir[1] * TMath::Sin(phi);
1664 tosource[1] = -dir[0] * TMath::Sin(phi) - dir[1] * TMath::Cos(phi);
1665 tosource[2] = -dir[2];
1666
1668
1669 Bool_t done;
1670 // Int_t istep;
1671 Int_t base_color, color;
1674 TPoint *pxy = new TPoint[1];
1676 Int_t up;
1677 Int_t ntotal = pxmax * pymax;
1678 Int_t nrays = 0;
1679 TStopwatch *timer = new TStopwatch();
1680 timer->Start();
1681 for (px = pxmin; px < pxmax; px++) {
1682 for (py = pymin; py < pymax; py++) {
1683 if ((nrays % 100) == 0)
1684 checker->OpProgress("Raytracing", nrays, ntotal, timer, kFALSE);
1685 nrays++;
1686 base_color = 1;
1687 steptot = 0;
1689 xloc = gPad->AbsPixeltoX(pxmin + pxmax - px);
1690 xloc = xloc * du - u0;
1691 yloc = gPad->AbsPixeltoY(pymin + pymax - py);
1692 yloc = yloc * dv - v0;
1694 local[0] = xloc / modloc;
1695 local[1] = yloc / modloc;
1696 local[2] = dproj / modloc;
1702 // fGeoManager->InitTrack(cop,dir);
1703 // current ray pointing to pixel (px,py)
1704 done = kFALSE;
1705 norm = nullptr;
1706 // propagate to the clipping shape if any
1707 if (fClippingShape) {
1708 if (inclip) {
1711 } else {
1713 stemin = 0;
1714 }
1715 }
1716
1717 while (!done) {
1718 if (fClippingShape) {
1719 if (stemin > 1E10)
1720 break;
1721 if (stemin > 0) {
1722 // we are inside clipping shape
1724 next = fGeoManager->Step();
1725 steptot = 0;
1726 stemin = 0;
1727 up = 0;
1728 while (next) {
1729 // we found something after clipping region
1730 nextvol = next->GetVolume();
1731 if (nextvol->TestAttBit(TGeoAtt::kVisOnScreen)) {
1732 done = kTRUE;
1733 base_color = nextvol->GetLineColor();
1735 norm = normal;
1736 break;
1737 }
1738 up++;
1739 next = fGeoManager->GetMother(up);
1740 }
1741 if (done)
1742 break;
1744 fGeoManager->SetStep(1E-3);
1745 while (inclip) {
1746 fGeoManager->Step();
1748 }
1750 }
1751 }
1753 step = fGeoManager->GetStep();
1754 if (step > 1E10)
1755 break;
1756 steptot += step;
1757 next = nextnode;
1758 // Check the step
1759 if (fClippingShape) {
1760 if (steptot > stemax) {
1761 steptot = 0;
1763 if (inclip) {
1766 continue;
1767 } else {
1768 stemin = 0;
1770 }
1771 }
1772 }
1773 // Check if next node is visible
1774 if (!nextnode)
1775 continue;
1776 nextvol = nextnode->GetVolume();
1777 if (nextvol->TestAttBit(TGeoAtt::kVisOnScreen)) {
1778 done = kTRUE;
1779 base_color = nextvol->GetLineColor();
1780 next = nextnode;
1781 break;
1782 }
1783 }
1784 if (!done)
1785 continue;
1786 // current ray intersect a visible volume having color=base_color
1787 if (rtMode > 0) {
1790 for (Int_t i = 0; i < 3; ++i)
1791 local[i] += 1.E-8 * dir[i];
1792 step = next->GetVolume()->GetShape()->DistFromInside(local, dir, 3);
1793 for (Int_t i = 0; i < 3; ++i)
1794 local[i] += step * dir[i];
1795 next->GetVolume()->GetShape()->ComputeNormal(local, dir, normal);
1796 norm = normal;
1797 } else {
1798 if (!norm)
1800 if (!norm)
1801 continue;
1802 }
1803 calf = norm[0] * tosource[0] + norm[1] * tosource[1] + norm[2] * tosource[2];
1805 color = GetColor(base_color, light);
1806 // Now we know the color of the pixel, just draw it
1807 gVirtualX->SetMarkerColor(color);
1808 pxy[0].fX = px;
1809 pxy[0].fY = py;
1810 gVirtualX->DrawPolyMarker(1, pxy);
1811 }
1812 }
1813 delete[] pxy;
1814 timer->Stop();
1815 checker->OpProgress("Raytracing", nrays, ntotal, timer, kTRUE);
1816 delete timer;
1817}
1818
1819////////////////////////////////////////////////////////////////////////////////
1820/// Set cartesian and radial bomb factors for translations.
1821
1831
1832////////////////////////////////////////////////////////////////////////////////
1833/// Set type of exploding view.
1834
1836{
1837 if ((ibomb < 0) || (ibomb > 3)) {
1838 Warning("SetExplodedView", "exploded view can be 0-3");
1839 return;
1840 }
1841 if ((Int_t)ibomb == fExplodedView)
1842 return;
1843 Bool_t change = (gPad == nullptr) ? kFALSE : kTRUE;
1844
1845 if (ibomb == kGeoNoBomb) {
1847 }
1848 if (ibomb == kGeoBombXYZ) {
1850 }
1851 if (ibomb == kGeoBombCyl) {
1853 }
1854 if (ibomb == kGeoBombSph) {
1856 }
1858 if (change)
1859 ModifiedPad();
1860}
1861
1862////////////////////////////////////////////////////////////////////////////////
1863/// Set number of segments to approximate circles.
1864
1866{
1867 if (nseg < 3) {
1868 Warning("SetNsegments", "number of segments should be > 2");
1869 return;
1870 }
1871 if (fNsegments == nseg)
1872 return;
1873 fNsegments = nseg;
1874 ModifiedPad();
1875}
1876
1877////////////////////////////////////////////////////////////////////////////////
1878/// Set default level down to which visualization is performed
1879
1881{
1882 if (level == fVisLevel && fLastVolume == fTopVolume)
1883 return;
1884 fVisLevel = level;
1885 if (!fTopVolume)
1886 return;
1887 if (fVisLock) {
1889 fVisLock = kFALSE;
1890 }
1891 if (!fLastVolume) {
1892 // printf("--- Drawing %6d nodes with %d visible levels\n",fNVisNodes,fVisLevel);
1893 return;
1894 }
1895 if (!gPad)
1896 return;
1897 if (gPad->GetView()) {
1898 // printf("--- Drawing %6d nodes with %d visible levels\n",fNVisNodes,fVisLevel);
1899 ModifiedPad();
1900 }
1901}
1902
1903////////////////////////////////////////////////////////////////////////////////
1904/// Set top geometry volume as visible.
1905
1907{
1908 if (fTopVisible == vis)
1909 return;
1910 fTopVisible = vis;
1911 ModifiedPad();
1912}
1913
1914////////////////////////////////////////////////////////////////////////////////
1915/// Set drawing mode :
1916/// - option=0 (default) all nodes drawn down to vislevel
1917/// - option=1 leaves and nodes at vislevel drawn
1918/// - option=2 path is drawn
1919
1921{
1922 if ((fVisOption < 0) || (fVisOption > 4)) {
1923 Warning("SetVisOption", "wrong visualization option");
1924 return;
1925 }
1926
1927 if (option == kGeoVisChanged) {
1928 if (fVisLock) {
1930 fVisLock = kFALSE;
1931 }
1932 ModifiedPad();
1933 return;
1934 }
1935
1936 if (fTopVolume) {
1938 att->SetAttBit(TGeoAtt::kVisBranch, kFALSE);
1939 att->SetAttBit(TGeoAtt::kVisContainers, kFALSE);
1940 att->SetAttBit(TGeoAtt::kVisOnly, kFALSE);
1941 switch (option) {
1942 case kGeoVisDefault: att->SetAttBit(TGeoAtt::kVisContainers, kTRUE); break;
1943 case kGeoVisLeaves: break;
1944 case kGeoVisOnly: att->SetAttBit(TGeoAtt::kVisOnly, kTRUE); break;
1945 }
1946 }
1947
1948 if (fVisOption == option)
1949 return;
1951 if (fVisLock) {
1953 fVisLock = kFALSE;
1954 }
1955 ModifiedPad();
1956}
1957
1958////////////////////////////////////////////////////////////////////////////////
1959/// Returns distance between point px,py on the pad an a shape.
1960
1962{
1963 const Int_t inaxis = 7;
1964 const Int_t maxdist = 5;
1965 const Int_t big = 9999;
1966 Int_t dist = big;
1967 if (!gPad)
1968 return dist;
1969 TView *view = gPad->GetView();
1970 if (!(numpoints && view))
1971 return dist;
1972 if (shape->IsA() == TGeoShapeAssembly::Class())
1973 return dist;
1974
1975 if (fIsPaintingShape) {
1976 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
1977 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
1978 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
1979 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
1980 // return if point not in user area
1981 if (px < puxmin - inaxis)
1982 return big;
1983 if (py > puymin + inaxis)
1984 return big;
1985 if (px > puxmax + inaxis)
1986 return big;
1987 if (py < puymax - inaxis)
1988 return big;
1989 if ((puxmax + inaxis - px) < 40) {
1990 // when the mouse points to the (40 pix) right edge of the pad, the manager class is selected
1991 gPad->SetSelected(fGeoManager);
1992 return 0;
1993 }
1994 }
1995
1996 fBuffer->SetRawSizes(numpoints, 3 * numpoints, 0, 0, 0, 0);
1998 shape->SetPoints(points);
1999 Double_t dpoint2, x1, y1, xndc[3];
2000 Double_t dmaster[3];
2001 Int_t j;
2002 for (Int_t i = 0; i < numpoints; i++) {
2003 j = 3 * i;
2004 TGeoShape::GetTransform()->LocalToMaster(&points[j], dmaster);
2005 points[j] = dmaster[0];
2006 points[j + 1] = dmaster[1];
2007 points[j + 2] = dmaster[2];
2008 view->WCtoNDC(&points[j], xndc);
2009 x1 = gPad->XtoAbsPixel(xndc[0]);
2010 y1 = gPad->YtoAbsPixel(xndc[1]);
2011 dpoint2 = (px - x1) * (px - x1) + (py - y1) * (py - y1);
2012 if (dpoint2 < dist)
2013 dist = (Int_t)dpoint2;
2014 }
2015 if (dist > 100)
2016 return dist;
2017 dist = Int_t(TMath::Sqrt(Double_t(dist)));
2018 if (dist < maxdist && fIsPaintingShape)
2019 gPad->SetSelected((TObject *)shape);
2020 return dist;
2021}
2022
2023////////////////////////////////////////////////////////////////////////////////
2024/// Get the new 'unbombed' translation vector according current exploded view mode.
2025
2027{
2028 memcpy(bombtr, tr, 3 * sizeof(Double_t));
2029 switch (fExplodedView) {
2030 case kGeoNoBomb: return;
2031 case kGeoBombXYZ:
2032 bombtr[0] /= fBombX;
2033 bombtr[1] /= fBombY;
2034 bombtr[2] /= fBombZ;
2035 return;
2036 case kGeoBombCyl:
2037 bombtr[0] /= fBombR;
2038 bombtr[1] /= fBombR;
2039 bombtr[2] /= fBombZ;
2040 return;
2041 case kGeoBombSph:
2042 bombtr[0] /= fBombR;
2043 bombtr[1] /= fBombR;
2044 bombtr[2] /= fBombR;
2045 return;
2046 default: return;
2047 }
2048}
@ kButton1Double
Definition Buttons.h:24
@ kButton1Up
Definition Buttons.h:19
@ kMouseLeave
Definition Buttons.h:23
@ kButton1Down
Definition Buttons.h:17
@ kMouseEnter
Definition Buttons.h:23
@ kWatch
Definition GuiTypes.h:375
@ kHand
Definition GuiTypes.h:374
@ kPointer
Definition GuiTypes.h:375
#define b(i)
Definition RSha256.hxx:100
#define g(i)
Definition RSha256.hxx:105
#define s1(x)
Definition RSha256.hxx:91
#define h(i)
Definition RSha256.hxx:106
static void update(gsl_integration_workspace *workspace, double a1, double b1, double area1, double error1, double a2, double b2, double area2, double error2)
int Int_t
Definition RtypesCore.h:45
float Float_t
Definition RtypesCore.h:57
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:374
@ kRed
Definition Rtypes.h:66
@ kBlack
Definition Rtypes.h:65
@ kGreen
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize wid
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
float xmin
float xmax
#define gROOT
Definition TROOT.h:414
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2489
#define gPad
#define gVirtualX
Definition TVirtualX.h:337
#define gSize3D
Definition X3DBuffer.h:40
const_iterator end() const
Line Attributes class.
Definition TAttLine.h:20
virtual Color_t GetLineColor() const
Return the line color.
Definition TAttLine.h:35
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:44
virtual Width_t GetLineWidth() const
Return the line width.
Definition TAttLine.h:37
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:45
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:42
virtual Style_t GetLineStyle() const
Return the line style.
Definition TAttLine.h:36
virtual void Modify()
Change current line attributes if necessary.
Definition TAttLine.cxx:247
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:39
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:41
virtual void SetMarkerSize(Size_t msize=1)
Set the marker size.
Definition TAttMarker.h:46
Generic 3D primitive description class.
Definition TBuffer3D.h:18
@ kBoundingBox
Definition TBuffer3D.h:51
@ kShapeSpecific
Definition TBuffer3D.h:52
Bool_t SetRawSizes(UInt_t reqPnts, UInt_t reqPntsCapacity, UInt_t reqSegs, UInt_t reqSegsCapacity, UInt_t reqPols, UInt_t reqPolsCapacity)
Set kRaw tessellation section of buffer with supplied sizes.
Double_t * fPnts
Definition TBuffer3D.h:113
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:3074
The color creation and management class.
Definition TColor.h:22
static void HLS2RGB(Float_t h, Float_t l, Float_t s, Float_t &r, Float_t &g, Float_t &b)
Static method to compute RGB from HLS.
Definition TColor.cxx:1582
static void InitializeColors()
Initialize colors used by the TCanvas based graphics (via TColor objects).
Definition TColor.cxx:1173
static Int_t CreateGradientColorTable(UInt_t Number, Double_t *Stops, Double_t *Red, Double_t *Green, Double_t *Blue, UInt_t NColors, Float_t alpha=1., Bool_t setPalette=kTRUE)
Static function creating a color table with several connected linear gradients.
Definition TColor.cxx:2743
static void RGB2HLS(Float_t r, Float_t g, Float_t b, Float_t &h, Float_t &l, Float_t &s)
Static method to compute HLS from RGB.
Definition TColor.cxx:1722
1-Dim function class
Definition TF1.h:234
virtual void SetMaximum(Double_t maximum=-1111)
Set the maximum value along Y for this function In case the function is already drawn,...
Definition TF1.cxx:3420
void SetTitle(const char *title="") override
Set function title if title has the form "fffffff;xxxx;yyyy", it is assumed that the function title i...
Definition TF1.cxx:3584
void Draw(Option_t *option="") override
Draw this function with its current attributes.
Definition TF1.cxx:1335
virtual void SetMinimum(Double_t minimum=-1111)
Set the minimum value along Y for this function In case the function is already drawn,...
Definition TF1.cxx:3433
Visualization and tracking attributes for volumes and nodes.
Definition TGeoAtt.h:17
Bool_t TestAttBit(UInt_t f) const
Definition TGeoAtt.h:64
Bool_t IsVisBranch() const
Definition TGeoAtt.h:85
@ kVisContainers
Definition TGeoAtt.h:32
@ kVisOnly
Definition TGeoAtt.h:33
@ kVisOnScreen
Definition TGeoAtt.h:31
@ kVisBranch
Definition TGeoAtt.h:34
void ResetAttBit(UInt_t f)
Definition TGeoAtt.h:63
void SetVisRaytrace(Bool_t flag=kTRUE)
Definition TGeoAtt.h:66
Bool_t IsVisDaughters() const
Definition TGeoAtt.h:84
void SetAttBit(UInt_t f)
Definition TGeoAtt.h:61
Box class.
Definition TGeoBBox.h:17
Class representing the Bateman solution for a decay branch.
Composite shapes are Boolean combinations of two or more shape components.
Matrix class used for computing global transformations Should NOT be used for node definition.
Definition TGeoMatrix.h:458
void Clear(Option_t *option="") override
clear the data for this matrix
void SetIterator(const TGeoIterator *iter)
Definition TGeoNode.h:237
virtual void ProcessNode()=0
A geometry iterator.
Definition TGeoNode.h:248
const TGeoMatrix * GetCurrentMatrix() const
Returns global matrix for current node.
void SetTopName(const char *name)
Set the top name for path.
Int_t GetLevel() const
Definition TGeoNode.h:294
void GetPath(TString &path) const
Returns the path for the current node.
void SetUserPlugin(TGeoIteratorPlugin *plugin)
Set a plugin.
void Skip()
Stop iterating the current branch.
The manager class for any TGeo geometry.
Definition TGeoManager.h:45
TGeoNode * GetMother(Int_t up=1) const
Double_t * FindNormalFast()
Computes fast normal to next crossed boundary, assuming that the current point is close enough to the...
void DoRestoreState()
Restore a backed-up state without affecting the cache stack.
const Double_t * GetCurrentDirection() const
TVirtualGeoChecker * GetGeomChecker()
Make a default checker if none present. Returns pointer to it.
void CdUp()
Go one level up in geometry.
void DoBackupState()
Backup the current state without affecting the cache stack.
TObjArray * GetListOfVolumes() const
void SetMatrixReflection(Bool_t flag=kTRUE)
virtual Bool_t cd(const char *path="")
Browse the tree of nodes starting from fTopNode according to pathname.
void LocalToMaster(const Double_t *local, Double_t *master) const
Int_t GetRTmode() const
Bool_t IsClosed() const
TGeoNode * GetCurrentNode() const
void SetCurrentDirection(Double_t *dir)
TGeoNode * Step(Bool_t is_geom=kTRUE, Bool_t cross=kTRUE)
Make a rectilinear step of length fStep from current point (fPoint) on current direction (fDirection)...
Bool_t IsDrawingExtra() const
void SetOutside(Bool_t flag=kTRUE)
TGeoNode * FindNextBoundaryAndStep(Double_t stepmax=TGeoShape::Big(), Bool_t compsafe=kFALSE)
Compute distance to next boundary within STEPMAX.
Int_t GetMaxVisNodes() const
void SetCurrentPoint(Double_t *point)
Int_t GetVisOption() const
Returns current depth to which geometry is drawn.
const Double_t * GetCurrentPoint() const
Bool_t IsOutside() const
TGeoNode * InitTrack(const Double_t *point, const Double_t *dir)
Initialize current point and current direction vector (normalized) in MARS.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
Int_t GetLevel() const
Double_t GetStep() const
TGeoHMatrix * GetCurrentMatrix() const
TGeoNode * GetTopNode() const
void MasterToLocalVect(const Double_t *master, Double_t *local) const
void SetPaintVolume(TGeoVolume *vol)
void SetStep(Double_t step)
TGeoVolume * GetCurrentVolume() const
Int_t GetVisLevel() const
Returns current depth to which geometry is drawn.
Int_t GetBombMode() const
void CdTop()
Make top level node the current node.
void MasterToLocal(const Double_t *master, Double_t *local) const
Int_t PushPath(Int_t startlevel=0)
Int_t GetNsegments() const
Get number of segments approximating circles.
Bool_t IsNodeSelectable() const
TGeoVolume * GetTopVolume() const
TObjArray * GetListOfPhysicalNodes()
Bool_t PopPath()
virtual Int_t GetDefaultColor() const
Get some default color related to this material.
Geometrical transformation package.
Definition TGeoMatrix.h:38
Bool_t IsReflection() const
Definition TGeoMatrix.h:66
virtual void LocalToMaster(const Double_t *local, Double_t *master) const
convert a point by multiplying its column vector (x, y, z, 1) to matrix inverse
A node represent a volume positioned inside another.They store links to both volumes and to the TGeoM...
Definition TGeoNode.h:39
TGeoVolume * GetVolume() const
Definition TGeoNode.h:99
Base class describing geometry overlaps.
Definition TGeoOverlap.h:37
TGeoVolume * GetSecondVolume() const
Definition TGeoOverlap.h:66
TGeoHMatrix * GetFirstMatrix() const
Definition TGeoOverlap.h:67
Bool_t IsExtrusion() const
Definition TGeoOverlap.h:70
Double_t GetOverlap() const
Definition TGeoOverlap.h:69
TGeoHMatrix * GetSecondMatrix() const
Definition TGeoOverlap.h:68
TGeoVolume * GetFirstVolume() const
Definition TGeoOverlap.h:65
Class implementing all draw interfaces for a generic 3D viewer using TBuffer3D mechanism.
Definition TGeoPainter.h:37
TVirtualGeoTrack * AddTrack(Int_t id, Int_t pdgcode, TObject *part) override
Create a primary TGeoTrack.
void PaintOverlap(void *ovlp, Option_t *option="") override
Paint an overlap.
Double_t fBombZ
Definition TGeoPainter.h:41
void EstimateCameraMove(Double_t tmin, Double_t tmax, Double_t *start, Double_t *end) override
Estimate camera movement between tmin and tmax for best track display.
TObjArray * fVisVolumes
Definition TGeoPainter.h:66
TGeoIteratorPlugin * fPlugin
Definition TGeoPainter.h:65
Double_t fMat[9]
Definition TGeoPainter.h:44
TBuffer3D * fBuffer
Definition TGeoPainter.h:60
void BombTranslation(const Double_t *tr, Double_t *bombtr) override
Get the new 'bombed' translation vector according current exploded view mode.
void Paint(Option_t *option="") override
Paint current geometry according to option.
void EditGeometry(Option_t *option="") override
Start the geometry editor.
void GetViewAngles(Double_t &longitude, Double_t &latitude, Double_t &psi) override
Get the current view angles.
TGeoManager * fGeoManager
Definition TGeoPainter.h:61
void Raytrace(Option_t *option="") override
Raytrace current drawn geometry.
TString fVisBranch
Definition TGeoPainter.h:55
TGeoVolume * fTopVolume
Definition TGeoPainter.h:63
~TGeoPainter() override
Default destructor.
void SetVisOption(Int_t option=0) override
Set drawing mode :
Bool_t IsExplodedView() const override
Bool_t fIsPaintingShape
Definition TGeoPainter.h:54
Double_t fBombR
Definition TGeoPainter.h:42
Int_t ShapeDistancetoPrimitive(const TGeoShape *shape, Int_t numpoints, Int_t px, Int_t py) const override
Returns distance between point px,py on the pad an a shape.
void Draw(Option_t *option="") override
Draw method.
Int_t CountVisibleNodes() override
Count total number of visible nodes.
void DefineColors() const
Define 100 colors with increasing light intensities for each basic color (1-7) Register these colors ...
void SetExplodedView(Int_t iopt=0) override
Set type of exploding view.
void ExecuteManagerEvent(TGeoManager *geom, Int_t event, Int_t px, Int_t py) override
Execute mouse actions on a given volume.
TGeoVolume * fLastVolume
Definition TGeoPainter.h:64
Int_t DistanceToPrimitiveVol(TGeoVolume *vol, Int_t px, Int_t py) override
Compute the closest distance of approach from point px,py to a volume.
void UnbombTranslation(const Double_t *tr, Double_t *bombtr) override
Get the new 'unbombed' translation vector according current exploded view mode.
Bool_t fVisLock
Definition TGeoPainter.h:50
void PaintNode(TGeoNode *node, Option_t *option="", TGeoMatrix *global=nullptr) override
Paint recursively a node and its content according to visualization options.
void DefaultAngles() override
Set default angles for the current view.
TGeoShape * fClippingShape
Definition TGeoPainter.h:62
Bool_t PaintShape(const TGeoShape &shape, Option_t *option) const
Paint the supplied shape into the current 3D viewer.
Bool_t fIsEditable
Definition TGeoPainter.h:67
Int_t CountNodes(TGeoVolume *vol, Int_t level) const
Count number of visible nodes down to a given level.
Double_t fCheckedBox[6]
Definition TGeoPainter.h:43
void DrawShape(TGeoShape *shape, Option_t *option="") override
Draw a shape.
void DrawOnly(Option_t *option="") override
Draw only one volume.
TGeoOverlap * fOverlap
Definition TGeoPainter.h:58
Double_t fBombY
Definition TGeoPainter.h:40
Bool_t fPaintingOverlaps
Definition TGeoPainter.h:52
void SetBombFactors(Double_t bombx=1.3, Double_t bomby=1.3, Double_t bombz=1.3, Double_t bombr=1.3) override
Set cartesian and radial bomb factors for translations.
void DefaultColors() override
Set default volume colors according to tracking media.
void CheckEdit()
Check if Ged library is loaded and load geometry editor classe.
void ClearVisibleVolumes()
Clear the list of visible volumes reset the kVisOnScreen bit for volumes previously in the list.
Int_t GetColor(Int_t base, Float_t light) const override
Get index of a base color with given light intensity (0,1)
void LocalToMasterVect(const Double_t *local, Double_t *master) const
Convert a local vector according view rotation matrix.
void DrawVolume(TGeoVolume *vol, Option_t *option="") override
Draw method.
TGeoVolume * GetDrawnVolume() const override
Get currently drawn volume.
void DrawPolygon(const TGeoPolygon *poly) override
Draw a polygon in 3D.
Int_t fNsegments
Definition TGeoPainter.h:45
void PaintVolume(TGeoVolume *vol, Option_t *option="", TGeoMatrix *global=nullptr) override
Paint recursively a node and its content according to visualization options.
TString fVolInfo
Definition TGeoPainter.h:56
Bool_t fTopVisible
Definition TGeoPainter.h:51
TGeoHMatrix * fGlobal
Definition TGeoPainter.h:59
Int_t fVisLevel
Definition TGeoPainter.h:47
void SetNsegments(Int_t nseg=20) override
Set number of segments to approximate circles.
void AddTrackPoint(Double_t *point, Double_t *box, Bool_t reset=kFALSE) override
Average center of view of all painted tracklets and compute view box.
void GrabFocus(Int_t nfr=0, Double_t dlong=0, Double_t dlat=0, Double_t dpsi=0) override
Move focus to current volume.
void DrawOverlap(void *ovlp, Option_t *option="") override
Draw an overlap.
void SetVisLevel(Int_t level=3) override
Set default level down to which visualization is performed.
void AddSize3D(Int_t numpoints, Int_t numsegs, Int_t numpolys) override
Add numpoints, numsegs, numpolys to the global 3D size.
TGeoNode * fCheckedNode
Definition TGeoPainter.h:57
void PaintPhysicalNode(TGeoPhysicalNode *node, Option_t *option="")
Paints a physical node associated with a path.
Int_t fNVisNodes
Definition TGeoPainter.h:46
Int_t fExplodedView
Definition TGeoPainter.h:49
const char * GetVolumeInfo(const TGeoVolume *volume, Int_t px, Int_t py) const override
Get some info about the current selected volume.
void DrawCurrentPoint(Int_t color) override
Draw current point in the same view.
void DrawPath(const char *path, Option_t *option="") override
Draw all volumes for a given path.
void DrawBatemanSol(TGeoBatemanSol *sol, Option_t *option="") override
Draw the time evolution of a radionuclide.
Bool_t fIsRaytracing
Definition TGeoPainter.h:53
void ExecuteShapeEvent(TGeoShape *shape, Int_t event, Int_t px, Int_t py) override
Execute mouse actions on a given shape.
void ExecuteVolumeEvent(TGeoVolume *volume, Int_t event, Int_t px, Int_t py) override
Execute mouse actions on a given volume.
TGeoPainter(TGeoManager *manager)
Default constructor.
Double_t fBombX
Definition TGeoPainter.h:39
void ModifiedPad(Bool_t update=kFALSE) const override
Check if a pad and view are present and send signal "Modified" to pad.
void SetTopVisible(Bool_t vis=kTRUE) override
Set top geometry volume as visible.
void DrawPanel() override
Int_t fVisOption
Definition TGeoPainter.h:48
Physical nodes are the actual 'touchable' objects in the geometry, representing a path of positioned ...
Int_t GetLevel() const
Bool_t IsVisible() const
Bool_t IsVisibleFull() const
TGeoHMatrix * GetMatrix(Int_t level=-1) const
Return global matrix for node at LEVEL.
Bool_t IsVolAttributes() const
TGeoVolume * GetVolume(Int_t level=-1) const
Return volume associated with node at LEVEL in the branch.
An arbitrary polygon defined by vertices.
Definition TGeoPolygon.h:19
static TClass * Class()
Base abstract class for all shapes.
Definition TGeoShape.h:25
Int_t DistancetoPrimitive(Int_t px, Int_t py) override=0
Computes distance from point (px,py) to the object.
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections, Bool_t localFrame) const
Stub implementation to avoid forcing implementation at this stage.
static Double_t Big()
Definition TGeoShape.h:94
virtual Double_t DistFromInside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const =0
static void SetTransform(TGeoMatrix *matrix)
Set current transformation matrix that applies to shape.
virtual Bool_t IsComposite() const
Definition TGeoShape.h:138
virtual void ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm) const =0
virtual Double_t DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact=1, Double_t step=TGeoShape::Big(), Double_t *safe=nullptr) const =0
static TGeoMatrix * GetTransform()
Returns current transformation matrix that applies to shape.
virtual Bool_t Contains(const Double_t *point) const =0
virtual void SetPoints(Double_t *points) const =0
TClass * IsA() const override
Definition TGeoShape.h:179
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
Bool_t IsVisContainers() const
Definition TGeoVolume.h:157
void SetLineWidth(Width_t lwidth) override
Set the line width.
TGeoMaterial * GetMaterial() const
Definition TGeoVolume.h:174
Int_t GetNdaughters() const
Definition TGeoVolume.h:362
void SetTransparency(Char_t transparency=0)
Definition TGeoVolume.h:376
void SetLineColor(Color_t lcolor) override
Set the line color.
TGeoShape * GetShape() const
Definition TGeoVolume.h:190
Bool_t IsRaytracing() const
Check if the painter is currently ray-tracing the content of this volume.
Bool_t IsVisLeaves() const
Definition TGeoVolume.h:158
void SetLineStyle(Style_t lstyle) override
Set the line style.
Bool_t IsVisOnly() const
Definition TGeoVolume.h:159
virtual Bool_t IsAssembly() const
Returns true if the volume is an assembly or a scaled assembly.
Char_t GetTransparency() const
Definition TGeoVolume.h:369
virtual Bool_t IsVisible() const
Definition TGeoVolume.h:155
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
void Reset()
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntriesFast() const
Definition TObjArray.h:58
void Clear(Option_t *option="") override
Remove all objects from the array.
void Add(TObject *obj) override
Definition TObjArray.h:68
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
Definition TObject.cxx:1057
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1071
Longptr_t ExecPlugin(int nargs)
A 3D polymarker.
Stopwatch class.
Definition TStopwatch.h:28
Basic string class.
Definition TString.h:139
void ToLower()
Change string to lower-case.
Definition TString.cxx:1182
const char * Data() const
Definition TString.h:376
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2378
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:632
See TView3D.
Definition TView.h:25
virtual void SetPerspective()=0
virtual Double_t GetPsi()=0
virtual void GetWindow(Double_t &u0, Double_t &v0, Double_t &du, Double_t &dv) const =0
virtual Double_t GetLongitude()=0
virtual void WCtoNDC(const Float_t *pw, Float_t *pn)=0
virtual Double_t GetDview() const =0
static TView * CreateView(Int_t system=1, const Double_t *rmin=nullptr, const Double_t *rmax=nullptr)
Create a concrete default 3-d view via the plug-in manager.
Definition TView.cxx:27
virtual void SetAutoRange(Bool_t autorange=kTRUE)=0
virtual Double_t GetDproj() const =0
virtual Bool_t IsPerspective() const =0
virtual void SetViewChanged(Bool_t flag=kTRUE)=0
virtual void GetRange(Float_t *min, Float_t *max)=0
virtual Double_t GetLatitude()=0
virtual 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)=0
virtual void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)=0
Abstract class for geometry painters.
static void SetPainter(const TVirtualGeoPainter *painter)
Static function to set an alternative histogram painter.
Base class for user-defined tracks attached to a geometry.
static void ShowEditor()
Show the global pad editor. Static method.
Abstract 3D shapes viewer.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
return c2
Definition legend2.C:14
return c3
Definition legend3.C:15
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
constexpr Double_t DegToRad()
Conversion from degree to radian: .
Definition TMath.h:80
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:668
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Definition TMath.h:600
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Definition TMath.h:594
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.
Definition TMathBase.h:123
TLine l
Definition textangle.C:4