25#include <glibmm/i18n.h>
56 g_source_remove(
_idle);
77 guint flags = selection->
_flags;
101 for (
auto this_item : this->
items()) {
102 if (page != pm.getPageFor(this_item,
true)) {
113 if (persist_selection_context) {
166 std::vector<Inkscape::SnapCandidatePoint> p;
168 if (snapprefs !=
nullptr){
172 for (
auto iter =
items.begin(); iter !=
items.end(); ++iter) {
173 SPItem *this_item = *iter;
189 constexpr double epsilon = 1e-12;
206 double const max_len = bbox->maxExtent();
207 if (max_len + amount <= 1e-3) {
210 amount = 1.0 + amount / max_len;
217 ((amount > 0) ?
"selector:grow:larger" :
"selector:grow:smaller" ),
218 ((amount > 0) ? _(
"Grow") : _(
"Shrink")), INKSCAPE_ICON(
"tool-pointer"));
231 if (
has_anchor && (actionkey ==
"selector:rotate:ccw" || actionkey ==
"selector:rotate:cw")) {
236 angle_degrees = d->yaxisdir() ? angle_degrees : -angle_degrees;
250 angle_degrees = 180 * atan2(angle_degrees / zoom, r) / M_PI;
258 if (angle_degrees == 90.0) {
260 }
else if (angle_degrees == -90.0) {
264 ( ( angle_degrees > 0 )?
"selector:rotate:ccw":
"selector:rotate:cw" ),
265 _(
"Rotate"), INKSCAPE_ICON(
"tool-pointer"));
272 g_return_val_if_fail(repr !=
nullptr, NULL);
280 std::set<SPObject*> layers;
281 for (
auto iter =
items.begin(); iter !=
items.end(); ++iter) {
283 layers.insert(layer);
286 return layers.size();
291 std::set<SPObject*> parents;
292 for (
auto iter =
items.begin(); iter !=
items.end(); ++iter) {
296 return parents.size();
312 for (
auto const *
const item :
items()) {
321 for (
auto const point : tool->_selected_nodes->_points_list) {
326 auto const &nodeList =
node->nodeList();
327 auto const &subpathList = nodeList.subpathList();
331 bool found_sp =
false;
332 for (
auto i = subpathList.begin(), e = subpathList.end(); i != e; ++i, ++sp) {
333 if (&**i == &nodeList) {
341 bool found_nl =
false;
342 for (
auto j = nodeList.begin(), e = nodeList.end(); j != e; ++j, ++nl) {
349 if (!(found_nl && found_sp)) {
350 g_warning(
"Something went wrong while trying to get node info. Please report a bug.");
354 if (
auto id = subpathList.pm().item()->getId()) {
377 std::vector<SPItem *> new_selection;
381 new_selection.push_back(
item);
386 add(new_selection.begin(), new_selection.end());
387 new_selection.clear();
393 auto const point = !cps->_points_list.empty() ? cps->_points_list.front() :
nullptr;
400 auto const &sp =
node->nodeList().subpathList();
403 for (
auto j = sp.begin(); j != sp.end(); ++j, ++sp_count) {
404 if (sp_count != node_state.subpath_index)
408 for (
auto k = (*j)->begin(); k != (*j)->end(); ++k, ++nt_count) {
409 if (nt_count == node_state.node_index) {
410 cps->insert(k.ptr());
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
static void maybeDone(SPDocument *document, const gchar *keyconst, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
static void resetKey(SPDocument *document)
SPObject * layerForObject(SPObject *object)
Return layer that contains object.
void setCurrentLayer(SPObject *object, bool clear=false)
Sets the current layer of the desktop.
SPGroup * currentLayer() const
Returns current top layer.
SPDesktop * desktop()
Returns the desktop the selection is bound to.
SPItemRange items()
Returns a range of selected SPItems.
void rotateRelative(const Geom::Point &, double)
std::optional< Geom::Point > center() const
Returns the rotation/skew center of the selection.
void clear()
Unselects all selected objects.
virtual void _emitChanged(bool persist_selection_context=false)
bool isEmpty()
Returns true if no items are selected.
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.
SPItem * firstItem() const
Returns the first selected item, returns nullptr if no items selected.
SPItem * singleItem()
Returns a single selected item.
Geom::OptRect visualBounds() const
bool selectPage(SPPage *page)
Set the given page as the selected page.
The set of selected SPObjects for a given document and layer model.
SPObject * _selection_context
void _releaseSignals(SPObject *object) override
sigc::scoped_connection _context_release_connection
void add(XML::Node *repr)
Add an XML node's SPObject to the set of selected objects.
sigc::signal< void(Selection *, unsigned)> _modified_signal
std::vector< Inkscape::SnapCandidatePoint > getSnapPoints(SnapPreferences const *snapprefs) const
Compute the list of points in the selection that are to be considered for snapping from.
void _releaseContext(SPObject *obj)
Releases an active layer object that is being removed.
void setAnchor(double x, double y, bool set=true)
Set the anchor point of the selection, used for telling it how transforms should be anchored against.
std::unordered_map< SPObject *, sigc::scoped_connection > _modified_connections
SPObject * activeContext()
Returns active layer for selection (currentLayer or its parent).
void _connectSignals(SPObject *object) override
size_t numberOfLayers()
Returns the number of layers in which there are selected objects.
Geom::Point _previous_rotate_anchor
void _emitChanged(bool persist_selection_context=false) override
Issues changed selection signal.
static int _emit_modified(Selection *selection)
Issues modification notification signals.
void rotateAnchored(double angle_degrees, double zoom=1.0)
Rotate the selection, anchoring it against the center, or a selected anchor.
SelectionState getState()
Returns the current selection state including selected objects and nodes.
void scaleAnchored(double amount, bool fixed=true)
Scale the selection, anchoring it against the center, or a selected anchor.
void _emitModified(unsigned int flags)
Issues modified selection signal.
void setState(SelectionState const &state)
Restores a selection state previously obtained from getState()
size_t numberOfParents()
Returns the number of parents to which the selected objects belong.
void _schedule_modified(SPObject *obj, unsigned int flags)
Schedules an item modification signal to be sent.
Selection(SPDesktop *desktop)
Constructs an selection object, bound to a particular layer model.
sigc::signal< void(Selection *)> _changed_signal
SPObject * _objectForXMLNode(XML::Node *repr) const
returns the SPObject corresponding to an xml node (if any).
Storing of snapping preferences.
void setTargetSnappable(Inkscape::SnapTargetType const target, bool enabled)
bool isTargetSnappable(Inkscape::SnapTargetType const target) const
void selectAll()
Select all points that this selection can contain.
Interface for refcounted XML nodes.
virtual char const * attribute(char const *key) const =0
Get the string representation of a node's attribute.
To do: update description of desktop.
Inkscape::UI::Tools::ToolBase * getTool() const
Inkscape::LayerManager & layerManager()
Typed SVG document implementation.
SPObject * getObjectById(std::string const &id) const
Glib::ustring const & action_key() const
Inkscape::PageManager & getPageManager()
SPDefs * getDefs()
Return the main defs object for the document.
SPObject * getObjectByRepr(Inkscape::XML::Node *repr) const
Base class for visual SVG elements.
Geom::Point getCenter(bool ensure_uptodate=true) const
void getSnappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs=nullptr) const
SPObject is an abstract base class of all of the document nodes at the SVG document level.
char const * getId() const
Returns the objects current ID string.
sigc::connection connectRelease(sigc::slot< void(SPObject *)> slot)
Connects to the release request signal.
bool isAncestorOf(SPObject const *object) const
True if object is non-NULL and this is some in/direct parent of object.
sigc::connection connectModified(sigc::slot< void(SPObject *, unsigned int)> slot)
Connects to the modification notification signal.
Control point selection - stores a set of control points and applies transformations to them.
Editable view implementation.
static char const *const parent
TODO: insert short description here.
Macro for icon names used in Inkscape.
Inkscape::XML::Node * node
SBasis L2(D2< SBasis > const &a, unsigned k)
Coord LInfty(Point const &p)
Helper class to stream background task notifications as a series of messages.
@ SNAPSOURCE_ROTATION_CENTER
@ SNAPTARGET_ROTATION_CENTER
Path manipulator - a component that edits a single path on-canvas.
static constexpr auto SP_SELECTION_UPDATE_PRIORITY
SPObject * sp_object_unref(SPObject *object, SPObject *owner)
Decrease reference count of object, with possible debugging and finalization.
SPObject * sp_object_ref(SPObject *object, SPObject *owner)
Increase reference count of object, with possible debugging.
Complete state of a selection, including selected objects and nodes.
std::vector< std::string > selected_ids
std::vector< PathNodeState > selected_nodes