13 #include "Riostream.h"
21 #include "TVolumeView.h"
22 #include "TVolumeViewIter.h"
23 #include "TVolumePosition.h"
26 #include "TTablePadView3D.h"
27 #include "TGeometry.h"
28 #include "TVirtualPad.h"
29 #include "TObjArray.h"
30 #include "TVirtualViewer3D.h"
31 #include "TBuffer3D.h"
54 :
TObjectSet(viewNode->GetName(),(TObject *)nodePosition),fListOfShapes(0)
63 if (!gGeometry)
new TGeometry;
65 SetTitle(viewNode->GetTitle());
66 EDataSetPass mode = kContinue;
71 if (nextView->IsMarked()) {
73 if (!position->GetNode()) {
74 Error(
"TVolumeView ctor",
"%s %s ",
GetName(),nextView->GetName());
86 :
TObjectSet(viewNode->GetName(),(TObject *)0),fListOfShapes(0)
99 if (!gGeometry)
new TGeometry;
100 if (viewNode && topNode) {
101 SetTitle(viewNode->GetTitle());
103 EDataSetPass mode = kContinue;
109 if (topNode != nextView)
continue;
111 if (!position->GetNode()) {
112 Error(
"TVolumeView ctor",
"%s %s ",
GetName(),nextView->GetName());
123 :
TObjectSet(viewNode->GetName(),(TObject *)0),fListOfShapes(0)
136 const Char_t *foundName[2] = {nodeName1, nodeName2};
137 Bool_t found = kFALSE;
138 if (!gGeometry)
new TGeometry;
139 if (viewNode && nodeName1 && nodeName1[0]) {
140 SetTitle(viewNode->GetTitle());
142 EDataSetPass mode = kContinue;
152 if (strcmp(nextView->GetName(),foundName[i]))
continue;
158 if (!found)
continue;
160 if (!position->GetNode()) {
161 Error(
"TVolumeView ctor",
"%s %s ",
GetName(),nextView->GetName());
172 :
TObjectSet(viewNode->GetName(),(TObject *)0),fListOfShapes(0)
186 const Int_t nViews =
sizeof(foundView)/
sizeof(
const TVolumeView *);
187 Bool_t found = kFALSE;
188 if (!gGeometry)
new TGeometry;
190 SetTitle(viewNode->GetTitle());
192 EDataSetPass mode = kContinue;
200 for (i=0;i<nViews;i++) {
202 if (nextView != foundView[i])
continue;
208 if (!found)
continue;
210 if (!position->GetNode()) {
211 Error(
"TVolumeView ctor",
"%s %s ",
GetName(),nextView->GetName());
237 :
TObjectSet(pattern.GetName(),(TObject *)nodePosition),fListOfShapes(0)
239 if (!gGeometry)
new TGeometry;
249 SetTitle(pattern.GetTitle());
250 if ( pattern.IsMarked() ) Mark();
252 const TList *list = pattern.GetListOfPositions();
253 if (!list || maxDepLevel == 1 || maxDepLevel < 0)
return;
255 TIter nextPosition(list);
256 Bool_t optSel = (iopt == kStruct);
258 Bool_t optMarked = (iopt == kMarked);
260 const TRotMatrix *thisMatrix = 0;
261 Double_t thisTranslation[3] = {0,0,0};
263 thisMatrix = nodePosition->GetMatrix();
264 for (
int i =0; i< 3; i++) thisTranslation[i]= nodePosition->GetX(i);
268 TVolume *node = position->GetNode();
269 Double_t *positionMatrix = ((TRotMatrix *)position->GetMatrix())->GetMatrix();
271 UInt_t positionId = position->GetId();
272 Double_t newTranslation[3] = {position->GetX(),position->GetY(),position->GetZ()};
273 Double_t newMatrix[9];
274 TRotMatrix currentMatrix;
277 if (positionMatrix) {
278 TGeometry::UpdateTempMatrix(thisTranslation,thisMatrix?((TRotMatrix *)thisMatrix)->GetMatrix():0
279 ,position->GetX(),position->GetY(),position->GetZ(),positionMatrix
280 ,newTranslation,newMatrix);
281 currentMatrix.SetMatrix(newMatrix);
283 TCL::vadd(thisTranslation, newTranslation,newTranslation,3);
284 currentMatrix.SetMatrix(((TRotMatrix *)thisMatrix)->GetMatrix());
288 currentMatrix.SetMatrix(positionMatrix);
290 TCL::ucopy(thisTranslation,newTranslation,3);
295 newTranslation[2], ¤tMatrix);
296 nextPos.SetId(positionId);
297 if (optMarked && !node->IsMarked()) {
298 TVolumeView fakeView(*node,maxDepLevel,&nextPos,iopt,rootVolume);
304 TDataSet *parent = node->GetParent();
305 if ( parent && (parent != (
TDataSet *)&pattern) )
continue;
307 TRotMatrix *newRotation =
new TRotMatrix();
308 newRotation->SetMatrix(currentMatrix.GetMatrix());
310 newTranslation[2], newRotation);
311 nP->SetId(positionId);
312 rootVolume->Add(
new TVolumeView(*node,maxDepLevel?maxDepLevel-1:0,nP,iopt));
314 Error(
"TVolumeView ctor",
"Position with NO node attached has been supplied");
322 TObjectSet(viewNode.GetName(),(TObject *)viewNode.GetPosition())
324 ,fListOfShapes(viewNode.GetListOfShapes())
326 if (viewNode.IsOwner()) {
333 TVolumeView::TVolumeView(Double_t *translate, Double_t *rotate, UInt_t positionId,
TVolume *topNode,
334 const Char_t *thisNodePath,
const Char_t *matrixName, Int_t matrixType)
338 if (!gGeometry)
new TGeometry;
341 Double_t thisX = translate[0];
342 Double_t thisY = translate[1];
343 Double_t thisZ = translate[2];
348 if (!thisNode->InheritsFrom(TVolume::Class())) {
349 Error(
"TVolumeView",
"wrong node <%s> on path: \"%s\"",thisNode->GetName(),thisNodePath);
354 TRotMatrix *thisRotMatrix = 0;
355 if (matrixName && strlen(matrixName)) thisRotMatrix = gGeometry->GetRotMatrix(matrixName);
358 thisPosition =
new TVolumePosition(thisNode,thisX, thisY, thisZ, matrixName);
359 else if (matrixType==2)
362 const Char_t *title =
"rotation";
363 thisRotMatrix =
new TRotMatrix((
char *)matrixName,(
char *)title,rotate);
364 thisPosition =
new TVolumePosition(thisNode,thisX, thisY, thisZ, thisRotMatrix);
366 Error(
"TVolumeView",
" No rotation matrix is defined");
367 if (thisPosition) thisPosition->SetId(positionId);
370 SetName(thisNode->GetName());
371 SetTitle(thisNode->GetTitle());
379 :
TObjectSet(thisNode?thisNode->GetName():
"",(TObject *)nodePosition),fListOfShapes(0)
381 if (!gGeometry)
new TGeometry;
382 SafeDelete(fListOfShapes);
384 SetTitle(thisNode->GetTitle());
403 if ( node && (pos = GetPosition() ) && (closedNode = pos->GetNode()) )
404 closedNode->Add(node);
411 void TVolumeView::Add(TShape *shape, Bool_t IsMaster)
414 if (!fListOfShapes) fListOfShapes =
new TList;
416 fListOfShapes->AddFirst(shape);
418 fListOfShapes->Add(shape);
443 const Int_t big = 9999;
444 const Int_t inaxis = 7;
445 const Int_t maxdist = 5;
449 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
450 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
451 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
452 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
455 if (px < puxmin - inaxis)
return big;
456 if (py > puymin + inaxis)
return big;
457 if (px > puxmax + inaxis)
return big;
458 if (py < puymax - inaxis)
return big;
460 TView *view =gPad->GetView();
461 if (!view)
return big;
465 TShape *thisShape = 0;
467 thisNode = position->GetNode();
470 thisShape = thisNode->GetShape();
471 if (!(thisNode->GetVisibility() & TVolume::kThisUnvisible) &&
472 thisShape && thisShape->GetVisibility()) {
473 dist = thisShape->DistancetoPrimitive(px,py);
474 if (dist < maxdist) {
475 gPad->SetSelected(
this);
485 TSeqCollection *fNodes = GetCollection();
486 Int_t nsons = fNodes?fNodes->GetSize():0;
489 gGeometry->PushLevel();
492 while ((node = (
TVolume *)next())) {
494 if (dnode <= 0)
break;
495 if (dnode < dist) dist = dnode;
496 if (gGeometry->GeomLevel() > 2)
break;
498 gGeometry->PopLevel();
501 if (gGeometry->GeomLevel()==0 && dnode > maxdist) {
502 gPad->SetSelected(view);
513 TString opt = option;
517 gROOT->MakeDefCanvas();
519 if (!opt.Contains(
"same")) gPad->Clear();
522 gGeometry->SetGeomLevel();
523 gGeometry->UpdateTempMatrix();
527 Int_t iopt = atoi(option);
531 snprintf(buffer,12,
"%d",-iopt);
535 do parent = parent->GetParent();
536 while (parent && ++iopt);
538 if (parent) parent->AppendPad(option);
539 else AppendPad(option);
541 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,03,05)
544 TView *view = gPad->GetView();
546 view = TView::CreateView(1,0,0);
549 view->SetAutoRange(kTRUE);
553 gPad->GetViewer3D(option);
566 return pos->GetNode();
579 SetTitle(rootNode->GetTitle());
580 EDataSetPass mode = kContinue;
584 while ( (nextView = (
TVolumeView *)next(mode)) && nextView !=
this ){}
585 if (nextView ==
this) {
587 if (!position->GetNode()) {
588 Error(
"TVolumeView ctor",
"%s %s ",GetName(),nextView->GetName());
592 Float_t offSet[3] = {Float_t(position->GetX()),Float_t(position->GetY()),Float_t(position->GetZ())};
593 for (Int_t i=0;i<3;i++) {
594 globalMin[i] += offSet[i];
595 globalMax[i] += offSet[i];
598 return next.GetDepth();
614 TVirtualPad *savePad = gPad;
616 TCanvas dummyPad(
"--Dumm--",
"dum",1,1);
618 TView *view = TView::CreateView(1,0,0);
620 gGeometry->SetGeomLevel();
621 gGeometry->UpdateTempMatrix();
622 view->SetAutoRange(kTRUE);
624 view->GetRange(&min[0],&max[0]);
627 if (savePad) savePad->cd();
636 static char info[512];
637 Double_t x[3] = {0,0,0.5};
638 ((TPad *)gPad)->AbsPixeltoXY(px,py,x[0],x[1]);
639 TView *view =gPad->GetView();
641 Double_t min[3], max[3];
642 view->GetRange(min,max);
643 for (
int i =0; i<3;i++) min[i] = (max[i]+min[i])/2;
644 view->WCtoNDC(min,max);
645 min[0] = x[0]; min[1] = x[1];
647 view->NDCtoWC(min, x);
649 TShape *shape = GetShape();
651 snprintf(info,512,
"%6.2f/%6.2f/%6.2f: %s/%s, shape=%s/%s",x[0],x[1],x[2],GetName(),GetTitle(),shape->GetName(),shape->ClassName());
653 snprintf(info,512,
"%6.2f/%6.2f/%6.2f: %s/%s",x[0],x[1],x[2],GetName(),GetTitle());
664 if (masterName && masterName[0]) masterNode = (
TVolumeView *)
Find(masterName);
667 if (transform(localName)) position = transform[0];
678 if (!masterNode) masterNode =
this;
679 if (masterNode && localNode) {
682 while ((nextNode = (
TVolumeView *)transform()) && nextNode != localNode) { }
683 if (nextNode) position = transform[0];
700 const Char_t *localName,
const Char_t *masterName, Int_t nVector)
705 if (masterName && masterName[0]) masterNode = (
TVolumeView *)
Find(masterName);
731 if (!masterNode) masterNode =
this;
732 if (masterNode && localNode) {
735 while ((nextNode = (
TVolumeView *)transform()) && nextNode != localNode) { }
757 Int_t level = gGeometry->GeomLevel();
759 if (option[0]==
'r' && level > 3 )
return;
761 Int_t iFirst = atoi(option);
763 const char *delim = strpbrk( option,
":-,");
764 if (delim) iLast = atoi(delim+1);
765 if (iLast < iFirst) {
770 if ( (0 < iLast) && (iLast < level) )
return;
779 thisNode = position->GetNode();
784 if (level >= iFirst) {
791 TSeqCollection *nodes = GetCollection();
792 Int_t nsons = nodes?nodes->GetSize():0;
796 gGeometry->PushLevel();
800 if (view3D) view3D->PushMatrix();
804 if (view3D) view3D->PopMatrix();
806 gGeometry->PopLevel();
815 Bool_t rangeView = option && option[0]==
'r';
817 TIter nextShape(fListOfShapes);
819 while( (shape = (TShape *)nextShape()) ) {
820 if (!shape->GetVisibility())
continue;
824 view3D->SetLineAttr(shape->GetLineColor(),shape->GetLineWidth(),option);
826 #if ROOT_VERSION_CODE >= ROOT_VERSION(4,03,05)
828 Bool_t viewerWantsSons = kTRUE;
829 TVirtualViewer3D * viewer3D = gPad->GetViewer3D();
836 const TBuffer3D & buffer =
837 shape->GetBuffer3D(TBuffer3D::kCore|TBuffer3D::kBoundingBox|TBuffer3D::kShapeSpecific);
841 const_cast<TBuffer3D &
>(buffer).fID =
this;
843 Int_t reqSections = viewer3D->AddObject(buffer, &viewerWantsSons);
844 if (reqSections != TBuffer3D::kNone) {
845 shape->GetBuffer3D(reqSections);
846 viewer3D->AddObject(buffer);
850 shape->Paint(option);
863 str = parent->
PathP();
870 snprintf(buffer,10,
";%d",p->GetId());
881 const Char_t *sceleton[] = {
882 "TVolumeView *CreateNodeView(TVolume *topNode) {"
883 ,
" TString thisNodePath = "
884 ,
" UInt_t thisPositionId = "
885 ,
" Double_t thisTranslate[3] = "
887 ,
" TString matrixName = "
888 ,
" Int_t matrixType = "
889 ,
" Double_t thisMatrix[] = { "
893 ,
" return = new TVolumeView(thisTranslate, thisMatrix, thisPositionId, topNode,"
894 ,
" thisNodePath.Data(),matrixName.Data(), matrixType);"
898 Int_t sceletonSize =
sizeof(sceleton)/
sizeof(
const Char_t*);
901 TString thisNodePath = thisFullNode ? thisFullNode->
Path() : TString(
"");
903 UInt_t thisPositionId = thisPosition ? thisPosition->GetId():0;
904 Double_t thisX = thisPosition ? thisPosition->GetX():0;
905 Double_t thisY = thisPosition ? thisPosition->GetY():0;
906 Double_t thisZ = thisPosition ? thisPosition->GetZ():0;
908 const TRotMatrix *matrix = thisPosition ? thisPosition->GetMatrix():0;
909 Int_t matrixType = 2;
910 TString matrixName =
" ";
911 Double_t thisMatrix[] = { 0,0,0, 0,0,0, 0,0,0 };
913 matrixName = matrix->GetName();
914 memcpy(thisMatrix,((TRotMatrix *)matrix)->GetMatrix(),9*
sizeof(Double_t));
915 matrixType = matrix->GetType();
918 for (Int_t lineNumber =0; lineNumber < sceletonSize; lineNumber++) {
919 out << sceleton[lineNumber];
920 switch (lineNumber) {
921 case 1: out <<
"\"" << thisNodePath.Data() <<
"\";" ;
923 case 2: out << thisPositionId <<
";" ;
925 case 3: out <<
"{" << thisX <<
", " << thisY <<
", "<< thisZ <<
"};";
927 case 5: out <<
"\"" << matrixName <<
"\";" ;
929 case 6: out << matrixType <<
";" ;
931 case 7: out << thisMatrix[im++] <<
", "; out << thisMatrix[im++] <<
", "; out << thisMatrix[im++] <<
", ";
933 case 8: out << thisMatrix[im++] <<
", "; out << thisMatrix[im++] <<
", "; out << thisMatrix[im++] <<
", ";
935 case 9: out << thisMatrix[im++] <<
", "; out << thisMatrix[im++] <<
", "; out << thisMatrix[im++];
941 out <<
" " << std::endl;
951 if (thisNode) thisNode->SetLineAttributes();
968 if (GetListOfShapes()) {
969 TIter nextShape(GetListOfShapes());
971 while( (shape = (TShape *)nextShape()) ) {
972 if (shape->GetVisibility()) shape->Sizeof3D();
977 if (thisNode && !(thisNode->GetVisibility()&TVolume::kThisUnvisible) ) {
978 TIter nextShape(thisNode->GetListOfShapes());
980 while( (shape = (TShape *)nextShape()) ) {
981 if (shape->GetVisibility()) shape->Sizeof3D();
virtual Bool_t DoOwner(Bool_t done=kTRUE)
TVolumeView(TVolumeView &viewNode)
to be documented
virtual void PaintShape(Option_t *option="")
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
virtual void SetVisibility(ENodeSEEN vis=TVolume::kBothVisible)
virtual TVolumePosition * Local2Master(const TVolumeView *localNode, const TVolumeView *masterNode=0)
to be documented
virtual Double_t * Local2Master(const Double_t *local, Double_t *master, Int_t nPoints=1) const
virtual void Paint(Option_t *option="")
static TRotMatrix * GetIdentity()
Return a pointer the "identity" matrix.
virtual void Sizeof3D() const
Return total size of this 3-D Node with its attributes.
virtual Int_t DistancetoPrimitive(Int_t px, Int_t py)
to be documented
virtual void GetLocalRange(Float_t *min, Float_t *max)
virtual void SetObject(TObject *obj)
The depricated method (left here for the sake of the backward compatibility)
virtual TVolume * AddNode(TVolume *node)
virtual void SetLineAttributes()
to be documented
virtual void UpdatePosition(Option_t *option="")
to be documented
virtual const TVolumePosition * GetPosition(Int_t level=0) const
to be documented
virtual TString PathP() const
return the full path of this data set
virtual void Browse(TBrowser *b)
to be documented
virtual void PaintShape(Option_t *option)
virtual char * GetObjectInfo(Int_t px, Int_t py) const
to be documented
virtual void Browse(TBrowser *b)
Browse this dataset (called by TBrowser).
virtual TVolume * GetNode() const
to be documented
virtual ~TVolumeView()
default dtor (empty for this class)
virtual void Draw(Option_t *depth="3")
Draw Referenced node with current parameters.
virtual TString Path() const
return the full path of this data set
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
to be documented
virtual Int_t GetGlobalRange(const TVolumeView *rootNode, Float_t *min, Float_t *max)
virtual void SetVisibility(Int_t vis=1)
to be documented
virtual TDataSet * Find(const char *path) const
virtual const Char_t * GetName() const
return VolumePosition name