Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RGeoPainter.cxx
Go to the documentation of this file.
1// Author: Sergey Linev, 27.02.2020
2
3/*************************************************************************
4 * Copyright (C) 1995-2023, 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#include <ROOT/RGeoPainter.hxx>
12
13#include "TGeoVolume.h"
14#include "TGeoManager.h"
15#include "TVirtualPad.h"
16#include "TGeoTrack.h"
17
18using namespace ROOT;
19
21{
23 fGeoManager = manager;
24}
25
27
29{
30 return (TVirtualGeoTrack *)(new TGeoTrack(id, pdgcode, nullptr, particle));
31}
32
34{
35 static Int_t npoints = 0;
36 static Double_t xmin[3] = {0, 0, 0};
37 static Double_t xmax[3] = {0, 0, 0};
38 Int_t i;
39 if (reset) {
40 memset(box, 0, 6 * sizeof(Double_t));
41 memset(xmin, 0, 3 * sizeof(Double_t));
42 memset(xmax, 0, 3 * sizeof(Double_t));
43 npoints = 0;
44 return;
45 }
46 if (npoints == 0) {
47 for (i = 0; i < 3; i++)
48 xmin[i] = xmax[i] = 0;
49 npoints++;
50 }
51 npoints++;
52 Double_t ninv = 1. / Double_t(npoints);
53 for (i = 0; i < 3; i++) {
54 box[i] += ninv * (point[i] - box[i]);
55 if (point[i] < xmin[i])
56 xmin[i] = point[i];
57 if (point[i] > xmax[i])
58 xmax[i] = point[i];
59 box[i + 3] = 0.5 * (xmax[i] - xmin[i]);
60 }
61}
62
64{
65 fTopVisible = on ? 1 : 0;
66}
67
69{
70 if (fViewer && (fGeoManager != mgr))
71 fViewer->SetGeometry(fGeoManager);
72
73 fGeoManager = mgr;
74}
75
77{
78 if (gPad) {
79 auto g = vol->GetGeoManager();
80
81 // append volume or geomanager itself to the pad, web canvas also support geometry drawing now
82 if (g && (g->GetTopVolume() == vol))
83 g->AppendPad(opt);
84 else
85 vol->AppendPad(opt);
86
87 return;
88 }
89
90 if (!fViewer)
91 fViewer = std::make_shared<RGeomViewer>(fGeoManager);
92
93 // select volume to draw
94 fViewer->SetGeometry(fGeoManager, vol->GetName());
95
96 std::string drawopt = "";
97 if (opt && strstr(opt, "s"))
98 drawopt = "wire";
99
100 // specify JSROOT draw options - here clipping on X,Y,Z axes
101 fViewer->SetDrawOptions(drawopt);
102
103 if (fTopVisible >= 0)
104 fViewer->SetTopVisible(fTopVisible > 0);
105
106 // set default limits for number of visible nodes and faces
107 // when viewer created, initial values exported from TGeoManager
108 // viewer->SetLimits();
109
110 // start browser
111 fViewer->Show();
112}
#define g(i)
Definition RSha256.hxx:105
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
float xmin
float xmax
#define gPad
TVirtualGeoTrack * AddTrack(Int_t, Int_t, TObject *) override
void DrawVolume(TGeoVolume *, Option_t *="") override
void AddTrackPoint(Double_t *, Double_t *, Bool_t=kFALSE) override
std::shared_ptr< RGeomViewer > fViewer
void SetTopVisible(Bool_t on=kTRUE) override
Int_t fTopVisible
! is s
~RGeoPainter() override
void SetGeoManager(TGeoManager *) override
RGeoPainter(TGeoManager *manager)
TGeoManager * fGeoManager
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
Definition TGeoVolume.h:43
TGeoManager * GetGeoManager() const
Definition TGeoVolume.h:173
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Mother of all ROOT objects.
Definition TObject.h:41
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:202
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.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition fillpatterns.C:1
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...