summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2009-08-22 21:49:32 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2009-08-22 21:49:32 +0000
commit6c059afd9ecdd6fc153e8e9ce0a9e5817fa3086c (patch)
tree95b3520ec96e0f8ad5f695f4d70ca483848ab9e2 /src
parentfix 272408 and address fixmes: fix inheriting of dasharray and dashoffset, ma... (diff)
downloadinkscape-6c059afd9ecdd6fc153e8e9ce0a9e5817fa3086c.tar.gz
inkscape-6c059afd9ecdd6fc153e8e9ce0a9e5817fa3086c.zip
fix rendering of testcase errorhandling-nosuchlpe.svg: make sure shapes do not calculate the curve if they have a broken lpe, instead reading it directly from d= and issuing a warning
(bzr r8520)
Diffstat (limited to 'src')
-rw-r--r--src/sp-ellipse.cpp13
-rw-r--r--src/sp-lpe-item.cpp18
-rw-r--r--src/sp-lpe-item.h1
-rw-r--r--src/sp-spiral.cpp17
-rw-r--r--src/sp-star.cpp29
5 files changed, 75 insertions, 3 deletions
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index ff2e39044..769fa54fd 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -28,6 +28,7 @@
#include "display/curve.h"
#include <glibmm/i18n.h>
#include <2geom/transforms.h>
+#include <2geom/pathvector.h>
#include "document.h"
#include "sp-ellipse.h"
@@ -184,6 +185,18 @@ sp_genericellipse_update_patheffect(SPLPEItem *lpeitem, bool write)
/* Can't we use arcto in this method? */
static void sp_genericellipse_set_shape(SPShape *shape)
{
+ if (sp_lpe_item_has_broken_path_effect(SP_LPE_ITEM(shape))) {
+ g_warning ("The ellipse shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as ellipse will remove the bad LPE");
+ if (SP_OBJECT_REPR(shape)->attribute("d")) {
+ // unconditionally read the curve from d, if any, to preserve appearance
+ Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
+ SPCurve *cold = new SPCurve(pv);
+ sp_shape_set_curve_insync (shape, cold, TRUE);
+ cold->unref();
+ }
+ return;
+ }
+
double rx, ry, s, e;
double x0, y0, x1, y1, x2, y2, x3, y3;
double len;
diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp
index 90e9b2d6d..a27344ebc 100644
--- a/src/sp-lpe-item.cpp
+++ b/src/sp-lpe-item.cpp
@@ -598,6 +598,24 @@ void sp_lpe_item_up_current_path_effect(SPLPEItem *lpeitem)
sp_lpe_item_cleanup_original_path_recursive(lpeitem);
}
+/** used for shapes so they can see if they should also disable shape calculation and read from d= */
+bool sp_lpe_item_has_broken_path_effect(SPLPEItem *lpeitem)
+{
+ if (lpeitem->path_effect_list->empty())
+ return false;
+
+ // go through the list; if some are unknown or invalid, return true
+ PathEffectList effect_list = sp_lpe_item_get_effect_list(lpeitem);
+ for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); it++)
+ {
+ LivePathEffectObject *lpeobj = (*it)->lpeobject;
+ if (!lpeobj || !lpeobj->get_lpe())
+ return true;
+ }
+
+ return false;
+}
+
bool sp_lpe_item_has_path_effect(SPLPEItem *lpeitem)
{
diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h
index e9561c2c2..5b6cc241e 100644
--- a/src/sp-lpe-item.h
+++ b/src/sp-lpe-item.h
@@ -64,6 +64,7 @@ void sp_lpe_item_remove_current_path_effect(SPLPEItem *lpeitem, bool keep_paths)
void sp_lpe_item_down_current_path_effect(SPLPEItem *lpeitem);
void sp_lpe_item_up_current_path_effect(SPLPEItem *lpeitem);
bool sp_lpe_item_has_path_effect(SPLPEItem *lpeitem);
+bool sp_lpe_item_has_broken_path_effect(SPLPEItem *lpeitem);
bool sp_lpe_item_has_path_effect_recursive(SPLPEItem *lpeitem);
Inkscape::LivePathEffect::Effect* sp_lpe_item_has_path_effect_of_type(SPLPEItem *lpeitem, int type);
bool sp_lpe_item_can_accept_freehand_shape(SPLPEItem *lpeitem);
diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index 71906fcc0..629715332 100644
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
@@ -20,6 +20,7 @@
#include "svg/svg.h"
#include "attributes.h"
#include <2geom/bezier-utils.h>
+#include <2geom/pathvector.h>
#include "display/curve.h"
#include <glibmm/i18n.h>
#include "xml/repr.h"
@@ -418,11 +419,23 @@ sp_spiral_fit_and_draw (SPSpiral const *spiral,
static void
sp_spiral_set_shape (SPShape *shape)
{
+ SPSpiral *spiral = SP_SPIRAL(shape);
+
+ if (sp_lpe_item_has_broken_path_effect(SP_LPE_ITEM(shape))) {
+ g_warning ("The spiral shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as spiral will remove the bad LPE");
+ if (SP_OBJECT_REPR(shape)->attribute("d")) {
+ // unconditionally read the curve from d, if any, to preserve appearance
+ Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
+ SPCurve *cold = new SPCurve(pv);
+ sp_shape_set_curve_insync (shape, cold, TRUE);
+ cold->unref();
+ }
+ return;
+ }
+
Geom::Point darray[SAMPLE_SIZE + 1];
double t;
- SPSpiral *spiral = SP_SPIRAL(shape);
-
SP_OBJECT (spiral)->requestModified(SP_OBJECT_MODIFIED_FLAG);
SPCurve *c = new SPCurve ();
diff --git a/src/sp-star.cpp b/src/sp-star.cpp
index 71c9ad1c7..9cffd952c 100644
--- a/src/sp-star.cpp
+++ b/src/sp-star.cpp
@@ -28,6 +28,8 @@
#include "xml/repr.h"
#include "document.h"
+#include <2geom/pathvector.h>
+
#include "sp-star.h"
static void sp_star_class_init (SPStarClass *klass);
@@ -428,6 +430,21 @@ sp_star_set_shape (SPShape *shape)
{
SPStar *star = SP_STAR (shape);
+ // perhaps we should convert all our shapes into LPEs without source path
+ // and with knotholders for parameters, then this situation will be handled automatically
+ // by disabling the entire stack (including the shape LPE)
+ if (sp_lpe_item_has_broken_path_effect(SP_LPE_ITEM(shape))) {
+ g_warning ("The star shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as star will remove the bad LPE");
+ if (SP_OBJECT_REPR(shape)->attribute("d")) {
+ // unconditionally read the curve from d, if any, to preserve appearance
+ Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
+ SPCurve *cold = new SPCurve(pv);
+ sp_shape_set_curve_insync (shape, cold, TRUE);
+ cold->unref();
+ }
+ return;
+ }
+
SPCurve *c = new SPCurve ();
gint sides = star->sides;
@@ -500,7 +517,7 @@ sp_star_set_shape (SPShape *shape)
bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe);
if (success) {
sp_shape_set_curve_insync (shape, c_lpe, TRUE);
- }
+ }
c_lpe->unref();
}
c->unref();
@@ -587,3 +604,13 @@ sp_star_get_xy (SPStar *star, SPStarPoint point, gint index, bool randomized)
}
}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :