Engauge Digitizer  2
GridInitializer.h
1 #ifndef GRID_INITIALIZER_H
2 #define GRID_INITIALIZER_H
3 
4 #include "DocumentModelGridDisplay.h"
5 #include <QRectF>
6 
8 class QSize;
9 
10 class Transformation;
11 
14 {
15  public:
18 
20  int computeCount (bool linearAxis,
21  double start,
22  double stop,
23  double step) const;
24 
26  double computeStart (bool linearAxis,
27  double stop,
28  double step,
29  int count) const;
30 
32  double computeStep (bool linearAxis,
33  double start,
34  double stop,
35  int count) const;
36 
38  double computeStop (bool linearAxis,
39  double start,
40  double step,
41  int count) const;
42 
44  DocumentModelGridDisplay initializeWithNarrowCoverage (const QRectF &boundingRectGraph,
45  const DocumentModelCoords &modelCoords) const;
46 
51  DocumentModelGridDisplay initializeWithWidePolarCoverage (const QRectF &boundingRectGraph,
52  const DocumentModelCoords &modelCoords,
53  const Transformation &transformation,
54  const QSize &imageSize) const;
55 
57  int valuePower (double value) const;
58 
59  private:
60 
61  // Given the min and max values on an axis, this method picks start, delta and stop
62  // values that nicely bound the low and high values. Key in algorithm is to minimize
63  // number of significant digits in start, delta and stop
64  void axisScale (double xMin,
65  double xMax,
66  bool linearAxis,
67  double &xStart,
68  double &xStop,
69  double &xDelta,
70  int &count) const;
71 
72  void overridePolarCoordinateSettings (const DocumentModelCoords &modelCoords,
73  const Transformation &transformation,
74  DocumentModelGridDisplay &modelGridDisplay,
75  const QSize &imageSize) const; // Adjust grid lines for polar coordinates
76  double roundOffToPower (double arg,
77  int roundOffPower) const;
78 
79  const QRectF m_boundingRectGraph;
80 };
81 
82 #endif // GRID_INITIALIZER_H
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
double computeStart(bool linearAxis, double stop, double step, int count) const
Compute axis scale start from the other axis parameters.
int valuePower(double value) const
Compute power of 10 for input value, rounding down to nearest integer solution of value>=10**solution...
Affine transformation between screen and graph coordinates, based on digitized axis points...
DocumentModelGridDisplay initializeWithWidePolarCoverage(const QRectF &boundingRectGraph, const DocumentModelCoords &modelCoords, const Transformation &transformation, const QSize &imageSize) const
Initialize given the boundaries of the graph coordinates, and then extra processing for polar coordin...
GridInitializer()
Single constructor.
DocumentModelGridDisplay initializeWithNarrowCoverage(const QRectF &boundingRectGraph, const DocumentModelCoords &modelCoords) const
Initialize given the boundaries of the graph coordinates. The output is useful for the Checker class...
int computeCount(bool linearAxis, double start, double stop, double step) const
Compute axis scale count from the other axis parameters.
This class initializes the count, start, step and stop parameters for one coordinate (either x/theta ...
Model for DlgSettingsCoords and CmdSettingsCoords.
double computeStop(bool linearAxis, double start, double step, int count) const
Compute axis scale stop from the other axis parameters.
double computeStep(bool linearAxis, double start, double stop, int count) const
Compute axis scale step from the other axis parameters.