summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-03-26 04:34:25 +0000
committerTed Gould <ted@gould.cx>2010-03-26 04:34:25 +0000
commit9e023a3aa964a0d3fa1e31e46d33657367ba68aa (patch)
tree33f1392a340737e4eeefca6fd031f96c29befd2b /src/live_effects
parentInstalling the pkgconfig file (diff)
parentAdding in shape-record.h (diff)
downloadinkscape-9e023a3aa964a0d3fa1e31e46d33657367ba68aa.tar.gz
inkscape-9e023a3aa964a0d3fa1e31e46d33657367ba68aa.zip
Merge from trunk
(bzr r8254.1.53)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/effect.cpp9
-rw-r--r--src/live_effects/effect.h2
-rw-r--r--src/live_effects/lpe-constructgrid.cpp9
-rw-r--r--src/live_effects/lpe-constructgrid.h2
-rw-r--r--src/live_effects/lpe-extrude.cpp60
-rw-r--r--src/live_effects/lpe-gears.cpp11
-rw-r--r--src/live_effects/lpe-gears.h2
-rw-r--r--src/live_effects/lpe-lattice.cpp1
-rw-r--r--src/live_effects/lpe-rough-hatches.cpp4
-rw-r--r--src/live_effects/lpe-spiro.cpp9
-rw-r--r--src/live_effects/lpe-spiro.h1
-rw-r--r--src/live_effects/lpe-vonkoch.cpp7
-rw-r--r--src/live_effects/parameter/path.cpp37
-rw-r--r--src/live_effects/parameter/vector.cpp30
14 files changed, 100 insertions, 84 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 9232792f6..f761a6a7c 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -28,7 +28,6 @@
#include "tools-switch.h"
#include "message-stack.h"
#include "desktop.h"
-#include "nodepath.h"
#include "knotholder.h"
#include "live_effects/lpeobject.h"
@@ -665,13 +664,6 @@ Effect::resetDefaults(SPItem * /*item*/)
}
void
-Effect::setup_nodepath(Inkscape::NodePath::Path *np)
-{
- np->helperpath_rgba = 0xff0000ff;
- np->helperpath_width = 1.0;
-}
-
-void
Effect::transform_multiply(Geom::Matrix const& postmul, bool set)
{
// cycle through all parameters. Most parameters will not need transformation, but path and point params do.
@@ -681,7 +673,6 @@ Effect::transform_multiply(Geom::Matrix const& postmul, bool set)
}
}
-// TODO: take _all_ parameters into account, not only PointParams
bool
Effect::providesKnotholder()
{
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 5d67ed016..a8d34a233 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -92,8 +92,6 @@ public:
*/
virtual void resetDefaults(SPItem * item);
- virtual void setup_nodepath(Inkscape::NodePath::Path *np);
-
/// /todo: is this method really necessary? it causes UI inconsistensies... (johan)
virtual void transform_multiply(Geom::Matrix const& postmul, bool set);
diff --git a/src/live_effects/lpe-constructgrid.cpp b/src/live_effects/lpe-constructgrid.cpp
index 144f4720d..4725573d7 100644
--- a/src/live_effects/lpe-constructgrid.cpp
+++ b/src/live_effects/lpe-constructgrid.cpp
@@ -16,8 +16,6 @@
#include <2geom/path.h>
#include <2geom/transforms.h>
-#include "nodepath.h"
-
namespace Inkscape {
namespace LivePathEffect {
@@ -81,13 +79,6 @@ LPEConstructGrid::doEffect_path (std::vector<Geom::Path> const & path_in)
}
}
-void
-LPEConstructGrid::setup_nodepath(Inkscape::NodePath::Path *np)
-{
- Effect::setup_nodepath(np);
- sp_nodepath_make_straight_path(np);
-}
-
} //namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-constructgrid.h b/src/live_effects/lpe-constructgrid.h
index 716960d32..c7e695794 100644
--- a/src/live_effects/lpe-constructgrid.h
+++ b/src/live_effects/lpe-constructgrid.h
@@ -27,8 +27,6 @@ public:
virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in);
- virtual void setup_nodepath(Inkscape::NodePath::Path *np);
-
private:
ScalarParam nr_x;
ScalarParam nr_y;
diff --git a/src/live_effects/lpe-extrude.cpp b/src/live_effects/lpe-extrude.cpp
index af933eae6..c861515aa 100644
--- a/src/live_effects/lpe-extrude.cpp
+++ b/src/live_effects/lpe-extrude.cpp
@@ -16,6 +16,7 @@
#include <2geom/path.h>
#include <2geom/piecewise.h>
#include <2geom/transforms.h>
+#include <algorithm>
namespace Inkscape {
namespace LivePathEffect {
@@ -35,6 +36,25 @@ LPEExtrude::~LPEExtrude()
}
+static bool are_colinear(Geom::Point a, Geom::Point b) {
+ return Geom::are_near(cross(a,b), 0., 0.5);
+}
+
+// find cusps, except at start/end for closed paths.
+// this should be factored out later.
+static std::vector<double> find_cusps( Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in ) {
+ using namespace Geom;
+ Piecewise<D2<SBasis> > deriv = derivative(pwd2_in);
+ std::vector<double> cusps;
+ // cusps are spots where the derivative jumps.
+ for (unsigned i = 1 ; i < deriv.size() ; ++i) {
+ if ( ! are_colinear(deriv[i-1].at1(), deriv[i].at0()) ) {
+ // there is a jump in the derivative, so add it to the cusps list
+ cusps.push_back(deriv.cuts[i]);
+ }
+ }
+ return cusps;
+}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPEExtrude::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
@@ -48,6 +68,9 @@ LPEExtrude::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2
switch( 1 ) {
case 0: {
+ /* This one results in the following subpaths: the original, a displaced copy, and connector lines between the two
+ */
+
Piecewise<D2<SBasis> > pwd2_out = pwd2_in;
// generate extrusion bottom: (just a copy of original path, displaced a bit)
pwd2_out.concat( pwd2_in + extrude_vector.getVector() );
@@ -75,15 +98,42 @@ LPEExtrude::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2
default:
case 1: {
+ /* This one creates separate closed subpaths that correspond to the faces of the extruded shape.
+ * When the LPE is complete, one can convert the shape to a normal path, then break subpaths apart and start coloring them.
+ */
+
Piecewise<D2<SBasis> > pwd2_out;
- bool closed_path = are_near(pwd2_in.firstValue(), pwd2_in.lastValue());
// split input path in pieces between points where deriv == vector
Piecewise<D2<SBasis> > deriv = derivative(pwd2_in);
std::vector<double> rts = roots(dot(deriv, rot90(extrude_vector.getVector())));
+
+ std::vector<double> cusps = find_cusps(pwd2_in);
+
+ // see if we should treat the path as being closed.
+ bool closed_path = false;
+ if ( are_near(pwd2_in.firstValue(), pwd2_in.lastValue()) ) {
+ // the path is closed, however if there is a cusp at the closing point, we should treat it as being an open path.
+ if ( are_colinear(deriv.firstValue(), deriv.lastValue()) ) {
+ // there is no jump in the derivative, so treat path as being closed
+ closed_path = true;
+ }
+ }
+
+ std::vector<double> connector_pts;
+ if (rts.size() < 1) {
+ connector_pts = cusps;
+ } else if (cusps.size() < 1) {
+ connector_pts = rts;
+ } else {
+ connector_pts = rts;
+ connector_pts.insert(connector_pts.begin(), cusps.begin(), cusps.end());
+ sort(connector_pts.begin(), connector_pts.end());
+ }
+
double portion_t = 0.;
- for (unsigned i = 0; i < rts.size() ; ++i) {
- Piecewise<D2<SBasis> > cut = portion(pwd2_in, portion_t, rts[i] );
- portion_t = rts[i];
+ for (unsigned i = 0; i < connector_pts.size() ; ++i) {
+ Piecewise<D2<SBasis> > cut = portion(pwd2_in, portion_t, connector_pts[i] );
+ portion_t = connector_pts[i];
if (closed_path && i == 0) {
// if the path is closed, skip the first cut and add it to the last cut later
continue;
@@ -96,7 +146,7 @@ LPEExtrude::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2
}
if (closed_path) {
Piecewise<D2<SBasis> > cut = portion(pwd2_in, portion_t, pwd2_in.domain().max() );
- cut.continuousConcat(portion(pwd2_in, pwd2_in.domain().min(), rts[0] ));
+ cut.continuousConcat(portion(pwd2_in, pwd2_in.domain().min(), connector_pts[0] ));
Piecewise<D2<SBasis> > part = cut;
part.continuousConcat(connector + cut.lastValue());
part.continuousConcat(reverse(cut) + extrude_vector.getVector());
diff --git a/src/live_effects/lpe-gears.cpp b/src/live_effects/lpe-gears.cpp
index e211483c6..00f7ec193 100644
--- a/src/live_effects/lpe-gears.cpp
+++ b/src/live_effects/lpe-gears.cpp
@@ -2,6 +2,8 @@
/*
* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ * Copyright 2006 Michael G. Sloan <mgsloan@gmail.com>
+ * Copyright 2006 Aaron Spike <aaron@ekips.org>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
@@ -14,8 +16,6 @@
#include <2geom/bezier-to-sbasis.h>
#include <2geom/path.h>
-#include "nodepath.h"
-
using std::vector;
using namespace Geom;
@@ -261,13 +261,6 @@ LPEGears::doEffect_path (std::vector<Geom::Path> const & path_in)
return path_out;
}
-void
-LPEGears::setup_nodepath(Inkscape::NodePath::Path *np)
-{
- Effect::setup_nodepath(np);
- sp_nodepath_make_straight_path(np);
-}
-
} // namespace LivePathEffect
} /* namespace Inkscape */
diff --git a/src/live_effects/lpe-gears.h b/src/live_effects/lpe-gears.h
index 4c3a9938b..bd5e4c4f9 100644
--- a/src/live_effects/lpe-gears.h
+++ b/src/live_effects/lpe-gears.h
@@ -24,8 +24,6 @@ public:
virtual std::vector<Geom::Path> doEffect_path (std::vector<Geom::Path> const & path_in);
- virtual void setup_nodepath(Inkscape::NodePath::Path *np);
-
private:
ScalarParam teeth;
ScalarParam phi;
diff --git a/src/live_effects/lpe-lattice.cpp b/src/live_effects/lpe-lattice.cpp
index 0beedb537..50ecdf04b 100644
--- a/src/live_effects/lpe-lattice.cpp
+++ b/src/live_effects/lpe-lattice.cpp
@@ -22,7 +22,6 @@
#include "sp-path.h"
#include "display/curve.h"
#include "svg/svg.h"
-#include "nodepath.h"
#include <2geom/sbasis.h>
#include <2geom/sbasis-2d.h>
diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp
index 228857ebf..f110aa743 100644
--- a/src/live_effects/lpe-rough-hatches.cpp
+++ b/src/live_effects/lpe-rough-hatches.cpp
@@ -279,6 +279,10 @@ LPERoughHatches::LPERoughHatches(LivePathEffectObject *lpeobject) :
front_thickness.param_set_range(0, NR_HUGE);
back_thickness.param_set_range(0, NR_HUGE);
+ // hide the widgets for direction and bender vectorparams
+ direction.widget_is_visible = false;
+ bender.widget_is_visible = false;
+
concatenate_before_pwd2 = false;
show_orig_path = true;
}
diff --git a/src/live_effects/lpe-spiro.cpp b/src/live_effects/lpe-spiro.cpp
index 794fd980e..7c8262af6 100644
--- a/src/live_effects/lpe-spiro.cpp
+++ b/src/live_effects/lpe-spiro.cpp
@@ -7,7 +7,6 @@
#include "live_effects/lpe-spiro.h"
#include "display/curve.h"
-#include "nodepath.h"
#include <typeinfo>
#include <2geom/pathvector.h>
#include <2geom/matrix.h>
@@ -116,14 +115,6 @@ LPESpiro::~LPESpiro()
}
void
-LPESpiro::setup_nodepath(Inkscape::NodePath::Path *np)
-{
- Effect::setup_nodepath(np);
- sp_nodepath_show_handles(np, false);
-// sp_nodepath_show_helperpath(np, false);
-}
-
-void
LPESpiro::doEffect(SPCurve * curve)
{
using Geom::X;
diff --git a/src/live_effects/lpe-spiro.h b/src/live_effects/lpe-spiro.h
index 7256665a2..4fcd9eaaa 100644
--- a/src/live_effects/lpe-spiro.h
+++ b/src/live_effects/lpe-spiro.h
@@ -24,7 +24,6 @@ public:
virtual LPEPathFlashType pathFlashType() { return SUPPRESS_FLASH; }
- virtual void setup_nodepath(Inkscape::NodePath::Path *np);
virtual void doEffect(SPCurve * curve);
private:
diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp
index 7fd0ac0b4..85f8cde0c 100644
--- a/src/live_effects/lpe-vonkoch.cpp
+++ b/src/live_effects/lpe-vonkoch.cpp
@@ -8,7 +8,6 @@
#include <cstdio>
#include "live_effects/lpe-vonkoch.h"
-#include "nodepath.h"
#include <2geom/transforms.h>
//using std::vector;
@@ -19,7 +18,7 @@ void
VonKochPathParam::param_setup_nodepath(Inkscape::NodePath::Path *np)
{
PathParam::param_setup_nodepath(np);
- sp_nodepath_make_straight_path(np);
+ //sp_nodepath_make_straight_path(np);
}
//FIXME: a path is used here instead of 2 points to work around path/point param incompatibility bug.
@@ -27,12 +26,12 @@ void
VonKochRefPathParam::param_setup_nodepath(Inkscape::NodePath::Path *np)
{
PathParam::param_setup_nodepath(np);
- sp_nodepath_make_straight_path(np);
+ //sp_nodepath_make_straight_path(np);
}
bool
VonKochRefPathParam::param_readSVGValue(const gchar * strvalue)
{
- std::vector<Geom::Path> old = _pathvector;
+ Geom::PathVector old = _pathvector;
bool res = PathParam::param_readSVGValue(strvalue);
if (res && _pathvector.size()==1 && _pathvector.front().size()==1){
return true;
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index 33e50155c..d8d5b0a7c 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -28,10 +28,8 @@
// needed for on-canvas editting:
#include "tools-switch.h"
#include "shape-editor.h"
-#include "node-context.h"
#include "desktop-handles.h"
#include "selection.h"
-#include "nodepath.h"
// clipboard support
#include "ui/clipboard.h"
// required for linking to other paths
@@ -40,6 +38,10 @@
#include "sp-text.h"
#include "display/curve.h"
+#include "ui/tool/node-tool.h"
+#include "ui/tool/multi-path-manipulator.h"
+#include "ui/tool/shape-record.h"
+
namespace Inkscape {
@@ -193,28 +195,35 @@ PathParam::param_newWidget(Gtk::Tooltips * tooltips)
}
void
-PathParam::param_editOncanvas(SPItem * item, SPDesktop * dt)
+PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt)
{
- // If not already in nodecontext, goto it!
+ using namespace Inkscape::UI;
+
+ // TODO remove the tools_switch atrocity.
if (!tools_isactive(dt, TOOLS_NODES)) {
tools_switch(dt, TOOLS_NODES);
}
- ShapeEditor * shape_editor = dt->event_context->shape_editor;
+ InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+ std::set<ShapeRecord> shapes;
+ ShapeRecord r;
+
+ r.role = SHAPE_ROLE_LPE_PARAM;
+ r.edit_transform = sp_item_i2d_affine(item); // TODO is it right?
if (!href) {
- shape_editor->set_item_lpe_path_parameter(item, param_effect->getLPEObj(), param_key.c_str());
+ r.item = reinterpret_cast<SPItem*>(param_effect->getLPEObj());
+ r.lpe_key = param_key;
} else {
- // set referred item for editing
- shape_editor->set_item(ref.getObject(), SH_NODEPATH);
+ r.item = ref.getObject();
}
+ shapes.insert(r);
+ nt->_multipath->setItems(shapes);
}
void
-PathParam::param_setup_nodepath(Inkscape::NodePath::Path *np)
+PathParam::param_setup_nodepath(Inkscape::NodePath::Path *)
{
- np->show_helperpath = true;
- np->helperpath_rgba = 0x009000ff;
- np->helperpath_width = 1.0;
+ // TODO this method should not exist at all!
}
void
@@ -403,7 +412,7 @@ void
PathParam::on_paste_button_click()
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- Glib::ustring svgd = cm->getPathParameter();
+ Glib::ustring svgd = cm->getPathParameter(SP_ACTIVE_DESKTOP);
paste_param_path(svgd.data());
sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
_("Paste path parameter"));
@@ -420,7 +429,7 @@ void
PathParam::on_link_button_click()
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
- Glib::ustring pathid = cm->getShapeOrTextObjectId();
+ Glib::ustring pathid = cm->getShapeOrTextObjectId(SP_ACTIVE_DESKTOP);
if (pathid == "") {
return;
diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp
index 35afe7f5d..5496b52f2 100644
--- a/src/live_effects/parameter/vector.cpp
+++ b/src/live_effects/parameter/vector.cpp
@@ -13,8 +13,9 @@
#include "svg/stringstream.h"
#include <gtkmm.h>
-// needed for on-canvas editting:
-class SPDesktop;
+#include "ui/widget/registered-widget.h"
+#include "live_effects/effect.h"
+#include "desktop.h"
namespace Inkscape {
@@ -82,28 +83,23 @@ VectorParam::param_getSVGValue() const
Gtk::Widget *
VectorParam::param_newWidget(Gtk::Tooltips * /*tooltips*/)
{
-/*
- Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage(
- new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label,
- param_tooltip,
- param_key,
- *param_wr,
- param_effect->getRepr(),
- param_effect->getSPDoc() ) );
- // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP)
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- Geom::Matrix transf = desktop->doc2dt();
- pointwdg->setTransform(transf);
- pointwdg->setValue( *this );
+ Inkscape::UI::Widget::RegisteredVector * pointwdg = Gtk::manage(
+ new Inkscape::UI::Widget::RegisteredVector( param_label,
+ param_tooltip,
+ param_key,
+ *param_wr,
+ param_effect->getRepr(),
+ param_effect->getSPDoc() ) );
+ pointwdg->setPolarCoords();
+ pointwdg->setValue( vector, origin );
pointwdg->clearProgrammatically();
- pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
+ pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change vector parameter"));
Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
static_cast<Gtk::HBox*>(hbox)->show_all_children();
return dynamic_cast<Gtk::Widget *> (hbox);
- */ return NULL;
}
void