* lazzara/afp/photos/gui/src/launch_dialog.cc,
* lazzara/afp/photos/gui/src/launch_dialog.hh,
* lazzara/afp/photos/gui/src/main_window.cc,
* lazzara/afp/photos/gui/src/main_window.hh,
* lazzara/afp/photos/gui/ui/launch_dialog.ui: Improve options menu
and progress dialog.
---
milena/sandbox/ChangeLog | 11 ++++
.../lazzara/afp/photos/gui/src/launch_dialog.cc | 17 ++++++-
.../lazzara/afp/photos/gui/src/launch_dialog.hh | 4 +-
.../lazzara/afp/photos/gui/src/main_window.cc | 56 ++++++++++++--------
.../lazzara/afp/photos/gui/src/main_window.hh | 8 ++-
.../lazzara/afp/photos/gui/ui/launch_dialog.ui | 33 +++++++++---
6 files changed, 93 insertions(+), 36 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 0d7aefd..989709b 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,14 @@
+2010-03-19 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Improve options menu and progress dialog.
+
+ * lazzara/afp/photos/gui/src/launch_dialog.cc,
+ * lazzara/afp/photos/gui/src/launch_dialog.hh,
+ * lazzara/afp/photos/gui/src/main_window.cc,
+ * lazzara/afp/photos/gui/src/main_window.hh,
+ * lazzara/afp/photos/gui/ui/launch_dialog.ui: Improve options menu
+ and progress dialog.
+
2010-02-16 Guillaume Lazzara <z(a)lrde.epita.fr>
Add a GUI for AFP's use case.
diff --git a/milena/sandbox/lazzara/afp/photos/gui/src/launch_dialog.cc
b/milena/sandbox/lazzara/afp/photos/gui/src/launch_dialog.cc
index b0e0fb8..9cd394a 100644
--- a/milena/sandbox/lazzara/afp/photos/gui/src/launch_dialog.cc
+++ b/milena/sandbox/lazzara/afp/photos/gui/src/launch_dialog.cc
@@ -62,7 +62,7 @@ namespace mln
void
launch_dialog::on_dialogBtnBox_accepted()
{
- emit ok_clicked(pathToPics->text(), checkBox->isChecked());
+ emit ok_clicked(pathToPics->text(), get_options());
}
@@ -72,6 +72,21 @@ namespace mln
dialogBtnBox->button(QDialogButtonBox::Ok)->setEnabled(!str.isEmpty());
}
+
+ QString launch_dialog::get_options() const
+ {
+ if (binarizationMode->currentIndex() == 0)
+ return "0 0";
+ if (binarizationMode->currentIndex() == 1)
+ return "1 0";
+ if (binarizationMode->currentIndex() == 2)
+ return "0 1";
+ if (binarizationMode->currentIndex() == 3)
+ return "1 1";
+
+ return "";
+ }
+
} // end of namespace scribo::demo
} // end of namespace scribo
diff --git a/milena/sandbox/lazzara/afp/photos/gui/src/launch_dialog.hh
b/milena/sandbox/lazzara/afp/photos/gui/src/launch_dialog.hh
index dd4ed31..d3aca98 100644
--- a/milena/sandbox/lazzara/afp/photos/gui/src/launch_dialog.hh
+++ b/milena/sandbox/lazzara/afp/photos/gui/src/launch_dialog.hh
@@ -49,8 +49,10 @@ namespace mln
void on_pathToPics_textChanged(const QString& str);
signals:
- void ok_clicked(const QString& path, bool fgbg);
+ void ok_clicked(const QString& path, const QString& options);
+ private: // members
+ QString get_options() const;
};
diff --git a/milena/sandbox/lazzara/afp/photos/gui/src/main_window.cc
b/milena/sandbox/lazzara/afp/photos/gui/src/main_window.cc
index ea63d46..7a94cb0 100644
--- a/milena/sandbox/lazzara/afp/photos/gui/src/main_window.cc
+++ b/milena/sandbox/lazzara/afp/photos/gui/src/main_window.cc
@@ -63,19 +63,6 @@ namespace mln
graphicsView->setScene(new QGraphicsScene());
- // Setup StatusBar
- QStatusBar *status = new QStatusBar();
- setStatusBar(status);
- status->addWidget(&progressLabel_);
- status->addWidget(&progressBar_);
-
- QPushButton *cancelBtn = new QPushButton(tr("Cancel"));
- connect(cancelBtn, SIGNAL(clicked(bool)),
- this, SLOT(cancel_clicked(bool)));
- status->addWidget(cancelBtn);
- statusBar()->hide();
-
-
// Customize item view delegate for picture with text.
withTextListWidget->setItemDelegate(new custom_delegate());
@@ -88,9 +75,26 @@ namespace mln
connect(removeImage, SIGNAL(triggered(bool)),
this, SLOT(remove_image(bool)));
toolbar_->addAction(removeImage);
+
addToolBar(toolbar_);
+ // Setup StatusBar
+ progressToolBar_ = new QToolBar(tr("ProgressBar"));
+
+ progressToolBar_->addWidget(&progressLabel_);
+ progressToolBar_->addWidget(&progressBar_);
+
+ QPushButton *cancelBtn = new QPushButton(tr("&Cancel"));
+ connect(cancelBtn, SIGNAL(clicked(bool)),
+ this, SLOT(cancel_clicked(bool)));
+ progressToolBar_->addWidget(cancelBtn);
+
+ addToolBar(progressToolBar_);
+ progressToolBar_->hide();
+
+
+
// Hide visualization buttons
textOnlyButton->hide();
fullImageButton->hide();
@@ -121,13 +125,14 @@ namespace mln
main_window::on_actionScan_directory_triggered()
{
launch_dialog *dialog = new launch_dialog(this);
- connect(dialog, SIGNAL(ok_clicked(const QString&, bool)),
- this, SLOT(init_and_start_process(const QString&, bool)));
+ connect(dialog, SIGNAL(ok_clicked(const QString&, const QString&)),
+ this, SLOT(init_and_start_process(const QString&, const QString&)));
dialog->show();
}
void
- main_window::init_and_start_process(const QString& dirname, bool bgfg)
+ main_window::init_and_start_process(const QString& dirname,
+ const QString& options)
{
dir_.setPath(dirname);
@@ -136,12 +141,12 @@ namespace mln
withTextListWidget->clear();
withoutTextListWidget->clear();
- statusBar()->show();
+ progressToolBar_->show();
progressLabel_.setText(tr("Processing images..."));
progressBar_.setRange(0, file_list_.size());
progressBar_.setValue(0);
- bgfg_ = bgfg;
+ options_ = options;
start_process();
}
@@ -162,7 +167,7 @@ namespace mln
start_process();
else
{
- statusBar()->hide();
+ progressToolBar_->hide();
emit process_finished();
}
}
@@ -192,9 +197,14 @@ namespace mln
{
QStringList args;
args << file_list_.at(current_file_).absoluteFilePath() // input file.
- << textMask_file(file_list_.at(current_file_).baseName()) // output file.
- << QString("%1").arg(bgfg_) // Enable/Disable remove background.
- << "1" << "1" << "1" <<
"1" // Enable all steps.
+ << textMask_file(file_list_.at(current_file_).baseName()); // output file.
+
+ // Enable/Disable remove background + Enable/Disable sauvola_ms.
+ QStringList options = options_.split(' ');
+ foreach(QString option, options)
+ args << option;
+
+ args << "1" << "1" << "1" // Enable
all steps.
<< "/tmp/" + file_list_.at(current_file_).baseName();
process_.start(text_in_photo_ppm_, args);
@@ -367,7 +377,7 @@ namespace mln
process_.waitForFinished();
progressBar_.setValue(progressBar_.maximum());
connect_process();
- statusBar()->hide();
+ progressToolBar_->hide();
}
void
diff --git a/milena/sandbox/lazzara/afp/photos/gui/src/main_window.hh
b/milena/sandbox/lazzara/afp/photos/gui/src/main_window.hh
index 55ea254..27b42e3 100644
--- a/milena/sandbox/lazzara/afp/photos/gui/src/main_window.hh
+++ b/milena/sandbox/lazzara/afp/photos/gui/src/main_window.hh
@@ -58,7 +58,8 @@ namespace mln
void on_tabWidget_currentChanged(int index);
void on_actionScan_directory_triggered();
- void init_and_start_process(const QString& dirname, bool bgfg);
+ void init_and_start_process(const QString& dirname,
+ const QString& options);
void cancel_clicked(bool);
void remove_image(bool);
@@ -85,12 +86,13 @@ namespace mln
QDir dir_;
QString text_in_photo_ppm_;
QProcess process_;
- bool bgfg_;
+ QString options_;
QFileInfoList file_list_;
int current_file_;
- // Status bar
+ // Progress tool bar
+ QToolBar *progressToolBar_;
QLabel progressLabel_;
QProgressBar progressBar_;
diff --git a/milena/sandbox/lazzara/afp/photos/gui/ui/launch_dialog.ui
b/milena/sandbox/lazzara/afp/photos/gui/ui/launch_dialog.ui
index cc59126..a7aa216 100644
--- a/milena/sandbox/lazzara/afp/photos/gui/ui/launch_dialog.ui
+++ b/milena/sandbox/lazzara/afp/photos/gui/ui/launch_dialog.ui
@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>285</width>
- <height>165</height>
+ <width>371</width>
+ <height>160</height>
</rect>
</property>
<property name="windowTitle" >
@@ -36,13 +36,30 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
- <widget class="QCheckBox" name="checkBox" >
- <property name="text" >
- <string>Enable Foreground extraction (slower)</string>
- </property>
- <property name="checked" >
- <bool>true</bool>
+ <widget class="QComboBox" name="binarizationMode" >
+ <property name="currentIndex" >
+ <number>3</number>
</property>
+ <item>
+ <property name="text" >
+ <string>Binarization from intensity</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Binarization from foreground (slower)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Multiscale Binarization from intensity </string>
+ </property>
+ </item>
+ <item>
+ <property name="text" >
+ <string>Multiscale Binarization from foreground
(slower)</string>
+ </property>
+ </item>
</widget>
</item>
</layout>
--
1.5.6.5