tracedialog.cpp revision 2cdb4e5af82e8a4e38d66065f181da590cec95ff
/*
* A simple dialog for setting the parameters for autotracing a
* bitmap <image> into an svg <path>
*
* Authors:
* Bob Jamison <rjamison@titan.com>
* Stéphane Gimenez <dev@gim.name>
* Other dudes from The Inkscape Organization
*
* Copyright (C) 2004-2006 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtkmm/notebook.h>
#include <gtkmm/spinbutton.h>
#include "tracedialog.h"
#include "trace/potrace/inkscape-potrace.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
//#########################################################################
//## I M P L E M E N T A T I O N
//#########################################################################
/**
* A dialog for adjusting bitmap->vector tracing parameters
*/
class TraceDialogImpl : public TraceDialog
{
public:
/**
* Constructor
*/
/**
* Destructor
*/
~TraceDialogImpl();
/**
* Callback from OK or Cancel
*/
void responseCallback(int response_id);
private:
/**
* This is the big almighty McGuffin
*/
/**
* This does potrace processing
* Only preview if do_i_trace is false
*/
void potraceProcess(bool do_i_trace);
/**
* Abort processing
*/
void abort();
void potracePreviewCallback();
//########## General items
//########## Potrace pages
//#### Modes
//## Single scan
//brightness
//edge detection
//Gtk::HSeparator potraceCannySeparator;
//Gtk::Label potraceCannyLoSpinnerLabel;
//Gtk::SpinButton potraceCannyLoSpinner;
//quantization
//params
//## Multiple path scanning
//brightness
//colors
//grays
//params
//#### Parameters
//credits
//########## Preview
};
//#########################################################################
//## E V E N T S
//#########################################################################
/**
* This does potrace processing
* Only preview if do_i_trace is false
*/
{
//##### Get the tracer and engine
/* inversion */
//##### Get the preprocessor settings
/* siox -- performed by Tracer, and before any of the others */
if (sioxButton.get_active())
tracer.enableSiox(true);
else
tracer.enableSiox(false);
/* one of the following */
else if (potraceMultiScanBrightnessRadioButton.get_active())
else if (potraceCannyRadioButton.get_active())
else if (potraceQuantRadioButton.get_active())
else if (potraceMultiScanColorRadioButton.get_active())
{
}
else if (potraceMultiScanMonoRadioButton.get_active())
{
}
/* params */
int paramsSpecklesSize =
0;
double paramsCornersThreshold =
0.;
//##### Get the single-scan settings
/* brightness */
/* canny */
/* quantization */
//##### Get multiple-scan settings
//##### Get intermediate bitmap image
if (pixbuf)
{
if (preview)
{
//g_object_unref(preview);
}
}
//##### Convert
if (do_i_trace)
{
if (potraceCancelButton)
potraceCancelButton->set_sensitive(true);
if (potraceOkButton)
potraceOkButton->set_sensitive(false);
if (potraceCancelButton)
potraceCancelButton->set_sensitive(false);
if (potraceOkButton)
potraceOkButton->set_sensitive(true);
}
}
/**
* Abort processing
*/
void TraceDialogImpl::abort()
{
//### Do some GUI thing
//### Make the abort() call to the tracer
}
//#########################################################################
//## E V E N T S
//#########################################################################
/**
* Callback from the Preview button. Can be called from elsewhere.
*/
{
potraceProcess(false);
}
/**
* Default response from the dialog. Let's intercept it
*/
{
if (response_id == GTK_RESPONSE_OK)
{
// for now, we assume potrace, as it's the only one we have
potraceProcess(true);
}
else if (response_id == GTK_RESPONSE_CANCEL)
{
abort();
}
else
{
hide();
return;
}
}
//#########################################################################
//## C O N S T R U C T O R / D E S T R U C T O R
//#########################################################################
/**
* Constructor
*/
{
#define MARGIN 2
/*#### brightness ####*/
/*#### canny edge detection ####*/
// TRANSLATORS: "Canny" is the name of the inventor of this edge detection method
tips.set_tip(potraceCannyRadioButton, _("Trace with optimal edge detection by J. Canny's algorithm"));
/*
potraceCannyBox.pack_start(potraceCannySeparator);
potraceCannyLoSpinnerLabel.set_label(_("Low"));
potraceCannyBox.pack_start(potraceCannyLoSpinnerLabel);
potraceCannyLoSpinner.set_digits(5);
potraceCannyLoSpinner.set_increments(0.01, 0.1);
potraceCannyLoSpinner.set_range(0.0, 1.0);
potraceCannyLoSpinner.set_value(0.1);
potraceCannyBox.pack_start(potraceCannyLoSpinner);
*/
tips.set_tip(potraceCannyHiSpinner, _("Brightness cutoff for adjacent pixels (determines edge thickness)"));
/*#### quantization ####*/
// TRANSLATORS: Color Quantization: the process of reducing the number of colors
// in an image by selecting an optimized set of representative colors and then
// re-applying this reduced set to the original image.
/*#### swap black and white ####*/
potraceInvertButton.set_active(false);
/*#### Multiple scanning####*/
//----Hbox1
tips.set_tip(potraceMultiScanBrightnessRadioButton, _("Trace the given number of brightness levels"));
//----Hbox2
//---Hbox3
tips.set_tip(potraceMultiScanMonoRadioButton, _("Same as Colors, but the result is converted to grayscale"));
// TRANSLATORS: "Smooth" is a verb here
// TRANSLATORS: "Stack" is a verb here
tips.set_tip(potraceMultiScanStackButton, _("Stack scans on top of one another (no gaps) instead of or tiling (usually with gaps)"));
// TRANSLATORS: "Layer" refers to one of the stacked paths in the multiscan
//potraceQuantFrame.set_shadow_type(Gtk::SHADOW_NONE);
//#### Parameters ####
//## Potrace Parameters
_("Ignore small spots (speckles) in the bitmap"));
//tips.set_tip(potraceParamsSpecklesButton, _(""));
_("Speckles of up to this many pixels will be suppressed"));
_("Smooth out sharp corners of the trace"));
//tips.set_tip(potraceParamsCornersButton, _(""));
_("Increase this to smooth corners more"));
_("Try to optimize paths by joining adjacent Bezier curve segments"));
_("Increase this to reduce the number of nodes in the trace by more aggressive optimization"));
//## SIOX
//for now, put at the top of the potrace box. something better later
_("Cover the area you want to select as the foreground"));
//## Credits
/*#### Preview ####*/
tips.set_tip(potracePreviewButton, _("Preview the intermediate bitmap with the current settings, without actual tracing"));
//potracePreviewImage.set_alignment (Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
potracePreviewFrame.set_label(_("Preview")); // I guess it's correct to call the "intermediate bitmap" a preview of the trace
//potracePreviewFrame.set_shadow_type(Gtk::SHADOW_NONE);
//attach contents to the main VBox
//#### Global Controls
//## The OK button
if (potraceCancelButton)
{
potraceCancelButton->set_sensitive(false);
}
//## Connect the signal
}
/**
* Factory method. Use this to create a new TraceDialog
*/
{
return dialog;
}
/**
* Constructor
*/
{
}
} //namespace Dialog
} //namespace UI
} //namespace Inkscape
//#########################################################################
//## E N D O F F I L E
//#########################################################################