14#ifndef INKSCAPE_PROTOTYPE_OBJECTSET_H
15#define INKSCAPE_PROTOTYPE_OBJECTSET_H
18#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>
71 return is<SPItem>(obj);
77 return is<SPGroup>(obj);
84 return cast<SPItem>(obj);
98 return cast<SPGroup>(obj);
102typedef boost::multi_index_container<
104 boost::multi_index::indexed_by<
105 boost::multi_index::sequenced<>,
106 boost::multi_index::random_access<
107 boost::multi_index::tag<random_access>>,
108 boost::multi_index::hashed_unique<
109 boost::multi_index::tag<hashed>,
110 boost::multi_index::identity<SPObject*>>
113typedef boost::any_range<
115 boost::random_access_traversal_tag,
145 bool add(
SPObject *
object,
bool nosignal =
false);
158 template <
typename InputIterator>
159 void add(InputIterator from, InputIterator to) {
160 for(
auto it = from; it != to; ++it) {
193 void set(
SPObject *
object,
bool persist_selection_context =
false);
257 | boost::adaptors::filtered(
is_item())
263 return {i.begin(), i.end()};
269 | boost::adaptors::filtered(
is_group())
276 | boost::adaptors::filtered(
is_item())
298 typename boost::enable_if<boost::is_base_of<SPObject, T>,
void>::type
311 void setReprList(std::vector<XML::Node*>
const &list);
325 typename boost::enable_if<boost::is_base_of<SPObject, T>,
void>::type
327 for (
auto obj: objs) {
359 std::optional<Geom::Point>
center()
const;
388 void duplicate(
bool suppressDone =
false,
bool duplicateLayer =
false);
389 void clone(
bool skip_undo =
false);
396 bool unlink(
const bool skip_undo =
false,
const bool silent =
false);
402 bool unlinkRecursive(
const bool skip_undo =
false,
const bool force =
false,
const bool silent =
false);
409 void ungroup(
bool skip_undo =
false);
414 void stackUp(
bool skip_undo =
false);
415 void raise(
bool skip_undo =
false);
418 void lower(
bool skip_undo =
false);
430 void pasteSize(
bool apply_x,
bool apply_y);
436 void combine(
bool skip_undo =
false,
bool silent =
false);
437 void breakApart(
bool skip_undo =
false,
bool overlapping =
true,
bool silent =
false);
438 void toCurves(
bool skip_undo =
false,
bool clonesjustunlink =
false);
448 void pathUnion (
bool skip_undo =
false,
bool silent =
false);
449 void pathIntersect(
bool skip_undo =
false,
bool silent =
false);
450 void pathDiff (
bool skip_undo =
false,
bool silent =
false);
451 void pathSymDiff (
bool skip_undo =
false,
bool silent =
false);
452 void pathCut (
bool skip_undo =
false,
bool silent =
false);
453 void pathSlice (
bool skip_undo =
false,
bool silent =
false);
461 void tile(
bool apply =
true);
464 void setMask(
bool apply_clip_path,
bool apply_to_layer,
bool remove_original);
466 void unsetMask(
const bool apply_clip_path,
const bool delete_helper_group,
bool remove_original);
476 void applyAffine(
Geom::Affine const &affine,
bool set_i2d=
true,
bool compensate=
true,
bool adjust_transf_center=
true);
485 void move(
double dx,
double dy);
487 void move(
double dx,
double dy,
bool rotated);
488 void move(
double dx,
double dy,
bool rotated,
bool screen);
489 void moveScreen(
double dx,
double dy,
bool rotated);
492 bool fitCanvas(
bool with_margins,
bool skip_undo =
false);
503 virtual void _emitChanged(
bool persist_selection_context =
false);
522 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
decltype(MultiIndexContainer().get< random_access >()|boost::adaptors::filtered(is_item())|boost::adaptors::transformed(object_to_item())) SPItemRange
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)
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.
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...
SPObjectRange objects()
Returns the list of selected objects.
void insertSiblingState(SPObject *object, SiblingState state)
virtual void _connectSignals(SPObject *object)
decltype(MultiIndexContainer().get< random_access >()|boost::adaptors::filtered(is_item())|boost::adaptors::transformed(object_to_node())) XMLNodeRange
void clone(bool skip_undo=false)
decltype(MultiIndexContainer().get< random_access >()|boost::adaptors::filtered(is_group())|boost::adaptors::transformed(object_to_group())) SPGroupRange
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)
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 * getRepr()
Returns the XML representation of tree.
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.
bool operator()(SPObject *obj)
bool operator()(SPObject *obj)
SPGroup * operator()(SPObject *obj) const
SPItem * operator()(SPObject *obj) const
XML::Node * operator()(SPObject *obj) const