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 DEBUG_FLAG =
false;
33 const QStringList NO_LOAD_STARTUP_FILES;
35 initializeLogging (
"engauge_test",
40 NO_REGRESSION_OPEN_FILE,
44 NO_LOAD_STARTUP_FILES);
48 void TestGridLineLimiter::testBadStepLinearX ()
50 bool success = testLinearX (0,
60 void TestGridLineLimiter::testBadStepLinearY ()
62 bool success = testLinearY (0,
72 void TestGridLineLimiter::testBadStepLogX ()
74 bool success = testLogX (0,
84 void TestGridLineLimiter::testBadStepLogY ()
86 bool success = testLogY (0,
96 bool TestGridLineLimiter::testLinearX (
double start,
100 double x2,
double y2,
101 double x3,
double y3)
110 double startX, stepX;
129 bool success = (stepX > 0);
133 bool stopX = modelGrid.
stopX ();
134 int gridLineCount = 1 + (stopX - startX) / stepX;
135 success = (gridLineCount <= 20);
142 bool TestGridLineLimiter::testLinearY (
double start,
145 double x1,
double y1,
146 double x2,
double y2,
147 double x3,
double y3)
156 double startY, stepY;
175 bool success = (stepY > 0);
179 bool stopY = modelGrid.
stopY ();
180 int gridLineCount = 1 + (stopY - startY) / stepY;
181 success = (gridLineCount <= 20);
188 bool TestGridLineLimiter::testLogX (
double start,
191 double x1,
double y1,
192 double x2,
double y2,
193 double x3,
double y3)
202 double startX, stepX;
221 bool success = (startX > 0) && (stepX > 0);
225 bool stopX = modelGrid.
stopX ();
226 int gridLineCount = 1 + (qLn (stopX) - qLn (startX)) / qLn (stepX);
227 success = (gridLineCount <= 20);
234 bool TestGridLineLimiter::testLogY (
double start,
237 double x1,
double y1,
238 double x2,
double y2,
239 double x3,
double y3)
248 double startY, stepY;
267 bool success = (startY > 0) && (stepY > 0);
271 bool stopY = modelGrid.
stopY ();
272 int gridLineCount = 1 + (qLn (stopY) - qLn (startY)) / qLn (stepY);
273 success = (gridLineCount <= 20);
280 void TestGridLineLimiter::testTransitionLinearToLogX ()
282 bool success = testLogX (0,
292 void TestGridLineLimiter::testTransitionLinearToLogY ()
294 bool success = testLogY (0,
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).
void addPointAxisWithSpecifiedIdentifier(const QPointF &posScreen, const QPointF &posGraph, const QString &identifier, double ordinal, bool isXOnly)
Add a single axis point with the specified point identifier.
Model for DlgSettingsMainWindow.
double stopY() const
Get method for y grid line upper bound (inclusive).
double stopX() const
Get method for x grid line upper bound (inclusive).
void setStopY(double yStop)
Set method for y grid line upper bound (inclusive).
Model for DlgSettingsCoords and CmdSettingsCoords.
void limitForYRadius(const Document &document, const Transformation &transformation, const DocumentModelCoords &modelCoords, const MainWindowModel &modelMainWindow, const DocumentModelGridDisplay &modelGrid, double &startY, double &stepY) const
Limit step value for y/range coordinate. This is a noop if the maximum grid line limit in MainWindowM...
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.
TestGridLineLimiter(QObject *parent=0)
Single constructor.
void limitForXTheta(const Document &document, const Transformation &transformation, const DocumentModelCoords &modelCoords, const MainWindowModel &modelMainWindow, const DocumentModelGridDisplay &modelGrid, double &startX, double &stepX) const
Limit step value for x/theta coordinate. This is a noop if the maximum grid line limit in MainWindowM...
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.