void DrawPathTool::finishFollowing() { following = false; int last = preview_path->getCoordinateCount() - 1; if (last >= 3 && preview_path->getCoordinate(last - 3).isCurveStart()) { MapCoord first = preview_path->getCoordinate(last - 1); MapCoord second = preview_path->getCoordinate(last); previous_point_is_curve_point = true; previous_point_direction = -atan2(second.x() - first.x(), first.y() - second.y()); previous_pos_map = MapCoordF(second); previous_drag_map = MapCoordF(second.x() + (second.x() - first.x()) / 2, second.y() + (second.y() - first.y()) / 2); } else previous_point_is_curve_point = false; updateAngleHelper(); }
void TransformTest::testTransformTranslate() { MapCoord offset { 100.0, 100.0 }; QTransform qt; qt.translate(offset.x(), offset.y()); QVERIFY(qt.isTranslating()); QCOMPARE(int(qt.type()), int(QTransform::TxTranslate)); auto t = TemplateTransform::fromQTransform(qt); QCOMPARE(t.template_x, offset.nativeX()); QCOMPARE(t.template_y, offset.nativeY()); QCOMPARE(t.template_scale_x, 1.0); QCOMPARE(t.template_scale_y, 1.0); QCOMPARE(t.template_rotation, 0.0); }
void DrawPathTool::closeDrawing() { Q_ASSERT(editingInProgress()); if (preview_path->getCoordinateCount() <= 1) return; if (previous_point_is_curve_point && preview_path->getCoordinate(0).isCurveStart()) { // Finish with a curve path_has_preview_point = false; if (dragging) previous_point_direction = -atan2(cur_pos_map.x() - click_pos_map.x(), click_pos_map.y() - cur_pos_map.y()); MapCoord first = preview_path->getCoordinate(0); MapCoord second = preview_path->getCoordinate(1); createPreviewCurve(first, -atan2(second.x() - first.x(), first.y() - second.y())); path_has_preview_point = false; } if (!preview_path->parts().empty()) preview_path->parts().front().setClosed(true, true); }
QPointF MapView::mapToView(MapCoord coords) const { return QPointF(map_to_view.m11() * coords.x() + map_to_view.m12() * coords.y() + map_to_view.m13(), map_to_view.m21() * coords.x() + map_to_view.m22() * coords.y() + map_to_view.m23()); }