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