Code

Modified filter rendering area handling to better accommodate upcoming feOffset
[inkscape.git] / src / trace / trace.cpp
index ae4191a6d5bcd3056182c0df35877e366fab9b1b..925e4e195de41aa2068d7f20fc56645ab0197563 100644 (file)
@@ -1,4 +1,4 @@
-/*
+/**
  * A generic interface for plugging different
  *  autotracers into Inkscape.
  *
@@ -308,6 +308,7 @@ Tracer::sioxProcessImage(SPImage *img,
                 }
             else
                 {
+                //g_message("miss!\n");
                 //dumpMap->setPixelLong(dumpMap, col, row,
                 //        simage.getPixel(col, row));
                 simage.setConfidence(col, row,
@@ -462,12 +463,16 @@ void Tracer::traceThread()
         return;
         }
 
-    int nrPaths;
-    TracingEngineResult *results = engine->trace(pixbuf, &nrPaths);
-    //printf("nrPaths:%d\n", nrPaths);
+    msgStack->flash(Inkscape::NORMAL_MESSAGE, _("Trace: Starting trace..."));
+    desktop->updateCanvasNow();
+    
+    std::vector<TracingEngineResult> results =
+                engine->trace(pixbuf);
+    //printf("nrPaths:%d\n", results.size());
+    int nrPaths = results.size();
 
     //### Check if we should stop
-    if (!keepGoing || !results || nrPaths<1)
+    if (!keepGoing || nrPaths<1)
         {
         engine = NULL;
         return;
@@ -512,25 +517,26 @@ void Tracer::traceThread()
 
     //#OK.  Now let's start making new nodes
 
+    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
     Inkscape::XML::Node *groupRepr = NULL;
 
     //# if more than 1, make a <g>roup of <path>s
     if (nrPaths > 1)
         {
-        groupRepr = sp_repr_new("svg:g");
+        groupRepr = xml_doc->createElement("svg:g");
         par->addChild(groupRepr, imgRepr);
         }
 
     long totalNodeCount = 0L;
 
-    for (TracingEngineResult *result=results ;
-                  result ; result=result->next)
+    for (unsigned int i=0 ; i<results.size() ; i++)
         {
-        totalNodeCount += result->getNodeCount();
+        TracingEngineResult result = results[i];
+        totalNodeCount += result.getNodeCount();
 
-        Inkscape::XML::Node *pathRepr = sp_repr_new("svg:path");
-        pathRepr->setAttribute("style", result->getStyle());
-        pathRepr->setAttribute("d",     result->getPathData());
+        Inkscape::XML::Node *pathRepr = xml_doc->createElement("svg:path");
+        pathRepr->setAttribute("style", result.getStyle().c_str());
+        pathRepr->setAttribute("d",     result.getPathData().c_str());
 
         if (nrPaths > 1)
             groupRepr->addChild(pathRepr, NULL);
@@ -552,8 +558,6 @@ void Tracer::traceThread()
         Inkscape::GC::release(pathRepr);
         }
 
-    delete results;
-
     // If we have a group, then focus on, then forget it
     if (nrPaths > 1)
         {
@@ -563,7 +567,7 @@ void Tracer::traceThread()
         }
 
     //## inform the document, so we can undo
-    sp_document_done(doc);
+    sp_document_done(doc, SP_VERB_SELECTION_TRACE, _("Trace bitmap"));
 
     engine = NULL;