37#include <ROOT/REveGeomViewer.hxx>
47std::shared_ptr<ROOT::Experimental::REveGeomViewer> viewer;
62 viewer = std::make_shared<ROOT::Experimental::REveGeomViewer>();
68 oldGeoManager =
nullptr;
71 std::string opt =
"z";
72 if (show_axis) opt+=
",axis";
73 if (grotate) opt+=
",rotate";
74 viewer->SetDrawOptions(opt);
77 viewer->Show(
"?nobrowser");
96void AddText(
TPaveText *pave,
const char *datamember,
Double_t value,
const char *comment)
99 for (
Int_t i=0; i<128; i++)
line[i] =
' ';
100 memcpy(&
line[0], datamember, strlen(datamember));
103 sprintf(number,
"%5.2f", value);
104 memcpy(&
line[12], number, strlen(number));
107 sprintf(&
line[30],
"%s",comment);
114void AddText(
TPaveText *pave,
const char *datamember,
Int_t value,
const char *comment)
117 for (
Int_t i=0; i<128; i++)
line[i] =
' ';
118 memcpy(&
line[0], datamember, strlen(datamember));
121 sprintf(number,
"%5i", value);
122 memcpy(&
line[12], number, strlen(number));
125 sprintf(&
line[30],
"%s",comment);
136 if (!pave || !pf)
return;
137 for (
Int_t i=0; i<128; i++)
line[i] =
' ';
144 AddText(pave,
"fNdiv",finder->
GetNdiv(),
"number of divisions");
145 AddText(pave,
"fStart",finder->
GetStart(),
"start divisioning position");
146 AddText(pave,
"fStep",finder->
GetStep(),
"division step");
158 return (1+
Int_t(color));
163 raytracing = !raytracing;
164 printf(
"Toggle raytracing\n");
171 new TCanvas(
"chelp",
"Help to run demos",200,10,700,600);
174 welcome->
AddText(
"Welcome to the new geometry package");
183 hdemo->
AddText(
"- Demo for building TGeo basic shapes and simple geometry. Shape parameters are");
184 hdemo->
AddText(
" displayed in the right pad");
185 hdemo->
AddText(
"- Click left mouse button to execute one demo");
186 hdemo->
AddText(
"- While pointing the mouse to the pad containing the geometry, do:");
187 hdemo->
AddText(
"- .... click-and-move to rotate");
188 hdemo->
AddText(
"- .... press j/k to zoom/unzoom");
189 hdemo->
AddText(
"- .... press l/h/u/i to move the view center around");
190 hdemo->
AddText(
"- Click Ray-trace ON/OFF to toggle ray-tracing");
191 hdemo->
AddText(
"- Use <View with x3d> from the <View> menu to get an x3d view");
192 hdemo->
AddText(
"- .... same methods to rotate/zoom/move the view");
193 hdemo->
AddText(
"- Execute box(1,8) to divide a box in 8 equal slices along X");
194 hdemo->
AddText(
"- Most shapes can be divided on X,Y,Z,Rxy or Phi :");
195 hdemo->
AddText(
"- .... root[0] <shape>(IAXIS, NDIV, START, STEP);");
196 hdemo->
AddText(
" .... IAXIS = 1,2,3 meaning (X,Y,Z) or (Rxy, Phi, Z)");
197 hdemo->
AddText(
" .... NDIV = number of slices");
198 hdemo->
AddText(
" .... START = start slicing position");
199 hdemo->
AddText(
" .... STEP = division step");
200 hdemo->
AddText(
"- Click Comments ON/OFF to toggle comments");
201 hdemo->
AddText(
"- Click Ideal/Align geometry to see how alignment works");
215 printf(
"Toggle rotate\n");
221 show_axis = !show_axis;
223 printf(
"Toggle axes\n");
229 if (iaxis<0 || iaxis>3) {
230 printf(
"Wrong division axis. Range is 1-3.\n");
354 if (iaxis<0 || iaxis>3) {
355 printf(
"Wrong division axis. Range is 1-3.\n");
416 if (iaxis<0 || iaxis>3) {
417 printf(
"Wrong division axis. Range is 1-3.\n");
480 if (iaxis<0 || iaxis>2) {
481 printf(
"Wrong division axis. Range is 1-2.\n");
504 TGeoVolume *vol =
gGeoManager->
MakeCtub(
"CTUB",med, 20,30,40,-30,250, nlow[0], nlow[1], nlow[2], nhi[0],nhi[1],nhi[2]);
546 if (iaxis<0 || iaxis>3) {
547 printf(
"Wrong division axis. Range is 1-3.\n");
551 printf(
"cannot divide cone on Rxy\n");
613 if (iaxis<0 || iaxis>3) {
614 printf(
"Wrong division axis. Range is 1-3.\n");
738 printf(
"Cannot divide spheres\n");
790 printf(
"Cannot divide a torus\n");
840 if (iaxis<0 || iaxis>3) {
841 printf(
"Wrong division axis. Range is 1-3.\n");
845 printf(
"Cannot divide trd1 on X axis\n");
1005 if (iaxis<0 || iaxis>3) {
1006 printf(
"Wrong division axis. Range is 1-3.\n");
1010 printf(
"Cannot divide pcon on Rxy\n");
1084 if (iaxis<0 || iaxis>3) {
1085 printf(
"Wrong division axis. Range is 1-3.\n");
1089 printf(
"Cannot divide pgon on Rxy\n");
1166 printf(
"Cannot divide arb8\n");
1241 if (iaxis && iaxis!=3) {
1242 printf(
"Wrong division axis. Can divide only in Z (3)\n");
1304 if (iaxis && iaxis!=3) {
1305 printf(
"Wrong division axis. Can divide only in Z (3)\n");
1316 TGeoVolume *vol =
gGeoManager->
MakeTrap(
"Trap",med, 30,15,30,20,10,15,0,20,10,15,0);
1375 if (iaxis && iaxis!=3) {
1376 printf(
"Wrong division axis. Can divide only in Z (3)\n");
1387 TGeoVolume *vol =
gGeoManager->
MakeGtra(
"Gtra",med, 30,15,30,30,20,10,15,0,20,10,15,0);
1456 Double_t x[8] = {-30,-30,30,30,15,15,-15,-15};
1457 Double_t y[8] = {-30,30,30,-30,-30,15,15,-30};
1664 for (
Int_t i=1; i<=10; i++) {
1665 for (
Int_t j=1; j<=10; j++) {
1667 sprintf(
name,
"TOP_1/SX_%d/SY_%d/CELL_1",i,j);
1685 printf(
"Terminate\n");
1708 bar->AddButton(
"How to run ",
"help()",
"Instructions for running this macro");
1709 bar->AddButton(
"Arb8 ",
"arb8()",
"An arbitrary polyhedron defined by vertices (max 8) sitting on 2 parallel planes");
1710 bar->AddButton(
"Box ",
"box()",
"A box shape.");
1711 bar->AddButton(
"Composite ",
"composite()",
"A composite shape");
1712 bar->AddButton(
"Cone ",
"cone()",
"A conical tube");
1713 bar->AddButton(
"Cone segment",
"coneseg()",
"A conical segment");
1714 bar->AddButton(
"Cut tube ",
"ctub()",
"A cut tube segment");
1715 bar->AddButton(
"Elliptical tube",
"eltu()",
"An elliptical tube");
1716 bar->AddButton(
"Extruded poly",
"xtru()",
"A general polygone extrusion");
1717 bar->AddButton(
"Hyperboloid ",
"hype()",
"A hyperboloid");
1718 bar->AddButton(
"Paraboloid ",
"parab()",
"A paraboloid");
1719 bar->AddButton(
"Polycone ",
"pcon()",
"A polycone shape");
1720 bar->AddButton(
"Polygone ",
"pgon()",
"A polygone");
1721 bar->AddButton(
"Parallelepiped",
"para()",
"A parallelepiped shape");
1722 bar->AddButton(
"Sphere ",
"sphere()",
"A spherical sector");
1723 bar->AddButton(
"Trd1 ",
"trd1()",
"A trapezoid with dX varying with Z");
1724 bar->AddButton(
"Trd2 ",
"trd2()",
"A trapezoid with both dX and dY varying with Z");
1725 bar->AddButton(
"Trapezoid ",
"trap()",
"A general trapezoid");
1726 bar->AddButton(
"Torus ",
"torus()",
"A toroidal segment");
1727 bar->AddButton(
"Tube ",
"tube()",
"A tube with inner and outer radius");
1728 bar->AddButton(
"Tube segment",
"tubeseg()",
"A tube segment");
1729 bar->AddButton(
"Twisted trap",
"gtra()",
"A twisted trapezoid");
1730 bar->AddButton(
"Aligned (ideal)",
"ideal()",
"An ideal (un-aligned) geometry");
1731 bar->AddButton(
"Un-aligned",
"align()",
"Some alignment operation");
1732 bar->AddButton(
"RAY-TRACE ON/OFF",
"raytrace()",
"Toggle ray-tracing mode");
1733 bar->AddButton(
"COMMENTS ON/OFF",
"comments = !comments;",
"Toggle explanations pad ON/OFF");
1734 bar->AddButton(
"AXES ON/OFF",
"axes()",
"Toggle axes ON/OFF");
1735 bar->AddButton(
"AUTOROTATE ON/OFF",
"autorotate()",
"Toggle autorotation ON/OFF");
1736 bar->AddButton(
"Quit",
"quit_root()",
"Exit from ROOT session");
1738 gROOT->SaveContext();
R__EXTERN TApplication * gApplication
R__EXTERN TGeoManager * gGeoManager
R__EXTERN TRandom * gRandom
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
A Control Bar is a fully user configurable tool which provides fast access to frequently used operati...
An arbitrary trapezoid with less than 8 vertices standing on two parallel planes perpendicular to Z a...
virtual void SetVertex(Int_t vnum, Double_t x, Double_t y)
Set values for a given vertex.
Class handling Boolean composition of shapes.
Hyperboloid class defined by 5 parameters.
The manager class for any TGeo geometry.
TGeoVolume * MakeCone(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2)
Make in one step a volume pointing to a cone shape with given medium.
TGeoVolume * MakeXtru(const char *name, TGeoMedium *medium, Int_t nz)
Make a TGeoXtru-shaped volume with nz planes.
TGeoVolume * MakePcon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nz)
Make in one step a volume pointing to a polycone shape with given medium.
TGeoVolume * MakeTube(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
TGeoVolume * MakeCons(const char *name, TGeoMedium *medium, Double_t dz, Double_t rmin1, Double_t rmax1, Double_t rmin2, Double_t rmax2, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a cone segment shape with given medium.
TGeoVolume * MakePara(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz, Double_t alpha, Double_t theta, Double_t phi)
Make in one step a volume pointing to a parallelepiped shape with given medium.
TGeoVolume * MakeTorus(const char *name, TGeoMedium *medium, Double_t r, Double_t rmin, Double_t rmax, Double_t phi1=0, Double_t dphi=360)
Make in one step a volume pointing to a torus shape with given medium.
void CloseGeometry(Option_t *option="d")
Closing geometry implies checking the geometry validity, fixing shapes with negative parameters (run-...
TGeoVolume * MakeTrd2(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy1, Double_t dy2, Double_t dz)
Make in one step a volume pointing to a TGeoTrd2 shape with given medium.
TGeoVolume * MakeGtra(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t twist, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2, Double_t alpha2)
Make in one step a volume pointing to a twisted trapezoid shape with given medium.
TGeoVolume * MakeBox(const char *name, TGeoMedium *medium, Double_t dx, Double_t dy, Double_t dz)
Make in one step a volume pointing to a box shape with given medium.
TGeoVolume * MakeTrd1(const char *name, TGeoMedium *medium, Double_t dx1, Double_t dx2, Double_t dy, Double_t dz)
Make in one step a volume pointing to a TGeoTrd1 shape with given medium.
TGeoVolume * MakeSphere(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t themin=0, Double_t themax=180, Double_t phimin=0, Double_t phimax=360)
Make in one step a volume pointing to a sphere shape with given medium.
void SetTopVolume(TGeoVolume *vol)
Set the top volume and corresponding node as starting point of the geometry.
TGeoVolume * MakeCtub(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2, Double_t lx, Double_t ly, Double_t lz, Double_t tx, Double_t ty, Double_t tz)
Make in one step a volume pointing to a tube segment shape with given medium.
TGeoVolume * MakePgon(const char *name, TGeoMedium *medium, Double_t phi, Double_t dphi, Int_t nedges, Int_t nz)
Make in one step a volume pointing to a polygone shape with given medium.
TGeoVolume * MakeTrap(const char *name, TGeoMedium *medium, Double_t dz, Double_t theta, Double_t phi, Double_t h1, Double_t bl1, Double_t tl1, Double_t alpha1, Double_t h2, Double_t bl2, Double_t tl2, Double_t alpha2)
Make in one step a volume pointing to a trapezoid shape with given medium.
void SetNsegments(Int_t nseg)
Set number of segments for approximating circles in drawing.
TGeoPhysicalNode * MakePhysicalNode(const char *path=0)
Makes a physical node corresponding to a path.
TObjArray * GetListOfPhysicalNodes()
TGeoVolume * MakeHype(const char *name, TGeoMedium *medium, Double_t rin, Double_t stin, Double_t rout, Double_t stout, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
TGeoVolume * MakeParaboloid(const char *name, TGeoMedium *medium, Double_t rlo, Double_t rhi, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
TGeoVolume * MakeTubs(const char *name, TGeoMedium *medium, Double_t rmin, Double_t rmax, Double_t dz, Double_t phi1, Double_t phi2)
Make in one step a volume pointing to a tube segment shape with given medium.
TGeoVolume * MakeEltu(const char *name, TGeoMedium *medium, Double_t a, Double_t b, Double_t dz)
Make in one step a volume pointing to a tube shape with given medium.
Base class describing materials.
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
Media are used to store properties related to tracking and which are useful only when using geometry ...
virtual TGeoMatrix * GetMatrix() const =0
Base finder class for patterns.
TGeoVolume * GetVolume() const
Double_t GetStart() const
virtual void DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax)
Defines z position of a section plane, rmin and rmax at this z.
Physical nodes are the actual 'touchable' objects in the geometry, representing a path of positioned ...
TGeoNode * GetNode(Int_t level=-1) const
Return node in branch at LEVEL. If not specified, return last leaf.
Bool_t Align(TGeoMatrix *newmat=0, TGeoShape *newshape=0, Bool_t check=kFALSE, Double_t ovlp=0.001)
Align a physical node with a new relative matrix/shape.
Base abstract class for all shapes.
virtual const char * GetAxisName(Int_t iaxis) const =0
Class describing translations.
void SetTranslation(Double_t dx, Double_t dy, Double_t dz)
Set translation components.
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
TGeoShape * GetShape() const
virtual TGeoVolume * Divide(const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="")
Division a la G3.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=0, Option_t *option="")
Add a TGeoNode to the list of nodes.
An extrusion with fixed outline shape in x-y and a sequence of z extents (segments).
Bool_t DefinePolygon(Int_t nvert, const Double_t *xv, const Double_t *yv)
Creates the polygon representing the blueprint of any Xtru section.
virtual void DefineSection(Int_t snum, Double_t z, Double_t x0=0., Double_t y0=0., Double_t scale=1.)
defines z position of a section plane, rmin and rmax at this z.
virtual void SetName(const char *name)
Set the name of the TNamed.
virtual const char * GetName() const
Returns name of object.
TObject * At(Int_t idx) const
Mother of all ROOT objects.
A Pave (see TPave) with text, lines or/and boxes inside.
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
virtual void SetAllWith(const char *text, Option_t *option, Double_t value)
Set attribute option for all lines containing string text.
virtual Double_t Rndm()
Machine independent random number generator.
Base class for several text objects.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
static constexpr double bar