| 810 | } |
| 811 | |
| 812 | void DatapickerTest::referenceMoveKeyPress() { |
| 813 | Datapicker datapicker(QStringLiteral("Test")); |
| 814 | datapicker.addNewPoint(QPointF(0, 1), datapicker.image()); |
| 815 | datapicker.addNewPoint(QPointF(0, 0), datapicker.image()); |
| 816 | datapicker.addNewPoint(QPointF(1, 0), datapicker.image()); |
| 817 | |
| 818 | auto ap = datapicker.image()->axisPoints(); |
| 819 | ap.type = DatapickerImage::GraphType::Linear; |
| 820 | datapicker.image()->setAxisPoints(ap); |
| 821 | |
| 822 | DatapickerImageWidget w(nullptr); |
| 823 | w.setImages({datapicker.image()}); |
| 824 | w.ui.sbPositionX1->setValue(0); |
| 825 | w.ui.sbPositionY1->setValue(10); |
| 826 | w.ui.sbPositionZ1->setValue(0); |
| 827 | w.ui.sbPositionX2->setValue(0); |
| 828 | w.ui.sbPositionY2->setValue(0); |
| 829 | w.ui.sbPositionZ2->setValue(0); |
| 830 | w.ui.sbPositionX3->setValue(10); |
| 831 | w.ui.sbPositionY3->setValue(0); |
| 832 | w.ui.sbPositionZ3->setValue(0); |
| 833 | w.logicalPositionChanged(); |
| 834 | |
| 835 | auto* curve = new DatapickerCurve(i18n("Curve")); |
| 836 | curve->addDatasheet(datapicker.image()->axisPoints().type); |
| 837 | datapicker.addChild(curve); |
| 838 | |
| 839 | datapicker.addNewPoint(QPointF(0.5, 0.6), curve); // (scene coordinates) updates the curve data |
| 840 | VALUES_EQUAL(curve->posXColumn()->valueAt(0), 5.); |
| 841 | VALUES_EQUAL(curve->posYColumn()->valueAt(0), 6.); |
| 842 | |
| 843 | // Points are stored in the image |
| 844 | auto points = datapicker.image()->children<DatapickerPoint>(AbstractAspect::ChildIndexFlag::IncludeHidden); |
| 845 | QCOMPARE(points.count(), 3); |
| 846 | |
| 847 | points[0]->d_ptr->setSelected(false); |
| 848 | points[1]->d_ptr->setSelected(false); |
| 849 | points[2]->d_ptr->setSelected(true); |
| 850 | auto view = static_cast<DatapickerImageView*>(datapicker.image()->view()); |
| 851 | view->shiftLeftAction->triggered(true); |
| 852 | |
| 853 | VALUES_EQUAL(points[0]->position().x(), 0.); |
| 854 | VALUES_EQUAL(points[1]->position().x(), 0.); |
| 855 | VALUES_EQUAL(points[2]->position().x(), 2.); |
| 856 | |
| 857 | VALUES_EQUAL(curve->posXColumn()->valueAt(0), 0.5 / 2 * 10); |
| 858 | VALUES_EQUAL(curve->posYColumn()->valueAt(0), 6.); |
| 859 | } |
| 860 | |
| 861 | /*! |
| 862 | * check the correctness of the data point after the point was moved on the scene. |
nothing calls this directly
no test coverage detected