Inkscape
Vector Graphics Editor
|
Snapping equidistant objects. More...
#include <distribution-snapper.h>
Public Member Functions | |
DistributionSnapper (SnapManager *sm, Geom::Coord const d) | |
~DistributionSnapper () override | |
bool | ThisSnapperMightSnap () const override |
Geom::Coord | getSnapperTolerance () const override |
bool | getSnapperAlwaysSnap (SnapSourceType const &source) const override |
void | freeSnap (IntermSnapResults &isr, Inkscape::SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, std::vector< SPObject const * > const *it, std::vector< 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 |
![]() | |
Snapper (SnapManager *sm, ::Geom::Coord const t) | |
Construct new Snapper for named view. | |
virtual | ~Snapper ()=default |
void | setEnabled (bool s) |
void | setSnapVisibleOnly (bool s) |
bool | getEnabled () const |
bool | getSnapVisibleOnly () const |
Private Types | |
enum class | Direction { RIGHT , LEFT , UP , DOWN } |
Private Member Functions | |
void | _collectBBoxes (Geom::OptRect const &bbox_to_snap, bool const &first_point) const |
Collects and caches bounding boxes to the left, right, up, and down of the selected object. | |
void | _snapEquidistantPoints (IntermSnapResults &isr, SnapCandidatePoint const &p, Geom::OptRect const &bbox_to_snap, std::vector< SnapCandidatePoint > *unselected_nodes, SnapConstraint const &c=SnapConstraint(), Geom::Point const &p_proj_on_constraint=Geom::Point()) const |
Finds and snaps to points that is equidistant from surrounding bboxes. | |
void | _correctSelectionBBox (Geom::Point &target, Geom::Point const &p, Geom::Rect const &bbox_to_snap) const |
When the selection has more than one objects in it, the bounding box of the object that the selection is grabbed from (closest to the pointer) is snapped to the center of the overall bounding box of the selection. | |
bool | _findSidewaysSnaps (Geom::Rect const &source_bbox, std::vector< Geom::Rect >::iterator it, std::vector< Geom::Rect >::iterator end, std::vector< Geom::Rect > &vec, Geom::Coord &dist, Geom::Coord tol, std::function< Geom::Coord(Geom::Rect const &, Geom::Rect const &)> const &distance_func, int level=0) const |
Finds and stores the bounding boxes that are at equal distance from each other. | |
void | _addBBoxForIntersectingBoxes (std::vector< Geom::Rect > *vec, Direction dir) const |
This functions adds overlapping bounding boxes to the list of bounding boxes. | |
Static Private Member Functions | |
static Geom::Coord | distRight (Geom::Rect const &a, Geom::Rect const &b) |
static Geom::Coord | distLeft (Geom::Rect const &a, Geom::Rect const &b) |
static Geom::Coord | distUp (Geom::Rect const &a, Geom::Rect const &b) |
static Geom::Coord | distDown (Geom::Rect const &a, Geom::Rect const &b) |
Private Attributes | |
std::unique_ptr< std::vector< Geom::Rect > > | _bboxes_left |
std::unique_ptr< std::vector< Geom::Rect > > | _bboxes_right |
std::unique_ptr< std::vector< Geom::Rect > > | _bboxes_down |
std::unique_ptr< std::vector< Geom::Rect > > | _bboxes_up |
Additional Inherited Members | |
![]() | |
SnapManager * | _snapmanager |
bool | _snap_enabled |
true if this snapper is enabled, otherwise false | |
bool | _snap_visible_only |
Snapping equidistant objects.
Definition at line 33 of file distribution-snapper.h.
|
strongprivate |
Enumerator | |
---|---|
RIGHT | |
LEFT | |
UP | |
DOWN |
Definition at line 124 of file distribution-snapper.h.
Inkscape::DistributionSnapper::DistributionSnapper | ( | SnapManager * | sm, |
Geom::Coord const | d | ||
) |
Definition at line 64 of file distribution-snapper.cpp.
References _bboxes_down, _bboxes_left, _bboxes_right, and _bboxes_up.
|
override |
Definition at line 73 of file distribution-snapper.cpp.
|
private |
This functions adds overlapping bounding boxes to the list of bounding boxes.
The new bounding boxes are added such that the union bounding box is placed before its constituents. This extra step is needed so that the overall union of any overlapping bounding boxes is also considered during distribution snapping.
Definition at line 267 of file distribution-snapper.cpp.
References num, and Geom::GenericRect< C >::unionWith().
|
private |
Collects and caches bounding boxes to the left, right, up, and down of the selected object.
bounding | box of the selected object |
is | the point first point in the selection? |
Definition at line 200 of file distribution-snapper.cpp.
References SPItem::desktopBounds(), Geom::GenericRect< C >::expandBy(), SPItem::GEOMETRIC_BBOX, Inkscape::Preferences::get(), Inkscape::Preferences::getBool(), Geom::GenericOptRect< C >::intersects(), Geom::GenericRect< C >::intersects(), sortBoxesDown(), sortBoxesLeft(), sortBoxesRight(), sortBoxesUp(), and SPItem::VISUAL_BBOX.
|
private |
When the selection has more than one objects in it, the bounding box of the object that the selection is grabbed from (closest to the pointer) is snapped to the center of the overall bounding box of the selection.
This function corrects the target point to be a point where the bounding box of that particular object must be snapped to.
snap | target point that need to be snapped to |
source | point to snap (this bbox midpoint of the object closest to the mouse pointer) |
bounding | box of the active selection to snap |
Definition at line 549 of file distribution-snapper.cpp.
References Geom::GenericRect< C >::midpoint().
|
private |
Finds and stores the bounding boxes that are at equal distance from each other.
the | distance between the object that needs to be snapped and the first object in the sideways vectors. |
first | iterator of the sideways vector |
end | of the sideways vector |
vector | where the snapped bboxes will be stored |
equal | distance between consecutive vectors |
snapped | tolerance |
a | function pointer to the distance function |
level | of recursion - do not pass this while calling the function |
Definition at line 101 of file distribution-snapper.cpp.
References compare_double(), end, and result.
|
private |
Finds and snaps to points that is equidistant from surrounding bboxes.
interm | snap results |
source | point to snap |
bounding | box of the selection to snap |
unselected | nodes in case editing nodes (never used here, remove?) |
active | snap constraint |
projection | of the source point on the constraint (never used, remove?) |
Definition at line 304 of file distribution-snapper.cpp.
References always, c, compare_double(), distDown(), distLeft(), distRight(), distUp(), Inkscape::SnappedPoint::getBBoxes(), Inkscape::SnappedPoint::getDistributionDistance(), Inkscape::SnapCandidatePoint::getPoint(), Inkscape::SnappedPoint::getPoint(), Inkscape::SnapCandidatePoint::getSourceNum(), Inkscape::SnapCandidatePoint::getSourceType(), Geom::GenericRect< C >::min(), offset, IntermSnapResults::points, Inkscape::SNAPSOURCE_BBOX_MIDPOINT, Inkscape::SNAPTARGET_DISTRIBUTION_DOWN, Inkscape::SNAPTARGET_DISTRIBUTION_LEFT, Inkscape::SNAPTARGET_DISTRIBUTION_RIGHT, Inkscape::SNAPTARGET_DISTRIBUTION_UP, Inkscape::SNAPTARGET_DISTRIBUTION_X, Inkscape::SNAPTARGET_DISTRIBUTION_XY, Inkscape::SNAPTARGET_DISTRIBUTION_Y, Geom::Point::x(), and Geom::Point::y().
|
overridevirtual |
Reimplemented from Inkscape::Snapper.
Definition at line 585 of file distribution-snapper.cpp.
References c, Geom::GenericOptRect< C >::empty(), Inkscape::SnapCandidatePoint::getPoint(), Inkscape::SnapCandidatePoint::getSourceNum(), Geom::identity(), Inkscape::SNAPTARGET_ALIGNMENT_CATEGORY, and Inkscape::SNAPTARGET_DISTRIBUTION_CATEGORY.
|
staticprivate |
Definition at line 96 of file distribution-snapper.cpp.
References Geom::GenericRect< C >::max(), and Geom::GenericRect< C >::min().
Referenced by _snapEquidistantPoints().
|
staticprivate |
Definition at line 86 of file distribution-snapper.cpp.
References Geom::GenericRect< C >::max(), and Geom::GenericRect< C >::min().
Referenced by _snapEquidistantPoints().
|
staticprivate |
Definition at line 81 of file distribution-snapper.cpp.
References Geom::GenericRect< C >::max(), and Geom::GenericRect< C >::min().
Referenced by _snapEquidistantPoints().
|
staticprivate |
Definition at line 91 of file distribution-snapper.cpp.
References Geom::GenericRect< C >::max(), and Geom::GenericRect< C >::min().
Referenced by _snapEquidistantPoints().
|
overridevirtual |
Reimplemented from Inkscape::Snapper.
Definition at line 559 of file distribution-snapper.cpp.
References Geom::GenericOptRect< C >::empty(), Inkscape::SnapCandidatePoint::getPoint(), Inkscape::SnapCandidatePoint::getSourceNum(), Inkscape::SnapCandidatePoint::getSourceType(), Geom::identity(), Inkscape::SNAPSOURCE_BBOX_CATEGORY, Inkscape::SNAPTARGET_ALIGNMENT_CATEGORY, and Inkscape::SNAPTARGET_DISTRIBUTION_CATEGORY.
|
overridevirtual |
Implements Inkscape::Snapper.
Definition at line 616 of file distribution-snapper.cpp.
References Inkscape::Preferences::get(), and Inkscape::Preferences::getBool().
|
overridevirtual |
Implements Inkscape::Snapper.
Definition at line 621 of file distribution-snapper.cpp.
References SPDesktop::current_zoom().
|
overridevirtual |
Reimplemented from Inkscape::Snapper.
Definition at line 611 of file distribution-snapper.cpp.
|
private |
Definition at line 68 of file distribution-snapper.h.
Referenced by DistributionSnapper().
|
private |
Definition at line 66 of file distribution-snapper.h.
Referenced by DistributionSnapper().
|
private |
Definition at line 67 of file distribution-snapper.h.
Referenced by DistributionSnapper().
|
private |
Definition at line 69 of file distribution-snapper.h.
Referenced by DistributionSnapper().