diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-03-18 18:13:01 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-03-18 18:13:01 +0000 |
| commit | 0d3d7f676b29f9d9a9cd53f08ced76e6588b856a (patch) | |
| tree | 12a2646048750e49e7edee42046b8aa138207f2c /src/live_effects | |
| parent | warping into a layer (diff) | |
| parent | Replace sp_style_xxx functions with SPStyle member functions. (diff) | |
| download | inkscape-0d3d7f676b29f9d9a9cd53f08ced76e6588b856a.tar.gz inkscape-0d3d7f676b29f9d9a9cd53f08ced76e6588b856a.zip | |
update to trunk
(bzr r13682.1.22)
Diffstat (limited to 'src/live_effects')
| -rw-r--r-- | src/live_effects/effect.cpp | 6 | ||||
| -rw-r--r-- | src/live_effects/lpe-bspline.cpp | 1 | ||||
| -rw-r--r-- | src/live_effects/lpe-mirror_symmetry.cpp | 47 | ||||
| -rw-r--r-- | src/live_effects/lpe-mirror_symmetry.h | 4 | ||||
| -rw-r--r-- | src/live_effects/lpe-perspective_path.cpp | 5 | ||||
| -rw-r--r-- | src/live_effects/lpe-roughen.cpp | 10 | ||||
| -rw-r--r-- | src/live_effects/lpe-show_handles.cpp | 18 | ||||
| -rw-r--r-- | src/live_effects/lpe-show_handles.h | 1 | ||||
| -rw-r--r-- | src/live_effects/parameter/originalpath.cpp | 4 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.cpp | 4 | ||||
| -rw-r--r-- | src/live_effects/parameter/text.cpp | 5 |
11 files changed, 60 insertions, 45 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 391eccdd3..37fe77aed 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -451,7 +451,7 @@ void Effect::doOnRemove (SPLPEItem const* /*lpeitem*/) void Effect::doOnApply_impl(SPLPEItem const* lpeitem) { sp_lpe_item = const_cast<SPLPEItem *>(lpeitem); - defaultUnit = &sp_lpe_item->document->getDefaultUnit()->abbr; + defaultUnit = &sp_lpe_item->document->getDisplayUnit()->abbr; /*sp_curve = SP_SHAPE(sp_lpe_item)->getCurve(); pathvector_before_effect = sp_curve->get_pathvector();*/ doOnApply(lpeitem); @@ -460,7 +460,7 @@ void Effect::doOnApply_impl(SPLPEItem const* lpeitem) void Effect::doBeforeEffect_impl(SPLPEItem const* lpeitem) { sp_lpe_item = const_cast<SPLPEItem *>(lpeitem); - defaultUnit = &sp_lpe_item->document->getDefaultUnit()->abbr; + defaultUnit = &sp_lpe_item->document->getDisplayUnit()->abbr; //printf("(SPLPEITEM*) %p\n", sp_lpe_item); sp_curve = SP_SHAPE(sp_lpe_item)->getCurve(); pathvector_before_effect = sp_curve->get_pathvector(); @@ -477,7 +477,7 @@ void Effect::doAcceptPathPreparations(SPLPEItem *lpeitem) { // switch to pen context - SPDesktop *desktop = inkscape_active_desktop(); // TODO: Is there a better method to find the item's desktop? + SPDesktop *desktop = SP_ACTIVE_DESKTOP; // TODO: Is there a better method to find the item's desktop? if (!tools_isactive(desktop, TOOLS_FREEHAND_PEN)) { tools_switch(desktop, TOOLS_FREEHAND_PEN); } diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index c5390a0c9..2bed90139 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -367,6 +367,7 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weightValue) { using Geom::X; using Geom::Y; + if (curve->get_segment_count() < 1) return; // Make copy of old path as it is changed during processing diff --git a/src/live_effects/lpe-mirror_symmetry.cpp b/src/live_effects/lpe-mirror_symmetry.cpp index 8df2eb176..f39b92e58 100644 --- a/src/live_effects/lpe-mirror_symmetry.cpp +++ b/src/live_effects/lpe-mirror_symmetry.cpp @@ -27,6 +27,7 @@ #include "knot-holder-entity.h" #include "knotholder.h" + namespace Inkscape { namespace LivePathEffect { @@ -55,47 +56,32 @@ LPEMirrorSymmetry::LPEMirrorSymmetry(LivePathEffectObject *lpeobject) : discard_orig_path(_("Discard original path?"), _("Check this to only keep the mirrored part of the path"), "discard_orig_path", &wr, this, false), fusionPaths(_("Fusioned symetry"), _("Fusion right side whith symm"), "fusionPaths", &wr, this, true), reverseFusion(_("Reverse fusion"), _("Reverse fusion"), "reverseFusion", &wr, this, false), - reflectionFromPage(_("Use page as relecion base"), _("Use page as relecion base"), "reflectionFromPage", &wr, this, false), + fixedReflectionLine(_("Fixed reflection line"), _("Fixed reflection line"), "fixedReflectionLine", &wr, this, false), reflection_line(_("Reflection line:"), _("Line which serves as 'mirror' for the reflection"), "reflection_line", &wr, this, "M0,0 L1,0"), center(_("Center of mirroring (X or Y)"), _("Center of the mirror"), "center", &wr, this, "Adjust the center of mirroring") { show_orig_path = true; - registerParameter(&mode); registerParameter( &discard_orig_path); registerParameter( &fusionPaths); registerParameter( &reverseFusion); - registerParameter( &reflectionFromPage); + registerParameter( &distanceToX); + registerParameter( &distanceToY); registerParameter( &reflection_line); registerParameter( ¢er); - } LPEMirrorSymmetry::~LPEMirrorSymmetry() { } -void LPEMirrorSymmetry::doOnApply(SPLPEItem const* lpeitem) -{ - SPDocument *doc = lpeitem->document(); - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - sp_selection_group_impl(GSList *p, group, xml_doc, doc); - Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); - group->setAttribute("inkscape:groupmode", "layer"); - sp_selection_group_impl(p, group, xml_doc, doc); - gchar *href = g_strdup_printf("#%s", this->lpeobject_href); - SP_LPE_ITEM(group)->addPathEffect(href, true); - lpeitem->removeCurrentPathEffect(false) - g_free(href); - Inkscape::GC::release(group); -} - void LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) { using namespace Geom; SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); + SPObject *subitem = static_cast<SPObject *>(item); Point A(boundingbox_X.max(), boundingbox_Y.min()); Point B(boundingbox_X.max(), boundingbox_Y.max()); Point C(boundingbox_X.max(), boundingbox_Y.middle()); @@ -107,7 +93,7 @@ LPEMirrorSymmetry::doBeforeEffect (SPLPEItem const* lpeitem) A = Geom::Point(center[X],boundingbox_Y.min()); B = Geom::Point(center[X],boundingbox_Y.max()); } - if( mode == MT_X || mode == MT_Y ){ + if( mode == MT_X || mode == MT_Y || mode == MT_FIXED_X || mode == MT_FIXED_Y ){ Geom::Path path; path.start( A ); path.appendNew<Geom::LineSegment>( B ); @@ -147,6 +133,27 @@ LPEMirrorSymmetry::doOnApply (SPLPEItem const* lpeitem) { using namespace Geom; + /* + SPDocument *doc = lpeitem->document; + Inkscape::XML::Document *xml_doc = doc->getReprDoc(); + Inkscape::XML::Node *group = xml_doc->createElement("svg:g"); + group->setAttribute("inkscape:groupmode", "layer"); + SPLPEItem* item = const_cast<SPLPEItem*>(lpeitem); + Inkscape::XML::Node *current = item->getRepr(); + gint topmost = current->position(); + Inkscape::XML::Node *top_current = current->parent(); + Inkscape::XML::Node *spnew = current->duplicate(xml_doc); + sp_repr_unparent(current); + group->appendChild(spnew); + Inkscape::GC::release(spnew); + top_current->appendChild(group); + group->setPosition(topmost + 1); + gchar *href = g_strdup_printf("#%s", item->getCurrentLPE()->getRepr()->attribute("id")); + SP_LPE_ITEM(group)->addPathEffect(href, true); + item->removeCurrentPathEffect(false); + g_free(href); + Inkscape::GC::release(group); + */ original_bbox(lpeitem); Point A(boundingbox_X.max(), boundingbox_Y.min()); diff --git a/src/live_effects/lpe-mirror_symmetry.h b/src/live_effects/lpe-mirror_symmetry.h index 6e9e7dd1a..c18fb265d 100644 --- a/src/live_effects/lpe-mirror_symmetry.h +++ b/src/live_effects/lpe-mirror_symmetry.h @@ -44,8 +44,6 @@ public: virtual void doOnApply (SPLPEItem const* lpeitem); - virtual void doOnApply(SPLPEItem const* lpeitem); - virtual void doBeforeEffect (SPLPEItem const* lpeitem); virtual int pointSideOfLine(Geom::Point A, Geom::Point B, Geom::Point X); @@ -64,7 +62,7 @@ private: BoolParam discard_orig_path; BoolParam fusionPaths; BoolParam reverseFusion; - BoolParam reflectionFromPage; + BoolParam fixedReflectionLine; PathParam reflection_line; Geom::Line lineSeparation; Geom::Point previousCenter; diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp index 5183a455f..901519b4f 100644 --- a/src/live_effects/lpe-perspective_path.cpp +++ b/src/live_effects/lpe-perspective_path.cpp @@ -23,7 +23,7 @@ #include "knot-holder-entity.h" #include "knotholder.h" #include "desktop.h" - +#include <util/units.h> #include "inkscape.h" #include <2geom/path.h> @@ -97,7 +97,8 @@ LPEPerspectivePath::doBeforeEffect (SPLPEItem const* lpeitem) return; } Proj::TransfMat3x4 pmat = persp->perspective_impl->tmat; - pmat = pmat * SP_ACTIVE_DESKTOP->doc2dt(); + Geom::Affine doc2d = Geom::Scale(1, -1) * Geom::Translate(0, item->document->getHeight().value("px")); + pmat = pmat * doc2d; pmat.copy_tmat(tmat); item->apply_to_clippath(item); item->apply_to_mask(item); diff --git a/src/live_effects/lpe-roughen.cpp b/src/live_effects/lpe-roughen.cpp index 07d9e63e8..8cef9a3a3 100644 --- a/src/live_effects/lpe-roughen.cpp +++ b/src/live_effects/lpe-roughen.cpp @@ -160,11 +160,11 @@ double LPERoughen::sign(double randNumber) Geom::Point LPERoughen::randomize() { - Inkscape::Util::Unit const *doc_units = SP_ACTIVE_DESKTOP->namedview->doc_units; + Inkscape::Util::Unit const *svg_units = SP_ACTIVE_DESKTOP->namedview->svg_units; double displaceXParsed = Inkscape::Util::Quantity::convert( - displaceX * globalRandomize, unit.get_abbreviation(), doc_units->abbr); + displaceX * globalRandomize, unit.get_abbreviation(), svg_units->abbr); double displaceYParsed = Inkscape::Util::Quantity::convert( - displaceY * globalRandomize, unit.get_abbreviation(), doc_units->abbr); + displaceY * globalRandomize, unit.get_abbreviation(), svg_units->abbr); Geom::Point output = Geom::Point(sign(displaceXParsed), sign(displaceYParsed)); return output; @@ -175,7 +175,7 @@ void LPERoughen::doEffect(SPCurve *curve) Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); curve->reset(); - Inkscape::Util::Unit const *doc_units = SP_ACTIVE_DESKTOP->namedview->doc_units; + Inkscape::Util::Unit const *svg_units = SP_ACTIVE_DESKTOP->namedview->svg_units; for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) { if (path_it->empty()) @@ -221,7 +221,7 @@ void LPERoughen::doEffect(SPCurve *curve) nCurve->lineto(A3); } double length = Inkscape::Util::Quantity::convert( - curve_it1->length(0.001), doc_units->abbr, unit.get_abbreviation()); + curve_it1->length(0.001), svg_units->abbr, unit.get_abbreviation()); std::size_t splits = 0; if (method == DM_SEGMENTS) { splits = segments; diff --git a/src/live_effects/lpe-show_handles.cpp b/src/live_effects/lpe-show_handles.cpp index 7b2b445b7..2d8148730 100644 --- a/src/live_effects/lpe-show_handles.cpp +++ b/src/live_effects/lpe-show_handles.cpp @@ -25,15 +25,20 @@ LPEShowHandles::LPEShowHandles(LivePathEffectObject *lpeobject) nodes(_("Show nodes"), _("Show nodes"), "nodes", &wr, this, true), handles(_("Show handles"), _("Show handles"), "handles", &wr, this, true), originalPath(_("Show path"), _("Show path"), "originalPath", &wr, this, true), - scaleNodesAndHandles(_("Scale nodes and handles"), _("Scale nodes and handles"), "scaleNodesAndHandles", &wr, this, 10) + scaleNodesAndHandles(_("Scale nodes and handles"), _("Scale nodes and handles"), "scaleNodesAndHandles", &wr, this, 10), + rotateNodes(_("Rotate nodes"), _("Rotate nodes"), "rotateNodes", &wr, this, 0) { registerParameter(dynamic_cast<Parameter *>(&nodes)); registerParameter(dynamic_cast<Parameter *>(&handles)); registerParameter(dynamic_cast<Parameter *>(&originalPath)); registerParameter(dynamic_cast<Parameter *>(&scaleNodesAndHandles)); + registerParameter(dynamic_cast<Parameter *>(&rotateNodes)); scaleNodesAndHandles.param_set_range(0, 500.); scaleNodesAndHandles.param_set_increments(1, 1); scaleNodesAndHandles.param_set_digits(2); + rotateNodes.param_set_range(0, 365); + rotateNodes.param_set_increments(1, 1); + rotateNodes.param_set_digits(0); strokeWidth = 1.0; } @@ -158,10 +163,11 @@ LPEShowHandles::drawNode(Geom::Point p) if(strokeWidth * scaleNodesAndHandles > 0.0) { double diameter = strokeWidth * scaleNodesAndHandles; char const * svgd; - svgd = "M 0.55,0.5 A 0.05,0.05 0 0 1 0.5,0.55 0.05,0.05 0 0 1 0.45,0.5 0.05,0.05 0 0 1 0.5,0.45 0.05,0.05 0 0 1 0.55,0.5 Z M 0,0 1,0 1,1 0,1 Z"; + svgd = "M 0.05,0 A 0.05,0.05 0 0 1 0,0.05 0.05,0.05 0 0 1 -0.05,0 0.05,0.05 0 0 1 0,-0.05 0.05,0.05 0 0 1 0.05,0 Z M -0.5,-0.5 0.5,-0.5 0.5,0.5 -0.5,0.5 Z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); - pathv *= Geom::Affine(diameter,0,0,diameter,0,0); - pathv += p - Geom::Point(diameter/2,diameter/2); + pathv *= Geom::Rotate::from_degrees(rotateNodes); + pathv *= Geom::Scale (diameter); + pathv += p; outlinepath.push_back(pathv[0]); outlinepath.push_back(pathv[1]); } @@ -175,8 +181,8 @@ LPEShowHandles::drawHandle(Geom::Point p) char const * svgd; svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); - pathv *= Geom::Affine(diameter,0,0,diameter,0,0); - pathv += p - Geom::Point(diameter * 0.35,diameter * 0.35); + pathv *= Geom::Scale (diameter); + pathv += p-Geom::Point(diameter * 0.35,diameter * 0.35); outlinepath.push_back(pathv[0]); } } diff --git a/src/live_effects/lpe-show_handles.h b/src/live_effects/lpe-show_handles.h index 278908bb5..a405c26ee 100644 --- a/src/live_effects/lpe-show_handles.h +++ b/src/live_effects/lpe-show_handles.h @@ -44,6 +44,7 @@ private: BoolParam handles; BoolParam originalPath; ScalarParam scaleNodesAndHandles; + ScalarParam rotateNodes; double strokeWidth; static bool alertsOff; diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp index 6c4f2a100..0884c4c9c 100644 --- a/src/live_effects/parameter/originalpath.cpp +++ b/src/live_effects/parameter/originalpath.cpp @@ -27,7 +27,7 @@ #include "live_effects/effect.h" #include "inkscape.h" -#include "desktop-handles.h" +#include "desktop.h" #include "selection.h" #include "ui/icon-names.h" @@ -128,7 +128,7 @@ OriginalPathParam::on_select_original_button_click() if (desktop == NULL || original == NULL) { return; } - Inkscape::Selection *selection = sp_desktop_selection(desktop); + Inkscape::Selection *selection = desktop->getSelection(); selection->clear(); selection->set(original); } diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index 2a14d4208..ba95affd9 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -30,7 +30,7 @@ // needed for on-canvas editting: #include "ui/tools-switch.h" #include "ui/shape-editor.h" -#include "desktop-handles.h" + #include "selection.h" // clipboard support #include "ui/clipboard.h" @@ -414,7 +414,7 @@ PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/) void PathParam::on_edit_button_click() { - SPItem * item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem(); + SPItem * item = SP_ACTIVE_DESKTOP->getSelection()->singleItem(); if (item != NULL) { param_editOncanvas(item, SP_ACTIVE_DESKTOP); } diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp index 956a001ad..234a6174d 100644 --- a/src/live_effects/parameter/text.cpp +++ b/src/live_effects/parameter/text.cpp @@ -19,6 +19,7 @@ #include "inkscape.h" #include "verbs.h" #include "display/canvas-text.h" + #include <2geom/sbasis-geometric.h> namespace Inkscape { @@ -32,8 +33,8 @@ TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip, value(default_value), defvalue(default_value) { - SPDesktop *desktop = inkscape_active_desktop(); // FIXME: we shouldn't use this! - canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), ""); + SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this! + canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), ""); sp_canvastext_set_text (canvas_text, default_value.c_str()); sp_canvastext_set_coords (canvas_text, 0, 0); } |
