14#ifndef INKSCAPE_PROTOTYPE_OBJECTSET_H
15#define INKSCAPE_PROTOTYPE_OBJECTSET_H
17#include <unordered_map>
20#include <boost/multi_index_container.hpp>
21#include <boost/multi_index/identity.hpp>
22#include <boost/multi_index/sequenced_index.hpp>
23#include <boost/multi_index/hashed_index.hpp>
24#include <boost/multi_index/random_access_index.hpp>
25#include <boost/range/adaptor/filtered.hpp>
26#include <boost/range/adaptor/transformed.hpp>
27#include <boost/range/sub_range.hpp>
28#include <boost/range/any_range.hpp>
29#include <boost/type_traits.hpp>
30#include <boost/utility/enable_if.hpp>
32#include <sigc++/connection.h>
71inline constexpr auto object_to_node = [] (
SPObject *obj) {
72 return obj->getRepr();
77typedef boost::multi_index_container<
79 boost::multi_index::indexed_by<
80 boost::multi_index::sequenced<>,
81 boost::multi_index::random_access<
82 boost::multi_index::tag<random_access>>,
83 boost::multi_index::hashed_unique<
84 boost::multi_index::tag<hashed>,
85 boost::multi_index::identity<SPObject*>>
88typedef boost::any_range<
90 boost::random_access_traversal_tag,
120 bool add(
SPObject *
object,
bool nosignal =
false);
133 template <
typename InputIterator>
134 void add(InputIterator from, InputIterator to) {
135 for(
auto it = from; it != to; ++it) {
168 void set(
SPObject *
object,
bool persist_selection_context =
false);
232 | boost::adaptors::filtered(is<SPItem>)
233 | boost::adaptors::transformed(cast_unsafe<SPItem>));
238 return {i.begin(), i.end()};
244 | boost::adaptors::filtered(is<SPGroup>)
245 | boost::adaptors::transformed(cast_unsafe<SPGroup>));
251 | boost::adaptors::filtered(is<SPItem>)
252 | boost::adaptors::transformed(object_to_node));
273 typename boost::enable_if<boost::is_base_of<SPObject, T>,
void>::type
286 void setReprList(std::vector<XML::Node*>
const &list);
300 typename boost::enable_if<boost::is_base_of<SPObject, T>,
void>::type
302 for (
auto obj: objs) {
316 typename boost::enable_if<boost::is_base_of<SPObject, T>,
void>::type
318 for (
auto obj: objs) {
348 std::optional<Geom::Point>
center()
const;
377 void duplicate(
bool suppressDone =
false,
bool duplicateLayer =
false);
378 void clone(
bool skip_undo =
false);
385 bool unlink(
const bool skip_undo =
false,
const bool silent =
false);
391 bool unlinkRecursive(
const bool skip_undo =
false,
const bool force =
false,
const bool silent =
false);
398 void ungroup(
bool skip_undo =
false);
403 void stackUp(
bool skip_undo =
false);
404 void raise(
bool skip_undo =
false);
407 void lower(
bool skip_undo =
false);
419 void pasteSize(
bool apply_x,
bool apply_y);
425 void combine(
bool skip_undo =
false,
bool silent =
false);
426 void breakApart(
bool skip_undo =
false,
bool overlapping =
true,
bool silent =
false);
427 void toCurves(
bool skip_undo =
false,
bool clonesjustunlink =
false);
437 void pathUnion (
bool skip_undo =
false,
bool silent =
false);
438 void pathIntersect(
bool skip_undo =
false,
bool silent =
false);
439 void pathDiff (
bool skip_undo =
false,
bool silent =
false);
440 void pathSymDiff (
bool skip_undo =
false,
bool silent =
false);
441 void pathCut (
bool skip_undo =
false,
bool silent =
false);
442 void pathSlice (
bool skip_undo =
false,
bool silent =
false);
450 void tile(
bool apply =
true);
453 void setMask(
bool apply_clip_path,
bool apply_to_layer,
bool remove_original);
455 void unsetMask(
const bool apply_clip_path,
const bool delete_helper_group,
bool remove_original);
465 void applyAffine(
Geom::Affine const &affine,
bool set_i2d=
true,
bool compensate=
true,
bool adjust_transf_center=
true);
474 void move(
double dx,
double dy);
476 void move(
double dx,
double dy,
bool rotated);
477 void move(
double dx,
double dy,
bool rotated,
bool screen);
478 void moveScreen(
double dx,
double dy,
bool rotated);
481 bool fitCanvas(
bool with_margins,
bool skip_undo =
false);
492 virtual void _emitChanged(
bool persist_selection_context =
false);
511 void _pathBoolOp(
BooleanOp bop,
char const *icon_name,
char const *description,
bool skip_undo,
bool silent);
TODO: insert short description here.
3x3 matrix representing an affine transformation.
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
void enforceIds()
Assign IDs to selected objects that don't have an ID attribute Checks if the object's id attribute is...
SPItem * smallestItem(CompareSize compare)
Returns the smallest item from this selection.
void moveScreen(double dx, double dy)
SPObject * includesAncestor(SPObject *object)
Returns ancestor if the given object has ancestor selected.
void pasteSize(bool apply_x, bool apply_y)
void _remove(SPObject *object)
SPGroupRange groups()
Returns a range of selected groups.
Inkscape::XML::Node * group(bool is_anchor=false)
void stackDown(bool skip_undo=false)
void pasteSizeSeparately(bool apply_x, bool apply_y)
SPItem * lastItem() const
Returns the last selected item, returns nullptr if no items selected.
SPDesktop * desktop()
Returns the desktop the selection is bound to.
void toNextLayer(bool skip_undo=false)
bool remove(SPObject *object)
Removes an item from the set of selected objects.
bool unlink(const bool skip_undo=false, const bool silent=false)
Unlink all directly selected clones.
void breakApart(bool skip_undo=false, bool overlapping=true, bool silent=false)
void move(double dx, double dy)
SPItemRange items()
Returns a range of selected SPItems.
void pathUnion(bool skip_undo=false, bool silent=false)
void removeLPESRecursive(bool keep_paths)
void _disconnect(SPObject *object)
void unsetMask(const bool apply_clip_path, const bool delete_helper_group, bool remove_original)
Geom::OptRect preferredBounds() const
Returns either the visual or geometric bounding rectangle of the selection, based on the preferences ...
void cloneOriginalPathLPE(bool allow_transforms=false, bool sync=false, bool skip_undo=false)
This applies the Fill Between Many LPE, and has it refer to the selection.
void rotateRelative(const Geom::Point &, double)
virtual void _remove3DBoxesRecursively(SPObject *obj)
void pathCut(bool skip_undo=false, bool silent=false)
void removePathTransforms()
bool add(SPObject *object, bool nosignal=false)
Add an SPObject to the set of selected objects.
boost::enable_if< boost::is_base_of< SPObject, T >, void >::type setList(const std::vector< T * > &objs)
Selects exactly the specified objects.
XMLNodeRange xmlNodes()
Returns a range of the xml nodes of all selected objects.
void raiseToTop(bool skip_undo=false)
void stackUp(bool skip_undo=false)
void setReprList(std::vector< XML::Node * > const &list)
Selects the objects with the same IDs as those in list.
void applyAffine(Geom::Affine const &affine, bool set_i2d=true, bool compensate=true, bool adjust_transf_center=true)
Apply matrix to the selection.
SPItem * largestItem(CompareSize compare)
Returns the largest item from this selection.
void add(InputIterator from, InputIterator to)
Add items from an STL iterator range to the selection.
bool strokesToPaths(bool legacy=false, bool skip_undo=false)
Geom::OptRect documentPreferredBounds() const
Returns either the visual or geometric bounding rectangle of selection in document coordinates based ...
void pathDiff(bool skip_undo=false, bool silent=false)
std::list< SPBox3D * > _3dboxes
void moveRelative(const Geom::Point &move, bool compensate=true)
Geom::Affine _last_affine
void duplicate(bool suppressDone=false, bool duplicateLayer=false)
SPItem * _sizeistItem(bool sml, CompareSize compare)
void setDocument(SPDocument *doc)
void pathIntersect(bool skip_undo=false, bool silent=false)
void toMarker(bool apply=true)
std::unordered_map< SPObject *, sigc::connection > _releaseConnections
void pathSymDiff(bool skip_undo=false, bool silent=false)
void toPrevLayer(bool skip_undo=false)
void reapplyAffine()
Reapply the same transform again.
std::optional< Geom::Point > center() const
Returns the rotation/skew center of the selection.
void _add(SPObject *object)
Geom::OptRect strokedBounds() const
void clear()
Unselects all selected objects.
virtual void _emitChanged(bool persist_selection_context=false)
std::list< SPBox3D * > const box3DList(Persp3D *persp=nullptr)
Returns a list of all 3D boxes in the current selection which are associated to persp.
Geom::OptRect geometricBounds() const
virtual void _add3DBoxesRecursively(SPObject *obj)
decltype(MultiIndexContainer().get< random_access >()|boost::adaptors::filtered(is< SPItem >)|boost::adaptors::transformed(cast_unsafe< SPItem >)) SPItemRange
virtual void _releaseSignals(SPObject *object)
ObjectSet & operator=(ObjectSet const &)=delete
void ungroup_all(bool skip_undo=false)
Keep ungrouping until there are no more groups.
boost::enable_if< boost::is_base_of< SPObject, T >, void >::type addList(const std::vector< T * > &objs)
Adds the specified objects to selection, without deselecting first.
void deleteItems(bool skip_undo=false)
SPObject * single()
Returns a single selected object.
decltype(MultiIndexContainer().get< random_access >()|boost::adaptors::filtered(is< SPGroup >)|boost::adaptors::transformed(cast_unsafe< SPGroup >)) SPGroupRange
void ungroup(bool skip_undo=false)
void skewRelative(const Geom::Point &, double, double)
void toLPEItems()
Converts the selected items to LPEItems if they are not already so; e.g.
bool isEmpty()
Returns true if no items are selected.
void tile(bool apply=true)
std::map< SPObject *, SiblingState > _sibling_state
Geom::OptRect documentBounds(SPItem::BBoxType type) const
int size()
Returns size of the selection.
void scaleRelative(const Geom::Point &, const Geom::Scale &)
SPDocument * document()
Returns the document the selection is bound to.
void _removeAncestorsFromSet(SPObject *object)
void raise(bool skip_undo=false)
bool _anyAncestorIsInSet(SPObject *object)
SPItem * firstItem() const
Returns the first selected item, returns nullptr if no items selected.
void clearSiblingStates()
void toCurves(bool skip_undo=false, bool clonesjustunlink=false)
void combine(bool skip_undo=false, bool silent=false)
void lowerToBottom(bool skip_undo=false)
void lower(bool skip_undo=false)
void toggle(SPObject *obj)
Removes an item if selected, adds otherwise.
void _removeDescendantsFromSet(SPObject *object)
bool includes(SPObject *object, bool anyAncestor=false)
Returns true if the given object is selected.
SPItem * singleItem()
Returns a single selected item.
void setScaleAbsolute(double, double, double, double)
bool unlinkRecursive(const bool skip_undo=false, const bool force=false, const bool silent=false)
Recursively unlink any clones present in the current selection, including clones which are used to cl...
ObjectSet(SPDocument *doc)
SPObjectRange objects()
Returns the list of selected objects.
void insertSiblingState(SPObject *object, SiblingState state)
decltype(MultiIndexContainer().get< random_access >()|boost::adaptors::filtered(is< SPItem >)|boost::adaptors::transformed(object_to_node)) XMLNodeRange
virtual void _connectSignals(SPObject *object)
void clone(bool skip_undo=false)
void toLayer(SPObject *layer)
Move selection to group moveto, after the last child of moveto (if it has any children).
void setMask(bool apply_clip_path, bool apply_to_layer, bool remove_original)
Creates a mask or clipPath from selection.
XML::Node * singleRepr()
Returns a single selected object's xml node.
bool simplifyPaths(bool skip_undo=false)
std::vector< SPItem * > items_vector()
bool fitCanvas(bool with_margins, bool skip_undo=false)
XML::Node * topRepr() const
The top-most item, or NULL if the selection is empty.
MultiIndexContainer _container
void _pathBoolOp(BooleanOp bop, char const *icon_name, char const *description, bool skip_undo, bool silent)
Geom::OptRect visualBounds() const
void pathSlice(bool skip_undo=false, bool silent=false)
boost::enable_if< boost::is_base_of< SPObject, T >, void >::type removeList(const std::vector< T * > &objs)
Remove the specified objects from selection.
SPObject * _getMutualAncestor(SPObject *object)
std::list< Persp3D * > const perspList()
Returns a list of all perspectives which have a 3D box in the current selection.
ObjectSet(ObjectSet const &)=delete
void fillBetweenMany()
Creates a linked fill between all the objects in the current selection using the "Fill Between Many" ...
SiblingState getSiblingState(SPItem *item)
Associates the given SPItem with a SiblingState enum Needed for handling special cases while transfor...
Interface for refcounted XML nodes.
To do: update description of desktop.
Typed SVG document implementation.
Base class for visual SVG elements.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
Inkscape::XML::Node * node
Helper class to stream background task notifications as a series of messages.
boost::multi_index_container< SPObject *, boost::multi_index::indexed_by< boost::multi_index::sequenced<>, boost::multi_index::random_access< boost::multi_index::tag< random_access > >, boost::multi_index::hashed_unique< boost::multi_index::tag< hashed >, boost::multi_index::identity< SPObject * > > > > MultiIndexContainer
ObjectSet::SPGroupRange SPGroupRange
ObjectSet::XMLNodeRange XMLNodeRange
ObjectSet::SPItemRange SPItemRange
boost::any_range< SPObject *, boost::random_access_traversal_tag, SPObject *const &, std::ptrdiff_t > SPObjectRange
static T clip(T const &v, T const &a, T const &b)
SiblingState
SiblingState enums are used to associate the current state while grabbing objects.
@ SIBLING_TEXT_SHAPE_INSIDE
@ SIBLING_TEXT_FLOW_FRAME
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.