From: buliabyak Date: Tue, 14 Nov 2006 00:43:28 +0000 (+0000) Subject: patch 1591723 for extra tracing parameters X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=38435c6b2e3729c171dc37ec637e6deb5a1d105c;p=inkscape.git patch 1591723 for extra tracing parameters --- diff --git a/src/trace/potrace/inkscape-potrace.cpp b/src/trace/potrace/inkscape-potrace.cpp index 404d25d3a..e36673e4f 100644 --- a/src/trace/potrace/inkscape-potrace.cpp +++ b/src/trace/potrace/inkscape-potrace.cpp @@ -3,8 +3,9 @@ * * Authors: * Bob Jamison + * Stéphane Gimenez * - * Copyright (C) 2004 Bob Jamison + * Copyright (C) 2004-2006 Authors * * Released under GNU GPL, read the file 'COPYING' for more information * @@ -70,18 +71,23 @@ namespace Potrace { */ PotraceTracingEngine::PotraceTracingEngine() { + /* get default parameters */ + potraceParams = potrace_param_default(); + potraceParams->progress.callback = potraceStatusCallback; + potraceParams->progress.data = (void *)this; //##### Our defaults invert = false; traceType = TRACE_BRIGHTNESS; - quantizationNrColors = 8; - brightnessThreshold = 0.45; - cannyHighThreshold = 0.65; +} +PotraceTracingEngine::~PotraceTracingEngine() +{ + potrace_param_free(potraceParams); } @@ -366,13 +372,6 @@ PotraceTracingEngine::preview(Glib::RefPtr thePixbuf) std::string PotraceTracingEngine::grayMapToPath(GrayMap *grayMap, long *nodeCount) { - - /* get default parameters */ - potrace_param_t *potraceParams = potrace_param_default(); - - potraceParams->progress.callback = potraceStatusCallback; - potraceParams->progress.data = (void *)this; - potrace_bitmap_t *potraceBitmap = bm_new(grayMap->width, grayMap->height); bm_clear(potraceBitmap, 0); @@ -410,7 +409,6 @@ PotraceTracingEngine::grayMapToPath(GrayMap *grayMap, long *nodeCount) { g_warning("aborted"); potrace_state_free(potraceState); - potrace_param_free(potraceParams); return ""; } @@ -424,7 +422,6 @@ PotraceTracingEngine::grayMapToPath(GrayMap *grayMap, long *nodeCount) /* free a potrace items */ potrace_state_free(potraceState); - potrace_param_free(potraceParams); if (!keepGoing) return ""; diff --git a/src/trace/potrace/inkscape-potrace.h b/src/trace/potrace/inkscape-potrace.h index f3459159f..838a1363a 100644 --- a/src/trace/potrace/inkscape-potrace.h +++ b/src/trace/potrace/inkscape-potrace.h @@ -3,8 +3,9 @@ * * Authors: * Bob Jamison + * Stéphane Gimenez * - * Copyright (C) 2004 Bob Jamison + * Copyright (C) 2004-2006 Authors * * Released under GNU GPL, read the file 'COPYING' for more information * @@ -20,6 +21,8 @@ #include #include +#include "potracelib.h" + namespace Inkscape { namespace Trace { @@ -50,8 +53,47 @@ class PotraceTracingEngine : public TracingEngine /** * */ - virtual ~PotraceTracingEngine() - {} + ~PotraceTracingEngine(); + + + /** + * Sets/gets potrace parameters + */ + void setParamsTurdSize(int val) + { + potraceParams->turdsize = val; + } + int getParamsTurdSize() + { + return potraceParams->turdsize; + } + + void setParamsAlphaMax(double val) + { + potraceParams->alphamax = val; + } + double getParamsAlphaMax() + { + return potraceParams->alphamax; + } + + void setParamsOptiCurve(bool val) + { + potraceParams->opticurve = val; + } + bool getParamsOptiCurve() + { + return potraceParams->opticurve; + } + + void setParamsOptTolerance(double val) + { + potraceParams->opttolerance = val; + } + double getParamsOptTolerance() + { + return potraceParams->opttolerance; + } void setTraceType(TraceType val) { @@ -199,6 +241,7 @@ class PotraceTracingEngine : public TracingEngine private: + potrace_param_t *potraceParams; TraceType traceType; //## do i invert at the end? diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp index 6182954f6..645ce885f 100644 --- a/src/ui/dialog/tracedialog.cpp +++ b/src/ui/dialog/tracedialog.cpp @@ -3,10 +3,11 @@ * bitmap into an svg * * Authors: - * Bob Jamison + * Bob Jamison + * Stéphane Gimenez * Other dudes from The Inkscape Organization * - * Copyright (C) 2004, 2005 Authors + * Copyright (C) 2004-2006 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -98,6 +99,22 @@ class TraceDialogImpl : public TraceDialog Gtk::Button *potraceOkButton; Gtk::Button *potraceCancelButton; + //params + Gtk::Frame potraceParamsFrame; + Gtk::VBox potraceParamsVBox; + Gtk::HBox potraceParamsSpecklesBox; + Gtk::CheckButton potraceParamsSpecklesButton; + Gtk::Label potraceParamsSpecklesSizeLabel; + Gtk::SpinButton potraceParamsSpecklesSizeSpinner; + Gtk::HBox potraceParamsCornersBox; + Gtk::CheckButton potraceParamsCornersButton; + Gtk::Label potraceParamsCornersThresholdLabel; + Gtk::SpinButton potraceParamsCornersThresholdSpinner; + Gtk::HBox potraceParamsOptimBox; + Gtk::CheckButton potraceParamsOptimButton; + Gtk::Label potraceParamsOptimToleranceLabel; + Gtk::SpinButton potraceParamsOptimToleranceSpinner; + //brightness Gtk::Frame potraceBrightnessFrame; Gtk::VBox potraceBrightnessVBox; @@ -211,7 +228,24 @@ void TraceDialogImpl::potraceProcess(bool do_i_trace) pte.setInvert(false); } + /* params */ + int paramsSpecklesSize = + potraceParamsSpecklesButton.get_active() ? + potraceParamsSpecklesSizeSpinner.get_value_as_int() : + 0; + pte.setParamsTurdSize(paramsSpecklesSize); + double paramsCornersThreshold = + potraceParamsCornersButton.get_active() ? + potraceParamsCornersThresholdSpinner.get_value() : + 0.; + pte.setParamsAlphaMax(paramsCornersThreshold); + bool paramsOptim = potraceParamsOptimButton.get_active(); + pte.setParamsOptiCurve(paramsOptim); + double paramsOptimTolerance = potraceParamsOptimToleranceSpinner.get_value(); + pte.setParamsOptTolerance(paramsOptimTolerance); + //##### Get the single-scan settings + /* brightness */ double brightnessThreshold = potraceBrightnessSpinner.get_value(); pte.setBrightnessThreshold(brightnessThreshold); @@ -357,6 +391,57 @@ TraceDialogImpl::TraceDialogImpl() //##Set up the Potrace panel + /*#### params ####*/ + potraceParamsSpecklesButton.set_label(_("Speckles Filtering")); + potraceParamsSpecklesButton.set_active(true); + //tips.set_tip(potraceParamsSpecklesButton, _("")); + potraceParamsSpecklesBox.pack_start(potraceParamsSpecklesButton, false, false, MARGIN); + potraceParamsSpecklesSizeSpinner.set_digits(0); + potraceParamsSpecklesSizeSpinner.set_increments(1, 10); + potraceParamsSpecklesSizeSpinner.set_range(0, 1000); + potraceParamsSpecklesSizeSpinner.set_value(2); + tips.set_tip(potraceParamsSpecklesSizeSpinner, + _("Suppress speckles of up to this many pixels")); + potraceParamsSpecklesBox.pack_end(potraceParamsSpecklesSizeSpinner, false, false, MARGIN); + potraceParamsSpecklesSizeLabel.set_label(_("Size:")); + potraceParamsSpecklesBox.pack_end(potraceParamsSpecklesSizeLabel, false, false, MARGIN); + + potraceParamsCornersButton.set_label(_("Corner Smoothing")); + potraceParamsCornersButton.set_active(true); + //tips.set_tip(potraceParamsCornersButton, _("")); + potraceParamsCornersBox.pack_start(potraceParamsCornersButton, false, false, MARGIN); + potraceParamsCornersThresholdSpinner.set_digits(2); + potraceParamsCornersThresholdSpinner.set_increments(0.01, 0.1); + potraceParamsCornersThresholdSpinner.set_range(0.0, 1.34); + potraceParamsCornersThresholdSpinner.set_value(1.0); + potraceParamsCornersBox.pack_end(potraceParamsCornersThresholdSpinner, false, false, MARGIN); + tips.set_tip(potraceParamsCornersThresholdSpinner, + _("The higher this value, the smoother corners will be produced")); + potraceParamsCornersThresholdLabel.set_label(_("Threshold:")); + potraceParamsCornersBox.pack_end(potraceParamsCornersThresholdLabel, false, false, MARGIN); + + potraceParamsOptimButton.set_label(_("Curve Optimization")); + potraceParamsOptimButton.set_active(true); + tips.set_tip(potraceParamsOptimButton, + _("Try to join adjacent Bezier curve segments")); + potraceParamsOptimBox.pack_start(potraceParamsOptimButton, false, false, MARGIN); + potraceParamsOptimToleranceSpinner.set_digits(2); + potraceParamsOptimToleranceSpinner.set_increments(0.05, 0.25); + potraceParamsOptimToleranceSpinner.set_range(0.0, 5.0); + potraceParamsOptimToleranceSpinner.set_value(0.2); + potraceParamsOptimBox.pack_end(potraceParamsOptimToleranceSpinner, false, false, MARGIN); + tips.set_tip(potraceParamsOptimToleranceSpinner, + _("Set the curve optimization tolerance")); + potraceParamsOptimToleranceLabel.set_label(_("Tolerance:")); + potraceParamsOptimBox.pack_end(potraceParamsOptimToleranceLabel, false, false, MARGIN); + + potraceParamsVBox.pack_start(potraceParamsSpecklesBox, false, false, MARGIN); + potraceParamsVBox.pack_start(potraceParamsCornersBox, false, false, MARGIN); + potraceParamsVBox.pack_start(potraceParamsOptimBox, false, false, MARGIN); + potraceParamsFrame.set_label(_("Parameters")); + potraceParamsFrame.add(potraceParamsVBox); + potraceBox.pack_start(potraceParamsFrame, false, false, 0); + /*#### brightness ####*/ potraceBrightnessRadioButton.set_label(_("Brightness")); potraceGroup = potraceBrightnessRadioButton.get_group();