Logo ROOT   6.14/05
Reference Guide
TVolume.cxx
Go to the documentation of this file.
1 // @(#)root/table:$Id$
2 // Author: Valery Fine 10/12/98
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 "Riostream.h"
13 #include <stdlib.h>
14 
15 #include "TROOT.h"
16 #include "TClass.h"
17 #include "TVirtualPad.h"
18 #include "TView.h"
19 #include "TGeometry.h"
20 #include "TRotMatrix.h"
21 #include "TShape.h"
22 #include "TVolume.h"
23 #include "TBrowser.h"
24 #include "X3DBuffer.h"
25 
26 #include "TTablePadView3D.h"
27 #include "TCanvas.h"
28 
29 #include "TRotMatrix.h"
30 #include "TVolumePosition.h"
31 #include "TVirtualViewer3D.h"
32 #include "TBuffer3D.h"
33 
34 #if 0
35 const Int_t kVectorSize = 3;
37 const Int_t kMAXLEVELS = 20;
38 
41 static Int_t gGeomLevel = 0;
42 
43 TVolume *gNode;
44 #endif
45 //R__EXTERN Size3D gSize3D;
46 static TRotMatrix *gIdentity = 0;
47 
49 
50 ////////////////////////////////////////////////////////////////////////////////
51 /// TVolume description
52 ///
53 /// A TVolume object is used to build the geometry hierarchy.
54 /// Since TVolume is derived from TDataSet class it may contain other volumes.
55 ///
56 /// A geometry volume has attributes:
57 /// - name and title
58 /// - pointer to the referenced shape (see TShape).
59 /// - list of TVolumePosition object defining the position of the nested volumes
60 /// with respect to the mother node.
61 ///
62 ///
63 /// A volume can be drawn.
64 
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 //// Volume default constructor
68 
70 {
71  fShape = 0;
72  fListOfShapes = 0;
74  if (!gGeometry) new TGeometry;
75 }
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 //// Volume normal constructor
79 ////
80 //// name is the name of the node
81 //// title is title
82 //// shapename is the name of the referenced shape
83 
84 TVolume::TVolume(const char *name, const char *title, const char *shapename, Option_t *option)
86 {
87 #ifdef WIN32
88 /// The color "1" - default produces a very bad 3D image with OpenGL
89  Color_t lcolor = 16;
90  SetLineColor(lcolor);
91 #endif
92  static Int_t counter = 0;
93  counter++;
94  SetTitle(title);
95  if(!(counter%1000))std::cout<<"TVolume count="<<counter<<" name="<<name<<std::endl;
96  if (!gGeometry) new TGeometry;
97  Add(gGeometry->GetShape(shapename),kTRUE);
98 // fParent = gGeometry->GetCurrenTVolume();
99  fOption = option;
101 
103 }
104 
105 ////////////////////////////////////////////////////////////////////////////////
106 //// Volume normal constructor
107 ////
108 //// name is the name of the node
109 //// title is title
110 //// shape is the pointer to the shape definition
111 
112 TVolume::TVolume(const char *name, const char *title, TShape *shape, Option_t *option)
114 {
115 #ifdef WIN32
116 /// The color "1" - default produces a very bad 3D image with OpenGL
117  Color_t lcolor = 16;
118  SetLineColor(lcolor);
119 #endif
120 
121  if (!gGeometry) new TGeometry;
122  Add(shape,kTRUE);
123  fOption = option;
125  SetTitle(title);
126  if(shape) ImportShapeAttributes();
127 }
128 
129 ////////////////////////////////////////////////////////////////////////////////
130 /// ENodeSEEN Visibility flag 00 - everything visible,
131 /// 10 - this invisible, but sons are visible
132 /// 01 - this visible but sons
133 /// 11 - neither this nor its sons are visible
134 /// Maps the value of the visibility flag to <a href="https://cern-tex.web.cern.ch/cern-tex/geant_html3/node128.html#SECTION056000000000000000000000">GEANT 3.21 "volume attributes"</a>
135 
137 {
138  const Int_t mapVis[4] = {1, -2, 0, -1 };
139  return mapVis[vis];
140 }
141 
142 ////////////////////////////////////////////////////////////////////////////////
143 /// ENodeSEEN TVolume::MapGEANT2StNodeVis(Int_t vis)
144 /// Maps the value of <a href="https://cern-tex.web.cern.ch/cern-tex/geant_html3/node128.html#SECTION056000000000000000000000">GEANT 3.21 "volume attributes"</a> to the visibility flag
145 
147 {
148  const Int_t mapVis[4] = {1, -2, 0, -1 };
149  Int_t i;
150 // for (i =0; i<3;i++) if (mapVis[i] == vis) return (ENodeSEEN)i;
151  for (i =0; i<3;i++) if (mapVis[i] == vis) return i;
152  return kBothVisible;
153 }
154 
155 ////////////////////////////////////////////////////////////////////////////////
156 /// Convert a TNode object into a TVolume
157 
159 {
160  SetName(rootNode.GetName());
161  SetTitle(rootNode.GetTitle());
163  fOption = rootNode.GetOption();
164  Add(rootNode.GetShape(),kTRUE);
165 
166  SetLineColor(rootNode.GetLineColor());
167  SetLineStyle(rootNode.GetLineStyle());
168  SetLineWidth(rootNode.GetLineWidth());
169  SetFillColor(rootNode.GetFillColor());
170  SetFillStyle(rootNode.GetFillStyle());
171 
172  TList *nodes = rootNode.GetListOfNodes();
173  if (nodes) {
174  TIter next(nodes);
175  TNode *node = 0;
176  while ( (node = (TNode *) next()) ){
177  TVolume *nextNode = new TVolume(*node);
178  Add(nextNode,node->GetX(),node->GetY(),node->GetZ(),node->GetMatrix());
179  }
180  }
181 }
182 
183 ////////////////////////////////////////////////////////////////////////////////
184 ///to be documented
185 
186 void TVolume::Add(TShape *shape, Bool_t IsMaster)
187 {
188  if (!shape) return;
189  if (!fListOfShapes) fListOfShapes = new TList;
190  fListOfShapes->Add(shape);
191  if (IsMaster) fShape = shape;
192 }
193 
194 ////////////////////////////////////////////////////////////////////////////////
195 /// Convert a TVolume object into a TNode
196 
198 {
199  Double_t x=0;
200  Double_t y=0;
201  Double_t z=0;
202  const TRotMatrix* matrix = 0;
203  if (position) {
204  x=position->GetX();
205  y=position->GetY();
206  z=position->GetZ();
207  matrix = position->GetMatrix();
208  }
209 // const Char_t *path = Path();
210 // printf("%s: %s/%s, shape=%s/%s\n",path,GetName(),GetTitle(),GetShape()->GetName(),GetShape()->ClassName());
211  TNode *newNode = new TNode(GetName(),GetTitle(),GetShape(),x,y,z,(TRotMatrix* )matrix,GetOption());
213 
214  newNode->SetLineColor(GetLineColor());
215  newNode->SetLineStyle(GetLineStyle());
216  newNode->SetLineWidth(GetLineWidth());
217  newNode->SetFillColor(GetFillColor());
218  newNode->SetFillStyle(GetFillStyle());
219 
220  TList *positions = GetListOfPositions();
221  if (positions) {
222  TIter next(positions);
223  TVolumePosition *pos = 0;
224  while ( (pos = (TVolumePosition *) next()) ){
225  TVolume *node = pos->GetNode();
226  if (node) {
227  newNode->cd();
228  node->CreateTNode(pos);
229  }
230  }
231  }
232  newNode->ImportShapeAttributes();
233  return newNode;
234 }
235 
236 ////////////////////////////////////////////////////////////////////////////////
237 //// Volume default destructor
238 
240 {
241  // Hmm, here we are in the troubles, in theory we have to find all
242  // place where this node is sitting but we don't (yet :-()
243 
244  if (GetListOfPositions()) {
247  }
249 
250  // Required since we overload TObject::Hash.
252 }
253 
254 ////////////////////////////////////////////////////////////////////////////////
255 /// to be documented
256 
258 {
260  if ( GetListOfPositions()) GetListOfPositions()->Add(position);
261  else Error("Add","Can not create list of positions for the current node <%s>:<%s>",GetName(),GetTitle());
262 }
263 
264 ////////////////////////////////////////////////////////////////////////////////
265 /// to be documented
266 
268 {
269  TVolumePosition *position = nodePosition;
270  if (!node) return 0;
271  if (!position) position = new TVolumePosition(node); // Create default position
272  // The object must be placed at once. Check it:
273  if (!(GetCollection() && GetCollection()->FindObject(node)) ) TDataSet::Add(node);
274  Add(position);
275  return position;
276 }
277 
278 ////////////////////////////////////////////////////////////////////////////////
279 ////
280 //// volume the pointer to the volume to be placed
281 //// x,y,z are the offsets of the volume with respect to his mother
282 //// matrix is the pointer to the rotation matrix
283 //// id is a unique position id
284 
286  TRotMatrix *matrix, UInt_t id, Option_t *)
287 {
288  if (!volume) return 0;
289  TRotMatrix *rotation = matrix;
290  if(!rotation) rotation = GetIdentity();
291  TVolumePosition *position = new TVolumePosition(volume,x,y,z,rotation);
292  position->SetId(id);
293  return Add(volume,position);
294 }
295 
296 ////////////////////////////////////////////////////////////////////////////////
297 ////
298 //// volume the pointer to the volume to be placed
299 //// x,y,z are the offsets of the volume with respect to his mother
300 //// matrixname is the name of the rotation matrix
301 //// id is a unique position id
302 
304  const char *matrixname, UInt_t id, Option_t *)
305 {
306  if (!volume) return 0;
307  TRotMatrix *rotation = 0;
308  if (matrixname && strlen(matrixname)) rotation = gGeometry->GetRotMatrix(matrixname);
309  if (!rotation) rotation = GetIdentity();
310  TVolumePosition *position = new TVolumePosition(volume,x,y,z,rotation);
311  position->SetId(id);
312  return Add(volume,position);
313 }
314 
315 ////////////////////////////////////////////////////////////////////////////////
316 /// to be documented
317 
319 {
320  if (GetListOfPositions()){
321  TVolumePosition *nodePosition = 0;
322  TIter next(GetListOfPositions());
323  Int_t posNumber = 0;
324  while ( (nodePosition = (TVolumePosition *)next()) ) {
325  posNumber = nodePosition->GetId();
326  TString posName = "*";
327  posName += nodePosition->GetNode()->GetTitle();
328  char num[10];
329  posName += ";";
330  snprintf(num,10,"%d",posNumber);
331  posName += num;
332  b->Add(nodePosition,posName.Data());
333  }
334  }
335 }
336 ////////////////////////////////////////////////////////////////////////////////
337 /// to be documented
338 
340 {
341  return DistancetoNodePrimitive(px,py);
342 }
343 
344 ////////////////////////////////////////////////////////////////////////////////
345 //// Compute distance from point px,py to a TVolumeView
346 ///
347 //// Compute the closest distance of approach from point px,py to the position of
348 //// this volume.
349 //// The distance is computed in pixels units.
350 ////
351 //// It is restricted by 2 levels of TVolumes
352 
354 {
355  const Int_t big = 9999;
356  if ( GetVisibility() == kNoneVisible ) return big;
357 
358  const Int_t inaxis = 7;
359  const Int_t maxdist = 5;
360 
361  Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
362  Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
363  Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
364  Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
365 
366 ///- return if point is not in the user area
367  if (px < puxmin - inaxis) return big;
368  if (py > puymin + inaxis) return big;
369  if (px > puxmax + inaxis) return big;
370  if (py < puymax - inaxis) return big;
371 
372  TView *view =gPad->GetView();
373  if (!view) return big;
374 
375  static TVolumePosition nullPosition;
376  TVolumePosition *position = pos;
377  if (!position) position = &nullPosition;
378  if (pos) position->UpdatePosition();
379  Int_t dist = big;
380  if ( !(GetVisibility() & kThisUnvisible ) ) {
381  TShape *shape = 0;
382  TIter nextShape(fListOfShapes);
383  while ((shape = (TShape *)nextShape())) {
384  ///- Distance to the next referenced shape if visible
385  if (shape->GetVisibility()) {
386  Int_t dshape = shape->DistancetoPrimitive(px,py);
387  if (dshape < maxdist) {
388  gPad->SetSelected(this);
389  return 0;
390  }
391  if (dshape < dist) dist = dshape;
392  }
393  }
394  }
395 
396  if ( (GetVisibility() & kSonUnvisible) ) return dist;
397 
398 ///- Loop on all sons
399  TList *posList = GetListOfPositions();
400  Int_t dnode = dist;
401  if (posList && posList->GetSize()) {
402  gGeometry->PushLevel();
403  TVolumePosition *thisPosition;
404  TObject *obj;
405  TIter next(posList);
406  while ((obj = next())) {
407  thisPosition = (TVolumePosition*)obj;
408  TVolume *node = thisPosition->GetNode();
409  dnode = node->DistancetoNodePrimitive(px,py,thisPosition);
410  if (dnode <= 0) break;
411  if (dnode < dist) dist = dnode;
412  if (gGeometry->GeomLevel() > 2) break;
413  }
414  gGeometry->PopLevel();
415  }
416 
417  if (gGeometry->GeomLevel()==0 && dnode > maxdist) {
418  gPad->SetSelected(view);
419  return 0;
420  } else
421  return dnode;
422 }
423 
424 ////////////////////////////////////////////////////////////////////////////////
425 //// Draw Referenced node with current parameters
426 
427 void TVolume::Draw(Option_t *option)
428 {
429  TString opt = option;
430  opt.ToLower();
431 ///- Clear pad if option "same" not given
432  if (!gPad) {
433  gROOT->MakeDefCanvas();
434  }
435  if (!opt.Contains("same")) gPad->Clear();
436 
437  // Check geometry level
438 
439  Int_t iopt = atoi(option);
440  TDataSet *parent = 0;
441  char buffer[12];
442  if (iopt < 0) {
443  // set the "positive option"
444  snprintf(buffer,12,"%d",-iopt);
445  option = buffer;
446  // select parent to draw
447  parent = this;
448  do parent = parent->GetParent();
449  while (parent && ++iopt);
450  }
451  if (parent) parent->AppendPad(option);
452  else AppendPad(option);
453 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,03,05)
454  // the new (4.03/05) way to active 3D viewer
455  // Create a 3-D view
456  TView *view = gPad->GetView();
457  if (!view) {
458  view = TView::CreateView(1,0,0);
459  // Set the view to perform a first autorange (frame) draw.
460  // TViewer3DPad will revert view to normal painting after this
461  view->SetAutoRange(kTRUE);
462  }
463 
464  // Create a 3D viewer to draw us
465 // gPad->GetViewer3D(option);
466  gPad->GetViewer3D();
467 #else
468  Paint(option);
469 #endif
470 }
471 
472 
473 ////////////////////////////////////////////////////////////////////////////////
474 //// Draw only Sons of this node
475 
477 {
479  Draw(option);
480 }
481 
482 
483 ////////////////////////////////////////////////////////////////////////////////
484 //// Execute action corresponding to one event
485 ////
486 //// This member function must be implemented to realize the action
487 //// corresponding to the mouse click on the object in the window
488 
490 {
491 // if (gPad->GetView())
492 // gPad->GetView()->ExecuteRotateView(event, px, py);
493 
494 // if (!gPad->GetListOfPrimitives()->FindObject(this)) gPad->SetCursor(kCross);
495  gPad->SetCursor(kHand);
496 }
497 
498 ////////////////////////////////////////////////////////////////////////////////
499 /// Return a pointer the "identity" matrix
500 
502 {
503  Double_t *identityMatrix = 0;
504  if (!gIdentity) {
505  gIdentity = gGeometry->GetRotMatrix("Identity");
506  if (!gIdentity) {
507  gIdentity = new TRotMatrix();
508  gIdentity->SetName("Identity");
509  gIdentity->SetTitle("Identity matrix");
510  gIdentity->SetMatrix((Double_t *)0);
511  identityMatrix = gIdentity->GetMatrix();
512  memset(identityMatrix,0,9*sizeof(Double_t));
513  *identityMatrix = 1;
514  identityMatrix += 4; *identityMatrix = 1;
515  identityMatrix += 4; *identityMatrix = 1;
516  gGeometry->GetListOfMatrices()->AddFirst(gIdentity);
517  }
518  }
519  return gIdentity;
520 }
521 
522 ////////////////////////////////////////////////////////////////////////////////
523 /// to be documented
524 
525 char *TVolume::GetObjectInfo(Int_t px, Int_t py) const
526 {
527  if (!gPad) return 0;
528  static char info[512];
529  snprintf(info,512,"%s/%s",GetName(),GetTitle());
530  Double_t x[3];
531  ((TPad *)gPad)->AbsPixeltoXY(px,py,x[0],x[1]);
532  x[2] = 0;
533  TView *view =gPad->GetView();
534  if (view) view->NDCtoWC(x, x);
535 
536  TIter nextShape(fListOfShapes);
537  TShape *shape = 0;
538  while( (shape = (TShape *)nextShape()) ) {
539  Int_t nchi = strlen(info);
540  snprintf(&info[nchi],512-nchi," %6.2f/%6.2f: shape=%s/%s",x[0],x[1],shape->GetName(),shape->ClassName());
541  }
542  return info;
543 }
544 
545 ////////////////////////////////////////////////////////////////////////////////
546 //// Copy shape attributes as node attributes
547 
549 {
550  if (fShape) {
556  }
557 
558  if (!GetCollection()) return;
559  TVolume *volume;
560  TIter next(GetCollection());
561  while ( (volume = (TVolume *)next()) )
562  volume->ImportShapeAttributes();
563 }
564 
565 ////////////////////////////////////////////////////////////////////////////////
566 ////- Draw Referenced node
567 
569 {
572  PaintNodePosition(opt);
573  return;
574 }
575 
576 ////////////////////////////////////////////////////////////////////////////////
577 //// Paint Referenced volume with current parameters
578 ////
579 ////
580 //// vis = 1 (default) shape is drawn
581 //// vis = 0 shape is not drawn but its sons may be not drawn
582 //// vis = -1 shape is not drawn. Its sons are not drawn
583 //// vis = -2 shape is drawn. Its sons are not drawn
584 
586 {
587  if ( GetVisibility() == kNoneVisible ) return;
588 
589  static TVolumePosition nullPosition;
590 
591 // restrict the levels for "range" option
592  Int_t level = gGeometry->GeomLevel();
593 // if (option && option[0]=='r' && level > 3 && strcmp(option,"range") == 0) return;
594  if ((!(GetVisibility() & kThisUnvisible)) && option && option[0]=='r' && level > 3 ) return;
595  Int_t iopt = 0;
596  if (option) iopt = atoi(option);
597  if ( (0 < iopt) && (iopt <= level) ) return;
598 
599  TTablePadView3D *view3D = (TTablePadView3D*)gPad->GetView3D();
600  TVirtualViewer3D * viewer3D = gPad->GetViewer3D();
601 
602  TVolumePosition *position = pos;
603  if (!position) position = &nullPosition;
604 
605  // PaintPosition does change the current matrix and it MUST be called FIRST !!!
606 
607  position->UpdatePosition(option);
608 
609  if ( viewer3D && !(GetVisibility() & kThisUnvisible)) PaintShape(option);
610 
611  if (GetVisibility() & kSonUnvisible) return;
612 
613 ///- Paint all sons
614  TList *posList = GetListOfPositions();
615  if (posList && posList->GetSize()) {
616  gGeometry->PushLevel();
617  TVolumePosition *thisPosition;
618  TIter next(posList);
619  while ((thisPosition = (TVolumePosition *)next())) {
620  if (view3D) view3D->PushMatrix();
621 
622  TVolume *volume = thisPosition->GetNode();
623  if (volume) volume->PaintNodePosition(option,thisPosition);
624 
625  if (view3D) view3D->PopMatrix();
626  }
627  gGeometry->PopLevel();
628  }
629 }
630 
631 ////////////////////////////////////////////////////////////////////////////////
632 /// Paint shape of the volume
633 /// To be called from the TObject::Paint method only
634 
636 {
637  Bool_t rangeView = option && option[0]=='r';
638  if (!rangeView) {
641  }
642 
643  if ( (GetVisibility() & kThisUnvisible) ) return;
644 
645  TIter nextShape(fListOfShapes);
646  TShape *shape = 0;
647  while( (shape = (TShape *)nextShape()) ) {
648  if (!rangeView) {
649  shape->SetLineColor(GetLineColor());
650  shape->SetLineStyle(GetLineStyle());
651  shape->SetLineWidth(GetLineWidth());
652  shape->SetFillColor(GetFillColor());
653  shape->SetFillStyle(GetFillStyle());
654  TTablePadView3D *view3D = (TTablePadView3D*)gPad->GetView3D();
655  gPad->GetViewer3D();
656  if (view3D)
657  view3D->SetLineAttr(GetLineColor(),GetLineWidth(),option);
658  }
659 
660 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,03,05)
661  // It MUST be the TShape::Paint method:
662  Bool_t viewerWantsSons = kTRUE;
663  TVirtualViewer3D * viewer3D = gPad->GetViewer3D();
664  if (viewer3D) {
665  // We only provide master frame positions in these shapes
666  // so don't ask viewer preference
667 
668  // Ask all shapes for kCore/kBoundingBox/kShapeSpecific
669  // Not all will support the last two - which is fine
670  const TBuffer3D & buffer =
672 
673  // TShape sets buffer id based on TNode * gNode
674  // As we not using TNode we need to override this
675  const_cast<TBuffer3D &>(buffer).fID = this;
676 
677  Int_t reqSections = viewer3D->AddObject(buffer, &viewerWantsSons);
678  if (reqSections != TBuffer3D::kNone) {
679  fShape->GetBuffer3D(reqSections);
680  viewer3D->AddObject(buffer);
681  }
682  }
683 #else
684  shape->Paint(option);
685 #endif
686  }
687 }
688 
689 ////////////////////////////////////////////////////////////////////////////////
690 /// DeletePosition deletes the position of the TVolume *node from this TVolume
691 /// and removes that volume from the list of the nodes of this TVolume
692 
694 {
695  if (!position) return;
696 
697  if (GetListOfPositions()) {
699  while (lnk) {
700  TVolumePosition *nextPosition = (TVolumePosition *)(lnk->GetObject());
701  if (nextPosition && nextPosition == position) {
702  TVolume *node = nextPosition->GetNode();
703  GetListOfPositions()->Remove(lnk);
704  delete nextPosition;
705  Remove(node);
706  break;
707  }
708  lnk = lnk->Next();
709  }
710  }
711 }
712 
713 ////////////////////////////////////////////////////////////////////////////////
714 /// GetRange
715 ///
716 /// Calculates the size of 3 box the volume occupies,
717 /// Return:
718 /// two floating point arrays with the bound of box
719 /// surrounding all shapes of this TVolumeView
720 
722 {
723  TVirtualPad *savePad = gPad;
724  // Create a dummy TPad;
725  TCanvas dummyPad("--Dumm--","dum",1,1);
726  // Asking 3D TView
727  TView *view = TView::CreateView(1,0,0);
728 
731  view->SetAutoRange(kTRUE);
732  Paint("range");
733  view->GetRange(&min[0],&max[0]);
734  delete view;
735  // restore "current pad"
736  if (savePad) savePad->cd();
737 }
738 
739 ////////////////////////////////////////////////////////////////////////////////
740 //// Set visibility for this volume and its sons
741 ///
742 /// ENodeSEEN Visibility flag 00 - everything visible,
743 /// 10 - this invisible, but sons are visible
744 /// 01 - this visible but sons
745 /// 11 - neither this nor its sons are visible
746 
748 {
749  fVisibility = vis;
750 }
751 
752 ////////////////////////////////////////////////////////////////////////////////
753 //// *Return total size of this 3-D volume with its attributes
754 
755 void TVolume::Sizeof3D() const
756 {
757  if (!(GetVisibility() & kThisUnvisible) ) {
758  TIter nextShape(fListOfShapes);
759  TShape *shape = 0;
760  while( (shape = (TShape *)nextShape()) ) {
761  if (shape->GetVisibility()) shape->Sizeof3D();
762  }
763  }
764 
765  if ( GetVisibility() & kSonUnvisible ) return;
766 
767  if (!Nodes()) return;
768  TVolume *node;
769  TObject *obj;
770  TIter next(Nodes());
771  while ((obj = next())) {
772  node = (TVolume*)obj;
773  node->Sizeof3D();
774  }
775 }
virtual void DeletePosition(TVolumePosition *position)
DeletePosition deletes the position of the TVolume *node from this TVolume and removes that volume fr...
Definition: TVolume.cxx:693
void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add object with name to browser.
Definition: TBrowser.cxx:261
virtual Double_t GetY() const
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual UInt_t GetId() const
virtual Double_t * GetMatrix()
Definition: TRotMatrix.h:54
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition: TAttLine.h:43
void AddFirst(TObject *obj)
Add object at the beginning of the list.
Definition: THashList.cxx:69
static Double_t gTranslation[kMAXLEVELS][kVectorSize]
Definition: TNode.cxx:32
double dist(Rotation3D const &r1, Rotation3D const &r2)
Definition: 3DDistances.cxx:48
virtual void Add(TDataSet *dataset)
Definition: TDataSet.h:150
virtual ENodeSEEN GetVisibility() const
Definition: TVolume.h:82
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:467
TRotMatrix * GetRotMatrix(const char *name) const
Return pointer to RotMatrix with name.
Definition: TGeometry.cxx:356
virtual TRotMatrix * GetMatrix() const
Definition: TNode.h:66
TList * GetListOfNodes() const
Definition: TNode.h:65
static Int_t MapGEANT2StNodeVis(Int_t vis)
ENodeSEEN TVolume::MapGEANT2StNodeVis(Int_t vis) Maps the value of GEANT 3.21 "volume attributes" to ...
Definition: TVolume.cxx:146
void CallRecursiveRemoveIfNeeded(TObject &obj)
call RecursiveRemove for obj if gROOT is valid and obj.TestBit(kMustCleanup) is true.
Definition: TROOT.h:399
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
Computes distance from point (px,py) to the object.
Definition: TObject.cxx:186
float Float_t
Definition: RtypesCore.h:53
static Int_t MapStNode2GEANTVis(ENodeSEEN vis)
ENodeSEEN Visibility flag 00 - everything visible, 10 - this invisible, but sons are visible 01 - thi...
Definition: TVolume.cxx:136
static Int_t gGeomLevel
Definition: TNode.cxx:34
const char Option_t
Definition: RtypesCore.h:62
ENodeSEEN
Definition: TVolume.h:38
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TNamed.cxx:140
virtual void SetAutoRange(Bool_t autorange=kTRUE)=0
virtual void cd(const char *path=0)
Change Current Reference node to this.
Definition: TNode.cxx:250
See TView3D.
Definition: TView.h:25
const Int_t kMAXLEVELS
Definition: TGeometry.h:27
TNode description.
Definition: TNode.h:33
#define gROOT
Definition: TROOT.h:410
TList * fListOfShapes
Definition: TVolume.h:44
ENodeSEEN fVisibility
Definition: TVolume.h:46
Basic string class.
Definition: TString.h:131
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1100
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual Double_t GetX() const
Definition: TNode.h:73
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition: TAttFill.h:39
virtual void Draw(Option_t *depth="3")
Default Draw method for all objects.
Definition: TVolume.cxx:427
virtual Double_t GetZ() const
virtual void Remove(TDataSet *set)
Remiove the "set" from this TDataSet.
Definition: TDataSet.cxx:641
virtual void Modify()
Change current line attributes if necessary.
Definition: TAttLine.cxx:234
virtual void SetMatrix(const Double_t *matrix)
copy predefined 3x3 matrix into TRotMatrix object
Definition: TRotMatrix.cxx:216
virtual void NDCtoWC(const Float_t *pn, Float_t *pw)=0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual Width_t GetLineWidth() const
Return the line width.
Definition: TAttLine.h:35
virtual void PaintShape(Option_t *option="")
Paint shape of the volume To be called from the TObject::Paint method only.
Definition: TVolume.cxx:635
virtual const TBuffer3D & GetBuffer3D(Int_t reqSections) const
Stub to avoid forcing implementation at this stage.
Definition: TShape.cxx:253
virtual void AppendPad(Option_t *option="")
Append graphics object to current pad.
Definition: TObject.cxx:105
const TRotMatrix * GetMatrix() const
virtual Style_t GetLineStyle() const
Return the line style.
Definition: TAttLine.h:34
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
Fill Area Attributes class.
Definition: TAttFill.h:19
Double_t x[n]
Definition: legend1.C:17
virtual void Paint(Option_t *option="")
This method must be overridden if a class wants to paint itself.
Definition: TVolume.cxx:568
virtual void Add(TDataSet *dataset)
Definition: TVolume.h:97
const Int_t kVectorSize
Definition: TGeometry.h:28
virtual void SetVisibility(Int_t vis=1)
Set visibility for this node and its sons.
Definition: TNode.cxx:759
Int_t GeomLevel() const
Definition: TGeometry.h:74
virtual void SetVisibility(ENodeSEEN vis=TVolume::kBothVisible)
Set visibility for this volume and its sons.
Definition: TVolume.cxx:747
virtual void Modify()
Change current fill area attributes if necessary.
Definition: TAttFill.cxx:210
virtual void ImportShapeAttributes()
Definition: TVolume.cxx:548
TShape * GetShape() const
Definition: TNode.h:71
const Option_t * GetOption() const
Definition: TVolume.h:78
virtual TList * GetListOfPositions()
Definition: TVolume.h:83
TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TDataSet.h:101
virtual Int_t PushLevel()
Definition: TGeometry.h:99
TShape * fShape
Definition: TVolume.h:43
Abstract 3D shapes viewer.
static TRotMatrix * GetIdentity()
Return a pointer the "identity" matrix.
Definition: TVolume.cxx:501
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:49
short Color_t
Definition: RtypesCore.h:79
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
to be documented
Definition: TVolume.cxx:339
A doubly linked list.
Definition: TList.h:44
TGeometry description.
Definition: TGeometry.h:39
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition: TAttLine.h:40
R__EXTERN TNode * gNode
Definition: TShape.h:68
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition: TRotMatrix.h:69
virtual Double_t GetX(Int_t indx=0) const
virtual ~TVolume()
Definition: TVolume.cxx:239
static TRotMatrix * gIdentity
Definition: TVolume.cxx:46
This is the base class for all geometry shapes.
Definition: TShape.h:35
Manages a detector rotation matrix.
Definition: TRotMatrix.h:28
const Option_t * GetOption() const
Definition: TNode.h:69
virtual void PaintNodePosition(Option_t *option="", TVolumePosition *postion=0)
Definition: TVolume.cxx:585
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:37
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:818
virtual void Browse(TBrowser *b)
to be documented
Definition: TVolume.cxx:318
virtual void UpdatePosition(Option_t *option="")
to be documented
virtual Int_t AddObject(const TBuffer3D &buffer, Bool_t *addChildren=0)=0
virtual TNode * CreateTNode(const TVolumePosition *position=0)
Convert a TVolume object into a TNode.
Definition: TVolume.cxx:197
unsigned int UInt_t
Definition: RtypesCore.h:42
TVolume()
TVolume description.
Definition: TVolume.cxx:69
The most important graphics class in the ROOT system.
Definition: TPad.h:29
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Generic 3D primitive description class.
Definition: TBuffer3D.h:17
virtual void ImportShapeAttributes()
Copy shape attributes as node attributes.
Definition: TNode.cxx:410
virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py)
Execute action corresponding to an event at (px,py).
Definition: TVolume.cxx:489
virtual TList * Nodes() const
Definition: TVolume.h:88
virtual TObjLink * FirstLink() const
Definition: TList.h:108
virtual void SetId(UInt_t id)
virtual Color_t GetLineColor() const
Return the line color.
Definition: TAttLine.h:33
virtual void DrawOnly(Option_t *option="")
Definition: TVolume.cxx:476
#define SafeDelete(p)
Definition: RConfig.h:529
virtual void Paint(Option_t *option="")
This method is used only when a shape is painted outside a TNode.
Definition: TShape.cxx:143
The Canvas class.
Definition: TCanvas.h:31
THashList * GetListOfMatrices() const
Definition: TGeometry.h:78
#define ClassImp(name)
Definition: Rtypes.h:359
virtual char * GetObjectInfo(Int_t px, Int_t py) const
to be documented
Definition: TVolume.cxx:525
double Double_t
Definition: RtypesCore.h:55
virtual void Sizeof3D() const
Set total size of this 3D object (used by X3D interface).
Definition: TVolume.cxx:755
Double_t y[n]
Definition: legend1.C:17
TString fOption
Definition: TVolume.h:45
virtual Color_t GetFillColor() const
Return the fill area color.
Definition: TAttFill.h:30
virtual Double_t GetY() const
Definition: TNode.h:74
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:619
void SetPositionsList(TList *list=0)
Definition: TVolume.h:55
virtual Int_t DistancetoNodePrimitive(Int_t px, Int_t py, TVolumePosition *position=0)
Compute distance from point px,py to a TVolumeView.
Definition: TVolume.cxx:353
const Int_t kMatrixSize
Definition: TGeometry.h:29
virtual void SetLineAttr(Color_t color, Int_t width, Option_t *opt="")
virtual void SetGeomLevel(Int_t level=0)
Definition: TGeometry.h:104
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition: TAttLine.h:42
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:39
virtual TVolume * GetNode() const
Mother of all ROOT objects.
Definition: TObject.h:37
you should not use this method at all Int_t Int_t z
Definition: TRolke.cxx:630
virtual void UpdateTempMatrix(Double_t x=0, Double_t y=0, Double_t z=0, TRotMatrix *matrix=0)
Update temp matrix.
Definition: TGeometry.cxx:661
TShape * GetShape() const
Definition: TVolume.h:79
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual void GetLocalRange(Float_t *min, Float_t *max)
GetRange.
Definition: TVolume.cxx:721
virtual void GetRange(Float_t *min, Float_t *max)=0
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
#define snprintf
Definition: civetweb.c:1351
static Double_t gRotMatrix[kMAXLEVELS][kMatrixSize]
Definition: TNode.cxx:33
#define gPad
Definition: TVirtualPad.h:285
virtual void Sizeof3D() const
Set total size of this 3D object (used by X3D interface).
Definition: TAtt3D.cxx:27
virtual Style_t GetFillStyle() const
Return the fill area style.
Definition: TAttFill.h:31
virtual void PopMatrix()
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
virtual Double_t GetZ() const
Definition: TNode.h:75
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition: TNamed.cxx:164
R__EXTERN TGeometry * gGeometry
Definition: TGeometry.h:158
const Bool_t kTRUE
Definition: RtypesCore.h:87
virtual Int_t PopLevel()
Definition: TGeometry.h:100
Int_t GetVisibility() const
Definition: TShape.h:58
Line Attributes class.
Definition: TAttLine.h:18
char name[80]
Definition: TGX11.cxx:109
virtual TSeqCollection * GetCollection() const
Definition: TDataSet.h:105
virtual void PushMatrix()
Int_t GetVisibility() const
Definition: TNode.h:72
TShape * GetShape(const char *name) const
Return pointer to Shape with name.
Definition: TGeometry.cxx:379
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual TDataSet * GetParent() const
Definition: TDataSet.h:111
const char * Data() const
Definition: TString.h:364