tracedialog.cpp revision fdeb14b5acd8ab24c8c8dab6e78c23c967547747
/*
* A simple dialog for setting the parameters for autotracing a
* bitmap <image> into an svg <path>
*
* Authors:
* Bob Jamison
* Other dudes from The Inkscape Organization
*
* Copyright (C) 2004, 2005 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 items
//brightness
//edge detection
//Gtk::HSeparator potraceCannySeparator;
//Gtk::Label potraceCannyLoSpinnerLabel;
//Gtk::SpinButton potraceCannyLoSpinner;
//quantization
//multiple path scanning
//preview
//credits
//########## Other items
};
//#########################################################################
//## 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())
{
}
//##### 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)
{
//g_message("selected panel:%d\n", panelNr);
if (panelNr == 0)
{
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 4
/*#### SIOX ####*/
//# for now, put at the top of the potrace box. something better later
_("Cover the area you want to select as the foreground"));
//##Set up the Potrace panel
/*#### brightness ####*/
//potraceBrightnessFrame.set_shadow_type(Gtk::SHADOW_NONE);
/*#### canny edge detection ####*/
// TRANSLATORS: "Canny" is the name of the inventor of this edge detection method
/*
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)"));
//potraceCannyFrame.set_shadow_type(Gtk::SHADOW_NONE);
/*#### 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.
//potraceQuantFrame.set_shadow_type(Gtk::SHADOW_NONE);
/*#### Multiple scanning####*/
//----Hbox1
tips.set_tip(potraceMultiScanBrightnessRadioButton, _("Trace the given number of brightness levels"));
//----Hbox2
//---Hbox3
// TRANSLATORS: "Stack" is a verb here
tips.set_tip(potraceMultiScanStackButton, _("Stack scans vertically (no gaps) or tile horizontally (usually with gaps)"));
// TRANSLATORS: "Smooth" is a verb here
//potraceQuantFrame.set_shadow_type(Gtk::SHADOW_NONE);
/*#### Preview ####*/
//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);
/*#### swap black and white ####*/
potraceInvertButton.set_active(false);
/*#### Credits ####*/
_("Thanks to Peter Selinger, http://potrace.sourceforge.net")
);
/*done */
// TRANSLATORS: Potrace is an application for transforming bitmaps into
// vector graphics (http://potrace.sourceforge.net/)
//##Set up the Other panel
// This may be reenabled when we have another tracer; now an empty tab is confusing so I'm disabling it
// notebook.append_page(otherBox, _("Other"));
//##Put the notebook on the dialog
//## 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
//#########################################################################