BinnerAxis.cxx
Go to the documentation of this file.
1 
12 //inconsistent dll
13 #ifdef _MSC_VER
14 #include "msdevstudio/MSconfig.h"
15 #endif
16 
17 #include "BinnerAxis.h"
18 
19 using std::vector;
20 using std::string;
21 
22 using namespace hippodraw;
23 
24 int BinnerAxis::s_num_bins = 50;
25 double BinnerAxis::s_bin_factor = 0.75;
26 
27 BinnerAxis::BinnerAxis ( const char * name )
28  : m_name ( name ),
29  m_dragging ( false ),
30  m_num_bins ( s_num_bins ),
31  m_range( 0.0, 50.0 ),
32  m_offset( 0.0 ),
33  m_width ( -1.0 )
34 {
35 }
36 
38  : m_name ( binner.m_name ),
39  m_dragging ( false ),
40  m_num_bins( binner.m_num_bins ),
41  m_range ( binner.m_range ),
42  m_offset ( binner.m_offset ),
43  m_width ( binner.m_width )
44 {
45 }
46 
48 {
49 }
50 
51 const string &
53 name () const
54 {
55  return m_name;
56 }
57 
58 bool
60 {
61  return false;
62 }
63 
64 double
66 {
67  return m_range.low();
68 }
69 
70 double
72 {
73  return m_range.high();
74 }
75 
76 const Range &
78 getRange() const
79 {
80  return m_range;
81 }
82 
83 int
85 {
86  return m_num_bins;
87 }
88 
89 void
90 BinnerAxis::setStartRange ( bool dragging ) const
91 {
92  if ( m_dragging == false ) {
94  }
95 
96  m_dragging = dragging;
97 }
98 
99 void
100 BinnerAxis::setStartWidth ( bool dragging ) const
101 {
102  if ( m_dragging == false ) {
104  }
105 
106  m_dragging = dragging;
107 }
108 
109 
110 const vector< double > & BinnerAxis::binEdges ()
111 {
112 
113  if( m_bin_edges.size() == 0 )
114  {
115  m_bin_edges.resize( m_num_bins + 1);
116 
117  m_bin_edges[0] = m_range.low();
118 
119  for( int i = 0; i < m_num_bins; i ++ )
121 
122  m_bin_edges[ m_num_bins + 1 ] = m_range.high();
123  }
124 
125  return m_bin_edges;
126 }
127 
128 double
130 calcBinWidth ( int parm, bool dragging ) const
131 {
132  setStartWidth ( dragging );
133 
134  double multiplier = ( 50 - parm ) / 50.0;
135  int num_start = getNob ( m_width_start );
136  if ( num_start == 1 ) {
137  multiplier *= 4.0;
138  }
139  double num_new = num_start + num_start * multiplier;
140 
141  num_new = std::max ( 1.0, num_new );
142  m_num_bins = static_cast < int > ( num_new );
143  double new_width = calcWidthParm ( m_num_bins );
144 
145  return new_width;
146 }
147 
unsigned int i
virtual bool hasEqualWidths() const
Returns true if all the bins have the same width.
Definition: BinnerAxis.cxx:59
BinnerAxis(const BinnerAxis &binner)
The copy constructor.
Definition: BinnerAxis.cxx:37
double high() const
Returns the maximum of the range object.
Definition: Range.cxx:100
virtual int getNob(double width) const =0
Returns the number of bins given the width parameter width.
void setStartWidth(bool dragging) const
Sets the starting width parameter.
Definition: BinnerAxis.cxx:100
const Range & getRange() const
Returns the range.
Definition: BinnerAxis.cxx:78
virtual ~BinnerAxis()
The destructor.
Definition: BinnerAxis.cxx:47
const std::string m_name
The name of the binner.
Definition: BinnerAxis.h:41
Range m_range_start
The Range at the start of dragging.
Definition: BinnerAxis.h:83
virtual const std::vector< double > & binEdges()
Returns the vector of coordinates of the bin edges i.e returns the member m_edges.
Definition: BinnerAxis.cxx:110
virtual double axisBinWidth(int i) const =0
Returns the width of each bin.
static int s_num_bins
The default number of bins.
Definition: BinnerAxis.h:57
static double s_bin_factor
The scale factor used to calculate new bin width from slider.
Definition: BinnerAxis.h:61
int axisNumberOfBins() const
Returns the number of bins.
Definition: BinnerAxis.cxx:84
std::vector< double > m_bin_edges
The coordinates of the edges of bins.
Definition: BinnerAxis.h:80
void setStartRange(bool dragging) const
Sets the starting Range.
Definition: BinnerAxis.cxx:90
double axisGetLow() const
Returns the lower edge of the first bin.
Definition: BinnerAxis.cxx:65
Range m_range
The range of the bins.
Definition: BinnerAxis.h:68
double m_width
The width parameter for the binning.
Definition: BinnerAxis.h:75
The base class for the BinnerAxis hierarchy.
Definition: BinnerAxis.h:35
double low() const
Returns the minimum of the range object.
Definition: Range.cxx:87
double m_width_start
The width parameter at the start of dragging.
Definition: BinnerAxis.h:86
Expresses a range of values.
Definition: Range.h:33
double axisGetHigh() const
Returns the lower edge of the last + 1 bin.
Definition: BinnerAxis.cxx:71
int m_num_bins
The number of bins.
Definition: BinnerAxis.h:64
virtual double calcWidthParm(int number) const =0
Calculates the bin width parameter given the number of bins.
bool m_dragging
The status of dragging.
Definition: BinnerAxis.h:44
hippodraw::BinnerAxis class interface
const std::string & name() const
Returns the name of this binner.
Definition: BinnerAxis.cxx:53
double calcBinWidth(int parm, bool dragging) const
Calculates the bin width parameter when dragging a slider control.
Definition: BinnerAxis.cxx:130

Generated for HippoDraw Class Library by doxygen