
* demo/viewer/config.cc, * demo/viewer/config.hh, * demo/viewer/defs.hh, * demo/viewer/general_options.cc, * demo/viewer/general_options.hh, * demo/viewer/general_options.ui, * demo/viewer/option_widget.cc, * demo/viewer/option_widget.hh, * demo/viewer/preferences_dialog.cc, * demo/viewer/preferences_dialog.hh, * demo/viewer/preferences_dialog.ui, * demo/viewer/toolchain_options.cc, * demo/viewer/toolchain_options.hh, * demo/viewer/toolchain_options.ui: New. --- scribo/ChangeLog | 19 ++++ scribo/demo/viewer/config.cc | 156 ++++++++++++++++++++++++++++++ scribo/demo/viewer/config.hh | 69 +++++++++++++ scribo/demo/viewer/defs.hh | 31 ++++++ scribo/demo/viewer/general_options.cc | 60 ++++++++++++ scribo/demo/viewer/general_options.hh | 40 ++++++++ scribo/demo/viewer/general_options.ui | 100 +++++++++++++++++++ scribo/demo/viewer/option_widget.cc | 30 ++++++ scribo/demo/viewer/option_widget.hh | 30 ++++++ scribo/demo/viewer/preferences_dialog.cc | 113 +++++++++++++++++++++ scribo/demo/viewer/preferences_dialog.hh | 45 +++++++++ scribo/demo/viewer/preferences_dialog.ui | 121 +++++++++++++++++++++++ scribo/demo/viewer/toolchain_options.cc | 75 ++++++++++++++ scribo/demo/viewer/toolchain_options.hh | 37 +++++++ scribo/demo/viewer/toolchain_options.ui | 121 +++++++++++++++++++++++ 15 files changed, 1047 insertions(+), 0 deletions(-) create mode 100644 scribo/demo/viewer/config.cc create mode 100644 scribo/demo/viewer/config.hh create mode 100644 scribo/demo/viewer/defs.hh create mode 100644 scribo/demo/viewer/general_options.cc create mode 100644 scribo/demo/viewer/general_options.hh create mode 100644 scribo/demo/viewer/general_options.ui create mode 100644 scribo/demo/viewer/option_widget.cc create mode 100644 scribo/demo/viewer/option_widget.hh create mode 100644 scribo/demo/viewer/preferences_dialog.cc create mode 100644 scribo/demo/viewer/preferences_dialog.hh create mode 100644 scribo/demo/viewer/preferences_dialog.ui create mode 100644 scribo/demo/viewer/toolchain_options.cc create mode 100644 scribo/demo/viewer/toolchain_options.hh create mode 100644 scribo/demo/viewer/toolchain_options.ui diff --git a/scribo/ChangeLog b/scribo/ChangeLog index e730400..7829717 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,24 @@ 2010-12-10 Guillaume Lazzara <z@lrde.epita.fr> + Add configuration widgets in Scribo viewer. + + * demo/viewer/config.cc, + * demo/viewer/config.hh, + * demo/viewer/defs.hh, + * demo/viewer/general_options.cc, + * demo/viewer/general_options.hh, + * demo/viewer/general_options.ui, + * demo/viewer/option_widget.cc, + * demo/viewer/option_widget.hh, + * demo/viewer/preferences_dialog.cc, + * demo/viewer/preferences_dialog.hh, + * demo/viewer/preferences_dialog.ui, + * demo/viewer/toolchain_options.cc, + * demo/viewer/toolchain_options.hh, + * demo/viewer/toolchain_options.ui: New. + +2010-12-10 Guillaume Lazzara <z@lrde.epita.fr> + * src/scribo-cli.in: Add a call to xml2doc. 2010-12-10 Guillaume Lazzara <z@lrde.epita.fr> diff --git a/scribo/demo/viewer/config.cc b/scribo/demo/viewer/config.cc new file mode 100644 index 0000000..bf12e95 --- /dev/null +++ b/scribo/demo/viewer/config.cc @@ -0,0 +1,156 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +#include <QDir> + +#include "config.hh" +#include "defs.hh" + +// Defines enum of binarization algorithms +# include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh> + + +config::config() + : QSettings("Olena-Scribo", "viewer") +{ + +} + +config* config::get_instance() +{ + static config * conf = new config(); + return conf; +} + + +// Preprocessing + +bool config::preprocessing_subsample() +{ + return value("preprocessing/subsample", false).toBool(); +} + +void config::set_preprocessing_subsample(bool b) +{ + setValue("preprocessing/subsample", b); +} + + +bool config::preprocessing_remove_bg() +{ + return value("preprocessing/remove_bg", false).toBool(); +} + +void config::set_preprocessing_remove_bg(bool b) +{ + setValue("preprocessing/remove_bg", b); +} + + +bool config::preprocessing_deskew() +{ + return value("preprocessing/deskew", false).toBool(); +} + +void config::set_preprocessing_deskew(bool b) +{ + setValue("preprocessing/deskew", b); +} + + +bool config::preprocessing_remove_noise() +{ + return value("preprocessing/remove_noise", true).toBool(); +} + +void config::set_preprocessing_remove_noise(bool b) +{ + setValue("preprocessing/remove_noise", b); +} + + +int config::preprocessing_bin_algo() +{ + return value("preprocessing/bin_algo", + scribo::toolchain::internal::SauvolaMs).toInt(); +} + +void config::set_preprocessing_bin_algo(int algo) +{ + setValue("preprocessing/bin_algo", algo); +} + + + +// Segmentation + +int config::segmentation_find_seps() +{ + return value("segmentation/find_seps", defs::LinesAndWhitespaces).toInt(); +} + +void config::set_segmentation_find_seps(int seps) +{ + setValue("segmentation/find_seps", seps); +} + + + +// General options + +bool config::general_save_xml_enabled() +{ + return value("general/save_xml/enabled", true).toBool(); +} + +void config::set_general_save_xml_enabled(bool b) +{ + setValue("general/save_xml/enabled", b); +} + + +bool config::general_save_xml_same_dir() +{ + return value("general/save_xml/same_dir", true).toBool(); +} + +void config::set_general_save_xml_same_dir(bool b) +{ + setValue("general/save_xml/same_dir", b); +} + + +bool config::general_save_xml_custom_dir() +{ + return value("general/save_xml/custom_dir", false).toBool(); +} + +void config::set_general_save_xml_custom_dir(bool b) +{ + setValue("general/save_xml/custom_dir", b); +} + + +QString config::general_save_xml_custom_dir_path() +{ + return value("general/save_xml/custom_dir_path", QDir::tempPath()).toString(); +} + +void config::set_general_save_xml_custom_dir_path(const QString& path) +{ + setValue("general/save_xml/custom_dir_path", path); +} + diff --git a/scribo/demo/viewer/config.hh b/scribo/demo/viewer/config.hh new file mode 100644 index 0000000..07d193c --- /dev/null +++ b/scribo/demo/viewer/config.hh @@ -0,0 +1,69 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +#ifndef SCRIBO_DEMO_VIEWER_CONFIG_HH +# define SCRIBO_DEMO_VIEWER_CONFIG_HH + +# include <QSettings> + +class config : public QSettings +{ +public: + + config(); + + static config* get_instance(); + + // Preprocessing + bool preprocessing_subsample(); + void set_preprocessing_subsample(bool b); + + bool preprocessing_remove_bg(); + void set_preprocessing_remove_bg(bool b); + + bool preprocessing_deskew(); + void set_preprocessing_deskew(bool b); + + bool preprocessing_remove_noise(); + void set_preprocessing_remove_noise(bool b); + + int preprocessing_bin_algo(); + void set_preprocessing_bin_algo(int algo); + + + // Segmentation + int segmentation_find_seps(); + void set_segmentation_find_seps(int seps); + + + // General options + bool general_save_xml_enabled(); + void set_general_save_xml_enabled(bool b); + + bool general_save_xml_same_dir(); + void set_general_save_xml_same_dir(bool b); + + bool general_save_xml_custom_dir(); + void set_general_save_xml_custom_dir(bool b); + + QString general_save_xml_custom_dir_path(); + void set_general_save_xml_custom_dir_path(const QString& path); + + +}; + + +#endif // ! SCRIBO_DEMO_VIEWER_CONFIG_HH diff --git a/scribo/demo/viewer/defs.hh b/scribo/demo/viewer/defs.hh new file mode 100644 index 0000000..ada4441 --- /dev/null +++ b/scribo/demo/viewer/defs.hh @@ -0,0 +1,31 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +#ifndef SCRIBO_DEMO_VIEWER_DEFS_HH +# define SCRIBO_DEMO_VIEWER_DEFS_HH + +namespace defs +{ + enum FindSeparators + { + Lines, + Whitespaces, + LinesAndWhitespaces + }; + +} // end of namespace defs + +#endif // ! SCRIBO_DEMO_VIEWER_DEFS_HH diff --git a/scribo/demo/viewer/general_options.cc b/scribo/demo/viewer/general_options.cc new file mode 100644 index 0000000..50201ff --- /dev/null +++ b/scribo/demo/viewer/general_options.cc @@ -0,0 +1,60 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +#include "general_options.hh" +#include "config.hh" + + +general_options::general_options(QWidget *parent) + : OptionWidget(parent) +{ + setupUi(this); + + load_config(); +} + +general_options::~general_options() +{ +} + + +void general_options::load_config() +{ + config * const conf = config::get_instance(); + + saveXml->setChecked(conf->general_save_xml_enabled()); + sameDir->setChecked(conf->general_save_xml_same_dir()); + customDir->setChecked(conf->general_save_xml_custom_dir()); + customDirValue->setText(conf->general_save_xml_custom_dir_path()); +} + + +void general_options::save_config() +{ + config * const conf = config::get_instance(); + + conf->set_general_save_xml_enabled(saveXml->isChecked()); + conf->set_general_save_xml_same_dir(sameDir->isChecked()); + conf->set_general_save_xml_custom_dir(customDir->isChecked()); + conf->set_general_save_xml_custom_dir_path(customDirValue->text()); +} + +void general_options::on_customDirBrowseBtn_clicked() +{ + QString dir = QFileDialog::getExistingDirectory(0, "Choose a directory"); + if (!dir.isEmpty()) + customDirValue->setText(dir); +} diff --git a/scribo/demo/viewer/general_options.hh b/scribo/demo/viewer/general_options.hh new file mode 100644 index 0000000..e2fcaae --- /dev/null +++ b/scribo/demo/viewer/general_options.hh @@ -0,0 +1,40 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +#ifndef SCRIBO_DEMO_VIEWER_GENERAL_OPTIONS_HH +# define SCRIBO_DEMO_VIEWER_GENERAL_OPTIONS_HH + +# include <QtGui> +# include <general_options.ui.h> +# include "option_widget.hh" + +class general_options : public OptionWidget, private Ui::GeneralOptions +{ + Q_OBJECT; + +public: + general_options(QWidget *parent = 0); + ~general_options(); + + virtual void load_config(); + virtual void save_config(); + +private slots: + void on_customDirBrowseBtn_clicked(); + +}; + +#endif // ! SCRIBO_DEMO_VIEWER_GENERAL_OPTIONS_HH diff --git a/scribo/demo/viewer/general_options.ui b/scribo/demo/viewer/general_options.ui new file mode 100644 index 0000000..5839c27 --- /dev/null +++ b/scribo/demo/viewer/general_options.ui @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>GeneralOptions</class> + <widget class="QWidget" name="GeneralOptions"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QGroupBox" name="saveXml"> + <property name="title"> + <string>Save segmentation results</string> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QRadioButton" name="sameDir"> + <property name="text"> + <string>In the same directory as the input image</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QRadioButton" name="customDir"> + <property name="text"> + <string>In the following directory</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Maximum</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLineEdit" name="customDirValue"/> + </item> + <item> + <widget class="QPushButton" name="customDirBrowseBtn"> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/scribo/demo/viewer/option_widget.cc b/scribo/demo/viewer/option_widget.cc new file mode 100644 index 0000000..4557749 --- /dev/null +++ b/scribo/demo/viewer/option_widget.cc @@ -0,0 +1,30 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +# include "option_widget.hh" + +OptionWidget::OptionWidget(QWidget * parent) + : QWidget(parent) +{ +} + +void OptionWidget::save_config() +{ +} + +void OptionWidget::load_config() +{ +} diff --git a/scribo/demo/viewer/option_widget.hh b/scribo/demo/viewer/option_widget.hh new file mode 100644 index 0000000..6b24e90 --- /dev/null +++ b/scribo/demo/viewer/option_widget.hh @@ -0,0 +1,30 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +#ifndef SCRIBO_DEMO_VIEWER_OPTION_WIDGET_HH +# define SCRIBO_DEMO_VIEWER_OPTION_WIDGET_HH + +#include <QWidget> + +struct OptionWidget : public QWidget +{ + OptionWidget(QWidget * parent); + + virtual void load_config(); + virtual void save_config(); +}; + +#endif // ! SCRIBO_DEMO_VIEWER_OPTION_WIDGET_HH diff --git a/scribo/demo/viewer/preferences_dialog.cc b/scribo/demo/viewer/preferences_dialog.cc new file mode 100644 index 0000000..dfd6061 --- /dev/null +++ b/scribo/demo/viewer/preferences_dialog.cc @@ -0,0 +1,113 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +#include "preferences_dialog.hh" +#include "toolchain_options.hh" +#include "general_options.hh" + + + +preferences_dialog::preferences_dialog(QWidget *parent) + : QDialog(parent) +{ + setupUi(this); + + // We may want to remove this useless object in the ui file. + delete widget; + + setAttribute(Qt::WA_DeleteOnClose); + + load_option_list(); + optionList->setCurrentRow(0); +} + +preferences_dialog::~preferences_dialog() +{ +} + + +void preferences_dialog::load_option_list() +{ + static const char *options[] = { "General", "Toolchain", 0 }; + + int i; + for (i = 0; options[i]; ++i) + optionList->insertItem(i, options[i]); + + widgets_.fill(0, i); +} + +void preferences_dialog::on_optionList_currentRowChanged(int row) +{ + select_option_widget(row); +} + + +void preferences_dialog::select_option_widget(int row) +{ + if (row >= widgets_.size()) + { + qDebug() << "select_option_widget - Hu? Something wrong... Invalid row"; + return; + } + + if (!widgets_[row]) + { + switch (row) + { + case 0: + widgets_[0] = new general_options(this); + break; + + case 1: + widgets_[1] = new toolchain_options(this); + break; + + default: + qDebug() << "select_option_widget - Hu? Something wrong..."; + } + } + + if (horizontalLayout_2->count() == 2) + { + QWidget *current_widget = horizontalLayout_2->itemAt(1)->widget(); + horizontalLayout_2->removeWidget(current_widget); + current_widget->hide(); + } + + horizontalLayout_2->insertWidget(1, widgets_[row]); + widgets_[row]->show(); +} + + +void preferences_dialog::accept() +{ + for (int i = 0; i < widgets_.size(); ++i) + if (widgets_[i]) + { + static_cast<OptionWidget *>(widgets_[i])->save_config(); + delete widgets_[i]; + } + QDialog::accept(); +} + + +void preferences_dialog::reject() +{ + for (int i = 0; i < widgets_.size(); ++i) + delete widgets_[i]; + QDialog::reject(); +} diff --git a/scribo/demo/viewer/preferences_dialog.hh b/scribo/demo/viewer/preferences_dialog.hh new file mode 100644 index 0000000..0368bbe --- /dev/null +++ b/scribo/demo/viewer/preferences_dialog.hh @@ -0,0 +1,45 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +#ifndef SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH +# define SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH + +# include <QtGui> +# include <preferences_dialog.ui.h> + +class preferences_dialog : public QDialog, private Ui::PreferencesDialog +{ + Q_OBJECT; + +public: + preferences_dialog(QWidget *parent = 0); + ~preferences_dialog(); + +private slots: + void on_optionList_currentRowChanged(int row); + virtual void accept(); + virtual void reject(); + +private: // Methods + void load_option_list(); + void select_option_widget(int row); + +private: // Attributes + QVector<QWidget *> widgets_; + +}; + +#endif // ! SCRIBO_DEMO_VIEWER_PREFERENCES_DIALOG_HH diff --git a/scribo/demo/viewer/preferences_dialog.ui b/scribo/demo/viewer/preferences_dialog.ui new file mode 100644 index 0000000..1d40563 --- /dev/null +++ b/scribo/demo/viewer/preferences_dialog.ui @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreferencesDialog</class> + <widget class="QDialog" name="PreferencesDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>668</width> + <height>418</height> + </rect> + </property> + <property name="windowTitle"> + <string>Preferences</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Preferences</span></p></body></html></string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QListWidget" name="optionList"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>200</width> + <height>16777215</height> + </size> + </property> + <property name="baseSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + </widget> + </item> + <item> + <widget class="QWidget" name="widget" native="true"/> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>PreferencesDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>PreferencesDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/scribo/demo/viewer/toolchain_options.cc b/scribo/demo/viewer/toolchain_options.cc new file mode 100644 index 0000000..6024ff3 --- /dev/null +++ b/scribo/demo/viewer/toolchain_options.cc @@ -0,0 +1,75 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +#include "defs.hh" +#include "toolchain_options.hh" +#include "config.hh" + +// Defines enum of binarization algorithms +# include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh> + +using namespace scribo::toolchain::internal; + +toolchain_options::toolchain_options(QWidget *parent) + : OptionWidget(parent) +{ + setupUi(this); + + bin_algoCbox->insertItem(Convert, "Violent convert"); + bin_algoCbox->insertItem(Sauvola, "Local threshold"); + bin_algoCbox->insertItem(SauvolaMs, + "Local threshold multiscale"); + + find_sepsCbox->insertItem(defs::Lines, "Lines"); + find_sepsCbox->insertItem(defs::Whitespaces, "Whitespaces"); + find_sepsCbox->insertItem(defs::LinesAndWhitespaces, "Lines and whitespaces"); + + load_config(); +} + +toolchain_options::~toolchain_options() +{ +} + + +void toolchain_options::load_config() +{ + config * const conf = config::get_instance(); + + // Preprocessing + subsampleCb->setChecked(conf->preprocessing_subsample()); + remove_bgCb->setChecked(conf->preprocessing_remove_bg()); + deskewCb->setChecked(conf->preprocessing_deskew()); + remove_noiseCb->setChecked(conf->preprocessing_remove_noise()); + bin_algoCbox->setCurrentIndex(conf->preprocessing_bin_algo()); + + // Page segmentation + find_sepsCbox->setCurrentIndex(conf->segmentation_find_seps()); +} + + +void toolchain_options::save_config() +{ + config * const conf = config::get_instance(); + + conf->set_preprocessing_subsample(subsampleCb->isChecked()); + conf->set_preprocessing_remove_bg(remove_bgCb->isChecked()); + conf->set_preprocessing_deskew(deskewCb->isChecked()); + conf->set_preprocessing_remove_noise(remove_noiseCb->isChecked()); + conf->set_preprocessing_bin_algo(bin_algoCbox->currentIndex()); + + conf->set_segmentation_find_seps(find_sepsCbox->currentIndex()); +} diff --git a/scribo/demo/viewer/toolchain_options.hh b/scribo/demo/viewer/toolchain_options.hh new file mode 100644 index 0000000..afad3e7 --- /dev/null +++ b/scribo/demo/viewer/toolchain_options.hh @@ -0,0 +1,37 @@ +// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Olena. If not, see <http://www.gnu.org/licenses/>. + +#ifndef SCRIBO_DEMO_VIEWER_TOOLCHAIN_OPTIONS_HH +# define SCRIBO_DEMO_VIEWER_TOOLCHAIN_OPTIONS_HH + +# include <QtGui> +# include <toolchain_options.ui.h> +# include "option_widget.hh" + +class toolchain_options : public OptionWidget, private Ui::ToolchainOptions +{ + Q_OBJECT; + +public: + toolchain_options(QWidget *parent = 0); + ~toolchain_options(); + + void load_config(); + void save_config(); + +}; + +#endif // ! SCRIBO_DEMO_VIEWER_TOOLCHAIN_OPTIONS_HH diff --git a/scribo/demo/viewer/toolchain_options.ui b/scribo/demo/viewer/toolchain_options.ui new file mode 100644 index 0000000..748696d --- /dev/null +++ b/scribo/demo/viewer/toolchain_options.ui @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ToolchainOptions</class> + <widget class="QWidget" name="ToolchainOptions"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>492</width> + <height>264</height> + </rect> + </property> + <property name="windowTitle"> + <string>Configure toolchain</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Preprocessing</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QCheckBox" name="subsampleCb"> + <property name="text"> + <string>Run on subsampled image</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="remove_bgCb"> + <property name="text"> + <string>Remove background (slow)</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="deskewCb"> + <property name="text"> + <string>Deskew</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="remove_noiseCb"> + <property name="text"> + <string>Remove noise</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Binarization method:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="bin_algoCbox"/> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Page segmentation</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Find separators</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="find_sepsCbox"/> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> -- 1.5.6.5