TEvePointSet.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEvePointSet.cxx 33955 2010-06-17 11:33:13Z matevz $
00002 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TEvePointSet.h"
00013 
00014 #include "TEveManager.h"
00015 #include "TEveProjectionManager.h"
00016 #include "TEveTrans.h"
00017 
00018 #include "TTree.h"
00019 #include "TTreePlayer.h"
00020 #include "TF3.h"
00021 
00022 #include "TColor.h"
00023 
00024 
00025 //==============================================================================
00026 //==============================================================================
00027 // TEvePointSet
00028 //==============================================================================
00029 
00030 //______________________________________________________________________________
00031 //
00032 // TEvePointSet is a render-element holding a collection of 3D points with
00033 // optional per-point TRef and an arbitrary number of integer ids (to
00034 // be used for signal, volume-id, track-id, etc).
00035 //
00036 // 3D point representation is implemented in base-class TPolyMarker3D.
00037 // Per-point TRef is implemented in base-class TPointSet3D.
00038 //
00039 // By using the TEvePointSelector the points and integer ids can be
00040 // filled directly from a TTree holding the source data.
00041 // Setting of per-point TRef's is not supported.
00042 //
00043 // TEvePointSet is a TEveProjectable: it can be projected by using the
00044 // TEveProjectionManager class.
00045 
00046 ClassImp(TEvePointSet);
00047 
00048 //______________________________________________________________________________
00049 TEvePointSet::TEvePointSet(Int_t n_points, ETreeVarType_e tv_type) :
00050    TEveElement(fMarkerColor),
00051    TPointSet3D(n_points),
00052    TEvePointSelectorConsumer(tv_type),
00053    TEveProjectable(),
00054    TQObject(),
00055 
00056    fTitle          (),
00057    fIntIds         (0),
00058    fIntIdsPerPoint (0)
00059 {
00060    // Constructor.
00061 
00062    fMarkerStyle = 20;
00063 
00064    // Override from TEveElement.
00065    fPickable = kTRUE;
00066 }
00067 
00068 //______________________________________________________________________________
00069 TEvePointSet::TEvePointSet(const char* name, Int_t n_points, ETreeVarType_e tv_type) :
00070    TEveElement(fMarkerColor),
00071    TPointSet3D(n_points),
00072    TEvePointSelectorConsumer(tv_type),
00073    TEveProjectable(),
00074    TQObject(),
00075 
00076    fTitle          (),
00077    fIntIds         (0),
00078    fIntIdsPerPoint (0)
00079 {
00080    // Constructor.
00081 
00082    fMarkerStyle = 20;
00083    SetName(name);
00084 
00085    // Override from TEveElement.
00086    fPickable = kTRUE;
00087 }
00088 
00089 //______________________________________________________________________________
00090 TEvePointSet::TEvePointSet(const TEvePointSet& e) :
00091    TEveElement(e),
00092    TPointSet3D(e),
00093    TEvePointSelectorConsumer(e),
00094    TEveProjectable(),
00095    TQObject(),
00096 
00097    fTitle          (e.fTitle),
00098    fIntIds         (e.fIntIds ? new TArrayI(*e.fIntIds) : 0),
00099    fIntIdsPerPoint (e.fIntIdsPerPoint)
00100 {
00101    // Copy constructor.
00102 }
00103 
00104 //______________________________________________________________________________
00105 TEvePointSet::~TEvePointSet()
00106 {
00107    // Destructor.
00108 
00109    delete fIntIds;
00110 }
00111 
00112 /******************************************************************************/
00113 
00114 //______________________________________________________________________________
00115 void TEvePointSet::ClonePoints(const TEvePointSet& e)
00116 {
00117    // Clone points and all point-related information from point-set 'e'.
00118 
00119    // TPolyMarker3D
00120    delete [] fP;
00121    fN = e.fN;
00122    if (fN > 0)
00123    {
00124       const Int_t nn = 3 * e.fN;
00125       fP = new Float_t [nn];
00126       for (Int_t i = 0; i < nn; i++) fP[i] = e.fP[i];
00127    } else {
00128       fP = 0;
00129    }
00130    fLastPoint = e.fLastPoint;
00131 
00132    // TPointSet3D
00133    CopyIds(e);
00134 
00135    // TEvePointSet
00136    delete fIntIds;
00137    fIntIds         = e.fIntIds ? new TArrayI(*e.fIntIds) : 0;
00138    fIntIdsPerPoint = e.fIntIdsPerPoint;
00139 }
00140 
00141 /******************************************************************************/
00142 
00143 //______________________________________________________________________________
00144 const TGPicture* TEvePointSet::GetListTreeIcon(Bool_t)
00145 {
00146    // Return pointset icon.
00147 
00148    return TEveElement::fgListTreeIcons[3];
00149 }
00150 
00151 //______________________________________________________________________________
00152 void TEvePointSet::Reset(Int_t n_points, Int_t n_int_ids)
00153 {
00154    // Drop all data and set-up the data structures to recive new data.
00155    // n_points   specifies the initial size of the arrays.
00156    // n_int_ids  specifies the number of integer ids per point.
00157 
00158    delete [] fP; fP = 0;
00159    fN = n_points;
00160    if (fN) {
00161       fP = new Float_t [3*fN];
00162       memset(fP, 0, 3*fN*sizeof(Float_t));
00163    }
00164    fLastPoint = -1;
00165    ClearIds();
00166    delete fIntIds; fIntIds = 0;
00167    fIntIdsPerPoint = n_int_ids;
00168    if (fIntIdsPerPoint > 0) fIntIds = new TArrayI(fIntIdsPerPoint*fN);
00169    ResetBBox();
00170 }
00171 
00172 //______________________________________________________________________________
00173 Int_t TEvePointSet::GrowFor(Int_t n_points)
00174 {
00175    // Resizes internal array to allow additional n_points to be stored.
00176    // Returns the old size which is also the location where one can
00177    // start storing new data.
00178    // The caller is *obliged* to fill the new point slots.
00179 
00180    Int_t old_size = Size();
00181    Int_t new_size = old_size + n_points;
00182    SetPoint(new_size - 1, 0, 0, 0);
00183    if (fIntIds)
00184       fIntIds->Set(fIntIdsPerPoint * new_size);
00185    return old_size;
00186 }
00187 
00188 /******************************************************************************/
00189 
00190 //______________________________________________________________________________
00191 inline void TEvePointSet::AssertIntIdsSize()
00192 {
00193    // Assert that size of IntId array is compatible with the size of
00194    // the point array.
00195 
00196    Int_t exp_size = GetN()*fIntIdsPerPoint;
00197    if (fIntIds->GetSize() < exp_size)
00198       fIntIds->Set(exp_size);
00199 }
00200 
00201 //______________________________________________________________________________
00202 Int_t* TEvePointSet::GetPointIntIds(Int_t p) const
00203 {
00204    // Return a pointer to integer ids of point with index p.
00205    // Existence of integer id array is checked, 0 is returned if it
00206    // does not exist.
00207    // Validity of p is *not* checked.
00208 
00209    if (fIntIds)
00210       return fIntIds->GetArray() + p*fIntIdsPerPoint;
00211    return 0;
00212 }
00213 
00214 //______________________________________________________________________________
00215 Int_t TEvePointSet::GetPointIntId(Int_t p, Int_t i) const
00216 {
00217    // Return i-th integer id of point with index p.
00218    // Existence of integer id array is checked, kMinInt is returned if
00219    // it does not exist.
00220    // Validity of p and i is *not* checked.
00221 
00222    if (fIntIds)
00223       return * (fIntIds->GetArray() + p*fIntIdsPerPoint + i);
00224    return kMinInt;
00225 }
00226 
00227 //______________________________________________________________________________
00228 void TEvePointSet::SetPointIntIds(Int_t* ids)
00229 {
00230    // Set integer ids for the last point that was registerd (most
00231    // probably via TPolyMarker3D::SetNextPoint(x,y,z)).
00232 
00233    SetPointIntIds(fLastPoint, ids);
00234 }
00235 
00236 //______________________________________________________________________________
00237 void TEvePointSet::SetPointIntIds(Int_t n, Int_t* ids)
00238 {
00239    // Set integer ids for point with index n.
00240 
00241    if (!fIntIds) return;
00242    AssertIntIdsSize();
00243    Int_t* x = fIntIds->GetArray() + n*fIntIdsPerPoint;
00244    for (Int_t i=0; i<fIntIdsPerPoint; ++i)
00245       x[i] = ids[i];
00246 }
00247 
00248 /******************************************************************************/
00249 
00250 //______________________________________________________________________________
00251 void TEvePointSet::SetMarkerStyle(Style_t mstyle)
00252 {
00253    // Set marker style, propagate to projecteds.
00254 
00255    static const TEveException eh("TEvePointSet::SetMarkerStyle ");
00256 
00257    std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
00258    while (pi != fProjectedList.end())
00259    {
00260       TEvePointSet* pt = dynamic_cast<TEvePointSet*>(*pi);
00261       if (pt)
00262       {
00263          pt->SetMarkerStyle(mstyle);
00264          pt->StampObjProps();
00265       }
00266       ++pi;
00267    }
00268    TAttMarker::SetMarkerStyle(mstyle);
00269 }
00270 
00271 //______________________________________________________________________________
00272 void TEvePointSet::SetMarkerSize(Size_t msize)
00273 {
00274    // Set marker size, propagate to projecteds.
00275 
00276    static const TEveException eh("TEvePointSet::SetMarkerSize ");
00277 
00278    std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
00279    while (pi != fProjectedList.end())
00280    {
00281       TEvePointSet* pt = dynamic_cast<TEvePointSet*>(*pi);
00282       if (pt)
00283       {
00284          pt->SetMarkerSize(msize);
00285          pt->StampObjProps();
00286       }
00287       ++pi;
00288    }
00289    TAttMarker::SetMarkerSize(msize);
00290 }
00291 
00292 /******************************************************************************/
00293 
00294 //______________________________________________________________________________
00295 void TEvePointSet::Paint(Option_t*)
00296 {
00297    // Paint point-set.
00298 
00299    PaintStandard(this);
00300 }
00301 
00302 /******************************************************************************/
00303 
00304 //______________________________________________________________________________
00305 void TEvePointSet::InitFill(Int_t subIdNum)
00306 {
00307    // Initialize point-set for new filling.
00308    // subIdNum gives the number of integer ids that can be assigned to
00309    // each point.
00310 
00311    if (subIdNum > 0) {
00312       fIntIdsPerPoint = subIdNum;
00313       if (!fIntIds)
00314          fIntIds = new TArrayI(fIntIdsPerPoint*GetN());
00315       else
00316          fIntIds->Set(fIntIdsPerPoint*GetN());
00317    } else {
00318       delete fIntIds; fIntIds = 0;
00319       fIntIdsPerPoint = 0;
00320    }
00321 }
00322 
00323 //______________________________________________________________________________
00324 void TEvePointSet::TakeAction(TEvePointSelector* sel)
00325 {
00326    // Called from TEvePointSelector when internal arrays of the tree-selector
00327    // are filled up and need to be processed.
00328    // Virtual from TEvePointSelectorConsumer.
00329 
00330    static const TEveException eh("TEvePointSet::TakeAction ");
00331 
00332    if(sel == 0)
00333       throw(eh + "selector is <null>.");
00334 
00335    Int_t    n = sel->GetNfill();
00336    Int_t  beg = GrowFor(n);
00337 
00338    // printf("TEvePointSet::TakeAction beg=%d n=%d size=%d nsubid=%d dim=%d\n",
00339    //        beg, n, Size(), sel->GetSubIdNum(), sel->GetDimension());
00340 
00341    Double_t *vx = sel->GetV1(), *vy = sel->GetV2(), *vz = sel->GetV3();
00342    Float_t  *p  = fP + 3*beg;
00343 
00344    switch(fSourceCS) {
00345       case kTVT_XYZ:
00346          while(n-- > 0) {
00347             p[0] = *vx; p[1] = *vy; p[2] = *vz;
00348             p += 3;
00349             ++vx; ++vy; ++vz;
00350          }
00351          break;
00352       case kTVT_RPhiZ:
00353          while(n-- > 0) {
00354             p[0] = *vx * TMath::Cos(*vy); p[1] = *vx * TMath::Sin(*vy); p[2] = *vz;
00355             p += 3;
00356             ++vx; ++vy; ++vz;
00357          }
00358          break;
00359       default:
00360          throw(eh + "unknown tree variable type.");
00361    }
00362 
00363    if (fIntIds) {
00364       Double_t** subarr = new Double_t* [fIntIdsPerPoint];
00365       for (Int_t i=0; i<fIntIdsPerPoint; ++i) {
00366          subarr[i] = sel->GetVal(sel->GetDimension() - fIntIdsPerPoint + i);
00367          if (subarr[i] == 0)
00368             throw(eh + "sub-id array not available.");
00369       }
00370       Int_t* ids = fIntIds->GetArray() + fIntIdsPerPoint*beg;
00371       n = sel->GetNfill();
00372       while (n-- > 0) {
00373          for (Int_t i=0; i<fIntIdsPerPoint; ++i) {
00374             ids[i] = TMath::Nint(*subarr[i]);
00375             ++subarr[i];
00376          }
00377          ids += fIntIdsPerPoint;
00378       }
00379       delete [] subarr;
00380    }
00381 }
00382 
00383 /******************************************************************************/
00384 
00385 //______________________________________________________________________________
00386 void TEvePointSet::CopyVizParams(const TEveElement* el)
00387 {
00388    // Copy visualization parameters from element el.
00389 
00390    const TEvePointSet* m = dynamic_cast<const TEvePointSet*>(el);
00391    if (m)
00392    {
00393       TAttMarker::operator=(*m);
00394       fOption = m->fOption;
00395    }
00396 
00397    TEveElement::CopyVizParams(el);
00398 }
00399 
00400 //______________________________________________________________________________
00401 void TEvePointSet::WriteVizParams(ostream& out, const TString& var)
00402 {
00403    // Write visualization parameters.
00404 
00405    TEveElement::WriteVizParams(out, var);
00406 
00407    TAttMarker::SaveMarkerAttributes(out, var);
00408 }
00409 
00410 //******************************************************************************
00411 
00412 //______________________________________________________________________________
00413 TClass* TEvePointSet::ProjectedClass(const TEveProjection*) const
00414 {
00415    // Virtual from TEveProjectable, returns TEvePointSetProjected class.
00416 
00417    return TEvePointSetProjected::Class();
00418 }
00419 
00420 //______________________________________________________________________________
00421 void TEvePointSet::PointSelected(Int_t id)
00422 {
00423    // Virtual method of base class TPointSet3D. The function call is
00424    // invoked with secondary selection in TPointSet3DGL.
00425 
00426    Emit("PointSelected(Int_t)", id);
00427    TPointSet3D::PointSelected(id);
00428 }
00429 
00430 
00431 //==============================================================================
00432 //==============================================================================
00433 // TEvePointSetArray
00434 //==============================================================================
00435 
00436 //______________________________________________________________________________
00437 //
00438 // An array of point-sets with each point-set playing a role of a bin
00439 // in a histogram. When a new point is added to a TEvePointSetArray,
00440 // an additional separating quantity needs to be specified: it
00441 // determines into which TEvePointSet (bin) the point will actually be
00442 // stored. Underflow and overflow bins are automatically created but
00443 // they are not drawn by default.
00444 //
00445 // By using the TEvePointSelector the points and the separating
00446 // quantities can be filled directly from a TTree holding the source
00447 // data.
00448 // Setting of per-point TRef's is not supported.
00449 //
00450 // After the filling, the range of separating variable can be
00451 // controlled with a slider to choose a sub-set of PointSets that are
00452 // actually shown.
00453 //
00454 
00455 ClassImp(TEvePointSetArray);
00456 
00457 //______________________________________________________________________________
00458 TEvePointSetArray::TEvePointSetArray(const char* name,
00459                                      const char* title) :
00460    TEveElement(fMarkerColor),
00461    TNamed(name, title),
00462 
00463    fBins(0), fDefPointSetCapacity(128), fNBins(0), fLastBin(-1),
00464    fMin(0), fCurMin(0), fMax(0), fCurMax(0),
00465    fBinWidth(0),
00466    fQuantName()
00467 {
00468    // Constructor.
00469 }
00470 
00471 //______________________________________________________________________________
00472 TEvePointSetArray::~TEvePointSetArray()
00473 {
00474    // Destructor: deletes the fBins array. Actual removal of
00475    // elements done by TEveElement.
00476 
00477    // printf("TEvePointSetArray::~TEvePointSetArray()\n");
00478    delete [] fBins; fBins = 0;
00479 }
00480 
00481 //______________________________________________________________________________
00482 void TEvePointSetArray::RemoveElementLocal(TEveElement* el)
00483 {
00484    // Virtual from TEveElement, provide bin management.
00485 
00486    for (Int_t i=0; i<fNBins; ++i) {
00487       if (fBins[i] == el) {
00488          fBins[i] = 0;
00489          break;
00490       }
00491    }
00492 }
00493 
00494 //______________________________________________________________________________
00495 void TEvePointSetArray::RemoveElementsLocal()
00496 {
00497    // Virtual from TEveElement, provide bin management.
00498 
00499    delete [] fBins; fBins = 0; fLastBin = -1;
00500 }
00501 
00502 /******************************************************************************/
00503 
00504 //______________________________________________________________________________
00505 void TEvePointSetArray::SetMarkerColor(Color_t tcolor)
00506 {
00507    // Set marker color, propagate to children.
00508 
00509    static const TEveException eh("TEvePointSetArray::SetMarkerColor ");
00510 
00511    for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
00512       TAttMarker* m = dynamic_cast<TAttMarker*>((*i)->GetObject(eh));
00513       if (m && m->GetMarkerColor() == fMarkerColor)
00514          m->SetMarkerColor(tcolor);
00515    }
00516    TAttMarker::SetMarkerColor(tcolor);
00517 }
00518 
00519 //______________________________________________________________________________
00520 void TEvePointSetArray::SetMarkerStyle(Style_t mstyle)
00521 {
00522    // Set marker style, propagate to children.
00523 
00524    static const TEveException eh("TEvePointSetArray::SetMarkerStyle ");
00525 
00526    for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
00527       TAttMarker* m = dynamic_cast<TAttMarker*>((*i)->GetObject(eh));
00528       if (m && m->GetMarkerStyle() == fMarkerStyle)
00529          m->SetMarkerStyle(mstyle);
00530    }
00531    TAttMarker::SetMarkerStyle(mstyle);
00532 }
00533 
00534 //______________________________________________________________________________
00535 void TEvePointSetArray::SetMarkerSize(Size_t msize)
00536 {
00537    // Set marker size, propagate to children.
00538 
00539    static const TEveException eh("TEvePointSetArray::SetMarkerSize ");
00540 
00541    for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
00542       TAttMarker* m = dynamic_cast<TAttMarker*>((*i)->GetObject(eh));
00543       if (m && m->GetMarkerSize() == fMarkerSize)
00544          m->SetMarkerSize(msize);
00545    }
00546    TAttMarker::SetMarkerSize(msize);
00547 }
00548 
00549 /******************************************************************************/
00550 
00551 //______________________________________________________________________________
00552 void TEvePointSetArray::TakeAction(TEvePointSelector* sel)
00553 {
00554    // Called from TEvePointSelector when internal arrays of the tree-selector
00555    // are filled up and need to be processed.
00556    // Virtual from TEvePointSelectorConsumer.
00557 
00558    static const TEveException eh("TEvePointSetArray::TakeAction ");
00559 
00560    if (sel == 0)
00561       throw eh + "selector is <null>.";
00562 
00563    Int_t n = sel->GetNfill();
00564 
00565    // printf("TEvePointSetArray::TakeAction n=%d\n", n);
00566 
00567    Double_t *vx = sel->GetV1(), *vy = sel->GetV2(), *vz = sel->GetV3();
00568    Double_t *qq = sel->GetV4();
00569 
00570    if (qq == 0)
00571       throw eh + "requires 4-d varexp.";
00572 
00573    switch (fSourceCS)
00574    {
00575       case kTVT_XYZ:
00576       {
00577          while (n-- > 0)
00578          {
00579             Fill(*vx, *vy, *vz, *qq);
00580             ++vx; ++vy; ++vz; ++qq;
00581          }
00582          break;
00583       }
00584       case kTVT_RPhiZ:
00585       {
00586          while (n-- > 0)
00587          {
00588             Fill(*vx * TMath::Cos(*vy), *vx * TMath::Sin(*vy), *vz, *qq);
00589             ++vx; ++vy; ++vz; ++qq;
00590          }
00591          break;
00592       }
00593       default:
00594       {
00595          throw eh + "unknown tree variable type.";
00596       }
00597    }
00598 }
00599 
00600 /******************************************************************************/
00601 
00602 //______________________________________________________________________________
00603 Int_t TEvePointSetArray::Size(Bool_t under, Bool_t over) const
00604 {
00605    // Get the total number of filled points.
00606    // 'under' and 'over' flags specify if under/overflow channels
00607    // should be added to the sum.
00608 
00609    Int_t size = 0;
00610    const Int_t min = under ? 0 : 1;
00611    const Int_t max = over  ? fNBins : fNBins - 1;
00612    for (Int_t i = min; i < max; ++i)
00613    {
00614       if (fBins[i])
00615          size += fBins[i]->Size();
00616    }
00617    return size;
00618 }
00619 
00620 //______________________________________________________________________________
00621 void TEvePointSetArray::InitBins(const char* quant_name,
00622                                  Int_t nbins, Double_t min, Double_t max)
00623 {
00624    // Initialize internal point-sets with given binning parameters.
00625    // The actual number of bins is nbins+2, bin 0 corresponding to
00626    // underflow and bin nbin+1 to owerflow pointset.
00627 
00628    static const TEveException eh("TEvePointSetArray::InitBins ");
00629 
00630    if (nbins < 1) throw eh + "nbins < 1.";
00631    if (min > max) throw eh + "min > max.";
00632 
00633    RemoveElements();
00634 
00635    fQuantName = quant_name;
00636    fNBins     = nbins + 2; // under/overflow
00637    fLastBin   = -1;
00638    fMin = fCurMin = min;
00639    fMax = fCurMax = max;
00640    fBinWidth  = (fMax - fMin)/(fNBins - 2);
00641 
00642    fBins = new TEvePointSet* [fNBins];
00643 
00644    for (Int_t i = 0; i < fNBins; ++i)
00645    {
00646       fBins[i] = new TEvePointSet
00647          (Form("Slice %d [%4.3lf, %4.3lf]", i, fMin + (i-1)*fBinWidth, fMin + i*fBinWidth),
00648           fDefPointSetCapacity);
00649       fBins[i]->SetMarkerColor(fMarkerColor);
00650       fBins[i]->SetMarkerStyle(fMarkerStyle);
00651       fBins[i]->SetMarkerSize(fMarkerSize);
00652       AddElement(fBins[i]);
00653    }
00654 
00655    fBins[0]->SetName("Underflow");
00656    fBins[0]->SetRnrSelf(kFALSE);
00657 
00658    fBins[fNBins-1]->SetName("Overflow");
00659    fBins[fNBins-1]->SetRnrSelf(kFALSE);
00660 }
00661 
00662 //______________________________________________________________________________
00663 Bool_t TEvePointSetArray::Fill(Double_t x, Double_t y, Double_t z, Double_t quant)
00664 {
00665    // Add a new point. Appropriate point-set will be chosen based on
00666    // the value of the separating quantity 'quant'.
00667    // If the selected bin does not have an associated TEvePointSet
00668    // the point is discarded and false is returned.
00669 
00670    fLastBin = TMath::FloorNint((quant - fMin)/fBinWidth) + 1;
00671 
00672    if (fLastBin < 0)
00673    {
00674       fLastBin = 0;
00675    }
00676    else if (fLastBin > fNBins - 1)
00677    {
00678       fLastBin = fNBins - 1;
00679    }
00680 
00681    if (fBins[fLastBin] != 0)
00682    {
00683       fBins[fLastBin]->SetNextPoint(x, y, z);
00684       return kTRUE;
00685    }
00686    else
00687    {
00688       return kFALSE;
00689    }
00690 }
00691 
00692 //______________________________________________________________________________
00693 void TEvePointSetArray::SetPointId(TObject* id)
00694 {
00695    // Set external object id of the last added point.
00696 
00697    if (fLastBin >= 0)
00698       fBins[fLastBin]->SetPointId(id);
00699 }
00700 
00701 //______________________________________________________________________________
00702 void TEvePointSetArray::CloseBins()
00703 {
00704    // Call this after all the points have been filled.
00705    // At this point we can calculate bounding-boxes of individual
00706    // point-sets.
00707 
00708    for (Int_t i=0; i<fNBins; ++i)
00709    {
00710       if (fBins[i] != 0)
00711       {
00712          fBins[i]->SetTitle(Form("N=%d", fBins[i]->Size()));
00713          fBins[i]->ComputeBBox();
00714       }
00715    }
00716    fLastBin = -1;
00717 }
00718 
00719 /******************************************************************************/
00720 
00721 //______________________________________________________________________________
00722 void TEvePointSetArray::SetOwnIds(Bool_t o)
00723 {
00724    // Propagate id-object ownership to children.
00725 
00726    for (Int_t i=0; i<fNBins; ++i)
00727    {
00728       if (fBins[i] != 0)
00729          fBins[i]->SetOwnIds(o);
00730    }
00731 }
00732 
00733 /******************************************************************************/
00734 
00735 //______________________________________________________________________________
00736 void TEvePointSetArray::SetRange(Double_t min, Double_t max)
00737 {
00738    // Set active range of the separating quantity.
00739    // Appropriate point-sets are tagged for rendering.
00740    // Over/underflow point-sets are left as they were.
00741 
00742    using namespace TMath;
00743 
00744    fCurMin = min; fCurMax = max;
00745    Int_t  low_b = Max(0,        FloorNint((min-fMin)/fBinWidth)) + 1;
00746    Int_t high_b = Min(fNBins-2, CeilNint ((max-fMin)/fBinWidth));
00747 
00748    for (Int_t i = 1; i < fNBins - 1; ++i)
00749    {
00750       if (fBins[i] != 0)
00751          fBins[i]->SetRnrSelf(i>=low_b && i<=high_b);
00752    }
00753 }
00754 
00755 
00756 //==============================================================================
00757 //==============================================================================
00758 // TEvePointSetProjected
00759 //==============================================================================
00760 
00761 //______________________________________________________________________________
00762 //
00763 // Projected copy of a TEvePointSet.
00764 
00765 ClassImp(TEvePointSetProjected);
00766 
00767 //______________________________________________________________________________
00768 TEvePointSetProjected::TEvePointSetProjected() :
00769    TEvePointSet  (),
00770    TEveProjected ()
00771 {
00772    // Default contructor.
00773 }
00774 
00775 //______________________________________________________________________________
00776 void TEvePointSetProjected::SetProjection(TEveProjectionManager* proj,
00777                                           TEveProjectable* model)
00778 {
00779    // Set projection manager and projection model.
00780    // Virtual from TEveProjected.
00781 
00782    TEveProjected::SetProjection(proj, model);
00783    CopyVizParams(dynamic_cast<TEveElement*>(model));
00784 }
00785 
00786 //______________________________________________________________________________
00787 void TEvePointSetProjected::SetDepthLocal(Float_t d)
00788 {
00789    // Set depth (z-coordinate) of the projected points.
00790 
00791    SetDepthCommon(d, this, fBBox);
00792 
00793    Int_t    n = Size();
00794    Float_t *p = GetP() + 2;
00795    for (Int_t i = 0; i < n; ++i, p+=3)
00796       *p = fDepth;
00797 }
00798 
00799 //______________________________________________________________________________
00800 void TEvePointSetProjected::UpdateProjection()
00801 {
00802    // Re-apply the projection.
00803    // Virtual from TEveProjected.
00804 
00805    TEveProjection &proj = * fManager->GetProjection();
00806    TEvePointSet   &ps   = * dynamic_cast<TEvePointSet*>(fProjectable);
00807    TEveTrans      *tr   =   ps.PtrMainTrans(kFALSE);
00808 
00809    Int_t n = ps.Size();
00810    Reset(n);
00811    fLastPoint = n - 1;
00812    Float_t *o = ps.GetP(), *p = GetP();
00813    for (Int_t i = 0; i < n; ++i, o+=3, p+=3)
00814    {
00815       proj.ProjectPointfv(tr, o, p, fDepth);
00816    }
00817 }
00818 
00819 //______________________________________________________________________________
00820 void TEvePointSetProjected::PointSelected(Int_t id)
00821 {
00822    // Virtual method of base class TPointSet3D.
00823    // Forward to projectable.
00824 
00825    TEvePointSet *ps = dynamic_cast<TEvePointSet*>(fProjectable);
00826    ps->PointSelected(id);
00827 }

Generated on Tue Jul 5 14:16:13 2011 for ROOT_528-00b_version by  doxygen 1.5.1