00001 #include "bfemDisplay/TNNode.h"
00002
00003 #include "TObject.h"
00004 #include "TBuffer.h"
00005 #include "TNamed.h"
00006 #include "TROOT.h"
00007 #include "TClass.h"
00008 #include "TVirtualPad.h"
00009 #include "TView.h"
00010 #include "TGeometry.h"
00011 #include "TRotMatrix.h"
00012 #include "TShape.h"
00013 #include "TNode.h"
00014 #include "TBrowser.h"
00015 #include "X3DBuffer.h"
00016
00017 #include "TPadView3D.h"
00018
00019
00020 ClassImp(TNNode)
00021
00022 Int_t TNNode::DistancetoPrimitive(Int_t px, Int_t py)
00023 {
00024
00025
00026
00027
00028
00029 const Int_t big = 9999;
00030 const Int_t inaxis = 7;
00031 const Int_t maxdist = 3;
00032
00033 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
00034 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
00035 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
00036 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
00037
00038
00039 if (px < puxmin - inaxis) return big;
00040 if (py > puymin + inaxis) return big;
00041 if (px > puxmax + inaxis) return big;
00042 if (py < puymax - inaxis) return big;
00043
00044 TView *view =gPad->GetView();
00045 if (!view) return big;
00046
00047
00048 if (fMatrix && gGeometry) {
00049 gGeometry->UpdateTempMatrix(fX,fY,fZ,fMatrix->GetMatrix(),fMatrix->IsReflection());
00050 }
00051
00052 Int_t dist = big;
00053 if (fVisibility && fShape->GetVisibility()) {
00054 gNode = this;
00055 dist = fShape->DistancetoPrimitive(px,py);
00056 if (dist < maxdist) {
00057 gPad->SetCursor(kHand);
00058 if(fRefObject) { gPad->SetSelected(fRefObject); return 0; }
00059 }
00060 }
00061 if ( TestBit(kSonsInvisible) ) return dist;
00062 if (!gGeometry) return dist;
00063
00064
00065 Int_t nsons = 0;
00066 if (fNodes) nsons = fNodes->GetSize();
00067 Int_t dnode = dist;
00068 if (nsons) {
00069
00070 gGeometry->PushLevel();
00071 TNode *node;
00072 TObject *obj;
00073 TIter next(fNodes);
00074 while ((obj = next())) {
00075 node = (TNode*)obj;
00076 dnode = node->DistancetoPrimitive(px,py);
00077 if (dnode <= 0) break;
00078 if (dnode < dist) dist = dnode;
00079 }
00080 gGeometry->PopLevel();
00081 }
00082
00083 if (gGeometry->GeomLevel()==0 && dnode > maxdist) {
00084 gPad->SetSelected(view);
00085 return 0;
00086 } else
00087 return dnode;
00088 }
00089
00090
00091