summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-11-17 22:27:50 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-11-17 22:27:50 +0000
commitdf29620f545c2eaf2ddb845f8d1d10b443e512be (patch)
treec5a3abfbf1bba71c5e0e6ad0f0fea3186f915ff9 /src
parentadding knot improvements pointed by su_v (diff)
parentfix a bug in fillet/chamfer on apply on non shapes (diff)
downloadinkscape-df29620f545c2eaf2ddb845f8d1d10b443e512be.tar.gz
inkscape-df29620f545c2eaf2ddb845f8d1d10b443e512be.zip
update to trunk
(bzr r13682.1.14)
Diffstat (limited to 'src')
-rw-r--r--src/attribute-rel-css.cpp1
-rw-r--r--src/attribute-rel-svg.cpp1
-rw-r--r--src/document.cpp6
-rw-r--r--src/live_effects/lpe-bspline.cpp21
-rw-r--r--src/live_effects/lpe-bspline.h2
-rw-r--r--src/live_effects/lpe-copy_rotate.cpp59
-rw-r--r--src/live_effects/lpe-copy_rotate.h5
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp12
-rw-r--r--src/live_effects/lpe-perspective_path.cpp40
-rw-r--r--src/live_effects/lpe-perspective_path.h5
-rw-r--r--src/live_effects/parameter/filletchamferpointarray.cpp25
-rw-r--r--src/sp-ellipse.cpp6
12 files changed, 64 insertions, 119 deletions
diff --git a/src/attribute-rel-css.cpp b/src/attribute-rel-css.cpp
index 89678edb5..b904cd5f4 100644
--- a/src/attribute-rel-css.cpp
+++ b/src/attribute-rel-css.cpp
@@ -60,6 +60,7 @@ bool SPAttributeRelCSS::findIfValid(Glib::ustring property, Glib::ustring elemen
|| property.substr(0,4) == "rdf:"
|| property.substr(0,3) == "cc:"
|| property.substr(0,4) == "ns1:" // JessyInk
+ || property.substr(0,4) == "osb:" // Open Swatch Book
|| (SPAttributeRelCSS::instance->propertiesOfElements[temp].find(property)
!= SPAttributeRelCSS::instance->propertiesOfElements[temp].end()) ) {
return true;
diff --git a/src/attribute-rel-svg.cpp b/src/attribute-rel-svg.cpp
index 49c97ae64..0064f4c62 100644
--- a/src/attribute-rel-svg.cpp
+++ b/src/attribute-rel-svg.cpp
@@ -56,6 +56,7 @@ bool SPAttributeRelSVG::findIfValid(Glib::ustring attribute, Glib::ustring eleme
|| attribute.substr(0,4) == "rdf:"
|| attribute.substr(0,3) == "cc:"
|| attribute.substr(0,4) == "ns1:" // JessyInk
+ || attribute.substr(0,4) == "osb:" // Open Swatch Book
|| (SPAttributeRelSVG::instance->attributesOfElements[temp].find(attribute)
!= SPAttributeRelSVG::instance->attributesOfElements[temp].end()) ) {
return true;
diff --git a/src/document.cpp b/src/document.cpp
index e5b827937..f5269eab3 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -713,11 +713,9 @@ void SPDocument::fitToRect(Geom::Rect const &rect, bool with_margins)
double const old_height = getHeight().value("px");
Inkscape::Util::Unit const *nv_units = unit_table.getUnit("px");
+ if (root->height.unit)
+ nv_units = unit_table.getUnit(root->height.unit);
SPNamedView *nv = sp_document_namedview(this, NULL);
- if (nv != NULL) {
- if (nv->getAttribute("units"))
- nv_units = unit_table.getUnit(nv->getAttribute("units"));
- }
/* in px */
double margin_top = 0.0;
diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index 97a4c6205..c5390a0c9 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);
}
}
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 e466093d3..51787e292 100644
--- a/src/live_effects/lpe-copy_rotate.cpp
+++ b/src/live_effects/lpe-copy_rotate.cpp
@@ -38,12 +38,6 @@ public:
virtual Geom::Point knot_get() const;
};
-class KnotHolderEntityRotationAngle : public LPEKnotHolderEntity {
-public:
- KnotHolderEntityRotationAngle(LPECopyRotate *effect) : LPEKnotHolderEntity(effect) {};
- virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
- virtual Geom::Point knot_get() const;
-};
} // namespace CR
@@ -52,6 +46,7 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) :
starting_angle(_("Starting:"), _("Angle of the first copy"), "starting_angle", &wr, this, 0.0),
rotation_angle(_("Rotation angle:"), _("Angle between two successive copies"), "rotation_angle", &wr, this, 30.0),
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),
origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this, "Adjust the origin of the rotation"),
dist_angle_handle(100)
{
@@ -59,6 +54,7 @@ LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) :
_provides_knotholder_entities = true;
// register all your parameters here, so Inkscape knows which parameters this effect has:
+ registerParameter( dynamic_cast<Parameter *>(&copiesTo360) );
registerParameter( dynamic_cast<Parameter *>(&starting_angle) );
registerParameter( dynamic_cast<Parameter *>(&rotation_angle) );
registerParameter( dynamic_cast<Parameter *>(&num_copies) );
@@ -76,11 +72,13 @@ LPECopyRotate::~LPECopyRotate()
void
LPECopyRotate::doOnApply(SPLPEItem const* lpeitem)
{
- SPCurve const *curve = SP_SHAPE(lpeitem)->_curve;
+ using namespace Geom;
- A = *(curve->first_point());
- B = *(curve->last_point());
+ original_bbox(lpeitem);
+ Point A(boundingbox_X.min(), boundingbox_Y.middle());
+ Point B(boundingbox_X.max(), boundingbox_Y.middle());
+ Point C(boundingbox_X.middle(), boundingbox_Y.middle());
origin.param_setValue(A);
dir = unit_vector(B - A);
@@ -95,7 +93,11 @@ LPECopyRotate::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
// I first suspected the minus sign to be a bug in 2geom but it is
// likely due to SVG's choice of coordinate system orientation (max)
start_pos = origin + dir * Rotate(-deg_to_rad(starting_angle)) * dist_angle_handle;
- rot_pos = origin + dir * Rotate(-deg_to_rad(starting_angle + rotation_angle)) * dist_angle_handle;
+ double rotation_angle_end = rotation_angle;
+ if(copiesTo360){
+ rotation_angle_end = 360.0/(double)num_copies;
+ }
+ rot_pos = origin + dir * Rotate(-deg_to_rad(starting_angle + rotation_angle_end)) * dist_angle_handle;
A = pwd2_in.firstValue();
B = pwd2_in.lastValue();
@@ -107,7 +109,7 @@ LPECopyRotate::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
for (int i = 0; i < num_copies; ++i) {
// I first suspected the minus sign to be a bug in 2geom but it is
// likely due to SVG's choice of coordinate system orientation (max)
- Rotate rot(-deg_to_rad(rotation_angle * i));
+ Rotate rot(-deg_to_rad(rotation_angle_end * i));
Affine t = pre * rot * Translate(origin);
output.concat(pwd2_in * t);
}
@@ -123,12 +125,12 @@ LPECopyRotate::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geo
Path path(start_pos);
path.appendNew<LineSegment>((Geom::Point) origin);
path.appendNew<LineSegment>(rot_pos);
-
PathVector pathv;
pathv.push_back(path);
hp_vec.push_back(pathv);
}
+
void LPECopyRotate::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
{
KnotHolderEntity *e = new CR::KnotHolderEntityStartingAngle(this);
@@ -136,12 +138,6 @@ void LPECopyRotate::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *des
_("Adjust the starting angle") );
knotholder->add(e);
}
- {
- KnotHolderEntity *e = new CR::KnotHolderEntityRotationAngle(this);
- e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN,
- _("Adjust the rotation angle") );
- knotholder->add(e);
- }
};
namespace CR {
@@ -168,26 +164,6 @@ KnotHolderEntityStartingAngle::knot_set(Geom::Point const &p, Geom::Point const
sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
}
-void
-KnotHolderEntityRotationAngle::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state)
-{
- LPECopyRotate* lpe = dynamic_cast<LPECopyRotate *>(_effect);
-
- Geom::Point const s = snap_knot_position(p, state);
-
- // I first suspected the minus sign to be a bug in 2geom but it is
- // likely due to SVG's choice of coordinate system orientation (max)
- lpe->rotation_angle.param_set_value(rad_to_deg(-angle_between(lpe->dir, s - lpe->origin)) - lpe->starting_angle);
- if (state & GDK_SHIFT_MASK) {
- lpe->dist_angle_handle = L2(lpe->B - lpe->A);
- } else {
- lpe->dist_angle_handle = L2(p - lpe->origin);
- }
-
- // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating.
- sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
-}
-
Geom::Point
KnotHolderEntityStartingAngle::knot_get() const
{
@@ -195,13 +171,6 @@ KnotHolderEntityStartingAngle::knot_get() const
return lpe->start_pos;
}
-Geom::Point
-KnotHolderEntityRotationAngle::knot_get() const
-{
- LPECopyRotate const *lpe = dynamic_cast<LPECopyRotate const*>(_effect);
- return lpe->rot_pos;
-}
-
} // namespace CR
diff --git a/src/live_effects/lpe-copy_rotate.h b/src/live_effects/lpe-copy_rotate.h
index ca7aa269c..123c92cdd 100644
--- a/src/live_effects/lpe-copy_rotate.h
+++ b/src/live_effects/lpe-copy_rotate.h
@@ -16,6 +16,7 @@
#include "live_effects/effect.h"
#include "live_effects/parameter/point.h"
+#include "live_effects/lpegroupbbox.h"
namespace Inkscape {
namespace LivePathEffect {
@@ -26,7 +27,7 @@ namespace CR {
class KnotHolderEntityRotationAngle;
}
-class LPECopyRotate : public Effect {
+class LPECopyRotate : public Effect, GroupBBoxEffect {
public:
LPECopyRotate(LivePathEffectObject *lpeobject);
virtual ~LPECopyRotate();
@@ -37,7 +38,6 @@ public:
/* the knotholder entity classes must be declared friends */
friend class CR::KnotHolderEntityStartingAngle;
- friend class CR::KnotHolderEntityRotationAngle;
void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
protected:
@@ -47,6 +47,7 @@ private:
ScalarParam starting_angle;
ScalarParam rotation_angle;
ScalarParam num_copies;
+ BoolParam copiesTo360;
PointParam origin;
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..5183a455f 100644
--- a/src/live_effects/lpe-perspective_path.cpp
+++ b/src/live_effects/lpe-perspective_path.cpp
@@ -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,41 @@ 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;
+ pmat = pmat * SP_ACTIVE_DESKTOP->doc2dt();
+ 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/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp
index 4e2be6e88..b23145db1 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(
@@ -733,8 +711,9 @@ void FilletChamferPointArrayParamKnotHolderEntity::knot_set(Point const &p,
/// @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/sp-ellipse.cpp b/src/sp-ellipse.cpp
index b5c6e4af8..a74d4687d 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -604,7 +604,7 @@ void SPGenericEllipse::update_patheffect(bool write)
if (write) {
Inkscape::XML::Node *repr = this->getRepr();
- if (this->_curve != NULL) {
+ if (this->_curve != NULL && type == SP_GENERIC_ELLIPSE_ARC) {
gchar *str = sp_svg_write_path(this->_curve->get_pathvector());
repr->setAttribute("d", str);
g_free(str);
@@ -642,8 +642,8 @@ bool SPGenericEllipse::set_elliptical_path_attribute(Inkscape::XML::Node *repr)
// Make sure our pathvector is up to date.
this->set_shape();
- if (this->getCurve() != NULL) {
- gchar* d = sp_svg_write_path(this->getCurve()->get_pathvector());
+ if (_curve != NULL) {
+ gchar* d = sp_svg_write_path(_curve->get_pathvector());
repr->setAttribute("d", d);