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, stopX;
134 int gridLineCount = 1 + (stopX - startX) / stepX;
135 success = (gridLineCount <= 20);
139 success = (startX == stopX);
146 bool TestGridLineLimiter::testLinearY (
double start,
149 double x1,
double y1,
150 double x2,
double y2,
151 double x3,
double y3)
160 double startY, stepY, stopY;
184 int gridLineCount = 1 + (stopY - startY) / stepY;
185 success = (gridLineCount <= 20);
189 success = (startY == stopY);
196 bool TestGridLineLimiter::testLogX (
double start,
199 double x1,
double y1,
200 double x2,
double y2,
201 double x3,
double y3)
210 double startX, stepX, stopX;
230 bool success = (startX > 0) && (stepX > 0);
234 int gridLineCount = 1 + (qLn (stopX) - qLn (startX)) / qLn (stepX);
235 success = (gridLineCount <= 20);
242 bool TestGridLineLimiter::testLogY (
double start,
245 double x1,
double y1,
246 double x2,
double y2,
247 double x3,
double y3)
256 double startY, stepY, stopY;
276 bool success = (startY > 0) && (stepY > 0);
280 int gridLineCount = 1 + (qLn (stopY) - qLn (startY)) / qLn (stepY);
281 success = (gridLineCount <= 20);
288 void TestGridLineLimiter::testTransitionLinearToLogX ()
290 bool success = testLogX (0,
300 void TestGridLineLimiter::testTransitionLinearToLogY ()
302 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 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.
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 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.
TestGridLineLimiter(QObject *parent=0)
Single constructor.
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.