summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d5edbcb)
raw | patch | inline | side by side (parent: d5edbcb)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sat, 22 Mar 2008 19:11:02 +0000 (19:11 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sat, 22 Mar 2008 19:11:02 +0000 (19:11 +0000) |
* move Geom::Point XML writing to central place in ostringstream
* add verb for LPE context
* add verb for LPE context
index 35d0fcdbab98f2a99f7efa2211998e23125aee06..9b48327f693026713da3fb36b9dd9cf5866bfc2e 100644 (file)
PointParam::param_writeSVGValue() const
{
Inkscape::SVGOStringStream os;
- os << (*this)[0] << "," << (*this)[1];
+ os << *dynamic_cast<Geom::Point const *>( this );
gchar * str = g_strdup(os.str().c_str());
return str;
}
PointParam::param_set_and_write_new_value (Geom::Point newpoint)
{
Inkscape::SVGOStringStream os;
- os << newpoint[0] << "," << newpoint[1];
+ os << newpoint;
gchar * str = g_strdup(os.str().c_str());
param_write_to_repr(str);
g_free(str);
diff --git a/src/live_effects/parameter/pointparam-knotholder.cpp b/src/live_effects/parameter/pointparam-knotholder.cpp
index 12d08170330f825c49b4eb5df47d8ddff6dac21e..fa042be5ad6323c272d08abf98ffd5cd838417ea 100644 (file)
+<<<<<<< .mine\r
+#define INKSCAPE_LPE_POINTPARAM_KNOTHOLDER_C\r
+\r
+/*\r
+ * Container for PointParamKnotHolder visual handles\r
+ *\r
+ * Authors:\r
+ * Johan Engelen <goejendaagh@zonnet.nl>\r
+ *\r
+ * Copyright (C) 2008 authors\r
+ *\r
+ * Released under GNU GPL, read the file 'COPYING' for more information\r
+ */\r
+\r
+#include "live_effects/parameter/pointparam-knotholder.h"\r
+#include "live_effects/lpeobject.h"\r
+#include "document.h"\r
+#include "sp-shape.h"\r
+#include "knot.h"\r
+#include "knotholder.h"\r
+#include "knot-holder-entity.h"\r
+\r
+#include <libnr/nr-matrix-div.h>\r
+#include <glibmm/i18n.h>\r
+#include <2geom/point.h>\r
+#include <2geom/matrix.h>\r
+#include "svg/stringstream.h"\r
+#include "xml/repr.h"\r
+\r
+class SPDesktop;\r
+\r
+namespace Inkscape {\r
+\r
+static void pointparam_knot_clicked_handler (SPKnot *knot, guint state, PointParamKnotHolder *kh);\r
+static void pointparam_knot_moved_handler(SPKnot *knot, NR::Point const *p, guint state, PointParamKnotHolder *kh);\r
+static void pointparam_knot_ungrabbed_handler (SPKnot *knot, unsigned int state, PointParamKnotHolder *kh);\r
+static void pointparam_knot_holder_class_init(PointParamKnotHolderClass *klass);\r
+\r
+void pointparam_knot_holder_dispose(GObject *object);\r
+\r
+static SPKnotHolderClass *parent_class;\r
+\r
+/**\r
+ * Registers PointParamKnotHolder class and returns its type number.\r
+ */\r
+GType pointparam_knot_holder_get_type()\r
+{\r
+ static GType type = 0;\r
+ if (!type) {\r
+ GTypeInfo info = {\r
+ sizeof(PointParamKnotHolderClass),\r
+ NULL, /* base_init */\r
+ NULL, /* base_finalize */\r
+ (GClassInitFunc) pointparam_knot_holder_class_init,\r
+ NULL, /* class_finalize */\r
+ NULL, /* class_data */\r
+ sizeof (PointParamKnotHolder),\r
+ 16, /* n_preallocs */\r
+ NULL,\r
+ NULL\r
+ };\r
+ type = g_type_register_static (G_TYPE_OBJECT, "InkscapePointParamKnotHolder", &info, (GTypeFlags) 0);\r
+ }\r
+ return type;\r
+}\r
+\r
+/**\r
+ * PointParamKnotHolder vtable initialization.\r
+ */\r
+static void pointparam_knot_holder_class_init(PointParamKnotHolderClass *klass)\r
+{\r
+ GObjectClass *gobject_class;\r
+ gobject_class = (GObjectClass *) klass;\r
+\r
+ parent_class = (SPKnotHolderClass*) g_type_class_peek_parent(klass);\r
+ gobject_class->dispose = pointparam_knot_holder_dispose;\r
+}\r
+\r
+PointParamKnotHolder *pointparam_knot_holder_new(SPDesktop *desktop, SPObject *lpeobject, const gchar * key, SPItem *item)\r
+{\r
+ g_return_val_if_fail(desktop != NULL, NULL);\r
+ g_return_val_if_fail(item != NULL, NULL);\r
+ g_return_val_if_fail(SP_IS_ITEM(item), NULL);\r
+\r
+ PointParamKnotHolder *knot_holder = (PointParamKnotHolder*)g_object_new (INKSCAPE_TYPE_POINTPARAM_KNOT_HOLDER, 0);\r
+ knot_holder->desktop = desktop;\r
+ knot_holder->item = item;\r
+ knot_holder->lpeobject = LIVEPATHEFFECT(lpeobject);\r
+ g_object_ref(G_OBJECT(item));\r
+ g_object_ref(G_OBJECT(lpeobject));\r
+ knot_holder->entity = NULL;\r
+\r
+ knot_holder->released = NULL;\r
+\r
+ knot_holder->repr = lpeobject->repr;\r
+ knot_holder->repr_key = key;\r
+\r
+ knot_holder->local_change = FALSE;\r
+\r
+ return knot_holder;\r
+}\r
+\r
+void pointparam_knot_holder_dispose(GObject *object) {\r
+ PointParamKnotHolder *kh = G_TYPE_CHECK_INSTANCE_CAST((object), INKSCAPE_TYPE_POINTPARAM_KNOT_HOLDER, PointParamKnotHolder);\r
+\r
+ g_object_unref(G_OBJECT(kh->item));\r
+ g_object_unref(G_OBJECT(kh->lpeobject));\r
+ while (kh->entity) {\r
+ SPKnotHolderEntity *e = (SPKnotHolderEntity *) kh->entity->data;\r
+ g_signal_handler_disconnect(e->knot, e->_click_handler_id);\r
+ g_signal_handler_disconnect(e->knot, e->_ungrab_handler_id);\r
+ /* unref should call destroy */\r
+ g_object_unref(e->knot);\r
+ g_free(e);\r
+ kh->entity = g_slist_remove(kh->entity, e);\r
+ }\r
+}\r
+\r
+void\r
+PointParamKnotHolder::add_knot (\r
+ Geom::Point & p,\r
+ PointParamKnotHolderClickedFunc knot_click,\r
+ SPKnotShapeType shape,\r
+ SPKnotModeType mode,\r
+ guint32 color,\r
+ const gchar *tip )\r
+{\r
+ /* create new SPKnotHolderEntry */\r
+ SPKnotHolderEntity *e = g_new(SPKnotHolderEntity, 1);\r
+ e->knot = sp_knot_new(desktop, tip);\r
+ e->knot_set = NULL;\r
+ e->knot_get = NULL;\r
+ if (knot_click) {\r
+ e->knot_click = knot_click;\r
+ } else {\r
+ e->knot_click = NULL;\r
+ }\r
+\r
+ g_object_set(G_OBJECT (e->knot->item), "shape", shape, NULL);\r
+ g_object_set(G_OBJECT (e->knot->item), "mode", mode, NULL);\r
+\r
+ e->knot->fill [SP_KNOT_STATE_NORMAL] = color;\r
+ g_object_set (G_OBJECT (e->knot->item), "fill_color", color, NULL);\r
+\r
+ entity = g_slist_append(entity, e);\r
+\r
+ /* Move to current point. */\r
+ NR::Point dp = p * sp_item_i2d_affine(item);\r
+ sp_knot_set_position(e->knot, &dp, SP_KNOT_STATE_NORMAL);\r
+\r
+ e->handler_id = g_signal_connect(e->knot, "moved", G_CALLBACK(pointparam_knot_moved_handler), this);\r
+ e->_click_handler_id = g_signal_connect(e->knot, "clicked", G_CALLBACK(pointparam_knot_clicked_handler), this);\r
+ e->_ungrab_handler_id = g_signal_connect(e->knot, "ungrabbed", G_CALLBACK(pointparam_knot_ungrabbed_handler), this);\r
+\r
+ sp_knot_show(e->knot);\r
+}\r
+\r
+static void pointparam_knot_clicked_handler(SPKnot */*knot*/, guint /*state*/, PointParamKnotHolder */*kh*/)\r
+{\r
+\r
+}\r
+\r
+/**\r
+ * \param p In desktop coordinates.\r
+ * This function does not write to XML, but tries to write directly to the PointParam to quickly live update the effect\r
+ */\r
+static void pointparam_knot_moved_handler(SPKnot */*knot*/, NR::Point const *p, guint /*state*/, PointParamKnotHolder *kh)\r
+{\r
+ NR::Matrix const i2d(sp_item_i2d_affine(kh->item));\r
+ NR::Point pos = (*p) / i2d;\r
+\r
+ Inkscape::SVGOStringStream os;\r
+ os << pos.to_2geom();\r
+\r
+ kh->lpeobject->lpe->setParameter(kh->repr_key, os.str().c_str());\r
+}\r
+\r
+static void pointparam_knot_ungrabbed_handler(SPKnot *knot, unsigned int /*state*/, PointParamKnotHolder *kh)\r
+{\r
+ NR::Matrix const i2d(sp_item_i2d_affine(kh->item));\r
+ NR::Point pos = sp_knot_position(knot) / i2d;\r
+\r
+ Inkscape::SVGOStringStream os;\r
+ os << pos.to_2geom();\r
+\r
+ kh->repr->setAttribute(kh->repr_key , os.str().c_str());\r
+\r
+ sp_document_done(SP_OBJECT_DOCUMENT (kh->lpeobject), SP_VERB_CONTEXT_LPE, _("Change LPE point parameter"));\r
+}\r
+\r
+} // namespace Inkscape\r
+\r
+/*\r
+ Local Variables:\r
+ mode:c++\r
+ c-file-style:"stroustrup"\r
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
+ indent-tabs-mode:nil\r
+ fill-column:99\r
+ End:\r
+*/\r
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :\r
+=======\r
#define INKSCAPE_LPE_POINTPARAM_KNOTHOLDER_C
/*
@@ -199,3 +402,4 @@ static void pointparam_knot_ungrabbed_handler(SPKnot *knot, unsigned int /*state
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+>>>>>>> .r17984\r
index 6612f3fd235231e25968c935e7f4ce389d6dc469..a8da1315065e9d43720163941d90dcb926c1ac4e 100644 (file)
#include <cxxtest/TestSuite.h>
#include "svg/stringstream.h"
+#include <2geom/point.h>
template<typename T>
static void
svg_test_datum(" my string ", " my string ");
svg_test_datum((signed char const *) "023", "023");
svg_test_datum((unsigned char const *) "023", "023");
+ svg_test_datum(Geom::Point(1.23, 3.45), "1.23,3.45");
}
void testConcat()
index 65c01e7b687b3332f138f5ee9f941643687b663c..62e20961aee4a71903404bc4033076e885d5740b 100644 (file)
--- a/src/svg/stringstream.cpp
+++ b/src/svg/stringstream.cpp
#include "svg/stringstream.h"
#include "svg/strip-trailing-zeros.h"
#include "prefs-utils.h"
+#include <2geom/point.h>
Inkscape::SVGOStringStream::SVGOStringStream()
{
return os;
}
+Inkscape::SVGOStringStream &
+operator<<(Inkscape::SVGOStringStream &os, Geom::Point const & p)
+{
+ os << p[0] << ',' << p[1];
+ return os;
+}
/*
Local Variables:
diff --git a/src/svg/stringstream.h b/src/svg/stringstream.h
index 8ef5ece523b1c7ee3d21063ac3a5ff9d5e5e837d..4e19125b40f51b1e818e1fd83c40781572158682 100644 (file)
--- a/src/svg/stringstream.h
+++ b/src/svg/stringstream.h
#include <sstream>
#include <string>
+namespace Geom {
+ class Point;
+}
namespace Inkscape {
typedef std::ios_base &(*std_oct_type)(std::ios_base &);
Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, double d);
+Inkscape::SVGOStringStream &operator<<(Inkscape::SVGOStringStream &os, Geom::Point const & p);
#endif
index 634329ddcb45892d884ffcf3eb02f4a48340d47f..1efb26a78ae3c3749b892fdc3d07cf670eac61e0 100644 (file)
--- a/src/ui/widget/point.cpp
+++ b/src/ui/widget/point.cpp
{
return ywidget.getValue();
}
+Geom::Point
+Point::getValue() const
+{
+ return Geom::Point( getXValue() , getYValue() );
+}
/** Get the value spin_button represented as an integer. */
int
diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h
index b65a13e2035de9953c67f0ff8b230267960ebfb7..a9be05afcec6aa44af9b703c60e6d6218c6b2bb2 100644 (file)
--- a/src/ui/widget/point.h
+++ b/src/ui/widget/point.h
#include <gtkmm/adjustment.h>
#include <gtkmm/spinbutton.h>
-
+#include <2geom/point.h>
#include "ui/widget/labelled.h"
#include "ui/widget/scalar.h"
bool getSnapToTicks() const;
double getXValue() const;
double getYValue() const;
+ Geom::Point getValue() const;
int getXValueAsInt() const;
int getYValueAsInt() const;
index 3b36ea6bc108f42e75a02bcb1c6bf22abdc3a0c0..1de084f5dfe2589e528ac19a7320b761302d00b4 100644 (file)
_wr->setUpdating (false);
}
+/*#########################################
+ * Registered TRANSFORMEDPOINT
+ */
+
+RegisteredTransformedPoint::~RegisteredTransformedPoint()
+{
+ _value_x_changed_connection.disconnect();
+ _value_y_changed_connection.disconnect();
+}
+
+RegisteredTransformedPoint::RegisteredTransformedPoint ( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
+ SPDocument* doc_in )
+ : RegisteredWidget<Point> (label, tip),
+ transform(Geom::identity())
+{
+ init_parent(key, wr, repr_in, doc_in);
+
+ setRange (-1e6, 1e6);
+ setDigits (2);
+ setIncrements(0.1, 1.0);
+ _value_x_changed_connection = signal_x_value_changed().connect (sigc::mem_fun (*this, &RegisteredTransformedPoint::on_value_changed));
+ _value_y_changed_connection = signal_y_value_changed().connect (sigc::mem_fun (*this, &RegisteredTransformedPoint::on_value_changed));
+}
+
+void
+RegisteredTransformedPoint::on_value_changed()
+{
+ if (setProgrammatically()) {
+ clearProgrammatically();
+ return;
+ }
+
+ if (_wr->isUpdating())
+ return;
+
+ _wr->setUpdating (true);
+
+ Geom::Point pos = getValue() * transform;
+
+ Inkscape::SVGOStringStream os;
+ os << pos;
+
+ write_to_xml(os.str().c_str());
+
+ _wr->setUpdating (false);
+}
/*#########################################
* Registered RANDOM
index a3b04575e826a015045d8b912f4d7f296e0674ad..f348956201c64c57d095884c798dc038fdb710fb 100644 (file)
#include <gtkmm/adjustment.h>
#include <gtkmm/tooltips.h>
#include <gtkmm/togglebutton.h>
-
+#include <2geom/matrix.h>
#include "xml/node.h"
#include "registry.h"
};
+class RegisteredTransformedPoint : public RegisteredWidget<Point> {
+public:
+ virtual ~RegisteredTransformedPoint();
+ RegisteredTransformedPoint ( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Registry& wr,
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL );
+
+protected:
+ sigc::connection _value_x_changed_connection;
+ sigc::connection _value_y_changed_connection;
+ void on_value_changed();
+
+ Geom::Matrix transform;
+};
+
+
class RegisteredRandom : public RegisteredWidget<Random> {
public:
virtual ~RegisteredRandom();
diff --git a/src/verbs.cpp b/src/verbs.cpp
index b9dfec2711de70e7b0db06eaed3d85fff68c8f5b..b32d0041b0760be8e341b865726dc7f1ca4421f8 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
N_("Create diagram connectors"), "draw_connector"),
new ContextVerb(SP_VERB_CONTEXT_PAINTBUCKET, "ToolPaintBucket", N_("Paint Bucket"),
N_("Fill bounded areas"), "draw_paintbucket"),
-
+ new ContextVerb(SP_VERB_CONTEXT_LPE, "ToolLPE", N_("LPE Edit"),
+ N_("Edit Live Path Effect parameters"), "draw_lpe"),
/* Tool prefs */
new ContextVerb(SP_VERB_CONTEXT_SELECT_PREFS, "SelectPrefs", N_("Selector Preferences"),
N_("Open Preferences for the Selector tool"), NULL),
diff --git a/src/verbs.h b/src/verbs.h
index 471beaa48ad60ae4fe3787ffb59948bd820dc754..89e677ead7149a248c50df55cfc45b14f6aceda2 100644 (file)
--- a/src/verbs.h
+++ b/src/verbs.h
SP_VERB_CONTEXT_DROPPER,
SP_VERB_CONTEXT_CONNECTOR,
SP_VERB_CONTEXT_PAINTBUCKET,
-// SP_VERB_CONTEXT_LPE, /*not really a tool but for editing LPE parameters on-canvas for example */
+ SP_VERB_CONTEXT_LPE, /* not really a tool but used for editing LPE parameters on-canvas for example */
/* Tool preferences */
SP_VERB_CONTEXT_SELECT_PREFS,
SP_VERB_CONTEXT_NODE_PREFS,