summaryrefslogtreecommitdiffstats
path: root/lib/tqwtplot3d/include/qwt3d_autoscaler.h
blob: 31c7497c70b4c53780dd0b5b26c18f4dc51d002d (plain)
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
#ifndef __qwt3d_autoscaler_2003_08_18_12_05__
#define __qwt3d_autoscaler_2003_08_18_12_05__

#include <vector>
#include "qwt3d_global.h"
#include "qwt3d_autoptr.h"

namespace Qwt3D
{

//! ABC for autoscaler
class QWT3D_EXPORT AutoScaler
{
friend class qwt3d_ptr<AutoScaler>;
protected:
  //! Returns a new heap based object of the derived class.  
  virtual AutoScaler* clone() const = 0;
  //! To implement from subclasses
  virtual int execute(double& a, double& b, double start, double stop, int ivals) = 0;
  virtual ~AutoScaler(){}

private:
  void destroy() const {delete this;} //!< Used by qwt3d_ptr      
};

//! Automatic beautifying of linear scales
class QWT3D_EXPORT LinearAutoScaler : public AutoScaler
{
friend class LinearScale;
protected:
  LinearAutoScaler();
  explicit LinearAutoScaler(std::vector<double>& mantisses);
  //! Returns a new heap based object utilized from qwt3d_ptr
  AutoScaler* clone() const {return new LinearAutoScaler(*this);}
	int execute(double& a, double& b, double start, double stop, int ivals);

private:
	
	double start_, stop_;
	int intervals_; 

	void init(double start, double stop, int ivals);
	double anchorvalue(double start, double mantisse, int exponent);
	int segments(int& l_intervals, int& r_intervals, double start, double stop, double anchor, double mantissa, int exponent);
  std::vector<double> mantissi_;
};

} // ns


#endif