Jpp  16.0.0
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 
52  push_back(TAttMarker(kBlack, 24, 0.85 * size));
53  push_back(TAttMarker(kRed, 25, 0.70 * size));
54  push_back(TAttMarker(kBlue, 32, 0.75 * size));
55  push_back(TAttMarker(kGreen, 26, 0.75 * size));
56  push_back(TAttMarker(kMagenta, 28, 0.75 * size));
57  push_back(TAttMarker(kYellow, 30, 0.75 * size));
58  push_back(TAttMarker(kCyan, 27, 0.75 * size));
59  }
60 
61 
62  /**
63  * Get reference to unique instance of this class object.
64  *
65  * \return reference to this class object
66  */
68  {
69  static JMarkerAttributes marker(1.0);
70 
71  return marker;
72  }
73 
74 
75  /**
76  * Set marker size.
77  *
78  * \param size marker size
79  */
80  void setMarkerSize(const Double_t size)
81  {
82  for (iterator i = this->begin(); i != this->end(); ++i) {
83  i->SetMarkerSize(i->GetMarkerSize() * size);
84  }
85  }
86 
87 
88  /**
89  * Rewind index.
90  */
91  virtual void rewind() override
92  {
93  index = 0;
94  }
95 
96 
97  /**
98  * Check availability of next element.
99  *
100  * \return true if the iteration has more elements; else false
101  */
102  virtual bool hasNext() override
103  {
104  return !this->empty();
105  }
106 
107 
108  /**
109  * Get next element.
110  *
111  * \return pointer to element
112  */
113  virtual const pointer_type& next() override
114  {
115  static pointer_type ps;
116 
117  if (index < this->size()) {
118  ps.reset(&this->at(index));
119  }
120 
121  ++index;
122 
123  index = index%this->size();
124 
125  return ps;
126  }
127 
128 
129  /**
130  * Get marker attributes.
131  *
132  * \param index index
133  * \return marker attributes
134  */
135  const TAttMarker& get(unsigned int index)
136  {
137  return this->at(index%this->size());
138  }
139 
140 
141  private:
142  unsigned int index;
143  };
144 }
145 
146 #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