| 785 | } |
| 786 | |
| 787 | bool DrawPathTool::removeLastPointFromSelectedPath() |
| 788 | { |
| 789 | if (editingInProgress() || map()->getNumSelectedObjects() != 1) |
| 790 | { |
| 791 | return false; |
| 792 | } |
| 793 | |
| 794 | Object* object = map()->getFirstSelectedObject(); |
| 795 | if (object->getType() != Object::Path) |
| 796 | { |
| 797 | return false; |
| 798 | } |
| 799 | |
| 800 | PathObject* path = object->asPath(); |
| 801 | if (path->parts().size() != 1) |
| 802 | { |
| 803 | return false; |
| 804 | } |
| 805 | |
| 806 | int points_on_path = 0; |
| 807 | auto num_coords = path->getCoordinateCount(); |
| 808 | for (MapCoordVector::size_type i = 0; i < num_coords && points_on_path < 3; ++i) |
| 809 | { |
| 810 | ++points_on_path; |
| 811 | if (path->getCoordinate(i).isCurveStart()) |
| 812 | { |
| 813 | i += 2; // Skip the control points. |
| 814 | } |
| 815 | } |
| 816 | |
| 817 | if (points_on_path < 3) |
| 818 | { |
| 819 | // Too few points after deleting the last: delete the whole object. |
| 820 | map()->deleteSelectedObjects(); |
| 821 | return true; |
| 822 | } |
| 823 | |
| 824 | auto undo_step = new ReplaceObjectsUndoStep(map()); |
| 825 | auto undo_duplicate = object->duplicate(); |
| 826 | undo_duplicate->setMap(map()); |
| 827 | undo_step->addObject(object, undo_duplicate); |
| 828 | map()->push(undo_step); |
| 829 | updateDirtyRect(); |
| 830 | |
| 831 | path->parts().front().setClosed(false); |
| 832 | path->deleteCoordinate(num_coords - 1, false); |
| 833 | |
| 834 | path->update(); |
| 835 | map()->setObjectsDirty(); |
| 836 | map()->emitSelectionEdited(); |
| 837 | return true; |
| 838 | } |
| 839 | |
| 840 | void DrawPathTool::closeDrawing() |
| 841 | { |
nothing calls this directly
no test coverage detected