1 #include "DocumentModelCoords.h"
2 #include "DocumentModelGridDisplay.h"
3 #include "GridLineLimiter.h"
5 #include "MainWindow.h"
6 #include "MainWindowModel.h"
8 #include <QtTest/QtTest>
9 #include "Test/TestGridLineLimiter.h"
10 #include "Transformation.h"
21 void TestGridLineLimiter::cleanupTestCase ()
25 void TestGridLineLimiter::initTestCase ()
27 const QString NO_ERROR_REPORT_LOG_FILE;
28 const QString NO_REGRESSION_OPEN_FILE;
29 const bool NO_GNUPLOT_LOG_FILES =
false;
30 const bool NO_REGRESSION_IMPORT =
false;
31 const bool NO_RESET =
false;
32 const bool NO_EXPORT_ONLY =
false;
33 const bool DEBUG_FLAG =
false;
34 const QStringList NO_LOAD_STARTUP_FILES;
36 initializeLogging (
"engauge_test",
41 NO_REGRESSION_OPEN_FILE,
46 NO_LOAD_STARTUP_FILES);
50 void TestGridLineLimiter::testBadStepLinearX ()
52 bool success = testLinearX (0,
62 void TestGridLineLimiter::testBadStepLinearY ()
64 bool success = testLinearY (0,
74 void TestGridLineLimiter::testBadStepLogX ()
76 bool success = testLogX (0,
86 void TestGridLineLimiter::testBadStepLogY ()
88 bool success = testLogY (0,
98 bool TestGridLineLimiter::testLinearX (
double start,
101 double x1,
double y1,
102 double x2,
double y2,
103 double x3,
double y3)
112 double startX, stepX, stopX;
119 document.addPointAxisWithSpecifiedIdentifier (QPointF (0 , 0), QPointF (x1, y1), QString (
"axis1"), 0.0,
false);
120 document.addPointAxisWithSpecifiedIdentifier (QPointF (100, 0), QPointF (x2, y2), QString (
"axis2"), 0.0,
false);
121 document.addPointAxisWithSpecifiedIdentifier (QPointF (0 , 100), QPointF (x3, y3), QString (
"axis3"), 0.0,
false);
136 int gridLineCount = 1 + (stopX - startX) / stepX;
137 success = (gridLineCount <= 20);
141 success = (startX == stopX);
148 bool TestGridLineLimiter::testLinearY (
double start,
151 double x1,
double y1,
152 double x2,
double y2,
153 double x3,
double y3)
162 double startY, stepY, stopY;
169 document.addPointAxisWithSpecifiedIdentifier (QPointF (0 , 0), QPointF (x1, y1), QString (
"axis1"), 0.0,
false);
170 document.addPointAxisWithSpecifiedIdentifier (QPointF (100, 0), QPointF (x2, y2), QString (
"axis2"), 0.0,
false);
171 document.addPointAxisWithSpecifiedIdentifier (QPointF (0 , 100), QPointF (x3, y3), QString (
"axis3"), 0.0,
false);
186 int gridLineCount = 1 + (stopY - startY) / stepY;
187 success = (gridLineCount <= 20);
191 success = (startY == stopY);
198 bool TestGridLineLimiter::testLogX (
double start,
201 double x1,
double y1,
202 double x2,
double y2,
203 double x3,
double y3)
212 double startX, stepX, stopX;
219 document.addPointAxisWithSpecifiedIdentifier (QPointF (0 , 0), QPointF (x1, y1), QString (
"axis1"), 0.0,
false);
220 document.addPointAxisWithSpecifiedIdentifier (QPointF (100, 0), QPointF (x2, y2), QString (
"axis2"), 0.0,
false);
221 document.addPointAxisWithSpecifiedIdentifier (QPointF (0 , 100), QPointF (x3, y3), QString (
"axis3"), 0.0,
false);
232 bool success = (startX > 0) && (stepX > 0);
236 int gridLineCount = 1 + (qLn (stopX) - qLn (startX)) / qLn (stepX);
237 success = (gridLineCount <= 20);
244 bool TestGridLineLimiter::testLogY (
double start,
247 double x1,
double y1,
248 double x2,
double y2,
249 double x3,
double y3)
258 double startY, stepY, stopY;
265 document.addPointAxisWithSpecifiedIdentifier (QPointF (0 , 0), QPointF (x1, y1), QString (
"axis1"), 0.0,
false);
266 document.addPointAxisWithSpecifiedIdentifier (QPointF (100, 0), QPointF (x2, y2), QString (
"axis2"), 0.0,
false);
267 document.addPointAxisWithSpecifiedIdentifier (QPointF (0 , 100), QPointF (x3, y3), QString (
"axis3"), 0.0,
false);
278 bool success = (startY > 0) && (stepY > 0);
282 int gridLineCount = 1 + (qLn (stopY) - qLn (startY)) / qLn (stepY);
283 success = (gridLineCount <= 20);
290 void TestGridLineLimiter::testTransitionLinearToLogX ()
292 bool success = testLogX (0,
302 void TestGridLineLimiter::testTransitionLinearToLogY ()
304 bool success = testLogY (0,
void limitForXTheta(const Document &document, const Transformation &transformation, const DocumentModelCoords &modelCoords, const MainWindowModel &modelMainWindow, const DocumentModelGridDisplay &modelGrid, double &startX, double &stepX, double &stopX) const
Limit step value for x/theta coordinate. This is a noop if the maximum grid line limit in MainWindowM...
void limitForYRadius(const Document &document, const Transformation &transformation, const DocumentModelCoords &modelCoords, const MainWindowModel &modelMainWindow, const DocumentModelGridDisplay &modelGrid, double &startY, double &stepY, double &stopY) const
Limit step value for y/range coordinate. This is a noop if the maximum grid line limit in MainWindowM...
void setStartX(double startX)
Set method for x grid line lower bound (inclusive).
Model for DlgSettingsGridDisplay and CmdSettingsGridDisplay.
void setStepX(double stepX)
Set method for x grid line increment.
void setCoordScaleYRadius(CoordScale coordScale)
Set method for linear/log scale on y/radius.
void setStepY(double yStep)
Set method for y grid line increment.
void setStopX(double stopX)
Set method for x grid line upper bound (inclusive).
Model for DlgSettingsMainWindow.
void setStopY(double yStop)
Set method for y grid line upper bound (inclusive).
Model for DlgSettingsCoords and CmdSettingsCoords.
Storage of one imported image and the data attached to that image.
void setMaximumGridLines(int maximumGridLines)
Set method for maximum number of grid lines.
void setStartY(double yStart)
Set method for y grid line lower bound (inclusive).
Unit test of GridLineLimiter class.
Limit the number of grid lines so a bad combination of start/step/stop value will not lead to extreme...
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
void setCoordScaleXTheta(CoordScale coordScale)
Set method for linear/log scale on x/theta.