summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/desktop-style.cpp10
-rw-r--r--src/desktop-style.h3
-rw-r--r--src/desktop.cpp1
-rw-r--r--src/extension/dbus/document-interface.cpp16
-rw-r--r--src/extension/internal/bluredge.cpp2
-rw-r--r--src/file.cpp12
-rw-r--r--src/object-set.h135
-rw-r--r--src/path-chemistry.cpp171
-rw-r--r--src/path-chemistry.h13
-rw-r--r--src/selection-chemistry.cpp1105
-rw-r--r--src/selection-chemistry.h73
-rw-r--r--src/selection.cpp10
-rw-r--r--src/seltrans.cpp2
-rw-r--r--src/ui/clipboard.cpp187
-rw-r--r--src/ui/clipboard.h10
-rw-r--r--src/ui/dialog/export.cpp2
-rw-r--r--src/ui/dialog/layer-properties.cpp2
-rw-r--r--src/ui/dialog/livepatheffect-editor.cpp4
-rw-r--r--src/ui/dialog/transformation.cpp20
-rw-r--r--src/ui/interface.cpp16
-rw-r--r--src/ui/tools/box3d-tool.cpp2
-rw-r--r--src/ui/tools/eraser-tool.cpp14
-rw-r--r--src/ui/tools/freehand-base.cpp2
-rw-r--r--src/ui/tools/pen-tool.cpp2
-rw-r--r--src/ui/tools/pencil-tool.cpp2
-rw-r--r--src/ui/tools/rect-tool.cpp2
-rw-r--r--src/ui/tools/select-tool.cpp46
-rw-r--r--src/verbs.cpp114
-rw-r--r--src/widgets/select-toolbar.cpp2
29 files changed, 984 insertions, 996 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 81aa95b48..65e511245 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -174,8 +174,12 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
/**
* Apply style on selection on desktop.
*/
+ void sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current){
+ return sp_desktop_set_style(desktop->getSelection(), desktop, css, change, write_current);
+}
+
void
-sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current)
+sp_desktop_set_style(Inkscape::ObjectSet *set, SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current)
{
if (write_current) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -187,7 +191,7 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write
sp_repr_css_merge(css_write, css);
sp_css_attr_unset_uris(css_write);
prefs->mergeStyle("/desktop/style", css_write);
- auto itemlist = desktop->selection->items();
+ auto itemlist = set->items();
for (auto i = itemlist.begin(); i!= itemlist.end(); ++i) {
/* last used styles for 3D box faces are stored separately */
SPObject *obj = *i;
@@ -227,7 +231,7 @@ sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write
sp_repr_css_merge(css_no_text, css);
css_no_text = sp_css_attr_unset_text(css_no_text);
- auto itemlist = desktop->selection->items();
+ auto itemlist = set->items();
for (auto i = itemlist.begin(); i!= itemlist.end(); ++i) {
SPItem *item = *i;
diff --git a/src/desktop-style.h b/src/desktop-style.h
index f3d6775a4..a404c94a8 100644
--- a/src/desktop-style.h
+++ b/src/desktop-style.h
@@ -12,7 +12,6 @@
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
class ColorRGBA;
class SPCSSAttr;
class SPDesktop;
@@ -20,6 +19,7 @@ class SPObject;
class SPItem;
class SPStyle;
namespace Inkscape {
+class ObjectSet;
namespace XML {
class Node;
}
@@ -59,6 +59,7 @@ enum { // which property was queried (add when you need more)
void sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines);
void sp_desktop_set_color(SPDesktop *desktop, ColorRGBA const &color, bool is_relative, bool fill);
+void sp_desktop_set_style(Inkscape::ObjectSet *set, SPDesktop *desktop, SPCSSAttr *css, bool change = true, bool write_current = true);
void sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change = true, bool write_current = true);
SPCSSAttr *sp_desktop_get_style(SPDesktop *desktop, bool with_text);
guint32 sp_desktop_get_color (SPDesktop *desktop, bool is_fill);
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 89a7da9d0..2476b10bb 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -1529,6 +1529,7 @@ SPDesktop::setDocument (SPDocument *doc)
}
layers->setDocument(doc);
+ selection->setDocument(doc);
// remove old EventLog if it exists (see also: bug #1071082)
if (event_log) {
diff --git a/src/extension/dbus/document-interface.cpp b/src/extension/dbus/document-interface.cpp
index 667830997..d3a06b81c 100644
--- a/src/extension/dbus/document-interface.cpp
+++ b/src/extension/dbus/document-interface.cpp
@@ -713,7 +713,7 @@ document_interface_move (DocumentInterface *doc_interface, gchar *name, gdouble
std::vector<SPObject*> oldsel = selection_swap(doc_interface->target.getSelection(), name, error);
if (oldsel.empty())
return FALSE;
- sp_selection_move (doc_interface->target.getSelection(), x, 0 - y);
+ doc_interface->target.getSelection()->move(x, 0 - y);
selection_restore(doc_interface->target.getSelection(), oldsel);
return TRUE;
}
@@ -726,7 +726,7 @@ document_interface_move_to (DocumentInterface *doc_interface, gchar *name, gdoub
if (oldsel.empty())
return FALSE;
Inkscape::Selection * sel = doc_interface->target.getSelection();
- sp_selection_move (doc_interface->target.getSelection(), x - selection_get_center_x(sel),
+ doc_interface->target.getSelection()->move(x - selection_get_center_x(sel),
0 - (y - selection_get_center_y(sel)));
selection_restore(doc_interface->target.getSelection(), oldsel);
return TRUE;
@@ -1150,7 +1150,7 @@ document_interface_selection_set_list (DocumentInterface *doc_interface,
gboolean document_interface_selection_rotate(DocumentInterface *doc_interface, int angle, GError ** /*error*/)
{
Inkscape::Selection *selection = doc_interface->target.getSelection();
- sp_selection_rotate(selection, angle);
+ selection->rotate(angle);
return TRUE;
}
@@ -1235,13 +1235,13 @@ gboolean document_interface_selection_scale(DocumentInterface *doc_interface, gd
{
return FALSE;
}
- sp_selection_scale (selection, grow);
+ selection->scale(grow);
return TRUE;
}
gboolean document_interface_selection_move(DocumentInterface *doc_interface, gdouble x, gdouble y, GError ** /*error*/)
{
- sp_selection_move(doc_interface->target.getSelection(), x, 0 - y); //switching coordinate systems.
+ doc_interface->target.getSelection()->move(x, 0 - y); //switching coordinate systems.
return TRUE;
}
@@ -1252,7 +1252,7 @@ gboolean document_interface_selection_move_to(DocumentInterface *doc_interface,
Geom::OptRect sel_bbox = sel->visualBounds();
if (sel_bbox) {
Geom::Point m( x - selection_get_center_x(sel) , 0 - (y - selection_get_center_y(sel)) );
- sp_object_set_move_relative(sel, m, true);
+ sel->moveRelative(m, true);
}
return TRUE;
}
@@ -1279,8 +1279,8 @@ document_interface_selection_move_to_layer (DocumentInterface *doc_interface,
return FALSE;
if (strcmp("layer", (next->getRepr())->attribute("inkscape:groupmode")) == 0) {
-
- sp_selection_cut(dt);
+
+ dt->selection->cut();
doc_interface->target.getSelection()->layers()->setCurrentLayer(next);
diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp
index 4f66b39fc..8aa982810 100644
--- a/src/extension/internal/bluredge.cpp
+++ b/src/extension/internal/bluredge.cpp
@@ -90,7 +90,7 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View
new_group->appendChild(new_items[i]);
selection->add(new_items[i]);
- sp_selected_path_to_curves(selection, static_cast<SPDesktop *>(desktop));
+ selection->toCurves();
if (offset < 0.0) {
/* Doing an inset here folks */
diff --git a/src/file.cpp b/src/file.cpp
index 7c17a6158..e5c7240dc 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -1118,14 +1118,14 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place)
Inkscape::Selection *selection = desktop->getSelection();
selection->setReprList(pasted_objects_not);
Geom::Affine doc2parent = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
- sp_object_set_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false);
- sp_selection_delete(desktop);
+ selection->applyAffine(desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false);
+ selection->deleteItems();
// Change the selection to the freshly pasted objects
selection->setReprList(pasted_objects);
// Apply inverse of parent transform
- sp_object_set_apply_affine(selection, desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false);
+ selection->applyAffine(desktop->dt2doc() * doc2parent * desktop->doc2dt(), true, false, false);
// Update (among other things) all curves in paths, for bounds() to work
target_document->ensureUpToDate();
@@ -1155,7 +1155,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place)
m.unSetup();
}
- sp_object_set_move_relative(selection, offset);
+ selection->moveRelative(offset);
}
}
@@ -1260,7 +1260,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
// c2p is identity matrix at this point unless ensureUpToDate is called
doc->ensureUpToDate();
Geom::Affine affine = doc->getRoot()->c2p * SP_ITEM(place_to_insert)->i2doc_affine().inverse();
- sp_object_set_apply_affine(selection, desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false);
+ selection->applyAffine(desktop->dt2doc() * affine * desktop->doc2dt(), true, false, false);
// move to mouse pointer
{
@@ -1268,7 +1268,7 @@ file_import(SPDocument *in_doc, const Glib::ustring &uri,
Geom::OptRect sel_bbox = selection->visualBounds();
if (sel_bbox) {
Geom::Point m( desktop->point() - sel_bbox->midpoint() );
- sp_object_set_move_relative(selection, m, false);
+ selection->moveRelative(m, false);
}
}
}
diff --git a/src/object-set.h b/src/object-set.h
index fae365f70..dc0602e06 100644
--- a/src/object-set.h
+++ b/src/object-set.h
@@ -3,6 +3,7 @@
*
* Authors:
* Adrian Boguszewski
+ * Marc Jeanmougin
*
* Copyright (C) 2016 Adrian Boguszewski
*
@@ -30,10 +31,11 @@
#include "sp-object.h"
#include "sp-item.h"
#include "sp-item-group.h"
+#include "desktop.h"
+#include "document.h"
class SPBox3D;
class Persp3D;
-class SPDesktop;
namespace Inkscape {
@@ -101,9 +103,17 @@ public:
typedef decltype(MultiIndexContainer().get<random_access>() | boost::adaptors::filtered(is_group()) | boost::adaptors::transformed(object_to_group())) SPGroupRange;
typedef decltype(MultiIndexContainer().get<random_access>() | boost::adaptors::filtered(is_item()) | boost::adaptors::transformed(object_to_node())) XMLNodeRange;
- ObjectSet(SPDesktop* desktop): _desktop(desktop) {};
- ObjectSet(): _desktop(nullptr) {};
+ ObjectSet(SPDesktop* desktop): _desktop(desktop) {
+ _document = desktop->getDocument();
+ };
+ ObjectSet(SPDocument* doc): _desktop(nullptr), _document(doc) {};
+ ObjectSet(): _desktop(nullptr), _document(nullptr) {};
virtual ~ObjectSet();
+
+ void setDocument(SPDocument* doc){
+ _document = doc;
+ }
+
/**
* Add an SPObject to the set of selected objects.
@@ -112,6 +122,16 @@ public:
*/
bool add(SPObject* object);
+ /**
+ * Add an XML node's SPObject to the set of selected objects.
+ *
+ * @param the xml node of the item to add
+ */
+ void add(XML::Node *repr) {
+ if(document() && repr)
+ add(document()->getObjectById(repr->attribute("id")));
+ }
+
/** Add items from an STL iterator range to the selection.
* \param from the begin iterator
* \param to the end iterator
@@ -146,7 +166,10 @@ public:
* @param obj the object to select
*/
void set(SPObject *object);
-
+ void set(XML::Node *repr) {
+ if(document() && repr)
+ set(document()->getObjectById(repr->attribute("id")));
+ }
/**
* Unselects all selected objects.
*/
@@ -235,6 +258,23 @@ public:
_clear();
addList(objs);
}
+
+ /**
+ * Selects exactly the specified objects.
+ *
+ * @param list the repr list to add
+ */
+ void setReprList(std::vector<XML::Node*> const &list) {
+ if(!document())
+ return;
+ clear();
+ for (auto iter = list.rbegin(); iter != list.rend(); ++iter) {
+ SPObject *obj = document()->getObjectById((*iter)->attribute("id"));
+ if (obj) {
+ add(obj);
+ }
+ }
+ }
/**
* Adds the specified objects to selection, without deselecting first.
@@ -287,6 +327,92 @@ public:
*/
SPDesktop *desktop() { return _desktop; }
+ /**
+ * Returns the document the selection is bound to
+ *
+ * @return the document the selection is bound to, or NULL if in console mode
+ */
+ SPDocument *document() { return _document; }
+
+ //item groups operations
+ //in selection-chemistry.cpp
+ void deleteItems();
+ void duplicate(bool suppressDone = false, bool duplicateLayer = false);
+ void clone();
+ void unlink();
+ void relink();
+ void cloneOriginal();
+ void cloneOriginalPathLPE();
+ Inkscape::XML::Node* group();
+ void popFromGroup();
+ void ungroup();
+
+ //z-order management
+ //in selection-chemistry.cpp
+ void raise(bool skip_undo = false);
+ void raiseToTop(bool skip_undo = false);
+ void lower(bool skip_undo = false);
+ void lowerToBottom(bool skip_undo = false);
+ void toNextLayer(bool skip_undo = false);
+ void toPrevLayer(bool skip_undo = false);
+ void toLayer(SPObject *layer, bool skip_undo = false);
+
+ //clipboard management
+ //in selection-chemistry.cpp
+ void copy();
+ void cut();
+ void pasteStyle();
+ void pasteSize(bool apply_x, bool apply_y);
+ void pasteSizeSeparately(bool apply_x, bool apply_y);
+ void pastePathEffect();
+
+ //path operations
+ //in path-chemistry.cpp
+ void combine(bool skip_undo = false);
+ void breakApart(bool skip_undo = false);
+ void toCurves(bool skip_undo = false);
+ void toLPEItems();
+ void pathReverse();
+
+ //Other path operations
+ //in selection-chemistry.cpp
+ void toMarker(bool apply = true);
+ void toGuides();
+ void toSymbol();
+ void unSymbol();
+ void tile(bool apply = true); //"Object to Pattern"
+ void untile();
+ void createBitmapCopy();
+ void setMask(bool apply_clip_path, bool apply_to_layer = false, bool skip_undo = false);
+ void editMask(bool clip);
+ void unsetMask(bool apply_clip_path);
+ void setClipGroup();
+
+ // moves
+ // in selection-chemistry.cpp
+ void removeLPE();
+ void removeFilter();
+ void applyAffine(Geom::Affine const &affine, bool set_i2d=true,bool compensate=true, bool adjust_transf_center=true);
+ void removeTransform();
+ void setScaleAbsolute(double, double, double, double);
+ void setScaleRelative(const Geom::Point&, const Geom::Scale&);
+ void rotateRelative(const Geom::Point&, double);
+ void skewRelative(const Geom::Point&, double, double);
+ void moveRelative(const Geom::Point &move, bool compensate = true);
+ void moveRelative(double dx, double dy);
+ void rotate90(bool ccw);
+ void rotate(double);
+ void rotateScreen(double);
+ void scale(double);
+ void scaleScreen(double);
+ void scaleTimes(double);
+ void move(double dx, double dy);
+ void moveScreen(double dx, double dy);
+
+ // various
+ void getExportHints(Glib::ustring &filename, float *xdpi, float *ydpi);
+
+
protected:
virtual void _connectSignals(SPObject* object) {};
virtual void _releaseSignals(SPObject* object) {};
@@ -304,6 +430,7 @@ protected:
MultiIndexContainer _container;
GC::soft_ptr<SPDesktop> _desktop;
+ GC::soft_ptr<SPDocument> _document;
std::list<SPBox3D *> _3dboxes;
std::unordered_map<SPObject*, sigc::connection> _releaseConnections;
diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 5295b7a70..a19ca9524 100644
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
@@ -38,8 +38,10 @@
#include "selection-chemistry.h"
#include "path-chemistry.h"
#include "verbs.h"
+#include "object-set.h"
using Inkscape::DocumentUndo;
+using Inkscape::ObjectSet;
inline bool less_than_items(SPItem const *first, SPItem const *second)
@@ -49,39 +51,42 @@ inline bool less_than_items(SPItem const *first, SPItem const *second)
}
void
-sp_selected_path_combine(SPDesktop *desktop, bool skip_undo)
+ObjectSet::combine(bool skip_undo)
{
- Inkscape::Selection *selection = desktop->getSelection();
- SPDocument *doc = desktop->getDocument();
+ //Inkscape::Selection *selection = desktop->getSelection();
+ SPDocument *doc = document();
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> items_copy(items().begin(), items().end());
- if (items.size() < 1) {
- desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine."));
+ if (items_copy.size() < 1) {
+ if(desktop())
+ desktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine."));
return;
}
- desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Combining paths..."));
- // set "busy" cursor
- desktop->setWaitingCursor();
+ if(desktop()){
+ desktop()->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Combining paths..."));
+ // set "busy" cursor
+ desktop()->setWaitingCursor();
+ }
- items = sp_degroup_list (items); // descend into any groups in selection
+ items_copy = sp_degroup_list (items_copy); // descend into any groups in selection
std::vector<SPItem*> to_paths;
- for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); ++i) {
+ for (std::vector<SPItem*>::const_reverse_iterator i = items_copy.rbegin(); i != items_copy.rend(); ++i) {
if (!dynamic_cast<SPPath *>(*i) && !dynamic_cast<SPGroup *>(*i)) {
to_paths.push_back(*i);
}
}
std::vector<Inkscape::XML::Node*> converted;
- bool did = sp_item_list_to_curves(to_paths, items, converted);
+ bool did = sp_item_list_to_curves(to_paths, items_copy, converted);
for (std::vector<Inkscape::XML::Node*>::const_iterator i = converted.begin(); i != converted.end(); ++i)
- items.push_back((SPItem*)doc->getObjectByRepr(*i));
+ items_copy.push_back((SPItem*)doc->getObjectByRepr(*i));
- items = sp_degroup_list (items); // converting to path may have added more groups, descend again
+ items_copy = sp_degroup_list (items_copy); // converting to path may have added more groups, descend again
- sort(items.begin(),items.end(),less_than_items);
- assert(!items.empty()); // cannot be NULL because of list length check at top of function
+ sort(items_copy.begin(),items_copy.end(),less_than_items);
+ assert(!items_copy.empty()); // cannot be NULL because of list length check at top of function
// remember the position, id, transform and style of the topmost path, they will be assigned to the combined one
gint position = 0;
@@ -95,10 +100,10 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo)
Inkscape::XML::Node *parent = NULL;
if (did) {
- selection->clear();
+ clear();
}
- for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); ++i){
+ for (std::vector<SPItem*>::const_reverse_iterator i = items_copy.rbegin(); i != items_copy.rend(); ++i){
SPItem *item = *i;
SPPath *path = dynamic_cast<SPPath *>(item);
@@ -107,7 +112,7 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo)
}
if (!did) {
- selection->clear();
+ clear();
did = true;
}
@@ -142,7 +147,7 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo)
first->deleteObject(false);
// delete the topmost.
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
// restore id, transform, path effect, and style
@@ -170,37 +175,40 @@ sp_selected_path_combine(SPDesktop *desktop, bool skip_undo)
// move to the position of the topmost, reduced by the number of deleted items
repr->setPosition(position > 0 ? position : 0);
if ( !skip_undo ) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_COMBINE,
+ DocumentUndo::done(doc, SP_VERB_SELECTION_COMBINE,
_("Combine"));
}
- selection->set(repr);
+ set(repr);
Inkscape::GC::release(repr);
} else {
- desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to combine in the selection."));
+ if(desktop())
+ desktop()->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to combine in the selection."));
}
- desktop->clearWaitingCursor();
+ if(desktop())
+ desktop()->clearWaitingCursor();
}
void
-sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo)
+ObjectSet::breakApart(bool skip_undo)
{
- Inkscape::Selection *selection = desktop->getSelection();
-
- if (selection->isEmpty()) {
- desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to break apart."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to break apart."));
return;
}
-
- desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Breaking apart paths..."));
- // set "busy" cursor
- desktop->setWaitingCursor();
+ if(desktop()){
+ desktop()->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Breaking apart paths..."));
+ // set "busy" cursor
+ desktop()->setWaitingCursor();
+
+ }
bool did = false;
- std::vector<SPItem*> itemlist(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> itemlist(items().begin(), items().end());
for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); ++i){
SPItem *item = *i;
@@ -264,83 +272,83 @@ sp_selected_path_break_apart(SPDesktop *desktop, bool skip_undo)
Inkscape::GC::release(repr);
}
- selection->setReprList(reprs);
+ setReprList(reprs);
g_slist_free(list);
g_free(style);
g_free(path_effect);
}
-
- desktop->clearWaitingCursor();
+
+ if(desktop())
+ desktop()->clearWaitingCursor();
if (did) {
if ( !skip_undo ) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_BREAK_APART,
+ DocumentUndo::done(document(), SP_VERB_SELECTION_BREAK_APART,
_("Break apart"));
}
} else {
- desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to break apart in the selection."));
+ if(desktop())
+ desktop()->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No path(s)</b> to break apart in the selection."));
}
}
-/* This function is an entry point from GUI */
-void
-sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, bool interactive)
+void ObjectSet::toCurves(bool skip_undo)
{
- if (selection->isEmpty()) {
- if (interactive && desktop)
- desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to path."));
+ if (isEmpty()) {
+ if (desktop())
+ desktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to path."));
return;
}
bool did = false;
- if (interactive && desktop) {
- desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Converting objects to paths..."));
+ if (desktop()) {
+ desktop()->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Converting objects to paths..."));
// set "busy" cursor
- desktop->setWaitingCursor();
+ desktop()->setWaitingCursor();
}
- std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> selected(items().begin(), items().end());
std::vector<Inkscape::XML::Node*> to_select;
- selection->clear();
+ clear();
std::vector<SPItem*> items(selected);
did = sp_item_list_to_curves(items, selected, to_select);
- selection->setReprList(to_select);
- selection->addList(selected);
+ setReprList(to_select);
+ addList(selected);
- if (interactive && desktop) {
- desktop->clearWaitingCursor();
- if (did) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_TO_CURVE,
+ if (desktop()) {
+ desktop()->clearWaitingCursor();
+ }
+ if (did&& !skip_undo) {
+ DocumentUndo::done(document(), SP_VERB_OBJECT_TO_CURVE,
_("Object to path"));
- } else {
- desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No objects</b> to convert to path in the selection."));
- return;
- }
+ } else {
+ if(desktop())
+ desktop()->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No objects</b> to convert to path in the selection."));
+ return;
}
}
/** Converts the selected items to LPEItems if they are not already so; e.g. SPRects) */
-void sp_selected_to_lpeitems(SPDesktop *desktop)
+void ObjectSet::toLPEItems()
{
- Inkscape::Selection *selection = desktop->getSelection();
- if (selection->isEmpty()) {
+ if (isEmpty()) {
return;
}
- std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> selected(items().begin(), items().end());
std::vector<Inkscape::XML::Node*> to_select;
- selection->clear();
+ clear();
std::vector<SPItem*> items(selected);
sp_item_list_to_curves(items, selected, to_select, true);
- selection->setReprList(to_select);
- selection->addList(selected);
+ setReprList(to_select);
+ addList(selected);
}
bool
@@ -597,24 +605,24 @@ sp_selected_item_to_curved_repr(SPItem *item, guint32 /*text_grouping_policy*/)
void
-sp_selected_path_reverse(SPDesktop *desktop)
+ObjectSet::pathReverse()
{
- Inkscape::Selection *selection = desktop->getSelection();
- auto items = selection->items();
-
- if (items.empty()) {
- desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse."));
return;
}
// set "busy" cursor
- desktop->setWaitingCursor();
-
+ if(desktop()){
+ desktop()->setWaitingCursor();
+ desktop()->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths..."));
+ }
+
bool did = false;
- desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths..."));
- for (auto i = items.begin(); i != items.end(); ++i){
+ for (auto i = items().begin(); i != items().end(); ++i){
SPPath *path = dynamic_cast<SPPath *>(*i);
if (!path) {
@@ -642,14 +650,15 @@ sp_selected_path_reverse(SPDesktop *desktop)
g_free(nodetypes);
}
}
-
- desktop->clearWaitingCursor();
+ if(desktop())
+ desktop()->clearWaitingCursor();
if (did) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_REVERSE,
+ DocumentUndo::done(document(), SP_VERB_SELECTION_REVERSE,
_("Reverse path"));
} else {
- desktop->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection."));
+ if(desktop())
+ desktop()->getMessageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No paths</b> to reverse in the selection."));
}
}
diff --git a/src/path-chemistry.h b/src/path-chemistry.h
index 7b9beaed8..3bcd0486a 100644
--- a/src/path-chemistry.h
+++ b/src/path-chemistry.h
@@ -18,6 +18,7 @@ class SPItem;
namespace Inkscape {
class Selection;
+class ObjectSet;
namespace XML {
class Node;
} // namespace XML
@@ -25,13 +26,13 @@ class Node;
typedef unsigned int guint32;
-void sp_selected_path_combine (SPDesktop *desktop, bool skip_undo = false);
-void sp_selected_path_break_apart (SPDesktop *desktop, bool skip_undo = false);
-// interactive=true only has an effect if desktop != NULL, i.e. if a GUI is available
-void sp_selected_path_to_curves (Inkscape::Selection *selection, SPDesktop *desktop, bool interactive = true);
-void sp_selected_to_lpeitems(SPDesktop *desktop);
+//void sp_selected_path_combine (SPDesktop *desktop, bool skip_undo = false);
+//void sp_selected_path_break_apart (SPDesktop *desktop, bool skip_undo = false);
+ //interactive=true only has an effect if desktop != NULL, i.e. if a GUI is available
+//void sp_selected_path_to_curves (Inkscape::Selection *selection, SPDesktop *desktop, bool interactive = true);
+//void sp_selected_to_lpeitems(ObjectSet *selection);
Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy);
-void sp_selected_path_reverse (SPDesktop *desktop);
+//void sp_selected_path_reverse (SPDesktop *desktop);
bool sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*> &selected, std::vector<Inkscape::XML::Node*> &to_select, bool skip_all_lpeitems = false);
#endif // SEEN_PATH_CHEMISTRY_H
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 7bed0a71d..2f9e72e2c 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -13,6 +13,7 @@
* Kris De Gussem <Kris.DeGussem@gmail.com>
* Tavmjong Bah <tavmjong@free.fr> (Symbol additions)
* Adrian Boguszewski
+ * Marc Jeanmougin
*
* Copyright (C) 1999-2016 authors
* Copyright (C) 2001-2002 Ximian, Inc.
@@ -223,7 +224,7 @@ void SelectionHelper::reverse(SPDesktop *dt)
NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
nt->_multipath->reverseSubpaths();
} else {
- sp_selected_path_reverse(dt);
+ dt->getSelection()->pathReverse();
}
}
@@ -374,43 +375,42 @@ static void sp_selection_delete_impl(std::vector<SPItem*> const &items, bool pro
}
-void sp_selection_delete(SPDesktop *desktop)
+void ObjectSet::deleteItems()
{
- if (desktop == NULL) {
- return;
- }
-
- if (tools_isactive(desktop, TOOLS_TEXT))
- if (Inkscape::UI::Tools::sp_text_delete_selection(desktop->event_context)) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
+ if(desktop() && tools_isactive(desktop(), TOOLS_TEXT)){
+ if (Inkscape::UI::Tools::sp_text_delete_selection(desktop()->event_context)) {
+ DocumentUndo::done(desktop()->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Delete text"));
return;
- }
-
- Inkscape::Selection *selection = desktop->getSelection();
-
- // check if something is selected
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted."));
+ }
+ }
+
+ if (isEmpty()) {
+ selection_display_message(desktop(),Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted."));
return;
}
- std::vector<SPItem*> selected(selection->items().begin(), selection->items().end());
- selection->clear();
+ std::vector<SPItem*> selected(items().begin(), items().end());
+ clear();
sp_selection_delete_impl(selected);
- desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
-
- /* a tool may have set up private information in it's selection context
- * that depends on desktop items. I think the only sane way to deal with
- * this currently is to reset the current tool, which will reset it's
- * associated selection context. For example: deleting an object
- * while moving it around the canvas.
- */
- tools_switch( desktop, tools_active( desktop ) );
+ if(SPDesktop *d = desktop()){
+ d->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+
+ /* a tool may have set up private information in it's selection context
+ * that depends on desktop items. I think the only sane way to deal with
+ * this currently is to reset the current tool, which will reset it's
+ * associated selection context. For example: deleting an object
+ * while moving it around the canvas.
+ */
+ tools_switch( d, tools_active( d ) );
+ }
+ if(document())
+ DocumentUndo::done(document(), SP_VERB_EDIT_DELETE,
+ _("Delete"));
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_DELETE,
- _("Delete"));
}
+
+
static void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj)
{
if (obj) {
@@ -424,29 +424,33 @@ static void add_ids_recursive(std::vector<const gchar *> &ids, SPObject *obj)
}
}
-void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone, bool duplicateLayer)
+void ObjectSet::duplicate(bool suppressDone, bool duplicateLayer)
{
- if (desktop == NULL) {
+ if(duplicateLayer && !desktop() ){
+ //TODO: understand why layer management is tied to desktop and not to document.
return;
}
-
- SPDocument *doc = desktop->doc();
+
+ SPDocument *doc = document();
+
+ if(!doc)
+ return;
+
Inkscape::XML::Document* xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
- if (selection->isEmpty() && !duplicateLayer) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate."));
+ if (isEmpty() && !duplicateLayer) {
+ selection_display_message(desktop(),Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate."));
return;
}
- std::vector<Inkscape::XML::Node*> reprs(selection->xmlNodes().begin(), selection->xmlNodes().end());
+ std::vector<Inkscape::XML::Node*> reprs(xmlNodes().begin(), xmlNodes().end());
if(duplicateLayer){
reprs.clear();
- reprs.push_back(desktop->currentLayer()->getRepr());
+ reprs.push_back(desktop()->currentLayer()->getRepr());
}
- selection->clear();
+ clear();
// sorting items from different parents sorts each parent's subset without possibly mixing
// them, just what we need
@@ -534,15 +538,15 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone, bool duplicat
if ( !suppressDone ) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_DUPLICATE,
+ DocumentUndo::done(document(), SP_VERB_EDIT_DUPLICATE,
_("Duplicate"));
}
if(!duplicateLayer)
- selection->setReprList(newsel);
+ setReprList(newsel);
else{
SPObject* new_layer = doc->getObjectByRepr(newsel[0]);
gchar* name = g_strdup_printf(_("%s copy"), new_layer->label());
- desktop->layer_manager->renameLayer( new_layer, name, TRUE );
+ desktop()->layer_manager->renameLayer( new_layer, name, TRUE );
g_free(name);
}
}
@@ -683,12 +687,18 @@ void sp_edit_invert_in_all_layers(SPDesktop *desktop)
sp_edit_select_all_full(desktop, true, true);
}
-static Inkscape::XML::Node* sp_object_set_group(ObjectSet *set) {
- SPDocument *doc = set->desktop()->getDocument();
+Inkscape::XML::Node* ObjectSet::group() {
+ SPDocument *doc = document();
+ if(!doc)
+ return nullptr;
+ if (isEmpty()) {
+ selection_display_message(desktop(), Inkscape::WARNING_MESSAGE, _("Select <b>some objects</b> to group."));
+ return nullptr;
+ }
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
Inkscape::XML::Node *group = xml_doc->createElement("svg:g");
- std::vector<Inkscape::XML::Node*> p(set->xmlNodes().begin(), set->xmlNodes().end());
+ std::vector<Inkscape::XML::Node*> p(xmlNodes().begin(), xmlNodes().end());
std::sort(p.begin(), p.end(), sp_repr_compare_position_bool);
// Remember the position and parent of the topmost object.
@@ -748,25 +758,13 @@ static Inkscape::XML::Node* sp_object_set_group(ObjectSet *set) {
// Move to the position of the topmost, reduced by the number of items deleted from topmost_parent
group->setPosition(topmost + 1);
- set->set(doc->getObjectByRepr(group));
+ set(doc->getObjectByRepr(group));
+ DocumentUndo::done(doc, SP_VERB_SELECTION_GROUP,
+ C_("Verb", "Group"));
return group;
}
-void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop)
-{
- // Check if something is selected.
- if (selection->isEmpty()) {
- selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>some objects</b> to group."));
- return;
- }
- Inkscape::XML::Node* group = sp_object_set_group(selection);
-
- DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_GROUP,
- C_("Verb", "Group"));
-
- Inkscape::GC::release(group);
-}
static gint clone_depth_descending(gconstpointer a, gconstpointer b) {
SPUse *use_a = static_cast<SPUse *>(const_cast<gpointer>(a));
@@ -781,20 +779,19 @@ static gint clone_depth_descending(gconstpointer a, gconstpointer b) {
return -1;
}
}
-
-void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop)
-{
- if (selection->isEmpty()) {
- selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("<b>No objects selected</b> to pop out of group."));
+
+void ObjectSet::popFromGroup(){
+ if (isEmpty()) {
+ selection_display_message(desktop(), Inkscape::WARNING_MESSAGE, _("<b>No objects selected</b> to pop out of group."));
return;
}
- auto item = selection->items().begin(); // leaving this because it will be useful for
+ auto item = items().begin(); // leaving this because it will be useful for
// future implementation of complex pop ungrouping
SPItem *obj = *item;
SPItem *parent_group = static_cast<SPItem*>(obj->parent);
if (!SP_IS_GROUP(parent_group) || SP_IS_LAYER(parent_group)) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Selection <b>not in a group</b>."));
+ selection_display_message(desktop(), Inkscape::WARNING_MESSAGE, _("Selection <b>not in a group</b>."));
return;
}
if (parent_group->firstChild()->getNext() == NULL) {
@@ -802,22 +799,20 @@ void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDeskto
sp_item_group_ungroup(static_cast<SPGroup*>(parent_group), children, false);
}
else {
- sp_selection_to_next_layer(desktop, 1); // suppress done
+ toNextLayer(1);
}
parent_group->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
- DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP_POP_SELECTION,
+ if(document())
+ DocumentUndo::done(document(), SP_VERB_SELECTION_UNGROUP_POP_SELECTION,
_("Pop selection from group"));
}
-static void sp_object_set_ungroup(ObjectSet *set)
+static void ungroup_impl(ObjectSet *set)
{
- GSList *groups = NULL;
- for (auto g: set->groups()) {
- groups = g_slist_prepend(groups, g);
- }
+ std::set<SPObject*> groups(set->groups().begin(),set->groups().end());
std::vector<SPItem*> new_select;
auto old_select = set->items();
@@ -834,7 +829,7 @@ static void sp_object_set_ungroup(ObjectSet *set)
original = dynamic_cast<SPUse *>(original)->get_original();
}
- if (g_slist_find(groups, original) != NULL) {
+ if (groups.find(original) != groups.end()) {
clones_to_unlink = g_slist_prepend(clones_to_unlink, *item);
}
}
@@ -856,7 +851,7 @@ static void sp_object_set_ungroup(ObjectSet *set)
SPItem *obj = *item;
// ungroup only the groups marked earlier
- if (g_slist_find(groups, *item) != NULL) {
+ if (groups.find(*item) != groups.end()) {
std::vector<SPItem*> children;
sp_item_group_ungroup(dynamic_cast<SPGroup *>(obj), children, false);
// add the items resulting from ungrouping to the selection
@@ -871,23 +866,28 @@ static void sp_object_set_ungroup(ObjectSet *set)
set->setList(new_select);
}
-void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop)
+void ObjectSet::ungroup()
{
- if (selection->isEmpty()) {
- selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select a <b>group</b> to ungroup."));
+ if (isEmpty()) {
+ if(desktop())
+ selection_display_message(desktop(), Inkscape::WARNING_MESSAGE, _("Select a <b>group</b> to ungroup."));
+ return;
}
- if (boost::distance(selection->groups()) == 0) {
- selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("<b>No groups</b> to ungroup in the selection."));
+ if (boost::distance(groups()) == 0) {
+ if(desktop())
+ selection_display_message(desktop(), Inkscape::ERROR_MESSAGE, _("<b>No groups</b> to ungroup in the selection."));
return;
}
- sp_object_set_ungroup(selection);
-
- DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP,
+ ungroup_impl(this);
+ if(document())
+ DocumentUndo::done(document(), SP_VERB_SELECTION_UNGROUP,
_("Ungroup"));
}
+// TODO replace it with ObjectSet::degroup_list
+
/** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */
std::vector<SPItem*>
sp_degroup_list(std::vector<SPItem*> &items)
@@ -967,16 +967,29 @@ bool sp_item_repr_compare_position_bool(SPObject const *first, SPObject const *s
((SPItem*)second)->getRepr())<0;
}
-void sp_object_set_raise(ObjectSet *set) {
- std::vector<SPItem*> items(set->items().begin(), set->items().end());
- Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(items.front()->parent->getRepr());
+void ObjectSet::raise(bool skip_undo){
+
+ if(isEmpty()){
+ selection_display_message(desktop(), Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise."));
+ return;
+ }
+
+ SPGroup const *group = sp_item_list_common_parent_group(items());
+ if (!group) {
+ if(desktop())
+ selection_display_message(desktop(), Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
+ return;
+ }
+
+ std::vector<SPItem*> items_copy(items().begin(), items().end());
+ Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(items_copy.front()->parent->getRepr());
/* Construct reverse-ordered list of selected children. */
- std::vector<SPItem*> rev(items);
+ std::vector<SPItem*> rev(items_copy);
sort(rev.begin(),rev.end(),sp_item_repr_compare_position_bool);
// Determine the common bbox of the selected items.
- Geom::OptRect selected = enclose_items(items);
+ Geom::OptRect selected = enclose_items(items_copy);
// Iterate over all objects in the selection (starting from top).
if (selected) {
@@ -990,7 +1003,7 @@ void sp_object_set_raise(ObjectSet *set) {
Geom::OptRect newref_bbox = newItem->desktopVisualBounds();
if ( newref_bbox && selected->intersects(*newref_bbox) ) {
// AND if it's not one of our selected objects,
- if ( std::find(items.begin(),items.end(),newref)==items.end()) {
+ if ( std::find(items_copy.begin(),items_copy.end(),newref)==items_copy.end()) {
// move the selected object after that sibling
grepr->changeOrder(child->getRepr(), newref->getRepr());
}
@@ -1000,70 +1013,59 @@ void sp_object_set_raise(ObjectSet *set) {
}
}
}
+ if(document() && !skip_undo)
+ DocumentUndo::done(document(), SP_VERB_SELECTION_RAISE,
+ //TRANSLATORS: "Raise" means "to raise an object" in the undo history
+ C_("Undo action", "Raise"));
}
-void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop)
-{
- if (selection->items().empty()) {
- selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise."));
+
+void ObjectSet::raiseToTop(bool skip_undo) {
+ if(isEmpty()){
+ selection_display_message(desktop(), Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise."));
return;
}
- SPGroup const *group = sp_item_list_common_parent_group(selection->items());
+ SPGroup const *group = sp_item_list_common_parent_group(items());
if (!group) {
- selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
+ selection_display_message(desktop(), Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
return;
}
- sp_object_set_raise(selection);
-
- DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE,
- //TRANSLATORS: "Raise" means "to raise an object" in the undo history
- C_("Undo action", "Raise"));
-}
-
-void sp_object_set_raise_to_top(ObjectSet *set) {
- std::vector<Inkscape::XML::Node*> rl(set->xmlNodes().begin(), set->xmlNodes().end());
+
+ std::vector<Inkscape::XML::Node*> rl(xmlNodes().begin(), xmlNodes().end());
sort(rl.begin(),rl.end(),sp_repr_compare_position_bool);
for (std::vector<Inkscape::XML::Node*>::const_iterator l=rl.begin(); l!=rl.end();++l) {
Inkscape::XML::Node *repr =(*l);
repr->setPosition(-1);
}
+ if (document() && !skip_undo) {
+ DocumentUndo::done(document(), SP_VERB_SELECTION_TO_FRONT,
+ _("Raise to top"));
+ }
}
-void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo)
-{
- SPDocument *document = selection->layers()->getDocument();
-
- if (selection->isEmpty()) {
- selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise to top."));
+void ObjectSet::lower(bool skip_undo){
+ if(isEmpty()){
+ selection_display_message(desktop(), Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower."));
return;
}
- SPGroup const *group = sp_item_list_common_parent_group(selection->items());
+ SPGroup const *group = sp_item_list_common_parent_group(items());
if (!group) {
- selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
+ selection_display_message(desktop(), Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
return;
}
- sp_object_set_raise_to_top(selection);
-
- if (!skip_undo) {
- DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT,
- _("Raise to top"));
- }
-}
-
-void sp_object_set_lower(ObjectSet *set) {
- std::vector<SPItem*> items(set->items().begin(), set->items().end());
- Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(items.front()->parent->getRepr());
+ std::vector<SPItem*> items_copy(items().begin(), items().end());
+ Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(items_copy.front()->parent->getRepr());
// Determine the common bbox of the selected items.
- Geom::OptRect selected = enclose_items(items);
+ Geom::OptRect selected = enclose_items(items_copy);
/* Construct direct-ordered list of selected children. */
- std::vector<SPItem*> rev(items);
+ std::vector<SPItem*> rev(items_copy);
sort(rev.begin(),rev.end(),sp_item_repr_compare_position_bool);
// Iterate over all objects in the selection (starting from top).
@@ -1078,7 +1080,7 @@ void sp_object_set_lower(ObjectSet *set) {
Geom::OptRect ref_bbox = newItem->desktopVisualBounds();
if ( ref_bbox && selected->intersects(*ref_bbox) ) {
// AND if it's not one of our selected objects,
- if (items.end()==std::find(items.begin(),items.end(),newref)) {
+ if (items_copy.end()==std::find(items_copy.begin(),items_copy.end(),newref)) {
// move the selected object before that sibling
SPObject *put_after = prev_sibling(newref);
if (put_after)
@@ -1092,38 +1094,35 @@ void sp_object_set_lower(ObjectSet *set) {
}
}
}
+ if(document() && !skip_undo)
+ DocumentUndo::done(document(), SP_VERB_SELECTION_LOWER,
+ //TRANSLATORS: "Lower" means "to lower an object" in the undo history
+ C_("Undo action", "Lower"));
}
-void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop)
-{
- if (selection->items().empty()) {
- selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower."));
+
+void ObjectSet::lowerToBottom(bool skip_undo){
+ if(!document())
+ return;
+ if (isEmpty()) {
+ selection_display_message(desktop(), Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower to bottom."));
return;
}
- SPGroup const *group = sp_item_list_common_parent_group(selection->items());
+ SPGroup const *group = sp_item_list_common_parent_group(items());
if (!group) {
- selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
+ selection_display_message(desktop(), Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
return;
}
- sp_object_set_lower(selection);
-
- DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER,
- //TRANSLATORS: "Lower" means "to lower an object" in the undo history
- C_("Undo action", "Lower"));
-}
-
-
-void sp_object_set_lower_to_bottom(ObjectSet *set) {
- std::vector<Inkscape::XML::Node*> rl(set->xmlNodes().begin(), set->xmlNodes().end());
+ std::vector<Inkscape::XML::Node*> rl(xmlNodes().begin(), xmlNodes().end());
sort(rl.begin(),rl.end(),sp_repr_compare_position_bool);
for (std::vector<Inkscape::XML::Node*>::const_reverse_iterator l=rl.rbegin();l!=rl.rend();++l) {
gint minpos;
SPObject *pp;
Inkscape::XML::Node *repr = (*l);
- pp = set->desktop()->getDocument()->getObjectByRepr(repr->parent());
+ pp = document()->getObjectByRepr(repr->parent());
minpos = 0;
g_assert(dynamic_cast<SPGroup *>(pp));
for (auto& pc: pp->children) {
@@ -1134,28 +1133,13 @@ void sp_object_set_lower_to_bottom(ObjectSet *set) {
}
repr->setPosition(minpos);
}
-}
-
-void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo)
-{
- if (selection->isEmpty()) {
- selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower to bottom."));
- return;
- }
-
- SPGroup const *group = sp_item_list_common_parent_group(selection->items());
- if (!group) {
- selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("You cannot raise/lower objects from <b>different groups</b> or <b>layers</b>."));
- return;
- }
-
- sp_object_set_lower_to_bottom(selection);
- if (!skip_undo) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_SELECTION_TO_BACK,
+ if (document() && !skip_undo) {
+ DocumentUndo::done(document(), SP_VERB_SELECTION_TO_BACK,
_("Lower to bottom"));
}
}
+
void
sp_undo(SPDesktop *desktop, SPDocument *)
{
@@ -1178,10 +1162,10 @@ sp_redo(SPDesktop *desktop, SPDocument *)
}
}
-void sp_selection_cut(SPDesktop *desktop)
+void ObjectSet::cut()
{
- sp_selection_copy(desktop);
- sp_selection_delete(desktop);
+ copy();
+ deleteItems();
}
/**
@@ -1236,11 +1220,10 @@ take_style_from_item(SPObject *object)
return css;
}
-
-void sp_selection_copy(SPDesktop *desktop)
+void ObjectSet::copy()
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- cm->copy(desktop);
+ cm->copy(this);
}
void sp_selection_paste(SPDesktop *desktop, bool in_place)
@@ -1251,20 +1234,20 @@ void sp_selection_paste(SPDesktop *desktop, bool in_place)
}
}
-void sp_selection_paste_style(SPDesktop *desktop)
+void ObjectSet::pasteStyle()
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- if (cm->pasteStyle(desktop)) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_STYLE, _("Paste style"));
+ if (cm->pasteStyle(this)) {
+ DocumentUndo::done(document(), SP_VERB_EDIT_PASTE_STYLE, _("Paste style"));
}
}
-void sp_selection_paste_livepatheffect(SPDesktop *desktop)
+void ObjectSet::pastePathEffect()
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- if (cm->pastePathEffect(desktop)) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT,
+ if (cm->pastePathEffect(this)) {
+ DocumentUndo::done(document(), SP_VERB_EDIT_PASTE_LIVEPATHEFFECT,
_("Paste live path effect"));
}
}
@@ -1279,18 +1262,16 @@ static void sp_selection_remove_livepatheffect_impl(SPItem *item)
}
}
-void sp_selection_remove_livepatheffect(SPDesktop *desktop)
+void ObjectSet::removeLPE()
{
- if (desktop == NULL) return;
-
- Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from."));
return;
}
- auto list= selection->items();
+ auto list= items();
for (auto itemlist=list.begin();itemlist!=list.end();++itemlist) {
SPItem *item = *itemlist;
@@ -1298,46 +1279,45 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop)
}
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT,
+ if(document())
+ DocumentUndo::done(document(), SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT,
_("Remove live path effect"));
}
-void sp_selection_remove_filter(SPDesktop *desktop)
+void ObjectSet::removeFilter()
{
- if (desktop == NULL) return;
-
- Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove filters from."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove filters from."));
return;
}
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_unset_property(css, "filter");
- sp_desktop_set_style(desktop, css);
+ sp_desktop_set_style(this, desktop(), css);
sp_repr_css_attr_unref(css);
-
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_REMOVE_FILTER,
+ if(document())
+ DocumentUndo::done(document(), SP_VERB_EDIT_REMOVE_FILTER,
_("Remove filter"));
}
-void sp_selection_paste_size(SPDesktop *desktop, bool apply_x, bool apply_y)
+void ObjectSet::pasteSize(bool apply_x, bool apply_y)
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- if (cm->pasteSize(desktop, false, apply_x, apply_y)) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_SIZE,
+ if (cm->pasteSize(this, false, apply_x, apply_y)) {
+ DocumentUndo::done(document(), SP_VERB_EDIT_PASTE_SIZE,
_("Paste size"));
}
}
-void sp_selection_paste_size_separately(SPDesktop *desktop, bool apply_x, bool apply_y)
+void ObjectSet::pasteSizeSeparately(bool apply_x, bool apply_y)
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- if (cm->pasteSize(desktop, true, apply_x, apply_y)) {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY,
+ if (cm->pasteSize(this, true, apply_x, apply_y)) {
+ DocumentUndo::done(document(), SP_VERB_EDIT_PASTE_SIZE_SEPARATELY,
_("Paste size separately"));
}
}
@@ -1360,27 +1340,28 @@ void sp_selection_change_layer_maintain_clones(std::vector<SPItem*> const &items
}
}
-
-void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone)
+void ObjectSet::toNextLayer(bool skip_undo)
{
- Inkscape::Selection *selection = dt->getSelection();
-
+ if(!desktop())
+ return;
+ SPDesktop *dt=desktop(); //TODO make it desktop-independent
+
// check if something is selected
- if (selection->isEmpty()) {
+ if (isEmpty()) {
dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to move to the layer above."));
return;
}
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> items_copy(items().begin(), items().end());
bool no_more = false; // Set to true, if no more layers above
SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer());
if (next) {
- selection->clear();
- sp_selection_change_layer_maintain_clones(items,next);
+ clear();
+ sp_selection_change_layer_maintain_clones(items_copy,next);
std::vector<Inkscape::XML::Node*> temp_clip;
- sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc());
- sp_selection_delete_impl(items, false, false);
+ sp_selection_copy_impl(items_copy, temp_clip, dt->doc()->getReprDoc());
+ sp_selection_delete_impl(items_copy, false, false);
next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
std::vector<Inkscape::XML::Node*> copied;
if (next) {
@@ -1389,9 +1370,9 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone)
copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip);
no_more = true;
}
- selection->setReprList(copied);
+ setReprList(copied);
if (next) dt->setCurrentLayer(next);
- if ( !suppressDone ) {
+ if ( !skip_undo ) {
DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT,
_("Raise to next layer"));
}
@@ -1405,26 +1386,28 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone)
}
-void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
+void ObjectSet::toPrevLayer(bool skip_undo)
{
- Inkscape::Selection *selection = dt->getSelection();
+ if(!desktop())
+ return;
+ SPDesktop *dt=desktop(); //TODO make it desktop-independent
// check if something is selected
- if (selection->isEmpty()) {
+ if (isEmpty()) {
dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to move to the layer below."));
return;
}
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> items_copy(items().begin(), items().end());
bool no_more = false; // Set to true, if no more layers below
SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer());
if (next) {
- selection->clear();
- sp_selection_change_layer_maintain_clones(items,next);
+ clear();
+ sp_selection_change_layer_maintain_clones(items_copy,next);
std::vector<Inkscape::XML::Node*> temp_clip;
- sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
- sp_selection_delete_impl(items, false, false);
+ sp_selection_copy_impl(items_copy, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
+ sp_selection_delete_impl(items_copy, false, false);
next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers
std::vector<Inkscape::XML::Node*> copied;
if (next) {
@@ -1433,9 +1416,9 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip);
no_more = true;
}
- selection->setReprList( copied);
+ setReprList( copied);
if (next) dt->setCurrentLayer(next);
- if ( !suppressDone ) {
+ if ( !skip_undo ) {
DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV,
_("Lower to previous layer"));
}
@@ -1448,30 +1431,33 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone)
}
}
-void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone)
+void ObjectSet::toLayer(SPObject *moveto, bool skip_undo)
{
- Inkscape::Selection *selection = dt->getSelection();
+ if(!document())
+ return;
+ SPDesktop *dt = desktop();
// check if something is selected
- if (selection->isEmpty()) {
- dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to move."));
+ if (isEmpty()) {
+ if(dt)
+ dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to move."));
return;
}
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> items_copy(items().begin(), items().end());
if (moveto) {
- selection->clear();
- sp_selection_change_layer_maintain_clones(items,moveto);
+ clear();
+ sp_selection_change_layer_maintain_clones(items_copy,moveto);
std::vector<Inkscape::XML::Node*> temp_clip;
- sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs
- sp_selection_delete_impl(items, false, false);
- std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip);
- selection->setReprList(copied);
+ sp_selection_copy_impl(items_copy, temp_clip, document()->getReprDoc()); // we're in the same doc, so no need to copy defs
+ sp_selection_delete_impl(items_copy, false, false);
+ std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(document(), moveto, temp_clip);
+ setReprList(copied);
if (!temp_clip.empty()) temp_clip.clear();
- if (moveto) dt->setCurrentLayer(moveto);
- if ( !suppressDone ) {
- DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO,
+ if (moveto && dt) dt->setCurrentLayer(moveto);
+ if ( !skip_undo ) {
+ DocumentUndo::done(document(), SP_VERB_LAYER_MOVE_TO,
_("Move selection to layer"));
}
}
@@ -1527,22 +1513,23 @@ value of set_i2d==false is only used by seltrans when it's dragging objects live
that case, items are already in the new position, but the repr is in the old, and this function
then simply updates the repr from item->transform.
*/
-void sp_object_set_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool set_i2d, bool compensate,
+
+void ObjectSet::applyAffine(Geom::Affine const &affine, bool set_i2d, bool compensate,
bool adjust_transf_center)
{
- if (set->isEmpty())
+ if (isEmpty())
return;
// For each perspective with a box in selection, check whether all boxes are selected and
// unlink all non-selected boxes.
Persp3D *persp;
Persp3D *transf_persp;
- std::list<Persp3D *> plist = set->perspList();
+ std::list<Persp3D *> plist = perspList();
for (std::list<Persp3D *>::iterator i = plist.begin(); i != plist.end(); ++i) {
persp = (Persp3D *) (*i);
- if (!persp3d_has_all_boxes_in_selection (persp, set)) {
- std::list<SPBox3D *> selboxes = set->box3DList(persp);
+ if (!persp3d_has_all_boxes_in_selection (persp, this)) {
+ std::list<SPBox3D *> selboxes = box3DList(persp);
// create a new perspective as a copy of the current one and link the selected boxes to it
transf_persp = persp3d_create_xml_element (persp->document, persp->perspective_impl);
@@ -1555,14 +1542,15 @@ void sp_object_set_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool
persp3d_apply_affine_transformation(transf_persp, affine);
}
- auto items = set->items();
- for (auto l=items.begin();l!=items.end() ;++l) {
+ auto items_copy = items();
+ for (auto l=items_copy.begin();l!=items_copy.end() ;++l) {
SPItem *item = *l;
if( dynamic_cast<SPRoot *>(item) ) {
// An SVG element cannot have a transform. We could change 'x' and 'y' in response
// to a translation... but leave that for another day.
- set->desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot transform an embedded SVG."));
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot transform an embedded SVG."));
break;
}
@@ -1572,21 +1560,21 @@ void sp_object_set_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool
#if 0 /* Re-enable this once persistent guides have a graphical indication.
At the time of writing, this is the only place to re-enable. */
- sp_item_update_cns(*item, selection->desktop());
+ sp_item_update_cns(*item, desktop());
#endif
// we're moving both a clone and its original or any ancestor in clone chain?
- bool transform_clone_with_original = object_set_contains_original(item, set);
+ bool transform_clone_with_original = object_set_contains_original(item, this);
// ...both a text-on-path and its path?
bool transform_textpath_with_path = ((dynamic_cast<SPText *>(item) && item->firstChild() && dynamic_cast<SPTextPath *>(item->firstChild()))
- && set->includes( sp_textpath_get_path_item(dynamic_cast<SPTextPath *>(item->firstChild())) ));
+ && includes( sp_textpath_get_path_item(dynamic_cast<SPTextPath *>(item->firstChild())) ));
// ...both a flowtext and its frame?
- bool transform_flowtext_with_frame = (dynamic_cast<SPFlowtext *>(item) && set->includes( dynamic_cast<SPFlowtext *>(item)->get_frame(NULL))); // (only the first frame is checked so far)
+ bool transform_flowtext_with_frame = (dynamic_cast<SPFlowtext *>(item) && includes( dynamic_cast<SPFlowtext *>(item)->get_frame(NULL))); // (only the first frame is checked so far)
// ...both an offset and its source?
- bool transform_offset_with_source = (dynamic_cast<SPOffset *>(item) && dynamic_cast<SPOffset *>(item)->sourceHref) && set->includes( sp_offset_get_source(dynamic_cast<SPOffset *>(item)) );
+ bool transform_offset_with_source = (dynamic_cast<SPOffset *>(item) && dynamic_cast<SPOffset *>(item)->sourceHref) && includes( sp_offset_get_source(dynamic_cast<SPOffset *>(item)) );
// If we're moving a connector, we want to detach it
// from shapes that aren't part of the selection, but
@@ -1597,7 +1585,7 @@ void sp_object_set_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool
SPItem *attItem[2] = {0, 0};
path->connEndPair.getAttachedItems(attItem);
for (int n = 0; n < 2; ++n) {
- if (!set->includes(attItem[n])) {
+ if (!includes(attItem[n])) {
sp_conn_end_detach(item, n);
}
}
@@ -1719,31 +1707,24 @@ void sp_object_set_apply_affine(ObjectSet *set, Geom::Affine const &affine, bool
}
}
-void sp_object_set_remove_transform(SPDesktop *desktop)
+void ObjectSet::removeTransform()
{
- if (desktop == NULL)
- return;
-
- Inkscape::Selection *selection = desktop->getSelection();
-
- auto items = selection->xmlNodes();
+ auto items = xmlNodes();
for (auto l=items.begin();l!=items.end() ;++l) {
(*l)->setAttribute("transform", NULL, false);
}
- DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN,
+ if(document())
+ DocumentUndo::done(document(), SP_VERB_OBJECT_FLATTEN,
_("Remove transform"));
}
-void
-sp_object_set_scale_absolute(ObjectSet *set,
- double x0, double x1,
- double y0, double y1)
+void ObjectSet::setScaleAbsolute(double x0, double x1,double y0, double y1)
{
- if (set->isEmpty())
+ if (isEmpty())
return;
- Geom::OptRect bbox = set->visualBounds();
+ Geom::OptRect bbox = visualBounds();
if ( !bbox ) {
return;
}
@@ -1756,16 +1737,15 @@ sp_object_set_scale_absolute(ObjectSet *set,
Geom::Translate const o2n(x0, y0);
Geom::Affine const final( p2o * scale * o2n );
- sp_object_set_apply_affine(set, final);
+ applyAffine(final);
}
-
-void sp_object_set_scale_relative(ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale)
+void ObjectSet::setScaleRelative(Geom::Point const &align, Geom::Scale const &scale)
{
- if (set->isEmpty())
+ if (isEmpty())
return;
- Geom::OptRect bbox = set->visualBounds();
+ Geom::OptRect bbox = visualBounds();
if ( !bbox ) {
return;
@@ -1781,21 +1761,19 @@ void sp_object_set_scale_relative(ObjectSet *set, Geom::Point const &align, Geom
Geom::Translate const n2d(-align);
Geom::Translate const d2n(align);
Geom::Affine const final( n2d * scale * d2n );
- sp_object_set_apply_affine(set, final);
+ applyAffine(final);
}
-void
-sp_object_set_rotate_relative(ObjectSet *set, Geom::Point const &center, double angle_degrees)
+void ObjectSet::rotateRelative(Geom::Point const &center, double angle_degrees)
{
Geom::Translate const d2n(center);
Geom::Translate const n2d(-center);
Geom::Rotate const rotate(Geom::Rotate::from_degrees(angle_degrees));
Geom::Affine const final( Geom::Affine(n2d) * rotate * d2n );
- sp_object_set_apply_affine(set, final);
+ applyAffine(final);
}
-void
-sp_object_set_skew_relative(ObjectSet *set, Geom::Point const &align, double dx, double dy)
+void ObjectSet::skewRelative(Geom::Point const &align, double dx, double dy)
{
Geom::Translate const d2n(align);
Geom::Translate const n2d(-align);
@@ -1803,32 +1781,30 @@ sp_object_set_skew_relative(ObjectSet *set, Geom::Point const &align, double dx,
dx, 1,
0, 0);
Geom::Affine const final( n2d * skew * d2n );
- sp_object_set_apply_affine(set, final);
+ applyAffine(final);
}
-void sp_object_set_move_relative(ObjectSet *set, Geom::Point const &move, bool compensate)
+void ObjectSet::moveRelative(Geom::Point const &move, bool compensate)
{
- sp_object_set_apply_affine(set, Geom::Affine(Geom::Translate(move)), true, compensate);
+ applyAffine(Geom::Affine(Geom::Translate(move)), true, compensate);
}
-void sp_object_set_move_relative(ObjectSet *set, double dx, double dy)
+void ObjectSet::moveRelative(double dx, double dy)
{
- sp_object_set_apply_affine(set, Geom::Affine(Geom::Translate(dx, dy)));
+ applyAffine(Geom::Affine(Geom::Translate(dx, dy)));
}
/**
* Rotates selected objects 90 degrees, either clock-wise or counter-clockwise, depending on the value of ccw.
*/
-void sp_selection_rotate_90(SPDesktop *desktop, bool ccw)
+void ObjectSet::rotate90(bool ccw)
{
- Inkscape::Selection *selection = desktop->getSelection();
-
- if (selection->isEmpty())
+ if (isEmpty())
return;
- auto items = selection->items();
+ auto items_copy = items();
Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw
- for (auto l=items.begin();l!=items.end() ;++l) {
+ for (auto l=items_copy.begin();l!=items_copy.end() ;++l) {
SPItem *item = *l;
if (item) {
sp_item_rotate_rel(item, rot_90);
@@ -1837,25 +1813,23 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw)
}
}
- DocumentUndo::done(desktop->getDocument(),
+ DocumentUndo::done(document(),
ccw ? SP_VERB_OBJECT_ROTATE_90_CCW : SP_VERB_OBJECT_ROTATE_90_CW,
ccw ? _("Rotate 90\xc2\xb0 CCW") : _("Rotate 90\xc2\xb0 CW"));
}
-void
-sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees)
+void ObjectSet::rotate(gdouble const angle_degrees)
{
- if (selection->isEmpty())
+ if (isEmpty())
return;
- boost::optional<Geom::Point> center = selection->center();
- if (!center) {
+ boost::optional<Geom::Point> center_ = center();
+ if (!center_) {
return;
}
+ rotateRelative(*center_, angle_degrees);
- sp_object_set_rotate_relative(selection, *center, angle_degrees);
-
- DocumentUndo::maybeDone(selection->desktop()->getDocument(),
+ DocumentUndo::maybeDone(document(),
( ( angle_degrees > 0 )
? "selector:rotate:ccw"
: "selector:rotate:cw" ),
@@ -2183,28 +2157,27 @@ cornerFarthestFrom(Geom::Rect const &r, Geom::Point const &p){
/**
\param angle the angle in "angular pixels", i.e. how many visible pixels must move the outermost point of the rotated object
*/
-void
-sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle)
+void ObjectSet::rotateScreen(double angle)
{
- if (selection->isEmpty())
+ if (isEmpty()||!desktop())
return;
- Geom::OptRect bbox = selection->visualBounds();
- boost::optional<Geom::Point> center = selection->center();
+ Geom::OptRect bbox = visualBounds();
+ boost::optional<Geom::Point> center_ = center();
- if ( !bbox || !center ) {
+ if ( !bbox || !center_ ) {
return;
}
- gdouble const zoom = selection->desktop()->current_zoom();
+ gdouble const zoom = desktop()->current_zoom();
gdouble const zmove = angle / zoom;
- gdouble const r = Geom::L2(cornerFarthestFrom(*bbox, *center) - *center);
+ gdouble const r = Geom::L2(cornerFarthestFrom(*bbox, *center_) - *center_);
gdouble const zangle = 180 * atan2(zmove, r) / M_PI;
- sp_object_set_rotate_relative(selection, *center, zangle);
+ rotateRelative(*center_, zangle);
- DocumentUndo::maybeDone(selection->desktop()->getDocument(),
+ DocumentUndo::maybeDone(document(),
( (angle > 0)
? "selector:rotate:ccw"
: "selector:rotate:cw" ),
@@ -2212,18 +2185,17 @@ sp_selection_rotate_screen(Inkscape::Selection *selection, gdouble angle)
_("Rotate by pixels"));
}
-void
-sp_selection_scale(Inkscape::Selection *selection, gdouble grow)
+void ObjectSet::scale(double grow)
{
- if (selection->isEmpty())
+ if (isEmpty())
return;
- Geom::OptRect bbox = selection->visualBounds();
+ Geom::OptRect bbox = visualBounds();
if (!bbox) {
return;
}
- Geom::Point const center(bbox->midpoint());
+ Geom::Point const center_(bbox->midpoint());
// you can't scale "do nizhe pola" (below zero)
double const max_len = bbox->maxExtent();
@@ -2232,9 +2204,9 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow)
}
double const times = 1.0 + grow / max_len;
- sp_object_set_scale_relative(selection, center, Geom::Scale(times, times));
+ setScaleRelative(center_, Geom::Scale(times, times));
- DocumentUndo::maybeDone(selection->desktop()->getDocument(),
+ DocumentUndo::maybeDone(document(),
( (grow > 0)
? "selector:scale:larger"
: "selector:scale:smaller" ),
@@ -2242,40 +2214,39 @@ sp_selection_scale(Inkscape::Selection *selection, gdouble grow)
_("Scale"));
}
-void
-sp_selection_scale_screen(Inkscape::Selection *selection, gdouble grow_pixels)
+void ObjectSet::scaleScreen(double grow_pixels)
{
- sp_selection_scale(selection, grow_pixels / selection->desktop()->current_zoom());
+ if(!desktop())
+ return;
+ scale(grow_pixels / desktop()->current_zoom());
}
-void
-sp_selection_scale_times(Inkscape::Selection *selection, gdouble times)
+void ObjectSet::scaleTimes(double times)
{
- if (selection->isEmpty())
+ if (isEmpty())
return;
- Geom::OptRect sel_bbox = selection->visualBounds();
+ Geom::OptRect sel_bbox = visualBounds();
if (!sel_bbox) {
return;
}
- Geom::Point const center(sel_bbox->midpoint());
- sp_object_set_scale_relative(selection, center, Geom::Scale(times, times));
- DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_CONTEXT_SELECT,
+ Geom::Point const center_(sel_bbox->midpoint());
+ setScaleRelative(center_, Geom::Scale(times, times));
+ DocumentUndo::done(document(), SP_VERB_CONTEXT_SELECT,
_("Scale by whole factor"));
}
-void
-sp_selection_move(Inkscape::Selection *selection, gdouble dx, gdouble dy)
+void ObjectSet::move(double dx, double dy)
{
- if (selection->isEmpty()) {
+ if (isEmpty()) {
return;
}
- sp_object_set_move_relative(selection, dx, dy);
+ moveRelative(dx, dy);
- SPDocument *doc = selection->layers()->getDocument();
+ SPDocument *doc = document();
if (dx == 0) {
DocumentUndo::maybeDone(doc, "selector:move:vertical", SP_VERB_CONTEXT_SELECT,
_("Move vertically"));
@@ -2288,20 +2259,19 @@ sp_selection_move(Inkscape::Selection *selection, gdouble dx, gdouble dy)
}
}
-void
-sp_selection_move_screen(Inkscape::Selection *selection, gdouble dx, gdouble dy)
+void ObjectSet::moveScreen(double dx, double dy)
{
- if (selection->isEmpty() || !selection->desktop()) {
+ if (isEmpty() || !desktop()) {
return;
}
// same as sp_selection_move but divide deltas by zoom factor
- gdouble const zoom = selection->desktop()->current_zoom();
+ gdouble const zoom = desktop()->current_zoom();
gdouble const zdx = dx / zoom;
gdouble const zdy = dy / zoom;
- sp_object_set_move_relative(selection, zdx, zdy);
+ moveRelative(zdx, zdy);
- SPDocument *doc = selection->layers()->getDocument();
+ SPDocument *doc = document();
if (dx == 0) {
DocumentUndo::maybeDone(doc, "selector:move:vertical", SP_VERB_CONTEXT_SELECT,
_("Move vertically by pixels"));
@@ -2531,7 +2501,7 @@ void sp_selection_next_patheffect_param(SPDesktop * dt)
return false;
}*/
-void sp_selection_edit_clip_or_mask(SPDesktop * /*dt*/, bool /*clip*/)
+void ObjectSet::editMask(bool /*clip*/)
{
return;
/*if (!dt) return;
@@ -2590,26 +2560,24 @@ void scroll_to_show_item(SPDesktop *desktop, SPItem *item)
}
}
-
-void sp_selection_clone(SPDesktop *desktop)
+void ObjectSet::clone()
{
- if (desktop == NULL) {
+ if (document() == NULL) {
return;
}
- Inkscape::Selection *selection = desktop->getSelection();
-
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ Inkscape::XML::Document *xml_doc = document()->getReprDoc();
// check if something is selected
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object</b> to clone."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object</b> to clone."));
return;
}
- std::vector<Inkscape::XML::Node*> reprs(selection->xmlNodes().begin(), selection->xmlNodes().end());
+ std::vector<Inkscape::XML::Node*> reprs(xmlNodes().begin(), xmlNodes().end());
- selection->clear();
+ clear();
// sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need
sort(reprs.begin(),reprs.end(),sp_repr_compare_position_bool);
@@ -2637,37 +2605,33 @@ void sp_selection_clone(SPDesktop *desktop)
Inkscape::GC::release(clone);
}
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_CLONE,
+ DocumentUndo::done(document(), SP_VERB_EDIT_CLONE,
C_("Action", "Clone"));
- selection->setReprList(newsel);
+ setReprList(newsel);
}
-void
-sp_selection_relink(SPDesktop *desktop)
+void ObjectSet::relink()
{
- if (!desktop)
- return;
-
- Inkscape::Selection *selection = desktop->getSelection();
-
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>clones</b> to relink."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>clones</b> to relink."));
return;
}
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
const gchar *newid = cm->getFirstObjectID();
if (!newid) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Copy an <b>object</b> to clipboard to relink clones to."));
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Copy an <b>object</b> to clipboard to relink clones to."));
return;
}
gchar *newref = g_strdup_printf("#%s", newid);
// Get a copy of current selection.
bool relinked = false;
- auto items= selection->items();
- for (auto i=items.begin();i!=items.end();++i){
+ auto items_= items();
+ for (auto i=items_.begin();i!=items_.end();++i){
SPItem *item = *i;
if (dynamic_cast<SPUse *>(item)) {
@@ -2680,33 +2644,29 @@ sp_selection_relink(SPDesktop *desktop)
g_free(newref);
if (!relinked) {
- desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to relink</b> in the selection."));
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to relink</b> in the selection."));
} else {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNLINK_CLONE,
+ DocumentUndo::done(document(), SP_VERB_EDIT_UNLINK_CLONE,
_("Relink clone"));
}
}
-void
-sp_selection_unlink(SPDesktop *desktop)
+void ObjectSet::unlink()
{
- if (!desktop)
- return;
-
- Inkscape::Selection *selection = desktop->getSelection();
-
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>clones</b> to unlink."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>clones</b> to unlink."));
return;
}
// Get a copy of current selection.
std::vector<SPItem*> new_select;
bool unlinked = false;
- std::vector<SPItem *> items(selection->items().begin(), selection->items().end());
+ std::vector<SPItem *> items_(items().begin(), items().end());
- for (auto i=items.rbegin();i!=items.rend();++i){
+ for (auto i=items_.rbegin();i!=items_.rend();++i){
SPItem *item = *i;
if (dynamic_cast<SPText *>(item)) {
@@ -2747,34 +2707,30 @@ sp_selection_unlink(SPDesktop *desktop)
}
if (!new_select.empty()) { // set new selection
- selection->clear();
- selection->setList(new_select);
+ clear();
+ setList(new_select);
}
if (!unlinked) {
- desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection."));
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection."));
}
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNLINK_CLONE,
+ DocumentUndo::done(document(), SP_VERB_EDIT_UNLINK_CLONE,
_("Unlink clone"));
}
-void
-sp_select_clone_original(SPDesktop *desktop)
+void ObjectSet::cloneOriginal()
{
- if (desktop == NULL)
- return;
-
- Inkscape::Selection *selection = desktop->getSelection();
-
- SPItem *item = selection->singleItem();
+ SPItem *item = singleItem();
gchar const *error = _("Select a <b>clone</b> to go to its original. Select a <b>linked offset</b> to go to its source. Select a <b>text on path</b> to go to the path. Select a <b>flowed text</b> to go to its frame.");
// Check if other than two objects are selected
- auto items= selection->items();
- if (boost::distance(items) != 1 || !item) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error);
+ auto items_= items();
+ if (boost::distance(items_) != 1 || !item) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, error);
return;
}
@@ -2813,18 +2769,21 @@ sp_select_clone_original(SPDesktop *desktop)
}
if (original == NULL) { // it's an object that we don't know what to do with
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error);
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, error);
return;
}
if (!original) {
- desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>Cannot find</b> the object to select (orphaned clone, offset, textpath, flowed text?)"));
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>Cannot find</b> the object to select (orphaned clone, offset, textpath, flowed text?)"));
return;
}
for (SPObject *o = original; o && !dynamic_cast<SPRoot *>(o); o = o->parent) {
if (dynamic_cast<SPDefs *>(o)) {
- desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The object you're trying to select is <b>not visible</b> (it is in &lt;defs&gt;)"));
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The object you're trying to select is <b>not visible</b> (it is in &lt;defs&gt;)"));
return;
}
}
@@ -2835,24 +2794,24 @@ sp_select_clone_original(SPDesktop *desktop)
if (highlight) {
Geom::OptRect a = item->desktopVisualBounds();
Geom::OptRect b = original->desktopVisualBounds();
- if ( a && b ) {
+ if ( a && b && desktop()) {
// draw a flashing line between the objects
SPCurve *curve = new SPCurve();
curve->moveto(a->midpoint());
curve->lineto(b->midpoint());
- SPCanvasItem * canvasitem = sp_canvas_bpath_new(desktop->getTempGroup(), curve);
+ SPCanvasItem * canvasitem = sp_canvas_bpath_new(desktop()->getTempGroup(), curve);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvasitem), 0x0000ddff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT, 5, 3);
sp_canvas_item_show(canvasitem);
curve->unref();
- desktop->add_temporary_canvasitem(canvasitem, 1000);
+ desktop()->add_temporary_canvasitem(canvasitem, 1000);
}
}
- selection->clear();
- selection->set(original);
- if (SP_CYCLING == SP_CYCLE_FOCUS) {
- scroll_to_show_item(desktop, original);
+ clear();
+ set(original);
+ if (SP_CYCLING == SP_CYCLE_FOCUS && desktop()) {
+ scroll_to_show_item(desktop(), original);
}
}
}
@@ -2860,18 +2819,13 @@ sp_select_clone_original(SPDesktop *desktop)
/**
* This creates a new path, applies the Original Path LPE, and has it refer to the selection.
*/
-void sp_selection_clone_original_path_lpe(SPDesktop *desktop)
+void ObjectSet::cloneOriginalPathLPE()
{
- if (desktop == NULL) {
- return;
- }
-
- Inkscape::Selection *selection = desktop->getSelection();
Inkscape::SVGOStringStream os;
SPObject * firstItem = NULL;
- auto items= selection->items();
- for (auto i=items.begin();i!=items.end();++i){
+ auto items_= items();
+ for (auto i=items_.begin();i!=items_.end();++i){
if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) {
if (firstItem) {
os << "|";
@@ -2882,7 +2836,7 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop)
}
}
if (firstItem) {
- Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
+ Inkscape::XML::Document *xml_doc = document()->getReprDoc();
SPObject *parent = firstItem->parent;
// create the LPE
@@ -2890,7 +2844,7 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop)
{
lpe_repr->setAttribute("effect", "fill_between_many");
lpe_repr->setAttribute("linkedpaths", os.str());
- desktop->doc()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to <defs> and assigns the 'id' attribute
+ document()->getDefs()->getRepr()->addChild(lpe_repr, NULL); // adds to <defs> and assigns the 'id' attribute
}
std::string lpe_id_href = std::string("#") + lpe_repr->attribute("id");
Inkscape::GC::release(lpe_repr);
@@ -2901,44 +2855,44 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop)
clone->setAttribute("d", "M 0 0", false);
// add the new clone to the top of the original's parent
parent->appendChildRepr(clone);
- SPObject *clone_obj = desktop->doc()->getObjectById(clone->attribute("id"));
+ SPObject *clone_obj = document()->getObjectById(clone->attribute("id"));
SPLPEItem *clone_lpeitem = dynamic_cast<SPLPEItem *>(clone_obj);
if (clone_lpeitem) {
clone_lpeitem->addPathEffect(lpe_id_href, false);
}
}
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, _("Fill between many"));
+ DocumentUndo::done(document(), SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE, _("Fill between many"));
// select the new object:
- selection->set(clone);
+ set(clone);
Inkscape::GC::release(clone);
} else {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to fill."));
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select path(s) to fill."));
}
}
-void sp_selection_to_marker(SPDesktop *desktop, bool apply)
+void ObjectSet::toMarker(bool apply)
{
// sp_selection_tile has similar code
- if (desktop == NULL) {
+ if (desktop() == NULL) { // TODO: We should not need desktop for that.
+ // Someone get rid of the dt2doc() call.
return;
}
- SPDocument *doc = desktop->getDocument();
+ SPDocument *doc = document();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = desktop->getSelection();
-
// check if something is selected
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to marker."));
+ if (isEmpty()) {
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to marker."));
return;
}
doc->ensureUpToDate();
- Geom::OptRect r = selection->visualBounds();
- boost::optional<Geom::Point> c = selection->center();
+ Geom::OptRect r = visualBounds();
+ boost::optional<Geom::Point> c = center();
if ( !r || !c ) {
return;
}
@@ -2955,12 +2909,10 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
Geom::Point center( *c - corner ); // As defined by rotation center
center[Geom::Y] = -center[Geom::Y];
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
-
- //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed?
+ std::vector<SPItem*> items_(items().begin(), items().end());
// bottommost object, after sorting
- SPObject *parent = items.front()->parent;
+ SPObject *parent = items_.front()->parent;
Geom::Affine parent_transform;
{
@@ -2974,17 +2926,17 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply)
// Create a list of duplicates, to be pasted inside marker element.
std::vector<Inkscape::XML::Node*> repr_copies;
- for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();++i){
+ for (std::vector<SPItem*>::const_reverse_iterator i=items_.rbegin();i!=items_.rend();++i){
Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc);
repr_copies.push_back(dup);
}
- Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
+ Geom::Rect bbox(desktop()->dt2doc(r->min()), desktop()->dt2doc(r->max()));
if (apply) {
// Delete objects so that their clones don't get alerted;
// the objects will be restored inside the marker element.
- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ for (std::vector<SPItem*>::const_iterator i=items_.begin();i!=items_.end();++i){
SPObject *item = *i;
item->deleteObject(false);
}
@@ -3021,18 +2973,15 @@ static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) {
}
}
-void sp_selection_to_guides(SPDesktop *desktop)
+void ObjectSet::toGuides()
{
- if (desktop == NULL)
- return;
-
- SPDocument *doc = desktop->getDocument();
- Inkscape::Selection *selection = desktop->getSelection();
+ SPDocument *doc = document();
// we need to copy the list because it gets reset when objects are deleted
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> items_(items().begin(), items().end());
- if (items.empty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides."));
return;
}
@@ -3044,13 +2993,13 @@ void sp_selection_to_guides(SPDesktop *desktop)
// and its entry in the selection list is invalid (crash).
// Therefore: first convert all, then delete all.
- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ for (std::vector<SPItem*>::const_iterator i=items_.begin();i!=items_.end();++i){
sp_selection_to_guides_recursive(*i, wholegroups);
}
if (deleteitems) {
- selection->clear();
- sp_selection_delete_impl(items);
+ clear();
+ sp_selection_delete_impl(items_);
}
DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides"));
@@ -3076,38 +3025,34 @@ void sp_selection_to_guides(SPDesktop *desktop)
* For SVG2, set 'refX' 'refY' to object center (with compensating shift in <use>
* transformation).
*/
-void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
+void ObjectSet::toSymbol()
{
- if (desktop == NULL) {
- return;
- }
- SPDocument *doc = desktop->getDocument();
+ SPDocument *doc = document();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = desktop->getSelection();
-
// Check if something is selected.
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>objects</b> to convert to symbol."));
+ if (isEmpty()) {
+ if (desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>objects</b> to convert to symbol."));
return;
}
doc->ensureUpToDate();
- std::vector<SPObject*> items(selection->objects().begin(), selection->objects().end());
- sort(items.begin(),items.end(),sp_object_compare_position_bool);
+ std::vector<SPObject*> items_(objects().begin(), objects().end());
+ sort(items_.begin(),items_.end(),sp_object_compare_position_bool);
// Keep track of parent, this is where <use> will be inserted.
- Inkscape::XML::Node *the_first_repr = items[0]->getRepr();
+ Inkscape::XML::Node *the_first_repr = items_[0]->getRepr();
Inkscape::XML::Node *the_parent_repr = the_first_repr->parent();
// Find out if we have a single group
bool single_group = false;
SPGroup *the_group = NULL;
Geom::Affine transform;
- if( items.size() == 1 ) {
- SPObject *object = items[0];
+ if( items_.size() == 1 ) {
+ SPObject *object = items_[0];
the_group = dynamic_cast<SPGroup *>(object);
if ( the_group ) {
single_group = true;
@@ -3118,7 +3063,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
if( transform.isTranslation() ) {
// Create new list from group children.
- items = object->childList(false);
+ items_ = object->childList(false);
// Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals
// without disturbing clones.
@@ -3162,7 +3107,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
}
// Move selected items to new <symbol>
- for (std::vector<SPObject*>::const_reverse_iterator i=items.rbegin();i!=items.rend();++i){
+ for (std::vector<SPObject*>::const_reverse_iterator i=items_.rbegin();i!=items_.rend();++i){
Inkscape::XML::Node *repr = (*i)->getRepr();
repr->parent()->removeChild(repr);
symbol_repr->addChild(repr,NULL);
@@ -3185,7 +3130,7 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
}
// Change selection to new <use> element.
- selection->set(clone);
+ set(clone);
// Clean up
Inkscape::GC::release(symbol_repr);
@@ -3196,29 +3141,25 @@ void sp_selection_symbol(SPDesktop *desktop, bool /*apply*/ )
/*
* Convert <symbol> to <g>. All <use> elements referencing symbol remain unchanged.
*/
-void sp_selection_unsymbol(SPDesktop *desktop)
+void ObjectSet::unSymbol()
{
- if (desktop == NULL) {
- return;
- }
-
- SPDocument *doc = desktop->getDocument();
+ SPDocument *doc = document();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = desktop->getSelection();
-
// Check if something is selected.
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a <b>symbol</b> to extract objects from."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select a <b>symbol</b> to extract objects from."));
return;
}
- SPObject* symbol = selection->single();
+ SPObject* symbol = single();
// Make sure we have only one object in selection.
// Require that we really have a <symbol>.
if( symbol == NULL || !dynamic_cast<SPSymbol *>( symbol )) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>symbol</b> in Symbol dialog to convert to group."));
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select only one <b>symbol</b> in Symbol dialog to convert to group."));
return;
}
@@ -3226,7 +3167,7 @@ void sp_selection_unsymbol(SPDesktop *desktop)
// Create new <g> and insert in current layer
Inkscape::XML::Node *group = xml_doc->createElement("svg:g");
- desktop->currentLayer()->getRepr()->appendChild(group);
+ symbol->parent->getRepr()->appendChild(group);
// Move all children of symbol to group
std::vector<SPObject*> children = symbol->childList(false);
@@ -3268,8 +3209,8 @@ void sp_selection_unsymbol(SPDesktop *desktop)
symbol->deleteObject(true);
// Change selection to new <g> element.
- SPItem *group_item = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(group));
- selection->set(group_item);
+ SPItem *group_item = static_cast<SPItem *>(document()->getObjectByRepr(group));
+ set(group_item);
// Clean up
Inkscape::GC::release(group);
@@ -3277,27 +3218,24 @@ void sp_selection_unsymbol(SPDesktop *desktop)
DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol"));
}
-void
-sp_selection_tile(SPDesktop *desktop, bool apply)
+void ObjectSet::tile(bool apply)
{
- // sp_selection_to_marker has similar code
- if (desktop == NULL) {
+ // toMarker has similar code
+ if (desktop() == NULL) { //same remark as in toMarker: no good reason to have this.
return;
}
- SPDocument *doc = desktop->getDocument();
+ SPDocument *doc = document();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = desktop->getSelection();
-
// check if something is selected
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to pattern."));
+ if (isEmpty()) {
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to pattern."));
return;
}
doc->ensureUpToDate();
- Geom::OptRect r = selection->visualBounds();
+ Geom::OptRect r = visualBounds();
if ( !r ) {
return;
}
@@ -3307,12 +3245,12 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
move_p[Geom::Y] = -move_p[Geom::Y];
Geom::Affine move = Geom::Affine(Geom::Translate(move_p));
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> items_(items().begin(), items().end());
- sort(items.begin(),items.end(),sp_object_compare_position_bool);
+ sort(items_.begin(),items_.end(),sp_object_compare_position_bool);
// bottommost object, after sorting
- SPObject *parent = items[0]->parent;
+ SPObject *parent = items_[0]->parent;
Geom::Affine parent_transform;
@@ -3326,20 +3264,20 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
}
// remember the position of the first item
- gint pos = items[0]->getRepr()->position();
+ gint pos = items_[0]->getRepr()->position();
// create a list of duplicates
std::vector<Inkscape::XML::Node*> repr_copies;
- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ for (std::vector<SPItem*>::const_iterator i=items_.begin();i!=items_.end();++i){
Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc);
repr_copies.push_back(dup);
}
- Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max()));
+ Geom::Rect bbox(desktop()->dt2doc(r->min()), desktop()->dt2doc(r->max()));
if (apply) {
// delete objects so that their clones don't get alerted; this object will be restored shortly
- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ for (std::vector<SPItem*>::const_iterator i=items_.begin();i!=items_.end();++i){
SPObject *item = *i;
item->deleteObject(false);
}
@@ -3353,7 +3291,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED);
gchar const *pat_id = SPPattern::produce(repr_copies, bbox, doc,
- ( Geom::Affine(Geom::Translate(desktop->dt2doc(Geom::Point(r->min()[Geom::X],
+ ( Geom::Affine(Geom::Translate(desktop()->dt2doc(Geom::Point(r->min()[Geom::X],
r->max()[Geom::Y]))))
* parent_transform.inverse() ),
parent_transform * move);
@@ -3378,12 +3316,12 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
// restore parent and position
parent->getRepr()->appendChild(rect);
rect->setPosition(pos > 0 ? pos : 0);
- SPItem *rectangle = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(rect));
+ SPItem *rectangle = static_cast<SPItem *>(document()->getObjectByRepr(rect));
Inkscape::GC::release(rect);
- selection->clear();
- selection->set(rectangle);
+ clear();
+ set(rectangle);
}
@@ -3391,20 +3329,16 @@ sp_selection_tile(SPDesktop *desktop, bool apply)
_("Objects to pattern"));
}
-void sp_selection_untile(SPDesktop *desktop)
+void ObjectSet::untile()
{
- if (desktop == NULL) {
- return;
- }
- SPDocument *doc = desktop->getDocument();
+ SPDocument *doc = document();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = desktop->getSelection();
-
// check if something is selected
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object with pattern fill</b> to extract objects from."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select an <b>object with pattern fill</b> to extract objects from."));
return;
}
@@ -3412,8 +3346,8 @@ void sp_selection_untile(SPDesktop *desktop)
bool did = false;
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
- for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();++i){
+ std::vector<SPItem*> items_(items().begin(), items().end());
+ for (std::vector<SPItem*>::const_reverse_iterator i=items_.rbegin();i!=items_.rend();++i){
SPItem *item = *i;
SPStyle *style = item->style;
@@ -3438,7 +3372,7 @@ void sp_selection_untile(SPDesktop *desktop)
for (auto& child: pattern->children) {
if (dynamic_cast<SPItem *>(&child)) {
Inkscape::XML::Node *copy = child.getRepr()->duplicate(xml_doc);
- SPItem *i = dynamic_cast<SPItem *>(desktop->currentLayer()->appendChildRepr(copy));
+ SPItem *i = dynamic_cast<SPItem *>(item->parent->appendChildRepr(copy));
// FIXME: relink clones to the new canvas objects
// use SPObject::setid when mental finishes it to steal ids of
@@ -3463,21 +3397,22 @@ void sp_selection_untile(SPDesktop *desktop)
}
if (!did) {
- desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No pattern fills</b> in the selection."));
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No pattern fills</b> in the selection."));
} else {
- DocumentUndo::done(desktop->getDocument(), SP_VERB_EDIT_UNTILE,
+ DocumentUndo::done(document(), SP_VERB_EDIT_UNTILE,
_("Pattern to objects"));
- selection->setList(new_select);
+ setList(new_select);
}
}
-void sp_object_set_get_export_hints(ObjectSet *set, Glib::ustring &filename, float *xdpi, float *ydpi)
+void ObjectSet::getExportHints(Glib::ustring &filename, float *xdpi, float *ydpi)
{
- if (set->isEmpty()) {
+ if (isEmpty()) {
return;
}
- auto reprlst = set->xmlNodes();
+ auto reprlst = xmlNodes();
bool filename_search = TRUE;
bool xdpi_search = TRUE;
bool ydpi_search = TRUE;
@@ -3539,40 +3474,38 @@ void sp_document_get_export_hints(SPDocument *doc, Glib::ustring &filename, floa
}
}
-void sp_selection_create_bitmap_copy(SPDesktop *desktop)
+void ObjectSet::createBitmapCopy()
{
- if (desktop == NULL) {
- return;
- }
- SPDocument *document = desktop->getDocument();
- Inkscape::XML::Document *xml_doc = document->getReprDoc();
-
- Inkscape::Selection *selection = desktop->getSelection();
+ SPDocument *doc = document();
+ Inkscape::XML::Document *xml_doc = doc->getReprDoc();
// check if something is selected
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to make a bitmap copy."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to make a bitmap copy."));
return;
}
-
- desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Rendering bitmap..."));
- // set "busy" cursor
- desktop->setWaitingCursor();
+ if(desktop()){
+ desktop()->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Rendering bitmap..."));
+ // set "busy" cursor
+ desktop()->setWaitingCursor();
+ }
// Get the bounding box of the selection
- document->ensureUpToDate();
- Geom::OptRect bbox = selection->visualBounds();
+ doc->ensureUpToDate();
+ Geom::OptRect bbox = visualBounds();
if (!bbox) {
- desktop->clearWaitingCursor();
+ if(desktop())
+ desktop()->clearWaitingCursor();
return; // exceptional situation, so not bother with a translatable error message, just quit quietly
}
// List of the items to show; all others will be hidden
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> items_(items().begin(), items().end());
// Sort items so that the topmost comes last
- sort(items.begin(),items.end(),sp_item_repr_compare_position_bool);
+ sort(items_.begin(),items_.end(),sp_item_repr_compare_position_bool);
// Generate a random value from the current time (you may create bitmap from the same object(s)
// multiple times, and this is done so that they don't clash)
@@ -3582,8 +3515,8 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
// Create the filename.
gchar *const basename = g_strdup_printf("%s-%s-%u.png",
- document->getName(),
- items[0]->getRepr()->attribute("id"),
+ doc->getName(),
+ items_[0]->getRepr()->attribute("id"),
current);
// Imagemagick is known not to handle spaces in filenames, so we replace anything but letters,
// digits, and a few other chars, with "_"
@@ -3591,8 +3524,8 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
// Build the complete path by adding document base dir, if set, otherwise home dir
gchar *directory = NULL;
- if ( document->getURI() ) {
- directory = g_path_get_dirname( document->getURI() );
+ if ( doc->getURI() ) {
+ directory = g_path_get_dirname( doc->getURI() );
}
if (directory == NULL) {
directory = INKSCAPE.homedir_path(NULL);
@@ -3603,8 +3536,8 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
//g_print("%s\n", filepath);
// Remember parent and z-order of the topmost one
- gint pos = items.back()->getRepr()->position();
- SPObject *parent_object = items.back()->parent;
+ gint pos = items_.back()->getRepr()->position();
+ SPObject *parent_object = items_.back()->parent;
Inkscape::XML::Node *parent = parent_object->getRepr();
// Calculate resolution
@@ -3622,12 +3555,12 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
float hint_xdpi = 0, hint_ydpi = 0;
Glib::ustring hint_filename;
// take resolution hint from the selected objects
- sp_object_set_get_export_hints(selection, hint_filename, &hint_xdpi, &hint_ydpi);
+ getExportHints(hint_filename, &hint_xdpi, &hint_ydpi);
if (hint_xdpi != 0) {
res = hint_xdpi;
} else {
// take resolution hint from the document
- sp_document_get_export_hints(document, hint_filename, &hint_xdpi, &hint_ydpi);
+ sp_document_get_export_hints(doc, hint_filename, &hint_xdpi, &hint_ydpi);
if (hint_xdpi != 0) {
res = hint_xdpi;
} else {
@@ -3687,14 +3620,14 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
// TODO: avoid roundtrip via file
// Do the export
- sp_export_png_file(document, filepath,
+ sp_export_png_file(doc, filepath,
bbox->min()[Geom::X], bbox->min()[Geom::Y],
bbox->max()[Geom::X], bbox->max()[Geom::Y],
width, height, res, res,
(guint32) 0xffffff00,
NULL, NULL,
true, /*bool force_overwrite,*/
- items);
+ items_);
// Run filter, if any
if (run) {
@@ -3732,19 +3665,19 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
repr->setPosition(pos > 0 ? pos + 1 : 1);
// Set selection to the new image
- selection->clear();
- selection->add(repr);
+ clear();
+ add(repr);
// Clean up
Inkscape::GC::release(repr);
g_object_unref(pb);
// Complete undoable transaction
- DocumentUndo::done(document, SP_VERB_SELECTION_CREATE_BITMAP,
+ DocumentUndo::done(doc, SP_VERB_SELECTION_CREATE_BITMAP,
_("Create bitmap"));
}
-
- desktop->clearWaitingCursor();
+ if(desktop())
+ desktop()->clearWaitingCursor();
g_free(basename);
g_free(filepath);
@@ -3756,25 +3689,22 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop)
* to clip the entire group using a few <use>s and generally irritating me.
*/
-void sp_selection_set_clipgroup(SPDesktop *desktop)
+void ObjectSet::setClipGroup()
{
- if (desktop == NULL) {
- return;
- }
- SPDocument* doc = desktop->getDocument();
+ SPDocument* doc = document();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = desktop->getSelection();
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));
return;
}
- std::vector<Inkscape::XML::Node*> p(selection->xmlNodes().begin(), selection->xmlNodes().end());
+ std::vector<Inkscape::XML::Node*> p(xmlNodes().begin(), xmlNodes().end());
sort(p.begin(),p.end(),sp_repr_compare_position_bool);
- selection->clear();
+ clear();
int topmost = (p.back())->position();
Inkscape::XML::Node *topmost_parent = (p.back())->parent();
@@ -3851,7 +3781,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop)
Inkscape::GC::release(clone);
- selection->set(outer);
+ set(outer);
DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Create Clip Group"));
}
@@ -3864,30 +3794,29 @@ void sp_selection_set_clipgroup(SPDesktop *desktop)
* If \a apply_clip_path parameter is true, clipPath is created, otherwise mask
*
*/
-void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer, bool skip_undo)
+ void ObjectSet::setMask(bool apply_clip_path, bool apply_to_layer, bool skip_undo)
{
- if (desktop == NULL) {
+ if(!desktop() && apply_to_layer)
return;
- }
- SPDocument *doc = desktop->getDocument();
+ SPDocument *doc = document();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = desktop->getSelection();
-
// check if something is selected
- bool is_empty = selection->isEmpty();
+ bool is_empty = isEmpty();
if ( apply_to_layer && is_empty) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from."));
return;
- } else if (!apply_to_layer && ( is_empty || boost::distance(selection->items())==1 )) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to."));
+ } else if (!apply_to_layer && ( is_empty || boost::distance(items())==1 )) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to."));
return;
}
// FIXME: temporary patch to prevent crash!
// Remove this when bboxes are fixed to not blow up on an item clipped/masked with its own clone
- bool clone_with_original = object_set_contains_both_clone_and_original(selection);
+ bool clone_with_original = object_set_contains_both_clone_and_original(this);
if (clone_with_original) {
return; // in this version, you cannot clip/mask an object with its own clone
}
@@ -3895,12 +3824,12 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
doc->ensureUpToDate();
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
+ std::vector<SPItem*> items_(items().begin(), items().end());
- sort(items.begin(),items.end(),sp_object_compare_position_bool);
+ sort(items_.begin(),items_.end(),sp_object_compare_position_bool);
// See lp bug #542004
- selection->clear();
+ clear();
// create a list of duplicates
std::vector<Inkscape::XML::Node*> mask_items;
@@ -3915,12 +3844,12 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
if (apply_to_layer) {
// all selected items are used for mask, which is applied to a layer
- apply_to_items.push_back(SP_ITEM(desktop->currentLayer()));
+ apply_to_items.push_back(SP_ITEM(desktop()->currentLayer()));
}
- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i) {
- if((!topmost && !apply_to_layer && *i == items.front())
- || (topmost && !apply_to_layer && *i == items.back())
+ for (std::vector<SPItem*>::const_iterator i=items_.begin();i!=items_.end();++i) {
+ if((!topmost && !apply_to_layer && *i == items_.front())
+ || (topmost && !apply_to_layer && *i == items_.back())
|| apply_to_layer){
Geom::Affine oldtr=(*i)->transform;
@@ -3942,17 +3871,17 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
}
}
- items.clear();
+ items_.clear();
if (grouping == PREFS_MASKOBJECT_GROUPING_ALL) {
// group all those objects into one group
// and apply mask to that
- ObjectSet* set = new ObjectSet(selection->desktop());
+ ObjectSet* set = new ObjectSet(document());
set->add(apply_to_items.begin(), apply_to_items.end());
items_to_select.clear();
- Inkscape::XML::Node *group = sp_object_set_group(set);
+ Inkscape::XML::Node *group = set->group();
group->setAttribute("inkscape:groupmode", "maskhelper");
// apply clip/mask only to newly created group
@@ -4018,10 +3947,10 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
for (std::vector<SPItem*>::const_iterator i = items_to_delete.begin(); i != items_to_delete.end(); ++i) {
SPObject *item = reinterpret_cast<SPObject*>(*i);
item->deleteObject(false);
- items_to_select.erase(remove(items_to_select.begin(), items_to_select.end(), item), items_to_select.end());
+ items_to_select.erase(std::remove(items_to_select.begin(), items_to_select.end(), item), items_to_select.end());
}
- selection->addList(items_to_select);
+ addList(items_to_select);
if (!skip_undo) {
if (apply_clip_path) {
DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path"));
@@ -4031,18 +3960,14 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_
}
}
-void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
- if (desktop == NULL) {
- return;
- }
-
- SPDocument *doc = desktop->getDocument();
+void ObjectSet::unsetMask(bool apply_clip_path) {
+ SPDocument *doc = document();
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::Selection *selection = desktop->getSelection();
// check if something is selected
- if (selection->isEmpty()) {
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove clippath or mask from."));
+ if (isEmpty()) {
+ if(desktop())
+ desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove clippath or mask from."));
return;
}
@@ -4054,16 +3979,16 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
gchar const *attributeName = apply_clip_path ? "clip-path" : "mask";
std::map<SPObject*,SPItem*> referenced_objects;
- std::vector<SPItem*> items(selection->items().begin(), selection->items().end());
- selection->clear();
+ std::vector<SPItem*> items_(items().begin(), items().end());
+ clear();
GSList *items_to_ungroup = NULL;
- std::vector<SPItem*> items_to_select(items);
+ std::vector<SPItem*> items_to_select(items_);
// SPObject* refers to a group containing the clipped path or mask itself,
// whereas SPItem* refers to the item being clipped or masked
- for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();++i){
+ for (std::vector<SPItem*>::const_iterator i=items_.begin();i!=items_.end();++i){
if (remove_original) {
// remember referenced mask/clippath, so orphaned masks can be moved back to document
SPItem *item = *i;
@@ -4127,7 +4052,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
parent->appendChild(repr);
repr->setPosition((pos + 1) > 0 ? (pos + 1) : 0);
- SPItem *mask_item = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(repr));
+ SPItem *mask_item = static_cast<SPItem *>(document()->getObjectByRepr(repr));
items_to_select.push_back(mask_item);
// transform mask, so it is moved the same spot where mask was applied
@@ -4143,7 +4068,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) {
SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(i->data));
if (group) {
- items_to_select.erase(remove(items_to_select.begin(), items_to_select.end(), group), items_to_select.end());
+ items_to_select.erase(std::remove(items_to_select.begin(), items_to_select.end(), group), items_to_select.end());
std::vector<SPItem*> children;
sp_item_group_ungroup(group, children, false);
items_to_select.insert(items_to_select.end(),children.rbegin(),children.rend());
@@ -4155,7 +4080,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) {
g_slist_free(items_to_ungroup);
// rebuild selection
- selection->addList(items_to_select);
+ addList(items_to_select);
if (apply_clip_path) {
DocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path"));
diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h
index 72e4acc66..969a6e35a 100644
--- a/src/selection-chemistry.h
+++ b/src/selection-chemistry.h
@@ -51,8 +51,6 @@ namespace LivePathEffect {
};
} // namespace Inkscape
-void sp_selection_delete(SPDesktop *desktop);
-void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone = false, bool duplicateLayer = false);
void sp_edit_clear_all(Inkscape::Selection *selection);
void sp_edit_select_all(SPDesktop *desktop);
@@ -60,82 +58,20 @@ void sp_edit_select_all_in_all_layers (SPDesktop *desktop);
void sp_edit_invert (SPDesktop *desktop);
void sp_edit_invert_in_all_layers (SPDesktop *desktop);
-void sp_selection_clone(SPDesktop *desktop);
-void sp_selection_unlink(SPDesktop *desktop);
-void sp_selection_relink(SPDesktop *desktop);
-void sp_select_clone_original(SPDesktop *desktop);
-void sp_selection_clone_original_path_lpe(SPDesktop *desktop);
-
-void sp_selection_to_marker(SPDesktop *desktop, bool apply = true);
-void sp_selection_to_guides(SPDesktop *desktop);
-
-void sp_selection_symbol(SPDesktop *desktop, bool apply = true);
-void sp_selection_unsymbol(SPDesktop *desktop);
-
-void sp_selection_tile(SPDesktop *desktop, bool apply = true);
-void sp_selection_untile(SPDesktop *desktop);
-
-void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop);
-void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop);
-void sp_selection_ungroup_pop_selection(Inkscape::Selection *selection, SPDesktop *desktop);
-
-void sp_object_set_raise(Inkscape::ObjectSet *set);
-void sp_object_set_raise_to_top(Inkscape::ObjectSet *set);
-void sp_object_set_lower(Inkscape::ObjectSet *set);
-void sp_object_set_lower_to_bottom(Inkscape::ObjectSet *set);
-
-void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop);
-void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo = false);
-void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop);
-void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *desktop, bool skip_undo = false);
SPCSSAttr *take_style_from_item (SPObject *object);
-void sp_selection_cut(SPDesktop *desktop);
-void sp_selection_copy(SPDesktop *desktop);
void sp_selection_paste(SPDesktop *desktop, bool in_place);
-void sp_selection_paste_style(SPDesktop *desktop);
-void sp_selection_paste_livepatheffect(SPDesktop *desktop);
-void sp_selection_remove_livepatheffect(SPDesktop *desktop);
-
-void sp_selection_remove_filter(SPDesktop *desktop);
void sp_set_style_clipboard (SPCSSAttr *css);
-void sp_selection_paste_size(SPDesktop *desktop, bool apply_x, bool apply_y);
-void sp_selection_paste_size_separately(SPDesktop *desktop, bool apply_x, bool apply_y);
-
-void sp_selection_to_next_layer( SPDesktop *desktop, bool suppressDone = false );
-void sp_selection_to_prev_layer( SPDesktop *desktop, bool suppressDone = false );
-void sp_selection_to_layer( SPDesktop *desktop, SPObject *layer, bool suppressDone = false );
-
-void sp_object_set_apply_affine(Inkscape::ObjectSet *set, Geom::Affine const &affine, bool set_i2d = true,
- bool compensate = true, bool adjust_transf_center = true);
-void sp_object_set_remove_transform(SPDesktop *desktop);
-void sp_object_set_scale_absolute(Inkscape::ObjectSet *set, double x0, double x1, double y0, double y1);
-void sp_object_set_scale_relative(Inkscape::ObjectSet *set, Geom::Point const &align, Geom::Scale const &scale);
-void sp_object_set_rotate_relative(Inkscape::ObjectSet *set, Geom::Point const &center, double angle);
-void sp_object_set_skew_relative(Inkscape::ObjectSet *set, Geom::Point const &align, double dx, double dy);
-void sp_object_set_move_relative(Inkscape::ObjectSet *set, Geom::Point const &move, bool compensate = true);
-void sp_object_set_move_relative(Inkscape::ObjectSet *set, double dx, double dy);
-
-void sp_selection_rotate_90 (SPDesktop *desktop, bool ccw);
-void sp_selection_rotate (Inkscape::Selection *selection, double angle);
-void sp_selection_rotate_screen (Inkscape::Selection *selection, double angle);
-
-void sp_selection_scale (Inkscape::Selection *selection, double grow);
-void sp_selection_scale_screen (Inkscape::Selection *selection, double grow_pixels);
-void sp_selection_scale_times (Inkscape::Selection *selection, double times);
-
-void sp_selection_move (Inkscape::Selection *selection, double dx, double dy);
-void sp_selection_move_screen (Inkscape::Selection *selection, double dx, double dy);
void sp_selection_item_next (SPDesktop *desktop);
void sp_selection_item_prev (SPDesktop *desktop);
void sp_selection_next_patheffect_param(SPDesktop * dt);
-void sp_selection_edit_clip_or_mask(SPDesktop * dt, bool clip);
+//void sp_selection_edit_clip_or_mask(SPDesktop * dt, bool clip);
enum SPSelectStrokeStyleType {
SP_FILL_COLOR = 0,
@@ -158,15 +94,8 @@ void scroll_to_show_item(SPDesktop *desktop, SPItem *item);
void sp_undo (SPDesktop *desktop, SPDocument *doc);
void sp_redo (SPDesktop *desktop, SPDocument *doc);
-void sp_object_set_get_export_hints(Inkscape::ObjectSet *set, Glib::ustring &filename, float *xdpi, float *ydpi);
void sp_document_get_export_hints (SPDocument * doc, Glib::ustring &filename, float *xdpi, float *ydpi);
-void sp_selection_create_bitmap_copy (SPDesktop *desktop);
-
-void sp_selection_set_clipgroup(SPDesktop *desktop);
-void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_to_layer, bool skip_undo = false);
-void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path);
-
bool fit_canvas_to_selection(SPDesktop *, bool with_margins = false);
void verb_fit_canvas_to_selection(SPDesktop *);
bool fit_canvas_to_drawing(SPDocument *, bool with_margins = false);
diff --git a/src/selection.cpp b/src/selection.cpp
index bdd4f0dc7..3e56e47fd 100644
--- a/src/selection.cpp
+++ b/src/selection.cpp
@@ -119,15 +119,7 @@ void Selection::set(SPObject *object, bool persist_selection_context) {
}
void Selection::setReprList(std::vector<XML::Node*> const &list) {
- clear();
-
- for (std::vector<XML::Node*>::const_reverse_iterator iter = list.rbegin(); iter != list.rend(); ++iter) {
- SPObject *obj = _objectForXMLNode(*iter);
- if (obj) {
- add(obj);
- }
- }
-
+ ObjectSet::setReprList(list);
_emitChanged();
}
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 7b17a294a..7a2a3777f 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -439,7 +439,7 @@ void Inkscape::SelTrans::ungrab()
if (!_current_relative_affine.isIdentity()) { // we can have a identity affine
// when trying to stretch a perfectly vertical line in horizontal direction, which will not be allowed by the handles;
- sp_object_set_apply_affine(selection, _current_relative_affine, (_show == SHOW_OUTLINE) ? true : false);
+ selection->applyAffine(_current_relative_affine, (_show == SHOW_OUTLINE) ? true : false);
if (_center) {
*_center *= _current_relative_affine;
_center_is_set = true;
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index 66b13ed9d..0a671cc8a 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -74,6 +74,7 @@
#include "svg/svg-color.h"
#include "sp-namedview.h"
#include "persp3d.h"
+#include "object-set.h"
/// Made up mimetype to represent Gdk::Pixbuf clipboard contents.
#define CLIPBOARD_GDK_PIXBUF_TARGET "image/x-gdk-pixbuf"
@@ -93,13 +94,13 @@ namespace UI {
*/
class ClipboardManagerImpl : public ClipboardManager {
public:
- virtual void copy(SPDesktop *desktop);
+ virtual void copy(ObjectSet *set);
virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *);
virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style, bool user_symbol);
virtual bool paste(SPDesktop *desktop, bool in_place);
- virtual bool pasteStyle(SPDesktop *desktop);
- virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y);
- virtual bool pastePathEffect(SPDesktop *desktop);
+ virtual bool pasteStyle(ObjectSet *set);
+ virtual bool pasteSize(ObjectSet *set, bool separately, bool apply_x, bool apply_y);
+ virtual bool pastePathEffect(ObjectSet *set);
virtual Glib::ustring getPathParameter(SPDesktop* desktop);
virtual Glib::ustring getShapeOrTextObjectId(SPDesktop *desktop);
virtual const gchar *getFirstObjectID();
@@ -108,7 +109,7 @@ public:
~ClipboardManagerImpl();
private:
- void _copySelection(Inkscape::Selection *);
+ void _copySelection(ObjectSet *);
void _copyUsedDefs(SPItem *);
void _copyGradient(SPGradient *);
void _copyPattern(SPPattern *);
@@ -183,76 +184,74 @@ ClipboardManagerImpl::~ClipboardManagerImpl() {}
/**
* Copy selection contents to the clipboard.
*/
-void ClipboardManagerImpl::copy(SPDesktop *desktop)
+void ClipboardManagerImpl::copy(ObjectSet *set)
{
- if ( desktop == NULL ) {
- return;
- }
- Inkscape::Selection *selection = desktop->getSelection();
+ if ( set->desktop() ) {
+ SPDesktop *desktop = set->desktop();
+
+ // Special case for when the gradient dragger is active - copies gradient color
+ if (desktop->event_context->get_drag()) {
+ GrDrag *drag = desktop->event_context->get_drag();
+ if (drag->hasSelection()) {
+ guint32 col = drag->getColor();
+
+ // set the color as clipboard content (text in RRGGBBAA format)
+ _setClipboardColor(col);
+
+ // create a style with this color on fill and opacity in master opacity, so it can be
+ // pasted on other stops or objects
+ if (_text_style) {
+ sp_repr_css_attr_unref(_text_style);
+ _text_style = NULL;
+ }
+ _text_style = sp_repr_css_attr_new();
+ // print and set properties
+ gchar color_str[16];
+ g_snprintf(color_str, 16, "#%06x", col >> 8);
+ sp_repr_css_set_property(_text_style, "fill", color_str);
+ float opacity = SP_RGBA32_A_F(col);
+ if (opacity > 1.0) {
+ opacity = 1.0; // safeguard
+ }
+ Inkscape::CSSOStringStream opcss;
+ opcss << opacity;
+ sp_repr_css_set_property(_text_style, "opacity", opcss.str().data());
- // Special case for when the gradient dragger is active - copies gradient color
- if (desktop->event_context->get_drag()) {
- GrDrag *drag = desktop->event_context->get_drag();
- if (drag->hasSelection()) {
- guint32 col = drag->getColor();
+ _discardInternalClipboard();
+ return;
+ }
+ }
- // set the color as clipboard content (text in RRGGBBAA format)
- _setClipboardColor(col);
+ // Special case for when the color picker ("dropper") is active - copies color under cursor
+ if (tools_isactive(desktop, TOOLS_DROPPER)) {
+ //_setClipboardColor(sp_dropper_context_get_color(desktop->event_context));
+ _setClipboardColor(SP_DROPPER_CONTEXT(desktop->event_context)->get_color());
+ _discardInternalClipboard();
+ return;
+ }
- // create a style with this color on fill and opacity in master opacity, so it can be
- // pasted on other stops or objects
+ // Special case for when the text tool is active - if some text is selected, copy plain text,
+ // not the object that holds it; also copy the style at cursor into
+ if (tools_isactive(desktop, TOOLS_TEXT)) {
+ _discardInternalClipboard();
+ Glib::ustring selected_text = Inkscape::UI::Tools::sp_text_get_selected_text(desktop->event_context);
+ _clipboard->set_text(selected_text);
if (_text_style) {
sp_repr_css_attr_unref(_text_style);
_text_style = NULL;
}
- _text_style = sp_repr_css_attr_new();
- // print and set properties
- gchar color_str[16];
- g_snprintf(color_str, 16, "#%06x", col >> 8);
- sp_repr_css_set_property(_text_style, "fill", color_str);
- float opacity = SP_RGBA32_A_F(col);
- if (opacity > 1.0) {
- opacity = 1.0; // safeguard
- }
- Inkscape::CSSOStringStream opcss;
- opcss << opacity;
- sp_repr_css_set_property(_text_style, "opacity", opcss.str().data());
-
- _discardInternalClipboard();
+ _text_style = Inkscape::UI::Tools::sp_text_get_style_at_cursor(desktop->event_context);
return;
}
}
-
- // Special case for when the color picker ("dropper") is active - copies color under cursor
- if (tools_isactive(desktop, TOOLS_DROPPER)) {
- //_setClipboardColor(sp_dropper_context_get_color(desktop->event_context));
- _setClipboardColor(SP_DROPPER_CONTEXT(desktop->event_context)->get_color());
- _discardInternalClipboard();
- return;
- }
-
- // Special case for when the text tool is active - if some text is selected, copy plain text,
- // not the object that holds it; also copy the style at cursor into
- if (tools_isactive(desktop, TOOLS_TEXT)) {
- _discardInternalClipboard();
- Glib::ustring selected_text = Inkscape::UI::Tools::sp_text_get_selected_text(desktop->event_context);
- _clipboard->set_text(selected_text);
- if (_text_style) {
- sp_repr_css_attr_unref(_text_style);
- _text_style = NULL;
- }
- _text_style = Inkscape::UI::Tools::sp_text_get_style_at_cursor(desktop->event_context);
- return;
- }
-
- if (selection->isEmpty()) { // check whether something is selected
- _userWarn(desktop, _("Nothing was copied."));
+ if (set->isEmpty()) { // check whether something is selected
+ _userWarn(set->desktop(), _("Nothing was copied."));
return;
}
_discardInternalClipboard();
_createInternalClipboard(); // construct a new clipboard document
- _copySelection(selection); // copy all items in the selection to the internal clipboard
+ _copySelection(set); // copy all items in the selection to the internal clipboard
fit_canvas_to_drawing(_clipboardSPDoc);
_setClipboardTargets();
@@ -426,16 +425,15 @@ const gchar *ClipboardManagerImpl::getFirstObjectID()
/**
* Implements the Paste Style action.
*/
-bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
+bool ClipboardManagerImpl::pasteStyle(ObjectSet *set)
{
- if (desktop == NULL) {
+ if (set->desktop() == NULL) {
return false;
}
// check whether something is selected
- Inkscape::Selection *selection = desktop->getSelection();
- if (selection->isEmpty()) {
- _userWarn(desktop, _("Select <b>object(s)</b> to paste style to."));
+ if (set->isEmpty()) {
+ _userWarn(set->desktop(), _("Select <b>object(s)</b> to paste style to."));
return false;
}
@@ -443,10 +441,10 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
if ( tempdoc == NULL ) {
// no document, but we can try _text_style
if (_text_style) {
- sp_desktop_set_style(desktop, _text_style);
+ sp_desktop_set_style(set, set->desktop(), _text_style);
return true;
} else {
- _userWarn(desktop, _("No style on the clipboard."));
+ _userWarn(set->desktop(), _("No style on the clipboard."));
return false;
}
}
@@ -457,13 +455,13 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
bool pasted = false;
if (clipnode) {
- desktop->doc()->importDefs(tempdoc);
+ set->document()->importDefs(tempdoc);
SPCSSAttr *style = sp_repr_css_attr(clipnode, "style");
- sp_desktop_set_style(desktop, style);
+ sp_desktop_set_style(set, set->desktop(), style);
pasted = true;
}
else {
- _userWarn(desktop, _("No style on the clipboard."));
+ _userWarn(set->desktop(), _("No style on the clipboard."));
}
tempdoc->doUnref();
@@ -477,29 +475,31 @@ bool ClipboardManagerImpl::pasteStyle(SPDesktop *desktop)
* @param apply_x Whether to scale the width of objects / selection
* @param apply_y Whether to scale the height of objects / selection
*/
-bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y)
+bool ClipboardManagerImpl::pasteSize(ObjectSet *set, bool separately, bool apply_x, bool apply_y)
{
if (!apply_x && !apply_y) {
return false; // pointless parameters
}
- if ( desktop == NULL ) {
+/* if ( desktop == NULL ) {
return false;
}
- Inkscape::Selection *selection = desktop->getSelection();
- if (selection->isEmpty()) {
- _userWarn(desktop, _("Select <b>object(s)</b> to paste size to."));
+ Inkscape::Selection *selection = desktop->getSelection();*/
+ if (set->isEmpty()) {
+ if(set->desktop())
+ _userWarn(set->desktop(), _("Select <b>object(s)</b> to paste size to."));
return false;
}
// FIXME: actually, this should accept arbitrary documents
SPDocument *tempdoc = _retrieveClipboard("image/x-inkscape-svg");
if ( tempdoc == NULL ) {
- _userWarn(desktop, _("No size on the clipboard."));
+ if(set->desktop())
+ _userWarn(set->desktop(), _("No size on the clipboard."));
return false;
}
- // retrieve size ifomration from the clipboard
+ // retrieve size information from the clipboard
Inkscape::XML::Node *root = tempdoc->getReprRoot();
Inkscape::XML::Node *clipnode = sp_repr_lookup_name(root, "inkscape:clipboard", 1);
bool pasted = false;
@@ -510,13 +510,13 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
// resize each object in the selection
if (separately) {
- auto itemlist= selection->items();
+ auto itemlist= set->items();
for(auto i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
if (item) {
Geom::OptRect obj_size = item->desktopVisualBounds();
if ( obj_size ) {
- sp_item_scale_rel(item, _getScale(desktop, min, max, *obj_size, apply_x, apply_y));
+ sp_item_scale_rel(item, _getScale(set->desktop(), min, max, *obj_size, apply_x, apply_y));
}
} else {
g_assert_not_reached();
@@ -525,10 +525,10 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
}
// resize the selection as a whole
else {
- Geom::OptRect sel_size = selection->visualBounds();
+ Geom::OptRect sel_size = set->visualBounds();
if ( sel_size ) {
- sp_object_set_scale_relative(selection, sel_size->midpoint(),
- _getScale(desktop, min, max, *sel_size, apply_x, apply_y));
+ set->setScaleRelative(sel_size->midpoint(),
+ _getScale(set->desktop(), min, max, *sel_size, apply_x, apply_y));
}
}
pasted = true;
@@ -541,18 +541,18 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a
/**
* Applies a path effect from the clipboard to the selected path.
*/
-bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
+bool ClipboardManagerImpl::pastePathEffect(ObjectSet *set)
{
/** @todo FIXME: pastePathEffect crashes when moving the path with the applied effect,
segfaulting in fork_private_if_necessary(). */
- if ( desktop == NULL ) {
+ if ( set->desktop() == NULL ) {
return false;
}
- Inkscape::Selection *selection = desktop->getSelection();
- if (!selection || selection->isEmpty()) {
- _userWarn(desktop, _("Select <b>object(s)</b> to paste live path effect to."));
+ //Inkscape::Selection *selection = desktop->getSelection();
+ if (!set || set->isEmpty()) {
+ _userWarn(set->desktop(), _("Select <b>object(s)</b> to paste live path effect to."));
return false;
}
@@ -563,10 +563,10 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
if ( clipnode ) {
gchar const *effectstack = clipnode->attribute("inkscape:path-effect");
if ( effectstack ) {
- desktop->doc()->importDefs(tempdoc);
+ set->document()->importDefs(tempdoc);
// make sure all selected items are converted to paths first (i.e. rectangles)
- sp_selected_to_lpeitems(desktop);
- auto itemlist= selection->items();
+ set->toLPEItems();
+ auto itemlist= set->items();
for(auto i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
_applyPathEffect(item, effectstack);
@@ -578,7 +578,7 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop)
}
// no_effect:
- _userWarn(desktop, _("No effect on the clipboard."));
+ _userWarn(set->desktop(), _("No effect on the clipboard."));
return false;
}
@@ -646,7 +646,7 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
/**
* Iterate over a list of items and copy them to the clipboard.
*/
-void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection)
+void ClipboardManagerImpl::_copySelection(ObjectSet *selection)
{
// copy the defs used by all items
auto itemlist= selection->items();
@@ -1270,7 +1270,7 @@ Geom::Scale ClipboardManagerImpl::_getScale(SPDesktop *desktop, Geom::Point cons
}
// If the "lock aspect ratio" button is pressed and we paste only a single coordinate,
// resize the second one by the same ratio too
- if (desktop->isToolboxButtonActive("lock")) {
+ if (desktop && desktop->isToolboxButtonActive("lock")) {
if (apply_x && !apply_y) {
scale_y = scale_x;
}
@@ -1432,7 +1432,8 @@ void ClipboardManagerImpl::_setClipboardColor(guint32 color)
*/
void ClipboardManagerImpl::_userWarn(SPDesktop *desktop, char const *msg)
{
- desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, msg);
+ if(desktop)
+ desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, msg);
}
/* #######################################
diff --git a/src/ui/clipboard.h b/src/ui/clipboard.h
index 9f3b6cbdb..32a49867c 100644
--- a/src/ui/clipboard.h
+++ b/src/ui/clipboard.h
@@ -24,7 +24,7 @@
// forward declarations
class SPDesktop;
namespace Inkscape {
-class Selection;
+class ObjectSet;
namespace XML { class Node; }
namespace LivePathEffect { class PathParam; }
@@ -42,13 +42,13 @@ namespace UI {
class ClipboardManager {
public:
- virtual void copy(SPDesktop *desktop) = 0;
+ virtual void copy(ObjectSet *set) = 0;
virtual void copyPathParameter(Inkscape::LivePathEffect::PathParam *) = 0;
virtual void copySymbol(Inkscape::XML::Node* symbol, gchar const* style, bool user_symbol = true) = 0;
virtual bool paste(SPDesktop *desktop, bool in_place = false) = 0;
- virtual bool pasteStyle(SPDesktop *desktop) = 0;
- virtual bool pasteSize(SPDesktop *desktop, bool separately, bool apply_x, bool apply_y) = 0;
- virtual bool pastePathEffect(SPDesktop *desktop) = 0;
+ virtual bool pasteStyle(ObjectSet *set) = 0;
+ virtual bool pasteSize(ObjectSet *set, bool separately, bool apply_x, bool apply_y) = 0;
+ virtual bool pastePathEffect(ObjectSet *set) = 0;
virtual Glib::ustring getPathParameter(SPDesktop* desktop) = 0;
virtual Glib::ustring getShapeOrTextObjectId(SPDesktop *desktop) = 0;
virtual const gchar *getFirstObjectID() = 0;
diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp
index 64a5d9866..98ecf6db7 100644
--- a/src/ui/dialog/export.cpp
+++ b/src/ui/dialog/export.cpp
@@ -785,7 +785,7 @@ void Export::onAreaToggled ()
case SELECTION_SELECTION:
if ((SP_ACTIVE_DESKTOP->getSelection())->isEmpty() == false) {
- sp_object_set_get_export_hints(SP_ACTIVE_DESKTOP->getSelection(), filename, &xdpi, &ydpi);
+ SP_ACTIVE_DESKTOP->getSelection()->getExportHints(filename, &xdpi, &ydpi);
/* If we still don't have a filename -- let's build
one that's nice */
diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp
index 4aa86cc48..f28f8336a 100644
--- a/src/ui/dialog/layer-properties.cpp
+++ b/src/ui/dialog/layer-properties.cpp
@@ -384,7 +384,7 @@ void LayerPropertiesDialog::Move::setup(LayerPropertiesDialog &dialog) {
void LayerPropertiesDialog::Move::perform(LayerPropertiesDialog &dialog) {
SPObject *moveto = dialog._selectedLayer();
- sp_selection_to_layer(dialog._desktop, moveto, false);
+ dialog._desktop->selection->toLayer(moveto);
}
void LayerPropertiesDialog::_setDesktop(SPDesktop *desktop) {
diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp
index 73f8debd6..b97b0e63a 100644
--- a/src/ui/dialog/livepatheffect-editor.cpp
+++ b/src/ui/dialog/livepatheffect-editor.cpp
@@ -419,7 +419,7 @@ LivePathEffectEditor::onAdd()
// If item is a SPRect, convert it to path first:
if ( dynamic_cast<SPRect *>(item) ) {
- sp_selected_path_to_curves(sel, current_desktop, false);
+ sel->toCurves();
item = sel->singleItem(); // get new item
}
@@ -451,7 +451,7 @@ LivePathEffectEditor::onAdd()
item = NULL;
// run sp_selection_clone_original_path_lpe
- sp_selection_clone_original_path_lpe(current_desktop);
+ sel->cloneOriginalPathLPE();
SPItem *new_item = sel->singleItem();
// Check that the cloning was successful. We don't want to change the ID of the original referenced path!
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index 7f1492cd7..5ec47b0dc 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -617,12 +617,11 @@ void Transformation::applyPageMove(Inkscape::Selection *selection)
if (!prefs->getBool("/dialogs/transformation/applyseparately")) {
// move selection as a whole
if (_check_move_relative.get_active()) {
- sp_object_set_move_relative(selection, x, y);
+ selection->moveRelative(x, y);
} else {
Geom::OptRect bbox = selection->preferredBounds();
if (bbox) {
- sp_object_set_move_relative(selection,
- x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
+ selection->moveRelative(x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
}
}
} else {
@@ -685,8 +684,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection)
} else {
Geom::OptRect bbox = selection->preferredBounds();
if (bbox) {
- sp_object_set_move_relative(selection,
- x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
+ selection->moveRelative(x - bbox->min()[Geom::X], y - bbox->min()[Geom::Y]);
}
}
}
@@ -750,7 +748,7 @@ void Transformation::applyPageScale(Inkscape::Selection *selection)
double y1 = bbox_pref->midpoint()[Geom::Y] + new_height/2;
Geom::Affine scaler = get_scale_transform_for_variable_stroke (*bbox_pref, *bbox_geom, transform_stroke, preserve, x0, y0, x1, y1);
- sp_object_set_apply_affine(selection, scaler);
+ selection->applyAffine(scaler);
}
}
@@ -776,7 +774,7 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection)
} else {
boost::optional<Geom::Point> center = selection->center();
if (center) {
- sp_object_set_rotate_relative(selection, *center, angle);
+ selection->rotateRelative(*center, angle);
}
}
@@ -843,7 +841,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
- sp_object_set_skew_relative(selection, *center, 0.01 * skewX, 0.01 * skewY);
+ selection->skewRelative(*center, 0.01 * skewX, 0.01 * skewY);
} else if (_units_skew.isRadial()) { //deg or rad
double angleX = _scalar_skew_horizontal.getValue("rad");
double angleY = _scalar_skew_vertical.getValue("rad");
@@ -856,7 +854,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
}
double skewX = tan(-angleX);
double skewY = tan(angleY);
- sp_object_set_skew_relative(selection, *center, skewX, skewY);
+ selection->skewRelative(*center, skewX, skewY);
} else { // absolute displacement
double skewX = _scalar_skew_horizontal.getValue("px");
double skewY = _scalar_skew_vertical.getValue("px");
@@ -864,7 +862,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection)
getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>."));
return;
}
- sp_object_set_skew_relative(selection, *center, skewX / height, skewY / width);
+ selection->skewRelative(*center, skewX / height, skewY / width);
}
}
}
@@ -897,7 +895,7 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection)
item->updateRepr();
}
} else {
- sp_object_set_apply_affine(selection, displayed); // post-multiply each object's transform
+ selection->applyAffine(displayed); // post-multiply each object's transform
}
DocumentUndo::done(selection->desktop()->getDocument(), SP_VERB_DIALOG_TRANSFORM,
diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp
index b47e66451..e0c767509 100644
--- a/src/ui/interface.cpp
+++ b/src/ui/interface.cpp
@@ -1210,7 +1210,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
Geom::OptRect sel_bbox = selection->visualBounds();
if (sel_bbox) {
Geom::Point m( desktop->point() - sel_bbox->midpoint() );
- sp_object_set_move_relative(selection, m, false);
+ selection->moveRelative(m, false);
}
}
@@ -1841,28 +1841,28 @@ void ContextMenu::ItemCreateLink(void)
void ContextMenu::SetMask(void)
{
- sp_selection_set_mask(_desktop, false, false);
+ _desktop->selection->setMask(false, false);
}
void ContextMenu::ReleaseMask(void)
{
- sp_selection_unset_mask(_desktop, false);
+ _desktop->selection->unsetMask(false);
}
void ContextMenu::CreateGroupClip(void)
{
- sp_selection_set_clipgroup(_desktop);
+ _desktop->selection->setClipGroup();
}
void ContextMenu::SetClip(void)
{
- sp_selection_set_mask(_desktop, true, false);
+ _desktop->selection->setMask(true, false);
}
void ContextMenu::ReleaseClip(void)
{
- sp_selection_unset_mask(_desktop, true);
+ _desktop->selection->unsetMask(true);
}
void ContextMenu::MakeGroupMenu(void)
@@ -1876,7 +1876,7 @@ void ContextMenu::MakeGroupMenu(void)
void ContextMenu::ActivateGroup(void)
{
- sp_selection_group(_desktop->selection, _desktop);
+ _desktop->selection->group();
}
void ContextMenu::ActivateUngroup(void)
@@ -1889,7 +1889,7 @@ void ContextMenu::ActivateUngroup(void)
void ContextMenu::ActivateUngroupPopSelection(void)
{
- sp_selection_ungroup_pop_selection(_desktop->selection, _desktop);
+ _desktop->selection->popFromGroup();
}
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 94488a700..425695a2c 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -400,7 +400,7 @@ bool Box3dTool::root_handler(GdkEvent* event) {
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
- sp_selection_to_guides(desktop);
+ desktop->selection->toGuides();
ret = true;
}
break;
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index 12686160b..4f941e534 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -732,10 +732,10 @@ void EraserTool::set_to_accumulated() {
workDone = true; // TODO set this only if something was cut.
bool break_apart = prefs->getBool("/tools/eraser/break_apart", false);
if(!break_apart){
- sp_selected_path_combine(this->desktop, true);
+ selection->combine(true);
} else {
if(!this->nowidth){
- sp_selected_path_break_apart(this->desktop, true);
+ selection->breakApart(true);
}
}
if ( !selection->isEmpty() ) {
@@ -784,7 +784,7 @@ void EraserTool::set_to_accumulated() {
sp_object_ref(clip_path, 0);
clip_path->deleteObject(true);
sp_object_unref(clip_path);
- sp_selection_raise_to_top(selection, this->desktop, true);
+ selection->raiseToTop(true);
selection->add(dup_clip);
sp_selected_path_diff_skip_undo(selection);
SPItem * clip = SP_ITEM(*(selection->items().begin()));
@@ -800,13 +800,13 @@ void EraserTool::set_to_accumulated() {
rect->transform = SP_ITEM(rect->parent)->i2dt_affine().inverse();
rect->updateRepr();
rect->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
- sp_selection_raise_to_top(selection, this->desktop, true);
+ selection->raiseToTop(true);
selection->add(rect);
sp_selected_path_diff_skip_undo(selection);
}
- sp_selection_raise_to_top(selection, this->desktop, true);
+ selection->raiseToTop(true);
selection->add(item);
- sp_selection_set_mask(this->desktop, true, false, true);
+ selection->setMask(true, false, true);
} else {
SPItem *erase_clip = selection->singleItem();
if (erase_clip) {
@@ -836,7 +836,7 @@ void EraserTool::set_to_accumulated() {
}
if (eraser_mode == ERASER_MODE_DELETE) {
- sp_selection_delete(this->desktop);
+ selection->deleteItems();
remainingItems.clear();
}
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index a7cd39a89..300324467 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -435,7 +435,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
if(bend_item != NULL && bend_item->getRepr() != NULL){
gchar const *svgd = item->getRepr()->attribute("d");
dc->selection->add(SP_OBJECT(bend_item));
- sp_selection_duplicate(dc->desktop);
+ dc->selection->duplicate();
dc->selection->remove(SP_OBJECT(bend_item));
bend_item = dc->selection->singleItem();
if(bend_item){
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index b7579b1fb..312338882 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -1233,7 +1233,7 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
- sp_selection_to_guides(this->desktop);
+ this->desktop->selection->toGuides();
ret = true;
}
break;
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index 9e8005be8..54106437c 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -487,7 +487,7 @@ bool PencilTool::_handleKeyPress(GdkEventKey const &event) {
case GDK_KEY_g:
case GDK_KEY_G:
if (Inkscape::UI::held_only_shift(event)) {
- sp_selection_to_guides(this->desktop);
+ this->desktop->selection->toGuides();
ret = true;
}
break;
diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp
index 00330ef57..272531945 100644
--- a/src/ui/tools/rect-tool.cpp
+++ b/src/ui/tools/rect-tool.cpp
@@ -294,7 +294,7 @@ bool RectTool::root_handler(GdkEvent* event) {
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
- sp_selection_to_guides(desktop);
+ desktop->selection->toGuides();
ret = true;
}
break;
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index 0cdeda0b6..6c450b3dc 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -902,15 +902,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(desktop->getSelection(), mul*-10, 0); // shift
+ desktop->getSelection()->moveScreen(mul*-10, 0); // shift
} else {
- sp_selection_move_screen(desktop->getSelection(), mul*-1, 0); // no shift
+ desktop->getSelection()->moveScreen(mul*-1, 0); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(desktop->getSelection(), mul*-10*nudge, 0); // shift
+ desktop->getSelection()->move(mul*-10*nudge, 0); // shift
} else {
- sp_selection_move(desktop->getSelection(), mul*-nudge, 0); // no shift
+ desktop->getSelection()->move(mul*-nudge, 0); // no shift
}
}
@@ -925,15 +925,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(desktop->getSelection(), 0, mul*10); // shift
+ desktop->getSelection()->moveScreen(0, mul*10); // shift
} else {
- sp_selection_move_screen(desktop->getSelection(), 0, mul*1); // no shift
+ desktop->getSelection()->moveScreen(0, mul*1); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(desktop->getSelection(), 0, mul*10*nudge); // shift
+ desktop->getSelection()->move(0, mul*10*nudge); // shift
} else {
- sp_selection_move(desktop->getSelection(), 0, mul*nudge); // no shift
+ desktop->getSelection()->move(0, mul*nudge); // no shift
}
}
@@ -948,15 +948,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(desktop->getSelection(), mul*10, 0); // shift
+ desktop->getSelection()->moveScreen(mul*10, 0); // shift
} else {
- sp_selection_move_screen(desktop->getSelection(), mul*1, 0); // no shift
+ desktop->getSelection()->moveScreen(mul*1, 0); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(desktop->getSelection(), mul*10*nudge, 0); // shift
+ desktop->getSelection()->move(mul*10*nudge, 0); // shift
} else {
- sp_selection_move(desktop->getSelection(), mul*nudge, 0); // no shift
+ desktop->getSelection()->move(mul*nudge, 0); // no shift
}
}
@@ -971,15 +971,15 @@ bool SelectTool::root_handler(GdkEvent* event) {
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
- sp_selection_move_screen(desktop->getSelection(), 0, mul*-10); // shift
+ desktop->getSelection()->moveScreen(0, mul*-10); // shift
} else {
- sp_selection_move_screen(desktop->getSelection(), 0, mul*-1); // no shift
+ desktop->getSelection()->moveScreen(0, mul*-1); // no shift
}
} else { // no alt
if (MOD__SHIFT(event)) {
- sp_selection_move(desktop->getSelection(), 0, mul*-10*nudge); // shift
+ desktop->getSelection()->move(0, mul*-10*nudge); // shift
} else {
- sp_selection_move(desktop->getSelection(), 0, mul*-nudge); // no shift
+ desktop->getSelection()->move(0, mul*-nudge); // no shift
}
}
@@ -1023,11 +1023,11 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_bracketleft:
if (MOD__ALT(event)) {
gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
- sp_selection_rotate_screen(selection, mul*1);
+ selection->rotateScreen(mul*1);
} else if (MOD__CTRL(event)) {
- sp_selection_rotate(selection, 90);
+ selection->rotate(90);
} else if (snaps) {
- sp_selection_rotate(selection, 180.0/snaps);
+ selection->rotate(180.0/snaps);
}
ret = TRUE;
@@ -1036,11 +1036,11 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_bracketright:
if (MOD__ALT(event)) {
gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
- sp_selection_rotate_screen(selection, -1*mul);
+ selection->rotateScreen(-1*mul);
} else if (MOD__CTRL(event)) {
- sp_selection_rotate(selection, -90);
+ selection->rotate(-90);
} else if (snaps) {
- sp_selection_rotate(selection, -180.0/snaps);
+ selection->rotate(-180.0/snaps);
}
ret = TRUE;
@@ -1084,7 +1084,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
- sp_selection_to_guides(desktop);
+ desktop->selection->toGuides();
ret = true;
}
break;
diff --git a/src/verbs.cpp b/src/verbs.cpp
index e061eaab6..7a9875c69 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -956,85 +956,85 @@ void EditVerb::perform(SPAction *action, void *data)
sp_redo(dt, dt->getDocument());
break;
case SP_VERB_EDIT_CUT:
- sp_selection_cut(dt);
+ dt->selection->cut();
break;
case SP_VERB_EDIT_COPY:
- sp_selection_copy(dt);
+ dt->selection->copy();
break;
case SP_VERB_EDIT_PASTE:
sp_selection_paste(dt, false);
break;
case SP_VERB_EDIT_PASTE_STYLE:
- sp_selection_paste_style(dt);
+ dt->selection->pasteStyle();
break;
case SP_VERB_EDIT_PASTE_SIZE:
- sp_selection_paste_size(dt, true, true);
+ dt->selection->pasteSize(true,true);
break;
case SP_VERB_EDIT_PASTE_SIZE_X:
- sp_selection_paste_size(dt, true, false);
+ dt->selection->pasteSize(true, false);
break;
case SP_VERB_EDIT_PASTE_SIZE_Y:
- sp_selection_paste_size(dt, false, true);
+ dt->selection->pasteSize(false, true);
break;
case SP_VERB_EDIT_PASTE_SIZE_SEPARATELY:
- sp_selection_paste_size_separately(dt, true, true);
+ dt->selection->pasteSizeSeparately(true, true);
break;
case SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_X:
- sp_selection_paste_size_separately(dt, true, false);
+ dt->selection->pasteSizeSeparately(true, false);
break;
case SP_VERB_EDIT_PASTE_SIZE_SEPARATELY_Y:
- sp_selection_paste_size_separately(dt, false, true);
+ dt->selection->pasteSizeSeparately(false, true);
break;
case SP_VERB_EDIT_PASTE_IN_PLACE:
sp_selection_paste(dt, true);
break;
case SP_VERB_EDIT_PASTE_LIVEPATHEFFECT:
- sp_selection_paste_livepatheffect(dt);
+ dt->selection->pastePathEffect();
break;
case SP_VERB_EDIT_REMOVE_LIVEPATHEFFECT:
- sp_selection_remove_livepatheffect(dt);
+ dt->selection->removeLPE();
break;
case SP_VERB_EDIT_REMOVE_FILTER:
- sp_selection_remove_filter(dt);
+ dt->selection->removeFilter();
break;
case SP_VERB_EDIT_DELETE:
- sp_selection_delete(dt);
+ dt->selection->deleteItems();
break;
case SP_VERB_EDIT_DUPLICATE:
- sp_selection_duplicate(dt);
+ dt->selection->duplicate();
break;
case SP_VERB_EDIT_CLONE:
- sp_selection_clone(dt);
+ dt->selection->clone();
break;
case SP_VERB_EDIT_UNLINK_CLONE:
- sp_selection_unlink(dt);
+ dt->selection->unlink();
break;
case SP_VERB_EDIT_RELINK_CLONE:
- sp_selection_relink(dt);
+ dt->selection->relink();
break;
case SP_VERB_EDIT_CLONE_SELECT_ORIGINAL:
- sp_select_clone_original(dt);
+ dt->selection->cloneOriginal();
break;
case SP_VERB_EDIT_CLONE_ORIGINAL_PATH_LPE:
- sp_selection_clone_original_path_lpe(dt);
+ dt->selection->cloneOriginalPathLPE();
break;
case SP_VERB_EDIT_SELECTION_2_MARKER:
- sp_selection_to_marker(dt);
+ dt->selection->toMarker();
break;
case SP_VERB_EDIT_SELECTION_2_GUIDES:
- sp_selection_to_guides(dt);
+ dt->selection->toGuides();
break;
case SP_VERB_EDIT_TILE:
- sp_selection_tile(dt);
+ dt->selection->tile();
break;
case SP_VERB_EDIT_UNTILE:
- sp_selection_untile(dt);
+ dt->selection->untile();
break;
case SP_VERB_EDIT_SYMBOL:
- sp_selection_symbol(dt);
+ dt->selection->toSymbol();
break;
case SP_VERB_EDIT_UNSYMBOL:
- sp_selection_unsymbol(dt);
+ dt->selection->unSymbol();
break;
case SP_VERB_EDIT_SELECT_ALL:
SelectionHelper::selectAll(dt);
@@ -1133,54 +1133,54 @@ void SelectionVerb::perform(SPAction *action, void *data)
{
// FIXME these and the other grow/shrink they should use gobble_key_events.
// the problem is how to get access to which key, if any, to gobble.
- sp_selection_scale(selection, prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000));
+ selection->scale(prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000));
break;
}
case SP_VERB_SELECTION_GROW_SCREEN:
{
- sp_selection_scale_screen(selection, 2);
+ selection->scaleScreen(2);
break;
}
case SP_VERB_SELECTION_GROW_DOUBLE:
{
- sp_selection_scale_times(selection, 2);
+ selection->scaleTimes(2);
break;
}
case SP_VERB_SELECTION_SHRINK:
{
- sp_selection_scale(selection, -prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000));
+ selection->scale(-prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000));
break;
}
case SP_VERB_SELECTION_SHRINK_SCREEN:
{
- sp_selection_scale_screen(selection, -2);
+ selection->scaleScreen(-2);
break;
}
case SP_VERB_SELECTION_SHRINK_HALVE:
{
- sp_selection_scale_times(selection, 0.5);
+ selection->scaleTimes(0.5);
break;
}
case SP_VERB_SELECTION_TO_FRONT:
- sp_selection_raise_to_top(selection, dt);
+ selection->raiseToTop();
break;
case SP_VERB_SELECTION_TO_BACK:
- sp_selection_lower_to_bottom(selection, dt);
+ selection->lowerToBottom();
break;
case SP_VERB_SELECTION_RAISE:
- sp_selection_raise(selection, dt);
+ selection->raise();
break;
case SP_VERB_SELECTION_LOWER:
- sp_selection_lower(selection, dt);
+ selection->lower();
break;
case SP_VERB_SELECTION_GROUP:
- sp_selection_group(selection, dt);
+ selection->group();
break;
case SP_VERB_SELECTION_UNGROUP:
- sp_selection_ungroup(selection, dt);
+ selection->ungroup();
break;
case SP_VERB_SELECTION_UNGROUP_POP_SELECTION:
- sp_selection_ungroup_pop_selection(selection, dt);
+ selection->popFromGroup();
break;
default:
handled = false;
@@ -1258,14 +1258,14 @@ void SelectionVerb::perform(SPAction *action, void *data)
dt->_dlg_mgr->showDialog("PixelArt");
break;
case SP_VERB_SELECTION_CREATE_BITMAP:
- sp_selection_create_bitmap_copy(dt);
+ dt->selection->createBitmapCopy();
break;
case SP_VERB_SELECTION_COMBINE:
- sp_selected_path_combine(dt);
+ selection->combine();
break;
case SP_VERB_SELECTION_BREAK_APART:
- sp_selected_path_break_apart(dt);
+ selection->breakApart();
break;
case SP_VERB_SELECTION_ARRANGE:
INKSCAPE.dialogs_unhide();
@@ -1324,11 +1324,11 @@ void LayerVerb::perform(SPAction *action, void *data)
break;
}
case SP_VERB_LAYER_MOVE_TO_NEXT: {
- sp_selection_to_next_layer(dt);
+ dt->selection->toNextLayer();
break;
}
case SP_VERB_LAYER_MOVE_TO_PREV: {
- sp_selection_to_prev_layer(dt);
+ dt->selection->toPrevLayer();
break;
}
case SP_VERB_LAYER_MOVE_TO: {
@@ -1399,7 +1399,7 @@ void LayerVerb::perform(SPAction *action, void *data)
case SP_VERB_LAYER_DUPLICATE: {
if ( dt->currentLayer() != dt->currentRoot() ) {
- sp_selection_duplicate(dt, true, true);
+ dt->selection->duplicate(true,true);
DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_DUPLICATE,
_("Duplicate layer"));
@@ -1515,7 +1515,7 @@ void ObjectVerb::perform( SPAction *action, void *data)
bool handled = true;
switch (reinterpret_cast<std::size_t>(data)) {
case SP_VERB_OBJECT_TO_CURVE:
- sp_selected_path_to_curves(sel, dt);
+ sel->toCurves();
break;
default:
handled = false;
@@ -1546,13 +1546,13 @@ void ObjectVerb::perform( SPAction *action, void *data)
switch (reinterpret_cast<std::size_t>(data)) {
case SP_VERB_OBJECT_ROTATE_90_CW:
- sp_selection_rotate_90(dt, false);
+ sel->rotate90(false);
break;
case SP_VERB_OBJECT_ROTATE_90_CCW:
- sp_selection_rotate_90(dt, true);
+ sel->rotate90(true);
break;
case SP_VERB_OBJECT_FLATTEN:
- sp_object_set_remove_transform(dt);
+ sel->removeTransform();
break;
case SP_VERB_OBJECT_FLOW_TEXT:
text_flow_into_shape();
@@ -1564,35 +1564,35 @@ void ObjectVerb::perform( SPAction *action, void *data)
flowtext_to_text();
break;
case SP_VERB_OBJECT_FLIP_HORIZONTAL:
- sp_object_set_scale_relative(sel, center, Geom::Scale(-1.0, 1.0));
+ sel->setScaleRelative(center, Geom::Scale(-1.0, 1.0));
DocumentUndo::done(dt->getDocument(), SP_VERB_OBJECT_FLIP_HORIZONTAL,
_("Flip horizontally"));
break;
case SP_VERB_OBJECT_FLIP_VERTICAL:
- sp_object_set_scale_relative(sel, center, Geom::Scale(1.0, -1.0));
+ sel->setScaleRelative(center, Geom::Scale(1.0, -1.0));
DocumentUndo::done(dt->getDocument(), SP_VERB_OBJECT_FLIP_VERTICAL,
_("Flip vertically"));
break;
case SP_VERB_OBJECT_SET_MASK:
- sp_selection_set_mask(dt, false, false);
+ sel->setMask(false, false);
break;
case SP_VERB_OBJECT_EDIT_MASK:
- sp_selection_edit_clip_or_mask(dt, false);
+ sel->editMask(false);
break;
case SP_VERB_OBJECT_UNSET_MASK:
- sp_selection_unset_mask(dt, false);
+ sel->unsetMask(false);
break;
case SP_VERB_OBJECT_SET_CLIPPATH:
- sp_selection_set_mask(dt, true, false);
+ sel->setMask(true, false);
break;
case SP_VERB_OBJECT_CREATE_CLIP_GROUP:
- sp_selection_set_clipgroup(dt);
+ sel->setClipGroup();
break;
case SP_VERB_OBJECT_EDIT_CLIPPATH:
- sp_selection_edit_clip_or_mask(dt, true);
+ sel->editMask(true);
break;
case SP_VERB_OBJECT_UNSET_CLIPPATH:
- sp_selection_unset_mask(dt, true);
+ sel->unsetMask(true);
break;
default:
break;
diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp
index e551c28c3..c5ff713bd 100644
--- a/src/widgets/select-toolbar.cpp
+++ b/src/widgets/select-toolbar.cpp
@@ -254,7 +254,7 @@ sp_object_layout_any_value_changed(GtkAdjustment *adj, GObject *tbl)
scaler = get_scale_transform_for_uniform_stroke (*bbox_geom, 0, 0, false, false, x0, y0, x1, y1);
}
- sp_object_set_apply_affine(selection, scaler);
+ selection->applyAffine(scaler);
DocumentUndo::maybeDone(document, actionkey, SP_VERB_CONTEXT_SELECT,
_("Transform by toolbar"));