Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TEvePointSet.cxx
Go to the documentation of this file.
1 // @(#)root/eve:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, 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 "TEvePointSet.h"
13 
14 #include "TEveManager.h"
15 #include "TEveProjectionManager.h"
16 #include "TEveTrans.h"
17 
18 #include "TTree.h"
19 #include "TTreePlayer.h"
20 #include "TF3.h"
21 
22 #include "TColor.h"
23 
24 /** \class TEvePointSet
25 \ingroup TEve
26 TEvePointSet is a render-element holding a collection of 3D points with
27 optional per-point TRef and an arbitrary number of integer ids (to
28 be used for signal, volume-id, track-id, etc).
29 
30 3D point representation is implemented in base-class TPolyMarker3D.
31 Per-point TRef is implemented in base-class TPointSet3D.
32 
33 By using the TEvePointSelector the points and integer ids can be
34 filled directly from a TTree holding the source data.
35 Setting of per-point TRef's is not supported.
36 
37 TEvePointSet is a TEveProjectable: it can be projected by using the
38 TEveProjectionManager class.
39 */
40 
41 ClassImp(TEvePointSet);
42 
43 ////////////////////////////////////////////////////////////////////////////////
44 /// Constructor.
45 
46 TEvePointSet::TEvePointSet(Int_t n_points, ETreeVarType_e tv_type) :
47  TEveElement(),
48  TPointSet3D(n_points),
49  TEvePointSelectorConsumer(tv_type),
50  TEveProjectable(),
51  TQObject(),
52 
53  fTitle (),
54  fIntIds (0),
55  fIntIdsPerPoint (0)
56 {
57  fMarkerStyle = 20;
58  SetMainColorPtr(&fMarkerColor);
59 
60  // Override from TEveElement.
61  fPickable = kTRUE;
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// Constructor.
66 
67 TEvePointSet::TEvePointSet(const char* name, Int_t n_points, ETreeVarType_e tv_type) :
68  TEveElement(),
69  TPointSet3D(n_points),
70  TEvePointSelectorConsumer(tv_type),
71  TEveProjectable(),
72  TQObject(),
73 
74  fTitle (),
75  fIntIds (0),
76  fIntIdsPerPoint (0)
77 {
78  fMarkerStyle = 20;
79  SetName(name);
80  SetMainColorPtr(&fMarkerColor);
81 
82  // Override from TEveElement.
83  fPickable = kTRUE;
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////
87 /// Copy constructor.
88 
89 TEvePointSet::TEvePointSet(const TEvePointSet& e) :
90  TEveElement(e),
91  TPointSet3D(e),
92  TEvePointSelectorConsumer(e),
93  TEveProjectable(),
94  TQObject(),
95 
96  fTitle (e.fTitle),
97  fIntIds (e.fIntIds ? new TArrayI(*e.fIntIds) : 0),
98  fIntIdsPerPoint (e.fIntIdsPerPoint)
99 {
100 }
101 
102 ////////////////////////////////////////////////////////////////////////////////
103 /// Destructor.
104 
105 TEvePointSet::~TEvePointSet()
106 {
107  delete fIntIds;
108 }
109 
110 ////////////////////////////////////////////////////////////////////////////////
111 /// Clone points and all point-related information from point-set 'e'.
112 
113 void TEvePointSet::ClonePoints(const TEvePointSet& e)
114 {
115  // TPolyMarker3D
116  delete [] fP;
117  fN = e.fN;
118  if (fN > 0)
119  {
120  const Int_t nn = 3 * e.fN;
121  fP = new Float_t [nn];
122  for (Int_t i = 0; i < nn; i++) fP[i] = e.fP[i];
123  } else {
124  fP = 0;
125  }
126  fLastPoint = e.fLastPoint;
127 
128  // TPointSet3D
129  CopyIds(e);
130 
131  // TEvePointSet
132  delete fIntIds;
133  fIntIds = e.fIntIds ? new TArrayI(*e.fIntIds) : 0;
134  fIntIdsPerPoint = e.fIntIdsPerPoint;
135 }
136 
137 ////////////////////////////////////////////////////////////////////////////////
138 /// Return pointset icon.
139 
140 const TGPicture* TEvePointSet::GetListTreeIcon(Bool_t)
141 {
142  return TEveElement::fgListTreeIcons[3];
143 }
144 
145 ////////////////////////////////////////////////////////////////////////////////
146 /// Drop all data and set-up the data structures to recive new data.
147 /// n_points specifies the initial size of the arrays.
148 /// n_int_ids specifies the number of integer ids per point.
149 
150 void TEvePointSet::Reset(Int_t n_points, Int_t n_int_ids)
151 {
152  delete [] fP; fP = 0;
153  fN = n_points;
154  if (fN) {
155  fP = new Float_t [3*fN];
156  memset(fP, 0, 3*fN*sizeof(Float_t));
157  }
158  fLastPoint = -1;
159  ClearIds();
160  delete fIntIds; fIntIds = 0;
161  fIntIdsPerPoint = n_int_ids;
162  if (fIntIdsPerPoint > 0) fIntIds = new TArrayI(fIntIdsPerPoint*fN);
163  ResetBBox();
164 }
165 
166 ////////////////////////////////////////////////////////////////////////////////
167 /// Resizes internal array to allow additional n_points to be stored.
168 /// Returns the old size which is also the location where one can
169 /// start storing new data.
170 /// The caller is *obliged* to fill the new point slots.
171 
172 Int_t TEvePointSet::GrowFor(Int_t n_points)
173 {
174  Int_t old_size = Size();
175  Int_t new_size = old_size + n_points;
176  SetPoint(new_size - 1, 0, 0, 0);
177  if (fIntIds)
178  fIntIds->Set(fIntIdsPerPoint * new_size);
179  return old_size;
180 }
181 
182 ////////////////////////////////////////////////////////////////////////////////
183 /// Assert that size of IntId array is compatible with the size of
184 /// the point array.
185 
186 inline void TEvePointSet::AssertIntIdsSize()
187 {
188  Int_t exp_size = GetN()*fIntIdsPerPoint;
189  if (fIntIds->GetSize() < exp_size)
190  fIntIds->Set(exp_size);
191 }
192 
193 ////////////////////////////////////////////////////////////////////////////////
194 /// Return a pointer to integer ids of point with index p.
195 /// Existence of integer id array is checked, 0 is returned if it
196 /// does not exist.
197 /// Validity of p is *not* checked.
198 
199 Int_t* TEvePointSet::GetPointIntIds(Int_t p) const
200 {
201  if (fIntIds)
202  return fIntIds->GetArray() + p*fIntIdsPerPoint;
203  return 0;
204 }
205 
206 ////////////////////////////////////////////////////////////////////////////////
207 /// Return i-th integer id of point with index p.
208 /// Existence of integer id array is checked, kMinInt is returned if
209 /// it does not exist.
210 /// Validity of p and i is *not* checked.
211 
212 Int_t TEvePointSet::GetPointIntId(Int_t p, Int_t i) const
213 {
214  if (fIntIds)
215  return * (fIntIds->GetArray() + p*fIntIdsPerPoint + i);
216  return kMinInt;
217 }
218 
219 ////////////////////////////////////////////////////////////////////////////////
220 /// Set integer ids for the last point that was registered (most
221 /// probably via TPolyMarker3D::SetNextPoint(x,y,z)).
222 
223 void TEvePointSet::SetPointIntIds(Int_t* ids)
224 {
225  SetPointIntIds(fLastPoint, ids);
226 }
227 
228 ////////////////////////////////////////////////////////////////////////////////
229 /// Set integer ids for point with index n.
230 
231 void TEvePointSet::SetPointIntIds(Int_t n, Int_t* ids)
232 {
233  if (!fIntIds) return;
234  AssertIntIdsSize();
235  Int_t* x = fIntIds->GetArray() + n*fIntIdsPerPoint;
236  for (Int_t i=0; i<fIntIdsPerPoint; ++i)
237  x[i] = ids[i];
238 }
239 
240 ////////////////////////////////////////////////////////////////////////////////
241 /// Set marker style, propagate to projecteds.
242 
243 void TEvePointSet::SetMarkerStyle(Style_t mstyle)
244 {
245  static const TEveException eh("TEvePointSet::SetMarkerStyle ");
246 
247  std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
248  while (pi != fProjectedList.end())
249  {
250  TEvePointSet* pt = dynamic_cast<TEvePointSet*>(*pi);
251  if (pt)
252  {
253  pt->SetMarkerStyle(mstyle);
254  pt->StampObjProps();
255  }
256  ++pi;
257  }
258  TAttMarker::SetMarkerStyle(mstyle);
259 }
260 
261 ////////////////////////////////////////////////////////////////////////////////
262 /// Set marker size, propagate to projecteds.
263 
264 void TEvePointSet::SetMarkerSize(Size_t msize)
265 {
266  static const TEveException eh("TEvePointSet::SetMarkerSize ");
267 
268  std::list<TEveProjected*>::iterator pi = fProjectedList.begin();
269  while (pi != fProjectedList.end())
270  {
271  TEvePointSet* pt = dynamic_cast<TEvePointSet*>(*pi);
272  if (pt)
273  {
274  pt->SetMarkerSize(msize);
275  pt->StampObjProps();
276  }
277  ++pi;
278  }
279  TAttMarker::SetMarkerSize(msize);
280 }
281 
282 ////////////////////////////////////////////////////////////////////////////////
283 /// Paint point-set.
284 
285 void TEvePointSet::Paint(Option_t*)
286 {
287  PaintStandard(this);
288 }
289 
290 ////////////////////////////////////////////////////////////////////////////////
291 /// Initialize point-set for new filling.
292 /// subIdNum gives the number of integer ids that can be assigned to
293 /// each point.
294 
295 void TEvePointSet::InitFill(Int_t subIdNum)
296 {
297  if (subIdNum > 0) {
298  fIntIdsPerPoint = subIdNum;
299  if (!fIntIds)
300  fIntIds = new TArrayI(fIntIdsPerPoint*GetN());
301  else
302  fIntIds->Set(fIntIdsPerPoint*GetN());
303  } else {
304  delete fIntIds; fIntIds = 0;
305  fIntIdsPerPoint = 0;
306  }
307 }
308 
309 ////////////////////////////////////////////////////////////////////////////////
310 /// Called from TEvePointSelector when internal arrays of the tree-selector
311 /// are filled up and need to be processed.
312 /// Virtual from TEvePointSelectorConsumer.
313 
314 void TEvePointSet::TakeAction(TEvePointSelector* sel)
315 {
316  static const TEveException eh("TEvePointSet::TakeAction ");
317 
318  if(sel == 0)
319  throw(eh + "selector is <null>.");
320 
321  Int_t n = sel->GetNfill();
322  Int_t beg = GrowFor(n);
323 
324  // printf("TEvePointSet::TakeAction beg=%d n=%d size=%d nsubid=%d dim=%d\n",
325  // beg, n, Size(), sel->GetSubIdNum(), sel->GetDimension());
326 
327  Double_t *vx = sel->GetV1(), *vy = sel->GetV2(), *vz = sel->GetV3();
328  Float_t *p = fP + 3*beg;
329 
330  switch(fSourceCS) {
331  case kTVT_XYZ:
332  while(n-- > 0) {
333  p[0] = *vx; p[1] = *vy; p[2] = *vz;
334  p += 3;
335  ++vx; ++vy; ++vz;
336  }
337  break;
338  case kTVT_RPhiZ:
339  while(n-- > 0) {
340  p[0] = *vx * TMath::Cos(*vy); p[1] = *vx * TMath::Sin(*vy); p[2] = *vz;
341  p += 3;
342  ++vx; ++vy; ++vz;
343  }
344  break;
345  default:
346  throw(eh + "unknown tree variable type.");
347  }
348 
349  if (fIntIds) {
350  Double_t** subarr = new Double_t* [fIntIdsPerPoint];
351  for (Int_t i=0; i<fIntIdsPerPoint; ++i) {
352  subarr[i] = sel->GetVal(sel->GetDimension() - fIntIdsPerPoint + i);
353  if (subarr[i] == 0) {
354  delete[] subarr;
355  throw(eh + "sub-id array not available.");
356  }
357  }
358  Int_t* ids = fIntIds->GetArray() + fIntIdsPerPoint*beg;
359  n = sel->GetNfill();
360  while (n-- > 0) {
361  for (Int_t i=0; i<fIntIdsPerPoint; ++i) {
362  ids[i] = TMath::Nint(*subarr[i]);
363  ++subarr[i];
364  }
365  ids += fIntIdsPerPoint;
366  }
367  delete [] subarr;
368  }
369 }
370 
371 ////////////////////////////////////////////////////////////////////////////////
372 /// Copy visualization parameters from element el.
373 
374 void TEvePointSet::CopyVizParams(const TEveElement* el)
375 {
376  const TEvePointSet* m = dynamic_cast<const TEvePointSet*>(el);
377  if (m)
378  {
379  TAttMarker::operator=(*m);
380  fOption = m->fOption;
381  }
382 
383  TEveElement::CopyVizParams(el);
384 }
385 
386 ////////////////////////////////////////////////////////////////////////////////
387 /// Write visualization parameters.
388 
389 void TEvePointSet::WriteVizParams(std::ostream& out, const TString& var)
390 {
391  TEveElement::WriteVizParams(out, var);
392 
393  TAttMarker::SaveMarkerAttributes(out, var);
394 }
395 
396 ////////////////////////////////////////////////////////////////////////////////
397 /// Virtual from TEveProjectable, returns TEvePointSetProjected class.
398 
399 TClass* TEvePointSet::ProjectedClass(const TEveProjection*) const
400 {
401  return TEvePointSetProjected::Class();
402 }
403 
404 ////////////////////////////////////////////////////////////////////////////////
405 /// Virtual method of base class TPointSet3D. The function call is
406 /// invoked with secondary selection in TPointSet3DGL.
407 
408 void TEvePointSet::PointSelected(Int_t id)
409 {
410  Emit("PointSelected(Int_t)", id);
411  TPointSet3D::PointSelected(id);
412 }
413 
414 //==============================================================================
415 /** \class TEvePointSetArray
416 \ingroup TEve
417 An array of point-sets with each point-set playing a role of a bin
418 in a histogram. When a new point is added to a TEvePointSetArray,
419 an additional separating quantity needs to be specified: it
420 determines into which TEvePointSet (bin) the point will actually be
421 stored. Underflow and overflow bins are automatically created but
422 they are not drawn by default.
423 
424 By using the TEvePointSelector the points and the separating
425 quantities can be filled directly from a TTree holding the source
426 data.
427 Setting of per-point TRef's is not supported.
428 
429 After the filling, the range of separating variable can be
430 controlled with a slider to choose a sub-set of PointSets that are
431 actually shown.
432 */
433 
434 ClassImp(TEvePointSetArray);
435 
436 ////////////////////////////////////////////////////////////////////////////////
437 /// Constructor.
438 
439 TEvePointSetArray::TEvePointSetArray(const char* name,
440  const char* title) :
441  TEveElement(),
442  TNamed(name, title),
443 
444  fBins(0), fDefPointSetCapacity(128), fNBins(0), fLastBin(-1),
445  fMin(0), fCurMin(0), fMax(0), fCurMax(0),
446  fBinWidth(0),
447  fQuantName()
448 {
449 
450  SetMainColorPtr(&fMarkerColor);
451 }
452 
453 ////////////////////////////////////////////////////////////////////////////////
454 /// Destructor: deletes the fBins array. Actual removal of
455 /// elements done by TEveElement.
456 
457 TEvePointSetArray::~TEvePointSetArray()
458 {
459  // printf("TEvePointSetArray::~TEvePointSetArray()\n");
460  delete [] fBins; fBins = 0;
461 }
462 
463 ////////////////////////////////////////////////////////////////////////////////
464 /// Virtual from TEveElement, provide bin management.
465 
466 void TEvePointSetArray::RemoveElementLocal(TEveElement* el)
467 {
468  for (Int_t i=0; i<fNBins; ++i) {
469  if (fBins[i] == el) {
470  fBins[i] = 0;
471  break;
472  }
473  }
474 }
475 
476 ////////////////////////////////////////////////////////////////////////////////
477 /// Virtual from TEveElement, provide bin management.
478 
479 void TEvePointSetArray::RemoveElementsLocal()
480 {
481  delete [] fBins; fBins = 0; fLastBin = -1;
482 }
483 
484 ////////////////////////////////////////////////////////////////////////////////
485 /// Set marker color, propagate to children.
486 
487 void TEvePointSetArray::SetMarkerColor(Color_t tcolor)
488 {
489  static const TEveException eh("TEvePointSetArray::SetMarkerColor ");
490 
491  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
492  TAttMarker* m = dynamic_cast<TAttMarker*>((*i)->GetObject(eh));
493  if (m && m->GetMarkerColor() == fMarkerColor)
494  m->SetMarkerColor(tcolor);
495  }
496  TAttMarker::SetMarkerColor(tcolor);
497 }
498 
499 ////////////////////////////////////////////////////////////////////////////////
500 /// Set marker style, propagate to children.
501 
502 void TEvePointSetArray::SetMarkerStyle(Style_t mstyle)
503 {
504  static const TEveException eh("TEvePointSetArray::SetMarkerStyle ");
505 
506  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
507  TAttMarker* m = dynamic_cast<TAttMarker*>((*i)->GetObject(eh));
508  if (m && m->GetMarkerStyle() == fMarkerStyle)
509  m->SetMarkerStyle(mstyle);
510  }
511  TAttMarker::SetMarkerStyle(mstyle);
512 }
513 
514 ////////////////////////////////////////////////////////////////////////////////
515 /// Set marker size, propagate to children.
516 
517 void TEvePointSetArray::SetMarkerSize(Size_t msize)
518 {
519  static const TEveException eh("TEvePointSetArray::SetMarkerSize ");
520 
521  for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
522  TAttMarker* m = dynamic_cast<TAttMarker*>((*i)->GetObject(eh));
523  if (m && m->GetMarkerSize() == fMarkerSize)
524  m->SetMarkerSize(msize);
525  }
526  TAttMarker::SetMarkerSize(msize);
527 }
528 
529 ////////////////////////////////////////////////////////////////////////////////
530 /// Called from TEvePointSelector when internal arrays of the tree-selector
531 /// are filled up and need to be processed.
532 /// Virtual from TEvePointSelectorConsumer.
533 
534 void TEvePointSetArray::TakeAction(TEvePointSelector* sel)
535 {
536  static const TEveException eh("TEvePointSetArray::TakeAction ");
537 
538  if (sel == 0)
539  throw eh + "selector is <null>.";
540 
541  Int_t n = sel->GetNfill();
542 
543  // printf("TEvePointSetArray::TakeAction n=%d\n", n);
544 
545  Double_t *vx = sel->GetV1(), *vy = sel->GetV2(), *vz = sel->GetV3();
546  Double_t *qq = sel->GetV4();
547 
548  if (qq == 0)
549  throw eh + "requires 4-d varexp.";
550 
551  switch (fSourceCS)
552  {
553  case kTVT_XYZ:
554  {
555  while (n-- > 0)
556  {
557  Fill(*vx, *vy, *vz, *qq);
558  ++vx; ++vy; ++vz; ++qq;
559  }
560  break;
561  }
562  case kTVT_RPhiZ:
563  {
564  while (n-- > 0)
565  {
566  Fill(*vx * TMath::Cos(*vy), *vx * TMath::Sin(*vy), *vz, *qq);
567  ++vx; ++vy; ++vz; ++qq;
568  }
569  break;
570  }
571  default:
572  {
573  throw eh + "unknown tree variable type.";
574  }
575  }
576 }
577 
578 ////////////////////////////////////////////////////////////////////////////////
579 /// Get the total number of filled points.
580 /// 'under' and 'over' flags specify if under/overflow channels
581 /// should be added to the sum.
582 
583 Int_t TEvePointSetArray::Size(Bool_t under, Bool_t over) const
584 {
585  Int_t size = 0;
586  const Int_t min = under ? 0 : 1;
587  const Int_t max = over ? fNBins : fNBins - 1;
588  for (Int_t i = min; i < max; ++i)
589  {
590  if (fBins[i])
591  size += fBins[i]->Size();
592  }
593  return size;
594 }
595 
596 ////////////////////////////////////////////////////////////////////////////////
597 /// Initialize internal point-sets with given binning parameters.
598 /// The actual number of bins is nbins+2, bin 0 corresponding to
599 /// underflow and bin nbin+1 to owerflow pointset.
600 
601 void TEvePointSetArray::InitBins(const char* quant_name,
602  Int_t nbins, Double_t min, Double_t max)
603 {
604  static const TEveException eh("TEvePointSetArray::InitBins ");
605 
606  if (nbins < 1) throw eh + "nbins < 1.";
607  if (min > max) throw eh + "min > max.";
608 
609  RemoveElements();
610 
611  fQuantName = quant_name;
612  fNBins = nbins + 2; // under/overflow
613  fLastBin = -1;
614  fMin = fCurMin = min;
615  fMax = fCurMax = max;
616  fBinWidth = (fMax - fMin)/(fNBins - 2);
617 
618  fBins = new TEvePointSet* [fNBins];
619 
620  for (Int_t i = 0; i < fNBins; ++i)
621  {
622  fBins[i] = new TEvePointSet
623  (Form("Slice %d [%4.3lf, %4.3lf]", i, fMin + (i-1)*fBinWidth, fMin + i*fBinWidth),
624  fDefPointSetCapacity);
625  fBins[i]->SetMarkerColor(fMarkerColor);
626  fBins[i]->SetMarkerStyle(fMarkerStyle);
627  fBins[i]->SetMarkerSize(fMarkerSize);
628  AddElement(fBins[i]);
629  }
630 
631  fBins[0]->SetName("Underflow");
632  fBins[0]->SetRnrSelf(kFALSE);
633 
634  fBins[fNBins-1]->SetName("Overflow");
635  fBins[fNBins-1]->SetRnrSelf(kFALSE);
636 }
637 
638 ////////////////////////////////////////////////////////////////////////////////
639 /// Add a new point. Appropriate point-set will be chosen based on
640 /// the value of the separating quantity 'quant'.
641 /// If the selected bin does not have an associated TEvePointSet
642 /// the point is discarded and false is returned.
643 
644 Bool_t TEvePointSetArray::Fill(Double_t x, Double_t y, Double_t z, Double_t quant)
645 {
646  fLastBin = TMath::FloorNint((quant - fMin)/fBinWidth) + 1;
647 
648  if (fLastBin < 0)
649  {
650  fLastBin = 0;
651  }
652  else if (fLastBin > fNBins - 1)
653  {
654  fLastBin = fNBins - 1;
655  }
656 
657  if (fBins[fLastBin] != 0)
658  {
659  fBins[fLastBin]->SetNextPoint(x, y, z);
660  return kTRUE;
661  }
662  else
663  {
664  return kFALSE;
665  }
666 }
667 
668 ////////////////////////////////////////////////////////////////////////////////
669 /// Set external object id of the last added point.
670 
671 void TEvePointSetArray::SetPointId(TObject* id)
672 {
673  if (fLastBin >= 0)
674  fBins[fLastBin]->SetPointId(id);
675 }
676 
677 ////////////////////////////////////////////////////////////////////////////////
678 /// Call this after all the points have been filled.
679 /// At this point we can calculate bounding-boxes of individual
680 /// point-sets.
681 
682 void TEvePointSetArray::CloseBins()
683 {
684  for (Int_t i=0; i<fNBins; ++i)
685  {
686  if (fBins[i] != 0)
687  {
688  fBins[i]->SetTitle(Form("N=%d", fBins[i]->Size()));
689  fBins[i]->ComputeBBox();
690  }
691  }
692  fLastBin = -1;
693 }
694 
695 ////////////////////////////////////////////////////////////////////////////////
696 /// Propagate id-object ownership to children.
697 
698 void TEvePointSetArray::SetOwnIds(Bool_t o)
699 {
700  for (Int_t i=0; i<fNBins; ++i)
701  {
702  if (fBins[i] != 0)
703  fBins[i]->SetOwnIds(o);
704  }
705 }
706 
707 ////////////////////////////////////////////////////////////////////////////////
708 /// Set active range of the separating quantity.
709 /// Appropriate point-sets are tagged for rendering.
710 /// Over/underflow point-sets are left as they were.
711 
712 void TEvePointSetArray::SetRange(Double_t min, Double_t max)
713 {
714  using namespace TMath;
715 
716  fCurMin = min; fCurMax = max;
717  Int_t low_b = Max(0, FloorNint((min-fMin)/fBinWidth)) + 1;
718  Int_t high_b = Min(fNBins-2, CeilNint ((max-fMin)/fBinWidth));
719 
720  for (Int_t i = 1; i < fNBins - 1; ++i)
721  {
722  if (fBins[i] != 0)
723  fBins[i]->SetRnrSelf(i>=low_b && i<=high_b);
724  }
725 }
726 
727 /** \class TEvePointSetProjected
728 \ingroup TEve
729 Projected copy of a TEvePointSet.
730 */
731 ClassImp(TEvePointSetProjected);
732 
733 ////////////////////////////////////////////////////////////////////////////////
734 /// Default contructor.
735 
736 TEvePointSetProjected::TEvePointSetProjected() :
737  TEvePointSet (),
738  TEveProjected ()
739 {
740 }
741 
742 ////////////////////////////////////////////////////////////////////////////////
743 /// Set projection manager and projection model.
744 /// Virtual from TEveProjected.
745 
746 void TEvePointSetProjected::SetProjection(TEveProjectionManager* proj,
747  TEveProjectable* model)
748 {
749  TEveProjected::SetProjection(proj, model);
750  CopyVizParams(dynamic_cast<TEveElement*>(model));
751 }
752 
753 ////////////////////////////////////////////////////////////////////////////////
754 /// Set depth (z-coordinate) of the projected points.
755 
756 void TEvePointSetProjected::SetDepthLocal(Float_t d)
757 {
758  SetDepthCommon(d, this, fBBox);
759 
760  Int_t n = Size();
761  Float_t *p = GetP() + 2;
762  for (Int_t i = 0; i < n; ++i, p+=3)
763  *p = fDepth;
764 }
765 
766 ////////////////////////////////////////////////////////////////////////////////
767 /// Re-apply the projection.
768 /// Virtual from TEveProjected.
769 
770 void TEvePointSetProjected::UpdateProjection()
771 {
772  TEveProjection &proj = * fManager->GetProjection();
773  TEvePointSet &ps = * dynamic_cast<TEvePointSet*>(fProjectable);
774  TEveTrans *tr = ps.PtrMainTrans(kFALSE);
775 
776  Int_t n = ps.Size();
777  Reset(n);
778  fLastPoint = n - 1;
779  Float_t *o = ps.GetP(), *p = GetP();
780  for (Int_t i = 0; i < n; ++i, o+=3, p+=3)
781  {
782  proj.ProjectPointfv(tr, o, p, fDepth);
783  }
784 }
785 
786 ////////////////////////////////////////////////////////////////////////////////
787 /// Virtual method of base class TPointSet3D.
788 /// Forward to projectable.
789 
790 void TEvePointSetProjected::PointSelected(Int_t id)
791 {
792  TEvePointSet *ps = dynamic_cast<TEvePointSet*>(fProjectable);
793  ps->PointSelected(id);
794 }