Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
REveStraightLineSet.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 ROOT_REveStraightLineSet
13 #define ROOT_REveStraightLineSet
14 
15 #include "TNamed.h"
16 #include "TAttMarker.h"
17 #include "TAttLine.h"
18 #include "TAttBBox.h"
19 
20 #include "ROOT/REveElement.hxx"
23 #include "ROOT/REveTrans.hxx"
24 
25 class TRandom;
26 
27 namespace ROOT {
28 namespace Experimental {
29 
30 ///////////////////////////////////////////////////////////////////////////////
31 /// REveStraightLineSet
32 /// Set of straight lines with optional markers along the lines.
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 class REveStraightLineSet : public REveElement,
36  public REveProjectable,
37  public TAttLine,
38  public TAttMarker,
39  public TAttBBox
40 {
41 private:
42  REveStraightLineSet(const REveStraightLineSet&); // Not implemented
43  REveStraightLineSet& operator=(const REveStraightLineSet&); // Not implemented
44 
45 public:
46  struct Line_t
47  {
48  Int_t fId;
49  Float_t fV1[3];
50  Float_t fV2[3];
51 
52  Line_t(Float_t x1, Float_t y1, Float_t z1,
53  Float_t x2, Float_t y2, Float_t z2) : fId(-1)
54  {
55  fV1[0] = x1, fV1[1] = y1, fV1[2] = z1;
56  fV2[0] = x2, fV2[1] = y2, fV2[2] = z2;
57  }
58  };
59 
60  struct Marker_t
61  {
62  Float_t fV[3];
63  Int_t fLineId;
64 
65  Marker_t(Float_t x, Float_t y, Float_t z, Int_t line_id) : fLineId(line_id)
66  {
67  fV[0] = x, fV[1] = y, fV[2] = z;
68  }
69  };
70 
71 protected:
72  REveChunkManager fLinePlex;
73  REveChunkManager fMarkerPlex;
74 
75  Bool_t fOwnLinesIds; // Flag specifying if id-objects are owned by the line-set
76  Bool_t fOwnMarkersIds; // Flag specifying if id-objects are owned by the line-set
77 
78  Bool_t fRnrMarkers;
79  Bool_t fRnrLines;
80 
81  Bool_t fDepthTest;
82 
83  Line_t *fLastLine{nullptr}; ///<!
84 
85 public:
86  REveStraightLineSet(const std::string &n="StraightLineSet", const std::string &t="");
87  virtual ~REveStraightLineSet() {}
88 
89  void SetLineColor(Color_t col) override { SetMainColor(col); }
90 
91  Line_t *AddLine(Float_t x1, Float_t y1, Float_t z1, Float_t x2, Float_t y2, Float_t z2);
92  Line_t *AddLine(const REveVector& p1, const REveVector& p2);
93  Marker_t *AddMarker(Float_t x, Float_t y, Float_t z, Int_t line_id=-1);
94  Marker_t *AddMarker(const REveVector& p, Int_t line_id=-1);
95  Marker_t *AddMarker(Int_t line_id, Float_t pos);
96 
97  void SetLine(int idx, Float_t x1, Float_t y1, Float_t z1, Float_t x2, Float_t y2, Float_t z2);
98  void SetLine(int idx, const REveVector& p1, const REveVector& p2);
99 
100  REveChunkManager &GetLinePlex() { return fLinePlex; }
101  REveChunkManager &GetMarkerPlex() { return fMarkerPlex; }
102 
103  virtual Bool_t GetRnrMarkers() { return fRnrMarkers; }
104  virtual Bool_t GetRnrLines() { return fRnrLines; }
105  virtual Bool_t GetDepthTest() { return fDepthTest; }
106 
107  virtual void SetRnrMarkers(Bool_t x) { fRnrMarkers = x; }
108  virtual void SetRnrLines(Bool_t x) { fRnrLines = x; }
109  virtual void SetDepthTest(Bool_t x) { fDepthTest = x; }
110 
111  void CopyVizParams(const REveElement* el) override;
112  void WriteVizParams(std::ostream& out, const TString& var) override;
113 
114  TClass* ProjectedClass(const REveProjection* p) const override;
115 
116  Int_t WriteCoreJson(nlohmann::json &j, Int_t rnr_offset) override;
117  void BuildRenderData() override;
118 
119  void ComputeBBox() override;
120 };
121 
122 
123 ///////////////////////////////////////////////////////////////////////////////
124 /// REveStraightLineSetProjected
125 /// Projected copy of a REveStraightLineSet.
126 ///////////////////////////////////////////////////////////////////////////////
127 
128 class REveStraightLineSetProjected : public REveStraightLineSet,
129  public REveProjected
130 {
131 private:
132  REveStraightLineSetProjected(const REveStraightLineSetProjected&); // Not implemented
133  REveStraightLineSetProjected& operator=(const REveStraightLineSetProjected&); // Not implemented
134 
135 protected:
136  void SetDepthLocal(Float_t d) override;
137 
138 public:
139  REveStraightLineSetProjected();
140  virtual ~REveStraightLineSetProjected() {}
141 
142  void SetProjection(REveProjectionManager* mng, REveProjectable* model) override;
143  void UpdateProjection() override;
144  REveElement* GetProjectedAsElement() override { return this; }
145 };
146 
147 } // namespace Experimental
148 } // namespace ROOT
149 
150 #endif