Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

TNNode.cxx

Go to the documentation of this file.
00001 #include "bfemDisplay/TNNode.h"
00002 #include "TROOT.h"
00003 
00004 #include "TObject.h"
00005 #include "TBuffer.h"
00006 #include "TNamed.h"
00007 #include "TROOT.h"
00008 #include "TClass.h"
00009 #include "TVirtualPad.h"
00010 #include "TView.h"
00011 #include "TGeometry.h"
00012 #include "TRotMatrix.h"
00013 #include "TShape.h"
00014 #include "TNode.h"
00015 #include "TBrowser.h"
00016 #include "X3DBuffer.h"
00017 
00018 #include "TPadView3D.h"
00019 
00020 
00021 ClassImp(TNNode)
00022 
00023   Int_t TNNode::DistancetoPrimitive(Int_t px, Int_t py)

00024 {
00025   //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
00026   // Ho modificato questa funzione in modo tale che, quando il mouse e`
00027   // ad una distanza inferiore a maxdist, l'oggetto selezionato e'
00028   // fRefObject ...
00029 
00030    const Int_t big = 9999;
00031    const Int_t inaxis = 7;
00032    const Int_t maxdist = 3;
00033 
00034    Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
00035    Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
00036    Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
00037    Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
00038 
00039 //*-*- return if point is not in the user area
00040    if (px < puxmin - inaxis) return big;
00041    if (py > puymin + inaxis) return big;
00042    if (px > puxmax + inaxis) return big;
00043    if (py < puymax - inaxis) return big;
00044 
00045    TView *view =gPad->GetView();
00046    if (!view) return big;
00047 
00048 //*-*- Update translation vector and rotation matrix for new level
00049    if (fMatrix && gGeometry) {
00050       gGeometry->UpdateTempMatrix(fX,fY,fZ,fMatrix->GetMatrix(),fMatrix->IsReflection());
00051    }
00052 //*-*- Paint Referenced shape
00053    Int_t dist = big;
00054    if (fVisibility && fShape->GetVisibility()) {
00055       gNode = this;
00056       dist = fShape->DistancetoPrimitive(px,py);
00057       if (dist < maxdist) {
00058         gPad->SetCursor(kHand);
00059         if(fRefObject) { gPad->SetSelected(fRefObject); return 0; }
00060       }
00061    }
00062    if ( TestBit(kSonsInvisible) ) return dist;
00063    if (!gGeometry) return dist;
00064    
00065 //*-*- Loop on all sons
00066    Int_t nsons = 0;
00067    if (fNodes) nsons = fNodes->GetSize();
00068    Int_t dnode = dist;
00069    if (nsons) {
00070 
00071       gGeometry->PushLevel();
00072       TNode *node;
00073       TObject *obj;
00074       TIter  next(fNodes);
00075       while ((obj = next())) {
00076          node = (TNode*)obj;
00077          dnode = node->DistancetoPrimitive(px,py);
00078          if (dnode <= 0) break;
00079          if (dnode < dist) dist = dnode;
00080       }
00081       gGeometry->PopLevel();
00082    }
00083 
00084    if (gGeometry->GeomLevel()==0 && dnode > maxdist) {
00085       gPad->SetSelected(view);
00086       return 0;
00087    } else
00088       return dnode;
00089 }
00090 
00091 
00092 

Generated at Mon Nov 26 18:20:07 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000