Code

Added skeleton files for other filter primitives' SP-objects. Added blur slider on...
[inkscape.git] / src / trace / trace.h
index bf4a345a6952622c9f8fa3c32b0ca12bcc95dc2e..1341e3d464871883b69015e13af1171acbddf4db 100644 (file)
@@ -1,11 +1,11 @@
-/*
+/**
  * A generic interface for plugging different
  *  autotracers into Inkscape.
  *
  * Authors:
  *   Bob Jamison <rjamison@titan.com>
  *
- * Copyright (C) 2004 Bob Jamison
+ * Copyright (C) 2004-2006 Bob Jamison
  *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 # include <string.h>
 #endif
 
-#include <gdk/gdkpixbuf.h>
+#include <gtkmm.h>
 
+#include <vector>
+#include <sp-shape.h>
 
 struct SPImage;
 struct SPItem;
@@ -47,38 +49,39 @@ public:
     /**
      *
      */
-    TracingEngineResult(char *theStyle, char *thePathData, long theNodeCount)
+    TracingEngineResult(const std::string &theStyle,
+                        const std::string &thePathData,
+                        long theNodeCount)
         {
-        next      = NULL;
-        style     = strdup(theStyle);
-        pathData  = strdup(thePathData);
+        style     = theStyle;
+        pathData  = thePathData;
         nodeCount = theNodeCount;
         }
 
+    TracingEngineResult(const TracingEngineResult &other)
+        { assign(other); }
+
+    virtual TracingEngineResult &operator=(const TracingEngineResult &other)
+        { assign(other); return *this; }
+
+
     /**
      *
      */
     virtual ~TracingEngineResult()
-        {
-        if (next)
-            delete next;
-        if (style)
-            free(style);
-        if (pathData)
-            free(pathData);
-        }
+        { }
 
 
     /**
      *
      */
-    char *getStyle()
+    std::string getStyle()
         { return style; }
 
     /**
      *
      */
-    char *getPathData()
+    std::string getPathData()
         { return pathData; }
 
     /**
@@ -87,16 +90,18 @@ public:
     long getNodeCount()
         { return nodeCount; }
 
-    /**
-     *
-     */
-    TracingEngineResult *next;
-
 private:
 
-    char *style;
+    void assign(const TracingEngineResult &other)
+        {
+        style = other.style;
+        pathData = other.pathData;
+        nodeCount = other.nodeCount;
+        }
 
-    char *pathData;
+    std::string style;
+
+    std::string pathData;
 
     long nodeCount;
 
@@ -131,8 +136,9 @@ class TracingEngine
      *  compatible with the d="" attribute
      *  of an SVG <path> element.
      */
-    virtual  TracingEngineResult *trace(GdkPixbuf *pixbuf, int *nrPaths)
-        { return NULL; }
+    virtual  std::vector<TracingEngineResult> trace(
+                           Glib::RefPtr<Gdk::Pixbuf> pixbuf)
+        { std::vector<TracingEngineResult> dummy;  return dummy; }
 
 
     /**
@@ -171,7 +177,7 @@ public:
     Tracer()
         {
         engine       = NULL;
-        selectedItem = NULL;
+        sioxEnabled  = false;
         }
 
 
@@ -187,7 +193,7 @@ public:
      *  A convenience method to allow other software to 'see' the
      *  same image that this class sees.
      */
-    GdkPixbuf *getSelectedImage();
+    Glib::RefPtr<Gdk::Pixbuf> getSelectedImage();
 
     /**
      * This is the main working method.  Trace the selected image, if
@@ -202,6 +208,11 @@ public:
      */
     void abort();
 
+    /**
+     *  Whether we want to enable SIOX subimage selection
+     */
+    void enableSiox(bool enable);
+
 
 private:
 
@@ -224,8 +235,15 @@ private:
 
     SPImage *getSelectedSPImage();
 
-    SPItem *selectedItem;
+    std::vector<SPShape *> sioxShapes;
+
+    bool sioxEnabled;
+
+    Glib::RefPtr<Gdk::Pixbuf> sioxProcessImage(
+           SPImage *img, Glib::RefPtr<Gdk::Pixbuf> origPixbuf);
 
+    Glib::RefPtr<Gdk::Pixbuf> lastSioxPixbuf;
+    Glib::RefPtr<Gdk::Pixbuf> lastOrigPixbuf;
 
 };//class Tracer