diff options
| author | Marc Jeanmougin <mc> | 2015-02-19 03:25:21 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <mc> | 2015-02-19 03:25:21 +0000 |
| commit | 5fd00cab14d48beaf2279a2b8f3ad5b02b76c87b (patch) | |
| tree | ff77bac142c02624cbdfaa2ebd01422e8697205a /src | |
| parent | I can't really understand why, but i can now launch inkscape without it segfa... (diff) | |
| download | inkscape-5fd00cab14d48beaf2279a2b8f3ad5b02b76c87b.tar.gz inkscape-5fd00cab14d48beaf2279a2b8f3ad5b02b76c87b.zip | |
Put a few std::vector<SPitem*>
(bzr r13922.1.5)
Diffstat (limited to 'src')
99 files changed, 744 insertions, 765 deletions
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp index f2cde352c..fb9fbd935 100644 --- a/src/conn-avoid-ref.cpp +++ b/src/conn-avoid-ref.cpp @@ -252,8 +252,8 @@ static std::vector<Geom::Point> approxItemWithPoints(SPItem const *item, const G { SPGroup* group = SP_GROUP(item); // consider all first-order children - SelContainer itemlist = sp_item_group_item_list(group); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector<SPItem*> itemlist = sp_item_group_item_list(group); + for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem* child_item = SP_ITEM(*i); std::vector<Geom::Point> child_points = approxItemWithPoints(child_item, item_transform * child_item->transform); poly_points.insert(poly_points.end(), child_points.begin(), child_points.end()); diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 39dfad44b..0c661ebfb 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -194,8 +194,8 @@ 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); - SelContainer const itemlist = desktop->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector<SPItem*> const itemlist = desktop->selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { /* last used styles for 3D box faces are stored separately */ SPObject *obj = reinterpret_cast<SPObject *>(*i); // TODO unsafe until Selection is refactored. Box3DSide *side = dynamic_cast<Box3DSide *>(obj); @@ -234,8 +234,8 @@ 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); - SelContainer const itemlist = desktop->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector<SPItem*> const itemlist = desktop->selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = reinterpret_cast<SPItem *>(*i); // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) @@ -439,7 +439,7 @@ sp_desktop_get_font_size_tool(SPDesktop *desktop) /** Determine average stroke width, simple method */ // see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually gdouble -stroke_average_width (const SelContainer &objects) +stroke_average_width (const std::vector<SPItem*> &objects) { if (objects.empty()) return Geom::infinity(); @@ -447,7 +447,7 @@ stroke_average_width (const SelContainer &objects) gdouble avgwidth = 0.0; bool notstroked = true; int n_notstroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); SPItem *item = dynamic_cast<SPItem *>(obj); if (!item) { @@ -492,7 +492,7 @@ static bool vectorsClose( std::vector<double> const &lhs, std::vector<double> co * Write to style_res the average fill or stroke of list of objects, if applicable. */ int -objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool const isfill) +objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_res, bool const isfill) { if (objects.empty()) { /* No objects, set empty */ @@ -514,7 +514,7 @@ objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool prev[0] = prev[1] = prev[2] = 0.0; bool same_color = true; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!obj) { continue; @@ -685,7 +685,7 @@ objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool * Write to style_res the average opacity of a list of objects. */ int -objects_query_opacity (const SelContainer &objects, SPStyle *style_res) +objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -698,7 +698,7 @@ objects_query_opacity (const SelContainer &objects, SPStyle *style_res) guint opacity_items = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!obj) { continue; @@ -739,7 +739,7 @@ objects_query_opacity (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average stroke width of a list of objects. */ int -objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) +objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -754,7 +754,7 @@ objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) int n_stroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!obj) { continue; @@ -815,7 +815,7 @@ objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average miter limit of a list of objects. */ int -objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) +objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -828,7 +828,7 @@ objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) gdouble prev_ml = -1; bool same_ml = true; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!dynamic_cast<SPItem *>(obj)) { continue; @@ -875,7 +875,7 @@ objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res) * Write to style_res the stroke cap of a list of objects. */ int -objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) +objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -887,7 +887,7 @@ objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) bool same_cap = true; int n_stroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!dynamic_cast<SPItem *>(obj)) { continue; @@ -929,7 +929,7 @@ objects_query_strokecap (const SelContainer &objects, SPStyle *style_res) * Write to style_res the stroke join of a list of objects. */ int -objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) +objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -941,7 +941,7 @@ objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) bool same_join = true; int n_stroked = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!dynamic_cast<SPItem *>(obj)) { continue; @@ -984,7 +984,7 @@ objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average font size and spacing of objects. */ int -objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) +objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res) { bool different = false; @@ -1004,7 +1004,7 @@ objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) int texts = 0; int no_size = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!isTextualItem(obj)) { @@ -1116,14 +1116,14 @@ objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average font style of objects. */ int -objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res) +objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res) { bool different = false; bool set = false; int texts = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!isTextualItem(obj)) { @@ -1173,7 +1173,7 @@ objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res) * Write to style_res the baseline numbers. */ static int -objects_query_baselines (const SelContainer &objects, SPStyle *style_res) +objects_query_baselines (const std::vector<SPItem*> &objects, SPStyle *style_res) { bool different = false; @@ -1192,7 +1192,7 @@ objects_query_baselines (const SelContainer &objects, SPStyle *style_res) int texts = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!isTextualItem(obj)) { @@ -1269,7 +1269,7 @@ objects_query_baselines (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average font family of objects. */ int -objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) +objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_res) { bool different = false; int texts = 0; @@ -1280,7 +1280,7 @@ objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) } style_res->font_family.set = FALSE; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl; @@ -1325,7 +1325,7 @@ objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res) } static int -objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res) +objects_query_fontspecification (const std::vector<SPItem*> &objects, SPStyle *style_res) { bool different = false; int texts = 0; @@ -1336,7 +1336,7 @@ objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res } style_res->font_specification.set = FALSE; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl; @@ -1385,7 +1385,7 @@ objects_query_fontspecification (const SelContainer &objects, SPStyle *style_res } static int -objects_query_blend (const SelContainer &objects, SPStyle *style_res) +objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res) { const int empty_prev = -2; const int complex_filter = 5; @@ -1394,7 +1394,7 @@ objects_query_blend (const SelContainer &objects, SPStyle *style_res) bool same_blend = true; guint items = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!obj) { continue; @@ -1471,7 +1471,7 @@ objects_query_blend (const SelContainer &objects, SPStyle *style_res) * Write to style_res the average blurring of a list of objects. */ int -objects_query_blur (const SelContainer &objects, SPStyle *style_res) +objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res) { if (objects.empty()) { /* No objects, set empty */ @@ -1484,7 +1484,7 @@ objects_query_blur (const SelContainer &objects, SPStyle *style_res) guint blur_items = 0; guint items = 0; - for (SelContainer::const_iterator i=objects.begin();i!=objects.end();i++) { + for (std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++) { SPObject *obj = reinterpret_cast<SPObject *>(*i); if (!obj) { continue; @@ -1553,7 +1553,7 @@ objects_query_blur (const SelContainer &objects, SPStyle *style_res) * the result to style, return appropriate flag. */ int -sp_desktop_query_style_from_list (const SelContainer &list, SPStyle *style, int property) +sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *style, int property) { if (property == QUERY_STYLE_PROPERTY_FILL) { return objects_query_fillstroke (list, style, true); diff --git a/src/desktop-style.h b/src/desktop-style.h index 0e40a2652..7ca25b9ae 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -65,21 +65,21 @@ guint32 sp_desktop_get_color_tool(SPDesktop *desktop, Glib::ustring const &tool, double sp_desktop_get_font_size_tool (SPDesktop *desktop); void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text); -gdouble stroke_average_width (const SelContainer &objects); +gdouble stroke_average_width (const std::vector<SPItem*> &objects); -int objects_query_fillstroke (const SelContainer &objects, SPStyle *style_res, bool const isfill); -int objects_query_fontnumbers (const SelContainer &objects, SPStyle *style_res); -int objects_query_fontstyle (const SelContainer &objects, SPStyle *style_res); -int objects_query_fontfamily (const SelContainer &objects, SPStyle *style_res); -int objects_query_opacity (const SelContainer &objects, SPStyle *style_res); -int objects_query_strokewidth (const SelContainer &objects, SPStyle *style_res); -int objects_query_miterlimit (const SelContainer &objects, SPStyle *style_res); -int objects_query_strokecap (const SelContainer &objects, SPStyle *style_res); -int objects_query_strokejoin (const SelContainer &objects, SPStyle *style_res); +int objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_res, bool const isfill); +int objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res); +int objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res); +int objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_res); +int objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res); +int objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_res); +int objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_res); +int objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res); +int objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_res); -int objects_query_blur (const SelContainer &objects, SPStyle *style_res); +int objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res); -int sp_desktop_query_style_from_list (const SelContainer &list, SPStyle *style, int property); +int sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *style, int property); int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property); bool sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query); diff --git a/src/desktop.cpp b/src/desktop.cpp index 64353e582..0cf0a3872 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -716,7 +716,7 @@ Inkscape::UI::Widget::Dock* SPDesktop::getDock() { /** * \see SPDocument::getItemFromListAtPointBottom() */ -SPItem *SPDesktop::getItemFromListAtPointBottom(const SelContainer &list, Geom::Point const &p) const +SPItem *SPDesktop::getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const { g_return_val_if_fail (doc() != NULL, NULL); return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p); diff --git a/src/desktop.h b/src/desktop.h index 8765fa699..754e09766 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -319,7 +319,7 @@ public: //void push_event_context (GType type, const gchar *config, unsigned int key); void set_coordinate_status (Geom::Point p); - SPItem *getItemFromListAtPointBottom(const SelContainer &list, Geom::Point const &p) const; + SPItem *getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const; SPItem *getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; SPItem *getGroupAtPoint(Geom::Point const &p) const; Geom::Point point() const; diff --git a/src/document.cpp b/src/document.cpp index 5c49ff6c3..07ad10505 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1235,7 +1235,7 @@ static bool overlaps(Geom::Rect const &area, Geom::Rect const &box) return area.intersects(box); } -static SelContainer &find_items_in_area(SelContainer &s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, +static std::vector<SPItem*> &find_items_in_area(std::vector<SPItem*> &s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false) { g_return_val_if_fail(SP_IS_GROUP(group), s); @@ -1275,7 +1275,7 @@ static bool item_is_in_group(SPItem *item, SPGroup *group) return inGroup; } -SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, SelContainer const &list,Geom::Point const &p, bool take_insensitive) +SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, std::vector<SPItem*> const &list,Geom::Point const &p, bool take_insensitive) { g_return_val_if_fail(group, NULL); SPItem *bottomMost = 0; @@ -1391,9 +1391,9 @@ static SPItem *find_group_at_point(unsigned int dkey, SPGroup *group, Geom::Poin * Assumes box is normalized (and g_asserts it!) * */ -SelContainer SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const +std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const { - SelContainer x; + std::vector<SPItem*> x; g_return_val_if_fail(this->priv != NULL, x); return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within); } @@ -1405,16 +1405,16 @@ SelContainer SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) * */ -SelContainer SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const +std::vector<SPItem*> SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const { - SelContainer x; + std::vector<SPItem*> x; g_return_val_if_fail(this->priv != NULL, x); return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps); } -SelContainer SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const +std::vector<SPItem*> SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const { - SelContainer items; + std::vector<SPItem*> items; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); // When picking along the path, we don't want small objects close together @@ -1423,11 +1423,11 @@ SelContainer SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom:: gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0); prefs->setDouble("/options/cursortolerance/value", 0.25); - for(unsigned int i = 0; i < points.size(); i++) { + for(int i = points.size()-1;i>=0; i--) { SPItem *item = getItemAtPoint(key, points[i], false, NULL); if (item && items.end()==find(items.begin(),items.end(), item)) - items.push_front(item); + items.push_back(item); } // and now we restore it back diff --git a/src/document.h b/src/document.h index 87262a079..57ff7643c 100644 --- a/src/document.h +++ b/src/document.h @@ -233,7 +233,7 @@ public: /** * Returns the bottommost item from the list which is at the point, or NULL if none. */ - static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const SelContainer &list, Geom::Point const &p, bool take_insensitive = false); + static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const std::vector<SPItem*> &list, Geom::Point const &p, bool take_insensitive = false); static SPDocument *createDoc(Inkscape::XML::Document *rdoc, char const *uri, char const *base, char const *name, unsigned int keepalive, @@ -257,10 +257,10 @@ public: bool addResource(char const *key, SPObject *object); bool removeResource(char const *key, SPObject *object); const GSList *getResourceList(char const *key) const; - SelContainer getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; - SelContainer getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; + std::vector<SPItem*> getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; + std::vector<SPItem*> getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; - SelContainer getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const; + std::vector<SPItem*> getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const; SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; void changeUriAndHrefs(char const *uri); diff --git a/src/extension/execution-env.cpp b/src/extension/execution-env.cpp index 66a8c4358..90a7810e6 100644 --- a/src/extension/execution-env.cpp +++ b/src/extension/execution-env.cpp @@ -64,8 +64,8 @@ ExecutionEnv::ExecutionEnv (Effect * effect, Inkscape::UI::View::View * doc, Imp sp_namedview_document_from_window(desktop); if (desktop != NULL) { - SelContainer selected = desktop->getSelection()->itemList(); - for(SelContainer::const_iterator x=selected.begin();x!=selected.end();x++){ + std::vector<SPItem*> selected = desktop->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator x=selected.begin();x!=selected.end();x++){ Glib::ustring selected_id; selected_id = (*x)->getId(); _selected.insert(_selected.end(), selected_id); diff --git a/src/extension/implementation/implementation.cpp b/src/extension/implementation/implementation.cpp index 6eff3ede3..cea6d139f 100644 --- a/src/extension/implementation/implementation.cpp +++ b/src/extension/implementation/implementation.cpp @@ -48,7 +48,7 @@ Gtk::Widget *Implementation::prefs_effect(Inkscape::Extension::Effect *module, I SPDocument * current_document = view->doc(); using Inkscape::Util::GSListConstIterator; - SelContainer selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node const* first_select = NULL; if (!selected.empty()) { const SPItem * item = SP_ITEM(selected.front()); diff --git a/src/extension/implementation/script.cpp b/src/extension/implementation/script.cpp index f396e9848..95d5c7edc 100644 --- a/src/extension/implementation/script.cpp +++ b/src/extension/implementation/script.cpp @@ -689,9 +689,9 @@ void Script::effect(Inkscape::Extension::Effect *module, return; } - SelContainer selected = + std::vector<SPItem*> selected = desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer - for(SelContainer::const_iterator x=selected.begin();x!=selected.end();x++){ + for(std::vector<SPItem*>::const_iterator x=selected.begin();x!=selected.end();x++){ Glib::ustring selected_id; selected_id += "--id="; selected_id += (*x)->getId(); diff --git a/src/extension/internal/bitmap/imagemagick.cpp b/src/extension/internal/bitmap/imagemagick.cpp index 87ef30887..64abd6c4d 100644 --- a/src/extension/internal/bitmap/imagemagick.cpp +++ b/src/extension/internal/bitmap/imagemagick.cpp @@ -70,7 +70,7 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems(NULL) { SPDesktop *desktop = (SPDesktop*)view; - const SelContainer selectedItemList = desktop->selection->itemList(); + const std::vector<SPItem*> selectedItemList = desktop->selection->itemList(); int selectCount = selectedItemList.size(); // Init the data-holders @@ -83,7 +83,7 @@ ImageMagickDocCache::ImageMagickDocCache(Inkscape::UI::View::View * view) : _imageItems = new SPItem*[selectCount]; // Loop through selected items - for (SelContainer::const_iterator i=selectedItemList.begin();i!=selectedItemList.end();i++) { + for (std::vector<SPItem*>::const_iterator i=selectedItemList.begin();i!=selectedItemList.end();i++) { SPItem *item = static_cast<SPItem *>(*i); Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr()); if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) @@ -242,7 +242,7 @@ ImageMagick::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::Vie using Inkscape::Util::GSListConstIterator; - SelContainer selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { first_select = (selected.front())->getRepr(); diff --git a/src/extension/internal/bluredge.cpp b/src/extension/internal/bluredge.cpp index 138172715..257cac161 100644 --- a/src/extension/internal/bluredge.cpp +++ b/src/extension/internal/bluredge.cpp @@ -65,10 +65,10 @@ BlurEdge::effect (Inkscape::Extension::Effect *module, Inkscape::UI::View::View using Inkscape::Util::GSListConstIterator; // TODO need to properly refcount the items, at least - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); selection->clear(); - for(SelContainer::iterator item = items.begin(); + for(std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); ++item) { SPItem * spitem = static_cast<SPItem*>(*item); diff --git a/src/extension/internal/filter/filter.cpp b/src/extension/internal/filter/filter.cpp index 821c023ac..a5eb7de60 100644 --- a/src/extension/internal/filter/filter.cpp +++ b/src/extension/internal/filter/filter.cpp @@ -126,12 +126,12 @@ void Filter::effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::Vie Inkscape::Selection * selection = ((SPDesktop *)document)->selection; // TODO need to properly refcount the items, at least - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); - for(SelContainer::iterator item = items.begin(); + for(std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); ++item) { SPItem * spitem = static_cast<SPItem*>(*item); Inkscape::XML::Node * node = spitem->getRepr(); diff --git a/src/extension/internal/grid.cpp b/src/extension/internal/grid.cpp index 4c12f629c..440c6b822 100644 --- a/src/extension/internal/grid.cpp +++ b/src/extension/internal/grid.cpp @@ -192,7 +192,7 @@ Grid::prefs_effect(Inkscape::Extension::Effect *module, Inkscape::UI::View::View using Inkscape::Util::GSListConstIterator; - SelContainer selected = ((SPDesktop *)view)->getSelection()->itemList(); + std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); Inkscape::XML::Node * first_select = NULL; if (!selected.empty()) { first_select = (selected.front())->getRepr(); diff --git a/src/file.cpp b/src/file.cpp index 4325c838b..f9dbe00a7 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1063,7 +1063,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) desktop->doc()->importDefs(clipdoc); // copy objects - std::list<SPObject*> pasted_objects; + std::vector<Inkscape::XML::Node*> pasted_objects; for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { // Don't copy metadata, defs, named views and internal clipboard contents to the document if (!strcmp(obj->name(), "svg:defs")) { @@ -1082,7 +1082,7 @@ void sp_import_document(SPDesktop *desktop, SPDocument *clipdoc, bool in_place) target_parent->appendChild(obj_copy); Inkscape::GC::release(obj_copy); - pasted_objects.push_front(dynamic_cast<SPObject*>(obj_copy)); + pasted_objects.push_back((obj_copy)); } // Change the selection to the freshly pasted objects diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 5f1da6cf1..a72423bbb 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -1570,8 +1570,8 @@ void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTa { Inkscape::Selection *selection = desktop->getSelection(); - const SelContainer list=selection->itemList(); - for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + const std::vector<SPItem*> list=selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=list.begin();i!=list.end();i++) { sp_item_gradient_invert_vector_color(SP_ITEM(*i), fill_or_stroke); } @@ -1595,8 +1595,8 @@ void sp_gradient_reverse_selected_gradients(SPDesktop *desktop) if (drag && drag->selected) { drag->selected_reverse_vector(); } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) - const SelContainer list=selection->itemList(); - for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + const std::vector<SPItem*> list=selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=list.begin();i!=list.end();i++) { sp_item_gradient_reverse_vector(SP_ITEM(*i), Inkscape::FOR_FILL); sp_item_gradient_reverse_vector(SP_ITEM(*i), Inkscape::FOR_STROKE); } diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 649928060..525fc074f 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -2082,8 +2082,8 @@ void GrDrag::updateDraggers() this->draggers = NULL; g_return_if_fail(this->selection != NULL); - SelContainer list = this->selection->itemList(); - for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + std::vector<SPItem*> list = this->selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=list.begin();i!=list.end();i++) { SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; @@ -2151,8 +2151,8 @@ void GrDrag::updateLines() g_return_if_fail(this->selection != NULL); - SelContainer list = this->selection->itemList(); - for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + std::vector<SPItem*> list = this->selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=list.begin();i!=list.end();i++) { SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; @@ -2295,8 +2295,8 @@ void GrDrag::updateLevels() g_return_if_fail (this->selection != NULL); - SelContainer list = this->selection->itemList(); - for (SelContainer::const_iterator i=list.begin();i!=list.end();i++) { + std::vector<SPItem*> list = this->selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=list.begin();i!=list.end();i++) { SPItem *item = SP_ITEM(*i); Geom::OptRect rect = item->desktopVisualBounds(); if (rect) { diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 613440269..4d590173a 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -88,8 +88,8 @@ struct CheckProgress : TestConvergence { * Scans the items list and places those items that are * not connectors in filtered */ -void filterConnectors(SelContainer const &items, list<SPItem *> &filtered) { - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ +void filterConnectors(std::vector<SPItem*> const &items, list<SPItem *> &filtered) { + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); if(!isConnector(item)) { filtered.push_back(item); @@ -101,7 +101,7 @@ void filterConnectors(SelContainer const &items, list<SPItem *> &filtered) { * connectors between them, and uses graph layout techniques to find * a nice layout */ -void graphlayout(SelContainer const &items) { +void graphlayout(std::vector<SPItem*> const &items) { if(items.empty()) { return; } diff --git a/src/graphlayout.h b/src/graphlayout.h index c38f9471c..9794dd6b5 100644 --- a/src/graphlayout.h +++ b/src/graphlayout.h @@ -19,10 +19,10 @@ typedef struct _GSList GSList; class SPItem; -void graphlayout(SelContainer const &items); +void graphlayout(std::vector<SPItem*> const &items); bool isConnector(SPItem const *const item); -void filterConnectors(SelContainer const &items, std::list<SPItem *> &filtered); +void filterConnectors(std::vector<SPItem*> const &items, std::list<SPItem *> &filtered); #endif // SEEN_GRAPHLAYOUT_H diff --git a/src/helper/png-write.cpp b/src/helper/png-write.cpp index 55fef5a4c..fc365c435 100644 --- a/src/helper/png-write.cpp +++ b/src/helper/png-write.cpp @@ -361,7 +361,7 @@ sp_export_get_rows(guchar const **rows, void **to_free, int row, int num_rows, v /** * Hide all items that are not listed in list, recursively, skipping groups and defs. */ -static void hide_other_items_recursively(SPObject *o, const SelContainer &list, unsigned dkey) +static void hide_other_items_recursively(SPObject *o, const std::vector<SPItem*> &list, unsigned dkey) { if ( SP_IS_ITEM(o) && !SP_IS_DEFS(o) @@ -387,7 +387,7 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, unsigned long bgcolor, unsigned int (*status) (float, void *), void *data, bool force_overwrite, - const SelContainer &items_only) + const std::vector<SPItem*> &items_only) { return sp_export_png_file(doc, filename, Geom::Rect(Geom::Point(x0,y0),Geom::Point(x1,y1)), width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only); @@ -399,7 +399,7 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, unsigned long bgcolor, unsigned (*status)(float, void *), void *data, bool force_overwrite, - const SelContainer &items_only) + const std::vector<SPItem*> &items_only) { g_return_val_if_fail(doc != NULL, EXPORT_ERROR); g_return_val_if_fail(filename != NULL, EXPORT_ERROR); diff --git a/src/helper/png-write.h b/src/helper/png-write.h index 47fad1b41..04ca85cd6 100644 --- a/src/helper/png-write.h +++ b/src/helper/png-write.h @@ -38,12 +38,12 @@ ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, double x0, double y0, double x1, double y1, unsigned long int width, unsigned long int height, double xdpi, double ydpi, unsigned long bgcolor, - unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const SelContainer &items_only = SelContainer()); + unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>()); ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, Geom::Rect const &area, unsigned long int width, unsigned long int height, double xdpi, double ydpi, unsigned long bgcolor, - unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const SelContainer &items_only = SelContainer()); + unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>()); #endif // SEEN_SP_PNG_WRITE_H diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 95a6b16dd..6cdf09180 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -505,8 +505,8 @@ LPEKnot::doEffect_path (std::vector<Geom::Path> const &path_in) static void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){ if (SP_IS_GROUP(lpeitem)) { - SelContainer item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast<SPObject *>(*iter); if (SP_IS_LPE_ITEM(subitem)) { collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths); diff --git a/src/main.cpp b/src/main.cpp index 25dc91f14..c62b9cd25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1156,7 +1156,7 @@ static int sp_process_file_list(GSList *fl) } if (sp_export_svg) { if (sp_export_text_to_path) { - SelContainer items; + std::vector<SPItem*> items; SPRoot *root = doc->getRoot(); doc->ensureUpToDate(); for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) { @@ -1169,8 +1169,8 @@ static int sp_process_file_list(GSList *fl) items.push_back(item); } - SelContainer selected; - SelContainer to_select; + std::vector<SPItem*> selected; + std::vector<Inkscape::XML::Node*> to_select; sp_item_list_to_curves(items, selected, to_select); @@ -1435,7 +1435,7 @@ static int sp_do_export_png(SPDocument *doc) g_warning ("--export-use-hints can only be used with --export-id or --export-area-drawing; ignored."); } - SelContainer items; + std::vector<SPItem*> items; Geom::Rect area; if (sp_export_id || sp_export_area_drawing) { @@ -1459,7 +1459,7 @@ static int sp_do_export_png(SPDocument *doc) return 1; } - items.push_front(SP_ITEM(o)); + items.push_back(SP_ITEM(o)); if (sp_export_id_only) { g_print("Exporting only object with id=\"%s\"; all other objects hidden\n", sp_export_id); @@ -1647,7 +1647,7 @@ static int sp_do_export_png(SPDocument *doc) if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, - dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : SelContainer()) == 1 ) { + dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : std::vector<SPItem*>()) == 1 ) { g_print("Bitmap saved as: %s\n", filename.c_str()); } else { g_warning("Bitmap failed to save to: %s", filename.c_str()); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 960b5087b..830c3c1db 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -237,8 +237,8 @@ void Inkscape::ObjectSnapper::_collectNodes(SnapSourceType const &t, // current selection (see the comment in SelTrans::centerRequest()) bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER); if (old_pref2) { - SelContainer rotationSource=_snapmanager->getRotationCenterSource(); - for ( SelContainer::const_iterator itemlist=rotationSource.begin();itemlist!=rotationSource.end();itemlist++) { + std::vector<SPItem*> rotationSource=_snapmanager->getRotationCenterSource(); + for ( std::vector<SPItem*>::const_iterator itemlist=rotationSource.begin();itemlist!=rotationSource.end();itemlist++) { if ((*i).item == reinterpret_cast<SPItem*>(*itemlist)) { // don't snap to this item's rotation center _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false); diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index a5e71b720..ae1e0064f 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -51,13 +51,19 @@ inline bool less_than_objects(SPObject const *first, SPObject const *second) second->getRepr())<0; } +inline bool less_than_items(SPItem const *first, SPItem const *second) +{ + return sp_repr_compare_position(first->getRepr(), + second->getRepr())<0; +} + void sp_selected_path_combine(SPDesktop *desktop) { Inkscape::Selection *selection = desktop->getSelection(); SPDocument *doc = desktop->getDocument(); - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); if (items.size() < 1) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine.")); @@ -70,23 +76,22 @@ sp_selected_path_combine(SPDesktop *desktop) items = sp_degroup_list (items); // descend into any groups in selection - SelContainer to_paths; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + std::vector<SPItem*> to_paths; + for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++) { SPItem *item = (SPItem *) (*i); if (!dynamic_cast<SPPath *>(item) && !dynamic_cast<SPGroup *>(item)) { - to_paths.push_front(item); + to_paths.push_back(item); } } - SelContainer converted; + std::vector<Inkscape::XML::Node*> converted; bool did = sp_item_list_to_curves(to_paths, items, converted); to_paths.clear(); - for (SelContainer::const_iterator i=converted.begin();i!=converted.end();i++) - items.push_front(doc->getObjectByRepr((Inkscape::XML::Node*)(*i))); + for (std::vector<Inkscape::XML::Node*>::const_iterator i=converted.begin();i!=converted.end();i++) + items.push_back((SPItem*)doc->getObjectByRepr((Inkscape::XML::Node*)(*i))); items = sp_degroup_list (items); // converting to path may have added more groups, descend again - items.sort(less_than_objects); - items.reverse(); + sort(items.begin(),items.end(),less_than_objects); assert(!items.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 @@ -104,7 +109,7 @@ sp_selected_path_combine(SPDesktop *desktop) selection->clear(); } - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ SPItem *item = (SPItem *) (*i); SPPath *path = dynamic_cast<SPPath *>(item); @@ -206,8 +211,8 @@ sp_selected_path_break_apart(SPDesktop *desktop) bool did = false; - SelContainer itemlist(selection->itemList()); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist(selection->itemList()); + for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = (SPItem *) (*i); @@ -246,7 +251,7 @@ sp_selected_path_break_apart(SPDesktop *desktop) curve->unref(); - SelContainer reprs; + std::vector<Inkscape::XML::Node*> reprs; for (GSList *l = list; l != NULL; l = l->next) { curve = (SPCurve *) l->data; @@ -272,14 +277,13 @@ sp_selected_path_break_apart(SPDesktop *desktop) if (l == list) repr->setAttribute("id", id); - reprs.push_front(dynamic_cast<SPObject*>(repr)); + reprs.push_back(repr); Inkscape::GC::release(repr); } - + //reverse selection->setReprList(reprs); - reprs.clear(); g_slist_free(list); g_free(style); g_free(path_effect); @@ -312,10 +316,10 @@ sp_selected_path_to_curves(Inkscape::Selection *selection, SPDesktop *desktop, b desktop->setWaitingCursor(); } - SelContainer selected(selection->itemList()); - SelContainer to_select; + std::vector<SPItem*> selected(selection->itemList()); + std::vector<Inkscape::XML::Node*> to_select; selection->clear(); - SelContainer items(selected); + std::vector<SPItem*> items(selected); did = sp_item_list_to_curves(items, selected, to_select); @@ -346,27 +350,24 @@ void sp_selected_to_lpeitems(SPDesktop *desktop) return; } - SelContainer selected(selection->itemList()); - SelContainer to_select; + std::vector<SPItem*> selected(selection->itemList()); + std::vector<Inkscape::XML::Node*> to_select; selection->clear(); - SelContainer items(selected); + std::vector<SPItem*> items(selected); sp_item_list_to_curves(items, selected, to_select, true); - items.clear(); selection->setReprList(to_select); selection->addList(selected); - to_select.clear(); - selected.clear(); } bool -sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelContainer &to_select, bool skip_all_lpeitems) +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) { bool did = false; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); g_assert(item != NULL); @@ -399,9 +400,9 @@ sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelCon Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr(); if (repr) { - to_select.push_front(dynamic_cast<SPObject *>(repr)); + to_select.push_back(repr); did = true; - selected.remove(item); + selected.erase(find(selected.begin(),selected.end(),item)); } continue; @@ -409,10 +410,10 @@ sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelCon if (group) { group->removeAllPathEffects(true); - SelContainer item_list = sp_item_group_item_list(group); + std::vector<SPItem*> item_list = sp_item_group_item_list(group); - SelContainer item_to_select; - SelContainer item_selected; + std::vector<Inkscape::XML::Node*> item_to_select; + std::vector<SPItem*> item_selected; if (sp_item_list_to_curves(item_list, item_selected, item_to_select)) did = true; @@ -429,7 +430,7 @@ sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelCon continue; did = true; - selected.remove(item); + selected.erase(find(selected.begin(),selected.end(),item)); // remember the position of the item gint pos = item->getRepr()->position(); @@ -471,7 +472,7 @@ sp_item_list_to_curves(const SelContainer &items, SelContainer& selected, SelCon /* Buglet: We don't re-add the (new version of the) object to the selection of any other * desktops where it was previously selected. */ - to_select.push_front(dynamic_cast<SPObject *>(repr)); + to_select.push_back(repr); Inkscape::GC::release(repr); } @@ -613,7 +614,7 @@ void sp_selected_path_reverse(SPDesktop *desktop) { Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items = selection->itemList(); + std::vector<SPItem*> items = selection->itemList(); if (items.empty()) { desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse.")); @@ -627,7 +628,7 @@ sp_selected_path_reverse(SPDesktop *desktop) bool did = false; desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPPath *path = dynamic_cast<SPPath *>(static_cast<SPObject *>(*i)); if (!path) { diff --git a/src/path-chemistry.h b/src/path-chemistry.h index 388268af4..f454167a9 100644 --- a/src/path-chemistry.h +++ b/src/path-chemistry.h @@ -33,7 +33,7 @@ void sp_selected_path_to_curves (Inkscape::Selection *selection, SPDesktop *desk void sp_selected_to_lpeitems(SPDesktop *desktop); Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy); void sp_selected_path_reverse (SPDesktop *desktop); -bool sp_item_list_to_curves(const SelContainer &items, SelContainer &selected, SelContainer &to_select, bool skip_all_lpeitems = false); +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/removeoverlap.cpp b/src/removeoverlap.cpp index 9009de5e9..7cb1694e3 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -38,14 +38,14 @@ namespace { * such that rectangular bounding boxes are separated by at least xGap * horizontally and yGap vertically */ -void removeoverlap(SelContainer const &items, double const xGap, double const yGap) { +void removeoverlap(std::vector<SPItem*> const &items, double const xGap, double const yGap) { using Inkscape::Util::GSListConstIterator; - SelContainer selected(items); + std::vector<SPItem*> selected(items); std::vector<Record> records; std::vector<Rectangle *> rs; Geom::Point const gap(xGap, yGap); - for (SelContainer::iterator it(selected.begin()); + for (std::vector<SPItem*>::iterator it(selected.begin()); it != selected.end(); ++it) { diff --git a/src/removeoverlap.h b/src/removeoverlap.h index d050ca9ef..d873663d1 100644 --- a/src/removeoverlap.h +++ b/src/removeoverlap.h @@ -15,6 +15,6 @@ typedef struct _GSList GSList; -void removeoverlap(SelContainer const &items, double xGap, double yGap); +void removeoverlap(std::vector<SPItem*> const &items, double xGap, double yGap); #endif // SEEN_REMOVEOVERLAP_H diff --git a/src/selcue.cpp b/src/selcue.cpp index 0fab6e5a8..f48378cdc 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -96,15 +96,15 @@ void Inkscape::SelCue::_updateItemBboxes(Inkscape::Preferences *prefs) void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) { - const SelContainer items = _selection->itemList(); + const std::vector<SPItem*> items = _selection->itemList(); if (_item_bboxes.size() != items.size()) { _newItemBboxes(); return; } int bcount = 0; - SelContainer ll=_selection->itemList(); - for (SelContainer::const_iterator l=ll.begin();l!=ll.end();l++) { + std::vector<SPItem*> ll=_selection->itemList(); + for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();l++) { SPItem *item = static_cast<SPItem *>(*l); SPCanvasItem* box = _item_bboxes[bcount ++]; @@ -146,8 +146,8 @@ void Inkscape::SelCue::_newItemBboxes() int prefs_bbox = prefs->getBool("/tools/bounding_box"); - SelContainer ll=_selection->itemList(); - for (SelContainer::const_iterator l=ll.begin();l!=ll.end();l++) { + std::vector<SPItem*> ll=_selection->itemList(); + for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();l++) { SPItem *item = static_cast<SPItem *>(*l); Geom::OptRect const b = (prefs_bbox == 0) ? @@ -201,8 +201,8 @@ void Inkscape::SelCue::_newTextBaselines() } _text_baselines.clear(); - SelContainer ll=_selection->itemList(); - for (SelContainer::const_iterator l=ll.begin();l!=ll.end();l++) { + std::vector<SPItem*> ll=_selection->itemList(); + for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();l++) { SPItem *item = static_cast<SPItem *>(*l); SPCanvasItem* baseline_point = NULL; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 9f27ca22e..f1c96b6b8 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -279,23 +279,21 @@ void SelectionHelper::fixSelection(SPDesktop *dt) Inkscape::Selection *selection = dt->getSelection(); - SelContainer items ; + std::vector<SPItem*> items ; - SelContainer const selList = selection->itemList(); + std::vector<SPItem*> const selList = selection->itemList(); - for( SelContainer::const_iterator i=selList.begin();i!=selList.end();i++ ) { + for( std::vector<SPItem*>::const_reverse_iterator i=selList.rbegin();i!=selList.rend();i++ ) { SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); if( item && !dt->isLayer(item) && (!item->isLocked())) { - items.push_front(item); + items.push_back(item); } } selection->setList(items); - - items.clear(); } } // namespace Inkscape @@ -305,7 +303,7 @@ void SelectionHelper::fixSelection(SPDesktop *dt) * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t', * then prepends the copy to 'clip'. */ -static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, SelContainer &clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, std::vector<SPItem*> &clip, Inkscape::XML::Document* xml_doc) { Inkscape::XML::Node *copy = repr->duplicate(xml_doc); @@ -321,17 +319,17 @@ static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t copy->setAttribute("transform", affinestr); g_free(affinestr); - clip.push_front(dynamic_cast<SPObject*>(copy)); + clip.insert(clip.begin(),dynamic_cast<SPItem*>(copy)); } -static void sp_selection_copy_impl(SelContainer const &items, SelContainer &clip, Inkscape::XML::Document* xml_doc) +static void sp_selection_copy_impl(std::vector<SPItem*> const &items, std::vector<SPItem*> &clip, Inkscape::XML::Document* xml_doc) { // Sort items: - SelContainer sorted_items(items); - sorted_items.sort(sp_object_compare_position); + std::vector<SPItem*> sorted_items(items); + sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position); // Copy item reprs: - for (SelContainer::const_iterator i = sorted_items.begin();i!=sorted_items.end();i++) { + for (std::vector<SPItem*>::const_iterator i = sorted_items.begin();i!=sorted_items.end();i++) { SPItem *item = dynamic_cast<SPItem *>(SP_OBJECT(*i)); if (item) { sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc); @@ -339,22 +337,22 @@ static void sp_selection_copy_impl(SelContainer const &items, SelContainer &clip g_assert_not_reached(); } } - - clip.reverse(); + std::vector<SPItem*> tmp(clip); + for(int i=0;i<tmp.size();i++){clip[i]=tmp[tmp.size()-i-1];} sorted_items.clear(); } // TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items. -static SelContainer sp_selection_paste_impl(SPDocument *doc, SPObject *parent, SelContainer &clip) +static std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector<SPItem*> &clip) { Inkscape::XML::Document *xml_doc = doc->getReprDoc(); SPItem *parentItem = dynamic_cast<SPItem *>(parent); g_assert(parentItem != NULL); - SelContainer copied; + std::vector<Inkscape::XML::Node*> copied; // add objects to document - for (SelContainer::const_iterator l=clip.begin();l!=clip.end();l++) { + for (std::vector<SPItem*>::const_iterator l=clip.begin();l!=clip.end();l++) { Inkscape::XML::Node *repr = dynamic_cast<Inkscape::XML::Node *>(*l); Inkscape::XML::Node *copy = repr->duplicate(xml_doc); @@ -373,18 +371,18 @@ static SelContainer sp_selection_paste_impl(SPDocument *doc, SPObject *parent, S } parent->appendChildRepr(copy); - copied.push_front(dynamic_cast<SPObject*>(copy)); + copied.push_back(copy); Inkscape::GC::release(copy); } return copied; } -static void sp_selection_delete_impl(SelContainer const &items, bool propagate = true, bool propagate_descendants = true) +static void sp_selection_delete_impl(std::vector<SPItem*> const &items, bool propagate = true, bool propagate_descendants = true) { - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { sp_object_ref(static_cast<SPItem *>(*i), NULL); } - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { SPItem *item = static_cast<SPItem *>(*i); item->deleteObject(propagate, propagate_descendants); sp_object_unref(item, NULL); @@ -412,7 +410,7 @@ void sp_selection_delete(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted.")); return; } - SelContainer selected(selection->itemList()); + std::vector<SPItem*> selected(selection->itemList()); selection->clear(); sp_selection_delete_impl(selected); selected.clear(); @@ -470,7 +468,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) // them, just what we need sort(reprs.begin(),reprs.end(),sp_repr_compare_position); - SelContainer newsel; + std::vector<Inkscape::XML::Node*> newsel; std::vector<const gchar *> old_ids; std::vector<const gchar *> new_ids; @@ -500,7 +498,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) } } - newsel.push_front(dynamic_cast<SPObject*>(copy)); + newsel.push_back(copy); Inkscape::GC::release(copy); } @@ -546,8 +544,6 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) } selection->setReprList(newsel); - - newsel.clear(); } void sp_edit_clear_all(Inkscape::Selection *selection) @@ -560,11 +556,10 @@ void sp_edit_clear_all(Inkscape::Selection *selection) SPGroup *group = dynamic_cast<SPGroup *>(selection->layers()->currentLayer()); g_return_if_fail(group != NULL); - SelContainer items = sp_item_group_item_list(group); + std::vector<SPItem*> items = sp_item_group_item_list(group); - while (!items.empty()) { - reinterpret_cast<SPObject*>(items.front())->deleteObject(); - items.pop_front(); + for(int i=0;i<items.size();i++){ + reinterpret_cast<SPObject*>(items[i])->deleteObject(); } DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, @@ -581,7 +576,7 @@ void sp_edit_clear_all(Inkscape::Selection *selection) * onlysensitive - TRUE includes only non-locked items * ingroups - TRUE to recursively get grouped items children */ -SelContainer &get_all_items(SelContainer &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, SelContainer const &exclude) +std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude) { for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { SPItem *item = dynamic_cast<SPItem *>(child); @@ -592,7 +587,7 @@ SelContainer &get_all_items(SelContainer &list, SPObject *from, SPDesktop *deskt (exclude.empty() || exclude.end() == std::find(exclude.begin(),exclude.end(),child)) ) { - list.push_front(item); + list.insert(list.begin(),item); } if (ingroups || (item && desktop->isLayer(item))) { @@ -617,9 +612,9 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); - SelContainer items ; + std::vector<SPItem*> items ; - SelContainer exclude; + std::vector<SPItem*> exclude; if (invert) { exclude = selection->itemList(); } @@ -633,16 +628,16 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i (onlyvisible && dt->itemIsHidden(dynamic_cast<SPItem *>(dt->currentLayer()))) ) return; - SelContainer all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer())); + std::vector<SPItem*> all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer())); - for (SelContainer::const_iterator i=all_items.begin();i!=all_items.end();i++) { + for (std::vector<SPItem*>::const_reverse_iterator i=all_items.rbegin();i!=all_items.rend();i++) { SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); if (item && (!onlysensitive || !item->isLocked())) { if (!onlyvisible || !dt->itemIsHidden(item)) { if (!dt->isLayer(item)) { if (!invert || exclude.end() == std::find(exclude.begin(),exclude.end(),item)) { - items.push_front(item); // leave it in the list + items.push_back(item); // leave it in the list } } } @@ -653,12 +648,12 @@ static void sp_edit_select_all_full(SPDesktop *dt, bool force_all_layers, bool i break; } case PREFS_SELECTION_LAYER_RECURSIVE: { - SelContainer x; + std::vector<SPItem*> x; items = get_all_items(x, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude); break; } default: { - SelContainer x; + std::vector<SPItem*> x; items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); break; } @@ -709,7 +704,7 @@ static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscap Inkscape::GC::release(spnew); topmost --; // only reduce count for those items deleted from topmost_parent } else { // move it to topmost_parent first - SelContainer temp_clip; + std::vector<SPItem*> temp_clip; // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform @@ -729,11 +724,11 @@ static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscap sp_repr_unparent(current); // paste into topmost_parent (temporarily) - SelContainer copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); + std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); if (!temp_clip.empty())temp_clip.clear() ; if (!copied.empty()) { // if success, // take pasted object (now in topmost_parent) - Inkscape::XML::Node *in_topmost = dynamic_cast<Inkscape::XML::Node *>(copied.front()); + Inkscape::XML::Node *in_topmost = copied.back(); // make a copy Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); // remove pasted @@ -800,10 +795,10 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } // first check whether there is anything to ungroup - SelContainer old_select = selection->itemList(); - SelContainer new_select; + std::vector<SPItem*> old_select = selection->itemList(); + std::vector<SPItem*> new_select; GSList *groups = NULL; - for (SelContainer::const_iterator item = old_select.begin(); item!=old_select.end(); item++) { + for (std::vector<SPItem*>::const_iterator item = old_select.begin(); item!=old_select.end(); item++) { SPItem *obj = static_cast<SPItem*>(*item); if (dynamic_cast<SPGroup *>(obj)) { groups = g_slist_prepend(groups, obj); @@ -816,13 +811,13 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) return; } - SelContainer items(old_select); + std::vector<SPItem*> items(old_select); selection->clear(); // If any of the clones refer to the groups, unlink them and replace them with successors // in the items list. GSList *clones_to_unlink = NULL; - for (SelContainer::const_iterator item = items.begin(); item!=items.end(); item++) { + for (std::vector<SPItem*>::const_iterator item = items.begin(); item!=items.end(); item++) { SPUse *use = dynamic_cast<SPUse *>(static_cast<SPItem *>(*item)); SPItem *original = use; @@ -842,21 +837,21 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) for (GSList *item = clones_to_unlink; item; item = item->next) { SPUse *use = static_cast<SPUse *>(item->data); - SelContainer::iterator items_node = std::find(items.begin(),items.end(), item->data); + std::vector<SPItem*>::iterator items_node = std::find(items.begin(),items.end(), item->data); (*items_node) = use->unlink(); } g_slist_free(clones_to_unlink); // do the actual work - for (SelContainer::iterator item = items.begin(); item!=items.end(); item++) { + for (std::vector<SPItem*>::iterator item = items.begin(); item!=items.end(); item++) { SPItem *obj = static_cast<SPItem *>(*item); // ungroup only the groups marked earlier if (g_slist_find(groups, *item) != NULL) { - SelContainer children; + std::vector<SPItem*> children; sp_item_group_ungroup(dynamic_cast<SPGroup *>(obj), children, false); // add the items resulting from ungrouping to the selection - new_select.splice(new_select.end(),children); + new_select.insert(new_select.end(),children.begin(),children.end()); (*item) = NULL; // zero out the original pointer, which is no longer valid } else { // if not a group, keep in the selection @@ -873,25 +868,24 @@ void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop) } /** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */ -SelContainer -sp_degroup_list(SelContainer &items) +std::vector<SPItem*> +sp_degroup_list(std::vector<SPItem*> &items) { - SelContainer out; + std::vector<SPItem*> out; bool has_groups = false; - for (SelContainer::const_iterator item=items.begin();item!=items.end();item++) { + for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) { SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(*item)); if (!group) { - out.push_front(*item); + out.push_back(*item); } else { has_groups = true; - SelContainer members = sp_item_group_item_list(group); - for (SelContainer::const_iterator member=members.begin();member!=members.end();member++) { - out.push_front(*member); + std::vector<SPItem*> members = sp_item_group_item_list(group); + for (std::vector<SPItem*>::const_iterator member=members.begin();member!=members.end();member++) { + out.push_back(*member); } members.clear(); } } - out.reverse(); items.clear(); if (has_groups) { // recurse if we unwrapped a group - it may have contained others @@ -904,7 +898,7 @@ sp_degroup_list(SelContainer &items) /** If items in the list have a common parent, return it, otherwise return NULL */ static SPGroup * -sp_item_list_common_parent_group(SelContainer const items) +sp_item_list_common_parent_group(std::vector<SPItem*> const items) { if (items.empty()) { return NULL; @@ -914,7 +908,7 @@ sp_item_list_common_parent_group(SelContainer const items) if (!dynamic_cast<SPGroup *>(parent)) { return NULL; } - for (SelContainer::const_iterator item=items.begin();item!=items.end();item++) { + for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) { if((*item)==items.front())continue; if (SP_OBJECT(*item)->parent != parent) { return NULL; @@ -926,12 +920,12 @@ sp_item_list_common_parent_group(SelContainer const items) /** Finds out the minimum common bbox of the selected items. */ static Geom::OptRect -enclose_items(SelContainer const &items) +enclose_items(std::vector<SPItem*> const &items) { g_assert(!items.empty()); Geom::OptRect r; - for (SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) { r.unionWith(static_cast<SPItem *>(*i)->desktopVisualBounds()); } return r; @@ -956,7 +950,7 @@ int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *sec void sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) { - SelContainer items= selection->itemList(); + std::vector<SPItem*> items= selection->itemList(); if (items.empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise.")); return; @@ -971,16 +965,16 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr()); /* Construct reverse-ordered list of selected children. */ - SelContainer rev(items); - rev.sort(sp_item_repr_compare_position_obj); + std::vector<SPItem*> rev(items); + sort(rev.begin(),rev.end(),sp_item_repr_compare_position); // Determine the common bbox of the selected items. Geom::OptRect selected = enclose_items(items); // Iterate over all objects in the selection (starting from top). if (selected) { - while (!rev.empty()) { - SPObject *child = reinterpret_cast<SPObject*>(rev.front()); + for (std::vector<SPItem*>::const_iterator item=rev.begin();item!=rev.end();item++) { + SPObject *child = reinterpret_cast<SPObject*>(*item); // for each selected object, find the next sibling for (SPObject *newref = child->next; newref; newref = newref->next) { // if the sibling is an item AND overlaps our selection, @@ -997,7 +991,6 @@ sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) } } } - rev.pop_front(); } } else { rev.clear(); @@ -1017,7 +1010,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto return; } - SelContainer items = selection->itemList(); + std::vector<SPItem*> items = selection->itemList(); SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { @@ -1039,7 +1032,7 @@ void sp_selection_raise_to_top(Inkscape::Selection *selection, SPDesktop *deskto void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) { - SelContainer items = selection->itemList(); + std::vector<SPItem*> items = selection->itemList(); if (items.empty()) { selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower.")); return; @@ -1057,14 +1050,13 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) Geom::OptRect selected = enclose_items(items); /* Construct direct-ordered list of selected children. */ - SelContainer rev(items); - rev.sort(sp_item_repr_compare_position_obj); - rev.reverse(); + std::vector<SPItem*> rev(items); + sort(rev.begin(),rev.end(),sp_item_repr_compare_position); // Iterate over all objects in the selection (starting from top). if (selected) { - while (!rev.empty()) { - SPObject *child = reinterpret_cast<SPObject*>(rev.front()); + for (std::vector<SPItem*>::const_reverse_iterator item=rev.rbegin();item!=rev.rend();item++) { + SPObject *child = reinterpret_cast<SPObject*>(*item); // for each selected object, find the prev sibling for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) { // if the sibling is an item AND overlaps our selection, @@ -1085,7 +1077,6 @@ void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) } } } - rev.pop_front(); } } else { rev.clear(); @@ -1105,7 +1096,7 @@ void sp_selection_lower_to_bottom(Inkscape::Selection *selection, SPDesktop *des return; } - SelContainer items =selection->itemList(); + std::vector<SPItem*> items =selection->itemList(); SPGroup const *group = sp_item_list_common_parent_group(items); if (!group) { @@ -1268,8 +1259,8 @@ void sp_selection_remove_livepatheffect(SPDesktop *desktop) desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from.")); return; } - SelContainer list=selection->itemList(); - for ( SelContainer::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) { + std::vector<SPItem*> list=selection->itemList(); + for ( std::vector<SPItem*>::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) { SPItem *item = reinterpret_cast<SPItem*>(*itemlist); sp_selection_remove_livepatheffect_impl(item); @@ -1330,16 +1321,16 @@ void sp_selection_to_next_layer(SPDesktop *dt, bool suppressDone) return; } - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); bool no_more = false; // Set to true, if no more layers above SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); if (next) { - SelContainer temp_clip; + std::vector<SPItem*> temp_clip; sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); sp_selection_delete_impl(items, false, false); next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers - SelContainer copied; + std::vector<Inkscape::XML::Node*> copied; if (next) { copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip); } else { @@ -1375,16 +1366,16 @@ void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) return; } - const SelContainer items(selection->itemList()); + const std::vector<SPItem*> items(selection->itemList()); bool no_more = false; // Set to true, if no more layers below SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); if (next) { - SelContainer temp_clip; + std::vector<SPItem*> 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); next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers - SelContainer copied; + std::vector<Inkscape::XML::Node*> copied; if (next) { copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip); } else { @@ -1418,13 +1409,13 @@ void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) return; } - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); if (moveto) { - SelContainer temp_clip; + std::vector<SPItem*> 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); - SelContainer copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); + std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); selection->setReprList(copied); copied.clear(); if (!temp_clip.empty()) temp_clip.clear(); @@ -1468,8 +1459,8 @@ static bool selection_contains_both_clone_and_original(Inkscape::Selection *selection) { bool clone_with_original = false; - SelContainer items = selection->itemList(); - for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { + std::vector<SPItem*> items = selection->itemList(); + for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*l)); if (item) { clone_with_original |= selection_contains_original(item, selection); @@ -1513,8 +1504,8 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons persp3d_apply_affine_transformation(transf_persp, affine); } - SelContainer items = selection->itemList(); - for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { + std::vector<SPItem*> items = selection->itemList(); + for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*l)); if( dynamic_cast<SPRoot *>(item) ) { @@ -1784,9 +1775,9 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) if (selection->isEmpty()) return; - SelContainer items = selection->itemList(); + std::vector<SPItem*> items = selection->itemList(); Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw - for (SelContainer::const_iterator l=items.begin();l!=items.end() ;l++) { + for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*l)); if (item) { sp_item_rotate_rel(item, rot_90); @@ -1843,15 +1834,15 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); bool ingroups = TRUE; - SelContainer x,y; - SelContainer all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); - SelContainer all_matches; + std::vector<SPItem*> x,y; + std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); + std::vector<SPItem*> all_matches; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items = selection->itemList(); - for (SelContainer::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { + std::vector<SPItem*> items = selection->itemList(); + for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(*sel_iter)); - SelContainer matches = all_list; + std::vector<SPItem*> matches = all_list; if (fill) { matches = sp_get_same_fill_or_stroke_color(sel, matches, SP_FILL_COLOR); } @@ -1863,7 +1854,7 @@ void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolea matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_DASHES); matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_MARKERS); } - all_matches.splice(all_matches.end(), matches); + all_matches.insert(all_matches.end(), matches.begin(),matches.end()); } selection->clear(); @@ -1889,14 +1880,14 @@ void sp_select_same_object_type(SPDesktop *desktop) bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); bool ingroups = TRUE; - SelContainer x,y; - SelContainer all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); - SelContainer matches = all_list; + std::vector<SPItem*> x,y; + std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); + std::vector<SPItem*> matches = all_list; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { + std::vector<SPItem*> items=selection->itemList(); + for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(*sel_iter)); if (sel) { matches = sp_get_same_object_type(sel, matches); @@ -1927,13 +1918,13 @@ void sp_select_same_stroke_style(SPDesktop *desktop) bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); bool ingroups = TRUE; - SelContainer x,y; - SelContainer matches = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); + std::vector<SPItem*> x,y; + std::vector<SPItem*> matches = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items=selection->itemList(); + std::vector<SPItem*> items=selection->itemList(); - for (SelContainer::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { + for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(*sel_iter)); if (sel) { matches = sp_get_same_stroke_style(sel, matches, SP_STROKE_STYLE_WIDTH); @@ -1953,14 +1944,14 @@ void sp_select_same_stroke_style(SPDesktop *desktop) * Find all items in src list that have the same fill or stroke style as sel * Return the list of matching items */ -SelContainer sp_get_same_fill_or_stroke_color(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type) +std::vector<SPItem*> sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type) { - SelContainer matches ; + std::vector<SPItem*> matches ; gboolean match = false; SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke); - for (SelContainer::const_iterator i=src.begin();i!=src.end();i++) { + for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { SPItem *iter = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); if (iter) { SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke); @@ -2000,7 +1991,7 @@ SelContainer sp_get_same_fill_or_stroke_color(SPItem *sel, SelContainer &src, SP } if (match) { - matches.push_front(iter); + matches.push_back(iter); } } else { g_assert_not_reached(); @@ -2051,14 +2042,14 @@ static bool item_type_match (SPItem *i, SPItem *j) * Find all items in src list that have the same object type as sel by type * Return the list of matching items */ -SelContainer sp_get_same_object_type(SPItem *sel, SelContainer &src) +std::vector<SPItem*> sp_get_same_object_type(SPItem *sel, std::vector<SPItem*> &src) { - SelContainer matches; + std::vector<SPItem*> matches; - for (SelContainer::const_iterator i=src.begin();i!=src.end();i++) { + for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); if (item && item_type_match(sel, item)) { - matches.push_front(item); + matches.push_back(item); } } return matches; @@ -2068,9 +2059,9 @@ SelContainer sp_get_same_object_type(SPItem *sel, SelContainer &src) * Find all items in src list that have the same stroke style as sel by type * Return the list of matching items */ -SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type) +std::vector<SPItem*> sp_get_same_stroke_style(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type) { - SelContainer matches; + std::vector<SPItem*> matches; gboolean match = false; SPStyle *sel_style = sel->style; @@ -2083,14 +2074,14 @@ SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectSt * Stroke width needs to handle transformations, so call this function * to get the transformed stroke width */ - SelContainer objects; + std::vector<SPItem*> objects; SPStyle *sel_style_for_width = NULL; if (type == SP_STROKE_STYLE_WIDTH) { - objects.push_front(sel); + objects.push_back(sel); sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT); objects_query_strokewidth (objects, sel_style_for_width); } - for (SelContainer::const_iterator i=src.begin();i!=src.end();i++) { + for (std::vector<SPItem*>::const_iterator i=src.begin();i!=src.end();i++) { SPItem *iter = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); if (iter) { SPStyle *iter_style = iter->style; @@ -2099,8 +2090,8 @@ SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectSt if (type == SP_STROKE_STYLE_WIDTH) { match = (sel_style->stroke_width.set == iter_style->stroke_width.set); if (sel_style->stroke_width.set && iter_style->stroke_width.set) { - SelContainer objects; - objects.push_front(iter); + std::vector<SPItem*> objects; + objects.insert(objects.begin(),iter); SPStyle tmp_style(SP_ACTIVE_DOCUMENT); objects_query_strokewidth (objects, &tmp_style); @@ -2130,7 +2121,7 @@ SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectSt } if (match) { - matches.push_front(iter); + matches.insert(matches.begin(),iter); } } else { g_assert_not_reached(); @@ -2386,11 +2377,11 @@ SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, template <typename D> -SPItem *next_item_from_list(SPDesktop *desktop, SelContainer const items, +SPItem *next_item_from_list(SPDesktop *desktop, std::vector<SPItem*> const items, SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) { SPObject *current=root; - for(SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) { SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); if ( root->isAncestorOf(item) && ( !only_in_viewport || desktop->isWithinViewport(item) ) ) @@ -2590,7 +2581,7 @@ void sp_selection_clone(SPDesktop *desktop) // 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); - SelContainer newsel; + std::vector<Inkscape::XML::Node*> newsel; for(std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ Inkscape::XML::Node *sel_repr = *i; @@ -2609,7 +2600,7 @@ void sp_selection_clone(SPDesktop *desktop) // add the new clone to the top of the original's parent parent->appendChild(clone); - newsel.push_front(dynamic_cast<SPObject*>(clone)); + newsel.push_back(clone); Inkscape::GC::release(clone); } @@ -2642,8 +2633,8 @@ sp_selection_relink(SPDesktop *desktop) // Get a copy of current selection. bool relinked = false; - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = static_cast<SPItem *>(*i); if (dynamic_cast<SPUse *>(item)) { @@ -2678,10 +2669,10 @@ sp_selection_unlink(SPDesktop *desktop) } // Get a copy of current selection. - SelContainer new_select; + std::vector<SPItem*> new_select; bool unlinked = false; - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=selection->itemList(); + for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ SPItem *item = static_cast<SPItem *>(*i); if (dynamic_cast<SPText *>(item)) { @@ -2698,7 +2689,7 @@ sp_selection_unlink(SPDesktop *desktop) if (!(dynamic_cast<SPUse *>(item) || dynamic_cast<SPTRef *>(item))) { // keep the non-use item in the new selection - new_select.push_front(item); + new_select.push_back(item); continue; } @@ -2708,7 +2699,7 @@ sp_selection_unlink(SPDesktop *desktop) unlink = use->unlink(); // Unable to unlink use (external or invalid href?) if (!unlink) { - new_select.push_front(item); + new_select.push_back(item); continue; } } else /*if (SP_IS_TREF(use))*/ { @@ -2718,7 +2709,7 @@ sp_selection_unlink(SPDesktop *desktop) unlinked = true; // Add ungrouped items to the new selection. - new_select.push_front(unlink); + new_select.push_back(unlink); } if (!new_select.empty()) { // set new selection @@ -2747,7 +2738,7 @@ sp_select_clone_original(SPDesktop *desktop) // Check if other than two objects are selected - SelContainer items=selection->itemList(); + std::vector<SPItem*> items=selection->itemList(); if (items.size() != 1 || !item) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error); return; @@ -2845,8 +2836,8 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop) Inkscape::SVGOStringStream os; SPObject * firstItem = NULL; - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) { if (firstItem) { os << "|"; @@ -2930,7 +2921,7 @@ 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]; - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? @@ -2948,10 +2939,10 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) } // Create a list of duplicates, to be pasted inside marker element. - SelContainer repr_copies; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<Inkscape::XML::Node*> repr_copies; + for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); - repr_copies.push_front(dynamic_cast<SPObject*>(dup)); + repr_copies.push_back(dup); } Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); @@ -2959,7 +2950,7 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) if (apply) { // Delete objects so that their clones don't get alerted; // the objects will be restored inside the marker element. - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPObject *item = reinterpret_cast<SPObject*>(*i); item->deleteObject(false); } @@ -2987,8 +2978,8 @@ void sp_selection_to_marker(SPDesktop *desktop, bool apply) static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) { SPGroup *group = dynamic_cast<SPGroup *>(item); if (group && !dynamic_cast<SPBox3D *>(item) && !wholegroups) { - SelContainer items=sp_item_group_item_list(group); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=sp_item_group_item_list(group); + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ sp_selection_to_guides_recursive(static_cast<SPItem*>(*i), wholegroups); } } else { @@ -3004,7 +2995,7 @@ void sp_selection_to_guides(SPDesktop *desktop) SPDocument *doc = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); // we need to copy the list because it gets reset when objects are deleted - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); if (items.empty()) { desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides.")); @@ -3019,7 +3010,7 @@ 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 (SelContainer::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(static_cast<SPItem*>(*i), wholegroups); } @@ -3282,9 +3273,9 @@ sp_selection_tile(SPDesktop *desktop, bool apply) move_p[Geom::Y] = -move_p[Geom::Y]; Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); - SelContainer items (selection->itemList()); + std::vector<SPItem*> items (selection->itemList()); - items.sort(sp_object_compare_position); + sort(items.begin(),items.end(),sp_object_compare_position); // bottommost object, after sorting SPObject *parent = SP_OBJECT(items.front())->parent; @@ -3304,19 +3295,17 @@ sp_selection_tile(SPDesktop *desktop, bool apply) gint pos = SP_OBJECT(items.front())->getRepr()->position(); // create a list of duplicates - SelContainer repr_copies; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<Inkscape::XML::Node*> repr_copies; + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ Inkscape::XML::Node *dup = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); - repr_copies.push_front(dynamic_cast<SPObject*>(dup)); + repr_copies.push_back(dup); } - // restore the z-order after prepends - repr_copies.reverse(); 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 (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPObject *item = reinterpret_cast<SPObject*>(*i); item->deleteObject(false); } @@ -3385,12 +3374,12 @@ void sp_selection_untile(SPDesktop *desktop) return; } - SelContainer new_select; + std::vector<SPItem*> new_select; bool did = false; - SelContainer items(selection->itemList()); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items(selection->itemList()); + for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ SPItem *item = static_cast<SPItem *>(*i); SPStyle *style = item->style; @@ -3427,7 +3416,7 @@ void sp_selection_untile(SPDesktop *desktop) Geom::Affine transform( i->transform * pat_transform ); i->doWriteTransform(i->getRepr(), transform); - new_select.push_front(i); + new_select.push_back(i); } else { g_assert_not_reached(); } @@ -3547,10 +3536,10 @@ void sp_selection_create_bitmap_copy(SPDesktop *desktop) } // List of the items to show; all others will be hidden - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); // Sort items so that the topmost comes last - items.sort(sp_item_repr_compare_position_obj); + sort(items.begin(),items.end(),sp_item_repr_compare_position); // 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) @@ -3770,7 +3759,7 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) Inkscape::GC::release(spnew); topmost --; // only reduce count for those items deleted from topmost_parent } else { // move it to topmost_parent first - SelContainer temp_clip; + std::vector<SPItem*> temp_clip; // At this point, current may already have no item, due to its being a clone whose original is already moved away // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform @@ -3790,10 +3779,10 @@ void sp_selection_set_clipgroup(SPDesktop *desktop) sp_repr_unparent(current); // paste into topmost_parent (temporarily) - SelContainer copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); + std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); if (!copied.empty()) { // if success, // take pasted object (now in topmost_parent) - Inkscape::XML::Node *in_topmost = dynamic_cast<Inkscape::XML::Node *>(copied.front()); + Inkscape::XML::Node *in_topmost = copied.back(); // make a copy Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); // remove pasted @@ -3875,9 +3864,9 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ doc->ensureUpToDate(); - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); - items.sort(sp_object_compare_position); + sort(items.begin(),items.end(),sp_object_compare_position); // See lp bug #542004 selection->clear(); @@ -3886,7 +3875,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ GSList *mask_items = NULL; GSList *apply_to_items = NULL; GSList *items_to_delete = NULL; - SelContainer items_to_select; + std::vector<SPItem*> items_to_select; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool topmost = prefs->getBool("/options/maskobject/topmost", true); @@ -3897,7 +3886,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ // all selected items are used for mask, which is applied to a layer apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer()); - for (SelContainer::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 = SP_OBJECT(*i)->getRepr()->duplicate(xml_doc); mask_items = g_slist_prepend(mask_items, dup); @@ -3906,7 +3895,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ items_to_delete = g_slist_prepend(items_to_delete, item); } else { - items_to_select.push_front(item); + items_to_select.push_back((SPItem*)item); } } } else if (!topmost) { @@ -3919,16 +3908,16 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ items_to_delete = g_slist_prepend(items_to_delete, item); } - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { if(i==items.begin())continue; apply_to_items = g_slist_prepend(apply_to_items, *i); - items_to_select.push_front(*i); + items_to_select.push_back(*i); } } else { GSList *i = NULL; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { apply_to_items = g_slist_prepend(apply_to_items, *i); - items_to_select.push_front(*i); + items_to_select.push_back(*i); } Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); @@ -3953,7 +3942,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ for (GSList *i = apply_to_items ; NULL != i ; i = i->next) { reprs_to_group.push_back(static_cast<SPObject*>(i->data)->getRepr()); - items_to_select.remove(static_cast<SPObject*>(i->data)); + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),static_cast<SPObject*>(i->data))); } sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); @@ -3963,7 +3952,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ apply_to_items = NULL; apply_to_items = g_slist_prepend(apply_to_items, doc->getObjectByRepr(group)); - items_to_select.push_front(doc->getObjectByRepr(group)); + items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group))); Inkscape::GC::release(group); } @@ -4003,7 +3992,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ Inkscape::XML::Node *spnew = current->duplicate(xml_doc); gint position = current->position(); - items_to_select.remove(item); + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item)); current->parent()->appendChild(group); sp_repr_unparent(current); group->appendChild(spnew); @@ -4012,7 +4001,7 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ // Apply clip/mask to group instead apply_mask_to = group; - items_to_select.push_front(doc->getObjectByRepr(group)); + items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group))); Inkscape::GC::release(spnew); Inkscape::GC::release(group); } @@ -4027,12 +4016,10 @@ void sp_selection_set_mask(SPDesktop *desktop, bool apply_clip_path, bool apply_ for (GSList *i = items_to_delete; NULL != i; i = i->next) { SPObject *item = reinterpret_cast<SPObject*>(i->data); item->deleteObject(false); - items_to_select.remove(item); + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item)); } g_slist_free(items_to_delete); - items_to_select.reverse(); - selection->addList(items_to_select); if (apply_clip_path) { @@ -4065,17 +4052,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; - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); selection->clear(); GSList *items_to_ungroup = NULL; - SelContainer items_to_select(items); - items_to_select.reverse(); + 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 (SelContainer::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 = reinterpret_cast<SPItem *>(*i); @@ -4140,7 +4126,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { repr->setPosition((pos + 1) > 0 ? (pos + 1) : 0); SPItem *mask_item = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(repr)); - items_to_select.push_front(mask_item); + items_to_select.push_back(mask_item); // transform mask, so it is moved the same spot where mask was applied Geom::Affine transform(mask_item->transform); @@ -4155,10 +4141,10 @@ 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.remove(group); - SelContainer children; + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),group)); + std::vector<SPItem*> children; sp_item_group_ungroup(group, children, false); - items_to_select.splice(items_to_select.begin(),children); + items_to_select.insert(items_to_select.end(),children.rbegin(),children.rend()); } else { g_assert_not_reached(); } @@ -4167,7 +4153,6 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { g_slist_free(items_to_ungroup); // rebuild selection - items_to_select.reverse(); selection->addList(items_to_select); if (apply_clip_path) { diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h index bc317d556..2acd62c02 100644 --- a/src/selection-chemistry.h +++ b/src/selection-chemistry.h @@ -143,9 +143,9 @@ enum SPSelectStrokeStyleType { void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean strok, gboolean style); void sp_select_same_stroke_style(SPDesktop *desktop); void sp_select_same_object_type(SPDesktop *desktop); -SelContainer sp_get_same_fill_or_stroke_color(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type); -SelContainer sp_get_same_stroke_style(SPItem *sel, SelContainer &src, SPSelectStrokeStyleType type); -SelContainer sp_get_same_object_type(SPItem *sel, SelContainer &src); +std::vector<SPItem*> sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type); +std::vector<SPItem*> sp_get_same_stroke_style(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type); +std::vector<SPItem*> sp_get_same_object_type(SPItem *sel, std::vector<SPItem*> &src); void scroll_to_show_item(SPDesktop *desktop, SPItem *item); @@ -172,9 +172,9 @@ void unlock_all_in_all_layers(SPDesktop *dt); void unhide_all(SPDesktop *dt); void unhide_all_in_all_layers(SPDesktop *dt); -SelContainer &get_all_items(SelContainer &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, SelContainer const &exclude); +std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude); -SelContainer sp_degroup_list (SelContainer &items); +std::vector<SPItem*> sp_degroup_list (std::vector<SPItem*> &items); /* selection cycling */ typedef enum diff --git a/src/selection-describer.cpp b/src/selection-describer.cpp index 0625c4002..d86cfa700 100644 --- a/src/selection-describer.cpp +++ b/src/selection-describer.cpp @@ -40,13 +40,13 @@ #include "sp-spiral.h" // Returns a list of terms for the items to be used in the statusbar -char* collect_terms (const SelContainer &items) +char* collect_terms (const std::vector<SPItem*> &items) { GSList *check = NULL; std::stringstream ss; bool first = true; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(*iter)); if (item) { const char *term = item->displayName(); @@ -61,11 +61,11 @@ char* collect_terms (const SelContainer &items) } // Returns the number of terms in the list -static int count_terms (const SelContainer &items) +static int count_terms (const std::vector<SPItem*> &items) { GSList *check = NULL; int count=0; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(*iter)); if (item) { const char *term = item->displayName(); @@ -79,10 +79,10 @@ static int count_terms (const SelContainer &items) } // Returns the number of filtered items in the list -static int count_filtered (const SelContainer &items) +static int count_filtered (const std::vector<SPItem*> &items) { int count=0; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>((*iter))); if (item) { count += item->isFiltered(); @@ -122,7 +122,7 @@ void SelectionDescriber::_selectionModified(Inkscape::Selection *selection, guin } void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { - SelContainer const items = selection->itemList(); + std::vector<SPItem*> const items = selection->itemList(); if (items.empty()) { // no items _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); diff --git a/src/selection.cpp b/src/selection.cpp index cbde9a799..2e8251048 100644 --- a/src/selection.cpp +++ b/src/selection.cpp @@ -44,7 +44,7 @@ namespace Inkscape { Selection::Selection(LayerModel *layers, SPDesktop *desktop) : _objs(SelContainer()), _reprs(std::vector<XML::Node*>()), - _items(SelContainer()), + _items(std::vector<SPItem*>()), _layers(layers), _desktop(desktop), _selection_context(NULL), @@ -234,7 +234,7 @@ void Selection::_remove(SPObject *obj) { _objs.remove(obj); } -void Selection::setList(SelContainer const &list) { +void Selection::setList(std::vector<SPItem*> const &list) { // Clear and add, or just clear with emit. if (!list.empty()) { _clear(); @@ -242,14 +242,14 @@ void Selection::setList(SelContainer const &list) { } else clear(); } -void Selection::addList(SelContainer const &list) { +void Selection::addList(std::vector<SPItem*> const &list) { if (list.empty()) return; _invalidateCachedLists(); - for ( SelContainer::const_iterator iter=list.begin();iter!=list.end();iter++ ) { + for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end();iter++ ) { SPObject *obj = reinterpret_cast<SPObject *>(*iter); if (includes(obj)) continue; _add (obj); @@ -258,11 +258,11 @@ void Selection::addList(SelContainer const &list) { _emitChanged(); } -void Selection::setReprList(SelContainer const &list) { +void Selection::setReprList(std::vector<XML::Node*> const &list) { _clear(); - for ( SelContainer::const_iterator iter=list.begin();iter!=list.end();iter++ ) { - SPObject *obj=_objectForXMLNode(reinterpret_cast<Inkscape::XML::Node *>(*iter)); + for ( std::vector<XML::Node*>::const_reverse_iterator iter=list.rbegin();iter!=list.rend();iter++ ) { + SPObject *obj=_objectForXMLNode(*iter); if (obj) { _add(obj); } @@ -280,7 +280,7 @@ SelContainer const &Selection::list() { return _objs; } -SelContainer const &Selection::itemList() { +std::vector<SPItem*> const &Selection::itemList() { if (!_items.empty()) { return _items; } @@ -288,18 +288,16 @@ SelContainer const &Selection::itemList() { for ( SelContainer::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { SPObject *obj=reinterpret_cast<SPObject *>(*iter); if (SP_IS_ITEM(obj)) { - _items.push_front(SP_ITEM(obj)); + _items.push_back(SP_ITEM(obj)); } } - _items.reverse(); - return _items; } std::vector<XML::Node*> const &Selection::reprList() { if (!_reprs.empty()) { return _reprs; } - SelContainer list = itemList(); - for ( SelContainer::const_iterator iter=list.begin();iter!=list.end();iter++ ) { + std::vector<SPItem*> list = itemList(); + for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end();iter++ ) { SPObject *obj=reinterpret_cast<SPObject *>(*iter); _reprs.push_back(obj->getRepr()); } @@ -340,7 +338,7 @@ SPObject *Selection::single() { } SPItem *Selection::singleItem() { - SelContainer const items=itemList(); + std::vector<SPItem*> const items=itemList(); if ( items.size()==1) { return reinterpret_cast<SPItem *>(items.front()); } else { @@ -357,11 +355,11 @@ SPItem *Selection::largestItem(Selection::CompareSize compare) { } SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { - SelContainer const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); gdouble max = sml ? 1e18 : 0; SPItem *ist = NULL; - for ( SelContainer::const_iterator i=items.begin();i!=items.end();i++ ) { + for ( std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++ ) { Geom::OptRect obox = SP_ITEM(*i)->desktopPreferredBounds(); if (!obox || obox.isEmpty()) continue; Geom::Rect bbox = *obox; @@ -390,10 +388,10 @@ Geom::OptRect Selection::bounds(SPItem::BBoxType type) const Geom::OptRect Selection::geometricBounds() const { - SelContainer const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); Geom::OptRect bbox; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { bbox.unionWith(SP_ITEM(*iter)->desktopGeometricBounds()); } return bbox; @@ -401,10 +399,10 @@ Geom::OptRect Selection::geometricBounds() const Geom::OptRect Selection::visualBounds() const { - SelContainer const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); Geom::OptRect bbox; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { bbox.unionWith(SP_ITEM(*iter)->desktopVisualBounds()); } return bbox; @@ -422,10 +420,10 @@ Geom::OptRect Selection::preferredBounds() const Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const { Geom::OptRect bbox; - SelContainer const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); if (items.empty()) return bbox; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *item = SP_ITEM(*iter); bbox |= item->documentBounds(type); } @@ -436,7 +434,7 @@ Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const // If we have a selection of multiple items, then the center of the first item // will be returned; this is also the case in SelTrans::centerRequest() boost::optional<Geom::Point> Selection::center() const { - SelContainer const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); if (!items.empty()) { SPItem *first = reinterpret_cast<SPItem*>(items.back()); // from the first item in selection if (first->isCenterSet()) { // only if set explicitly @@ -452,12 +450,12 @@ boost::optional<Geom::Point> Selection::center() const { } std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferences const *snapprefs) const { - SelContainer const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center std::vector<Inkscape::SnapCandidatePoint> p; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *this_item = SP_ITEM(*iter); this_item->getSnappoints(p, &snapprefs_dummy); @@ -505,9 +503,9 @@ SPObject *Selection::_objectForXMLNode(Inkscape::XML::Node *repr) const { } uint Selection::numberOfLayers() { - SelContainer const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); std::set<SPObject*> layers; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPObject *layer = _layers->layerForObject(SP_OBJECT(*iter)); layers.insert(layer); } @@ -515,9 +513,9 @@ uint Selection::numberOfLayers() { } guint Selection::numberOfParents() { - SelContainer const items = const_cast<Selection *>(this)->itemList(); + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); std::set<SPObject*> parents; - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPObject *parent = SP_OBJECT(*iter)->parent; parents.insert(parent); } diff --git a/src/selection.h b/src/selection.h index f85c6346b..2d5e7c34a 100644 --- a/src/selection.h +++ b/src/selection.h @@ -170,21 +170,21 @@ public: * * @param objs the objects to select */ - void setList(SelContainer const &objs); + void setList(std::vector<SPItem*> const &objs); /** * Adds the specified objects to selection, without deselecting first. * * @param objs the objects to select */ - void addList(SelContainer const &objs); + void addList(std::vector<SPItem*> const &objs); /** * Clears the selection and selects the specified objects. * * @param repr a list of xml nodes for the items to select */ - void setReprList(std::list<SPObject*> const &reprs); + void setReprList(std::vector<XML::Node*> const &reprs); /** Add items from an STL iterator range to the selection. * \param from the begin iterator @@ -256,7 +256,7 @@ public: /** Returns the list of selected objects. */ std::list<SPObject*> const &list(); /** Returns the list of selected SPItems. */ - std::list<SPObject*> const &itemList(); + std::vector<SPItem*> const &itemList(); /** Returns a list of the xml nodes of all selected objects. */ /// \todo only returns reprs of SPItems currently; need a separate /// method for that @@ -378,7 +378,7 @@ private: mutable std::list<SPObject*> _objs; mutable std::vector<XML::Node*> _reprs; - mutable std::list<SPObject*> _items; + mutable std::vector<SPItem*> _items; void add_box_perspective(SPBox3D *box); void add_3D_boxes_recursively(SPObject *obj); diff --git a/src/seltrans.cpp b/src/seltrans.cpp index 8c06356db..0a428edf2 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -112,7 +112,7 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) : _opposite_for_bboxpoints(Geom::Point(0,0)), _origin_for_specpoints(Geom::Point(0,0)), _origin_for_bboxpoints(Geom::Point(0,0)), - _stamp_cache(SelContainer()), + _stamp_cache(std::vector<SPItem*>()), _message_context(desktop->messageStack()), _bounding_box_prefs_observer(*this) { @@ -239,8 +239,8 @@ void Inkscape::SelTrans::setCenter(Geom::Point const &p) _center_is_set = true; // Write the new center position into all selected items - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector<SPItem*> items=_desktop->selection->itemList(); + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = SP_ITEM(*iter); it->setCenter(p); // only set the value; updating repr and document_done will be done once, on ungrab @@ -269,8 +269,8 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s return; } - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector<SPItem*> items=_desktop->selection->itemList(); + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = reinterpret_cast<SPItem*>(sp_object_ref(SP_ITEM(*iter), NULL)); _items.push_back(it); _items_const.push_back(it); @@ -492,8 +492,8 @@ void Inkscape::SelTrans::ungrab() if (_center_is_set) { // we were dragging center; update reprs and commit undoable action - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector<SPItem*> items=_desktop->selection->itemList(); + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = SP_ITEM(*iter); it->updateRepr(); } @@ -524,17 +524,17 @@ void Inkscape::SelTrans::stamp() /* stamping mode */ if (!_empty) { - SelContainer l; + std::vector<SPItem*> l; if (!_stamp_cache.empty()) { l = _stamp_cache; } else { /* Build cache */ l = selection->itemList(); - l.sort(sp_object_compare_position); + sort(l.begin(),l.end(),sp_object_compare_position); _stamp_cache = l; } - for(SelContainer::const_iterator x=l.begin();x!=l.end();x++) { + for(std::vector<SPItem*>::const_iterator x=l.begin();x!=l.end();x++) { SPItem *original_item = SP_ITEM(*x); Inkscape::XML::Node *original_repr = original_item->getRepr(); @@ -711,8 +711,8 @@ void Inkscape::SelTrans::handleClick(SPKnot */*knot*/, guint state, SPSelTransHa case HANDLE_CENTER: if (state & GDK_SHIFT_MASK) { // Unset the center position for all selected items - SelContainer items=_desktop->selection->itemList(); - for ( SelContainer::const_iterator iter=items.begin();iter!=items.end();iter++ ) { + std::vector<SPItem*> items=_desktop->selection->itemList(); + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { SPItem *it = SP_ITEM(*iter); it->unsetCenter(); it->updateRepr(); @@ -1283,7 +1283,7 @@ gboolean Inkscape::SelTrans::centerRequest(Geom::Point &pt, guint state) // items will share a single center. While dragging that single center, it should never snap to the // centers of any of the selected objects. Therefore we will have to pass the list of selected items // to the snapper, to avoid self-snapping of the rotation center - SelContainer items = const_cast<Selection *>(_selection)->itemList(); + std::vector<SPItem*> items = const_cast<Selection *>(_selection)->itemList(); SnapManager &m = _desktop->namedview->snap_manager; m.setup(_desktop); m.setRotationCenterSource(items); diff --git a/src/seltrans.h b/src/seltrans.h index 8f9c329ed..26c2e9cd9 100644 --- a/src/seltrans.h +++ b/src/seltrans.h @@ -187,7 +187,7 @@ private: SPCtrlLine *_l[4]; unsigned int _sel_changed_id; unsigned int _sel_modified_id; - SelContainer _stamp_cache; + std::vector<SPItem*> _stamp_cache; Geom::Point _origin; ///< position of origin for transforms Geom::Point _point; ///< original position of the knot being used for the current transform diff --git a/src/snap.cpp b/src/snap.cpp index a7145b834..c711874d7 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -43,7 +43,7 @@ SnapManager::SnapManager(SPNamedView const *v) : object(this, 0), snapprefs(), _named_view(v), - _rotation_center_source_items(SelContainer()), + _rotation_center_source_items(std::vector<SPItem*>()), _guide_to_ignore(NULL), _desktop(NULL), _snapindicator(true), @@ -1053,8 +1053,8 @@ void SnapManager::setupIgnoreSelection(SPDesktop const *desktop, _items_to_ignore.clear(); Inkscape::Selection *sel = _desktop->selection; - SelContainer const items = sel->itemList(); - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + std::vector<SPItem*> const items = sel->itemList(); + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { _items_to_ignore.push_back(static_cast<SPItem const *>(*i)); } } diff --git a/src/snap.h b/src/snap.h index 012eb072b..49bdbfa7c 100644 --- a/src/snap.h +++ b/src/snap.h @@ -145,8 +145,8 @@ public: // of this rotation center; this reference is used to make sure that we do not snap a rotation // center to itself // NOTE: Must be called after calling setup(), not before! - void setRotationCenterSource(const SelContainer &items) {_rotation_center_source_items = items;} - SelContainer getRotationCenterSource() {return _rotation_center_source_items;} + void setRotationCenterSource(const std::vector<SPItem*> &items) {_rotation_center_source_items = items;} + const std::vector<SPItem*> &getRotationCenterSource() {return _rotation_center_source_items;} // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a // point if snapping has occurred (by overwriting p); otherwise p is untouched @@ -490,7 +490,7 @@ protected: private: std::vector<SPItem const *> _items_to_ignore; ///< Items that should not be snapped to, for example the items that are currently being dragged. Set using the setup() method - SelContainer _rotation_center_source_items; // to avoid snapping a rotation center to itself + std::vector<SPItem*> _rotation_center_source_items; // to avoid snapping a rotation center to itself SPGuide *_guide_to_ignore; ///< A guide that should not be snapped to, e.g. the guide that is currently being dragged SPDesktop const *_desktop; bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp index bd139277d..d09699f41 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -50,8 +50,8 @@ static bool try_get_intersect_point_with_item_recursive(Geom::PathVector& conn_p // consider all first-order children double child_pos = 0.0; - SelContainer g = sp_item_group_item_list(group); - for (SelContainer::const_iterator i = g.begin();i!=g.end();i++) { + std::vector<SPItem*> g = sp_item_group_item_list(group); + for (std::vector<SPItem*>::const_iterator i = g.begin();i!=g.end();i++) { SPItem* child_item = SP_ITEM(*i); try_get_intersect_point_with_item_recursive(conn_pv, child_item, item_transform * child_item->transform, child_pos); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index e6531c6be..f09a4ee47 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -387,7 +387,7 @@ void SPGroup::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape: void -sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done) +sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_done) { g_return_if_fail (group != NULL); @@ -547,7 +547,7 @@ sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done) Inkscape::GC::release(repr); if (!children.empty() && item) { - children.push_front(dynamic_cast<SPObject*>(item)); + children.insert(children.begin(),item); } items = g_slist_remove (items, items->data); @@ -562,17 +562,16 @@ sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done) * some API for list aspect of SPGroup */ -SelContainer sp_item_group_item_list(SPGroup * group) +std::vector<SPItem*> sp_item_group_item_list(SPGroup * group) { - SelContainer s; + std::vector<SPItem*> s; g_return_val_if_fail(group != NULL, s); for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { if ( dynamic_cast<SPItem *>(o) ) { - s.push_front(o); + s.push_back((SPItem*)o); } } - s.reverse(); return s; } @@ -813,9 +812,9 @@ void SPGroup::update_patheffect(bool write) { g_message("sp_group_update_patheffect: %p\n", lpeitem); #endif - SelContainer const item_list = sp_item_group_item_list(this); + std::vector<SPItem*> const item_list = sp_item_group_item_list(this); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast<SPObject *>(*iter); SPLPEItem *lpeItem = dynamic_cast<SPLPEItem *>(subitem); @@ -841,9 +840,9 @@ void SPGroup::update_patheffect(bool write) { static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) { - SelContainer const item_list = sp_item_group_item_list(group); + std::vector<SPItem*> const item_list = sp_item_group_item_list(group); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast<SPObject *>(*iter); SPGroup *subGroup = dynamic_cast<SPGroup *>(subitem); diff --git a/src/sp-item-group.h b/src/sp-item-group.h index 9a5ee0161..dcabea78c 100644 --- a/src/sp-item-group.h +++ b/src/sp-item-group.h @@ -96,10 +96,10 @@ public: virtual void update_patheffect(bool write); }; -void sp_item_group_ungroup (SPGroup *group, SelContainer &children, bool do_done = true); +void sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_done = true); -SelContainer sp_item_group_item_list (SPGroup *group); +std::vector<SPItem*> sp_item_group_item_list (SPGroup *group); SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const char *name); #endif diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index 1305efd83..1f4704e22 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -353,8 +353,8 @@ sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem) sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); } if (SP_IS_GROUP(lpeitem)) { - SelContainer item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast<SPObject *>(*iter); if (SP_IS_LPE_ITEM(subitem)) { sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(subitem)); @@ -387,8 +387,8 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); } } - SelContainer item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast<SPObject *>(*iter); if (SP_IS_LPE_ITEM(subitem)) { sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem)); @@ -680,8 +680,8 @@ SPLPEItem::apply_to_clippath(SPItem *item) } } if(SP_IS_GROUP(item)){ - SelContainer item_list = sp_item_group_item_list(SP_GROUP(item)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast<SPObject *>(*iter); apply_to_clippath(SP_ITEM(subitem)); } @@ -732,8 +732,8 @@ SPLPEItem::apply_to_mask(SPItem *item) } } if(SP_IS_GROUP(item)){ - SelContainer item_list = sp_item_group_item_list(SP_GROUP(item)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast<SPObject *>(*iter); apply_to_mask(SP_ITEM(subitem)); } @@ -746,8 +746,8 @@ SPLPEItem::apply_to_clip_or_mask_group(SPItem *group, SPItem *item) if (!SP_IS_GROUP(group)) { return; } - SelContainer item_list = sp_item_group_item_list(SP_GROUP(group)); - for ( SelContainer::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(group)); + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { SPObject *subitem = static_cast<SPObject *>(*iter); if (SP_IS_GROUP(subitem)) { apply_to_clip_or_mask_group(SP_ITEM(subitem), item); diff --git a/src/sp-marker.cpp b/src/sp-marker.cpp index 66b445265..5bb80bd39 100644 --- a/src/sp-marker.cpp +++ b/src/sp-marker.cpp @@ -429,7 +429,7 @@ sp_marker_hide (SPMarker *marker, unsigned int key) } -const gchar *generate_marker(SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) +const gchar *generate_marker(std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); @@ -452,8 +452,8 @@ const gchar *generate_marker(SelContainer &reprs, Geom::Rect bounds, SPDocument const gchar *mark_id = repr->attribute("id"); SPObject *mark_object = document->getObjectById(mark_id); - for (SelContainer::const_iterator i=reprs.begin();i!=reprs.end();i++){ - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(*i); + for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ + Inkscape::XML::Node *node = (*i); SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); Geom::Affine dup_transform; diff --git a/src/sp-marker.h b/src/sp-marker.h index 594c164c5..56cbaf94f 100644 --- a/src/sp-marker.h +++ b/src/sp-marker.h @@ -101,7 +101,7 @@ Inkscape::DrawingItem *sp_marker_show_instance (SPMarker *marker, Inkscape::Draw unsigned int key, unsigned int pos, Geom::Affine const &base, float linewidth); void sp_marker_hide (SPMarker *marker, unsigned int key); -const char *generate_marker (SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); +const char *generate_marker (std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); SPObject *sp_marker_fork_if_necessary(SPObject *marker); #endif diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index d5eff9796..33d66c5dc 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -408,7 +408,7 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se g_free(c); } -const gchar *pattern_tile(const SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) +const gchar *pattern_tile(const std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) { Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); @@ -426,7 +426,7 @@ const gchar *pattern_tile(const SelContainer &reprs, Geom::Rect bounds, SPDocume const gchar *pat_id = repr->attribute("id"); SPObject *pat_object = document->getObjectById(pat_id); - for (SelContainer::const_iterator i=reprs.begin();i!=reprs.end();i++){ + for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ Inkscape::XML::Node *node = (Inkscape::XML::Node *)(*i); SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); diff --git a/src/sp-pattern.h b/src/sp-pattern.h index 0e2b058b5..34dd5a05b 100644 --- a/src/sp-pattern.h +++ b/src/sp-pattern.h @@ -89,7 +89,7 @@ SPPattern *pattern_chain (SPPattern *pattern); SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property); void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); -const char *pattern_tile (const SelContainer &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); +const char *pattern_tile (const std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); SPPattern *pattern_getroot (SPPattern *pat); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 107dfc629..6e47dfff3 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -331,7 +331,7 @@ void sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool_op bop, const unsigned int verb, const Glib::ustring description) { SPDocument *doc = selection->layers()->getDocument(); - SelContainer il= selection->itemList(); + std::vector<SPItem*> il= selection->itemList(); // allow union on a single object for the purpose of removing self overlapse (svn log, revision 13334) if ( (il.size() < 2) && (bop != bool_op_union)) { @@ -403,7 +403,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // first check if all the input objects have shapes // otherwise bail out - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++) + for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++) { SPItem *item = SP_ITEM(*l); if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item) && !SP_IS_FLOWTEXT(item)) @@ -421,7 +421,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool int curOrig; { curOrig = 0; - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++) + for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++) { // apply live path effects prior to performing boolean operation if (SP_IS_LPE_ITEM(*l)) { @@ -474,7 +474,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool theShapeA->ConvertToShape(theShape, origWind[0]); curOrig = 1; - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ if(*l==il.front())continue; originaux[curOrig]->ConvertWithBackData(0.1); @@ -671,7 +671,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool if (res->descr_cmd.size() <= 1) { // only one command, presumably a moveto: it isn't a path - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ SP_OBJECT(*l)->deleteObject(); } DocumentUndo::done(doc, SP_VERB_NONE, description); @@ -720,7 +720,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool gchar *desc = source->desc(); // remove source paths selection->clear(); - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ // if this is the bottommost object, if (!strcmp(reinterpret_cast<SPObject *>(*l)->getRepr()->attribute("id"), id)) { // delete it so that its clones don't get alerted; this object will be restored shortly, with the same id @@ -1157,8 +1157,8 @@ sp_selected_path_outline(SPDesktop *desktop) } bool did = false; - SelContainer il(selection->itemList()); - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + std::vector<SPItem*> il(selection->itemList()); + for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = SP_ITEM(*l); if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item)) @@ -1769,8 +1769,8 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) } bool did = false; - SelContainer il(selection->itemList()); - for (SelContainer::const_iterator l = il.begin(); l != il.end(); l++){ + std::vector<SPItem*> il(selection->itemList()); + for (std::vector<SPItem*>::const_iterator l = il.begin(); l != il.end(); l++){ SPItem *item = SP_ITEM(*l); SPCurve *curve = NULL; @@ -1967,7 +1967,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset) static bool sp_selected_path_simplify_items(SPDesktop *desktop, - Inkscape::Selection *selection, SelContainer &items, + Inkscape::Selection *selection, std::vector<SPItem*> &items, float threshold, bool justCoalesce, float angleLimit, bool breakableAngles, bool modifySelection); @@ -1986,7 +1986,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, //If this is a group, do the children instead if (SP_IS_GROUP(item)) { - SelContainer items = sp_item_group_item_list(SP_GROUP(item)); + std::vector<SPItem*> items = sp_item_group_item_list(SP_GROUP(item)); return sp_selected_path_simplify_items(desktop, selection, items, threshold, justCoalesce, @@ -2111,7 +2111,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, bool sp_selected_path_simplify_items(SPDesktop *desktop, - Inkscape::Selection *selection, SelContainer &items, + Inkscape::Selection *selection, std::vector<SPItem*> &items, float threshold, bool justCoalesce, float angleLimit, bool breakableAngles, bool modifySelection) @@ -2142,7 +2142,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop, // set "busy" cursor desktop->setWaitingCursor(); - for (SelContainer::const_iterator l = items.begin(); l != items.end(); l++){ + for (std::vector<SPItem*>::const_iterator l = items.begin(); l != items.end(); l++){ SPItem *item = SP_ITEM(*l); if (!(SP_IS_GROUP(item) || SP_IS_SHAPE(item) || SP_IS_TEXT(item))) @@ -2191,7 +2191,7 @@ sp_selected_path_simplify_selection(SPDesktop *desktop, float threshold, bool ju return; } - SelContainer items(selection->itemList()); + std::vector<SPItem*> items(selection->itemList()); bool didSomething = sp_selected_path_simplify_items(desktop, selection, items, threshold, diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp index 391e255a5..33192a330 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -43,8 +43,8 @@ using Inkscape::DocumentUndo; static SPItem * flowtext_in_selection(Inkscape::Selection *selection) { - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items = selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_FLOWTEXT(*i)) return ((SPItem *) *i); } @@ -54,8 +54,8 @@ flowtext_in_selection(Inkscape::Selection *selection) static SPItem * text_or_flowtext_in_selection(Inkscape::Selection *selection) { - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items = selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) return ((SPItem *) *i); } @@ -65,8 +65,8 @@ text_or_flowtext_in_selection(Inkscape::Selection *selection) static SPItem * shape_in_selection(Inkscape::Selection *selection) { - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items = selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_SHAPE(*i)) return ((SPItem *) *i); } @@ -196,8 +196,8 @@ text_remove_from_path() } bool did = false; - SelContainer items(selection->itemList()); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items(selection->itemList()); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPObject *obj = SP_OBJECT(*i); if (SP_IS_TEXT_TEXTPATH(obj)) { @@ -260,8 +260,8 @@ text_remove_all_kerns() bool did = false; - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items = selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPObject *obj = SP_OBJECT(*i); if (!SP_IS_TEXT(obj) && !SP_IS_TSPAN(obj) && !SP_IS_FLOWTEXT(obj)) { @@ -320,8 +320,8 @@ text_flow_into_shape() g_return_if_fail(SP_IS_FLOWREGION(object)); /* Add clones */ - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items = selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_SHAPE(item)){ Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); @@ -392,11 +392,11 @@ text_unflow () return; } - SelContainer new_objs; + std::vector<SPItem*> new_objs; GSList *old_objs = NULL; - SelContainer items = selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items = selection->itemList(); + for(std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ if (!SP_IS_FLOWTEXT(SP_OBJECT(*i))) { continue; @@ -443,7 +443,7 @@ text_unflow () SPText *text = SP_TEXT(text_object); text->_adjustFontsizeRecursive(text, ex); - new_objs.push_front(text_object); + new_objs.push_back((SPItem*)text_object); old_objs = g_slist_prepend (old_objs, flowtext); Inkscape::GC::release(rtext); @@ -478,9 +478,9 @@ flowtext_to_text() bool did = false; - SelContainer reprs; - SelContainer items(selection->itemList()); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<Inkscape::XML::Node*> reprs; + std::vector<SPItem*> items(selection->itemList()); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = (SPItem *) *i; @@ -510,7 +510,7 @@ flowtext_to_text() Inkscape::GC::release(repr); item->deleteObject(); - reprs.push_front(dynamic_cast<SPObject*>(repr)); + reprs.push_back(repr); } diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 44d90b4ae..88210dc0b 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -67,8 +67,8 @@ static void te_update_layout_now (SPItem *item) void te_update_layout_now_recursive(SPItem *item) { if (SP_IS_GROUP(item)) { - SelContainer item_list = sp_item_group_item_list(SP_GROUP(item)); - for(SelContainer::const_iterator i=item_list.begin();i!=item_list.end();i++){ + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); + for(std::vector<SPItem*>::const_iterator i=item_list.begin();i!=item_list.end();i++){ SPItem* list_item = static_cast<SPItem*>(*i); te_update_layout_now_recursive(list_item); } diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 2becca5cc..4853f127c 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -65,7 +65,7 @@ SPImage *Tracer::getSelectedSPImage() if (sioxEnabled) { SPImage *img = NULL; - SelContainer const list = sel->itemList(); + std::vector<SPItem*> const list = sel->itemList(); std::vector<SPItem *> items; sioxShapes.clear(); @@ -74,7 +74,7 @@ SPImage *Tracer::getSelectedSPImage() them as bottom-to-top so that we can discover the image and any SPItems above it */ - for (SelContainer::const_iterator i=list.begin() ; list.end()!=i ; i++) + for (std::vector<SPItem*>::const_iterator i=list.begin() ; list.end()!=i ; i++) { if (!SP_IS_ITEM(*i)) { diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 20b43af3b..6c15121c2 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -523,8 +523,8 @@ bool ClipboardManagerImpl::pasteSize(SPDesktop *desktop, bool separately, bool a // resize each object in the selection if (separately) { - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (item) { Geom::OptRect obj_size = item->desktopVisualBounds(); @@ -579,8 +579,8 @@ bool ClipboardManagerImpl::pastePathEffect(SPDesktop *desktop) desktop->doc()->importDefs(tempdoc); // make sure all selected items are converted to paths first (i.e. rectangles) sp_selected_to_lpeitems(desktop); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); _applyPathEffect(item, effectstack); } @@ -662,8 +662,8 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop) void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) { // copy the defs used by all items - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (item) { _copyUsedDefs(item); @@ -673,10 +673,10 @@ void ClipboardManagerImpl::_copySelection(Inkscape::Selection *selection) } // copy the representation of the items - SelContainer sorted_items(itemlist); - sorted_items.sort(sp_object_compare_position); + std::vector<SPItem*> sorted_items(itemlist); + sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position); - for(SelContainer::const_iterator i=sorted_items.begin();i!=sorted_items.end();i++){ + for(std::vector<SPItem*>::const_iterator i=sorted_items.begin();i!=sorted_items.end();i++){ SPItem *item = SP_ITEM(*i); if (item) { Inkscape::XML::Node *obj = item->getRepr(); @@ -1157,7 +1157,7 @@ void ClipboardManagerImpl::_onGet(Gtk::SelectionData &sel, guint /*info*/) sp_repr_get_double(nv, "inkscape:pageopacity", &opacity); bgcolor |= SP_COLOR_F_TO_U(opacity); } - SelContainer x; + std::vector<SPItem*> x; sp_export_png_file(_clipboardSPDoc, filename, area, width, height, dpi, dpi, bgcolor, NULL, NULL, true, x); } else diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 562bc28b7..34dbd150b 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -98,7 +98,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) bool sel_as_group = prefs->getBool("/dialogs/align/sel-as-groups"); using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector<SPItem*> selected(selection->itemList()); if (selected.empty()) return; const Coeffs &a = _allCoeffs[index]; @@ -148,7 +148,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) b = selection->preferredBounds(); //Move each item in the selected list separately - for (SelContainer::iterator it(selected.begin()); + for (std::vector<SPItem*>::iterator it(selected.begin()); it != selected.end(); ++it) { SPItem* item=static_cast<SPItem*> (*it); @@ -251,18 +251,18 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector<SPItem*> selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects - SelContainer::iterator second(selected.begin()); + std::vector<SPItem*>::iterator second(selected.begin()); ++second; if (second == selected.end()) return; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int prefs_bbox = prefs->getBool("/tools/bounding_box"); std::vector< BBoxSort > sorted; - for (SelContainer::iterator it(selected.begin()); + for (std::vector<SPItem*>::iterator it(selected.begin()); it != selected.end(); ++it) {SPItem *item=static_cast<SPItem*>(*it); @@ -540,10 +540,6 @@ private : return (a->isSiblingOf(b)); } - static bool local_obj_compare(SPObject* a,SPObject* b){ - return ActionExchangePositions::sort_compare(static_cast<SPItem*>(a),static_cast<SPItem*>(b)); - } - virtual void on_button_click() { SPDesktop *desktop = _dialog.getDesktop(); @@ -553,7 +549,7 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector<SPItem*> selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects @@ -571,9 +567,9 @@ private : } else { // sorting by ZOrder is outomatically done by not setting the center center.reset(); } - selected.sort(local_obj_compare); + sort(selected.begin(),selected.end(),sort_compare); } - SelContainer::iterator it(selected.begin()); + std::vector<SPItem*>::iterator it(selected.begin()); SPItem* item=static_cast<SPItem*>(*it); Geom::Point p1 = (item)->getCenter(); for (++it ;it != selected.end(); ++it) @@ -619,7 +615,7 @@ private : Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - SelContainer x(_dialog.getDesktop()->getSelection()->itemList()); + std::vector<SPItem*> x(_dialog.getDesktop()->getSelection()->itemList()); unclump (x); // restore compensation setting @@ -651,7 +647,7 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector<SPItem*> selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects @@ -675,7 +671,7 @@ private : int saved_compensation = prefs->getInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); prefs->setInt("/options/clonecompensation/value", SP_CLONE_COMPENSATION_UNMOVED); - for (SelContainer::iterator it(selected.begin()); + for (std::vector<SPItem*>::iterator it(selected.begin()); it != selected.end(); ++it) { @@ -750,7 +746,7 @@ private : if (!selection) return; using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector<SPItem*> selected(selection->itemList()); if (selected.empty()) return; //Check 2 or more selected objects @@ -761,7 +757,7 @@ private : std::vector<Baselines> sorted; - for (SelContainer::iterator it(selected.begin()); + for (std::vector<SPItem*>::iterator it(selected.begin()); it != selected.end(); ++it) { @@ -805,7 +801,7 @@ private : } } else { - for (SelContainer::iterator it(selected.begin()); + for (std::vector<SPItem*>::iterator it(selected.begin()); it != selected.end(); ++it) { diff --git a/src/ui/dialog/clonetiler.cpp b/src/ui/dialog/clonetiler.cpp index abfab8b19..680757373 100644 --- a/src/ui/dialog/clonetiler.cpp +++ b/src/ui/dialog/clonetiler.cpp @@ -2104,16 +2104,17 @@ void CloneTiler::clonetiler_unclump(GtkWidget */*widget*/, void *) SPObject *obj = selection->singleItem(); SPObject *parent = obj->parent; - SelContainer to_unclump; // not including the original + std::vector<SPItem*> to_unclump; // not including the original for (SPObject *child = parent->firstChild(); child != NULL; child = child->next) { if (clonetiler_is_a_clone_of (child, obj)) { - to_unclump.push_front(child); + to_unclump.push_back((SPItem*)child); } } desktop->getDocument()->ensureUpToDate(); - + std::vector<SPItem*> tu2(to_unclump); + for(int i=0;i<tu2.size();i++)to_unclump[i]=tu2[tu2.size()-i-1]; unclump (to_unclump); DocumentUndo::done(desktop->getDocument(), SP_VERB_DIALOG_CLONETILER, diff --git a/src/ui/dialog/export.cpp b/src/ui/dialog/export.cpp index 0667ba721..32eed088c 100644 --- a/src/ui/dialog/export.cpp +++ b/src/ui/dialog/export.cpp @@ -1024,8 +1024,8 @@ void Export::onExport () gint export_count = 0; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ + std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end() && !interrupted ;i++){ SPItem *item = reinterpret_cast<SPItem *>(*i); prog_dlg->set_data("current", GINT_TO_POINTER(n)); @@ -1064,7 +1064,7 @@ void Export::onExport () _("Exporting file <b>%s</b>..."), safeFile), desktop); MessageCleaner msgFlashCleanup(desktop->messageStack()->flashF(Inkscape::IMMEDIATE_MESSAGE, _("Exporting file <b>%s</b>..."), safeFile), desktop); - SelContainer x; + std::vector<SPItem*> x; if (!sp_export_png_file (doc, path.c_str(), *area, width, height, dpi, dpi, nv->pagecolor, @@ -1154,7 +1154,7 @@ void Export::onExport () prog_dlg->set_data("total", GINT_TO_POINTER(0)); /* Do export */ - SelContainer x; + std::vector<SPItem*> x; ExportResult status = sp_export_png_file(desktop->getDocument(), path.c_str(), Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)), width, height, xdpi, ydpi, nv->pagecolor, diff --git a/src/ui/dialog/filter-effects-dialog.cpp b/src/ui/dialog/filter-effects-dialog.cpp index f67c1d173..a6312140d 100644 --- a/src/ui/dialog/filter-effects-dialog.cpp +++ b/src/ui/dialog/filter-effects-dialog.cpp @@ -1465,8 +1465,8 @@ void FilterEffectsDialog::FilterModifier::update_selection(Selection *sel) } std::set<SPObject*> used; - SelContainer itemlist=sel->itemList(); - for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + std::vector<SPItem*> itemlist=sel->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPStyle *style = obj->style; if (!style || !SP_IS_ITEM(obj)) { @@ -1545,8 +1545,8 @@ void FilterEffectsDialog::FilterModifier::on_selection_toggled(const Glib::ustri if((*iter)[_columns.sel] == 1) filter = 0; - SelContainer itemlist=sel->itemList(); - for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + std::vector<SPItem*> itemlist=sel->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { SPItem * item = SP_ITEM(*i); SPStyle *style = item->style; g_assert(style != NULL); @@ -1649,9 +1649,9 @@ void FilterEffectsDialog::FilterModifier::remove_filter() SPDocument* doc = filter->document; // Delete all references to this filter - SelContainer x,y; - SelContainer all = get_all_items(x, _desktop->currentRoot(), _desktop, false, false, true, y); - for(SelContainer::const_iterator i=all.begin(); all.end() != i; i++) { + std::vector<SPItem*> x,y; + std::vector<SPItem*> all = get_all_items(x, _desktop->currentRoot(), _desktop, false, false, true, y); + for(std::vector<SPItem*>::const_iterator i=all.begin(); all.end() != i; i++) { if (!SP_IS_ITEM(*i)) { continue; } diff --git a/src/ui/dialog/find.cpp b/src/ui/dialog/find.cpp index 43ecb60ac..283d79c0d 100644 --- a/src/ui/dialog/find.cpp +++ b/src/ui/dialog/find.cpp @@ -549,7 +549,7 @@ bool Find::item_font_match(SPItem *item, const gchar *text, bool exact, bool cas } -SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) +std::vector<SPItem*> Find::filter_fields (std::vector<SPItem*> &l, bool exact, bool casematch) { Glib::ustring tmp = entry_find.getEntry()->get_text(); if (tmp.empty()) { @@ -557,17 +557,17 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) } gchar* text = g_strdup(tmp.c_str()); - SelContainer in = l; - SelContainer out; + std::vector<SPItem*> in = l; + std::vector<SPItem*> out; if (check_searchin_text.get_active()) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector<SPItem*>::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); if (item_text_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)) { - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_text_match(item, text, exact, casematch, _action_replace); } @@ -584,12 +584,12 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) bool attrvalue = check_attributevalue.get_active(); if (ids) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector<SPItem*>::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(obj); if (item_id_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)) { - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_id_match(item, text, exact, casematch, _action_replace); } @@ -600,13 +600,13 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) if (style) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector<SPItem*>::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); if (item_style_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)){ - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_style_match(item, text, exact, casematch, _action_replace); } @@ -617,13 +617,13 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) if (attrname) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector<SPItem*>::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); if (item_attr_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)) { - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_attr_match(item, text, exact, casematch, _action_replace); } @@ -634,13 +634,13 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) if (attrvalue) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector<SPItem*>::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); if (item_attrvalue_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(), *i)) { - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_attrvalue_match(item, text, exact, casematch, _action_replace); } @@ -651,13 +651,13 @@ SelContainer Find::filter_fields (SelContainer &l, bool exact, bool casematch) if (font) { - for(SelContainer::const_iterator i=in.begin(); in.end() != i; i++) { + for(std::vector<SPItem*>::const_reverse_iterator i=in.rbegin(); in.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); if (item_font_match(item, text, exact, casematch)) { if (out.end()==find(out.begin(),out.end(),*i)) { - out.push_front(*i); + out.push_back(*i); if (_action_replace) { item_font_match(item, text, exact, casematch, _action_replace); } @@ -715,29 +715,29 @@ bool Find::item_type_match (SPItem *item) return false; } -SelContainer Find::filter_types (SelContainer &l) +std::vector<SPItem*> Find::filter_types (std::vector<SPItem*> &l) { - SelContainer n; - for(SelContainer::const_iterator i=l.begin(); l.end() != i; i++) { + std::vector<SPItem*> n; + for(std::vector<SPItem*>::const_reverse_iterator i=l.rbegin(); l.rend() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); if (item_type_match(item)) { - n.push_front(*i); + n.push_back(*i); } } return n; } -SelContainer &Find::filter_list (SelContainer &l, bool exact, bool casematch) +std::vector<SPItem*> &Find::filter_list (std::vector<SPItem*> &l, bool exact, bool casematch) { l = filter_types (l); l = filter_fields (l, exact, casematch); return l; } -SelContainer &Find::all_items (SPObject *r, SelContainer &l, bool hidden, bool locked) +std::vector<SPItem*> &Find::all_items (SPObject *r, std::vector<SPItem*> &l, bool hidden, bool locked) { if (dynamic_cast<SPDefs *>(r)) { return l; // we're not interested in items in defs @@ -751,7 +751,7 @@ SelContainer &Find::all_items (SPObject *r, SelContainer &l, bool hidden, bool l SPItem *item = dynamic_cast<SPItem *>(child); if (item && !child->cloned && !desktop->isLayer(item)) { if ((hidden || !desktop->itemIsHidden(item)) && (locked || !item->isLocked())) { - l.push_front(child); + l.insert(l.begin(),(SPItem*)child); } } l = all_items (child, l, hidden, locked); @@ -759,10 +759,10 @@ SelContainer &Find::all_items (SPObject *r, SelContainer &l, bool hidden, bool l return l; } -SelContainer &Find::all_selection_items (Inkscape::Selection *s, SelContainer &l, SPObject *ancestor, bool hidden, bool locked) +std::vector<SPItem*> &Find::all_selection_items (Inkscape::Selection *s, std::vector<SPItem*> &l, SPObject *ancestor, bool hidden, bool locked) { - SelContainer itemlist=s->itemList(); - for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + std::vector<SPItem*> itemlist=s->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { SPObject *obj = SP_OBJECT (*i); SPItem *item = dynamic_cast<SPItem *>(obj); g_assert(item != NULL); @@ -817,7 +817,7 @@ void Find::onAction() bool casematch = check_case_sensitive.get_active(); blocked = true; - SelContainer l; + std::vector<SPItem*> l; if (check_scope_selection.get_active()) { if (check_scope_layer.get_active()) { l = all_selection_items (desktop->selection, l, desktop->currentLayer(), hidden, locked); @@ -833,7 +833,7 @@ void Find::onAction() } guint all = l.size(); - SelContainer n = filter_list (l, exact, casematch); + std::vector<SPItem*> n = filter_list (l, exact, casematch); if (!n.empty()) { int count = n.size(); diff --git a/src/ui/dialog/find.h b/src/ui/dialog/find.h index 1aded96f2..61f4463ae 100644 --- a/src/ui/dialog/find.h +++ b/src/ui/dialog/find.h @@ -149,10 +149,10 @@ protected: /** * Function to filter a list of items based on the item type by calling each item_XXX_match function */ - SelContainer filter_fields (SelContainer &l, bool exact, bool casematch); + std::vector<SPItem*> filter_fields (std::vector<SPItem*> &l, bool exact, bool casematch); bool item_type_match (SPItem *item); - SelContainer filter_types (SelContainer &l); - SelContainer & filter_list (SelContainer &l, bool exact, bool casematch); + std::vector<SPItem*> filter_types (std::vector<SPItem*> &l); + std::vector<SPItem*> & filter_list (std::vector<SPItem*> &l, bool exact, bool casematch); /** * Find a string within a string and returns true if found with options for exact and casematching @@ -173,12 +173,12 @@ protected: * recursive function to return a list of all the items in the SPObject tree * */ - SelContainer & all_items (SPObject *r, SelContainer &l, bool hidden, bool locked); + std::vector<SPItem*> & all_items (SPObject *r, std::vector<SPItem*> &l, bool hidden, bool locked); /** * to return a list of all the selected items * */ - SelContainer & all_selection_items (Inkscape::Selection *s, SelContainer &l, SPObject *ancestor, bool hidden, bool locked); + std::vector<SPItem*> & all_selection_items (Inkscape::Selection *s, std::vector<SPItem*> &l, SPObject *ancestor, bool hidden, bool locked); /** * Shrink the dialog size when the expander widget is closed diff --git a/src/ui/dialog/font-substitution.cpp b/src/ui/dialog/font-substitution.cpp index 625ed99b9..e9a0fc017 100644 --- a/src/ui/dialog/font-substitution.cpp +++ b/src/ui/dialog/font-substitution.cpp @@ -70,7 +70,7 @@ FontSubstitution::checkFontSubstitutions(SPDocument* doc) int show_dlg = prefs->getInt("/options/font/substitutedlg", 0); if (show_dlg) { Glib::ustring out; - SelContainer l = getFontReplacedItems(doc, &out); + std::vector<SPItem*> l = getFontReplacedItems(doc, &out); if (out.length() > 0) { show(out, l); } @@ -78,7 +78,7 @@ FontSubstitution::checkFontSubstitutions(SPDocument* doc) } void -FontSubstitution::show(Glib::ustring out, SelContainer &l) +FontSubstitution::show(Glib::ustring out, std::vector<SPItem*> &l) { Gtk::MessageDialog warning(_("\nSome fonts are not available and have been substituted."), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true); @@ -148,17 +148,17 @@ FontSubstitution::show(Glib::ustring out, SelContainer &l) * b. Build up a list of the objects rendered fonts - taken for the objects layout/spans * If there are fonts in a. that are not in b. then those fonts have been substituted. */ -SelContainer FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring *out) +std::vector<SPItem*> FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustring *out) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; - SelContainer allList; - SelContainer outList,x,y; + std::vector<SPItem*> allList; + std::vector<SPItem*> outList,x,y; std::set<Glib::ustring> setErrors; std::set<Glib::ustring> setFontSpans; std::map<SPItem *, Glib::ustring> mapFontStyles; allList = get_all_items(x, doc->getRoot(), desktop, false, false, true, y); - for(SelContainer::const_iterator i = allList.begin();i!=allList.end();i++){ + for(std::vector<SPItem*>::const_iterator i = allList.begin();i!=allList.end();i++){ SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; Glib::ustring family = ""; @@ -214,8 +214,8 @@ SelContainer FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustri } // Check if any document styles are not in the actual layout - std::map<SPItem *, Glib::ustring>::const_iterator mapIter; - for (mapIter = mapFontStyles.begin(); mapIter != mapFontStyles.end(); ++mapIter) { + std::map<SPItem *, Glib::ustring>::const_reverse_iterator mapIter; + for (mapIter = mapFontStyles.rbegin(); mapIter != mapFontStyles.rend(); ++mapIter) { SPItem *item = mapIter->first; Glib::ustring fonts = mapIter->second; @@ -248,7 +248,7 @@ SelContainer FontSubstitution::getFontReplacedItems(SPDocument* doc, Glib::ustri Glib::ustring err = Glib::ustring::compose( _("Font '%1' substituted with '%2'"), fonts.c_str(), subName.c_str()); setErrors.insert(err); - outList.push_front(item); + outList.push_back(item); } } diff --git a/src/ui/dialog/font-substitution.h b/src/ui/dialog/font-substitution.h index eed7adcf2..cdb4e22b4 100644 --- a/src/ui/dialog/font-substitution.h +++ b/src/ui/dialog/font-substitution.h @@ -25,13 +25,13 @@ public: FontSubstitution(); virtual ~FontSubstitution(); void checkFontSubstitutions(SPDocument* doc); - void show(Glib::ustring out, SelContainer &l); + void show(Glib::ustring out, std::vector<SPItem*> &l); static FontSubstitution &getInstance() { return *new FontSubstitution(); } Glib::ustring getSubstituteFontName (Glib::ustring font); protected: - SelContainer getFontReplacedItems(SPDocument* doc, Glib::ustring *out); + std::vector<SPItem*> getFontReplacedItems(SPDocument* doc, Glib::ustring *out); private: FontSubstitution(FontSubstitution const &d); diff --git a/src/ui/dialog/glyphs.cpp b/src/ui/dialog/glyphs.cpp index 1ef97b996..fa469dc4b 100644 --- a/src/ui/dialog/glyphs.cpp +++ b/src/ui/dialog/glyphs.cpp @@ -578,8 +578,8 @@ void GlyphsPanel::setTargetDesktop(SPDesktop *desktop) void GlyphsPanel::insertText() { SPItem *textItem = 0; - SelContainer itemlist=targetDesktop->selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + std::vector<SPItem*> itemlist=targetDesktop->selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { textItem = SP_ITEM(*i); break; @@ -688,8 +688,8 @@ void GlyphsPanel::selectionModifiedCB(guint flags) void GlyphsPanel::calcCanInsert() { int items = 0; - SelContainer itemlist=targetDesktop->selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { + std::vector<SPItem*> itemlist=targetDesktop->selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin(); itemlist.end() != i; i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) { ++items; } diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp index ba8616d9b..d62032e9d 100644 --- a/src/ui/dialog/grid-arrange-tab.cpp +++ b/src/ui/dialog/grid-arrange-tab.cpp @@ -175,9 +175,9 @@ void GridArrangeTab::arrange() desktop->getDocument()->ensureUpToDate(); Inkscape::Selection *selection = desktop->getSelection(); - const SelContainer items = selection ? selection->itemList() : SelContainer(); + const std::vector<SPItem*> items = selection ? selection->itemList() : std::vector<SPItem*>(); cnt=0; - for(SelContainer::const_iterator i = items.begin();i!=items.end();i++){ + for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); Geom::OptRect b = item->documentVisualBounds(); if (!b) { @@ -205,18 +205,17 @@ void GridArrangeTab::arrange() // require the sorting done before we can calculate row heights etc. g_return_if_fail(selection); - SelContainer rev(selection->itemList()); - rev.sort(sp_compare_y_position_obj); - SelContainer sorted(rev); - sorted.sort(sp_compare_x_position_obj); + std::vector<SPItem*> sorted(selection->itemList()); + sort(sorted.begin(),sorted.end(),sp_compare_y_position); + sort(sorted.begin(),sorted.end(),sp_compare_x_position); // Calculate individual Row and Column sizes if necessary cnt=0; - const SelContainer sizes(sorted); - for (SelContainer::const_iterator i = sizes.begin();i!=sizes.end();i++) { + const std::vector<SPItem*> sizes(sorted); + for (std::vector<SPItem*>::const_iterator i = sizes.begin();i!=sizes.end();i++) { SPItem *item = SP_ITEM(*i); Geom::OptRect b = item->documentVisualBounds(); if (b) { @@ -314,7 +313,7 @@ g_print("\n row = %f col = %f selection x= %f selection y = %f", total_row_h } cnt=0; - SelContainer::iterator it = sorted.begin(); + std::vector<SPItem*>::iterator it = sorted.begin(); for (row_cnt=0; ((it != sorted.end()) && (row_cnt<NoOfRows)); row_cnt++) { GSList *current_row = NULL; @@ -382,7 +381,7 @@ void GridArrangeTab::on_row_spinbutton_changed() Inkscape::Selection *selection = desktop ? desktop->selection : 0; g_return_if_fail( selection ); - SelContainer const items = selection->itemList(); + std::vector<SPItem*> const items = selection->itemList(); int selcount = items.size(); double PerCol = ceil(selcount / NoOfColsSpinner.get_value()); @@ -545,7 +544,7 @@ void GridArrangeTab::updateSelection() updating = true; SPDesktop *desktop = Parent->getDesktop(); Inkscape::Selection *selection = desktop ? desktop->selection : 0; - SelContainer const items = selection ? selection->itemList() : SelContainer(); + std::vector<SPItem*> const items = selection ? selection->itemList() : std::vector<SPItem*>(); if (!items.empty()) { int selcount = items.size(); diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index 79e5b556d..6ad3d61ac 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -366,8 +366,8 @@ void IconPreviewPanel::refreshPreview() if ( sel ) { //g_message("found a selection to play with"); - SelContainer const items = sel->itemList(); - for(SelContainer::const_iterator i=items.begin();!target && i!=items.end();i++){ + std::vector<SPItem*> const items = sel->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();!target && i!=items.end();i++){ SPItem* item = SP_ITEM( *i); gchar const *id = item->getId(); if ( id ) { diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp index 0ae3027c7..d60780f78 100644 --- a/src/ui/dialog/objects.cpp +++ b/src/ui/dialog/objects.cpp @@ -479,8 +479,8 @@ void ObjectsPanel::_objectsSelected( Selection *sel ) { _selectedConnection.block(); _tree.get_selection()->unselect_all(); SPItem *item = NULL; - SelContainer const items = sel->itemList(); - for(SelContainer::const_iterator i=items.begin(); i!=items.end();i++){ + std::vector<SPItem*> const items = sel->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end();i++){ item = reinterpret_cast<SPItem *>(*i); if (setOpacity) { diff --git a/src/ui/dialog/pixelartdialog.cpp b/src/ui/dialog/pixelartdialog.cpp index 273a378e5..760391df6 100644 --- a/src/ui/dialog/pixelartdialog.cpp +++ b/src/ui/dialog/pixelartdialog.cpp @@ -372,8 +372,8 @@ void PixelArtDialogImpl::vectorize() return; } - SelContainer const items = desktop->selection->itemList(); - for(SelContainer::const_iterator i=items.begin(); i!=items.end();i++){ + std::vector<SPItem*> const items = desktop->selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end();i++){ if ( !SP_IS_IMAGE(*i) ) continue; diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 8a382fc93..a68e73caf 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -297,14 +297,14 @@ static void moveToPoint(int anchor, SPItem *item, Geom::Point p) void PolarArrangeTab::arrange() { Inkscape::Selection *selection = parent->getDesktop()->getSelection(); - const SelContainer tmp(selection->itemList()); + const std::vector<SPItem*> tmp(selection->itemList()); SPGenericEllipse *referenceEllipse = NULL; // Last ellipse in selection bool arrangeOnEllipse = !arrangeOnParametersRadio.get_active(); bool arrangeOnFirstEllipse = arrangeOnEllipse && arrangeOnFirstCircleRadio.get_active(); int count = 0; - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) + for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++) { if(arrangeOnEllipse) { @@ -373,7 +373,7 @@ void PolarArrangeTab::arrange() Geom::Point realCenter = Geom::Point(cx, cy) * transformation; int i = 0; - for(SelContainer::const_iterator it=tmp.begin();it!=tmp.end();it++) + for(std::vector<SPItem*>::const_iterator it=tmp.begin();it!=tmp.end();it++) { SPItem *item = SP_ITEM(*it); diff --git a/src/ui/dialog/print.cpp b/src/ui/dialog/print.cpp index dc98b6032..351971294 100644 --- a/src/ui/dialog/print.cpp +++ b/src/ui/dialog/print.cpp @@ -81,7 +81,7 @@ static void draw_page( width, height, (unsigned long)(Inkscape::Util::Quantity::convert(width, "px", "in") * dpi), (unsigned long)(Inkscape::Util::Quantity::convert(height, "px", "in") * dpi), - dpi, dpi, bgcolor, NULL, NULL, true, SelContainer()); + dpi, dpi, bgcolor, NULL, NULL, true, std::vector<SPItem*>()); // This doesn't seem to work: //context->set_cairo_context ( Cairo::Context::create (Cairo::ImageSurface::create_from_png (tmp_png) ), dpi, dpi ); diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp index da24ad605..72677c07e 100644 --- a/src/ui/dialog/swatches.cpp +++ b/src/ui/dialog/swatches.cpp @@ -123,7 +123,7 @@ static void editGradientImpl( SPDesktop* desktop, SPGradient* gr ) bool shown = false; if ( desktop && desktop->doc() ) { Inkscape::Selection *selection = desktop->getSelection(); - SelContainer const items = selection->itemList(); + std::vector<SPItem*> const items = selection->itemList(); if (!items.empty()) { SPStyle query( desktop->doc() ); int result = objects_query_fillstroke((items), &query, true); diff --git a/src/ui/dialog/tags.cpp b/src/ui/dialog/tags.cpp index ba3a6b914..c2df5fc1c 100644 --- a/src/ui/dialog/tags.cpp +++ b/src/ui/dialog/tags.cpp @@ -669,8 +669,8 @@ bool TagsPanel::_handleButtonEvent(GdkEventButton* event) if (col == _tree.get_column(COL_ADD - 1) && down_at_add) { if (SP_IS_TAG(obj)) { bool wasadded = false; - SelContainer items=_desktop->selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=_desktop->selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPObject *newobj = reinterpret_cast<SPObject *>(*i); bool addchild = true; for ( SPObject *child = obj->children; child != NULL; child = child->next) { diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp index 593261ec5..1c1cf5937 100644 --- a/src/ui/dialog/text-edit.cpp +++ b/src/ui/dialog/text-edit.cpp @@ -418,8 +418,8 @@ SPItem *TextEdit::getSelectedTextItem (void) if (!SP_ACTIVE_DESKTOP) return NULL; - SelContainer tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) + std::vector<SPItem*> tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) return SP_ITEM (*i); @@ -436,8 +436,8 @@ unsigned TextEdit::getSelectedTextCount (void) unsigned int items = 0; - SelContainer tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++) + std::vector<SPItem*> tmp=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++) { if (SP_IS_TEXT(*i) || SP_IS_FLOWTEXT(*i)) ++items; @@ -540,11 +540,11 @@ void TextEdit::onApply() SPDesktop *desktop = SP_ACTIVE_DESKTOP; unsigned items = 0; - const SelContainer item_list = desktop->getSelection()->itemList(); + const std::vector<SPItem*> item_list = desktop->getSelection()->itemList(); SPCSSAttr *css = fillTextStyle (); sp_desktop_set_style(desktop, css, true); - for(SelContainer::const_iterator i=item_list.begin();i!=item_list.end();i++){ + for(std::vector<SPItem*>::const_iterator i=item_list.begin();i!=item_list.end();i++){ // apply style to the reprs of all text objects in the selection if (SP_IS_TEXT (*i)) { diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 8c52144e0..0f81a7e58 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -741,12 +741,12 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) if (_check_move_relative.get_active()) { // shift each object relatively to the previous one using Inkscape::Util::GSListConstIterator; - SelContainer selected(selection->itemList()); + std::vector<SPItem*> selected(selection->itemList()); if (selected.empty()) return; if (fabs(x) > 1e-6) { std::vector< BBoxSort > sorted; - for (SelContainer::iterator it(selected.begin()); + for (std::vector<SPItem*>::iterator it(selected.begin()); it != selected.end(); ++it) { @@ -771,7 +771,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) } if (fabs(y) > 1e-6) { std::vector< BBoxSort > sorted; - for (SelContainer::iterator it(selected.begin()); + for (std::vector<SPItem*>::iterator it(selected.begin()); it != selected.end(); ++it) { @@ -816,8 +816,8 @@ void Transformation::applyPageScale(Inkscape::Selection *selection) bool transform_stroke = prefs->getBool("/options/transform/stroke", true); bool preserve = prefs->getBool("/options/preservetransform/value", false); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - SelContainer tmp=selection->itemList(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++){ + std::vector<SPItem*> tmp=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++){ SPItem *item = SP_ITEM(*i); Geom::OptRect bbox_pref = item->desktopPreferredBounds(); Geom::OptRect bbox_geom = item->desktopGeometricBounds(); @@ -880,8 +880,8 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection) } if (prefs->getBool("/dialogs/transformation/applyseparately")) { - SelContainer tmp=selection->itemList(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++){ + std::vector<SPItem*> tmp=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++){ SPItem *item = SP_ITEM(*i); sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0)); } @@ -900,8 +900,8 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/dialogs/transformation/applyseparately")) { - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i = items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); if (!_units_skew.isAbsolute()) { // percentage @@ -1002,8 +1002,8 @@ void Transformation::applyPageTransform(Inkscape::Selection *selection) } if (_check_replace_matrix.get_active()) { - SelContainer tmp=selection->itemList(); - for(SelContainer::const_iterator i=tmp.begin();i!=tmp.end();i++){ + std::vector<SPItem*> tmp=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=tmp.begin();i!=tmp.end();i++){ SPItem *item = SP_ITEM(*i); item->set_item_transform(displayed); SP_OBJECT(item)->updateRepr(); diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 86cf629c1..43e35df9d 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -1906,7 +1906,7 @@ void ContextMenu::ActivateGroup(void) void ContextMenu::ActivateUngroup(void) { - SelContainer children; + std::vector<SPItem*> children; sp_item_group_ungroup(static_cast<SPGroup*>(_item), children); _desktop->selection->setList(children); @@ -1958,7 +1958,7 @@ void ContextMenu::AnchorLinkFollow(void) void ContextMenu::AnchorLinkRemove(void) { - SelContainer children; + std::vector<SPItem*> children; sp_item_group_ungroup(static_cast<SPAnchor*>(_item), children, false); DocumentUndo::done(_desktop->doc(), SP_VERB_NONE, _("Remove link")); } @@ -2075,8 +2075,8 @@ void ContextMenu::ImageEdit(void) } #endif - SelContainer itemlist=_desktop->selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=_desktop->selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ Inkscape::XML::Node *ir = SP_ITEM(*i)->getRepr(); const gchar *href = ir->attribute("xlink:href"); diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp index fc40c20e7..9c6eead16 100644 --- a/src/ui/tools/connector-tool.cpp +++ b/src/ui/tools/connector-tool.cpp @@ -1316,8 +1316,8 @@ void cc_selection_set_avoid(bool const set_avoid) int changes = 0; - SelContainer l = selection->itemList(); - for(SelContainer::const_iterator i=l.begin();i!=l.end();i++) { + std::vector<SPItem*> l = selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=l.begin();i!=l.end();i++) { SPItem *item = SP_ITEM(*i); char const *value = (set_avoid) ? "true" : NULL; diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp index 3526e015a..520b93e72 100644 --- a/src/ui/tools/eraser-tool.cpp +++ b/src/ui/tools/eraser-tool.cpp @@ -676,8 +676,7 @@ void EraserTool::set_to_accumulated() { Geom::OptRect eraserBbox = acid->visualBounds(); Geom::Rect bounds = (*eraserBbox) * desktop->doc2dt(); std::vector<SPItem*> remainingItems; - SelContainer toWorkOn; - + std::vector<SPItem*> toWorkOn; if (selection->isEmpty()) { if ( eraserMode ) { toWorkOn = desktop->getDocument()->getItemsPartiallyInBox(desktop->dkey, bounds); @@ -685,16 +684,15 @@ void EraserTool::set_to_accumulated() { Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); toWorkOn = desktop->getDocument()->getItemsAtPoints(desktop->dkey, r->getPoints()); } - - toWorkOn.remove(static_cast<SPObject*>(acid) ); + toWorkOn.erase(find(toWorkOn.begin(),toWorkOn.end(),acid)); } else { - toWorkOn = selection->itemList(); + toWorkOn= selection->itemList(); wasSelection = true; } if ( !toWorkOn.empty() ) { if ( eraserMode ) { - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { SPItem *item = SP_ITEM(*i); if ( eraserMode ) { @@ -712,8 +710,8 @@ void EraserTool::set_to_accumulated() { if ( !selection->isEmpty() ) { // If the item was not completely erased, track the new remainder. - SelContainer nowSel(selection->itemList()); - for (SelContainer::const_iterator i2 = nowSel.begin();i!=nowSel.end();i++) { + std::vector<SPItem*> nowSel(selection->itemList()); + for (std::vector<SPItem*>::const_iterator i2 = nowSel.begin();i!=nowSel.end();i2++) { remainingItems.push_back(SP_ITEM(*i2)); } } @@ -723,11 +721,11 @@ void EraserTool::set_to_accumulated() { } } } else { - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector<SPItem*> ::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { sp_object_ref( SP_ITEM(*i), 0 ); } - for (SelContainer::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { + for (std::vector<SPItem*>::const_iterator i = toWorkOn.begin();i!=toWorkOn.end();i++) { SPItem *item = SP_ITEM(*i); item->deleteObject(true); sp_object_unref(item); diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index d1db5fb93..6f7b220ed 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -504,8 +504,8 @@ bool GradientTool::root_handler(GdkEvent* event) { // always resets selection to the single object under cursor sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); } else { - SelContainer items=selection->itemList(); - for (SelContainer::const_iterator i = items.begin();i!=items.end();i++) { + std::vector<SPItem*> items=selection->itemList(); + for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) { SPItem *item = SP_ITEM(*i); SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR); Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -915,8 +915,8 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta } else { // Starting from empty space: // Sort items so that the topmost comes last - SelContainer items(selection->itemList()); - items.sort(sp_item_repr_compare_position_obj); + std::vector<SPItem*> items(selection->itemList()); + sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); } @@ -925,8 +925,8 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - SelContainer itemlist = selection->itemList(); - for (SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end();i++) { + std::vector<SPItem*> itemlist = selection->itemList(); + for (std::vector<SPItem*>::const_iterator i = itemlist.begin();i!=itemlist.end();i++) { //FIXME: see above sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp index ce0ad7a9a..290eeef87 100644 --- a/src/ui/tools/lpe-tool.cpp +++ b/src/ui/tools/lpe-tool.cpp @@ -407,8 +407,8 @@ lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection) SPCanvasGroup *tmpgrp = lc->desktop->getTempGroup(); gchar *arc_length; double lengthval; - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ if (SP_IS_PATH(*i)) { path = SP_PATH(*i); curve = path->getCurve(); diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 8d52210ff..2b44639c8 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -441,9 +441,9 @@ bool MeasureTool::root_handler(GdkEvent* event) { // TODO switch to a different variable name. The single letter 'l' is easy to misread. //select elements crossed by line segment: - SelContainer items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); + std::vector<SPItem*> items = desktop->getDocument()->getItemsAtPoints(desktop->dkey, points); std::vector<double> intersection_times; - for (SelContainer::const_iterator i=items.begin();i!=items.end();i++) { + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { SPItem *item = static_cast<SPItem*>(*i); if (SP_IS_SHAPE(item)) { diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 1cc06a5b9..0a34e4855 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -481,8 +481,8 @@ bool MeshTool::root_handler(GdkEvent* event) { sp_mesh_context_split_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time); } else { // Create a new gradient with default coordinates. - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = SP_ITEM(*i); SPGradientType new_type = SP_GRADIENT_TYPE_MESH; Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; @@ -958,8 +958,8 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ } else { // Starting from empty space: // Sort items so that the topmost comes last - SelContainer items(selection->itemList()); - items.sort(sp_item_repr_compare_position_obj); + std::vector<SPItem*> items(selection->itemList()); + sort(items.begin(),items.end(),sp_item_repr_compare_position); // take topmost vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke); } @@ -968,8 +968,8 @@ static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/ SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_set_property(css, "fill-opacity", "1.0"); - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style"); diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 46c978c84..6ddb379cc 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -420,8 +420,8 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) { std::set<ShapeRecord> shapes; - SelContainer items=sel->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=sel->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPObject *obj = static_cast<SPObject*>(*i); if (SP_IS_ITEM(obj)) { @@ -667,7 +667,7 @@ void NodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) { if (this->_multipath->empty()) { // if multipath is empty, select rubberbanded items rather than nodes Inkscape::Selection *selection = this->desktop->selection; - SelContainer items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel); + std::vector<SPItem*> items = this->desktop->getDocument()->getItemsInBox(this->desktop->dkey, sel); selection->setList(items); } else { if (!held_shift(*event)) { diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index f84170631..25cbf76a4 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -718,7 +718,7 @@ bool SelectTool::root_handler(GdkEvent* event) { if (r->is_started() && !within_tolerance) { // this was a rubberband drag - SelContainer items; + std::vector<SPItem*> items; if (r->getMode() == RUBBERBAND_MODE_RECT) { Geom::OptRect const b = r->getRectangle(); diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index d339f6d19..ac41f3a34 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -436,9 +436,9 @@ static bool sp_spray_recursive(SPDesktop *desktop, SPItem *unionResult = NULL; // Previous union int i=1; - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator it=items.begin();it!=items.end();it++){ - SPItem *item1 = dynamic_cast<SPItem *>(static_cast<SPObject *>(*it)); + std::vector<SPItem*> items=selection->itemList(); + for(std::vector<SPItem*>::const_iterator it=items.begin();it!=items.end();it++){ + SPItem *item1 = *it; if (i == 1) { parent_item = item1; } @@ -550,15 +550,15 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point double move_standard_deviation = get_move_standard_deviation(tc); { - SelContainer const items(selection->itemList()); + std::vector<SPItem*> const items(selection->itemList()); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); g_assert(item != NULL); sp_object_ref(item); } - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); g_assert(item != NULL); @@ -573,7 +573,7 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point } } - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); g_assert(item != NULL); sp_object_unref(item); diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp index a4370256d..48c109688 100644 --- a/src/ui/tools/text-tool.cpp +++ b/src/ui/tools/text-tool.cpp @@ -1470,7 +1470,7 @@ int TextTool::_styleQueried(SPStyle *style, int property) } sp_text_context_validate_cursor_iterators(this); - SelContainer styles_list; + std::vector<SPItem*> styles_list; Inkscape::Text::Layout::iterator begin_it, end_it; if (this->text_sel_start < this->text_sel_end) { @@ -1496,7 +1496,7 @@ int TextTool::_styleQueried(SPStyle *style, int property) while (SP_IS_STRING(pos_obj) && pos_obj->parent) { pos_obj = pos_obj->parent; // SPStrings don't have style } - styles_list.push_front(pos_obj); + styles_list.insert(styles_list.begin(),(SPItem*)pos_obj); } int result = sp_desktop_query_style_from_list (styles_list, style, property); diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index cc05f9775..def8080d0 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -1178,8 +1178,8 @@ SPItem *sp_event_context_find_item(SPDesktop *desktop, Geom::Point const &p, SPItem * sp_event_context_over_item(SPDesktop *desktop, SPItem *item, Geom::Point const &p) { - SelContainer temp; - temp.push_front(static_cast<SPObject*>(item)); + std::vector<SPItem*> temp; + temp.push_back(item); SPItem *item_at_point = desktop->getItemFromListAtPointBottom(temp, p); return item_at_point; } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 9342127ce..6f7764506 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -382,13 +382,13 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P } if (dynamic_cast<SPText *>(item) || dynamic_cast<SPFlowtext *>(item)) { - SelContainer items; + std::vector<SPItem*> items; items.push_back(item); - SelContainer selected; - SelContainer to_select; + std::vector<SPItem*> selected; + std::vector<Inkscape::XML::Node*> to_select; SPDocument *doc = item->document; sp_item_list_to_curves (items, selected, to_select); - SPObject* newObj = doc->getObjectByRepr(dynamic_cast<Inkscape::XML::Node *>(to_select.front())); + SPObject* newObj = doc->getObjectByRepr(to_select.back()); item = dynamic_cast<SPItem *>(newObj); g_assert(item != NULL); selection->add(item); @@ -1087,8 +1087,8 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point double move_force = get_move_force(tc); double color_force = MIN(sqrt(path_force)/20.0, 1); - SelContainer items=selection->itemList(); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + std::vector<SPItem*> items=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(*i)); if (is_color_mode (tc->mode)) { diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp index ddf67fb5b..598a90e95 100644 --- a/src/ui/widget/object-composite-settings.cpp +++ b/src/ui/widget/object-composite-settings.cpp @@ -125,8 +125,8 @@ ObjectCompositeSettings::_blendBlurValueChanged() const Glib::ustring blendmode = _fe_cb.get_blend_mode(); //apply created filter to every selected item - SelContainer sel=_subject->getDesktop()->getSelection()->itemList(); - for (SelContainer::const_iterator i = sel.begin() ; i != sel.end() ; ++i ) { + std::vector<SPItem*> sel=_subject->getDesktop()->getSelection()->itemList(); + for (std::vector<SPItem*>::const_iterator i = sel.begin() ; i != sel.end() ; ++i ) { if (!SP_IS_ITEM(*i)) { continue; } diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp index 9d09e67d3..1ded546dd 100644 --- a/src/ui/widget/style-subject.cpp +++ b/src/ui/widget/style-subject.cpp @@ -148,10 +148,10 @@ Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) { } int StyleSubject::CurrentLayer::queryStyle(SPStyle *query, int property) { - SelContainer list; + std::vector<SPItem*> list; SPObject* i=_getLayerSList(); if (i) { - list.push_back(i); + list.push_back((SPItem*)i); return sp_desktop_query_style_from_list(list, query, property); } else { return QUERY_STYLE_NOTHING; diff --git a/src/unclump.cpp b/src/unclump.cpp index d1cfc6628..29608befa 100644 --- a/src/unclump.cpp +++ b/src/unclump.cpp @@ -168,11 +168,11 @@ unclump_dist (SPItem *item1, SPItem *item2) /** Average unclump_dist from item to others */ -static double unclump_average (SPItem *item, SelContainer &others) +static double unclump_average (SPItem *item, std::list<SPItem*> &others) { int n = 0; double sum = 0; - for (SelContainer::const_iterator i = others.begin(); i != others.end();i++) { + for (std::list<SPItem*>::const_iterator i = others.begin(); i != others.end();i++) { SPItem *other = SP_ITEM (*i); if (other == item) @@ -191,12 +191,12 @@ static double unclump_average (SPItem *item, SelContainer &others) /** Closest to item among others */ -static SPItem *unclump_closest (SPItem *item, SelContainer &others) +static SPItem *unclump_closest (SPItem *item, std::list<SPItem*> &others) { double min = HUGE_VAL; SPItem *closest = NULL; - for (SelContainer::const_iterator i = others.begin(); i != others.end();i++) { + for (std::list<SPItem*>::const_iterator i = others.begin(); i != others.end();i++) { SPItem *other = SP_ITEM (*i); if (other == item) @@ -215,11 +215,11 @@ static SPItem *unclump_closest (SPItem *item, SelContainer &others) /** Most distant from item among others */ -static SPItem *unclump_farest (SPItem *item, SelContainer &others) +static SPItem *unclump_farest (SPItem *item, std::list<SPItem*> &others) { double max = -HUGE_VAL; SPItem *farest = NULL; - for (SelContainer::const_iterator i = others.begin(); i != others.end();i++) { + for (std::list<SPItem*>::const_iterator i = others.begin(); i != others.end();i++) { SPItem *other = SP_ITEM (*i); if (other == item) @@ -240,8 +240,8 @@ Removes from the \a rest list those items that are "behind" \a closest as seen f i.e. those on the other side of the line through \a closest perpendicular to the direction from \a item to \a closest. Returns a newly created list which must be freed. */ -static SelContainer -unclump_remove_behind (SPItem *item, SPItem *closest, SelContainer &rest) +static std::vector<SPItem*> +unclump_remove_behind (SPItem *item, SPItem *closest, std::list<SPItem*> &rest) { Geom::Point it = unclump_center (item); Geom::Point p1 = unclump_center (closest); @@ -258,8 +258,8 @@ unclump_remove_behind (SPItem *item, SPItem *closest, SelContainer &rest) // substitute the item into it: double val_item = A * it[Geom::X] + B * it[Geom::Y] + C; - SelContainer out; - for (SelContainer::const_iterator i = rest.begin(); i != rest.end();i++) { + std::vector<SPItem*> out; + for (std::list<SPItem*>::const_reverse_iterator i = rest.rbegin(); i != rest.rend();i++) { SPItem *other = SP_ITEM (*i); if (other == item) @@ -271,7 +271,7 @@ unclump_remove_behind (SPItem *item, SPItem *closest, SelContainer &rest) if (val_item * val_other <= 1e-6) { // different signs, which means item and other are on the different sides of p1-p2 line; skip } else { - out.push_front(other); + out.push_back(other); } } @@ -331,17 +331,18 @@ similar to "engraver dots". The only distribution which is unchanged by unclumpi grid. May be called repeatedly for stronger effect. */ void -unclump (SelContainer &items) +unclump (std::vector<SPItem*> &items) { c_cache.clear(); wh_cache.clear(); - for (SelContainer::const_iterator i = items.begin(); i != items.end();i++) { // for each original/clone x: + for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end();i++) { // for each original/clone x: SPItem *item = SP_ITEM (*i); - SelContainer nei; + std::list<SPItem*> nei; - SelContainer rest(items); + std::list<SPItem*> rest; + for(int i=0;i<items.size();i++)rest.push_front(items[items.size()-i-1]); rest.remove(item); while (!rest.empty()) { @@ -349,8 +350,9 @@ unclump (SelContainer &items) if (closest) { nei.push_front(closest); rest.remove(closest); - SelContainer new_rest = unclump_remove_behind (item, closest, rest); - rest = new_rest; + std::vector<SPItem*> new_rest = unclump_remove_behind (item, closest, rest); + rest.clear(); + for(int i=0;i<new_rest.size();i++)rest.push_front(new_rest[new_rest.size()-i-1]); } else { break; } diff --git a/src/unclump.h b/src/unclump.h index 54f43ffde..407628f3a 100644 --- a/src/unclump.h +++ b/src/unclump.h @@ -14,7 +14,7 @@ typedef struct _GSList GSList; #include "selection.h" -void unclump(SelContainer &items); +void unclump(std::vector<SPItem*> &items); #endif /* !UNCLUMP_H_SEEN */ diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 98a3eaa67..770845f38 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -256,8 +256,8 @@ VanishingPoint::set_pos(Proj::Pt2 const &pt) { std::list<SPBox3D *> VanishingPoint::selectedBoxes(Inkscape::Selection *sel) { std::list<SPBox3D *> sel_boxes; - SelContainer itemlist=sel->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector<SPItem*> itemlist=sel->itemList(); + for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast<SPItem *>(*i); SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box && this->hasBox(box)) { @@ -396,8 +396,8 @@ VPDragger::VPsOfSelectedBoxes() { VanishingPoint *vp; // FIXME: Should we take the selection from the parent VPDrag? I guess it shouldn't make a difference. Inkscape::Selection *sel = SP_ACTIVE_DESKTOP->getSelection(); - SelContainer itemlist=sel->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector<SPItem*> itemlist=sel->itemList(); + for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast<SPItem *>(*i); SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { @@ -579,8 +579,8 @@ VPDrag::updateDraggers () g_return_if_fail (this->selection != NULL); - SelContainer itemlist=this->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector<SPItem*> itemlist=this->selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast<SPItem *>(*i); SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { @@ -612,8 +612,8 @@ VPDrag::updateLines () g_return_if_fail (this->selection != NULL); - SelContainer itemlist=this->selection->itemList(); - for (SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { + std::vector<SPItem*> itemlist=this->selection->itemList(); + for (std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++) { SPItem *item = static_cast<SPItem *>(*i); SPBox3D *box = dynamic_cast<SPBox3D *>(item); if (box) { @@ -630,7 +630,7 @@ VPDrag::updateBoxHandles () // FIXME: Is there a way to update the knots without accessing the // (previously) statically linked function KnotHolder::update_knots? - SelContainer sel = selection->itemList(); + std::vector<SPItem*> sel = selection->itemList(); if (sel.empty()) return; // no selection diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index 23c248129..cb24bb8aa 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -97,8 +97,8 @@ sp_arctb_startend_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const *v gchar* namespaced_name = g_strconcat("sodipodi:", value_name, NULL); bool modmade = false; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { @@ -163,8 +163,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) bool modmade = false; if ( ege_select_one_action_get_active(act) != 0 ) { - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -174,8 +174,8 @@ static void sp_arctb_open_state_changed( EgeSelectOneAction *act, GObject *tbl ) } } } else { - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -264,8 +264,8 @@ static void sp_arc_toolbox_selection_changed(Inkscape::Selection *selection, GOb purge_repr_listener( tbl, tbl ); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_GENERICELLIPSE(item)) { n_selected++; diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp index 401ce932a..49cf8e6fd 100644 --- a/src/widgets/connector-toolbar.cpp +++ b/src/widgets/connector-toolbar.cpp @@ -97,8 +97,8 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl gchar *value = is_orthog ? orthog_str : polyline_str ; bool modmade = false; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (Inkscape::UI::Tools::cc_item_is_connector(item)) { @@ -144,8 +144,8 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl) g_ascii_dtostr(value, G_ASCII_DTOSTR_BUF_SIZE, newValue); bool modmade = false; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (Inkscape::UI::Tools::cc_item_is_connector(item)) { diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp index 2c298b04d..dbb84efba 100644 --- a/src/widgets/fill-style.cpp +++ b/src/widgets/fill-style.cpp @@ -481,7 +481,7 @@ void FillNStroke::updateFromPaint() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - SelContainer const items = selection->itemList(); + std::vector<SPItem*> const items = selection->itemList(); switch (psel->mode) { case SPPaintSelector::MODE_EMPTY: @@ -576,7 +576,7 @@ void FillNStroke::updateFromPaint() } } - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above if (kind == FILL) { sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(*i)->getRepr(), css, "style"); @@ -602,7 +602,7 @@ void FillNStroke::updateFromPaint() // We have changed from another gradient type, or modified spread/units within // this gradient type. vector = sp_gradient_ensure_vector_normalized(vector); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ //FIXME: see above if (kind == FILL) { sp_repr_css_change_recursive(reinterpret_cast<SPObject*>(*i)->getRepr(), css, "style"); @@ -648,7 +648,7 @@ void FillNStroke::updateFromPaint() // cannot just call sp_desktop_set_style, because we don't want to touch those // objects who already have the same root pattern but through a different href // chain. FIXME: move this to a sp_item_set_pattern - for(SelContainer::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 *selrepr = reinterpret_cast<SPObject*>(*i)->getRepr(); if ( (kind == STROKE) && !selrepr) { continue; diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp index b9608130b..5aa654a80 100644 --- a/src/widgets/gradient-toolbar.cpp +++ b/src/widgets/gradient-toolbar.cpp @@ -116,8 +116,8 @@ void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient } // If no drag or no dragger selected, act on selection - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ gr_apply_gradient_to_item(SP_ITEM(*i), gr, initialType, initialMode, initialMode); } } @@ -218,8 +218,8 @@ void gr_get_dt_selected_gradient(Inkscape::Selection *selection, SPGradient *&gr { SPGradient *gradient = 0; - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i);// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; @@ -286,8 +286,8 @@ void gr_read_selection( Inkscape::Selection *selection, } // If no selected dragger, read desktop selection - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index b4176db6f..682c61e77 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -87,8 +87,8 @@ void ms_read_selection( Inkscape::Selection *selection, bool first = true; ms_smooth = SP_MESH_SMOOTH_NONE; - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; @@ -214,8 +214,8 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMeshGradient { SPMeshGradient *gradient = 0; - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i);// get the items gradient, not the getVector() version SPStyle *style = item->style; SPPaintServer *server = 0; diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index 1f19867ee..65078af01 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -106,8 +106,8 @@ static void sp_rtb_value_changed(GtkAdjustment *adj, GObject *tbl, gchar const * bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ if (SP_IS_RECT(*i)) { if (gtk_adjustment_get_value(adj) != 0) { (SP_RECT(*i)->*setter)(Quantity::convert(gtk_adjustment_get_value(adj), unit, desktop->getNamedView()->svg_units)); @@ -244,8 +244,8 @@ static void sp_rect_toolbox_selection_changed(Inkscape::Selection *selection, GO } purge_repr_listener( tbl, tbl ); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ if (SP_IS_RECT(reinterpret_cast<SPItem *>(*i))) { n_selected++; item = reinterpret_cast<SPItem *>(*i); diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp index 2f4ad481d..6f967e8ae 100644 --- a/src/widgets/spiral-toolbar.cpp +++ b/src/widgets/spiral-toolbar.cpp @@ -79,8 +79,8 @@ static void sp_spl_tb_value_changed(GtkAdjustment *adj, GObject *tbl, Glib::ustr gchar* namespaced_name = g_strconcat("sodipodi:", value_name.data(), NULL); bool modmade = false; - SelContainer itemlist=desktop->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=desktop->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_SPIRAL(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -195,8 +195,8 @@ static void sp_spiral_toolbox_selection_changed(Inkscape::Selection *selection, purge_repr_listener( tbl, tbl ); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_SPIRAL(item)) { n_selected++; diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp index 37daf69d0..1946dee6e 100644 --- a/src/widgets/star-toolbar.cpp +++ b/src/widgets/star-toolbar.cpp @@ -83,8 +83,8 @@ static void sp_stb_magnitude_value_changed( GtkAdjustment *adj, GObject *dataKlu bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -128,8 +128,8 @@ static void sp_stb_proportion_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -185,8 +185,8 @@ static void sp_stb_sides_flat_state_changed( EgeSelectOneAction *act, GObject *d gtk_action_set_sensitive( prop_action, !flat ); } - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -224,8 +224,8 @@ static void sp_stb_rounded_value_changed( GtkAdjustment *adj, GObject *dataKludg bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -264,8 +264,8 @@ static void sp_stb_randomized_value_changed( GtkAdjustment *adj, GObject *dataKl bool modmade = false; Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { Inkscape::XML::Node *repr = item->getRepr(); @@ -367,8 +367,8 @@ sp_star_toolbox_selection_changed(Inkscape::Selection *selection, GObject *tbl) purge_repr_listener( tbl, tbl ); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (SP_IS_STAR(item)) { n_selected++; diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp index 2599fe537..65390819b 100644 --- a/src/widgets/stroke-style.cpp +++ b/src/widgets/stroke-style.cpp @@ -475,8 +475,8 @@ void StrokeStyle::markerSelectCB(MarkerComboBox *marker_combo, StrokeStyle *spw, //spw->updateMarkerHist(which); Inkscape::Selection *selection = spw->desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ SPItem *item = SP_ITEM(*i); if (!SP_IS_SHAPE(item) || SP_IS_RECT(item)) { // can't set marker to rect, until it's converted to using <path> continue; @@ -901,7 +901,7 @@ StrokeStyle::updateLine() if (!sel || sel->isEmpty()) return; - SelContainer const objects = sel->itemList(); + std::vector<SPItem*> const objects = sel->itemList(); SPObject * const object = SP_OBJECT(objects.front()); SPStyle * const style = object->style; @@ -957,7 +957,7 @@ StrokeStyle::scaleLine() SPDocument *document = desktop->getDocument(); Inkscape::Selection *selection = desktop->getSelection(); - SelContainer items=selection->itemList(); + std::vector<SPItem*> items=selection->itemList(); /* TODO: Create some standardized method */ SPCSSAttr *css = sp_repr_css_attr_new(); @@ -977,7 +977,7 @@ StrokeStyle::scaleLine() int ndash; dashSelector->get_dash(&ndash, &dash, &offset); - for(SelContainer::const_iterator i=items.begin();i!=items.end();i++){ + for(std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ /* Set stroke width */ double width; if (unit->type == Inkscape::Util::UNIT_TYPE_LINEAR) { @@ -1143,7 +1143,7 @@ StrokeStyle::setCapButtons(Gtk::ToggleButton *active) * that marker. */ void -StrokeStyle::updateAllMarkers(SelContainer const &objects) +StrokeStyle::updateAllMarkers(std::vector<SPItem*> const &objects) { struct { MarkerComboBox *key; int loc; } const keyloc[] = { { startMarkerCombo, SP_MARKER_LOC_START }, @@ -1152,7 +1152,7 @@ StrokeStyle::updateAllMarkers(SelContainer const &objects) }; bool all_texts = true; - for(SelContainer::const_iterator i=objects.begin();i!=objects.end();i++){ + for(std::vector<SPItem*>::const_iterator i=objects.begin();i!=objects.end();i++){ if (!SP_IS_TEXT (*i)) { all_texts = false; } diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h index 286305ec3..2605e1acf 100644 --- a/src/widgets/stroke-style.h +++ b/src/widgets/stroke-style.h @@ -153,7 +153,7 @@ private: }; void updateLine(); - void updateAllMarkers(SelContainer const &objects); + void updateAllMarkers(std::vector<SPItem*> const &objects); void updateMarkerHist(SPMarkerLoc const which); void setDashSelectorFromStyle(SPDashSelector *dsel, SPStyle *style); void setJoinType (unsigned const jointype); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index ba7dfc1fd..71915377e 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -366,8 +366,8 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl ) // move the x of all texts to preserve the same bbox Inkscape::Selection *selection = desktop->getSelection(); - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ if (SP_IS_TEXT(SP_ITEM(*i))) { SPItem *item = SP_ITEM(*i); @@ -519,8 +519,8 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) // Until deprecated sodipodi:linespacing purged: Inkscape::Selection *selection = desktop->getSelection(); bool modmade = false; - SelContainer itemlist=selection->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=selection->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ if (SP_IS_TEXT (*i)) { SP_OBJECT(*i)->getRepr()->setAttribute("sodipodi:linespacing", sp_repr_css_property (css, "line-height", NULL)); modmade = true; @@ -864,8 +864,8 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ // Only flowed text can be justified, only normal text can be kerned... // Find out if we have flowed text now so we can use it several places gboolean isFlow = false; - SelContainer itemlist=SP_ACTIVE_DESKTOP->getSelection()->itemList(); - for(SelContainer::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ + std::vector<SPItem*> itemlist=SP_ACTIVE_DESKTOP->getSelection()->itemList(); + for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){ // const gchar* id = reinterpret_cast<SPItem *>(items->data)->getId(); // std::cout << " " << id << std::endl; if( SP_IS_FLOWTEXT(SP_ITEM(*i))) { @@ -1153,13 +1153,13 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p //std::cout << "text_toolbox_missing_font_cb: selecting: " << family << std::endl; // Get all items with matching font-family set (not inherited!). - SelContainer selectList; + std::vector<SPItem*> selectList; SPDesktop *desktop = SP_ACTIVE_DESKTOP; SPDocument *document = desktop->getDocument(); - SelContainer x,y; - SelContainer allList = get_all_items(x, document->getRoot(), desktop, false, false, true, y); - for(SelContainer::const_iterator i=allList.begin();i!=allList.end();i++){ + std::vector<SPItem*> x,y; + std::vector<SPItem*> allList = get_all_items(x, document->getRoot(), desktop, false, false, true, y); + for(std::vector<SPItem*>::const_reverse_iterator i=allList.rbegin();i!=allList.rend();i++){ SPItem *item = SP_ITEM(*i); SPStyle *style = item->style; @@ -1177,7 +1177,7 @@ static void sp_text_toolbox_select_cb( GtkEntry* entry, GtkEntryIconPosition /*p if (family_style.compare( family ) == 0 ) { //std::cout << " found: " << item->getId() << std::endl; - selectList.push_front(static_cast<SPObject*>(item)); + selectList.push_back(item); } } } |
