Code

remove many unnecessary to_2geom and from_2geom calls
[inkscape.git] / src / ui / dialog / tracedialog.cpp
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 previewCallback();
85     //############ General items
87     Gtk::HBox             mainHBox;
88     Gtk::Tooltips         tips;
90     Gtk::Button           *mainOkButton;
91     Gtk::Button           *mainCancelButton;
93     //######## Left pannel
95     Gtk::VBox             leftVBox;
97     //#### Notebook
99     Gtk::Notebook         notebook;
101     //## Modes
103     Gtk::VBox             modePageBox;
104     Gtk::RadioButtonGroup modeGroup;
106     //# Single scan mode
107     //brightness
108     Gtk::Frame            modeBrightnessFrame;
109     Gtk::VBox             modeBrightnessVBox;
110     Gtk::HBox             modeBrightnessBox;
111     Gtk::RadioButton      modeBrightnessRadioButton;
112     Gtk::Label            modeBrightnessSpinnerLabel;
113     Gtk::SpinButton       modeBrightnessSpinner;
114     //edge detection
115     Gtk::Frame            modeCannyFrame;
116     Gtk::HBox             modeCannyBox;
117     Gtk::VBox             modeCannyVBox;
118     Gtk::RadioButton      modeCannyRadioButton;
119     //Gtk::HSeparator     modeCannySeparator;
120     //Gtk::Label          modeCannyLoSpinnerLabel;
121     //Gtk::SpinButton     modeCannyLoSpinner;
122     Gtk::Label            modeCannyHiSpinnerLabel;
123     Gtk::SpinButton       modeCannyHiSpinner;
124     //quantization
125     Gtk::Frame            modeQuantFrame;
126     Gtk::HBox             modeQuantBox;
127     Gtk::VBox             modeQuantVBox;
128     Gtk::RadioButton      modeQuantRadioButton;
129     Gtk::Label            modeQuantNrColorLabel;
130     Gtk::SpinButton       modeQuantNrColorSpinner;
131     //params
132     Gtk::CheckButton      modeInvertButton;
133     Gtk::HBox             modeInvertBox;
135     //# Multiple path scanning mode
136     Gtk::Frame            modeMultiScanFrame;
137     Gtk::VBox             modeMultiScanVBox;
138     //brightness
139     Gtk::HBox             modeMultiScanHBox1;
140     Gtk::RadioButton      modeMultiScanBrightnessRadioButton;
141     Gtk::SpinButton       modeMultiScanNrColorSpinner;
142     //colors
143     Gtk::HBox             modeMultiScanHBox2;
144     Gtk::RadioButton      modeMultiScanColorRadioButton;
145     //grays
146     Gtk::HBox             modeMultiScanHBox3;
147     Gtk::RadioButton      modeMultiScanMonoRadioButton;
148     Gtk::Label            modeMultiScanNrColorLabel;
149     //params
150     Gtk::HBox             modeMultiScanHBox4;
151     Gtk::CheckButton      modeMultiScanStackButton;
152     Gtk::CheckButton      modeMultiScanSmoothButton;
153     Gtk::CheckButton      modeMultiScanBackgroundButton;
155     //## Options
157     Gtk::VBox             optionsPageBox;
159     // potrace parameters
161     Gtk::Frame            optionsFrame;
162     Gtk::VBox             optionsVBox;
163     Gtk::HBox             optionsSpecklesBox;
164     Gtk::CheckButton      optionsSpecklesButton;
165     Gtk::Label            optionsSpecklesSizeLabel;
166     Gtk::SpinButton       optionsSpecklesSizeSpinner;
167     Gtk::HBox             optionsCornersBox;
168     Gtk::CheckButton      optionsCornersButton;
169     Gtk::Label            optionsCornersThresholdLabel;
170     Gtk::SpinButton       optionsCornersThresholdSpinner;
171     Gtk::HBox             optionsOptimBox;
172     Gtk::CheckButton      optionsOptimButton;
173     Gtk::Label            optionsOptimToleranceLabel;
174     Gtk::SpinButton       optionsOptimToleranceSpinner;
177     //#### Credits
179     Gtk::Frame            potraceCreditsFrame;
180     Gtk::VBox             potraceCreditsVBox;
181     Gtk::Label            potraceCreditsLabel;
183     //######## Right pannel
185     Gtk::VBox             rightVBox;
187     //#### SIOX selection
189     Gtk::HBox             sioxBox;
190     Gtk::CheckButton      sioxButton;
192     //#### Preview
194     Gtk::Frame            previewFrame;
195     Gtk::VBox             previewVBox;
196     Gtk::Button           previewButton;
197     Gtk::Image            previewImage;
199 };
203 //#########################################################################
204 //## E V E N T S
205 //#########################################################################
207 /**
208  * This does potrace processing
209  * Only preview if do_i_trace is false
210  */
211 void TraceDialogImpl::potraceProcess(bool do_i_trace)
213     //##### Get the tracer and engine
214     Inkscape::Trace::Potrace::PotraceTracingEngine pte;
216     /* inversion */
217     bool invert = modeInvertButton.get_active();
218     pte.setInvert(invert);
220     //##### Get the preprocessor settings
221     /* siox -- performed by Tracer, and before any of the others */
222     if (sioxButton.get_active())
223         tracer.enableSiox(true);
224     else
225         tracer.enableSiox(false);
227     /* one of the following */
228     if (modeBrightnessRadioButton.get_active())
229         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_BRIGHTNESS);
230     else if (modeMultiScanBrightnessRadioButton.get_active())
231         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_BRIGHTNESS_MULTI);
232     else if (modeCannyRadioButton.get_active())
233         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_CANNY);
234     else if (modeQuantRadioButton.get_active())
235         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_QUANT);
236     else if (modeMultiScanColorRadioButton.get_active())
237         {
238         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_QUANT_COLOR);
239         pte.setInvert(false);
240         }
241     else if (modeMultiScanMonoRadioButton.get_active())
242         {
243         pte.setTraceType(Inkscape::Trace::Potrace::TRACE_QUANT_MONO);
244         pte.setInvert(false);
245         }
247     /* params */
248     int paramsSpecklesSize =
249       optionsSpecklesButton.get_active() ?
250       optionsSpecklesSizeSpinner.get_value_as_int() :
251       0;
252     pte.setParamsTurdSize(paramsSpecklesSize);
253     double paramsCornersThreshold =
254       optionsCornersButton.get_active() ?
255       optionsCornersThresholdSpinner.get_value() :
256       0.;
257     pte.setParamsAlphaMax(paramsCornersThreshold);
258     bool paramsOptim = optionsOptimButton.get_active();
259     pte.setParamsOptiCurve(paramsOptim);
260     double paramsOptimTolerance = optionsOptimToleranceSpinner.get_value();
261     pte.setParamsOptTolerance(paramsOptimTolerance);
263     //##### Get the single-scan settings
264     /* brightness */
265     double brightnessThreshold = modeBrightnessSpinner.get_value();
266     pte.setBrightnessThreshold(brightnessThreshold);
267     /* canny */
268     double cannyHighThreshold = modeCannyHiSpinner.get_value();
269     pte.setCannyHighThreshold(cannyHighThreshold);
270     /* quantization */
271     int quantNrColors = modeQuantNrColorSpinner.get_value_as_int();
272     pte.setQuantizationNrColors(quantNrColors);
274     //##### Get multiple-scan settings
275     int multiScanNrColors = modeMultiScanNrColorSpinner.get_value_as_int();
276     pte.setMultiScanNrColors(multiScanNrColors);
277     bool do_i_stack = modeMultiScanStackButton.get_active();
278     pte.setMultiScanStack(do_i_stack);
279     bool do_i_smooth = modeMultiScanSmoothButton.get_active();
280     pte.setMultiScanSmooth(do_i_smooth);
281     bool do_i_remove_background = modeMultiScanBackgroundButton.get_active();
282     pte.setMultiScanRemoveBackground(do_i_remove_background);
284     //##### Get intermediate bitmap image
285     Glib::RefPtr<Gdk::Pixbuf> pixbuf = tracer.getSelectedImage();
286     if (pixbuf)
287          {
288          Glib::RefPtr<Gdk::Pixbuf> preview = pte.preview(pixbuf);
289          if (preview)
290              {
291              int width  = preview->get_width();
292              int height = preview->get_height();
293              double scaleFX = 200.0 / (double)width;
294              double scaleFY = 200.0 / (double)height;
295              double scaleFactor = scaleFX > scaleFY ? scaleFY : scaleFX;
296              int newWidth  = (int) (((double)width)  * scaleFactor);
297              int newHeight = (int) (((double)height) * scaleFactor);
298              Glib::RefPtr<Gdk::Pixbuf> scaledPreview =
299                     preview->scale_simple(newWidth, newHeight,
300                        Gdk::INTERP_NEAREST);
301              //g_object_unref(preview);
302              previewImage.set(scaledPreview);
303              }
304          }
306     //##### Convert
307     if (do_i_trace)
308         {
309         if (mainCancelButton)
310             mainCancelButton->set_sensitive(true);
311         if (mainOkButton)
312             mainOkButton->set_sensitive(false);
313         tracer.trace(&pte);
314         if (mainCancelButton)
315             mainCancelButton->set_sensitive(false);
316         if (mainOkButton)
317             mainOkButton->set_sensitive(true);
318         }
323 /**
324  * Abort processing
325  */
326 void TraceDialogImpl::abort()
328     //### Do some GUI thing
330     //### Make the abort() call to the tracer
331     tracer.abort();
337 //#########################################################################
338 //## E V E N T S
339 //#########################################################################
341 /**
342  * Callback from the Preview button.  Can be called from elsewhere.
343  */
344 void TraceDialogImpl::previewCallback()
346     potraceProcess(false);
349 /**
350  * Default response from the dialog.  Let's intercept it
351  */
352 void TraceDialogImpl::responseCallback(int response_id)
354     if (response_id == GTK_RESPONSE_OK)
355         {
356             // for now, we assume potrace, as it's the only one we have
357             potraceProcess(true);
358         }
359     else if (response_id == GTK_RESPONSE_CANCEL)
360         {
361         abort();
362         }
363     else
364         {
365         hide();
366         return;
367         }
373 //#########################################################################
374 //## C O N S T R U C T O R    /    D E S T R U C T O R
375 //#########################################################################
376 /**
377  * Constructor
378  */
379 TraceDialogImpl::TraceDialogImpl() :
380     TraceDialog()
383     Gtk::Box *contents = _getContents();
385 #define MARGIN 2
386     //#### begin left panel
388     //### begin notebook
390     //## begin mode page
392     //# begin single scan
394     // brightness
396     modeBrightnessRadioButton.set_label(_("Brightness cutoff"));
397     modeGroup = modeBrightnessRadioButton.get_group();
398     modeBrightnessBox.pack_start(modeBrightnessRadioButton, false, false, MARGIN);
399     tips.set_tip(modeBrightnessRadioButton,
400                  _("Trace by a given brightness level"));
402     modeBrightnessSpinner.set_digits(3);
403     modeBrightnessSpinner.set_increments(0.01, 0.1);
404     modeBrightnessSpinner.set_range(0.0, 1.0);
405     modeBrightnessSpinner.set_value(0.45);
406     modeBrightnessBox.pack_end(modeBrightnessSpinner, false, false, MARGIN);
407     tips.set_tip(modeBrightnessSpinner,
408                  _("Brightness cutoff for black/white"));
410     modeBrightnessSpinnerLabel.set_label(_("Threshold:"));
411     modeBrightnessBox.pack_end(modeBrightnessSpinnerLabel, false, false, MARGIN);
413     modeBrightnessVBox.pack_start(modeBrightnessBox, false, false, MARGIN);
415     modeBrightnessFrame.set_label(_("Single scan: creates a path"));
417     // canny edge detection
418     // TRANSLATORS: "Canny" is the name of the inventor of this edge detection method
420     modeCannyRadioButton.set_label(_("Edge detection"));
421     modeCannyRadioButton.set_group(modeGroup);
422     modeCannyBox.pack_start(modeCannyRadioButton, false, false, MARGIN);
423     tips.set_tip(modeCannyRadioButton,
424                  _("Trace with optimal edge detection by J. Canny's algorithm"));
425     /*
426     modeCannyBox.pack_start(modeCannySeparator);
427     modeCannyLoSpinnerLabel.set_label(_("Low"));
428     modeCannyBox.pack_start(modeCannyLoSpinnerLabel);
429     modeCannyLoSpinner.set_digits(5);
430     modeCannyLoSpinner.set_increments(0.01, 0.1);
431     modeCannyLoSpinner.set_range(0.0, 1.0);
432     modeCannyLoSpinner.set_value(0.1);
433     modeCannyBox.pack_start(modeCannyLoSpinner);
434     */
435     modeCannyHiSpinner.set_digits(3);
436     modeCannyHiSpinner.set_increments(0.01, 0.1);
437     modeCannyHiSpinner.set_range(0.0, 1.0);
438     modeCannyHiSpinner.set_value(0.65);
439     modeCannyBox.pack_end(modeCannyHiSpinner, false, false, MARGIN);
440     tips.set_tip(modeCannyHiSpinner,
441                  _("Brightness cutoff for adjacent pixels (determines edge thickness)"));
443     modeCannyHiSpinnerLabel.set_label(_("Threshold:"));
444     modeCannyBox.pack_end(modeCannyHiSpinnerLabel, false, false, MARGIN);
446     modeBrightnessVBox.pack_start(modeCannyBox, false, false, MARGIN);
448     // quantization
449     // TRANSLATORS: Color Quantization: the process of reducing the number
450     // of colors in an image by selecting an optimized set of representative
451     // colors and then re-applying this reduced set to the original image.
453     modeQuantRadioButton.set_label(_("Color quantization"));
454     modeQuantRadioButton.set_group(modeGroup);
455     modeQuantBox.pack_start(modeQuantRadioButton, false, false, MARGIN);
456     tips.set_tip(modeQuantRadioButton,
457                  _("Trace along the boundaries of reduced colors"));
459     modeQuantNrColorSpinner.set_digits(0);
460     modeQuantNrColorSpinner.set_increments(1.0, 4.0);
461     modeQuantNrColorSpinner.set_range(2.0, 64.0);
462     modeQuantNrColorSpinner.set_value(8.0);
463     modeQuantBox.pack_end(modeQuantNrColorSpinner, false, false, MARGIN);
464     tips.set_tip(modeQuantNrColorSpinner,
465                  _("The number of reduced colors"));
467     modeQuantNrColorLabel.set_label(_("Colors:"));
468     modeQuantBox.pack_end(modeQuantNrColorLabel, false, false, MARGIN);
470     modeBrightnessVBox.pack_start(modeQuantBox, false, false, MARGIN);
472     // swap black and white
473     modeInvertButton.set_label(_("Invert image"));
474     modeInvertButton.set_active(false);
475     modeInvertBox.pack_start(modeInvertButton, false, false, MARGIN);
476     modeBrightnessVBox.pack_start(modeInvertBox, false, false, MARGIN);
477     tips.set_tip(modeInvertButton,
478                  _("Invert black and white regions"));
480     modeBrightnessFrame.add(modeBrightnessVBox);
481     modePageBox.pack_start(modeBrightnessFrame, false, false, 0);
483     //# end single scan
485     //# begin multiple scan
487     modeMultiScanBrightnessRadioButton.set_label(_("Brightness steps"));
488     modeMultiScanBrightnessRadioButton.set_group(modeGroup);
489     modeMultiScanHBox1.pack_start(modeMultiScanBrightnessRadioButton, false, false, MARGIN);
490     tips.set_tip(modeMultiScanBrightnessRadioButton,
491                  _("Trace the given number of brightness levels"));
493     modeMultiScanNrColorSpinner.set_digits(0);
494     modeMultiScanNrColorSpinner.set_increments(1.0, 4.0);
495     modeMultiScanNrColorSpinner.set_range(2.0, 256.0);
496     modeMultiScanNrColorSpinner.set_value(8.0);
497     modeMultiScanHBox1.pack_end(modeMultiScanNrColorSpinner, false, false, MARGIN);
498     modeMultiScanNrColorLabel.set_label(_("Scans:"));
499     modeMultiScanHBox1.pack_end(modeMultiScanNrColorLabel, false, false, MARGIN);
500     tips.set_tip(modeMultiScanNrColorSpinner,
501                  _("The desired number of scans"));
503     modeMultiScanVBox.pack_start(modeMultiScanHBox1, false, false, MARGIN);
505     modeMultiScanColorRadioButton.set_label(_("Colors"));
506     modeMultiScanColorRadioButton.set_group(modeGroup);
507     modeMultiScanHBox2.pack_start(modeMultiScanColorRadioButton, false, false, MARGIN);
508     tips.set_tip(modeMultiScanColorRadioButton,
509                  _("Trace the given number of reduced colors"));
511     modeMultiScanVBox.pack_start(modeMultiScanHBox2, false, false, MARGIN);
513     modeMultiScanMonoRadioButton.set_label(_("Grays"));
514     modeMultiScanMonoRadioButton.set_group(modeGroup);
515     modeMultiScanHBox3.pack_start(modeMultiScanMonoRadioButton, false, false, MARGIN);
516     tips.set_tip(modeMultiScanMonoRadioButton,
517                  _("Same as Colors, but the result is converted to grayscale"));
519     modeMultiScanVBox.pack_start(modeMultiScanHBox3, false, false, MARGIN);
521     // TRANSLATORS: "Smooth" is a verb here
522     modeMultiScanSmoothButton.set_label(_("Smooth"));
523     modeMultiScanSmoothButton.set_active(true);
524     modeMultiScanHBox4.pack_start(modeMultiScanSmoothButton, false, false, MARGIN);
525     tips.set_tip(modeMultiScanSmoothButton,
526                  _("Apply Gaussian blur to the bitmap before tracing"));
528     // TRANSLATORS: "Stack" is a verb here
529     modeMultiScanStackButton.set_label(_("Stack scans"));
530     modeMultiScanStackButton.set_active(true);
531     modeMultiScanHBox4.pack_start(modeMultiScanStackButton, false, false, MARGIN);
532     tips.set_tip(modeMultiScanStackButton, _("Stack scans on top of one another (no gaps) instead of tiling (usually with gaps)"));
535     modeMultiScanBackgroundButton.set_label(_("Remove background"));
536     modeMultiScanBackgroundButton.set_active(false);
537     modeMultiScanHBox4.pack_start(modeMultiScanBackgroundButton, false, false, MARGIN);
538     // TRANSLATORS: "Layer" refers to one of the stacked paths in the multiscan
539     tips.set_tip(modeMultiScanBackgroundButton,
540                  _("Remove bottom (background) layer when done"));
542     modeMultiScanVBox.pack_start(modeMultiScanHBox4, false, false, MARGIN);
544     modeMultiScanFrame.set_label(_("Multiple scans: creates a group of paths"));
545     //modeQuantFrame.set_shadow_type(Gtk::SHADOW_NONE);
546     modeMultiScanFrame.add(modeMultiScanVBox);
547     modePageBox.pack_start(modeMultiScanFrame, false, false, 0);
549     //# end multiple scan
551     //## end mode page
553     notebook.append_page(modePageBox, _("Mode"));
555     //## begin option page
557     //# potrace parameters
559     optionsSpecklesButton.set_label(_("Suppress speckles"));
560     tips.set_tip(optionsSpecklesButton,
561                  _("Ignore small spots (speckles) in the bitmap"));
562     optionsSpecklesButton.set_active(true);
563     optionsSpecklesBox.pack_start(optionsSpecklesButton, false, false, MARGIN);
564     optionsSpecklesSizeSpinner.set_digits(0);
565     optionsSpecklesSizeSpinner.set_increments(1, 10);
566     optionsSpecklesSizeSpinner.set_range(0, 1000);
567     optionsSpecklesSizeSpinner.set_value(2);
568     tips.set_tip(optionsSpecklesSizeSpinner,
569                  _("Speckles of up to this many pixels will be suppressed"));
570     optionsSpecklesBox.pack_end(optionsSpecklesSizeSpinner, false, false, MARGIN);
571     optionsSpecklesSizeLabel.set_label(_("Size:"));
572     optionsSpecklesBox.pack_end(optionsSpecklesSizeLabel, false, false, MARGIN);
574     optionsCornersButton.set_label(_("Smooth corners"));
575     tips.set_tip(optionsCornersButton,
576                  _("Smooth out sharp corners of the trace"));
577     optionsCornersButton.set_active(true);
578     optionsCornersBox.pack_start(optionsCornersButton, false, false, MARGIN);
579     optionsCornersThresholdSpinner.set_digits(2);
580     optionsCornersThresholdSpinner.set_increments(0.01, 0.1);
581     optionsCornersThresholdSpinner.set_range(0.0, 1.34);
582     optionsCornersThresholdSpinner.set_value(1.0);
583     optionsCornersBox.pack_end(optionsCornersThresholdSpinner, false, false, MARGIN);
584     tips.set_tip(optionsCornersThresholdSpinner,
585                  _("Increase this to smooth corners more"));
586     optionsCornersThresholdLabel.set_label(_("Threshold:"));
587     optionsCornersBox.pack_end(optionsCornersThresholdLabel, false, false, MARGIN);
589     optionsOptimButton.set_label(_("Optimize paths"));
590     optionsOptimButton.set_active(true);
591     tips.set_tip(optionsOptimButton,
592                  _("Try to optimize paths by joining adjacent Bezier curve segments"));
593     optionsOptimBox.pack_start(optionsOptimButton, false, false, MARGIN);
594     optionsOptimToleranceSpinner.set_digits(2);
595     optionsOptimToleranceSpinner.set_increments(0.05, 0.25);
596     optionsOptimToleranceSpinner.set_range(0.0, 5.0);
597     optionsOptimToleranceSpinner.set_value(0.2);
598     optionsOptimBox.pack_end(optionsOptimToleranceSpinner, false, false, MARGIN);
599     tips.set_tip(optionsOptimToleranceSpinner,
600                  _("Increase this to reduce the number of nodes in the trace by more aggressive optimization"));
601     optionsOptimToleranceLabel.set_label(_("Tolerance:"));
602     optionsOptimBox.pack_end(optionsOptimToleranceLabel, false, false, MARGIN);
604     optionsVBox.pack_start(optionsSpecklesBox, false, false, MARGIN);
605     optionsVBox.pack_start(optionsCornersBox, false, false, MARGIN);
606     optionsVBox.pack_start(optionsOptimBox, false, false, MARGIN);
607     optionsFrame.set_label(_("Options"));
608     optionsFrame.add(optionsVBox);
609     optionsPageBox.pack_start(optionsFrame, false, false, 0);
611     //## end option page
613     notebook.append_page(optionsPageBox, _("Options"));
615     //### end notebook
617     leftVBox.pack_start(notebook, true, true, MARGIN);
619     //### credits
621     potraceCreditsLabel.set_text(_("Thanks to Peter Selinger, http://potrace.sourceforge.net"));
622     potraceCreditsVBox.pack_start(potraceCreditsLabel, false, false, MARGIN);
623     potraceCreditsFrame.set_label(_("Credits"));
624     potraceCreditsFrame.set_shadow_type(Gtk::SHADOW_NONE);
625     potraceCreditsFrame.add(potraceCreditsVBox);
627     leftVBox.pack_start(potraceCreditsFrame, false, false, 0);
629     //#### end left panel
631     mainHBox.pack_start(leftVBox);
633     //#### begin right panel
635     //## SIOX
637     sioxButton.set_label(_("SIOX foreground selection"));
638     sioxBox.pack_start(sioxButton, false, false, MARGIN);
639     tips.set_tip(sioxButton,
640                  _("Cover the area you want to select as the foreground"));
641     rightVBox.pack_start(sioxBox, false, false, 0);
643     //## preview
645     previewButton.set_label(_("Update"));
646     previewButton.signal_clicked().connect(
647          sigc::mem_fun(*this, &TraceDialogImpl::previewCallback) );
648     previewVBox.pack_end(previewButton, false, false, 0);
649     // I guess it's correct to call the "intermediate bitmap" a preview of the trace
650     tips.set_tip(previewButton,
651                  _("Preview the intermediate bitmap with the current settings, without actual tracing"));
652     previewImage.set_size_request(200,200);
653     //previewImage.set_alignment (Gtk::ALIGN_CENTER, Gtk::ALIGN_CENTER);
654     previewVBox.pack_start(previewImage, true, true, 0);
655     previewFrame.set_label(_("Preview"));
656     //previewFrame.set_shadow_type(Gtk::SHADOW_NONE);
657     previewFrame.add(previewVBox);
659     rightVBox.pack_start(previewFrame, true, true, MARGIN);
661     //#### end right panel
663     mainHBox.pack_start(rightVBox);
665     //#### Global stuff
667     contents->pack_start(mainHBox);
669     //## The OK button
670     mainCancelButton = addResponseButton(Gtk::Stock::STOP, GTK_RESPONSE_CANCEL);
671     if (mainCancelButton) {
672         tips.set_tip((*mainCancelButton), _("Abort a trace in progress"));
673         mainCancelButton->set_sensitive(false);
674     }
675     mainOkButton = addResponseButton(Gtk::Stock::OK, GTK_RESPONSE_OK);
676     tips.set_tip((*mainOkButton), _("Execute the trace"));
678     show_all_children();
680     //## Connect the signal
681     signalResponse().connect(
682         sigc::mem_fun(*this, &TraceDialogImpl::responseCallback));
685 /**
686  * Factory method.  Use this to create a new TraceDialog
687  */
688 TraceDialog &TraceDialog::getInstance()
690     TraceDialog *dialog = new TraceDialogImpl();
691     return *dialog;
695 /**
696  * Constructor
697  */
698 TraceDialogImpl::~TraceDialogImpl()
704 } //namespace Dialog
705 } //namespace UI
706 } //namespace Inkscape
708 //#########################################################################
709 //## E N D    O F    F I L E
710 //#########################################################################