summaryrefslogtreecommitdiffstats
path: root/src/grid-snapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/grid-snapper.h')
-rw-r--r--src/grid-snapper.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/grid-snapper.h b/src/grid-snapper.h
new file mode 100644
index 0000000..8648d80
--- /dev/null
+++ b/src/grid-snapper.h
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/** @file
+ * Grid Snapper for Rectangular and Axonometric Grids
+ *//*
+ * Authors: see git history
+ *
+ * Copyright (C) 2022 Authors
+ * Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
+ * Copyright (C) Lauris Kaplinski 2000
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+#ifndef SEEN_GRID_SNAPPER_H_
+#define SEEN_GRID_SNAPPER_H_
+
+#include "line-snapper.h"
+
+class SPGrid;
+
+namespace Inkscape {
+
+/**
+ * Snapper class for grids
+ */
+class GridSnapper : public LineSnapper {
+public:
+ GridSnapper(SPGrid const *grid, SnapManager *sm, Geom::Coord const d);
+ bool ThisSnapperMightSnap() const override;
+
+ Geom::Coord getSnapperTolerance() const override; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
+ bool getSnapperAlwaysSnap() const override; //if true, then the snapper will always snap, regardless of its tolerance
+
+protected:
+ LineList _getSnapLines(Geom::Point const &p) const override;
+ void _addSnappedLine(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const &normal_to_line, const Geom::Point &point_on_line) const override;
+ void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const override;
+ void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const override;
+
+private:
+ SPGrid const *_grid;
+
+ LineList getSnapLinesXY(Geom::Point const &p) const;
+ LineList getSnapLinesAxonom(Geom::Point const &p) const;
+};
+
+} // namepsace Inkscape
+
+#endif // SEEN_GRID_SNAPPER_H_