From d6d991c7215d37adaef31cd5896f30d5454708a6 Mon Sep 17 00:00:00 2001 From: su_v Date: Sat, 17 Jan 2015 22:43:01 +0100 Subject: Fix EPS export area (Bug #1411208) Fixed bugs: - https://launchpad.net/bugs/1411208 (bzr r13863) --- src/extension/internal/cairo-ps-out.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/extension/internal/cairo-ps-out.cpp b/src/extension/internal/cairo-ps-out.cpp index d1511ba84..f6790687c 100644 --- a/src/extension/internal/cairo-ps-out.cpp +++ b/src/extension/internal/cairo-ps-out.cpp @@ -169,14 +169,14 @@ CairoPsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar con bool new_areaPage = true; try { - new_areaPage = (strcmp(ext->get_param_optiongroup("area"), "page") == 0); + new_areaPage = (strcmp(mod->get_param_optiongroup("area"), "page") == 0); } catch(...) {} bool new_areaDrawing = !new_areaPage; float bleedmargin_px = 0.; try { - bleedmargin_px = ext->get_param_float("bleed"); + bleedmargin_px = mod->get_param_float("bleed"); } catch(...) {} const gchar *new_exportId = NULL; @@ -221,7 +221,7 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co Inkscape::Extension::Extension * ext; unsigned int ret; - ext = Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_PS); + ext = Inkscape::Extension::db.get(SP_MODULE_KEY_PRINT_CAIRO_EPS); if (ext == NULL) return; @@ -258,14 +258,14 @@ CairoEpsOutput::save(Inkscape::Extension::Output *mod, SPDocument *doc, gchar co bool new_areaPage = true; try { - new_areaPage = (strcmp(ext->get_param_optiongroup("area"), "page") == 0); + new_areaPage = (strcmp(mod->get_param_optiongroup("area"), "page") == 0); } catch(...) {} bool new_areaDrawing = !new_areaPage; float bleedmargin_px = 0.; try { - bleedmargin_px = ext->get_param_float("bleed"); + bleedmargin_px = mod->get_param_float("bleed"); } catch(...) {} const gchar *new_exportId = NULL; -- cgit v1.2.3 From 82ea99160b97349036d173bf8aa95d47d571eeaf Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 19 Jan 2015 16:18:38 +0100 Subject: Don't update viewbox if referenced element not or (bzr r13864) --- src/sp-use.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-use.cpp b/src/sp-use.cpp index 3b95e599d..7e02de3c1 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -35,6 +35,7 @@ #include "preferences.h" #include "style.h" #include "sp-symbol.h" +#include "sp-root.h" #include "sp-use.h" #include "sp-use-reference.h" #include "sp-shape.h" @@ -562,13 +563,17 @@ void SPUse::update(SPCtx *ctx, unsigned flags) { this->height.computed = this->height.value * ictx->viewport.height(); } - cctx.viewport = Geom::Rect::from_xywh(0, 0, this->width.computed, this->height.computed); - cctx.i2vp = Geom::identity(); childflags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; if (this->child) { sp_object_ref(this->child); + // viewport is only changed if referencing a symbol or svg element + if( SP_IS_SYMBOL(this->child) || SP_IS_ROOT(this->child) ) { + cctx.viewport = Geom::Rect::from_xywh(0, 0, this->width.computed, this->height.computed); + cctx.i2vp = Geom::identity(); + } + if (childflags || (this->child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { SPItem const *chi = dynamic_cast(child); g_assert(chi != NULL); -- cgit v1.2.3 From 4e5bd3f7fbe73ce2694fad89ab32cf0d466d4bdc Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 21 Jan 2015 00:05:32 +0100 Subject: Fix wrong knots in rotate curves LPE (bzr r13865) --- src/live_effects/lpe-copy_rotate.cpp | 142 +++++++++++++++++++++++++---------- src/live_effects/lpe-copy_rotate.h | 8 +- 2 files changed, 110 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 51787e292..3428ba8b3 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -17,11 +17,15 @@ #include "live_effects/lpe-copy_rotate.h" #include "sp-shape.h" #include "display/curve.h" - +#include <2geom/path.h> +#include <2geom/path-intersection.h> +#include <2geom/sbasis-to-bezier.h> #include <2geom/path.h> #include <2geom/transforms.h> #include <2geom/d2-sbasis.h> #include <2geom/angle.h> +#include <2geom/line.h> +#include #include "knot-holder-entity.h" #include "knotholder.h" @@ -38,27 +42,40 @@ public: virtual Geom::Point knot_get() const; }; +class KnotHolderEntityRotationAngle : public LPEKnotHolderEntity { +public: + KnotHolderEntityRotationAngle(LPECopyRotate *effect) : LPEKnotHolderEntity(effect) {}; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get() const; +}; + +class KnotHolderEntityOrigin : public LPEKnotHolderEntity { +public: + KnotHolderEntityOrigin(LPECopyRotate *effect) : LPEKnotHolderEntity(effect) {}; + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); + virtual Geom::Point knot_get() const; +}; } // namespace CR LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) : Effect(lpeobject), + origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this, "Adjust the origin of the rotation"), starting_angle(_("Starting:"), _("Angle of the first copy"), "starting_angle", &wr, this, 0.0), rotation_angle(_("Rotation angle:"), _("Angle between two successive copies"), "rotation_angle", &wr, this, 30.0), num_copies(_("Number of copies:"), _("Number of copies of the original path"), "num_copies", &wr, this, 5), copiesTo360(_("360º Copies"), _("No rotation angle, fixed to 360º"), "copiesTo360", &wr, this, true), - origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this, "Adjust the origin of the rotation"), - dist_angle_handle(100) + dist_angle_handle(100.0) { show_orig_path = true; _provides_knotholder_entities = true; // register all your parameters here, so Inkscape knows which parameters this effect has: - registerParameter( dynamic_cast(&copiesTo360) ); - registerParameter( dynamic_cast(&starting_angle) ); - registerParameter( dynamic_cast(&rotation_angle) ); - registerParameter( dynamic_cast(&num_copies) ); - registerParameter( dynamic_cast(&origin) ); + registerParameter(&copiesTo360); + registerParameter(&starting_angle); + registerParameter(&rotation_angle); + registerParameter(&num_copies); + registerParameter(&origin); num_copies.param_make_integer(true); num_copies.param_set_range(0, 1000); @@ -73,47 +90,57 @@ void LPECopyRotate::doOnApply(SPLPEItem const* lpeitem) { using namespace Geom; - original_bbox(lpeitem); - Point A(boundingbox_X.min(), boundingbox_Y.middle()); - Point B(boundingbox_X.max(), boundingbox_Y.middle()); - Point C(boundingbox_X.middle(), boundingbox_Y.middle()); + A = Point(boundingbox_X.min(), boundingbox_Y.middle()); + B = Point(boundingbox_X.middle(), boundingbox_Y.middle()); origin.param_setValue(A); - - dir = unit_vector(B - A); dist_angle_handle = L2(B - A); + dir = unit_vector(B - A); } -Geom::Piecewise > -LPECopyRotate::doEffect_pwd2 (Geom::Piecewise > const & pwd2_in) + +void +LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem) { using namespace Geom; - + original_bbox(lpeitem); + if(copiesTo360 ){ + rotation_angle.param_set_value(360.0/(double)num_copies); + } + A = Point(boundingbox_X.min(), boundingbox_Y.middle()); + B = Point(boundingbox_X.middle(), boundingbox_Y.middle()); + dir = unit_vector(B - A); // I first suspected the minus sign to be a bug in 2geom but it is // likely due to SVG's choice of coordinate system orientation (max) start_pos = origin + dir * Rotate(-deg_to_rad(starting_angle)) * dist_angle_handle; - double rotation_angle_end = rotation_angle; - if(copiesTo360){ - rotation_angle_end = 360.0/(double)num_copies; + rot_pos = origin + dir * Rotate(-deg_to_rad(rotation_angle+starting_angle)) * dist_angle_handle; + if(copiesTo360 ){ + rot_pos = origin; } - rot_pos = origin + dir * Rotate(-deg_to_rad(starting_angle + rotation_angle_end)) * dist_angle_handle; + SPLPEItem * item = const_cast(lpeitem); + item->apply_to_clippath(item); + item->apply_to_mask(item); - A = pwd2_in.firstValue(); - B = pwd2_in.lastValue(); - dir = unit_vector(B - A); +} - Piecewise > output; +Geom::Piecewise > +LPECopyRotate::doEffect_pwd2 (Geom::Piecewise > const & pwd2_in) +{ + using namespace Geom; + + if(num_copies == 1){ + return pwd2_in; + } + + Piecewise > output; Affine pre = Translate(-origin) * Rotate(-deg_to_rad(starting_angle)); for (int i = 0; i < num_copies; ++i) { - // I first suspected the minus sign to be a bug in 2geom but it is - // likely due to SVG's choice of coordinate system orientation (max) - Rotate rot(-deg_to_rad(rotation_angle_end * i)); + Rotate rot(-deg_to_rad(rotation_angle * i)); Affine t = pre * rot * Translate(origin); output.concat(pwd2_in * t); } - return output; } @@ -121,12 +148,13 @@ void LPECopyRotate::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec) { using namespace Geom; - - Path path(start_pos); - path.appendNew((Geom::Point) origin); - path.appendNew(rot_pos); - PathVector pathv; - pathv.push_back(path); + hp_vec.clear(); + Geom::Path hp; + hp.start(start_pos); + hp.appendNew((Geom::Point)origin); + hp.appendNew(origin + dir * Rotate(-deg_to_rad(rotation_angle+starting_angle)) * dist_angle_handle); + Geom::PathVector pathv; + pathv.push_back(hp); hp_vec.push_back(pathv); } @@ -135,9 +163,22 @@ void LPECopyRotate::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *des { KnotHolderEntity *e = new CR::KnotHolderEntityStartingAngle(this); e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, - _("Adjust the starting angle") ); + _("Adjust the starting angle")); knotholder->add(e); } + { + KnotHolderEntity *e = new CR::KnotHolderEntityRotationAngle(this); + e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, + _("Adjust the rotation angle")); + knotholder->add(e); + } +} + +void +LPECopyRotate::resetDefaults(SPItem const* item) +{ + Effect::resetDefaults(item); + original_bbox(SP_LPE_ITEM(item)); }; namespace CR { @@ -164,6 +205,26 @@ KnotHolderEntityStartingAngle::knot_set(Geom::Point const &p, Geom::Point const sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); } +void +KnotHolderEntityRotationAngle::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) +{ + LPECopyRotate* lpe = dynamic_cast(_effect); + + Geom::Point const s = snap_knot_position(p, state); + + // I first suspected the minus sign to be a bug in 2geom but it is + // likely due to SVG's choice of coordinate system orientation (max) + lpe->rotation_angle.param_set_value(rad_to_deg(-angle_between(lpe->dir, s - lpe->origin)) - lpe->starting_angle); + if (state & GDK_SHIFT_MASK) { + lpe->dist_angle_handle = L2(lpe->B - lpe->A); + } else { + lpe->dist_angle_handle = L2(p - lpe->origin); + } + + // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating. + sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true); +} + Geom::Point KnotHolderEntityStartingAngle::knot_get() const { @@ -171,9 +232,14 @@ KnotHolderEntityStartingAngle::knot_get() const return lpe->start_pos; } -} // namespace CR - +Geom::Point +KnotHolderEntityRotationAngle::knot_get() const +{ + LPECopyRotate const *lpe = dynamic_cast(_effect); + return lpe->rot_pos; +} +} // namespace CR /* ######################## */ diff --git a/src/live_effects/lpe-copy_rotate.h b/src/live_effects/lpe-copy_rotate.h index 123c92cdd..9392026a7 100644 --- a/src/live_effects/lpe-copy_rotate.h +++ b/src/live_effects/lpe-copy_rotate.h @@ -36,21 +36,25 @@ public: virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); + + virtual void resetDefaults(SPItem const* item); + /* the knotholder entity classes must be declared friends */ friend class CR::KnotHolderEntityStartingAngle; + friend class CR::KnotHolderEntityRotationAngle; void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); protected: virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); private: + PointParam origin; ScalarParam starting_angle; ScalarParam rotation_angle; ScalarParam num_copies; BoolParam copiesTo360; - PointParam origin; - Geom::Point A; Geom::Point B; Geom::Point dir; -- cgit v1.2.3