This repository has been archived by the owner on Nov 23, 2019. It is now read-only.
forked from yayahjb/ncdist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinearAxis.h
executable file
·156 lines (133 loc) · 5.01 KB
/
LinearAxis.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// LinearAxis.h: interface for the LinearAxis class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(LINEARAXIS_H)
#define LINEARAXIS_H
#if _MSC_VER
#pragma once
#endif
#include <cfloat>
#include <climits>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cstddef>
//-----------------------------------------------------------------------------
class AxisLimits
{
friend class LinearAxis;
public:
AxisLimits(
const double lowerLimit = DBL_MAX,
const double maxDataValue = DBL_MAX,
const double minDataValue = DBL_MAX,
const double upperLimit = DBL_MAX,
const size_t& numSteps = size_t(INT_MAX),
const size_t& objectScaleFactor = size_t(INT_MAX) );
AxisLimits& operator=( const AxisLimits& ) const; // no assignment operator allowed
public:
const double m_lowerLimit;
const double m_maxDataValue;
const double m_minDataValue;
const double m_upperLimit;
const size_t m_numSteps;
const size_t m_objectScaleFactor;
};
//-----------------------------------------------------------------------------
class StepSizeList
{
public:
StepSizeList( );
virtual ~StepSizeList( );
void clear ( );
size_t size( ) const;
StepSizeList operator<< ( const double d );
double operator[ ] ( const size_t& i ) const;
std::vector<double> m_vStepSizes;
private:
size_t sort( );
};
//-----------------------------------------------------------------------------
class LinearAxis : private StepSizeList
{
public:
class Scale; // forward declaration
// the operator<< is a friend so that it can use Scale's private member functions
friend std::ostream& operator<< ( std::ostream& os, const LinearAxis& la );
//#############################################################################
//-----------------------------------------------------------------------------
// BEGIN NESTED CLASSES
//-----------------------------------------------------------------------------
//#############################################################################
class StepSize
{
friend class Scale;
friend class LinearAxis;
private:
explicit StepSize( const double s = DBL_MAX );
const double m_dStepSize;
StepSize& operator=( const StepSize& ) const; // no assignment operator allowed
public:
// virtual void SetStepSizeList( ) = 0;
};
//-----------------------------------------------------------------------------
class Modulus
{
friend class Scale;
friend class LinearAxis;
private:
explicit Modulus( const double m = DBL_MAX );
Modulus& operator=( const Modulus& ) const; // no assignment operator allowed
const double m_dModulus;
};
//-----------------------------------------------------------------------------
class Range
{
friend class Scale;
friend class LinearAxis;
private:
explicit Range( const double r = DBL_MAX );
Range& operator=( const Range& ) const; // no assignment operator allowed
const double m_dRange;
};
//-----------------------------------------------------------------------------
class Scale
{
friend class LinearAxis;
friend std::ostream& operator<< ( std::ostream& os, const LinearAxis& la );
public:
~Scale( );
bool operator< ( const Scale& cs ) const;
double GetModulus ( ) const;
double GetStepSize( ) const;
double GetRange ( ) const;
private:
explicit Scale(
const Modulus& dModulus = LinearAxis::Modulus (DBL_MAX),
const Range& dRange = LinearAxis::Range (DBL_MAX),
const StepSize& dStepSize = LinearAxis::StepSize(DBL_MAX) );
double m_dModulus;
double m_dRange;
double m_dStepSize;
//#############################################################################
//-----------------------------------------------------------------------------
// END NESTED CLASSES
//-----------------------------------------------------------------------------
//#############################################################################
};
public:
LinearAxis( );
StepSizeList m_Steps;
LinearAxis ( const size_t uiTickMax );
virtual ~LinearAxis( );
AxisLimits LinearAxisLimits( const double dMin, const double dMax );
size_t SetAxisConstants( const size_t uiMaxTicks = 11 );
virtual void SetStepSizeList( );
const std::vector<Scale>& GetScale( void ) const { return( m_vScale ); }
protected:
private:
AxisLimits FindActualLimits( const double dDataMin, const double dDataMax );
std::vector<Scale> m_vScale;
};
#endif