Engauge Digitizer 2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
GridInitializer Class Reference

This class initializes the count, start, step and stop parameters for one coordinate (either x/theta or y/range) More...

#include <GridInitializer.h>

Collaboration diagram for GridInitializer:
Collaboration graph

Public Member Functions

 GridInitializer ()
 Single constructor.
 
int computeCount (bool linearAxis, double start, double stop, double step) const
 Compute axis scale count from the other axis parameters.
 
double computeStart (bool linearAxis, double stop, double step, int count) const
 Compute axis scale start 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.
 
double computeStop (bool linearAxis, double start, double step, int count) const
 Compute axis scale stop from the other axis parameters.
 
DocumentModelGridDisplay initializeWithNarrowCoverage (const QPointF &boundingRectGraphMin, const QPointF &boundingRectGraphMax, const DocumentModelCoords &modelCoords) const
 Initialize given the boundaries of the graph coordinates.
 
DocumentModelGridDisplay initializeWithWidePolarCoverage (const QPointF &boundingRectGraphMin, const QPointF &boundingRectGraphMax, const DocumentModelCoords &modelCoords, const Transformation &transformation, const QSize &imageSize) const
 Initialize given the boundaries of the graph coordinates, and then extra processing for polar coordinates:
 
int valuePower (double value) const
 Compute power of 10 for input value, rounding down to nearest integer solution of value>=10**solution.
 

Detailed Description

This class initializes the count, start, step and stop parameters for one coordinate (either x/theta or y/range)

Definition at line 13 of file GridInitializer.h.

Constructor & Destructor Documentation

◆ GridInitializer()

GridInitializer::GridInitializer ( )

Single constructor.

Definition at line 9 of file GridInitializer.cpp.

10{
11}

Member Function Documentation

◆ computeCount()

int GridInitializer::computeCount ( bool linearAxis,
double start,
double stop,
double step ) const

Compute axis scale count from the other axis parameters.

Definition at line 95 of file GridInitializer.cpp.

99{
100 int count;
101
102 if (linearAxis) {
103 if (qAbs (step) <= 0) {
104 count = 1;
105 } else {
106 count = qFloor (1.0 + (stop - start) / step);
107 }
108 } else {
109 if ((start <= 0) || (step <= 0.0)) {
110 count = 1;
111 } else {
112 count = qFloor (1.0 + log10 (stop / start) / log10 (step));
113 }
114 }
115
116 return count;
117}
const int INNER_RADIUS_MIN

◆ computeStart()

double GridInitializer::computeStart ( bool linearAxis,
double stop,
double step,
int count ) const

Compute axis scale start from the other axis parameters.

Definition at line 119 of file GridInitializer.cpp.

123{
124 double start;
125
126 if (linearAxis) {
127 start = stop - step * (count - 1);
128 } else {
129 start = stop / pow (step, double (count - 1));
130 }
131
132 return start;
133}

◆ computeStep()

double GridInitializer::computeStep ( bool linearAxis,
double start,
double stop,
int count ) const

Compute axis scale step from the other axis parameters.

Definition at line 135 of file GridInitializer.cpp.

139{
140 double step;
141
142 if (linearAxis) {
143 if (count > 1) {
144 step = (stop - start) / (count - 1);
145 } else {
146 step = stop - start;
147 }
148 } else {
149 if (start <= 0.0) {
150 step = 1.0;
151 } else {
152 if (count > 1) {
153 step = pow (stop / start, 1.0 / double (count - 1));
154 } else {
155 step = stop / start;
156 }
157 }
158 }
159
160 return step;
161}

◆ computeStop()

double GridInitializer::computeStop ( bool linearAxis,
double start,
double step,
int count ) const

Compute axis scale stop from the other axis parameters.

Definition at line 163 of file GridInitializer.cpp.

167{
168 double stop;
169
170 if (linearAxis) {
171 stop = start + step * (count - 1);
172 } else {
173 stop = start * pow (step, double (count - 1));
174 }
175
176 return stop;
177}

◆ initializeWithNarrowCoverage()

DocumentModelGridDisplay GridInitializer::initializeWithNarrowCoverage ( const QPointF & boundingRectGraphMin,
const QPointF & boundingRectGraphMax,
const DocumentModelCoords & modelCoords ) const

Initialize given the boundaries of the graph coordinates.

The output is useful for the Checker class. The bounding rectangle is handled as two QPointFs rather one QRectF since QRectF rounds off the lower coordinate to zero when there is a large dynamic range (1e-3 to 1e+9) and zeros break log calculations

Definition at line 179 of file GridInitializer.cpp.

182{
183 LOG4CPP_INFO_S ((*mainCat)) << "GridInitializer::initializeWithNarrowCoverage";
184
185 DocumentModelGridDisplay modelGridDisplay;
186
187 int count;
188 double start, stop, step;
189
190 // X/theta coordinate
191 axisScale (boundingRectGraphMin.x(),
192 boundingRectGraphMax.x(),
193 (modelCoords.coordScaleXTheta() == COORD_SCALE_LINEAR),
194 start,
195 stop,
196 step,
197 count);
198
199 modelGridDisplay.setDisableX (GRID_COORD_DISABLE_COUNT);
200 modelGridDisplay.setCountX (unsigned (count));
201 modelGridDisplay.setStartX (start);
202 modelGridDisplay.setStepX (step);
203 modelGridDisplay.setStopX (stop);
204
205 // Y/radius coordinate
206 axisScale (boundingRectGraphMin.y(),
207 boundingRectGraphMax.y(),
208 (modelCoords.coordScaleYRadius() == COORD_SCALE_LINEAR),
209 start,
210 stop,
211 step,
212 count);
213
214 modelGridDisplay.setDisableY (GRID_COORD_DISABLE_COUNT);
215 modelGridDisplay.setCountY (unsigned (count));
216 modelGridDisplay.setStartY (start);
217 modelGridDisplay.setStepY (step);
218 modelGridDisplay.setStopY (stop);
219
220 modelGridDisplay.setStable (true);
221
222 return modelGridDisplay;
223}
@ COORD_SCALE_LINEAR
Definition CoordScale.h:13
@ GRID_COORD_DISABLE_COUNT
log4cpp::Category * mainCat
Definition Logger.cpp:14
CoordScale coordScaleYRadius() const
Get method for linear/log scale on y/radius.
CoordScale coordScaleXTheta() const
Get method for linear/log scale on x/theta.
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
void setStepX(double stepX)
Set method for x grid line increment.
void setStepY(double yStep)
Set method for y grid line increment.
void setStopX(double stopX)
Set method for x grid line upper bound (inclusive).
void setDisableX(GridCoordDisable disableX)
Set method for x grid line disabled variable.
void setStopY(double yStop)
Set method for y grid line upper bound (inclusive).
void setDisableY(GridCoordDisable disableY)
Set method for y grid line disabled variable.
void setCountX(unsigned int countX)
Set method for x grid line count.
void setStartX(double startX)
Set method for x grid line lower bound (inclusive).
void setStable(bool stable)
Set method for stable flag.
void setStartY(double yStart)
Set method for y grid line lower bound (inclusive).
void setCountY(unsigned int countY)
Set method for y grid line count.
#define LOG4CPP_INFO_S(logger)
Definition convenience.h:18

◆ initializeWithWidePolarCoverage()

DocumentModelGridDisplay GridInitializer::initializeWithWidePolarCoverage ( const QPointF & boundingRectGraphMin,
const QPointF & boundingRectGraphMax,
const DocumentModelCoords & modelCoords,
const Transformation & transformation,
const QSize & imageSize ) const

Initialize given the boundaries of the graph coordinates, and then extra processing for polar coordinates:

  1. radial range expanded to cover the center (to remove hole at center) to the image corners (to guarantee coverage at corners of graph)
  2. angular range is expanded to cover the entire circle (so coverage is total for all directions) The bounding rectangle is handled as two QPointFs rather one QRectF since QRectF rounds off the lower coordinate to zero when there is a large dynamic range (1e-3 to 1e+9) and zeros break log calculations

Definition at line 225 of file GridInitializer.cpp.

230{
231 LOG4CPP_INFO_S ((*mainCat)) << "GridInitializer::initializeWithWidePolarCoverage";
232
233 DocumentModelGridDisplay modelGridDisplay = initializeWithNarrowCoverage (boundingRectGraphMin,
234 boundingRectGraphMax,
235 modelCoords);
236
237 if (modelCoords.coordsType() == COORDS_TYPE_POLAR) {
238
239 overridePolarCoordinateSettings (modelCoords,
240 transformation,
241 modelGridDisplay,
242 imageSize);
243 }
244
245 return modelGridDisplay;
246}
@ COORDS_TYPE_POLAR
Definition CoordsType.h:14
CoordsType coordsType() const
Get method for coordinates type.
DocumentModelGridDisplay initializeWithNarrowCoverage(const QPointF &boundingRectGraphMin, const QPointF &boundingRectGraphMax, const DocumentModelCoords &modelCoords) const
Initialize given the boundaries of the graph coordinates.

◆ valuePower()

int GridInitializer::valuePower ( double value) const

Compute power of 10 for input value, rounding down to nearest integer solution of value>=10**solution.

Definition at line 308 of file GridInitializer.cpp.

309{
310 const int minPower = -30; // MAX_DOUBLE is 10^38
311
312 double avalue = fabs(value);
313 if (avalue < pow(10.0, minPower)) {
314 return minPower;
315 } else {
316 return qFloor (log10 (avalue));
317 }
318}

The documentation for this class was generated from the following files: