summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 044d712)
raw | patch | inline | side by side (parent: 044d712)
author | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 18 Jun 2008 02:14:06 +0000 (02:14 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Wed, 18 Jun 2008 02:14:06 +0000 (02:14 +0000) |
configure.ac | patch | blob | history | |
src/live_effects/lpe-copy_rotate.cpp | patch | blob | history | |
src/live_effects/lpe-copy_rotate.h | patch | blob | history |
diff --git a/configure.ac b/configure.ac
index 852970ba8d2a579c020035ef60d6fff147f2e70c..c3b9980751a067e0be218e7a23aa62686a3076ce 100644 (file)
--- a/configure.ac
+++ b/configure.ac
AC_SUBST(IMAGEMAGICK_LIBS)
AC_SUBST(IMAGEMAGICK_CFLAGS)
-dnl ***********************************************************************************************************
-dnl Check for a Cairo version that implements user-fonts feature, so that we conditionally add SVGFonts support
-dnl ***********************************************************************************************************
-
-PKG_CHECK_MODULES(CAIRO_USER_FONTS, cairo > 1.6.4, cairouserfonts=yes, cairouserfonts=no)
-if test "x$cairouserfonts" = "xyes"; then
- AC_DEFINE(ENABLE_SVG_FONTS, 1, [SVG Fonts should be used])
-fi
-
dnl ******************************
dnl Unconditional dependencies
dnl ******************************
# Add even more stuff
CXXFLAGS="-Wpointer-arith -Wcast-align -Wsign-compare -Woverloaded-virtual -Wswitch $CXXFLAGS"
+ ## This is evil!
+ CXXFLAGS=""
+ CFLAGS=""
+
dnl Test for arch-specific situations.
case "$host_cpu" in
mips|mipsel)
share/extensions/Makefile
share/extensions/alphabet_soup/Makefile
share/extensions/Barcode/Makefile
-share/extensions/Poly3DObjects/Makefile
share/extensions/xaml2svg/Makefile
share/fonts/Makefile
share/gradients/Makefile
index e3f996a1b33f7c40c586b5683ef1834ba97d850e..52ac7d6bec1803f7bf6bb2dd841f57ae7ec5f82d 100644 (file)
namespace Inkscape {
namespace LivePathEffect {
+namespace CR {
+
+class KnotHolderEntityAngle : public KnotHolderEntity
+{
+public:
+ virtual bool isLPEParam() { return true; }
+
+ virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
+ virtual NR::Point knot_get();
+};
+
+} // namespace CR
+
LPECopyRotate::LPECopyRotate(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
+ include_original(_("Include original?"), _(""), "include_original", &wr, this, false),
angle(_("Angle"), _("Angle"), "angle", &wr, this, 30.0),
num_copies(_("Number of copies"), _("Number of copies of the original path"), "num_copies", &wr, this, 1),
- origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this)
+ origin(_("Origin"), _("Origin of the rotation"), "origin", &wr, this),
+ dist_angle_handle(100)
{
show_orig_path = true;
// register all your parameters here, so Inkscape knows which parameters this effect has:
+ registerParameter( dynamic_cast<Parameter *>(&include_original) );
registerParameter( dynamic_cast<Parameter *>(&angle) );
registerParameter( dynamic_cast<Parameter *>(&num_copies) );
registerParameter( dynamic_cast<Parameter *>(&origin) );
+ registerKnotHolderHandle(new CR::KnotHolderEntityAngle(), _("Adjust the angle"));
+
num_copies.param_make_integer(true);
+ num_copies.param_set_range(0, 1000);
+
}
LPECopyRotate::~LPECopyRotate()
LPECopyRotate::doOnApply(SPLPEItem *lpeitem)
{
origin.param_setValue(SP_SHAPE(lpeitem)->curve->first_point().to_2geom());
+ A = pwd2_in.firstValue();
+ B = pwd2_in.lastValue();
+ dir = unit_vector(B - A);
+ dist_angle_handle = L2(B - A);
}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
{
using namespace Geom;
+ A = pwd2_in.firstValue();
+ B = pwd2_in.lastValue();
+ dir = unit_vector(B - A);
+
Piecewise<D2<SBasis> > output;
+ if (include_original) {
+ output = pwd2_in;
+ }
+
for (int i = 1; i <= num_copies; ++i) {
Rotate rot(deg_to_rad(angle * i));
Matrix t = Translate(-origin) * rot * Translate(origin);
return output;
}
+namespace CR {
+
+using namespace Geom;
+
+// TODO: make this more generic
+static LPECopyRotate *
+get_effect(SPItem *item)
+{
+ Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
+ if (effect->effectType() != COPY_ROTATE) {
+ g_print ("Warning: Effect is not of type LPECopyRotate!\n");
+ return NULL;
+ }
+ return static_cast<LPECopyRotate *>(effect);
+}
+
+void
+KnotHolderEntityAngle::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint state)
+{
+ LPECopyRotate* lpe = get_effect(item);
+
+ // FIXME: is the minus sign due to a bug in 2geom?
+ lpe->angle.param_set_value(rad_to_deg(-angle_between(lpe->dir, p.to_2geom() - lpe->origin)));
+ 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);
+}
+
+NR::Point
+KnotHolderEntityAngle::knot_get()
+{
+ LPECopyRotate* lpe = get_effect(item);
+
+ // FIXME: is the minus sign due to a bug in 2geom?
+ Point d = lpe->dir * Rotate(-deg_to_rad(lpe->angle)) * lpe->dist_angle_handle;
+
+ return lpe->origin + d;
+}
+
+} // namespace CR
+
/* ######################## */
} //namespace LivePathEffect
index 72b46b5d6d52b03bf2b06f13521db484aafd6e0c..9678014fce78fe87c970efc62ba5c946cc384318 100644 (file)
namespace Inkscape {
namespace LivePathEffect {
+namespace CR {
+ // we need a separate namespace to avoid clashes with LPEPerpBisector
+ class KnotHolderEntityAngle;
+}
+
class LPECopyRotate : public Effect {
public:
LPECopyRotate(LivePathEffectObject *lpeobject);
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
+ /* the knotholder entity classes must be declared friends */
+ friend class CR::KnotHolderEntityAngle;
+
private:
ScalarParam angle;
ScalarParam num_copies;
PointParam origin;
+ BoolParam include_original;
+
+ Geom::Point A;
+ Geom::Point B;
+ Geom::Point dir;
+ double dist_angle_handle;
LPECopyRotate(const LPECopyRotate&);
LPECopyRotate& operator=(const LPECopyRotate&);