diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:24:48 +0000 |
commit | cca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch) | |
tree | 146f39ded1c938019e1ed42d30923c2ac9e86789 /src/line-snapper.h | |
parent | Initial commit. (diff) | |
download | inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.tar.xz inkscape-cca66b9ec4e494c1d919bff0f71a820d8afab1fa.zip |
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/line-snapper.h')
-rw-r--r-- | src/line-snapper.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/line-snapper.h b/src/line-snapper.h new file mode 100644 index 0000000..4e1d919 --- /dev/null +++ b/src/line-snapper.h @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#ifndef SEEN_LINE_SNAPPER_H +#define SEEN_LINE_SNAPPER_H +/* + * Authors: + * Carl Hetherington <inkscape@carlh.net> + * Diederik van Lierop <mail@diedenrezi.nl> + * + * Copyright (C) 1999-2008 Authors + * + * Released under GNU GPL v2+, read the file 'COPYING' for more information. + */ + +#include "snapper.h" + +namespace Inkscape { + +class SnapCandidatePoint; + +/** + * Superclass for snappers to horizontal and vertical lines. + */ +class LineSnapper : public Snapper +{ +public: + LineSnapper(SnapManager *sm, Geom::Coord const d); + + void freeSnap(IntermSnapResults &isr, + Inkscape::SnapCandidatePoint const &p, + Geom::OptRect const &bbox_to_snap, + std::vector<SPObject const *> const *it, + std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes) const override; + + void constrainedSnap(IntermSnapResults &isr, + Inkscape::SnapCandidatePoint const &p, + Geom::OptRect const &bbox_to_snap, + SnapConstraint const &c, + std::vector<SPObject const *> const *it, + std::vector<SnapCandidatePoint> *unselected_nodes) const override; + +protected: + typedef std::list<std::pair<Geom::Point, Geom::Point> > LineList; + //first point is a vector normal to the line + //second point is a point on the line + +private: + /** + * \param p Point that we are trying to snap. + * \return List of lines that we should try snapping to. + */ + virtual LineList _getSnapLines(Geom::Point const &p) const = 0; + + virtual 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, Geom::Point const &point_on_line) const = 0; + + // Will only be implemented for guide lines, because grid lines don't have an origin + virtual void _addSnappedLinesOrigin(IntermSnapResults &isr, Geom::Point const &origin, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const; + + virtual void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const = 0; + virtual void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const = 0; +}; + +} + +#endif /* !SEEN_LINE_SNAPPER_H */ |