Bins1DBase.cxx
Go to the documentation of this file.
1 
12 #ifdef _MSC_VER
13 #include "msdevstudio/MSconfig.h"
14 #endif
15 
16 
17 #include "Bins1DBase.h"
18 
20 #include "datasrcs/NTuple.h"
21 
22 #include <cassert>
23 
24 using std::string;
25 using std::vector;
26 
27 using namespace hippodraw;
28 
29 Bins1DBase::Bins1DBase ( const char * name )
30  : BinsBase ( name ),
31  binner_axis ( 0 )
32 {
33 }
34 
36  : BinsBase ( binner ),
37  binner_axis ( 0 )
38 {
39  if ( binner.binner_axis != 0 ) {
40  binner_axis = binner.binner_axis->clone();
41  }
42 
43  m_values_dirty = true;
44 }
45 
47 {
48  if ( binner_axis ) delete binner_axis;
49 }
50 
51 int
54 {
55  return 1;
56 }
57 const BinnerAxis *
60 {
61  assert ( axis == Axes::X );
62 
63  return binner_axis;
64 }
65 
68 {
69  assert ( axis == Axes::X );
70 
71  if ( binner_axis ) delete binner_axis;
72 
73  binner_axis = binner;
74  resize ();
75  m_values_dirty = true;
76 }
77 
79 {
80  assert ( axis == Axes::X );
81 
82  return binner_axis->axisGetLow();
83 }
84 
85 double Bins1DBase::getHigh() const
86 {
87  return binner_axis->axisGetHigh();
88 }
89 
91 {
92  assert ( axis == Axes::X );
93 
94  return binner_axis->axisNumberOfBins();
95 }
96 
98 {
99  assert ( axis == Axes::X && nb > 0 );
100 
102 
103  resize ();
104 }
105 
106 bool
108 {
109  return binner_axis->hasEqualWidths ();
110 }
111 
112 double
113 Bins1DBase::binWidth ( int i ) const
114 {
115  return binner_axis->axisBinWidth(i);
116 }
117 
118 double
120 {
121  return binner_axis->scaleFactorWid ();
122 }
123 
124 double
126 {
127  assert ( axis == Axes::X );
128 
129  return binner_axis->getConstWid();
130 }
131 
132 const Range &
134 {
135  assert ( axis == Axes::X &&
136  width > 0.0 );
137 
138  const Range & range = binner_axis->setBinWidth ( width );
139  resize ();
140 
141  return range;
142 }
143 
144 double
146 calcBinWidth ( Axes::Type axis, int parm, bool dragging ) const
147 {
148  assert ( axis == Axes::X );
149  double new_width = binner_axis->calcBinWidth ( parm, dragging );
150 
151  return new_width;
152 }
153 
154 double
155 Bins1DBase::calcOffset ( const std::string & axis,
156  int parm,
157  bool dragging ) const
158 {
159  assert ( axis == "X" );
160 
161  return binner_axis->calcOffset ( parm, dragging );
162 }
163 
164 double
166 {
167  assert ( axis == Axes::X );
168 
169  return binner_axis->getOffset();
170 }
171 
172 void
174 setOffset ( hippodraw::Axes::Type axis, double offset )
175 {
176  assert ( axis == Axes::X );
177 
178  binner_axis->setOffset ( offset );
179 }
180 
181 const Range &
183 setRange ( hippodraw::Axes::Type axis, const Range & range, bool hold_width )
184 {
185  assert ( axis == Axes::X );
186 
187  const Range & new_range = binner_axis->setRange ( range, hold_width );
188  resize ();
189 
190  return new_range;
191 }
192 
193 const Range &
196 {
197  assert ( axis == Axes::X );
198 
199  return binner_axis->getRange();
200 }
201 
203 {
204  int number = numberOfBins ( Axes::X );
205  resize ( number );
206 }
207 
208 namespace dp = DataPoint2DTuple;
209 
210 NTuple *
212 prepareNTuple ( unsigned int rows ) const
213 {
214  unsigned int columns = 4;
215  NTuple * ntuple = new NTuple ( columns );
216  ntuple -> reserve ( rows );
217 
218  vector < string > labels;
219  labels.push_back ( "X" );
220  labels.push_back ( "Value" );
221  labels.push_back ( dp::WIDTH );
222  labels.push_back ( dp::ERROR );
223 
224  ntuple->setLabels ( labels );
225 
226  return ntuple;
227 }

Generated for HippoDraw Class Library by doxygen