Code

This is the first c++ification commit from me. It handles sp-line, sp-polyline, sp...
[inkscape.git] / src / ui / dialog / tracedialog.cpp
1 /** @file
2  * @brief Bitmap tracing settings dialog - implementation
3  */
4 /* Authors:
5  *   Bob Jamison <rjamison@titan.com>
6  *   Stéphane Gimenez <dev@gim.name>
7  *   Other dudes from The Inkscape Organization
8  *
9  * Copyright (C) 2004-2006 Authors
10  *
11  * Released under GNU GPL, read the file 'COPYING' for more information
12  */
13 #ifdef HAVE_CONFIG_H
14 # include <config.h>
15 #endif
17 #include <gtkmm/notebook.h>
18 #include <gtkmm/frame.h>
19 #include <gtkmm/spinbutton.h>
20 #include <gtkmm/stock.h>
22 #include <gtk/gtkdialog.h> //for GTK_RESPONSE* types
23 #include <glibmm/i18n.h>
25 #include "desktop.h"
27 #include "tracedialog.h"
28 #include "trace/potrace/inkscape-potrace.h"
31 namespace Inkscape {
32 namespace UI {
33 namespace Dialog {
36 //#########################################################################
37 //## I M P L E M E N T A T I O N
38 //#########################################################################
40 /**
41  * A dialog for adjusting bitmap->vector tracing parameters
42  */
43 class TraceDialogImpl : public TraceDialog
44 {
46     public:
49     /**
50      * Constructor
51      */
52     TraceDialogImpl();
54     /**
55      * Destructor
56      */
57     ~TraceDialogImpl();
59     /**
60      * Callback from OK or Cancel
61      */
62     void responseCallback(int response_id);
64     private:
66     /**
67      * This is the big almighty McGuffin
68      */
69     Inkscape::Trace::Tracer tracer;
71     /**
72      * This does potrace processing
73      * Only preview if do_i_trace is false
74      */
75     void potraceProcess(bool do_i_trace);
77     /**
78      * Abort processing
79      */
80     void abort();
82     void previewCallback();
84     //############ General items
86     Gtk::HBox             mainHBox;
87     Gtk::Tooltips         tips;
89     Gtk::Button           *mainOkButton;
90     Gtk::Button           *mainCancelButton;
92     //######## Left pannel
94     Gtk::VBox             leftVBox;
96     //#### Notebook
98     Gtk::Notebook         notebook;
100     //## Modes
102     Gtk::VBox             modePageBox;
103     Gtk::RadioButtonGroup modeGroup;
105     //# Single scan mode
106     //brightness
107     Gtk::Frame            modeBrightnessFrame;
108     Gtk::VBox             modeBrightnessVBox;
109     Gtk::HBox             modeBrightnessBox;
110     Gtk::RadioButton      modeBrightnessRadioButton;
111     Gtk::Label            modeBrightnessSpinnerLabel;
112     Gtk::SpinButton       modeBrightnessSpinner;
113     //edge detection
114     Gtk::Frame            modeCannyFrame;
115     Gtk::HBox             modeCannyBox;
116     Gtk::VBox             modeCannyVBox;
117     Gtk::RadioButton      modeCannyRadioButton;
118     //Gtk::HSeparator     modeCannySeparator;
119     //Gtk::Label          modeCannyLoSpinnerLabel;
120     //Gtk::SpinButton     modeCannyLoSpinner;
121     Gtk::Label            modeCannyHiSpinnerLabel;
122     Gtk::SpinButton       modeCannyHiSpinner;
123     //quantization
124     Gtk::Frame            modeQuantFrame;
125     Gtk::HBox             modeQuantBox;
126     Gtk::VBox             modeQuantVBox;
127     Gtk::RadioButton      modeQuantRadioButton;
128     Gtk::Label            modeQuantNrColorLabel;
129     Gtk::SpinButton       modeQuantNrColorSpinner;
130     //params
131     Gtk::CheckButton      modeInvertButton;
132     Gtk::HBox             modeInvertBox;
134     //# Multiple path scanning mode
135     Gtk::Frame            modeMultiScanFrame;
136     Gtk::VBox             modeMultiScanVBox;
137     //brightness
138     Gtk::HBox             modeMultiScanHBox1;
139     Gtk::RadioButton      modeMultiScanBrightnessRadioButton;
140     Gtk::SpinButton       modeMultiScanNrColorSpinner;
141     //colors
142     Gtk::HBox             modeMultiScanHBox2;
143     Gtk::RadioButton      modeMultiScanColorRadioButton;
144     //grays
145     Gtk::HBox             modeMultiScanHBox3;
146     Gtk::RadioButton      modeMultiScanMonoRadioButton;
147     Gtk::Label            modeMultiScanNrColorLabel;
148     //params
149     Gtk::HBox             modeMultiScanHBox4;
150     Gtk::CheckButton      modeMultiScanStackButton;
151     Gtk::CheckButton      modeMultiScanSmoothButton;
152     Gtk::CheckButton      modeMultiScanBackgroundButton;
154     //## Options
156     Gtk::VBox             optionsPageBox;
158     // potrace parameters
160     Gtk::Frame            optionsFrame;
161     Gtk::VBox             optionsVBox;
162     Gtk::HBox             optionsSpecklesBox;
163     Gtk::CheckButton      optionsSpecklesButton;
164     Gtk::Label            optionsSpecklesSizeLabel;
165     Gtk::SpinButton       optionsSpecklesSizeSpinner;
166     Gtk::HBox             optionsCornersBox;
167     Gtk::CheckButton      optionsCornersButton;
168     Gtk::Label            optionsCornersThresholdLabel;
169     Gtk::SpinButton       optionsCornersThresholdSpinner;
170     Gtk::HBox             optionsOptimBox;
171     Gtk::CheckButton      optionsOptimButton;
172     Gtk::Label            optionsOptimToleranceLabel;
173     Gtk::SpinButton       optionsOptimToleranceSpinner;
176     //#### Credits
178     Gtk::VBox             potraceCreditsVBox;
179     Gtk::Label            potraceCreditsLabel;
181     //######## Right pannel
183     Gtk::VBox             rightVBox;
185     //#### SIOX selection
187     Gtk::HBox             sioxBox;
188     Gtk::CheckButton      sioxButton;
190     //#### Preview
192     Gtk::Frame            previewFrame;
193     Gtk::VBox             previewVBox;
194     Gtk::Button           previewButton;
195     Gtk::Image            previewImage;
197 };
201 //#########################################################################
202 //## E V E N T S
203 //#########################################################################
205 /**
206  * This does potrace processing
207  * Only preview if do_i_trace is false
208  */
209 void TraceDialogImpl::potraceProcess(bool do_i_trace)
211     SPDesktop *desktop = SP_ACTIVE_DESKTOP;
212     if (desktop)
213         desktop->setWaitingCursor();
215     //##### Get the tracer and engine
216     Inkscape::Trace::Potrace::PotraceTracingEngine pte;
218     /* inversion */
219     bool invert = modeInvertButton.get_active();
220     pte.setInvert(invert);
222     //##### Get the preprocessor settings
223     /* siox -- performed by Tracer, and before any of the others */
224     if (sioxButton.get_active())
225         tracer.enableSiox(true);
226     else
227         tracer.enableSiox(false);
229     /* one of the following */
230     if (modeBrightnessRadioButton.get_active())
231         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_BRIGHTNESS);
232     else if (modeMultiScanBrightnessRadioButton.get_active())
233         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_BRIGHTNESS_MULTI);
234     else if (modeCannyRadioButton.get_active())
235         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_CANNY);
236     else if (modeQuantRadioButton.get_active())
237         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_QUANT);
238     else if (modeMultiScanColorRadioButton.get_active())
239         {
240         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_QUANT_COLOR);
241         pte.setInvert(false);
242         }
243     else if (modeMultiScanMonoRadioButton.get_active())
244         {
245         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_QUANT_MONO);
246         pte.setInvert(false);
247         }
249     /* params */
250     int paramsSpecklesSize =
251       optionsSpecklesButton.get_active() ?
252       optionsSpecklesSizeSpinner.get_value_as_int() :
253       0;
254     pte.setParamsTurdSize(paramsSpecklesSize);
255     double paramsCornersThreshold =
256       optionsCornersButton.get_active() ?
257       optionsCornersThresholdSpinner.get_value() :
258       0.;
259     pte.setParamsAlphaMax(paramsCornersThreshold);
260     bool paramsOptim = optionsOptimButton.get_active();
261     pte.setParamsOptiCurve(paramsOptim);
262     double paramsOptimTolerance = optionsOptimToleranceSpinner.get_value();
263     pte.setParamsOptTolerance(paramsOptimTolerance);
265     //##### Get the single-scan settings
266     /* brightness */
267     double brightnessThreshold = modeBrightnessSpinner.get_value();
268     pte.setBrightnessThreshold(brightnessThreshold);
269     /* canny */
270     double cannyHighThreshold = modeCannyHiSpinner.get_value();
271     pte.setCannyHighThreshold(cannyHighThreshold);
272     /* quantization */
273     int quantNrColors = modeQuantNrColorSpinner.get_value_as_int();
274     pte.setQuantizationNrColors(quantNrColors);
276     //##### Get multiple-scan settings
277     int multiScanNrColors = modeMultiScanNrColorSpinner.get_value_as_int();
278     pte.setMultiScanNrColors(multiScanNrColors);
279     bool do_i_stack = modeMultiScanStackButton.get_active();
280     pte.setMultiScanStack(do_i_stack);
281     bool do_i_smooth = modeMultiScanSmoothButton.get_active();
282     pte.setMultiScanSmooth(do_i_smooth);
283     bool do_i_remove_background = modeMultiScanBackgroundButton.get_active();
284     pte.setMultiScanRemoveBackground(do_i_remove_background);
286     //##### Get intermediate bitmap image
287     Glib::RefPtr<Gdk::Pixbuf> pixbuf = tracer.getSelectedImage();
288     if (pixbuf)
289          {
290          Glib::RefPtr<Gdk::Pixbuf> preview = pte.preview(pixbuf);
291          if (preview)
292              {
293              int width  = preview->get_width();
294              int height = preview->get_height();
295              double scaleFX = 200.0 / (double)width;
296              double scaleFY = 200.0 / (double)height;
297              double scaleFactor = scaleFX > scaleFY ? scaleFY : scaleFX;
298              int newWidth  = (int) (((double)width)  * scaleFactor);
299              int newHeight = (int) (((double)height) * scaleFactor);
300              Glib::RefPtr<Gdk::Pixbuf> scaledPreview =
301                     preview->scale_simple(newWidth, newHeight,
302                        Gdk::INTERP_NEAREST);
303              //g_object_unref(preview);
304              previewImage.set(scaledPreview);
305              }
306          }
308     //##### Convert
309     if (do_i_trace)
310         {
311         if (mainCancelButton)
312             mainCancelButton->set_sensitive(true);
313         if (mainOkButton)
314             mainOkButton->set_sensitive(false);
315         tracer.trace(&pte);
316         if (mainCancelButton)
317             mainCancelButton->set_sensitive(false);
318         if (mainOkButton)
319             mainOkButton->set_sensitive(true);
320         }
322     if (desktop)
323         desktop->clearWaitingCursor();
327 /**
328  * Abort processing
329  */
330 void TraceDialogImpl::abort()
332     SPDesktop *desktop = SP_ACTIVE_DESKTOP;
333     if (desktop)
334         desktop->setWaitingCursor();
336     if (mainCancelButton)
337         mainCancelButton->set_sensitive(false);
338     if (mainOkButton)
339         mainOkButton->set_sensitive(true);
341     //### Make the abort() call to the tracer
342     tracer.abort();
347 //#########################################################################
348 //## E V E N T S
349 //#########################################################################
351 /**
352  * Callback from the Preview button.  Can be called from elsewhere.
353  */
354 void TraceDialogImpl::previewCallback()
356     potraceProcess(false);
359 /**
360  * Default response from the dialog.  Let's intercept it
361  */
362 void TraceDialogImpl::responseCallback(int response_id)
364     if (response_id == GTK_RESPONSE_OK)
365         {
366             // for now, we assume potrace, as it's the only one we have
367             potraceProcess(true);
368         }
369     else if (response_id == GTK_RESPONSE_CANCEL)
370         {
371         abort();
372         }
373     else
374         {
375         hide();
376         return;
377         }
383 //#########################################################################
384 //## C O N S T R U C T O R    /    D E S T R U C T O R
385 //#########################################################################
386 /**
387  * Constructor
388  */
389 TraceDialogImpl::TraceDialogImpl() :
390     TraceDialog()
393     Gtk::Box *contents = _getContents();
395 #define MARGIN 2
396     //#### begin left panel
398     //### begin notebook
400     //## begin mode page
402     //# begin single scan
404     // brightness
406     modeBrightnessRadioButton.set_label(_("Brightness cutoff"));
407     modeGroup = modeBrightnessRadioButton.get_group();
408     modeBrightnessBox.pack_start(modeBrightnessRadioButton, false, false, MARGIN);
409     tips.set_tip(modeBrightnessRadioButton,
410                  _("Trace by a given brightness level"));
412     modeBrightnessSpinner.set_digits(3);
413     modeBrightnessSpinner.set_increments(0.01, 0);
414     modeBrightnessSpinner.set_range(0.0, 1.0);
415     modeBrightnessSpinner.set_value(0.45);
416     modeBrightnessBox.pack_end(modeBrightnessSpinner, false, false, MARGIN);
417     tips.set_tip(modeBrightnessSpinner,
418                  _("Brightness cutoff for black/white"));
420     modeBrightnessSpinnerLabel.set_label(_("Threshold:"));
421     modeBrightnessBox.pack_end(modeBrightnessSpinnerLabel, false, false, MARGIN);
423     modeBrightnessVBox.pack_start(modeBrightnessBox, false, false, MARGIN);
425     modeBrightnessFrame.set_label(_("Single scan: creates a path"));
427     // canny edge detection
428     // TRANSLATORS: "Canny" is the name of the inventor of this edge detection method
430     modeCannyRadioButton.set_label(_("Edge detection"));
431     modeCannyRadioButton.set_group(modeGroup);
432     modeCannyBox.pack_start(modeCannyRadioButton, false, false, MARGIN);
433     tips.set_tip(modeCannyRadioButton,
434                  _("Trace with optimal edge detection by J. Canny's algorithm"));
435     /*
436     modeCannyBox.pack_start(modeCannySeparator);
437     modeCannyLoSpinnerLabel.set_label(_("Low"));
438     modeCannyBox.pack_start(modeCannyLoSpinnerLabel);
439     modeCannyLoSpinner.set_digits(5);
440     modeCannyLoSpinner.set_increments(0.01, 0);
441     modeCannyLoSpinner.set_range(0.0, 1.0);
442     modeCannyLoSpinner.set_value(0.1);
443     modeCannyBox.pack_start(modeCannyLoSpinner);
444     */
445     modeCannyHiSpinner.set_digits(3);
446     modeCannyHiSpinner.set_increments(0.01, 0);
447     modeCannyHiSpinner.set_range(0.0, 1.0);
448     modeCannyHiSpinner.set_value(0.65);
449     modeCannyBox.pack_end(modeCannyHiSpinner, false, false, MARGIN);
450     tips.set_tip(modeCannyHiSpinner,
451                  _("Brightness cutoff for adjacent pixels (determines edge thickness)"));
453     modeCannyHiSpinnerLabel.set_label(_("Threshold:"));
454     modeCannyBox.pack_end(modeCannyHiSpinnerLabel, false, false, MARGIN);
456     modeBrightnessVBox.pack_start(modeCannyBox, false, false, MARGIN);
458     // quantization
459     // TRANSLATORS: Color Quantization: the process of reducing the number
460     // of colors in an image by selecting an optimized set of representative
461     // colors and then re-applying this reduced set to the original image.
463     modeQuantRadioButton.set_label(_("Color quantization"));
464     modeQuantRadioButton.set_group(modeGroup);
465     modeQuantBox.pack_start(modeQuantRadioButton, false, false, MARGIN);
466     tips.set_tip(modeQuantRadioButton,
467                  _("Trace along the boundaries of reduced colors"));
469     modeQuantNrColorSpinner.set_digits(0);
470     modeQuantNrColorSpinner.set_increments(1.0, 0);
471     modeQuantNrColorSpinner.set_range(2.0, 64.0);
472     modeQuantNrColorSpinner.set_value(8.0);
473     modeQuantBox.pack_end(modeQuantNrColorSpinner, false, false, MARGIN);
474     tips.set_tip(modeQuantNrColorSpinner,
475                  _("The number of reduced colors"));
477     modeQuantNrColorLabel.set_label(_("Colors:"));
478     modeQuantBox.pack_end(modeQuantNrColorLabel, false, false, MARGIN);
480     modeBrightnessVBox.pack_start(modeQuantBox, false, false, MARGIN);
482     // swap black and white
483     modeInvertButton.set_label(_("Invert image"));
484     modeInvertButton.set_active(false);
485     modeInvertBox.pack_start(modeInvertButton, false, false, MARGIN);
486     modeBrightnessVBox.pack_start(modeInvertBox, false, false, MARGIN);
487     tips.set_tip(modeInvertButton,
488                  _("Invert black and white regions"));
490     modeBrightnessFrame.add(modeBrightnessVBox);
491     modePageBox.pack_start(modeBrightnessFrame, false, false, 0);
493     //# end single scan
495     //# begin multiple scan
497     modeMultiScanBrightnessRadioButton.set_label(_("Brightness steps"));
498     modeMultiScanBrightnessRadioButton.set_group(modeGroup);
499     modeMultiScanHBox1.pack_start(modeMultiScanBrightnessRadioButton, false, false, MARGIN);
500     tips.set_tip(modeMultiScanBrightnessRadioButton,
501                  _("Trace the given number of brightness levels"));
503     modeMultiScanNrColorSpinner.set_digits(0);
504     modeMultiScanNrColorSpinner.set_increments(1.0, 0);
505     modeMultiScanNrColorSpinner.set_range(2.0, 256.0);
506     modeMultiScanNrColorSpinner.set_value(8.0);
507     modeMultiScanHBox1.pack_end(modeMultiScanNrColorSpinner, false, false, MARGIN);
508     modeMultiScanNrColorLabel.set_label(_("Scans:"));
509     modeMultiScanHBox1.pack_end(modeMultiScanNrColorLabel, false, false, MARGIN);
510     tips.set_tip(modeMultiScanNrColorSpinner,
511                  _("The desired number of scans"));
513     modeMultiScanVBox.pack_start(modeMultiScanHBox1, false, false, MARGIN);
515     modeMultiScanColorRadioButton.set_label(_("Colors"));
516     modeMultiScanColorRadioButton.set_group(modeGroup);
517     modeMultiScanHBox2.pack_start(modeMultiScanColorRadioButton, false, false, MARGIN);
518     tips.set_tip(modeMultiScanColorRadioButton,
519                  _("Trace the given number of reduced colors"));
521     modeMultiScanVBox.pack_start(modeMultiScanHBox2, false, false, MARGIN);
523     modeMultiScanMonoRadioButton.set_label(_("Grays"));
524     modeMultiScanMonoRadioButton.set_group(modeGroup);
525     modeMultiScanHBox3.pack_start(modeMultiScanMonoRadioButton, false, false, MARGIN);
526     tips.set_tip(modeMultiScanMonoRadioButton,
527                  _("Same as Colors, but the result is converted to grayscale"));
529     modeMultiScanVBox.pack_start(modeMultiScanHBox3, false, false, MARGIN);
531     // TRANSLATORS: "Smooth" is a verb here
532     modeMultiScanSmoothButton.set_label(_("Smooth"));
533     modeMultiScanSmoothButton.set_active(true);
534     modeMultiScanHBox4.pack_start(modeMultiScanSmoothButton, false, false, MARGIN);
535     tips.set_tip(modeMultiScanSmoothButton,
536                  _("Apply Gaussian blur to the bitmap before tracing"));
538     // TRANSLATORS: "Stack" is a verb here
539     modeMultiScanStackButton.set_label(_("Stack scans"));
540     modeMultiScanStackButton.set_active(true);
541     modeMultiScanHBox4.pack_start(modeMultiScanStackButton, false, false, MARGIN);
542     tips.set_tip(modeMultiScanStackButton, _("Stack scans on top of one another (no gaps) instead of tiling (usually with gaps)"));
545     modeMultiScanBackgroundButton.set_label(_("Remove background"));
546     modeMultiScanBackgroundButton.set_active(false);
547     modeMultiScanHBox4.pack_start(modeMultiScanBackgroundButton, false, false, MARGIN);
548     // TRANSLATORS: "Layer" refers to one of the stacked paths in the multiscan
549     tips.set_tip(modeMultiScanBackgroundButton,
550                  _("Remove bottom (background) layer when done"));
552     modeMultiScanVBox.pack_start(modeMultiScanHBox4, false, false, MARGIN);
554     modeMultiScanFrame.set_label(_("Multiple scans: creates a group of paths"));
555     //modeQuantFrame.set_shadow_type(Gtk::SHADOW_NONE);
556     modeMultiScanFrame.add(modeMultiScanVBox);
557     modePageBox.pack_start(modeMultiScanFrame, false, false, 0);
559     //# end multiple scan
561     //## end mode page
563     notebook.append_page(modePageBox, _("Mode"));
565     //## begin option page
567     //# potrace parameters
569     optionsSpecklesButton.set_label(_("Suppress speckles"));
570     tips.set_tip(optionsSpecklesButton,
571                  _("Ignore small spots (speckles) in the bitmap"));
572     optionsSpecklesButton.set_active(true);
573     optionsSpecklesBox.pack_start(optionsSpecklesButton, false, false, MARGIN);
574     optionsSpecklesSizeSpinner.set_digits(0);
575     optionsSpecklesSizeSpinner.set_increments(1, 0);
576     optionsSpecklesSizeSpinner.set_range(0, 1000);
577     optionsSpecklesSizeSpinner.set_value(2);
578     tips.set_tip(optionsSpecklesSizeSpinner,
579                  _("Speckles of up to this many pixels will be suppressed"));
580     optionsSpecklesBox.pack_end(optionsSpecklesSizeSpinner, false, false, MARGIN);
581     optionsSpecklesSizeLabel.set_label(_("Size:"));
582     optionsSpecklesBox.pack_end(optionsSpecklesSizeLabel, false, false, MARGIN);
584     optionsCornersButton.set_label(_("Smooth corners"));
585     tips.set_tip(optionsCornersButton,
586                  _("Smooth out sharp corners of the trace"));
587     optionsCornersButton.set_active(true);
588     optionsCornersBox.pack_start(optionsCornersButton, false, false, MARGIN);
589     optionsCornersThresholdSpinner.set_digits(2);
590     optionsCornersThresholdSpinner.set_increments(0.01, 0);
591     optionsCornersThresholdSpinner.set_range(0.0, 1.34);
592     optionsCornersThresholdSpinner.set_value(1.0);
593     optionsCornersBox.pack_end(optionsCornersThresholdSpinner, false, false, MARGIN);
594     tips.set_tip(optionsCornersThresholdSpinner,
595                  _("Increase this to smooth corners more"));
596     optionsCornersThresholdLabel.set_label(_("Threshold:"));
597     optionsCornersBox.pack_end(optionsCornersThresholdLabel, false, false, MARGIN);
599     optionsOptimButton.set_label(_("Optimize paths"));
600     optionsOptimButton.set_active(true);
601     tips.set_tip(optionsOptimButton,
602                  _("Try to optimize paths by joining adjacent Bezier curve segments"));
603     optionsOptimBox.pack_start(optionsOptimButton, false, false, MARGIN);
604     optionsOptimToleranceSpinner.set_digits(2);
605     optionsOptimToleranceSpinner.set_increments(0.05, 0);
606     optionsOptimToleranceSpinner.set_range(0.0, 5.0);
607     optionsOptimToleranceSpinner.set_value(0.2);
608     optionsOptimBox.pack_end(optionsOptimToleranceSpinner, false, false, MARGIN);
609     tips.set_tip(optionsOptimToleranceSpinner,
610                  _("Increase this to reduce the number of nodes in the trace by more aggressive optimization"));
611     optionsOptimToleranceLabel.set_label(_("Tolerance:"));
612     optionsOptimBox.pack_end(optionsOptimToleranceLabel, false, false, MARGIN);
614     optionsVBox.pack_start(optionsSpecklesBox, false, false, MARGIN);
615     optionsVBox.pack_start(optionsCornersBox, false, false, MARGIN);
616     optionsVBox.pack_start(optionsOptimBox, false, false, MARGIN);
617     optionsFrame.set_label(_("Options"));
618     optionsFrame.add(optionsVBox);
619     optionsPageBox.pack_start(optionsFrame, false, false, 0);
621     //## end option page
623     notebook.append_page(optionsPageBox, _("Options"));
625     //### credits
627     potraceCreditsLabel.set_text(_("Inkscape bitmap tracing\nis based on Potrace,\ncreated by Peter Selinger\n\nhttp://potrace.sourceforge.net"));
628     potraceCreditsVBox.pack_start(potraceCreditsLabel, false, false, MARGIN);
630     notebook.append_page(potraceCreditsVBox, _("Credits"));
632     //### end notebook
634     leftVBox.pack_start(notebook, true, true, MARGIN);
636     //#### end left panel
638     mainHBox.pack_start(leftVBox);
640     //#### begin right panel
642     //## SIOX
644     sioxButton.set_label(_("SIOX foreground selection"));
645     sioxBox.pack_start(sioxButton, false, false, MARGIN);
646     tips.set_tip(sioxButton,
647                  _("Cover the area you want to select as the foreground"));
648     rightVBox.pack_start(sioxBox, false, false, 0);
650     //## preview
652     previewButton.set_label(_("Update"));
653     previewButton.signal_clicked().connect(
654          sigc::mem_fun(*this, &TraceDialogImpl::previewCallback) );
655     previewVBox.pack_end(previewButton, false, false, 0);
656     // I guess it's correct to call the "intermediate bitmap" a preview of the trace
657     tips.set_tip(previewButton,
658                  _("Preview the intermediate bitmap with the current settings, without actual tracing"));
659     previewImage.set_size_request(200,200);
660     //previewImage.set_alignment (Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
661     previewVBox.pack_start(previewImage, true, true, 0);
662     previewFrame.set_label(_("Preview"));
663     //previewFrame.set_shadow_type(Gtk::SHADOW_NONE);
664     previewFrame.add(previewVBox);
666     rightVBox.pack_start(previewFrame, true, true, MARGIN);
668     //#### end right panel
670     mainHBox.pack_start(rightVBox);
672     //#### Global stuff
674     contents->pack_start(mainHBox);
676     //## The OK button
677     mainCancelButton = addResponseButton(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL);
678     if (mainCancelButton) {
679         tips.set_tip((*mainCancelButton), _("Abort a trace in progress"));
680         mainCancelButton->set_sensitive(false);
681     }
682     mainOkButton = addResponseButton(Gtk::Stock::OK, GTK_RESPONSE_OK);
683     tips.set_tip((*mainOkButton), _("Execute the trace"));
685     show_all_children();
687     //## Connect the signal
688     signalResponse().connect(
689         sigc::mem_fun(*this, &TraceDialogImpl::responseCallback));
692 /**
693  * Factory method.  Use this to create a new TraceDialog
694  */
695 TraceDialog &TraceDialog::getInstance()
697     TraceDialog *dialog = new TraceDialogImpl();
698     return *dialog;
702 /**
703  * Constructor
704  */
705 TraceDialogImpl::~TraceDialogImpl()
711 } //namespace Dialog
712 } //namespace UI
713 } //namespace Inkscape
715 //#########################################################################
716 //## E N D    O F    F I L E
717 //#########################################################################