Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TNode.cxx
Go to the documentation of this file.
1// @(#)root/g3d:$Id$
2// Author: Rene Brun 14/09/95
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include <iostream>
13#include "TROOT.h"
14#include "TBuffer.h"
15#include "TClass.h"
16#include "TVirtualPad.h"
17#include "TView.h"
18#include "TGeometry.h"
19#include "TRotMatrix.h"
20#include "TShape.h"
21#include "TNode.h"
22#include "TBrowser.h"
23#include "X3DBuffer.h"
24#include "TVirtualViewer3D.h"
25#include "TBuffer3D.h"
26
27#if 0
28const Int_t kMAXLEVELS = 20;
29const Int_t kVectorSize = 3;
31#endif
32
35static Int_t gGeomLevel = 0;
36
38
39
40/** \class TNode
41\ingroup g3d
42TNode description
43
44A TNode object is used to build the geometry hierarchy (see TGeometry).
45A node may contain other nodes.
46
47A geometry node has attributes:
48
49 - name and title
50 - pointer to the referenced shape (see TShape).
51 - x,y,z offset with respect to the mother node.
52 - pointer to the rotation matrix (see TRotMatrix).
53
54A node can be drawn.
55*/
56
57////////////////////////////////////////////////////////////////////////////////
58/// Node default constructor.
59
61{
62 fMatrix = nullptr;
63 fParent = nullptr;
64 fShape = nullptr;
65 fNodes = nullptr;
66 fVisibility = 1;
67 fX = fY = fZ = 0;
68}
69
70////////////////////////////////////////////////////////////////////////////////
71/// Node normal constructor.
72///
73/// - name is the name of the node
74/// - title is title
75/// - shapename is the name of the referenced shape
76/// - x,y,z are the offsets of the volume with respect to his mother
77/// - matrixname is the name of the rotation matrix
78///
79/// This new node is added into the list of sons of the current node
80
81TNode::TNode(const char *name, const char *title, const char *shapename, Double_t x, Double_t y, Double_t z, const char *matrixname, Option_t *option)
82 :TNamed(name,title),TAttLine(), TAttFill()
83{
84#ifdef WIN32
85 // The color "1" - default produces a very bad 3D image with OpenGL
86 Color_t lcolor = 16;
88#endif
89 fX = x;
90 fY = y;
91 fZ = z;
92 fNodes = nullptr;
96 fVisibility = 1;
97
99 else {
100 fMatrix = gGeometry->GetRotMatrix("Identity");
101 if (!fMatrix)
102 fMatrix = new TRotMatrix("Identity","Identity matrix",90,0,90,90,0,0);
103 }
104
105 if (!fShape) {
106 Printf("Error Referenced shape does not exist: %s",shapename);
107 return;
108 }
109
111 if (fParent) {
113 fParent->GetListOfNodes()->Add(this);
114 } else {
115 gGeometry->GetListOfNodes()->Add(this);
116 cd();
117 }
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// Node normal constructor.
122///
123/// - name is the name of the node
124/// - title is title
125/// - shape is the pointer to the shape definition
126/// - x,y,z are the offsets of the volume with respect to his mother
127/// - matrix is the pointer to the rotation matrix
128///
129/// This new node is added into the list of sons of the current node
130
131TNode::TNode(const char *name, const char *title, TShape *shape, Double_t x, Double_t y, Double_t z, TRotMatrix *matrix, Option_t *option)
132 :TNamed(name,title),TAttLine(),TAttFill()
133{
134#ifdef WIN32
135// The color "1" - default produces a very bad 3D image with OpenGL
136 Color_t lcolor = 16;
138#endif
139
140 fX = x;
141 fY = y;
142 fZ = z;
143 fNodes = nullptr;
144 fShape = shape;
145 fMatrix = matrix;
146 fOption = option;
147 fVisibility = 1;
149 if(!fMatrix) {
150 fMatrix =gGeometry->GetRotMatrix("Identity");
151 if (!fMatrix)
152 fMatrix = new TRotMatrix("Identity","Identity matrix",90,0,90,90,0,0);
153 }
154
155 if(!shape) {Printf("Illegal referenced shape"); return;}
156
157 if (fParent) {
159 fParent->GetListOfNodes()->Add(this);
161 } else {
162 gGeometry->GetListOfNodes()->Add(this);
163 cd();
164 }
165
166}
167
168////////////////////////////////////////////////////////////////////////////////
169/// copy constructor
170
172 TNamed(no),
173 TAttLine(no),
174 TAttFill(no),
175 TAtt3D(no),
176 fX(no.fX),
177 fY(no.fY),
178 fZ(no.fZ),
179 fMatrix(no.fMatrix),
181 fParent(no.fParent),
182 fNodes(no.fNodes),
183 fOption(no.fOption),
184 fVisibility(no.fVisibility)
185{
186}
187
188////////////////////////////////////////////////////////////////////////////////
189/// assignment operator
190
192{
193 if(this!=&no) {
195 TAttLine::operator=(no);
196 TAttFill::operator=(no);
197 TAtt3D::operator=(no);
198 fX=no.fX;
199 fY=no.fY;
200 fZ=no.fZ;
201 fMatrix=no.fMatrix;
202 fShape=no.fShape;
203 fParent=no.fParent;
204 fNodes=no.fNodes;
205 fOption=no.fOption;
206 fVisibility=no.fVisibility;
207 }
208 return *this;
209}
210
211////////////////////////////////////////////////////////////////////////////////
212/// Node default destructor.
213
215{
216 if (fParent) fParent->GetListOfNodes()->Remove(this);
217 else {if (gGeometry) gGeometry->GetListOfNodes()->Remove(this);}
218 if (fNodes) fNodes->Delete();
219 if (gGeometry && gGeometry->GetCurrentNode() == this) gGeometry->SetCurrentNode(nullptr);
220 delete fNodes;
221 fNodes = nullptr;
222}
223
224////////////////////////////////////////////////////////////////////////////////
225/// Browse.
226
228{
229 if( fNodes ) {
230 fNodes->Browse( b );
231 } else {
232 Draw();
233 gPad->Update();
234 }
235}
236
237////////////////////////////////////////////////////////////////////////////////
238/// Create the list to support sons of this node.
239
241{
242 if (!fNodes) fNodes = new TList;
243}
244
245////////////////////////////////////////////////////////////////////////////////
246/// Change Current Reference node to this.
247
248void TNode::cd(const char *)
249{
251}
252
253////////////////////////////////////////////////////////////////////////////////
254/// Compute distance from point px,py to a Node.
255///
256/// Compute the closest distance of approach from point px,py to this node.
257/// The distance is computed in pixels units.
258
260{
261 const Int_t big = 9999;
262 const Int_t inaxis = 7;
263 const Int_t maxdist = 5;
264
265 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
266 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
267 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
268 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
269
270 // return if point is not in the user area
271 if (px < puxmin - inaxis) return big;
272 if (py > puymin + inaxis) return big;
273 if (px > puxmax + inaxis) return big;
274 if (py < puymax - inaxis) return big;
275
276 TView *view =gPad->GetView();
277 if (!view) return big;
278
279 // Update translation vector and rotation matrix for new level
280 if (fMatrix && gGeometry) {
282 }
283
284 // Paint Referenced shape
285 Int_t dist = big;
286 if (fVisibility && fShape->GetVisibility()) {
287 gNode = this;
288 dist = fShape->DistancetoPrimitive(px,py);
289 if (dist < maxdist) {
290 gPad->SetSelected(this);
291 return 0;
292 }
293 }
294 if ( TestBit(kSonsInvisible) ) return dist;
295 if (!gGeometry) return dist;
296
297 // Loop on all sons
298 Int_t nsons = 0;
299 if (fNodes) nsons = fNodes->GetSize();
300 Int_t dnode = dist;
301 if (nsons) {
303 TNode *node;
304 TObject *obj;
305 TIter next(fNodes);
306 while ((obj = next())) {
307 node = (TNode*)obj;
308 dnode = node->DistancetoPrimitive(px,py);
309 if (dnode <= 0) break;
310 if (dnode < dist) dist = dnode;
311 }
313 }
314
315 return dnode;
316}
317
318////////////////////////////////////////////////////////////////////////////////
319/// Draw Referenced node with current parameters.
320
322{
323 TString opt = option;
324 opt.ToLower();
325
326 // Clear pad if option "same" not given
327 if (!gPad) {
328 gROOT->MakeDefCanvas();
329 }
330 if (!opt.Contains("same")) gPad->Clear();
331
332 // Draw Referenced node
333 if (!gGeometry) new TGeometry;
336
338
339 // Create a 3-D view
340 TView *view = gPad->GetView();
341 if (!view) {
342 view = TView::CreateView(11,nullptr,nullptr);
343 // Set the view to perform a first autorange (frame) draw.
344 // TViewer3DPad will revert view to normal painting after this
345 if (view) view->SetAutoRange(kTRUE);
346 }
347
348 // Create a 3D viewer to draw us
349 gPad->GetViewer3D(option);
350}
351
352////////////////////////////////////////////////////////////////////////////////
353/// Draw only Sons of this node.
354
360
361////////////////////////////////////////////////////////////////////////////////
362/// Execute action corresponding to one event.
363///
364/// This member function must be implemented to realize the action
365/// corresponding to the mouse click on the object in the window
366
368{
369 if (!gPad) return;
370 gPad->SetCursor(kHand);
371}
372
373////////////////////////////////////////////////////////////////////////////////
374/// Return pointer to node with name in the node tree.
375
376TNode *TNode::GetNode(const char *name) const
377{
378 if (!strcmp(name, GetName())) return (TNode*)this;
379 TNode *node, *nodefound;
380 if (!fNodes) return nullptr;
382 while (lnk) {
383 node = (TNode *)lnk->GetObject();
384 if (!ROOT::Detail::HasBeenDeleted(node)) {
385 nodefound = node->GetNode(name);
386 if (nodefound) return nodefound;
387 }
388 lnk = lnk->Next();
389 }
390 return nullptr;
391}
392
393////////////////////////////////////////////////////////////////////////////////
394/// Get object info.
395
397{
398 const char *snull = "";
399 if (!gPad) return (char*)snull;
400 static TString info;
401 info.Form("%s/%s, shape=%s/%s",GetName(),GetTitle(),fShape->GetName(),fShape->ClassName());
402 return const_cast<char*>(info.Data());
403}
404
405////////////////////////////////////////////////////////////////////////////////
406/// Copy shape attributes as node attributes.
407
409{
415
416 if (!fNodes) return;
417 TNode *node;
418
420 while (lnk) {
421 node = (TNode *)lnk->GetObject();
422 node->ImportShapeAttributes();
423 lnk = lnk->Next();
424 }
425}
426
427////////////////////////////////////////////////////////////////////////////////
428/// Return TRUE if node contains nodes, FALSE otherwise.
429
431{
432 if (fNodes) return kTRUE;
433 else return kFALSE;
434}
435
436////////////////////////////////////////////////////////////////////////////////
437/// Convert one point from local system to master reference system.
438///
439/// Note that before invoking this function, the global rotation matrix
440/// and translation vector for this node must have been computed.
441/// This is automatically done by the Paint functions.
442/// Otherwise TNode::UpdateMatrix should be called before.
443
445{
446 Double_t x,y,z;
448
451
452 x = bomb*translation[0]
453 + local[0]*matrix[0]
454 + local[1]*matrix[3]
455 + local[2]*matrix[6];
456
457 y = bomb*translation[1]
458 + local[0]*matrix[1]
459 + local[1]*matrix[4]
460 + local[2]*matrix[7];
461
462 z = bomb*translation[2]
463 + local[0]*matrix[2]
464 + local[1]*matrix[5]
465 + local[2]*matrix[8];
466
467 master[0] = x; master[1] = y; master[2] = z;
468}
469
470////////////////////////////////////////////////////////////////////////////////
471/// Convert one point from local system to master reference system.
472///
473/// Note that before invoking this function, the global rotation matrix
474/// and translation vector for this node must have been computed.
475/// This is automatically done by the Paint functions.
476/// Otherwise TNode::UpdateMatrix should be called before.
477
479{
480 Float_t x,y,z;
482
485
486 x = bomb*translation[0]
487 + local[0]*matrix[0]
488 + local[1]*matrix[3]
489 + local[2]*matrix[6];
490
491 y = bomb*translation[1]
492 + local[0]*matrix[1]
493 + local[1]*matrix[4]
494 + local[2]*matrix[7];
495
496 z = bomb*translation[2]
497 + local[0]*matrix[2]
498 + local[1]*matrix[5]
499 + local[2]*matrix[8];
500
501 master[0] = x; master[1] = y; master[2] = z;
502}
503
504////////////////////////////////////////////////////////////////////////////////
505/// List Referenced object with current parameters.
506
508{
509 Int_t sizeX3D = 0;
510 TString opt = option;
511 opt.ToLower();
512
513 if (!gGeometry) new TGeometry;
514
515 Int_t maxlevel = 15;
516 if (opt.Contains("1")) maxlevel = 1;
517 if (opt.Contains("2")) maxlevel = 2;
518 if (opt.Contains("3")) maxlevel = 3;
519 if (opt.Contains("4")) maxlevel = 4;
520 if (opt.Contains("5")) maxlevel = 5;
521 if (opt.Contains("x")) sizeX3D = 1;
522
524
525 Int_t nsons = 0;
526 if (fNodes) nsons = fNodes->GetSize();
527 const char *shapename, *matrixname;
528 if (fShape) shapename = fShape->IsA()->GetName();
529 else shapename = "????";
530 std::cout<<GetName()<<":"<<GetTitle()<<" is a "<<shapename;
531 if (sizeX3D) {
532 gSize3D.numPoints = 0;
533 gSize3D.numSegs = 0;
534 gSize3D.numPolys = 0;
535 Sizeof3D();
536 std::cout<<" NumPoints="<<gSize3D.numPoints;
537 std::cout<<" NumSegs ="<<gSize3D.numSegs;
538 std::cout<<" NumPolys ="<<gSize3D.numPolys;
539 } else {
540 std::cout<<" X="<<fX<<" Y="<<fY<<" Z="<<fZ;
541 if (nsons) std::cout<<" Sons="<<nsons;
543 else matrixname = "Identity";
544 if(strcmp(matrixname,"Identity")) std::cout<<" Rot="<<matrixname;
545 }
546 std::cout<<std::endl;
547 if(!nsons) return;
548 if (gGeomLevel >= maxlevel) return;
549
551 gGeomLevel++;
552 fNodes->ls(option);
553 gGeomLevel--;
555
556}
557
558////////////////////////////////////////////////////////////////////////////////
559/// Convert one point from master system to local reference system.
560///
561/// Note that before invoking this function, the global rotation matrix
562/// and translation vector for this node must have been computed.
563/// This is automatically done by the Paint functions.
564/// Otherwise TNode::UpdateMatrix should be called before.
565
567{
568 Double_t x,y,z;
570
573
577
578 x = xms*matrix[0] + yms*matrix[1] + zms*matrix[2];
579 y = xms*matrix[3] + yms*matrix[4] + zms*matrix[5];
580 z = xms*matrix[6] + yms*matrix[7] + zms*matrix[8];
581
582 local[0] = x; local[1] = y; local[2] = z;
583}
584
585////////////////////////////////////////////////////////////////////////////////
586/// Convert one point from master system to local reference system.
587///
588/// Note that before invoking this function, the global rotation matrix
589/// and translation vector for this node must have been computed.
590/// This is automatically done by the Paint functions.
591/// Otherwise TNode::UpdateMatrix should be called before.
592
594{
595 Float_t x,y,z;
597
600
604
605 x = xms*matrix[0] + yms*matrix[1] + zms*matrix[2];
606 y = xms*matrix[3] + yms*matrix[4] + zms*matrix[5];
607 z = xms*matrix[6] + yms*matrix[7] + zms*matrix[8];
608
609 local[0] = x; local[1] = y; local[2] = z;
610}
611
612////////////////////////////////////////////////////////////////////////////////
613/// Paint Referenced node with current parameters.
614///
615/// - vis = 1 (default) shape is drawn
616/// - vis = 0 shape is not drawn but its sons may be not drawn
617/// - vis = -1 shape is not drawn. Its sons are not drawn
618/// - vis = -2 shape is drawn. Its sons are not drawn
619
621{
622 Int_t level = 0;
623 if (gGeometry) level = gGeometry->GeomLevel();
624
625 // Update translation vector and rotation matrix for new level
626 if (level) {
628 }
629
630 // Paint Referenced shape
631 Int_t nsons = 0;
632 if (fNodes) nsons = fNodes->GetSize();
633
636
638
639 if (fVisibility && fShape->GetVisibility()) {
640 gNode = this;
646
647 TVirtualViewer3D * viewer3D = gPad->GetViewer3D();
648 if (viewer3D) {
649 // We only provide master frame positions in these shapes
650 // so don't ask viewer preference
651
652 // Ask all shapes for kCore/kBoundingBox/kShapeSpecific
653 // Not all will support the last two - which is fine
654 const TBuffer3D & buffer =
656
657 Int_t reqSections = viewer3D->AddObject(buffer, &viewerWantsSons);
659 {
661 viewer3D->AddObject(buffer, &viewerWantsSons);
662 }
663 }
664 }
665 if ( TestBit(kSonsInvisible) ) return;
666
667 // Paint all sons
668 if(!nsons || !viewerWantsSons) return;
669
671 TNode *node;
672 TObject *obj;
673 TIter next(fNodes);
674 while ((obj = next())) {
675 node = (TNode*)obj;
676 node->Paint(option);
677 }
679}
680
681////////////////////////////////////////////////////////////////////////////////
682/// Recursively remove object from the list of nodes of this node.
683
685{
686 if (fNodes && dynamic_cast<TNode*>(obj) ) fNodes->RecursiveRemove(obj);
687}
688
689////////////////////////////////////////////////////////////////////////////////
690/// Change the name of this Node
691
692void TNode::SetName(const char *name)
693{
694 if (gPad) gPad->Modified();
695
696 // Nodes are named objects in a THashList.
697 // We must update the hashlist if we change the name
698 if (fParent) fParent->GetListOfNodes()->Remove(this);
699 fName = name;
700 if (fParent) fParent->GetListOfNodes()->Add(this);
701}
702
703////////////////////////////////////////////////////////////////////////////////
704/// Change the name and title of this Node
705
706void TNode::SetNameTitle(const char *name, const char *title)
707{
708 if (gPad) gPad->Modified();
709
710 // Nodes are named objects in a THashList.
711 // We must update the hashlist if we change the name
712 if (fParent) fParent->GetListOfNodes()->Remove(this);
713 fName = name;
714 fTitle = title;
715 if (fParent) fParent->GetListOfNodes()->Add(this);
716}
717
718////////////////////////////////////////////////////////////////////////////////
719/// Set the pointer to the parent, keep parents informed about who they have
720
722{
723 TNode *pp = parent;
724 while(pp) {
725 if (pp == this) {
726 printf("Error: Cannot set parent node to be a child node:%s\n",GetName());
727 printf(" Operation not performed!\n");
728 return;
729 }
730 pp = pp->GetParent();
731 }
732
733 if (fParent) fParent->GetListOfNodes()->Remove(this);
734 else gGeometry->GetListOfNodes()->Remove(this);
735
736 fParent = parent;
737
738 if (fParent) {
739 fParent->BuildListOfNodes(); // new parent might not have list
740 fParent->GetListOfNodes()->Add(this);
741 }
742 else gGeometry->GetListOfNodes()->Add(this);
743}
744
745////////////////////////////////////////////////////////////////////////////////
746/// Set visibility for this node and its sons.
747///
748/// - vis = 3 node is drawn and its sons are drawn
749/// - vis = 2 node is not drawn but its sons are drawn
750/// - vis = 1 (default) node is drawn
751/// - vis = 0 node is not drawn
752/// - vis = -1 node is not drawn. Its sons are not drawn
753/// - vis = -2 node is drawn. Its sons are not drawn
754/// - vis = -3 Only node leaves are drawn
755/// - vis = -4 Node is not drawn. Its immediate sons are drawn
756
758{
760 TNode *node;
761 if (vis == -4 ) { //Node is not drawn. Its immediate sons are drawn
762 fVisibility = 0;
763 if (!fNodes) { fVisibility = 1; return;}
764 TIter next(fNodes); while ((node = (TNode*)next())) { node->SetVisibility(-2); }
765 } else if (vis == -3 ) { //Only node leaves are drawn
766 fVisibility = 0;
767 if (!fNodes) { fVisibility = 1; return;}
768 TIter next(fNodes); while ((node = (TNode*)next())) { node->SetVisibility(-3); }
769
770 } else if (vis == -2) { //node is drawn. Its sons are not drawn
771 fVisibility = 1; SetBit(kSonsInvisible); if (!fNodes) return;
772 TIter next(fNodes); while ((node = (TNode*)next())) { node->SetVisibility(-1); }
773
774 } else if (vis == -1) { //node is not drawn. Its sons are not drawn
775 fVisibility = 0; SetBit(kSonsInvisible); if (!fNodes) return;
776 TIter next(fNodes); while ((node = (TNode*)next())) { node->SetVisibility(-1); }
777
778 } else if (vis == 0) { //node is not drawn
779 fVisibility = 0;
780
781 } else if (vis == 1) { //node is drawn
782 fVisibility = 1;
783
784 } else if (vis == 2) { //node is not drawn but its sons are drawn
785 fVisibility = 0; if (!fNodes) return;
786 TIter next(fNodes); while ((node = (TNode*)next())) { node->SetVisibility(3); }
787
788 } else if (vis == 3) { //node is drawn and its sons are drawn
789 fVisibility = 1; if (!fNodes) return;
790 TIter next(fNodes); while ((node = (TNode*)next())) { node->SetVisibility(3); }
791 }
792}
793
794////////////////////////////////////////////////////////////////////////////////
795/// Return total size of this 3-D Node with its attributes.
796
797void TNode::Sizeof3D() const
798{
799 if (fVisibility && fShape && fShape->GetVisibility()) {
800 fShape->Sizeof3D();
801 }
802 if ( TestBit(kSonsInvisible) ) return;
803
804 if (!fNodes) return;
805 TNode *node;
806 TObject *obj;
807 TIter next(fNodes);
808 while ((obj = next())) {
809 node = (TNode*)obj;
810 node->Sizeof3D();
811 }
812}
813
814////////////////////////////////////////////////////////////////////////////////
815/// Stream a class object.
816
818{
819 if (b.IsReading()) {
821 Version_t R__v = b.ReadVersion(&R__s, &R__c);
822 if (R__v > 2) {
823 b.ReadClassBuffer(TNode::Class(), this, R__v, R__s, R__c);
824 return;
825 }
826 //====process old versions before automatic schema evolution
830 b >> fX;
831 b >> fY;
832 b >> fZ;
833 b >> fMatrix;
834 b >> fShape;
835 b >> fParent;
836 b >> fNodes;
838 if (R__v > 1) b >> fVisibility;
840 b.CheckByteCount(R__s, R__c, TNode::IsA());
841 //====end of old versions
842
843 } else {
844 b.WriteClassBuffer(TNode::Class(),this);
845 }
846}
847
848////////////////////////////////////////////////////////////////////////////////
849/// Update global rotation matrix/translation vector for this node
850/// this function must be called before invoking Local2Master
851
853{
854 TNode *nodes[kMAXLEVELS], *node;
855 Int_t i;
856 for (i=0;i<kVectorSize;i++) gTranslation[0][i] = 0;
857 for (i=0;i<kMatrixSize;i++) gRotMatrix[0][i] = 0;
858 gRotMatrix[0][0] = 1; gRotMatrix[0][4] = 1; gRotMatrix[0][8] = 1;
859
860 node = this;
861 gGeomLevel = 0;
862 //build array of parent nodes
863 while (node) {
864 nodes[gGeomLevel] = node;
865 node = node->GetParent();
866 gGeomLevel++;
867 }
868 gGeomLevel--;
869 //Update matrices in the hierarchy
870 for (i=1;i<=gGeomLevel;i++) {
871 node = nodes[gGeomLevel-i];
872 UpdateTempMatrix(&(gTranslation[i-1][0]),&gRotMatrix[i-1][0]
873 ,node->GetX(),node->GetY(),node->GetZ(),node->GetMatrix()->GetMatrix()
874 ,&gTranslation[i][0],&gRotMatrix[i][0]);
875 }
876}
877
878////////////////////////////////////////////////////////////////////////////////
879/// Compute new translation vector and global matrix.
880///
881/// - dx old translation vector
882/// - rmat old global matrix
883/// - x,y,z offset of new local system with respect to mother
884/// - dxnew new translation vector
885/// - rmatnew new global rotation matrix
886
890{
891 dxnew[0] = dx[0] + x*rmat[0] + y*rmat[3] + z*rmat[6];
892 dxnew[1] = dx[1] + x*rmat[1] + y*rmat[4] + z*rmat[7];
893 dxnew[2] = dx[2] + x*rmat[2] + y*rmat[5] + z*rmat[8];
894
895 rmatnew[0] = rmat[0]*matrix[0] + rmat[3]*matrix[1] + rmat[6]*matrix[2];
896 rmatnew[1] = rmat[1]*matrix[0] + rmat[4]*matrix[1] + rmat[7]*matrix[2];
897 rmatnew[2] = rmat[2]*matrix[0] + rmat[5]*matrix[1] + rmat[8]*matrix[2];
898 rmatnew[3] = rmat[0]*matrix[3] + rmat[3]*matrix[4] + rmat[6]*matrix[5];
899 rmatnew[4] = rmat[1]*matrix[3] + rmat[4]*matrix[4] + rmat[7]*matrix[5];
900 rmatnew[5] = rmat[2]*matrix[3] + rmat[5]*matrix[4] + rmat[8]*matrix[5];
901 rmatnew[6] = rmat[0]*matrix[6] + rmat[3]*matrix[7] + rmat[6]*matrix[8];
902 rmatnew[7] = rmat[1]*matrix[6] + rmat[4]*matrix[7] + rmat[7]*matrix[8];
903 rmatnew[8] = rmat[2]*matrix[6] + rmat[5]*matrix[7] + rmat[8]*matrix[8];
904}
dims_t fShape
@ kHand
Definition GuiTypes.h:374
#define b(i)
Definition RSha256.hxx:100
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
short Color_t
Color number (short)
Definition RtypesCore.h:99
short Version_t
Class version identifier (short)
Definition RtypesCore.h:79
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
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 SetLineWidth
Option_t Option_t SetFillStyle
Option_t Option_t SetLineColor
Option_t Option_t SetFillColor
char name[80]
Definition TGX11.cxx:110
const Int_t kVectorSize
Definition TGeometry.h:28
const Int_t kMAXLEVELS
Definition TGeometry.h:27
const Int_t kMatrixSize
Definition TGeometry.h:29
R__EXTERN TGeometry * gGeometry
Definition TGeometry.h:158
static Double_t gRotMatrix[kMAXLEVELS][kMatrixSize]
Definition TNode.cxx:34
static Double_t gTranslation[kMAXLEVELS][kVectorSize]
Definition TNode.cxx:33
TNode * gNode
Definition TNode.cxx:37
static Int_t gGeomLevel
Definition TNode.cxx:35
#define gROOT
Definition TROOT.h:411
R__EXTERN TNode * gNode
Definition TShape.h:68
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
Definition TString.cxx:2509
#define gPad
#define gSize3D
Definition X3DBuffer.h:40
Use this attribute class when an object should have 3D capabilities.
Definition TAtt3D.h:19
virtual void Sizeof3D() const
Set total size of this 3D object (used by X3D interface).
Definition TAtt3D.cxx:26
Fill Area Attributes class.
Definition TAttFill.h:20
virtual void Streamer(TBuffer &)
virtual Color_t GetFillColor() const
Return the fill area color.
Definition TAttFill.h:31
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition TAttFill.h:32
virtual void Modify()
Change current fill area attributes if necessary.
Definition TAttFill.cxx:215
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:38
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:40
Line Attributes class.
Definition TAttLine.h:20
virtual void Streamer(TBuffer &)
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:246
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
Generic 3D primitive description class.
Definition TBuffer3D.h:18
@ kBoundingBox
Definition TBuffer3D.h:51
@ kShapeSpecific
Definition TBuffer3D.h:52
Buffer base class used for serializing objects.
Definition TBuffer.h:43
void ls(Option_t *option="") const override
List (ls) all objects in this collection.
void Browse(TBrowser *b) override
Browse this collection (called by TBrowser).
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
TGeometry description.
Definition TGeometry.h:39
Float_t GetBomb() const
Definition TGeometry.h:73
Int_t GeomLevel() const
Definition TGeometry.h:74
TNode * GetCurrentNode() const
Definition TGeometry.h:79
virtual void SetCurrentNode(TNode *node)
Definition TGeometry.h:103
virtual Int_t PopLevel()
Definition TGeometry.h:100
virtual void SetGeomLevel(Int_t level=0)
Definition TGeometry.h:104
virtual void UpdateTempMatrix(Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=nullptr)
Update temp matrix.
TRotMatrix * GetRotMatrix(const char *name) const
Return pointer to RotMatrix with name.
virtual Int_t PushLevel()
Definition TGeometry.h:99
TShape * GetShape(const char *name) const
Return pointer to Shape with name.
TList * GetListOfNodes() const
Definition TGeometry.h:76
A doubly linked list.
Definition TList.h:38
void RecursiveRemove(TObject *obj) override
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition TList.cxx:761
void Add(TObject *obj) override
Definition TList.h:81
TObject * Remove(TObject *obj) override
Remove object from the list.
Definition TList.cxx:819
virtual TObjLink * FirstLink() const
Definition TList.h:102
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:467
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
void Streamer(TBuffer &) override
Stream an object of class TObject.
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
TString fTitle
Definition TNamed.h:33
TString fName
Definition TNamed.h:32
TNamed & operator=(const TNamed &rhs)
TNamed assignment operator.
Definition TNamed.cxx:50
TNode description.
Definition TNode.h:33
virtual void Master2Local(const Double_t *master, Double_t *local)
Convert one point from master system to local reference system.
Definition TNode.cxx:566
Int_t DistancetoPrimitive(Int_t px, Int_t py) override
Compute distance from point px,py to a Node.
Definition TNode.cxx:259
virtual void UpdateTempMatrix(const Double_t *dx1, const Double_t *rmat1, Double_t x, Double_t y, Double_t z, Double_t *matrix, Double_t *dxnew, Double_t *rmatnew)
Compute new translation vector and global matrix.
Definition TNode.cxx:887
virtual void UpdateMatrix()
Update global rotation matrix/translation vector for this node this function must be called before in...
Definition TNode.cxx:852
virtual TNode * GetParent() const
Definition TNode.h:70
void SetName(const char *name) override
Change the name of this Node.
Definition TNode.cxx:692
@ kSonsInvisible
Definition TNode.h:36
virtual Double_t GetY() const
Definition TNode.h:74
TClass * IsA() const override
Definition TNode.h:97
TNode * fParent
Definition TNode.h:43
void Sizeof3D() const override
Return total size of this 3-D Node with its attributes.
Definition TNode.cxx:797
TRotMatrix * fMatrix
Definition TNode.h:41
void Draw(Option_t *option="") override
Draw Referenced node with current parameters.
Definition TNode.cxx:321
Double_t fX
Definition TNode.h:38
virtual Double_t GetX() const
Definition TNode.h:73
virtual TRotMatrix * GetMatrix() const
Definition TNode.h:66
void SetNameTitle(const char *name, const char *title) override
Change the name and title of this Node.
Definition TNode.cxx:706
virtual void BuildListOfNodes()
Create the list to support sons of this node.
Definition TNode.cxx:240
TNode()
Node default constructor.
Definition TNode.cxx:60
void Paint(Option_t *option="") override
Paint Referenced node with current parameters.
Definition TNode.cxx:620
virtual void DrawOnly(Option_t *option="")
Draw only Sons of this node.
Definition TNode.cxx:355
char * GetObjectInfo(Int_t px, Int_t py) const override
Get object info.
Definition TNode.cxx:396
virtual Double_t GetZ() const
Definition TNode.h:75
TNode & operator=(const TNode &)
assignment operator
Definition TNode.cxx:191
virtual void Local2Master(const Double_t *local, Double_t *master)
Convert one point from local system to master reference system.
Definition TNode.cxx:444
static TClass * Class()
void RecursiveRemove(TObject *obj) override
Recursively remove object from the list of nodes of this node.
Definition TNode.cxx:684
virtual void cd(const char *path=nullptr)
Change Current Reference node to this.
Definition TNode.cxx:248
TShape * fShape
Definition TNode.h:42
Bool_t IsFolder() const override
Return TRUE if node contains nodes, FALSE otherwise.
Definition TNode.cxx:430
virtual void SetParent(TNode *parent)
Set the pointer to the parent, keep parents informed about who they have.
Definition TNode.cxx:721
TString fOption
Definition TNode.h:45
~TNode() override
Node default destructor.
Definition TNode.cxx:214
void Browse(TBrowser *b) override
Browse.
Definition TNode.cxx:227
virtual void ImportShapeAttributes()
Copy shape attributes as node attributes.
Definition TNode.cxx:408
void ExecuteEvent(Int_t event, Int_t px, Int_t py) override
Execute action corresponding to one event.
Definition TNode.cxx:367
Int_t fVisibility
Definition TNode.h:46
Double_t fZ
Definition TNode.h:40
virtual void SetVisibility(Int_t vis=1)
Set visibility for this node and its sons.
Definition TNode.cxx:757
void ls(Option_t *option="2") const override
List Referenced object with current parameters.
Definition TNode.cxx:507
TList * fNodes
Definition TNode.h:44
TList * GetListOfNodes() const
Definition TNode.h:65
Double_t fY
Definition TNode.h:39
void Streamer(TBuffer &) override
Stream a class object.
Definition TNode.cxx:817
virtual TNode * GetNode(const char *name) const
Return pointer to node with name in the node tree.
Definition TNode.cxx:376
Mother of all ROOT objects.
Definition TObject.h:41
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point (px,py) to the object.
Definition TObject.cxx:284
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:202
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition TObject.cxx:203
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:864
void ResetBit(UInt_t f)
Definition TObject.h:201
static Int_t IncreaseDirLevel()
Increase the indentation level for ls().
Definition TROOT.cxx:2890
static void IndentLevel()
Functions used by ls() to indent an object hierarchy.
Definition TROOT.cxx:2898
static Int_t DecreaseDirLevel()
Decrease the indentation level for ls().
Definition TROOT.cxx:2748
Manages a detector rotation matrix.
Definition TRotMatrix.h:28
virtual Double_t * GetMatrix()
Definition TRotMatrix.h:54
virtual Bool_t IsReflection() const
Definition TRotMatrix.h:61
This is the base class for all geometry shapes.
Definition TShape.h:35
Int_t GetVisibility() const
Definition TShape.h:58
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections) const
Stub to avoid forcing implementation at this stage.
Definition TShape.cxx:251
TClass * IsA() const override
Definition TShape.h:65
Basic string class.
Definition TString.h:138
void ToLower()
Change string to lower-case.
Definition TString.cxx:1189
virtual void Streamer(TBuffer &)
Stream a string object.
Definition TString.cxx:1418
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:640
See TView3D.
Definition TView.h:25
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:26
virtual void SetAutoRange(Bool_t autorange=kTRUE)=0
Abstract 3D shapes viewer.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
Definition TObject.h:405
th1 Draw()