~ubuntu-branches/debian/experimental/inkscape/experimental

« back to all changes in this revision

Viewing changes to src/trace/trace.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2008-09-09 23:29:02 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20080909232902-c50iujhk1w79u8e7
Tags: 0.46-2.1
* Non-maintainer upload.
* Add upstream patch fixing a crash in the open dialog
  in the zh_CN.utf8 locale. Closes: #487623.
  Thanks to Luca Bruno for the patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
 
1
/**
2
2
 * A generic interface for plugging different
3
3
 *  autotracers into Inkscape.
4
4
 *
308
308
                }
309
309
            else
310
310
                {
 
311
                //g_message("miss!\n");
311
312
                //dumpMap->setPixelLong(dumpMap, col, row,
312
313
                //        simage.getPixel(col, row));
313
314
                simage.setConfidence(col, row,
462
463
        return;
463
464
        }
464
465
 
465
 
    int nrPaths;
466
 
    TracingEngineResult *results = engine->trace(pixbuf, &nrPaths);
467
 
    //printf("nrPaths:%d\n", nrPaths);
 
466
    msgStack->flash(Inkscape::NORMAL_MESSAGE, _("Trace: Starting trace..."));
 
467
    desktop->updateCanvasNow();
 
468
    
 
469
    std::vector<TracingEngineResult> results =
 
470
                engine->trace(pixbuf);
 
471
    //printf("nrPaths:%d\n", results.size());
 
472
    int nrPaths = results.size();
468
473
 
469
474
    //### Check if we should stop
470
 
    if (!keepGoing || !results || nrPaths<1)
 
475
    if (!keepGoing || nrPaths<1)
471
476
        {
472
477
        engine = NULL;
473
478
        return;
512
517
 
513
518
    //#OK.  Now let's start making new nodes
514
519
 
 
520
    Inkscape::XML::Document *xml_doc = sp_document_repr_doc(desktop->doc());
515
521
    Inkscape::XML::Node *groupRepr = NULL;
516
522
 
517
523
    //# if more than 1, make a <g>roup of <path>s
518
524
    if (nrPaths > 1)
519
525
        {
520
 
        groupRepr = sp_repr_new("svg:g");
 
526
        groupRepr = xml_doc->createElement("svg:g");
521
527
        par->addChild(groupRepr, imgRepr);
522
528
        }
523
529
 
524
530
    long totalNodeCount = 0L;
525
531
 
526
 
    for (TracingEngineResult *result=results ;
527
 
                  result ; result=result->next)
 
532
    for (unsigned int i=0 ; i<results.size() ; i++)
528
533
        {
529
 
        totalNodeCount += result->getNodeCount();
 
534
        TracingEngineResult result = results[i];
 
535
        totalNodeCount += result.getNodeCount();
530
536
 
531
 
        Inkscape::XML::Node *pathRepr = sp_repr_new("svg:path");
532
 
        pathRepr->setAttribute("style", result->getStyle());
533
 
        pathRepr->setAttribute("d",     result->getPathData());
 
537
        Inkscape::XML::Node *pathRepr = xml_doc->createElement("svg:path");
 
538
        pathRepr->setAttribute("style", result.getStyle().c_str());
 
539
        pathRepr->setAttribute("d",     result.getPathData().c_str());
534
540
 
535
541
        if (nrPaths > 1)
536
542
            groupRepr->addChild(pathRepr, NULL);
552
558
        Inkscape::GC::release(pathRepr);
553
559
        }
554
560
 
555
 
    delete results;
556
 
 
557
561
    // If we have a group, then focus on, then forget it
558
562
    if (nrPaths > 1)
559
563
        {
563
567
        }
564
568
 
565
569
    //## inform the document, so we can undo
566
 
    sp_document_done(doc);
 
570
    sp_document_done(doc, SP_VERB_SELECTION_TRACE, _("Trace bitmap"));
567
571
 
568
572
    engine = NULL;
569
573