summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7947f75)
raw | patch | inline | side by side (parent: 7947f75)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Sat, 22 Aug 2009 21:49:32 +0000 (21:49 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Sat, 22 Aug 2009 21:49:32 +0000 (21:49 +0000) |
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index ff2e3904437961c62e8f6481a4cb7e12ad9c323e..769fa54fd62ed41b84ac16d06b6b9251eebe0041 100644 (file)
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
#include "display/curve.h"
#include <glibmm/i18n.h>
#include <2geom/transforms.h>
+#include <2geom/pathvector.h>
#include "document.h"
#include "sp-ellipse.h"
/* 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 90e9b2d6d62e18057b40c46c71177d811b5362ef..a27344ebca69fd14c2672741ba90d8830c2d3b14 100644 (file)
--- a/src/sp-lpe-item.cpp
+++ b/src/sp-lpe-item.cpp
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 e9561c2c2c26f6f89a9ba5436c0b213d8a15d924..5b6cc241eeb2112f37cf3e1460d762ccb29ef1e4 100644 (file)
--- a/src/sp-lpe-item.h
+++ b/src/sp-lpe-item.h
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 71906fcc0c3b65d394e6333dd163c7640a7ddaed..6297153327939f3b71f5100d4675add5a31ac9ed 100644 (file)
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
#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"
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 71c9ad1c72d47bc17513335be25baf65d8c064c7..9cffd952ca2c72bb2ea91ec0b26ebdc4a9eb1933 100644 (file)
--- a/src/sp-star.cpp
+++ b/src/sp-star.cpp
#include "xml/repr.h"
#include "document.h"
+#include <2geom/pathvector.h>
+
#include "sp-star.h"
static void sp_star_class_init (SPStarClass *klass);
{
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;
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();
}
}
+/*
+ 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 :