diff options
Diffstat (limited to 'src/selection.h')
| -rw-r--r-- | src/selection.h | 158 |
1 files changed, 15 insertions, 143 deletions
diff --git a/src/selection.h b/src/selection.h index 91d033d58..8f43d51e7 100644 --- a/src/selection.h +++ b/src/selection.h @@ -5,7 +5,9 @@ * Lauris Kaplinski <lauris@kaplinski.com> * MenTaLguY <mental@rydia.net> * bulia byak <buliabyak@users.sf.net> + * Adrian Boguszewski * + * Copyright (C) 2016 Adrian Boguszewski * Copyright (C) 2004-2005 MenTaLguY * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2001-2002 Ximian, Inc. @@ -15,8 +17,6 @@ #include <vector> #include <map> -#include <list> -#include <set> #include <stddef.h> #include <sigc++/sigc++.h> @@ -27,11 +27,8 @@ #include "sp-item.h" #include "object-set.h" - class SPDesktop; class SPItem; -class SPBox3D; -class Persp3D; namespace Inkscape { class LayerModel; @@ -62,10 +59,10 @@ namespace Inkscape { */ class Selection : public Inkscape::GC::Managed<>, public Inkscape::GC::Finalized, - public Inkscape::GC::Anchored + public Inkscape::GC::Anchored, + public ObjectSet { public: - enum CompareSize { HORIZONTAL, VERTICAL, AREA }; /** * Constructs an selection object, bound to a particular * layer model @@ -98,12 +95,7 @@ public: */ SPObject *activeContext(); - /** - * Add an SPObject to the set of selected objects. - * - * @param obj the SPObject to add - */ - void add(SPObject *obj, bool persist_selection_context = false); + using ObjectSet::add; /** * Add an XML node's SPObject to the set of selected objects. @@ -130,21 +122,7 @@ public: set(_objectForXMLNode(repr)); } - /** - * Removes an item from the set of selected objects. - * - * It is ok to call this method for an unselected item. - * - * @param item the item to unselect - */ - void remove(SPObject *obj); - - /** - * Removes an item if selected, adds otherwise. - * - * @param item the item to unselect - */ - void toggle(SPObject *obj); + using ObjectSet::remove; /** * Removes an item from the set of selected objects. @@ -153,21 +131,9 @@ public: * * @param repr the xml node of the item to remove */ - void remove(XML::Node *repr) { remove(_objectForXMLNode(repr)); } - - /** - * Selects exactly the specified objects. - * - * @param objs the objects to select - */ - void setList(std::vector<SPItem*> const &objs); - - /** - * Adds the specified objects to selection, without deselecting first. - * - * @param objs the objects to select - */ - void addList(std::vector<SPItem*> const &objs); + void remove(XML::Node *repr) { + remove(_objectForXMLNode(repr)); + } /** * Clears the selection and selects the specified objects. @@ -176,33 +142,7 @@ public: */ void setReprList(std::vector<XML::Node*> const &reprs); - /** Add items from an STL iterator range to the selection. - * \param from the begin iterator - * \param to the end iterator - */ - template <typename InputIterator> - void add(InputIterator from, InputIterator to) { - while (from != to) { - _add(*from); - ++from; - } - _emitChanged(); - } - - /** - * Unselects all selected objects.. - */ - void clear(); - - /** - * Returns true if no items are selected. - */ - bool isEmpty(); - - /** - * Returns true if the given object is selected. - */ - bool includes(SPObject *obj); + using ObjectSet::includes; /** * Returns true if the given item is selected. @@ -212,80 +152,21 @@ public: } /** - * Returns a single selected object. - * - * @return NULL unless exactly one object is selected - */ - SPObject *single(); - - /** - * Returns a single selected item. - * - * @return NULL unless exactly one object is selected - */ - SPItem *singleItem(); - - /** - * Returns the smallest item from this selection. - */ - SPItem *smallestItem(CompareSize compare); - - /** - * Returns the largest item from this selection. - */ - SPItem *largestItem(CompareSize compare); - - /** * Returns a single selected object's xml node. * * @return NULL unless exactly one object is selected */ XML::Node *singleRepr(); - /** Returns the list of selected objects. */ - std::vector<SPObject*> list(); - /** Returns the list of selected SPItems. */ - std::vector<SPItem*> itemList(); /** Returns a list of the xml nodes of all selected objects. */ - /// \todo only returns reprs of SPItems currently; need a separate - /// method for that std::vector<XML::Node*> reprList(); - /** Returns a list of all perspectives which have a 3D box in the current selection. - (these may also be nested in groups) */ - std::list<Persp3D *> const perspList(); - - /** - * Returns a list of all 3D boxes in the current selection which are associated to @c - * persp. If @c pers is @c NULL, return all selected boxes. - */ - std::list<SPBox3D *> const box3DList(Persp3D *persp = NULL); - /** Returns the number of layers in which there are selected objects. */ size_t numberOfLayers(); /** Returns the number of parents to which the selected objects belong. */ size_t numberOfParents(); - /** Returns the bounding rectangle of the selection. */ - Geom::OptRect bounds(SPItem::BBoxType type) const; - Geom::OptRect visualBounds() const; - Geom::OptRect geometricBounds() const; - - /** - * Returns either the visual or geometric bounding rectangle of the selection, based on the - * preferences specified for the selector tool - */ - Geom::OptRect preferredBounds() const; - - /// Returns the bounding rectangle of the selectionin document coordinates. - Geom::OptRect documentBounds(SPItem::BBoxType type) const; - - /** - * Returns the rotation/skew center of the selection. - */ - boost::optional<Geom::Point> center() const; - /** * Compute the list of points in the selection that are to be considered for snapping from. * @@ -332,6 +213,11 @@ public: return _modified_signal.slots().insert(_modified_signal.slots().begin(), slot); } +protected: + void _emitSignals(); + void _connectSignals(SPObject* object); + void _releaseSignals(SPObject* object); + private: /** no copy. */ Selection(Selection const &); @@ -347,25 +233,11 @@ private: void _emitModified(unsigned int flags); /** Issues changed selection signal. */ void _emitChanged(bool persist_selection_context = false); - /** clears the selection (without issuing a notification). */ - void _clear(); - /** adds an object (without issuing a notification). */ - void _add(SPObject *obj); - /** removes an object (without issuing a notification). */ - void _remove(SPObject *obj); /** returns the SPObject corresponding to an xml node (if any). */ SPObject *_objectForXMLNode(XML::Node *repr) const; /** Releases an active layer object that is being removed. */ void _releaseContext(SPObject *obj); - ObjectSet _selectionSet; - - void add_3D_boxes_recursively(SPObject *obj); - void remove_3D_boxes_recursively(SPObject *obj); - SPItem *_sizeistItem(bool sml, CompareSize compare); - - std::list<SPBox3D *> _3dboxes; - LayerModel *_layers; GC::soft_ptr<SPDesktop> _desktop; SPObject* _selection_context; |
