diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/internal/bitmap/crop.cpp | 4 | ||||
| -rw-r--r-- | src/graphlayout.cpp | 4 | ||||
| -rw-r--r-- | src/object/sp-item-group.cpp | 2 | ||||
| -rw-r--r-- | src/object/sp-item-transform.cpp | 35 | ||||
| -rw-r--r-- | src/object/sp-item-transform.h | 4 | ||||
| -rw-r--r-- | src/object/sp-item.cpp | 36 | ||||
| -rw-r--r-- | src/object/sp-item.h | 3 | ||||
| -rw-r--r-- | src/removeoverlap.cpp | 2 | ||||
| -rw-r--r-- | src/ui/clipboard.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/align-and-distribute.cpp | 14 | ||||
| -rw-r--r-- | src/ui/dialog/polar-arrange-tab.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/transformation.cpp | 10 | ||||
| -rw-r--r-- | src/ui/tools/spray-tool.cpp | 6 | ||||
| -rw-r--r-- | src/ui/tools/tweak-tool.cpp | 300 |
14 files changed, 212 insertions, 212 deletions
diff --git a/src/extension/internal/bitmap/crop.cpp b/src/extension/internal/bitmap/crop.cpp index b83e7d882..69e23c770 100644 --- a/src/extension/internal/bitmap/crop.cpp +++ b/src/extension/internal/bitmap/crop.cpp @@ -38,7 +38,7 @@ Crop::postEffect(Magick::Image *image, SPItem *item) { Geom::Scale scale (0,0); scale = Geom::Scale(image->columns() / (double) image->baseColumns(), image->rows() / (double) image->baseRows()); - sp_item_scale_rel (item, scale); + item->scale_rel(scale); // Translate proportionaly to the image/bbox ratio Geom::OptRect bbox(item->desktopGeometricBounds()); @@ -47,7 +47,7 @@ Crop::postEffect(Magick::Image *image, SPItem *item) { Geom::Translate translate (0,0); translate = Geom::Translate(((_left - _right) / 2.0) * (bbox->dimensions()[Geom::X] / (double) image->columns()), ((_bottom - _top) / 2.0) * (bbox->dimensions()[Geom::Y] / (double) image->rows())); - sp_item_move_rel(item, translate); + item->move_rel(translate); } void diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp index 4c244489c..b04e5f703 100644 --- a/src/graphlayout.cpp +++ b/src/graphlayout.cpp @@ -76,7 +76,7 @@ struct CheckProgress: TestConvergence { Geom::Rect const item_box(sp_item_bbox_desktop(u)); Geom::Point const curr(item_box.midpoint()); Geom::Point const dest(r->getCentreX(),r->getCentreY()); - sp_item_move_rel(u, Geom::Translate(dest - curr)); + u->move_rel(Geom::Translate(dest - curr)); } } */ @@ -210,7 +210,7 @@ void graphlayout(std::vector<SPItem*> const & items) { if (item_box) { Geom::Point const curr(item_box->midpoint()); Geom::Point const dest(r->getCentreX(),r->getCentreY()); - sp_item_move_rel(item, Geom::Translate(dest - curr)); + item->move_rel(Geom::Translate(dest - curr)); } } } diff --git a/src/object/sp-item-group.cpp b/src/object/sp-item-group.cpp index acc08d175..981308b0e 100644 --- a/src/object/sp-item-group.cpp +++ b/src/object/sp-item-group.cpp @@ -733,7 +733,7 @@ void SPGroup::translateChildItems(Geom::Translate const &tr) for (auto& o: children) { SPItem *item = dynamic_cast<SPItem *>(&o); if ( item ) { - sp_item_move_rel(item, tr); + item->move_rel(tr); } } } diff --git a/src/object/sp-item-transform.cpp b/src/object/sp-item-transform.cpp index 4fbe0bcc5..e01571ef4 100644 --- a/src/object/sp-item-transform.cpp +++ b/src/object/sp-item-transform.cpp @@ -21,41 +21,6 @@ #include <glib.h> -void sp_item_scale_rel(SPItem *item, Geom::Scale const &scale) -{ - Geom::OptRect bbox = item->desktopVisualBounds(); - if (bbox) { - Geom::Translate const s(bbox->midpoint()); // use getCenter? - item->set_i2d_affine(item->i2dt_affine() * s.inverse() * scale * s); - item->doWriteTransform(item->transform); - } -} - -void sp_item_skew_rel(SPItem *item, double skewX, double skewY) -{ - Geom::Point center = item->getCenter(); - Geom::Translate const s(item->getCenter()); - - Geom::Affine const skew(1, skewY, skewX, 1, 0, 0); - Geom::Affine affine = Geom::Affine(s).inverse() * skew * Geom::Affine(s); - - item->set_i2d_affine(item->i2dt_affine() * affine); - item->doWriteTransform(item->transform); - - // Restore the center position (it's changed because the bbox center changed) - if (item->isCenterSet()) { - item->setCenter(center * affine); - item->updateRepr(); - } -} - -void sp_item_move_rel(SPItem *item, Geom::Translate const &tr) -{ - item->set_i2d_affine(item->i2dt_affine() * tr); - - item->doWriteTransform(item->transform); -} - /** * Calculate the affine transformation required to transform one visual bounding box into another, accounting for a uniform strokewidth. * diff --git a/src/object/sp-item-transform.h b/src/object/sp-item-transform.h index 02c8362dd..4c7401409 100644 --- a/src/object/sp-item-transform.h +++ b/src/object/sp-item-transform.h @@ -14,10 +14,6 @@ class SPItem; -void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale); -void sp_item_skew_rel (SPItem *item, double skewX, double skewY); -void sp_item_move_rel(SPItem *item, Geom::Translate const &tr); - Geom::Affine get_scale_transform_for_uniform_stroke (Geom::Rect const &bbox_visual, double stroke_x, double stroke_y, bool transform_stroke, bool preserve, double x0, double y0, double x1, double y1); Geom::Affine get_scale_transform_for_variable_stroke (Geom::Rect const &bbox_visual, Geom::Rect const &bbox_geom, bool transform_stroke, bool preserve, double x0, double y0, double x1, double y1); Geom::Rect get_visual_bbox (Geom::OptRect const &initial_geom_bbox, Geom::Affine const &abs_affine, double const initial_strokewidth, bool const transform_stroke); diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp index ee54c8ada..7d8ab4b50 100644 --- a/src/object/sp-item.cpp +++ b/src/object/sp-item.cpp @@ -1733,6 +1733,42 @@ void SPItem::rotate_rel(Geom::Rotate const &rotation) updateRepr(); } } + +void SPItem::scale_rel(Geom::Scale const &scale) +{ + Geom::OptRect bbox = desktopVisualBounds(); + if (bbox) { + Geom::Translate const s(bbox->midpoint()); // use getCenter? + set_i2d_affine(i2dt_affine() * s.inverse() * scale * s); + doWriteTransform(transform); + } +} + +void SPItem::skew_rel(double skewX, double skewY) +{ + Geom::Point center = getCenter(); + Geom::Translate const s(getCenter()); + + Geom::Affine const skew(1, skewY, skewX, 1, 0, 0); + Geom::Affine affine = Geom::Affine(s).inverse() * skew * Geom::Affine(s); + + set_i2d_affine(i2dt_affine() * affine); + doWriteTransform(transform); + + // Restore the center position (it's changed because the bbox center changed) + if (isCenterSet()) { + setCenter(center * affine); + updateRepr(); + } +} + +void SPItem::move_rel( Geom::Translate const &tr) +{ + set_i2d_affine(i2dt_affine() * tr); + + doWriteTransform(transform); +} + /* Local Variables: mode:c++ diff --git a/src/object/sp-item.h b/src/object/sp-item.h index 4ff3ca460..8a4eb7e78 100644 --- a/src/object/sp-item.h +++ b/src/object/sp-item.h @@ -396,6 +396,9 @@ private: public: void rotate_rel(Geom::Rotate const &rotation); + void scale_rel(Geom::Scale const &scale); + void skew_rel(double skewX, double skewY); + void move_rel( Geom::Translate const &tr); void build(SPDocument *document, Inkscape::XML::Node *repr) override; void release() override; void set(SPAttributeEnum key, char const* value) override; diff --git a/src/removeoverlap.cpp b/src/removeoverlap.cpp index b9e13bfa4..8b3064bd9 100644 --- a/src/removeoverlap.cpp +++ b/src/removeoverlap.cpp @@ -79,7 +79,7 @@ void removeoverlap(std::vector<SPItem*> const & items, double const xGap, double for (Record & rec: records) { Geom::Point const curr = rec.midpoint; Geom::Point const dest(rec.vspc_rect->getCentreX(), rec.vspc_rect->getCentreY()); - sp_item_move_rel(rec.item, Geom::Translate(dest - curr)); + rec.item->move_rel(Geom::Translate(dest - curr)); delete rec.vspc_rect; } } diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 7460822c9..b9b4ce605 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -521,7 +521,7 @@ bool ClipboardManagerImpl::pasteSize(ObjectSet *set, bool separately, bool apply if (item) { Geom::OptRect obj_size = item->desktopVisualBounds(); if ( obj_size ) { - sp_item_scale_rel(item, _getScale(set->desktop(), min, max, *obj_size, apply_x, apply_y)); + item->scale_rel(_getScale(set->desktop(), min, max, *obj_size, apply_x, apply_y)); } } else { g_assert_not_reached(); diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index a714b96f6..135584932 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -201,7 +201,7 @@ void ActionAlign::do_action(SPDesktop *desktop, int index) a.sy0 * b->min()[Geom::Y] + a.sy1 * b->max()[Geom::Y]); Geom::Point const mp_rel( mp - sp ); if (LInfty(mp_rel) > 1e-9) { - sp_item_move_rel(item, Geom::Translate(mp_rel)); + item->move_rel(Geom::Translate(mp_rel)); changed = true; } } @@ -359,7 +359,7 @@ private : if (!Geom::are_near(pos, it->bbox.min()[_orientation], 1e-6)) { Geom::Point t(0.0, 0.0); t[_orientation] = pos - it->bbox.min()[_orientation]; - sp_item_move_rel(it->item, Geom::Translate(t)); + it->item->move_rel(Geom::Translate(t)); changed = true; } pos += it->bbox[_orientation].extent(); @@ -384,7 +384,7 @@ private : Geom::Point t(0.0, 0.0); t[_orientation] = pos - it.anchor; //translate - sp_item_move_rel(it.item, Geom::Translate(t)); + it.item->move_rel(Geom::Translate(t)); changed = true; } } @@ -626,7 +626,7 @@ private : { Geom::Point p2 = item->getCenter(); Geom::Point delta = p1 - p2; - sp_item_move_rel(item,Geom::Translate(delta[Geom::X],delta[Geom::Y] )); + item->move_rel(Geom::Translate(delta[Geom::X],delta[Geom::Y] )); p1 = p2; } @@ -729,7 +729,7 @@ private : g_random_double_range (0, (*_dialog.randomize_bbox)[Geom::Y].extent() - (*item_box)[Geom::Y].extent()); // displacement is the new center minus old: Geom::Point t = Geom::Point (x, y) - 0.5*(item_box->max() + item_box->min()); - sp_item_move_rel(item, Geom::Translate(t)); + item->move_rel(Geom::Translate(t)); } } @@ -825,7 +825,7 @@ private : Geom::Point base = sorted[i]._base; Geom::Point t(0.0, 0.0); t[_orientation] = b_min[_orientation] + step * i - base[_orientation]; - sp_item_move_rel(item, Geom::Translate(t)); + item->move_rel(Geom::Translate(t)); changed = true; } @@ -888,7 +888,7 @@ private : Geom::Point base = *pt * (item)->i2dt_affine(); Geom::Point t(0.0, 0.0); t[_orientation] = ref_point[_orientation] - base[_orientation]; - sp_item_move_rel(item, Geom::Translate(t)); + item->move_rel(Geom::Translate(t)); changed = true; } } diff --git a/src/ui/dialog/polar-arrange-tab.cpp b/src/ui/dialog/polar-arrange-tab.cpp index 7a64b91c6..98f3bf2aa 100644 --- a/src/ui/dialog/polar-arrange-tab.cpp +++ b/src/ui/dialog/polar-arrange-tab.cpp @@ -260,7 +260,7 @@ static Geom::Point getAnchorPoint(int anchor, SPItem *item) */ static void moveToPoint(int anchor, SPItem *item, Geom::Point p) { - sp_item_move_rel(item, Geom::Translate(p - getAnchorPoint(anchor, item))); + item->move_rel(Geom::Translate(p - getAnchorPoint(anchor, item))); } void PolarArrangeTab::arrange() diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp index 2c0ffc869..82efa9de6 100644 --- a/src/ui/dialog/transformation.cpp +++ b/src/ui/dialog/transformation.cpp @@ -682,7 +682,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) it < sorted.end(); ++it ) { - sp_item_move_rel(it->item, Geom::Translate(move, 0)); + it->item->move_rel(Geom::Translate(move, 0)); // move each next object by x relative to previous move += x; } @@ -704,7 +704,7 @@ void Transformation::applyPageMove(Inkscape::Selection *selection) it < sorted.end(); ++it ) { - sp_item_move_rel(it->item, Geom::Translate(0, move)); + it->item->move_rel(Geom::Translate(0, move)); // move each next object by x relative to previous move += y; } @@ -826,7 +826,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); return; } - sp_item_skew_rel (item, 0.01*skewX, 0.01*skewY); + item->skew_rel(0.01*skewX, 0.01*skewY); } else if (_units_skew.isRadial()) { //deg or rad double angleX = _scalar_skew_horizontal.getValue("rad"); double angleY = _scalar_skew_vertical.getValue("rad"); @@ -840,7 +840,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) double skewX = tan(-angleX); double skewY = tan(angleY); skewY *= getDesktop()->yaxisdir(); - sp_item_skew_rel (item, skewX, skewY); + item->skew_rel(skewX, skewY); } else { // absolute displacement double skewX = _scalar_skew_horizontal.getValue("px"); double skewY = _scalar_skew_vertical.getValue("px"); @@ -853,7 +853,7 @@ void Transformation::applyPageSkew(Inkscape::Selection *selection) getDesktop()->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Transform matrix is singular, <b>not used</b>.")); return; } - sp_item_skew_rel (item, skewX/height, skewY/width); + item->skew_rel(skewX/height, skewY/width); } } } diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp index 5fed9e806..f29a68691 100644 --- a/src/ui/tools/spray-tool.cpp +++ b/src/ui/tools/spray-tool.cpp @@ -970,7 +970,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, sp_spray_scale_rel(center,desktop, item_copied, Geom::Scale(scale)); sp_spray_rotate_rel(center,desktop,item_copied, Geom::Rotate(angle)); // Move the cursor p - sp_item_move_rel(item_copied, Geom::Translate(move * desktop->doc2dt().withoutTranslation())); + item_copied->move_rel(Geom::Translate(move * desktop->doc2dt().withoutTranslation())); Inkscape::GC::release(copy); if(picker){ sp_desktop_apply_css_recursive(item_copied, css, true); @@ -1014,7 +1014,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale)); sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale)); sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle)); - sp_item_move_rel(item_copied, Geom::Translate(move * desktop->doc2dt().withoutTranslation())); + item_copied->move_rel(Geom::Translate(move * desktop->doc2dt().withoutTranslation())); // Union and duplication set->clear(); @@ -1102,7 +1102,7 @@ static bool sp_spray_recursive(SPDesktop *desktop, sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(_scale, _scale)); sp_spray_scale_rel(center, desktop, item_copied, Geom::Scale(scale, scale)); sp_spray_rotate_rel(center, desktop, item_copied, Geom::Rotate(angle)); - sp_item_move_rel(item_copied, Geom::Translate(move * desktop->doc2dt().withoutTranslation())); + item_copied->move_rel(Geom::Translate(move * desktop->doc2dt().withoutTranslation())); if(picker){ sp_desktop_apply_css_recursive(item_copied, css, true); } diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp index 205de0e5d..1c2016b9f 100644 --- a/src/ui/tools/tweak-tool.cpp +++ b/src/ui/tools/tweak-tool.cpp @@ -400,7 +400,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (a->contains(p)) x = 0; if (x < 1) { Geom::Point move = force * 0.5 * (cos(M_PI * x) + 1) * vector; - sp_item_move_rel(item, Geom::Translate(move * selection->desktop()->doc2dt().withoutTranslation())); + item->move_rel(Geom::Translate(move * selection->desktop()->doc2dt().withoutTranslation())); did = true; } } @@ -414,7 +414,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (x < 1) { Geom::Point move = force * 0.5 * (cos(M_PI * x) + 1) * (reverse? (a->midpoint() - p) : (p - a->midpoint())); - sp_item_move_rel(item, Geom::Translate(move * selection->desktop()->doc2dt().withoutTranslation())); + item->move_rel(Geom::Translate(move * selection->desktop()->doc2dt().withoutTranslation())); did = true; } } @@ -429,7 +429,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (a->contains(p)) x = 0; if (x < 1) { Geom::Point move = force * 0.5 * (cos(M_PI * x) + 1) * Geom::Point(cos(dp)*dr, sin(dp)*dr); - sp_item_move_rel(item, Geom::Translate(move * selection->desktop()->doc2dt().withoutTranslation())); + item->move_rel(Geom::Translate(move * selection->desktop()->doc2dt().withoutTranslation())); did = true; } } @@ -442,7 +442,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P if (a->contains(p)) x = 0; if (x < 1) { double scale = 1 + (reverse? force : -force) * 0.05 * (cos(M_PI * x) + 1); - sp_item_scale_rel(item, Geom::Scale(scale, scale)); + item->scale_rel(Geom::Scale(scale, scale)); did = true; } } @@ -553,28 +553,28 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P bool did_this = false; if (mode == TWEAK_MODE_SHRINK_GROW) { if (theShape->MakeTweak(tweak_mode_grow, theRes, - reverse? force : -force, - join_straight, 4.0, - true, p, Geom::Point(0,0), radius, &i2doc) == 0) // 0 means the shape was actually changed - did_this = true; + reverse? force : -force, + join_straight, 4.0, + true, p, Geom::Point(0,0), radius, &i2doc) == 0) // 0 means the shape was actually changed + did_this = true; } else if (mode == TWEAK_MODE_ATTRACT_REPEL) { if (theShape->MakeTweak(tweak_mode_repel, theRes, - reverse? force : -force, - join_straight, 4.0, - true, p, Geom::Point(0,0), radius, &i2doc) == 0) - did_this = true; + reverse? force : -force, + join_straight, 4.0, + true, p, Geom::Point(0,0), radius, &i2doc) == 0) + did_this = true; } else if (mode == TWEAK_MODE_PUSH) { if (theShape->MakeTweak(tweak_mode_push, theRes, - 1.0, - join_straight, 4.0, - true, p, force*2*vector, radius, &i2doc) == 0) - did_this = true; + 1.0, + join_straight, 4.0, + true, p, force*2*vector, radius, &i2doc) == 0) + did_this = true; } else if (mode == TWEAK_MODE_ROUGHEN) { if (theShape->MakeTweak(tweak_mode_roughen, theRes, - force, - join_straight, 4.0, - true, p, Geom::Point(0,0), radius, &i2doc) == 0) - did_this = true; + force, + join_straight, 4.0, + true, p, Geom::Point(0,0), radius, &i2doc) == 0) + did_this = true; } // the rest only makes sense if we actually changed the path @@ -647,7 +647,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P return did; } -static void + static void tweak_colorpaint (float *color, guint32 goal, double force, bool do_h, bool do_s, bool do_l) { float rgb_g[3]; @@ -679,7 +679,7 @@ tweak_colorpaint (float *color, guint32 goal, double force, bool do_h, bool do_s } } -static void + static void tweak_colorjitter (float *color, double force, bool do_h, bool do_s, bool do_l) { float hsl_c[3]; @@ -704,7 +704,7 @@ tweak_colorjitter (float *color, double force, bool do_h, bool do_s, bool do_l) SPColor::hsl_to_rgb_floatv (color, hsl_c[0], hsl_c[1], hsl_c[2]); } -static void + static void tweak_color (guint mode, float *color, guint32 goal, double force, bool do_h, bool do_s, bool do_l) { if (mode == TWEAK_MODE_COLORPAINT) { @@ -714,7 +714,7 @@ tweak_color (guint mode, float *color, guint32 goal, double force, bool do_h, bo } } -static void + static void tweak_opacity (guint mode, SPIScale24 *style_opacity, double opacity_goal, double force) { double opacity = SP_SCALE24_TO_FLOAT (style_opacity->value); @@ -730,7 +730,7 @@ tweak_opacity (guint mode, SPIScale24 *style_opacity, double opacity_goal, doubl } -static double + static double tweak_profile (double dist, double radius) { if (radius == 0) { @@ -748,8 +748,8 @@ tweak_profile (double dist, double radius) } static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or_stroke, - guint32 const rgb_goal, Geom::Point p_w, double radius, double force, guint mode, - bool do_h, bool do_s, bool do_l, bool /*do_o*/) + guint32 const rgb_goal, Geom::Point p_w, double radius, double force, guint mode, + bool do_h, bool do_s, bool do_l, bool /*do_o*/) { SPGradient *gradient = getGradient(item, fill_or_stroke); @@ -841,11 +841,11 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or // distribute the force between the two endstops so that they // get all the painting even if they are not touched by the brush tweak_color (mode, stop->getColor().v.c, rgb_goal, - force * (pos_e - offset_l) / (offset_h - offset_l), - do_h, do_s, do_l); + force * (pos_e - offset_l) / (offset_h - offset_l), + do_h, do_s, do_l); tweak_color(mode, prevStop->getColor().v.c, rgb_goal, - force * (offset_h - pos_e) / (offset_h - offset_l), - do_h, do_s, do_l); + force * (offset_h - pos_e) / (offset_h - offset_l), + do_h, do_s, do_l); stop->updateRepr(); child_prev->updateRepr(); break; @@ -854,15 +854,15 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or // paint each stop by the force from the profile curve if (offset_l <= pos_e && offset_l > pos_e - r) { tweak_color(mode, prevStop->getColor().v.c, rgb_goal, - force * tweak_profile (fabs (pos_e - offset_l), r), - do_h, do_s, do_l); + force * tweak_profile (fabs (pos_e - offset_l), r), + do_h, do_s, do_l); child_prev->updateRepr(); } if (offset_h >= pos_e && offset_h < pos_e + r) { tweak_color (mode, stop->getColor().v.c, rgb_goal, - force * tweak_profile (fabs (pos_e - offset_h), r), - do_h, do_s, do_l); + force * tweak_profile (fabs (pos_e - offset_h), r), + do_h, do_s, do_l); stop->updateRepr(); } } @@ -883,7 +883,7 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or SPStop *stop = array->nodes[i][j]->stop; double distance = Geom::L2(Geom::Point(p - array->nodes[i][j]->p)); tweak_color (mode, stop->getColor().v.c, rgb_goal, - force * tweak_profile (distance, radius), do_h, do_s, do_l); + force * tweak_profile (distance, radius), do_h, do_s, do_l); stop->updateRepr(); } } @@ -891,14 +891,14 @@ static void tweak_colors_in_gradient(SPItem *item, Inkscape::PaintTarget fill_or } } -static bool + static bool sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, - guint32 fill_goal, bool do_fill, - guint32 stroke_goal, bool do_stroke, - float opacity_goal, bool do_opacity, - bool do_blur, bool reverse, - Geom::Point p, double radius, double force, - bool do_h, bool do_s, bool do_l, bool do_o) + guint32 fill_goal, bool do_fill, + guint32 stroke_goal, bool do_stroke, + float opacity_goal, bool do_opacity, + bool do_blur, bool reverse, + Geom::Point p, double radius, double force, + bool do_h, bool do_s, bool do_l, bool do_o) { bool did = false; @@ -907,11 +907,11 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, SPItem *childItem = dynamic_cast<SPItem *>(&child); if (childItem) { if (sp_tweak_color_recursive (mode, childItem, item_at_point, - fill_goal, do_fill, - stroke_goal, do_stroke, - opacity_goal, do_opacity, - do_blur, reverse, - p, radius, force, do_h, do_s, do_l, do_o)) { + fill_goal, do_fill, + stroke_goal, do_stroke, + opacity_goal, do_opacity, + do_blur, reverse, + p, radius, force, do_h, do_s, do_l, do_o)) { did = true; } } @@ -932,99 +932,99 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point, Geom::Point center = bbox->midpoint(); double this_force; -// if item == item_at_point, use max force + // if item == item_at_point, use max force if (item == item_at_point) { this_force = force; -// else if no overlap of bbox and brush box, skip: + // else if no overlap of bbox and brush box, skip: } else if (!bbox->intersects(brush)) { return false; -//TODO: -// else if object > 1.5 brush: test 4/8/16 points in the brush on hitting the object, choose max - //} else if (bbox->maxExtent() > 3 * radius) { - //} -// else if object > 0.5 brush: test 4 corners of bbox and center on being in the brush, choose max -// else if still smaller, then check only the object center: - } else { - this_force = force * tweak_profile (Geom::L2 (p - center), radius); - } + //TODO: + // else if object > 1.5 brush: test 4/8/16 points in the brush on hitting the object, choose max + //} else if (bbox->maxExtent() > 3 * radius) { + //} + // else if object > 0.5 brush: test 4 corners of bbox and center on being in the brush, choose max + // else if still smaller, then check only the object center: + } else { + this_force = force * tweak_profile (Geom::L2 (p - center), radius); + } - if (this_force > 0.002) { + if (this_force > 0.002) { - if (do_blur) { - Geom::OptRect bbox = item->documentGeometricBounds(); - if (!bbox) { - return did; - } + if (do_blur) { + Geom::OptRect bbox = item->documentGeometricBounds(); + if (!bbox) { + return did; + } - double blur_now = 0; - Geom::Affine i2dt = item->i2dt_affine (); - if (style->filter.set && style->getFilter()) { - //cycle through filter primitives - for (auto& primitive_obj: style->getFilter()->children) { - SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj); - if (primitive) { - //if primitive is gaussianblur - SPGaussianBlur * spblur = dynamic_cast<SPGaussianBlur *>(primitive); - if (spblur) { - float num = spblur->stdDeviation.getNumber(); - blur_now += num * i2dt.descrim(); // sum all blurs in the filter - } + double blur_now = 0; + Geom::Affine i2dt = item->i2dt_affine (); + if (style->filter.set && style->getFilter()) { + //cycle through filter primitives + for (auto& primitive_obj: style->getFilter()->children) { + SPFilterPrimitive *primitive = dynamic_cast<SPFilterPrimitive *>(&primitive_obj); + if (primitive) { + //if primitive is gaussianblur + SPGaussianBlur * spblur = dynamic_cast<SPGaussianBlur *>(primitive); + if (spblur) { + float num = spblur->stdDeviation.getNumber(); + blur_now += num * i2dt.descrim(); // sum all blurs in the filter } } } - double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; - blur_now = blur_now / perimeter; - - double blur_new; - if (reverse) { - blur_new = blur_now - 0.06 * force; - } else { - blur_new = blur_now + 0.06 * force; - } - if (blur_new < 0.0005 && blur_new < blur_now) { - blur_new = 0; - } - if (blur_new == 0) { - remove_filter(item, false); - } else { - double radius = blur_new * perimeter; - SPFilter *filter = modify_filter_gaussian_blur_from_item(item->document, item, radius); - sp_style_set_property_url(item, "filter", filter, false); - } - return true; // do not do colors, blur is a separate mode } + double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; + blur_now = blur_now / perimeter; - if (do_fill) { - if (style->fill.isPaintserver()) { - tweak_colors_in_gradient(item, Inkscape::FOR_FILL, fill_goal, p, radius, this_force, mode, do_h, do_s, do_l, do_o); - did = true; - } else if (style->fill.isColor()) { - tweak_color (mode, style->fill.value.color.v.c, fill_goal, this_force, do_h, do_s, do_l); - item->updateRepr(); - did = true; - } + double blur_new; + if (reverse) { + blur_new = blur_now - 0.06 * force; + } else { + blur_new = blur_now + 0.06 * force; } - if (do_stroke) { - if (style->stroke.isPaintserver()) { - tweak_colors_in_gradient(item, Inkscape::FOR_STROKE, stroke_goal, p, radius, this_force, mode, do_h, do_s, do_l, do_o); - did = true; - } else if (style->stroke.isColor()) { - tweak_color (mode, style->stroke.value.color.v.c, stroke_goal, this_force, do_h, do_s, do_l); - item->updateRepr(); - did = true; - } + if (blur_new < 0.0005 && blur_new < blur_now) { + blur_new = 0; } - if (do_opacity && do_o) { - tweak_opacity (mode, &style->opacity, opacity_goal, this_force); + if (blur_new == 0) { + remove_filter(item, false); + } else { + double radius = blur_new * perimeter; + SPFilter *filter = modify_filter_gaussian_blur_from_item(item->document, item, radius); + sp_style_set_property_url(item, "filter", filter, false); } + return true; // do not do colors, blur is a separate mode + } + + if (do_fill) { + if (style->fill.isPaintserver()) { + tweak_colors_in_gradient(item, Inkscape::FOR_FILL, fill_goal, p, radius, this_force, mode, do_h, do_s, do_l, do_o); + did = true; + } else if (style->fill.isColor()) { + tweak_color (mode, style->fill.value.color.v.c, fill_goal, this_force, do_h, do_s, do_l); + item->updateRepr(); + did = true; + } + } + if (do_stroke) { + if (style->stroke.isPaintserver()) { + tweak_colors_in_gradient(item, Inkscape::FOR_STROKE, stroke_goal, p, radius, this_force, mode, do_h, do_s, do_l, do_o); + did = true; + } else if (style->stroke.isColor()) { + tweak_color (mode, style->stroke.value.color.v.c, stroke_goal, this_force, do_h, do_s, do_l); + item->updateRepr(); + did = true; + } + } + if (do_opacity && do_o) { + tweak_opacity (mode, &style->opacity, opacity_goal, this_force); } } +} - return did; +return did; } -static bool + static bool sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point vector, bool reverse) { Inkscape::Selection *selection = tc->desktop->getSelection(); @@ -1049,15 +1049,15 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point float hsv[3]; float rgb[3]; SPColor::rgb_to_hsv_floatv (hsv, - SP_RGBA32_R_F(fill_goal), - SP_RGBA32_G_F(fill_goal), - SP_RGBA32_B_F(fill_goal)); + SP_RGBA32_R_F(fill_goal), + SP_RGBA32_G_F(fill_goal), + SP_RGBA32_B_F(fill_goal)); SPColor::hsv_to_rgb_floatv (rgb, hsv[0]<.5? hsv[0]+.5 : hsv[0]-.5, 1 - hsv[1], 1 - hsv[2]); fill_goal = SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1); SPColor::rgb_to_hsv_floatv (hsv, - SP_RGBA32_R_F(stroke_goal), - SP_RGBA32_G_F(stroke_goal), - SP_RGBA32_B_F(stroke_goal)); + SP_RGBA32_R_F(stroke_goal), + SP_RGBA32_G_F(stroke_goal), + SP_RGBA32_B_F(stroke_goal)); SPColor::hsv_to_rgb_floatv (rgb, hsv[0]<.5? hsv[0]+.5 : hsv[0]-.5, 1 - hsv[1], 1 - hsv[2]); stroke_goal = SP_RGBA32_F_COMPOSE(rgb[0], rgb[1], rgb[2], 1); #else @@ -1083,17 +1083,17 @@ 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); -// auto items= selection->items(); + // auto items= selection->items(); std::vector<SPItem*> items(selection->items().begin(), selection->items().end()); for(auto item : items){ if (is_color_mode (tc->mode)) { if (do_fill || do_stroke || do_opacity) { if (sp_tweak_color_recursive (tc->mode, item, item_at_point, - fill_goal, do_fill, - stroke_goal, do_stroke, - opacity_goal, do_opacity, - tc->mode == TWEAK_MODE_BLUR, reverse, - p, radius, color_force, tc->do_h, tc->do_s, tc->do_l, tc->do_o)) { + fill_goal, do_fill, + stroke_goal, do_stroke, + opacity_goal, do_opacity, + tc->mode == TWEAK_MODE_BLUR, reverse, + p, radius, color_force, tc->do_h, tc->do_s, tc->do_l, tc->do_o)) { did = true; } } @@ -1111,16 +1111,16 @@ sp_tweak_dilate (TweakTool *tc, Geom::Point event_p, Geom::Point p, Geom::Point return did; } -static void + static void sp_tweak_update_area (TweakTool *tc) { - double radius = get_dilate_radius(tc); - Geom::Affine const sm (Geom::Scale(radius, radius) * Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point())); - sp_canvas_item_affine_absolute(tc->dilate_area, sm); - sp_canvas_item_show(tc->dilate_area); + double radius = get_dilate_radius(tc); + Geom::Affine const sm (Geom::Scale(radius, radius) * Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point())); + sp_canvas_item_affine_absolute(tc->dilate_area, sm); + sp_canvas_item_show(tc->dilate_area); } -static void + static void sp_tweak_switch_mode (TweakTool *tc, gint mode, bool with_shift) { auto tb = dynamic_cast<UI::Toolbar::TweakToolbar*>(SP_EVENT_CONTEXT(tc)->desktop->get_toolbar_by_name("TweakToolbar")); @@ -1136,24 +1136,24 @@ sp_tweak_switch_mode (TweakTool *tc, gint mode, bool with_shift) tc->update_cursor(with_shift); } -static void + static void sp_tweak_switch_mode_temporarily (TweakTool *tc, gint mode, bool with_shift) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - // Juggling about so that prefs have the old value but tc->mode and the button show new mode: - gint now_mode = prefs->getInt("/tools/tweak/mode", 0); + // Juggling about so that prefs have the old value but tc->mode and the button show new mode: + gint now_mode = prefs->getInt("/tools/tweak/mode", 0); - auto tb = dynamic_cast<UI::Toolbar::TweakToolbar*>(SP_EVENT_CONTEXT(tc)->desktop->get_toolbar_by_name("TweakToolbar")); + auto tb = dynamic_cast<UI::Toolbar::TweakToolbar*>(SP_EVENT_CONTEXT(tc)->desktop->get_toolbar_by_name("TweakToolbar")); - if(tb) { - tb->set_mode(mode); - } else { - std::cerr << "Could not access Tweak toolbar" << std::endl; - } + if(tb) { + tb->set_mode(mode); + } else { + std::cerr << "Could not access Tweak toolbar" << std::endl; + } - // button has changed prefs, restore - prefs->setInt("/tools/tweak/mode", now_mode); - // changing prefs changed tc->mode, restore back :) + // button has changed prefs, restore + prefs->setInt("/tools/tweak/mode", now_mode); + // changing prefs changed tc->mode, restore back : tc->mode = mode; tc->update_cursor(with_shift); } |
