File indexing completed on 2024-09-29 03:31:30
0001 /* 0002 File : MultiRangeTest.cpp 0003 Project : LabPlot 0004 Description : Tests for multi ranges 0005 -------------------------------------------------------------------- 0006 SPDX-FileCopyrightText: 2021 Martin Marmsoler <martin.marmsoler@gmail.com> 0007 SPDX-FileCopyrightText: 2021 Stefan Gerlach <stefan.gerlach@uni.kn> 0008 0009 SPDX-License-Identifier: GPL-2.0-or-later 0010 */ 0011 0012 #include "MultiRangeTest.h" 0013 #include "MultiRangeTest_macros.h" 0014 0015 // ############################################################################## 0016 // ##################### import of LabPlot projects ############################ 0017 // ############################################################################## 0018 0019 // Test1: 0020 // Check if the correct actions are enabled/disabled. 0021 0022 // Combinations: Curve selected. Zoom SelectionX , Plot selected: Autoscale X, Autoscale 0023 0024 // Other tests: 0025 // Apply Action To Selection 0026 // Curve plot 1 selected 0027 // Zoom Selection (check dirty state) 0028 // X Zoom Selection 0029 // Y Zoom Selection 0030 // Autoscale X 0031 // Autoscale Y 0032 // Autoscale 0033 // X Axis selected 0034 // Y Axis selected 0035 // Plot selected 0036 // Apply Action To All 0037 // Curve plot 1 selected 0038 // XAxis plot 1 selected 0039 // YAxis plot 1 selected 0040 // Curve plot 2 selected 0041 // Apply Action to AllX 0042 // Apply Action to AllY 0043 0044 /*! 0045 * \brief MultiRangeTest::applyActionToSelection_CurveSelected_ZoomSelection 0046 * 0047 */ 0048 void MultiRangeTest::applyActionToSelection_CurveSelected_ZoomSelection() { 0049 LOAD_PROJECT 0050 // QActionGroup* cartesianPlotActionGroup = nullptr; 0051 // auto children = view->findChildren<QActionGroup*>(); 0052 // for (int i=0; i < children.count(); i++) { 0053 // auto actions = children[i]->findChildren<QAction*>(); 0054 // for (int j=0; j < actions.count(); j++) { 0055 // if (actions[j]->text() == i18n("Select Region and Zoom In")) { 0056 // // correct action group found 0057 // cartesianPlotActionGroup = children[i]; 0058 // break; 0059 // } 0060 // } 0061 //// 0062 // } 0063 // QCOMPARE(cartesianPlotActionGroup != nullptr, true); 0064 // TODO: where to check if the actions are enabled or not? 0065 0066 // w->setCartesianPlotActionMode(Worksheet::CartesianPlotActionMode::ApplyActionToSelection); 0067 // sinCurve->setSelected(true); 0068 // SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomSelection) 0069 0070 // // Dirty is not stored in the project 0071 // p1->scaleAuto(-1); 0072 // p2->scaleAuto(-1); 0073 0074 // QPointF logicPos(0.2, -0.5); 0075 // auto* sender =const_cast<QObject*>(QObject::sender()); 0076 // sender = p1; 0077 // w->cartesianPlotMousePressZoomSelectionMode(logicPos); 0078 // w->cartesianPlotMouseMoveZoomSelectionMode(QPointF(0.6, 0.3)); 0079 // w->cartesianPlotMouseReleaseZoomSelectionMode(); 0080 0081 // QCOMPARE(p1->xRangeDirty(sinCurve->coordinateSystemIndex()), true); 0082 // QCOMPARE(p1->yRangeDirty(sinCurve->coordinateSystemIndex()), true); 0083 // // True, because sinCurve and tanCurve use the same range 0084 // QCOMPARE(p1->xRangeDirty(tanCurve->coordinateSystemIndex()), true); 0085 // QCOMPARE(p1->yRangeDirty(tanCurve->coordinateSystemIndex()), true); 0086 0087 // QCOMPARE(p2->xRangeDirty(cosCurve->coordinateSystemIndex()), false); 0088 // QCOMPARE(p2->yRangeDirty(cosCurve->coordinateSystemIndex()), false); 0089 0090 // CHECK_RANGE(p1, sinCurve, Dimension::X, 0.2, 0.6); 0091 // CHECK_RANGE(p1, sinCurve, Dimension::Y, -0.5, 0.3); 0092 0093 // CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0094 // CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0095 0096 // CHECK_RANGE(p2, cosCurve, x, 0., 1.); 0097 // CHECK_RANGE(p2, cosCurve, y, -1., 1.); 0098 } 0099 0100 // ZOOM SELECTION 0101 0102 void MultiRangeTest::zoomXSelection_AllRanges() { 0103 LOAD_PROJECT 0104 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0105 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0106 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0107 w->setCartesianPlotActionMode(Worksheet::CartesianPlotActionMode::ApplyActionToSelection); 0108 horAxisP1->setSelected(true); 0109 SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomXSelection) 0110 0111 // select range with mouse 0112 p1->mousePressZoomSelectionMode(QPointF(0.2, -150), -1); 0113 p1->mouseMoveZoomSelectionMode(QPointF(0.6, 100), -1); 0114 p1->mouseReleaseZoomSelectionMode(-1); 0115 0116 // DEBUG_RANGE(p1, sinCurve) 0117 // DEBUG_RANGE(p1, tanCurve) 0118 // DEBUG_RANGE(p1, logCurve) 0119 0120 CHECK_RANGE(p1, sinCurve, Dimension::X, .2, .6); // zoom 0121 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0122 CHECK_RANGE(p1, tanCurve, Dimension::X, .2, .6); // zoom 0123 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0124 CHECK_RANGE(p1, logCurve, Dimension::X, 20., 60.); // zoom 0125 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); // No niceExtends() done! 0126 0127 QVector<double> ref = {-250, -150.0, -50, 50, 150, 250}; 0128 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), ref); 0129 ref = {-1., -0.5, 0.0, 0.5, 1.0}; 0130 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0131 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale, because it uses a different range 0132 } 0133 0134 void MultiRangeTest::zoomXSelection_SingleRange() { 0135 LOAD_PROJECT 0136 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0137 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0138 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0139 horAxisP1->setSelected(true); 0140 SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomXSelection) 0141 0142 p1->mousePressZoomSelectionMode(QPointF(0.2, -150), 0); 0143 p1->mouseMoveZoomSelectionMode(QPointF(0.6, 100), 0); 0144 p1->mouseReleaseZoomSelectionMode(0); 0145 0146 CHECK_RANGE(p1, sinCurve, Dimension::X, 0.2, 0.6); // zoom 0147 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0148 CHECK_RANGE(p1, tanCurve, Dimension::X, 0.2, 0.6); // zoom 0149 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0150 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0151 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); // should not change, because y scale is not auto 0152 0153 QVector<double> ref = {-250, -150.0, -50, 50, 150, 250}; 0154 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), ref); 0155 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0156 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale, because it uses a different range 0157 } 0158 0159 void MultiRangeTest::zoomYSelection_AllRanges() { 0160 LOAD_PROJECT 0161 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0162 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0163 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0164 vertAxisP1->setSelected(true); 0165 w->setCartesianPlotActionMode(Worksheet::CartesianPlotActionMode::ApplyActionToSelection); 0166 SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomYSelection) 0167 0168 p1->mousePressZoomSelectionMode(QPointF(0.2, -150), -1); 0169 p1->mouseMoveZoomSelectionMode(QPointF(0.6, 100), -1); 0170 p1->mouseReleaseZoomSelectionMode(-1); 0171 0172 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0173 CHECK_RANGE(p1, sinCurve, Dimension::Y, -0.8, 0.6); // zoom 0174 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0175 CHECK_RANGE(p1, tanCurve, Dimension::Y, -150., 100.); // zoom 0176 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0177 CHECK_RANGE(p1, logCurve, Dimension::Y, -7., 2.); // zoom 0178 0179 QVector<double> ref = {-150.0, -100, -50, 0, 50, 100}; 0180 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), ref); 0181 ref = {-0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6}; 0182 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), ref); 0183 ref = {-7., -4., -1., 2.}; 0184 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), ref); 0185 } 0186 0187 void MultiRangeTest::zoomYSelection_SingleRange() { 0188 LOAD_PROJECT 0189 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0190 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0191 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0192 vertAxisP1->setSelected(true); 0193 SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomYSelection) 0194 0195 p1->mousePressZoomSelectionMode(QPointF(0.2, -150), 0); 0196 p1->mouseMoveZoomSelectionMode(QPointF(0.6, 100), 0); 0197 p1->mouseReleaseZoomSelectionMode(vertAxisP1->coordinateSystemIndex()); 0198 0199 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0200 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0201 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0202 CHECK_RANGE(p1, tanCurve, Dimension::Y, -150., 100.); // zoom 0203 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0204 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0205 0206 QVector<double> ref = {-150.0, -100, -50, 0, 50, 100}; 0207 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), ref); 0208 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0209 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); 0210 } 0211 0212 void MultiRangeTest::zoomSelection_AllRanges() { 0213 LOAD_PROJECT 0214 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0215 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0216 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0217 horAxisP1->setSelected(true); 0218 vertAxisP1->setSelected(true); 0219 SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomSelection) 0220 0221 p1->mousePressZoomSelectionMode(QPointF(0.2, -150), -1); 0222 p1->mouseMoveZoomSelectionMode(QPointF(0.6, 100), -1); 0223 p1->mouseReleaseZoomSelectionMode(-1); 0224 0225 CHECK_RANGE(p1, sinCurve, Dimension::X, 0.2, 0.6); // zoom 0226 CHECK_RANGE(p1, sinCurve, Dimension::Y, -0.8, 0.6); // zoom 0227 CHECK_RANGE(p1, tanCurve, Dimension::X, 0.2, 0.6); // zoom 0228 CHECK_RANGE(p1, tanCurve, Dimension::Y, -150., 100.); // zoom 0229 CHECK_RANGE(p1, logCurve, Dimension::X, 20., 60.); // zoom 0230 CHECK_RANGE(p1, logCurve, Dimension::Y, -7., 2.); // zoom 0231 0232 QVector<double> ref = {-150.0, -100, -50, 0, 50, 100}; 0233 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), ref); 0234 ref = {-0.8, -0.6, -0.4, -0.2, 0, 0.2, 0.4, 0.6}; 0235 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), ref); 0236 ref = {-7., -4., -1., 2.}; 0237 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), ref); 0238 } 0239 0240 void MultiRangeTest::zoomSelection_SingleRange() { 0241 LOAD_PROJECT 0242 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0243 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0244 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0245 horAxisP1->setSelected(true); 0246 vertAxisP1->setSelected(true); 0247 SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomSelection) 0248 0249 p1->mousePressZoomSelectionMode(QPointF(0.2, -150), 0); 0250 p1->mouseMoveZoomSelectionMode(QPointF(0.6, 100), 0); 0251 p1->mouseReleaseZoomSelectionMode(0); 0252 0253 CHECK_RANGE(p1, sinCurve, Dimension::X, 0.2, 0.6); // zoom 0254 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0255 CHECK_RANGE(p1, tanCurve, Dimension::X, 0.2, 0.6); // zoom 0256 CHECK_RANGE(p1, tanCurve, Dimension::Y, -150., 100.); // zoom 0257 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0258 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0259 0260 QVector<double> ref = {-150.0, -100, -50, 0, 50, 100}; 0261 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), ref); 0262 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0263 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); 0264 } 0265 0266 // ZOOM 0267 0268 void MultiRangeTest::zoomInX_SingleRange() { 0269 LOAD_PROJECT 0270 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0271 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0272 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0273 horAxisP1->setSelected(true); 0274 p1->zoomInX(0); 0275 0276 CHECK_RANGE(p1, sinCurve, Dimension::X, 0.1, 0.9); // zoom 0277 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0278 CHECK_RANGE(p1, tanCurve, Dimension::X, 0.1, 0.9); // zoom 0279 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0280 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0281 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0282 0283 // check auto scale 0284 p1->navigate(0, CartesianPlot::NavigationOperation::ScaleAutoX); 0285 0286 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0287 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0288 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0289 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0290 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0291 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0292 0293 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0294 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0295 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale, because it uses a different range 0296 } 0297 0298 void MultiRangeTest::zoomInX_SingleRangeDateTimeMonotonicIncrease() { 0299 Project project; 0300 auto* ws = new Worksheet(QStringLiteral("worksheet")); 0301 QVERIFY(ws != nullptr); 0302 project.addChild(ws); 0303 0304 auto* view = dynamic_cast<WorksheetView*>(ws->view()); 0305 QVERIFY(view != nullptr); 0306 view->initActions(); // needed by SET_CARTESIAN_MOUSE_MODE() 0307 0308 Spreadsheet* spreadsheetData = new Spreadsheet(QStringLiteral("data"), false); 0309 spreadsheetData->setColumnCount(2); 0310 spreadsheetData->setRowCount(3); 0311 project.addChild(spreadsheetData); 0312 auto* xCol = spreadsheetData->column(0); 0313 xCol->setColumnMode(AbstractColumn::ColumnMode::DateTime); 0314 QDateTime dt1 = QDateTime::fromString(QStringLiteral("2017-07-10T00:00:00Z"), Qt::ISODate); 0315 QDateTime dt2 = QDateTime::fromString(QStringLiteral("2017-07-11T00:00:00Z"), Qt::ISODate); 0316 QDateTime dt3 = QDateTime::fromString(QStringLiteral("2017-07-12T00:00:00Z"), Qt::ISODate); 0317 QDateTime dt4 = QDateTime::fromString(QStringLiteral("2017-07-13T00:00:00Z"), Qt::ISODate); 0318 QDateTime dt5 = QDateTime::fromString(QStringLiteral("2017-07-14T00:00:00Z"), Qt::ISODate); 0319 QDateTime dt6 = QDateTime::fromString(QStringLiteral("2017-07-15T00:00:00Z"), Qt::ISODate); 0320 QDateTime dt7 = QDateTime::fromString(QStringLiteral("2017-07-16T00:00:00Z"), Qt::ISODate); 0321 QDateTime dt8 = QDateTime::fromString(QStringLiteral("2017-07-17T00:00:00Z"), Qt::ISODate); 0322 QDateTime dt9 = QDateTime::fromString(QStringLiteral("2017-07-18T00:00:00Z"), Qt::ISODate); 0323 QDateTime dt10 = QDateTime::fromString(QStringLiteral("2017-07-19T00:00:00Z"), Qt::ISODate); 0324 xCol->replaceDateTimes(-1, QVector<QDateTime>({dt1, dt2, dt3, dt4, dt5, dt6, dt7, dt8, dt9, dt10})); 0325 auto* yCol = spreadsheetData->column(1); 0326 yCol->replaceValues(-1, QVector<double>({2., 3., 4., 5., 6., 7., 8., 9., 10., 11.})); 0327 0328 auto* p = new CartesianPlot(QStringLiteral("plot")); 0329 p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created 0330 p->setNiceExtend(false); 0331 QVERIFY(p != nullptr); 0332 ws->addChild(p); 0333 0334 auto* curve = new XYCurve(QStringLiteral("curve")); 0335 p->addChild(curve); 0336 curve->setXColumn(xCol); 0337 curve->setYColumn(yCol); 0338 0339 CHECK_RANGE(p, curve, Dimension::X, (double)dt1.toMSecsSinceEpoch(), (double)dt10.toMSecsSinceEpoch()); 0340 CHECK_RANGE(p, curve, Dimension::Y, 2., 11.); 0341 0342 QCOMPARE(p->rangeCount(Dimension::X), 1); 0343 QCOMPARE(p->rangeCount(Dimension::Y), 1); 0344 QCOMPARE(p->range(Dimension::Y, 0).autoScale(), true); 0345 0346 const auto& axes = p->children<Axis>(); 0347 QCOMPARE(axes.count(), 2); 0348 QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); 0349 axes.at(0)->setSelected(true); 0350 SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomXSelection) 0351 0352 p->mousePressZoomSelectionMode(QPointF((double)dt3.toMSecsSinceEpoch(), 3.), 0); 0353 p->mouseMoveZoomSelectionMode(QPointF((double)dt5.toMSecsSinceEpoch(), 3.), 0); 0354 p->mouseReleaseZoomSelectionMode(0); 0355 0356 CHECK_RANGE(p, curve, Dimension::X, (double)dt3.toMSecsSinceEpoch(), (double)dt5.toMSecsSinceEpoch()); // zoom 0357 CHECK_RANGE(p, curve, Dimension::Y, 4., 6.); // autoscaled 0358 } 0359 0360 void MultiRangeTest::zoomInX_SingleRangeDateTimeNonMonotonic() { 0361 Project project; 0362 auto* ws = new Worksheet(QStringLiteral("worksheet")); 0363 QVERIFY(ws != nullptr); 0364 project.addChild(ws); 0365 0366 auto* view = dynamic_cast<WorksheetView*>(ws->view()); 0367 QVERIFY(view != nullptr); 0368 view->initActions(); // needed by SET_CARTESIAN_MOUSE_MODE() 0369 0370 Spreadsheet* spreadsheetData = new Spreadsheet(QStringLiteral("data"), false); 0371 spreadsheetData->setColumnCount(2); 0372 spreadsheetData->setRowCount(3); 0373 project.addChild(spreadsheetData); 0374 auto* xCol = spreadsheetData->column(0); 0375 xCol->setColumnMode(AbstractColumn::ColumnMode::DateTime); 0376 QDateTime dt1 = QDateTime::fromString(QStringLiteral("2017-07-10T00:00:00Z"), Qt::ISODate); 0377 QDateTime dt2 = QDateTime::fromString(QStringLiteral("2017-07-11T00:00:00Z"), Qt::ISODate); 0378 QDateTime dt3 = QDateTime::fromString(QStringLiteral("2017-07-12T00:00:00Z"), Qt::ISODate); 0379 QDateTime dt4 = QDateTime::fromString(QStringLiteral("2017-07-15T00:00:00Z"), Qt::ISODate); 0380 QDateTime dt5 = QDateTime::fromString(QStringLiteral("2017-07-14T00:00:00Z"), Qt::ISODate); // Nonmonoton 0381 QDateTime dt6 = QDateTime::fromString(QStringLiteral("2017-07-15T00:00:00Z"), Qt::ISODate); 0382 QDateTime dt7 = QDateTime::fromString(QStringLiteral("2017-07-16T00:00:00Z"), Qt::ISODate); 0383 QDateTime dt8 = QDateTime::fromString(QStringLiteral("2017-07-17T00:00:00Z"), Qt::ISODate); 0384 QDateTime dt9 = QDateTime::fromString(QStringLiteral("2017-07-18T00:00:00Z"), Qt::ISODate); 0385 QDateTime dt10 = QDateTime::fromString(QStringLiteral("2017-07-19T00:00:00Z"), Qt::ISODate); 0386 xCol->replaceDateTimes(-1, QVector<QDateTime>({dt1, dt2, dt3, dt4, dt5, dt6, dt7, dt8, dt9, dt10})); 0387 auto* yCol = spreadsheetData->column(1); 0388 yCol->replaceValues(-1, QVector<double>({2., 3., 4., 5., 6., 7., 8., 9., 10., 11.})); 0389 0390 auto* p = new CartesianPlot(QStringLiteral("plot")); 0391 p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created 0392 p->setNiceExtend(false); 0393 QVERIFY(p != nullptr); 0394 ws->addChild(p); 0395 0396 auto* curve = new XYCurve(QStringLiteral("curve")); 0397 p->addChild(curve); 0398 curve->setXColumn(xCol); 0399 curve->setYColumn(yCol); 0400 0401 CHECK_RANGE(p, curve, Dimension::X, (double)dt1.toMSecsSinceEpoch(), (double)dt10.toMSecsSinceEpoch()); 0402 CHECK_RANGE(p, curve, Dimension::Y, 2., 11.); 0403 0404 QCOMPARE(p->rangeCount(Dimension::X), 1); 0405 QCOMPARE(p->rangeCount(Dimension::Y), 1); 0406 QCOMPARE(p->range(Dimension::Y, 0).autoScale(), true); 0407 0408 const auto& axes = p->children<Axis>(); 0409 QCOMPARE(axes.count(), 2); 0410 QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); 0411 axes.at(0)->setSelected(true); 0412 SET_CARTESIAN_MOUSE_MODE(CartesianPlot::MouseMode::ZoomXSelection) 0413 0414 p->mousePressZoomSelectionMode(QPointF((double)dt3.toMSecsSinceEpoch(), 3.), 0); 0415 p->mouseMoveZoomSelectionMode(QPointF((double)dt5.addSecs(3600 * 2).toMSecsSinceEpoch(), 3.), 0416 0); // Adding an offset, because the error happens only if the exact time is not hit 0417 p->mouseReleaseZoomSelectionMode(0); 0418 0419 CHECK_RANGE(p, curve, Dimension::X, (double)dt3.toMSecsSinceEpoch(), (double)dt5.addSecs(3600 * 2).toMSecsSinceEpoch()); // zoom 0420 CHECK_RANGE(p, curve, Dimension::Y, 4., 6.); // autoscaled 0421 } 0422 0423 void MultiRangeTest::zoomInX_AllRanges() { 0424 LOAD_PROJECT 0425 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0426 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0427 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0428 horAxisP1->setSelected(true); 0429 p1->zoomInX(); 0430 0431 CHECK_RANGE(p1, sinCurve, Dimension::X, 0.1, 0.9); // zoom 0432 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0433 CHECK_RANGE(p1, tanCurve, Dimension::X, 0.1, 0.9); // zoom 0434 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0435 CHECK_RANGE(p1, logCurve, Dimension::X, 10., 90.); // zoom 0436 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0437 0438 // check auto scale (all) 0439 p1->navigate(-1, CartesianPlot::NavigationOperation::ScaleAuto); 0440 0441 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0442 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0443 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0444 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0445 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0446 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0447 0448 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0449 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0450 QVector<double> ref = {-10, -7.71429, -5.42857, -3.14286, -0.857143, 1.42857, 3.71429, 6}; 0451 // COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), ref); // vertAxis3 is not autoscaled when loading, after autoscaling the values are different 0452 } 0453 0454 void MultiRangeTest::zoomInY_SingleRange() { 0455 LOAD_PROJECT 0456 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0457 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0458 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0459 vertAxisP1->setSelected(true); 0460 p1->zoomInY(0); 0461 0462 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0463 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0464 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0465 CHECK_RANGE(p1, tanCurve, Dimension::Y, -200., 200.); // zoom 0466 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0467 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0468 0469 // check auto scale 0470 p1->navigate(0, CartesianPlot::NavigationOperation::ScaleAutoY); 0471 0472 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0473 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0474 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0475 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0476 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0477 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0478 0479 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0480 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0481 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale, because it uses a different range 0482 } 0483 0484 void MultiRangeTest::zoomInY_AllRanges() { 0485 LOAD_PROJECT 0486 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0487 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0488 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0489 vertAxisP1->setSelected(true); 0490 p1->zoomInY(); 0491 0492 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0493 CHECK_RANGE(p1, sinCurve, Dimension::Y, -0.8, 0.8); // zoom 0494 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0495 CHECK_RANGE(p1, tanCurve, Dimension::Y, -200., 200.); // zoom 0496 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0497 CHECK_RANGE(p1, logCurve, Dimension::Y, -8., 4.); // zoom 0498 0499 // check auto scale 0500 p1->navigate(-1, CartesianPlot::NavigationOperation::ScaleAutoY); 0501 0502 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0503 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0504 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0505 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0506 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0507 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0508 0509 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0510 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0511 QVector<double> ref = {-10, -6, -2, 2, 6}; 0512 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), ref); // vertAxis3 is not autoscaled when loading, after autoscaling the values are different 0513 } 0514 0515 void MultiRangeTest::zoomOutX_SingleRange() { 0516 LOAD_PROJECT 0517 0518 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0519 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0520 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0521 horAxisP1->setSelected(true); 0522 p1->zoomOutX(0); 0523 0524 CHECK_RANGE(p1, sinCurve, Dimension::X, -0.2, 1.2); // zoom 0525 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0526 CHECK_RANGE(p1, tanCurve, Dimension::X, -0.2, 1.2); // zoom 0527 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0528 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0529 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0530 0531 // check auto scale 0532 p1->navigate(0, CartesianPlot::NavigationOperation::ScaleAutoX); 0533 0534 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0535 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0536 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0537 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0538 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0539 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0540 0541 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0542 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0543 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale, because it uses a different range 0544 } 0545 0546 void MultiRangeTest::zoomOutX_AllRanges() { 0547 LOAD_PROJECT 0548 0549 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0550 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0551 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0552 horAxisP1->setSelected(true); 0553 p1->zoomOutX(); 0554 0555 CHECK_RANGE(p1, sinCurve, Dimension::X, -0.2, 1.2); // zoom 0556 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0557 CHECK_RANGE(p1, tanCurve, Dimension::X, -0.2, 1.2); // zoom 0558 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0559 CHECK_RANGE(p1, logCurve, Dimension::X, -20., 120.); // zoom 0560 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0561 0562 // check auto scale 0563 p1->navigate(-1, CartesianPlot::NavigationOperation::ScaleAutoX); 0564 0565 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0566 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0567 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0568 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0569 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0570 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0571 0572 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0573 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0574 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale, because it uses a different range 0575 } 0576 0577 void MultiRangeTest::zoomOutY_SingleRange() { 0578 LOAD_PROJECT 0579 0580 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0581 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0582 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0583 vertAxisP1->setSelected(true); 0584 p1->zoomOutY(0); 0585 0586 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0587 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0588 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0589 CHECK_RANGE(p1, tanCurve, Dimension::Y, -300., 300.); // zoom 0590 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0591 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0592 0593 // check auto scale 0594 p1->navigate(0, CartesianPlot::NavigationOperation::ScaleAutoY); 0595 0596 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0597 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0598 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0599 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0600 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0601 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0602 0603 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0604 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0605 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale, because it uses a different range 0606 } 0607 0608 void MultiRangeTest::zoomOutY_AllRanges() { 0609 LOAD_PROJECT 0610 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0611 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0612 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0613 vertAxisP1->setSelected(true); 0614 p1->zoomOutY(); 0615 0616 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0617 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1.5, 1.5); // zoom 0618 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0619 CHECK_RANGE(p1, tanCurve, Dimension::Y, -300., 300.); // zoom 0620 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0621 CHECK_RANGE(p1, logCurve, Dimension::Y, -12., 8.); // zoom 0622 0623 // check auto scale (all) 0624 p1->navigate(-1, CartesianPlot::NavigationOperation::ScaleAuto); 0625 0626 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0627 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0628 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0629 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0630 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0631 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0632 0633 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0634 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0635 QVector<double> ref = {-10, -6, -2, 2, 6}; 0636 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), ref); // vertAxis3 is not autoscaled when loading, after autoscaling the values are different 0637 } 0638 0639 // SHIFT 0640 0641 void MultiRangeTest::shiftLeft_SingleRange() { 0642 LOAD_PROJECT 0643 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0644 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0645 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0646 horAxisP1->setSelected(true); 0647 p1->shiftLeftX(0); 0648 0649 CHECK_RANGE(p1, sinCurve, Dimension::X, 0.1, 1.1); // shift 0650 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0651 CHECK_RANGE(p1, tanCurve, Dimension::X, 0.1, 1.1); // shift 0652 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0653 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0654 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0655 0656 // check auto scale 0657 p1->navigate(0, CartesianPlot::NavigationOperation::ScaleAutoX); 0658 0659 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0660 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0661 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0662 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0663 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0664 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0665 0666 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0667 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0668 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale, because it uses a different range 0669 } 0670 0671 void MultiRangeTest::shiftRight_SingleRange() { 0672 LOAD_PROJECT 0673 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0674 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0675 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0676 horAxisP1->setSelected(true); 0677 p1->shiftRightX(0); 0678 0679 CHECK_RANGE(p1, sinCurve, Dimension::X, -0.1, 0.9); // shift 0680 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0681 CHECK_RANGE(p1, tanCurve, Dimension::X, -0.1, 0.9); // shift 0682 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0683 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0684 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0685 0686 // check auto scale 0687 p1->navigate(0, CartesianPlot::NavigationOperation::ScaleAutoX); 0688 0689 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0690 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0691 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0692 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0693 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0694 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0695 0696 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0697 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0698 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale 0699 } 0700 0701 void MultiRangeTest::shiftLeft_AllRanges() { 0702 LOAD_PROJECT 0703 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0704 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0705 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0706 horAxisP1->setSelected(true); 0707 p1->shiftLeftX(); 0708 0709 CHECK_RANGE(p1, sinCurve, Dimension::X, 0.1, 1.1); // shift 0710 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0711 CHECK_RANGE(p1, tanCurve, Dimension::X, 0.1, 1.1); // shift 0712 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0713 CHECK_RANGE(p1, logCurve, Dimension::X, 10., 110.); // shift 0714 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0715 0716 // check auto scale (all) 0717 p1->navigate(-1, CartesianPlot::NavigationOperation::ScaleAutoX); 0718 0719 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0720 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0721 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0722 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0723 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0724 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0725 0726 // check if retransform is done by comparing the tickLabelValues 0727 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0728 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0729 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale 0730 } 0731 0732 void MultiRangeTest::shiftRight_AllRanges() { 0733 LOAD_PROJECT 0734 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0735 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0736 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0737 horAxisP1->setSelected(true); 0738 p1->shiftRightX(); 0739 0740 CHECK_RANGE(p1, sinCurve, Dimension::X, -0.1, 0.9); // shift 0741 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0742 CHECK_RANGE(p1, tanCurve, Dimension::X, -0.1, 0.9); // shift 0743 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0744 CHECK_RANGE(p1, logCurve, Dimension::X, -10., 90.); // shift 0745 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0746 0747 // check auto scale 0748 p1->navigate(-1, CartesianPlot::NavigationOperation::ScaleAutoX); 0749 0750 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0751 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0752 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0753 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0754 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0755 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0756 0757 // check if retransform is done by comparing the tickLabelValues 0758 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0759 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0760 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); // on third axis there is no autoscale 0761 } 0762 0763 void MultiRangeTest::shiftUp_SingleRange() { 0764 LOAD_PROJECT 0765 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0766 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0767 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0768 vertAxisP1->setSelected(true); 0769 p1->shiftUpY(0); 0770 0771 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0772 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0773 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0774 CHECK_RANGE(p1, tanCurve, Dimension::Y, -300., 200.); // shift 0775 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0776 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0777 0778 // check auto scale 0779 p1->navigate(0, CartesianPlot::NavigationOperation::ScaleAutoY); 0780 0781 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0782 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0783 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0784 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0785 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0786 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0787 0788 // retransform of vertAxisP1 is done, so the tickLabelValues change back 0789 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0790 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0791 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); 0792 } 0793 0794 void MultiRangeTest::shiftDown_SingleRange() { 0795 LOAD_PROJECT 0796 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0797 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0798 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0799 0800 vertAxisP1->setSelected(true); 0801 p1->shiftDownY(0); 0802 0803 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0804 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0805 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.) 0806 CHECK_RANGE(p1, tanCurve, Dimension::Y, -200., 300.); // shift 0807 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0808 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0809 0810 // check auto scale 0811 // p1->enableAutoScale(Dimension::Y, 0); 0812 p1->navigate(0, CartesianPlot::NavigationOperation::ScaleAutoY); 0813 0814 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0815 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0816 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0817 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0818 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0819 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0820 0821 // retransform of vertAxisP1 is done, so the tickLabelValues change back 0822 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0823 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0824 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), refValuesAxis3); 0825 } 0826 0827 void MultiRangeTest::shiftUp_AllRanges() { 0828 LOAD_PROJECT 0829 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0830 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0831 vertAxisP1->setSelected(true); 0832 p1->shiftUpY(); 0833 0834 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0835 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1.2, 0.8); // shift 0836 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0837 CHECK_RANGE(p1, tanCurve, Dimension::Y, -300., 200.); // shift 0838 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0839 CHECK_RANGE(p1, logCurve, Dimension::Y, -11.6, 4.4); // shift 0840 0841 // check auto scale 0842 p1->setSelected(true); 0843 p1->navigate(-1, CartesianPlot::NavigationOperation::ScaleAuto); 0844 0845 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0846 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0847 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0848 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0849 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0850 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0851 // retransform of vertAxisP1 is done, so the tickLabelValues change back 0852 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0853 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0854 QVector<double> ref = {-10, -6, -2, 2, 6}; 0855 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), ref); // vertAxis3 is not autoscaled when loading, after autoscaling the values are different 0856 } 0857 0858 void MultiRangeTest::shiftDown_AllRanges() { 0859 LOAD_PROJECT 0860 auto refValuesAxis1 = vertAxisP1->tickLabelValues(); 0861 auto refValuesAxis2 = vertAxis2P1->tickLabelValues(); 0862 auto refValuesAxis3 = vertAxis3P1->tickLabelValues(); 0863 vertAxisP1->setSelected(true); 0864 p1->shiftDownY(); 0865 0866 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0867 CHECK_RANGE(p1, sinCurve, Dimension::Y, -0.8, 1.2); // shift 0868 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0869 CHECK_RANGE(p1, tanCurve, Dimension::Y, -200., 300.); // shift 0870 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0871 CHECK_RANGE(p1, logCurve, Dimension::Y, -8.4, 7.6); // shift 0872 0873 // check auto scale (all) 0874 p1->setSelected(true); 0875 p1->navigate(-1, CartesianPlot::NavigationOperation::ScaleAuto); 0876 0877 CHECK_RANGE(p1, sinCurve, Dimension::X, 0., 1.); 0878 CHECK_RANGE(p1, sinCurve, Dimension::Y, -1., 1.); 0879 CHECK_RANGE(p1, tanCurve, Dimension::X, 0., 1.); 0880 CHECK_RANGE(p1, tanCurve, Dimension::Y, -250., 250.); 0881 CHECK_RANGE(p1, logCurve, Dimension::X, 0., 100.); 0882 CHECK_RANGE(p1, logCurve, Dimension::Y, -10., 6.); 0883 0884 // retransform of vertAxisP1 is done, so the tickLabelValues change back 0885 COMPARE_DOUBLE_VECTORS(vertAxisP1->tickLabelValues(), refValuesAxis1); 0886 COMPARE_DOUBLE_VECTORS(vertAxis2P1->tickLabelValues(), refValuesAxis2); 0887 QVector<double> ref = {-10, -6, -2, 2, 6}; 0888 COMPARE_DOUBLE_VECTORS(vertAxis3P1->tickLabelValues(), ref); // vertAxis3 is not autoscaled when loading, after autoscaling the values are different 0889 } 0890 0891 QTEST_MAIN(MultiRangeTest)