1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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_
|