summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4f5ae37)
raw | patch | inline | side by side (parent: 4f5ae37)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 23 Mar 2008 19:23:08 +0000 (19:23 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 23 Mar 2008 19:23:08 +0000 (19:23 +0000) |
index 85d6e5e8fe892f6acabd6821a4150c6111bce002..dc9cfe63587d906b2c9c192fb84d7ad7a6d19af1 100644 (file)
startpoint_spacing_variation.resetRandomizer();
endpoint_spacing_variation.resetRandomizer();
- D2<Piecewise<SBasis> > stroke = make_cuts_independant(strokepath);
+ D2<Piecewise<SBasis> > stroke = make_cuts_independant(strokepath.get_pwd2());
Interval bndsStroke = bounds_exact(stroke[0]);
gdouble scaling = bndsStroke.max() - bndsStroke.min();
Interval bndsStrokeY = bounds_exact(stroke[1]);
transform.setXAxis( (end-start) / scaling );
transform.setYAxis( rot90(unit_vector(end-start)) * scaling_y);
transform.setTranslation( start );
- Piecewise<D2<SBasis> > pwd2_out = (strokepath-stroke_origin) * transform;
+ Piecewise<D2<SBasis> > pwd2_out = (strokepath.get_pwd2()-stroke_origin) * transform;
// add stuff to one big pw<d2<sbasis> > and then outside the loop convert to path?
// No: this way, the separate result paths are kept separate which might come in handy some time!
using namespace Geom;
// set the stroke path to run horizontally in the middle of the bounding box of the original path
+
+ // calculate bounding box: (isn't there a simpler way?)
Piecewise<D2<SBasis> > pwd2;
std::vector<Geom::Path> temppath = SVGD_to_2GeomPath( SP_OBJECT_REPR(item)->attribute("inkscape:original-d"));
for (unsigned int i=0; i < temppath.size(); i++) {
pwd2.concat( temppath[i].toPwSb() );
}
-
D2<Piecewise<SBasis> > d2pw = make_cuts_independant(pwd2);
Interval bndsX = bounds_exact(d2pw[0]);
Interval bndsY = bounds_exact(d2pw[1]);
index 750d7834675402dd4ee1c1149435262ae387c55d..0475f46033ef8efbd71ec04f9fcb28f1f34535ab 100644 (file)
/* Much credit should go to jfb and mgsloan of lib2geom development for the code below! */
- Piecewise<D2<SBasis> > uskeleton = arc_length_parametrization(Piecewise<D2<SBasis> >(bend_path),2,.1);
+ Piecewise<D2<SBasis> > uskeleton = arc_length_parametrization(Piecewise<D2<SBasis> >(bend_path.get_pwd2()),2,.1);
uskeleton = remove_short_cuts(uskeleton,.01);
Piecewise<D2<SBasis> > n = rot90(derivative(uskeleton));
n = force_continuity(remove_short_cuts(n,.1));
for (unsigned int i=0; i < temppath.size(); i++) {
pwd2.concat( temppath[i].toPwSb() );
}
-
D2<Piecewise<SBasis> > d2pw = make_cuts_independant(pwd2);
Interval bndsX = bounds_exact(d2pw[0]);
Interval bndsY = bounds_exact(d2pw[1]);
index 0f8e013b8a7d47f8aa08730006389b08d1545670..77c5a75c86482f122ab7caf00e472dbb9834d75b 100644 (file)
@@ -103,7 +103,7 @@ LPESkeletalStrokes::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pw
Piecewise<D2<SBasis> > n = rot90(derivative(uskeleton));
n = force_continuity(remove_short_cuts(n,.1));
- D2<Piecewise<SBasis> > patternd2 = make_cuts_independant(pattern);
+ D2<Piecewise<SBasis> > patternd2 = make_cuts_independant(pattern.get_pwd2());
Piecewise<SBasis> x = vertical_pattern.get_value() ? Piecewise<SBasis>(patternd2[1]) : Piecewise<SBasis>(patternd2[0]);
Piecewise<SBasis> y = vertical_pattern.get_value() ? Piecewise<SBasis>(patternd2[0]) : Piecewise<SBasis>(patternd2[1]);
Interval pattBndsX = bounds_exact(x);
index cb5ea126c2036c3a06028b8abccefcf2f9fa3cd5..760295ed7867b724409346d8cb70db2520380a2f 100644 (file)
LPEVonKoch::doEffect_path (std::vector<Geom::Path> & path_in)
{
using namespace Geom;
- std::vector<Geom::Path> generating_path = path_from_piecewise(generator,.01);//TODO what should that tolerance be?
+ std::vector<Geom::Path> generating_path = path_from_piecewise(generator.get_pwd2(),.01);//TODO what should that tolerance be?
//Collect transform matrices.
//FIXME: fusing/cutting nodes mix up component order in the path. This is why the last segment is used.
index ded004eee7da9ba07709285b17675604b535a7fa..944fe3da74e943ddec1c9c46ac2200081a186977 100644 (file)
PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
Effect* effect, const gchar * default_value)
- : Parameter(label, tip, key, wr, effect)
+ : Parameter(label, tip, key, wr, effect),
+ _pwd2(),
+ referring(false)
{
defvalue = g_strdup(default_value);
param_readSVGValue(defvalue);
g_free(defvalue);
}
+Geom::Piecewise<Geom::D2<Geom::SBasis> > &
+PathParam::get_pwd2()
+{
+ if (!referring) {
+ return _pwd2;
+ } else {
+ /* update own pwd2 with data from path referred to
+ when this works, optimize to only update own pwd2 when referred path changed. */
+ //_pwd2 = ...;
+ return _pwd2;
+ }
+}
+
void
PathParam::param_set_default()
{
for (unsigned int i=0; i < temppath.size(); i++) {
newpath.concat( temppath[i].toPwSb() );
}
- *( dynamic_cast<Geom::Piecewise<Geom::D2<Geom::SBasis> > *> (this) ) = newpath;
+ _pwd2 = newpath;
signal_path_changed.emit();
return true;
}
PathParam::param_writeSVGValue() const
{
const std::vector<Geom::Path> temppath =
- Geom::path_from_piecewise(* dynamic_cast<const Geom::Piecewise<Geom::D2<Geom::SBasis> > *> (this), LPE_CONVERSION_TOLERANCE);
+ Geom::path_from_piecewise(_pwd2, LPE_CONVERSION_TOLERANCE);
gchar * svgd = SVGD_from_2GeomPath( temppath );
return svgd;
}
void
PathParam::param_transform_multiply(Geom::Matrix const& postmul, bool /*set*/)
{
- param_set_and_write_new_value( (*this) * postmul );
+ // only apply transform when not referring to other path
+ if (!referring)
+ param_set_and_write_new_value( _pwd2 * postmul );
}
void
-PathParam::param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath)
+PathParam::param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & newpath)
{
const std::vector<Geom::Path> temppath = Geom::path_from_piecewise(newpath, LPE_CONVERSION_TOLERANCE);
gchar * svgd = SVGD_from_2GeomPath( temppath );
index 0bb65b77ce4cebb5aa59a8124b1b92551fdea12a..838543cd96f8b73df2c0f96ca5e37583e0c552ba 100644 (file)
namespace LivePathEffect {
-class PathParam : public Geom::Piecewise<Geom::D2<Geom::SBasis> >, public Parameter {
+class PathParam : public Parameter {
public:
PathParam ( const Glib::ustring& label,
const Glib::ustring& tip,
const gchar * default_value = "M0,0 L1,1");
virtual ~PathParam();
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > & get_pwd2();
+
virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips);
bool param_readSVGValue(const gchar * strvalue);
void param_set_default();
void param_set_and_write_default();
- void param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath);
+ void param_set_and_write_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & newpath);
virtual void param_editOncanvas(SPItem * item, SPDesktop * dt);
virtual void param_setup_nodepath(Inkscape::NodePath::Path *np);
sigc::signal <void> signal_path_pasted;
sigc::signal <void> signal_path_changed;
-private:
- PathParam(const PathParam&);
- PathParam& operator=(const PathParam&);
+protected:
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > _pwd2;
+ bool referring; // set when referring to another path, i.e. does not have its own pwd2, but should get it from another path
void on_edit_button_click();
void on_paste_button_click();
void on_copy_button_click();
gchar * defvalue;
+
+private:
+ PathParam(const PathParam&);
+ PathParam& operator=(const PathParam&);
};
index 81af6512aee7f42df749e874e8b44035a6510235..e407460616a41cbd3d0a6855119d8441de85d7f5 100644 (file)
@@ -1178,7 +1178,7 @@ void sp_selection_copy_lpe_pathparam(Inkscape::LivePathEffect::PathParam * pathp
clipboard = g_slist_prepend(clipboard, newnode);
- Geom::Rect bnds = Geom::bounds_exact(*pathparam);
+ Geom::Rect bnds = Geom::bounds_exact(pathparam->get_pwd2());
size_clipboard = from_2geom(bnds);
}