summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-12-02 18:39:33 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-12-02 18:39:33 +0000
commit09e2f7b62d13537a0f006fc9953c533802fd9c12 (patch)
tree78c1a72538f0e60e38c3ca1845a909fcad53f394 /src/live_effects
parentadding fussion improvements (diff)
parentExtensions. Fix for Bug #1192746 (e key does not start export on firefox [Jes... (diff)
downloadinkscape-09e2f7b62d13537a0f006fc9953c533802fd9c12.tar.gz
inkscape-09e2f7b62d13537a0f006fc9953c533802fd9c12.zip
update to trunk
(bzr r13708.1.4)
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/effect.cpp6
-rw-r--r--src/live_effects/lpe-bspline.cpp22
-rw-r--r--src/live_effects/lpe-bspline.h2
-rw-r--r--src/live_effects/lpe-copy_rotate.cpp1
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp12
-rw-r--r--src/live_effects/lpe-perspective_path.cpp43
-rw-r--r--src/live_effects/lpe-perspective_path.h5
-rw-r--r--src/live_effects/lpe-roughen.cpp10
-rw-r--r--src/live_effects/parameter/filletchamferpointarray.cpp27
-rw-r--r--src/live_effects/parameter/text.cpp2
10 files changed, 53 insertions, 77 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 0f4bdfaaa..4a323cc7e 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 97a4c6205..2bed90139 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -88,25 +88,12 @@ void LPEBSpline::doBeforeEffect (SPLPEItem const* /*lpeitem*/)
}
-void LPEBSpline::createAndApply(const char *name, SPDocument *doc,
- SPItem *item)
+void LPEBSpline::doOnApply(SPLPEItem const* lpeitem)
{
- if (!SP_IS_SHAPE(item)) {
+ if (!SP_IS_SHAPE(lpeitem)) {
g_warning("LPE BSpline can only be applied to shapes (not groups).");
- } else {
- // Path effect definition
- Inkscape::XML::Document *xml_doc = doc->getReprDoc();
- Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect");
- repr->setAttribute("effect", name);
-
- doc->getDefs()->getRepr()
- ->addChild(repr, NULL); // adds to <defs> and assigns the 'id' attribute
- const gchar *repr_id = repr->attribute("id");
- Inkscape::GC::release(repr);
-
- gchar *href = g_strdup_printf("#%s", repr_id);
- SP_LPE_ITEM(item)->addPathEffect(href, true);
- g_free(href);
+ SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
+ item->removeCurrentPathEffect(false);
}
}
@@ -380,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-bspline.h b/src/live_effects/lpe-bspline.h
index 8751a5720..a17c0c4ac 100644
--- a/src/live_effects/lpe-bspline.h
+++ b/src/live_effects/lpe-bspline.h
@@ -19,10 +19,10 @@ public:
LPEBSpline(LivePathEffectObject *lpeobject);
virtual ~LPEBSpline();
- virtual void createAndApply(const char *name, SPDocument *doc, SPItem *item);
virtual LPEPathFlashType pathFlashType() const {
return SUPPRESS_FLASH;
}
+ virtual void doOnApply(SPLPEItem const* lpeitem);
virtual void doEffect(SPCurve *curve);
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
void drawHandle(Geom::Point p, double radiusHelperNodes);
diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp
index e0855d452..553f273fe 100644
--- a/src/live_effects/lpe-copy_rotate.cpp
+++ b/src/live_effects/lpe-copy_rotate.cpp
@@ -48,6 +48,7 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) :
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),
fusionPaths(_("Fusioned paths"), _("Fusion paths"), "fusionPaths", &wr, this, true),
+
origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this, "Adjust the origin of the rotation"),
dist_angle_handle(100)
{
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index 78e24f0b8..119759b87 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -79,7 +79,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) :
radius.param_set_range(0., infinity());
radius.param_set_increments(1, 1);
radius.param_set_digits(4);
- chamfer_steps.param_set_range(0, 999);
+ chamfer_steps.param_set_range(1, 999);
chamfer_steps.param_set_increments(1, 1);
chamfer_steps.param_set_digits(0);
helper_size.param_set_range(0, infinity());
@@ -431,6 +431,8 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
fillet_chamfer_values.param_set_and_write_new_value(point);
} else {
g_warning("LPE Fillet can only be applied to shapes (not groups).");
+ SPLPEItem * item = const_cast<SPLPEItem*>(lpeItem);
+ item->removeCurrentPathEffect(false);
}
}
@@ -578,8 +580,10 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
} else {
type = std::abs(filletChamferData[counter + 1][Y]);
}
- if (type >= 3000 && type < 4000) {
- unsigned int chamferSubs = type-2999;
+ if(are_near(middle_point(startArcPoint,endArcPoint),curve_it1->finalPoint(), 0.0001)){
+ path_out.appendNew<Geom::LineSegment>(endArcPoint);
+ } else if (type >= 3000 && type < 4000) {
+ unsigned int chamferSubs = type-3000;
Geom::Path path_chamfer;
path_chamfer.start(path_out.finalPoint());
if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){
@@ -594,7 +598,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
}
path_out.appendNew<Geom::LineSegment>(endArcPoint);
} else if (type >= 4000 && type < 5000) {
- unsigned int chamferSubs = type-3999;
+ unsigned int chamferSubs = type-4000;
Geom::Path path_chamfer;
path_chamfer.start(path_out.finalPoint());
if((is_straight_curve(*curve_it1) && is_straight_curve(*curve_it2Fixed) && method != FM_BEZIER )|| method == FM_ARC){
diff --git a/src/live_effects/lpe-perspective_path.cpp b/src/live_effects/lpe-perspective_path.cpp
index d43772cf7..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>
@@ -44,6 +44,8 @@ public:
} // namespace PP
static Glib::ustring perspectiveID = _("First perspective");
+
+
LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
// initialise your parameters here:
@@ -62,35 +64,42 @@ LPEPerspectivePath::LPEPerspectivePath(LivePathEffectObject *lpeobject) :
concatenate_before_pwd2 = true; // don't split the path into its subpaths
_provides_knotholder_entities = true;
- unapply = false;
- Persp3D *persp = persp3d_document_first_persp(lpeobject->document);
+}
+
+LPEPerspectivePath::~LPEPerspectivePath()
+{
+
+}
+void
+LPEPerspectivePath::doOnApply(SPLPEItem const* lpeitem)
+{
+ Persp3D *persp = persp3d_document_first_persp(lpeitem->document);
if(persp == 0 ){
char *msg = _("You need a BOX 3D object");
Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO,
Gtk::BUTTONS_OK, true);
dialog.run();
- unapply = true;
- return;
+ SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
+ item->removeCurrentPathEffect(false);
}
- Proj::TransfMat3x4 pmat = persp->perspective_impl->tmat;
- pmat = pmat * SP_ACTIVE_DESKTOP->doc2dt();
- pmat.copy_tmat(tmat);
}
-
-LPEPerspectivePath::~LPEPerspectivePath()
-{
-
-}
-
void
LPEPerspectivePath::doBeforeEffect (SPLPEItem const* lpeitem)
{
original_bbox(lpeitem, true);
- if(unapply){
- SP_LPE_ITEM(lpeitem)->removeCurrentPathEffect(false);
+ SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
+ Persp3D *persp = persp3d_document_first_persp(lpeitem->document);
+ if(persp == 0 ){
+ char *msg = _("You need a BOX 3D object");
+ Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_INFO,
+ Gtk::BUTTONS_OK, true);
+ dialog.run();
return;
}
- SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
+ Proj::TransfMat3x4 pmat = persp->perspective_impl->tmat;
+ 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-perspective_path.h b/src/live_effects/lpe-perspective_path.h
index 6ccac4a51..c4ddf1853 100644
--- a/src/live_effects/lpe-perspective_path.h
+++ b/src/live_effects/lpe-perspective_path.h
@@ -33,9 +33,8 @@ class LPEPerspectivePath : public Effect, GroupBBoxEffect {
public:
LPEPerspectivePath(LivePathEffectObject *lpeobject);
virtual ~LPEPerspectivePath();
-
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
-
+ virtual void doOnApply(SPLPEItem const* lpeitem);
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
virtual void refresh(Gtk::Entry* perspective);
@@ -53,8 +52,6 @@ private:
ScalarParam offsety;
BoolParam uses_plane_xy;
// there are all kinds of parameters. Check the /live_effects/parameter directory which types exist!
-
- bool unapply;
Geom::Point orig;
LPEPerspectivePath(const LPEPerspectivePath&);
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/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp
index 4e2be6e88..7d8c8e9b0 100644
--- a/src/live_effects/parameter/filletchamferpointarray.cpp
+++ b/src/live_effects/parameter/filletchamferpointarray.cpp
@@ -693,28 +693,6 @@ void FilletChamferPointArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
knot_mode = mode;
knot_color = color;
}
-/*
-class FilletChamferPointArrayParamKnotHolderEntity : public KnotHolderEntity {
-public:
- FilletChamferPointArrayParamKnotHolderEntity(FilletChamferPointArrayParam
-*p, unsigned int index);
- virtual ~FilletChamferPointArrayParamKnotHolderEntity() {}
-
- virtual void knot_set(Point const &p, Point const &origin, guint state);
- virtual Point knot_get() const;
- virtual void knot_click(guint state);
- virtual void knot_doubleclicked(guint state);
-
- /Checks whether the index falls within the size of the parameter's vector/
- bool valid_index(unsigned int index) const {
- return (_pparam->_vector.size() > index);
- };
-
-private:
- FilletChamferPointArrayParam *_pparam;
- unsigned int _index;
-};
-/*/
FilletChamferPointArrayParamKnotHolderEntity::
FilletChamferPointArrayParamKnotHolderEntity(
@@ -730,11 +708,10 @@ void FilletChamferPointArrayParamKnotHolderEntity::knot_set(Point const &p,
if (!valid_index(_index)) {
return;
}
- /// @todo how about item transforms???
Piecewise<D2<SBasis> > const &pwd2 = _pparam->get_pwd2();
- //todo: add snapping
- Geom::Point const s = snap_knot_position(p, state);
double t = nearest_point(p, pwd2[_index]);
+ Geom::Point const s = snap_knot_position(pwd2[_index].valueAt(t), state);
+ t = nearest_point(s, pwd2[_index]);
if (t == 1) {
t = 0.9999;
}
diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp
index 956a001ad..a88ac7d75 100644
--- a/src/live_effects/parameter/text.cpp
+++ b/src/live_effects/parameter/text.cpp
@@ -32,7 +32,7 @@ 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!
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this!
canvas_text = (SPCanvasText *) sp_canvastext_new(sp_desktop_tempgroup(desktop), desktop, Geom::Point(0,0), "");
sp_canvastext_set_text (canvas_text, default_value.c_str());
sp_canvastext_set_coords (canvas_text, 0, 0);