Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
binners
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
19
#include "
datasrcs/DataPointTuple.h
"
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
35
Bins1DBase::Bins1DBase
(
const
Bins1DBase
& binner )
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
46
Bins1DBase::~Bins1DBase
()
47
{
48
if
(
binner_axis
)
delete
binner_axis
;
49
}
50
51
int
52
Bins1DBase::
53
getNumberOfAxes
()
const
54
{
55
return
1;
56
}
57
const
BinnerAxis
*
58
Bins1DBase::
59
getBinnerOn
(
hippodraw::Axes::Type
axis )
const
60
{
61
assert ( axis ==
Axes::X
);
62
63
return
binner_axis
;
64
}
65
66
void
Bins1DBase::setBinnerOn
(
BinnerAxis
* binner,
67
hippodraw::Axes::Type
axis )
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
78
double
Bins1DBase::getLow
(
hippodraw::Axes::Type
axis )
const
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
90
int
Bins1DBase::numberOfBins
(
hippodraw::Axes::Type
axis )
const
91
{
92
assert ( axis ==
Axes::X
);
93
94
return
binner_axis
->
axisNumberOfBins
();
95
}
96
97
void
Bins1DBase::setNumberOfBins
(
hippodraw::Axes::Type
axis,
int
nb )
98
{
99
assert ( axis ==
Axes::X
&& nb > 0 );
100
101
binner_axis
->
axisSetNumberOfBins
( nb );
102
103
resize
();
104
}
105
106
bool
107
Bins1DBase::hasEqualWidths
()
const
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
119
Bins1DBase::scaleFactor
()
const
120
{
121
return
binner_axis
->
scaleFactorWid
();
122
}
123
124
double
125
Bins1DBase::binWidth
(
hippodraw::Axes::Type
axis )
const
126
{
127
assert ( axis ==
Axes::X
);
128
129
return
binner_axis
->
getConstWid
();
130
}
131
132
const
Range
&
133
Bins1DBase::setBinWidth
(
hippodraw::Axes::Type
axis,
double
width )
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
145
Bins1DBase::
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
165
Bins1DBase::getOffset
(
hippodraw::Axes::Type
axis )
const
166
{
167
assert ( axis ==
Axes::X
);
168
169
return
binner_axis
->
getOffset
();
170
}
171
172
void
173
Bins1DBase::
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
&
182
Bins1DBase::
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
&
194
Bins1DBase::
195
getRange
(
hippodraw::Axes::Type
axis )
196
{
197
assert ( axis ==
Axes::X
);
198
199
return
binner_axis
->
getRange
();
200
}
201
202
void
Bins1DBase::resize
()
203
{
204
int
number =
numberOfBins
(
Axes::X
);
205
resize
( number );
206
}
207
208
namespace
dp = DataPoint2DTuple;
209
210
NTuple
*
211
Bins1DBase::
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