Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
REvePointSet.hxx
Go to the documentation of this file.
1 // @(#)root/eve7:$Id$
2 // Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2019, 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 #ifndef ROOT7_REvePointSet
13 #define ROOT7_REvePointSet
14 
15 #include <ROOT/REveElement.hxx>
17 #include <ROOT/REveVector.hxx>
18 
19 #include <TAttMarker.h>
20 #include <TAttBBox.h>
21 
22 #include <cassert>
23 
24 namespace ROOT {
25 namespace Experimental {
26 
27 ////////////////////////////////////////////////////////////////////////////////
28 // REvePointSet
29 // Set of 3D points with same marker attributes;
30 // optionally each point can be assigned an
31 // external TRef or a number of integer indices.
32 ////////////////////////////////////////////////////////////////////////////////
33 
34 class REvePointSet : public REveElement,
35  public REveProjectable,
36  public TAttMarker,
37  public TAttBBox
38 {
39  friend class REvePointSetArray;
40 
41 private:
42  REvePointSet &operator=(const REvePointSet &); // Not implemented
43 
44 protected:
45  std::vector<REveVector> fPoints;
46  int fCapacity{0};
47  int fSize{0};
48 
49 public:
50  REvePointSet(const std::string& name="", const std::string& title="", Int_t n_points = 0);
51  REvePointSet(const REvePointSet &e);
52  virtual ~REvePointSet();
53 
54  REvePointSet *CloneElement() const override { return new REvePointSet(*this); }
55 
56  virtual void ClonePoints(const REvePointSet &e);
57 
58  void Reset(Int_t n_points = 0);
59  Int_t GrowFor(Int_t n_points);
60 
61  int SetNextPoint(float x, float y, float z);
62  int SetPoint(int n, float x, float y, float z);
63 
64  int GetCapacity() const { return fCapacity; }
65  int GetSize() const { return fSize; }
66 
67  REveVector& RefPoint(int n) { assert (n < fSize); return fPoints[n]; }
68  const REveVector& RefPoint(int n) const { assert (n < fSize); return fPoints[n]; }
69 
70  void SetMarkerColor(Color_t col) override { SetMainColor(col); }
71  void SetMarkerStyle(Style_t mstyle = 1) override;
72  void SetMarkerSize(Size_t msize = 1) override;
73 
74  void CopyVizParams(const REveElement *el) override;
75  void WriteVizParams(std::ostream &out, const TString &var) override;
76 
77  TClass* ProjectedClass(const REveProjection *p) const override;
78 
79  Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
80  void BuildRenderData()override;
81 
82  void ComputeBBox() override;
83 
84  void PointSelected(Int_t id); // *SIGNAL*
85 };
86 
87 /******************************************************************************/
88 // REvePointSetArray
89 // Array of REvePointSet's filled via a common point-source; range of displayed REvePointSet's can be
90 // controlled, based on a separating quantity provided on fill-time by a user.
91 /******************************************************************************/
92 
93 class REvePointSetArray : public REveElement,
94  public REveProjectable,
95  public TAttMarker
96 {
97  REvePointSetArray(const REvePointSetArray &); // Not implemented
98  REvePointSetArray &operator=(const REvePointSetArray &); // Not implemented
99 
100 protected:
101  REvePointSet **fBins{nullptr}; // Pointers to subjugated REvePointSet's.
102  Int_t fDefPointSetCapacity; // Default capacity of subjugated REvePointSet's.
103  Int_t fNBins; // Number of subjugated REvePointSet's.
104  Int_t fLastBin; //! Index of the last filled REvePointSet.
105  Double_t fMin, fCurMin; // Overall and current minimum value of the separating quantity.
106  Double_t fMax, fCurMax; // Overall and current maximum value of the separating quantity.
107  Double_t fBinWidth; // Separating quantity bin-width.
108  std::string fQuantName; // Name of the separating quantity.
109 
110 public:
111  REvePointSetArray(const std::string &name = "REvePointSetArray", const std::string &title = "");
112  virtual ~REvePointSetArray();
113 
114  void RemoveElementLocal(REveElement *el) override;
115  void RemoveElementsLocal() override;
116 
117  void SetMarkerColor(Color_t tcolor = 1) override;
118  void SetMarkerStyle(Style_t mstyle = 1) override;
119  void SetMarkerSize(Size_t msize = 1) override;
120 
121  Int_t Size(Bool_t under = kFALSE, Bool_t over = kFALSE) const;
122 
123  void InitBins(const std::string& quant_name, Int_t nbins, Double_t min, Double_t max);
124  Bool_t Fill(Double_t x, Double_t y, Double_t z, Double_t quant);
125  void CloseBins();
126 
127  Int_t GetDefPointSetCapacity() const { return fDefPointSetCapacity; }
128  void SetDefPointSetCapacity(Int_t c) { fDefPointSetCapacity = c; }
129 
130  Int_t GetNBins() const { return fNBins; }
131  REvePointSet *GetBin(Int_t bin) const { return fBins[bin]; }
132 
133  Double_t GetMin() const { return fMin; }
134  Double_t GetCurMin() const { return fCurMin; }
135  Double_t GetMax() const { return fMax; }
136  Double_t GetCurMax() const { return fCurMax; }
137 
138  void SetRange(Double_t min, Double_t max);
139 };
140 
141 /******************************************************************************/
142 // REvePointSetProjected
143 // Projected copy of a REvePointSet.
144 /******************************************************************************/
145 
146 class REvePointSetProjected : public REvePointSet,
147  public REveProjected
148 {
149 private:
150  REvePointSetProjected(const REvePointSetProjected &); // Not implemented
151  REvePointSetProjected &operator=(const REvePointSetProjected &); // Not implemented
152 
153 protected:
154  void SetDepthLocal(Float_t d) override;
155 
156 public:
157  REvePointSetProjected();
158  virtual ~REvePointSetProjected() {}
159 
160  void SetProjection(REveProjectionManager *proj, REveProjectable *model) override;
161  void UpdateProjection() override;
162  REveElement *GetProjectedAsElement() override { return this; }
163 
164  void PointSelected(Int_t id);
165 };
166 
167 } // namespace Experimental
168 } // namespace ROOT
169 
170 #endif