diff options
| author | Jabiertxof <jtx@jtx> | 2017-03-16 19:08:44 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx> | 2017-03-16 19:08:44 +0000 |
| commit | 8330d0ef2b97c73121ead78ea9fbcec6ee01f879 (patch) | |
| tree | 1b1717d1706ee6ebfecc800f2cc80430eb0450e0 /src/live_effects | |
| parent | update to trunk (diff) | |
| parent | Fix rendering when canvas rotated. General code clean-up and documentation. (diff) | |
| download | inkscape-8330d0ef2b97c73121ead78ea9fbcec6ee01f879.tar.gz inkscape-8330d0ef2b97c73121ead78ea9fbcec6ee01f879.zip | |
Update to trunk
(bzr r13645.1.170)
Diffstat (limited to 'src/live_effects')
21 files changed, 307 insertions, 170 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index a02f62ac9..07e431376 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -469,6 +469,9 @@ void Effect::processObjects(LpeAction lpe_action) { SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } for (std::vector<const char *>::iterator el_it = items.begin(); el_it != items.end(); ++el_it) { const char * id = *el_it; diff --git a/src/live_effects/lpe-clone-original.cpp b/src/live_effects/lpe-clone-original.cpp index e70575986..440af6f9c 100644 --- a/src/live_effects/lpe-clone-original.cpp +++ b/src/live_effects/lpe-clone-original.cpp @@ -64,6 +64,9 @@ void LPECloneOriginal::cloneAttrbutes(SPObject *origin, SPObject *dest, bool live, const char * attributes, const char * style_attributes, bool root) { SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } if ( SP_IS_GROUP(origin) && SP_IS_GROUP(dest) && SP_GROUP(origin)->getItemCount() == SP_GROUP(dest)->getItemCount() ) { std::vector< SPObject * > childs = origin->childList(true); size_t index = 0; @@ -258,28 +261,18 @@ LPECloneOriginal::doBeforeEffect (SPLPEItem const* lpeitem){ style_attr.erase (style_attr.size()-1, 1); } style_attr.append(Glib::ustring(style_attributes.param_getSVGValue()).append(",")); - if (inverse) { - cloneAttrbutes(SP_OBJECT(sp_lpe_item), linked_item.getObject(), true, g_strdup(attr.c_str()), g_strdup(style_attr.c_str()), true); - Geom::OptRect bbox = SP_ITEM(sp_lpe_item)->geometricBounds(); - if (bbox && preserve_position && origin != Geom::Point(0,0)) { - origin = (*bbox).corner(0) - origin; - SP_ITEM(linked_item.getObject())->transform *= Geom::Translate(origin); - } - bbox = SP_ITEM(sp_lpe_item)->geometricBounds(); - if (bbox && preserve_position) { - origin = (*bbox).corner(0); - } - } else { - cloneAttrbutes(linked_item.getObject(), SP_OBJECT(sp_lpe_item), true, g_strdup(attr.c_str()), g_strdup(style_attr.c_str()), true); - Geom::OptRect bbox = SP_ITEM(linked_item.getObject())->geometricBounds(); - if (bbox && preserve_position && origin != Geom::Point(0,0)) { - origin = (*bbox).corner(0) - origin; - SP_ITEM(sp_lpe_item)->transform *= Geom::Translate(origin); - } - bbox = SP_ITEM(linked_item.getObject())->geometricBounds(); - if (bbox && preserve_position) { - origin = (*bbox).corner(0); - } + + SPItem * from = inverse ? SP_ITEM(sp_lpe_item) : SP_ITEM(linked_item.getObject()); + SPItem * to = !inverse ? SP_ITEM(sp_lpe_item) : SP_ITEM(linked_item.getObject()); + cloneAttrbutes(from, to, true, g_strdup(attr.c_str()), g_strdup(style_attr.c_str()), true); + Geom::OptRect bbox = from->geometricBounds(); + if (bbox && preserve_position && origin != Geom::Point(0,0)) { + origin = (*bbox).corner(0) - origin; + to->transform *= Geom::Translate(origin); + } + bbox = from->geometricBounds(); + if (bbox && preserve_position) { + origin = (*bbox).corner(0); } } } @@ -354,7 +347,6 @@ void LPECloneOriginal::transform_multiply(Geom::Affine const& postmul, bool set) { if (linked_item.linksToItem()) { - bool changed = false; linked_item.getObject()->requestModified(SP_OBJECT_MODIFIED_FLAG); } } diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index 42e055062..9ba680cd4 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -92,11 +92,13 @@ LPECopyRotate::doAfterEffect (SPLPEItem const* lpeitem) { if (split_items) { SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } items.clear(); container = dynamic_cast<SPObject *>(sp_lpe_item->parent); - SPDocument * doc = SP_ACTIVE_DOCUMENT; Inkscape::XML::Node *root = sp_lpe_item->document->getReprRoot(); - Inkscape::XML::Node *root_origin = doc->getReprRoot(); + Inkscape::XML::Node *root_origin = document->getReprRoot(); if (root_origin != root) { return; } @@ -168,15 +170,15 @@ LPECopyRotate::doAfterEffect (SPLPEItem const* lpeitem) processObjects(LPE_ERASE); items.clear(); } - - std::cout << previous_num_copies << "previous_num_copies\n"; - std::cout << num_copies << "num_copies\n"; } void LPECopyRotate::cloneD(SPObject *origin, SPObject *dest, bool root, bool reset) { SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } Inkscape::XML::Document *xml_doc = document->getReprDoc(); if ( SP_IS_GROUP(origin) && SP_IS_GROUP(dest) && SP_GROUP(origin)->getItemCount() == SP_GROUP(dest)->getItemCount() ) { std::vector< SPObject * > childs = origin->childList(true); @@ -190,7 +192,7 @@ LPECopyRotate::cloneD(SPObject *origin, SPObject *dest, bool root, bool reset) } SPShape * shape = SP_SHAPE(origin); SPPath * path = SP_PATH(dest); - if (!path && !SP_IS_GROUP(dest)) { + if (shape && !path) { Inkscape::XML::Node *dest_node = sp_selected_item_to_curved_repr(SP_ITEM(dest), 0); dest->updateRepr(xml_doc, dest_node, SP_OBJECT_WRITE_ALL); path = SP_PATH(dest); @@ -219,6 +221,9 @@ void LPECopyRotate::toItem(Geom::Affine transform, size_t i, bool reset) { SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } Inkscape::XML::Document *xml_doc = document->getReprDoc(); const char * elemref_id = g_strdup(Glib::ustring("rotated-").append(std::to_string(i)).append("-").append(sp_lpe_item->getRepr()->attribute("id")).c_str()); items.push_back(elemref_id); @@ -377,11 +382,11 @@ LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem) num_copies.param_set_increments(1.0, 10.0); } - if (dist_angle_handle < 1.0) { - dist_angle_handle = 1.0; - } A = Point(boundingbox_X.min(), boundingbox_Y.middle()); B = Point(boundingbox_X.middle(), boundingbox_Y.middle()); + if (Geom::are_near(A, B, 0.01)) { + B += Geom::Point(1.0, 0.0); + } 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) @@ -394,6 +399,9 @@ LPECopyRotate::doBeforeEffect (SPLPEItem const* lpeitem) dist_angle_handle = L2(starting_point - origin); } } + if (dist_angle_handle < 1.0) { + dist_angle_handle = 1.0; + } start_pos = origin + dir * Rotate(-rad_from_deg(starting_angle)) * dist_angle_handle; rot_pos = origin + dir * Rotate(-rad_from_deg(rotation_angle+starting_angle)) * dist_angle_handle; near = Geom::are_near(start_pos, (Geom::Point)starting_point, 0.01); diff --git a/src/live_effects/lpe-curvestitch.cpp b/src/live_effects/lpe-curvestitch.cpp index 38cbeaac0..f2fc00aeb 100644 --- a/src/live_effects/lpe-curvestitch.cpp +++ b/src/live_effects/lpe-curvestitch.cpp @@ -54,6 +54,7 @@ LPECurveStitch::LPECurveStitch(LivePathEffectObject *lpeobject) : prop_scale.param_set_digits(3); prop_scale.param_set_increments(0.01, 0.10); + transformed = false; } LPECurveStitch::~LPECurveStitch() @@ -106,8 +107,9 @@ LPECurveStitch::doEffect_path (Geom::PathVector const & path_in) if (!Geom::are_near(start,end)) { gdouble scaling_y = 1.0; - if (scale_y_rel.get_value()) { + if (scale_y_rel.get_value() || transformed) { scaling_y = (L2(end-start)/scaling)*prop_scale; + transformed = false; } else { scaling_y = prop_scale; } @@ -193,12 +195,8 @@ LPECurveStitch::transform_multiply(Geom::Affine const& postmul, bool set) if (postmul.isTranslation()) { strokepath.param_transform_multiply(postmul, set); } else if (!scale_y_rel.get_value()) { - // this basically means that for this transformation, the result should be the same as normal scaling the result path - // don't know how to do this yet. -// Geom::Affine new_postmul; - //new_postmul.setIdentity(); -// new_postmul.setTranslation(postmul.translation()); -// Effect::transform_multiply(new_postmul, set); + transformed = true; + strokepath.param_transform_multiply(postmul, set); } } diff --git a/src/live_effects/lpe-curvestitch.h b/src/live_effects/lpe-curvestitch.h index c6ea66f6c..0a48046e0 100644 --- a/src/live_effects/lpe-curvestitch.h +++ b/src/live_effects/lpe-curvestitch.h @@ -43,6 +43,7 @@ private: RandomParam endpoint_spacing_variation; ScalarParam prop_scale; BoolParam scale_y_rel; + bool transformed; LPECurveStitch(const LPECurveStitch&); LPECurveStitch& operator=(const LPECurveStitch&); diff --git a/src/live_effects/lpe-fill-between-many.cpp b/src/live_effects/lpe-fill-between-many.cpp index 1e2eadfdb..2e1fe0dc1 100644 --- a/src/live_effects/lpe-fill-between-many.cpp +++ b/src/live_effects/lpe-fill-between-many.cpp @@ -4,13 +4,13 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include <gtkmm/box.h> #include "live_effects/lpe-fill-between-many.h" #include "display/curve.h" #include "sp-shape.h" #include "sp-text.h" +#include "svg/svg.h" // TODO due to internal breakage in glibmm headers, this must be last: #include <glibmm/i18n.h> @@ -19,10 +19,18 @@ namespace LivePathEffect { LPEFillBetweenMany::LPEFillBetweenMany(LivePathEffectObject *lpeobject) : Effect(lpeobject), - linked_paths(_("Linked path:"), _("Paths from which to take the original path data"), "linkedpaths", &wr, this) + linked_paths(_("Linked path:"), _("Paths from which to take the original path data"), "linkedpaths", &wr, this), + fuse(_("Fuse coincident points"), _("Fuse coincident points"), "fuse", &wr, this, false), + allow_transforms(_("Allow transforms"), _("Allow transforms"), "allow_transforms", &wr, this, false), + join(_("Join subpaths"), _("Join subpaths"), "join", &wr, this, true), + close(_("Close"), _("Close path"), "close", &wr, this, true) { registerParameter( dynamic_cast<Parameter *>(&linked_paths) ); - //perceived_path = true; + registerParameter( dynamic_cast<Parameter *>(&fuse) ); + registerParameter( dynamic_cast<Parameter *>(&allow_transforms) ); + registerParameter( dynamic_cast<Parameter *>(&join) ); + registerParameter( dynamic_cast<Parameter *>(&close) ); + transformmultiply = false; } LPEFillBetweenMany::~LPEFillBetweenMany() @@ -44,25 +52,50 @@ void LPEFillBetweenMany::doEffect (SPCurve * curve) linked_path = (*iter)->_pathvector.front(); } - if (!res_pathv.empty()) { + if (!res_pathv.empty() && join) { linked_path = linked_path * SP_ITEM(obj)->getRelativeTransform(firstObj); - res_pathv.front().appendNew<Geom::LineSegment>(linked_path.initialPoint()); + if (!are_near(res_pathv.front().finalPoint(), linked_path.initialPoint(), 0.01) || !fuse) { + res_pathv.front().appendNew<Geom::LineSegment>(linked_path.initialPoint()); + } else { + linked_path.setInitial(res_pathv.front().finalPoint()); + } res_pathv.front().append(linked_path); } else { firstObj = SP_ITEM(obj); + if (close && !join) { + linked_path.close(); + } res_pathv.push_back(linked_path); } } } - if (!res_pathv.empty()) { + if (!res_pathv.empty() && close) { res_pathv.front().close(); } if (res_pathv.empty()) { res_pathv = curve->get_pathvector(); } + if(!allow_transforms && !transformmultiply) { + Geom::Affine affine = Geom::identity(); + sp_svg_transform_read(SP_ITEM(sp_lpe_item)->getAttribute("transform"), &affine); + res_pathv *= affine.inverse(); + } + if(transformmultiply) { + transformmultiply = false; + } curve->set_pathvector(res_pathv); } +void +LPEFillBetweenMany::transform_multiply(Geom::Affine const& postmul, bool set) +{ + if(!allow_transforms && sp_lpe_item) { + SP_ITEM(sp_lpe_item)->transform *= postmul.inverse(); + transformmultiply = true; + sp_lpe_item_update_patheffect(sp_lpe_item, false, false); + } +} + } // namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-fill-between-many.h b/src/live_effects/lpe-fill-between-many.h index 99ee8b15f..fe824e936 100644 --- a/src/live_effects/lpe-fill-between-many.h +++ b/src/live_effects/lpe-fill-between-many.h @@ -19,12 +19,16 @@ class LPEFillBetweenMany : public Effect { public: LPEFillBetweenMany(LivePathEffectObject *lpeobject); virtual ~LPEFillBetweenMany(); - + virtual void transform_multiply(Geom::Affine const& postmul, bool set); virtual void doEffect (SPCurve * curve); private: OriginalPathArrayParam linked_paths; - + BoolParam fuse; + BoolParam allow_transforms; + BoolParam join; + BoolParam close; + bool transformmultiply; private: LPEFillBetweenMany(const LPEFillBetweenMany&); LPEFillBetweenMany& operator=(const LPEFillBetweenMany&); diff --git a/src/live_effects/lpe-fill-between-strokes.cpp b/src/live_effects/lpe-fill-between-strokes.cpp index 0dbebdf26..43fef4288 100644 --- a/src/live_effects/lpe-fill-between-strokes.cpp +++ b/src/live_effects/lpe-fill-between-strokes.cpp @@ -8,6 +8,7 @@ #include "display/curve.h" #include "sp-shape.h" #include "sp-text.h" +#include "svg/svg.h" // TODO due to internal breakage in glibmm headers, this must be last: #include <glibmm/i18n.h> @@ -18,12 +19,20 @@ LPEFillBetweenStrokes::LPEFillBetweenStrokes(LivePathEffectObject *lpeobject) : Effect(lpeobject), linked_path(_("Linked path:"), _("Path from which to take the original path data"), "linkedpath", &wr, this), second_path(_("Second path:"), _("Second path from which to take the original path data"), "secondpath", &wr, this), - reverse_second(_("Reverse Second"), _("Reverses the second path order"), "reversesecond", &wr, this) + reverse_second(_("Reverse Second"), _("Reverses the second path order"), "reversesecond", &wr, this), + fuse(_("Fuse coincident points"), _("Fuse coincident points"), "fuse", &wr, this, false), + allow_transforms(_("Allow transforms"), _("Allow transforms"), "allow_transforms", &wr, this, false), + join(_("Join subpaths"), _("Join subpaths"), "join", &wr, this, true), + close(_("Close"), _("Close path"), "close", &wr, this, true) { registerParameter( dynamic_cast<Parameter *>(&linked_path) ); registerParameter( dynamic_cast<Parameter *>(&second_path) ); registerParameter( dynamic_cast<Parameter *>(&reverse_second) ); - //perceived_path = true; + registerParameter( dynamic_cast<Parameter *>(&fuse) ); + registerParameter( dynamic_cast<Parameter *>(&allow_transforms) ); + registerParameter( dynamic_cast<Parameter *>(&join) ); + registerParameter( dynamic_cast<Parameter *>(&close) ); + transformmultiply = false; } LPEFillBetweenStrokes::~LPEFillBetweenStrokes() @@ -34,6 +43,13 @@ LPEFillBetweenStrokes::~LPEFillBetweenStrokes() void LPEFillBetweenStrokes::doEffect (SPCurve * curve) { if (curve) { + Geom::Affine affine = Geom::identity(); + if(!allow_transforms && !transformmultiply) { + sp_svg_transform_read(SP_ITEM(sp_lpe_item)->getAttribute("transform"), &affine); + } + if(transformmultiply) { + transformmultiply = false; + } if ( linked_path.linksToPath() && second_path.linksToPath() && linked_path.getObject() && second_path.getObject() ) { Geom::PathVector linked_pathv = linked_path.get_pathvector(); Geom::PathVector second_pathv = second_path.get_pathvector(); @@ -51,22 +67,33 @@ void LPEFillBetweenStrokes::doEffect (SPCurve * curve) } if ( !result_linked_pathv.empty() && !result_second_pathv.empty() && !result_linked_pathv.front().closed() ) { - if (reverse_second.get_value()) - { - result_linked_pathv.front().appendNew<Geom::LineSegment>(result_second_pathv.front().finalPoint()); - result_linked_pathv.front().append(result_second_pathv.front().reversed()); + if (reverse_second.get_value()) { + result_second_pathv.front() = result_second_pathv.front().reversed(); } - else - { - result_linked_pathv.front().appendNew<Geom::LineSegment>(result_second_pathv.front().initialPoint()); + if (join) { + if (!are_near(result_linked_pathv.front().finalPoint(), result_second_pathv.front().initialPoint(),0.01) || !fuse) { + result_linked_pathv.front().appendNew<Geom::LineSegment>(result_second_pathv.front().initialPoint()); + } else { + result_second_pathv.front().setInitial(result_linked_pathv.front().finalPoint()); + } result_linked_pathv.front().append(result_second_pathv.front()); + if (close) { + result_linked_pathv.front().close(); + } + } else { + if (close) { + result_linked_pathv.front().close(); + result_second_pathv.front().close(); + } + result_linked_pathv.push_back(result_second_pathv.front()); } + result_linked_pathv *= affine.inverse(); curve->set_pathvector(result_linked_pathv); - } - else if ( !result_linked_pathv.empty() ) { + } else if ( !result_linked_pathv.empty() ) { + result_linked_pathv *= affine.inverse(); curve->set_pathvector(result_linked_pathv); - } - else if ( !result_second_pathv.empty() ) { + } else if ( !result_second_pathv.empty() ) { + result_second_pathv *= affine.inverse(); curve->set_pathvector(result_second_pathv); } } @@ -79,6 +106,10 @@ void LPEFillBetweenStrokes::doEffect (SPCurve * curve) result_pathv.push_back((*iter)); } if ( !result_pathv.empty() ) { + result_pathv *= affine.inverse(); + if (close) { + result_pathv.front().close(); + } curve->set_pathvector(result_pathv); } } @@ -91,12 +122,26 @@ void LPEFillBetweenStrokes::doEffect (SPCurve * curve) result_pathv.push_back((*iter)); } if ( !result_pathv.empty() ) { + result_pathv *= affine.inverse(); + if (close) { + result_pathv.front().close(); + } curve->set_pathvector(result_pathv); } } } } +void +LPEFillBetweenStrokes::transform_multiply(Geom::Affine const& postmul, bool set) +{ + if(!allow_transforms && sp_lpe_item) { + SP_ITEM(sp_lpe_item)->transform *= postmul.inverse(); + transformmultiply = true; + sp_lpe_item_update_patheffect(sp_lpe_item, false, false); + } +} + } // namespace LivePathEffect } /* namespace Inkscape */ diff --git a/src/live_effects/lpe-fill-between-strokes.h b/src/live_effects/lpe-fill-between-strokes.h index ec57b1852..5bbd6e7da 100644 --- a/src/live_effects/lpe-fill-between-strokes.h +++ b/src/live_effects/lpe-fill-between-strokes.h @@ -19,13 +19,18 @@ class LPEFillBetweenStrokes : public Effect { public: LPEFillBetweenStrokes(LivePathEffectObject *lpeobject); virtual ~LPEFillBetweenStrokes(); - + virtual void transform_multiply(Geom::Affine const& postmul, bool set); virtual void doEffect (SPCurve * curve); private: OriginalPathParam linked_path; OriginalPathParam second_path; BoolParam reverse_second; + BoolParam fuse; + BoolParam allow_transforms; + BoolParam join; + BoolParam close; + bool transformmultiply; private: LPEFillBetweenStrokes(const LPEFillBetweenStrokes&); diff --git a/src/live_effects/lpe-lattice.h b/src/live_effects/lpe-lattice.h index 5eb48909b..8720af138 100644 --- a/src/live_effects/lpe-lattice.h +++ b/src/live_effects/lpe-lattice.h @@ -9,7 +9,7 @@ * Authors: * Johan Engelen * Steren Giannini - * Noé Falzon + * Noé Falzon * Victor Navez * * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> diff --git a/src/live_effects/lpe-lattice2.h b/src/live_effects/lpe-lattice2.h index 59a0350d3..95c5285fb 100644 --- a/src/live_effects/lpe-lattice2.h +++ b/src/live_effects/lpe-lattice2.h @@ -9,7 +9,7 @@ * Authors: * Johan Engelen * Steren Giannini - * Noé Falzon + * Noé Falzon * Victor Navez * ~suv * Jabiertxo Arraiza diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp index ef87be81c..83ae60fc4 100644 --- a/src/live_effects/lpe-measure-line.cpp +++ b/src/live_effects/lpe-measure-line.cpp @@ -171,6 +171,9 @@ void LPEMeasureLine::createArrowMarker(const char * mode) { SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } Inkscape::XML::Document *xml_doc = document->getReprDoc(); SPObject *elemref = NULL; Inkscape::XML::Node *arrow = NULL; @@ -232,6 +235,9 @@ void LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angle, bool remove, bool valid) { SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } Inkscape::XML::Document *xml_doc = document->getReprDoc(); Inkscape::XML::Node *rtext = NULL; double doc_w = document->getRoot()->width.value; @@ -323,19 +329,20 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl Inkscape::GC::release(rtspan); } length = Inkscape::Util::Quantity::convert(length / doc_scale, display_unit.c_str(), unit.get_abbreviation()); - std::stringstream length_str; - length_str.precision(precision); - length_str.setf(std::ios::fixed, std::ios::floatfield); + char *oldlocale = g_strdup (setlocale(LC_NUMERIC, NULL)); if (local_locale) { - length_str.imbue(std::locale("")); + setlocale (LC_NUMERIC, ""); } else { - length_str.imbue(std::locale::classic()); + setlocale (LC_NUMERIC, "C"); } - length_str << std::fixed << length; + gchar length_str[64]; + g_snprintf(length_str, 64, "%.*f", (int)precision, length); + setlocale (LC_NUMERIC, oldlocale); + g_free (oldlocale); Glib::ustring label_value = Glib::ustring(format.param_getSVGValue()); size_t s = label_value.find(Glib::ustring("{measure}"),0); if(s < label_value.length()) { - label_value.replace(s,s+9,length_str.str()); + label_value.replace(s,s+9,length_str); } s = label_value.find(Glib::ustring("{unit}"),0); if(s < label_value.length()) { @@ -376,6 +383,9 @@ void LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, const char * id, bool main, bool overflow, bool remove, bool arrows) { SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } Inkscape::XML::Document *xml_doc = document->getReprDoc(); SPObject *elemref = NULL; Inkscape::XML::Node *line = NULL; @@ -500,6 +510,9 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem); sp_lpe_item->parent = dynamic_cast<SPObject *>(splpeitem->parent); SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } Inkscape::XML::Node *root = splpeitem->document->getReprRoot(); Inkscape::XML::Node *root_origin = document->getReprRoot(); if (root_origin != root) { @@ -643,9 +656,11 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem) } SPCSSAttr *css = sp_repr_css_attr_new(); sp_repr_css_attr_add_from_string(css, dimline_format.param_getSVGValue()); - setlocale(LC_NUMERIC, std::locale::classic().name().c_str()); + char *oldlocale = g_strdup (setlocale(LC_NUMERIC, NULL)); + setlocale (LC_NUMERIC, "C"); double width_line = atof(sp_repr_css_property(css,"stroke-width","-1")); - setlocale(LC_NUMERIC, std::locale("").name().c_str()); + setlocale (LC_NUMERIC, oldlocale); + g_free (oldlocale); if (width_line > -0.0001) { arrow_gap = 8 * Inkscape::Util::Quantity::convert(width_line/ doc_scale, "mm", display_unit.c_str()); } diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 7f0a93c52..c31ce7c01 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -87,11 +87,14 @@ LPEMirrorSymmetry::~LPEMirrorSymmetry() void LPEMirrorSymmetry::doAfterEffect (SPLPEItem const* lpeitem) { + SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } if (split_items && !discard_orig_path) { container = dynamic_cast<SPObject *>(sp_lpe_item->parent); - SPDocument * doc = SP_ACTIVE_DOCUMENT; Inkscape::XML::Node *root = sp_lpe_item->document->getReprRoot(); - Inkscape::XML::Node *root_origin = doc->getReprRoot(); + Inkscape::XML::Node *root_origin = document->getReprRoot(); if (root_origin != root) { return; } @@ -161,20 +164,24 @@ LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) } } else if ( mode == MT_V){ SPDocument * document = SP_ACTIVE_DOCUMENT; - Geom::Affine transform = i2anc_affine(SP_OBJECT(lpeitem), NULL).inverse(); - Geom::Point sp = Geom::Point(document->getWidth().value("px")/2.0, 0) * transform; - start_point.param_setValue(sp, true); - Geom::Point ep = Geom::Point(document->getWidth().value("px")/2.0, document->getHeight().value("px")) * transform; - end_point.param_setValue(ep, true); - center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true); + if (document) { + Geom::Affine transform = i2anc_affine(SP_OBJECT(lpeitem), NULL).inverse(); + Geom::Point sp = Geom::Point(document->getWidth().value("px")/2.0, 0) * transform; + start_point.param_setValue(sp, true); + Geom::Point ep = Geom::Point(document->getWidth().value("px")/2.0, document->getHeight().value("px")) * transform; + end_point.param_setValue(ep, true); + center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true); + } } else { //horizontal page SPDocument * document = SP_ACTIVE_DOCUMENT; - Geom::Affine transform = i2anc_affine(SP_OBJECT(lpeitem), NULL).inverse(); - Geom::Point sp = Geom::Point(0, document->getHeight().value("px")/2.0) * transform; - start_point.param_setValue(sp, true); - Geom::Point ep = Geom::Point(document->getWidth().value("px"), document->getHeight().value("px")/2.0) * transform; - end_point.param_setValue(ep, true); - center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true); + if (document) { + Geom::Affine transform = i2anc_affine(SP_OBJECT(lpeitem), NULL).inverse(); + Geom::Point sp = Geom::Point(0, document->getHeight().value("px")/2.0) * transform; + start_point.param_setValue(sp, true); + Geom::Point ep = Geom::Point(document->getWidth().value("px"), document->getHeight().value("px")/2.0) * transform; + end_point.param_setValue(ep, true); + center_point.param_setValue(Geom::middle_point((Geom::Point)start_point, (Geom::Point)end_point), true); + } } previous_center = center_point; } @@ -183,6 +190,9 @@ void LPEMirrorSymmetry::cloneD(SPObject *origin, SPObject *dest, bool live, bool root) { SPDocument * document = SP_ACTIVE_DOCUMENT; + if (!document) { + return; + } Inkscape::XML::Document *xml_doc = document->getReprDoc(); if ( SP_IS_GROUP(origin) && SP_IS_GROUP(dest) && SP_GROUP(origin)->getItemCount() == SP_GROUP(dest)->getItemCount() ) { std::vector< SPObject * > childs = origin->childList(true); @@ -196,7 +206,7 @@ LPEMirrorSymmetry::cloneD(SPObject *origin, SPObject *dest, bool live, bool root } SPShape * shape = SP_SHAPE(origin); SPPath * path = SP_PATH(dest); - if (!path && !SP_IS_GROUP(dest)) { + if (shape && !path) { Inkscape::XML::Node *dest_node = sp_selected_item_to_curved_repr(SP_ITEM(dest), 0); dest->updateRepr(xml_doc, dest_node, SP_OBJECT_WRITE_ALL); path = SP_PATH(dest); @@ -226,67 +236,69 @@ void LPEMirrorSymmetry::toMirror(Geom::Affine transform) { SPDocument * document = SP_ACTIVE_DOCUMENT; - Inkscape::XML::Document *xml_doc = document->getReprDoc(); - const char * id_origin_char = id_origin.param_getSVGValue(); - const char * elemref_id = g_strdup(Glib::ustring("mirror-").append(id_origin_char).c_str()); - items.clear(); - items.push_back(elemref_id); - SPObject *elemref= NULL; - Inkscape::XML::Node *phantom = NULL; - if (elemref = document->getObjectById(elemref_id)) { - phantom = elemref->getRepr(); - } else { - phantom = sp_lpe_item->getRepr()->duplicate(xml_doc); - std::vector<const char *> attrs; - attrs.push_back("inkscape:path-effect"); - attrs.push_back("inkscape:original-d"); - attrs.push_back("sodipodi:type"); - attrs.push_back("sodipodi:rx"); - attrs.push_back("sodipodi:ry"); - attrs.push_back("sodipodi:cx"); - attrs.push_back("sodipodi:cy"); - attrs.push_back("sodipodi:end"); - attrs.push_back("sodipodi:start"); - attrs.push_back("inkscape:flatsided"); - attrs.push_back("inkscape:randomized"); - attrs.push_back("inkscape:rounded"); - attrs.push_back("sodipodi:arg1"); - attrs.push_back("sodipodi:arg2"); - attrs.push_back("sodipodi:r1"); - attrs.push_back("sodipodi:r2"); - attrs.push_back("sodipodi:sides"); - attrs.push_back("inkscape:randomized"); - attrs.push_back("sodipodi:argument"); - attrs.push_back("sodipodi:expansion"); - attrs.push_back("sodipodi:radius"); - attrs.push_back("sodipodi:revolution"); - attrs.push_back("sodipodi:t0"); - attrs.push_back("inkscape:randomized"); - attrs.push_back("inkscape:randomized"); - attrs.push_back("inkscape:randomized"); - attrs.push_back("x"); - attrs.push_back("y"); - attrs.push_back("rx"); - attrs.push_back("ry"); - attrs.push_back("width"); - attrs.push_back("height"); - for(const char * attr : attrs) { - phantom->setAttribute(attr, NULL); + if (document) { + Inkscape::XML::Document *xml_doc = document->getReprDoc(); + const char * id_origin_char = id_origin.param_getSVGValue(); + const char * elemref_id = g_strdup(Glib::ustring("mirror-").append(id_origin_char).c_str()); + items.clear(); + items.push_back(elemref_id); + SPObject *elemref= NULL; + Inkscape::XML::Node *phantom = NULL; + if (elemref = document->getObjectById(elemref_id)) { + phantom = elemref->getRepr(); + } else { + phantom = sp_lpe_item->getRepr()->duplicate(xml_doc); + std::vector<const char *> attrs; + attrs.push_back("inkscape:path-effect"); + attrs.push_back("inkscape:original-d"); + attrs.push_back("sodipodi:type"); + attrs.push_back("sodipodi:rx"); + attrs.push_back("sodipodi:ry"); + attrs.push_back("sodipodi:cx"); + attrs.push_back("sodipodi:cy"); + attrs.push_back("sodipodi:end"); + attrs.push_back("sodipodi:start"); + attrs.push_back("inkscape:flatsided"); + attrs.push_back("inkscape:randomized"); + attrs.push_back("inkscape:rounded"); + attrs.push_back("sodipodi:arg1"); + attrs.push_back("sodipodi:arg2"); + attrs.push_back("sodipodi:r1"); + attrs.push_back("sodipodi:r2"); + attrs.push_back("sodipodi:sides"); + attrs.push_back("inkscape:randomized"); + attrs.push_back("sodipodi:argument"); + attrs.push_back("sodipodi:expansion"); + attrs.push_back("sodipodi:radius"); + attrs.push_back("sodipodi:revolution"); + attrs.push_back("sodipodi:t0"); + attrs.push_back("inkscape:randomized"); + attrs.push_back("inkscape:randomized"); + attrs.push_back("inkscape:randomized"); + attrs.push_back("x"); + attrs.push_back("y"); + attrs.push_back("rx"); + attrs.push_back("ry"); + attrs.push_back("width"); + attrs.push_back("height"); + for(const char * attr : attrs) { + phantom->setAttribute(attr, NULL); + } + } + phantom->setAttribute("id", elemref_id); + if (!elemref) { + elemref = container->appendChildRepr(phantom); + Inkscape::GC::release(phantom); + } + cloneD(SP_OBJECT(sp_lpe_item), elemref, true, true); + elemref->getRepr()->setAttribute("transform" , sp_svg_transform_write(transform)); + if (elemref->parent != container) { + Inkscape::XML::Node *copy = phantom->duplicate(xml_doc); + copy->setAttribute("id", elemref_id); + container->appendChildRepr(copy); + Inkscape::GC::release(copy); + elemref->deleteObject(); } - } - phantom->setAttribute("id", elemref_id); - if (!elemref) { - elemref = container->appendChildRepr(phantom); - Inkscape::GC::release(phantom); - } - cloneD(SP_OBJECT(sp_lpe_item), elemref, true, true); - elemref->getRepr()->setAttribute("transform" , sp_svg_transform_write(transform)); - if (elemref->parent != container) { - Inkscape::XML::Node *copy = phantom->duplicate(xml_doc); - copy->setAttribute("id", elemref_id); - container->appendChildRepr(copy); - Inkscape::GC::release(copy); - elemref->deleteObject(); } } diff --git a/src/live_effects/lpe-perspective-envelope.cpp b/src/live_effects/lpe-perspective-envelope.cpp index 18b5b724d..365ff5389 100644 --- a/src/live_effects/lpe-perspective-envelope.cpp +++ b/src/live_effects/lpe-perspective-envelope.cpp @@ -369,12 +369,12 @@ LPEPerspectiveEnvelope::newWidget() Gtk::Label* handles = Gtk::manage(new Gtk::Label(Glib::ustring(_("Handles:")),Gtk::ALIGN_START)); vbox->pack_start(*handles, false, false, 2); hbox_up_handles->pack_start(*widg, true, true, 2); - hbox_up_handles->pack_start(*Gtk::manage(new Gtk::VSeparator()), Gtk::PACK_EXPAND_WIDGET); + hbox_up_handles->pack_start(*Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_VERTICAL)), Gtk::PACK_EXPAND_WIDGET); } else if(param->param_key == "up_right_point") { hbox_up_handles->pack_start(*widg, true, true, 2); } else if(param->param_key == "down_left_point") { hbox_down_handles->pack_start(*widg, true, true, 2); - hbox_down_handles->pack_start(*Gtk::manage(new Gtk::VSeparator()), Gtk::PACK_EXPAND_WIDGET); + hbox_down_handles->pack_start(*Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_VERTICAL)), Gtk::PACK_EXPAND_WIDGET); } else { hbox_down_handles->pack_start(*widg, true, true, 2); } @@ -403,8 +403,8 @@ LPEPerspectiveEnvelope::newWidget() } vbox->pack_start(*hbox_up_handles,true, true, 2); Gtk::HBox * hbox_middle = Gtk::manage(new Gtk::HBox(true,2)); - hbox_middle->pack_start(*Gtk::manage(new Gtk::HSeparator()), Gtk::PACK_EXPAND_WIDGET); - hbox_middle->pack_start(*Gtk::manage(new Gtk::HSeparator()), Gtk::PACK_EXPAND_WIDGET); + hbox_middle->pack_start(*Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)), Gtk::PACK_EXPAND_WIDGET); + hbox_middle->pack_start(*Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)), Gtk::PACK_EXPAND_WIDGET); vbox->pack_start(*hbox_middle, false, true, 2); vbox->pack_start(*hbox_down_handles, true, true, 2); Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false,0)); diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index 979b6dea5..b83fb67d7 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -226,15 +226,28 @@ LPEPerspectivePath::newWidget() ++it; } Gtk::HBox * perspectiveId = Gtk::manage(new Gtk::HBox(true,0)); + +#if WITH_GTKMM_3_10 + Gtk::Label* labelPerspective = Gtk::manage(new Gtk::Label("Perspective ID:", Gtk::ALIGN_START, Gtk::ALIGN_START)); +#else Gtk::Label* labelPerspective = Gtk::manage(new Gtk::Label("Perspective ID:", 0., 0.)); +#endif + Gtk::Entry* perspective = Gtk::manage(new Gtk::Entry()); perspective->set_text(perspectiveID); perspective->set_tooltip_text("Set the perspective ID to apply"); perspectiveId->pack_start(*labelPerspective, true, true, 2); perspectiveId->pack_start(*perspective, true, true, 2); vbox->pack_start(*perspectiveId, true, true, 2); - Gtk::Button* apply3D = Gtk::manage(new Gtk::Button(Glib::ustring(_("Refresh perspective")))); - apply3D->set_alignment(0.0, 0.5); + Gtk::Button* apply3D = Gtk::manage(new Gtk::Button()); + +#if WITH_GTKMM_3_10 + Gtk::Label *apply3DLabel = Gtk::manage(new Gtk::Label(_("Refresh perspective"), Gtk::ALIGN_START, Gtk::ALIGN_CENTER)); +#else + Gtk::Label *apply3DLabel = Gtk::manage(new Gtk::Label(_("Refresh perspective"), 0.0, 0.5)); +#endif + + apply3D->add(*apply3DLabel); apply3D->signal_clicked().connect(sigc::bind<Gtk::Entry*>(sigc::mem_fun(*this,&LPEPerspectivePath::refresh),perspective)); Gtk::Widget* apply3DWidget = dynamic_cast<Gtk::Widget *>(apply3D); apply3DWidget->set_tooltip_text("Refresh perspective"); diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index c6edffd9b..e847494a2 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -120,7 +120,7 @@ Gtk::Widget *LPERoughen::newWidget() Gtk::ALIGN_START)); method_label->set_use_markup(true); vbox->pack_start(*method_label, false, false, 2); - vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), + vbox->pack_start(*Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)), Gtk::PACK_EXPAND_WIDGET); } if (param->param_key == "displace_x") { @@ -129,7 +129,7 @@ Gtk::Widget *LPERoughen::newWidget() Gtk::ALIGN_START)); displace_x_label->set_use_markup(true); vbox->pack_start(*displace_x_label, false, false, 2); - vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), + vbox->pack_start(*Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)), Gtk::PACK_EXPAND_WIDGET); } if (param->param_key == "global_randomize") { @@ -138,7 +138,7 @@ Gtk::Widget *LPERoughen::newWidget() Gtk::ALIGN_START)); global_rand->set_use_markup(true); vbox->pack_start(*global_rand, false, false, 2); - vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), + vbox->pack_start(*Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)), Gtk::PACK_EXPAND_WIDGET); } if (param->param_key == "handles") { @@ -147,7 +147,7 @@ Gtk::Widget *LPERoughen::newWidget() Gtk::ALIGN_START)); options->set_use_markup(true); vbox->pack_start(*options, false, false, 2); - vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), + vbox->pack_start(*Gtk::manage(new Gtk::Separator(Gtk::ORIENTATION_HORIZONTAL)), Gtk::PACK_EXPAND_WIDGET); } Glib::ustring *tip = param->param_getTooltip(); diff --git a/src/live_effects/lpeobject-reference.cpp b/src/live_effects/lpeobject-reference.cpp index 1940806bd..83cd6623c 100644 --- a/src/live_effects/lpeobject-reference.cpp +++ b/src/live_effects/lpeobject-reference.cpp @@ -6,9 +6,11 @@ * Released under GNU GPL, read the file 'COPYING' for more information. */ +#include "live_effects/lpeobject-reference.h" + #include <string.h> -#include "live_effects/lpeobject-reference.h" +#include "bad-uri-exception.h" #include "live_effects/lpeobject.h" #include "uri.h" diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp index 8caea4e26..93cf2b15f 100644 --- a/src/live_effects/parameter/item.cpp +++ b/src/live_effects/parameter/item.cpp @@ -5,15 +5,20 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "ui/widget/point.h" +#include "live_effects/parameter/item.h" + #include <glibmm/i18n.h> -#include "live_effects/parameter/item.h" +#include <gtkmm/button.h> +#include <gtkmm/label.h> + +#include "bad-uri-exception.h" +#include "ui/widget/point.h" + #include "live_effects/effect.h" #include "svg/svg.h" #include "widgets/icon.h" -#include <gtk/gtk.h> #include "selection-chemistry.h" #include "xml/repr.h" #include "desktop.h" @@ -25,8 +30,6 @@ // required for linking to other paths #include "uri.h" -#include <gtkmm/button.h> -#include <gtkmm/label.h> #include "ui/icon-names.h" namespace Inkscape { diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp index f7eb48b7a..1e78f7fe1 100644 --- a/src/live_effects/parameter/originalpath.cpp +++ b/src/live_effects/parameter/originalpath.cpp @@ -89,7 +89,7 @@ OriginalPathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags* { SPCurve *curve = NULL; if (SP_IS_SHAPE(linked_obj)) { - curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE(); + curve = SP_SHAPE(linked_obj)->getCurve(); } if (SP_IS_TEXT(linked_obj)) { curve = SP_TEXT(linked_obj)->getNormalizedBpath(); diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp index 083abc94c..693821ed2 100644 --- a/src/live_effects/parameter/originalpatharray.cpp +++ b/src/live_effects/parameter/originalpatharray.cpp @@ -386,7 +386,7 @@ void OriginalPathArrayParam::setPathVector(SPObject *linked_obj, guint /*flags*/ } SPCurve *curve = NULL; if (SP_IS_SHAPE(linked_obj)) { - curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE(); + curve = SP_SHAPE(linked_obj)->getCurve(); } if (SP_IS_TEXT(linked_obj)) { curve = SP_TEXT(linked_obj)->getNormalizedBpath(); diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index f0c494267..dafc6d406 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -5,10 +5,16 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "ui/widget/point.h" +#include "live_effects/parameter/path.h" + #include <glibmm/i18n.h> -#include "live_effects/parameter/path.h" +#include <gtkmm/button.h> +#include <gtkmm/label.h> + +#include "bad-uri-exception.h" +#include "ui/widget/point.h" + #include "live_effects/effect.h" #include "svg/svg.h" #include <2geom/svg-path-parser.h> @@ -17,7 +23,6 @@ #include <2geom/d2.h> #include "widgets/icon.h" -#include <gtk/gtk.h> #include "selection-chemistry.h" #include "xml/repr.h" #include "desktop.h" @@ -44,8 +49,6 @@ #include "ui/tool/multi-path-manipulator.h" #include "ui/tool/shape-record.h" -#include <gtkmm/button.h> -#include <gtkmm/label.h> #include "ui/icon-names.h" namespace Inkscape { |
