15#include <boost/range/adaptor/filtered.hpp>
16#include <boost/range/adaptor/transformed.hpp>
18#include <sigc++/sigc++.h>
39 g_return_val_if_fail(
object !=
nullptr,
false);
69 g_return_val_if_fail(
object !=
nullptr,
false);
94 g_return_val_if_fail(
object !=
nullptr,
false);
112 g_return_val_if_fail(
object !=
nullptr,
nullptr);
114 while (o !=
nullptr) {
134 while (o !=
nullptr) {
145 for (
auto&
child: object->children) {
185 while (o->
parent !=
nullptr) {
202 while (o->
parent !=
nullptr) {
239 if (is<SPItem>(obj)) {
240 return cast<SPItem>(obj);
267 gdouble max = sml ? 1e18 : 0;
272 if (!obox || obox.
empty()) {
296 return obj ? obj->
getRepr() :
nullptr;
307#ifdef _LIBCPP_VERSION
310 auto const n = std::vector<Inkscape::XML::Node *>(nodes.begin(), nodes.end());
312 auto const& n = nodes;
337 for (
auto iter = list.rbegin(); iter != list.rend(); ++iter) {
341 assert(obj ==
document()->getObjectById((*iter)->attribute(
"id")));
354 bool idAssigned =
false;
427 if (
items.empty())
return bbox;
449 if (!
items.empty()) {
457 return bbox->midpoint();
459 return std::optional<Geom::Point>();
464 std::list<Persp3D *> pl;
466 Persp3D *persp = _3dboxe->get_perspective();
467 if (std::find(pl.begin(), pl.end(), persp) == pl.end())
474 std::list<SPBox3D *> boxes;
477 if (persp == box->get_perspective()) {
478 boxes.push_back(box);
490 for (
auto box : boxes) {
498 for (
auto box : boxes) {
499 std::list<SPBox3D *>::iterator b = std::find(
_3dboxes.begin(),
_3dboxes.end(), box);
501 g_warning (
"Warning! Trying to remove unselected box from selection.");
void unionWith(CRect const &b)
Enlarge the rectangle to contain the argument.
bool empty() const
Check for emptiness.
C area() const
Compute the rectangle's area.
C height() const
Get the vertical extent of the rectangle.
C width() const
Get the horizontal extent of the rectangle.
Axis-aligned rectangle that can be empty.
Axis aligned, non-empty rectangle.
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.
SPObject * includesAncestor(SPObject *object)
Returns ancestor if the given object has ancestor selected.
void _remove(SPObject *object)
SPItem * lastItem() const
Returns the last selected item, returns nullptr if no items selected.
SPDesktop * desktop()
Returns the desktop the selection is bound to.
bool remove(SPObject *object)
Removes an item from the set of selected objects.
SPItemRange items()
Returns a range of selected SPItems.
void _disconnect(SPObject *object)
Geom::OptRect preferredBounds() const
Returns either the visual or geometric bounding rectangle of the selection, based on the preferences ...
Geom::OptRect bounds(SPItem::BBoxType type) const
Returns the bounding rectangle of the selection.
virtual void _remove3DBoxesRecursively(SPObject *obj)
bool add(SPObject *object, bool nosignal=false)
Add an SPObject to the set of selected objects.
XMLNodeRange xmlNodes()
Returns a range of the xml nodes of all selected objects.
void setReprList(std::vector< XML::Node * > const &list)
Selects the objects with the same IDs as those in list.
SPItem * largestItem(CompareSize compare)
Returns the largest item from this selection.
Geom::OptRect documentPreferredBounds() const
Returns either the visual or geometric bounding rectangle of selection in document coordinates based ...
std::list< SPBox3D * > _3dboxes
SPItem * _sizeistItem(bool sml, CompareSize compare)
std::unordered_map< SPObject *, sigc::connection > _releaseConnections
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)
SPObject * single()
Returns a single selected object.
bool isEmpty()
Returns true if no items are selected.
std::map< SPObject *, SiblingState > _sibling_state
void set(SPObject *object, bool persist_selection_context=false)
Set the selection to a single specific object.
Geom::OptRect documentBounds(SPItem::BBoxType type) const
int size()
Returns size of the selection.
SPDocument * document()
Returns the document the selection is bound to.
void _removeAncestorsFromSet(SPObject *object)
bool _anyAncestorIsInSet(SPObject *object)
SPItem * firstItem() const
Returns the first selected item, returns nullptr if no items selected.
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.
SPObjectRange objects()
Returns the list of selected objects.
virtual void _connectSignals(SPObject *object)
XML::Node * singleRepr()
Returns a single selected object's xml node.
XML::Node * topRepr() const
The top-most item, or NULL if the selection is empty.
MultiIndexContainer _container
Geom::OptRect visualBounds() const
SPObject * _getMutualAncestor(SPObject *object)
std::list< Persp3D * > const perspList()
Returns a list of all perspectives which have a 3D box in the current selection.
static Preferences * get()
Access the singleton Preferences object.
Interface for refcounted XML nodes.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
static std::list< SPBox3D * > extract_boxes(SPObject *obj)
To do: update description of desktop.
SPDocument * getDocument() const
Typed SVG document implementation.
const Geom::Affine & doc2dt() const
Document to desktop coordinate transformation.
SPObject * getObjectById(std::string const &id) const
void setModifiedSinceSave(bool const modified=true)
Indicate to the user if the document has been modified since the last save by displaying a "*" in fro...
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
Base class for visual SVG elements.
Geom::OptRect documentPreferredBounds() const
Geom::OptRect documentBounds(BBoxType type) const
Geom::Point getCenter(bool ensure_uptodate=true) const
Geom::OptRect desktopVisualBounds() const
Get item's visual bbox in desktop coordinate system.
Geom::OptRect desktopGeometricBounds() const
Get item's geometric bbox in desktop coordinate system.
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
Geom::OptRect visualBounds(Geom::Affine const &transform=Geom::identity(), bool wfilter=true, bool wclip=true, bool wmask=true) const
Get item's visual bounding box in this item's coordinate system.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
char const * getId() const
Returns the objects current ID string.
std::string generate_unique_id(char const *default_id=nullptr) const
Generate a document-wide unique id for this object.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
Editable view implementation.
static char const *const parent
Inkscape::XML::Node * node
Helper class to stream background task notifications as a series of messages.
boost::any_range< SPObject *, boost::random_access_traversal_tag, SPObject *const &, std::ptrdiff_t > SPObjectRange
Singleton class to access the preferences file in a convenient way.
bool sp_repr_compare_position_bool(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second)