Jpp  17.2.1-pre0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JMarkerAttributes.hh
Go to the documentation of this file.
1 #ifndef __JROOT__JMARKERATTRIBUTES__
2 #define __JROOT__JMARKERATTRIBUTES__
3 
4 #include <vector>
5 
6 #include "TAttMarker.h"
7 
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JROOT {}
16 namespace JPP { using namespace JROOT; }
17 
18 namespace JROOT {
19 
21 
22 
23  /**
24  * Auxiliary class to set marker attributes.
25  */
27  public JRewindableObjectIterator<TAttMarker>,
28  public std::vector <TAttMarker>
29  {
30  public:
31 
33 
34 
35  /**
36  * Constructor.
37  *
38  * \param size marker size
39  */
40  JMarkerAttributes(const Double_t size = 1.0) :
41  std::vector<TAttMarker>(),
42  index(0)
43  {
44  push_back(TAttMarker(kBlack, 20, 0.85 * size));
45  push_back(TAttMarker(kRed, 21, 0.70 * size));
46  push_back(TAttMarker(kBlue, 23, 0.75 * size));
47  push_back(TAttMarker(kGreen, 22, 0.75 * size));
48  push_back(TAttMarker(kMagenta, 34, 0.75 * size));
49  push_back(TAttMarker(kYellow, 29, 0.75 * size));
50  push_back(TAttMarker(kCyan, 33, 0.75 * size));
51  push_back(TAttMarker(kOrange, 47, 0.75 * size));
52  push_back(TAttMarker(kPink, 41, 0.75 * size));
53  push_back(TAttMarker(kViolet, 43, 0.75 * size));
54 
55  push_back(TAttMarker(kBlack, 24, 0.85 * size));
56  push_back(TAttMarker(kRed, 25, 0.70 * size));
57  push_back(TAttMarker(kBlue, 32, 0.75 * size));
58  push_back(TAttMarker(kGreen, 26, 0.75 * size));
59  push_back(TAttMarker(kMagenta, 28, 0.75 * size));
60  push_back(TAttMarker(kYellow, 30, 0.75 * size));
61  push_back(TAttMarker(kCyan, 27, 0.75 * size));
62  push_back(TAttMarker(kOrange, 46, 0.75 * size));
63  push_back(TAttMarker(kPink, 40, 0.75 * size));
64  push_back(TAttMarker(kViolet, 42, 0.75 * size));
65  }
66 
67 
68  /**
69  * Get reference to unique instance of this class object.
70  *
71  * \return reference to this class object
72  */
74  {
75  static JMarkerAttributes marker(1.0);
76 
77  return marker;
78  }
79 
80 
81  /**
82  * Set marker size.
83  *
84  * \param size marker size
85  */
86  void setMarkerSize(const Double_t size)
87  {
88  for (iterator i = this->begin(); i != this->end(); ++i) {
89  i->SetMarkerSize(i->GetMarkerSize() * size);
90  }
91  }
92 
93 
94  /**
95  * Rewind index.
96  */
97  virtual void rewind() override
98  {
99  index = 0;
100  }
101 
102 
103  /**
104  * Check availability of next element.
105  *
106  * \return true if the iteration has more elements; else false
107  */
108  virtual bool hasNext() override
109  {
110  return !this->empty();
111  }
112 
113 
114  /**
115  * Get next element.
116  *
117  * \return pointer to element
118  */
119  virtual const pointer_type& next() override
120  {
121  static pointer_type ps;
122 
123  if (index < this->size()) {
124  ps.reset(&this->at(index));
125  }
126 
127  ++index;
128 
129  index = index%this->size();
130 
131  return ps;
132  }
133 
134 
135  /**
136  * Get marker attributes.
137  *
138  * \param index index
139  * \return marker attributes
140  */
141  const TAttMarker& get(unsigned int index)
142  {
143  return this->at(index%this->size());
144  }
145 
146 
147  private:
148  unsigned int index;
149  };
150 }
151 
152 #endif
virtual bool hasNext() override
Check availability of next element.
Interface for object iteration with rewinding.
JMarkerAttributes(const Double_t size=1.0)
Constructor.
virtual void rewind() override
Rewind index.
JRewindableObjectIterator< TAttMarker >::pointer_type pointer_type
Auxiliary class to set marker attributes.
void setMarkerSize(const Double_t size)
Set marker size.
virtual const pointer_type & next() override
Get next element.
static JMarkerAttributes & getInstance()
Get reference to unique instance of this class object.
virtual void reset() override
Reset pointer.
Definition: JPointer.hh:84