trace.cpp revision 23c2596db8256f153092ae54cdad0dedb5b2ac94
/*
* A generic interface for plugging different
* autotracers into Inkscape.
*
* Authors:
* Bob Jamison <rjamison@earthlink.net>
*
* Copyright (C) 2004-2006 Bob Jamison
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "trace/potrace/inkscape-potrace.h"
#include <inkscape.h>
#include <desktop-handles.h>
#include <document.h>
#include "message-stack.h"
#include <selection.h>
#include "sp-item.h"
#include "sp-image.h"
#include "siox.h"
#include "imagemap-gdk.h"
namespace Inkscape {
namespace Trace {
/**
*
*/
SPImage *
{
if (!desktop)
{
g_warning("Trace: No active desktop\n");
return NULL;
}
if (!sel)
{
char *msg = _("Select an <b>image</b> to trace");
//g_warning(msg);
return NULL;
}
if (sioxEnabled)
{
/*
First, things are selected top-to-bottom, so we need to invert
them as bottom-to-top so that we can discover the image and any
SPItems above it
*/
{
{
continue;
}
}
{
if (SP_IS_IMAGE(item))
{
if (img) //we want only one
{
char *msg = _("Select only one <b>image</b> to trace");
return NULL;
}
}
else if (img) //# items -after- the image in tree (above it in Z)
{
}
}
{
char *msg = _("Select one image and one or more items above it");
return NULL;
}
return img;
}
else
//### No SIOX. We want exactly one image selected
{
if (!item)
{
//g_warning(msg);
return NULL;
}
if (!SP_IS_IMAGE(item))
{
char *msg = _("Select an <b>image</b> to trace");
//g_warning(msg);
return NULL;
}
return img;
}
}
/**
*
*/
{
if (!img)
return NULL;
return pixbuf;
}
{
//We need to create two things:
// 1. An array of long pixel values of ARGB
// 2. A matching array of per-pixel float 'confidence' values
long idx = 0;
{
(((long)rgb.b) & 0x0000FFL);
}
//## ok we have our pixel buf
0, 0.0);
idx = 0;
{
}
delete imgBuf;
delete confidenceMatrix;
return newPixbuf;
}
//#########################################################################
//# T R A C E
//#########################################################################
/**
* Whether we want to enable SIOX subimage selection
*/
{
}
/**
* Threaded method that does single bitmap--->path conversion
*/
void Tracer::traceThread()
{
//## Remember. NEVER leave this method without setting
//## engine back to NULL
//## Prepare our kill flag. We will watch this later to
//## see if the main thread wants us to stop
keepGoing = true;
if (!desktop)
{
g_warning("Trace: No active desktop\n");
return;
}
if (!SP_ACTIVE_DOCUMENT)
{
char *msg = _("Trace: No active document");
//g_warning(msg);
return;
}
if (!img)
{
return;
}
if (!pixbuf)
{
char *msg = _("Trace: Image has no bitmap data");
//g_warning(msg);
return;
}
//## SIOX pre-processing to get a smart subimage of the pixbuf.
//## This is done before any other filters
if (sioxEnabled)
{
/*
Ok, we have requested siox, and getSelectedSPImage() has found a single
bitmap and one or more SPItems above it. Now what we need to do is create
a siox-segmented subimage pixbuf. We not need alter 'img' at all, since this
pixbuf will be the same dimensions and at the same location.
Remember to free this new pixbuf later.
*/
}
int nrPaths;
//printf("nrPaths:%d\n", nrPaths);
//### Check if we should stop
{
return;
}
//### Get pointers to the <image> and its parent
//### Get some information for the new transform()
double x = 0.0;
double y = 0.0;
double width = 0.0;
double height = 0.0;
double dval = 0.0;
x = dval;
y = dval;
//# Convolve scale, translation, and the original transform
//#OK. Now let's start making new nodes
//# if more than 1, make a <g>roup of <path>s
if (nrPaths > 1)
{
}
long totalNodeCount = 0L;
{
if (nrPaths > 1)
else
//### Apply the transform from the image to the new shape
if (reprobj)
{
}
if (nrPaths == 1)
{
}
}
//did we allocate a pixbuf copy?
if (sioxEnabled)
{
}
delete results;
// If we have a group, then focus on, then forget it
if (nrPaths > 1)
{
}
//## inform the document, so we can undo
}
/**
* Main tracing method
*/
{
//Check if we are already running
if (engine)
return;
#if HAVE_THREADS
//Ensure that thread support is running
if (!Glib::thread_supported())
Glib::thread_init();
//Create our thread and run it
#else
traceThread();
#endif
}
/**
* Abort the thread that is executing trace()
*/
{
//## Inform Trace's working thread
keepGoing = false;
if (engine)
{
}
}
} // namespace Trace
} // namespace Inkscape
//#########################################################################
//# E N D O F F I L E
//#########################################################################