01607bd5ddb309e887bccef6f1332d7514b3c394
1 /*
2 * A simple dialog for setting the parameters for autotracing a
3 * bitmap <image> into an svg <path>
4 *
5 * Authors:
6 * Bob Jamison <rjamison@titan.com>
7 * Stéphane Gimenez <dev@gim.name>
8 * Other dudes from The Inkscape Organization
9 *
10 * Copyright (C) 2004-2006 Authors
11 *
12 * Released under GNU GPL, read the file 'COPYING' for more information
13 */
14 #ifdef HAVE_CONFIG_H
15 # include <config.h>
16 #endif
18 #include <gtkmm/notebook.h>
19 #include <gtkmm/frame.h>
20 #include <gtkmm/spinbutton.h>
21 #include <gtkmm/stock.h>
23 #include <gtk/gtkdialog.h> //for GTK_RESPONSE* types
24 #include <glibmm/i18n.h>
28 #include "tracedialog.h"
29 #include "trace/potrace/inkscape-potrace.h"
32 namespace Inkscape {
33 namespace UI {
34 namespace Dialog {
37 //#########################################################################
38 //## I M P L E M E N T A T I O N
39 //#########################################################################
41 /**
42 * A dialog for adjusting bitmap->vector tracing parameters
43 */
44 class TraceDialogImpl : public TraceDialog
45 {
47 public:
50 /**
51 * Constructor
52 */
53 TraceDialogImpl();
55 /**
56 * Destructor
57 */
58 ~TraceDialogImpl();
60 /**
61 * Callback from OK or Cancel
62 */
63 void responseCallback(int response_id);
65 private:
67 /**
68 * This is the big almighty McGuffin
69 */
70 Inkscape::Trace::Tracer tracer;
72 /**
73 * This does potrace processing
74 * Only preview if do_i_trace is false
75 */
76 void potraceProcess(bool do_i_trace);
78 /**
79 * Abort processing
80 */
81 void abort();
83 void potracePreviewCallback();
85 Gtk::HBox mainHBox;
86 Gtk::Notebook notebook;
87 Gtk::Tooltips tips;
89 //########## General items
90 Gtk::Frame sioxFrame;
91 Gtk::VBox sioxVBox;
92 Gtk::HBox sioxBox;
93 Gtk::CheckButton sioxButton;
95 //########## Potrace pages
96 Gtk::VBox potraceModePageBox;
97 Gtk::VBox potraceParamsPageBox;
99 Gtk::RadioButtonGroup potraceGroup;
100 Gtk::Button *potraceOkButton;
101 Gtk::Button *potraceCancelButton;
103 //#### Modes
105 //## Single scan
106 //brightness
107 Gtk::Frame potraceBrightnessFrame;
108 Gtk::VBox potraceBrightnessVBox;
109 Gtk::HBox potraceBrightnessBox;
110 Gtk::RadioButton potraceBrightnessRadioButton;
111 Gtk::Label potraceBrightnessSpinnerLabel;
112 Gtk::SpinButton potraceBrightnessSpinner;
113 //edge detection
114 Gtk::Frame potraceCannyFrame;
115 Gtk::HBox potraceCannyBox;
116 Gtk::VBox potraceCannyVBox;
117 Gtk::RadioButton potraceCannyRadioButton;
118 //Gtk::HSeparator potraceCannySeparator;
119 //Gtk::Label potraceCannyLoSpinnerLabel;
120 //Gtk::SpinButton potraceCannyLoSpinner;
121 Gtk::Label potraceCannyHiSpinnerLabel;
122 Gtk::SpinButton potraceCannyHiSpinner;
123 //quantization
124 Gtk::Frame potraceQuantFrame;
125 Gtk::HBox potraceQuantBox;
126 Gtk::VBox potraceQuantVBox;
127 Gtk::RadioButton potraceQuantRadioButton;
128 Gtk::Label potraceQuantNrColorLabel;
129 Gtk::SpinButton potraceQuantNrColorSpinner;
130 //params
131 Gtk::CheckButton potraceInvertButton;
132 Gtk::HBox potraceInvertBox;
134 //## Multiple path scanning
135 Gtk::Frame potraceMultiScanFrame;
136 Gtk::VBox potraceMultiScanVBox;
137 //brightness
138 Gtk::HBox potraceMultiScanHBox1;
139 Gtk::RadioButton potraceMultiScanBrightnessRadioButton;
140 Gtk::SpinButton potraceMultiScanNrColorSpinner;
141 //colors
142 Gtk::HBox potraceMultiScanHBox2;
143 Gtk::RadioButton potraceMultiScanColorRadioButton;
144 //grays
145 Gtk::HBox potraceMultiScanHBox3;
146 Gtk::RadioButton potraceMultiScanMonoRadioButton;
147 Gtk::Label potraceMultiScanNrColorLabel;
148 //params
149 Gtk::HBox potraceMultiScanHBox4;
150 Gtk::CheckButton potraceMultiScanStackButton;
151 Gtk::CheckButton potraceMultiScanSmoothButton;
152 Gtk::CheckButton potraceMultiScanBackgroundButton;
154 //#### Parameters
156 Gtk::Frame potraceParamsFrame;
157 Gtk::VBox potraceParamsVBox;
158 Gtk::HBox potraceParamsSpecklesBox;
159 Gtk::CheckButton potraceParamsSpecklesButton;
160 Gtk::Label potraceParamsSpecklesSizeLabel;
161 Gtk::SpinButton potraceParamsSpecklesSizeSpinner;
162 Gtk::HBox potraceParamsCornersBox;
163 Gtk::CheckButton potraceParamsCornersButton;
164 Gtk::Label potraceParamsCornersThresholdLabel;
165 Gtk::SpinButton potraceParamsCornersThresholdSpinner;
166 Gtk::HBox potraceParamsOptimBox;
167 Gtk::CheckButton potraceParamsOptimButton;
168 Gtk::Label potraceParamsOptimToleranceLabel;
169 Gtk::SpinButton potraceParamsOptimToleranceSpinner;
171 //credits
172 Gtk::Frame potraceCreditsFrame;
173 Gtk::VBox potraceCreditsVBox;
174 Gtk::Label potraceCreditsLabel;
176 //########## Preview
177 Gtk::Frame potracePreviewFrame;
178 Gtk::VBox potracePreviewVBox;
179 Gtk::Button potracePreviewButton;
180 Gtk::Image potracePreviewImage;
182 };
187 //#########################################################################
188 //## E V E N T S
189 //#########################################################################
191 /**
192 * This does potrace processing
193 * Only preview if do_i_trace is false
194 */
195 void TraceDialogImpl::potraceProcess(bool do_i_trace)
196 {
197 //##### Get the tracer and engine
198 Inkscape::Trace::Potrace::PotraceTracingEngine pte;
200 /* inversion */
201 bool invert = potraceInvertButton.get_active();
202 pte.setInvert(invert);
204 //##### Get the preprocessor settings
205 /* siox -- performed by Tracer, and before any of the others */
206 if (sioxButton.get_active())
207 tracer.enableSiox(true);
208 else
209 tracer.enableSiox(false);
211 /* one of the following */
212 if (potraceBrightnessRadioButton.get_active())
213 pte.setTraceType(Inkscape::Trace::Potrace::TRACE_BRIGHTNESS);
214 else if (potraceMultiScanBrightnessRadioButton.get_active())
215 pte.setTraceType(Inkscape::Trace::Potrace::TRACE_BRIGHTNESS_MULTI);
216 else if (potraceCannyRadioButton.get_active())
217 pte.setTraceType(Inkscape::Trace::Potrace::TRACE_CANNY);
218 else if (potraceQuantRadioButton.get_active())
219 pte.setTraceType(Inkscape::Trace::Potrace::TRACE_QUANT);
220 else if (potraceMultiScanColorRadioButton.get_active())
221 {
222 pte.setTraceType(Inkscape::Trace::Potrace::TRACE_QUANT_COLOR);
223 pte.setInvert(false);
224 }
225 else if (potraceMultiScanMonoRadioButton.get_active())
226 {
227 pte.setTraceType(Inkscape::Trace::Potrace::TRACE_QUANT_MONO);
228 pte.setInvert(false);
229 }
231 /* params */
232 int paramsSpecklesSize =
233 potraceParamsSpecklesButton.get_active() ?
234 potraceParamsSpecklesSizeSpinner.get_value_as_int() :
235 0;
236 pte.setParamsTurdSize(paramsSpecklesSize);
237 double paramsCornersThreshold =
238 potraceParamsCornersButton.get_active() ?
239 potraceParamsCornersThresholdSpinner.get_value() :
240 0.;
241 pte.setParamsAlphaMax(paramsCornersThreshold);
242 bool paramsOptim = potraceParamsOptimButton.get_active();
243 pte.setParamsOptiCurve(paramsOptim);
244 double paramsOptimTolerance = potraceParamsOptimToleranceSpinner.get_value();
245 pte.setParamsOptTolerance(paramsOptimTolerance);
247 //##### Get the single-scan settings
249 /* brightness */
250 double brightnessThreshold = potraceBrightnessSpinner.get_value();
251 pte.setBrightnessThreshold(brightnessThreshold);
253 /* canny */
254 double cannyHighThreshold = potraceCannyHiSpinner.get_value();
255 pte.setCannyHighThreshold(cannyHighThreshold);
257 /* quantization */
258 int quantNrColors = potraceQuantNrColorSpinner.get_value_as_int();
259 pte.setQuantizationNrColors(quantNrColors);
261 //##### Get multiple-scan settings
262 int multiScanNrColors = potraceMultiScanNrColorSpinner.get_value_as_int();
263 pte.setMultiScanNrColors(multiScanNrColors);
264 bool do_i_stack = potraceMultiScanStackButton.get_active();
265 pte.setMultiScanStack(do_i_stack);
266 bool do_i_smooth = potraceMultiScanSmoothButton.get_active();
267 pte.setMultiScanSmooth(do_i_smooth);
268 bool do_i_remove_background = potraceMultiScanBackgroundButton.get_active();
269 pte.setMultiScanRemoveBackground(do_i_remove_background);
271 //##### Get intermediate bitmap image
272 Glib::RefPtr<Gdk::Pixbuf> pixbuf = tracer.getSelectedImage();
273 if (pixbuf)
274 {
275 Glib::RefPtr<Gdk::Pixbuf> preview = pte.preview(pixbuf);
276 if (preview)
277 {
278 int width = preview->get_width();
279 int height = preview->get_height();
280 double scaleFX = 200.0 / (double)width;
281 double scaleFY = 200.0 / (double)height;
282 double scaleFactor = scaleFX > scaleFY ? scaleFY : scaleFX;
283 int newWidth = (int) (((double)width) * scaleFactor);
284 int newHeight = (int) (((double)height) * scaleFactor);
285 Glib::RefPtr<Gdk::Pixbuf> scaledPreview =
286 preview->scale_simple(newWidth, newHeight,
287 Gdk::INTERP_NEAREST);
288 //g_object_unref(preview);
289 potracePreviewImage.set(scaledPreview);
290 }
291 }
293 //##### Convert
294 if (do_i_trace)
295 {
296 if (potraceCancelButton)
297 potraceCancelButton->set_sensitive(true);
298 if (potraceOkButton)
299 potraceOkButton->set_sensitive(false);
300 tracer.trace(&pte);
301 if (potraceCancelButton)
302 potraceCancelButton->set_sensitive(false);
303 if (potraceOkButton)
304 potraceOkButton->set_sensitive(true);
305 }
307 }
310 /**
311 * Abort processing
312 */
313 void TraceDialogImpl::abort()
314 {
315 //### Do some GUI thing
317 //### Make the abort() call to the tracer
318 tracer.abort();
320 }
324 //#########################################################################
325 //## E V E N T S
326 //#########################################################################
328 /**
329 * Callback from the Preview button. Can be called from elsewhere.
330 */
331 void TraceDialogImpl::potracePreviewCallback()
332 {
333 potraceProcess(false);
334 }
336 /**
337 * Default response from the dialog. Let's intercept it
338 */
339 void TraceDialogImpl::responseCallback(int response_id)
340 {
341 if (response_id == GTK_RESPONSE_OK)
342 {
343 // for now, we assume potrace, as it's the only one we have
344 potraceProcess(true);
345 }
346 else if (response_id == GTK_RESPONSE_CANCEL)
347 {
348 abort();
349 }
350 else
351 {
352 hide();
353 return;
354 }
356 }
360 //#########################################################################
361 //## C O N S T R U C T O R / D E S T R U C T O R
362 //#########################################################################
363 /**
364 * Constructor
365 */
366 TraceDialogImpl::TraceDialogImpl()
367 {
369 Gtk::VBox *mainVBox = get_vbox();
371 #define MARGIN 2
373 /*#### brightness ####*/
374 potraceBrightnessRadioButton.set_label(_("Brightness cutoff"));
375 potraceGroup = potraceBrightnessRadioButton.get_group();
376 potraceBrightnessBox.pack_start(potraceBrightnessRadioButton, false, false, MARGIN);
377 tips.set_tip(potraceBrightnessRadioButton, _("Trace by a given brightness level"));
379 potraceBrightnessSpinner.set_digits(3);
380 potraceBrightnessSpinner.set_increments(0.01, 0.1);
381 potraceBrightnessSpinner.set_range(0.0, 1.0);
382 potraceBrightnessSpinner.set_value(0.45);
383 potraceBrightnessBox.pack_end(potraceBrightnessSpinner, false, false, MARGIN);
384 tips.set_tip(potraceBrightnessSpinner, _("Brightness cutoff for black/white"));
386 potraceBrightnessSpinnerLabel.set_label(_("Threshold:"));
387 potraceBrightnessBox.pack_end(potraceBrightnessSpinnerLabel, false, false, MARGIN);
389 potraceBrightnessVBox.pack_start(potraceBrightnessBox, false, false, MARGIN);
391 potraceBrightnessFrame.set_label(_("Single scan: creates a path"));
393 /*#### canny edge detection ####*/
394 // TRANSLATORS: "Canny" is the name of the inventor of this edge detection method
395 potraceCannyRadioButton.set_label(_("Edge detection"));
396 potraceCannyRadioButton.set_group(potraceGroup);
397 potraceCannyBox.pack_start(potraceCannyRadioButton, false, false, MARGIN);
398 tips.set_tip(potraceCannyRadioButton, _("Trace with optimal edge detection by J. Canny's algorithm"));
399 /*
400 potraceCannyBox.pack_start(potraceCannySeparator);
401 potraceCannyLoSpinnerLabel.set_label(_("Low"));
402 potraceCannyBox.pack_start(potraceCannyLoSpinnerLabel);
403 potraceCannyLoSpinner.set_digits(5);
404 potraceCannyLoSpinner.set_increments(0.01, 0.1);
405 potraceCannyLoSpinner.set_range(0.0, 1.0);
406 potraceCannyLoSpinner.set_value(0.1);
407 potraceCannyBox.pack_start(potraceCannyLoSpinner);
408 */
409 potraceCannyHiSpinner.set_digits(3);
410 potraceCannyHiSpinner.set_increments(0.01, 0.1);
411 potraceCannyHiSpinner.set_range(0.0, 1.0);
412 potraceCannyHiSpinner.set_value(0.65);
413 potraceCannyBox.pack_end(potraceCannyHiSpinner, false, false, MARGIN);
414 tips.set_tip(potraceCannyHiSpinner, _("Brightness cutoff for adjacent pixels (determines edge thickness)"));
416 potraceCannyHiSpinnerLabel.set_label(_("Threshold:"));
417 potraceCannyBox.pack_end(potraceCannyHiSpinnerLabel, false, false, MARGIN);
419 potraceBrightnessVBox.pack_start(potraceCannyBox, false, false, MARGIN);
421 /*#### quantization ####*/
422 // TRANSLATORS: Color Quantization: the process of reducing the number of colors
423 // in an image by selecting an optimized set of representative colors and then
424 // re-applying this reduced set to the original image.
425 potraceQuantRadioButton.set_label(_("Color quantization"));
426 potraceQuantRadioButton.set_group(potraceGroup);
427 potraceQuantBox.pack_start(potraceQuantRadioButton, false, false, MARGIN);
428 tips.set_tip(potraceQuantRadioButton, _("Trace along the boundaries of reduced colors"));
430 potraceQuantNrColorSpinner.set_digits(0);
431 potraceQuantNrColorSpinner.set_increments(1.0, 4.0);
432 potraceQuantNrColorSpinner.set_range(2.0, 64.0);
433 potraceQuantNrColorSpinner.set_value(8.0);
434 potraceQuantBox.pack_end(potraceQuantNrColorSpinner, false, false, MARGIN);
435 tips.set_tip(potraceQuantNrColorSpinner, _("The number of reduced colors"));
437 potraceQuantNrColorLabel.set_label(_("Colors:"));
438 potraceQuantBox.pack_end(potraceQuantNrColorLabel, false, false, MARGIN);
440 potraceBrightnessVBox.pack_start(potraceQuantBox, false, false, MARGIN);
442 /*#### swap black and white ####*/
443 potraceInvertButton.set_label(_("Invert image"));
444 potraceInvertButton.set_active(false);
445 potraceInvertBox.pack_start(potraceInvertButton, false, false, MARGIN);
446 potraceBrightnessVBox.pack_start(potraceInvertBox, false, false, MARGIN);
447 tips.set_tip(potraceInvertButton, _("Invert black and white regions"));
449 potraceBrightnessFrame.add(potraceBrightnessVBox);
450 potraceModePageBox.pack_start(potraceBrightnessFrame, false, false, 0);
453 /*#### Multiple scanning####*/
454 //----Hbox1
455 potraceMultiScanBrightnessRadioButton.set_label(_("Brightness steps"));
456 potraceMultiScanBrightnessRadioButton.set_group(potraceGroup);
457 potraceMultiScanHBox1.pack_start(potraceMultiScanBrightnessRadioButton, false, false, MARGIN);
458 tips.set_tip(potraceMultiScanBrightnessRadioButton, _("Trace the given number of brightness levels"));
460 potraceMultiScanNrColorSpinner.set_digits(0);
461 potraceMultiScanNrColorSpinner.set_increments(1.0, 4.0);
462 potraceMultiScanNrColorSpinner.set_range(2.0, 256.0);
463 potraceMultiScanNrColorSpinner.set_value(8.0);
464 potraceMultiScanHBox1.pack_end(potraceMultiScanNrColorSpinner, false, false, MARGIN);
465 potraceMultiScanNrColorLabel.set_label(_("Scans:"));
466 potraceMultiScanHBox1.pack_end(potraceMultiScanNrColorLabel, false, false, MARGIN);
467 tips.set_tip(potraceMultiScanNrColorSpinner, _("The desired number of scans"));
469 potraceMultiScanVBox.pack_start(potraceMultiScanHBox1, false, false, MARGIN);
471 //----Hbox2
472 potraceMultiScanColorRadioButton.set_label(_("Colors"));
473 potraceMultiScanColorRadioButton.set_group(potraceGroup);
474 potraceMultiScanHBox2.pack_start(potraceMultiScanColorRadioButton, false, false, MARGIN);
475 tips.set_tip(potraceMultiScanColorRadioButton, _("Trace the given number of reduced colors"));
477 potraceMultiScanVBox.pack_start(potraceMultiScanHBox2, false, false, MARGIN);
479 //---Hbox3
480 potraceMultiScanMonoRadioButton.set_label(_("Grays"));
481 potraceMultiScanMonoRadioButton.set_group(potraceGroup);
482 potraceMultiScanHBox3.pack_start(potraceMultiScanMonoRadioButton, false, false, MARGIN);
483 tips.set_tip(potraceMultiScanMonoRadioButton, _("Same as Colors, but the result is converted to grayscale"));
485 potraceMultiScanVBox.pack_start(potraceMultiScanHBox3, false, false, MARGIN);
487 // TRANSLATORS: "Smooth" is a verb here
488 potraceMultiScanSmoothButton.set_label(_("Smooth"));
489 potraceMultiScanSmoothButton.set_active(true);
490 potraceMultiScanHBox4.pack_start(potraceMultiScanSmoothButton, false, false, MARGIN);
491 tips.set_tip(potraceMultiScanSmoothButton, _("Apply Gaussian blur to the bitmap before tracing"));
493 // TRANSLATORS: "Stack" is a verb here
494 potraceMultiScanStackButton.set_label(_("Stack scans"));
495 potraceMultiScanStackButton.set_active(true);
496 potraceMultiScanHBox4.pack_start(potraceMultiScanStackButton, false, false, MARGIN);
497 tips.set_tip(potraceMultiScanStackButton, _("Stack scans on top of one another (no gaps) instead of or tiling (usually with gaps)"));
499 // TRANSLATORS: "Layer" refers to one of the stacked paths in the multiscan
500 potraceMultiScanBackgroundButton.set_label(_("Remove background"));
501 potraceMultiScanBackgroundButton.set_active(false);
502 potraceMultiScanHBox4.pack_start(potraceMultiScanBackgroundButton, false, false, MARGIN);
503 tips.set_tip(potraceMultiScanBackgroundButton, _("Remove bottom (background) layer when done"));
505 potraceMultiScanVBox.pack_start(potraceMultiScanHBox4, false, false, MARGIN);
507 potraceMultiScanFrame.set_label(_("Multiple scans: creates a group of paths"));
508 //potraceQuantFrame.set_shadow_type(Gtk::SHADOW_NONE);
509 potraceMultiScanFrame.add(potraceMultiScanVBox);
510 potraceModePageBox.pack_start(potraceMultiScanFrame, false, false, 0);
512 notebook.append_page(potraceModePageBox, _("Mode"));
514 //#### Parameters ####
516 //## Potrace Parameters
517 potraceParamsSpecklesButton.set_label(_("Suppress speckles"));
518 tips.set_tip(potraceParamsSpecklesButton,
519 _("Ignore small spots (speckles) in the bitmap"));
520 potraceParamsSpecklesButton.set_active(true);
521 //tips.set_tip(potraceParamsSpecklesButton, _(""));
522 potraceParamsSpecklesBox.pack_start(potraceParamsSpecklesButton, false, false, MARGIN);
523 potraceParamsSpecklesSizeSpinner.set_digits(0);
524 potraceParamsSpecklesSizeSpinner.set_increments(1, 10);
525 potraceParamsSpecklesSizeSpinner.set_range(0, 1000);
526 potraceParamsSpecklesSizeSpinner.set_value(2);
527 tips.set_tip(potraceParamsSpecklesSizeSpinner,
528 _("Speckles of up to this many pixels will be suppressed"));
529 potraceParamsSpecklesBox.pack_end(potraceParamsSpecklesSizeSpinner, false, false, MARGIN);
530 potraceParamsSpecklesSizeLabel.set_label(_("Size:"));
531 potraceParamsSpecklesBox.pack_end(potraceParamsSpecklesSizeLabel, false, false, MARGIN);
533 potraceParamsCornersButton.set_label(_("Smooth corners"));
534 tips.set_tip(potraceParamsCornersButton,
535 _("Smooth out sharp corners of the trace"));
536 potraceParamsCornersButton.set_active(true);
537 //tips.set_tip(potraceParamsCornersButton, _(""));
538 potraceParamsCornersBox.pack_start(potraceParamsCornersButton, false, false, MARGIN);
539 potraceParamsCornersThresholdSpinner.set_digits(2);
540 potraceParamsCornersThresholdSpinner.set_increments(0.01, 0.1);
541 potraceParamsCornersThresholdSpinner.set_range(0.0, 1.34);
542 potraceParamsCornersThresholdSpinner.set_value(1.0);
543 potraceParamsCornersBox.pack_end(potraceParamsCornersThresholdSpinner, false, false, MARGIN);
544 tips.set_tip(potraceParamsCornersThresholdSpinner,
545 _("Increase this to smooth corners more"));
546 potraceParamsCornersThresholdLabel.set_label(_("Threshold:"));
547 potraceParamsCornersBox.pack_end(potraceParamsCornersThresholdLabel, false, false, MARGIN);
549 potraceParamsOptimButton.set_label(_("Optimize paths"));
550 potraceParamsOptimButton.set_active(true);
551 tips.set_tip(potraceParamsOptimButton,
552 _("Try to optimize paths by joining adjacent Bezier curve segments"));
553 potraceParamsOptimBox.pack_start(potraceParamsOptimButton, false, false, MARGIN);
554 potraceParamsOptimToleranceSpinner.set_digits(2);
555 potraceParamsOptimToleranceSpinner.set_increments(0.05, 0.25);
556 potraceParamsOptimToleranceSpinner.set_range(0.0, 5.0);
557 potraceParamsOptimToleranceSpinner.set_value(0.2);
558 potraceParamsOptimBox.pack_end(potraceParamsOptimToleranceSpinner, false, false, MARGIN);
559 tips.set_tip(potraceParamsOptimToleranceSpinner,
560 _("Increase this to reduce the number of nodes in the trace by more aggressive optimization"));
561 potraceParamsOptimToleranceLabel.set_label(_("Tolerance:"));
562 potraceParamsOptimBox.pack_end(potraceParamsOptimToleranceLabel, false, false, MARGIN);
564 potraceParamsVBox.pack_start(potraceParamsSpecklesBox, false, false, MARGIN);
565 potraceParamsVBox.pack_start(potraceParamsCornersBox, false, false, MARGIN);
566 potraceParamsVBox.pack_start(potraceParamsOptimBox, false, false, MARGIN);
567 potraceParamsFrame.set_label(_("Options"));
568 potraceParamsFrame.add(potraceParamsVBox);
569 potraceParamsPageBox.pack_start(potraceParamsFrame, false, false, 0);
571 //## SIOX
572 //for now, put at the top of the potrace box. something better later
573 sioxButton.set_label(_("SIOX foreground selection"));
574 sioxBox.pack_start(sioxButton, false, false, MARGIN);
575 tips.set_tip(sioxButton,
576 _("Cover the area you want to select as the foreground"));
577 sioxVBox.pack_start(sioxBox, false, false, MARGIN);
578 sioxFrame.set_label(_("SIOX"));
579 sioxFrame.add(sioxVBox);
580 potraceParamsPageBox.pack_start(sioxFrame, false, false, 0);
582 //## Credits
583 potraceCreditsLabel.set_text(_("Thanks to Peter Selinger, http://potrace.sourceforge.net"));
584 potraceCreditsVBox.pack_start(potraceCreditsLabel, false, false, MARGIN);
585 potraceCreditsFrame.set_label(_("Credits"));
586 potraceCreditsFrame.set_shadow_type(Gtk::SHADOW_NONE);
587 potraceCreditsFrame.add(potraceCreditsVBox);
588 potraceParamsPageBox.pack_end(potraceCreditsFrame, false, false, 0);
590 notebook.append_page(potraceParamsPageBox, _("Options"));
592 mainHBox.pack_start(notebook, true, true, MARGIN);
594 /*#### Preview ####*/
595 potracePreviewButton.set_label(_("Update"));
596 potracePreviewButton.signal_clicked().connect(
597 sigc::mem_fun(*this, &TraceDialogImpl::potracePreviewCallback) );
598 potracePreviewVBox.pack_end(potracePreviewButton, false, false, 0);
599 tips.set_tip(potracePreviewButton, _("Preview the intermediate bitmap with the current settings, without actual tracing"));
601 potracePreviewImage.set_size_request(200,200);
602 //potracePreviewImage.set_alignment (Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
603 potracePreviewVBox.pack_start(potracePreviewImage, true, true, 0);
604 potracePreviewFrame.set_label(_("Preview")); // I guess it's correct to call the "intermediate bitmap" a preview of the trace
605 //potracePreviewFrame.set_shadow_type(Gtk::SHADOW_NONE);
606 potracePreviewFrame.add(potracePreviewVBox);
608 mainHBox.pack_start(potracePreviewFrame, true, true, MARGIN);
610 //attach contents to the main VBox
611 mainVBox->pack_start(mainHBox);
613 //#### Global Controls
615 //## The OK button
616 potraceCancelButton = add_button(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL);
617 if (potraceCancelButton)
618 {
619 tips.set_tip((*potraceCancelButton), _("Abort a trace in progress"));
620 potraceCancelButton->set_sensitive(false);
621 }
622 potraceOkButton = add_button(Gtk::Stock::OK, GTK_RESPONSE_OK);
623 tips.set_tip((*potraceOkButton), _("Execute the trace"));
625 show_all_children();
627 //## Connect the signal
628 signal_response().connect(
629 sigc::mem_fun(*this, &TraceDialogImpl::responseCallback) );
630 }
632 /**
633 * Factory method. Use this to create a new TraceDialog
634 */
635 TraceDialog *TraceDialog::create()
636 {
637 TraceDialog *dialog = new TraceDialogImpl();
638 return dialog;
639 }
642 /**
643 * Constructor
644 */
645 TraceDialogImpl::~TraceDialogImpl()
646 {
648 }
651 } //namespace Dialog
652 } //namespace UI
653 } //namespace Inkscape
655 //#########################################################################
656 //## E N D O F F I L E
657 //#########################################################################