From 3b4e451ace16cc3a4c62d2dfdc50587d4a8acf8c Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Mon, 26 May 2014 21:02:55 +0200 Subject: SPPattern c++-sification: replaced guint by bool and enum (bzr r13341.6.16) --- src/sp-pattern.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 9b7330a24..c5461d302 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -59,14 +59,14 @@ SPPattern::SPPattern() : SPPaintServer(), SPViewBox() { this->ref = new SPPatternReference(this); this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(pattern_ref_changed), this)); - this->patternUnits = SP_PATTERN_UNITS_OBJECTBOUNDINGBOX; - this->patternUnits_set = FALSE; + this->patternUnits = UNITS_OBJECTBOUNDINGBOX; + this->patternUnits_set = false; - this->patternContentUnits = SP_PATTERN_UNITS_USERSPACEONUSE; - this->patternContentUnits_set = FALSE; + this->patternContentUnits = UNITS_USERSPACEONUSE; + this->patternContentUnits_set = false; this->patternTransform = Geom::identity(); - this->patternTransform_set = FALSE; + this->patternTransform_set = false; this->x.unset(); this->y.unset(); @@ -116,14 +116,14 @@ void SPPattern::set(unsigned int key, const gchar* value) { case SP_ATTR_PATTERNUNITS: if (value) { if (!strcmp (value, "userSpaceOnUse")) { - this->patternUnits = SP_PATTERN_UNITS_USERSPACEONUSE; + this->patternUnits = UNITS_USERSPACEONUSE; } else { - this->patternUnits = SP_PATTERN_UNITS_OBJECTBOUNDINGBOX; + this->patternUnits = UNITS_OBJECTBOUNDINGBOX; } - this->patternUnits_set = TRUE; + this->patternUnits_set = true; } else { - this->patternUnits_set = FALSE; + this->patternUnits_set = false; } this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -132,14 +132,14 @@ void SPPattern::set(unsigned int key, const gchar* value) { case SP_ATTR_PATTERNCONTENTUNITS: if (value) { if (!strcmp (value, "userSpaceOnUse")) { - this->patternContentUnits = SP_PATTERN_UNITS_USERSPACEONUSE; + this->patternContentUnits = UNITS_USERSPACEONUSE; } else { - this->patternContentUnits = SP_PATTERN_UNITS_OBJECTBOUNDINGBOX; + this->patternContentUnits = UNITS_OBJECTBOUNDINGBOX; } - this->patternContentUnits_set = TRUE; + this->patternContentUnits_set = true; } else { - this->patternContentUnits_set = FALSE; + this->patternContentUnits_set = false; } this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -150,10 +150,10 @@ void SPPattern::set(unsigned int key, const gchar* value) { if (value && sp_svg_transform_read (value, &t)) { this->patternTransform = t; - this->patternTransform_set = TRUE; + this->patternTransform_set = true; } else { this->patternTransform = Geom::identity(); - this->patternTransform_set = FALSE; + this->patternTransform_set = false; } this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -399,7 +399,7 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se } else { pattern->patternTransform = pattern_patternTransform(pattern) * postmul; } - pattern->patternTransform_set = TRUE; + pattern->patternTransform_set = true; gchar *c=sp_svg_transform_write(pattern->patternTransform); pattern->getRepr()->setAttribute("patternTransform", c); @@ -455,7 +455,7 @@ SPPattern *pattern_getroot(SPPattern *pat) // Access functions that look up fields up the chain of referenced patterns and return the first one which is set // FIXME: all of them must use chase_hrefs the same as in SPGradient, to avoid lockup on circular refs -guint pattern_patternUnits (SPPattern const *pat) +SPPattern::PatternUnits pattern_patternUnits (SPPattern const *pat) { for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->patternUnits_set) @@ -464,7 +464,7 @@ guint pattern_patternUnits (SPPattern const *pat) return pat->patternUnits; } -guint pattern_patternContentUnits (SPPattern const *pat) +SPPattern::PatternUnits pattern_patternContentUnits (SPPattern const *pat) { for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->patternContentUnits_set) @@ -603,7 +603,7 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b double tile_y = pattern_y(this); double tile_width = pattern_width(this); double tile_height = pattern_height(this); - if ( bbox && (pattern_patternUnits(this) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) ) { + if ( bbox && (pattern_patternUnits(this) == UNITS_OBJECTBOUNDINGBOX) ) { tile_x *= bbox->width(); tile_y *= bbox->height(); tile_width *= bbox->width(); @@ -625,7 +625,7 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b } else { // Content to bbox - if (bbox && (pattern_patternContentUnits(this) == SP_PATTERN_UNITS_OBJECTBOUNDINGBOX) ) { + if (bbox && (pattern_patternContentUnits(this) == UNITS_OBJECTBOUNDINGBOX) ) { content2ps = Geom::Affine(bbox->width(), 0.0, 0.0, bbox->height(), 0,0); } } -- cgit v1.2.3 From 258b23eac6fadcd3c02053ac6e890b0be5819194 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Mon, 26 May 2014 22:52:46 +0200 Subject: SPPattern c++-sification: replaced gchar* by Glib::ustring (bzr r13341.6.17) --- src/sp-pattern.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index c5461d302..59fbca435 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -54,8 +54,6 @@ namespace { } SPPattern::SPPattern() : SPPaintServer(), SPViewBox() { - this->href = NULL; - this->ref = new SPPatternReference(this); this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(pattern_ref_changed), this)); @@ -190,15 +188,14 @@ void SPPattern::set(unsigned int key, const gchar* value) { break; case SP_ATTR_XLINK_HREF: - if ( value && this->href && ( strcmp(value, this->href) == 0 ) ) { + if ( value && this->href == value ) { /* Href unchanged, do nothing. */ } else { - g_free(this->href); - this->href = NULL; + this->href.clear(); if (value) { // First, set the href field; it's only used in the "unchanged" check above. - this->href = g_strdup(value); + this->href = value; // Now do the attaching, which emits the changed signal. if (value) { try { @@ -360,9 +357,8 @@ SPPattern *pattern_chain(SPPattern *pattern) Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); repr->setAttribute("inkscape:collect", "always"); - gchar *parent_ref = g_strconcat("#", pattern->getRepr()->attribute("id"), NULL); + Glib::ustring parent_ref = Glib::ustring::compose("#%1", pattern->getRepr()->attribute("id")); repr->setAttribute("xlink:href", parent_ref); - g_free (parent_ref); defsrepr->addChild(repr, NULL); const gchar *child_id = repr->attribute("id"); @@ -375,13 +371,14 @@ SPPattern *pattern_chain(SPPattern *pattern) SPPattern * sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property) { - if (!pattern->href || pattern->hrefcount > count_pattern_hrefs(item, pattern)) { + if (pattern->href.empty() || pattern->hrefcount > count_pattern_hrefs(item, pattern)) { pattern = pattern_chain (pattern); - gchar *href = g_strconcat("url(#", pattern->getRepr()->attribute("id"), ")", NULL); + Glib::ustring href = Glib::ustring::compose("url(#%1)", pattern->getRepr()->attribute("id")); SPCSSAttr *css = sp_repr_css_attr_new (); - sp_repr_css_set_property (css, property, href); + sp_repr_css_set_property (css, property, href.c_str()); sp_repr_css_change_recursive(item->getRepr(), css, "style"); + } return pattern; } @@ -401,9 +398,8 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se } pattern->patternTransform_set = true; - gchar *c=sp_svg_transform_write(pattern->patternTransform); + Glib::ustring c=sp_svg_transform_write(pattern->patternTransform); pattern->getRepr()->setAttribute("patternTransform", c); - g_free(c); } const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) @@ -416,9 +412,8 @@ const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document sp_repr_set_svg_double(repr, "width", bounds.dimensions()[Geom::X]); sp_repr_set_svg_double(repr, "height", bounds.dimensions()[Geom::Y]); - gchar *t=sp_svg_transform_write(transform); + Glib::ustring t=sp_svg_transform_write(transform); repr->setAttribute("patternTransform", t); - g_free(t); defsrepr->appendChild(repr); const gchar *pat_id = repr->attribute("id"); -- cgit v1.2.3 From 6508c429a4a678541bc51df10a8335bbb45f0128 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Tue, 27 May 2014 19:13:09 +0200 Subject: SPPattern c++-sification: replaced GSList by std::list (bzr r13341.6.18) --- src/sp-pattern.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 59fbca435..a3de09368 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -222,37 +222,34 @@ void SPPattern::set(unsigned int key, const gchar* value) { /* fixme: We need ::order_changed handler too (Lauris) */ -static GSList *pattern_getchildren(SPPattern *pat) +void pattern_getchildren(SPPattern *pat, std::list& l) { - GSList *l = NULL; - for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children for (SPObject *child = pat->firstChild() ; child ; child = child->getNext() ) { - l = g_slist_prepend (l, child); + l.push_back(child); } break; // do not go further up the chain if children are found } } - - return l; } void SPPattern::update(SPCtx* ctx, unsigned int flags) { - if (flags & SP_OBJECT_MODIFIED_FLAG) { + typedef std::list::iterator SPObjectIterator; + + if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } flags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = pattern_getchildren (this); - l = g_slist_reverse (l); + std::list l; + pattern_getchildren (this, l); - while (l) { - SPObject *child = SP_OBJECT (l->data); + for (SPObjectIterator it = l.begin(); it != l.end(); it++) { + SPObject *child = *it; sp_object_ref (child, NULL); - l = g_slist_remove (l, child); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->updateDisplay(ctx, flags); @@ -263,20 +260,21 @@ void SPPattern::update(SPCtx* ctx, unsigned int flags) { } void SPPattern::modified(unsigned int flags) { + typedef std::list::iterator SPObjectIterator; + if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } flags &= SP_OBJECT_MODIFIED_CASCADE; - GSList *l = pattern_getchildren (this); - l = g_slist_reverse (l); + std::list l; + pattern_getchildren (this, l); - while (l) { - SPObject *child = SP_OBJECT (l->data); + for (SPObjectIterator it = l.begin(); it != l.end(); it++) { + SPObject *child = *it; sp_object_ref (child, NULL); - l = g_slist_remove (l, child); if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { child->emitModified(flags); @@ -402,8 +400,11 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se pattern->getRepr()->setAttribute("patternTransform", c); } -const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) +const gchar *pattern_tile(const std::list &reprs, Geom::Rect bounds, + SPDocument *document, Geom::Affine transform, Geom::Affine move) { + typedef std::list::const_iterator NodePtrIterator; + Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); @@ -419,8 +420,8 @@ const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document const gchar *pat_id = repr->attribute("id"); SPObject *pat_object = document->getObjectById(pat_id); - for (GSList *i = reprs; i != NULL; i = i->next) { - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); + for (NodePtrIterator i = reprs.begin(); i != reprs.end(); i++) { + Inkscape::XML::Node *node = *i; SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); Geom::Affine dup_transform; -- cgit v1.2.3 From 22db6068f172d060429f17a489bdce59e5836c69 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Tue, 27 May 2014 21:57:33 +0200 Subject: SPPattern c++-sification: replacing pattern_ functions by methods pt1 (bzr r13341.6.19) --- src/sp-pattern.cpp | 66 +++++++++++++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index a3de09368..81e11ecb2 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -392,7 +392,7 @@ sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool se if (set) { pattern->patternTransform = postmul; } else { - pattern->patternTransform = pattern_patternTransform(pattern) * postmul; + pattern->patternTransform = pattern->get_transform() * postmul; } pattern->patternTransform_set = true; @@ -451,73 +451,73 @@ SPPattern *pattern_getroot(SPPattern *pat) // Access functions that look up fields up the chain of referenced patterns and return the first one which is set // FIXME: all of them must use chase_hrefs the same as in SPGradient, to avoid lockup on circular refs -SPPattern::PatternUnits pattern_patternUnits (SPPattern const *pat) +SPPattern::PatternUnits SPPattern::get_pattern_units() const { - for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->patternUnits_set) return pat_i->patternUnits; } - return pat->patternUnits; + return patternUnits; } -SPPattern::PatternUnits pattern_patternContentUnits (SPPattern const *pat) +SPPattern::PatternUnits SPPattern::get_pattern_content_units() const { - for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->patternContentUnits_set) return pat_i->patternContentUnits; } - return pat->patternContentUnits; + return patternContentUnits; } -Geom::Affine const &pattern_patternTransform(SPPattern const *pat) +Geom::Affine const &SPPattern::get_transform() const { - for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->patternTransform_set) return pat_i->patternTransform; } - return pat->patternTransform; + return patternTransform; } -gdouble pattern_x (SPPattern const *pat) +gdouble SPPattern::get_x() const { - for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->x._set) return pat_i->x.computed; } return 0; } -gdouble pattern_y (SPPattern const *pat) +gdouble SPPattern::get_y() const { - for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->y._set) return pat_i->y.computed; } return 0; } -gdouble pattern_width (SPPattern const* pat) +gdouble SPPattern::get_width() const { - for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->width._set) return pat_i->width.computed; } return 0; } -gdouble pattern_height (SPPattern const *pat) +gdouble SPPattern::get_height() const { - for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->height._set) return pat_i->height.computed; } return 0; } -Geom::OptRect pattern_viewBox (SPPattern const *pat) +Geom::OptRect SPPattern::get_viewbox() const { Geom::OptRect viewbox; - for (SPPattern const *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->viewBox_set) { viewbox = pat_i->viewBox; break; @@ -526,10 +526,10 @@ Geom::OptRect pattern_viewBox (SPPattern const *pat) return viewbox; } -static bool pattern_hasItemChildren (SPPattern const *pat) +bool SPPattern::_has_item_children() const { bool hasChildren = false; - for (SPObject const *child = pat->firstChild() ; child && !hasChildren ; child = child->getNext() ) { + for (SPObject const *child = firstChild() ; child && !hasChildren ; child = child->getNext() ) { if (SP_IS_ITEM(child)) { hasChildren = true; } @@ -539,8 +539,8 @@ static bool pattern_hasItemChildren (SPPattern const *pat) bool SPPattern::isValid() const { - double tile_width = pattern_width(this); - double tile_height = pattern_height(this); + double tile_width = get_width(); + double tile_height = get_height(); if (tile_width <= 0 || tile_height <= 0) return false; @@ -561,7 +561,7 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { // find the first one with item children - if (pat_i && SP_IS_OBJECT(pat_i) && pattern_hasItemChildren(pat_i)) { + if (pat_i && SP_IS_OBJECT(pat_i) && pat_i->_has_item_children()) { shown = pat_i; break; // do not go further up the chain if children are found } @@ -595,11 +595,11 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // * "x", "y", and "patternTransform" transform tile to user space after tile is generated. // These functions recursively search up the tree to find the values. - double tile_x = pattern_x(this); - double tile_y = pattern_y(this); - double tile_width = pattern_width(this); - double tile_height = pattern_height(this); - if ( bbox && (pattern_patternUnits(this) == UNITS_OBJECTBOUNDINGBOX) ) { + double tile_x = get_x(); + double tile_y = get_y(); + double tile_width = get_width(); + double tile_height = get_height(); + if ( bbox && (get_pattern_units() == UNITS_OBJECTBOUNDINGBOX) ) { tile_x *= bbox->width(); tile_y *= bbox->height(); tile_width *= bbox->width(); @@ -611,7 +611,7 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // Content to tile (pattern space) Geom::Affine content2ps; - Geom::OptRect effective_view_box = pattern_viewBox(this); + Geom::OptRect effective_view_box = get_viewbox(); if (effective_view_box) { // viewBox to pattern server (using SPViewBox) viewBox = *effective_view_box; @@ -621,14 +621,14 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b } else { // Content to bbox - if (bbox && (pattern_patternContentUnits(this) == UNITS_OBJECTBOUNDINGBOX) ) { + if (bbox && (get_pattern_content_units() == UNITS_OBJECTBOUNDINGBOX) ) { content2ps = Geom::Affine(bbox->width(), 0.0, 0.0, bbox->height(), 0,0); } } // Tile (pattern space) to user. - Geom::Affine ps2user = Geom::Translate(tile_x,tile_y) * pattern_patternTransform(this); + Geom::Affine ps2user = Geom::Translate(tile_x,tile_y) * get_transform(); // Transform of object with pattern (includes screen scaling) -- cgit v1.2.3 From 4d75f1ecca2fcab4cbfec9fb84c5b1f3647dbc17 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Wed, 28 May 2014 23:28:17 +0200 Subject: SPPattern c++-sification: replaced function by methods (bzr r13341.6.21) --- src/sp-pattern.cpp | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 81e11ecb2..bd24ab1bb 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -312,12 +312,7 @@ static void pattern_ref_modified (SPObject */*ref*/, guint /*flags*/, SPPattern // Conditional to avoid causing infinite loop if there's a cycle in the href chain. } - -/** -Count how many times pat is used by the styles of o and its descendants -*/ -static guint -count_pattern_hrefs(SPObject *o, SPPattern *pat) +guint SPPattern::_count_hrefs(SPObject *o) const { if (!o) return 1; @@ -328,34 +323,32 @@ count_pattern_hrefs(SPObject *o, SPPattern *pat) if (style && style->fill.isPaintserver() && SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style)) - && SP_PATTERN(SP_STYLE_FILL_SERVER(style)) == pat) + && SP_PATTERN(SP_STYLE_FILL_SERVER(style)) == this) { i ++; } if (style && style->stroke.isPaintserver() && SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style)) - && SP_PATTERN(SP_STYLE_STROKE_SERVER(style)) == pat) + && SP_PATTERN(SP_STYLE_STROKE_SERVER(style)) == this) { i ++; } for ( SPObject *child = o->firstChild(); child != NULL; child = child->next ) { - i += count_pattern_hrefs(child, pat); + i += _count_hrefs(child); } return i; } -SPPattern *pattern_chain(SPPattern *pattern) -{ - SPDocument *document = pattern->document; - Inkscape::XML::Document *xml_doc = document->getReprDoc(); +SPPattern *SPPattern::_chain() const { + Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); repr->setAttribute("inkscape:collect", "always"); - Glib::ustring parent_ref = Glib::ustring::compose("#%1", pattern->getRepr()->attribute("id")); + Glib::ustring parent_ref = Glib::ustring::compose("#%1", getRepr()->attribute("id")); repr->setAttribute("xlink:href", parent_ref); defsrepr->addChild(repr, NULL); @@ -366,11 +359,10 @@ SPPattern *pattern_chain(SPPattern *pattern) return SP_PATTERN (child); } -SPPattern * -sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *property) -{ - if (pattern->href.empty() || pattern->hrefcount > count_pattern_hrefs(item, pattern)) { - pattern = pattern_chain (pattern); +SPPattern *SPPattern::clone_if_necessary(SPItem *item, const gchar *property) { + SPPattern *pattern = this; + if (pattern->href.empty() || pattern->hrefcount > _count_hrefs(item)) { + pattern = _chain(); Glib::ustring href = Glib::ustring::compose("url(#%1)", pattern->getRepr()->attribute("id")); SPCSSAttr *css = sp_repr_css_attr_new (); @@ -381,23 +373,21 @@ sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const gchar *pr return pattern; } -void -sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set) -{ +void SPPattern::transform_multiply(Geom::Affine postmul, bool set) { // this formula is for a different interpretation of pattern transforms as described in (*) in sp-pattern.cpp // for it to work, we also need sp_object_read_attr( item, "transform"); //pattern->patternTransform = premul * item->transform * pattern->patternTransform * item->transform.inverse() * postmul; // otherwise the formula is much simpler if (set) { - pattern->patternTransform = postmul; + patternTransform = postmul; } else { - pattern->patternTransform = pattern->get_transform() * postmul; + patternTransform = get_transform() * postmul; } - pattern->patternTransform_set = true; + patternTransform_set = true; - Glib::ustring c=sp_svg_transform_write(pattern->patternTransform); - pattern->getRepr()->setAttribute("patternTransform", c); + Glib::ustring c=sp_svg_transform_write(patternTransform); + getRepr()->setAttribute("patternTransform", c); } const gchar *pattern_tile(const std::list &reprs, Geom::Rect bounds, @@ -436,14 +426,14 @@ const gchar *pattern_tile(const std::list &reprs, Geom::Re return pat_id; } -SPPattern *pattern_getroot(SPPattern *pat) +SPPattern *SPPattern::get_root() { - for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if ( pat_i->firstChild() ) { // find the first one with children return pat_i; } } - return pat; // document is broken, we can't get to root; but at least we can return pat which is supposedly a valid pattern + return this; // document is broken, we can't get to root; but at least we can return pat which is supposedly a valid pattern } -- cgit v1.2.3 From 85840ae655411c47248cd794a19dedd9ea3a591f Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Thu, 29 May 2014 12:04:56 +0200 Subject: SPPattern c++-sification: replaced function by methods pt3 (bzr r13341.6.22) --- src/sp-pattern.cpp | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index bd24ab1bb..82e3cdacf 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -19,7 +19,8 @@ #include #include #include <2geom/transforms.h> -#include "macros.h" +#include + #include "svg/svg.h" #include "display/cairo-utils.h" #include "display/drawing-context.h" @@ -32,16 +33,6 @@ #include "style.h" #include "sp-pattern.h" #include "xml/repr.h" -#include "display/grayscale.h" - -#include -#include - -/* - * Pattern - */ -static void pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat); -static void pattern_ref_modified (SPObject *ref, guint flags, SPPattern *pattern); #include "sp-factory.h" @@ -55,7 +46,7 @@ namespace { SPPattern::SPPattern() : SPPaintServer(), SPViewBox() { this->ref = new SPPatternReference(this); - this->ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(pattern_ref_changed), this)); + this->ref->changedSignal().connect(sigc::mem_fun(this, &SPPattern::_on_ref_changed)); this->patternUnits = UNITS_OBJECTBOUNDINGBOX; this->patternUnits_set = false; @@ -284,31 +275,21 @@ void SPPattern::modified(unsigned int flags) { } } -/** -Gets called when the pattern is reattached to another -*/ -static void -pattern_ref_changed(SPObject *old_ref, SPObject *ref, SPPattern *pat) -{ +void SPPattern::_on_ref_changed(SPObject *old_ref, SPObject *ref) { if (old_ref) { - pat->modified_connection.disconnect(); + modified_connection.disconnect(); } if (SP_IS_PATTERN (ref)) { - pat->modified_connection = ref->connectModified(sigc::bind<2>(sigc::ptr_fun(&pattern_ref_modified), pat)); + modified_connection = ref->connectModified(sigc::mem_fun(this, &SPPattern::_on_ref_modified)); } - pattern_ref_modified (ref, 0, pat); + _on_ref_modified(ref, 0); } -/** -Gets called when the referenced is changed -*/ -static void pattern_ref_modified (SPObject */*ref*/, guint /*flags*/, SPPattern *pattern) +void SPPattern::_on_ref_modified(SPObject */*ref*/, guint /*flags*/) { - if ( SP_IS_OBJECT(pattern) ) { - pattern->requestModified(SP_OBJECT_MODIFIED_FLAG); - } + requestModified(SP_OBJECT_MODIFIED_FLAG); // Conditional to avoid causing infinite loop if there's a cycle in the href chain. } @@ -390,7 +371,7 @@ void SPPattern::transform_multiply(Geom::Affine postmul, bool set) { getRepr()->setAttribute("patternTransform", c); } -const gchar *pattern_tile(const std::list &reprs, Geom::Rect bounds, +const gchar *SPPattern::produce(const std::list &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) { typedef std::list::const_iterator NodePtrIterator; -- cgit v1.2.3 From 35100d54d146fd0fcf702abca02311b0ef95152f Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Thu, 29 May 2014 12:35:19 +0200 Subject: SPPattern c++-sification: class fields are private (bzr r13341.6.23) --- src/sp-pattern.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index 82e3cdacf..c2835eadd 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -213,8 +213,8 @@ void SPPattern::set(unsigned int key, const gchar* value) { /* fixme: We need ::order_changed handler too (Lauris) */ -void pattern_getchildren(SPPattern *pat, std::list& l) -{ +void SPPattern::_get_children(std::list& l) { + SPPattern *pat = this; for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children for (SPObject *child = pat->firstChild() ; child ; child = child->getNext() ) { @@ -235,7 +235,7 @@ void SPPattern::update(SPCtx* ctx, unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; std::list l; - pattern_getchildren (this, l); + _get_children(l); for (SPObjectIterator it = l.begin(); it != l.end(); it++) { SPObject *child = *it; @@ -260,7 +260,7 @@ void SPPattern::modified(unsigned int flags) { flags &= SP_OBJECT_MODIFIED_CASCADE; std::list l; - pattern_getchildren (this, l); + _get_children(l); for (SPObjectIterator it = l.begin(); it != l.end(); it++) { SPObject *child = *it; -- cgit v1.2.3 From f92d08e05a6e8af396e9afda669e3f25d06ee7bf Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Thu, 29 May 2014 12:38:20 +0200 Subject: fixed possible bug SPPattern::_get_children (bzr r13341.6.24) --- src/sp-pattern.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index c2835eadd..18eb78a27 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -214,10 +214,9 @@ void SPPattern::set(unsigned int key, const gchar* value) { /* fixme: We need ::order_changed handler too (Lauris) */ void SPPattern::_get_children(std::list& l) { - SPPattern *pat = this; - for (SPPattern *pat_i = pat; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { + for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children - for (SPObject *child = pat->firstChild() ; child ; child = child->getNext() ) { + for (SPObject *child = pat_i->firstChild() ; child ; child = child->getNext() ) { l.push_back(child); } break; // do not go further up the chain if children are found -- cgit v1.2.3 From c1165a6e6713f62f6f6442f172d7b31eae51f264 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Sun, 3 May 2015 11:53:07 +0200 Subject: Reformatted SPPattern (bzr r14059.1.19) --- src/sp-pattern.cpp | 512 +++++++++++++++++++++++++++-------------------------- 1 file changed, 265 insertions(+), 247 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index c2ba23370..db2017351 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -5,7 +5,7 @@ * Lauris Kaplinski * bulia byak * Jon A. Cruz - * Abhishek Sharma + * Abhishek Sharma * * Copyright (C) 2002 Lauris Kaplinski * @@ -13,7 +13,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include "config.h" #endif #include @@ -37,47 +37,51 @@ #include "sp-factory.h" -SPPattern::SPPattern() : SPPaintServer(), SPViewBox() { - this->ref = new SPPatternReference(this); - this->ref->changedSignal().connect(sigc::mem_fun(this, &SPPattern::_on_ref_changed)); +SPPattern::SPPattern() + : SPPaintServer() + , SPViewBox() +{ + this->ref = new SPPatternReference(this); + this->ref->changedSignal().connect(sigc::mem_fun(this, &SPPattern::_on_ref_changed)); - this->patternUnits = UNITS_OBJECTBOUNDINGBOX; - this->patternUnits_set = false; + this->patternUnits = UNITS_OBJECTBOUNDINGBOX; + this->patternUnits_set = false; - this->patternContentUnits = UNITS_USERSPACEONUSE; - this->patternContentUnits_set = false; + this->patternContentUnits = UNITS_USERSPACEONUSE; + this->patternContentUnits_set = false; - this->patternTransform = Geom::identity(); - this->patternTransform_set = false; + this->patternTransform = Geom::identity(); + this->patternTransform_set = false; - this->x.unset(); - this->y.unset(); - this->width.unset(); - this->height.unset(); + this->x.unset(); + this->y.unset(); + this->width.unset(); + this->height.unset(); } -SPPattern::~SPPattern() { -} +SPPattern::~SPPattern() {} -void SPPattern::build(SPDocument* doc, Inkscape::XML::Node* repr) { - SPPaintServer::build(doc, repr); - - this->readAttr( "patternUnits" ); - this->readAttr( "patternContentUnits" ); - this->readAttr( "patternTransform" ); - this->readAttr( "x" ); - this->readAttr( "y" ); - this->readAttr( "width" ); - this->readAttr( "height" ); - this->readAttr( "viewBox" ); - this->readAttr( "preserveAspectRatio" ); - this->readAttr( "xlink:href" ); - - /* Register ourselves */ - doc->addResource("pattern", this); +void SPPattern::build(SPDocument *doc, Inkscape::XML::Node *repr) +{ + SPPaintServer::build(doc, repr); + + this->readAttr("patternUnits"); + this->readAttr("patternContentUnits"); + this->readAttr("patternTransform"); + this->readAttr("x"); + this->readAttr("y"); + this->readAttr("width"); + this->readAttr("height"); + this->readAttr("viewBox"); + this->readAttr("preserveAspectRatio"); + this->readAttr("xlink:href"); + + /* Register ourselves */ + doc->addResource("pattern", this); } -void SPPattern::release() { +void SPPattern::release() +{ if (this->document) { // Unregister ourselves this->document->removeResource("pattern", this); @@ -93,112 +97,121 @@ void SPPattern::release() { SPPaintServer::release(); } -void SPPattern::set(unsigned int key, const gchar* value) { - switch (key) { - case SP_ATTR_PATTERNUNITS: - if (value) { - if (!strcmp (value, "userSpaceOnUse")) { - this->patternUnits = UNITS_USERSPACEONUSE; - } else { - this->patternUnits = UNITS_OBJECTBOUNDINGBOX; - } - - this->patternUnits_set = true; - } else { - this->patternUnits_set = false; - } - - this->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - - case SP_ATTR_PATTERNCONTENTUNITS: - if (value) { - if (!strcmp (value, "userSpaceOnUse")) { - this->patternContentUnits = UNITS_USERSPACEONUSE; - } else { - this->patternContentUnits = UNITS_OBJECTBOUNDINGBOX; - } - - this->patternContentUnits_set = true; - } else { - this->patternContentUnits_set = false; - } - - this->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - - case SP_ATTR_PATTERNTRANSFORM: { - Geom::Affine t; - - if (value && sp_svg_transform_read (value, &t)) { - this->patternTransform = t; - this->patternTransform_set = true; - } else { - this->patternTransform = Geom::identity(); - this->patternTransform_set = false; - } - - this->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - } - case SP_ATTR_X: - this->x.readOrUnset(value); - this->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - - case SP_ATTR_Y: - this->y.readOrUnset(value); - this->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - - case SP_ATTR_WIDTH: - this->width.readOrUnset(value); - this->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - - case SP_ATTR_HEIGHT: - this->height.readOrUnset(value); - this->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - - case SP_ATTR_VIEWBOX: - set_viewBox( value ); +void SPPattern::set(unsigned int key, const gchar *value) +{ + switch (key) { + case SP_ATTR_PATTERNUNITS: + if (value) { + if (!strcmp(value, "userSpaceOnUse")) { + this->patternUnits = UNITS_USERSPACEONUSE; + } + else { + this->patternUnits = UNITS_OBJECTBOUNDINGBOX; + } + + this->patternUnits_set = true; + } + else { + this->patternUnits_set = false; + } + + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + + case SP_ATTR_PATTERNCONTENTUNITS: + if (value) { + if (!strcmp(value, "userSpaceOnUse")) { + this->patternContentUnits = UNITS_USERSPACEONUSE; + } + else { + this->patternContentUnits = UNITS_OBJECTBOUNDINGBOX; + } + + this->patternContentUnits_set = true; + } + else { + this->patternContentUnits_set = false; + } + + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + + case SP_ATTR_PATTERNTRANSFORM: { + Geom::Affine t; + + if (value && sp_svg_transform_read(value, &t)) { + this->patternTransform = t; + this->patternTransform_set = true; + } + else { + this->patternTransform = Geom::identity(); + this->patternTransform_set = false; + } + + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + } + case SP_ATTR_X: + this->x.readOrUnset(value); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + + case SP_ATTR_Y: + this->y.readOrUnset(value); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + + case SP_ATTR_WIDTH: + this->width.readOrUnset(value); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + + case SP_ATTR_HEIGHT: + this->height.readOrUnset(value); + this->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; + + case SP_ATTR_VIEWBOX: + set_viewBox(value); this->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; case SP_ATTR_PRESERVEASPECTRATIO: - set_preserveAspectRatio( value ); + set_preserveAspectRatio(value); this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG); break; - case SP_ATTR_XLINK_HREF: - if ( value && this->href == value ) { - /* Href unchanged, do nothing. */ - } else { - this->href.clear(); - - if (value) { - // First, set the href field; it's only used in the "unchanged" check above. - this->href = value; - // Now do the attaching, which emits the changed signal. - if (value) { - try { - this->ref->attach(Inkscape::URI(value)); - } catch (Inkscape::BadURIException &e) { - g_warning("%s", e.what()); - this->ref->detach(); - } - } else { - this->ref->detach(); - } - } - } - break; - - default: - SPPaintServer::set(key, value); - break; - } + case SP_ATTR_XLINK_HREF: + if (value && this->href == value) { + /* Href unchanged, do nothing. */ + } + else { + this->href.clear(); + + if (value) { + // First, set the href field; it's only used in the "unchanged" check above. + this->href = value; + // Now do the attaching, which emits the changed signal. + if (value) { + try { + this->ref->attach(Inkscape::URI(value)); + } + catch (Inkscape::BadURIException &e) { + g_warning("%s", e.what()); + this->ref->detach(); + } + } + else { + this->ref->detach(); + } + } + } + break; + + default: + SPPaintServer::set(key, value); + break; + } } @@ -206,82 +219,86 @@ void SPPattern::set(unsigned int key, const gchar* value) { /* fixme: We need ::order_changed handler too (Lauris) */ -void SPPattern::_get_children(std::list& l) { +void SPPattern::_get_children(std::list &l) +{ for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children - for (SPObject *child = pat_i->firstChild() ; child ; child = child->getNext() ) { - l.push_back(child); - } - break; // do not go further up the chain if children are found + for (SPObject *child = pat_i->firstChild(); child; child = child->getNext()) { + l.push_back(child); + } + break; // do not go further up the chain if children are found } } } -void SPPattern::update(SPCtx* ctx, unsigned int flags) { - typedef std::list::iterator SPObjectIterator; +void SPPattern::update(SPCtx *ctx, unsigned int flags) +{ + typedef std::list::iterator SPObjectIterator; if (flags & SP_OBJECT_MODIFIED_FLAG) { - flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; - } + flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; + } - flags &= SP_OBJECT_MODIFIED_CASCADE; + flags &= SP_OBJECT_MODIFIED_CASCADE; - std::list l; - _get_children(l); + std::list l; + _get_children(l); - for (SPObjectIterator it = l.begin(); it != l.end(); it++) { - SPObject *child = *it; + for (SPObjectIterator it = l.begin(); it != l.end(); it++) { + SPObject *child = *it; - sp_object_ref (child, NULL); + sp_object_ref(child, NULL); - if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { - child->updateDisplay(ctx, flags); - } + if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { + child->updateDisplay(ctx, flags); + } - sp_object_unref (child, NULL); - } + sp_object_unref(child, NULL); + } } -void SPPattern::modified(unsigned int flags) { - typedef std::list::iterator SPObjectIterator; +void SPPattern::modified(unsigned int flags) +{ + typedef std::list::iterator SPObjectIterator; - if (flags & SP_OBJECT_MODIFIED_FLAG) { - flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; - } + if (flags & SP_OBJECT_MODIFIED_FLAG) { + flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; + } - flags &= SP_OBJECT_MODIFIED_CASCADE; + flags &= SP_OBJECT_MODIFIED_CASCADE; - std::list l; - _get_children(l); + std::list l; + _get_children(l); - for (SPObjectIterator it = l.begin(); it != l.end(); it++) { - SPObject *child = *it; + for (SPObjectIterator it = l.begin(); it != l.end(); it++) { + SPObject *child = *it; - sp_object_ref (child, NULL); + sp_object_ref(child, NULL); - if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { - child->emitModified(flags); - } + if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { + child->emitModified(flags); + } - sp_object_unref (child, NULL); - } + sp_object_unref(child, NULL); + } } -void SPPattern::_on_ref_changed(SPObject *old_ref, SPObject *ref) { - if (old_ref) { - modified_connection.disconnect(); - } +void SPPattern::_on_ref_changed(SPObject *old_ref, SPObject *ref) +{ + if (old_ref) { + modified_connection.disconnect(); + } - if (SP_IS_PATTERN (ref)) { - modified_connection = ref->connectModified(sigc::mem_fun(this, &SPPattern::_on_ref_modified)); - } + if (SP_IS_PATTERN(ref)) { + modified_connection = ref->connectModified(sigc::mem_fun(this, &SPPattern::_on_ref_modified)); + } - _on_ref_modified(ref, 0); + _on_ref_modified(ref, 0); } -void SPPattern::_on_ref_modified(SPObject */*ref*/, guint /*flags*/) +void SPPattern::_on_ref_modified(SPObject * /*ref*/, guint /*flags*/) { - requestModified(SP_OBJECT_MODIFIED_FLAG); + requestModified(SP_OBJECT_MODIFIED_FLAG); // Conditional to avoid causing infinite loop if there's a cycle in the href chain. } @@ -293,80 +310,78 @@ guint SPPattern::_count_hrefs(SPObject *o) const guint i = 0; SPStyle *style = o->style; - if (style - && style->fill.isPaintserver() - && SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style)) - && SP_PATTERN(SP_STYLE_FILL_SERVER(style)) == this) - { - i ++; - } - if (style - && style->stroke.isPaintserver() - && SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style)) - && SP_PATTERN(SP_STYLE_STROKE_SERVER(style)) == this) - { - i ++; - } - - for ( SPObject *child = o->firstChild(); child != NULL; child = child->next ) { + if (style && style->fill.isPaintserver() && SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style)) && + SP_PATTERN(SP_STYLE_FILL_SERVER(style)) == this) { + i++; + } + if (style && style->stroke.isPaintserver() && SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style)) && + SP_PATTERN(SP_STYLE_STROKE_SERVER(style)) == this) { + i++; + } + + for (SPObject *child = o->firstChild(); child != NULL; child = child->next) { i += _count_hrefs(child); } return i; } -SPPattern *SPPattern::_chain() const { +SPPattern *SPPattern::_chain() const +{ Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); Inkscape::XML::Node *repr = xml_doc->createElement("svg:pattern"); repr->setAttribute("inkscape:collect", "always"); Glib::ustring parent_ref = Glib::ustring::compose("#%1", getRepr()->attribute("id")); - repr->setAttribute("xlink:href", parent_ref); + repr->setAttribute("xlink:href", parent_ref); defsrepr->addChild(repr, NULL); const gchar *child_id = repr->attribute("id"); SPObject *child = document->getObjectById(child_id); - g_assert (SP_IS_PATTERN (child)); + g_assert(SP_IS_PATTERN(child)); - return SP_PATTERN (child); + return SP_PATTERN(child); } -SPPattern *SPPattern::clone_if_necessary(SPItem *item, const gchar *property) { +SPPattern *SPPattern::clone_if_necessary(SPItem *item, const gchar *property) +{ SPPattern *pattern = this; if (pattern->href.empty() || pattern->hrefcount > _count_hrefs(item)) { pattern = _chain(); Glib::ustring href = Glib::ustring::compose("url(#%1)", pattern->getRepr()->attribute("id")); - SPCSSAttr *css = sp_repr_css_attr_new (); - sp_repr_css_set_property (css, property, href.c_str()); + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_set_property(css, property, href.c_str()); sp_repr_css_change_recursive(item->getRepr(), css, "style"); - } return pattern; } -void SPPattern::transform_multiply(Geom::Affine postmul, bool set) { +void SPPattern::transform_multiply(Geom::Affine postmul, bool set) +{ // this formula is for a different interpretation of pattern transforms as described in (*) in sp-pattern.cpp // for it to work, we also need sp_object_read_attr( item, "transform"); - //pattern->patternTransform = premul * item->transform * pattern->patternTransform * item->transform.inverse() * postmul; + // pattern->patternTransform = premul * item->transform * pattern->patternTransform * item->transform.inverse() * + // postmul; // otherwise the formula is much simpler if (set) { patternTransform = postmul; - } else { + } + else { patternTransform = get_transform() * postmul; } patternTransform_set = true; - Glib::ustring c=sp_svg_transform_write(patternTransform); + Glib::ustring c = sp_svg_transform_write(patternTransform); getRepr()->setAttribute("patternTransform", c); } -const gchar *SPPattern::produce(const std::vector &reprs, Geom::Rect bounds, - SPDocument *document, Geom::Affine transform, Geom::Affine move) +const gchar *SPPattern::produce(const std::vector &reprs, Geom::Rect bounds, + SPDocument *document, Geom::Affine transform, Geom::Affine move) { - typedef std::vector::const_iterator NodePtrIterator; + typedef std::vector::const_iterator NodePtrIterator; Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); @@ -376,7 +391,7 @@ const gchar *SPPattern::produce(const std::vector &reprs, sp_repr_set_svg_double(repr, "width", bounds.dimensions()[Geom::X]); sp_repr_set_svg_double(repr, "height", bounds.dimensions()[Geom::Y]); - Glib::ustring t=sp_svg_transform_write(transform); + Glib::ustring t = sp_svg_transform_write(transform); repr->setAttribute("patternTransform", t); defsrepr->appendChild(repr); @@ -388,7 +403,7 @@ const gchar *SPPattern::produce(const std::vector &reprs, SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); Geom::Affine dup_transform; - if (!sp_svg_transform_read (node->attribute("transform"), &dup_transform)) + if (!sp_svg_transform_read(node->attribute("transform"), &dup_transform)) dup_transform = Geom::identity(); dup_transform *= move; @@ -402,11 +417,12 @@ const gchar *SPPattern::produce(const std::vector &reprs, SPPattern *SPPattern::get_root() { for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if ( pat_i->firstChild() ) { // find the first one with children + if (pat_i->firstChild()) { // find the first one with children return pat_i; } } - return this; // document is broken, we can't get to root; but at least we can return pat which is supposedly a valid pattern + return this; // document is broken, we can't get to root; but at least we can return pat which is supposedly a valid + // pattern } @@ -492,7 +508,7 @@ Geom::OptRect SPPattern::get_viewbox() const bool SPPattern::_has_item_children() const { bool hasChildren = false; - for (SPObject const *child = firstChild() ; child && !hasChildren ; child = child->getNext() ) { + for (SPObject const *child = firstChild(); child && !hasChildren; child = child->getNext()) { if (SP_IS_ITEM(child)) { hasChildren = true; } @@ -502,15 +518,16 @@ bool SPPattern::_has_item_children() const bool SPPattern::isValid() const { - double tile_width = get_width(); - double tile_height = get_height(); + double tile_width = get_width(); + double tile_height = get_height(); - if (tile_width <= 0 || tile_height <= 0) - return false; - return true; + if (tile_width <= 0 || tile_height <= 0) + return false; + return true; } -cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &bbox, double opacity) { +cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &bbox, double opacity) +{ bool needs_opacity = (1.0 - opacity) >= 1e-3; bool visible = opacity >= 1e-3; @@ -531,21 +548,21 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b } if (!shown) { - return cairo_pattern_create_rgba(0,0,0,0); + return cairo_pattern_create_rgba(0, 0, 0, 0); } /* Create drawing for rendering */ Inkscape::Drawing drawing; - unsigned int dkey = SPItem::display_key_new (1); + unsigned int dkey = SPItem::display_key_new(1); Inkscape::DrawingGroup *root = new Inkscape::DrawingGroup(drawing); drawing.setRoot(root); - for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext() ) { - if (SP_IS_ITEM (child)) { + for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) { + if (SP_IS_ITEM(child)) { // for each item in pattern, show it on our drawing, add to the group, // and connect to the release signal in case the item gets deleted Inkscape::DrawingItem *cai; - cai = SP_ITEM(child)->invoke_show (drawing, dkey, SP_ITEM_SHOW_DISPLAY); + cai = SP_ITEM(child)->invoke_show(drawing, dkey, SP_ITEM_SHOW_DISPLAY); root->appendChild(cai); } } @@ -558,40 +575,41 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // * "x", "y", and "patternTransform" transform tile to user space after tile is generated. // These functions recursively search up the tree to find the values. - double tile_x = get_x(); - double tile_y = get_y(); - double tile_width = get_width(); + double tile_x = get_x(); + double tile_y = get_y(); + double tile_width = get_width(); double tile_height = get_height(); - if ( bbox && (get_pattern_units() == UNITS_OBJECTBOUNDINGBOX) ) { - tile_x *= bbox->width(); - tile_y *= bbox->height(); - tile_width *= bbox->width(); + if (bbox && (get_pattern_units() == UNITS_OBJECTBOUNDINGBOX)) { + tile_x *= bbox->width(); + tile_y *= bbox->height(); + tile_width *= bbox->width(); tile_height *= bbox->height(); } // Pattern size in pattern space Geom::Rect pattern_tile = Geom::Rect::from_xywh(0, 0, tile_width, tile_height); - + // Content to tile (pattern space) Geom::Affine content2ps; Geom::OptRect effective_view_box = get_viewbox(); if (effective_view_box) { - // viewBox to pattern server (using SPViewBox) + // viewBox to pattern server (using SPViewBox) viewBox = *effective_view_box; c2p.setIdentity(); - apply_viewbox( pattern_tile ); + apply_viewbox(pattern_tile); content2ps = c2p; - } else { + } + else { // Content to bbox - if (bbox && (get_pattern_content_units() == UNITS_OBJECTBOUNDINGBOX) ) { - content2ps = Geom::Affine(bbox->width(), 0.0, 0.0, bbox->height(), 0,0); + if (bbox && (get_pattern_content_units() == UNITS_OBJECTBOUNDINGBOX)) { + content2ps = Geom::Affine(bbox->width(), 0.0, 0.0, bbox->height(), 0, 0); } } // Tile (pattern space) to user. - Geom::Affine ps2user = Geom::Translate(tile_x,tile_y) * get_transform(); + Geom::Affine ps2user = Geom::Translate(tile_x, tile_y) * get_transform(); // Transform of object with pattern (includes screen scaling) @@ -611,7 +629,7 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // to find the optimum tile size for rendering // c is number of pixels in buffer x and y. // Scale factor of 1.1 is too small... see bug #1251039 - Geom::Point c(pattern_tile.dimensions()*ps2user.descrim()*full.descrim()*2.0); + Geom::Point c(pattern_tile.dimensions() * ps2user.descrim() * full.descrim() * 2.0); // Create drawing surface with size of pattern tile (in pattern space) but with number of pixels // based on required resolution (c). @@ -627,16 +645,16 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b } // TODO: make sure there are no leaks. - Inkscape::UpdateContext ctx; // UpdateContext is structure with only ctm! + Inkscape::UpdateContext ctx; // UpdateContext is structure with only ctm! ctx.ctm = content2ps * pattern_surface.drawingTransform(); - dc.transform( pattern_surface.drawingTransform().inverse() ); + dc.transform(pattern_surface.drawingTransform().inverse()); drawing.update(Geom::IntRect::infinite(), ctx); // Render drawing to pattern_surface via drawing context, this calls root->render // which is really DrawingItem->render(). drawing.render(dc, one_tile); - for (SPObject *child = shown->firstChild() ; child != NULL; child = child->getNext() ) { - if (SP_IS_ITEM (child)) { + for (SPObject *child = shown->firstChild(); child != NULL; child = child->getNext()) { + if (SP_IS_ITEM(child)) { SP_ITEM(child)->invoke_hide(dkey); } } @@ -652,12 +670,12 @@ cairo_pattern_t* SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b if (needs_opacity) { dc.popGroupToSource(); // pop raw pattern - dc.paint(opacity); // apply opacity + dc.paint(opacity); // apply opacity } cairo_pattern_t *cp = cairo_pattern_create_for_surface(pattern_surface.raw()); // Apply transformation to user space. Also compensate for oversampling. - ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * pattern_surface.drawingTransform() ); + ink_cairo_pattern_set_matrix(cp, ps2user.inverse() * pattern_surface.drawingTransform()); cairo_pattern_set_extend(cp, CAIRO_EXTEND_REPEAT); -- cgit v1.2.3 From 705243e1266aec7527ae76065213ca7536ed7c41 Mon Sep 17 00:00:00 2001 From: Tomasz Boczkowski Date: Sun, 3 May 2015 12:37:06 +0200 Subject: renamed SPPattern methods to match coding style (bzr r14059.1.20) --- src/sp-pattern.cpp | 162 ++++++++++++++++++++++++++--------------------------- 1 file changed, 81 insertions(+), 81 deletions(-) (limited to 'src/sp-pattern.cpp') diff --git a/src/sp-pattern.cpp b/src/sp-pattern.cpp index db2017351..755d3d162 100644 --- a/src/sp-pattern.cpp +++ b/src/sp-pattern.cpp @@ -42,21 +42,21 @@ SPPattern::SPPattern() , SPViewBox() { this->ref = new SPPatternReference(this); - this->ref->changedSignal().connect(sigc::mem_fun(this, &SPPattern::_on_ref_changed)); + this->ref->changedSignal().connect(sigc::mem_fun(this, &SPPattern::_onRefChanged)); - this->patternUnits = UNITS_OBJECTBOUNDINGBOX; - this->patternUnits_set = false; + this->_pattern_units = UNITS_OBJECTBOUNDINGBOX; + this->_pattern_units_set = false; - this->patternContentUnits = UNITS_USERSPACEONUSE; - this->patternContentUnits_set = false; + this->_pattern_content_units = UNITS_USERSPACEONUSE; + this->_pattern_content_units_set = false; - this->patternTransform = Geom::identity(); - this->patternTransform_set = false; + this->_pattern_transform = Geom::identity(); + this->_pattern_transform_set = false; - this->x.unset(); - this->y.unset(); - this->width.unset(); - this->height.unset(); + this->_x.unset(); + this->_y.unset(); + this->_width.unset(); + this->_height.unset(); } SPPattern::~SPPattern() {} @@ -88,7 +88,7 @@ void SPPattern::release() } if (this->ref) { - this->modified_connection.disconnect(); + this->_modified_connection.disconnect(); this->ref->detach(); delete this->ref; this->ref = NULL; @@ -103,16 +103,16 @@ void SPPattern::set(unsigned int key, const gchar *value) case SP_ATTR_PATTERNUNITS: if (value) { if (!strcmp(value, "userSpaceOnUse")) { - this->patternUnits = UNITS_USERSPACEONUSE; + this->_pattern_units = UNITS_USERSPACEONUSE; } else { - this->patternUnits = UNITS_OBJECTBOUNDINGBOX; + this->_pattern_units = UNITS_OBJECTBOUNDINGBOX; } - this->patternUnits_set = true; + this->_pattern_units_set = true; } else { - this->patternUnits_set = false; + this->_pattern_units_set = false; } this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -121,16 +121,16 @@ void SPPattern::set(unsigned int key, const gchar *value) case SP_ATTR_PATTERNCONTENTUNITS: if (value) { if (!strcmp(value, "userSpaceOnUse")) { - this->patternContentUnits = UNITS_USERSPACEONUSE; + this->_pattern_content_units = UNITS_USERSPACEONUSE; } else { - this->patternContentUnits = UNITS_OBJECTBOUNDINGBOX; + this->_pattern_content_units = UNITS_OBJECTBOUNDINGBOX; } - this->patternContentUnits_set = true; + this->_pattern_content_units_set = true; } else { - this->patternContentUnits_set = false; + this->_pattern_content_units_set = false; } this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -140,34 +140,34 @@ void SPPattern::set(unsigned int key, const gchar *value) Geom::Affine t; if (value && sp_svg_transform_read(value, &t)) { - this->patternTransform = t; - this->patternTransform_set = true; + this->_pattern_transform = t; + this->_pattern_transform_set = true; } else { - this->patternTransform = Geom::identity(); - this->patternTransform_set = false; + this->_pattern_transform = Geom::identity(); + this->_pattern_transform_set = false; } this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; } case SP_ATTR_X: - this->x.readOrUnset(value); + this->_x.readOrUnset(value); this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_Y: - this->y.readOrUnset(value); + this->_y.readOrUnset(value); this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_WIDTH: - this->width.readOrUnset(value); + this->_width.readOrUnset(value); this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_HEIGHT: - this->height.readOrUnset(value); + this->_height.readOrUnset(value); this->requestModified(SP_OBJECT_MODIFIED_FLAG); break; @@ -219,7 +219,7 @@ void SPPattern::set(unsigned int key, const gchar *value) /* fixme: We need ::order_changed handler too (Lauris) */ -void SPPattern::_get_children(std::list &l) +void SPPattern::_getChildren(std::list &l) { for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children @@ -242,7 +242,7 @@ void SPPattern::update(SPCtx *ctx, unsigned int flags) flags &= SP_OBJECT_MODIFIED_CASCADE; std::list l; - _get_children(l); + _getChildren(l); for (SPObjectIterator it = l.begin(); it != l.end(); it++) { SPObject *child = *it; @@ -268,7 +268,7 @@ void SPPattern::modified(unsigned int flags) flags &= SP_OBJECT_MODIFIED_CASCADE; std::list l; - _get_children(l); + _getChildren(l); for (SPObjectIterator it = l.begin(); it != l.end(); it++) { SPObject *child = *it; @@ -283,26 +283,26 @@ void SPPattern::modified(unsigned int flags) } } -void SPPattern::_on_ref_changed(SPObject *old_ref, SPObject *ref) +void SPPattern::_onRefChanged(SPObject *old_ref, SPObject *ref) { if (old_ref) { - modified_connection.disconnect(); + _modified_connection.disconnect(); } if (SP_IS_PATTERN(ref)) { - modified_connection = ref->connectModified(sigc::mem_fun(this, &SPPattern::_on_ref_modified)); + _modified_connection = ref->connectModified(sigc::mem_fun(this, &SPPattern::_onRefModified)); } - _on_ref_modified(ref, 0); + _onRefModified(ref, 0); } -void SPPattern::_on_ref_modified(SPObject * /*ref*/, guint /*flags*/) +void SPPattern::_onRefModified(SPObject * /*ref*/, guint /*flags*/) { requestModified(SP_OBJECT_MODIFIED_FLAG); // Conditional to avoid causing infinite loop if there's a cycle in the href chain. } -guint SPPattern::_count_hrefs(SPObject *o) const +guint SPPattern::_countHrefs(SPObject *o) const { if (!o) return 1; @@ -320,7 +320,7 @@ guint SPPattern::_count_hrefs(SPObject *o) const } for (SPObject *child = o->firstChild(); child != NULL; child = child->next) { - i += _count_hrefs(child); + i += _countHrefs(child); } return i; @@ -347,7 +347,7 @@ SPPattern *SPPattern::_chain() const SPPattern *SPPattern::clone_if_necessary(SPItem *item, const gchar *property) { SPPattern *pattern = this; - if (pattern->href.empty() || pattern->hrefcount > _count_hrefs(item)) { + if (pattern->href.empty() || pattern->hrefcount > _countHrefs(item)) { pattern = _chain(); Glib::ustring href = Glib::ustring::compose("url(#%1)", pattern->getRepr()->attribute("id")); @@ -367,14 +367,14 @@ void SPPattern::transform_multiply(Geom::Affine postmul, bool set) // otherwise the formula is much simpler if (set) { - patternTransform = postmul; + _pattern_transform = postmul; } else { - patternTransform = get_transform() * postmul; + _pattern_transform = getTransform() * postmul; } - patternTransform_set = true; + _pattern_transform_set = true; - Glib::ustring c = sp_svg_transform_write(patternTransform); + Glib::ustring c = sp_svg_transform_write(_pattern_transform); getRepr()->setAttribute("patternTransform", c); } @@ -414,7 +414,7 @@ const gchar *SPPattern::produce(const std::vector &reprs, return pat_id; } -SPPattern *SPPattern::get_root() +SPPattern *SPPattern::rootPattern() { for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { if (pat_i->firstChild()) { // find the first one with children @@ -430,70 +430,70 @@ SPPattern *SPPattern::get_root() // Access functions that look up fields up the chain of referenced patterns and return the first one which is set // FIXME: all of them must use chase_hrefs the same as in SPGradient, to avoid lockup on circular refs -SPPattern::PatternUnits SPPattern::get_pattern_units() const +SPPattern::PatternUnits SPPattern::patternUnits() const { for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i->patternUnits_set) - return pat_i->patternUnits; + if (pat_i->_pattern_units_set) + return pat_i->_pattern_units; } - return patternUnits; + return _pattern_units; } -SPPattern::PatternUnits SPPattern::get_pattern_content_units() const +SPPattern::PatternUnits SPPattern::patternContentUnits() const { for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i->patternContentUnits_set) - return pat_i->patternContentUnits; + if (pat_i->_pattern_content_units_set) + return pat_i->_pattern_content_units; } - return patternContentUnits; + return _pattern_content_units; } -Geom::Affine const &SPPattern::get_transform() const +Geom::Affine const &SPPattern::getTransform() const { for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i->patternTransform_set) - return pat_i->patternTransform; + if (pat_i->_pattern_transform_set) + return pat_i->_pattern_transform; } - return patternTransform; + return _pattern_transform; } -gdouble SPPattern::get_x() const +gdouble SPPattern::x() const { for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i->x._set) - return pat_i->x.computed; + if (pat_i->_x._set) + return pat_i->_x.computed; } return 0; } -gdouble SPPattern::get_y() const +gdouble SPPattern::y() const { for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i->y._set) - return pat_i->y.computed; + if (pat_i->_y._set) + return pat_i->_y.computed; } return 0; } -gdouble SPPattern::get_width() const +gdouble SPPattern::width() const { for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i->width._set) - return pat_i->width.computed; + if (pat_i->_width._set) + return pat_i->_width.computed; } return 0; } -gdouble SPPattern::get_height() const +gdouble SPPattern::height() const { for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { - if (pat_i->height._set) - return pat_i->height.computed; + if (pat_i->_height._set) + return pat_i->_height.computed; } return 0; } -Geom::OptRect SPPattern::get_viewbox() const +Geom::OptRect SPPattern::viewbox() const { Geom::OptRect viewbox; for (SPPattern const *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { @@ -505,7 +505,7 @@ Geom::OptRect SPPattern::get_viewbox() const return viewbox; } -bool SPPattern::_has_item_children() const +bool SPPattern::_hasItemChildren() const { bool hasChildren = false; for (SPObject const *child = firstChild(); child && !hasChildren; child = child->getNext()) { @@ -518,8 +518,8 @@ bool SPPattern::_has_item_children() const bool SPPattern::isValid() const { - double tile_width = get_width(); - double tile_height = get_height(); + double tile_width = width(); + double tile_height = height(); if (tile_width <= 0 || tile_height <= 0) return false; @@ -541,7 +541,7 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b for (SPPattern *pat_i = this; pat_i != NULL; pat_i = pat_i->ref ? pat_i->ref->getObject() : NULL) { // find the first one with item children - if (pat_i && SP_IS_OBJECT(pat_i) && pat_i->_has_item_children()) { + if (pat_i && SP_IS_OBJECT(pat_i) && pat_i->_hasItemChildren()) { shown = pat_i; break; // do not go further up the chain if children are found } @@ -575,11 +575,11 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // * "x", "y", and "patternTransform" transform tile to user space after tile is generated. // These functions recursively search up the tree to find the values. - double tile_x = get_x(); - double tile_y = get_y(); - double tile_width = get_width(); - double tile_height = get_height(); - if (bbox && (get_pattern_units() == UNITS_OBJECTBOUNDINGBOX)) { + double tile_x = x(); + double tile_y = y(); + double tile_width = width(); + double tile_height = height(); + if (bbox && (patternUnits() == UNITS_OBJECTBOUNDINGBOX)) { tile_x *= bbox->width(); tile_y *= bbox->height(); tile_width *= bbox->width(); @@ -591,7 +591,7 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b // Content to tile (pattern space) Geom::Affine content2ps; - Geom::OptRect effective_view_box = get_viewbox(); + Geom::OptRect effective_view_box = viewbox(); if (effective_view_box) { // viewBox to pattern server (using SPViewBox) viewBox = *effective_view_box; @@ -602,14 +602,14 @@ cairo_pattern_t *SPPattern::pattern_new(cairo_t *base_ct, Geom::OptRect const &b else { // Content to bbox - if (bbox && (get_pattern_content_units() == UNITS_OBJECTBOUNDINGBOX)) { + if (bbox && (patternContentUnits() == UNITS_OBJECTBOUNDINGBOX)) { content2ps = Geom::Affine(bbox->width(), 0.0, 0.0, bbox->height(), 0, 0); } } // Tile (pattern space) to user. - Geom::Affine ps2user = Geom::Translate(tile_x, tile_y) * get_transform(); + Geom::Affine ps2user = Geom::Translate(tile_x, tile_y) * getTransform(); // Transform of object with pattern (includes screen scaling) -- cgit v1.2.3