summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9822058)
raw | patch | inline | side by side (parent: 9822058)
author | glimmer07 <glimmer07@users.sourceforge.net> | |
Thu, 16 Jul 2009 16:01:55 +0000 (16:01 +0000) | ||
committer | glimmer07 <glimmer07@users.sourceforge.net> | |
Thu, 16 Jul 2009 16:01:55 +0000 (16:01 +0000) |
Added get_path method.
Added documentation on paths.
Added documentation on paths.
diff --git a/src/extension/dbus/doc/inkscapeDbusTerms.xml b/src/extension/dbus/doc/inkscapeDbusTerms.xml
index cd41195a9f9a28170166630dfb8c99ec8ecce7c2..507fcbf2488262da7cde7e0b9bba20c6aaf31343 100644 (file)
@@ -119,9 +119,20 @@ Style strings look something like this: "fill:#ff0000;fill-opacity:1;stroke:#000
</para>
</sect1>
- <anchor id="Nodes and Paths"/>
+ <anchor id="Paths"/>
<sect1>
- <title>Nodes and Paths</title>
+ <title>Paths</title>
+ <para>
+A path is a string representing a series of points, and how the line curves between the points. It looks something like this: "m 351.42857,296.64789 a 54.285713,87.14286 0 1 1 -108.57143,0 54.285713,87.14286 0 1 1 108.57143,0 z" and is usually found as an attribute of a shape with the label "d". All shapes except rectangles have this "d" attribute.
+ </para>
+ <para>
+Just because a shape has a path does not mean it IS a path however. A path object has no attributes except the path and a style. Calling <link linkend="document.object_to_path">object_to_path()</link> will convert any object to a path, stripping away any other attributes except id and style which stay the same. This will not change the visual appearance but you will no longer be able to use shape handles or affect it by changing any attributes except for "style", "d", and "transform". Some functions may require paths.
+ </para>
+ </sect1>
+
+ <anchor id="Nodes"/>
+ <sect1>
+ <title>Nodes</title>
<para>
To be written.
</para>
index 1cdff0133bc439e9d10355e3df735560f5495a10..e3573989a577b5ee9bfbbe458a14bfd2015864a2 100644 (file)
{
Inkscape::XML::Node *newNode = get_object_by_name(object->desk, shape)->repr;
- /* ALTERNATIVE
- Inkscape::XML::Node *repr2 = sp_repr_lookup_name((doc->root)->repr, name);
+ /* ALTERNATIVE (is this faster?)
+ Inkscape::XML::Node *newnode = sp_repr_lookup_name((doc->root)->repr, name);
*/
if (newNode)
{
document_interface_get_attribute (DocumentInterface *object, char *shape,
char *attribute, GError **error)
{
- SPDesktop *desk2 = object->desk;
- SPDocument * doc = sp_desktop_document (desk2);
-
- Inkscape::XML::Node *newNode = doc->getObjectById(shape)->repr;
+ Inkscape::XML::Node *newNode = get_object_by_name(object->desk, shape)->repr;
- /* WORKS
- Inkscape::XML::Node *repr2 = sp_repr_lookup_name((doc->root)->repr, name);
- */
if (newNode)
return g_strdup(newNode->attribute(attribute));
return FALSE;
@@ -493,16 +487,17 @@ document_interface_move_to (DocumentInterface *object, gchar *name, gdouble x,
return TRUE;
}
-void
+gboolean
document_interface_object_to_path (DocumentInterface *object,
char *shape, GError **error)
{
const GSList *oldsel = selection_swap(object->desk, shape);
dbus_call_verb (object, SP_VERB_OBJECT_TO_CURVE, error);
selection_restore(object->desk, oldsel);
+ return TRUE;
}
-gboolean
+gchar *
document_interface_get_path (DocumentInterface *object, char *pathname, GError **error)
{
Inkscape::XML::Node *node = document_retrive_node (sp_desktop_document (object->desk), pathname);
@@ -510,15 +505,7 @@ document_interface_get_path (DocumentInterface *object, char *pathname, GError *
g_set_error(error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION, "Object is not a path or does not exist.");
return FALSE;
}
- gchar *pathstr = strdup(node->attribute("d"));
- printf("PATH: %s\n", pathstr);
- //gfree (pathstr);
- std::istringstream iss(pathstr);
- std::copy(std::istream_iterator<std::string>(iss),
- std::istream_iterator<std::string>(),
- std::ostream_iterator<std::string>(std::cout, "\n"));
-
- return TRUE;
+ return strdup(node->attribute("d"));
}
gboolean
DBUSPoint **
document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape)
{
- //FIXME: implement.
+ //FIXME: not implemented.
+ Inkscape::XML::Node *node = document_retrive_node (sp_desktop_document (object->desk), pathname);
+ if (node == NULL || node->attribute("d") == NULL) {
+ g_set_error(error, DBUS_GERROR, DBUS_GERROR_REMOTE_EXCEPTION, "Object is not a path or does not exist.");
+ return FALSE;
+ }
+ char * path = strdup(node->attribute("d"));
+
return NULL;
}
SELECTION FUNCTIONS FIXME: use call_verb where appropriate.
****************************************************************************/
-gchar **
-document_interface_selection_get (DocumentInterface *object)
+gboolean
+document_interface_selection_get (DocumentInterface *object, GSList const * listy, GError **error)
{
Inkscape::Selection * sel = sp_desktop_selection(object->desk);
GSList const *oldsel = sel->list();
printf("%d = %s\n", i, list[i]);
}
- return list;
+ listy = oldsel;
+ return TRUE;
}
gboolean
diff --git a/src/extension/dbus/document-interface.h b/src/extension/dbus/document-interface.h
--- /dev/null
@@ -0,0 +1,353 @@
+#ifndef INKSCAPE_EXTENSION_DOCUMENT_INTERFACE_H_
+#define INKSCAPE_EXTENSION_DOCUMENT_INTERFACE_H_
+
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-bindings.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include "desktop.h"
+
+#define DBUS_DOCUMENT_INTERFACE_PATH "/org/inkscape/document"
+
+#define TYPE_DOCUMENT_INTERFACE (document_interface_get_type ())
+#define DOCUMENT_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TYPE_DOCUMENT_INTERFACE, DocumentInterface))
+#define DOCUMENT_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT_INTERFACE, DocumentInterfaceClass))
+#define IS_DOCUMENT_INTERFACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TYPE_DOCUMENT_INTERFACE))
+#define IS_DOCUMENT_INTERFACE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT_INTERFACE))
+#define DOCUMENT_INTERFACE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT_INTERFACE, DocumentInterfaceClass))
+
+G_BEGIN_DECLS
+
+typedef struct _DocumentInterface DocumentInterface;
+typedef struct _DocumentInterfaceClass DocumentInterfaceClass;
+
+struct _DocumentInterface {
+ GObject parent;
+ SPDesktop *desk;
+ gboolean updates;
+};
+
+struct _DocumentInterfaceClass {
+ GObjectClass parent;
+};
+
+struct DBUSPoint {
+ int x;
+ int y;
+};
+/****************************************************************************
+ MISC FUNCTIONS
+****************************************************************************/
+
+gboolean
+document_interface_delete_all (DocumentInterface *object, GError **error);
+
+void
+document_interface_call_verb (DocumentInterface *object,
+ gchar *verbid, GError **error);
+
+/****************************************************************************
+ CREATION FUNCTIONS
+****************************************************************************/
+
+gchar*
+document_interface_rectangle (DocumentInterface *object, int x, int y,
+ int width, int height, GError **error);
+
+gchar*
+document_interface_ellipse (DocumentInterface *object, int x, int y,
+ int width, int height, GError **error);
+
+gchar*
+document_interface_polygon (DocumentInterface *object, int cx, int cy,
+ int radius, int rotation, int sides,
+ GError **error);
+
+gchar*
+document_interface_star (DocumentInterface *object, int cx, int cy,
+ int r1, int r2, int sides, gdouble rounded,
+ gdouble arg1, gdouble arg2, GError **error);
+
+gchar*
+document_interface_spiral (DocumentInterface *object, int cx, int cy,
+ int r, int revolutions, GError **error);
+
+gchar*
+document_interface_line (DocumentInterface *object, int x, int y,
+ int x2, int y2, GError **error);
+
+gchar*
+document_interface_text (DocumentInterface *object, gchar *text,
+ GError **error);
+
+gchar*
+document_interface_node (DocumentInterface *object, gchar *svgtype,
+ GError **error);
+
+
+/****************************************************************************
+ ENVIORNMENT FUNCTIONS
+****************************************************************************/
+gdouble
+document_interface_document_get_width (DocumentInterface *object);
+
+gdouble
+document_interface_document_get_height (DocumentInterface *object);
+
+gchar *
+document_interface_document_get_css (DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_document_merge_css (DocumentInterface *object,
+ gchar *stylestring, GError **error);
+
+gboolean
+document_interface_document_set_css (DocumentInterface *object,
+ gchar *stylestring, GError **error);
+
+gboolean
+document_interface_document_resize_to_fit_selection (DocumentInterface *object,
+ GError **error);
+
+/****************************************************************************
+ OBJECT FUNCTIONS
+****************************************************************************/
+
+gboolean
+document_interface_set_attribute (DocumentInterface *object,
+ char *shape, char *attribute,
+ char *newval, GError **error);
+
+void
+document_interface_set_int_attribute (DocumentInterface *object,
+ char *shape, char *attribute,
+ int newval, GError **error);
+
+void
+document_interface_set_double_attribute (DocumentInterface *object,
+ char *shape, char *attribute,
+ double newval, GError **error);
+
+gchar *
+document_interface_get_attribute (DocumentInterface *object,
+ char *shape, char *attribute, GError **error);
+
+gboolean
+document_interface_move (DocumentInterface *object, gchar *name,
+ gdouble x, gdouble y, GError **error);
+
+gboolean
+document_interface_move_to (DocumentInterface *object, gchar *name,
+ gdouble x, gdouble y, GError **error);
+
+gboolean
+document_interface_object_to_path (DocumentInterface *object,
+ char *shape, GError **error);
+
+gchar *
+document_interface_get_path (DocumentInterface *object,
+ char *pathname, GError **error);
+
+gboolean
+document_interface_transform (DocumentInterface *object, gchar *shape,
+ gchar *transformstr, GError **error);
+
+gchar *
+document_interface_get_css (DocumentInterface *object, gchar *shape,
+ GError **error);
+
+gboolean
+document_interface_modify_css (DocumentInterface *object, gchar *shape,
+ gchar *cssattrb, gchar *newval, GError **error);
+
+gboolean
+document_interface_merge_css (DocumentInterface *object, gchar *shape,
+ gchar *stylestring, GError **error);
+
+gboolean
+document_interface_move_to_layer (DocumentInterface *object, gchar *shape,
+ gchar *layerstr, GError **error);
+
+
+DBUSPoint **
+document_interface_get_node_coordinates (DocumentInterface *object, gchar *shape);
+
+/****************************************************************************
+ FILE I/O FUNCTIONS
+****************************************************************************/
+
+gboolean
+document_interface_save (DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_load (DocumentInterface *object,
+ gchar *filename, GError **error);
+
+gboolean
+document_interface_save_as (DocumentInterface *object,
+ gchar *filename, GError **error);
+/*
+gboolean
+document_interface_print_to_file (DocumentInterface *object, GError **error);
+*/
+
+/****************************************************************************
+ PROGRAM CONTROL FUNCTIONS
+****************************************************************************/
+
+gboolean
+document_interface_close (DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_exit (DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_undo (DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_redo (DocumentInterface *object, GError **error);
+
+
+/****************************************************************************
+ UPDATE FUNCTIONS
+****************************************************************************/
+void
+document_interface_pause_updates (DocumentInterface *object, GError **error);
+
+void
+document_interface_resume_updates (DocumentInterface *object, GError **error);
+
+void
+document_interface_update (DocumentInterface *object, GError **error);
+
+/****************************************************************************
+ SELECTION FUNCTIONS
+****************************************************************************/
+gboolean
+document_interface_selection_get (DocumentInterface *object, GSList const * listy, GError **error);
+
+gboolean
+document_interface_selection_add (DocumentInterface *object,
+ char *name, GError **error);
+
+gboolean
+document_interface_selection_add_list (DocumentInterface *object,
+ char **names, GError **error);
+
+gboolean
+document_interface_selection_set (DocumentInterface *object,
+ char *name, GError **error);
+
+gboolean
+document_interface_selection_set_list (DocumentInterface *object,
+ gchar **names, GError **error);
+
+gboolean
+document_interface_selection_rotate (DocumentInterface *object,
+ int angle, GError **error);
+
+gboolean
+document_interface_selection_delete(DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_selection_clear(DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_select_all(DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_select_all_in_all_layers(DocumentInterface *object,
+ GError **error);
+
+gboolean
+document_interface_selection_box (DocumentInterface *object, int x, int y,
+ int x2, int y2, gboolean replace,
+ GError **error);
+
+gboolean
+document_interface_selection_invert (DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_selection_group(DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_selection_ungroup(DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_selection_cut(DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_selection_copy(DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_selection_paste(DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_selection_scale (DocumentInterface *object,
+ gdouble grow, GError **error);
+
+gboolean
+document_interface_selection_move (DocumentInterface *object, gdouble x,
+ gdouble y, GError **error);
+
+gboolean
+document_interface_selection_move_to (DocumentInterface *object, gdouble x,
+ gdouble y, GError **error);
+
+gboolean
+document_interface_selection_move_to_layer (DocumentInterface *object,
+ gchar *layerstr, GError **error);
+
+gboolean
+document_interface_selection_get_center (DocumentInterface *object);
+
+gboolean
+document_interface_selection_to_path (DocumentInterface *object, GError **error);
+
+gchar *
+document_interface_selection_combine (DocumentInterface *object, gchar *cmd,
+ GError **error);
+
+
+gboolean
+document_interface_selection_change_level (DocumentInterface *object, gchar *cmd,
+ GError **error);
+
+/****************************************************************************
+ LAYER FUNCTIONS
+****************************************************************************/
+
+gchar *
+document_interface_layer_new (DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_layer_set (DocumentInterface *object,
+ gchar *layerstr, GError **error);
+
+gchar **
+document_interface_layer_get_all (DocumentInterface *object);
+
+gboolean
+document_interface_layer_change_level (DocumentInterface *object,
+ gchar *cmd, GError **error);
+
+gboolean
+document_interface_layer_next (DocumentInterface *object, GError **error);
+
+gboolean
+document_interface_layer_previous (DocumentInterface *object, GError **error);
+
+
+
+
+
+
+
+
+DocumentInterface *document_interface_new (void);
+GType document_interface_get_type (void);
+
+
+G_END_DECLS
+
+#endif // INKSCAPE_EXTENSION_DOCUMENT_INTERFACE_H_
index f79816de160c705311b995e03c0d1a8a338ed8c1..14be0312bb16ede3f0a538cb0f7695f43752a02a 100644 (file)
<doc:para>After doing this you will no longer be able to modify the shape using shape specific attributes (cx, radius etc.) except transform</doc:para>
<doc:para>Required for certain functions that work on paths (not yet present in this API.)</doc:para>
</doc:description>
+ <doc:seealso><doc:ref type="interface" to="Paths">Paths</doc:ref></doc:seealso>
+ </doc:doc>
+ </method>
+
+ <method name="get_path">
+ <arg type="s" name="shape" direction="in" >
+ <doc:doc>
+ <doc:summary>The id of an object.</doc:summary>
+ </doc:doc>
+ </arg>
+ <arg type="s" name="val" direction="out" >
+ <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value="error"/>
+ <doc:doc>
+ <doc:summary>The path of the object. NULL if the object has no path.</doc:summary>
+ </doc:doc>
+ </arg>
+ <doc:doc>
+ <doc:description>
+ <doc:para>Get the path value of an object. Equivilent to calling <doc:ref type="method" to="document.get_attribte">get_attribte()</doc:ref> with argument "d". Will not turn object into a path if it is not already.</doc:para>
+ </doc:description>
+ <doc:seealso><doc:ref type="interface" to="Paths">Paths</doc:ref></doc:seealso>
</doc:doc>
</method>
<!-- SELECTION FUNCTIONS -->
<method name="selection_get">
- <arg type="as" name="list" direction="out" >
- <annotation name="org.freedesktop.DBus.GLib.ReturnVal" value=""/>
+ <arg type="as" name="listy" direction="out" >
<doc:doc>
<doc:summary>List of the ids of currently selected objects.</doc:summary>
</doc:doc>