Olena-patches
Threads by month
- ----- 2025 -----
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
April 2013
- 7 participants
- 363 discussions

olena-2.0-549-g1cd17e3 src/primitive/extract/lines_pattern.cc: Fix description.
by Guillaume Lazzara 18 Apr '13
by Guillaume Lazzara 18 Apr '13
18 Apr '13
---
scribo/ChangeLog | 4 ++++
scribo/src/primitive/extract/lines_pattern.cc | 2 +-
2 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 89f8fc9..1fe01ca 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,7 @@
+2013-04-18 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * src/primitive/extract/lines_pattern.cc: Fix description.
+
2013-02-27 Anthony Seure <anthony.seure(a)lrde.epita.fr>
Fix different forward declarations (class/struct) in scribo/core.
diff --git a/scribo/src/primitive/extract/lines_pattern.cc b/scribo/src/primitive/extract/lines_pattern.cc
index 075dca6..a120a62 100644
--- a/scribo/src/primitive/extract/lines_pattern.cc
+++ b/scribo/src/primitive/extract/lines_pattern.cc
@@ -51,7 +51,7 @@ int main(int argc, char *argv[])
if (argc != 5)
return scribo::debug::usage(argv,
- "Extract horizontal lines patterns",
+ "Extract horizontal and vertical lines patterns",
"input.pbm length delta output.pbm",
args_desc);
--
1.7.2.5
1
0
* demo/viewer/PagesWidget/pageswidget.cc: Rely on signal
activated().
* demo/viewer/mainwindow.cc: Fix a segmentation fault with
preferences dialog. Do not disable segmentation action if xml file
exists.
* demo/viewer/mainwindow.hh: Remove preferencesDialog attribute.
* demo/viewer/xml.cc,
* demo/viewer/xml.hh: Fix getPath() and add makeXmlFilename.
---
scribo/ChangeLog | 20 +-
scribo/demo/viewer/PagesWidget/pageswidget.cc | 2 +-
scribo/demo/viewer/mainwindow.cc | 614 +++++++++++++------------
scribo/demo/viewer/mainwindow.hh | 1 -
scribo/demo/viewer/xml.cc | 38 ++-
scribo/demo/viewer/xml.hh | 1 +
6 files changed, 357 insertions(+), 319 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 378f46c..ebbb1c7 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,4 +1,3 @@
-<<<<<<< HEAD
2013-04-17 Guillaume Lazzara <z(a)lrde.epita.fr>
* scribo/core/object_links.hh: Always initialize links in
@@ -683,7 +682,23 @@
* scribo/make/text_components_image.hh,
* scribo/primitive/extract/non_text.hh: Here.
-=======
+
+2013-03-08 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Several small fixes in viewer.
+
+ * demo/viewer/PagesWidget/pageswidget.cc: Rely on signal
+ activated().
+
+ * demo/viewer/mainwindow.cc: Fix a segmentation fault with
+ preferences dialog. Do not disable segmentation action if xml file
+ exists.
+
+ * demo/viewer/mainwindow.hh: Remove preferencesDialog attribute.
+
+ * demo/viewer/xml.cc,
+ * demo/viewer/xml.hh: Fix getPath() and add makeXmlFilename.
+
2013-02-27 Guillaume Lazzara <z(a)lrde.epita.fr>
Move new viewer to scribo/demo.
@@ -823,7 +838,6 @@
* scribo/demo/viewer/viewer.qrc ,
* scribo/demo/viewer/xml_widget.cc,
* scribo/demo/viewer/xml_widget.hh: Remove.
->>>>>>> Move new viewer to scribo/demo.
2013-03-08 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/demo/viewer/PagesWidget/pageswidget.cc b/scribo/demo/viewer/PagesWidget/pageswidget.cc
index 0355419..f80d3a1 100644
--- a/scribo/demo/viewer/PagesWidget/pageswidget.cc
+++ b/scribo/demo/viewer/PagesWidget/pageswidget.cc
@@ -33,7 +33,7 @@ PagesWidget::PagesWidget(QWidget *parent):
QShortcut *remove = new QShortcut(Qt::Key_Delete, this);
connect(remove, SIGNAL(activated()), this, SLOT(removeSelection()));
- connect(this, SIGNAL(doubleClicked(QModelIndex)),
+ connect(this, SIGNAL(activated(QModelIndex)),
this, SLOT(getPicture(QModelIndex)));
}
diff --git a/scribo/demo/viewer/mainwindow.cc b/scribo/demo/viewer/mainwindow.cc
index 97cda4e..148595e 100644
--- a/scribo/demo/viewer/mainwindow.cc
+++ b/scribo/demo/viewer/mainwindow.cc
@@ -21,456 +21,460 @@ MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
ui(new Ui::MainWindow)
{
- ui->setupUi(this);
-
- setWindowTitle(tr("GScribo"));
- showMaximized();
-
- initGraphicsRegion();
- initDialogsWidget();
- initXmlWidget();
- initRegionWidget();
- initPageWidget();
- initMenuBar();
-
- // Told the left dock widget (here the pages widget and the region
- // widget) to fill the bottom left corner.
- setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
- // Merge the region and pages widget in one tab (pages widget over
- // the region widget).
- tabifyDockWidget(&dockRegion_, &dockPages_);
-
- connectWidgets();
+ ui->setupUi(this);
+
+ setWindowTitle(tr("GScribo"));
+ showMaximized();
+
+ initGraphicsRegion();
+ initDialogsWidget();
+ initXmlWidget();
+ initRegionWidget();
+ initPageWidget();
+ initMenuBar();
+
+ // Told the left dock widget (here the pages widget and the region
+ // widget) to fill the bottom left corner.
+ setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
+ // Merge the region and pages widget in one tab (pages widget over
+ // the region widget).
+ tabifyDockWidget(&dockRegion_, &dockPages_);
+
+ connectWidgets();
}
MainWindow::~MainWindow()
{
- delete preferencesDialog_;
- delete aboutDialog_;
- delete progressDialog_;
- delete ui;
+ delete aboutDialog_;
+ delete progressDialog_;
+ delete ui;
}
void MainWindow::changeEvent(QEvent *e)
{
- QMainWindow::changeEvent(e);
- switch (e->type())
- {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
+ QMainWindow::changeEvent(e);
+ switch (e->type())
+ {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
}
void MainWindow::initGraphicsRegion()
{
- graphicsView_.setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
- graphicsView_.setScene(&scene_);
+ graphicsView_.setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
+ graphicsView_.setScene(&scene_);
- setCentralWidget(&graphicsView_);
+ setCentralWidget(&graphicsView_);
}
void MainWindow::initDialogsWidget()
{
- preferencesDialog_ = new PreferencesDialog(this);
- aboutDialog_ = new AboutDialog(this);
- progressDialog_ = new ProgressDialog(this);
+ aboutDialog_ = new AboutDialog(this);
+ progressDialog_ = new ProgressDialog(this);
}
void MainWindow::initPageWidget()
{
- dockPages_.setWindowTitle("Pages");
- dockPages_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
- dockPages_.setWidget(&pagesWidget_);
- dockPages_.setMinimumWidth(190);
+ dockPages_.setWindowTitle("Pages");
+ dockPages_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
+ dockPages_.setWidget(&pagesWidget_);
+ dockPages_.setMinimumWidth(190);
- addDockWidget(Qt::LeftDockWidgetArea, &dockPages_);
+ addDockWidget(Qt::LeftDockWidgetArea, &dockPages_);
}
void MainWindow::initRegionWidget()
{
- dockRegion_.setWindowTitle("Regions");
- dockRegion_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
- dockRegion_.setWidget(®ionWidget_);
+ dockRegion_.setWindowTitle("Regions");
+ dockRegion_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
+ dockRegion_.setWidget(®ionWidget_);
- addDockWidget(Qt::LeftDockWidgetArea, &dockRegion_);
+ addDockWidget(Qt::LeftDockWidgetArea, &dockRegion_);
}
void MainWindow::initXmlWidget()
{
- dockXml_.setWindowTitle("Xml");
- dockXml_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
- dockXml_.setWidget(&xmlWidget_);
+ dockXml_.setWindowTitle("Xml");
+ dockXml_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
+ dockXml_.setWidget(&xmlWidget_);
- addDockWidget(Qt::BottomDockWidgetArea, &dockXml_);
- dockXml_.setVisible(false);
+ addDockWidget(Qt::BottomDockWidgetArea, &dockXml_);
+ dockXml_.setVisible(false);
}
void MainWindow::initMenuBar()
{
- QMenu *menuFile = ui->menuBar->addMenu(tr("File"));
+ QMenu *menuFile = ui->menuBar->addMenu(tr("File"));
- menuFile->addAction(tr("&Open"), this, SLOT(onOpen()),
- QKeySequence(tr("Ctrl+O")));
+ menuFile->addAction(tr("&Open"), this, SLOT(onOpen()),
+ QKeySequence(tr("Ctrl+O")));
- segment_ = menuFile->addAction(tr("Segment"), this, SLOT(onSegment()),
- QKeySequence(tr("Ctrl+S")));
- segment_->setEnabled(false);
+ segment_ = menuFile->addAction(tr("Segment selected"),
+ this, SLOT(onSegment()),
+ QKeySequence(tr("Ctrl+S")));
+ segment_->setEnabled(false);
- menuFile->addSeparator();
+ menuFile->addSeparator();
- previewPrinting_ = menuFile->addAction(tr("Preview Printing"),
- this, SLOT(onPreviewPrint()),
- QKeySequence(tr("Shift+Ctrl+P")));
- previewPrinting_->setEnabled(false);
+ previewPrinting_ = menuFile->addAction(tr("Preview Printing"),
+ this, SLOT(onPreviewPrint()),
+ QKeySequence(tr("Shift+Ctrl+P")));
+ previewPrinting_->setEnabled(false);
- print_ = menuFile->addAction(tr("Print"), this, SLOT(onPrint()),
- QKeySequence(tr("Ctrl+P")));
- print_->setEnabled(false);
+ print_ = menuFile->addAction(tr("Print"), this, SLOT(onPrint()),
+ QKeySequence(tr("Ctrl+P")));
+ print_->setEnabled(false);
- menuFile->addSeparator();
+ menuFile->addSeparator();
- export_ = menuFile->addAction(tr("&Exportation"),
- this, SLOT(onExportation()),
- QKeySequence(tr("Ctrl+E")));
- export_->setEnabled(false);
+ export_ = menuFile->addAction(tr("&Exportation"),
+ this, SLOT(onExportation()),
+ QKeySequence(tr("Ctrl+E")));
+ export_->setEnabled(false);
- menuFile->addSeparator();
+ menuFile->addSeparator();
- menuFile->addAction(tr("Quit"), this, SLOT(close()));
+ menuFile->addAction(tr("Quit"), this, SLOT(close()));
- ui->menuBar->addAction(tr("Preferences"),
- this, SLOT(onPreferences()));
+ ui->menuBar->addAction(tr("Preferences"),
+ this, SLOT(onPreferences()));
- QMenu *menuAreas = ui->menuBar->addMenu(tr("Window"));
+ QMenu *menuAreas = ui->menuBar->addMenu(tr("Window"));
- next_ = menuAreas->addAction(tr("Next document"),
- &pagesWidget_, SLOT(selectNextRow()),
- QKeySequence(tr("Space")));
- next_->setEnabled(false);
+ next_ = menuAreas->addAction(tr("Next document"),
+ &pagesWidget_, SLOT(selectNextRow()),
+ QKeySequence(tr("Space")));
+ next_->setEnabled(false);
- prev_ = menuAreas->addAction(tr("Previous document"),
- &pagesWidget_, SLOT(selectPreviousRow()),
- QKeySequence(tr("Backspace")));
- prev_->setEnabled(false);
+ prev_ = menuAreas->addAction(tr("Previous document"),
+ &pagesWidget_, SLOT(selectPreviousRow()),
+ QKeySequence(tr("Backspace")));
+ prev_->setEnabled(false);
- menuAreas->addSeparator();
+ menuAreas->addSeparator();
- QAction *page = menuAreas->addAction(tr("Page"),
- &dockPages_, SLOT(switchVisibility()));
- page->setCheckable(true);
- page->setChecked(true);
+ QAction *page = menuAreas->addAction(tr("Page"),
+ &dockPages_, SLOT(switchVisibility()));
+ page->setCheckable(true);
+ page->setChecked(true);
- QAction *region = menuAreas->addAction(tr("Region"),
- &dockRegion_, SLOT(switchVisibility()));
- region->setCheckable(true);
- region->setChecked(true);
+ QAction *region = menuAreas->addAction(tr("Region"),
+ &dockRegion_, SLOT(switchVisibility()));
+ region->setCheckable(true);
+ region->setChecked(true);
- QAction *xml = menuAreas->addAction(tr("Xml"),
- &dockXml_, SLOT(switchVisibility()));
- xml->setCheckable(true);
- xml->setChecked(false);
+ QAction *xml = menuAreas->addAction(tr("Xml"),
+ &dockXml_, SLOT(switchVisibility()));
+ xml->setCheckable(true);
+ xml->setChecked(false);
- ui->menuBar->addAction(tr("&About"), this, SLOT(onAbout()));
+ ui->menuBar->addAction(tr("&About"), this, SLOT(onAbout()));
}
void MainWindow::setActionsEnabled(bool isSegmented)
{
- segment_->setEnabled(!isSegmented);
- print_->setEnabled(isSegmented);
- previewPrinting_->setEnabled(isSegmented);
+ // No reason for disabling this action even if this is already segmented.
+ segment_->setEnabled(isSegmented);
+ print_->setEnabled(isSegmented);
+ previewPrinting_->setEnabled(isSegmented);
}
void MainWindow::disableActions()
{
- segment_->setEnabled(false);
- print_->setEnabled(false);
- previewPrinting_->setEnabled(false);
- export_->setEnabled(false);
+ segment_->setEnabled(false);
+ print_->setEnabled(false);
+ previewPrinting_->setEnabled(false);
+ export_->setEnabled(false);
}
void MainWindow::connectWidgets()
{
- // Each time the scene rect change (when a new picture is loaded), we fit the scene background rectangle in the view.
- connect(&scene_, SIGNAL(sceneRectChanged(QRectF)),
- &graphicsView_, SLOT(fitInView(QRectF)));
- // When dragging with right click, disable selection.
- connect(&graphicsView_, SIGNAL(beginDrag()),
- &scene_, SLOT(disableSelection()));
- connect(&graphicsView_, SIGNAL(endDrag()),
- &scene_, SLOT(enableSelection()));
-
- // If double click on a picture of the page widget -> draw it on background scene.
- connect(&pagesWidget_, SIGNAL(imageSelected(QString)),
- this, SLOT(onFileChanged(QString)));
-
- // Connect the scene to the xml widget and vice versa.
- connect(&scene_, SIGNAL(newSelection(QList<RegionItem*>)),
- this, SLOT(onRegionSelection(QList<RegionItem*>)));
- connect(xmlWidget_.view(), SIGNAL(select(QList<XmlItem*>)),
- this, SLOT(onXmlSelect(QList<XmlItem*>)));
- connect(xmlWidget_.view(), SIGNAL(unselect(QList<XmlItem*>)),
- this, SLOT(onXmlUnselect(QList<XmlItem*>)));
- connect(xmlWidget_.view(), SIGNAL(emptySelection()),
- &scene_, SLOT(selectBase()));
- connect(xmlWidget_.view(), SIGNAL(resetSelection()),
- &scene_, SLOT(clearSelection()));
-
- // Connect the scene with the region widget.
- connect(®ionWidget_, SIGNAL(checkStateChanged(GraphicsRegion::Id,bool)), &scene_, SLOT(setVisible(GraphicsRegion::Id,bool)));
-
- // Connect the xml widget with the region widget.
- connect(®ionWidget_, SIGNAL(checkStateChanged(QString)), xmlWidget_.view(), SLOT(setFilterString(QString)));
-
- connect(&runner_, SIGNAL(progress()), progressDialog_, SLOT(run()));
- connect(&runner_, SIGNAL(new_progress_max_value(int)),
- progressDialog_, SLOT(setMaximum(int)));
- connect(&runner_, SIGNAL(new_progress_label(QString)),
- progressDialog_, SLOT(setLabelText(QString)));
- connect(&runner_, SIGNAL(finished()), progressDialog_, SLOT(close()));
- connect(&runner_, SIGNAL(xml_saved(QString)),
- this, SLOT(onXmlSaved(QString)));
+ // Each time the scene rect change (when a new picture is loaded), we fit the scene background rectangle in the view.
+ connect(&scene_, SIGNAL(sceneRectChanged(QRectF)),
+ &graphicsView_, SLOT(fitInView(QRectF)));
+ // When dragging with right click, disable selection.
+ connect(&graphicsView_, SIGNAL(beginDrag()),
+ &scene_, SLOT(disableSelection()));
+ connect(&graphicsView_, SIGNAL(endDrag()),
+ &scene_, SLOT(enableSelection()));
+
+ // If double click on a picture of the page widget -> draw it on background scene.
+ connect(&pagesWidget_, SIGNAL(imageSelected(QString)),
+ this, SLOT(onFileChanged(QString)));
+
+ // Connect the scene to the xml widget and vice versa.
+ connect(&scene_, SIGNAL(newSelection(QList<RegionItem*>)),
+ this, SLOT(onRegionSelection(QList<RegionItem*>)));
+ connect(xmlWidget_.view(), SIGNAL(select(QList<XmlItem*>)),
+ this, SLOT(onXmlSelect(QList<XmlItem*>)));
+ connect(xmlWidget_.view(), SIGNAL(unselect(QList<XmlItem*>)),
+ this, SLOT(onXmlUnselect(QList<XmlItem*>)));
+ connect(xmlWidget_.view(), SIGNAL(emptySelection()),
+ &scene_, SLOT(selectBase()));
+ connect(xmlWidget_.view(), SIGNAL(resetSelection()),
+ &scene_, SLOT(clearSelection()));
+
+ // Connect the scene with the region widget.
+ connect(®ionWidget_, SIGNAL(checkStateChanged(GraphicsRegion::Id,bool)), &scene_, SLOT(setVisible(GraphicsRegion::Id,bool)));
+
+ // Connect the xml widget with the region widget.
+ connect(®ionWidget_, SIGNAL(checkStateChanged(QString)), xmlWidget_.view(), SLOT(setFilterString(QString)));
+
+ connect(&runner_, SIGNAL(progress()), progressDialog_, SLOT(run()));
+ connect(&runner_, SIGNAL(new_progress_max_value(int)),
+ progressDialog_, SLOT(setMaximum(int)));
+ connect(&runner_, SIGNAL(new_progress_label(QString)),
+ progressDialog_, SLOT(setLabelText(QString)));
+ connect(&runner_, SIGNAL(finished()), progressDialog_, SLOT(close()));
+ connect(&runner_, SIGNAL(xml_saved(QString)),
+ this, SLOT(onXmlSaved(QString)));
}
void MainWindow::onOpen()
{
- QStringList
- paths = QFileDialog::getOpenFileNames(this, "Open Image(s)",
- QDir::homePath(),
- "Images (*.png *.jpg *.ppm *.bmp)");
- setWindowTitle(tr("GScribo"));
+ QStringList
+ paths = QFileDialog::getOpenFileNames(this, "Open Image(s)",
+ QDir::homePath(),
+ "Images (*.png *.jpg *.ppm *.bmp)");
+ setWindowTitle(tr("GScribo"));
+
+ if(paths.count() > 0)
+ {
+ QStringList filenames = pagesWidget_.filenames();
+ QString path;
+
+ int counter = 0;
+ bool isContained;
+ // Check for an image not already added to the page widget.
+ do
+ {
+ path = paths[counter];
+ counter++;
+ isContained = filenames.contains(path);
+ } while(isContained && counter < paths.count());
- if(paths.count() > 0)
+ if(!isContained)
{
- QStringList filenames = pagesWidget_.filenames();
- QString path;
-
- int counter = 0;
- bool isContained;
- // Check for an image not already added to the page widget.
- do
- {
- path = paths[counter];
- counter++;
- isContained = filenames.contains(path);
- } while(isContained && counter < paths.count());
-
- if(!isContained)
- {
- pagesWidget_.addPicture(path, QPixmap(path));
-
- // If more than one file, we store it in the page widget.
- for(int i = counter; i < paths.count(); i++)
- {
- // Check if the page widget contains the image.
- if(!filenames.contains(paths[i]))
- {
- path = paths[i];
- pagesWidget_.addPicture(path, QPixmap(path));
- }
- }
-
- pagesWidget_.setCurrentRow(0);
- pagesWidget_.scrollToTop();
- }
-
- // Change current scene.
- onFileChanged(path);
+ pagesWidget_.addPicture(path, QPixmap(path));
+
+ // If more than one file, we store it in the page widget.
+ for(int i = counter; i < paths.count(); i++)
+ {
+ // Check if the page widget contains the image.
+ if(!filenames.contains(paths[i]))
+ {
+ path = paths[i];
+ pagesWidget_.addPicture(path, QPixmap(path));
+ }
+ }
+
+ pagesWidget_.setCurrentRow(0);
+ pagesWidget_.scrollToTop();
}
+
+ // Change current scene.
+ onFileChanged(path);
+ }
}
void MainWindow::onSegment()
{
- QStringList filenames;
+ QStringList filenames;
- filenames << scene_.backgroundPath();
+ filenames << scene_.backgroundPath();
- // Run segmentation of page(s).
- progressDialog_->reset();
- runner_.start_demat(filenames);
+ // Run segmentation of page(s).
+ progressDialog_->reset();
+ runner_.start_demat(filenames);
}
void MainWindow::onPreviewPrint()
{
- QPrinter printer(QPrinter::HighResolution);
- printer.setPaperSize(QPrinter::A4);
- printer.setResolution(300);
+ QPrinter printer(QPrinter::HighResolution);
+ printer.setPaperSize(QPrinter::A4);
+ printer.setResolution(300);
- QPrintPreviewDialog preview(&printer, this);
- connect(&preview, SIGNAL(paintRequested(QPrinter*)),
- this, SLOT(printScene(QPrinter*)));
+ QPrintPreviewDialog preview(&printer, this);
+ connect(&preview, SIGNAL(paintRequested(QPrinter*)),
+ this, SLOT(printScene(QPrinter*)));
- preview.exec();
+ preview.exec();
}
void MainWindow::onPrint()
{
- QPrinter printer(QPrinter::HighResolution);
- printer.setPaperSize(QPrinter::A4);
- printer.setResolution(300);
+ QPrinter printer(QPrinter::HighResolution);
+ printer.setPaperSize(QPrinter::A4);
+ printer.setResolution(300);
- QPrintDialog dialog(&printer, this);
- dialog.setWindowTitle("Print Document");
+ QPrintDialog dialog(&printer, this);
+ dialog.setWindowTitle("Print Document");
- if(dialog.exec() != QDialog::Accepted)
- return;
+ if(dialog.exec() != QDialog::Accepted)
+ return;
- printScene(&printer);
+ printScene(&printer);
}
void MainWindow::printScene(QPrinter *printer)
{
- QPainter painter(printer);
- QStyleOptionGraphicsItem options;
+ QPainter painter(printer);
+ QStyleOptionGraphicsItem options;
- scene_.backgroundPixmap()->paint(&painter, &options, 0);
+ scene_.backgroundPixmap()->paint(&painter, &options, 0);
- // Paint backwards items first.
- printItems(&painter, scene_.root()->childsFrom(GraphicsRegion::TextRegion),
- &options);
- printItems(&painter, scene_.root()->childsFrom(GraphicsRegion::Image),
- &options);
+ // Paint backwards items first.
+ printItems(&painter, scene_.root()->childsFrom(GraphicsRegion::TextRegion),
+ &options);
+ printItems(&painter, scene_.root()->childsFrom(GraphicsRegion::Image),
+ &options);
- for(int i = GraphicsRegion::Line; i < GraphicsRegion::Image; i++)
- printItems(&painter,
- scene_.root()->childsFrom(static_cast<GraphicsRegion::Id>(i)),
- &options);
+ for(int i = GraphicsRegion::Line; i < GraphicsRegion::Image; i++)
+ printItems(&painter,
+ scene_.root()->childsFrom(static_cast<GraphicsRegion::Id>(i)),
+ &options);
- for(int i = GraphicsRegion::Noise; i <= GraphicsRegion::Meanline; i++)
- printItems(&painter,
- scene_.root()->childsFrom(static_cast<GraphicsRegion::Id>(i)),
- &options);
+ for(int i = GraphicsRegion::Noise; i <= GraphicsRegion::Meanline; i++)
+ printItems(&painter,
+ scene_.root()->childsFrom(static_cast<GraphicsRegion::Id>(i)),
+ &options);
}
void MainWindow::printItems(QPainter *painter,
const QList<QGraphicsItem *>& items,
QStyleOptionGraphicsItem *options)
{
- foreach(QGraphicsItem *child, items)
+ foreach(QGraphicsItem *child, items)
+ {
+ if(child->isVisible())
{
- if(child->isVisible())
- {
- QRect
- viewport = scene_.backgroundPixmap()->mapRectFromItem(child, child->boundingRect()).toRect();
- painter->translate(abs(child->boundingRect().x() - viewport.x()),
- abs(child->boundingRect().y() - viewport.y()));
- child->paint(painter, options);
- painter->resetTransform();
- }
+ QRect
+ viewport = scene_.backgroundPixmap()->mapRectFromItem(child, child->boundingRect()).toRect();
+ painter->translate(abs(child->boundingRect().x() - viewport.x()),
+ abs(child->boundingRect().y() - viewport.y()));
+ child->paint(painter, options);
+ painter->resetTransform();
}
+ }
}
void MainWindow::onExportation()
{
- QMessageBox messageBox(this);
- messageBox.setWindowTitle("Information");
- messageBox.setText("This feature is not available yet");
- messageBox.exec();
- return;
-
- QFileInfo fileInfo(scene_.backgroundPath());
- QString outputSuggestion = fileInfo.baseName() + ".pdf";
- QString output = QFileDialog::getSaveFileName(0, tr("Export Document As ..."), outputSuggestion,
- tr("PDF (*.pdf);; HTML (*.html *.htm"));
-
- if(!output.isEmpty())
- {
- progressDialog_->reset();
- runner_.start_export(scene_.backgroundPath(), xml_.filename(), output);
- }
+ QMessageBox messageBox(this);
+ messageBox.setWindowTitle("Information");
+ messageBox.setText("This feature is not available yet");
+ messageBox.exec();
+ return;
+
+ QFileInfo fileInfo(scene_.backgroundPath());
+ QString outputSuggestion = fileInfo.baseName() + ".pdf";
+ QString output = QFileDialog::getSaveFileName(0, tr("Export Document As ..."), outputSuggestion,
+ tr("PDF (*.pdf);; HTML (*.html *.htm"));
+
+ if(!output.isEmpty())
+ {
+ progressDialog_->reset();
+ runner_.start_export(scene_.backgroundPath(), xml_.filename(), output);
+ }
}
void MainWindow::onXmlSaved(const QString& filename)
{
- xml_.load(filename);
- xmlWidget_.changeView(xml_.xmlItem());
- scene_.setRoot(xml_.graphicsItem());
+ xml_.load(filename);
+ xmlWidget_.changeView(xml_.xmlItem());
+ scene_.setRoot(xml_.graphicsItem());
- setActionsEnabled(true);
- export_->setEnabled(xml_.recognized());
+ setActionsEnabled(true);
+ export_->setEnabled(xml_.recognized());
}
void MainWindow::onFileChanged(const QString& filename)
{
- // If it's not the current scene.
- if(scene_.backgroundPath() != filename)
+ // If it's not the current scene.
+ if(scene_.backgroundPath() != filename)
+ {
+ QString xmlPath = Xml::getPath(filename);
+ QString
+ pathToXml = xmlPath + QDir::separator()
+ + Xml::makeXmlFilename(filename);
+
+ if(filename.isEmpty())
+ {
+ pathToXml = QString();
+ disableActions();
+ }
+ // Check if the xml file already exists.
+ else if(!QFile(pathToXml).exists())
{
- QString xmlPath = Xml::getPath(filename);
-
- if(filename.isEmpty())
- {
- xmlPath = QString();
- disableActions();
- }
- // Check if the xml file already exists.
- else if(!QFile(xmlPath).exists())
- {
- xmlPath = QString();
- setActionsEnabled(false);
- }
- else
- setActionsEnabled(true);
-
- xml_.load(xmlPath);
- scene_.changeScene(filename, xml_.graphicsItem());
- xmlWidget_.changeView(xml_.xmlItem());
- export_->setEnabled(xml_.recognized());
- updatePageBrowsing();
+ pathToXml = QString();
+ setActionsEnabled(false);
}
+ else
+ setActionsEnabled(true);
+
+ xml_.load(pathToXml);
+ scene_.changeScene(filename, xml_.graphicsItem());
+ xmlWidget_.changeView(xml_.xmlItem());
+ export_->setEnabled(xml_.recognized());
+ updatePageBrowsing();
+ }
}
void MainWindow::onRegionSelection(QList<RegionItem *> regionItems)
{
- if(!regionItems.isEmpty())
- xmlWidget_.view()->displayOnly(toXmlItems(regionItems));
- else
- {
- xmlWidget_.view()->reset();
- xmlWidget_.view()->displayAll();
- xmlWidget_.view()->expandAll();
- }
+ if(!regionItems.isEmpty())
+ xmlWidget_.view()->displayOnly(toXmlItems(regionItems));
+ else
+ {
+ xmlWidget_.view()->reset();
+ xmlWidget_.view()->displayAll();
+ xmlWidget_.view()->expandAll();
+ }
}
void MainWindow::onXmlChangeSelection(QList<XmlItem *> xmlItems, bool select)
{
- QList<RegionItem *> regionItems = toRegionItems(xmlItems);
+ QList<RegionItem *> regionItems = toRegionItems(xmlItems);
- if(!regionItems.isEmpty())
- {
- if(select)
- scene_.select(regionItems);
- else
- scene_.unselect(regionItems);
- }
+ if(!regionItems.isEmpty())
+ {
+ if(select)
+ scene_.select(regionItems);
+ else
+ scene_.unselect(regionItems);
+ }
}
QList<RegionItem *> MainWindow::toRegionItems(QList<XmlItem *> xmlItems) const
{
- QList<RegionItem *> regionItems;
- XmlItem *child;
- foreach(child, xmlItems)
- {
- if(child->regionItem())
- regionItems << child->regionItem();
- }
-
- return regionItems;
+ QList<RegionItem *> regionItems;
+ XmlItem *child;
+ foreach(child, xmlItems)
+ {
+ if(child->regionItem())
+ regionItems << child->regionItem();
+ }
+
+ return regionItems;
}
QList<XmlItem *> MainWindow::toXmlItems(QList<RegionItem *> regionItems) const
{
- QList<XmlItem *> xmlItems;
- RegionItem *child;
- foreach(child, regionItems)
- xmlItems << child->xmlItem();
+ QList<XmlItem *> xmlItems;
+ RegionItem *child;
+ foreach(child, regionItems)
+ xmlItems << child->xmlItem();
- return xmlItems;
+ return xmlItems;
}
void MainWindow::onPreferences()
{
+ PreferencesDialog *preferencesDialog_ = new PreferencesDialog(this);
preferencesDialog_->show();
}
diff --git a/scribo/demo/viewer/mainwindow.hh b/scribo/demo/viewer/mainwindow.hh
index 527b612..8f52e09 100644
--- a/scribo/demo/viewer/mainwindow.hh
+++ b/scribo/demo/viewer/mainwindow.hh
@@ -89,7 +89,6 @@ private:
AboutDialog *aboutDialog_;
ProgressDialog *progressDialog_;
- PreferencesDialog *preferencesDialog_;
XmlWidget xmlWidget_;
Xml xml_;
diff --git a/scribo/demo/viewer/xml.cc b/scribo/demo/viewer/xml.cc
index 74c9112..c09ea66 100644
--- a/scribo/demo/viewer/xml.cc
+++ b/scribo/demo/viewer/xml.cc
@@ -21,19 +21,39 @@ Xml::Xml(const QString& filename)
load(filename);
}
+QString Xml::makeXmlFilename(const QString& filename)
+{
+ QString xml_file = filename;
+
+ // Get xml filename from image path.
+ xml_file.remove(0, xml_file.lastIndexOf('/')+1);
+ int pos = xml_file.lastIndexOf('.');
+ xml_file.remove(pos, xml_file.length()-pos);
+ xml_file += "_gui.xml";
+
+ return xml_file;
+}
+
QString Xml::getPath(const QString& filename)
{
Configs *const configs = Configs::getInstance();
- QString xmlPath = filename;
-
- // Get xml filename from image path.
- xmlPath.remove(0, xmlPath.lastIndexOf('/')+1);
- int pos = xmlPath.lastIndexOf('.');
- xmlPath.remove(pos, xmlPath.length()-pos);
- xmlPath += "_gui.xml";
+ // Get directory where XML files are stored.
+ QFileInfo file(filename);
+ QString output_dir = QDir::tempPath();
+ if (configs->generalSaveXmlEnabled())
+ {
+ if (configs->generalSaveXmlSameDir())
+ output_dir = file.absolutePath();
+ else if (configs->generalSaveXmlCustomDir())
+ output_dir = configs->generalSaveXmlCustomDirPath();
+
+ QDir dir(output_dir);
+ if (!dir.exists() && !dir.mkpath(output_dir))
+ output_dir = QDir::tempPath();
+ }
- return configs->generalSaveXmlCustomDirPath() + "/" + xmlPath;
+ return output_dir;
}
void Xml::isRecognized(const QDomElement& textElement)
diff --git a/scribo/demo/viewer/xml.hh b/scribo/demo/viewer/xml.hh
index c5f59d4..608aa7a 100644
--- a/scribo/demo/viewer/xml.hh
+++ b/scribo/demo/viewer/xml.hh
@@ -67,6 +67,7 @@ public:
QString filename() const;
bool recognized() const;
+ static QString makeXmlFilename(const QString& filename);
static QString getPath(const QString& filename);
void load(const QString& filename);
--
1.7.2.5
1
0
---
AUTHORS | 4 +++-
ChangeLog | 4 ++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index 9bea227..ba976b4 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -79,8 +79,10 @@ Past contributors of LRDE Staff.
Interns.
========
-* **Arthur Crépin-Leblond**
+* Antoine Froger
+ - Graphical improvements of SCRIBO viewer.
+* Arthur Crépin-Leblond
- SCRIBO structured outputs (XML, HTML, PDF).
diff --git a/ChangeLog b/ChangeLog
index 841926a..a2ac91c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2013-02-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+ * AUTHORS: Add Antoine Froger.
+
+2013-02-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Move new viewer to scribo/demo.
* GScribo/BUGS,
--
1.7.2.5
1
0
* scribo/demo/viewer/BUGS,
* scribo/demo/viewer/GScribo.pro,
* scribo/demo/viewer/GScribo.pro.user,
* scribo/demo/viewer/GScribo.pro.user.1.3,
* scribo/demo/viewer/Makefile.am,
* scribo/demo/viewer/PagesWidget/pagesdelegate.cc,
* scribo/demo/viewer/PagesWidget/pagesdelegate.hh,
* scribo/demo/viewer/PagesWidget/pagesmodel.cc,
* scribo/demo/viewer/PagesWidget/pagesmodel.hh,
* scribo/demo/viewer/PagesWidget/pageswidget.cc,
* scribo/demo/viewer/PagesWidget/pageswidget.hh,
* scribo/demo/viewer/Preferences/generaloptions.cc,
* scribo/demo/viewer/Preferences/generaloptions.hh,
* scribo/demo/viewer/Preferences/generaloptions.ui,
* scribo/demo/viewer/Preferences/ocroptions.cc,
* scribo/demo/viewer/Preferences/ocroptions.hh,
* scribo/demo/viewer/Preferences/ocroptions.ui,
* scribo/demo/viewer/Preferences/optionwidget.hh,
* scribo/demo/viewer/Preferences/preferencesdialog.cc,
* scribo/demo/viewer/Preferences/preferencesdialog.hh,
* scribo/demo/viewer/Preferences/preferencesdialog.ui,
* scribo/demo/viewer/Preferences/preprocessingoptions.cc,
* scribo/demo/viewer/Preferences/preprocessingoptions.hh,
* scribo/demo/viewer/Preferences/preprocessingoptions.ui,
* scribo/demo/viewer/Preferences/segmentationoptions.cc,
* scribo/demo/viewer/Preferences/segmentationoptions.hh,
* scribo/demo/viewer/Preferences/segmentationoptions.ui,
* scribo/demo/viewer/Processing/preprocess.cc,
* scribo/demo/viewer/Processing/preprocess.hh,
* scribo/demo/viewer/Processing/process.cc,
* scribo/demo/viewer/Processing/process.hh,
* scribo/demo/viewer/Processing/progressdialog.cc,
* scribo/demo/viewer/Processing/progressdialog.hh,
* scribo/demo/viewer/Processing/runner.cc,
* scribo/demo/viewer/Processing/runner.hh,
* scribo/demo/viewer/Rendering/abstractregionitem.hh,
* scribo/demo/viewer/Rendering/backgroundtexture.hh,
* scribo/demo/viewer/Rendering/graphicsview.cc,
* scribo/demo/viewer/Rendering/graphicsview.hh,
* scribo/demo/viewer/Rendering/regionitem.cc,
* scribo/demo/viewer/Rendering/regionitem.hh,
* scribo/demo/viewer/Rendering/rootgraphicsitem.cc,
* scribo/demo/viewer/Rendering/rootgraphicsitem.hh,
* scribo/demo/viewer/Rendering/scene.cc,
* scribo/demo/viewer/Rendering/scene.hh,
* scribo/demo/viewer/Rendering/selection.cc,
* scribo/demo/viewer/Rendering/selection.hh,
* scribo/demo/viewer/TODO,
* scribo/demo/viewer/XmlWidget/attributesmodel.cc,
* scribo/demo/viewer/XmlWidget/attributesmodel.hh,
* scribo/demo/viewer/XmlWidget/selectionproxy.hh,
* scribo/demo/viewer/XmlWidget/xmlattributes.cc,
* scribo/demo/viewer/XmlWidget/xmlattributes.hh,
* scribo/demo/viewer/XmlWidget/xmldelegate.hh,
* scribo/demo/viewer/XmlWidget/xmlitem.cc,
* scribo/demo/viewer/XmlWidget/xmlitem.hh,
* scribo/demo/viewer/XmlWidget/xmlmodel.cc,
* scribo/demo/viewer/XmlWidget/xmlmodel.hh,
* scribo/demo/viewer/XmlWidget/xmlview.cc,
* scribo/demo/viewer/XmlWidget/xmlview.hh,
* scribo/demo/viewer/XmlWidget/xmlwidget.cc,
* scribo/demo/viewer/XmlWidget/xmlwidget.hh,
* scribo/demo/viewer/aboutdialog.cc,
* scribo/demo/viewer/aboutdialog.hh,
* scribo/demo/viewer/aboutdialog.ui,
* scribo/demo/viewer/config.cc,
* scribo/demo/viewer/configs.cc,
* scribo/demo/viewer/configs.hh,
* scribo/demo/viewer/defs.hh,
* scribo/demo/viewer/dir.hh,
* scribo/demo/viewer/dockwidget.cc,
* scribo/demo/viewer/dockwidget.hh,
* scribo/demo/viewer/general_options.hh,
* scribo/demo/viewer/help_dialog.hh,
* scribo/demo/viewer/image_scene.hh,
* scribo/demo/viewer/image_view.hh,
* scribo/demo/viewer/main.cc,
* scribo/demo/viewer/mainwindow.cc,
* scribo/demo/viewer/mainwindow.hh,
* scribo/demo/viewer/mainwindow.ui,
* scribo/demo/viewer/ocr_options.hh,
* scribo/demo/viewer/option_widget.cc,
* scribo/demo/viewer/option_widget.hh,
* scribo/demo/viewer/preprocess.cc,
* scribo/demo/viewer/preprocess.hh,
* scribo/demo/viewer/process.cc,
* scribo/demo/viewer/region.hh,
* scribo/demo/viewer/regionwidget.cc,
* scribo/demo/viewer/regionwidget.hh,
* scribo/demo/viewer/variantpointer.cc,
* scribo/demo/viewer/variantpointer.hh,
* scribo/demo/viewer/xml.cc,
* scribo/demo/viewer/xml.hh: New.
* scribo/demo/viewer/README,
* scribo/demo/viewer/browser_widget.cc,
* scribo/demo/viewer/browser_widget.hh,
* scribo/demo/viewer/common.hh,
* scribo/demo/viewer/config.hh,
* scribo/demo/viewer/general_options.cc,
* scribo/demo/viewer/general_options.ui,
* scribo/demo/viewer/help_dialog.cc,
* scribo/demo/viewer/help_dialog.ui,
* scribo/demo/viewer/icons/olena_smaller.jpg,
* scribo/demo/viewer/image_region.cc,
* scribo/demo/viewer/image_region.hh,
* scribo/demo/viewer/image_region.hxx,
* scribo/demo/viewer/image_scene.cc,
* scribo/demo/viewer/image_view.cc,
* scribo/demo/viewer/image_widget.cc,
* scribo/demo/viewer/image_widget.hh,
* scribo/demo/viewer/key_widget.cc,
* scribo/demo/viewer/key_widget.hh,
* scribo/demo/viewer/ocr_options.cc,
* scribo/demo/viewer/ocr_options.ui,
* scribo/demo/viewer/preferences_dialog.cc,
* scribo/demo/viewer/preferences_dialog.hh,
* scribo/demo/viewer/preferences_dialog.ui,
* scribo/demo/viewer/preprocessing_options.cc,
* scribo/demo/viewer/preprocessing_options.hh,
* scribo/demo/viewer/preprocessing_options.ui,
* scribo/demo/viewer/process.hh,
* scribo/demo/viewer/runner.cc,
* scribo/demo/viewer/runner.hh,
* scribo/demo/viewer/segmentation_options.cc,
* scribo/demo/viewer/segmentation_options.hh,
* scribo/demo/viewer/segmentation_options.ui,
* scribo/demo/viewer/step_widget.cc,
* scribo/demo/viewer/step_widget.hh,
* scribo/demo/viewer/viewer.cc,
* scribo/demo/viewer/viewer.hh,
* scribo/demo/viewer/viewer.hxx,
* scribo/demo/viewer/viewer.qrc ,
* scribo/demo/viewer/xml_widget.cc,
* scribo/demo/viewer/xml_widget.hh: Remove.
---
ChangeLog | 80 ++
GScribo/GScribo.pro | 83 --
GScribo/PagesWidget/pagesdelegate.cpp | 20 -
GScribo/PagesWidget/pagesdelegate.h | 18 -
GScribo/PagesWidget/pagesmodel.cpp | 55 --
GScribo/PagesWidget/pagesmodel.h | 43 -
GScribo/PagesWidget/pageswidget.cpp | 49 -
GScribo/PagesWidget/pageswidget.h | 55 --
GScribo/Preferences/generaloptions.cpp | 44 -
GScribo/Preferences/generaloptions.h | 34 -
GScribo/Preferences/ocroptions.cpp | 53 -
GScribo/Preferences/ocroptions.h | 33 -
GScribo/Preferences/preferencesdialog.cpp | 98 --
GScribo/Preferences/preferencesdialog.h | 42 -
GScribo/Preferences/preprocessingoptions.cpp | 45 -
GScribo/Preferences/preprocessingoptions.h | 32 -
GScribo/Preferences/segmentationoptions.cpp | 33 -
GScribo/Preferences/segmentationoptions.h | 31 -
GScribo/Processing/preprocess.cpp | 11 -
GScribo/Processing/preprocess.h | 26 -
GScribo/Processing/process.cpp | 21 -
GScribo/Processing/process.h | 29 -
GScribo/Processing/progressdialog.cpp | 16 -
GScribo/Processing/progressdialog.h | 22 -
GScribo/Processing/runner.cpp | 183 ----
GScribo/Processing/runner.h | 58 --
GScribo/Rendering/graphicsview.cpp | 150 ---
GScribo/Rendering/graphicsview.h | 43 -
GScribo/Rendering/regionitem.cpp | 59 --
GScribo/Rendering/regionitem.h | 80 --
GScribo/Rendering/rootgraphicsitem.h | 30 -
GScribo/Rendering/scene.cpp | 273 ------
GScribo/Rendering/scene.h | 118 ---
GScribo/Rendering/selection.cpp | 36 -
GScribo/XmlWidget/attributesmodel.cpp | 69 --
GScribo/XmlWidget/attributesmodel.h | 48 -
GScribo/XmlWidget/selectionproxy.h | 47 -
GScribo/XmlWidget/xmlattributes.cpp | 23 -
GScribo/XmlWidget/xmlattributes.h | 33 -
GScribo/XmlWidget/xmlitem.cpp | 43 -
GScribo/XmlWidget/xmlitem.h | 90 --
GScribo/XmlWidget/xmlmodel.cpp | 87 --
GScribo/XmlWidget/xmlmodel.h | 44 -
GScribo/XmlWidget/xmlview.cpp | 88 --
GScribo/XmlWidget/xmlview.h | 79 --
GScribo/XmlWidget/xmlwidget.cpp | 34 -
GScribo/XmlWidget/xmlwidget.h | 54 -
GScribo/aboutdialog.h | 25 -
GScribo/aboutdialog.ui | 136 ---
GScribo/configs.h | 134 ---
GScribo/dockwidget.h | 22 -
GScribo/main.cpp | 23 -
GScribo/mainwindow.cpp | 415 --------
GScribo/mainwindow.h | 120 ---
GScribo/region.h | 56 --
GScribo/regionwidget.cpp | 70 --
GScribo/regionwidget.h | 40 -
GScribo/variantpointer.h | 19 -
GScribo/xml.cpp | 206 ----
GScribo/xml.h | 93 --
scribo/ChangeLog | 142 +++
{GScribo => scribo/demo/viewer}/BUGS | 0
scribo/demo/viewer/GScribo.pro | 83 ++
{GScribo => scribo/demo/viewer}/GScribo.pro.user | 0
.../demo/viewer}/GScribo.pro.user.1.3 | 0
scribo/demo/viewer/Makefile.am | 204 +++--
scribo/demo/viewer/PagesWidget/pagesdelegate.cc | 38 +
scribo/demo/viewer/PagesWidget/pagesdelegate.hh | 36 +
scribo/demo/viewer/PagesWidget/pagesmodel.cc | 91 ++
scribo/demo/viewer/PagesWidget/pagesmodel.hh | 51 +
scribo/demo/viewer/PagesWidget/pageswidget.cc | 119 +++
scribo/demo/viewer/PagesWidget/pageswidget.hh | 61 ++
scribo/demo/viewer/Preferences/generaloptions.cc | 60 ++
scribo/demo/viewer/Preferences/generaloptions.hh | 50 +
.../demo/viewer}/Preferences/generaloptions.ui | 0
scribo/demo/viewer/Preferences/ocroptions.cc | 69 ++
scribo/demo/viewer/Preferences/ocroptions.hh | 49 +
.../demo/viewer}/Preferences/ocroptions.ui | 0
.../demo/viewer/Preferences/optionwidget.hh | 0
.../demo/viewer/Preferences/preferencesdialog.cc | 120 +++
.../demo/viewer/Preferences/preferencesdialog.hh | 55 ++
.../demo/viewer}/Preferences/preferencesdialog.ui | 0
.../viewer/Preferences/preprocessingoptions.cc | 61 ++
.../viewer/Preferences/preprocessingoptions.hh | 48 +
.../viewer}/Preferences/preprocessingoptions.ui | 0
.../demo/viewer/Preferences/segmentationoptions.cc | 49 +
.../demo/viewer/Preferences/segmentationoptions.hh | 46 +
.../viewer}/Preferences/segmentationoptions.ui | 0
scribo/demo/viewer/Processing/preprocess.cc | 27 +
scribo/demo/viewer/Processing/preprocess.hh | 42 +
scribo/demo/viewer/Processing/process.cc | 37 +
scribo/demo/viewer/Processing/process.hh | 45 +
scribo/demo/viewer/Processing/progressdialog.cc | 37 +
scribo/demo/viewer/Processing/progressdialog.hh | 36 +
scribo/demo/viewer/Processing/runner.cc | 199 ++++
scribo/demo/viewer/Processing/runner.hh | 74 ++
scribo/demo/viewer/README | 32 -
.../demo/viewer/Rendering/abstractregionitem.hh | 0
.../demo/viewer/Rendering/backgroundtexture.hh | 0
scribo/demo/viewer/Rendering/graphicsview.cc | 165 ++++
scribo/demo/viewer/Rendering/graphicsview.hh | 59 ++
scribo/demo/viewer/Rendering/regionitem.cc | 130 +++
scribo/demo/viewer/Rendering/regionitem.hh | 66 ++
scribo/demo/viewer/Rendering/rootgraphicsitem.cc | 46 +
scribo/demo/viewer/Rendering/rootgraphicsitem.hh | 39 +
scribo/demo/viewer/Rendering/scene.cc | 289 ++++++
scribo/demo/viewer/Rendering/scene.hh | 118 +++
scribo/demo/viewer/Rendering/selection.cc | 52 +
.../demo/viewer/Rendering/selection.hh | 0
{GScribo => scribo/demo/viewer}/TODO | 0
scribo/demo/viewer/XmlWidget/attributesmodel.cc | 108 ++
scribo/demo/viewer/XmlWidget/attributesmodel.hh | 55 ++
scribo/demo/viewer/XmlWidget/selectionproxy.hh | 47 +
scribo/demo/viewer/XmlWidget/xmlattributes.cc | 49 +
scribo/demo/viewer/XmlWidget/xmlattributes.hh | 44 +
.../demo/viewer/XmlWidget/xmldelegate.hh | 0
scribo/demo/viewer/XmlWidget/xmlitem.cc | 59 ++
scribo/demo/viewer/XmlWidget/xmlitem.hh | 106 ++
scribo/demo/viewer/XmlWidget/xmlmodel.cc | 123 +++
scribo/demo/viewer/XmlWidget/xmlmodel.hh | 51 +
scribo/demo/viewer/XmlWidget/xmlview.cc | 104 ++
scribo/demo/viewer/XmlWidget/xmlview.hh | 95 ++
scribo/demo/viewer/XmlWidget/xmlwidget.cc | 66 ++
scribo/demo/viewer/XmlWidget/xmlwidget.hh | 61 ++
scribo/demo/viewer/aboutdialog.cc | 31 +
scribo/demo/viewer/aboutdialog.hh | 40 +
scribo/demo/viewer/aboutdialog.ui | 136 +++
scribo/demo/viewer/browser_widget.cc | 138 ---
scribo/demo/viewer/browser_widget.hh | 50 -
scribo/demo/viewer/common.hh | 73 --
scribo/demo/viewer/config.cc | 182 ----
scribo/demo/viewer/config.hh | 78 --
scribo/demo/viewer/configs.cc | 149 +++
scribo/demo/viewer/configs.hh | 74 ++
scribo/demo/viewer/defs.hh | 31 -
GScribo/dir.h => scribo/demo/viewer/dir.hh | 0
scribo/demo/viewer/dockwidget.cc | 34 +
scribo/demo/viewer/dockwidget.hh | 36 +
scribo/demo/viewer/general_options.cc | 60 --
scribo/demo/viewer/general_options.hh | 40 -
scribo/demo/viewer/general_options.ui | 100 --
scribo/demo/viewer/help_dialog.cc | 23 -
scribo/demo/viewer/help_dialog.hh | 31 -
scribo/demo/viewer/help_dialog.ui | 138 ---
scribo/demo/viewer/icons/olena_smaller.jpg | Bin 8028 -> 0 bytes
scribo/demo/viewer/image_region.cc | 138 ---
scribo/demo/viewer/image_region.hh | 81 --
scribo/demo/viewer/image_region.hxx | 106 --
scribo/demo/viewer/image_scene.cc | 104 --
scribo/demo/viewer/image_scene.hh | 45 -
scribo/demo/viewer/image_view.cc | 81 --
scribo/demo/viewer/image_view.hh | 42 -
scribo/demo/viewer/image_widget.cc | 61 --
scribo/demo/viewer/image_widget.hh | 47 -
scribo/demo/viewer/key_widget.cc | 162 ---
scribo/demo/viewer/key_widget.hh | 55 --
scribo/demo/viewer/main.cc | 41 +-
scribo/demo/viewer/mainwindow.cc | 496 ++++++++++
scribo/demo/viewer/mainwindow.hh | 130 +++
{GScribo => scribo/demo/viewer}/mainwindow.ui | 0
scribo/demo/viewer/ocr_options.cc | 74 --
scribo/demo/viewer/ocr_options.hh | 40 -
scribo/demo/viewer/ocr_options.ui | 62 --
scribo/demo/viewer/option_widget.cc | 30 -
scribo/demo/viewer/option_widget.hh | 30 -
scribo/demo/viewer/preferences_dialog.cc | 129 ---
scribo/demo/viewer/preferences_dialog.hh | 45 -
scribo/demo/viewer/preferences_dialog.ui | 121 ---
scribo/demo/viewer/preprocess.cc | 29 -
scribo/demo/viewer/preprocess.hh | 41 -
scribo/demo/viewer/preprocessing_options.cc | 66 --
scribo/demo/viewer/preprocessing_options.hh | 38 -
scribo/demo/viewer/preprocessing_options.ui | 76 --
scribo/demo/viewer/process.cc | 42 -
scribo/demo/viewer/process.hh | 46 -
scribo/demo/viewer/region.hh | 72 ++
scribo/demo/viewer/regionwidget.cc | 114 +++
scribo/demo/viewer/regionwidget.hh | 58 ++
scribo/demo/viewer/runner.cc | 243 -----
scribo/demo/viewer/runner.hh | 73 --
scribo/demo/viewer/segmentation_options.cc | 56 --
scribo/demo/viewer/segmentation_options.hh | 37 -
scribo/demo/viewer/segmentation_options.ui | 52 -
scribo/demo/viewer/step_widget.cc | 178 ----
scribo/demo/viewer/step_widget.hh | 56 --
scribo/demo/viewer/variantpointer.cc | 39 +
scribo/demo/viewer/variantpointer.hh | 33 +
scribo/demo/viewer/viewer.cc | 1021 --------------------
scribo/demo/viewer/viewer.hh | 132 ---
scribo/demo/viewer/viewer.hxx | 38 -
scribo/demo/viewer/viewer.qrc | 5 -
scribo/demo/viewer/xml.cc | 253 +++++
scribo/demo/viewer/xml.hh | 91 ++
scribo/demo/viewer/xml_widget.cc | 164 ----
scribo/demo/viewer/xml_widget.hh | 48 -
195 files changed, 5662 insertions(+), 8997 deletions(-)
delete mode 100644 GScribo/GScribo.pro
delete mode 100644 GScribo/PagesWidget/pagesdelegate.cpp
delete mode 100644 GScribo/PagesWidget/pagesdelegate.h
delete mode 100644 GScribo/PagesWidget/pagesmodel.cpp
delete mode 100644 GScribo/PagesWidget/pagesmodel.h
delete mode 100644 GScribo/PagesWidget/pageswidget.cpp
delete mode 100644 GScribo/PagesWidget/pageswidget.h
delete mode 100644 GScribo/Preferences/generaloptions.cpp
delete mode 100644 GScribo/Preferences/generaloptions.h
delete mode 100644 GScribo/Preferences/ocroptions.cpp
delete mode 100644 GScribo/Preferences/ocroptions.h
delete mode 100644 GScribo/Preferences/preferencesdialog.cpp
delete mode 100644 GScribo/Preferences/preferencesdialog.h
delete mode 100644 GScribo/Preferences/preprocessingoptions.cpp
delete mode 100644 GScribo/Preferences/preprocessingoptions.h
delete mode 100644 GScribo/Preferences/segmentationoptions.cpp
delete mode 100644 GScribo/Preferences/segmentationoptions.h
delete mode 100644 GScribo/Processing/preprocess.cpp
delete mode 100644 GScribo/Processing/preprocess.h
delete mode 100644 GScribo/Processing/process.cpp
delete mode 100644 GScribo/Processing/process.h
delete mode 100644 GScribo/Processing/progressdialog.cpp
delete mode 100644 GScribo/Processing/progressdialog.h
delete mode 100644 GScribo/Processing/runner.cpp
delete mode 100644 GScribo/Processing/runner.h
delete mode 100644 GScribo/Rendering/graphicsview.cpp
delete mode 100644 GScribo/Rendering/graphicsview.h
delete mode 100644 GScribo/Rendering/regionitem.cpp
delete mode 100644 GScribo/Rendering/regionitem.h
delete mode 100644 GScribo/Rendering/rootgraphicsitem.h
delete mode 100644 GScribo/Rendering/scene.cpp
delete mode 100644 GScribo/Rendering/scene.h
delete mode 100644 GScribo/Rendering/selection.cpp
delete mode 100644 GScribo/XmlWidget/attributesmodel.cpp
delete mode 100644 GScribo/XmlWidget/attributesmodel.h
delete mode 100644 GScribo/XmlWidget/selectionproxy.h
delete mode 100644 GScribo/XmlWidget/xmlattributes.cpp
delete mode 100644 GScribo/XmlWidget/xmlattributes.h
delete mode 100644 GScribo/XmlWidget/xmlitem.cpp
delete mode 100644 GScribo/XmlWidget/xmlitem.h
delete mode 100644 GScribo/XmlWidget/xmlmodel.cpp
delete mode 100644 GScribo/XmlWidget/xmlmodel.h
delete mode 100644 GScribo/XmlWidget/xmlview.cpp
delete mode 100644 GScribo/XmlWidget/xmlview.h
delete mode 100644 GScribo/XmlWidget/xmlwidget.cpp
delete mode 100644 GScribo/XmlWidget/xmlwidget.h
delete mode 100644 GScribo/aboutdialog.h
delete mode 100644 GScribo/aboutdialog.ui
delete mode 100644 GScribo/configs.h
delete mode 100644 GScribo/dockwidget.h
delete mode 100644 GScribo/main.cpp
delete mode 100644 GScribo/mainwindow.cpp
delete mode 100644 GScribo/mainwindow.h
delete mode 100644 GScribo/region.h
delete mode 100644 GScribo/regionwidget.cpp
delete mode 100644 GScribo/regionwidget.h
delete mode 100644 GScribo/variantpointer.h
delete mode 100644 GScribo/xml.cpp
delete mode 100644 GScribo/xml.h
rename {GScribo => scribo/demo/viewer}/BUGS (100%)
create mode 100644 scribo/demo/viewer/GScribo.pro
rename {GScribo => scribo/demo/viewer}/GScribo.pro.user (100%)
rename {GScribo => scribo/demo/viewer}/GScribo.pro.user.1.3 (100%)
create mode 100644 scribo/demo/viewer/PagesWidget/pagesdelegate.cc
create mode 100644 scribo/demo/viewer/PagesWidget/pagesdelegate.hh
create mode 100644 scribo/demo/viewer/PagesWidget/pagesmodel.cc
create mode 100644 scribo/demo/viewer/PagesWidget/pagesmodel.hh
create mode 100644 scribo/demo/viewer/PagesWidget/pageswidget.cc
create mode 100644 scribo/demo/viewer/PagesWidget/pageswidget.hh
create mode 100644 scribo/demo/viewer/Preferences/generaloptions.cc
create mode 100644 scribo/demo/viewer/Preferences/generaloptions.hh
rename {GScribo => scribo/demo/viewer}/Preferences/generaloptions.ui (100%)
create mode 100644 scribo/demo/viewer/Preferences/ocroptions.cc
create mode 100644 scribo/demo/viewer/Preferences/ocroptions.hh
rename {GScribo => scribo/demo/viewer}/Preferences/ocroptions.ui (100%)
rename GScribo/Preferences/optionwidget.h => scribo/demo/viewer/Preferences/optionwidget.hh (100%)
create mode 100644 scribo/demo/viewer/Preferences/preferencesdialog.cc
create mode 100644 scribo/demo/viewer/Preferences/preferencesdialog.hh
rename {GScribo => scribo/demo/viewer}/Preferences/preferencesdialog.ui (100%)
create mode 100644 scribo/demo/viewer/Preferences/preprocessingoptions.cc
create mode 100644 scribo/demo/viewer/Preferences/preprocessingoptions.hh
rename {GScribo => scribo/demo/viewer}/Preferences/preprocessingoptions.ui (100%)
create mode 100644 scribo/demo/viewer/Preferences/segmentationoptions.cc
create mode 100644 scribo/demo/viewer/Preferences/segmentationoptions.hh
rename {GScribo => scribo/demo/viewer}/Preferences/segmentationoptions.ui (100%)
create mode 100644 scribo/demo/viewer/Processing/preprocess.cc
create mode 100644 scribo/demo/viewer/Processing/preprocess.hh
create mode 100644 scribo/demo/viewer/Processing/process.cc
create mode 100644 scribo/demo/viewer/Processing/process.hh
create mode 100644 scribo/demo/viewer/Processing/progressdialog.cc
create mode 100644 scribo/demo/viewer/Processing/progressdialog.hh
create mode 100644 scribo/demo/viewer/Processing/runner.cc
create mode 100644 scribo/demo/viewer/Processing/runner.hh
delete mode 100644 scribo/demo/viewer/README
rename GScribo/Rendering/abstractregionitem.h => scribo/demo/viewer/Rendering/abstractregionitem.hh (100%)
rename GScribo/Rendering/backgroundtexture.h => scribo/demo/viewer/Rendering/backgroundtexture.hh (100%)
create mode 100644 scribo/demo/viewer/Rendering/graphicsview.cc
create mode 100644 scribo/demo/viewer/Rendering/graphicsview.hh
create mode 100644 scribo/demo/viewer/Rendering/regionitem.cc
create mode 100644 scribo/demo/viewer/Rendering/regionitem.hh
create mode 100644 scribo/demo/viewer/Rendering/rootgraphicsitem.cc
create mode 100644 scribo/demo/viewer/Rendering/rootgraphicsitem.hh
create mode 100644 scribo/demo/viewer/Rendering/scene.cc
create mode 100644 scribo/demo/viewer/Rendering/scene.hh
create mode 100644 scribo/demo/viewer/Rendering/selection.cc
rename GScribo/Rendering/selection.h => scribo/demo/viewer/Rendering/selection.hh (100%)
rename {GScribo => scribo/demo/viewer}/TODO (100%)
create mode 100644 scribo/demo/viewer/XmlWidget/attributesmodel.cc
create mode 100644 scribo/demo/viewer/XmlWidget/attributesmodel.hh
create mode 100644 scribo/demo/viewer/XmlWidget/selectionproxy.hh
create mode 100644 scribo/demo/viewer/XmlWidget/xmlattributes.cc
create mode 100644 scribo/demo/viewer/XmlWidget/xmlattributes.hh
rename GScribo/XmlWidget/xmldelegate.h => scribo/demo/viewer/XmlWidget/xmldelegate.hh (100%)
create mode 100644 scribo/demo/viewer/XmlWidget/xmlitem.cc
create mode 100644 scribo/demo/viewer/XmlWidget/xmlitem.hh
create mode 100644 scribo/demo/viewer/XmlWidget/xmlmodel.cc
create mode 100644 scribo/demo/viewer/XmlWidget/xmlmodel.hh
create mode 100644 scribo/demo/viewer/XmlWidget/xmlview.cc
create mode 100644 scribo/demo/viewer/XmlWidget/xmlview.hh
create mode 100644 scribo/demo/viewer/XmlWidget/xmlwidget.cc
create mode 100644 scribo/demo/viewer/XmlWidget/xmlwidget.hh
create mode 100644 scribo/demo/viewer/aboutdialog.cc
create mode 100644 scribo/demo/viewer/aboutdialog.hh
create mode 100644 scribo/demo/viewer/aboutdialog.ui
delete mode 100644 scribo/demo/viewer/browser_widget.cc
delete mode 100644 scribo/demo/viewer/browser_widget.hh
delete mode 100644 scribo/demo/viewer/common.hh
delete mode 100644 scribo/demo/viewer/config.cc
delete mode 100644 scribo/demo/viewer/config.hh
create mode 100644 scribo/demo/viewer/configs.cc
create mode 100644 scribo/demo/viewer/configs.hh
delete mode 100644 scribo/demo/viewer/defs.hh
rename GScribo/dir.h => scribo/demo/viewer/dir.hh (100%)
create mode 100644 scribo/demo/viewer/dockwidget.cc
create mode 100644 scribo/demo/viewer/dockwidget.hh
delete mode 100644 scribo/demo/viewer/general_options.cc
delete mode 100644 scribo/demo/viewer/general_options.hh
delete mode 100644 scribo/demo/viewer/general_options.ui
delete mode 100644 scribo/demo/viewer/help_dialog.cc
delete mode 100644 scribo/demo/viewer/help_dialog.hh
delete mode 100644 scribo/demo/viewer/help_dialog.ui
delete mode 100644 scribo/demo/viewer/icons/olena_smaller.jpg
delete mode 100644 scribo/demo/viewer/image_region.cc
delete mode 100644 scribo/demo/viewer/image_region.hh
delete mode 100644 scribo/demo/viewer/image_region.hxx
delete mode 100644 scribo/demo/viewer/image_scene.cc
delete mode 100644 scribo/demo/viewer/image_scene.hh
delete mode 100644 scribo/demo/viewer/image_view.cc
delete mode 100644 scribo/demo/viewer/image_view.hh
delete mode 100644 scribo/demo/viewer/image_widget.cc
delete mode 100644 scribo/demo/viewer/image_widget.hh
delete mode 100644 scribo/demo/viewer/key_widget.cc
delete mode 100644 scribo/demo/viewer/key_widget.hh
create mode 100644 scribo/demo/viewer/mainwindow.cc
create mode 100644 scribo/demo/viewer/mainwindow.hh
rename {GScribo => scribo/demo/viewer}/mainwindow.ui (100%)
delete mode 100644 scribo/demo/viewer/ocr_options.cc
delete mode 100644 scribo/demo/viewer/ocr_options.hh
delete mode 100644 scribo/demo/viewer/ocr_options.ui
delete mode 100644 scribo/demo/viewer/option_widget.cc
delete mode 100644 scribo/demo/viewer/option_widget.hh
delete mode 100644 scribo/demo/viewer/preferences_dialog.cc
delete mode 100644 scribo/demo/viewer/preferences_dialog.hh
delete mode 100644 scribo/demo/viewer/preferences_dialog.ui
delete mode 100644 scribo/demo/viewer/preprocess.cc
delete mode 100644 scribo/demo/viewer/preprocess.hh
delete mode 100644 scribo/demo/viewer/preprocessing_options.cc
delete mode 100644 scribo/demo/viewer/preprocessing_options.hh
delete mode 100644 scribo/demo/viewer/preprocessing_options.ui
delete mode 100644 scribo/demo/viewer/process.cc
delete mode 100644 scribo/demo/viewer/process.hh
create mode 100644 scribo/demo/viewer/region.hh
create mode 100644 scribo/demo/viewer/regionwidget.cc
create mode 100644 scribo/demo/viewer/regionwidget.hh
delete mode 100644 scribo/demo/viewer/runner.cc
delete mode 100644 scribo/demo/viewer/runner.hh
delete mode 100644 scribo/demo/viewer/segmentation_options.cc
delete mode 100644 scribo/demo/viewer/segmentation_options.hh
delete mode 100644 scribo/demo/viewer/segmentation_options.ui
delete mode 100644 scribo/demo/viewer/step_widget.cc
delete mode 100644 scribo/demo/viewer/step_widget.hh
create mode 100644 scribo/demo/viewer/variantpointer.cc
create mode 100644 scribo/demo/viewer/variantpointer.hh
delete mode 100644 scribo/demo/viewer/viewer.cc
delete mode 100644 scribo/demo/viewer/viewer.hh
delete mode 100644 scribo/demo/viewer/viewer.hxx
delete mode 100644 scribo/demo/viewer/viewer.qrc
create mode 100644 scribo/demo/viewer/xml.cc
create mode 100644 scribo/demo/viewer/xml.hh
delete mode 100644 scribo/demo/viewer/xml_widget.cc
delete mode 100644 scribo/demo/viewer/xml_widget.hh
diff --git a/ChangeLog b/ChangeLog
index b47e5a1..841926a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,83 @@
+2013-02-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Move new viewer to scribo/demo.
+
+ * GScribo/BUGS,
+ * GScribo/GScribo.pro,
+ * GScribo/GScribo.pro.user,
+ * GScribo/GScribo.pro.user.1.3,
+ * GScribo/PagesWidget/pagesdelegate.cpp,
+ * GScribo/PagesWidget/pagesdelegate.h,
+ * GScribo/PagesWidget/pagesmodel.cpp,
+ * GScribo/PagesWidget/pagesmodel.h,
+ * GScribo/PagesWidget/pageswidget.cpp,
+ * GScribo/PagesWidget/pageswidget.h,
+ * GScribo/Preferences/generaloptions.cpp,
+ * GScribo/Preferences/generaloptions.h,
+ * GScribo/Preferences/generaloptions.ui,
+ * GScribo/Preferences/ocroptions.cpp,
+ * GScribo/Preferences/ocroptions.h,
+ * GScribo/Preferences/ocroptions.ui,
+ * GScribo/Preferences/optionwidget.h,
+ * GScribo/Preferences/preferencesdialog.cpp,
+ * GScribo/Preferences/preferencesdialog.h,
+ * GScribo/Preferences/preferencesdialog.ui,
+ * GScribo/Preferences/preprocessingoptions.cpp,
+ * GScribo/Preferences/preprocessingoptions.h,
+ * GScribo/Preferences/preprocessingoptions.ui,
+ * GScribo/Preferences/segmentationoptions.cpp,
+ * GScribo/Preferences/segmentationoptions.h,
+ * GScribo/Preferences/segmentationoptions.ui,
+ * GScribo/Processing/preprocess.cpp,
+ * GScribo/Processing/preprocess.h,
+ * GScribo/Processing/process.cpp,
+ * GScribo/Processing/process.h,
+ * GScribo/Processing/progressdialog.cpp,
+ * GScribo/Processing/progressdialog.h,
+ * GScribo/Processing/runner.cpp,
+ * GScribo/Processing/runner.h,
+ * GScribo/Rendering/abstractregionitem.h,
+ * GScribo/Rendering/backgroundtexture.h,
+ * GScribo/Rendering/graphicsview.cpp,
+ * GScribo/Rendering/graphicsview.h,
+ * GScribo/Rendering/regionitem.cpp,
+ * GScribo/Rendering/regionitem.h,
+ * GScribo/Rendering/rootgraphicsitem.h,
+ * GScribo/Rendering/scene.cpp,
+ * GScribo/Rendering/scene.h,
+ * GScribo/Rendering/selection.cpp,
+ * GScribo/Rendering/selection.h,
+ * GScribo/TODO,
+ * GScribo/XmlWidget/attributesmodel.cpp,
+ * GScribo/XmlWidget/attributesmodel.h,
+ * GScribo/XmlWidget/selectionproxy.h,
+ * GScribo/XmlWidget/xmlattributes.cpp,
+ * GScribo/XmlWidget/xmlattributes.h,
+ * GScribo/XmlWidget/xmldelegate.h,
+ * GScribo/XmlWidget/xmlitem.cpp,
+ * GScribo/XmlWidget/xmlitem.h,
+ * GScribo/XmlWidget/xmlmodel.cpp,
+ * GScribo/XmlWidget/xmlmodel.h,
+ * GScribo/XmlWidget/xmlview.cpp,
+ * GScribo/XmlWidget/xmlview.h,
+ * GScribo/XmlWidget/xmlwidget.cpp,
+ * GScribo/XmlWidget/xmlwidget.h,
+ * GScribo/aboutdialog.h,
+ * GScribo/aboutdialog.ui,
+ * GScribo/configs.h,
+ * GScribo/dir.h,
+ * GScribo/dockwidget.h,
+ * GScribo/main.cpp,
+ * GScribo/mainwindow.cpp,
+ * GScribo/mainwindow.h,
+ * GScribo/mainwindow.ui,
+ * GScribo/region.h,
+ * GScribo/regionwidget.cpp,
+ * GScribo/regionwidget.h,
+ * GScribo/variantpointer.h,
+ * GScribo/xml.cpp,
+ * GScribo/xml.h: Move to scribo/demo.
+
2013-04-17 Guillaume Lazzara <z(a)lrde.epita.fr>
* doc/Makefile.am: Fix a link in documentations generated with
diff --git a/GScribo/GScribo.pro b/GScribo/GScribo.pro
deleted file mode 100644
index 1495495..0000000
--- a/GScribo/GScribo.pro
+++ /dev/null
@@ -1,83 +0,0 @@
-# -------------------------------------------------
-# Project created by QtCreator 2013-01-21T09:20:54
-# -------------------------------------------------
-QT += xml
-INCLUDEPATH += /lrde/home/stage/froger_a/olena/scribo/ \
- /lrde/home/stage/froger_a/olena/milena/ \
- /lrde/home/stage/froger_a/olena/_build/scribo/demo/
-QMAKE_CXXFLAGS += -DNDEBUG \
- -DMLN_WO_GLOBAL_VARS
-LIBS += -I/usr/include/graphicsImage \
- -lGraphicsMagick++ \
- -ltesseract_full \
- -ltiff
-TARGET = GScribo
-TEMPLATE = app
-SOURCES += regionwidget.cpp \
- mainwindow.cpp \
- main.cpp \
- xml.cpp \
- Rendering/scene.cpp \
- Rendering/selection.cpp \
- Rendering/regionitem.cpp \
- Rendering/graphicsview.cpp \
- PagesWidget/pageswidget.cpp \
- PagesWidget/pagesmodel.cpp \
- PagesWidget/pagesdelegate.cpp \
- Preferences/segmentationoptions.cpp \
- Preferences/preprocessingoptions.cpp \
- Preferences/ocroptions.cpp \
- Preferences/generaloptions.cpp \
- Preferences/preferencesdialog.cpp \
- Processing/progressdialog.cpp \
- Processing/preprocess.cpp \
- Processing/process.cpp \
- Processing/runner.cpp \
- XmlWidget/xmlwidget.cpp \
- XmlWidget/xmlmodel.cpp \
- XmlWidget/xmlitem.cpp \
- XmlWidget/xmlattributes.cpp \
- XmlWidget/attributesmodel.cpp \
- XmlWidget/xmlview.cpp
-HEADERS += mainwindow.h \
- variantpointer.h \
- regionwidget.h \
- aboutdialog.h \
- configs.h \
- region.h \
- dir.h \
- xml.h \
- Rendering/scene.h \
- Rendering/selection.h \
- Rendering/regionitem.h \
- Rendering/graphicsview.h \
- PagesWidget/pageswidget.h \
- PagesWidget/pagesmodel.h \
- Processing/preprocess.h \
- Processing/process.h \
- Processing/runner.h \
- Processing/progressdialog.h \
- Preferences/segmentationoptions.h \
- Preferences/preprocessingoptions.h \
- Preferences/ocroptions.h \
- Preferences/generaloptions.h \
- Preferences/optionwidget.h \
- Preferences/preferencesdialog.h \
- XmlWidget/xmlwidget.h \
- XmlWidget/xmlmodel.h \
- XmlWidget/xmlitem.h \
- XmlWidget/xmlattributes.h \
- XmlWidget/selectionproxy.h \
- XmlWidget/xmldelegate.h \
- XmlWidget/attributesmodel.h \
- PagesWidget/pagesdelegate.h \
- Rendering/rootgraphicsitem.h \
- XmlWidget/xmlview.h \
- dockwidget.h
-FORMS += mainwindow.ui \
- aboutdialog.ui \
- Preferences/preferencesdialog.ui \
- Preferences/ocroptions.ui \
- Preferences/segmentationoptions.ui \
- Preferences/generaloptions.ui \
- Preferences/preprocessingoptions.ui
diff --git a/GScribo/PagesWidget/pagesdelegate.cpp b/GScribo/PagesWidget/pagesdelegate.cpp
deleted file mode 100644
index 19a34c2..0000000
--- a/GScribo/PagesWidget/pagesdelegate.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "pagesdelegate.h"
-
-PagesDelegate::PagesDelegate(QObject *parent) :
- QStyledItemDelegate(parent)
-{
- pen_.setColor(QColor::fromRgb(255, 69, 0, 255));
- pen_.setWidth(2);
-}
-
-void PagesDelegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
-{
- QStyledItemDelegate::paint(painter, option, index);
-
- if(index.row() == index.data(Qt::UserRole+1).toInt())
- {
- painter->setPen(pen_);
- painter->drawRect(option.rect);
- painter->fillRect(option.rect, QColor::fromRgb(255, 69, 0, 60));
- }
-}
diff --git a/GScribo/PagesWidget/pagesdelegate.h b/GScribo/PagesWidget/pagesdelegate.h
deleted file mode 100644
index ff422ca..0000000
--- a/GScribo/PagesWidget/pagesdelegate.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef PAGESDELEGATE_H
-#define PAGESDELEGATE_H
-
-#include <QStyledItemDelegate>
-#include <QPainter>
-
-class PagesDelegate :
- public QStyledItemDelegate
-{
- public:
- explicit PagesDelegate(QObject *parent = 0);
- void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
-
- private:
- QPen pen_;
-};
-
-#endif // PAGESDELEGATE_H
diff --git a/GScribo/PagesWidget/pagesmodel.cpp b/GScribo/PagesWidget/pagesmodel.cpp
deleted file mode 100644
index faccb74..0000000
--- a/GScribo/PagesWidget/pagesmodel.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-#include "pagesmodel.h"
-
-PagesModel::PagesModel(QObject *parent):
- QAbstractListModel(parent)
-{
- currentRow_ = 0;
-}
-
-QVariant PagesModel::data(const QModelIndex& index, int role) const
-{
- if(!index.isValid())
- return QVariant();
-
- if(role == Qt::DecorationRole)
- return pixmaps_[index.row()];
-
- if(role == Qt::UserRole)
- return filenames_[index.row()];
-
- if(role == Qt::UserRole+1)
- return currentRow_;
-
- return QVariant();
-}
-
-void PagesModel::addPicture(const QString& filename, const QPixmap& pixmap)
-{
- beginInsertRows(QModelIndex(), 0, 0);
-
- pixmaps_.prepend(pixmap.scaled(QSize(200, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation));
- filenames_.prepend(filename);
-
- endInsertRows();
-}
-
-void PagesModel::removePixmap(const QModelIndex &parent)
-{
- int row = parent.row();
-
- beginRemoveRows(parent, row, row);
-
- pixmaps_.removeAt(row);
- filenames_.removeAt(row);
-
- endRemoveRows();
-}
-
-void PagesModel::setCurrentRow(int currentRow)
-{
- beginResetModel();
-
- currentRow_ = currentRow;
-
- endResetModel();
-}
diff --git a/GScribo/PagesWidget/pagesmodel.h b/GScribo/PagesWidget/pagesmodel.h
deleted file mode 100644
index 4c18842..0000000
--- a/GScribo/PagesWidget/pagesmodel.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef PAGESMODEL_H
-#define PAGESMODEL_H
-
-#include <QAbstractListModel>
-#include <QIcon>
-#include <QList>
-
-class PagesModel:
- public QAbstractListModel
-{
- Q_OBJECT
-
- public:
- explicit PagesModel(QObject *parent = 0);
-
- inline QStringList filenames() const;
- inline int rowCount(const QModelIndex& parent = QModelIndex()) const;
-
- inline int currentRow() const;
- void setCurrentRow(int currentRow);
-
- QVariant data(const QModelIndex& index, int role = Qt::DecorationRole) const;
- void addPicture(const QString& filename, const QPixmap& pixmap);
-
- private:
- QStringList filenames_;
- QList<QPixmap> pixmaps_;
- int currentRow_;
-
- public slots:
- void removePixmap(const QModelIndex& parent);
-};
-
-inline QStringList PagesModel::filenames() const
-{ return filenames_; }
-
-inline int PagesModel::rowCount(const QModelIndex&) const
-{ return filenames_.count(); }
-
-inline int PagesModel::currentRow() const
-{ return currentRow_; }
-
-#endif // PAGESMODEL_H
diff --git a/GScribo/PagesWidget/pageswidget.cpp b/GScribo/PagesWidget/pageswidget.cpp
deleted file mode 100644
index 400046a..0000000
--- a/GScribo/PagesWidget/pageswidget.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-#include "pageswidget.h"
-
-PagesWidget::PagesWidget(QWidget *parent):
- QListView(parent)
-{
- setUniformItemSizes(true);
- setSelectionMode(QAbstractItemView::ExtendedSelection);
- setViewMode(QListView::IconMode);
- setIconSize(QSize(200, 200));
- setMovement(QListView::Static);
- setResizeMode(QListView::Adjust);
- setSpacing(10);
-
- setModel(&model_);
- setItemDelegate(new PagesDelegate());
-
- QShortcut *remove = new QShortcut(Qt::Key_Delete, this);
- connect(remove, SIGNAL(activated()), this, SLOT(removeSelection()));
- connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(getPicture(QModelIndex)));
-}
-
-void PagesWidget::removeSelection()
-{
- QModelIndexList indexes = selectionModel()->selectedIndexes();
- if(hasFocus() && indexes.count() > 0)
- {
- // Sort the list because after the first removal, the second row index may not be the good one.
- qSort(indexes.begin(), indexes.end());
-
- // From the highest row to the smallest to be sure to remove the good index.
- for(int i = indexes.count()-1; i > -1; i--)
- model_.removePixmap(indexes[i]);
-
- // Draw new image on the scene.
- getPicture(model_.index(indexes[0].row()));
- clearSelection();
-
- model_.setCurrentRow(indexes[0].row());
- scrollTo(indexes[0]);
- }
-}
-
-void PagesWidget::getPicture(const QModelIndex& index)
-{
- QString filename = index.data(Qt::UserRole).toString();
- model_.setCurrentRow(index.row());
-
- emit imageSelectionned(filename);
-}
diff --git a/GScribo/PagesWidget/pageswidget.h b/GScribo/PagesWidget/pageswidget.h
deleted file mode 100644
index eb6488c..0000000
--- a/GScribo/PagesWidget/pageswidget.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef PAGESWIDGET_H
-#define PAGESWIDGET_H
-
-#include <QListView>
-#include <QShortcut>
-
-#include "pagesdelegate.h"
-#include "pagesmodel.h"
-
-class PagesWidget:
- public QListView
-{
- Q_OBJECT
-
- public:
- explicit PagesWidget(QWidget *parent = 0);
-
- inline QStringList filenames() const;
- inline int currentRow() const;
- inline void setCurrentRow(int currentRow);
-
- inline void addPicture(const QString& filename, const QPixmap& pixmap);
-
- protected:
- inline void focusOutEvent(QFocusEvent *event);
-
- private:
- PagesModel model_;
-
- public slots:
- void removeSelection();
-
- private slots:
- void getPicture(const QModelIndex& index);
-
- signals:
- void imageSelectionned(const QString& filename);
-};
-
-inline QStringList PagesWidget::filenames() const
-{ return model_.filenames(); }
-
-inline int PagesWidget::currentRow() const
-{ return model_.currentRow(); }
-
-inline void PagesWidget::setCurrentRow(int currentRow)
-{ model_.setCurrentRow(currentRow); }
-
-inline void PagesWidget::addPicture(const QString& filename, const QPixmap& pixmap)
-{ model_.addPicture(filename, pixmap); }
-
-inline void PagesWidget::focusOutEvent(QFocusEvent *event)
-{ QListView::focusOutEvent(event); clearSelection(); }
-
-#endif // PAGESWIDGET_H
diff --git a/GScribo/Preferences/generaloptions.cpp b/GScribo/Preferences/generaloptions.cpp
deleted file mode 100644
index 620a8fd..0000000
--- a/GScribo/Preferences/generaloptions.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "generaloptions.h"
-#include "ui_generaloptions.h"
-
-GeneralOptions::GeneralOptions(QWidget *parent) :
- OptionWidget(parent),
- ui(new Ui::GeneralOptions)
-{
- ui->setupUi(this);
- loadConfig();
-}
-
-GeneralOptions::~GeneralOptions()
-{
- delete ui;
-}
-
-void GeneralOptions::loadConfig()
-{
- Configs *const conf = Configs::getInstance();
-
- ui->saveXml->setChecked(conf->generalSaveXmlEnabled());
- ui->sameDir->setChecked(conf->generalSaveXmlSameDir());
- ui->customDir->setChecked(conf->generalSaveXmlCustomDir());
- ui->customDirValue->setText(conf->generalSaveXmlCustomDirPath());
-}
-
-
-void GeneralOptions::saveConfig()
-{
- Configs *const conf = Configs::getInstance();
-
- conf->setGeneralSaveXmlEnabled(ui->saveXml->isChecked());
- conf->setGeneralSaveXmlSameDir(ui->sameDir->isChecked());
- conf->setGeneralSaveXmlCustomDir(ui->customDir->isChecked());
- conf->setGeneralSaveXmlCustomDirPath(ui->customDirValue->text());
-}
-
-void GeneralOptions::onCustomDirBrowseBtnClicked()
-{
- QString dir = QFileDialog::getExistingDirectory(0, "Choose a directory");
-
- if (!dir.isEmpty())
- ui->customDirValue->setText(dir);
-}
diff --git a/GScribo/Preferences/generaloptions.h b/GScribo/Preferences/generaloptions.h
deleted file mode 100644
index 0c07129..0000000
--- a/GScribo/Preferences/generaloptions.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef GENERALOPTIONS_H
-#define GENERALOPTIONS_H
-
-#include <QFileDialog>
-
-#include "optionwidget.h"
-#include "configs.h"
-
-namespace Ui
-{
- class GeneralOptions;
-}
-
-class GeneralOptions :
- public OptionWidget
-{
- Q_OBJECT
-
- public:
- explicit GeneralOptions(QWidget *parent = 0);
- ~GeneralOptions();
-
- virtual void loadConfig();
- virtual void saveConfig();
-
- private:
- Ui::GeneralOptions *ui;
-
- private slots:
- void onCustomDirBrowseBtnClicked();
-
-};
-
-#endif // GENERAL_OPTIONS_H
diff --git a/GScribo/Preferences/ocroptions.cpp b/GScribo/Preferences/ocroptions.cpp
deleted file mode 100644
index fff05b2..0000000
--- a/GScribo/Preferences/ocroptions.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-#include "ocroptions.h"
-#include "ui_ocroptions.h"
-
-static const char *language[][2] =
-{
- { "English", "eng" },
- { "French", "fra" },
- { 0, 0 }
-};
-
-OcrOptions::OcrOptions(QWidget *parent) :
- OptionWidget(parent),
- ui(new Ui::OcrOptions)
-{
- ui->setupUi(this);
-
- for (unsigned i = 0; language[i][0]; ++i)
- ui->ocr_language->insertItem(i, language[i][0]);
-
- loadConfig();
-}
-
-OcrOptions::~OcrOptions()
-{
- delete ui;
-}
-
-int OcrOptions::findIndex(const QString& lang)
-{
- for (unsigned i = 0; language[i][0]; ++i)
- if (lang == language[i][1])
- return i;
-
- return 0;
-}
-
-
-void OcrOptions::loadConfig()
-{
- Configs *const conf = Configs::getInstance();
-
- ui->enable_ocr->setChecked(conf->ocrEnabled());
- ui->ocr_language->setCurrentIndex(findIndex(conf->ocrLanguage()));
-}
-
-
-void OcrOptions::saveConfig()
-{
- Configs *const conf = Configs::getInstance();
-
- conf->setOcrEnabled(ui->enable_ocr->isChecked());
- conf->setOcrLanguage(language[ui->ocr_language->currentIndex()][1]);
-}
diff --git a/GScribo/Preferences/ocroptions.h b/GScribo/Preferences/ocroptions.h
deleted file mode 100644
index 9ba8d53..0000000
--- a/GScribo/Preferences/ocroptions.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef OCR_OPTIONS_H
-#define OCR_OPTIONS_H
-
-//#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
-
-#include "optionwidget.h"
-#include "configs.h"
-#include "region.h"
-
-namespace Ui
-{
- class OcrOptions;
-}
-
-class OcrOptions :
- public OptionWidget
-{
- Q_OBJECT
-
- public:
- explicit OcrOptions(QWidget *parent = 0);
- ~OcrOptions();
-
- void loadConfig();
- void saveConfig();
-
- private:
- int findIndex(const QString& lang);
-
- Ui::OcrOptions *ui;
-};
-
-#endif // OCR_OPTIONS_H
diff --git a/GScribo/Preferences/preferencesdialog.cpp b/GScribo/Preferences/preferencesdialog.cpp
deleted file mode 100644
index 23a0dd6..0000000
--- a/GScribo/Preferences/preferencesdialog.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#include "preferencesdialog.h"
-#include "ui_preferencesdialog.h"
-
-PreferencesDialog::PreferencesDialog(QWidget *parent) :
- QDialog(parent, Qt::Dialog),
- ui(new Ui::PreferencesDialog)
-{
- ui->setupUi(this);
-
- // We may want to remove this useless object in the ui file.
- delete ui->widget;
-
- connect(ui->optionList, SIGNAL(currentRowChanged(int)), this, SLOT(onOptionListCurrentRowChanged(int)));
- setAttribute(Qt::WA_DeleteOnClose);
-
- loadOptionList();
- ui->optionList->setCurrentRow(0);
-}
-
-PreferencesDialog::~PreferencesDialog()
-{
- delete ui;
-}
-
-void PreferencesDialog::loadOptionList()
-{
- static const char *options[] = { "General", "Preprocessing", "Segmentation", "OCR", 0 };
-
- int i;
- for (i = 0; options[i]; ++i)
- ui->optionList->insertItem(i, options[i]);
-
- widgets.fill(0, i);
-}
-
-void PreferencesDialog::selectOptionWidget(int row)
-{
- if(!widgets[row])
- {
- QWidget *widget = 0;
-
- switch(row)
- {
- case 0:
- widget = new GeneralOptions(this);
- break;
-
- case 1:
- widget = new PreprocessingOptions(this);
- break;
-
- case 2:
- widget = new SegmentationOptions(this);
- break;
-
- case 3:
- widget = new OcrOptions(this);
- break;
- }
-
- if(widget)
- widgets[row] = widget;
- }
-
- if(ui->horizontalLayout_2->count() == 2)
- {
- QWidget *current_widget = ui->horizontalLayout_2->itemAt(1)->widget();
- ui->horizontalLayout_2->removeWidget(current_widget);
- current_widget->hide();
- }
-
- ui->horizontalLayout_2->insertWidget(1, widgets[row]);
- widgets[row]->show();
-}
-
-
-void PreferencesDialog::accept()
-{
- for (int i = 0; i < widgets.size(); ++i)
- {
- if (widgets[i])
- {
- static_cast<OptionWidget *>(widgets[i])->saveConfig();
- delete widgets[i];
- }
- }
-
- QDialog::accept();
-}
-
-
-void PreferencesDialog::reject()
-{
- for (int i = 0; i < widgets.size(); ++i)
- delete widgets[i];
-
- QDialog::reject();
-}
diff --git a/GScribo/Preferences/preferencesdialog.h b/GScribo/Preferences/preferencesdialog.h
deleted file mode 100644
index b0b9b61..0000000
--- a/GScribo/Preferences/preferencesdialog.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef PREFERENCESDIALOG_H
-#define PREFERENCESDIALOG_H
-
-#include <QDialog>
-
-#include "preprocessingoptions.h"
-#include "segmentationoptions.h"
-#include "generaloptions.h"
-#include "ocroptions.h"
-
-namespace Ui
-{
- class PreferencesDialog;
-}
-
-class PreferencesDialog :
- public QDialog
-{
- Q_OBJECT
-
- public:
- explicit PreferencesDialog(QWidget *parent = 0);
- ~PreferencesDialog();
-
- private:
- void loadOptionList();
- void selectOptionWidget(int row);
-
- Ui::PreferencesDialog *ui;
- QVector<QWidget *> widgets;
-
- private slots:
- inline void onOptionListCurrentRowChanged(int row);
- virtual void accept();
- virtual void reject();
-
-};
-
-inline void PreferencesDialog::onOptionListCurrentRowChanged(int row)
-{ selectOptionWidget(row); }
-
-#endif // PREFERENCESDIALOG_H
diff --git a/GScribo/Preferences/preprocessingoptions.cpp b/GScribo/Preferences/preprocessingoptions.cpp
deleted file mode 100644
index 6639bae..0000000
--- a/GScribo/Preferences/preprocessingoptions.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "preprocessingoptions.h"
-#include "ui_preprocessingoptions.h"
-
-using namespace scribo::toolchain::internal;
-
-PreprocessingOptions::PreprocessingOptions(QWidget *parent) :
- OptionWidget(parent),
- ui(new Ui::PreprocessingOptions)
-{
- ui->setupUi(this);
-
- ui->bin_algoCbox->insertItem(Convert, "Violent convert");
- ui->bin_algoCbox->insertItem(Sauvola, "Local threshold");
- ui->bin_algoCbox->insertItem(SauvolaMs, "Local threshold multiscale");
-
- loadConfig();
-}
-
-PreprocessingOptions::~PreprocessingOptions()
-{
- delete ui;
-}
-
-void PreprocessingOptions::loadConfig()
-{
- Configs *const conf = Configs::getInstance();
-
- ui->subsampleCb->setChecked(conf->preprocessingSubsample());
- ui->remove_bgCb->setChecked(conf->preprocessingRemoveBg());
- ui->deskewCb->setChecked(conf->preprocessingDeskew());
- ui->remove_noiseCb->setChecked(conf->preprocessingRemoveNoise());
- ui->bin_algoCbox->setCurrentIndex(conf->preprocessingBinAlgo());
-}
-
-
-void PreprocessingOptions::saveConfig()
-{
- Configs *const conf = Configs::getInstance();
-
- conf->setPreprocessingSubsample(ui->subsampleCb->isChecked());
- conf->setPreprocessingRemoveBg(ui->remove_bgCb->isChecked());
- conf->setPreprocessingDeskew(ui->deskewCb->isChecked());
- conf->setPreprocessingRemoveNoise(ui->remove_noiseCb->isChecked());
- conf->setPreprocessingBinAlgo(ui->bin_algoCbox->currentIndex());
-}
diff --git a/GScribo/Preferences/preprocessingoptions.h b/GScribo/Preferences/preprocessingoptions.h
deleted file mode 100644
index 6cc0081..0000000
--- a/GScribo/Preferences/preprocessingoptions.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef PREPROCESSINGOPTIONS_H
-#define PREPROCESSINGOPTIONS_H
-
-#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
-
-#include "optionwidget.h"
-#include "region.h"
-#include "configs.h"
-
-namespace Ui
-{
- class PreprocessingOptions;
-}
-
-class PreprocessingOptions :
- public OptionWidget
-{
- Q_OBJECT
-
- public:
- explicit PreprocessingOptions(QWidget *parent = 0);
- ~PreprocessingOptions();
-
- void loadConfig();
- void saveConfig();
-
- private:
- Ui::PreprocessingOptions *ui;
-
-};
-
-#endif // PREPROCESSINGOPTIONS_H
diff --git a/GScribo/Preferences/segmentationoptions.cpp b/GScribo/Preferences/segmentationoptions.cpp
deleted file mode 100644
index d35209f..0000000
--- a/GScribo/Preferences/segmentationoptions.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-#include "segmentationoptions.h"
-#include "ui_segmentationoptions.h"
-
-SegmentationOptions::SegmentationOptions(QWidget *parent) :
- OptionWidget(parent),
- ui(new Ui::SegmentationOptions)
-{
- ui->setupUi(this);
-
- ui->find_sepsCbox->insertItem(Separator::Lines, "Lines");
- ui->find_sepsCbox->insertItem(Separator::Whitespaces, "Whitespaces");
- ui->find_sepsCbox->insertItem(Separator::Both, "Lines and whitespaces");
-
- loadConfig();
-}
-
-SegmentationOptions::~SegmentationOptions()
-{
- delete ui;
-}
-
-void SegmentationOptions::loadConfig()
-{
- Configs *const conf = Configs::getInstance();
- ui->find_sepsCbox->setCurrentIndex(conf->segmentationFindSeps());
-}
-
-
-void SegmentationOptions::saveConfig()
-{
- Configs *const conf = Configs::getInstance();
- conf->setSegmentationFindSeps(ui->find_sepsCbox->currentIndex());
-}
diff --git a/GScribo/Preferences/segmentationoptions.h b/GScribo/Preferences/segmentationoptions.h
deleted file mode 100644
index 1506bfa..0000000
--- a/GScribo/Preferences/segmentationoptions.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef SEGMENTATIONOPTIONS_H
-#define SEGMENTATIONOPTIONS_H
-
-//#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
-
-#include "optionwidget.h"
-#include "configs.h"
-#include "region.h"
-
-namespace Ui
-{
- class SegmentationOptions;
-}
-
-class SegmentationOptions :
- public OptionWidget
-{
- Q_OBJECT
-
- public:
- explicit SegmentationOptions(QWidget *parent = 0);
- ~SegmentationOptions();
-
- void loadConfig();
- void saveConfig();
-
- private:
- Ui::SegmentationOptions *ui;
-};
-
-#endif // SEGMENTATIONOPTIONS_H
diff --git a/GScribo/Processing/preprocess.cpp b/GScribo/Processing/preprocess.cpp
deleted file mode 100644
index f012d88..0000000
--- a/GScribo/Processing/preprocess.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "preprocess.h"
-
-void Preprocess::on_progress()
-{
- emit progress();
-}
-
-void Preprocess::on_new_progress_label(const char *label)
-{
- emit newProgressLabel(QString(label));
-}
diff --git a/GScribo/Processing/preprocess.h b/GScribo/Processing/preprocess.h
deleted file mode 100644
index d65357f..0000000
--- a/GScribo/Processing/preprocess.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef PREPROCESS_H
-#define PREPROCESS_H
-
-#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/value/rgb8.hh>
-#include <QObject>
-
-using namespace scribo::toolchain::internal;
-
-class Preprocess :
- public QObject,
- public text_in_doc_preprocess_functor<mln::image2d<mln::value::rgb8> >
-{
- Q_OBJECT
-
- public:
- virtual void on_progress();
- virtual void on_new_progress_label(const char *label);
-
- signals:
- void newProgressLabel(const QString& label);
- void progress();
-};
-
-#endif // PREPROCESS_H
diff --git a/GScribo/Processing/process.cpp b/GScribo/Processing/process.cpp
deleted file mode 100644
index bd37480..0000000
--- a/GScribo/Processing/process.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-#include "process.h"
-
-Process::Process(const char *doc_filename)
- : superT(doc_filename)
-{
-}
-
-void Process::on_progress()
-{
- emit progress();
-}
-
-void Process::on_new_progress_label(const char *label)
-{
- emit newProgressLabel(QString(label));
-}
-
-void Process::on_xml_saved()
-{
- emit xmlSaved(QString(output_file.c_str()));
-}
diff --git a/GScribo/Processing/process.h b/GScribo/Processing/process.h
deleted file mode 100644
index 579a988..0000000
--- a/GScribo/Processing/process.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef PROCESS_H
-#define PROCESS_H
-
-#include <scribo/toolchain/internal/content_in_doc_functor.hh>
-#include <mln/core/image/image2d.hh>
-#include <QObject>
-
-using namespace scribo::toolchain::internal;
-
-struct Process :
- public QObject,
- public content_in_doc_functor<mln::image2d<bool> >
-{
- Q_OBJECT
- typedef content_in_doc_functor<mln::image2d<bool> > superT;
-
- public :
- explicit Process(const char *docFilename);
- virtual void on_progress();
- virtual void on_new_progress_label(const char *label);
- virtual void on_xml_saved();
-
- signals:
- void newProgressLabel(const QString& label);
- void progress();
- void xmlSaved(const QString& filename);
-};
-
-#endif // PROCESS_H
diff --git a/GScribo/Processing/progressdialog.cpp b/GScribo/Processing/progressdialog.cpp
deleted file mode 100644
index 7f9d833..0000000
--- a/GScribo/Processing/progressdialog.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "progressdialog.h"
-
-ProgressDialog::ProgressDialog(QWidget *parent):
- QProgressDialog(parent, Qt::Dialog)
-{
- setAutoClose(false);
- setCancelButton(0);
- hide();
-}
-
-void ProgressDialog::reset()
-{
- setValue(0);
- setLabelText("Initilization");
- show();
-}
diff --git a/GScribo/Processing/progressdialog.h b/GScribo/Processing/progressdialog.h
deleted file mode 100644
index 822d9ba..0000000
--- a/GScribo/Processing/progressdialog.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef PROGRESSDIALOG_H
-#define PROGRESSDIALOG_H
-
-#include <QProgressDialog>
-
-class ProgressDialog :
- public QProgressDialog
-{
- Q_OBJECT
-
- public:
- explicit ProgressDialog(QWidget *parent = 0);
- void reset();
-
- public slots:
- inline void run();
-};
-
-void ProgressDialog::run()
-{ setValue(value()+1); }
-
-#endif // PROGRESSDIALOG_H
diff --git a/GScribo/Processing/runner.cpp b/GScribo/Processing/runner.cpp
deleted file mode 100644
index c02223c..0000000
--- a/GScribo/Processing/runner.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-#include "runner.h"
-
-using namespace mln;
-using namespace scribo::toolchain::internal;
-
-static QString get_pathto(const QString& file, const QString localdirsuffix = QString())
-{
- QFile f(SCRIBO_LOCAL_DEMODIR "/" + localdirsuffix + "/" + file);
- if (f.exists())
- return SCRIBO_LOCAL_DEMODIR "/" + localdirsuffix;
- f.setFileName(SCRIBO_PREFIX_BINDIR "/" + file);
- if (f.exists())
- return SCRIBO_PREFIX_BINDIR;
-
- return "";
-}
-
-Runner::Runner(QObject *parent) :
- QThread(parent)
-{
- moveToThread(this);
-}
-
-void Runner::run()
-{
- if(mode_ == Demat)
- {
- image2d<value::rgb8> ima;
- for(int i = 0; i < args_.count(); i++)
- {
- io::magick::load(ima, args_.at(i).toUtf8().constData());
- image2d<bool> bin_ima = preprocess(ima);
- process(ima, bin_ima, i);
- }
- }
-
- else if(mode_ == Export)
- export_as();
-
- emit finished();
-}
-
-void Runner::stop()
-{
- terminate();
-}
-
-// Demat related stuff
-void Runner::start_demat(const QStringList& filenames)
-{
- args_.clear();
- args_ = filenames;
- mode_ = Demat;
- QThread::start();
-}
-
-
-image2d<bool> Runner::preprocess(const image2d<value::rgb8>& ima)
-{
- emit new_step("Preprocessing");
- Preprocess f;
-
- // Load config.
- Configs *const conf = Configs::getInstance();
-
- connect(&f, SIGNAL(progress()), this, SIGNAL(progress()));
- connect(&f, SIGNAL(newProgressLabel(QString)),
- this, SIGNAL(new_progress_label(const QString&)));
-
- f.enable_subsample = conf->preprocessingSubsample();
- f.enable_fg_extraction = conf->preprocessingRemoveBg();
- f.enable_deskew = conf->preprocessingDeskew();
- f.enable_denoising = conf->preprocessingRemoveNoise();
-
- f.binarization_algo = static_cast<Binarization_Algo>(conf->preprocessingBinAlgo());
-
- emit new_progress_max_value(f.nsteps());
-
- // Perform preprocessing.
- f(ima);
-
- return f.output;
-}
-
-
-void Runner::process(const image2d<value::rgb8>& original_ima,
- const image2d<bool>& processed_ima, int arg)
-{
- emit new_step("Page segmentation");
-
- Process f(args_.at(arg).toUtf8().constData());
-
- connect(&f, SIGNAL(progress()), this, SIGNAL(progress()));
- connect(&f, SIGNAL(newProgressLabel(QString)),
- this, SIGNAL(new_progress_label(QString)));
- connect(&f, SIGNAL(xmlSaved(QString)),
- this, SIGNAL(xml_saved(const QString&)));
-
- // Load config.
- Configs *const conf = Configs::getInstance();
-
- Separator::FindSeparator find_seps = static_cast<Separator::FindSeparator>(conf->segmentationFindSeps());
- f.enable_line_seps = (find_seps == Separator::Lines
- || find_seps == Separator::Both);
- f.enable_whitespace_seps = (find_seps == Separator::Whitespaces
- || find_seps == Separator::Both);
- f.enable_ocr = conf->ocrEnabled();
- f.ocr_language = conf->ocrLanguage().toAscii().data();
- f.xml_format = scribo::io::xml::PageExtended;
-
-
- f.save_doc_as_xml = true;
- QFileInfo file(args_.at(arg));
- QString output_dir = QDir::tempPath();
- if (conf->generalSaveXmlEnabled())
- {
- if (conf->generalSaveXmlSameDir())
- output_dir = file.absolutePath();
- else if (conf->generalSaveXmlCustomDir())
- output_dir = conf->generalSaveXmlCustomDirPath();
-
- QDir dir(output_dir);
- if (!dir.exists() && !dir.mkpath(output_dir))
- output_dir = QDir::tempPath();
- }
- QString filename = (output_dir + "/" + file.baseName() + "_gui.xml");
- f.output_file = filename.toUtf8().constData();
- emit new_progress_max_value(f.nsteps());
-
- // Perform text detection.
- f(original_ima, processed_ima);
-}
-
-// Export related stuff
-void Runner::start_export(const QString& imgfile,
- const QString& xmlfile, const QString& outfile)
-{
- args_.clear();
- args_ << imgfile << xmlfile << outfile;
- mode_ = Export;
-
- QThread::start();
-}
-
-void Runner::export_as()
-{
- emit new_step("Exporting document");
- emit new_progress_max_value(2);
-
- // Checking output format
- QFileInfo f(args_.at(2));
-
- QString pathto_xml2doc = get_pathto("scribo-xml2doc", "xml2doc");
-
- if (pathto_xml2doc.isEmpty())
- {
- QMessageBox::critical(0, "Fatal error", "Cannot export! Cannot find scribo-xml2doc program!");
- return;
- }
-
- emit progress();
-
- int rvalue = 0;
- if (f.suffix() == "pdf")
- {
- emit new_step("Exporting as PDF");
- rvalue = system(QString("%1/scribo-xml2doc --pdf %2 %3 %4")
- .arg(pathto_xml2doc).arg(args_.at(1)).arg(args_.at(0))
- .arg(args_.at(2)).toAscii().constData());
- }
- else if (f.suffix() == "html" || f.suffix() == "htm")
- {
- emit new_step("Exporting as HTML");
- rvalue = system(QString("%1/scribo-xml2doc --html %2 %3 %4")
- .arg(pathto_xml2doc).arg(args_.at(1)).arg(args_.at(0))
- .arg(args_.at(2)).toAscii().constData());
- }
- else
- QMessageBox::critical(0, "Fatal error", "Cannot export! Invalid output format!");
-
- if (rvalue != 0)
- QMessageBox::critical(0, "Fatal error", "Cannot export! Return value is not 0!");
-}
diff --git a/GScribo/Processing/runner.h b/GScribo/Processing/runner.h
deleted file mode 100644
index 721086a..0000000
--- a/GScribo/Processing/runner.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef RUNNER_H
-#define RUNNER_H
-
-#include <mln/core/image/image2d.hh>
-#include <mln/io/magick/load.hh>
-#include <mln/value/rgb8.hh>
-#include <QStringList>
-#include <QMessageBox>
-#include <QThread>
-#include <QFile>
-
-#include "preprocess.h"
-#include "process.h"
-#include "configs.h"
-#include "region.h"
-#include "dir.h"
-
-using namespace mln;
-
-enum RunMode
-{
- Demat,
- Export
-};
-
-class Runner :
- public QThread
-{
- Q_OBJECT
-
- public:
- explicit Runner(QObject *parent = 0);
- void start_demat(const QStringList& filenames);
- void start_export(const QString& imgfile, const QString& xmlfile, const QString& outfile);
-
- private:
- image2d<bool> preprocess(const image2d<value::rgb8>& ima);
- void process(const image2d<value::rgb8>& original_ima, const image2d<bool>& processed_ima, int arg);
- void export_as();
- virtual void run();
- template <typename V> unsigned find_best_scale(const mln::image2d<V>& ima);
-
- QStringList args_;
- RunMode mode_;
-
- public slots:
- void stop();
-
- signals:
- void new_step(const QString& step_name);
- void new_progress_max_value(int i);
- void new_progress_label(const QString& msg);
- void xml_saved(const QString& filename);
- void progress();
- void finished();
-};
-
-#endif // RUNNER_H
diff --git a/GScribo/Rendering/graphicsview.cpp b/GScribo/Rendering/graphicsview.cpp
deleted file mode 100644
index 336d5c2..0000000
--- a/GScribo/Rendering/graphicsview.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-#include "graphicsview.h"
-#include <QDebug>
-
-GraphicsView::GraphicsView(QWidget *parent) :
- QGraphicsView(parent)
-{
- init();
-}
-
-GraphicsView::GraphicsView(QGraphicsScene *scene, QWidget *parent) :
- QGraphicsView(scene, parent)
-{
- init();
-}
-
-void GraphicsView::init()
-{
- isRightClicking_ = false;
- scaleRatio_ = QSizeF(1, 1);
- setTransformationAnchor(GraphicsView::AnchorUnderMouse);
- setBackgroundBrush(QBrush(Qt::lightGray));
-
- // Important to hide scroll bars : when they appear, it triggers the resizeEvent.
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-}
-
-void GraphicsView::mousePressEvent(QMouseEvent *event)
-{
- if(event->button() == Qt::RightButton)
- {
- emit beginDrag();
- setDragMode(QGraphicsView::ScrollHandDrag);
- }
-
- QMouseEvent *mouseEvent = new QMouseEvent(QEvent::MouseButtonPress, event->pos(), Qt::LeftButton,
- Qt::LeftButton, Qt::MetaModifier);
- event->ignore();
- QGraphicsView::mousePressEvent(mouseEvent);
-}
-
-void GraphicsView::mouseReleaseEvent(QMouseEvent *event)
-{
- if(event->button() == Qt::RightButton)
- {
- setDragMode(GraphicsView::NoDrag);
- emit endDrag();
- }
-
- QGraphicsView::mouseReleaseEvent(event);
-}
-
-void GraphicsView::wheelEvent(QWheelEvent *event)
-{
- if(event->modifiers() & Qt::ControlModifier)
- {
- // Current wheel have an angle of 15 degrees by steps with a delta of + or - 120. A good scale is +- 0.1 in that case.
- // So we have to adapt for wheel whith better precision.
- qreal degrees = 1 + static_cast<qreal>(event->delta()) / 1200;
- qreal nextScaleRatio = degrees * isWidthGreater_ ? scaleRatio_.width() :
- scaleRatio_.height();
- if(event->delta() > 0)
- {
- if(nextScaleRatio <= 20)
- {
- scaleRatio_ *= degrees;
- scale(degrees, degrees);
- }
- }
- else
- {
- if(nextScaleRatio >= 1.1)
- {
- scaleRatio_ *= degrees;
- scale(degrees, degrees);
- }
- else if(isContainedInView_)
- {
- QGraphicsView::fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
- scaleRatio_ = QSizeF(1, 1);
- }
- }
- }
- else
- QGraphicsView::wheelEvent(event);
-}
-
-void GraphicsView::keyPressEvent(QKeyEvent* event)
-{
- // Bitwise AND to check if at least CTRL is pushed.
- if(event->modifiers() & Qt::ControlModifier)
- {
- qreal nextScaleRatio;
- if(event->key() == Qt::Key_Plus)
- {
- nextScaleRatio = 1.2 * isWidthGreater_ ? scaleRatio_.width() :
- scaleRatio_.height();
- if(nextScaleRatio <= 19)
- {
- scaleRatio_ *= 1.2;
- scale(1.2, 1.2);
- }
- }
- else if(event->key() == Qt::Key_Minus)
- {
- nextScaleRatio = 0.8 * isWidthGreater_ ? scaleRatio_.width() :
- scaleRatio_.height();
- if(nextScaleRatio >= 1.2)
- {
- scaleRatio_ *= 0.8;
- scale(0.8, 0.8);
- }
- else if(isContainedInView_)
- {
- QGraphicsView::fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
- scaleRatio_ = QSizeF(1, 1);
- }
- }
- }
-
- QGraphicsView::keyPressEvent(event);
-}
-
-void GraphicsView::fitInView(const QRectF& rect)
-{
- setFocus();
- isWidthGreater_ = static_cast<qreal>(rect.width()) / static_cast<qreal>(rect.height()) > 1 ? true :
- false;
- qreal ratio = isWidthGreater_ ? static_cast<qreal>(width()) / static_cast<qreal>(rect.width()) :
- static_cast<qreal>(height()) / static_cast<qreal>(rect.height());
-
- isContainedInView_ = ratio < 1 ? true : false;
- if(isContainedInView_)
- {
- scaleRatio_ = QSizeF(1, 1);
- QGraphicsView::fitInView(rect, Qt::KeepAspectRatio);
- }
-}
-
-void GraphicsView::resizeEvent(QResizeEvent *event)
-{
- if(scene()->items().count() > 1)
- {
- qreal ratio = isWidthGreater_ ? static_cast<qreal>(event->size().width()) / static_cast<qreal>(event->oldSize().width()) :
- static_cast<qreal>(event->size().height()) / static_cast<qreal>(event->oldSize().height());
- scale(ratio, ratio);
- }
-
- QGraphicsView::resizeEvent(event);
-}
diff --git a/GScribo/Rendering/graphicsview.h b/GScribo/Rendering/graphicsview.h
deleted file mode 100644
index 285f4cd..0000000
--- a/GScribo/Rendering/graphicsview.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef GRAPHICSVIEW_H
-#define GRAPHICSVIEW_H
-
-#include <QGraphicsView>
-#include <QWheelEvent>
-#include <QScrollBar>
-
-class GraphicsView :
- public QGraphicsView
-{
- Q_OBJECT
-
- public:
- explicit GraphicsView(QWidget *parent = 0);
- explicit GraphicsView(QGraphicsScene *scene, QWidget *parent = 0);
-
- protected:
- void init();
-
- void resizeEvent(QResizeEvent *event);
-
- void wheelEvent(QWheelEvent *event);
- void keyPressEvent(QKeyEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
-
- private:
- bool isWidthGreater_;
- bool isContainedInView_;
- QSizeF scaleRatio_;
-
- bool isRightClicking_;
- QPointF prevMousePos_;
-
- public slots:
- void fitInView(const QRectF& rect);
-
- signals:
- void beginDrag();
- void endDrag();
-};
-
-#endif // GRAPHICSVIEW_H
diff --git a/GScribo/Rendering/regionitem.cpp b/GScribo/Rendering/regionitem.cpp
deleted file mode 100644
index 77cbcb3..0000000
--- a/GScribo/Rendering/regionitem.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "regionitem.h"
-
-RegionItem::RegionItem(QGraphicsItem *parent, QGraphicsScene *scene)
- : QGraphicsPolygonItem(parent, scene)
-{
- init();
-}
-
-RegionItem::RegionItem(const QPolygonF& polygon, QGraphicsItem *parent, QGraphicsScene *scene):
- QGraphicsPolygonItem(polygon, parent, scene)
-{
- init();
-}
-
-void RegionItem::init()
-{
- xmlItem_ = 0;
-
- selectedPen_.setStyle(Qt::SolidLine);
- unselectedPen_.setStyle(Qt::SolidLine);
-
- selectedPen_.setWidthF(2);
- unselectedPen_.setWidth(0);
-
- selectedPen_.setCapStyle(Qt::SquareCap);
- unselectedPen_.setCapStyle(Qt::SquareCap);
-
- selectedBrush_.setStyle(Qt::SolidPattern);
- unselectedBrush_.setStyle(Qt::SolidPattern);
-}
-
-void RegionItem::setColor(const QColor& color)
-{
- selectedPen_.setColor(QColor::fromRgb(color.red(), color.green(), color.blue(), 255));
- unselectedPen_.setColor(color);
-
- selectedBrush_.setColor(color);
- unselectedBrush_.setColor(QColor::fromRgb(color.red(), color.green(), color.blue(), 40));
-
- setPen(unselectedPen_);
- setBrush(unselectedBrush_);
-}
-
-void RegionItem::setSelected(bool isSelected)
-{
- if(isSelected)
- {
- isSelected_ = true;
- setPen(selectedPen_);
- setBrush(selectedBrush_);
- }
-
- else
- {
- isSelected_ = false;
- setPen(unselectedPen_);
- setBrush(unselectedBrush_);
- }
-}
diff --git a/GScribo/Rendering/regionitem.h b/GScribo/Rendering/regionitem.h
deleted file mode 100644
index 3e8eb11..0000000
--- a/GScribo/Rendering/regionitem.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef RegionITEM_H
-#define RegionITEM_H
-
-#include <QGraphicsPolygonItem>
-#include <QTreeWidgetItem>
-#include <QPen>
-
-#include "variantpointer.h"
-#include "region.h"
-
-class XmlItem;
-
-class RegionItem :
- public QGraphicsPolygonItem
-{
- public:
- explicit RegionItem(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
- explicit RegionItem(const QPolygonF& path, QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
-
- void setColor(const QColor& color);
- inline QColor color() const;
-
- inline void setXmlItem(XmlItem *xmlItem);
- inline XmlItem *xmlItem() const;
-
- inline void loadData(const GraphicsRegion::Data& data);
- inline int region() const;
-
- inline bool intersects(const QRectF& rect);
- inline bool contains(const QPointF& point);
-
- void setSelected(bool isSelected);
- inline bool isSelected();
- inline void unselect();
- inline void select();
-
- private:
- void init();
-
- XmlItem *xmlItem_;
- int region_;
- bool isSelected_;
-
- QPen selectedPen_;
- QPen unselectedPen_;
- QBrush selectedBrush_;
- QBrush unselectedBrush_;
-};
-
-inline void RegionItem::setXmlItem(XmlItem *xmlItem)
-{ xmlItem_ = xmlItem; }
-
-inline XmlItem *RegionItem::xmlItem() const
-{ return xmlItem_; }
-
-inline QColor RegionItem::color() const
-{ return selectedBrush_.color(); }
-
-inline int RegionItem::region() const
-{ return region_; }
-
-inline bool RegionItem::isSelected()
-{ return isSelected_; }
-
-inline void RegionItem::select()
-{ setSelected(true); }
-
-inline void RegionItem::unselect()
-{ setSelected(false); }
-
-inline void RegionItem::loadData(const GraphicsRegion::Data& data)
-{ region_ = data.region; setColor(data.color); setZValue(data.zValue); }
-
-inline bool RegionItem::contains(const QPointF& point)
-{ return (boundingRect().width() * boundingRect().height() == 0 || boundingRect().contains(point)) && shape().contains(point); }
-
-inline bool RegionItem::intersects(const QRectF& rect)
-{ return (boundingRect().width() * boundingRect().height() == 0 || boundingRect().intersects(rect)) && shape().intersects(rect); }
-
-#endif // RegionITEM_H
diff --git a/GScribo/Rendering/rootgraphicsitem.h b/GScribo/Rendering/rootgraphicsitem.h
deleted file mode 100644
index 2e95297..0000000
--- a/GScribo/Rendering/rootgraphicsitem.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef ROOTGRAPHICSITEM_H
-#define ROOTGRAPHICSITEM_H
-
-#include <QGraphicsItem>
-
-#include "region.h"
-
-class RootGraphicsItem :
- public QGraphicsPolygonItem
-{
- public:
- explicit RootGraphicsItem(int numberRegion)
- { childsFromRegion_.fill(QList<QGraphicsItem *>(), numberRegion); }
- ~RootGraphicsItem()
- { foreach(QList<QGraphicsItem *> list, childsFromRegion_) { foreach(QGraphicsItem *child, list) delete child; } }
-
- inline void addItemFrom(QGraphicsItem *graphicalItem, const GraphicsRegion::Id& region);
- inline QList<QGraphicsItem *> childsFrom(const GraphicsRegion::Id& region) const;
-
- private:
- QVector<QList<QGraphicsItem *> > childsFromRegion_;
-};
-
-inline QList<QGraphicsItem *> RootGraphicsItem::childsFrom(const GraphicsRegion::Id& region) const
-{ return childsFromRegion_[region]; }
-
-inline void RootGraphicsItem::addItemFrom(QGraphicsItem *graphicalItem, const GraphicsRegion::Id& region)
-{ childsFromRegion_[region] << graphicalItem; }
-
-#endif // ROOTGRAPHICSITEM_H
diff --git a/GScribo/Rendering/scene.cpp b/GScribo/Rendering/scene.cpp
deleted file mode 100644
index 903bb97..0000000
--- a/GScribo/Rendering/scene.cpp
+++ /dev/null
@@ -1,273 +0,0 @@
-#include "scene.h"
-
-Scene::Scene(QObject *parent):
- QGraphicsScene(parent)
-{
- init();
-}
-
-Scene::Scene(const QRectF &sceneRect, QObject *parent):
- QGraphicsScene(sceneRect, parent)
-{
- init();
-}
-
-Scene::Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent):
- QGraphicsScene(x, y, width, height, parent)
-{
- init();
-}
-
-void Scene::init()
-{
- isPressing_ = false;
- isSelectionDisabled_ = false;
- backgroundPixmap_ = 0;
- root_ = 0;
-
- selection_.hide();
- addItem(&selection_);
-}
-
-void Scene::clearAll()
-{
- if(root_)
- delete root_;
-
- if(backgroundPixmap_)
- delete backgroundPixmap_;
-
- selectedRegions_.clear();
- backgroundPath_ = QString();
- backgroundPixmap_ = 0;
- root_ = 0;
-}
-
-void Scene::clearRegions()
-{
- if(root_)
- delete root_;
-
- selectedRegions_.clear();
- root_ = 0;
-}
-
-void Scene::clearSelection()
-{
- QGraphicsItem *child;
- RegionItem *regionItem;
-
- // Unselect all items.
- foreach(child, selectedRegions_)
- {
- regionItem = static_cast<RegionItem *>(child);
- regionItem->unselect();
- }
-
- selectedRegions_.clear();
- emit selectionCleared();
-}
-
-void Scene::selectAll()
-{
- RegionItem *item;
- foreach(QGraphicsItem *child, root_->childItems())
- {
- item = static_cast<RegionItem *>(child);
- item->select();
- selectedRegions_ << item;
- }
-}
-
-void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- if(!backgroundPath_.isEmpty() && event->button() == Qt::LeftButton && !isSelectionDisabled_)
- {
- isPressing_ = true;
-
- baseSelection_.clear();
- pressPos_ = event->scenePos();
- selection_.show();
- }
-}
-
-void Scene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- if(isPressing_)
- {
- // Adapt if the selection rectangle has a negative size.
- if(pressPos_.x() < event->scenePos().x())
- selection_.setRect(pressPos_.x(), 0, event->scenePos().x()-pressPos_.x(), 0);
- else
- selection_.setRect(event->scenePos().x(), 0, pressPos_.x()-event->scenePos().x(), 0);
-
- if(pressPos_.y() < event->scenePos().y())
- selection_.setRect(selection_.rect().x(), pressPos_.y(), selection_.rect().width(), event->scenePos().y()-pressPos_.y());
- else
- selection_.setRect(selection_.rect().x(), event->scenePos().y(), selection_.rect().width(), pressPos_.y()-event->scenePos().y());
- }
-}
-
-void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- if(event->button() == Qt::LeftButton)
- {
- isPressing_ = false;
-
- // Redraw all items in selection.
- if(root_)
- {
- clearSelection();
-
- // Check if it is a click.
- if(selection_.rect().width() * selection_.rect().height() == 0)
- select(event->scenePos());
- else
- select(selection_.rect());
-
- baseSelection_ = selectedRegions();
- emit newSelection(selectedRegions_);
- }
-
- selection_.setRect(QRect());
- selection_.hide();
- }
-}
-
-void Scene::select(QGraphicsItem *root, const QPointF& point, const QRectF& rect)
-{
- QGraphicsItem *child;
- RegionItem *regionItem;
-
- // Check if it is a click.
- if(!point.isNull())
- {
- foreach(child, root->childItems())
- {
- regionItem = static_cast<RegionItem *>(child);
-
- if(regionItem->contains(point))
- {
- regionItem->select();
- selectedRegions_ << regionItem;
- }
- }
- }
- else
- {
- foreach(child, root->childItems())
- {
- regionItem = static_cast<RegionItem *>(child);
-
- if(regionItem->intersects(rect))
- {
- regionItem->select();
- selectedRegions_ << regionItem;
- }
- }
- }
-
- emit newSelection();
-}
-
-void Scene::select(const QList<RegionItem *>& selectedRegions)
-{
- RegionItem *child;
- foreach(child, selectedRegions)
- {
- if(!child->isSelected())
- {
- child->select();
- selectedRegions_ << child;
- }
- }
-
- ensureVisible(selectedRegions_.last());
- emit newSelection();
-}
-
-void Scene::unselect(const QList<RegionItem *>& unselectedRegions)
-{
- RegionItem *child;
- foreach(child, unselectedRegions)
- {
- if(child->isSelected())
- {
- child->unselect();
- selectedRegions_.removeOne(child);
- }
- }
-
- // Check if after the removal, the selected list isn't empty.
- if(!selectedRegions_.isEmpty())
- ensureVisible(selectedRegions_.last());
-
- emit newSelection();
-}
-
-
-void Scene::ensureVisible(QGraphicsItem *graphicalItem)
-{
- QGraphicsView *view;
- foreach (view, views())
- view->ensureVisible(graphicalItem);
-}
-
-void Scene::setVisible(const GraphicsRegion::Id& region, bool visible)
-{
- if(root_)
- {
- QGraphicsItem *child;
-
- if(visible)
- {
- foreach(child, root_->childsFrom(region))
- child->setVisible(true);
- }
-
- else
- {
- foreach(child, root_->childsFrom(region))
- child->setVisible(false);
- }
- }
-}
-
-void Scene::setRoot(RootGraphicsItem *root)
-{
- // Delete all items.
- clearRegions();
-
- root_ = root;
- addItem(root);
-
- // Add typo lines separately because can't be selected.
- QGraphicsItem *line;
- foreach(line, root->childsFrom(GraphicsRegion::Baseline))
- addItem(line);
-
- foreach(line, root->childsFrom(GraphicsRegion::Meanline))
- addItem(line);
-}
-
-void Scene::changeScene(const QString& filename, RootGraphicsItem *root)
-{
- // Delete all items.
- clearAll();
- backgroundPath_ = filename;
-
- if(!filename.isEmpty())
- {
- QPixmap pixmap(filename);
- setSceneRect(pixmap.rect());
- // Create the background item and dock it at the maximal depth of the scene.
- backgroundPixmap_ = new QGraphicsPixmapItem(pixmap, 0, this);
- backgroundPixmap_->setZValue(INT_MIN);
- }
- else
- setSceneRect(QRectF());
-
- // Add new items.
- if(root)
- setRoot(root);
-}
diff --git a/GScribo/Rendering/scene.h b/GScribo/Rendering/scene.h
deleted file mode 100644
index 129359b..0000000
--- a/GScribo/Rendering/scene.h
+++ /dev/null
@@ -1,118 +0,0 @@
-#ifndef SCENE_H
-#define SCENE_H
-
-#include <QGraphicsSceneMouseEvent>
-#include <QGraphicsView>
-#include <QGraphicsScene>
-#include <QFileDialog>
-#include <climits>
-
-#include "rootgraphicsitem.h"
-#include "regionitem.h"
-#include "selection.h"
-
-class Scene :
- public QGraphicsScene
-{
- Q_OBJECT
-
- public:
- explicit Scene(QObject *parent = 0);
- explicit Scene(const QRectF &sceneRect, QObject *parent = 0);
- explicit Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent = 0);
-
- inline QString backgroundPath() const;
- inline QGraphicsPixmapItem *backgroundPixmap() const;
-
- inline QList<RegionItem *> selectedRegions() const;
-
- void setRoot(RootGraphicsItem *rootItem);
- inline RootGraphicsItem *root() const;
-
- void select(const QRectF& rect);
- void select(const QPointF& point);
- void selectAll();
-
- inline bool selectionEnable() const;
- inline void setSelectionEnable(bool enable);
-
- void changeScene(const QString& filename, RootGraphicsItem *root = 0);
-
- protected:
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
-
- private:
- void init();
- void select(QGraphicsItem *root, const QPointF& point, const QRectF& rect);
-
- QGraphicsView *mainView_;
- RootGraphicsItem *root_;
-
- QString backgroundPath_;
- QGraphicsPixmapItem *backgroundPixmap_;
-
- Selection selection_;
- QList<RegionItem *> selectedRegions_;
- QList<RegionItem *> baseSelection_;
-
- QPointF pressPos_;
- bool isPressing_;
- bool isSelectionDisabled_;
-
- public slots:
- void clearAll();
- void clearRegions();
- void clearSelection();
-
- void select(const QList<RegionItem *>& selectedRegions);
- inline void selectBase();
- void unselect(const QList<RegionItem *>& unselectedItems);
-
- void setVisible(const GraphicsRegion::Id& region, bool visible);
- void ensureVisible(QGraphicsItem *graphicsItem);
-
- inline void disableSelection();
- inline void enableSelection();
-
- signals:
- void selectionCleared();
- void newSelection();
- void newSelection(const QList<RegionItem *>& selectedRegions);
-};
-
-inline QString Scene::backgroundPath() const
-{ return backgroundPath_; }
-
-inline QGraphicsPixmapItem *Scene::backgroundPixmap() const
-{ return backgroundPixmap_; }
-
-inline RootGraphicsItem *Scene::root() const
-{ return root_; }
-
-inline QList<RegionItem *> Scene::selectedRegions() const
-{ return selectedRegions_; }
-
-inline void Scene::selectBase()
-{ select(baseSelection_); }
-
-inline void Scene::select(const QPointF& point)
-{ select(root_, point, QRectF()); }
-
-inline void Scene::select(const QRectF& rect)
-{ select(root_, QPointF(), rect); }
-
-inline void Scene::setSelectionEnable(bool enable)
-{ isSelectionDisabled_ = !enable; }
-
-inline bool Scene::selectionEnable() const
-{ return isSelectionDisabled_; }
-
-inline void Scene::disableSelection()
-{ setSelectionEnable(false); }
-
-inline void Scene::enableSelection()
-{ setSelectionEnable(true); }
-
-#endif // SCENE_H
diff --git a/GScribo/Rendering/selection.cpp b/GScribo/Rendering/selection.cpp
deleted file mode 100644
index f5c3f4a..0000000
--- a/GScribo/Rendering/selection.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "selection.h"
-
-Selection::Selection(QGraphicsScene *scene):
- QGraphicsRectItem(0, scene)
-{
- init();
-}
-
-Selection::Selection(const QRectF &rect, QGraphicsScene *scene):
- QGraphicsRectItem(rect, 0, scene)
-{
- init();
-}
-
-Selection::Selection(qreal x, qreal y, qreal width, qreal height, QGraphicsScene *scene):
- QGraphicsRectItem(x, y, width, height, 0, scene)
-{
- init();
-}
-
-void Selection::init()
-{
- // Always drawn on top of the scene.
- setZValue(INT_MAX);
-
- QPen pen;
- pen.setStyle(Qt::SolidLine);
- pen.setCapStyle(Qt::SquareCap);
- pen.setCosmetic(true);
- setPen(pen);
-
- QBrush brush;
- brush.setStyle(Qt::SolidPattern);
- brush.setColor(QColor::fromRgb(80, 200, 10, 60));
- setBrush(brush);
-}
diff --git a/GScribo/XmlWidget/attributesmodel.cpp b/GScribo/XmlWidget/attributesmodel.cpp
deleted file mode 100644
index 783fafb..0000000
--- a/GScribo/XmlWidget/attributesmodel.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-#include "attributesmodel.h"
-
-AttributesModel::AttributesModel(const XmlAttributes& attributes, QObject *parent) :
- QAbstractItemModel(parent)
-{
- attributes_ = attributes;
-}
-
-AttributesModel::AttributesModel(const XmlAttributes& attributes, QAbstractItemModelPrivate& dd, QObject *parent) :
- QAbstractItemModel(dd, parent)
-{
- attributes_ = attributes;
-}
-
-QVariant AttributesModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
- if(orientation == Qt::Horizontal && role == Qt::DisplayRole)
- {
- switch(section)
- {
- case 0:
- return tr("Name");
-
- case 1:
- return tr("Value");
-
- default:
- return QVariant();
- }
- }
-
- return QVariant();
-}
-
-QVariant AttributesModel::data(const QModelIndex& index, int role) const
-{
- if(!index.isValid())
- return QVariant();
-
- switch(role)
- {
- case Qt::UserRole:
- return attributes_.names()[index.row()];
-
- case Qt::UserRole+1:
- return attributes_.values()[index.row()];
-
- default:
- return QVariant();
- }
-}
-
-void AttributesModel::load(const XmlAttributes& attributes)
-{
- beginResetModel();
-
- attributes_ = attributes;
-
- endResetModel();
-}
-
-void AttributesModel::reset()
-{
- beginResetModel();
-
- attributes_ = XmlAttributes();
-
- endResetModel();
-}
diff --git a/GScribo/XmlWidget/attributesmodel.h b/GScribo/XmlWidget/attributesmodel.h
deleted file mode 100644
index 1dd3289..0000000
--- a/GScribo/XmlWidget/attributesmodel.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef ATTRIBUTESMODEL_H
-#define ATTRIBUTESMODEL_H
-
-#include <QAbstractItemModel>
-
-#include "xmlattributes.h"
-
-class AttributesModel :
- public QAbstractItemModel
-{
- Q_OBJECT
-
- public:
- explicit AttributesModel(const XmlAttributes& attributes = XmlAttributes(), QObject *parent = 0);
- explicit AttributesModel(const XmlAttributes& attributes, QAbstractItemModelPrivate& dd, QObject *parent = 0);
-
- inline int rowCount(const QModelIndex& parent) const;
- inline int columnCount(const QModelIndex& parent) const;
-
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- QVariant data(const QModelIndex& index, int role) const;
-
- inline QModelIndex index(int row, int column, const QModelIndex &parent) const;
- inline QModelIndex parent(const QModelIndex &child) const;
-
- public slots:
- void reset();
-
- private:
- XmlAttributes attributes_;
-
- public slots:
- void load(const XmlAttributes& attributes);
-};
-
-inline int AttributesModel::rowCount(const QModelIndex&) const
-{ return attributes_.names().count(); }
-
-inline int AttributesModel::columnCount(const QModelIndex&) const
-{ return 2; }
-
-inline QModelIndex AttributesModel::index(int row, int column, const QModelIndex& parent) const
-{ if(!hasIndex(row, column, parent)) return QModelIndex(); return createIndex(row, column, 0); }
-
-inline QModelIndex AttributesModel::parent(const QModelIndex&) const
-{ return QModelIndex(); }
-
-#endif // ATTRIBUTESMODEL_H
diff --git a/GScribo/XmlWidget/selectionproxy.h b/GScribo/XmlWidget/selectionproxy.h
deleted file mode 100644
index 604c46a..0000000
--- a/GScribo/XmlWidget/selectionproxy.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef SELECTIONPROXY_H
-#define SELECTIONPROXY_H
-
-#include <QSortFilterProxyModel>
-#include <QDebug>
-
-#include "xmlitem.h"
-
-class SelectionProxy :
- public QSortFilterProxyModel
-{
- public:
- explicit SelectionProxy(QObject *parent = 0) : QSortFilterProxyModel(parent) { isAllDisplayed_ = true; }
-
- inline void displayAll();
- inline bool isAllDisplayed();
-
- inline void beginResetModel();
- inline void endResetModel();
- inline void invalidateFilter();
-
- protected:
- inline bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
-
- private:
- bool isAllDisplayed_;
-};
-
-inline bool SelectionProxy::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
-{ return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent) && (isAllDisplayed_ || sourceModel()->index(sourceRow, 0, sourceParent).data(Qt::UserRole+2).value<XmlItem *>()->isVisible()); }
-
-inline void SelectionProxy::beginResetModel()
-{ isAllDisplayed_ = false; QSortFilterProxyModel::beginResetModel(); }
-
-inline void SelectionProxy::endResetModel()
-{ QSortFilterProxyModel::endResetModel(); }
-
-inline void SelectionProxy::displayAll()
-{ isAllDisplayed_ = true; }
-
-inline bool SelectionProxy::isAllDisplayed()
-{ return isAllDisplayed_; }
-
-inline void SelectionProxy::invalidateFilter()
-{ QSortFilterProxyModel::invalidateFilter(); }
-
-#endif // SELECTIONPROXY_H
diff --git a/GScribo/XmlWidget/xmlattributes.cpp b/GScribo/XmlWidget/xmlattributes.cpp
deleted file mode 100644
index 0c4221f..0000000
--- a/GScribo/XmlWidget/xmlattributes.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#include "xmlattributes.h"
-
-XmlAttributes::XmlAttributes()
-{
-}
-
-XmlAttributes::XmlAttributes(const QDomNamedNodeMap& node)
-{
- load(node);
-}
-
-void XmlAttributes::load(const QDomNamedNodeMap& node)
-{
- QDomAttr attr;
-
- for(int i = 0; i < node.count(); i++)
- {
- attr = node.item(i).toAttr();
-
- names_ << attr.name();
- values_ << attr.value();
- }
-}
diff --git a/GScribo/XmlWidget/xmlattributes.h b/GScribo/XmlWidget/xmlattributes.h
deleted file mode 100644
index 8dbf547..0000000
--- a/GScribo/XmlWidget/xmlattributes.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef XMLATTRIBUTES_H
-#define XMLATTRIBUTES_H
-
-#include <QDomNamedNodeMap>
-#include <QStringList>
-#include <QVariant>
-
-class XmlAttributes
-{
- public:
- explicit XmlAttributes();
- explicit XmlAttributes(const QDomNamedNodeMap& node);
-
- void load(const QDomNamedNodeMap& node);
-
- inline QStringList names() const;
- inline QStringList values() const;
-
- private:
- QStringList names_;
- QStringList values_;
-};
-
-inline QStringList XmlAttributes::names() const
-{ return names_; }
-
-inline QStringList XmlAttributes::values() const
-{ return values_; }
-
-Q_DECLARE_METATYPE(XmlAttributes)
-Q_DECLARE_METATYPE(XmlAttributes *)
-
-#endif // XMLATTRIBUTES_H
diff --git a/GScribo/XmlWidget/xmlitem.cpp b/GScribo/XmlWidget/xmlitem.cpp
deleted file mode 100644
index 53d09aa..0000000
--- a/GScribo/XmlWidget/xmlitem.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-#include "xmlitem.h"
-
-XmlItem::XmlItem(XmlItem *parent, XmlItem *precItem)
-{
- init(parent, precItem);
-}
-
-XmlItem::XmlItem(const QDomElement& node, XmlItem *parent, XmlItem *precItem)
-{
- init(parent, precItem);
- load(node);
-}
-
-XmlItem::~XmlItem()
-{
- // Delete all childs.
- XmlItem *child;
- foreach(child, childs_)
- delete child;
-}
-
-void XmlItem::init(XmlItem *parent, XmlItem *precItem)
-{
- isVisible_ = false;
- regionItem_ = 0;
- parent_ = parent;
-
- if(parent)
- parent->addChild(this);
-
- if(precItem)
- row_ = precItem->row()+1;
- else
- row_ = 0;
-}
-
-void XmlItem::load(const QDomElement& node)
-{
- text_ = node.tagName();
-
- // Load attributes.
- attributes_.load(node.attributes());
-}
diff --git a/GScribo/XmlWidget/xmlitem.h b/GScribo/XmlWidget/xmlitem.h
deleted file mode 100644
index 5b14ba7..0000000
--- a/GScribo/XmlWidget/xmlitem.h
+++ /dev/null
@@ -1,90 +0,0 @@
-#ifndef XMLITEM_H
-#define XMLITEM_H
-
-#include <QDomElement>
-
-#include "xmlattributes.h"
-
-class RegionItem;
-
-class XmlItem
-{
- public:
- explicit XmlItem(XmlItem *parent = 0, XmlItem *precItem = 0);
- explicit XmlItem(const QDomElement& node, XmlItem *parent = 0, XmlItem *precItem = 0);
- ~XmlItem();
-
- void load(const QDomElement& node);
-
- inline QList<XmlItem *> childs() const;
- inline XmlItem *child(int i) const;
- inline void addChild(XmlItem *child);
- inline XmlItem *parent() const;
-
- inline RegionItem *regionItem();
- inline void setRegionItem(RegionItem *regionItem);
-
- inline bool isVisible() const;
- inline void setVisible(bool visible);
- inline void show();
- inline void hide();
-
- inline QString text() const;
- inline int row() const;
- inline XmlAttributes attributes() const;
-
- private:
- void init(XmlItem *parent = 0, XmlItem *precItem = 0);
-
- int row_;
- bool isVisible_;
- QList<XmlItem *> childs_;
- XmlItem *parent_;
- RegionItem *regionItem_;
- QString text_;
- XmlAttributes attributes_;
-};
-
-inline QList<XmlItem *> XmlItem::childs() const
-{ return childs_; }
-
-inline XmlItem *XmlItem::child(int i) const
-{ if(i > -1 && i < childs_.count()) return childs_[i]; return 0; }
-
-inline void XmlItem::addChild(XmlItem *child)
-{ childs_ << child; }
-
-inline XmlItem *XmlItem::parent() const
-{ return parent_; }
-
-inline RegionItem *XmlItem::regionItem()
-{ return regionItem_; }
-
-inline void XmlItem::setRegionItem(RegionItem *regionItem)
-{ regionItem_ = regionItem; }
-
-inline bool XmlItem::isVisible() const
-{ return isVisible_; }
-
-inline void XmlItem::setVisible(bool visible)
-{ isVisible_ = visible; }
-
-inline void XmlItem::show()
-{ isVisible_ = true; }
-
-inline void XmlItem::hide()
-{ isVisible_ = false; }
-
-inline QString XmlItem::text() const
-{ return text_; }
-
-inline int XmlItem::row() const
-{ return row_; }
-
-inline XmlAttributes XmlItem::attributes() const
-{ return attributes_; }
-
-Q_DECLARE_METATYPE(XmlItem)
-Q_DECLARE_METATYPE(XmlItem *)
-
-#endif // XMLITEM_H
diff --git a/GScribo/XmlWidget/xmlmodel.cpp b/GScribo/XmlWidget/xmlmodel.cpp
deleted file mode 100644
index 0f58075..0000000
--- a/GScribo/XmlWidget/xmlmodel.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-#include "xmlmodel.h"
-
-XmlModel::XmlModel(XmlItem *rootItem, QObject *parent) :
- QAbstractItemModel(parent)
-{
- rootItem_ = rootItem;
-}
-
-XmlModel::XmlModel(XmlItem *rootItem, QAbstractItemModelPrivate& dd, QObject *parent) :
- QAbstractItemModel(dd, parent)
-{
- rootItem_ = rootItem;
-}
-
-XmlModel::~XmlModel()
-{
- if(rootItem_)
- delete rootItem_;
-}
-
-QVariant XmlModel::headerData(int, Qt::Orientation orientation, int role) const
-{
- if(orientation == Qt::Horizontal && role == Qt::DisplayRole)
- return tr("Tree");
-
- return QVariant();
-}
-
-QVariant XmlModel::data(const QModelIndex& index, int role) const
-{
- if(!index.isValid())
- return QVariant();
-
- switch(role)
- {
- case Qt::UserRole:
- return static_cast<XmlItem *>(index.internalPointer())->text();
-
- case Qt::UserRole+1:
- return QVariant::fromValue(static_cast<XmlItem *>(index.internalPointer())->attributes());
-
- case Qt::UserRole+2:
- return QVariant::fromValue(static_cast<XmlItem *>(index.internalPointer()));
-
- default:
- return QVariant();
- }
-}
-
-QModelIndex XmlModel::index(int row, int column, const QModelIndex& parent) const
-{
- if(!hasIndex(row, column, parent))
- return QModelIndex();
-
- XmlItem *childItem = toXmlItem(parent)->child(row);
-
- // Create the model index from the child item.
- if(childItem)
- return createIndex(row, column, childItem);
- else
- return QModelIndex();
-}
-
-QModelIndex XmlModel::parent(const QModelIndex& child) const
-{
- if(!child.isValid())
- return QModelIndex();
-
- XmlItem *parentItem = static_cast<XmlItem *>(child.internalPointer())->parent();
-
- if(!parentItem || parentItem == rootItem_)
- return QModelIndex();
-
- return createIndex(parentItem->row(), 0, parentItem);
-}
-
-void XmlModel::load(XmlItem *rootItem)
-{
- beginResetModel();
-
- if(rootItem_)
- delete rootItem_;
-
- rootItem_ = rootItem;
-
- endResetModel();
-}
diff --git a/GScribo/XmlWidget/xmlmodel.h b/GScribo/XmlWidget/xmlmodel.h
deleted file mode 100644
index 7e74e6f..0000000
--- a/GScribo/XmlWidget/xmlmodel.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef XMLMODEL_H
-#define XMLMODEL_H
-
-#include <QAbstractItemModel>
-
-#include "variantpointer.h"
-#include "xmlitem.h"
-
-class XmlModel :
- public QAbstractItemModel
-{
- public:
- explicit XmlModel(XmlItem *rootItem = 0, QObject *parent = 0);
- explicit XmlModel(XmlItem *rootItem, QAbstractItemModelPrivate& dd, QObject *parent = 0);
- ~XmlModel();
-
- void load(XmlItem *rootItem);
-
- inline int rowCount(const QModelIndex& parent) const;
- inline int columnCount(const QModelIndex& parent) const;
-
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
-
- QVariant data(const QModelIndex& index, int role) const;
-
- QModelIndex index(int row, int column, const QModelIndex& parent) const;
- QModelIndex parent(const QModelIndex& child) const;
-
- private:
- inline XmlItem *toXmlItem(const QModelIndex& index) const;
-
- XmlItem *rootItem_;
-};
-
-inline XmlItem *XmlModel::toXmlItem(const QModelIndex& parent) const
-{ return !parent.isValid() ? rootItem_ : static_cast<XmlItem *>(parent.internalPointer()); }
-
-inline int XmlModel::rowCount(const QModelIndex& parent) const
-{ if(rootItem_) return toXmlItem(parent)->childs().count(); return 0; }
-
-inline int XmlModel::columnCount(const QModelIndex&) const
-{ return 1; }
-
-#endif // XMLMODEL_H
diff --git a/GScribo/XmlWidget/xmlview.cpp b/GScribo/XmlWidget/xmlview.cpp
deleted file mode 100644
index 70a79b7..0000000
--- a/GScribo/XmlWidget/xmlview.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "xmlview.h"
-
-XmlView::XmlView(QWidget *parent) :
- QTreeView(parent)
-{
- proxy_.setFilterRole(Qt::UserRole);
- proxy_.setDynamicSortFilter(true);
-
- setUniformRowHeights(true);
- setItemDelegate(new XmlDelegate(Qt::UserRole));
- setSelectionMode(QAbstractItemView::ExtendedSelection);
-}
-
-void XmlView::hideAll()
-{
- proxy_.beginResetModel();
-
- XmlItem *child;
- foreach(child, displayedItems_)
- child->hide();
-
- displayedItems_.clear();
- emit resetProperty();
-
- proxy_.endResetModel();
-}
-
-void XmlView::display(QList<XmlItem *> displayedItems, bool addToDisplayedList)
-{
- proxy_.beginResetModel();
-
- if(!addToDisplayedList)
- hideAll();
-
- XmlItem *child;
- foreach(child, displayedItems)
- {
- child->show();
- displayedItems_ << child;
- }
-
- proxy_.endResetModel();
-
- expandAll();
-}
-
-QList<XmlItem *> XmlView::transform(const QModelIndexList& modelIndexList) const
-{
- QList<XmlItem *> selectedItems;
- QModelIndex index;
-
- foreach(index, modelIndexList)
- selectedItems << index.data(Qt::UserRole+2).value<XmlItem *>();
-
- return selectedItems;
-}
-
-void XmlView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
-{
- QTreeView::selectionChanged(selected, deselected);
-
- if(selected.indexes() == selectedIndexes())
- emit resetSelection();
-
- if(!selectedIndexes().isEmpty())
- {
- QList<XmlItem *> xmlItems;
- if(!selected.isEmpty())
- {
- xmlItems = transform(selected.indexes());
- emit select(xmlItems);
- }
- else
- {
- xmlItems = transform(deselected.indexes());
- emit unselect(xmlItems);
- }
-
- emit loadAttributes(xmlItems.last()->attributes());
- }
- else
- {
- emit resetProperty();
- emit emptySelection();
- }
-
- emit newSelection();
-}
diff --git a/GScribo/XmlWidget/xmlview.h b/GScribo/XmlWidget/xmlview.h
deleted file mode 100644
index fef7386..0000000
--- a/GScribo/XmlWidget/xmlview.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef XMLVIEW_H
-#define XMLVIEW_H
-
-#include <QGraphicsItem>
-#include <QTreeView>
-
-#include "Rendering/regionitem.h"
-#include "selectionproxy.h"
-#include "xmldelegate.h"
-#include "xmlitem.h"
-
-class XmlView :
- public QTreeView
-{
- Q_OBJECT
-
- public:
- explicit XmlView(QWidget *parent = 0);
-
- inline QList<XmlItem *> displayedItems() const;
- void hideAll();
-
- inline QList<XmlItem *> selectedItems() const;
-
- inline void setModel(QAbstractItemModel *model);
-
- protected:
- void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
-
- private:
- QList<XmlItem *> transform(const QModelIndexList& modelIndexList) const;
- void display(QList<XmlItem *> displayedItems, bool addToDisplayedList);
-
- SelectionProxy proxy_;
- QList<XmlItem *> displayedItems_;
-
- public slots:
- inline void display(QList<XmlItem *> displayedItems);
- inline void displayOnly(QList<XmlItem *> displayedItems);
-
- inline void displayAll();
-
- inline void setFilterString(const QString& filterString);
-
- signals:
- void loadAttributes(const XmlAttributes& xmlAttributes);
-
- void select(const QList<XmlItem *>& selectedItems);
- void unselect(const QList<XmlItem *>& unselectedItems);
-
- void newSelection();
- void emptySelection();
-
- void resetSelection();
- void resetProperty();
-};
-
-inline QList<XmlItem *> XmlView::displayedItems() const
-{ return displayedItems_; }
-
-inline void XmlView::display(QList<XmlItem *> displayedItems)
-{ display(displayedItems, true); }
-
-inline void XmlView::displayOnly(QList<XmlItem *> displayedItems)
-{ display(displayedItems, false); }
-
-inline void XmlView::displayAll()
-{ hideAll(); proxy_.displayAll(); }
-
-inline QList<XmlItem *> XmlView::selectedItems() const
-{ return transform(selectedIndexes()); }
-
-inline void XmlView::setFilterString(const QString& filterString)
-{ proxy_.setFilterRegExp(QRegExp(filterString, Qt::CaseSensitive)); proxy_.invalidateFilter(); }
-
-inline void XmlView::setModel(QAbstractItemModel *model)
-{ proxy_.setSourceModel(model); QTreeView::setModel(&proxy_); }
-
-#endif // XMLVIEW_H
diff --git a/GScribo/XmlWidget/xmlwidget.cpp b/GScribo/XmlWidget/xmlwidget.cpp
deleted file mode 100644
index dc24193..0000000
--- a/GScribo/XmlWidget/xmlwidget.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "xmlwidget.h"
-
-XmlWidget::XmlWidget(QWidget *parent) :
- QSplitter(Qt::Horizontal, parent)
-{
- proxy_.setFilterRegExp(QRegExp("(?:Page|.Region|Line)", Qt::CaseSensitive));
- proxy_.setDynamicSortFilter(true);
- proxy_.setFilterRole(Qt::UserRole);
- proxy_.setSourceModel(&model_);
-
- view_.setModel(&proxy_);
-
- attributes_.setModel(&attributesModel_);
- attributes_.setSelectionMode(QAbstractItemView::NoSelection);
- attributes_.setItemDelegateForColumn(0, new XmlDelegate(Qt::UserRole));
- attributes_.setItemDelegateForColumn(1, new XmlDelegate(Qt::UserRole+1));
-
- addWidget(&view_);
- addWidget(&attributes_);
-
- connect(&view_, SIGNAL(resetProperty()), &attributesModel_, SLOT(reset()));
- connect(&view_, SIGNAL(clicked(QModelIndex)), this, SLOT(loadAttributes(QModelIndex)));
- connect(&view_, SIGNAL(loadAttributes(XmlAttributes)), &attributesModel_, SLOT(load(XmlAttributes)));
-}
-
-void XmlWidget::changeView(XmlItem *rootItem)
-{
- attributesModel_.reset();
-
- model_.load(rootItem);
-
- view_.displayAll();
- view_.expandAll();
-}
diff --git a/GScribo/XmlWidget/xmlwidget.h b/GScribo/XmlWidget/xmlwidget.h
deleted file mode 100644
index 32eca37..0000000
--- a/GScribo/XmlWidget/xmlwidget.h
+++ /dev/null
@@ -1,54 +0,0 @@
-#ifndef XMLWIDGET_H
-#define XMLWIDGET_H
-
-#include <QSortFilterProxyModel>
-#include <QTableView>
-#include <QTreeWidget>
-#include <QSplitter>
-#include <QDomElement>
-#include <QWidget>
-
-#include "Rendering/scene.h"
-#include "selectionproxy.h"
-#include "attributesmodel.h"
-#include "variantpointer.h"
-#include "xmldelegate.h"
-#include "xmlmodel.h"
-#include "xmlview.h"
-
-class XmlWidget :
- public QSplitter
-{
- Q_OBJECT
-
- public:
- explicit XmlWidget(QWidget *parent = 0);
-
- inline XmlView *view();
- inline QTableView *attributes();
-
- void changeView(XmlItem *rootItem);
-
- private:
- QSortFilterProxyModel proxy_;
-
- XmlModel model_;
- AttributesModel attributesModel_;
-
- XmlView view_;
- QTableView attributes_;
-
- private slots:
- inline void loadAttributes(const QModelIndex& index);
-};
-
-inline XmlView * XmlWidget::view()
-{ return &view_; }
-
-inline QTableView *XmlWidget::attributes()
-{ return &attributes_; }
-
-inline void XmlWidget::loadAttributes(const QModelIndex& index)
-{ attributesModel_.load(index.data(Qt::UserRole+2).value<XmlItem *>()->attributes()); }
-
-#endif // XMLWIDGET_H
diff --git a/GScribo/aboutdialog.h b/GScribo/aboutdialog.h
deleted file mode 100644
index fa91ada..0000000
--- a/GScribo/aboutdialog.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef ABOUTDIALOG_H
-#define ABOUTDIALOG_H
-
-#include <QDialog>
-
-#include "ui_aboutdialog.h"
-
-namespace Ui
-{
- class AboutDialog;
-}
-
-class AboutDialog :
- public QDialog
-{
- public:
- explicit AboutDialog(QWidget *parent = 0) : QDialog(parent, Qt::Dialog)
- { ui = new Ui::AboutDialog; ui->setupUi(this); }
- ~AboutDialog() { delete ui; }
-
- private:
- Ui::AboutDialog *ui;
-};
-
-#endif // ABOUTDIALOG_H
diff --git a/GScribo/aboutdialog.ui b/GScribo/aboutdialog.ui
deleted file mode 100644
index d16b076..0000000
--- a/GScribo/aboutdialog.ui
+++ /dev/null
@@ -1,136 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>AboutDialog</class>
- <widget class="QDialog" name="AboutDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>557</width>
- <height>390</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>557</width>
- <height>390</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>557</width>
- <height>390</height>
- </size>
- </property>
- <property name="windowTitle">
- <string>About</string>
- </property>
- <property name="windowIcon">
- <iconset>
- <normaloff>:/icons/shared/icons/olena_smaller.jpg</normaloff>:/icons/shared/icons/olena_smaller.jpg</iconset>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string/>
- </property>
- <property name="pixmap">
- <pixmap>:/icons/shared/icons/olena_smaller.jpg</pixmap>
- </property>
- <property name="scaledContents">
- <bool>false</bool>
- </property>
- </widget>
- </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>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="label_2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <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:'Sans Serif'; 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-family:'DejaVu Sans'; font-size:12pt; font-weight:600;">Document Image Analysis Tool</span></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt; font-weight:600;"></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans';">This project is powered by </span><span style=" font-family:'DejaVu Sans'; font-weight:600; font-style:italic;">Milena</span><span style=" font-family:'DejaVu Sans';">, a generic image processing library.</span></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans';">It is part of </span><span style=" font-family:'DejaVu Sans'; font-weight:600; font-style:italic;">Olena</span><span style=" font-family:'DejaVu Sans';">, an Image Processing Platform and its module </span><span style=" font-family:'DejaVu Sans'; font-weight:600; font-style:italic;">Scribo</span><span style=" font-family:'DejaVu Sans';">, a set of tools for Document Image Analysis.</span></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
-<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://olena.lrde.epita.fr"><span style=" font-family:'DejaVu Sans'; text-decoration: underline; color:#0057ae;">http://olena.lrde.epita.fr</span></a></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:8pt;">Thanks to Arthur Crépin-Leblond, Samuel Da Mota, Loic Denuziere, Jérôme Galtier, Florent d'Halluin, Alex Hamelin, Damien Lefortier, Vincent Ordy, Guillaume Sadegh and Warren Seine for their contribution.</span></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:8pt;"></p>
-<p align="justify" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:8pt;"></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:7pt;">This application has been developed in the context of the SCRIBO project of the Free Software Thematic Group, part of the &quot;System@tic Paris-Région&quot; Cluster (France). This project is partially funded by the French Government, its economic development agencies, and by the Paris-Région institutions.</span></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:7pt;"></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:7pt;">Copyright (C) 2012, 2013 EPITA Research and Development Laboratory (LRDE)</span></p></body></html></string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Ok</set>
- </property>
- <property name="centerButtons">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>AboutDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>281</x>
- <y>391</y>
- </hint>
- <hint type="destinationlabel">
- <x>240</x>
- <y>203</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/GScribo/configs.h b/GScribo/configs.h
deleted file mode 100644
index c6aac68..0000000
--- a/GScribo/configs.h
+++ /dev/null
@@ -1,134 +0,0 @@
-#ifndef CONFIGS_H
-#define CONFIGS_H
-
-#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
-#include <QSettings>
-#include <QDir>
-#include <QDebug>
-
-#include "region.h"
-
-class Configs :
- public QSettings
-{
- public:
- inline static Configs *getInstance();
-
- inline bool preprocessingSubsample();
- inline void setPreprocessingSubsample(bool b);
-
- inline bool preprocessingRemoveBg();
- inline void setPreprocessingRemoveBg(bool b);
-
- inline bool preprocessingDeskew();
- inline void setPreprocessingDeskew(bool b);
-
- inline bool preprocessingRemoveNoise();
- inline void setPreprocessingRemoveNoise(bool b);
-
- inline int preprocessingBinAlgo();
- inline void setPreprocessingBinAlgo(int algo);
-
- inline int segmentationFindSeps();
- inline void setSegmentationFindSeps(int seps);
-
- inline bool ocrEnabled();
- inline void setOcrEnabled(bool b);
-
- inline QString ocrLanguage();
- inline void setOcrLanguage(const QString& lang);
-
- inline bool generalSaveXmlEnabled();
- inline void setGeneralSaveXmlEnabled(bool b);
-
- inline bool generalSaveXmlSameDir();
- inline void setGeneralSaveXmlSameDir(bool b);
-
- inline bool generalSaveXmlCustomDir();
- inline void setGeneralSaveXmlCustomDir(bool b);
-
- inline QString generalSaveXmlCustomDirPath();
- inline void setGeneralSaveXmlCustomDirPath(const QString& path);
-
- private:
- explicit Configs() : QSettings("olena-scribo", "gui") { }
-};
-
-inline Configs *Configs::getInstance()
-{ static Configs *conf = new Configs(); return conf; }
-
-inline bool Configs::preprocessingSubsample()
-{ return value("preprocessing/subsample", false).toBool(); }
-
-inline void Configs::setPreprocessingSubsample(bool b)
-{ setValue("preprocessing/subsample", b); }
-
-inline bool Configs::preprocessingRemoveBg()
-{ return value("preprocessing/remove_bg", false).toBool(); }
-
-inline void Configs::setPreprocessingRemoveBg(bool b)
-{ setValue("preprocessing/remove_bg", b); }
-
-inline bool Configs::preprocessingDeskew()
-{ return value("preprocessing/deskew", false).toBool(); }
-
-inline void Configs::setPreprocessingDeskew(bool b)
-{ setValue("preprocessing/deskew", b); }
-
-inline bool Configs::preprocessingRemoveNoise()
-{ return value("preprocessing/remove_noise", true).toBool(); }
-
-inline void Configs::setPreprocessingRemoveNoise(bool b)
-{ setValue("preprocessing/remove_noise", b); }
-
-inline int Configs::preprocessingBinAlgo()
-{ return value("preprocessing/bin_algo",
- scribo::toolchain::internal::SauvolaMs).toInt(); }
-
-inline void Configs::setPreprocessingBinAlgo(int algo)
-{ setValue("preprocessing/bin_algo", algo); }
-
-inline int Configs::segmentationFindSeps()
-{ return value("segmentation/find_seps", Separator::Both).toInt(); }
-
-inline void Configs::setSegmentationFindSeps(int seps)
-{ setValue("segmentation/find_seps", seps); }
-
-inline bool Configs::ocrEnabled()
-{ return value("ocr/enabled", true).toBool(); }
-
-inline void Configs::setOcrEnabled(bool b)
-{ setValue("ocr/enabled", b); }
-
-inline QString Configs::ocrLanguage()
-{ return value("ocr/language", 0).toString(); }
-
-inline void Configs::setOcrLanguage(const QString& lang)
-{ setValue("ocr/language", lang); }
-
-inline bool Configs::generalSaveXmlEnabled()
-{ return value("general/save_xml/enabled", true).toBool(); }
-
-inline void Configs::setGeneralSaveXmlEnabled(bool b)
-{ setValue("general/save_xml/enabled", b); }
-
-inline bool Configs::generalSaveXmlSameDir()
-{ return value("general/save_xml/same_dir", true).toBool(); }
-
-inline void Configs::setGeneralSaveXmlSameDir(bool b)
-{ setValue("general/save_xml/same_dir", b); }
-
-inline bool Configs::generalSaveXmlCustomDir()
-{ return value("general/save_xml/custom_dir", false).toBool(); }
-
-inline void Configs::setGeneralSaveXmlCustomDir(bool b)
-{ setValue("general/save_xml/custom_dir", b); }
-
-inline QString Configs::generalSaveXmlCustomDirPath()
-{ return value("general/save_xml/custom_dir_path",
- QDir::tempPath()).toString(); }
-
-inline void Configs::setGeneralSaveXmlCustomDirPath(const QString& path)
-{ setValue("general/save_xml/custom_dir_path", path); }
-
-#endif // CONFIGS_H
diff --git a/GScribo/dockwidget.h b/GScribo/dockwidget.h
deleted file mode 100644
index a1a2b40..0000000
--- a/GScribo/dockwidget.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef DOCKWIDGET_H
-#define DOCKWIDGET_H
-
-#include <QDockWidget>
-
-class DockWidget :
- public QDockWidget
-{
- Q_OBJECT
-
- public:
- explicit DockWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0) : QDockWidget(parent, flags) { }
- explicit DockWidget(const QString& title, QWidget *parent = 0, Qt::WindowFlags flags = 0) : QDockWidget(title, parent, flags) { }
-
- public slots:
- inline void switchVisibility();
-};
-
-inline void DockWidget::switchVisibility()
-{ setVisible(!isVisible()); }
-
-#endif // DOCKWIDGET_H
diff --git a/GScribo/main.cpp b/GScribo/main.cpp
deleted file mode 100644
index d47ec16..0000000
--- a/GScribo/main.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-#undef MLN_WO_GLOBAL_VARS
-
-#include <scribo/make/debug_filename.hh>
-#include <mln/labeling/colorize.hh>
-#include <mln/io/magick/load.hh>
-#include <mln/literal/colors.hh>
-#include <mln/debug/filename.hh>
-#include <QtGui/QApplication>
-#include <mln/math/pi.hh>
-
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
- Magick::InitializeMagick(*argv);
- // On Linux, we NEED to use the raster graphics system.
- // Linux don't really support openGL graphics system (the default one on Linux).
- QApplication::setGraphicsSystem("raster");
- QApplication a(argc, argv);
- MainWindow w;
- w.show();
- return a.exec();
-}
diff --git a/GScribo/mainwindow.cpp b/GScribo/mainwindow.cpp
deleted file mode 100644
index 4bb5c74..0000000
--- a/GScribo/mainwindow.cpp
+++ /dev/null
@@ -1,415 +0,0 @@
-#include "mainwindow.h"
-#include "ui_mainwindow.h"
-
-MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::MainWindow)
-{
- ui->setupUi(this);
-
- setWindowTitle(tr("GScribo"));
- showMaximized();
-
- initGraphicsRegion();
- initDialogsWidget();
- initXmlWidget();
- initRegionWidget();
- initPageWidget();
- initMenuBar();
-
- // Told the left dock widget (here the pages widget and the region widget) to fill the bottom left corner.
- setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
- // Merge the region and pages widget in one tab (pages widget over the region widget).
- tabifyDockWidget(&dockRegion_, &dockPages_);
-
- connectWidgets();
-}
-
-MainWindow::~MainWindow()
-{
- delete preferencesDialog_;
- delete aboutDialog_;
- delete progressDialog_;
- delete ui;
-}
-
-void MainWindow::changeEvent(QEvent *e)
-{
- QMainWindow::changeEvent(e);
- switch (e->type())
- {
- case QEvent::LanguageChange:
- ui->retranslateUi(this);
- break;
- default:
- break;
- }
-}
-
-void MainWindow::initGraphicsRegion()
-{
- graphicsView_.setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
- graphicsView_.setScene(&scene_);
-
- setCentralWidget(&graphicsView_);
-}
-
-void MainWindow::initDialogsWidget()
-{
- preferencesDialog_ = new PreferencesDialog(this);
- aboutDialog_ = new AboutDialog(this);
- progressDialog_ = new ProgressDialog(this);
-}
-
-void MainWindow::initPageWidget()
-{
- dockPages_.setWindowTitle("Pages");
- dockPages_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
- dockPages_.setWidget(&pagesWidget_);
- dockPages_.setMinimumWidth(190);
-
- addDockWidget(Qt::LeftDockWidgetArea, &dockPages_);
-}
-
-void MainWindow::initRegionWidget()
-{
- dockRegion_.setWindowTitle("Regions");
- dockRegion_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
- dockRegion_.setWidget(®ionWidget_);
-
- addDockWidget(Qt::LeftDockWidgetArea, &dockRegion_);
-}
-
-void MainWindow::initXmlWidget()
-{
- dockXml_.setWindowTitle("Xml");
- dockXml_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
- dockXml_.setWidget(&xmlWidget_);
-
- addDockWidget(Qt::BottomDockWidgetArea, &dockXml_);
- dockXml_.setVisible(false);
-}
-
-void MainWindow::initMenuBar()
-{
- QMenu *menuFile = ui->menuBar->addMenu(tr("File"));
-
- QAction *open = menuFile->addAction(tr("Open"));
- connect(open, SIGNAL(triggered()), this, SLOT(onOpen()));
-
- segment_ = menuFile->addAction(tr("Segment"));
- segment_->setEnabled(false);
- connect(segment_, SIGNAL(triggered()), this, SLOT(onSegment()));
-
- menuFile->addSeparator();
-
- previewPrinting_ = menuFile->addAction(tr("Preview Printing"));
- previewPrinting_->setEnabled(false);
- connect(previewPrinting_, SIGNAL(triggered()), this, SLOT(onPreviewPrint()));
-
- print_ = menuFile->addAction(tr("Print"));
- print_->setEnabled(false);
- connect(print_, SIGNAL(triggered()), this, SLOT(onPrint()));
-
- menuFile->addSeparator();
-
- export_ = menuFile->addAction(tr("Exportation"));
- export_->setEnabled(false);
- connect(export_, SIGNAL(triggered()), this, SLOT(onExportation()));
-
- menuFile->addSeparator();
-
- QAction *quit = menuFile->addAction(tr("Quit"));
- connect(quit, SIGNAL(triggered()), this, SLOT(close()));
-
- QMenu *menuAreas = ui->menuBar->addMenu(tr("Areas"));
-
- QAction *page = menuAreas->addAction(tr("Page"));
- page->setCheckable(true);
- page->setChecked(true);
- connect(page, SIGNAL(triggered()), &dockPages_, SLOT(switchVisibility()));
-
- QAction *region = menuAreas->addAction(tr("Region"));
- region->setCheckable(true);
- region->setChecked(true);
- connect(region, SIGNAL(triggered()), &dockRegion_, SLOT(switchVisibility()));
-
- QAction *xml = menuAreas->addAction(tr("Xml"));
- xml->setCheckable(true);
- xml->setChecked(false);
- connect(xml, SIGNAL(triggered()), &dockXml_, SLOT(switchVisibility()));
-
- QAction *preferences = ui->menuBar->addAction(tr("Preferences"));
- connect(preferences, SIGNAL(triggered()), this, SLOT(onPreferences()));
-
- QAction *about = ui->menuBar->addAction(tr("About"));
- connect(about, SIGNAL(triggered()), this, SLOT(onAbout()));
-}
-
-void MainWindow::setActionsEnabled(bool isSegmented)
-{
- segment_->setEnabled(!isSegmented);
- print_->setEnabled(isSegmented);
- previewPrinting_->setEnabled(isSegmented);
-}
-
-void MainWindow::disableActions()
-{
- segment_->setEnabled(false);
- print_->setEnabled(false);
- previewPrinting_->setEnabled(false);
- export_->setEnabled(false);
-}
-
-void MainWindow::connectWidgets()
-{
- // Each time the scene rect change (when a new picture is loaded), we fit the scene background rectangle in the view.
- connect(&scene_, SIGNAL(sceneRectChanged(QRectF)), &graphicsView_, SLOT(fitInView(QRectF)));
- // When dragging with right click, disable selection.
- connect(&graphicsView_, SIGNAL(beginDrag()), &scene_, SLOT(disableSelection()));
- connect(&graphicsView_, SIGNAL(endDrag()), &scene_, SLOT(enableSelection()));
-
- // If double click on a picture of the page widget -> draw it on background scene.
- connect(&pagesWidget_, SIGNAL(imageSelectionned(QString)), this, SLOT(onFileChanged(QString)));
-
- // Connect the scene to the xml widget and vice versa.
- connect(&scene_, SIGNAL(newSelection(QList<RegionItem*>)), this, SLOT(onRegionSelection(QList<RegionItem*>)));
- connect(xmlWidget_.view(), SIGNAL(select(QList<XmlItem*>)), this, SLOT(onXmlSelect(QList<XmlItem*>)));
- connect(xmlWidget_.view(), SIGNAL(unselect(QList<XmlItem*>)), this, SLOT(onXmlUnselect(QList<XmlItem*>)));
- connect(xmlWidget_.view(), SIGNAL(emptySelection()), &scene_, SLOT(selectBase()));
- connect(xmlWidget_.view(), SIGNAL(resetSelection()), &scene_, SLOT(clearSelection()));
-
- // Connect the scene with the region widget.
- connect(®ionWidget_, SIGNAL(checkStateChanged(GraphicsRegion::Id,bool)), &scene_, SLOT(setVisible(GraphicsRegion::Id,bool)));
-
- // Connect the xml widget with the region widget.
- connect(®ionWidget_, SIGNAL(checkStateChanged(QString)), xmlWidget_.view(), SLOT(setFilterString(QString)));
-
- connect(&runner_, SIGNAL(progress()), progressDialog_, SLOT(run()));
- connect(&runner_, SIGNAL(new_progress_max_value(int)), progressDialog_, SLOT(setMaximum(int)));
- connect(&runner_, SIGNAL(new_progress_label(QString)), progressDialog_, SLOT(setLabelText(QString)));
- connect(&runner_, SIGNAL(finished()), progressDialog_, SLOT(close()));
- connect(&runner_, SIGNAL(xml_saved(QString)), this, SLOT(onXmlSaved(QString)));
-}
-
-void MainWindow::onOpen()
-{
- QStringList paths = QFileDialog::getOpenFileNames(this, "Open Image(s)", QDir::homePath(),
- "Images (*.png *.jpg *.ppm *.bmp)");
- setWindowTitle(tr("GScribo"));
-
- if(paths.count() > 0)
- {
- QStringList filenames = pagesWidget_.filenames();
- QString path;
-
- int counter = 0;
- bool isContained;
- // Check for an image not already added to the page widget.
- do
- {
- path = paths[counter];
- counter++;
- isContained = filenames.contains(path);
- } while(isContained && counter < paths.count());
-
- if(!isContained)
- {
- pagesWidget_.addPicture(path, QPixmap(path));
-
- // If more than one file, we store it in the page widget.
- for(int i = counter; i < paths.count(); i++)
- {
- // Check if the page widget contains the image.
- if(!filenames.contains(paths[i]))
- {
- path = paths[i];
- pagesWidget_.addPicture(path, QPixmap(path));
- }
- }
-
- pagesWidget_.setCurrentRow(0);
- pagesWidget_.scrollToTop();
- }
-
- // Change current scene.
- onFileChanged(path);
- }
-}
-
-void MainWindow::onSegment()
-{
- QStringList filenames;
-
- filenames << scene_.backgroundPath();
-
- // Run segmentation of page(s).
- progressDialog_->reset();
- runner_.start_demat(filenames);
-}
-
-void MainWindow::onPreviewPrint()
-{
- QPrinter printer(QPrinter::HighResolution);
- printer.setPaperSize(QPrinter::A4);
- printer.setResolution(300);
-
- QPrintPreviewDialog preview(&printer, this);
- connect(&preview, SIGNAL(paintRequested(QPrinter*)), this, SLOT(printScene(QPrinter*)));
-
- preview.exec();
-}
-
-void MainWindow::onPrint()
-{
- QPrinter printer(QPrinter::HighResolution);
- printer.setPaperSize(QPrinter::A4);
- printer.setResolution(300);
-
- QPrintDialog dialog(&printer, this);
- dialog.setWindowTitle("Print Document");
-
- if(dialog.exec() != QDialog::Accepted)
- return;
-
- printScene(&printer);
-}
-
-void MainWindow::printScene(QPrinter *printer)
-{
- QPainter painter(printer);
- QStyleOptionGraphicsItem options;
-
- scene_.backgroundPixmap()->paint(&painter, &options, 0);
-
- // Paint backwards items first.
- printItems(&painter, scene_.root()->childsFrom(GraphicsRegion::TextRegion), &options);
- printItems(&painter, scene_.root()->childsFrom(GraphicsRegion::Image), &options);
-
- for(int i = GraphicsRegion::Line; i < GraphicsRegion::Image; i++)
- printItems(&painter, scene_.root()->childsFrom(static_cast<GraphicsRegion::Id>(i)), &options);
-
- for(int i = GraphicsRegion::Noise; i <= GraphicsRegion::Meanline; i++)
- printItems(&painter, scene_.root()->childsFrom(static_cast<GraphicsRegion::Id>(i)), &options);
-}
-
-void MainWindow::printItems(QPainter *painter, const QList<QGraphicsItem *>& items, QStyleOptionGraphicsItem *options)
-{
- foreach(QGraphicsItem *child, items)
- {
- if(child->isVisible())
- {
- QRect viewport = scene_.backgroundPixmap()->mapRectFromItem(child, child->boundingRect()).toRect();
- painter->translate(abs(child->boundingRect().x() - viewport.x()),
- abs(child->boundingRect().y() - viewport.y()));
- child->paint(painter, options);
- painter->resetTransform();
- }
- }
-}
-
-void MainWindow::onExportation()
-{
- QMessageBox messageBox(this);
- messageBox.setWindowTitle("Information");
- messageBox.setText("This feature is not available yet");
- messageBox.exec();
- return;
-
- QFileInfo fileInfo(scene_.backgroundPath());
- QString outputSuggestion = fileInfo.baseName() + ".pdf";
- QString output = QFileDialog::getSaveFileName(0, tr("Export Document As ..."), outputSuggestion,
- tr("PDF (*.pdf);; HTML (*.html *.htm"));
-
- if(!output.isEmpty())
- {
- progressDialog_->reset();
- runner_.start_export(scene_.backgroundPath(), xml_.filename(), output);
- }
-}
-
-void MainWindow::onXmlSaved(const QString& filename)
-{
- xml_.load(filename);
- xmlWidget_.changeView(xml_.xmlItem());
- scene_.setRoot(xml_.graphicsItem());
-
- setActionsEnabled(true);
- export_->setEnabled(xml_.recognized());
-}
-
-void MainWindow::onFileChanged(const QString& filename)
-{
- // If it's not the current scene.
- if(scene_.backgroundPath() != filename)
- {
- QString xmlPath = Xml::getPath(filename);
-
- if(filename.isEmpty())
- {
- xmlPath = QString();
- disableActions();
- }
- // Check if the xml file already exists.
- else if(!QFile(xmlPath).exists())
- {
- xmlPath = QString();
- setActionsEnabled(false);
- }
- else
- setActionsEnabled(true);
-
- xml_.load(xmlPath);
- scene_.changeScene(filename, xml_.graphicsItem());
- xmlWidget_.changeView(xml_.xmlItem());
- export_->setEnabled(xml_.recognized());
- }
-}
-
-void MainWindow::onRegionSelection(QList<RegionItem *> regionItems)
-{
- if(!regionItems.isEmpty())
- xmlWidget_.view()->displayOnly(toXmlItems(regionItems));
- else
- {
- xmlWidget_.view()->reset();
- xmlWidget_.view()->displayAll();
- xmlWidget_.view()->expandAll();
- }
-}
-
-void MainWindow::onXmlChangeSelection(QList<XmlItem *> xmlItems, bool select)
-{
- QList<RegionItem *> regionItems = toRegionItems(xmlItems);
-
- if(!regionItems.isEmpty())
- {
- if(select)
- scene_.select(regionItems);
- else
- scene_.unselect(regionItems);
- }
-}
-
-QList<RegionItem *> MainWindow::toRegionItems(QList<XmlItem *> xmlItems) const
-{
- QList<RegionItem *> regionItems;
- XmlItem *child;
- foreach(child, xmlItems)
- {
- if(child->regionItem())
- regionItems << child->regionItem();
- }
-
- return regionItems;
-}
-
-QList<XmlItem *> MainWindow::toXmlItems(QList<RegionItem *> regionItems) const
-{
- QList<XmlItem *> xmlItems;
- RegionItem *child;
- foreach(child, regionItems)
- xmlItems << child->xmlItem();
-
- return xmlItems;
-}
diff --git a/GScribo/mainwindow.h b/GScribo/mainwindow.h
deleted file mode 100644
index 0637f44..0000000
--- a/GScribo/mainwindow.h
+++ /dev/null
@@ -1,120 +0,0 @@
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QPrintPreviewDialog>
-#include <QGraphicsView>
-#include <QPrintDialog>
-#include <QMainWindow>
-#include <QHBoxLayout>
-#include <QDockWidget>
-#include <QFileDialog>
-#include <QGroupBox>
-#include <QPrinter>
-
-#include "Preferences/preferencesdialog.h"
-#include "Processing/progressdialog.h"
-#include "PagesWidget/pageswidget.h"
-#include "Rendering/graphicsview.h"
-#include "XmlWidget/xmlwidget.h"
-#include "Processing/runner.h"
-#include "Rendering/scene.h"
-#include "regionwidget.h"
-#include "aboutdialog.h"
-#include "dockwidget.h"
-#include "xml.h"
-
-namespace Ui
-{
- class MainWindow;
-}
-
-class MainWindow:
- public QMainWindow
-{
- Q_OBJECT
-
- public:
- MainWindow(QWidget *parent = 0);
- ~MainWindow();
-
- protected:
- void changeEvent(QEvent *e);
-
- private:
- void initGraphicsRegion();
- void initDialogsWidget();
- void initPageWidget();
- void initRegionWidget();
- void initXmlWidget();
- void initMenuBar();
- void connectWidgets();
-
- void setActionsEnabled(bool isSegmented);
- void disableActions();
-
- void printItems(QPainter *painter, const QList<QGraphicsItem *>& items, QStyleOptionGraphicsItem *options);
-
- Xml processTmpXml(const QString& filename) const;
- QList<RegionItem *> toRegionItems(QList<XmlItem *> regionItems) const;
- QList<XmlItem *> toXmlItems(QList<RegionItem *> xmlItems) const;
-
- Ui::MainWindow *ui;
-
- DockWidget dockRegion_;
- DockWidget dockPages_;
- DockWidget dockXml_;
-
- GraphicsView graphicsView_;
- Scene scene_;
-
- PagesWidget pagesWidget_;
- RegionWidget regionWidget_;
-
- AboutDialog *aboutDialog_;
- ProgressDialog *progressDialog_;
- PreferencesDialog *preferencesDialog_;
-
- XmlWidget xmlWidget_;
- Xml xml_;
- Runner runner_;
-
- QAction *segment_;
- QAction *previewPrinting_;
- QAction *print_;
- QAction *export_;
-
- public slots:
- void printScene(QPrinter *printer);
-
- private slots:
- void onOpen();
- void onSegment();
- void onPreviewPrint();
- void onPrint();
- void onExportation();
- inline void onPreferences();
- inline void onAbout();
-
- void onXmlSaved(const QString& filename);
- void onFileChanged(const QString& filename);
-
- void onRegionSelection(QList<RegionItem *> regionItems);
-
- void onXmlChangeSelection(QList<XmlItem *> xmlItems, bool select);
- inline void onXmlSelect(QList<XmlItem *> xmlItems);
- inline void onXmlUnselect(QList<XmlItem *> xmlItems);
-};
-
-inline void MainWindow::onPreferences()
-{ preferencesDialog_->show(); }
-
-inline void MainWindow::onAbout()
-{ aboutDialog_->show(); }
-
-inline void MainWindow::onXmlSelect(QList<XmlItem *> xmlItems)
-{ onXmlChangeSelection(xmlItems, true); }
-
-inline void MainWindow::onXmlUnselect(QList<XmlItem *> xmlItems)
-{ onXmlChangeSelection(xmlItems, false); }
-
-#endif // MAINWINDOW_H
diff --git a/GScribo/region.h b/GScribo/region.h
deleted file mode 100644
index ee8d836..0000000
--- a/GScribo/region.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef REGION_H
-#define REGION_H
-
-#include <QColor>
-
-namespace GraphicsRegion
-{
- // WARNING : The order is important.
- enum Id
- {
- TextRegion,
- Line,
-
- VerticalSeparator,
- HorizontalSeparator,
- WhiteSpaceSeparator,
-
- Image,
- Noise,
- Table,
- Maths,
- Graphic,
- Chart,
-
- Baseline,
- Meanline,
-
- Text,
- Separators,
- Miscellaneous,
- Typology,
-
- None
- };
-
- struct Data
- {
- QColor color;
- QString name;
- GraphicsRegion::Id region;
- GraphicsRegion::Id parent;
- int zValue;
- };
-}
-
-namespace Separator
-{
- enum FindSeparator
- {
- Lines,
- Whitespaces,
- Both
- };
-}
-
-#endif // REGION_H
diff --git a/GScribo/regionwidget.cpp b/GScribo/regionwidget.cpp
deleted file mode 100644
index 5d1a95e..0000000
--- a/GScribo/regionwidget.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-#include "regionwidget.h"
-
-RegionWidget::RegionWidget(QWidget *parent) :
- QTreeWidget(parent)
-{
- setHeaderHidden(true);
- setSelectionMode(QAbstractItemView::NoSelection);
-
- addTopLevelItem(createRoot("Text", GraphicsRegion::Text, GraphicsRegion::TextRegion, GraphicsRegion::Line));
- addTopLevelItem(createRoot("Typological Lines", GraphicsRegion::Typology, GraphicsRegion::Baseline, GraphicsRegion::Meanline));
- addTopLevelItem(createRoot("Separators", GraphicsRegion::Separators, GraphicsRegion::VerticalSeparator, GraphicsRegion::WhiteSpaceSeparator));
- addTopLevelItem(createRoot("Miscellaneous", GraphicsRegion::Miscellaneous, GraphicsRegion::Image, GraphicsRegion::Chart));
-
- expandAll();
-
- connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(checkStateChanged(QTreeWidgetItem*)));
-}
-
-QTreeWidgetItem *RegionWidget::createRoot(const QString& text, const GraphicsRegion::Id& region, const GraphicsRegion::Id& begin, const GraphicsRegion::Id& end)
-{
- // Create root.
- QTreeWidgetItem *rootItem = createItem(text, region);
-
- // Fill root with corresponding childs.
- for(int region_ = begin; region_ <= end; region_++)
- fillRoot(rootItem, static_cast<GraphicsRegion::Id>(region_));
-
- return rootItem;
-}
-
-QTreeWidgetItem *RegionWidget::createItem(const QString& text, const GraphicsRegion::Id& region, const QColor& color)
-{
- QTreeWidgetItem *item = new QTreeWidgetItem;
- item->setText(0, text);
- item->setCheckState(0, Qt::Checked);
- item->setBackgroundColor(0, color);
- // Store graphical id in the object to recognize it afterward.
- item->setData(0, Qt::UserRole, static_cast<int>(region));
-
- return item;
-}
-
-void RegionWidget::checkStateChanged(QTreeWidgetItem *item)
-{
- // If it's a root item, go to childs.
- if(item->childCount() != 0)
- {
- QTreeWidgetItem *child;
- for(int i = 0; i < item->childCount(); i++)
- {
- child = item->child(i);
- child->setCheckState(0, item->checkState(0));
- }
- }
- else
- {
- if(item->checkState(0) == Qt::Checked)
- {
- filterString_.append('|' + item->text(0));
- emit checkStateChanged(static_cast<GraphicsRegion::Id>(item->data(0, Qt::UserRole).toInt()), true);
- }
- else
- {
- filterString_.remove('|' + item->text(0), Qt::CaseSensitive);
- emit checkStateChanged(static_cast<GraphicsRegion::Id>(item->data(0, Qt::UserRole).toInt()), false);
- }
-
- //emit checkStateChanged(filterString_);
- }
-}
diff --git a/GScribo/regionwidget.h b/GScribo/regionwidget.h
deleted file mode 100644
index aaa6eda..0000000
--- a/GScribo/regionwidget.h
+++ /dev/null
@@ -1,40 +0,0 @@
-#ifndef REGIONWIDGET_H
-#define REGIONWIDGET_H
-
-#include <QTreeWidget>
-#include <QLabel>
-
-#include "xml.h"
-
-class RegionWidget :
- public QTreeWidget
-{
- Q_OBJECT
-
- public:
- explicit RegionWidget(QWidget *parent = 0);
-
- inline QString filterString() const;
-
- private:
- QTreeWidgetItem *createRoot(const QString& text, const GraphicsRegion::Id& region, const GraphicsRegion::Id& begin, const GraphicsRegion::Id& end);
- QTreeWidgetItem *createItem(const QString& text, const GraphicsRegion::Id& region, const QColor& color = QColor::fromRgb(255, 255, 255));
- inline void fillRoot(QTreeWidgetItem *rootItem, const GraphicsRegion::Id& region);
-
- QString filterString_;
-
- private slots:
- void checkStateChanged(QTreeWidgetItem *item);
-
- signals:
- void checkStateChanged(const GraphicsRegion::Id& region, bool checked);
- void checkStateChanged(const QString& filterString);
-};
-
-inline void RegionWidget::fillRoot(QTreeWidgetItem *rootItem, const GraphicsRegion::Id& region)
-{ GraphicsRegion::Data data = Xml::dataFromRegion(region); filterString_.append('|' + data.name); rootItem->addChild(createItem(data.name, region, data.color)); }
-
-inline QString RegionWidget::filterString() const
-{ return filterString_.right(filterString_.count()-1); }
-
-#endif // REGIONWIDGET_H
diff --git a/GScribo/variantpointer.h b/GScribo/variantpointer.h
deleted file mode 100644
index a11072c..0000000
--- a/GScribo/variantpointer.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef VARIANTPOINTER_H
-#define VARIANTPOINTER_H
-
-#include <QVariant>
-
-template<typename T> class VariantPointer
-{
- public:
- static inline QVariant toQVariant(T *pointer)
- { return QVariant::fromValue(static_cast<void *>(pointer)); }
-
- static inline T *fromQVariant(const QVariant& variant)
- { return static_cast<T *>(variant.value<void *>()); }
-
- private:
- VariantPointer() { }
-};
-
-#endif // VARIANTPOINTER_H
diff --git a/GScribo/xml.cpp b/GScribo/xml.cpp
deleted file mode 100644
index 9b0334d..0000000
--- a/GScribo/xml.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-#include "xml.h"
-
-Xml::Xml(const QString& filename)
-{
- load(filename);
-}
-
-QString Xml::getPath(const QString& filename)
-{
- Configs *const configs = Configs::getInstance();
-
- QString xmlPath = filename;
-
- // Get xml filename from image path.
- xmlPath.remove(0, xmlPath.lastIndexOf('/')+1);
- int pos = xmlPath.lastIndexOf('.');
- xmlPath.remove(pos, xmlPath.length()-pos);
- xmlPath += "_gui.xml";
-
- return configs->generalSaveXmlCustomDirPath() + "/" + xmlPath;
-}
-
-void Xml::isRecognized(const QDomElement& textElement)
-{
- QDomElement lineElement = textElement.firstChild().nextSiblingElement("Line");
-
- // Check if the attributes "text" exists in the attributes of line in the xml file.
- isRecognized_ = lineElement.attributeNode("text").isNull() ? false : true;
-}
-
-void Xml::load(const QString& filename)
-{
- if(filename.isEmpty())
- {
- xmlItem_ = 0;
- graphicsItem_ = 0;
- filename_ = QString();
- isRecognized_ = false;
- return;
- }
-
- // Reset graphic and tree items;
- xmlItem_ = new XmlItem;
- graphicsItem_ = new RootGraphicsItem(13);
- filename_ = getPath(filename);
-
- QFile xmlFile(filename);
- xmlFile.open(QIODevice::ReadOnly);
-
- // Fill new xml tree.
- xml_.clear();
- xml_.setContent(&xmlFile);
-
- xmlFile.close();
-
- QDomElement root = xml_.documentElement();
- xmlItem_->load(root);
- xmlItem_->show();
-
- root = root.firstChild().toElement();
- XmlItem *parentTreeItem = init(root, xmlItem_);
-
- // Run through the xml file structure by structure.
- root = root.nextSibling().firstChild().toElement();
- // Check if the xml file has been recognized by the ocr or not.
- isRecognized(root);
-
- processNode(root, datas_[0], parentTreeItem);
- for(int i = 2; i < 11; i++)
- processNode(root.nextSiblingElement(datas_[i].name), datas_[i], parentTreeItem);
-}
-
-XmlItem *Xml::init(const QDomElement& root, XmlItem *rootTreeItem)
-{
- XmlItem *metadataItem = new XmlItem(root, rootTreeItem);
-
- XmlItem *contentItem = 0;
-
- // Run through "METADATA" node and subnodes.
- QDomElement node = root.firstChild().toElement();
- while(!node.isNull())
- {
- contentItem = new XmlItem(node, metadataItem, contentItem);
- node = node.nextSibling().toElement();
- }
-
- // Add "PAGE" root node and return it.
- metadataItem = new XmlItem(root.nextSibling().toElement(), rootTreeItem, metadataItem);
- metadataItem->show();
-
- return metadataItem;
-}
-
-void Xml::processNode(const QDomElement& root, const GraphicsRegion::Data& data, XmlItem *pageItem)
-{
- if(!root.isNull())
- {
- // Create corresponding tree item.
- XmlItem *regionItem = new XmlItem(root, pageItem);
-
- QDomElement node = root.firstChild().toElement();
- XmlItem *coordsItem = new XmlItem(node, regionItem);
-
- QPolygon polygon;
- XmlItem *pointItem = 0;
- QString x, y;
-
- // Run through all points data.
- node = node.firstChild().toElement();
- while(!node.isNull())
- {
- x = node.attribute("x", "null");
- y = node.attribute("y", "null");
-
- pointItem = new XmlItem(node, coordsItem, pointItem);
-
- polygon << QPoint(x.toInt(), y.toInt());
- node = node.nextSibling().toElement();
- }
-
- // Create the graphics item from data structure.
- RegionItem *graphicsItem = new RegionItem(polygon, graphicsItem_);
- graphicsItem->loadData(data);
- graphicsItem_->addItemFrom(graphicsItem, data.region);
-
- // Store xml item and graphics item in each object for selection.
- regionItem->setRegionItem(graphicsItem);
- graphicsItem->setXmlItem(regionItem);
-
- if(data.region == GraphicsRegion::TextRegion)
- processLineNode(root.firstChild().nextSiblingElement("Line"), coordsItem);
-
- // Run through all nodes from the same data structure recursively.
- processNode(root.nextSiblingElement(data.name), data, pageItem);
- }
-}
-
-void Xml::processLineNode(const QDomElement& root, XmlItem *precItem)
-{
- if(!root.isNull())
- {
- // Create corresponding tree item.
- XmlItem *lineItem = new XmlItem(root, precItem->parent(), precItem);
-
- QDomElement node = root.firstChild().toElement();
- XmlItem *coordsItem = new XmlItem(node, lineItem);
-
- QPolygon polygon;
- XmlItem *pointItem = 0;
-
- QString xs, ys;
- int x, y;
-
- int xMin = INT_MAX;
- int xMax = INT_MIN;
-
- // Run through all points data.
- node = node.firstChild().toElement();
- while(!node.isNull())
- {
- xs = node.attribute("x", "null");
- ys = node.attribute("y", "null");
-
- pointItem = new XmlItem(node, coordsItem, pointItem);
-
- x = xs.toInt();
- y = ys.toInt();
-
- // Get beginning and end of line.
- if(xMin > x)
- xMin = x;
- if(xMax < x)
- xMax = x;
-
- polygon << QPoint(x, y);
- node = node.nextSibling().toElement();
- }
-
- // Create the graphics item from data structure.
- RegionItem *graphicsItem = new RegionItem(polygon, graphicsItem_);
- graphicsItem->loadData(datas_[1]);
- graphicsItem_->addItemFrom(graphicsItem, datas_[1].region);
-
- // Store xml item and graphics item in each object for selection.
- lineItem->setRegionItem(graphicsItem);
- graphicsItem->setXmlItem(lineItem);
-
- // Get meanline and baseline.
- processTypoNode(root, QPoint(xMin, xMax));
- // Run through all line nodes recursively.
- processLineNode(root.nextSiblingElement(datas_[1].name), lineItem);
- }
-}
-
-void Xml::processTypoNode(const QDomElement& root, const QPoint& xPoint)
-{
- int yPos = root.attribute("baseline", "null").toInt();
- QGraphicsLineItem *baselineItem = new QGraphicsLineItem(QLine(QPoint(xPoint.x(), yPos), QPoint(xPoint.y(), yPos)));
- baselineItem->setZValue(datas_[11].zValue);
- graphicsItem_->addItemFrom(baselineItem, datas_[11].region);
-
- yPos = root.attribute("meanline", "null").toInt();
- QGraphicsLineItem *meanlineItem = new QGraphicsLineItem(QLine(QPoint(xPoint.x(), yPos), QPoint(xPoint.y(), yPos)));
- meanlineItem->setZValue(datas_[12].zValue);
- graphicsItem_->addItemFrom(meanlineItem, datas_[12].region);
-}
diff --git a/GScribo/xml.h b/GScribo/xml.h
deleted file mode 100644
index f9274ed..0000000
--- a/GScribo/xml.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef XML_H
-#define XML_H
-
-#include <QTreeWidgetItem>
-#include <QGraphicsItem>
-#include <QStringList>
-#include <QDomElement>
-#include <QDomAttr>
-#include <climits>
-#include <QFile>
-
-#include "Rendering/rootgraphicsitem.h"
-#include "Rendering/regionitem.h"
-#include "XmlWidget/xmlitem.h"
-#include "variantpointer.h"
-#include "configs.h"
-#include "region.h"
-
-// WARNING : The order is VERY IMPORTANT (depending on the enum).
-static const GraphicsRegion::Data datas_[] =
-{
- /* COLOR | NAME | REGION | PARENT | Z */
- { QColor::fromRgb(0, 100, 0, 110), "TextRegion", GraphicsRegion::TextRegion, GraphicsRegion::Text, 1 },
- { QColor::fromRgb(255, 0, 0, 110), "Line", GraphicsRegion::Line, GraphicsRegion::Text, 2 },
- { QColor::fromRgb(0, 0, 255, 110), "VerticalSeparatorRegion", GraphicsRegion::VerticalSeparator, GraphicsRegion::Separators, 2 },
- { QColor::fromRgb(0, 0, 255, 110), "HorizontalSeparatorRegion", GraphicsRegion::HorizontalSeparator, GraphicsRegion::Separators, 2 },
- { QColor::fromRgb(0, 0, 128, 110), "WhitespaceSeparatorRegion", GraphicsRegion::WhiteSpaceSeparator, GraphicsRegion::Separators, 2 },
- { QColor::fromRgb(255, 120, 0, 110), "ImageRegion", GraphicsRegion::Image, GraphicsRegion::Miscellaneous, 1 },
- { QColor::fromRgb(43, 39, 128, 110), "NoiseRegion", GraphicsRegion::Noise, GraphicsRegion::Miscellaneous, 2 },
- { QColor::fromRgb(220, 246, 0, 110), "TableRegion", GraphicsRegion::Table, GraphicsRegion::Miscellaneous, 2 },
- { QColor::fromRgb(170, 0, 255, 110), "MathsRegion", GraphicsRegion::Maths, GraphicsRegion::Miscellaneous, 2 },
- { QColor::fromRgb(255, 0, 144, 110), "GraphicsRegion", GraphicsRegion::Graphic, GraphicsRegion::Miscellaneous, 2 },
- { QColor::fromRgb(0, 204, 255, 110), "ChartRegion", GraphicsRegion::Chart, GraphicsRegion::Miscellaneous, 2 },
- { QColor::fromRgb(128, 0, 255), "Baseline", GraphicsRegion::Baseline, GraphicsRegion::Typology, 3 },
- { QColor::fromRgb(128, 0, 255), "Meanline", GraphicsRegion::Meanline, GraphicsRegion::Typology, 3 },
- { QColor::fromRgb(255, 255, 255), "Text", GraphicsRegion::Text, GraphicsRegion::None, 0 },
- { QColor::fromRgb(255, 255, 255), "Separators", GraphicsRegion::Separators, GraphicsRegion::None, 0 },
- { QColor::fromRgb(255, 255, 255), "Miscellaneous", GraphicsRegion::Miscellaneous, GraphicsRegion::None, 0 },
- { QColor::fromRgb(255, 255, 255), "Typological Lines", GraphicsRegion::Typology, GraphicsRegion::None, 0 }
-};
-
-class Xml
-{
- public:
- explicit Xml(const QString& filename = QString());
-
- inline XmlItem *xmlItem();
- inline RootGraphicsItem *graphicsItem();
-
- inline QDomDocument document() const;
- inline QString filename() const;
- inline bool recognized() const;
-
- static QString getPath(const QString& filename);
-
- void load(const QString& filename);
- inline static GraphicsRegion::Data dataFromRegion(GraphicsRegion::Id region);
-
- private:
- XmlItem *init(const QDomElement& root, XmlItem *rootTreeItem);
- void isRecognized(const QDomElement& element);
-
- void processNode(const QDomElement& root, const GraphicsRegion::Data& data, XmlItem *rootTreeItem);
- void processLineNode(const QDomElement& root, XmlItem *rootTreeItem);
- void processTypoNode(const QDomElement& root, const QPoint& xPoint);
-
- RootGraphicsItem *graphicsItem_;
- XmlItem *xmlItem_;
-
- QDomDocument xml_;
- QString filename_;
- bool isRecognized_;
-};
-
-inline XmlItem *Xml::xmlItem()
-{ return xmlItem_; }
-
-inline RootGraphicsItem *Xml::graphicsItem()
-{ return graphicsItem_; }
-
-inline QDomDocument Xml::document() const
-{ return xml_; }
-
-inline QString Xml::filename() const
-{ return filename_; }
-
-inline GraphicsRegion::Data Xml::dataFromRegion(GraphicsRegion::Id region)
-{ return datas_[region]; }
-
-inline bool Xml::recognized() const
-{ return isRecognized_; }
-
-#endif // XML_H
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 14a2e51..378f46c 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,4 @@
+<<<<<<< HEAD
2013-04-17 Guillaume Lazzara <z(a)lrde.epita.fr>
* scribo/core/object_links.hh: Always initialize links in
@@ -682,6 +683,147 @@
* scribo/make/text_components_image.hh,
* scribo/primitive/extract/non_text.hh: Here.
+=======
+2013-02-27 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Move new viewer to scribo/demo.
+
+ * scribo/demo/viewer/BUGS,
+ * scribo/demo/viewer/GScribo.pro,
+ * scribo/demo/viewer/GScribo.pro.user,
+ * scribo/demo/viewer/GScribo.pro.user.1.3,
+ * scribo/demo/viewer/Makefile.am,
+ * scribo/demo/viewer/PagesWidget/pagesdelegate.cc,
+ * scribo/demo/viewer/PagesWidget/pagesdelegate.hh,
+ * scribo/demo/viewer/PagesWidget/pagesmodel.cc,
+ * scribo/demo/viewer/PagesWidget/pagesmodel.hh,
+ * scribo/demo/viewer/PagesWidget/pageswidget.cc,
+ * scribo/demo/viewer/PagesWidget/pageswidget.hh,
+ * scribo/demo/viewer/Preferences/generaloptions.cc,
+ * scribo/demo/viewer/Preferences/generaloptions.hh,
+ * scribo/demo/viewer/Preferences/generaloptions.ui,
+ * scribo/demo/viewer/Preferences/ocroptions.cc,
+ * scribo/demo/viewer/Preferences/ocroptions.hh,
+ * scribo/demo/viewer/Preferences/ocroptions.ui,
+ * scribo/demo/viewer/Preferences/optionwidget.hh,
+ * scribo/demo/viewer/Preferences/preferencesdialog.cc,
+ * scribo/demo/viewer/Preferences/preferencesdialog.hh,
+ * scribo/demo/viewer/Preferences/preferencesdialog.ui,
+ * scribo/demo/viewer/Preferences/preprocessingoptions.cc,
+ * scribo/demo/viewer/Preferences/preprocessingoptions.hh,
+ * scribo/demo/viewer/Preferences/preprocessingoptions.ui,
+ * scribo/demo/viewer/Preferences/segmentationoptions.cc,
+ * scribo/demo/viewer/Preferences/segmentationoptions.hh,
+ * scribo/demo/viewer/Preferences/segmentationoptions.ui,
+ * scribo/demo/viewer/Processing/preprocess.cc,
+ * scribo/demo/viewer/Processing/preprocess.hh,
+ * scribo/demo/viewer/Processing/process.cc,
+ * scribo/demo/viewer/Processing/process.hh,
+ * scribo/demo/viewer/Processing/progressdialog.cc,
+ * scribo/demo/viewer/Processing/progressdialog.hh,
+ * scribo/demo/viewer/Processing/runner.cc,
+ * scribo/demo/viewer/Processing/runner.hh,
+ * scribo/demo/viewer/Rendering/abstractregionitem.hh,
+ * scribo/demo/viewer/Rendering/backgroundtexture.hh,
+ * scribo/demo/viewer/Rendering/graphicsview.cc,
+ * scribo/demo/viewer/Rendering/graphicsview.hh,
+ * scribo/demo/viewer/Rendering/regionitem.cc,
+ * scribo/demo/viewer/Rendering/regionitem.hh,
+ * scribo/demo/viewer/Rendering/rootgraphicsitem.cc,
+ * scribo/demo/viewer/Rendering/rootgraphicsitem.hh,
+ * scribo/demo/viewer/Rendering/scene.cc,
+ * scribo/demo/viewer/Rendering/scene.hh,
+ * scribo/demo/viewer/Rendering/selection.cc,
+ * scribo/demo/viewer/Rendering/selection.hh,
+ * scribo/demo/viewer/TODO,
+ * scribo/demo/viewer/XmlWidget/attributesmodel.cc,
+ * scribo/demo/viewer/XmlWidget/attributesmodel.hh,
+ * scribo/demo/viewer/XmlWidget/selectionproxy.hh,
+ * scribo/demo/viewer/XmlWidget/xmlattributes.cc,
+ * scribo/demo/viewer/XmlWidget/xmlattributes.hh,
+ * scribo/demo/viewer/XmlWidget/xmldelegate.hh,
+ * scribo/demo/viewer/XmlWidget/xmlitem.cc,
+ * scribo/demo/viewer/XmlWidget/xmlitem.hh,
+ * scribo/demo/viewer/XmlWidget/xmlmodel.cc,
+ * scribo/demo/viewer/XmlWidget/xmlmodel.hh,
+ * scribo/demo/viewer/XmlWidget/xmlview.cc,
+ * scribo/demo/viewer/XmlWidget/xmlview.hh,
+ * scribo/demo/viewer/XmlWidget/xmlwidget.cc,
+ * scribo/demo/viewer/XmlWidget/xmlwidget.hh,
+ * scribo/demo/viewer/aboutdialog.cc,
+ * scribo/demo/viewer/aboutdialog.hh,
+ * scribo/demo/viewer/aboutdialog.ui,
+ * scribo/demo/viewer/config.cc,
+ * scribo/demo/viewer/configs.cc,
+ * scribo/demo/viewer/configs.hh,
+ * scribo/demo/viewer/defs.hh,
+ * scribo/demo/viewer/dir.hh,
+ * scribo/demo/viewer/dockwidget.cc,
+ * scribo/demo/viewer/dockwidget.hh,
+ * scribo/demo/viewer/general_options.hh,
+ * scribo/demo/viewer/help_dialog.hh,
+ * scribo/demo/viewer/image_scene.hh,
+ * scribo/demo/viewer/image_view.hh,
+ * scribo/demo/viewer/main.cc,
+ * scribo/demo/viewer/mainwindow.cc,
+ * scribo/demo/viewer/mainwindow.hh,
+ * scribo/demo/viewer/mainwindow.ui,
+ * scribo/demo/viewer/ocr_options.hh,
+ * scribo/demo/viewer/option_widget.cc,
+ * scribo/demo/viewer/option_widget.hh,
+ * scribo/demo/viewer/preprocess.cc,
+ * scribo/demo/viewer/preprocess.hh,
+ * scribo/demo/viewer/process.cc,
+ * scribo/demo/viewer/region.hh,
+ * scribo/demo/viewer/regionwidget.cc,
+ * scribo/demo/viewer/regionwidget.hh,
+ * scribo/demo/viewer/variantpointer.cc,
+ * scribo/demo/viewer/variantpointer.hh,
+ * scribo/demo/viewer/xml.cc,
+ * scribo/demo/viewer/xml.hh: New.
+
+ * scribo/demo/viewer/README,
+ * scribo/demo/viewer/browser_widget.cc,
+ * scribo/demo/viewer/browser_widget.hh,
+ * scribo/demo/viewer/common.hh,
+ * scribo/demo/viewer/config.hh,
+ * scribo/demo/viewer/general_options.cc,
+ * scribo/demo/viewer/general_options.ui,
+ * scribo/demo/viewer/help_dialog.cc,
+ * scribo/demo/viewer/help_dialog.ui,
+ * scribo/demo/viewer/icons/olena_smaller.jpg,
+ * scribo/demo/viewer/image_region.cc,
+ * scribo/demo/viewer/image_region.hh,
+ * scribo/demo/viewer/image_region.hxx,
+ * scribo/demo/viewer/image_scene.cc,
+ * scribo/demo/viewer/image_view.cc,
+ * scribo/demo/viewer/image_widget.cc,
+ * scribo/demo/viewer/image_widget.hh,
+ * scribo/demo/viewer/key_widget.cc,
+ * scribo/demo/viewer/key_widget.hh,
+ * scribo/demo/viewer/ocr_options.cc,
+ * scribo/demo/viewer/ocr_options.ui,
+ * scribo/demo/viewer/preferences_dialog.cc,
+ * scribo/demo/viewer/preferences_dialog.hh,
+ * scribo/demo/viewer/preferences_dialog.ui,
+ * scribo/demo/viewer/preprocessing_options.cc,
+ * scribo/demo/viewer/preprocessing_options.hh,
+ * scribo/demo/viewer/preprocessing_options.ui,
+ * scribo/demo/viewer/process.hh,
+ * scribo/demo/viewer/runner.cc,
+ * scribo/demo/viewer/runner.hh,
+ * scribo/demo/viewer/segmentation_options.cc,
+ * scribo/demo/viewer/segmentation_options.hh,
+ * scribo/demo/viewer/segmentation_options.ui,
+ * scribo/demo/viewer/step_widget.cc,
+ * scribo/demo/viewer/step_widget.hh,
+ * scribo/demo/viewer/viewer.cc,
+ * scribo/demo/viewer/viewer.hh,
+ * scribo/demo/viewer/viewer.hxx,
+ * scribo/demo/viewer/viewer.qrc ,
+ * scribo/demo/viewer/xml_widget.cc,
+ * scribo/demo/viewer/xml_widget.hh: Remove.
+>>>>>>> Move new viewer to scribo/demo.
2013-03-08 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/GScribo/BUGS b/scribo/demo/viewer/BUGS
similarity index 100%
rename from GScribo/BUGS
rename to scribo/demo/viewer/BUGS
diff --git a/scribo/demo/viewer/GScribo.pro b/scribo/demo/viewer/GScribo.pro
new file mode 100644
index 0000000..d607cc5
--- /dev/null
+++ b/scribo/demo/viewer/GScribo.pro
@@ -0,0 +1,83 @@
+# -------------------------------------------------
+# Project created by QtCreator 2013-01-21T09:20:54
+# -------------------------------------------------
+QT += xml
+INCLUDEPATH += /lrde/home/stage/froger_a/olena/scribo/ \
+ /lrde/home/stage/froger_a/olena/milena/ \
+ /lrde/home/stage/froger_a/olena/_build/scribo/demo/
+QMAKE_CXXFLAGS += -DNDEBUG \
+ -DMLN_WO_GLOBAL_VARS
+LIBS += -I/usr/include/graphicsImage \
+ -lGraphicsMagick++ \
+ -ltesseract_full \
+ -ltiff
+TARGET = GScribo
+TEMPLATE = app
+SOURCES += regionwidget.cc \
+ mainwindow.cc \
+ main.cc \
+ xml.cc \
+ Rendering/scene.cc \
+ Rendering/selection.cc \
+ Rendering/regionitem.cc \
+ Rendering/graphicsview.cc \
+ PagesWidget/pageswidget.cc \
+ PagesWidget/pagesmodel.cc \
+ PagesWidget/pagesdelegate.cc \
+ Preferences/segmentationoptions.cc \
+ Preferences/preprocessingoptions.cc \
+ Preferences/ocroptions.cc \
+ Preferences/generaloptions.cc \
+ Preferences/preferencesdialog.cc \
+ Processing/progressdialog.cc \
+ Processing/preprocess.cc \
+ Processing/process.cc \
+ Processing/runner.cc \
+ XmlWidget/xmlwidget.cc \
+ XmlWidget/xmlmodel.cc \
+ XmlWidget/xmlitem.cc \
+ XmlWidget/xmlattributes.cc \
+ XmlWidget/attributesmodel.cc \
+ XmlWidget/xmlview.cc
+HEADERS += mainwindow.hh \
+ variantpointer.hh \
+ regionwidget.hh \
+ aboutdialog.hh \
+ configs.hh \
+ region.hh \
+ dir.hh \
+ xml.hh \
+ Rendering/scene.hh \
+ Rendering/selection.hh \
+ Rendering/regionitem.hh \
+ Rendering/graphicsview.hh \
+ PagesWidget/pageswidget.hh \
+ PagesWidget/pagesmodel.hh \
+ Processing/preprocess.hh \
+ Processing/process.hh \
+ Processing/runner.hh \
+ Processing/progressdialog.hh \
+ Preferences/segmentationoptions.hh \
+ Preferences/preprocessingoptions.hh \
+ Preferences/ocroptions.hh \
+ Preferences/generaloptions.hh \
+ Preferences/optionwidget.hh \
+ Preferences/preferencesdialog.hh \
+ XmlWidget/xmlwidget.hh \
+ XmlWidget/xmlmodel.hh \
+ XmlWidget/xmlitem.hh \
+ XmlWidget/xmlattributes.hh \
+ XmlWidget/selectionproxy.hh \
+ XmlWidget/xmldelegate.hh \
+ XmlWidget/attributesmodel.hh \
+ PagesWidget/pagesdelegate.hh \
+ Rendering/rootgraphicsitem.hh \
+ XmlWidget/xmlview.hh \
+ dockwidget.hh
+FORMS += mainwindow.ui \
+ aboutdialog.ui \
+ Preferences/preferencesdialog.ui \
+ Preferences/ocroptions.ui \
+ Preferences/segmentationoptions.ui \
+ Preferences/generaloptions.ui \
+ Preferences/preprocessingoptions.ui
diff --git a/GScribo/GScribo.pro.user b/scribo/demo/viewer/GScribo.pro.user
similarity index 100%
rename from GScribo/GScribo.pro.user
rename to scribo/demo/viewer/GScribo.pro.user
diff --git a/GScribo/GScribo.pro.user.1.3 b/scribo/demo/viewer/GScribo.pro.user.1.3
similarity index 100%
rename from GScribo/GScribo.pro.user.1.3
rename to scribo/demo/viewer/GScribo.pro.user.1.3
diff --git a/scribo/demo/viewer/Makefile.am b/scribo/demo/viewer/Makefile.am
index d79abcf..23c800b 100644
--- a/scribo/demo/viewer/Makefile.am
+++ b/scribo/demo/viewer/Makefile.am
@@ -19,96 +19,131 @@ include $(top_srcdir)/build-aux/autotroll.mk
bin_PROGRAMS = scribo-viewer
-scribo_viewer_SOURCES = viewer.cc \
+scribo_viewer_SOURCES = mainwindow.cc \
+ aboutdialog.cc \
+ configs.cc \
main.cc \
- image_widget.cc \
- xml_widget.cc \
- key_widget.cc \
- browser_widget.cc \
- image_scene.cc \
- image_view.cc \
- image_region.cc \
- help_dialog.cc \
- step_widget.cc \
- preprocessing_options.cc\
- segmentation_options.cc \
- ocr_options.cc \
- runner.cc \
- preprocess.cc \
- process.cc \
- general_options.cc \
- preferences_dialog.cc \
- option_widget.cc \
- config.cc
+ regionwidget.cc \
+ xml.cc \
+ dockwidget.cc \
+ PagesWidget/pagesdelegate.cc \
+ PagesWidget/pagesmodel.cc \
+ PagesWidget/pageswidget.cc \
+ Preferences/generaloptions.cc \
+ Preferences/ocroptions.cc \
+ Preferences/preferencesdialog.cc \
+ Preferences/preprocessingoptions.cc \
+ Preferences/segmentationoptions.cc \
+ Processing/preprocess.cc \
+ Processing/process.cc \
+ Processing/progressdialog.cc \
+ Processing/runner.cc \
+ Rendering/graphicsview.cc \
+ Rendering/regionitem.cc \
+ Rendering/scene.cc \
+ Rendering/selection.cc \
+ Rendering/rootgraphicsitem.cc \
+ XmlWidget/attributesmodel.cc \
+ XmlWidget/xmlattributes.cc \
+ XmlWidget/xmlitem.cc \
+ XmlWidget/xmlmodel.cc \
+ XmlWidget/xmlview.cc \
+ XmlWidget/xmlwidget.cc
+
+
nodist_scribo_viewer_SOURCES = $(BUILT_SOURCES)
+
+
scribo_viewer_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS) -I$(srcdir) \
+ -I$(builddir) \
-I$(top_srcdir)/milena \
-I$(top_srcdir)/scribo \
$(MAGICKXX_CPPFLAGS) \
$(TESSERACT_CPPFLAGS) \
$(TIFF_CPPFLAGS) \
-DNDEBUG -DMLN_WO_GLOBAL_VARS
+
+
+
scribo_viewer_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS) \
$(STRICT_ALIASING_CXXFLAGS) -O3
+
+
+
scribo_viewer_LDFLAGS = $(QT_LDFLAGS) $(LDFLAGS) \
$(MAGICKXX_LDFLAGS) \
$(TESSERACT_LDFLAGS) \
$(TIFF_LDFLAGS)
+
+
+
scribo_viewer_LDADD = $(QT_LIBS) $(LDADD)
-BUILT_SOURCES = viewer.moc.cc \
- image_widget.moc.cc \
- xml_widget.moc.cc \
- key_widget.moc.cc \
- browser_widget.moc.cc \
- image_scene.moc.cc \
- image_view.moc.cc \
- image_region.moc.cc \
- help_dialog.ui.h \
- step_widget.moc.cc \
- preprocessing_options.moc.cc \
- preprocessing_options.ui.h \
- segmentation_options.moc.cc \
- segmentation_options.ui.h \
- ocr_options.moc.cc \
- ocr_options.ui.h \
- runner.moc.cc \
- preprocess.moc.cc \
- process.moc.cc \
- preferences_dialog.moc.cc \
- preferences_dialog.ui.h \
- general_options.moc.cc \
- general_options.ui.h \
- demodir.hh \
- viewer.qrc.cc
-
-
-noinst_HEADERS = viewer.hh \
- viewer.hxx \
- image_widget.hh \
- xml_widget.hh \
- key_widget.hh \
- browser_widget.hh \
- image_scene.hh \
- image_view.hh \
- image_region.hh \
- image_region.hxx \
- common.hh \
- help_dialog.hh \
- step_widget.hh \
- preprocessing_options.hh\
- segmentation_options.hh\
- ocr_options.hh \
- runner.hh \
- preprocess.hh \
- process.hh \
- general_options.hh \
- preferences_dialog.hh \
- option_widget.hh \
- config.hh \
- defs.hh
+
+
+BUILT_SOURCES = demodir.hh \
+ dockwidget.moc.cc \
+ Rendering/graphicsview.moc.cc \
+ mainwindow.moc.cc \
+ Preferences/ocroptions.moc.cc \
+ PagesWidget/pagesmodel.moc.cc \
+ PagesWidget/pageswidget.moc.cc \
+ Preferences/preferencesdialog.moc.cc \
+ Processing/preprocess.moc.cc \
+ Preferences/preprocessingoptions.moc.cc \
+ Processing/process.moc.cc \
+ Processing/progressdialog.moc.cc \
+ regionwidget.moc.cc \
+ Processing/runner.moc.cc \
+ Rendering/scene.moc.cc \
+ Preferences/segmentationoptions.moc.cc \
+ XmlWidget/xmlview.moc.cc \
+ XmlWidget/xmlwidget.moc.cc \
+ aboutdialog.ui.h \
+ Preferences/generaloptions.ui.h \
+ mainwindow.ui.h \
+ Preferences/generaloptions.moc.cc \
+ Preferences/ocroptions.ui.h \
+ Preferences/preferencesdialog.ui.h \
+ Preferences/preprocessingoptions.ui.h \
+ Preferences/segmentationoptions.ui.h \
+ XmlWidget/attributesmodel.moc.cc
+
+
+noinst_HEADERS = mainwindow.hh \
+ aboutdialog.hh \
+ regionwidget.hh \
+ xml.hh \
+ PagesWidget/pagesdelegate.hh \
+ PagesWidget/pagesmodel.hh \
+ PagesWidget/pageswidget.hh \
+ Preferences/generaloptions.hh \
+ Preferences/ocroptions.hh \
+ Preferences/optionwidget.hh \
+ Preferences/preferencesdialog.hh \
+ Preferences/preprocessingoptions.hh \
+ Preferences/segmentationoptions.hh \
+ Processing/preprocess.hh \
+ Processing/process.hh \
+ Processing/progressdialog.hh \
+ Processing/runner.hh \
+ Rendering/graphicsview.hh \
+ Rendering/regionitem.hh \
+ Rendering/rootgraphicsitem.hh \
+ Rendering/scene.hh \
+ Rendering/selection.hh \
+ XmlWidget/attributesmodel.hh \
+ XmlWidget/selectionproxy.hh \
+ XmlWidget/xmlattributes.hh \
+ XmlWidget/xmldelegate.hh \
+ XmlWidget/xmlitem.hh \
+ XmlWidget/xmlmodel.hh \
+ XmlWidget/xmlview.hh \
+ XmlWidget/xmlwidget.hh
+
+
# Generated files
@@ -116,6 +151,8 @@ do_subst = sed \
-e 's|@libexecdir[@]|$(libexecdir)|g' \
-e 's|@abs_demodir[@]|$(abs_top_builddir)/scribo/demo|g'
+
+
demodir.hh: $(srcdir)/demodir.hh.in Makefile
rm -f $@ $@.tmp
srcdir=''; \
@@ -124,17 +161,20 @@ demodir.hh: $(srcdir)/demodir.hh.in Makefile
chmod a-w $@.tmp
mv $@.tmp $@
+
+
CLEANFILES = $(BUILT_SOURCES)
-EXTRA_DIST = \
- general_options.ui \
- preferences_dialog.ui \
- README \
- preprocessing_options.ui\
- segmentation_options.ui \
- ocr_options.ui \
- help_dialog.ui \
- demodir.hh.in \
- viewer.qrc \
- icons/olena_smaller.jpg
+
+
+EXTRA_DIST = BUGS \
+ README \
+ aboutdialog.ui \
+ mainwindow.ui \
+ Preferences/generaloptions.ui \
+ Preferences/ocroptions.ui \
+ Preferences/preferencesdialog.ui \
+ Preferences/preprocessingoptions.ui \
+ Preferences/segmentationoptions.ui \
+ demodir.hh.in
diff --git a/scribo/demo/viewer/PagesWidget/pagesdelegate.cc b/scribo/demo/viewer/PagesWidget/pagesdelegate.cc
new file mode 100644
index 0000000..f981e1f
--- /dev/null
+++ b/scribo/demo/viewer/PagesWidget/pagesdelegate.cc
@@ -0,0 +1,38 @@
+// Copyright (C) 2013 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 "pagesdelegate.hh"
+
+PagesDelegate::PagesDelegate(QObject *parent) :
+ QStyledItemDelegate(parent)
+{
+ pen_.setColor(QColor::fromRgb(255, 69, 0, 255));
+ pen_.setWidth(2);
+}
+
+void PagesDelegate::paint(QPainter *painter,
+ const QStyleOptionViewItem& option,
+ const QModelIndex& index) const
+{
+ QStyledItemDelegate::paint(painter, option, index);
+
+ if(index.row() == index.data(Qt::UserRole+1).toInt())
+ {
+ painter->setPen(pen_);
+ painter->drawRect(option.rect);
+ painter->fillRect(option.rect, QColor::fromRgb(255, 69, 0, 60));
+ }
+}
diff --git a/scribo/demo/viewer/PagesWidget/pagesdelegate.hh b/scribo/demo/viewer/PagesWidget/pagesdelegate.hh
new file mode 100644
index 0000000..02440f8
--- /dev/null
+++ b/scribo/demo/viewer/PagesWidget/pagesdelegate.hh
@@ -0,0 +1,36 @@
+// Copyright (C) 2013 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 PAGESDELEGATE_H
+# define PAGESDELEGATE_H
+
+#include <QStyledItemDelegate>
+#include <QPainter>
+
+class PagesDelegate :
+ public QStyledItemDelegate
+{
+ public:
+ explicit PagesDelegate(QObject *parent = 0);
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+
+ private:
+ QPen pen_;
+};
+
+#endif // PAGESDELEGATE_H
diff --git a/scribo/demo/viewer/PagesWidget/pagesmodel.cc b/scribo/demo/viewer/PagesWidget/pagesmodel.cc
new file mode 100644
index 0000000..6246f18
--- /dev/null
+++ b/scribo/demo/viewer/PagesWidget/pagesmodel.cc
@@ -0,0 +1,91 @@
+// Copyright (C) 2013 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 "pagesmodel.hh"
+
+PagesModel::PagesModel(QObject *parent):
+ QAbstractListModel(parent)
+{
+ currentRow_ = 0;
+}
+
+QVariant PagesModel::data(const QModelIndex& index, int role) const
+{
+ if(!index.isValid())
+ return QVariant();
+
+ if(role == Qt::DecorationRole)
+ return pixmaps_[index.row()];
+
+ if(role == Qt::UserRole)
+ return filenames_[index.row()];
+
+ if(role == Qt::UserRole+1)
+ return currentRow_;
+
+ return QVariant();
+}
+
+void PagesModel::addPicture(const QString& filename, const QPixmap& pixmap)
+{
+ beginInsertRows(QModelIndex(), 0, 0);
+
+ pixmaps_.prepend(pixmap.scaled(QSize(200, 200),
+ Qt::KeepAspectRatio,
+ Qt::SmoothTransformation));
+ filenames_.prepend(filename);
+
+ endInsertRows();
+}
+
+void PagesModel::removePixmap(const QModelIndex &parent)
+{
+ int row = parent.row();
+
+ beginRemoveRows(parent, row, row);
+
+ pixmaps_.removeAt(row);
+ filenames_.removeAt(row);
+
+ endRemoveRows();
+}
+
+void PagesModel::setCurrentRow(int currentRow)
+{
+ beginResetModel();
+
+ currentRow_ = currentRow;
+
+ endResetModel();
+}
+
+
+QStringList PagesModel::filenames() const
+{
+ return filenames_;
+}
+
+
+int PagesModel::rowCount(const QModelIndex&) const
+{
+ return filenames_.count();
+}
+
+
+int PagesModel::currentRow() const
+{
+ return currentRow_;
+}
diff --git a/scribo/demo/viewer/PagesWidget/pagesmodel.hh b/scribo/demo/viewer/PagesWidget/pagesmodel.hh
new file mode 100644
index 0000000..2a0ec4b
--- /dev/null
+++ b/scribo/demo/viewer/PagesWidget/pagesmodel.hh
@@ -0,0 +1,51 @@
+// Copyright (C) 2013 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 PAGESMODEL_HH
+# define PAGESMODEL_HH
+
+#include <QAbstractListModel>
+#include <QIcon>
+#include <QList>
+
+class PagesModel:
+ public QAbstractListModel
+{
+ Q_OBJECT
+
+ public:
+ explicit PagesModel(QObject *parent = 0);
+
+ QStringList filenames() const;
+ int rowCount(const QModelIndex& parent = QModelIndex()) const;
+
+ int currentRow() const;
+ void setCurrentRow(int currentRow);
+
+ QVariant data(const QModelIndex& index, int role = Qt::DecorationRole) const;
+ void addPicture(const QString& filename, const QPixmap& pixmap);
+
+ private:
+ QStringList filenames_;
+ QList<QPixmap> pixmaps_;
+ int currentRow_;
+
+ public slots:
+ void removePixmap(const QModelIndex& parent);
+};
+
+
+#endif // PAGESMODEL_HH
diff --git a/scribo/demo/viewer/PagesWidget/pageswidget.cc b/scribo/demo/viewer/PagesWidget/pageswidget.cc
new file mode 100644
index 0000000..0355419
--- /dev/null
+++ b/scribo/demo/viewer/PagesWidget/pageswidget.cc
@@ -0,0 +1,119 @@
+// Copyright (C) 2013 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 <QDebug>
+#include "pageswidget.hh"
+
+PagesWidget::PagesWidget(QWidget *parent):
+ QListView(parent)
+{
+ setUniformItemSizes(true);
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
+ setViewMode(QListView::IconMode);
+ setIconSize(QSize(200, 200));
+ setMovement(QListView::Static);
+ setResizeMode(QListView::Adjust);
+ setSpacing(10);
+
+ setModel(&model_);
+ setItemDelegate(new PagesDelegate());
+
+ QShortcut *remove = new QShortcut(Qt::Key_Delete, this);
+ connect(remove, SIGNAL(activated()), this, SLOT(removeSelection()));
+ connect(this, SIGNAL(doubleClicked(QModelIndex)),
+ this, SLOT(getPicture(QModelIndex)));
+}
+
+void PagesWidget::removeSelection()
+{
+ QModelIndexList indexes = selectionModel()->selectedIndexes();
+ if(hasFocus() && indexes.count() > 0)
+ {
+ // Sort the list because after the first removal, the second row index may not be the good one.
+ qSort(indexes.begin(), indexes.end());
+
+ // From the highest row to the smallest to be sure to remove the good index.
+ for(int i = indexes.count()-1; i > -1; i--)
+ model_.removePixmap(indexes[i]);
+
+ // Draw new image on the scene.
+ getPicture(model_.index(indexes[0].row()));
+ clearSelection();
+
+ model_.setCurrentRow(indexes[0].row());
+ scrollTo(indexes[0]);
+ }
+}
+
+void PagesWidget::getPicture(const QModelIndex& index)
+{
+ QString filename = index.data(Qt::UserRole).toString();
+ model_.setCurrentRow(index.row());
+
+ emit imageSelected(filename);
+}
+
+QStringList PagesWidget::filenames() const
+{
+ return model_.filenames();
+}
+
+int PagesWidget::currentRow() const
+{
+ return model_.currentRow();
+}
+
+void PagesWidget::setCurrentRow(int currentRow)
+{
+ model_.setCurrentRow(currentRow);
+}
+
+void PagesWidget::addPicture(const QString& filename,
+ const QPixmap& pixmap)
+{
+ model_.addPicture(filename, pixmap);
+}
+
+void PagesWidget::focusOutEvent(QFocusEvent *event)
+{
+ QListView::focusOutEvent(event); clearSelection();
+}
+
+bool PagesWidget::haveNextRow() const
+{
+ return currentRow() + 1 < model_.rowCount();
+}
+
+bool PagesWidget::havePreviousRow() const
+{
+ return currentRow() - 1 >= 0;
+}
+
+void PagesWidget::selectNextRow()
+{
+ Q_ASSERT(haveNextRow());
+ QModelIndex index = model_.index(currentRow() + 1);
+ getPicture(index);
+ scrollTo(index);
+}
+
+void PagesWidget::selectPreviousRow()
+{
+ Q_ASSERT(havePreviousRow());
+ QModelIndex index = model_.index(currentRow() - 1);
+ getPicture(index);
+ scrollTo(index);
+}
diff --git a/scribo/demo/viewer/PagesWidget/pageswidget.hh b/scribo/demo/viewer/PagesWidget/pageswidget.hh
new file mode 100644
index 0000000..d159a8e
--- /dev/null
+++ b/scribo/demo/viewer/PagesWidget/pageswidget.hh
@@ -0,0 +1,61 @@
+// Copyright (C) 2013 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 PAGESWIDGET_HH
+# define PAGESWIDGET_HH
+
+#include <QListView>
+#include <QShortcut>
+
+#include "pagesdelegate.hh"
+#include "pagesmodel.hh"
+
+class PagesWidget : public QListView
+{
+ Q_OBJECT;
+
+public:
+ explicit PagesWidget(QWidget *parent = 0);
+
+ QStringList filenames() const;
+ int currentRow() const;
+ void setCurrentRow(int currentRow);
+
+ void addPicture(const QString& filename, const QPixmap& pixmap);
+
+ bool haveNextRow() const;
+ bool havePreviousRow() const;
+
+protected:
+ void focusOutEvent(QFocusEvent *event);
+
+private:
+ PagesModel model_;
+
+public slots:
+ void removeSelection();
+ void selectNextRow();
+ void selectPreviousRow();
+
+private slots:
+ void getPicture(const QModelIndex& index);
+
+signals:
+ void imageSelected(const QString& filename);
+};
+
+
+#endif // PAGESWIDGET_HH
diff --git a/scribo/demo/viewer/Preferences/generaloptions.cc b/scribo/demo/viewer/Preferences/generaloptions.cc
new file mode 100644
index 0000000..d32ee40
--- /dev/null
+++ b/scribo/demo/viewer/Preferences/generaloptions.cc
@@ -0,0 +1,60 @@
+// Copyright (C) 2013 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 "generaloptions.hh"
+#include "Preferences/generaloptions.ui.h"
+
+GeneralOptions::GeneralOptions(QWidget *parent) :
+ OptionWidget(parent),
+ ui(new Ui::GeneralOptions)
+{
+ ui->setupUi(this);
+ loadConfig();
+}
+
+GeneralOptions::~GeneralOptions()
+{
+ delete ui;
+}
+
+void GeneralOptions::loadConfig()
+{
+ Configs *const conf = Configs::getInstance();
+
+ ui->saveXml->setChecked(conf->generalSaveXmlEnabled());
+ ui->sameDir->setChecked(conf->generalSaveXmlSameDir());
+ ui->customDir->setChecked(conf->generalSaveXmlCustomDir());
+ ui->customDirValue->setText(conf->generalSaveXmlCustomDirPath());
+}
+
+
+void GeneralOptions::saveConfig()
+{
+ Configs *const conf = Configs::getInstance();
+
+ conf->setGeneralSaveXmlEnabled(ui->saveXml->isChecked());
+ conf->setGeneralSaveXmlSameDir(ui->sameDir->isChecked());
+ conf->setGeneralSaveXmlCustomDir(ui->customDir->isChecked());
+ conf->setGeneralSaveXmlCustomDirPath(ui->customDirValue->text());
+}
+
+void GeneralOptions::onCustomDirBrowseBtnClicked()
+{
+ QString dir = QFileDialog::getExistingDirectory(0, "Choose a directory");
+
+ if (!dir.isEmpty())
+ ui->customDirValue->setText(dir);
+}
diff --git a/scribo/demo/viewer/Preferences/generaloptions.hh b/scribo/demo/viewer/Preferences/generaloptions.hh
new file mode 100644
index 0000000..1d31d18
--- /dev/null
+++ b/scribo/demo/viewer/Preferences/generaloptions.hh
@@ -0,0 +1,50 @@
+// Copyright (C) 2013 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 GENERALOPTIONS_HH
+# define GENERALOPTIONS_HH
+
+#include <QFileDialog>
+
+#include "optionwidget.hh"
+#include "configs.hh"
+
+namespace Ui
+{
+ class GeneralOptions;
+}
+
+class GeneralOptions :
+ public OptionWidget
+{
+ Q_OBJECT
+
+ public:
+ explicit GeneralOptions(QWidget *parent = 0);
+ ~GeneralOptions();
+
+ virtual void loadConfig();
+ virtual void saveConfig();
+
+ private:
+ Ui::GeneralOptions *ui;
+
+ private slots:
+ void onCustomDirBrowseBtnClicked();
+
+};
+
+#endif // GENERAL_OPTIONS_HH
diff --git a/GScribo/Preferences/generaloptions.ui b/scribo/demo/viewer/Preferences/generaloptions.ui
similarity index 100%
rename from GScribo/Preferences/generaloptions.ui
rename to scribo/demo/viewer/Preferences/generaloptions.ui
diff --git a/scribo/demo/viewer/Preferences/ocroptions.cc b/scribo/demo/viewer/Preferences/ocroptions.cc
new file mode 100644
index 0000000..187a8d7
--- /dev/null
+++ b/scribo/demo/viewer/Preferences/ocroptions.cc
@@ -0,0 +1,69 @@
+// Copyright (C) 2013 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 "ocroptions.hh"
+#include "Preferences/ocroptions.ui.h"
+
+static const char *language[][2] =
+{
+ { "English", "eng" },
+ { "French", "fra" },
+ { 0, 0 }
+};
+
+OcrOptions::OcrOptions(QWidget *parent) :
+ OptionWidget(parent),
+ ui(new Ui::OcrOptions)
+{
+ ui->setupUi(this);
+
+ for (unsigned i = 0; language[i][0]; ++i)
+ ui->ocr_language->insertItem(i, language[i][0]);
+
+ loadConfig();
+}
+
+OcrOptions::~OcrOptions()
+{
+ delete ui;
+}
+
+int OcrOptions::findIndex(const QString& lang)
+{
+ for (unsigned i = 0; language[i][0]; ++i)
+ if (lang == language[i][1])
+ return i;
+
+ return 0;
+}
+
+
+void OcrOptions::loadConfig()
+{
+ Configs *const conf = Configs::getInstance();
+
+ ui->enable_ocr->setChecked(conf->ocrEnabled());
+ ui->ocr_language->setCurrentIndex(findIndex(conf->ocrLanguage()));
+}
+
+
+void OcrOptions::saveConfig()
+{
+ Configs *const conf = Configs::getInstance();
+
+ conf->setOcrEnabled(ui->enable_ocr->isChecked());
+ conf->setOcrLanguage(language[ui->ocr_language->currentIndex()][1]);
+}
diff --git a/scribo/demo/viewer/Preferences/ocroptions.hh b/scribo/demo/viewer/Preferences/ocroptions.hh
new file mode 100644
index 0000000..8b5b209
--- /dev/null
+++ b/scribo/demo/viewer/Preferences/ocroptions.hh
@@ -0,0 +1,49 @@
+// Copyright (C) 2013 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 OCR_OPTIONS_HH
+# define OCR_OPTIONS_HH
+
+//#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
+
+#include "optionwidget.hh"
+#include "configs.hh"
+#include "region.hh"
+
+namespace Ui
+{
+ class OcrOptions;
+}
+
+class OcrOptions :
+ public OptionWidget
+{
+ Q_OBJECT
+
+ public:
+ explicit OcrOptions(QWidget *parent = 0);
+ ~OcrOptions();
+
+ void loadConfig();
+ void saveConfig();
+
+ private:
+ int findIndex(const QString& lang);
+
+ Ui::OcrOptions *ui;
+};
+
+#endif // OCR_OPTIONS_HH
diff --git a/GScribo/Preferences/ocroptions.ui b/scribo/demo/viewer/Preferences/ocroptions.ui
similarity index 100%
rename from GScribo/Preferences/ocroptions.ui
rename to scribo/demo/viewer/Preferences/ocroptions.ui
diff --git a/GScribo/Preferences/optionwidget.h b/scribo/demo/viewer/Preferences/optionwidget.hh
similarity index 100%
rename from GScribo/Preferences/optionwidget.h
rename to scribo/demo/viewer/Preferences/optionwidget.hh
diff --git a/scribo/demo/viewer/Preferences/preferencesdialog.cc b/scribo/demo/viewer/Preferences/preferencesdialog.cc
new file mode 100644
index 0000000..ee6feda
--- /dev/null
+++ b/scribo/demo/viewer/Preferences/preferencesdialog.cc
@@ -0,0 +1,120 @@
+// Copyright (C) 2013 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 "preferencesdialog.hh"
+#include "Preferences/preferencesdialog.ui.h"
+
+PreferencesDialog::PreferencesDialog(QWidget *parent) :
+ QDialog(parent, Qt::Dialog),
+ ui(new Ui::PreferencesDialog)
+{
+ ui->setupUi(this);
+
+ // We may want to remove this useless object in the ui file.
+ delete ui->widget;
+
+ connect(ui->optionList, SIGNAL(currentRowChanged(int)), this, SLOT(onOptionListCurrentRowChanged(int)));
+ setAttribute(Qt::WA_DeleteOnClose);
+
+ loadOptionList();
+ ui->optionList->setCurrentRow(0);
+}
+
+PreferencesDialog::~PreferencesDialog()
+{
+ delete ui;
+}
+
+void PreferencesDialog::loadOptionList()
+{
+ static const char *options[] = { "General", "Preprocessing", "Segmentation", "OCR", 0 };
+
+ int i;
+ for (i = 0; options[i]; ++i)
+ ui->optionList->insertItem(i, options[i]);
+
+ widgets.fill(0, i);
+}
+
+void PreferencesDialog::selectOptionWidget(int row)
+{
+ if(!widgets[row])
+ {
+ QWidget *widget = 0;
+
+ switch(row)
+ {
+ case 0:
+ widget = new GeneralOptions(this);
+ break;
+
+ case 1:
+ widget = new PreprocessingOptions(this);
+ break;
+
+ case 2:
+ widget = new SegmentationOptions(this);
+ break;
+
+ case 3:
+ widget = new OcrOptions(this);
+ break;
+ }
+
+ if(widget)
+ widgets[row] = widget;
+ }
+
+ if(ui->horizontalLayout_2->count() == 2)
+ {
+ QWidget *current_widget = ui->horizontalLayout_2->itemAt(1)->widget();
+ ui->horizontalLayout_2->removeWidget(current_widget);
+ current_widget->hide();
+ }
+
+ ui->horizontalLayout_2->insertWidget(1, widgets[row]);
+ widgets[row]->show();
+}
+
+
+void PreferencesDialog::accept()
+{
+ for (int i = 0; i < widgets.size(); ++i)
+ {
+ if (widgets[i])
+ {
+ static_cast<OptionWidget *>(widgets[i])->saveConfig();
+ delete widgets[i];
+ }
+ }
+
+ QDialog::accept();
+}
+
+
+void PreferencesDialog::reject()
+{
+ for (int i = 0; i < widgets.size(); ++i)
+ delete widgets[i];
+
+ QDialog::reject();
+}
+
+
+void PreferencesDialog::onOptionListCurrentRowChanged(int row)
+{
+ selectOptionWidget(row);
+}
diff --git a/scribo/demo/viewer/Preferences/preferencesdialog.hh b/scribo/demo/viewer/Preferences/preferencesdialog.hh
new file mode 100644
index 0000000..f867b26
--- /dev/null
+++ b/scribo/demo/viewer/Preferences/preferencesdialog.hh
@@ -0,0 +1,55 @@
+// Copyright (C) 2013 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 PREFERENCESDIALOG_HH
+# define PREFERENCESDIALOG_HH
+
+#include <QDialog>
+
+#include "preprocessingoptions.hh"
+#include "segmentationoptions.hh"
+#include "generaloptions.hh"
+#include "ocroptions.hh"
+
+namespace Ui
+{
+ class PreferencesDialog;
+}
+
+class PreferencesDialog :
+ public QDialog
+{
+ Q_OBJECT
+
+ public:
+ explicit PreferencesDialog(QWidget *parent = 0);
+ ~PreferencesDialog();
+
+ private:
+ void loadOptionList();
+ void selectOptionWidget(int row);
+
+ Ui::PreferencesDialog *ui;
+ QVector<QWidget *> widgets;
+
+ private slots:
+ void onOptionListCurrentRowChanged(int row);
+ virtual void accept();
+ virtual void reject();
+
+};
+
+#endif // PREFERENCESDIALOG_HH
diff --git a/GScribo/Preferences/preferencesdialog.ui b/scribo/demo/viewer/Preferences/preferencesdialog.ui
similarity index 100%
rename from GScribo/Preferences/preferencesdialog.ui
rename to scribo/demo/viewer/Preferences/preferencesdialog.ui
diff --git a/scribo/demo/viewer/Preferences/preprocessingoptions.cc b/scribo/demo/viewer/Preferences/preprocessingoptions.cc
new file mode 100644
index 0000000..23d2538
--- /dev/null
+++ b/scribo/demo/viewer/Preferences/preprocessingoptions.cc
@@ -0,0 +1,61 @@
+// Copyright (C) 2013 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 "preprocessingoptions.hh"
+#include "Preferences/preprocessingoptions.ui.h"
+
+using namespace scribo::toolchain::internal;
+
+PreprocessingOptions::PreprocessingOptions(QWidget *parent) :
+ OptionWidget(parent),
+ ui(new Ui::PreprocessingOptions)
+{
+ ui->setupUi(this);
+
+ ui->bin_algoCbox->insertItem(Convert, "Violent convert");
+ ui->bin_algoCbox->insertItem(Sauvola, "Local threshold");
+ ui->bin_algoCbox->insertItem(SauvolaMs, "Local threshold multiscale");
+
+ loadConfig();
+}
+
+PreprocessingOptions::~PreprocessingOptions()
+{
+ delete ui;
+}
+
+void PreprocessingOptions::loadConfig()
+{
+ Configs *const conf = Configs::getInstance();
+
+ ui->subsampleCb->setChecked(conf->preprocessingSubsample());
+ ui->remove_bgCb->setChecked(conf->preprocessingRemoveBg());
+ ui->deskewCb->setChecked(conf->preprocessingDeskew());
+ ui->remove_noiseCb->setChecked(conf->preprocessingRemoveNoise());
+ ui->bin_algoCbox->setCurrentIndex(conf->preprocessingBinAlgo());
+}
+
+
+void PreprocessingOptions::saveConfig()
+{
+ Configs *const conf = Configs::getInstance();
+
+ conf->setPreprocessingSubsample(ui->subsampleCb->isChecked());
+ conf->setPreprocessingRemoveBg(ui->remove_bgCb->isChecked());
+ conf->setPreprocessingDeskew(ui->deskewCb->isChecked());
+ conf->setPreprocessingRemoveNoise(ui->remove_noiseCb->isChecked());
+ conf->setPreprocessingBinAlgo(ui->bin_algoCbox->currentIndex());
+}
diff --git a/scribo/demo/viewer/Preferences/preprocessingoptions.hh b/scribo/demo/viewer/Preferences/preprocessingoptions.hh
new file mode 100644
index 0000000..38645fa
--- /dev/null
+++ b/scribo/demo/viewer/Preferences/preprocessingoptions.hh
@@ -0,0 +1,48 @@
+// Copyright (C) 2013 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 PREPROCESSINGOPTIONS_HH
+# define PREPROCESSINGOPTIONS_HH
+
+#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
+
+#include "optionwidget.hh"
+#include "region.hh"
+#include "configs.hh"
+
+namespace Ui
+{
+ class PreprocessingOptions;
+}
+
+class PreprocessingOptions :
+ public OptionWidget
+{
+ Q_OBJECT
+
+ public:
+ explicit PreprocessingOptions(QWidget *parent = 0);
+ ~PreprocessingOptions();
+
+ void loadConfig();
+ void saveConfig();
+
+ private:
+ Ui::PreprocessingOptions *ui;
+
+};
+
+#endif // PREPROCESSINGOPTIONS_HH
diff --git a/GScribo/Preferences/preprocessingoptions.ui b/scribo/demo/viewer/Preferences/preprocessingoptions.ui
similarity index 100%
rename from GScribo/Preferences/preprocessingoptions.ui
rename to scribo/demo/viewer/Preferences/preprocessingoptions.ui
diff --git a/scribo/demo/viewer/Preferences/segmentationoptions.cc b/scribo/demo/viewer/Preferences/segmentationoptions.cc
new file mode 100644
index 0000000..867aa9a
--- /dev/null
+++ b/scribo/demo/viewer/Preferences/segmentationoptions.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2013 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 "segmentationoptions.hh"
+#include "Preferences/segmentationoptions.ui.h"
+
+SegmentationOptions::SegmentationOptions(QWidget *parent) :
+ OptionWidget(parent),
+ ui(new Ui::SegmentationOptions)
+{
+ ui->setupUi(this);
+
+ ui->find_sepsCbox->insertItem(Separator::Lines, "Lines");
+ ui->find_sepsCbox->insertItem(Separator::Whitespaces, "Whitespaces");
+ ui->find_sepsCbox->insertItem(Separator::Both, "Lines and whitespaces");
+
+ loadConfig();
+}
+
+SegmentationOptions::~SegmentationOptions()
+{
+ delete ui;
+}
+
+void SegmentationOptions::loadConfig()
+{
+ Configs *const conf = Configs::getInstance();
+ ui->find_sepsCbox->setCurrentIndex(conf->segmentationFindSeps());
+}
+
+
+void SegmentationOptions::saveConfig()
+{
+ Configs *const conf = Configs::getInstance();
+ conf->setSegmentationFindSeps(ui->find_sepsCbox->currentIndex());
+}
diff --git a/scribo/demo/viewer/Preferences/segmentationoptions.hh b/scribo/demo/viewer/Preferences/segmentationoptions.hh
new file mode 100644
index 0000000..4ad282a
--- /dev/null
+++ b/scribo/demo/viewer/Preferences/segmentationoptions.hh
@@ -0,0 +1,46 @@
+// Copyright (C) 2013 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 SEGMENTATIONOPTIONS_HH
+# define SEGMENTATIONOPTIONS_HH
+
+
+#include "optionwidget.hh"
+#include "configs.hh"
+#include "region.hh"
+
+namespace Ui
+{
+ class SegmentationOptions;
+}
+
+class SegmentationOptions :
+ public OptionWidget
+{
+ Q_OBJECT
+
+ public:
+ explicit SegmentationOptions(QWidget *parent = 0);
+ ~SegmentationOptions();
+
+ void loadConfig();
+ void saveConfig();
+
+ private:
+ Ui::SegmentationOptions *ui;
+};
+
+#endif // SEGMENTATIONOPTIONS_HH
diff --git a/GScribo/Preferences/segmentationoptions.ui b/scribo/demo/viewer/Preferences/segmentationoptions.ui
similarity index 100%
rename from GScribo/Preferences/segmentationoptions.ui
rename to scribo/demo/viewer/Preferences/segmentationoptions.ui
diff --git a/scribo/demo/viewer/Processing/preprocess.cc b/scribo/demo/viewer/Processing/preprocess.cc
new file mode 100644
index 0000000..c913c60
--- /dev/null
+++ b/scribo/demo/viewer/Processing/preprocess.cc
@@ -0,0 +1,27 @@
+// Copyright (C) 2013 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 "preprocess.hh"
+
+void Preprocess::on_progress()
+{
+ emit progress();
+}
+
+void Preprocess::on_new_progress_label(const char *label)
+{
+ emit newProgressLabel(QString(label));
+}
diff --git a/scribo/demo/viewer/Processing/preprocess.hh b/scribo/demo/viewer/Processing/preprocess.hh
new file mode 100644
index 0000000..457efde
--- /dev/null
+++ b/scribo/demo/viewer/Processing/preprocess.hh
@@ -0,0 +1,42 @@
+// Copyright (C) 2013 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 PREPROCESS_H
+# define PREPROCESS_H
+
+#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/value/rgb8.hh>
+#include <QObject>
+
+using namespace scribo::toolchain::internal;
+
+class Preprocess :
+ public QObject,
+ public text_in_doc_preprocess_functor<mln::image2d<mln::value::rgb8> >
+{
+ Q_OBJECT
+
+ public:
+ virtual void on_progress();
+ virtual void on_new_progress_label(const char *label);
+
+ signals:
+ void newProgressLabel(const QString& label);
+ void progress();
+};
+
+#endif // PREPROCESS_H
diff --git a/scribo/demo/viewer/Processing/process.cc b/scribo/demo/viewer/Processing/process.cc
new file mode 100644
index 0000000..0fb54a6
--- /dev/null
+++ b/scribo/demo/viewer/Processing/process.cc
@@ -0,0 +1,37 @@
+// Copyright (C) 2013 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 "process.hh"
+
+Process::Process(const char *doc_filename)
+ : superT(doc_filename)
+{
+}
+
+void Process::on_progress()
+{
+ emit progress();
+}
+
+void Process::on_new_progress_label(const char *label)
+{
+ emit newProgressLabel(QString(label));
+}
+
+void Process::on_xml_saved()
+{
+ emit xmlSaved(QString(output_file.c_str()));
+}
diff --git a/scribo/demo/viewer/Processing/process.hh b/scribo/demo/viewer/Processing/process.hh
new file mode 100644
index 0000000..fc3809c
--- /dev/null
+++ b/scribo/demo/viewer/Processing/process.hh
@@ -0,0 +1,45 @@
+// Copyright (C) 2013 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 PROCESS_H
+# define PROCESS_H
+
+#include <scribo/toolchain/internal/content_in_doc_functor.hh>
+#include <mln/core/image/image2d.hh>
+#include <QObject>
+
+using namespace scribo::toolchain::internal;
+
+struct Process :
+ public QObject,
+ public content_in_doc_functor<mln::image2d<bool> >
+{
+ Q_OBJECT
+ typedef content_in_doc_functor<mln::image2d<bool> > superT;
+
+ public :
+ explicit Process(const char *docFilename);
+ virtual void on_progress();
+ virtual void on_new_progress_label(const char *label);
+ virtual void on_xml_saved();
+
+ signals:
+ void newProgressLabel(const QString& label);
+ void progress();
+ void xmlSaved(const QString& filename);
+};
+
+#endif // PROCESS_H
diff --git a/scribo/demo/viewer/Processing/progressdialog.cc b/scribo/demo/viewer/Processing/progressdialog.cc
new file mode 100644
index 0000000..beda013
--- /dev/null
+++ b/scribo/demo/viewer/Processing/progressdialog.cc
@@ -0,0 +1,37 @@
+// Copyright (C) 2013 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 "progressdialog.hh"
+
+ProgressDialog::ProgressDialog(QWidget *parent):
+ QProgressDialog(parent, Qt::Dialog)
+{
+ setAutoClose(false);
+ setCancelButton(0);
+ hide();
+}
+
+void ProgressDialog::reset()
+{
+ setValue(0);
+ setLabelText("Initilization");
+ show();
+}
+
+void ProgressDialog::run()
+{
+ setValue(value()+1);
+}
diff --git a/scribo/demo/viewer/Processing/progressdialog.hh b/scribo/demo/viewer/Processing/progressdialog.hh
new file mode 100644
index 0000000..fe2ea0f
--- /dev/null
+++ b/scribo/demo/viewer/Processing/progressdialog.hh
@@ -0,0 +1,36 @@
+// Copyright (C) 2013 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 PROGRESSDIALOG_H
+#define PROGRESSDIALOG_H
+
+#include <QProgressDialog>
+
+class ProgressDialog :
+ public QProgressDialog
+{
+ Q_OBJECT
+
+ public:
+ explicit ProgressDialog(QWidget *parent = 0);
+ void reset();
+
+ public slots:
+ void run();
+};
+
+
+#endif // PROGRESSDIALOG_H
diff --git a/scribo/demo/viewer/Processing/runner.cc b/scribo/demo/viewer/Processing/runner.cc
new file mode 100644
index 0000000..a52c6eb
--- /dev/null
+++ b/scribo/demo/viewer/Processing/runner.cc
@@ -0,0 +1,199 @@
+// Copyright (C) 2013 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 "runner.hh"
+
+using namespace mln;
+using namespace scribo::toolchain::internal;
+
+static QString get_pathto(const QString& file, const QString localdirsuffix = QString())
+{
+ QFile f(SCRIBO_LOCAL_DEMODIR "/" + localdirsuffix + "/" + file);
+ if (f.exists())
+ return SCRIBO_LOCAL_DEMODIR "/" + localdirsuffix;
+ f.setFileName(SCRIBO_PREFIX_BINDIR "/" + file);
+ if (f.exists())
+ return SCRIBO_PREFIX_BINDIR;
+
+ return "";
+}
+
+Runner::Runner(QObject *parent) :
+ QThread(parent)
+{
+ moveToThread(this);
+}
+
+void Runner::run()
+{
+ if(mode_ == Demat)
+ {
+ image2d<value::rgb8> ima;
+ for(int i = 0; i < args_.count(); i++)
+ {
+ io::magick::load(ima, args_.at(i).toUtf8().constData());
+ image2d<bool> bin_ima = preprocess(ima);
+ process(ima, bin_ima, i);
+ }
+ }
+
+ else if(mode_ == Export)
+ export_as();
+
+ emit finished();
+}
+
+void Runner::stop()
+{
+ terminate();
+}
+
+// Demat related stuff
+void Runner::start_demat(const QStringList& filenames)
+{
+ args_.clear();
+ args_ = filenames;
+ mode_ = Demat;
+ QThread::start();
+}
+
+
+image2d<bool> Runner::preprocess(const image2d<value::rgb8>& ima)
+{
+ emit new_step("Preprocessing");
+ Preprocess f;
+
+ // Load config.
+ Configs *const conf = Configs::getInstance();
+
+ connect(&f, SIGNAL(progress()), this, SIGNAL(progress()));
+ connect(&f, SIGNAL(newProgressLabel(QString)),
+ this, SIGNAL(new_progress_label(const QString&)));
+
+ f.enable_subsample = conf->preprocessingSubsample();
+ f.enable_fg_extraction = conf->preprocessingRemoveBg();
+ f.enable_deskew = conf->preprocessingDeskew();
+ f.enable_denoising = conf->preprocessingRemoveNoise();
+
+ f.binarization_algo = static_cast<Binarization_Algo>(conf->preprocessingBinAlgo());
+
+ emit new_progress_max_value(f.nsteps());
+
+ // Perform preprocessing.
+ f(ima);
+
+ return f.output;
+}
+
+
+void Runner::process(const image2d<value::rgb8>& original_ima,
+ const image2d<bool>& processed_ima, int arg)
+{
+ emit new_step("Page segmentation");
+
+ Process f(args_.at(arg).toUtf8().constData());
+
+ connect(&f, SIGNAL(progress()), this, SIGNAL(progress()));
+ connect(&f, SIGNAL(newProgressLabel(QString)),
+ this, SIGNAL(new_progress_label(QString)));
+ connect(&f, SIGNAL(xmlSaved(QString)),
+ this, SIGNAL(xml_saved(const QString&)));
+
+ // Load config.
+ Configs *const conf = Configs::getInstance();
+
+ Separator::FindSeparator find_seps = static_cast<Separator::FindSeparator>(conf->segmentationFindSeps());
+ f.enable_line_seps = (find_seps == Separator::Lines
+ || find_seps == Separator::Both);
+ f.enable_whitespace_seps = (find_seps == Separator::Whitespaces
+ || find_seps == Separator::Both);
+ f.enable_ocr = conf->ocrEnabled();
+ f.ocr_language = conf->ocrLanguage().toAscii().data();
+ f.xml_format = scribo::io::xml::PageExtended;
+
+
+ f.save_doc_as_xml = true;
+ QFileInfo file(args_.at(arg));
+ QString output_dir = QDir::tempPath();
+ if (conf->generalSaveXmlEnabled())
+ {
+ if (conf->generalSaveXmlSameDir())
+ output_dir = file.absolutePath();
+ else if (conf->generalSaveXmlCustomDir())
+ output_dir = conf->generalSaveXmlCustomDirPath();
+
+ QDir dir(output_dir);
+ if (!dir.exists() && !dir.mkpath(output_dir))
+ output_dir = QDir::tempPath();
+ }
+ QString filename = (output_dir + "/" + file.baseName() + "_gui.xml");
+ f.output_file = filename.toUtf8().constData();
+ emit new_progress_max_value(f.nsteps());
+
+ // Perform text detection.
+ f(original_ima, processed_ima);
+}
+
+// Export related stuff
+void Runner::start_export(const QString& imgfile,
+ const QString& xmlfile, const QString& outfile)
+{
+ args_.clear();
+ args_ << imgfile << xmlfile << outfile;
+ mode_ = Export;
+
+ QThread::start();
+}
+
+void Runner::export_as()
+{
+ emit new_step("Exporting document");
+ emit new_progress_max_value(2);
+
+ // Checking output format
+ QFileInfo f(args_.at(2));
+
+ QString pathto_xml2doc = get_pathto("scribo-xml2doc", "xml2doc");
+
+ if (pathto_xml2doc.isEmpty())
+ {
+ QMessageBox::critical(0, "Fatal error", "Cannot export! Cannot find scribo-xml2doc program!");
+ return;
+ }
+
+ emit progress();
+
+ int rvalue = 0;
+ if (f.suffix() == "pdf")
+ {
+ emit new_step("Exporting as PDF");
+ rvalue = system(QString("%1/scribo-xml2doc --pdf %2 %3 %4")
+ .arg(pathto_xml2doc).arg(args_.at(1)).arg(args_.at(0))
+ .arg(args_.at(2)).toAscii().constData());
+ }
+ else if (f.suffix() == "html" || f.suffix() == "htm")
+ {
+ emit new_step("Exporting as HTML");
+ rvalue = system(QString("%1/scribo-xml2doc --html %2 %3 %4")
+ .arg(pathto_xml2doc).arg(args_.at(1)).arg(args_.at(0))
+ .arg(args_.at(2)).toAscii().constData());
+ }
+ else
+ QMessageBox::critical(0, "Fatal error", "Cannot export! Invalid output format!");
+
+ if (rvalue != 0)
+ QMessageBox::critical(0, "Fatal error", "Cannot export! Return value is not 0!");
+}
diff --git a/scribo/demo/viewer/Processing/runner.hh b/scribo/demo/viewer/Processing/runner.hh
new file mode 100644
index 0000000..ab0fb79
--- /dev/null
+++ b/scribo/demo/viewer/Processing/runner.hh
@@ -0,0 +1,74 @@
+// Copyright (C) 2013 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 RUNNER_H
+# define RUNNER_H
+
+#include <mln/core/image/image2d.hh>
+#include <mln/io/magick/load.hh>
+#include <mln/value/rgb8.hh>
+#include <QStringList>
+#include <QMessageBox>
+#include <QThread>
+#include <QFile>
+
+#include "preprocess.hh"
+#include "process.hh"
+#include "configs.hh"
+#include "region.hh"
+#include "dir.hh"
+
+using namespace mln;
+
+enum RunMode
+{
+ Demat,
+ Export
+};
+
+class Runner :
+ public QThread
+{
+ Q_OBJECT
+
+ public:
+ explicit Runner(QObject *parent = 0);
+ void start_demat(const QStringList& filenames);
+ void start_export(const QString& imgfile, const QString& xmlfile, const QString& outfile);
+
+ private:
+ image2d<bool> preprocess(const image2d<value::rgb8>& ima);
+ void process(const image2d<value::rgb8>& original_ima, const image2d<bool>& processed_ima, int arg);
+ void export_as();
+ virtual void run();
+ template <typename V> unsigned find_best_scale(const mln::image2d<V>& ima);
+
+ QStringList args_;
+ RunMode mode_;
+
+ public slots:
+ void stop();
+
+ signals:
+ void new_step(const QString& step_name);
+ void new_progress_max_value(int i);
+ void new_progress_label(const QString& msg);
+ void xml_saved(const QString& filename);
+ void progress();
+ void finished();
+};
+
+#endif // RUNNER_H
diff --git a/scribo/demo/viewer/README b/scribo/demo/viewer/README
deleted file mode 100644
index 31c66aa..0000000
--- a/scribo/demo/viewer/README
+++ /dev/null
@@ -1,32 +0,0 @@
-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/>.
-
-__________________________________________________________________
-
-
-Document Layout Viewer
-
-Purpose:
-- Display layout information about image documents.
-
-Usage:
-- Get XML layout descriptions (PAGE format, ICDAR2009).
-- Put XML and image files in the same directory, with the same name.
-- Select an image within the application.
-- Click on regions to display their attributes.
-
-Infos:
-- Everything is read-only.
diff --git a/GScribo/Rendering/abstractregionitem.h b/scribo/demo/viewer/Rendering/abstractregionitem.hh
similarity index 100%
rename from GScribo/Rendering/abstractregionitem.h
rename to scribo/demo/viewer/Rendering/abstractregionitem.hh
diff --git a/GScribo/Rendering/backgroundtexture.h b/scribo/demo/viewer/Rendering/backgroundtexture.hh
similarity index 100%
rename from GScribo/Rendering/backgroundtexture.h
rename to scribo/demo/viewer/Rendering/backgroundtexture.hh
diff --git a/scribo/demo/viewer/Rendering/graphicsview.cc b/scribo/demo/viewer/Rendering/graphicsview.cc
new file mode 100644
index 0000000..10ac034
--- /dev/null
+++ b/scribo/demo/viewer/Rendering/graphicsview.cc
@@ -0,0 +1,165 @@
+// Copyright (C) 2013 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 "graphicsview.hh"
+
+GraphicsView::GraphicsView(QWidget *parent) :
+ QGraphicsView(parent)
+{
+ init();
+}
+
+GraphicsView::GraphicsView(QGraphicsScene *scene, QWidget *parent) :
+ QGraphicsView(scene, parent)
+{
+ init();
+}
+
+void GraphicsView::init()
+{
+ isRightClicking_ = false;
+ scaleRatio_ = QSizeF(1, 1);
+ setTransformationAnchor(GraphicsView::AnchorUnderMouse);
+ setBackgroundBrush(QBrush(Qt::lightGray));
+
+ // Important to hide scroll bars : when they appear, it triggers the resizeEvent.
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+}
+
+void GraphicsView::mousePressEvent(QMouseEvent *event)
+{
+ if(event->button() == Qt::RightButton)
+ {
+ emit beginDrag();
+ setDragMode(QGraphicsView::ScrollHandDrag);
+ }
+
+ QMouseEvent *mouseEvent = new QMouseEvent(QEvent::MouseButtonPress, event->pos(), Qt::LeftButton,
+ Qt::LeftButton, Qt::MetaModifier);
+ event->ignore();
+ QGraphicsView::mousePressEvent(mouseEvent);
+}
+
+void GraphicsView::mouseReleaseEvent(QMouseEvent *event)
+{
+ if(event->button() == Qt::RightButton)
+ {
+ setDragMode(GraphicsView::NoDrag);
+ emit endDrag();
+ }
+
+ QGraphicsView::mouseReleaseEvent(event);
+}
+
+void GraphicsView::wheelEvent(QWheelEvent *event)
+{
+ if(event->modifiers() & Qt::ControlModifier)
+ {
+ // Current wheel have an angle of 15 degrees by steps with a delta of + or - 120. A good scale is +- 0.1 in that case.
+ // So we have to adapt for wheel whith better precision.
+ qreal degrees = 1 + static_cast<qreal>(event->delta()) / 1200;
+ qreal nextScaleRatio = degrees * isWidthGreater_ ? scaleRatio_.width() :
+ scaleRatio_.height();
+ if(event->delta() > 0)
+ {
+ if(nextScaleRatio <= 20)
+ {
+ scaleRatio_ *= degrees;
+ scale(degrees, degrees);
+ }
+ }
+ else
+ {
+ if(nextScaleRatio >= 1.1)
+ {
+ scaleRatio_ *= degrees;
+ scale(degrees, degrees);
+ }
+ else if(isContainedInView_)
+ {
+ QGraphicsView::fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
+ scaleRatio_ = QSizeF(1, 1);
+ }
+ }
+ }
+ else
+ QGraphicsView::wheelEvent(event);
+}
+
+void GraphicsView::keyPressEvent(QKeyEvent* event)
+{
+ // Bitwise AND to check if at least CTRL is pushed.
+ if(event->modifiers() & Qt::ControlModifier)
+ {
+ qreal nextScaleRatio;
+ if(event->key() == Qt::Key_Plus)
+ {
+ nextScaleRatio = 1.2 * isWidthGreater_ ? scaleRatio_.width() :
+ scaleRatio_.height();
+ if(nextScaleRatio <= 19)
+ {
+ scaleRatio_ *= 1.2;
+ scale(1.2, 1.2);
+ }
+ }
+ else if(event->key() == Qt::Key_Minus)
+ {
+ nextScaleRatio = 0.8 * isWidthGreater_ ? scaleRatio_.width() :
+ scaleRatio_.height();
+ if(nextScaleRatio >= 1.2)
+ {
+ scaleRatio_ *= 0.8;
+ scale(0.8, 0.8);
+ }
+ else if(isContainedInView_)
+ {
+ QGraphicsView::fitInView(scene()->sceneRect(), Qt::KeepAspectRatio);
+ scaleRatio_ = QSizeF(1, 1);
+ }
+ }
+ }
+
+ QGraphicsView::keyPressEvent(event);
+}
+
+void GraphicsView::fitInView(const QRectF& rect)
+{
+ setFocus();
+ isWidthGreater_ = static_cast<qreal>(rect.width()) / static_cast<qreal>(rect.height()) > 1 ? true :
+ false;
+ qreal ratio = isWidthGreater_ ? static_cast<qreal>(width()) / static_cast<qreal>(rect.width()) :
+ static_cast<qreal>(height()) / static_cast<qreal>(rect.height());
+
+ isContainedInView_ = ratio < 1 ? true : false;
+ if(isContainedInView_)
+ {
+ scaleRatio_ = QSizeF(1, 1);
+ QGraphicsView::fitInView(rect, Qt::KeepAspectRatio);
+ }
+}
+
+void GraphicsView::resizeEvent(QResizeEvent *event)
+{
+ if(scene()->items().count() > 1)
+ {
+ qreal ratio = isWidthGreater_ ? static_cast<qreal>(event->size().width()) / static_cast<qreal>(event->oldSize().width()) :
+ static_cast<qreal>(event->size().height()) / static_cast<qreal>(event->oldSize().height());
+ scale(ratio, ratio);
+ }
+
+ QGraphicsView::resizeEvent(event);
+}
diff --git a/scribo/demo/viewer/Rendering/graphicsview.hh b/scribo/demo/viewer/Rendering/graphicsview.hh
new file mode 100644
index 0000000..86e1786
--- /dev/null
+++ b/scribo/demo/viewer/Rendering/graphicsview.hh
@@ -0,0 +1,59 @@
+// Copyright (C) 2013 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 GRAPHICSVIEW_HH
+# define GRAPHICSVIEW_HH
+
+#include <QGraphicsView>
+#include <QWheelEvent>
+#include <QScrollBar>
+
+class GraphicsView :
+ public QGraphicsView
+{
+ Q_OBJECT
+
+ public:
+ explicit GraphicsView(QWidget *parent = 0);
+ explicit GraphicsView(QGraphicsScene *scene, QWidget *parent = 0);
+
+ protected:
+ void init();
+
+ void resizeEvent(QResizeEvent *event);
+
+ void wheelEvent(QWheelEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+
+ private:
+ bool isWidthGreater_;
+ bool isContainedInView_;
+ QSizeF scaleRatio_;
+
+ bool isRightClicking_;
+ QPointF prevMousePos_;
+
+ public slots:
+ void fitInView(const QRectF& rect);
+
+ signals:
+ void beginDrag();
+ void endDrag();
+};
+
+#endif // GRAPHICSVIEW_HH
diff --git a/scribo/demo/viewer/Rendering/regionitem.cc b/scribo/demo/viewer/Rendering/regionitem.cc
new file mode 100644
index 0000000..d845413
--- /dev/null
+++ b/scribo/demo/viewer/Rendering/regionitem.cc
@@ -0,0 +1,130 @@
+// Copyright (C) 2013 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 "Rendering/regionitem.hh"
+
+RegionItem::RegionItem(QGraphicsItem *parent, QGraphicsScene *scene)
+ : QGraphicsPolygonItem(parent, scene)
+{
+ init();
+}
+
+RegionItem::RegionItem(const QPolygonF& polygon, QGraphicsItem *parent, QGraphicsScene *scene):
+ QGraphicsPolygonItem(polygon, parent, scene)
+{
+ init();
+}
+
+void RegionItem::init()
+{
+ xmlItem_ = 0;
+
+ selectedPen_.setStyle(Qt::SolidLine);
+ unselectedPen_.setStyle(Qt::SolidLine);
+
+ selectedPen_.setWidthF(2);
+ unselectedPen_.setWidth(0);
+
+ selectedPen_.setCapStyle(Qt::SquareCap);
+ unselectedPen_.setCapStyle(Qt::SquareCap);
+
+ selectedBrush_.setStyle(Qt::SolidPattern);
+ unselectedBrush_.setStyle(Qt::SolidPattern);
+}
+
+void RegionItem::setColor(const QColor& color)
+{
+ selectedPen_.setColor(QColor::fromRgb(color.red(), color.green(), color.blue(), 255));
+ unselectedPen_.setColor(color);
+
+ selectedBrush_.setColor(color);
+ unselectedBrush_.setColor(QColor::fromRgb(color.red(), color.green(), color.blue(), 40));
+
+ setPen(unselectedPen_);
+ setBrush(unselectedBrush_);
+}
+
+void RegionItem::setSelected(bool isSelected)
+{
+ if(isSelected)
+ {
+ isSelected_ = true;
+ setPen(selectedPen_);
+ setBrush(selectedBrush_);
+ }
+
+ else
+ {
+ isSelected_ = false;
+ setPen(unselectedPen_);
+ setBrush(unselectedBrush_);
+ }
+}
+
+
+void RegionItem::setXmlItem(XmlItem *xmlItem)
+{
+ xmlItem_ = xmlItem;
+}
+
+XmlItem *RegionItem::xmlItem() const
+{
+ return xmlItem_;
+}
+
+QColor RegionItem::color() const
+{
+ return selectedBrush_.color();
+}
+
+int RegionItem::region() const
+{
+ return region_;
+}
+
+bool RegionItem::isSelected()
+{
+ return isSelected_;
+}
+
+void RegionItem::select()
+{
+ setSelected(true);
+}
+
+void RegionItem::unselect()
+{
+ setSelected(false);
+}
+
+void RegionItem::loadData(const GraphicsRegion::Data& data)
+{
+ region_ = data.region; setColor(data.color); setZValue(data.zValue);
+}
+
+bool RegionItem::contains(const QPointF& point)
+{
+ return (boundingRect().width() * boundingRect().height() == 0
+ || boundingRect().contains(point))
+ && shape().contains(point);
+}
+
+bool RegionItem::intersects(const QRectF& rect)
+{
+ return (boundingRect().width() * boundingRect().height() == 0
+ || boundingRect().intersects(rect))
+ && shape().intersects(rect);
+}
diff --git a/scribo/demo/viewer/Rendering/regionitem.hh b/scribo/demo/viewer/Rendering/regionitem.hh
new file mode 100644
index 0000000..3fe03a7
--- /dev/null
+++ b/scribo/demo/viewer/Rendering/regionitem.hh
@@ -0,0 +1,66 @@
+// Copyright (C) 2013 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 RegionITEM_HH
+# define RegionITEM_HH
+
+#include <QGraphicsPolygonItem>
+#include <QTreeWidgetItem>
+#include <QPen>
+
+#include "variantpointer.hh"
+#include "region.hh"
+
+class XmlItem;
+
+class RegionItem :
+ public QGraphicsPolygonItem
+{
+ public:
+ explicit RegionItem(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
+ explicit RegionItem(const QPolygonF& path, QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);
+
+ void setColor(const QColor& color);
+ QColor color() const;
+
+ void setXmlItem(XmlItem *xmlItem);
+ XmlItem *xmlItem() const;
+
+ void loadData(const GraphicsRegion::Data& data);
+ int region() const;
+
+ bool intersects(const QRectF& rect);
+ bool contains(const QPointF& point);
+
+ void setSelected(bool isSelected);
+ bool isSelected();
+ void unselect();
+ void select();
+
+ private:
+ void init();
+
+ XmlItem *xmlItem_;
+ int region_;
+ bool isSelected_;
+
+ QPen selectedPen_;
+ QPen unselectedPen_;
+ QBrush selectedBrush_;
+ QBrush unselectedBrush_;
+};
+
+#endif // RegionITEM_HH
diff --git a/scribo/demo/viewer/Rendering/rootgraphicsitem.cc b/scribo/demo/viewer/Rendering/rootgraphicsitem.cc
new file mode 100644
index 0000000..166a186
--- /dev/null
+++ b/scribo/demo/viewer/Rendering/rootgraphicsitem.cc
@@ -0,0 +1,46 @@
+// Copyright (C) 2013 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 "Rendering/rootgraphicsitem.hh"
+
+RootGraphicsItem::RootGraphicsItem(int numberRegion)
+{
+ childsFromRegion_.fill(QList<QGraphicsItem *>(), numberRegion);
+}
+
+RootGraphicsItem::~RootGraphicsItem()
+{
+ foreach(QList<QGraphicsItem *> list, childsFromRegion_)
+ {
+ foreach(QGraphicsItem *child, list)
+ {
+ delete child;
+ }
+ }
+}
+
+QList<QGraphicsItem *>
+RootGraphicsItem::childsFrom(const GraphicsRegion::Id& region) const
+{
+ return childsFromRegion_[region];
+}
+
+void
+RootGraphicsItem::addItemFrom(QGraphicsItem *graphicalItem,
+ const GraphicsRegion::Id& region)
+{
+ childsFromRegion_[region] << graphicalItem;
+}
diff --git a/scribo/demo/viewer/Rendering/rootgraphicsitem.hh b/scribo/demo/viewer/Rendering/rootgraphicsitem.hh
new file mode 100644
index 0000000..fe7f5a2
--- /dev/null
+++ b/scribo/demo/viewer/Rendering/rootgraphicsitem.hh
@@ -0,0 +1,39 @@
+// Copyright (C) 2013 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 ROOTGRAPHICSITEM_HH
+# define ROOTGRAPHICSITEM_HH
+
+#include <QGraphicsItem>
+
+#include "region.hh"
+
+class RootGraphicsItem :
+ public QGraphicsPolygonItem
+{
+public:
+ explicit RootGraphicsItem(int numberRegion);
+ ~RootGraphicsItem();
+
+
+ void addItemFrom(QGraphicsItem *graphicalItem, const GraphicsRegion::Id& region);
+ QList<QGraphicsItem *> childsFrom(const GraphicsRegion::Id& region) const;
+
+private:
+ QVector<QList<QGraphicsItem *> > childsFromRegion_;
+};
+
+#endif // ROOTGRAPHICSITEM_HH
diff --git a/scribo/demo/viewer/Rendering/scene.cc b/scribo/demo/viewer/Rendering/scene.cc
new file mode 100644
index 0000000..a036ed2
--- /dev/null
+++ b/scribo/demo/viewer/Rendering/scene.cc
@@ -0,0 +1,289 @@
+// Copyright (C) 2013 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 "scene.hh"
+
+Scene::Scene(QObject *parent):
+ QGraphicsScene(parent)
+{
+ init();
+}
+
+Scene::Scene(const QRectF &sceneRect, QObject *parent):
+ QGraphicsScene(sceneRect, parent)
+{
+ init();
+}
+
+Scene::Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent):
+ QGraphicsScene(x, y, width, height, parent)
+{
+ init();
+}
+
+void Scene::init()
+{
+ isPressing_ = false;
+ isSelectionDisabled_ = false;
+ backgroundPixmap_ = 0;
+ root_ = 0;
+
+ selection_.hide();
+ addItem(&selection_);
+}
+
+void Scene::clearAll()
+{
+ if(root_)
+ delete root_;
+
+ if(backgroundPixmap_)
+ delete backgroundPixmap_;
+
+ selectedRegions_.clear();
+ backgroundPath_ = QString();
+ backgroundPixmap_ = 0;
+ root_ = 0;
+}
+
+void Scene::clearRegions()
+{
+ if(root_)
+ delete root_;
+
+ selectedRegions_.clear();
+ root_ = 0;
+}
+
+void Scene::clearSelection()
+{
+ QGraphicsItem *child;
+ RegionItem *regionItem;
+
+ // Unselect all items.
+ foreach(child, selectedRegions_)
+ {
+ regionItem = static_cast<RegionItem *>(child);
+ regionItem->unselect();
+ }
+
+ selectedRegions_.clear();
+ emit selectionCleared();
+}
+
+void Scene::selectAll()
+{
+ RegionItem *item;
+ foreach(QGraphicsItem *child, root_->childItems())
+ {
+ item = static_cast<RegionItem *>(child);
+ item->select();
+ selectedRegions_ << item;
+ }
+}
+
+void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ if(!backgroundPath_.isEmpty() && event->button() == Qt::LeftButton && !isSelectionDisabled_)
+ {
+ isPressing_ = true;
+
+ baseSelection_.clear();
+ pressPos_ = event->scenePos();
+ selection_.show();
+ }
+}
+
+void Scene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ if(isPressing_)
+ {
+ // Adapt if the selection rectangle has a negative size.
+ if(pressPos_.x() < event->scenePos().x())
+ selection_.setRect(pressPos_.x(), 0, event->scenePos().x()-pressPos_.x(), 0);
+ else
+ selection_.setRect(event->scenePos().x(), 0, pressPos_.x()-event->scenePos().x(), 0);
+
+ if(pressPos_.y() < event->scenePos().y())
+ selection_.setRect(selection_.rect().x(), pressPos_.y(), selection_.rect().width(), event->scenePos().y()-pressPos_.y());
+ else
+ selection_.setRect(selection_.rect().x(), event->scenePos().y(), selection_.rect().width(), pressPos_.y()-event->scenePos().y());
+ }
+}
+
+void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ if(event->button() == Qt::LeftButton)
+ {
+ isPressing_ = false;
+
+ // Redraw all items in selection.
+ if(root_)
+ {
+ clearSelection();
+
+ // Check if it is a click.
+ if(selection_.rect().width() * selection_.rect().height() == 0)
+ select(event->scenePos());
+ else
+ select(selection_.rect());
+
+ baseSelection_ = selectedRegions();
+ emit newSelection(selectedRegions_);
+ }
+
+ selection_.setRect(QRect());
+ selection_.hide();
+ }
+}
+
+void Scene::select(QGraphicsItem *root, const QPointF& point, const QRectF& rect)
+{
+ QGraphicsItem *child;
+ RegionItem *regionItem;
+
+ // Check if it is a click.
+ if(!point.isNull())
+ {
+ foreach(child, root->childItems())
+ {
+ regionItem = static_cast<RegionItem *>(child);
+
+ if(regionItem->contains(point))
+ {
+ regionItem->select();
+ selectedRegions_ << regionItem;
+ }
+ }
+ }
+ else
+ {
+ foreach(child, root->childItems())
+ {
+ regionItem = static_cast<RegionItem *>(child);
+
+ if(regionItem->intersects(rect))
+ {
+ regionItem->select();
+ selectedRegions_ << regionItem;
+ }
+ }
+ }
+
+ emit newSelection();
+}
+
+void Scene::select(const QList<RegionItem *>& selectedRegions)
+{
+ RegionItem *child;
+ foreach(child, selectedRegions)
+ {
+ if(!child->isSelected())
+ {
+ child->select();
+ selectedRegions_ << child;
+ }
+ }
+
+ ensureVisible(selectedRegions_.last());
+ emit newSelection();
+}
+
+void Scene::unselect(const QList<RegionItem *>& unselectedRegions)
+{
+ RegionItem *child;
+ foreach(child, unselectedRegions)
+ {
+ if(child->isSelected())
+ {
+ child->unselect();
+ selectedRegions_.removeOne(child);
+ }
+ }
+
+ // Check if after the removal, the selected list isn't empty.
+ if(!selectedRegions_.isEmpty())
+ ensureVisible(selectedRegions_.last());
+
+ emit newSelection();
+}
+
+
+void Scene::ensureVisible(QGraphicsItem *graphicalItem)
+{
+ QGraphicsView *view;
+ foreach (view, views())
+ view->ensureVisible(graphicalItem);
+}
+
+void Scene::setVisible(const GraphicsRegion::Id& region, bool visible)
+{
+ if(root_)
+ {
+ QGraphicsItem *child;
+
+ if(visible)
+ {
+ foreach(child, root_->childsFrom(region))
+ child->setVisible(true);
+ }
+
+ else
+ {
+ foreach(child, root_->childsFrom(region))
+ child->setVisible(false);
+ }
+ }
+}
+
+void Scene::setRoot(RootGraphicsItem *root)
+{
+ // Delete all items.
+ clearRegions();
+
+ root_ = root;
+ addItem(root);
+
+ // Add typo lines separately because can't be selected.
+ QGraphicsItem *line;
+ foreach(line, root->childsFrom(GraphicsRegion::Baseline))
+ addItem(line);
+
+ foreach(line, root->childsFrom(GraphicsRegion::Meanline))
+ addItem(line);
+}
+
+void Scene::changeScene(const QString& filename, RootGraphicsItem *root)
+{
+ // Delete all items.
+ clearAll();
+ backgroundPath_ = filename;
+
+ if(!filename.isEmpty())
+ {
+ QPixmap pixmap(filename);
+ setSceneRect(pixmap.rect());
+ // Create the background item and dock it at the maximal depth of the scene.
+ backgroundPixmap_ = new QGraphicsPixmapItem(pixmap, 0, this);
+ backgroundPixmap_->setZValue(INT_MIN);
+ }
+ else
+ setSceneRect(QRectF());
+
+ // Add new items.
+ if(root)
+ setRoot(root);
+}
diff --git a/scribo/demo/viewer/Rendering/scene.hh b/scribo/demo/viewer/Rendering/scene.hh
new file mode 100644
index 0000000..7d2771d
--- /dev/null
+++ b/scribo/demo/viewer/Rendering/scene.hh
@@ -0,0 +1,118 @@
+#ifndef SCENE_H
+#define SCENE_H
+
+#include <QGraphicsSceneMouseEvent>
+#include <QGraphicsView>
+#include <QGraphicsScene>
+#include <QFileDialog>
+#include <climits>
+
+#include "rootgraphicsitem.hh"
+#include "regionitem.hh"
+#include "selection.hh"
+
+class Scene :
+ public QGraphicsScene
+{
+ Q_OBJECT
+
+ public:
+ explicit Scene(QObject *parent = 0);
+ explicit Scene(const QRectF &sceneRect, QObject *parent = 0);
+ explicit Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent = 0);
+
+ inline QString backgroundPath() const;
+ inline QGraphicsPixmapItem *backgroundPixmap() const;
+
+ inline QList<RegionItem *> selectedRegions() const;
+
+ void setRoot(RootGraphicsItem *rootItem);
+ inline RootGraphicsItem *root() const;
+
+ void select(const QRectF& rect);
+ void select(const QPointF& point);
+ void selectAll();
+
+ inline bool selectionEnable() const;
+ inline void setSelectionEnable(bool enable);
+
+ void changeScene(const QString& filename, RootGraphicsItem *root = 0);
+
+ protected:
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+
+ private:
+ void init();
+ void select(QGraphicsItem *root, const QPointF& point, const QRectF& rect);
+
+ QGraphicsView *mainView_;
+ RootGraphicsItem *root_;
+
+ QString backgroundPath_;
+ QGraphicsPixmapItem *backgroundPixmap_;
+
+ Selection selection_;
+ QList<RegionItem *> selectedRegions_;
+ QList<RegionItem *> baseSelection_;
+
+ QPointF pressPos_;
+ bool isPressing_;
+ bool isSelectionDisabled_;
+
+ public slots:
+ void clearAll();
+ void clearRegions();
+ void clearSelection();
+
+ void select(const QList<RegionItem *>& selectedRegions);
+ inline void selectBase();
+ void unselect(const QList<RegionItem *>& unselectedItems);
+
+ void setVisible(const GraphicsRegion::Id& region, bool visible);
+ void ensureVisible(QGraphicsItem *graphicsItem);
+
+ inline void disableSelection();
+ inline void enableSelection();
+
+ signals:
+ void selectionCleared();
+ void newSelection();
+ void newSelection(const QList<RegionItem *>& selectedRegions);
+};
+
+inline QString Scene::backgroundPath() const
+{ return backgroundPath_; }
+
+inline QGraphicsPixmapItem *Scene::backgroundPixmap() const
+{ return backgroundPixmap_; }
+
+inline RootGraphicsItem *Scene::root() const
+{ return root_; }
+
+inline QList<RegionItem *> Scene::selectedRegions() const
+{ return selectedRegions_; }
+
+inline void Scene::selectBase()
+{ select(baseSelection_); }
+
+inline void Scene::select(const QPointF& point)
+{ select(root_, point, QRectF()); }
+
+inline void Scene::select(const QRectF& rect)
+{ select(root_, QPointF(), rect); }
+
+inline void Scene::setSelectionEnable(bool enable)
+{ isSelectionDisabled_ = !enable; }
+
+inline bool Scene::selectionEnable() const
+{ return isSelectionDisabled_; }
+
+inline void Scene::disableSelection()
+{ setSelectionEnable(false); }
+
+inline void Scene::enableSelection()
+{ setSelectionEnable(true); }
+
+#endif // SCENE_H
diff --git a/scribo/demo/viewer/Rendering/selection.cc b/scribo/demo/viewer/Rendering/selection.cc
new file mode 100644
index 0000000..89d2349
--- /dev/null
+++ b/scribo/demo/viewer/Rendering/selection.cc
@@ -0,0 +1,52 @@
+// Copyright (C) 2013 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 "selection.hh"
+
+Selection::Selection(QGraphicsScene *scene):
+ QGraphicsRectItem(0, scene)
+{
+ init();
+}
+
+Selection::Selection(const QRectF &rect, QGraphicsScene *scene):
+ QGraphicsRectItem(rect, 0, scene)
+{
+ init();
+}
+
+Selection::Selection(qreal x, qreal y, qreal width, qreal height, QGraphicsScene *scene):
+ QGraphicsRectItem(x, y, width, height, 0, scene)
+{
+ init();
+}
+
+void Selection::init()
+{
+ // Always drawn on top of the scene.
+ setZValue(INT_MAX);
+
+ QPen pen;
+ pen.setStyle(Qt::SolidLine);
+ pen.setCapStyle(Qt::SquareCap);
+ pen.setCosmetic(true);
+ setPen(pen);
+
+ QBrush brush;
+ brush.setStyle(Qt::SolidPattern);
+ brush.setColor(QColor::fromRgb(80, 200, 10, 60));
+ setBrush(brush);
+}
diff --git a/GScribo/Rendering/selection.h b/scribo/demo/viewer/Rendering/selection.hh
similarity index 100%
rename from GScribo/Rendering/selection.h
rename to scribo/demo/viewer/Rendering/selection.hh
diff --git a/GScribo/TODO b/scribo/demo/viewer/TODO
similarity index 100%
rename from GScribo/TODO
rename to scribo/demo/viewer/TODO
diff --git a/scribo/demo/viewer/XmlWidget/attributesmodel.cc b/scribo/demo/viewer/XmlWidget/attributesmodel.cc
new file mode 100644
index 0000000..d2e1cb0
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/attributesmodel.cc
@@ -0,0 +1,108 @@
+// Copyright (C) 2013 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 "attributesmodel.hh"
+
+AttributesModel::AttributesModel(const XmlAttributes& attributes, QObject *parent) :
+ QAbstractItemModel(parent)
+{
+ attributes_ = attributes;
+}
+
+AttributesModel::AttributesModel(const XmlAttributes& attributes, QAbstractItemModelPrivate& dd, QObject *parent) :
+ QAbstractItemModel(dd, parent)
+{
+ attributes_ = attributes;
+}
+
+QVariant AttributesModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if(orientation == Qt::Horizontal && role == Qt::DisplayRole)
+ {
+ switch(section)
+ {
+ case 0:
+ return tr("Name");
+
+ case 1:
+ return tr("Value");
+
+ default:
+ return QVariant();
+ }
+ }
+
+ return QVariant();
+}
+
+QVariant AttributesModel::data(const QModelIndex& index, int role) const
+{
+ if(!index.isValid())
+ return QVariant();
+
+ switch(role)
+ {
+ case Qt::UserRole:
+ return attributes_.names()[index.row()];
+
+ case Qt::UserRole+1:
+ return attributes_.values()[index.row()];
+
+ default:
+ return QVariant();
+ }
+}
+
+void AttributesModel::load(const XmlAttributes& attributes)
+{
+ beginResetModel();
+
+ attributes_ = attributes;
+
+ endResetModel();
+}
+
+void AttributesModel::reset()
+{
+ beginResetModel();
+
+ attributes_ = XmlAttributes();
+
+ endResetModel();
+}
+
+
+int AttributesModel::rowCount(const QModelIndex&) const
+{
+ return attributes_.names().count();
+}
+
+int AttributesModel::columnCount(const QModelIndex&) const
+{
+ return 2;
+}
+
+QModelIndex AttributesModel::index(int row, int column, const QModelIndex& parent) const
+{
+ if(!hasIndex(row, column, parent))
+ return QModelIndex();
+ return createIndex(row, column, 0);
+}
+
+QModelIndex AttributesModel::parent(const QModelIndex&) const
+{
+ return QModelIndex();
+}
diff --git a/scribo/demo/viewer/XmlWidget/attributesmodel.hh b/scribo/demo/viewer/XmlWidget/attributesmodel.hh
new file mode 100644
index 0000000..c99c993
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/attributesmodel.hh
@@ -0,0 +1,55 @@
+// Copyright (C) 2013 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 ATTRIBUTESMODEL_HH
+# define ATTRIBUTESMODEL_HH
+
+#include <QAbstractItemModel>
+
+#include "xmlattributes.hh"
+
+class AttributesModel :
+ public QAbstractItemModel
+{
+ Q_OBJECT
+
+ public:
+ explicit AttributesModel(const XmlAttributes& attributes = XmlAttributes(),
+ QObject *parent = 0);
+ explicit AttributesModel(const XmlAttributes& attributes,
+ QAbstractItemModelPrivate& dd,
+ QObject *parent = 0);
+
+ int rowCount(const QModelIndex& parent) const;
+ int columnCount(const QModelIndex& parent) const;
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ QVariant data(const QModelIndex& index, int role) const;
+
+ QModelIndex index(int row, int column, const QModelIndex &parent) const;
+ QModelIndex parent(const QModelIndex &child) const;
+
+public slots:
+ void reset();
+
+private:
+ XmlAttributes attributes_;
+
+public slots:
+ void load(const XmlAttributes& attributes);
+};
+
+#endif // ATTRIBUTESMODEL_HH
diff --git a/scribo/demo/viewer/XmlWidget/selectionproxy.hh b/scribo/demo/viewer/XmlWidget/selectionproxy.hh
new file mode 100644
index 0000000..7817c72
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/selectionproxy.hh
@@ -0,0 +1,47 @@
+#ifndef SELECTIONPROXY_H
+#define SELECTIONPROXY_H
+
+#include <QSortFilterProxyModel>
+#include <QDebug>
+
+#include "xmlitem.hh"
+
+class SelectionProxy :
+ public QSortFilterProxyModel
+{
+ public:
+ explicit SelectionProxy(QObject *parent = 0) : QSortFilterProxyModel(parent) { isAllDisplayed_ = true; }
+
+ inline void displayAll();
+ inline bool isAllDisplayed();
+
+ inline void beginResetModel();
+ inline void endResetModel();
+ inline void invalidateFilter();
+
+ protected:
+ inline bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const;
+
+ private:
+ bool isAllDisplayed_;
+};
+
+inline bool SelectionProxy::filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const
+{ return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent) && (isAllDisplayed_ || sourceModel()->index(sourceRow, 0, sourceParent).data(Qt::UserRole+2).value<XmlItem *>()->isVisible()); }
+
+inline void SelectionProxy::beginResetModel()
+{ isAllDisplayed_ = false; QSortFilterProxyModel::beginResetModel(); }
+
+inline void SelectionProxy::endResetModel()
+{ QSortFilterProxyModel::endResetModel(); }
+
+inline void SelectionProxy::displayAll()
+{ isAllDisplayed_ = true; }
+
+inline bool SelectionProxy::isAllDisplayed()
+{ return isAllDisplayed_; }
+
+inline void SelectionProxy::invalidateFilter()
+{ QSortFilterProxyModel::invalidateFilter(); }
+
+#endif // SELECTIONPROXY_H
diff --git a/scribo/demo/viewer/XmlWidget/xmlattributes.cc b/scribo/demo/viewer/XmlWidget/xmlattributes.cc
new file mode 100644
index 0000000..0a441c3
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/xmlattributes.cc
@@ -0,0 +1,49 @@
+// Copyright (C) 2013 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 "xmlattributes.hh"
+
+XmlAttributes::XmlAttributes()
+{
+}
+
+XmlAttributes::XmlAttributes(const QDomNamedNodeMap& node)
+{
+ load(node);
+}
+
+void XmlAttributes::load(const QDomNamedNodeMap& node)
+{
+ QDomAttr attr;
+
+ for(int i = 0; i < node.count(); i++)
+ {
+ attr = node.item(i).toAttr();
+
+ names_ << attr.name();
+ values_ << attr.value();
+ }
+}
+
+QStringList XmlAttributes::names() const
+{
+ return names_;
+}
+
+QStringList XmlAttributes::values() const
+{
+ return values_;
+}
diff --git a/scribo/demo/viewer/XmlWidget/xmlattributes.hh b/scribo/demo/viewer/XmlWidget/xmlattributes.hh
new file mode 100644
index 0000000..89c546e
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/xmlattributes.hh
@@ -0,0 +1,44 @@
+// Copyright (C) 2013 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 XMLATTRIBUTES_H
+# define XMLATTRIBUTES_H
+
+#include <QDomNamedNodeMap>
+#include <QStringList>
+#include <QVariant>
+
+class XmlAttributes
+{
+ public:
+ explicit XmlAttributes();
+ explicit XmlAttributes(const QDomNamedNodeMap& node);
+
+ void load(const QDomNamedNodeMap& node);
+
+ QStringList names() const;
+ QStringList values() const;
+
+ private:
+ QStringList names_;
+ QStringList values_;
+};
+
+
+Q_DECLARE_METATYPE(XmlAttributes)
+Q_DECLARE_METATYPE(XmlAttributes *)
+
+#endif // XMLATTRIBUTES_H
diff --git a/GScribo/XmlWidget/xmldelegate.h b/scribo/demo/viewer/XmlWidget/xmldelegate.hh
similarity index 100%
rename from GScribo/XmlWidget/xmldelegate.h
rename to scribo/demo/viewer/XmlWidget/xmldelegate.hh
diff --git a/scribo/demo/viewer/XmlWidget/xmlitem.cc b/scribo/demo/viewer/XmlWidget/xmlitem.cc
new file mode 100644
index 0000000..c12c819
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/xmlitem.cc
@@ -0,0 +1,59 @@
+// Copyright (C) 2013 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 "xmlitem.hh"
+
+XmlItem::XmlItem(XmlItem *parent, XmlItem *precItem)
+{
+ init(parent, precItem);
+}
+
+XmlItem::XmlItem(const QDomElement& node, XmlItem *parent, XmlItem *precItem)
+{
+ init(parent, precItem);
+ load(node);
+}
+
+XmlItem::~XmlItem()
+{
+ // Delete all childs.
+ XmlItem *child;
+ foreach(child, childs_)
+ delete child;
+}
+
+void XmlItem::init(XmlItem *parent, XmlItem *precItem)
+{
+ isVisible_ = false;
+ regionItem_ = 0;
+ parent_ = parent;
+
+ if(parent)
+ parent->addChild(this);
+
+ if(precItem)
+ row_ = precItem->row()+1;
+ else
+ row_ = 0;
+}
+
+void XmlItem::load(const QDomElement& node)
+{
+ text_ = node.tagName();
+
+ // Load attributes.
+ attributes_.load(node.attributes());
+}
diff --git a/scribo/demo/viewer/XmlWidget/xmlitem.hh b/scribo/demo/viewer/XmlWidget/xmlitem.hh
new file mode 100644
index 0000000..a964ea7
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/xmlitem.hh
@@ -0,0 +1,106 @@
+// Copyright (C) 2013 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 XMLITEM_H
+#define XMLITEM_H
+
+#include <QDomElement>
+
+#include "xmlattributes.hh"
+
+class RegionItem;
+
+class XmlItem
+{
+ public:
+ explicit XmlItem(XmlItem *parent = 0, XmlItem *precItem = 0);
+ explicit XmlItem(const QDomElement& node, XmlItem *parent = 0, XmlItem *precItem = 0);
+ ~XmlItem();
+
+ void load(const QDomElement& node);
+
+ inline QList<XmlItem *> childs() const;
+ inline XmlItem *child(int i) const;
+ inline void addChild(XmlItem *child);
+ inline XmlItem *parent() const;
+
+ inline RegionItem *regionItem();
+ inline void setRegionItem(RegionItem *regionItem);
+
+ inline bool isVisible() const;
+ inline void setVisible(bool visible);
+ inline void show();
+ inline void hide();
+
+ inline QString text() const;
+ inline int row() const;
+ inline XmlAttributes attributes() const;
+
+ private:
+ void init(XmlItem *parent = 0, XmlItem *precItem = 0);
+
+ int row_;
+ bool isVisible_;
+ QList<XmlItem *> childs_;
+ XmlItem *parent_;
+ RegionItem *regionItem_;
+ QString text_;
+ XmlAttributes attributes_;
+};
+
+inline QList<XmlItem *> XmlItem::childs() const
+{ return childs_; }
+
+inline XmlItem *XmlItem::child(int i) const
+{ if(i > -1 && i < childs_.count()) return childs_[i]; return 0; }
+
+inline void XmlItem::addChild(XmlItem *child)
+{ childs_ << child; }
+
+inline XmlItem *XmlItem::parent() const
+{ return parent_; }
+
+inline RegionItem *XmlItem::regionItem()
+{ return regionItem_; }
+
+inline void XmlItem::setRegionItem(RegionItem *regionItem)
+{ regionItem_ = regionItem; }
+
+inline bool XmlItem::isVisible() const
+{ return isVisible_; }
+
+inline void XmlItem::setVisible(bool visible)
+{ isVisible_ = visible; }
+
+inline void XmlItem::show()
+{ isVisible_ = true; }
+
+inline void XmlItem::hide()
+{ isVisible_ = false; }
+
+inline QString XmlItem::text() const
+{ return text_; }
+
+inline int XmlItem::row() const
+{ return row_; }
+
+inline XmlAttributes XmlItem::attributes() const
+{ return attributes_; }
+
+Q_DECLARE_METATYPE(XmlItem)
+Q_DECLARE_METATYPE(XmlItem *)
+
+#endif // XMLITEM_H
diff --git a/scribo/demo/viewer/XmlWidget/xmlmodel.cc b/scribo/demo/viewer/XmlWidget/xmlmodel.cc
new file mode 100644
index 0000000..0f51eb7
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/xmlmodel.cc
@@ -0,0 +1,123 @@
+// Copyright (C) 2013 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 "xmlmodel.hh"
+
+XmlModel::XmlModel(XmlItem *rootItem, QObject *parent) :
+ QAbstractItemModel(parent)
+{
+ rootItem_ = rootItem;
+}
+
+XmlModel::XmlModel(XmlItem *rootItem,
+ QAbstractItemModelPrivate& dd,
+ QObject *parent)
+ : QAbstractItemModel(dd, parent)
+{
+ rootItem_ = rootItem;
+}
+
+XmlModel::~XmlModel()
+{
+ if(rootItem_)
+ delete rootItem_;
+}
+
+QVariant XmlModel::headerData(int, Qt::Orientation orientation, int role) const
+{
+ if(orientation == Qt::Horizontal && role == Qt::DisplayRole)
+ return tr("Tree");
+
+ return QVariant();
+}
+
+QVariant XmlModel::data(const QModelIndex& index, int role) const
+{
+ if(!index.isValid())
+ return QVariant();
+
+ switch(role)
+ {
+ case Qt::UserRole:
+ return static_cast<XmlItem *>(index.internalPointer())->text();
+
+ case Qt::UserRole+1:
+ return QVariant::fromValue(static_cast<XmlItem *>(index.internalPointer())->attributes());
+
+ case Qt::UserRole+2:
+ return QVariant::fromValue(static_cast<XmlItem *>(index.internalPointer()));
+
+ default:
+ return QVariant();
+ }
+}
+
+QModelIndex XmlModel::index(int row, int column, const QModelIndex& parent) const
+{
+ if(!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ XmlItem *childItem = toXmlItem(parent)->child(row);
+
+ // Create the model index from the child item.
+ if(childItem)
+ return createIndex(row, column, childItem);
+ else
+ return QModelIndex();
+}
+
+QModelIndex XmlModel::parent(const QModelIndex& child) const
+{
+ if(!child.isValid())
+ return QModelIndex();
+
+ XmlItem *parentItem = static_cast<XmlItem *>(child.internalPointer())->parent();
+
+ if(!parentItem || parentItem == rootItem_)
+ return QModelIndex();
+
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+
+void XmlModel::load(XmlItem *rootItem)
+{
+ beginResetModel();
+
+ if(rootItem_)
+ delete rootItem_;
+
+ rootItem_ = rootItem;
+
+ endResetModel();
+}
+
+
+inline XmlItem *XmlModel::toXmlItem(const QModelIndex& parent) const
+{
+ return !parent.isValid() ? rootItem_ : static_cast<XmlItem *>(parent.internalPointer());
+}
+
+inline int XmlModel::rowCount(const QModelIndex& parent) const
+{
+ if(rootItem_)
+ return toXmlItem(parent)->childs().count();
+ return 0;
+}
+
+inline int XmlModel::columnCount(const QModelIndex&) const
+{
+ return 1;
+}
diff --git a/scribo/demo/viewer/XmlWidget/xmlmodel.hh b/scribo/demo/viewer/XmlWidget/xmlmodel.hh
new file mode 100644
index 0000000..a781ea7
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/xmlmodel.hh
@@ -0,0 +1,51 @@
+// Copyright (C) 2013 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 XMLMODEL_H
+#define XMLMODEL_H
+
+#include <QAbstractItemModel>
+
+#include "variantpointer.hh"
+#include "xmlitem.hh"
+
+class XmlModel :
+ public QAbstractItemModel
+{
+ public:
+ explicit XmlModel(XmlItem *rootItem = 0, QObject *parent = 0);
+ explicit XmlModel(XmlItem *rootItem, QAbstractItemModelPrivate& dd, QObject *parent = 0);
+ ~XmlModel();
+
+ void load(XmlItem *rootItem);
+
+ inline int rowCount(const QModelIndex& parent) const;
+ inline int columnCount(const QModelIndex& parent) const;
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+
+ QVariant data(const QModelIndex& index, int role) const;
+
+ QModelIndex index(int row, int column, const QModelIndex& parent) const;
+ QModelIndex parent(const QModelIndex& child) const;
+
+ private:
+ inline XmlItem *toXmlItem(const QModelIndex& index) const;
+
+ XmlItem *rootItem_;
+};
+
+#endif // XMLMODEL_H
diff --git a/scribo/demo/viewer/XmlWidget/xmlview.cc b/scribo/demo/viewer/XmlWidget/xmlview.cc
new file mode 100644
index 0000000..c943401
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/xmlview.cc
@@ -0,0 +1,104 @@
+// Copyright (C) 2013 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 "xmlview.hh"
+
+XmlView::XmlView(QWidget *parent) :
+ QTreeView(parent)
+{
+ proxy_.setFilterRole(Qt::UserRole);
+ proxy_.setDynamicSortFilter(true);
+
+ setUniformRowHeights(true);
+ setItemDelegate(new XmlDelegate(Qt::UserRole));
+ setSelectionMode(QAbstractItemView::ExtendedSelection);
+}
+
+void XmlView::hideAll()
+{
+ proxy_.beginResetModel();
+
+ XmlItem *child;
+ foreach(child, displayedItems_)
+ child->hide();
+
+ displayedItems_.clear();
+ emit resetProperty();
+
+ proxy_.endResetModel();
+}
+
+void XmlView::display(QList<XmlItem *> displayedItems, bool addToDisplayedList)
+{
+ proxy_.beginResetModel();
+
+ if(!addToDisplayedList)
+ hideAll();
+
+ XmlItem *child;
+ foreach(child, displayedItems)
+ {
+ child->show();
+ displayedItems_ << child;
+ }
+
+ proxy_.endResetModel();
+
+ expandAll();
+}
+
+QList<XmlItem *> XmlView::transform(const QModelIndexList& modelIndexList) const
+{
+ QList<XmlItem *> selectedItems;
+ QModelIndex index;
+
+ foreach(index, modelIndexList)
+ selectedItems << index.data(Qt::UserRole+2).value<XmlItem *>();
+
+ return selectedItems;
+}
+
+void XmlView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected)
+{
+ QTreeView::selectionChanged(selected, deselected);
+
+ if(selected.indexes() == selectedIndexes())
+ emit resetSelection();
+
+ if(!selectedIndexes().isEmpty())
+ {
+ QList<XmlItem *> xmlItems;
+ if(!selected.isEmpty())
+ {
+ xmlItems = transform(selected.indexes());
+ emit select(xmlItems);
+ }
+ else
+ {
+ xmlItems = transform(deselected.indexes());
+ emit unselect(xmlItems);
+ }
+
+ emit loadAttributes(xmlItems.last()->attributes());
+ }
+ else
+ {
+ emit resetProperty();
+ emit emptySelection();
+ }
+
+ emit newSelection();
+}
diff --git a/scribo/demo/viewer/XmlWidget/xmlview.hh b/scribo/demo/viewer/XmlWidget/xmlview.hh
new file mode 100644
index 0000000..b9720dc
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/xmlview.hh
@@ -0,0 +1,95 @@
+// Copyright (C) 2013 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 XMLVIEW_H
+#define XMLVIEW_H
+
+#include <QGraphicsItem>
+#include <QTreeView>
+
+#include "Rendering/regionitem.hh"
+#include "selectionproxy.hh"
+#include "xmldelegate.hh"
+#include "xmlitem.hh"
+
+class XmlView :
+ public QTreeView
+{
+ Q_OBJECT
+
+ public:
+ explicit XmlView(QWidget *parent = 0);
+
+ inline QList<XmlItem *> displayedItems() const;
+ void hideAll();
+
+ inline QList<XmlItem *> selectedItems() const;
+
+ inline void setModel(QAbstractItemModel *model);
+
+ protected:
+ void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
+
+ private:
+ QList<XmlItem *> transform(const QModelIndexList& modelIndexList) const;
+ void display(QList<XmlItem *> displayedItems, bool addToDisplayedList);
+
+ SelectionProxy proxy_;
+ QList<XmlItem *> displayedItems_;
+
+ public slots:
+ inline void display(QList<XmlItem *> displayedItems);
+ inline void displayOnly(QList<XmlItem *> displayedItems);
+
+ inline void displayAll();
+
+ inline void setFilterString(const QString& filterString);
+
+ signals:
+ void loadAttributes(const XmlAttributes& xmlAttributes);
+
+ void select(const QList<XmlItem *>& selectedItems);
+ void unselect(const QList<XmlItem *>& unselectedItems);
+
+ void newSelection();
+ void emptySelection();
+
+ void resetSelection();
+ void resetProperty();
+};
+
+inline QList<XmlItem *> XmlView::displayedItems() const
+{ return displayedItems_; }
+
+inline void XmlView::display(QList<XmlItem *> displayedItems)
+{ display(displayedItems, true); }
+
+inline void XmlView::displayOnly(QList<XmlItem *> displayedItems)
+{ display(displayedItems, false); }
+
+inline void XmlView::displayAll()
+{ hideAll(); proxy_.displayAll(); }
+
+inline QList<XmlItem *> XmlView::selectedItems() const
+{ return transform(selectedIndexes()); }
+
+inline void XmlView::setFilterString(const QString& filterString)
+{ proxy_.setFilterRegExp(QRegExp(filterString, Qt::CaseSensitive)); proxy_.invalidateFilter(); }
+
+inline void XmlView::setModel(QAbstractItemModel *model)
+{ proxy_.setSourceModel(model); QTreeView::setModel(&proxy_); }
+
+#endif // XMLVIEW_H
diff --git a/scribo/demo/viewer/XmlWidget/xmlwidget.cc b/scribo/demo/viewer/XmlWidget/xmlwidget.cc
new file mode 100644
index 0000000..e6bfe2a
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/xmlwidget.cc
@@ -0,0 +1,66 @@
+// Copyright (C) 2013 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 "xmlwidget.hh"
+
+XmlWidget::XmlWidget(QWidget *parent) :
+ QSplitter(Qt::Horizontal, parent)
+{
+ proxy_.setFilterRegExp(QRegExp("(?:Page|.Region|Line)", Qt::CaseSensitive));
+ proxy_.setDynamicSortFilter(true);
+ proxy_.setFilterRole(Qt::UserRole);
+ proxy_.setSourceModel(&model_);
+
+ view_.setModel(&proxy_);
+
+ attributes_.setModel(&attributesModel_);
+ attributes_.setSelectionMode(QAbstractItemView::NoSelection);
+ attributes_.setItemDelegateForColumn(0, new XmlDelegate(Qt::UserRole));
+ attributes_.setItemDelegateForColumn(1, new XmlDelegate(Qt::UserRole+1));
+
+ addWidget(&view_);
+ addWidget(&attributes_);
+
+ connect(&view_, SIGNAL(resetProperty()), &attributesModel_, SLOT(reset()));
+ connect(&view_, SIGNAL(clicked(QModelIndex)), this, SLOT(loadAttributes(QModelIndex)));
+ connect(&view_, SIGNAL(loadAttributes(XmlAttributes)), &attributesModel_, SLOT(load(XmlAttributes)));
+}
+
+void XmlWidget::changeView(XmlItem *rootItem)
+{
+ attributesModel_.reset();
+
+ model_.load(rootItem);
+
+ view_.displayAll();
+ view_.expandAll();
+}
+
+
+XmlView * XmlWidget::view()
+{
+ return &view_;
+}
+
+QTableView *XmlWidget::attributes()
+{
+ return &attributes_;
+}
+
+void XmlWidget::loadAttributes(const QModelIndex& index)
+{
+ attributesModel_.load(index.data(Qt::UserRole+2).value<XmlItem *>()->attributes());
+}
diff --git a/scribo/demo/viewer/XmlWidget/xmlwidget.hh b/scribo/demo/viewer/XmlWidget/xmlwidget.hh
new file mode 100644
index 0000000..2662ae1
--- /dev/null
+++ b/scribo/demo/viewer/XmlWidget/xmlwidget.hh
@@ -0,0 +1,61 @@
+// Copyright (C) 2013 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 XMLWIDGET_H
+# define XMLWIDGET_H
+
+#include <QSortFilterProxyModel>
+#include <QTableView>
+#include <QTreeWidget>
+#include <QSplitter>
+#include <QDomElement>
+#include <QWidget>
+
+#include "Rendering/scene.hh"
+#include "selectionproxy.hh"
+#include "attributesmodel.hh"
+#include "variantpointer.hh"
+#include "xmldelegate.hh"
+#include "xmlmodel.hh"
+#include "xmlview.hh"
+
+class XmlWidget :
+ public QSplitter
+{
+ Q_OBJECT
+
+ public:
+ explicit XmlWidget(QWidget *parent = 0);
+
+ XmlView *view();
+ QTableView *attributes();
+
+ void changeView(XmlItem *rootItem);
+
+ private:
+ QSortFilterProxyModel proxy_;
+
+ XmlModel model_;
+ AttributesModel attributesModel_;
+
+ XmlView view_;
+ QTableView attributes_;
+
+ private slots:
+ void loadAttributes(const QModelIndex& index);
+};
+
+#endif // XMLWIDGET_H
diff --git a/scribo/demo/viewer/aboutdialog.cc b/scribo/demo/viewer/aboutdialog.cc
new file mode 100644
index 0000000..c668d23
--- /dev/null
+++ b/scribo/demo/viewer/aboutdialog.cc
@@ -0,0 +1,31 @@
+// Copyright (C) 2013 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 <aboutdialog.hh>
+
+
+AboutDialog::AboutDialog(QWidget *parent)
+ : QDialog(parent, Qt::Dialog)
+{
+ ui = new Ui::AboutDialog;
+ ui->setupUi(this);
+}
+
+AboutDialog::~AboutDialog()
+{
+ delete ui;
+}
+
diff --git a/scribo/demo/viewer/aboutdialog.hh b/scribo/demo/viewer/aboutdialog.hh
new file mode 100644
index 0000000..359489d
--- /dev/null
+++ b/scribo/demo/viewer/aboutdialog.hh
@@ -0,0 +1,40 @@
+// Copyright (C) 2013 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 ABOUTDIALOG_HH
+# define ABOUTDIALOG_HH
+
+#include <QDialog>
+
+#include "aboutdialog.ui.h"
+
+namespace Ui
+{
+ class AboutDialog;
+}
+
+class AboutDialog :
+ public QDialog
+{
+public:
+ explicit AboutDialog(QWidget *parent = 0);
+ ~AboutDialog();
+
+private:
+ Ui::AboutDialog *ui;
+};
+
+#endif // ABOUTDIALOG_HH
diff --git a/scribo/demo/viewer/aboutdialog.ui b/scribo/demo/viewer/aboutdialog.ui
new file mode 100644
index 0000000..87bed94
--- /dev/null
+++ b/scribo/demo/viewer/aboutdialog.ui
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AboutDialog</class>
+ <widget class="QDialog" name="AboutDialog">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>557</width>
+ <height>390</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>557</width>
+ <height>390</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>557</width>
+ <height>390</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>About</string>
+ </property>
+ <property name="windowIcon">
+ <iconset>
+ <normaloff>:/icons/shared/icons/olena_smaller.jpg</normaloff>:/icons/shared/icons/olena_smaller.jpg</iconset>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="pixmap">
+ <pixmap>:/icons/shared/icons/olena_smaller.jpg</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </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>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <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:'Sans Serif'; 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-family:'DejaVu Sans'; font-size:12pt; font-weight:600;">Document Image Analysis Tool</span></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:12pt; font-weight:600;"></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans';">This project is powered by </span><span style=" font-family:'DejaVu Sans'; font-weight:600; font-style:italic;">Milena</span><span style=" font-family:'DejaVu Sans';">, a generic image processing library.</span></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans';">It is part of </span><span style=" font-family:'DejaVu Sans'; font-weight:600; font-style:italic;">Olena</span><span style=" font-family:'DejaVu Sans';">, an Image Processing Platform and its module </span><span style=" font-family:'DejaVu Sans'; font-weight:600; font-style:italic;">Scribo</span><span style=" font-family:'DejaVu Sans';">, a set of tools for Document Image Analysis.</span></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
+<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://olena.lrde.epita.fr"><span style=" font-family:'DejaVu Sans'; text-decoration: underline; color:#0057ae;">http://olena.lrde.epita.fr</span></a></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans';"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:8pt;">Thanks to Antoine Froger, Arthur Crépin-Leblond, Samuel Da Mota, Loic Denuziere, Jérôme Galtier, Florent d'Halluin, Alex Hamelin, Damien Lefortier, Vincent Ordy, Guillaume Sadegh and Warren Seine for their contribution.</span></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:8pt;"></p>
+<p align="justify" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:8pt;"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:7pt;">This application has been developed in the context of the SCRIBO project of the Free Software Thematic Group, part of the &quot;System@tic Paris-Région&quot; Cluster (France). This project is partially funded by the French Government, its economic development agencies, and by the Paris-Région institutions.</span></p>
+<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'DejaVu Sans'; font-size:7pt;"></p>
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'DejaVu Sans'; font-size:7pt;">Copyright (C) 2012, 2013 EPITA Research and Development Laboratory (LRDE)</span></p></body></html></string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Ok</set>
+ </property>
+ <property name="centerButtons">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>AboutDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>281</x>
+ <y>391</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>240</x>
+ <y>203</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/scribo/demo/viewer/browser_widget.cc b/scribo/demo/viewer/browser_widget.cc
deleted file mode 100644
index 17e1c61..0000000
--- a/scribo/demo/viewer/browser_widget.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-// 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 "browser_widget.hh"
-
-BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
- : files_(files),
- view_(new QListView()),
- path_(new QLineEdit("")),
- first_time_(true)
-{
- QToolButton* next= new QToolButton();
- QToolButton* prev= new QToolButton();
-
- prev->setIcon(style()->standardIcon(QStyle::SP_ArrowLeft));
- next->setIcon(style()->standardIcon(QStyle::SP_ArrowRight));
- next->setShortcut(QKeySequence("Ctrl+right"));
- prev->setShortcut(QKeySequence("Ctrl+left"));
-
- QLabel* title = new QLabel(tr("Images"));
- title->setAlignment(Qt::AlignHCenter);
-
- QVBoxLayout* layout = new QVBoxLayout;
- QHBoxLayout *hlayout = new QHBoxLayout;
-
- hlayout->addWidget(prev);
- hlayout->addWidget(title);
- hlayout->addWidget(next);
- layout->addLayout(hlayout);
- layout->addWidget(path_);
- layout->addWidget(view_);
-
- //setLayout(hlayout);
- setLayout(layout);
-
- view_->setModel(files);
- files->setFilter(QDir::AllDirs | QDir::Files
- | QDir::Readable | QDir::Drives);
-
- view_->setRootIndex(files->index(QDir::currentPath()));
-
- QDir d(dir);
- if (d.isReadable())
- view_->setRootIndex(files->index(d.absolutePath()));
-
- view_->setRowHidden(0, true);
-
- path_->setText(files->filePath(view_->rootIndex()));
-
- connect(view_, SIGNAL(activated(const QModelIndex&)),
- this, SLOT(activate(const QModelIndex&)));
- connect(next, SIGNAL(released ()),
- this, SLOT(next()));
- connect(prev, SIGNAL(released ()),
- this, SLOT(prev()));
- connect(path_, SIGNAL(returnPressed()),
- this, SLOT(path_return_pressed()));
-
- QStringList files_filters;
- files_filters << "*.png" << "*.jpg"
- << "*.tif" << "*.ppm"
- << "*.pgm" << "*.pbm"
- << "*.pnm" << "*.xmlc";
-
- files->setNameFilters(files_filters);
-}
-
-void
-BrowserWidget::path_return_pressed()
-{
- QString path = path_->text();
- QDir d(path);
-
- if (d.isReadable())
- activate(files_->index(QString(path)), false);
-}
-
-void
-BrowserWidget::activate(const QModelIndex& index, bool b)
-{
- if (files_->isDir(index))
- {
- view_->setRootIndex(index);
- view_->setRowHidden(0, true);
- path_->setText(files_->filePath(view_->rootIndex()));
- first_time_ = true;
- return;
- }
-
- first_time_ = false;
-
- if (files_->filePath(index).endsWith(".xmlc"))
- emit activated(files_->filePath(index), b, true);
- else
- emit activated(files_->filePath(index), b, false);
-}
-
-void
-BrowserWidget::change_pos(bool next)
-{
- QModelIndex index = view_->currentIndex();
-
- if(next)
- index = files_->index(index.row() + 1, index.column(), index.parent());
- else
- index = files_->index(index.row() - 1, index.column(), index.parent());
-
- if (index.isValid())
- {
- if (!files_->isDir(index))
- if (!first_time_)
- activate(index, true);
- view_->setCurrentIndex(index);
- }
-}
-
-BrowserWidget::~BrowserWidget()
-{
-}
-
-QString
-BrowserWidget::current() const
-{
- return files_->filePath(view_->currentIndex());
-}
diff --git a/scribo/demo/viewer/browser_widget.hh b/scribo/demo/viewer/browser_widget.hh
deleted file mode 100644
index 9567c11..0000000
--- a/scribo/demo/viewer/browser_widget.hh
+++ /dev/null
@@ -1,50 +0,0 @@
-// 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_BROWSER_WIDGET_HH
-# define SCRIBO_DEMO_VIEWER_BROWSER_WIDGET_HH
-
-# include <QtGui>
-
-class BrowserWidget
- : public QWidget
-{
- Q_OBJECT
-
-public:
- BrowserWidget(QDirModel* files, QString dir = QString());
- ~BrowserWidget();
-
- QString current() const;
-
-public slots:
- void activate(const QModelIndex& index, bool b = false);
- void path_return_pressed();
- void next() { change_pos(true); }
- void prev() { change_pos(false); }
-
-signals:
- void activated(QString filename, bool b, bool x);
-
-private:
- void change_pos(bool next);
- QDirModel* files_;
- QListView* view_;
- QLineEdit* path_;
- bool first_time_;
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_BROWSER_WIDGET_HH
diff --git a/scribo/demo/viewer/common.hh b/scribo/demo/viewer/common.hh
deleted file mode 100644
index 0072376..0000000
--- a/scribo/demo/viewer/common.hh
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (C) 2010, 2011 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_COMMON_HH
-# define SCRIBO_DEMO_VIEWER_COMMON_HH
-
-namespace region
-{
- typedef QVector<QPair<QString, QColor> > KeyMap;
-
- enum RegionId
- {
- // Text regions
- // -------------
-
- Text = 0,
-
- // Extension
- Line,
-
- EndOfTextRegion,
-
- // Separators
- // ----------
-
- HorizontalSeparator,
- VerticalSeparator,
-
- // Extension
- WhitespaceSeparator,
-
- EndOfSepsRegion,
-
- // Misc regions.
- // -------------
- Image,
- Noise,
- Table,
- LineDrawing,
- Graphic,
- Chart,
- Maths,
-
- EndOfMiscRegion,
-
- // Typographical lines
- // -------------------
-
- // Extension
- Baseline,
- Meanline,
-
- EndOfTypoRegion,
-
- RegionIdCount
- };
-}
-
-#endif // ! SCRIBO_DEMO_VIEWER_COMMON_HH
diff --git a/scribo/demo/viewer/config.cc b/scribo/demo/viewer/config.cc
deleted file mode 100644
index 6bdcd35..0000000
--- a/scribo/demo/viewer/config.cc
+++ /dev/null
@@ -1,182 +0,0 @@
-// Copyright (C) 2010, 2011 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);
-}
-
-
-// OCR
-
-bool config::ocr_enabled()
-{
- return value("ocr/enabled", true).toBool();
-}
-
-void config::set_ocr_enabled(bool b)
-{
- setValue("ocr/enabled", b);
-}
-
-
-
-QString config::ocr_language()
-{
- return value("ocr/language", 0).toString();
-}
-
-void config::set_ocr_language(const QString& lang)
-{
- setValue("ocr/language", lang);
-}
-
-
-
-// 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
deleted file mode 100644
index 74dab3b..0000000
--- a/scribo/demo/viewer/config.hh
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (C) 2010, 2011 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);
-
-
- // OCR
- bool ocr_enabled();
- void set_ocr_enabled(bool b);
-
- QString ocr_language();
- void set_ocr_language(const QString& lang);
-
-
- // 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/configs.cc b/scribo/demo/viewer/configs.cc
new file mode 100644
index 0000000..f832b5a
--- /dev/null
+++ b/scribo/demo/viewer/configs.cc
@@ -0,0 +1,149 @@
+// Copyright (C) 2013 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 "configs.hh"
+
+Configs::Configs()
+ : QSettings("olena-scribo", "gui")
+{
+}
+
+Configs *Configs::getInstance()
+{
+ static Configs *conf = new Configs(); return conf;
+}
+
+bool Configs::preprocessingSubsample()
+{
+ return value("preprocessing/subsample", false).toBool();
+}
+
+void Configs::setPreprocessingSubsample(bool b)
+{
+ setValue("preprocessing/subsample", b);
+}
+
+bool Configs::preprocessingRemoveBg()
+{
+ return value("preprocessing/remove_bg", false).toBool();
+}
+
+void Configs::setPreprocessingRemoveBg(bool b)
+{
+ setValue("preprocessing/remove_bg", b);
+}
+
+bool Configs::preprocessingDeskew()
+{
+ return value("preprocessing/deskew", false).toBool();
+}
+
+void Configs::setPreprocessingDeskew(bool b)
+{
+ setValue("preprocessing/deskew", b);
+}
+
+bool Configs::preprocessingRemoveNoise()
+{
+ return value("preprocessing/remove_noise", true).toBool();
+}
+
+void Configs::setPreprocessingRemoveNoise(bool b)
+{
+ setValue("preprocessing/remove_noise", b);
+}
+
+int Configs::preprocessingBinAlgo()
+{
+ return value("preprocessing/bin_algo",
+ scribo::toolchain::internal::SauvolaMs).toInt();
+}
+
+void Configs::setPreprocessingBinAlgo(int algo)
+{
+ setValue("preprocessing/bin_algo", algo);
+}
+
+int Configs::segmentationFindSeps()
+{
+ return value("segmentation/find_seps", Separator::Both).toInt();
+}
+
+void Configs::setSegmentationFindSeps(int seps)
+{
+ setValue("segmentation/find_seps", seps);
+}
+
+bool Configs::ocrEnabled()
+{
+ return value("ocr/enabled", true).toBool();
+}
+
+void Configs::setOcrEnabled(bool b)
+{
+ setValue("ocr/enabled", b);
+}
+
+QString Configs::ocrLanguage()
+{
+ return value("ocr/language", 0).toString();
+}
+
+void Configs::setOcrLanguage(const QString& lang)
+{
+ setValue("ocr/language", lang);
+}
+
+bool Configs::generalSaveXmlEnabled()
+{
+ return value("general/save_xml/enabled", true).toBool();
+}
+
+void Configs::setGeneralSaveXmlEnabled(bool b)
+{
+ setValue("general/save_xml/enabled", b);
+}
+
+bool Configs::generalSaveXmlSameDir()
+{
+ return value("general/save_xml/same_dir", true).toBool();
+}
+
+void Configs::setGeneralSaveXmlSameDir(bool b)
+{
+ setValue("general/save_xml/same_dir", b);
+}
+
+bool Configs::generalSaveXmlCustomDir()
+{
+ return value("general/save_xml/custom_dir", false).toBool();
+}
+
+void Configs::setGeneralSaveXmlCustomDir(bool b)
+{
+ setValue("general/save_xml/custom_dir", b);
+}
+
+QString Configs::generalSaveXmlCustomDirPath()
+{
+ return value("general/save_xml/custom_dir_path",
+ QDir::tempPath()).toString();
+}
+
+void Configs::setGeneralSaveXmlCustomDirPath(const QString& path)
+{
+ setValue("general/save_xml/custom_dir_path", path);
+}
diff --git a/scribo/demo/viewer/configs.hh b/scribo/demo/viewer/configs.hh
new file mode 100644
index 0000000..26de148
--- /dev/null
+++ b/scribo/demo/viewer/configs.hh
@@ -0,0 +1,74 @@
+// Copyright (C) 2013 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 CONFIGS_H
+# define CONFIGS_H
+
+#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
+#include <QSettings>
+#include <QDir>
+#include <QDebug>
+
+#include "region.hh"
+
+class Configs :
+ public QSettings
+{
+public:
+ static Configs *getInstance();
+
+ bool preprocessingSubsample();
+ void setPreprocessingSubsample(bool b);
+
+ bool preprocessingRemoveBg();
+ void setPreprocessingRemoveBg(bool b);
+
+ bool preprocessingDeskew();
+ void setPreprocessingDeskew(bool b);
+
+ bool preprocessingRemoveNoise();
+ void setPreprocessingRemoveNoise(bool b);
+
+ int preprocessingBinAlgo();
+ void setPreprocessingBinAlgo(int algo);
+
+ int segmentationFindSeps();
+ void setSegmentationFindSeps(int seps);
+
+ bool ocrEnabled();
+ void setOcrEnabled(bool b);
+
+ QString ocrLanguage();
+ void setOcrLanguage(const QString& lang);
+
+ bool generalSaveXmlEnabled();
+ void setGeneralSaveXmlEnabled(bool b);
+
+ bool generalSaveXmlSameDir();
+ void setGeneralSaveXmlSameDir(bool b);
+
+ bool generalSaveXmlCustomDir();
+ void setGeneralSaveXmlCustomDir(bool b);
+
+ QString generalSaveXmlCustomDirPath();
+ void setGeneralSaveXmlCustomDirPath(const QString& path);
+
+private:
+ explicit Configs();
+};
+
+
+#endif // CONFIGS_H
diff --git a/scribo/demo/viewer/defs.hh b/scribo/demo/viewer/defs.hh
deleted file mode 100644
index ada4441..0000000
--- a/scribo/demo/viewer/defs.hh
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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/GScribo/dir.h b/scribo/demo/viewer/dir.hh
similarity index 100%
rename from GScribo/dir.h
rename to scribo/demo/viewer/dir.hh
diff --git a/scribo/demo/viewer/dockwidget.cc b/scribo/demo/viewer/dockwidget.cc
new file mode 100644
index 0000000..fc895b0
--- /dev/null
+++ b/scribo/demo/viewer/dockwidget.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2013 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 "dockwidget.hh"
+
+DockWidget::DockWidget(QWidget *parent, Qt::WindowFlags flags)
+ : QDockWidget(parent, flags)
+{
+}
+
+
+DockWidget::DockWidget(const QString& title,
+ QWidget *parent, Qt::WindowFlags flags)
+ : QDockWidget(title, parent, flags)
+{
+}
+
+void DockWidget::switchVisibility()
+{
+ setVisible(!isVisible());
+}
diff --git a/scribo/demo/viewer/dockwidget.hh b/scribo/demo/viewer/dockwidget.hh
new file mode 100644
index 0000000..e6fb483
--- /dev/null
+++ b/scribo/demo/viewer/dockwidget.hh
@@ -0,0 +1,36 @@
+// Copyright (C) 2013 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 DOCKWIDGET_H
+# define DOCKWIDGET_H
+
+#include <QDockWidget>
+
+class DockWidget :
+ public QDockWidget
+{
+ Q_OBJECT
+
+ public:
+ explicit DockWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ explicit DockWidget(const QString& title,
+ QWidget *parent = 0, Qt::WindowFlags flags = 0);
+
+public slots:
+ void switchVisibility();
+};
+
+#endif // DOCKWIDGET_H
diff --git a/scribo/demo/viewer/general_options.cc b/scribo/demo/viewer/general_options.cc
deleted file mode 100644
index 50201ff..0000000
--- a/scribo/demo/viewer/general_options.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-// 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
deleted file mode 100644
index e2fcaae..0000000
--- a/scribo/demo/viewer/general_options.hh
+++ /dev/null
@@ -1,40 +0,0 @@
-// 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
deleted file mode 100644
index 5839c27..0000000
--- a/scribo/demo/viewer/general_options.ui
+++ /dev/null
@@ -1,100 +0,0 @@
-<?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/help_dialog.cc b/scribo/demo/viewer/help_dialog.cc
deleted file mode 100644
index 2d5ce6c..0000000
--- a/scribo/demo/viewer/help_dialog.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (C) 2010, 2011 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 "help_dialog.hh"
-
-HelpDialog::HelpDialog()
-{
- setupUi(this);
-}
diff --git a/scribo/demo/viewer/help_dialog.hh b/scribo/demo/viewer/help_dialog.hh
deleted file mode 100644
index 9f179c6..0000000
--- a/scribo/demo/viewer/help_dialog.hh
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2010, 2011 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_HELP_DIALOG_HH
-# define SCRIBO_DEMO_VIEWER_HELP_DIALOG_HH
-
-# include <QtGui>
-# include <help_dialog.ui.h>
-
-class HelpDialog : public QDialog, private Ui::HelpDialog
-{
-public:
- HelpDialog();
-
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_HELP_DIALOG_HH
diff --git a/scribo/demo/viewer/help_dialog.ui b/scribo/demo/viewer/help_dialog.ui
deleted file mode 100644
index 9ab7e58..0000000
--- a/scribo/demo/viewer/help_dialog.ui
+++ /dev/null
@@ -1,138 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>HelpDialog</class>
- <widget class="QDialog" name="HelpDialog">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>557</width>
- <height>390</height>
- </rect>
- </property>
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>557</width>
- <height>390</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>557</width>
- <height>390</height>
- </size>
- </property>
- <property name="windowTitle">
- <string>About</string>
- </property>
- <property name="windowIcon">
- <iconset resource="viewer.qrc">
- <normaloff>:/icons/shared/icons/olena_smaller.jpg</normaloff>:/icons/shared/icons/olena_smaller.jpg</iconset>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string/>
- </property>
- <property name="pixmap">
- <pixmap resource="viewer.qrc">:/icons/shared/icons/olena_smaller.jpg</pixmap>
- </property>
- <property name="scaledContents">
- <bool>false</bool>
- </property>
- </widget>
- </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>
- </item>
- <item row="0" column="1">
- <widget class="QLabel" name="label_2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <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;">Document Image Analysis Tool</span></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:12pt; font-weight:600;"></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This project is powered by <span style=" font-weight:600; font-style:italic;">Milena</span>, a generic image processing library.</p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
-<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">It is part of <span style=" font-weight:600; font-style:italic;">Olena</span>, an Image Processing Platform and its module <span style=" font-weight:600; font-style:italic;">Scribo</span>, a set of tools for Document Image Analysis.</p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
-<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://olena.lrde.epita.fr"><span style=" text-decoration: underline; color:#0057ae;">http://olena.lrde.epita.fr</span></a></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p>
-<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:8pt;">Thanks to Arthur Crépin-Leblond, Samuel Da Mota, Loic Denuziere, </span><span style=" font-size:8pt;">Jérôme Galtier,</span><span style=" font-size:8pt;"> </span><span style=" font-size:8pt;">Florent d'Halluin, </span><span style=" font-size:8pt;">Alex Hamelin, </span><span style=" font-size:8pt;">Damien Lefortier, </span><span style=" font-size:8pt;">Vincent Ordy, </span><span style=" font-size:8pt;">Guillaume Sadegh and</span><span style=" font-size:8pt;"> </span><span style=" font-size:8pt;">Warren Seine </span><span style=" font-size:8pt;">for their contribution.</span></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p>
-<p align="justify" style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;"></p>
-<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:7pt;">This application has been developed in the context of the SCRIBO project of the Free Software Thematic Group, part of the &quot;System@tic Paris-Région&quot; Cluster (France). This project is partially funded by the French Government, its economic development agencies, and by the Paris-Région institutions.</span></p>
-<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:7pt;"></p>
-<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:7pt;">Copyright (C) 2010, 2011 EPITA Research and Development Laboratory (LRDE)</span></p></body></html></string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Ok</set>
- </property>
- <property name="centerButtons">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="viewer.qrc"/>
- </resources>
- <connections>
- <connection>
- <sender>buttonBox</sender>
- <signal>accepted()</signal>
- <receiver>HelpDialog</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel">
- <x>281</x>
- <y>391</y>
- </hint>
- <hint type="destinationlabel">
- <x>240</x>
- <y>203</y>
- </hint>
- </hints>
- </connection>
- </connections>
-</ui>
diff --git a/scribo/demo/viewer/icons/olena_smaller.jpg b/scribo/demo/viewer/icons/olena_smaller.jpg
deleted file mode 100644
index c6b9110..0000000
Binary files a/scribo/demo/viewer/icons/olena_smaller.jpg and /dev/null differ
diff --git a/scribo/demo/viewer/image_region.cc b/scribo/demo/viewer/image_region.cc
deleted file mode 100644
index 93d9d79..0000000
--- a/scribo/demo/viewer/image_region.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright (C) 2010, 2011 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 "image_region.hh"
-
-ImageRegion::ImageRegion(region::RegionId id,
- QString name,
- QColor color,
- QString attr_id,
- const QVector<QPoint>& points,
- bool outline,
- bool fill,
- bool precise,
- bool draw)
- : QGraphicsItem(0),
- id_(id),
- name_(name),
- color_(color),
- attr_id_(attr_id),
- shape_(),
- rect_(),
- outline_(outline),
- precise_(precise),
- fill_(fill),
- draw_(draw),
- selected_(false),
- alpha_(50)
-{
- setCursor(Qt::ArrowCursor);
- if (id_ == region::Line)
- setZValue(3);
- else
- setZValue(1);
-
- if (points.size() == 0)
- return;
-
- for (int i = 1; i < points.size(); ++i)
- shape_.lineTo(points[i] - points[0]);
- shape_.lineTo(QPoint(0, 0));
-
- rect_ = shape_.boundingRect();
- setPos(points[0] + QPointF(0.5, 0.5));
-
- prepareGeometryChange();
-}
-
-ImageRegion::~ImageRegion()
-{
-}
-
-region::RegionId ImageRegion::id()
-{
- return id_;
-}
-
-void
-ImageRegion::paint(QPainter* painter,
- const QStyleOptionGraphicsItem*,
- QWidget*)
-{
- if (!draw_ && !selected_)
- return;
-
- int width = 0;
- if (precise_)
- width = 1;
-
- if (outline_)
- painter->setPen(QPen(QBrush(color_), width, Qt::SolidLine,
- Qt::SquareCap, Qt::MiterJoin));
- else
- painter->setPen(QColor(0, 0, 0, 0));
-
- QColor brush = color_;
- if (fill_)
- brush.setAlpha(alpha_);
- else
- brush.setAlpha(0);
- painter->setBrush(brush);
-
- painter->drawPath(shape_);
-
- if (selected_)
- {
- QPolygonF sceneRect = mapFromScene(scene()->sceneRect());
- QPainterPath path;
- path.addPolygon(sceneRect);
- QColor brush(255, 255, 255);
- brush.setAlpha(120);
- painter->setBrush(brush);
- painter->setPen(QColor(0, 0, 0, 0));
- painter->drawPath(path.subtracted(shape_));
- }
-}
-
-void
-ImageRegion::select()
-{
- if (!selected_)
- {
- selected_ = true;
- setZValue(4);
- prepareGeometryChange();
- scene()->invalidate();
- update();
- }
-}
-
-void
-ImageRegion::deselect()
-{
- if (selected_)
- {
- selected_ = false;
- if (id_ == region::Line)
- setZValue(3);
- else
- setZValue(1);
- prepareGeometryChange();
- scene()->invalidate();
- update();
- }
-}
diff --git a/scribo/demo/viewer/image_region.hh b/scribo/demo/viewer/image_region.hh
deleted file mode 100644
index 2ad0150..0000000
--- a/scribo/demo/viewer/image_region.hh
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (C) 2010, 2013 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_IMAGE_REGION_HH
-# define SCRIBO_DEMO_VIEWER_IMAGE_REGION_HH
-
-# include <QtGui>
-# include "common.hh"
-
-class ImageRegion
- : public QObject, public QGraphicsItem
-{
- Q_OBJECT;
- Q_INTERFACES(QGraphicsItem);
-
-public:
- ImageRegion(region::RegionId id,
- QString name,
- QColor color,
- QString attr_id,
- const QVector<QPoint>& points,
- bool outline,
- bool fill,
- bool precise,
- bool draw);
-
- ~ImageRegion();
-
- region::RegionId id();
- void paint(QPainter* painter,
- const QStyleOptionGraphicsItem* option,
- QWidget* widget = 0);
-
- QRectF boundingRect() const;
- QPainterPath shape() const;
- QString name() { return name_; }
- QRectF rect() { return rect_; }
- QString attr_id() { return attr_id_; }
-
-public slots:
- void setOutline(bool outline);
- void setFill(bool fill);
- void setFillAlpha(int alpha);
- void setDraw(bool draw);
- void setPrecise(bool precise);
- void setDrawIfSameId(int id, bool draw);
- void select();
- void deselect();
-
-private:
- region::RegionId id_;
- QString name_;
- QColor color_;
- QString attr_id_;
- QPainterPath shape_;
- QRectF rect_;
- bool outline_;
- bool precise_;
- bool fill_;
- bool draw_;
- bool selected_;
- int alpha_;
-};
-
-#include "image_region.hxx"
-
-#endif // ! SCRIBO_DEMO_VIEWER_IMAGE_REGION_HH
diff --git a/scribo/demo/viewer/image_region.hxx b/scribo/demo/viewer/image_region.hxx
deleted file mode 100644
index 5ddd7de..0000000
--- a/scribo/demo/viewer/image_region.hxx
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright (C) 2009, 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/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef IMAGE_REGION_HXX_
-# define IMAGE_REGION_HXX_
-
-# include "image_region.hh"
-
-inline
-void
-ImageRegion::setOutline(bool outline)
-{
- outline_ = outline;
- scene()->invalidate();
- update();
-}
-
-inline
-void
-ImageRegion::setPrecise(bool precise)
-{
- precise_ = precise;
- scene()->invalidate();
- update();
-}
-
-inline
-void
-ImageRegion::setFill(bool fill)
-{
- fill_ = fill;
- update();
-}
-
-inline
-void
-ImageRegion::setDraw(bool draw)
-{
- draw_ = draw;
- update();
-}
-
-inline
-void
-ImageRegion::setDrawIfSameId(int id, bool draw)
-{
- if (id == id_)
- {
- draw_ = draw;
- setVisible(draw);
- if (scene())
- {
- scene()->invalidate();
- update();
- }
- }
-}
-
-inline
-void
-ImageRegion::setFillAlpha(int alpha)
-{
- alpha_ = alpha;
- update();
-}
-
-inline
-QRectF
-ImageRegion::boundingRect() const
-{
-// if (selected_)
-// return mapFromScene(scene()->sceneRect()).boundingRect();
- return rect_;
-}
-
-inline
-QPainterPath
-ImageRegion::shape() const
-{
- return shape_;
-}
-
-#endif /* !IMAGE_REGION_HXX_ */
diff --git a/scribo/demo/viewer/image_scene.cc b/scribo/demo/viewer/image_scene.cc
deleted file mode 100644
index a800896..0000000
--- a/scribo/demo/viewer/image_scene.cc
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright (C) 2010, 2011 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 "image_scene.hh"
-#include "image_region.hh"
-
-ImageScene::ImageScene(QObject *parent)
- : QGraphicsScene(parent), selected_(0)
-{
-}
-
-void
-ImageScene::clear()
-{
- selected_ = 0;
- QGraphicsScene::clear();
-}
-
-void
-ImageScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
-{
- QGraphicsScene::mousePressEvent(event);
- QList<QGraphicsItem *> items_list = items(event->scenePos()); // includes both ImageRegions and the picture.
-
- if (items_list.isEmpty())
- {
- if (selected_)
- {
- selected_->deselect();
- emit deselected();
- selected_ = 0;
- }
- }
-
- // Selection is under the mouse click (at event->pos()).
- bool selection_is_clicked = items_list.contains(selected_);
-
- foreach(QGraphicsItem* elt, items_list)
- {
- ImageRegion* item = dynamic_cast<ImageRegion*>(elt);
- if (item)
- {
- if (item != selected_)
- {
- if (selected_)
- {
- if ( (item->boundingRect().intersects(selected_->boundingRect())))
- {
- int item_area = item->boundingRect().size().height() * item->boundingRect().size().width();
- int selected_area = selected_->boundingRect().size().height() * selected_->boundingRect().size().width();
-
- if (selected_area < item_area && selection_is_clicked)
- return;
- else
- {
- selected_->deselect();
- emit deselected();
- selected_ = 0;
- }
- }
- else
- {
- selected_->deselect();
- emit deselected();
- selected_ = 0;
- }
- }
- selected_ = item;
- item->select();
- emit selected(item->attr_id(), item->name());
- return;
- }
- }
- else
- {
- if ( (selected_)
- && (items_list.size() == 1) )// no ImageRegion, only the picture
- {
- selected_->deselect();
- emit deselected();
- selected_ = 0;
- }
- }
- }
-}
-
-ImageScene::~ImageScene()
-{
-}
diff --git a/scribo/demo/viewer/image_scene.hh b/scribo/demo/viewer/image_scene.hh
deleted file mode 100644
index b141478..0000000
--- a/scribo/demo/viewer/image_scene.hh
+++ /dev/null
@@ -1,45 +0,0 @@
-// 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_IMAGE_SCENE_HH
-# define SCRIBO_DEMO_VIEWER_IMAGE_SCENE_HH
-
-# include <QtGui>
-
-class ImageRegion;
-
-class ImageScene
- : public QGraphicsScene
-{
- Q_OBJECT
-
-public:
- ImageScene(QObject *parent = 0);
- ~ImageScene();
-
- void mousePressEvent(QGraphicsSceneMouseEvent* event);
- void clear();
-
-signals:
- void selected(QString, QString);
- void deselected();
-
-private:
- ImageRegion* selected_;
- QVector<ImageRegion*> region_vector_;
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_IMAGE_SCENE_HH
diff --git a/scribo/demo/viewer/image_view.cc b/scribo/demo/viewer/image_view.cc
deleted file mode 100644
index 9190227..0000000
--- a/scribo/demo/viewer/image_view.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright (C) 2010, 2013 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 "image_view.hh"
-
-ImageView::ImageView(QGraphicsScene* scene)
- : QGraphicsView(scene)
-{
-}
-
-void
-ImageView::wheelEvent(QWheelEvent* event)
-{
- // Basic zoom code (same as yavgui)
- if (event->delta() != 0)
- {
- qreal degrees = ((qreal) event->delta()) / 8;
- qreal sc;
- if (degrees > 0)
- sc = 1 + degrees / 100;
- else
- sc = 1 / (1 - degrees / 100);
-
- // QPointF center = mapToScene(width() / 2, height() / 2);
- // QPointF mouse = mapToScene(event->pos());
-
- // qreal dx = (mouse.x() - center.x());
- // qreal dy = (mouse.y() - center.y());
- // QPointF newCenter = QPointF (mouse.x() - dx / sc,
- // mouse.y() - dy / sc);
- scale(sc, sc);
- scaleUpdate();
- }
-}
-
-void
-ImageView::keyPressEvent(QKeyEvent* event)
-{
- if (event->key() == Qt::Key_PageUp)
- scale(1.25, 1.25);
- else if (event->key() == Qt::Key_PageDown)
- scale(0.75, 0.75);
- else if (event->key() == Qt::Key_Home)
- resetMatrix();
- else if (event->key() == Qt::Key_End)
- fitInView(sceneRect(), Qt::KeepAspectRatio);
- else
- {
- QGraphicsView::keyPressEvent(event);
- return;
- }
- scaleUpdate();
- event->accept();
-}
-
-void
-ImageView::scaleUpdate()
-{
- // Used to determine whether to change the main image cache mode.
- QRect orig(0, 0, 10, 1);
- QRectF scene = mapToScene(orig).boundingRect();
- emit scaleUpdated(10 / scene.width());
-}
-
-ImageView::~ImageView()
-{
-}
diff --git a/scribo/demo/viewer/image_view.hh b/scribo/demo/viewer/image_view.hh
deleted file mode 100644
index 622999b..0000000
--- a/scribo/demo/viewer/image_view.hh
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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_IMAGE_VIEW_HH
-# define SCRIBO_DEMO_VIEWER_IMAGE_VIEW_HH
-
-# include <QtGui>
-
-class ImageView
- : public QGraphicsView
-{
- Q_OBJECT
-
-public:
- ImageView(QGraphicsScene* scene);
- ~ImageView();
-
- void wheelEvent(QWheelEvent* event);
- void keyPressEvent(QKeyEvent *event);
-
- // Call after changing the scale.
- void scaleUpdate();
-
-signals:
- // Scale is approximate.
- void scaleUpdated(qreal scale);
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_IMAGE_VIEW_HH
diff --git a/scribo/demo/viewer/image_widget.cc b/scribo/demo/viewer/image_widget.cc
deleted file mode 100644
index f86ff1d..0000000
--- a/scribo/demo/viewer/image_widget.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (C) 2010, 2011 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 "image_widget.hh"
-#include "image_view.hh"
-
-ImageWidget::ImageWidget(QGraphicsScene* scene)
- : view_ (new ImageView(scene))
-{
- scene->setParent(view_);
-
- QLabel* title = new QLabel(tr("Layout"));
- title->setAlignment(Qt::AlignHCenter);
-
- QVBoxLayout* layout = new QVBoxLayout;
- layout->addWidget(title);
- layout->addWidget(view_);
-
- view_->setDragMode(QGraphicsView::ScrollHandDrag);
- view_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- view_->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- view_->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
-
- connect(view_, SIGNAL(scaleUpdated(qreal)),
- this, SIGNAL(scaleUpdated(qreal)));
-
- setLayout(layout);
-}
-
-
-ImageWidget::~ImageWidget()
-{
-}
-
-
-void
-ImageWidget::update()
-{
- view_->fitInView(view_->sceneRect(), Qt::KeepAspectRatio);
- view_->scaleUpdate();
-}
-
-ImageView *
-ImageWidget::view() const
-{
- return view_;
-}
diff --git a/scribo/demo/viewer/image_widget.hh b/scribo/demo/viewer/image_widget.hh
deleted file mode 100644
index 79dd672..0000000
--- a/scribo/demo/viewer/image_widget.hh
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2010, 2011 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_IMAGE_WIDGET_HH
-# define SCRIBO_DEMO_VIEWER_IMAGE_WIDGET_HH
-
-# include <QtGui>
-# include "image_view.hh"
-
-class ImageView;
-
-class ImageWidget
- : public QWidget
-{
- Q_OBJECT
-
-public:
- ImageWidget(QGraphicsScene* scene);
- ~ImageWidget();
-
- ImageView * view() const;
-
-public slots:
- void update();
-
-signals:
- void scaleUpdated(qreal scale);
-
-private:
- ImageView* view_;
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_IMAGE_WIDGET_HH
diff --git a/scribo/demo/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc
deleted file mode 100644
index 3b07617..0000000
--- a/scribo/demo/viewer/key_widget.cc
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright (C) 2010, 2011 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 "key_widget.hh"
-#include "common.hh"
-
-KeyWidget::KeyWidget(const region::KeyMap& key_map)
- : items_(new QTreeWidget())
-{
- item_list_.append(new QTreeWidgetItem(QStringList("Text")));
- item_list_.append(new QTreeWidgetItem(QStringList("Separators")));
- item_list_.append(new QTreeWidgetItem(QStringList("Misc. Regions")));
- item_list_.append(new QTreeWidgetItem(QStringList("Typographical lines")));
-
- QLabel* title = new QLabel(tr("Key"));
- title->setAlignment(Qt::AlignHCenter);
-
- foreach(QTreeWidgetItem* item, item_list_)
- {
- items_->addTopLevelItem(item);
- item->setCheckState(0, Qt::Checked);
- item->setExpanded(true);
- }
- items_->setHeaderHidden(true);
-
- base_id_.append(0);
- base_id_.append(region::EndOfTextRegion + 1);
- base_id_.append(region::EndOfSepsRegion + 1);
- base_id_.append(region::EndOfMiscRegion + 1);
- base_id_.append(region::EndOfTypoRegion + 1);
-
- for (int j = 0; j < base_id_.size() - 1; ++j)
- for (int i = base_id_.at(j); i < base_id_.at(j + 1) - 1; ++i)
- add_item_(key_map.at(i).first, key_map.at(i).second, false, item_list_.at(j));
-
- QVBoxLayout* layout = new QVBoxLayout;
- layout->addWidget(title);
- layout->addWidget(items_);
-
- setLayout(layout);
-
- connect(items_, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
- this, SLOT(update(QTreeWidgetItem*)));
-}
-
-void KeyWidget::update_all()
-{
- foreach(QTreeWidgetItem* item, item_list_)
- for (int i = 0; i < item->childCount(); ++i)
- update(item->child(i));
-}
-
-void KeyWidget::setAll(bool b)
-{
- Qt::CheckState state;
- if (b)
- state = Qt::Checked;
- else
- state = Qt::Unchecked;
-
- foreach(QTreeWidgetItem* item, item_list_)
- item->setCheckState(0, state);
-}
-
-void KeyWidget::setAllCheck(QTreeWidgetItem* parent)
-{
- for (int i = 0; i < parent->childCount(); ++i)
- {
- if (parent->checkState(0) == Qt::Checked)
- parent->child(i)->setCheckState(0, Qt::Checked);
- else
- parent->child(i)->setCheckState(0, Qt::Unchecked);
- update(parent->child(i));
- }
-}
-
-void
-KeyWidget::change_mode(bool b)
-{
- item_list_.at(0)->child(region::Line)->setHidden(!b);
- // FIXME: we may like to hide also typographical objects.
-}
-
-void
-KeyWidget::add_item_(QString text, QColor color, bool b, QTreeWidgetItem* parent)
-{
- QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(text));
- QPixmap pixmap(10, 6);
-
- pixmap.fill(color);
- item->setIcon(0, QIcon(pixmap));
- item->setCheckState(0, Qt::Checked);
- parent->addChild(item);
- item->setHidden(b);
-}
-
-bool
-KeyWidget::isChecked(region::RegionId id)
-{
- QTreeWidgetItem* current_item = 0;
-
- foreach(QTreeWidgetItem* item, item_list_)
- {
- current_item = item->child(id);
- if (item)
- break;
- else
- current_item = 0;
- }
-
- if (!current_item)
- return false;
-
- return current_item->checkState(0) == Qt::Checked;
-}
-
-void
-KeyWidget::update(QTreeWidgetItem* item_up)
-{
- int id = -1;
-
- foreach(QTreeWidgetItem* item, item_list_)
- if (item_up == item)
- {
- setAllCheck(item);
- return;
- }
-
-
- int i = 0;
- foreach(QTreeWidgetItem* item, item_list_)
- {
- id = item->indexOfChild(item_up);
- if (id != -1)
- {
- id += base_id_.at(i);
- break;
- }
- ++i;
- }
-
- emit updated(id, item_up->checkState(0) == Qt::Checked);
-}
-
-KeyWidget::~KeyWidget()
-{
-}
-
diff --git a/scribo/demo/viewer/key_widget.hh b/scribo/demo/viewer/key_widget.hh
deleted file mode 100644
index 1a3518e..0000000
--- a/scribo/demo/viewer/key_widget.hh
+++ /dev/null
@@ -1,55 +0,0 @@
-// 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_KEY_WIDGET_HH
-# define SCRIBO_DEMO_VIEWER_KEY_WIDGET_HH
-
-# include <QtGui>
-# include "common.hh"
-
-class KeyWidget
- : public QWidget
-{
- Q_OBJECT
-
-public:
- KeyWidget(const region::KeyMap& key_map);
- ~KeyWidget();
-
- bool isChecked(region::RegionId id);
- QTreeWidget* items() { return items_; };
- void update_all();
-
-signals:
- void updated(int key, bool checked);
-
-public slots:
- void setAll(bool b);
-
-private slots:
- void change_mode(bool b);
- void update(QTreeWidgetItem* item);
- void setAllCheck(QTreeWidgetItem* parent);
-
-private:
- void add_item_(QString text, QColor color, bool b, QTreeWidgetItem* parent);
-
- QTreeWidget* items_;
- QVector<QTreeWidgetItem*> item_list_;
- QVector<int> base_id_;
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_KEY_WIDGET_HH
diff --git a/scribo/demo/viewer/main.cc b/scribo/demo/viewer/main.cc
index ff79f01..a867553 100644
--- a/scribo/demo/viewer/main.cc
+++ b/scribo/demo/viewer/main.cc
@@ -1,5 +1,4 @@
-// Copyright (C) 2010, 2011, 2013 EPITA Research and Development
-// Laboratory (LRDE)
+// Copyright (C) 2013 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -15,34 +14,28 @@
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-#include <QtGui>
-#include <iostream>
-
#undef MLN_WO_GLOBAL_VARS
-#include "viewer.hh"
+
+#include <QtGui/QApplication>
+
+#include <scribo/make/debug_filename.hh>
#include <mln/labeling/colorize.hh>
-#include <mln/math/pi.hh>
#include <mln/io/magick/load.hh>
#include <mln/debug/filename.hh>
#include <mln/literal/colors.hh>
-#include <scribo/make/debug_filename.hh>
#include <scribo/binarization/sauvola_ms.hh>
+#include <mln/math/pi.hh>
-int main(int argc, char** argv)
-{
- if (argc > 2 ||
- (argc == 2 &&
- (QString(argv[1]) == "--help" || QString(argv[1]) == "-h")))
- {
- std::cout << "Usage:" << std::endl
- << argv[0] << " <image dir>" << std::endl;
- return 0;
- }
-
- Viewer* viewer = Viewer::Instance(argc, argv);
-
- if (!viewer)
- return -1;
+#include "mainwindow.hh"
- return viewer->exec();
+int main(int argc, char *argv[])
+{
+ Magick::InitializeMagick(*argv);
+ // On Linux, we NEED to use the raster graphics system.
+ // Linux don't really support openGL graphics system (the default one on Linux).
+ QApplication::setGraphicsSystem("raster");
+ QApplication a(argc, argv);
+ MainWindow w;
+ w.show();
+ return a.exec();
}
diff --git a/scribo/demo/viewer/mainwindow.cc b/scribo/demo/viewer/mainwindow.cc
new file mode 100644
index 0000000..97cda4e
--- /dev/null
+++ b/scribo/demo/viewer/mainwindow.cc
@@ -0,0 +1,496 @@
+// Copyright (C) 2013 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 "mainwindow.hh"
+#include "mainwindow.ui.h"
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent),
+ ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+
+ setWindowTitle(tr("GScribo"));
+ showMaximized();
+
+ initGraphicsRegion();
+ initDialogsWidget();
+ initXmlWidget();
+ initRegionWidget();
+ initPageWidget();
+ initMenuBar();
+
+ // Told the left dock widget (here the pages widget and the region
+ // widget) to fill the bottom left corner.
+ setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
+ // Merge the region and pages widget in one tab (pages widget over
+ // the region widget).
+ tabifyDockWidget(&dockRegion_, &dockPages_);
+
+ connectWidgets();
+}
+
+MainWindow::~MainWindow()
+{
+ delete preferencesDialog_;
+ delete aboutDialog_;
+ delete progressDialog_;
+ delete ui;
+}
+
+void MainWindow::changeEvent(QEvent *e)
+{
+ QMainWindow::changeEvent(e);
+ switch (e->type())
+ {
+ case QEvent::LanguageChange:
+ ui->retranslateUi(this);
+ break;
+ default:
+ break;
+ }
+}
+
+void MainWindow::initGraphicsRegion()
+{
+ graphicsView_.setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
+ graphicsView_.setScene(&scene_);
+
+ setCentralWidget(&graphicsView_);
+}
+
+void MainWindow::initDialogsWidget()
+{
+ preferencesDialog_ = new PreferencesDialog(this);
+ aboutDialog_ = new AboutDialog(this);
+ progressDialog_ = new ProgressDialog(this);
+}
+
+void MainWindow::initPageWidget()
+{
+ dockPages_.setWindowTitle("Pages");
+ dockPages_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
+ dockPages_.setWidget(&pagesWidget_);
+ dockPages_.setMinimumWidth(190);
+
+ addDockWidget(Qt::LeftDockWidgetArea, &dockPages_);
+}
+
+void MainWindow::initRegionWidget()
+{
+ dockRegion_.setWindowTitle("Regions");
+ dockRegion_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
+ dockRegion_.setWidget(®ionWidget_);
+
+ addDockWidget(Qt::LeftDockWidgetArea, &dockRegion_);
+}
+
+void MainWindow::initXmlWidget()
+{
+ dockXml_.setWindowTitle("Xml");
+ dockXml_.setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable);
+ dockXml_.setWidget(&xmlWidget_);
+
+ addDockWidget(Qt::BottomDockWidgetArea, &dockXml_);
+ dockXml_.setVisible(false);
+}
+
+void MainWindow::initMenuBar()
+{
+ QMenu *menuFile = ui->menuBar->addMenu(tr("File"));
+
+ menuFile->addAction(tr("&Open"), this, SLOT(onOpen()),
+ QKeySequence(tr("Ctrl+O")));
+
+ segment_ = menuFile->addAction(tr("Segment"), this, SLOT(onSegment()),
+ QKeySequence(tr("Ctrl+S")));
+ segment_->setEnabled(false);
+
+ menuFile->addSeparator();
+
+ previewPrinting_ = menuFile->addAction(tr("Preview Printing"),
+ this, SLOT(onPreviewPrint()),
+ QKeySequence(tr("Shift+Ctrl+P")));
+ previewPrinting_->setEnabled(false);
+
+ print_ = menuFile->addAction(tr("Print"), this, SLOT(onPrint()),
+ QKeySequence(tr("Ctrl+P")));
+ print_->setEnabled(false);
+
+ menuFile->addSeparator();
+
+ export_ = menuFile->addAction(tr("&Exportation"),
+ this, SLOT(onExportation()),
+ QKeySequence(tr("Ctrl+E")));
+ export_->setEnabled(false);
+
+ menuFile->addSeparator();
+
+ menuFile->addAction(tr("Quit"), this, SLOT(close()));
+
+ ui->menuBar->addAction(tr("Preferences"),
+ this, SLOT(onPreferences()));
+
+ QMenu *menuAreas = ui->menuBar->addMenu(tr("Window"));
+
+ next_ = menuAreas->addAction(tr("Next document"),
+ &pagesWidget_, SLOT(selectNextRow()),
+ QKeySequence(tr("Space")));
+ next_->setEnabled(false);
+
+ prev_ = menuAreas->addAction(tr("Previous document"),
+ &pagesWidget_, SLOT(selectPreviousRow()),
+ QKeySequence(tr("Backspace")));
+ prev_->setEnabled(false);
+
+ menuAreas->addSeparator();
+
+ QAction *page = menuAreas->addAction(tr("Page"),
+ &dockPages_, SLOT(switchVisibility()));
+ page->setCheckable(true);
+ page->setChecked(true);
+
+ QAction *region = menuAreas->addAction(tr("Region"),
+ &dockRegion_, SLOT(switchVisibility()));
+ region->setCheckable(true);
+ region->setChecked(true);
+
+ QAction *xml = menuAreas->addAction(tr("Xml"),
+ &dockXml_, SLOT(switchVisibility()));
+ xml->setCheckable(true);
+ xml->setChecked(false);
+
+ ui->menuBar->addAction(tr("&About"), this, SLOT(onAbout()));
+}
+
+void MainWindow::setActionsEnabled(bool isSegmented)
+{
+ segment_->setEnabled(!isSegmented);
+ print_->setEnabled(isSegmented);
+ previewPrinting_->setEnabled(isSegmented);
+}
+
+void MainWindow::disableActions()
+{
+ segment_->setEnabled(false);
+ print_->setEnabled(false);
+ previewPrinting_->setEnabled(false);
+ export_->setEnabled(false);
+}
+
+void MainWindow::connectWidgets()
+{
+ // Each time the scene rect change (when a new picture is loaded), we fit the scene background rectangle in the view.
+ connect(&scene_, SIGNAL(sceneRectChanged(QRectF)),
+ &graphicsView_, SLOT(fitInView(QRectF)));
+ // When dragging with right click, disable selection.
+ connect(&graphicsView_, SIGNAL(beginDrag()),
+ &scene_, SLOT(disableSelection()));
+ connect(&graphicsView_, SIGNAL(endDrag()),
+ &scene_, SLOT(enableSelection()));
+
+ // If double click on a picture of the page widget -> draw it on background scene.
+ connect(&pagesWidget_, SIGNAL(imageSelected(QString)),
+ this, SLOT(onFileChanged(QString)));
+
+ // Connect the scene to the xml widget and vice versa.
+ connect(&scene_, SIGNAL(newSelection(QList<RegionItem*>)),
+ this, SLOT(onRegionSelection(QList<RegionItem*>)));
+ connect(xmlWidget_.view(), SIGNAL(select(QList<XmlItem*>)),
+ this, SLOT(onXmlSelect(QList<XmlItem*>)));
+ connect(xmlWidget_.view(), SIGNAL(unselect(QList<XmlItem*>)),
+ this, SLOT(onXmlUnselect(QList<XmlItem*>)));
+ connect(xmlWidget_.view(), SIGNAL(emptySelection()),
+ &scene_, SLOT(selectBase()));
+ connect(xmlWidget_.view(), SIGNAL(resetSelection()),
+ &scene_, SLOT(clearSelection()));
+
+ // Connect the scene with the region widget.
+ connect(®ionWidget_, SIGNAL(checkStateChanged(GraphicsRegion::Id,bool)), &scene_, SLOT(setVisible(GraphicsRegion::Id,bool)));
+
+ // Connect the xml widget with the region widget.
+ connect(®ionWidget_, SIGNAL(checkStateChanged(QString)), xmlWidget_.view(), SLOT(setFilterString(QString)));
+
+ connect(&runner_, SIGNAL(progress()), progressDialog_, SLOT(run()));
+ connect(&runner_, SIGNAL(new_progress_max_value(int)),
+ progressDialog_, SLOT(setMaximum(int)));
+ connect(&runner_, SIGNAL(new_progress_label(QString)),
+ progressDialog_, SLOT(setLabelText(QString)));
+ connect(&runner_, SIGNAL(finished()), progressDialog_, SLOT(close()));
+ connect(&runner_, SIGNAL(xml_saved(QString)),
+ this, SLOT(onXmlSaved(QString)));
+}
+
+void MainWindow::onOpen()
+{
+ QStringList
+ paths = QFileDialog::getOpenFileNames(this, "Open Image(s)",
+ QDir::homePath(),
+ "Images (*.png *.jpg *.ppm *.bmp)");
+ setWindowTitle(tr("GScribo"));
+
+ if(paths.count() > 0)
+ {
+ QStringList filenames = pagesWidget_.filenames();
+ QString path;
+
+ int counter = 0;
+ bool isContained;
+ // Check for an image not already added to the page widget.
+ do
+ {
+ path = paths[counter];
+ counter++;
+ isContained = filenames.contains(path);
+ } while(isContained && counter < paths.count());
+
+ if(!isContained)
+ {
+ pagesWidget_.addPicture(path, QPixmap(path));
+
+ // If more than one file, we store it in the page widget.
+ for(int i = counter; i < paths.count(); i++)
+ {
+ // Check if the page widget contains the image.
+ if(!filenames.contains(paths[i]))
+ {
+ path = paths[i];
+ pagesWidget_.addPicture(path, QPixmap(path));
+ }
+ }
+
+ pagesWidget_.setCurrentRow(0);
+ pagesWidget_.scrollToTop();
+ }
+
+ // Change current scene.
+ onFileChanged(path);
+ }
+}
+
+void MainWindow::onSegment()
+{
+ QStringList filenames;
+
+ filenames << scene_.backgroundPath();
+
+ // Run segmentation of page(s).
+ progressDialog_->reset();
+ runner_.start_demat(filenames);
+}
+
+void MainWindow::onPreviewPrint()
+{
+ QPrinter printer(QPrinter::HighResolution);
+ printer.setPaperSize(QPrinter::A4);
+ printer.setResolution(300);
+
+ QPrintPreviewDialog preview(&printer, this);
+ connect(&preview, SIGNAL(paintRequested(QPrinter*)),
+ this, SLOT(printScene(QPrinter*)));
+
+ preview.exec();
+}
+
+void MainWindow::onPrint()
+{
+ QPrinter printer(QPrinter::HighResolution);
+ printer.setPaperSize(QPrinter::A4);
+ printer.setResolution(300);
+
+ QPrintDialog dialog(&printer, this);
+ dialog.setWindowTitle("Print Document");
+
+ if(dialog.exec() != QDialog::Accepted)
+ return;
+
+ printScene(&printer);
+}
+
+void MainWindow::printScene(QPrinter *printer)
+{
+ QPainter painter(printer);
+ QStyleOptionGraphicsItem options;
+
+ scene_.backgroundPixmap()->paint(&painter, &options, 0);
+
+ // Paint backwards items first.
+ printItems(&painter, scene_.root()->childsFrom(GraphicsRegion::TextRegion),
+ &options);
+ printItems(&painter, scene_.root()->childsFrom(GraphicsRegion::Image),
+ &options);
+
+ for(int i = GraphicsRegion::Line; i < GraphicsRegion::Image; i++)
+ printItems(&painter,
+ scene_.root()->childsFrom(static_cast<GraphicsRegion::Id>(i)),
+ &options);
+
+ for(int i = GraphicsRegion::Noise; i <= GraphicsRegion::Meanline; i++)
+ printItems(&painter,
+ scene_.root()->childsFrom(static_cast<GraphicsRegion::Id>(i)),
+ &options);
+}
+
+void MainWindow::printItems(QPainter *painter,
+ const QList<QGraphicsItem *>& items,
+ QStyleOptionGraphicsItem *options)
+{
+ foreach(QGraphicsItem *child, items)
+ {
+ if(child->isVisible())
+ {
+ QRect
+ viewport = scene_.backgroundPixmap()->mapRectFromItem(child, child->boundingRect()).toRect();
+ painter->translate(abs(child->boundingRect().x() - viewport.x()),
+ abs(child->boundingRect().y() - viewport.y()));
+ child->paint(painter, options);
+ painter->resetTransform();
+ }
+ }
+}
+
+void MainWindow::onExportation()
+{
+ QMessageBox messageBox(this);
+ messageBox.setWindowTitle("Information");
+ messageBox.setText("This feature is not available yet");
+ messageBox.exec();
+ return;
+
+ QFileInfo fileInfo(scene_.backgroundPath());
+ QString outputSuggestion = fileInfo.baseName() + ".pdf";
+ QString output = QFileDialog::getSaveFileName(0, tr("Export Document As ..."), outputSuggestion,
+ tr("PDF (*.pdf);; HTML (*.html *.htm"));
+
+ if(!output.isEmpty())
+ {
+ progressDialog_->reset();
+ runner_.start_export(scene_.backgroundPath(), xml_.filename(), output);
+ }
+}
+
+void MainWindow::onXmlSaved(const QString& filename)
+{
+ xml_.load(filename);
+ xmlWidget_.changeView(xml_.xmlItem());
+ scene_.setRoot(xml_.graphicsItem());
+
+ setActionsEnabled(true);
+ export_->setEnabled(xml_.recognized());
+}
+
+void MainWindow::onFileChanged(const QString& filename)
+{
+ // If it's not the current scene.
+ if(scene_.backgroundPath() != filename)
+ {
+ QString xmlPath = Xml::getPath(filename);
+
+ if(filename.isEmpty())
+ {
+ xmlPath = QString();
+ disableActions();
+ }
+ // Check if the xml file already exists.
+ else if(!QFile(xmlPath).exists())
+ {
+ xmlPath = QString();
+ setActionsEnabled(false);
+ }
+ else
+ setActionsEnabled(true);
+
+ xml_.load(xmlPath);
+ scene_.changeScene(filename, xml_.graphicsItem());
+ xmlWidget_.changeView(xml_.xmlItem());
+ export_->setEnabled(xml_.recognized());
+ updatePageBrowsing();
+ }
+}
+
+void MainWindow::onRegionSelection(QList<RegionItem *> regionItems)
+{
+ if(!regionItems.isEmpty())
+ xmlWidget_.view()->displayOnly(toXmlItems(regionItems));
+ else
+ {
+ xmlWidget_.view()->reset();
+ xmlWidget_.view()->displayAll();
+ xmlWidget_.view()->expandAll();
+ }
+}
+
+void MainWindow::onXmlChangeSelection(QList<XmlItem *> xmlItems, bool select)
+{
+ QList<RegionItem *> regionItems = toRegionItems(xmlItems);
+
+ if(!regionItems.isEmpty())
+ {
+ if(select)
+ scene_.select(regionItems);
+ else
+ scene_.unselect(regionItems);
+ }
+}
+
+QList<RegionItem *> MainWindow::toRegionItems(QList<XmlItem *> xmlItems) const
+{
+ QList<RegionItem *> regionItems;
+ XmlItem *child;
+ foreach(child, xmlItems)
+ {
+ if(child->regionItem())
+ regionItems << child->regionItem();
+ }
+
+ return regionItems;
+}
+
+QList<XmlItem *> MainWindow::toXmlItems(QList<RegionItem *> regionItems) const
+{
+ QList<XmlItem *> xmlItems;
+ RegionItem *child;
+ foreach(child, regionItems)
+ xmlItems << child->xmlItem();
+
+ return xmlItems;
+}
+
+void MainWindow::onPreferences()
+{
+ preferencesDialog_->show();
+}
+
+void MainWindow::onAbout()
+{
+ aboutDialog_->show();
+}
+
+void MainWindow::onXmlSelect(QList<XmlItem *> xmlItems)
+{
+ onXmlChangeSelection(xmlItems, true);
+}
+
+void MainWindow::onXmlUnselect(QList<XmlItem *> xmlItems)
+{
+ onXmlChangeSelection(xmlItems, false);
+}
+
+void MainWindow::updatePageBrowsing()
+{
+ next_->setEnabled(pagesWidget_.haveNextRow());
+ prev_->setEnabled(pagesWidget_.havePreviousRow());
+}
diff --git a/scribo/demo/viewer/mainwindow.hh b/scribo/demo/viewer/mainwindow.hh
new file mode 100644
index 0000000..527b612
--- /dev/null
+++ b/scribo/demo/viewer/mainwindow.hh
@@ -0,0 +1,130 @@
+// Copyright (C) 2013 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 MAINWINDOW_HH
+# define MAINWINDOW_HH
+
+#include <QPrintPreviewDialog>
+#include <QGraphicsView>
+#include <QPrintDialog>
+#include <QMainWindow>
+#include <QHBoxLayout>
+#include <QDockWidget>
+#include <QFileDialog>
+#include <QGroupBox>
+#include <QPrinter>
+
+#include "Preferences/preferencesdialog.hh"
+#include "Processing/progressdialog.hh"
+#include "PagesWidget/pageswidget.hh"
+#include "Rendering/graphicsview.hh"
+#include "XmlWidget/xmlwidget.hh"
+#include "Processing/runner.hh"
+#include "Rendering/scene.hh"
+#include "regionwidget.hh"
+#include "aboutdialog.hh"
+#include "dockwidget.hh"
+#include "xml.hh"
+
+namespace Ui
+{
+ class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT;
+
+public:
+ MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+protected:
+ void changeEvent(QEvent *e);
+
+private:
+ void initGraphicsRegion();
+ void initDialogsWidget();
+ void initPageWidget();
+ void initRegionWidget();
+ void initXmlWidget();
+ void initMenuBar();
+ void connectWidgets();
+
+ void setActionsEnabled(bool isSegmented);
+ void disableActions();
+
+ void updatePageBrowsing();
+
+ void printItems(QPainter *painter, const QList<QGraphicsItem *>& items, QStyleOptionGraphicsItem *options);
+
+ Xml processTmpXml(const QString& filename) const;
+ QList<RegionItem *> toRegionItems(QList<XmlItem *> regionItems) const;
+ QList<XmlItem *> toXmlItems(QList<RegionItem *> xmlItems) const;
+
+ Ui::MainWindow *ui;
+
+ DockWidget dockRegion_;
+ DockWidget dockPages_;
+ DockWidget dockXml_;
+
+ GraphicsView graphicsView_;
+ Scene scene_;
+
+ PagesWidget pagesWidget_;
+ RegionWidget regionWidget_;
+
+ AboutDialog *aboutDialog_;
+ ProgressDialog *progressDialog_;
+ PreferencesDialog *preferencesDialog_;
+
+ XmlWidget xmlWidget_;
+ Xml xml_;
+ Runner runner_;
+
+ QAction *segment_;
+ QAction *previewPrinting_;
+ QAction *print_;
+ QAction *export_;
+
+ // Browse among documents.
+ QAction *next_;
+ QAction *prev_;
+
+public slots:
+ void printScene(QPrinter *printer);
+
+private slots:
+ void onOpen();
+ void onSegment();
+ void onPreviewPrint();
+ void onPrint();
+ void onExportation();
+ void onPreferences();
+ void onAbout();
+
+ void onXmlSaved(const QString& filename);
+ void onFileChanged(const QString& filename);
+
+ void onRegionSelection(QList<RegionItem *> regionItems);
+
+ void onXmlChangeSelection(QList<XmlItem *> xmlItems, bool select);
+ void onXmlSelect(QList<XmlItem *> xmlItems);
+ void onXmlUnselect(QList<XmlItem *> xmlItems);
+};
+
+
+#endif // MAINWINDOW_HH
diff --git a/GScribo/mainwindow.ui b/scribo/demo/viewer/mainwindow.ui
similarity index 100%
rename from GScribo/mainwindow.ui
rename to scribo/demo/viewer/mainwindow.ui
diff --git a/scribo/demo/viewer/ocr_options.cc b/scribo/demo/viewer/ocr_options.cc
deleted file mode 100644
index 0ff09d9..0000000
--- a/scribo/demo/viewer/ocr_options.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-// Copyright (C) 2011 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 "ocr_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;
-
-
-static const char *language[][2] = {
- { "English", "eng" },
- { "French", "fra" },
- { 0, 0 }
-};
-
-
-ocr_options::ocr_options(QWidget *parent)
- : OptionWidget(parent)
-{
- setupUi(this);
-
- for (unsigned i = 0; language[i][0]; ++i)
- ocr_language->insertItem(i, language[i][0]);
-
- load_config();
-}
-
-ocr_options::~ocr_options()
-{
-}
-
-
-int ocr_options::find_index(const QString& lang)
-{
- for (unsigned i = 0; language[i][0]; ++i)
- if (lang == language[i][1])
- return i;
- return 0;
-}
-
-
-void ocr_options::load_config()
-{
- config * const conf = config::get_instance();
-
- enable_ocr->setChecked(conf->ocr_enabled());
- ocr_language->setCurrentIndex(find_index(conf->ocr_language()));
-}
-
-
-void ocr_options::save_config()
-{
- config * const conf = config::get_instance();
-
- conf->set_ocr_enabled(enable_ocr->isChecked());
- conf->set_ocr_language(language[ocr_language->currentIndex()][1]);
-}
diff --git a/scribo/demo/viewer/ocr_options.hh b/scribo/demo/viewer/ocr_options.hh
deleted file mode 100644
index 67ab4ef..0000000
--- a/scribo/demo/viewer/ocr_options.hh
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (C) 2011 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_OCR_OPTIONS_HH
-# define SCRIBO_DEMO_VIEWER_OCR_OPTIONS_HH
-
-# include <QtGui>
-# include <ocr_options.ui.h>
-# include "option_widget.hh"
-
-class ocr_options : public OptionWidget, private Ui::OcrOptions
-{
- Q_OBJECT;
-
-public:
- ocr_options(QWidget *parent = 0);
- ~ocr_options();
-
- void load_config();
- void save_config();
-
-private:
- int find_index(const QString& lang);
-
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_OCR_OPTIONS_HH
diff --git a/scribo/demo/viewer/ocr_options.ui b/scribo/demo/viewer/ocr_options.ui
deleted file mode 100644
index d001c64..0000000
--- a/scribo/demo/viewer/ocr_options.ui
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>OcrOptions</class>
- <widget class="QWidget" name="OcrOptions">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>366</width>
- <height>112</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Form</string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QGroupBox" name="enable_ocr">
- <property name="title">
- <string>Enable OCR</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="1" column="1">
- <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>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Language</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QComboBox" name="ocr_language"/>
- </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
deleted file mode 100644
index 4557749..0000000
--- a/scribo/demo/viewer/option_widget.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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
deleted file mode 100644
index 6b24e90..0000000
--- a/scribo/demo/viewer/option_widget.hh
+++ /dev/null
@@ -1,30 +0,0 @@
-// 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
deleted file mode 100644
index 1eb80a7..0000000
--- a/scribo/demo/viewer/preferences_dialog.cc
+++ /dev/null
@@ -1,129 +0,0 @@
-// Copyright (C) 2010, 2011 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 "general_options.hh"
-#include "ocr_options.hh"
-#include "preprocessing_options.hh"
-#include "segmentation_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", "Preprocessing", "Segmentation", "OCR", 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])
- {
- QWidget *widget = 0;
-
- switch (row)
- {
- case 0:
- widget = new general_options(this);
- break;
-
- case 1:
- widget = new preprocessing_options(this);
- break;
-
- case 2:
- widget = new segmentation_options(this);
- break;
-
- case 3:
- widget = new ocr_options(this);
- break;
-
- default:
- qDebug() << "select_option_widget - Hu? Something wrong...";
- }
-
- if (widget)
- widgets_[row] = widget;
- }
-
- 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
deleted file mode 100644
index 0368bbe..0000000
--- a/scribo/demo/viewer/preferences_dialog.hh
+++ /dev/null
@@ -1,45 +0,0 @@
-// 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
deleted file mode 100644
index 1d40563..0000000
--- a/scribo/demo/viewer/preferences_dialog.ui
+++ /dev/null
@@ -1,121 +0,0 @@
-<?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/preprocess.cc b/scribo/demo/viewer/preprocess.cc
deleted file mode 100644
index fd9a48b..0000000
--- a/scribo/demo/viewer/preprocess.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-// 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 "preprocess.hh"
-
-void preprocess::on_progress()
-{
- emit progress();
-}
-
-
-void preprocess::on_new_progress_label(const char *label)
-{
- QString lbl(label);
- emit new_progress_label(label);
-}
diff --git a/scribo/demo/viewer/preprocess.hh b/scribo/demo/viewer/preprocess.hh
deleted file mode 100644
index 4562cfb..0000000
--- a/scribo/demo/viewer/preprocess.hh
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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_PREPROCESS_HH
-# define SCRIBO_DEMO_VIEWER_PREPROCESS_HH
-
-# include <QtCore/QObject>
-# include <mln/core/image/image2d.hh>
-# include <mln/value/rgb8.hh>
-# include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh>
-
-using namespace scribo::toolchain::internal;
-
-struct preprocess
- : public QObject,
- public text_in_doc_preprocess_functor<mln::image2d<mln::value::rgb8> >
-{
- Q_OBJECT;
-
- virtual void on_progress();
- virtual void on_new_progress_label(const char *label);
-
-signals:
- void new_progress_label(const QString& label);
- void progress();
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_PREPROCESS_HH
diff --git a/scribo/demo/viewer/preprocessing_options.cc b/scribo/demo/viewer/preprocessing_options.cc
deleted file mode 100644
index 2d55fea..0000000
--- a/scribo/demo/viewer/preprocessing_options.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2010, 2011 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 "preprocessing_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;
-
-preprocessing_options::preprocessing_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");
-
- load_config();
-}
-
-preprocessing_options::~preprocessing_options()
-{
-}
-
-
-void preprocessing_options::load_config()
-{
- config * const conf = config::get_instance();
-
- 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());
-}
-
-
-void preprocessing_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());
-}
diff --git a/scribo/demo/viewer/preprocessing_options.hh b/scribo/demo/viewer/preprocessing_options.hh
deleted file mode 100644
index c676880..0000000
--- a/scribo/demo/viewer/preprocessing_options.hh
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (C) 2010, 2011 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_PREPROCESSING_OPTIONS_HH
-# define SCRIBO_DEMO_VIEWER_PREPROCESSING_OPTIONS_HH
-
-# include <QtGui>
-# include <preprocessing_options.ui.h>
-# include "option_widget.hh"
-
-class preprocessing_options : public OptionWidget, private Ui::PreprocessingOptions
-{
- Q_OBJECT;
-
-public:
- preprocessing_options(QWidget *parent = 0);
- ~preprocessing_options();
-
- void load_config();
- void save_config();
-
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_PREPROCESSING_OPTIONS_HH
diff --git a/scribo/demo/viewer/preprocessing_options.ui b/scribo/demo/viewer/preprocessing_options.ui
deleted file mode 100644
index 962cf49..0000000
--- a/scribo/demo/viewer/preprocessing_options.ui
+++ /dev/null
@@ -1,76 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>PreprocessingOptions</class>
- <widget class="QWidget" name="PreprocessingOptions">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>466</width>
- <height>198</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string>Configure toolchain</string>
- </property>
- <layout class="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <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 row="1" column="0">
- <widget class="QCheckBox" name="subsampleCb">
- <property name="text">
- <string>Run on subsampled image</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="remove_bgCb">
- <property name="text">
- <string>Remove background (slow)</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QCheckBox" name="deskewCb">
- <property name="text">
- <string>Deskew</string>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QCheckBox" name="remove_noiseCb">
- <property name="text">
- <string>Remove noise</string>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>48</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/scribo/demo/viewer/process.cc b/scribo/demo/viewer/process.cc
deleted file mode 100644
index 8fa5b9f..0000000
--- a/scribo/demo/viewer/process.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// 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 "process.hh"
-
-process::process(const char *doc_filename)
- : super_t(doc_filename)
-{
-
-}
-
-void process::on_progress()
-{
- emit progress();
-}
-
-
-void process::on_new_progress_label(const char *label)
-{
- QString lbl(label);
- emit new_progress_label(label);
-}
-
-
-void process::on_xml_saved()
-{
- QString filename(output_file.c_str());
- emit xml_saved(filename);
-}
diff --git a/scribo/demo/viewer/process.hh b/scribo/demo/viewer/process.hh
deleted file mode 100644
index 09ace43..0000000
--- a/scribo/demo/viewer/process.hh
+++ /dev/null
@@ -1,46 +0,0 @@
-// 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_PROCESS_HH
-# define SCRIBO_DEMO_VIEWER_PROCESS_HH
-
-# include <QtCore/QObject>
-# include <mln/core/image/image2d.hh>
-# include <scribo/toolchain/internal/content_in_doc_functor.hh>
-
-using namespace scribo::toolchain::internal;
-
-struct process
- : public QObject,
- public content_in_doc_functor<mln::image2d<bool> >
-{
- Q_OBJECT;
- typedef content_in_doc_functor<mln::image2d<bool> > super_t;
-
-public:
- process(const char *doc_filename);
-
- virtual void on_progress();
- virtual void on_new_progress_label(const char *label);
- virtual void on_xml_saved();
-
-signals:
- void new_progress_label(const QString& label);
- void progress();
- void xml_saved(const QString& filename);
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_PROCESS_HH
diff --git a/scribo/demo/viewer/region.hh b/scribo/demo/viewer/region.hh
new file mode 100644
index 0000000..806d8b4
--- /dev/null
+++ b/scribo/demo/viewer/region.hh
@@ -0,0 +1,72 @@
+// Copyright (C) 2013 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 REGION_HH
+# define REGION_HH
+
+#include <QColor>
+
+namespace GraphicsRegion
+{
+ // WARNING : The order is important.
+ enum Id
+ {
+ TextRegion,
+ Line,
+
+ VerticalSeparator,
+ HorizontalSeparator,
+ WhiteSpaceSeparator,
+
+ Image,
+ Noise,
+ Table,
+ Maths,
+ Graphic,
+ Chart,
+
+ Baseline,
+ Meanline,
+
+ Text,
+ Separators,
+ Miscellaneous,
+ Typology,
+
+ None
+ };
+
+ struct Data
+ {
+ QColor color;
+ QString name;
+ GraphicsRegion::Id region;
+ GraphicsRegion::Id parent;
+ int zValue;
+ };
+}
+
+namespace Separator
+{
+ enum FindSeparator
+ {
+ Lines,
+ Whitespaces,
+ Both
+ };
+}
+
+#endif // REGION_HH
diff --git a/scribo/demo/viewer/regionwidget.cc b/scribo/demo/viewer/regionwidget.cc
new file mode 100644
index 0000000..a9553ca
--- /dev/null
+++ b/scribo/demo/viewer/regionwidget.cc
@@ -0,0 +1,114 @@
+// Copyright (C) 2013 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 "regionwidget.hh"
+
+RegionWidget::RegionWidget(QWidget *parent) :
+ QTreeWidget(parent)
+{
+ setHeaderHidden(true);
+ setSelectionMode(QAbstractItemView::NoSelection);
+
+ addTopLevelItem(createRoot("Text", GraphicsRegion::Text,
+ GraphicsRegion::TextRegion,
+ GraphicsRegion::Line));
+ addTopLevelItem(createRoot("Typological Lines", GraphicsRegion::Typology,
+ GraphicsRegion::Baseline,
+ GraphicsRegion::Meanline));
+ addTopLevelItem(createRoot("Separators", GraphicsRegion::Separators,
+ GraphicsRegion::VerticalSeparator,
+ GraphicsRegion::WhiteSpaceSeparator));
+ addTopLevelItem(createRoot("Miscellaneous", GraphicsRegion::Miscellaneous,
+ GraphicsRegion::Image, GraphicsRegion::Chart));
+
+ expandAll();
+
+ connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
+ this, SLOT(checkStateChanged(QTreeWidgetItem*)));
+}
+
+QTreeWidgetItem *RegionWidget::createRoot(const QString& text,
+ const GraphicsRegion::Id& region,
+ const GraphicsRegion::Id& begin,
+ const GraphicsRegion::Id& end)
+{
+ // Create root.
+ QTreeWidgetItem *rootItem = createItem(text, region);
+
+ // Fill root with corresponding childs.
+ for(int region_ = begin; region_ <= end; region_++)
+ fillRoot(rootItem, static_cast<GraphicsRegion::Id>(region_));
+
+ return rootItem;
+}
+
+QTreeWidgetItem *RegionWidget::createItem(const QString& text,
+ const GraphicsRegion::Id& region,
+ const QColor& color)
+{
+ QTreeWidgetItem *item = new QTreeWidgetItem;
+ item->setText(0, text);
+ item->setCheckState(0, Qt::Checked);
+ item->setBackgroundColor(0, color);
+ // Store graphical id in the object to recognize it afterward.
+ item->setData(0, Qt::UserRole, static_cast<int>(region));
+
+ return item;
+}
+
+void RegionWidget::checkStateChanged(QTreeWidgetItem *item)
+{
+ // If it's a root item, go to childs.
+ if(item->childCount() != 0)
+ {
+ QTreeWidgetItem *child;
+ for(int i = 0; i < item->childCount(); i++)
+ {
+ child = item->child(i);
+ child->setCheckState(0, item->checkState(0));
+ }
+ }
+ else
+ {
+ if(item->checkState(0) == Qt::Checked)
+ {
+ filterString_.append('|' + item->text(0));
+ emit checkStateChanged(static_cast<GraphicsRegion::Id>(item->data(0, Qt::UserRole).toInt()), true);
+ }
+ else
+ {
+ filterString_.remove('|' + item->text(0), Qt::CaseSensitive);
+ emit checkStateChanged(static_cast<GraphicsRegion::Id>(item->data(0, Qt::UserRole).toInt()), false);
+ }
+
+ //emit checkStateChanged(filterString_);
+ }
+}
+
+
+inline void RegionWidget::fillRoot(QTreeWidgetItem *rootItem,
+ const GraphicsRegion::Id& region)
+{
+ GraphicsRegion::Data data = Xml::dataFromRegion(region);
+ filterString_.append('|' + data.name);
+ rootItem->addChild(createItem(data.name, region, data.color));
+}
+
+
+inline QString RegionWidget::filterString() const
+{
+ return filterString_.right(filterString_.count()-1);
+}
diff --git a/scribo/demo/viewer/regionwidget.hh b/scribo/demo/viewer/regionwidget.hh
new file mode 100644
index 0000000..3899ffc
--- /dev/null
+++ b/scribo/demo/viewer/regionwidget.hh
@@ -0,0 +1,58 @@
+// Copyright (C) 2013 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 REGIONWIDGET_HH
+# define REGIONWIDGET_HH
+
+#include <QTreeWidget>
+#include <QLabel>
+
+#include "xml.hh"
+
+class RegionWidget :
+ public QTreeWidget
+{
+ Q_OBJECT;
+
+public:
+ explicit RegionWidget(QWidget *parent = 0);
+
+ QString filterString() const;
+
+private:
+ QTreeWidgetItem *createRoot(const QString& text,
+ const GraphicsRegion::Id& region,
+ const GraphicsRegion::Id& begin,
+ const GraphicsRegion::Id& end);
+ QTreeWidgetItem *createItem(const QString& text,
+ const GraphicsRegion::Id& region,
+ const QColor& color = QColor::fromRgb(255, 255, 255));
+ void fillRoot(QTreeWidgetItem *rootItem,
+ const GraphicsRegion::Id& region);
+
+ QString filterString_;
+
+private slots:
+ void checkStateChanged(QTreeWidgetItem *item);
+
+signals:
+ void checkStateChanged(const GraphicsRegion::Id& region,
+ bool checked);
+ void checkStateChanged(const QString& filterString);
+};
+
+
+#endif // REGIONWIDGET_HH
diff --git a/scribo/demo/viewer/runner.cc b/scribo/demo/viewer/runner.cc
deleted file mode 100644
index da2f3bf..0000000
--- a/scribo/demo/viewer/runner.cc
+++ /dev/null
@@ -1,243 +0,0 @@
-// Copyright (C) 2010, 2011 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 "runner.hh"
-
-#include <mln/core/image/image2d.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/io/magick/load.hh>
-
-#include "demodir.hh"
-
-#include "process.hh"
-#include "preprocess.hh"
-#include "config.hh"
-#include "defs.hh"
-
-
-
-using namespace mln;
-using namespace scribo::toolchain::internal;
-
-static
-QString get_pathto(const QString& file,
- const QString localdirsuffix = QString())
-{
- QFile f(SCRIBO_LOCAL_DEMODIR "/" + localdirsuffix + "/" + file);
- if (f.exists())
- return SCRIBO_LOCAL_DEMODIR "/" + localdirsuffix;
-
- f.setFileName(SCRIBO_PREFIX_LIBEXECDIR "/" + file);
- if (f.exists())
- return SCRIBO_PREFIX_LIBEXECDIR;
-
- qDebug() << "FATAL ERROR: Can't locate file: " + file;
-
- return "";
-}
-
-
-runner::runner(QObject *parent)
- : QThread(parent)
-{
- moveToThread(this);
-}
-
-
-void runner::run()
-{
-
- switch(mode_)
- {
- default:
- case Demat:
- {
- image2d<value::rgb8> ima;
- io::magick::load(ima, args_.at(0).toUtf8().constData());
-
- image2d<bool> bin_ima = preprocess(ima);
- process(ima, bin_ima);
- }
- break;
-
- case Export:
- export_as();
- break;
- }
-
- emit finished();
- qDebug() << "Done.";
-}
-
-
-void runner::stop()
-{
- terminate();
-}
-
-
-
-// Demat related stuff
-
-void runner::start_demat(const QString& filename)
-{
- args_.clear();
- args_ << filename;
- mode_ = Demat;
-
- QThread::start();
-}
-
-
-image2d<bool>
-runner::preprocess(const image2d<value::rgb8>& ima)
-{
- emit new_step("Preprocessing");
-
- ::preprocess f;
-
- // Load config.
- config * const conf = config::get_instance();
-
- connect(&f, SIGNAL(progress()), this, SIGNAL(progress()));
- connect(&f, SIGNAL(new_progress_label(const QString&)),
- this, SIGNAL(new_progress_label(const QString&)));
-
- f.enable_subsample = conf->preprocessing_subsample();
- f.enable_fg_extraction = conf->preprocessing_remove_bg();
- f.enable_deskew = conf->preprocessing_deskew();
- f.enable_denoising = conf->preprocessing_remove_noise();
-
- f.binarization_algo = static_cast<Binarization_Algo>(conf->preprocessing_bin_algo());
-
- emit new_progress_max_value(f.nsteps());
-
- // Perform preprocessing.
- f(ima);
-
- qDebug() << "Preprocess Done.";
- return f.output;
-}
-
-
-void runner::process(const image2d<value::rgb8>& original_ima,
- const image2d<bool>& processed_ima)
-{
- emit new_step("Page segmentation");
-
- ::process f(args_.at(0).toUtf8().constData());
-
- connect(&f, SIGNAL(progress()), this, SIGNAL(progress()));
- connect(&f, SIGNAL(new_progress_label(const QString&)),
- this, SIGNAL(new_progress_label(const QString&)));
- connect(&f, SIGNAL(xml_saved(const QString&)),
- this, SIGNAL(xml_saved(const QString&)));
-
- // Load config.
- config * const conf = config::get_instance();
-
- defs::FindSeparators
- find_seps = static_cast<defs::FindSeparators>(conf->segmentation_find_seps());
- f.enable_line_seps = (find_seps == defs::Lines
- || find_seps == defs::LinesAndWhitespaces);
- f.enable_whitespace_seps = (find_seps == defs::Whitespaces
- || find_seps == defs::LinesAndWhitespaces);
- f.enable_ocr = conf->ocr_enabled();
- f.ocr_language = conf->ocr_language().toAscii().data();
- f.xml_format = scribo::io::xml::PageExtended;
-
-
- f.save_doc_as_xml = true;
- QFileInfo file(args_.at(0));
- QString output_dir = QDir::tempPath();
- if (conf->general_save_xml_enabled())
- {
- if (conf->general_save_xml_same_dir())
- output_dir = file.absolutePath();
- else if (conf->general_save_xml_custom_dir())
- output_dir = conf->general_save_xml_custom_dir_path();
- else
- qDebug() << "runner::progress - Invalid xml saving option!";
-
- QDir dir(output_dir);
- if (!dir.exists() && !dir.mkpath(output_dir))
- output_dir = QDir::tempPath();
- }
- f.output_file = (output_dir + "/" + file.baseName() + "_gui.xml").toUtf8().constData();
-
- emit new_progress_max_value(f.nsteps());
-
- // Perform text detection.
- f(original_ima, processed_ima);
-
- qDebug() << "Process Done.";
-}
-
-
-
-// Export related stuff
-
-void runner::start_export(const QString& imgfile,
- const QString& xmlfile, const QString& outfile)
-{
- args_.clear();
- args_ << imgfile << xmlfile << outfile;
- mode_ = Export;
-
- QThread::start();
-}
-
-
-void runner::export_as()
-{
- emit new_step("Exporting document...");
- emit new_progress_max_value(2);
-
- // Checking output format
- QFileInfo f(args_.at(2));
-
- QString pathto_xml2doc = get_pathto("scribo-xml2doc", "xml2doc");
-
- if (pathto_xml2doc.isEmpty())
- {
- QMessageBox::critical(0, "Fatal error", "Cannot export! Cannot find scribo-xml2doc program!");
- return;
- }
-
- emit progress();
-
- int rvalue = 0;
- if (f.suffix() == "pdf")
- {
- emit new_step("Exporting as PDF...");
- rvalue = system(QString("%1/scribo-xml2doc --pdf %2 %3 %4")
- .arg(pathto_xml2doc).arg(args_.at(1)).arg(args_.at(0))
- .arg(args_.at(2)).toAscii().constData());
- }
- else if (f.suffix() == "html" || f.suffix() == "htm")
- {
- emit new_step("Exporting as HTML...");
- rvalue = system(QString("%1/scribo-xml2doc --html %2 %3 %4")
- .arg(pathto_xml2doc).arg(args_.at(1)).arg(args_.at(0))
- .arg(args_.at(2)).toAscii().constData());
- }
- else
- QMessageBox::critical(0, "Fatal error", "Cannot export! Invalid output format!");
-
- if (rvalue != 0)
- QMessageBox::critical(0, "Fatal error", "Cannot export! Return value is not 0!");
-}
diff --git a/scribo/demo/viewer/runner.hh b/scribo/demo/viewer/runner.hh
deleted file mode 100644
index 176dcd8..0000000
--- a/scribo/demo/viewer/runner.hh
+++ /dev/null
@@ -1,73 +0,0 @@
-// 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_RUNNER_HH
-# define SCRIBO_DEMO_VIEWER_RUNNER_HH
-
-# include <QtGui>
-
-# include <mln/core/image/image2d.hh>
-# include <mln/value/rgb8.hh>
-
-using namespace mln;
-
-enum RunMode
-{
- Demat,
- Export
-};
-
-class runner : public QThread
-{
- Q_OBJECT;
-
-public:
- runner(QObject *parent = 0);
-
- void start_demat(const QString& filename);
- void start_export(const QString& imgfile,
- const QString& xmlfile, const QString& outfile);
-
-public slots:
- void stop();
-
-signals:
- void new_step(const QString& step_name);
- void new_progress_max_value(int i);
- void new_progress_label(const QString& msg);
- void xml_saved(const QString& filename);
- void progress();
- void finished();
-
-private: // members
- image2d<bool> preprocess(const image2d<value::rgb8>& ima);
- void process(const image2d<value::rgb8>& original_ima,
- const image2d<bool>& processed_ima);
-
- void export_as();
-
- virtual void run();
-
- template <typename V>
- unsigned find_best_scale(const mln::image2d<V>& ima);
-
-private: // attributes
- QStringList args_;
- RunMode mode_;
-};
-
-
-#endif // ! SCRIBO_DEMO_VIEWER_RUNNER_HH
diff --git a/scribo/demo/viewer/segmentation_options.cc b/scribo/demo/viewer/segmentation_options.cc
deleted file mode 100644
index c120879..0000000
--- a/scribo/demo/viewer/segmentation_options.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (C) 2011 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 "segmentation_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;
-
-segmentation_options::segmentation_options(QWidget *parent)
- : OptionWidget(parent)
-{
- setupUi(this);
-
- find_sepsCbox->insertItem(defs::Lines, "Lines");
- find_sepsCbox->insertItem(defs::Whitespaces, "Whitespaces");
- find_sepsCbox->insertItem(defs::LinesAndWhitespaces, "Lines and whitespaces");
-
- load_config();
-}
-
-segmentation_options::~segmentation_options()
-{
-}
-
-
-void segmentation_options::load_config()
-{
- config * const conf = config::get_instance();
-
- find_sepsCbox->setCurrentIndex(conf->segmentation_find_seps());
-}
-
-
-void segmentation_options::save_config()
-{
- config * const conf = config::get_instance();
-
- conf->set_segmentation_find_seps(find_sepsCbox->currentIndex());
-}
diff --git a/scribo/demo/viewer/segmentation_options.hh b/scribo/demo/viewer/segmentation_options.hh
deleted file mode 100644
index bdf65f9..0000000
--- a/scribo/demo/viewer/segmentation_options.hh
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (C) 2011 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_SEGMENTATION_OPTIONS_HH
-# define SCRIBO_DEMO_VIEWER_SEGMENTATION_OPTIONS_HH
-
-# include <QtGui>
-# include <segmentation_options.ui.h>
-# include "option_widget.hh"
-
-class segmentation_options : public OptionWidget, private Ui::SegmentationOptions
-{
- Q_OBJECT;
-
-public:
- segmentation_options(QWidget *parent = 0);
- ~segmentation_options();
-
- void load_config();
- void save_config();
-
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_SEGMENTATION_OPTIONS_HH
diff --git a/scribo/demo/viewer/segmentation_options.ui b/scribo/demo/viewer/segmentation_options.ui
deleted file mode 100644
index 485e448..0000000
--- a/scribo/demo/viewer/segmentation_options.ui
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>SegmentationOptions</class>
- <widget class="QWidget" name="SegmentationOptions">
- <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="QGridLayout" name="gridLayout">
- <item row="0" column="0">
- <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">
- <property name="editable">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="1" column="0">
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>258</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/scribo/demo/viewer/step_widget.cc b/scribo/demo/viewer/step_widget.cc
deleted file mode 100644
index 19b5d0f..0000000
--- a/scribo/demo/viewer/step_widget.cc
+++ /dev/null
@@ -1,178 +0,0 @@
-// 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 "step_widget.hh"
-# include "config.hh"
-
-StepWidget::StepWidget()
- : view_(new QListWidget()),
- step_(QString::Null())
-{
- QLabel* title = new QLabel(tr("Steps"));
- title->setAlignment(Qt::AlignHCenter);
-
- QVBoxLayout* layout = new QVBoxLayout;
-
- layout->addWidget(title);
- layout->addWidget(view_);
-
- view_->setSortingEnabled(true);
-
- setLayout(layout);
-
- connect(view_, SIGNAL(itemActivated(QListWidgetItem*)),
- this, SLOT(activate(QListWidgetItem*)));
-
- connect(this, SIGNAL(activated(QListWidgetItem*)),
- this, SLOT(activate(QListWidgetItem*)));
-
-}
-
-StepWidget::~StepWidget()
-{
-}
-
-
-void StepWidget::activate(QListWidgetItem* item)
-{
- QString key, value;
-
- StepQMap::iterator iter = map_.find(item->text());
-
- if (iter != map_.end())
- {
- view_->setCurrentItem(item);
- step_ = item->text();
- key = iter.key();
- value = iter.value();
-
- qDebug() << "Loading " << value;
- emit load_xml(value);
- }
- else
- qDebug() << "Step not found!";
-
- emit step_selected(view_->count());
-}
-
-
-void StepWidget::fill_steps(QString file, bool step, bool container)
-{
- view_->clear();
- map_.clear();
-
- if (container)
- {
- emit change_base(true);
- // emit load_image(file, true);
- emit load_xml(file);
- }
- else
- {
- emit change_base(false);
- // image is loaded once
- emit load_image(file, false);
-
-
- QFileInfo f(file);
- file_with_no_ext_ = f.baseName();
-
- QStringList dirlist;
- dirlist << f.absolutePath() << QDir::tempPath();
-
- // Set directories to look at according to settings.
- config * const conf = config::get_instance();
- if (conf->general_save_xml_custom_dir())
- dirlist << conf->general_save_xml_custom_dir_path();
-
- foreach(QString path, dirlist)
- {
- QDir dir(path);
-
- if (dir.isReadable())
- {
- QStringList filter;
- filter << "*.xml";
- QFileInfoList xml_list = dir.entryInfoList(filter);
- for (int i = 0; i < xml_list.size(); ++i)
- insert_new_entry(xml_list.at(i));
- }
- }
-
- if ( (step && step_ != QString::Null()))
- {
- QList<QListWidgetItem*> list = view_->findItems(step_, Qt::MatchContains);
-
- if (!list.isEmpty())
- emit activated(list.first());
- }
- else
- {
- step_ = QString::Null();
- if (view_->count())
- emit activated(view_->item(0));
- }
- }
-}
-
-
-QListWidgetItem* StepWidget::insert_new_entry(const QFileInfo& file)
-{
- QListWidgetItem *item = 0;
-
- if (file.fileName().startsWith(file_with_no_ext_))
- {
- QString key = file.baseName();
- key.replace(file_with_no_ext_ + QString("_"), QString(""));
- key.replace(QRegExp("^step([0-9])"), "Step \\1");
- key.replace(QRegExp("^Step ([0-9])_"), "Step \\1 : ");
- key.replace("_", " ");
-
- bool exists = (map_.find(key) != map_.end());
-
- map_.insertMulti(key, file.absoluteFilePath());
-
- if (!exists)
- {
- item = new QListWidgetItem(key);
- view_->addItem(item);
- }
- else
- item = view_->findItems(key, Qt::MatchCaseSensitive).at(0);
- }
-
- return item;
-}
-
-
-QListWidgetItem* StepWidget::add_element(const QString& element)
-{
- QListWidgetItem *item = new QListWidgetItem(element);
- view_->addItem(item);
-
- return item;
-}
-
-QString StepWidget::current() const
-{
- return map_.value(step_);
-}
-
-
-
-
-
-
diff --git a/scribo/demo/viewer/step_widget.hh b/scribo/demo/viewer/step_widget.hh
deleted file mode 100644
index f648ede..0000000
--- a/scribo/demo/viewer/step_widget.hh
+++ /dev/null
@@ -1,56 +0,0 @@
-// 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_STEP_WIDGET_HH_
-# define SCRIBO_DEMO_VIEWER_STEP_WIDGET_HH_
-
-# include <QtGui>
-
-typedef QMap<QString, QString> StepQMap;
-
-class StepWidget
- : public QWidget
-{
- Q_OBJECT
-
-public:
- StepWidget();
- ~StepWidget();
- QListWidgetItem* add_element(const QString& element);
-
- QString current() const;
-
-signals:
- void load_image(QString, bool);
- void load_xml(QString);
- void activated(QListWidgetItem*);
- void change_base(bool);
- void step_selected(bool);
-
-public slots:
- void fill_steps(QString file, bool step = false, bool container = false);
- void activate(QListWidgetItem* item);
- QListWidgetItem* insert_new_entry(const QFileInfo& file);
-
-private:
- QListWidget* view_;
- StepQMap map_;
- QString step_;
- QString file_with_no_ext_;
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_STEP_WIDGET_HH_
diff --git a/scribo/demo/viewer/variantpointer.cc b/scribo/demo/viewer/variantpointer.cc
new file mode 100644
index 0000000..07213aa
--- /dev/null
+++ b/scribo/demo/viewer/variantpointer.cc
@@ -0,0 +1,39 @@
+// Copyright (C) 2013 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 <variantpointer.hh>
+
+
+template<typename T>
+VariantPointer<T>::VariantPointer()
+{
+}
+
+
+template<typename T>
+QVariant
+VariantPointer<T>::toQVariant(T *pointer)
+{
+ return QVariant::fromValue(static_cast<void *>(pointer));
+}
+
+
+template<typename T>
+T *
+VariantPointer<T>::fromQVariant(const QVariant& variant)
+{
+ return static_cast<T *>(variant.value<void *>());
+}
diff --git a/scribo/demo/viewer/variantpointer.hh b/scribo/demo/viewer/variantpointer.hh
new file mode 100644
index 0000000..e8aab4b
--- /dev/null
+++ b/scribo/demo/viewer/variantpointer.hh
@@ -0,0 +1,33 @@
+// Copyright (C) 2013 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 VARIANTPOINTER_HH
+# define VARIANTPOINTER_HH
+
+#include <QVariant>
+
+template<typename T>
+class VariantPointer
+{
+public:
+ static QVariant toQVariant(T *pointer);
+ static T *fromQVariant(const QVariant& variant);
+
+private:
+ VariantPointer();
+};
+
+#endif // VARIANTPOINTER_HH
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
deleted file mode 100644
index 866761d..0000000
--- a/scribo/demo/viewer/viewer.cc
+++ /dev/null
@@ -1,1021 +0,0 @@
-// Copyright (C) 2010, 2011 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 <iostream>
-#include <limits.h>
-
-#include "viewer.hh"
-#include "key_widget.hh"
-#include "browser_widget.hh"
-#include "xml_widget.hh"
-#include "step_widget.hh"
-#include "image_scene.hh"
-#include "image_view.hh"
-#include "image_region.hh"
-#include "help_dialog.hh"
-#include "preferences_dialog.hh"
-#include "runner.hh"
-#include "config.hh"
-
-#include "common.hh"
-
-Viewer::Viewer(int &argc, char** argv)
- : app_ (new QApplication(argc, argv)),
- win_ (new QMainWindow()),
- image_(0),
- scene_(new ImageScene()),
- files_(new QDirModel()),
- doc_layout_(0),
- key_map_(region::RegionIdCount),
- no_cache_(false),
- extended_mode_(false),
- xml_file_(QString::Null()),
- base64_(false),
- text_(true),
- use_image_(true),
- pdialog_(win_)
-{
- // Key map
- // --------
-
- key_map_[region::Text] = qMakePair(tr("Text Region"), QColor(0, 200, 0));
-
- // Extension
- key_map_[region::Line] = qMakePair(tr("Text line"), QColor(255, 0, 0));
-
- key_map_[region::Image] = qMakePair(tr("Image"), QColor(255, 120, 0));
- key_map_[region::Noise] = qMakePair(tr("Noise"), QColor(43, 39, 128));
- key_map_[region::Table] = qMakePair(tr("Table"), QColor(220, 246, 0));
- key_map_[region::LineDrawing] = qMakePair(tr("LineDrawing"),
- QColor(255, 198, 0));
- key_map_[region::Graphic] = qMakePair(tr("Graphic"), QColor(255, 0, 144));
- key_map_[region::Chart] = qMakePair(tr("Chart"), QColor(0, 204, 255));
- key_map_[region::Maths] = qMakePair(tr("Maths"), QColor(170, 0, 255));
-
- // Extension
- key_map_[region::HorizontalSeparator] = qMakePair(tr("HorizontalSeparator"), QColor(0, 0, 255));
- key_map_[region::VerticalSeparator] = qMakePair(tr("VerticalSeparator"), QColor(0, 0, 255));
- key_map_[region::WhitespaceSeparator] = qMakePair(tr("Whitespace Separator"), QColor(0, 0, 128));
-
- // Extension
- key_map_[region::Baseline] = qMakePair(tr("Baseline"), QColor(128, 0, 255));
- key_map_[region::Meanline] = qMakePair(tr("Meanline"), QColor(128, 0, 255));
-
-
-
- // Region ids
- // ----------
-
- region_ids_["TextRegion"] = region::Text;
-
- // Extension
- region_ids_["Line"] = region::Line;
-
- region_ids_["ImageRegion"] = region::Image;
- region_ids_["NoiseRegion"] = region::Noise;
- region_ids_["TableRegion"] = region::Table;
- region_ids_["Line_drawingRegion"] = region::LineDrawing;
- region_ids_["GraphicRegion"] = region::Graphic;
- region_ids_["ChartRegion"] = region::Chart;
- region_ids_["MathsRegion"] = region::Maths;
-
- // Extension
- region_ids_["VerticalSeparatorRegion"] = region::VerticalSeparator;
- region_ids_["HorizontalSeparatorRegion"] = region::HorizontalSeparator;
- region_ids_["WhitespaceSeparatorRegion"] = region::WhitespaceSeparator;
-
-
-
- win_->resize(1152, 864);
- win_->statusBar();
-
- QMenu* file_menu = win_->menuBar()->addMenu(tr("File"));
- QMenu* option_menu = win_->menuBar()->addMenu(tr("Options"));
- QMenu* view_menu = win_->menuBar()->addMenu(tr("View"));
- QMenu* help_menu = win_->menuBar()->addMenu(tr("Help"));
-
-
- // File menu
-
- QAction *doc_seg_action = create_action("Segment document", file_menu,
- "Segment document", "Ctrl+S");
- connect(doc_seg_action, SIGNAL(triggered()),
- this, SLOT(run_process()));
- file_menu->addAction(doc_seg_action);
-
- file_menu->addSeparator();
-
- export_action_ = create_action("Export as...", file_menu,
- "Export as...", "Shift+Ctrl+S");
- connect(export_action_, SIGNAL(triggered()),
- this, SLOT(export_as()));
- file_menu->addAction(export_action_);
- export_action_->setEnabled(false);
-
- file_menu->addSeparator();
-
- QAction *preview_print_action = create_action("Printing preview", file_menu,
- "Printint preview", "Ctrl+P");
- connect(preview_print_action, SIGNAL(triggered()),
- this, SLOT(preview_print()));
- file_menu->addAction(preview_print_action);
- preview_print_action->setEnabled(false);
-
-
- QAction *print_action = create_action("Print", file_menu,
- "Print", "Ctrl+P");
- connect(print_action, SIGNAL(triggered()),
- this, SLOT(print()));
- file_menu->addAction(print_action);
- print_action->setEnabled(false);
-
- file_menu->addSeparator();
-
-
- QAction* quit_action = create_action("Quit", file_menu,
- "Exit the program.", "Ctrl+q");
- connect(quit_action, SIGNAL(triggered()),
- app_, SLOT(quit()));
- file_menu->addAction(quit_action);
-
- // Option menu
-
- QAction* preferences_action_ = create_action("Preferences", option_menu,
- "Preferences", "Ctrl+Alt+P");
- preferences_action_->setCheckable(false);
- connect(preferences_action_, SIGNAL(triggered(bool)),
- this, SLOT(on_preferences()));
- option_menu->addAction(preferences_action_);
-
-
- // View menu
-
- outline_action_ = create_action("Draw outline", view_menu,
- "Draw region outlines.", "Ctrl+o");
- outline_action_->setCheckable(true);
- outline_action_->setChecked(true);
- connect(outline_action_, SIGNAL(toggled(bool)),
- this, SIGNAL(setOutline(bool)));
- view_menu->addAction(outline_action_);
-
- precise_action_ = create_action("Precise outline", view_menu,
- "1px outline relative to the image "
- "(1px relative to the view if off).",
- "Shift+Ctrl+p");
- precise_action_->setCheckable(true);
- precise_action_->setChecked(false);
- connect(precise_action_, SIGNAL(toggled(bool)),
- this, SIGNAL(setPrecise(bool)));
- view_menu->addAction(precise_action_);
-
- fill_action_ = create_action("Fill regions", view_menu,
- "Color the inside of regions.", "Ctrl+f");
- fill_action_->setCheckable(true);
- fill_action_->setChecked(true);
- connect(fill_action_, SIGNAL(toggled(bool)),
- this, SIGNAL(setFill(bool)));
- view_menu->addAction(fill_action_);
-
- QAction* cache_action = create_action("Disable cache", view_menu,
- "Disable the image cache (useful for"
- " large images).", "Ctrl+c");
- cache_action->setCheckable(true);
- cache_action->setChecked(false);
- connect(cache_action, SIGNAL(toggled(bool)),
- this, SLOT(useCache(bool)));
- view_menu->addAction(cache_action);
-
-
- QAction* extended_action = create_action("Extended mode", view_menu,
- "If enabled, some features "
- "not supported by ICDAR"
- " are added such as text regions"
- "or text lines", "Ctrl+e");
- extended_action->setCheckable(true);
- extended_action->setChecked(false);
- connect(extended_action, SIGNAL(toggled(bool)),
- this, SLOT(useExtended(bool)));
- view_menu->addAction(extended_action);
-
- QAction* show_image_action = create_action("Show pictures", view_menu,
- "Display pictures on the scene or not",
- "Ctrl+i");
- show_image_action->setCheckable(true);
- show_image_action->setChecked(true);
- connect(show_image_action, SIGNAL(toggled(bool)),
- this, SLOT(useImage(bool)));
- view_menu->addAction(show_image_action);
-
- QAction* show_text_action = create_action("Show text", view_menu,
- "Show detected text inside boxes.",
- "Ctrl+t");
- show_text_action->setCheckable(true);
- show_text_action->setChecked(true);
- connect(show_text_action, SIGNAL(toggled(bool)),
- this, SLOT(useText(bool)));
- view_menu->addAction(show_text_action);
-
- key_wgt_ = new KeyWidget(key_map_);
- QAction *show_region_action = create_action("Show regions", view_menu,
- "Display regions that are present in"
- " the XML file.",
- "Ctrl+r");
- show_region_action->setCheckable(true);
- show_region_action->setChecked(true);
- connect(show_region_action, SIGNAL(toggled(bool)),
- key_wgt_, SLOT(setAll(bool)));
- view_menu->addAction(show_region_action);
-
- // Help menu
-
- QAction* about_action = create_action("About", help_menu,
- "About this program",
- "Ctrl+h");
- connect(about_action, SIGNAL(triggered()),
- this, SLOT(help()));
- help_menu->addAction(about_action);
-
- // Layout
-
- QSplitter* h_splitter = new QSplitter();
- QSplitter* v_splitter = new QSplitter(Qt::Vertical);
- QSplitter* v_splitter2 = new QSplitter(Qt::Vertical);
-
- step_widget_ = new StepWidget();
- XmlWidget* xml_wgt = new XmlWidget();
- browser_wgt_ = new BrowserWidget(files_, argc != 2 ? QString() : argv[1]);
- image_wgt_ = new ImageWidget(scene_);
-
- connect(step_widget_, SIGNAL(step_selected(bool)),
- export_action_, SLOT(setEnabled(bool)));
- connect(step_widget_, SIGNAL(step_selected(bool)),
- print_action, SLOT(setEnabled(bool)));
- connect(step_widget_, SIGNAL(step_selected(bool)),
- preview_print_action, SLOT(setEnabled(bool)));
-
- scene_->setBackgroundBrush(scene_->palette().window());
-
- v_splitter->addWidget(step_widget_);
- v_splitter->addWidget(key_wgt_);
- v_splitter->addWidget(browser_wgt_);
-
- v_splitter2->addWidget(image_wgt_);
- v_splitter2->addWidget(xml_wgt);
-
- h_splitter->addWidget(v_splitter);
- h_splitter->addWidget(v_splitter2);
-
- win_->setCentralWidget(h_splitter);
-
- QList<int> v_sizes;
- v_sizes << 200 << 250 << 350;
- v_splitter->setSizes(v_sizes);
-
- QList<int> v_sizes2;
- v_sizes2 << 725 << 175;
- v_splitter2->setSizes(v_sizes2);
-
- QList<int> h_sizes;
- h_sizes << 200 << 900;
- h_splitter->setSizes(h_sizes);
-
- connect(browser_wgt_, SIGNAL(activated(QString, bool, bool)),
- step_widget_, SLOT(fill_steps(QString, bool, bool)));
-
- connect(step_widget_, SIGNAL(change_base(bool)),
- this, SLOT(change_base(bool)));
- connect(step_widget_, SIGNAL(load_image(QString, bool)),
- this, SLOT(load(QString, bool)));
- connect(step_widget_, SIGNAL(load_xml(QString)),
- this, SLOT(load_xml(QString)));
-
- connect(this, SIGNAL(mode_changed(bool)),
- key_wgt_, SLOT(change_mode(bool)));
- connect(this, SIGNAL(updated()),
- image_wgt_, SLOT(update()));
- connect(this, SIGNAL(fill_xml(QString)),
- xml_wgt, SLOT(fill_widget(QString)));
-
- connect(key_wgt_, SIGNAL(updated(int, bool)),
- this, SIGNAL(key_updated(int, bool)));
-
- connect(scene_, SIGNAL(selected(QString, QString)),
- xml_wgt, SLOT(select(QString, QString)));
- connect(scene_, SIGNAL(deselected()),
- xml_wgt, SLOT(deselect()));
-
- connect(image_wgt_, SIGNAL(scaleUpdated(qreal)),
- this, SLOT(maybeChangeCacheMode(qreal)));
-
-
- // Progress dialog and process runner.
- pdialog_.setModal(true);
- pdialog_.setAutoClose(false);
- pdialog_.setCancelButton(0);
- connect(&runner_, SIGNAL(finished()), &pdialog_, SLOT(close()));
-
- connect(&runner_, SIGNAL(new_step(const QString&)),
- &pdialog_, SLOT(setWindowTitle(const QString&)));
- connect(&runner_, SIGNAL(new_progress_max_value(int)),
- &pdialog_, SLOT(setMaximum(int)));
- connect(&runner_, SIGNAL(new_progress_label(const QString&)),
- &pdialog_, SLOT(setLabelText(const QString&)));
- connect(&runner_, SIGNAL(progress()),
- this, SLOT(run_progress()));
- connect(&runner_, SIGNAL(xml_saved(const QString&)),
- this, SLOT(on_xml_saved(const QString&)));
-
- extended_action->setChecked(true);
-}
-
-
-Viewer::~Viewer()
-{
- // Remove temporary xml files.
- foreach(QString file, tmp_files_to_remove_)
- QFile::remove(file);
-}
-
-void
-Viewer::add_text(QDomNode line)
-{
-
- int a_height = line.toElement().attribute("aHeight", "0").toInt();
- int d_height = line.toElement().attribute("dHeight", "0").toInt();
- int x_height = line.toElement().attribute("xHeight", "0").toInt();
-
- if (d_height < 0)
- d_height = -d_height;
-
- if ( (a_height - x_height) < (d_height))
- a_height = x_height + d_height;
-
- if ( (a_height - x_height) > (d_height))
- d_height = a_height - x_height;
-
- QDomNode coords = line.firstChild();
-
- while (!coords.isNull() && !coords.toElement().tagName().contains("Coords"))
- coords = coords.nextSibling();
-
- if (coords.isNull())
- {
- qDebug() << "Warning : textline without coordinates...";
- return;
- }
-
- QDomNode point = coords.firstChild();
-
- int x_min = INT_MAX;
- int y_min = INT_MAX;
-
- while (!point.isNull())
- {
- int x = point.toElement().attribute("x", "0").toInt();
- int y = point.toElement().attribute("y", "0").toInt();
-
- if (x < x_min)
- x_min = x;
-
- if (y < y_min)
- y_min = y;
-
- point = point.nextSibling();
- }
-
- QString text = line.toElement().attribute("text", "");
- QFont font("Times");
- font.setPixelSize(a_height + d_height);
- QGraphicsTextItem* text_item = scene_->addText(text, font);
- text_item->setPos(x_min, y_min);
- text_item->setTextInteractionFlags(Qt::TextSelectableByMouse);
- text_item->setZValue(5);
- text_vector_ << text_item;
- if (!text_)
- scene_->removeItem(text_item);
-
-}
-
-void
-Viewer::add_region(QDomNode father, QString attr_id)
-{
- QDomNode coords = father.firstChild();
- QString name = father.toElement().tagName();
- region::RegionId id = static_cast<region::RegionId>(region_ids_[name]);
-
- while (!coords.isNull() && !coords.toElement().tagName().contains("Coords"))
- coords = coords.nextSibling();
-
- if (coords.isNull())
- {
- qDebug() << "Warning : add_region - region without coordinates";
- return;
- }
-
- QDomNode point = coords.firstChild();
- QVector<QPoint> points;
-
- while (!point.isNull())
- {
- int x = point.toElement().attribute("x", "0").toInt();
- int y = point.toElement().attribute("y", "0").toInt();
-
- points << QPoint(x, y);
- point = point.nextSibling();
- }
-
- ImageRegion* r = new ImageRegion(id,
- key_map_[id].first,
- key_map_[id].second,
- attr_id, points,
- outline_action_->isChecked(),
- fill_action_->isChecked(),
- precise_action_->isChecked(),
- key_wgt_->isChecked(id));
-
- connect(this, SIGNAL(key_updated(int, bool)),
- r, SLOT(setDrawIfSameId(int, bool)));
- connect(this, SIGNAL(setOutline(bool)),
- r, SLOT(setOutline(bool)));
- connect(this, SIGNAL(setPrecise(bool)),
- r, SLOT(setPrecise(bool)));
- connect(this, SIGNAL(setFill(bool)),
- r, SLOT(setFill(bool)));
-
- scene_->addItem(r);
-}
-
-
-void
-Viewer::add_typo_lines(QDomNode father, QString attr_id)
-{
- // Retrieve typographical information
- int baseline = father.toElement().attribute("baseline").toInt();
- int meanline = father.toElement().attribute("meanline").toInt();
-
- QRect bbox;
-
- // Looking for bbox coordinates.
- {
- QDomNode coords = father.firstChild();
- while (!coords.isNull() && !coords.toElement().tagName().contains("Coords"))
- coords = coords.nextSibling();
-
- if (coords.isNull())
- return;
-
-
- QDomNode point = coords.firstChild();
- QVector<QPoint> points;
-
- while (!point.isNull())
- {
- int x = point.toElement().attribute("x", "0").toInt();
- int y = point.toElement().attribute("y", "0").toInt();
-
- points << QPoint(x, y);
- point = point.nextSibling();
- }
-
- QPolygon polygon(points);
- bbox = polygon.boundingRect();
- }
-
- // Creating blocks
-
- // Baseline
- {
- QVector<QPoint> points;
- points.append(QPoint(bbox.topLeft().x(), baseline));
- points.append(QPoint(bbox.topRight().x(), baseline));
-
- ImageRegion* r = new ImageRegion(region::Baseline,
- key_map_[region::Baseline].first,
- key_map_[region::Baseline].second,
- attr_id, points,
- outline_action_->isChecked(),
- fill_action_->isChecked(),
- precise_action_->isChecked(),
- key_wgt_->isChecked(region::Baseline));
-
- connect(this, SIGNAL(key_updated(int, bool)),
- r, SLOT(setDrawIfSameId(int, bool)));
- connect(this, SIGNAL(setOutline(bool)),
- r, SLOT(setOutline(bool)));
- connect(this, SIGNAL(setPrecise(bool)),
- r, SLOT(setPrecise(bool)));
- connect(this, SIGNAL(setFill(bool)),
- r, SLOT(setFill(bool)));
-
- scene_->addItem(r);
- }
-
- // Meanline
- {
- QVector<QPoint> points;
- points.append(QPoint(bbox.topLeft().x(), meanline));
- points.append(QPoint(bbox.topRight().x(), meanline));
-
- ImageRegion* r = new ImageRegion(region::Meanline,
- key_map_[region::Meanline].first,
- key_map_[region::Meanline].second,
- attr_id, points,
- outline_action_->isChecked(),
- fill_action_->isChecked(),
- precise_action_->isChecked(),
- key_wgt_->isChecked(region::Meanline));
-
- connect(this, SIGNAL(key_updated(int, bool)),
- r, SLOT(setDrawIfSameId(int, bool)));
- connect(this, SIGNAL(setOutline(bool)),
- r, SLOT(setOutline(bool)));
- connect(this, SIGNAL(setPrecise(bool)),
- r, SLOT(setPrecise(bool)));
- connect(this, SIGNAL(setFill(bool)),
- r, SLOT(setFill(bool)));
-
- scene_->addItem(r);
- }
-}
-
-
-void
-Viewer::load_xml(QString filename)
-{
- app_->setOverrideCursor(QCursor(Qt::WaitCursor));
- emit fill_xml(filename);
-
- if (image_ && image_->scene() && image_->scene() == scene_)
- scene_->removeItem(image_);
-
- text_vector_.clear();
- image_vector_.clear();
- scene_->clear();
-
- if (!base64_ && use_image_ && image_)
- scene_->addItem(image_);
-
- scene_->update();
-
- xml_file_ = filename;
- QFile f_in(xml_file_);
- f_in.open(QIODevice::ReadOnly);
-
- QDomDocument doc;
- doc.setContent(&f_in);
- f_in.close();
-
- QDomElement root = doc.documentElement();
- QDomNode page = root.firstChild();
-
- while (!page.isNull() && !page.toElement().tagName().contains("Page"))
- page = page.nextSibling();
-
- if (page.isNull())
- return;
-
- int width = page.toElement().attribute("imageWidth", "none").toInt();
- int height = page.toElement().attribute("imageHeight", "none").toInt();
-
- scene_->setSceneRect(0, 0, width, height);
-
- QDomNode region = page.firstChild();
-
- while (!region.isNull())
- {
- if (region.toElement().tagName().contains(QRegExp("(WhitespaceSeparator|Image|Graphic|Chart|Separator|Table|Text)Region")))
- {
- QString attr_id = region.toElement().attribute("id", "none");
- add_region(region, attr_id);
-
- if ( base64_ &&
- region.toElement().tagName().contains(QRegExp("(Image|Graphic|Chart|Separator|Table)Region")))
- {
- QDomNode container = region.firstChild();
-
- while (!container.isNull() && !container.toElement().tagName().contains("container"))
- container = container.nextSibling();
-
- QDomNode coords = region.firstChild();
-
- while (!coords.isNull() && !coords.toElement().tagName().contains("Coords"))
- coords = coords.nextSibling();
-
- if (!container.isNull() && !coords.isNull())
- {
- QDomNode child = container.firstChild();
-
- while (!child.isNull() && !child.toElement().tagName().contains("data"))
- child = child.nextSibling();
-
- QPixmap pix;
- QString data = child.toElement().text();
- QByteArray ba;
- ba = ba.append(data);
- QByteArray out_ba = QByteArray::fromBase64(ba);
- pix.loadFromData(out_ba);
-
- QGraphicsPixmapItem* image = new QGraphicsPixmapItem(pix);
-
- QDomNode point = coords.firstChild();
-
- int x_min = INT_MAX;
- int y_min = INT_MAX;
-
- while (!point.isNull())
- {
- int x = point.toElement().attribute("x", "0").toInt();
- int y = point.toElement().attribute("y", "0").toInt();
-
- if (x < x_min)
- x_min = x;
-
- if (y < y_min)
- y_min = y;
-
- point = point.nextSibling();
- }
-
- image->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
- image->setZValue(0);
- image->setOffset(x_min, y_min);
- if (use_image_)
- scene_->addItem(image);
- image_vector_ << image;
-
- if (no_cache_)
- image->setCacheMode(QGraphicsItem::NoCache);
- else
- image->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
-
- child = child.nextSibling();
- }
- }
-
- if (region.toElement().tagName().contains("TextRegion"))
- {
- QDomNode line = region.firstChild();
-
- do
- {
- while (!line.isNull() && !line.toElement().tagName().contains("Line"))
- line = line.nextSibling();
-
- if (!line.isNull())
- {
- if (extended_mode_)
- {
- QString line_id = line.toElement().attribute("id", "none");
- add_region(line, line_id);
- add_typo_lines(line, line_id);
- }
- add_text(line);
- }
- }
- while (!(line = line.nextSiblingElement("Line")).isNull());
- }
- }
-
- region = region.nextSibling();
- }
-
- //emit updated();
- scene_->update();
- key_wgt_->update_all();
-
- app_->restoreOverrideCursor();
-}
-
-void
-Viewer::load(QString filename, bool b)
-{
- app_->setOverrideCursor(QCursor(Qt::WaitCursor));
-
- scene_->clear();
- text_vector_.clear();
- image_vector_.clear();
- scene_->update();
- image_ = 0;
- xml_file_ = QString::Null();
-
- // Load the image in a pixmap that is directly shown on screen.
- // This is very slow when used with the normal rendering system.
- // OpenGL might speed up things a bit.
- if (b)
- image_ = new QGraphicsPixmapItem(load_base64(filename));
- else
- image_ = new QGraphicsPixmapItem(QPixmap(filename));
-
- current_image_ = filename;
-
- image_->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
- image_->setZValue(0);
- if (use_image_)
- scene_->addItem(image_);
-
- if (no_cache_)
- image_->setCacheMode(QGraphicsItem::NoCache);
- else
- image_->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
-
- app_->restoreOverrideCursor();
- emit updated();
-
- app_->restoreOverrideCursor();
-}
-
-int
-Viewer::exec()
-{
- win_->show();
- return app_->exec();
-}
-
-void
-Viewer::help()
-{
- HelpDialog dlg;
- dlg.exec();
-}
-
-void
-Viewer::maybeChangeCacheMode(qreal scale)
-{
- if (image_)
- {
- if (scale >= 0.7)
- image_->setCacheMode(QGraphicsItem::NoCache);
- else if (!no_cache_)
- image_->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- }
-}
-
-void Viewer::useExtended(bool b)
-{
- extended_mode_ = b;
- key_wgt_->update_all();
-
- if (xml_file_ != QString::Null())
- load_xml(xml_file_);
-
- emit mode_changed(b);
-}
-
-void
-Viewer::useCache(bool b)
-{
- no_cache_ = b;
- if (b)
- {
- if (image_)
- image_->setCacheMode(QGraphicsItem::NoCache);
- }
- else
- if (image_)
- image_->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
-}
-
-QPixmap Viewer::load_base64(QString xml)
-{
- QPixmap pix;
- QFile f_in(xml);
- f_in.open(QIODevice::ReadOnly);
-
- QDomDocument doc;
- doc.setContent(&f_in);
- f_in.close();
-
- QDomElement root = doc.documentElement();
- QDomNode child = root.firstChild();
-
- while (!child.isNull() && !child.toElement().tagName().contains("Page"))
- child = child.nextSibling();
-
- child = child.firstChild();
- while (!child.isNull())
- {
- if (child.toElement().tagName().contains(QRegExp("ImageRegion")))
- {
- QDomNode node = child.firstChild();
- QString id = child.toElement().attribute("id", "none");
-
- while (!node.isNull() && !node.toElement().tagName().contains("container"))
- node = node.nextSibling();
-
- if (!node.isNull())
- {
- QString data = node.firstChildElement("data").text();
- QByteArray ba;
- ba = ba.append(data);
- QByteArray out_ba = QByteArray::fromBase64(ba);
- pix.loadFromData(out_ba);
-
- return pix;
- }
- }
- child = child.nextSibling();
- }
-
- return pix;
-}
-
-void
-Viewer::useText(bool b)
-{
- text_ = b;
- if (!b)
- {
- for (int i = 0; i < text_vector_.size(); ++i)
- scene_->removeItem(text_vector_[i]);
- }
- else
- {
- for (int i = 0; i < text_vector_.size(); ++i)
- scene_->addItem(text_vector_[i]);
- }
-
- scene_->update();
-}
-
-void
-Viewer::useImage(bool b)
-{
- use_image_ = b;
- if (!b)
- {
- if (image_ && image_->scene() && image_->scene() == scene_)
- scene_->removeItem(image_);
-
- for (int i = 0; i < image_vector_.size(); ++i)
- scene_->removeItem(image_vector_[i]);
- }
- else
- {
- if (image_ && image_->scene() == 0)
- scene_->addItem(image_);
-
- for (int i = 0; i < image_vector_.size(); ++i)
- scene_->addItem(image_vector_[i]);
- }
-
- scene_->update();
-}
-
-void
-Viewer::change_base(bool b)
-{
- base64_ = b;
-}
-
-
-QAction
-*Viewer::create_action(QString name, QMenu *menu, QString status, QString shortcut)
-{
- QAction* action = new QAction(name, menu);
- action->setStatusTip(status);
- action->setShortcut(QKeySequence(shortcut));
-
- return (action);
-}
-
-void
-Viewer::on_preferences()
-{
- preferences_dialog *win = new preferences_dialog(win_);
- win->show();
-}
-
-
-void
-Viewer::run_process()
-{
- if (!current_image_.isEmpty())
- {
- reset_progress_dialog();
- runner_.start_demat(current_image_);
- }
-}
-
-
-void
-Viewer::run_progress()
-{
- pdialog_.setValue(pdialog_.value() + 1);
-}
-
-
-void
-Viewer::on_xml_saved(const QString& filename)
-{
- config * const conf = config::get_instance();
-
- if (!conf->general_save_xml_enabled())
- tmp_files_to_remove_.insert(filename);
-
- QListWidgetItem *item = step_widget_->insert_new_entry(filename);
- step_widget_->activate(item);
-}
-
-
-void
-Viewer::export_as()
-{
- QFileInfo f(browser_wgt_->current());
- QString output_suggestion = f.baseName() + ".pdf";
- QString output = QFileDialog::getSaveFileName(0, "Export document as...", output_suggestion, tr("PDF (*.pdf);; HTML (*.html *.htm)"));
-
- if (!output.isEmpty())
- {
- reset_progress_dialog();
- runner_.start_export(browser_wgt_->current(), step_widget_->current(), output);
- qDebug() << "Saving to " << output << " - " << browser_wgt_->current() << " - " << step_widget_->current();
- }
-}
-
-
-void
-Viewer::reset_progress_dialog()
-{
- pdialog_.setValue(0);
- pdialog_.setLabelText("");
- pdialog_.show();
-}
-
-
-void
-Viewer::print()
-{
- QPrinter printer(QPrinter::HighResolution);
- configure_printer(printer);
-
- QPrintDialog dialog(&printer);
- dialog.setWindowTitle(tr("Print Document"));
- if (dialog.exec() != QDialog::Accepted)
- return;
-
- do_print(&printer);
-}
-
-void
-Viewer::preview_print()
-{
- QPrinter printer(QPrinter::HighResolution);
- configure_printer(printer);
-
- QPrintPreviewDialog preview(&printer);
- connect(&preview, SIGNAL(paintRequested(QPrinter *)),
- this, SLOT(do_print(QPrinter *)));
-
- preview.exec();
-}
-
-void Viewer::do_print(QPrinter * printer)
-{
- QList<QGraphicsItem *> items = image_wgt_->view()->items();
-
- QPainter painter(printer);
-
- QGraphicsItem *item;
- QStyleOptionGraphicsItem options;
-
- // Painting backward objects first.
- for (int i = items.size() - 1; i >= 0; --i)
- {
- item = items.at(i);
-
- if (item != image_)
- {
- QRect vport = image_->mapRectFromItem(item,
- item->boundingRect()).toRect();
-
- painter.translate(std::abs(item->boundingRect().x() - vport.x()),
- std::abs(item->boundingRect().y() - vport.y()));
- }
-
-
- item->paint(&painter, &options);
- painter.resetTransform();
- }
-}
-
-void
-Viewer::configure_printer(QPrinter& printer)
-{
- printer.setPageSize(QPrinter::A4);
- printer.setResolution(300);
-}
diff --git a/scribo/demo/viewer/viewer.hh b/scribo/demo/viewer/viewer.hh
deleted file mode 100644
index c68dd02..0000000
--- a/scribo/demo/viewer/viewer.hh
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright (C) 2010, 2011 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_VIEWER_HH
-# define SCRIBO_DEMO_VIEWER_VIEWER_HH
-
-# include <QtGui>
-# include <QDomNode>
-# include "common.hh"
-# include "runner.hh"
-# include "image_widget.hh"
-
-class ImageScene;
-class DomModel;
-class KeyWidget;
-class ImageRegion;
-class StepWidget;
-class BrowserWidget;
-
-
-class Viewer
- : public QObject
-{
- Q_OBJECT
-
-public:
- ~Viewer();
-
- static Viewer* Instance(int &argc, char** argv);
-
- int exec();
-
-public slots:
- // Load the file as an image, load the layout if xml with the same
- // name is found.
- void load(QString filename, bool b);
- void help();
- void load_xml(QString filename);
- void maybeChangeCacheMode(qreal scale);
- void useCache(bool b);
- void useExtended(bool b);
- void useText(bool b);
- void useImage(bool b);
- void change_base(bool b);
-
-private slots:
- void on_preferences();
- void run_process();
- void run_progress();
- void on_xml_saved(const QString& filename);
- void export_as();
- void print();
- void preview_print();
- void do_print(QPrinter * printer);
-
-signals:
- void updated();
- void key_updated(int key, bool checked);
- void setOutline(bool b);
- void setPrecise(bool b);
- void setFill(bool b);
- void mode_changed(bool b);
- void fill_xml(QString);
-
-private:
- Viewer(int &argc, char** argv);
- Viewer();
-
- void xml_to_layout();
- QPixmap load_base64(QString xml);
- void add_region(QDomNode father, QString attr_id);
- void add_text(QDomNode line);
- void add_typo_lines(QDomNode father, QString attr_id);
- QAction *create_action(QString name, QMenu* menu, QString status, QString shortcut);
- void reset_progress_dialog();
- void configure_printer(QPrinter& printer);
-
- QApplication* app_;
- QMainWindow* win_;
- StepWidget* step_widget_;
- BrowserWidget* browser_wgt_;
-
- QGraphicsPixmapItem* image_;
-
- ImageScene* scene_;
- ImageWidget* image_wgt_;
- QDirModel* files_;
- DomModel* doc_layout_;
-
- QAction* outline_action_;
- QAction* fill_action_;
- QAction* precise_action_;
- QAction *export_action_;
-
- KeyWidget* key_wgt_;
-
- QMap<QString, int> region_ids_;
- region::KeyMap key_map_;
-
- bool no_cache_;
- bool extended_mode_;
- QString xml_file_;
- bool base64_;
- bool text_;
- bool use_image_;
- QVector<QGraphicsTextItem *> text_vector_;
- QVector<QGraphicsPixmapItem*> image_vector_;
- QString current_image_;
-
- QProgressDialog pdialog_;
- runner runner_;
-
- QSet<QString> tmp_files_to_remove_;
-};
-
-#include "viewer.hxx"
-
-#endif // ! SCRIBO_DEMO_VIEWER_VIEWER_HH
diff --git a/scribo/demo/viewer/viewer.hxx b/scribo/demo/viewer/viewer.hxx
deleted file mode 100644
index cba59f3..0000000
--- a/scribo/demo/viewer/viewer.hxx
+++ /dev/null
@@ -1,38 +0,0 @@
-// 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/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef VIEWER_HXX_
-# define VIEWER_HXX_
-
-# include "viewer.hh"
-
-inline Viewer* Viewer::Instance(int &argc, char** argv)
-{
- static Viewer viewer(argc, argv);
-
- return &viewer;
-}
-
-#endif /* !VIEWER_HXX_ */
diff --git a/scribo/demo/viewer/viewer.qrc b/scribo/demo/viewer/viewer.qrc
deleted file mode 100644
index c64fdcc..0000000
--- a/scribo/demo/viewer/viewer.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="icons">
- <file>icons/olena_smaller.jpg</file>
- </qresource>
-</RCC>
diff --git a/scribo/demo/viewer/xml.cc b/scribo/demo/viewer/xml.cc
new file mode 100644
index 0000000..74c9112
--- /dev/null
+++ b/scribo/demo/viewer/xml.cc
@@ -0,0 +1,253 @@
+// Copyright (C) 2013 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 "xml.hh"
+
+Xml::Xml(const QString& filename)
+{
+ load(filename);
+}
+
+QString Xml::getPath(const QString& filename)
+{
+ Configs *const configs = Configs::getInstance();
+
+ QString xmlPath = filename;
+
+ // Get xml filename from image path.
+ xmlPath.remove(0, xmlPath.lastIndexOf('/')+1);
+ int pos = xmlPath.lastIndexOf('.');
+ xmlPath.remove(pos, xmlPath.length()-pos);
+ xmlPath += "_gui.xml";
+
+ return configs->generalSaveXmlCustomDirPath() + "/" + xmlPath;
+}
+
+void Xml::isRecognized(const QDomElement& textElement)
+{
+ QDomElement lineElement = textElement.firstChild().nextSiblingElement("Line");
+
+ // Check if the attributes "text" exists in the attributes of line in the xml file.
+ isRecognized_ = lineElement.attributeNode("text").isNull() ? false : true;
+}
+
+void Xml::load(const QString& filename)
+{
+ if(filename.isEmpty())
+ {
+ xmlItem_ = 0;
+ graphicsItem_ = 0;
+ filename_ = QString();
+ isRecognized_ = false;
+ return;
+ }
+
+ // Reset graphic and tree items;
+ xmlItem_ = new XmlItem;
+ graphicsItem_ = new RootGraphicsItem(13);
+ filename_ = getPath(filename);
+
+ QFile xmlFile(filename);
+ xmlFile.open(QIODevice::ReadOnly);
+
+ // Fill new xml tree.
+ xml_.clear();
+ xml_.setContent(&xmlFile);
+
+ xmlFile.close();
+
+ QDomElement root = xml_.documentElement();
+ xmlItem_->load(root);
+ xmlItem_->show();
+
+ root = root.firstChild().toElement();
+ XmlItem *parentTreeItem = init(root, xmlItem_);
+
+ // Run through the xml file structure by structure.
+ root = root.nextSibling().firstChild().toElement();
+ // Check if the xml file has been recognized by the ocr or not.
+ isRecognized(root);
+
+ processNode(root, datas_[0], parentTreeItem);
+ for(int i = 2; i < 11; i++)
+ processNode(root.nextSiblingElement(datas_[i].name), datas_[i], parentTreeItem);
+}
+
+XmlItem *Xml::init(const QDomElement& root, XmlItem *rootTreeItem)
+{
+ XmlItem *metadataItem = new XmlItem(root, rootTreeItem);
+
+ XmlItem *contentItem = 0;
+
+ // Run through "METADATA" node and subnodes.
+ QDomElement node = root.firstChild().toElement();
+ while(!node.isNull())
+ {
+ contentItem = new XmlItem(node, metadataItem, contentItem);
+ node = node.nextSibling().toElement();
+ }
+
+ // Add "PAGE" root node and return it.
+ metadataItem = new XmlItem(root.nextSibling().toElement(), rootTreeItem, metadataItem);
+ metadataItem->show();
+
+ return metadataItem;
+}
+
+void Xml::processNode(const QDomElement& root, const GraphicsRegion::Data& data, XmlItem *pageItem)
+{
+ if(!root.isNull())
+ {
+ // Create corresponding tree item.
+ XmlItem *regionItem = new XmlItem(root, pageItem);
+
+ QDomElement node = root.firstChild().toElement();
+ XmlItem *coordsItem = new XmlItem(node, regionItem);
+
+ QPolygon polygon;
+ XmlItem *pointItem = 0;
+ QString x, y;
+
+ // Run through all points data.
+ node = node.firstChild().toElement();
+ while(!node.isNull())
+ {
+ x = node.attribute("x", "null");
+ y = node.attribute("y", "null");
+
+ pointItem = new XmlItem(node, coordsItem, pointItem);
+
+ polygon << QPoint(x.toInt(), y.toInt());
+ node = node.nextSibling().toElement();
+ }
+
+ // Create the graphics item from data structure.
+ RegionItem *graphicsItem = new RegionItem(polygon, graphicsItem_);
+ graphicsItem->loadData(data);
+ graphicsItem_->addItemFrom(graphicsItem, data.region);
+
+ // Store xml item and graphics item in each object for selection.
+ regionItem->setRegionItem(graphicsItem);
+ graphicsItem->setXmlItem(regionItem);
+
+ if(data.region == GraphicsRegion::TextRegion)
+ processLineNode(root.firstChild().nextSiblingElement("Line"), coordsItem);
+
+ // Run through all nodes from the same data structure recursively.
+ processNode(root.nextSiblingElement(data.name), data, pageItem);
+ }
+}
+
+void Xml::processLineNode(const QDomElement& root, XmlItem *precItem)
+{
+ if(!root.isNull())
+ {
+ // Create corresponding tree item.
+ XmlItem *lineItem = new XmlItem(root, precItem->parent(), precItem);
+
+ QDomElement node = root.firstChild().toElement();
+ XmlItem *coordsItem = new XmlItem(node, lineItem);
+
+ QPolygon polygon;
+ XmlItem *pointItem = 0;
+
+ QString xs, ys;
+ int x, y;
+
+ int xMin = INT_MAX;
+ int xMax = INT_MIN;
+
+ // Run through all points data.
+ node = node.firstChild().toElement();
+ while(!node.isNull())
+ {
+ xs = node.attribute("x", "null");
+ ys = node.attribute("y", "null");
+
+ pointItem = new XmlItem(node, coordsItem, pointItem);
+
+ x = xs.toInt();
+ y = ys.toInt();
+
+ // Get beginning and end of line.
+ if(xMin > x)
+ xMin = x;
+ if(xMax < x)
+ xMax = x;
+
+ polygon << QPoint(x, y);
+ node = node.nextSibling().toElement();
+ }
+
+ // Create the graphics item from data structure.
+ RegionItem *graphicsItem = new RegionItem(polygon, graphicsItem_);
+ graphicsItem->loadData(datas_[1]);
+ graphicsItem_->addItemFrom(graphicsItem, datas_[1].region);
+
+ // Store xml item and graphics item in each object for selection.
+ lineItem->setRegionItem(graphicsItem);
+ graphicsItem->setXmlItem(lineItem);
+
+ // Get meanline and baseline.
+ processTypoNode(root, QPoint(xMin, xMax));
+ // Run through all line nodes recursively.
+ processLineNode(root.nextSiblingElement(datas_[1].name), lineItem);
+ }
+}
+
+void Xml::processTypoNode(const QDomElement& root, const QPoint& xPoint)
+{
+ int yPos = root.attribute("baseline", "null").toInt();
+ QGraphicsLineItem *baselineItem = new QGraphicsLineItem(QLine(QPoint(xPoint.x(), yPos), QPoint(xPoint.y(), yPos)));
+ baselineItem->setZValue(datas_[11].zValue);
+ graphicsItem_->addItemFrom(baselineItem, datas_[11].region);
+
+ yPos = root.attribute("meanline", "null").toInt();
+ QGraphicsLineItem *meanlineItem = new QGraphicsLineItem(QLine(QPoint(xPoint.x(), yPos), QPoint(xPoint.y(), yPos)));
+ meanlineItem->setZValue(datas_[12].zValue);
+ graphicsItem_->addItemFrom(meanlineItem, datas_[12].region);
+}
+
+
+XmlItem *Xml::xmlItem()
+{
+ return xmlItem_;
+}
+
+RootGraphicsItem *Xml::graphicsItem()
+{
+ return graphicsItem_;
+}
+
+QDomDocument Xml::document() const
+{
+ return xml_;
+}
+
+QString Xml::filename() const
+{
+ return filename_;
+}
+
+GraphicsRegion::Data Xml::dataFromRegion(GraphicsRegion::Id region)
+{
+ return datas_[region];
+}
+
+bool Xml::recognized() const
+{
+ return isRecognized_;
+}
diff --git a/scribo/demo/viewer/xml.hh b/scribo/demo/viewer/xml.hh
new file mode 100644
index 0000000..c5f59d4
--- /dev/null
+++ b/scribo/demo/viewer/xml.hh
@@ -0,0 +1,91 @@
+// Copyright (C) 2013 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 XML_HH
+# define XML_HH
+
+#include <QTreeWidgetItem>
+#include <QGraphicsItem>
+#include <QStringList>
+#include <QDomElement>
+#include <QDomAttr>
+#include <climits>
+#include <QFile>
+
+#include "Rendering/rootgraphicsitem.hh"
+#include "Rendering/regionitem.hh"
+#include "XmlWidget/xmlitem.hh"
+#include "variantpointer.hh"
+#include "configs.hh"
+#include "region.hh"
+
+// WARNING : The order is VERY IMPORTANT (depending on the enum).
+static const GraphicsRegion::Data datas_[] =
+{
+ /* COLOR | NAME | REGION | PARENT | Z */
+ { QColor::fromRgb(0, 100, 0, 110), "TextRegion", GraphicsRegion::TextRegion, GraphicsRegion::Text, 1 },
+ { QColor::fromRgb(255, 0, 0, 110), "Line", GraphicsRegion::Line, GraphicsRegion::Text, 2 },
+ { QColor::fromRgb(0, 0, 255, 110), "VerticalSeparatorRegion", GraphicsRegion::VerticalSeparator, GraphicsRegion::Separators, 2 },
+ { QColor::fromRgb(0, 0, 255, 110), "HorizontalSeparatorRegion", GraphicsRegion::HorizontalSeparator, GraphicsRegion::Separators, 2 },
+ { QColor::fromRgb(0, 0, 128, 110), "WhitespaceSeparatorRegion", GraphicsRegion::WhiteSpaceSeparator, GraphicsRegion::Separators, 2 },
+ { QColor::fromRgb(255, 120, 0, 110), "ImageRegion", GraphicsRegion::Image, GraphicsRegion::Miscellaneous, 1 },
+ { QColor::fromRgb(43, 39, 128, 110), "NoiseRegion", GraphicsRegion::Noise, GraphicsRegion::Miscellaneous, 2 },
+ { QColor::fromRgb(220, 246, 0, 110), "TableRegion", GraphicsRegion::Table, GraphicsRegion::Miscellaneous, 2 },
+ { QColor::fromRgb(170, 0, 255, 110), "MathsRegion", GraphicsRegion::Maths, GraphicsRegion::Miscellaneous, 2 },
+ { QColor::fromRgb(255, 0, 144, 110), "GraphicsRegion", GraphicsRegion::Graphic, GraphicsRegion::Miscellaneous, 2 },
+ { QColor::fromRgb(0, 204, 255, 110), "ChartRegion", GraphicsRegion::Chart, GraphicsRegion::Miscellaneous, 2 },
+ { QColor::fromRgb(128, 0, 255), "Baseline", GraphicsRegion::Baseline, GraphicsRegion::Typology, 3 },
+ { QColor::fromRgb(128, 0, 255), "Meanline", GraphicsRegion::Meanline, GraphicsRegion::Typology, 3 },
+ { QColor::fromRgb(255, 255, 255), "Text", GraphicsRegion::Text, GraphicsRegion::None, 0 },
+ { QColor::fromRgb(255, 255, 255), "Separators", GraphicsRegion::Separators, GraphicsRegion::None, 0 },
+ { QColor::fromRgb(255, 255, 255), "Miscellaneous", GraphicsRegion::Miscellaneous, GraphicsRegion::None, 0 },
+ { QColor::fromRgb(255, 255, 255), "Typological Lines", GraphicsRegion::Typology, GraphicsRegion::None, 0 }
+};
+
+class Xml
+{
+public:
+ explicit Xml(const QString& filename = QString());
+
+ XmlItem *xmlItem();
+ RootGraphicsItem *graphicsItem();
+
+ QDomDocument document() const;
+ QString filename() const;
+ bool recognized() const;
+
+ static QString getPath(const QString& filename);
+
+ void load(const QString& filename);
+ static GraphicsRegion::Data dataFromRegion(GraphicsRegion::Id region);
+
+private:
+ XmlItem *init(const QDomElement& root, XmlItem *rootTreeItem);
+ void isRecognized(const QDomElement& element);
+
+ void processNode(const QDomElement& root, const GraphicsRegion::Data& data, XmlItem *rootTreeItem);
+ void processLineNode(const QDomElement& root, XmlItem *rootTreeItem);
+ void processTypoNode(const QDomElement& root, const QPoint& xPoint);
+
+ RootGraphicsItem *graphicsItem_;
+ XmlItem *xmlItem_;
+
+ QDomDocument xml_;
+ QString filename_;
+ bool isRecognized_;
+};
+
+#endif // XML_HH
diff --git a/scribo/demo/viewer/xml_widget.cc b/scribo/demo/viewer/xml_widget.cc
deleted file mode 100644
index 642cf9a..0000000
--- a/scribo/demo/viewer/xml_widget.cc
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright (C) 2010, 2011 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 "xml_widget.hh"
-
-XmlWidget::XmlWidget()
- : tree_(new QTreeWidget()),
- property_(new QTreeWidget())
-{
- QLabel* title = new QLabel(tr("XML"));
- title->setAlignment(Qt::AlignHCenter);
-
- tree_->setHeaderHidden(true);
-
- QVBoxLayout* layout = new QVBoxLayout;
- QHBoxLayout *hlayout = new QHBoxLayout;
-
- QStringList header_names;
- header_names << tr("Name") << tr("Value");
- property_->setHeaderItem(new QTreeWidgetItem(header_names));
-
- hlayout->addWidget(tree_);
- hlayout->addWidget(property_);
-
- layout->addWidget(title);
- layout->addLayout(hlayout);
-
- setLayout(layout);
-
- connect(tree_, SIGNAL(itemDoubleClicked (QTreeWidgetItem*, int)),
- this, SLOT(check_item (QTreeWidgetItem*) ) );
-}
-
-void
-XmlWidget::select(QString id, QString /*name*/)
-{
- QDomNode n = node_map_[item_map_[id]];
-
- if (!n.isNull())
- {
- QTreeWidgetItem* item = node_map_.key(n);
-
- tree_->setCurrentItem(item, 0);
- item->setExpanded(true);
- check_item(item);
- }
-}
-
-void
-XmlWidget::check_item (QTreeWidgetItem* item)
-{
- QDomNode node = node_map_[item];
-
- if (node.hasAttributes())
- {
- property_->clear();
- QDomNamedNodeMap attributes = node.toElement().attributes();
-
- for (int i = 0; i < attributes.count(); ++i)
- {
- QStringList values;
- values << attributes.item(i).toAttr().name() << attributes.item(i).toAttr().value();
- property_->addTopLevelItem(new QTreeWidgetItem(values));
- }
- }
-
- property_->resizeColumnToContents(0);
-}
-
-void XmlWidget::NFS(QDomNode node, QTreeWidgetItem* item)
-{
- if (!node.isNull())
- {
- QString append;
- if (node.toElement().tagName().contains("Point"))
- {
- QString x = node.toElement().attribute("x", "0");
- QString y = node.toElement().attribute("y", "0");
- append.append(" = (" + x + ", " + y + ")");
- }
-
- QTreeWidgetItem* child =
- new QTreeWidgetItem(QStringList(node.toElement().tagName() + node.nodeValue() + append));
-
- if (node.hasAttributes())
- {
- QString id = node.toElement().attribute("id", "none");
- item_map_[id] = child;
- }
-
- node_map_[child] = node;
- item->addChild(child);
-
- QDomNode sibling = node.firstChild();
- while (!sibling.isNull())
- {
- if (!sibling.toElement().tagName().contains("data"))
- NFS(sibling, child);
- else
- {
- QTreeWidgetItem* child_son =
- new QTreeWidgetItem(QStringList("data = base64-encoded"));
-
- child->addChild(child_son);
- }
- sibling = sibling.nextSibling();
- }
- }
-}
-
-void XmlWidget::fill_widget(QString xml)
-{
- node_map_.clear();
- item_map_.clear();
-
- tree_->clear();
- property_->clear();
- QFile f_in(xml);
- f_in.open(QIODevice::ReadOnly);
-
- QDomDocument doc;
- doc.setContent(&f_in);
- f_in.close();
-
- int i = 0;
-
- QDomElement root = doc.documentElement();
- QTreeWidgetItem* root_item=
- new QTreeWidgetItem(QStringList(root.tagName()));
-
- tree_->addTopLevelItem(root_item);
- root = root.firstChild().toElement();
-
- while (!root.isNull())
- {
- ++i;
- NFS(root, root_item);
- root = root.nextSibling().toElement();
- }
-}
-
-void
-XmlWidget::deselect()
-{
- property_->clear();
-}
-
-XmlWidget::~XmlWidget()
-{
-}
diff --git a/scribo/demo/viewer/xml_widget.hh b/scribo/demo/viewer/xml_widget.hh
deleted file mode 100644
index b7cd868..0000000
--- a/scribo/demo/viewer/xml_widget.hh
+++ /dev/null
@@ -1,48 +0,0 @@
-// 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_XML_WIDGET_HH
-# define SCRIBO_DEMO_VIEWER_XML_WIDGET_HH
-
-# include <QtGui>
-# include <QDomNode>
-
-class DomModel;
-
-class XmlWidget
- : public QWidget
-{
- Q_OBJECT
-
-public:
- XmlWidget();
- ~XmlWidget();
-
-public slots:
- void select(QString id, QString name);
- void deselect();
- void fill_widget(QString xml);
- void check_item (QTreeWidgetItem* item);
-
-private:
- void NFS(QDomNode node, QTreeWidgetItem* item);
- QTreeWidget* tree_;
- QTreeWidget* property_;
- QMap<QString, QTreeWidgetItem*> item_map_;
- QMap<QTreeWidgetItem*, QDomNode> node_map_;
-};
-
-#endif // ! SCRIBO_DEMO_VIEWER_XML_WIDGET_HH
--
1.7.2.5
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/TL has been updated
via 7f27ebc5b750a3e9d59827823b0b30076e5994c8 (commit)
via f8e6233302741208eb78a51e9f0c8655115422fc (commit)
via fe3d6d46aa9357d3db8fdbe118d421faf6b540cd (commit)
from afa987bad716e6ff5afcb1e1a23a04af6d269cdc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
7f27ebc Merge branch 'exp/all-blobs' into exp/TL
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 22 +++++
milena/mln/canvas/labeling/blobs.hh | 136 ++++++++++++++++++++++++++--
milena/mln/core/internal/pixel_impl.hh | 6 ++
milena/mln/labeling/all_blobs.hh | 127 --------------------------
milena/mln/labeling/blobs.hh | 65 ++++++++++----
milena/mln/labeling/blobs_and_compute.hh | 83 +++++++++++++++--
milena/tests/labeling/Makefile.am | 1 -
milena/tests/labeling/all_blobs.cc | 63 -------------
milena/tests/labeling/blobs.cc | 26 +++++-
milena/tests/labeling/blobs_and_compute.cc | 55 ++++++++---
10 files changed, 339 insertions(+), 245 deletions(-)
delete mode 100644 milena/mln/labeling/all_blobs.hh
delete mode 100644 milena/tests/labeling/all_blobs.cc
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/viewer-new has been updated
discards c3550ec3eef049edfb394f5b7d8415e1eec74b27 (commit)
discards d17f8e48fecf710e46b93a0d8d5cb4ec3b595d98 (commit)
discards 0f58d1befe8352b14321a35a576372eb3f285e48 (commit)
via 3e94af2b1495438ac2eba45e299466ecbca37ef2 (commit)
via 2b50f1866c04e7cbaef8f35983250de0accbcc34 (commit)
via 6939920e72d80d4f8d5ef014674300fac1b3f9af (commit)
via 81824c6b2a74d526744302b38a5479989c961f76 (commit)
via 92344248afe3b83428d1db46b156e745451e5ce5 (commit)
via ce97be8f1743324174f965410d1249994eba3e8d (commit)
via 289bcac105fb22c53d37d73a32c1f1402bc5c358 (commit)
via 83d9bff14f8b49b346c6342855d612a37c58cfd0 (commit)
via aa8db8d1be7bdf624312762a1630355d3fec543a (commit)
via e2f4e925bc23a4698abe15108d0ec754bbf67c29 (commit)
via 07333d2c000f65cfabcc4702b704b5abf4126278 (commit)
via 1a302adfd37c3aebe33a477d64cb0304150e37c9 (commit)
via b0051dcaccff406bf3176e17f4abfb95a71822dd (commit)
via 13b61491d6933f69e26cb421e1448f094351cae9 (commit)
via 77d7b3a938fe16dc7216117a80158007706e1236 (commit)
via 9cf87e52f51dbc3344e7aca36a884b8ae0892bed (commit)
via ce8691742261a97e214f5e99024e319cc9e761e2 (commit)
via 9df9980fe8d9d1b2e7cd68ef41aa6bad00f261c0 (commit)
via 002e0e957be01c8a22605d884b9b1dd591e1ee5b (commit)
via 592a16814171acc776241e80db25673125619bda (commit)
via 979d54b458e41fc3bac8f347742d6a42a03df2a1 (commit)
via 22f1827a91aba6dd05a98e784d53d4e76a1498cd (commit)
via 733ef50fa2606d41c09badbe0f2204d16a806d61 (commit)
via 02fa89bb503205bdda6c35b477db63d637e36d31 (commit)
via 1b8c3754d59e04b11e38b19232b138e8cc42f8eb (commit)
via 11438e15a022b02513161e8191679c4409d6b4be (commit)
via 07973346bd57c8bef7e0346c28b6469da5db91e2 (commit)
via b3c468886a96090e094f3c7d79e48e489954997f (commit)
via 81e04f2a8a3166a165634524c0a73d7e9dc4f952 (commit)
via 0987e7f285f366e8129e1c1d439367e269932279 (commit)
via 17105bad97c497797a9f5ac257aca1b25c9a3678 (commit)
via 1c93a61f5b62f6ca9d96b8349d5140874adc0bce (commit)
via 3a7edf0e93669104e45a36ee5face28103dd3cd8 (commit)
via cfaf93d08cc8b366906aeffc7fca9a4a3ee7ec72 (commit)
via 7b919388ab17f9e0f6ce5b6c19755a05760737da (commit)
via 61a8584dff43f330bab0a81207b4326d2c73ab1e (commit)
via 57c088c4a0139017d368dfe6f82c85108645daba (commit)
via 26507619401189aa3f0009a4e90f288028806930 (commit)
via ab7704c3b8725fe5526f0c04ddd89f5058aeec90 (commit)
via 720b4ac09e8e1ce997da5f3a3055dd5e9506a310 (commit)
via d76275d6454849a89f1a8e443856b39ddb889efd (commit)
via fec02485ded083e6fa7220192b53aaf82c587da9 (commit)
via 87a4a347258b9acf3cb1c662e5327a15250c642c (commit)
via ac8d6ba7597e20b07f1b7401cdcf5e926c22dca1 (commit)
via dde0e23d75e77e157992b656322044fad5c1f9e1 (commit)
via 6750f67b683f4d2a3d77f2413f8282466806807b (commit)
via 26b7669e890316c16cdf04ef1ccd8bdcd68b00f1 (commit)
via af9984876b7de257a610bfddec7b20235b026850 (commit)
via a35bff38b91abc202b9a18ba45922423c3c85662 (commit)
via 5a67b47545170fd6ad5ce94bd1cb5b7edca55e9b (commit)
via 731ab1a14efd7c99632127b3f7515bfb2d53c98b (commit)
via 375b4e61b2c1bf292088f7ff3b5f020180a72770 (commit)
via 6487a9dba1b813f2d50df08d397ec3080e0be7bb (commit)
via 90aac13355f5f5518d291a41a81550471d75c97a (commit)
via 5afba3842bb7cf3e22d63a13326e3907a4a9c972 (commit)
via 4a0ee16f50566efb2180ae81764141bed236563b (commit)
via a1c740d02538ff9dd3f68b07cd561c67af3cabdc (commit)
via d6ac69cac5c35e0a47ace3f3b749c661e4c235b0 (commit)
via bc91dfb5dd05ce8b4f6b68f7f4eec1926b3aef0f (commit)
via 73774f40bae141b0b7cf507d6df8893279a46ea7 (commit)
via c173d75dba1a8d8a03c8fee43947145d2570ab64 (commit)
via 52ab07c654f83ee4968524f7e372599b762df21d (commit)
via 6a7f9e5a35954f24d74bd276193ddd257b230cac (commit)
via 8b40c86f5258ba437638b5e5d5d538ff3dcbe1c1 (commit)
via 3e5f8ace4ca6039eb22a587f463ec41014c66eec (commit)
via e048c0b0d60d75ca4458f7235179dfa283580fb2 (commit)
via 7c236c79dc621193afcf23c2ad0689a280b9e868 (commit)
via 42ff098b62214a8e3ff9984c6c554b051a93ad2e (commit)
via 04402f0a54a522e695cb3e492edc9cc9d280daf4 (commit)
via 0b442682e8f59c4e411ff0590b203bb1dcf04668 (commit)
via 5528729cfe130744aa8aa7d317af9d3a58146a2b (commit)
via cf3ad8f314f476fcac9768d2663d9afcd7661ef4 (commit)
via c57275b2a386c1fc291b4e1e800023eed552942d (commit)
via 409c1433fbb3845715a9f5b817f65d70ad161d90 (commit)
via 09c6148c1a2c9eda201e638b1ab6f5ebc7082745 (commit)
via c72cffc104bdffa902ebbdedc993ad5ddae8af5d (commit)
via cdcfe668b182ed328bae6dbd0d14528f72c50d4d (commit)
via c0f8681d2958afb11d3b4f5585de4804bc6524d4 (commit)
via 2f40e47c6660deb2d8f12c2ad403fffff6b44eb1 (commit)
via e3089252d712c2b0839f9798a98a99f690f959e2 (commit)
via b5d61ebe4059d8e89e1a40d7fd26545219172813 (commit)
via 5e4d3053fa3f8c92e02cbef811673b7c2a79040a (commit)
via 272ccdacb752b2352c26decdd648cbcf85b42b53 (commit)
via 73c3a74aea4d833e899baf0d69cd88e2c597908f (commit)
via dc7c3b9944d4b691b2099f10fba965714f82014f (commit)
via 5cd01f612dd0d318156ed7f7d369153f52a084d9 (commit)
via 5f3a088f08e99c16191c8e9461ae7052e9db8562 (commit)
via ea9c608068f019514e068fa629b18e53085ae5a3 (commit)
via d7ed1add8edcb87c4f347ad8ba4857057b3e05dc (commit)
via 2d4989772890ec1e0cb12f9036e8965066eaa866 (commit)
via 13dc18679d5dc70e9e678d0ea653e67254ecadb2 (commit)
via dac3105f148502b55ddf0130389af6c099e07a16 (commit)
via 6323abc221199973f4ba5e85e8ca4f8def31a374 (commit)
via 973a00494322c776a9dff16acce72f0f52480039 (commit)
via 1a77aaae579961af4febf45e7210595753a1d155 (commit)
via 66f08d0c354d1d55afd75438f6a0b1a4552b5ad2 (commit)
via 22dd51887a8e6df6a74c5e3249a815265e974572 (commit)
via d86fc9a3c534f3b71711d1daea4c46a081863f41 (commit)
via 055f40a10996f1d64c9c2577f395a46409b49e2c (commit)
via a74409363a9941dec0c4a86205cb5f22bdc2dab2 (commit)
via e0089be56aed528efb113d4f804adc7b0eeca65d (commit)
via c6262b2dd178ba0b4cb6e6b9135d3006b287b98b (commit)
via d8058ce8214e68759c706366cb5d331d9eb38f91 (commit)
via fd193702df57265383453bbf942b1fa651ed3caf (commit)
via 5d57444eef6406777b20a7ea545a2491d58ea0d0 (commit)
via 00f9215f95b48cba5b7518eb0ec8c2ccc50368dd (commit)
via c1877f8b356b8a6ba234852313828f06b61bf771 (commit)
via 62fccd14b6863c79ec96ef7102ff0f2bd38b4812 (commit)
via 2fe026c16ad4d9df4266c16993684576ba8b495d (commit)
via f92264244ca22751936f2f909ab911a2e6d9753f (commit)
via 81bdc8aae8645f38551682ac4ac8e2657cc7b3d9 (commit)
via b375ab3e82b52e4a07a4590c02272c718f8ffa6c (commit)
via 4938c8d839f9d4994cf577d8dd57906636d9d25d (commit)
via 1a432a30f9344628f2082772d29ac4b8f03a0cd3 (commit)
via 27abe98ff8779d1e01e11c55f740b079f69b3c35 (commit)
via e5b58eb213b3a88a2be6934e9e8f1e3e55d8bd64 (commit)
via 7e08fb78a5055a9adf5fba277a9a0c429b20ce5f (commit)
via 2d8786ecfd45afcdf0bac86ddbcb0e3029f17f2f (commit)
via 9a0159551ff9e29e5c8c52e1f791db137f44c670 (commit)
via 66cb484adc91ca65c034f198baae67fe20e83262 (commit)
via eef02666ee55a78e5c4fe8510149b26718f43f65 (commit)
via 1750bc523cdc01e1717bc168644a16524b77fa1e (commit)
via 961ef463d342b373a63c1c570568e44e564012b9 (commit)
via ae155c6e37215fcd722f44a82573729e89647108 (commit)
via 92262d2499f2eb25a2aa6919ac58c240d66a10d4 (commit)
via 5dd49fd54cb0aefc62307d2c44bb2aa2bad9bc13 (commit)
via 16506fd482cea6aae09c272d70c0cd12c9d11703 (commit)
via ca6ca83dc3fae9efe685fe774df68ddf6793acbe (commit)
via 48849ed3b8a9749bb310f12cccf70bdc8429c61a (commit)
via 1ec09726a5670c541c9ea5f57b832a6374ca09c0 (commit)
via 9a540a39c053b5a730edb6ccff5d9871bdfa1274 (commit)
via c621ab07ea277fd211c6905aa581918891ba2174 (commit)
via 7c5e9ccb89f6f8b2d9ca6a2531386aef2201bd1a (commit)
via b6f55689cb59716f61c6331c3e3483185c42a410 (commit)
via 28448a695a1c10a090f7d03c395fdf203fe6cb7e (commit)
via ce984130f0fcb7959a6b62dd0f1e819e5d66728e (commit)
via 357035117860ee79ae50a628f4e91e496905e6fc (commit)
via 4b986216fbc85d5f86db7b55a85a28a9d25608f2 (commit)
via 1995b37c1c05412c38ae84ba0528e5510d379409 (commit)
via e45787c19b8816a54b4a57f514eae3a7c0a5a219 (commit)
via 3164abc5750dc9dbf92c86a4b6d006a26126c8ec (commit)
via e435b9ba61dddbb786e339dbef3d593316c0d3e8 (commit)
via d48b8a4ae1e70487c3d8cd3370090e8ab132eb98 (commit)
via 24d3d373e86a8db51b64e2b2ff640cbec1486455 (commit)
via 153144dc8928d799662d0398a48e06eec842a8ed (commit)
via 4da0078b5a812846e1d6be5a78b22dcb15b2c448 (commit)
via e4ad8e3807e7e42cdeeb9e24cd0419b87852dd3c (commit)
via 64b6e9d0c557c719707c6ee057fc96160a1fd38e (commit)
via 40eaf23f6c4f0798ff624b6efd24214f63ccc947 (commit)
via 65886835663c0a8f85aa56071b1ca0b61dfee5dc (commit)
via 2a9b240ff2100b6f9d02969deb754f58d701e251 (commit)
via 62dbacde6331505524aa418e00c4ec111f679799 (commit)
via effa1b7572027494c649d84e43bd0d066b8317e4 (commit)
via 1d131cfacc87cbe0485582a92da949908d46f41f (commit)
via af1e2e373ae8d18c3ccef3297aa00547af4ba28e (commit)
via cb4de64dddfb5e43bc9a5ba57ffede6cb54a8256 (commit)
via 85cf60236cf2f22ca0a263056bb0952321275174 (commit)
via 59845993406e6a7db4a4dee30fc2798011d63931 (commit)
via 57bfad3c334cbb4e891bf3330531f68b739b5c4a (commit)
via 3f878aba04012c1069a3ecc4f240a7c87f76729c (commit)
via 22a49ac2882aba28798e8eaf02e8f161f4f0edc3 (commit)
via 9352b4dd5c97cc913eabcc31277270c7aa2b9729 (commit)
via 993220a95e21a684ee0a378873f8702b45d8a852 (commit)
via 766aeea463fc2ec7c091dae0e300f9baa9716675 (commit)
via 1ee4cecf9d02cb75521fb65fc734c27a0c7d9592 (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (c3550ec3eef049edfb394f5b7d8415e1eec74b27)
\
N -- N -- N (3e94af2b1495438ac2eba45e299466ecbca37ef2)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
3e94af2 Several small fixes in viewer.
2b50f18 AUTHORS: Add Antoine Froger.
6939920 Move new viewer to scribo/demo.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 114 ++-
Makefile.am | 30 +-
NEWS | 18 +-
configure.ac | 19 +-
distrib/macports/Portfile.in | 4 +-
doc/Doxyfile.in | 8 +-
doc/Makefile.am | 25 +-
doc/doc.bib | 40 +-
doc/header.html | 2 +-
doc/mainpage.dox | 4 +-
milena/ChangeLog | 1138 ++++++++++++++++++++
milena/apps/mesh-segm-skel/Makefile.am | 2 +-
.../mesh-segm-skel/mesh-complex-max-curv-segm.cc | 7 +-
milena/apps/mesh-segm-skel/mesh-complex-segm.cc | 7 +-
milena/apps/morphers/Makefile.am | 2 +
milena/apps/morphers/image2d-skel.hh | 8 +-
.../apps/papers/levillain.09.ismm/classif-graph.cc | 4 +-
milena/apps/papers/levillain.09.ismm/io.hh | 4 -
milena/doc/Doxyfile.in | 60 +-
milena/doc/DoxygenLayout.xml | 4 +-
milena/doc/Makefile.am | 80 +-
milena/doc/benchmark/canvas.cc | 6 +-
milena/doc/examples.dox | 14 +
milena/doc/examples/multi_files_f1.cc.raw | 6 +
milena/doc/examples/multi_files_f2.cc.raw | 6 +
milena/doc/examples/multi_files_main.cc.raw | 16 +
milena/doc/examples/multiple_def.cc.raw | 9 +
.../examples/split/tuto3_first_routine-1.cc.raw | 3 +-
.../examples/split/tuto3_first_routine-3.cc.raw | 2 +-
.../examples/split/tuto3_first_routine-8.cc.raw | 1 -
milena/doc/examples/split/tuto3_trace-1.cc.raw | 2 +-
milena/doc/examples/split/tuto3_trace-2.cc.raw | 2 +-
milena/doc/examples/trash/tuto_bis.cc | 11 +-
milena/doc/examples/trash/tuto_one.cc | 4 +-
milena/doc/examples/tuto3/first_routine.cc | 6 +-
milena/doc/examples/tuto3/trace.cc | 6 +-
milena/doc/examples/typenametemplate.cc.raw | 1 +
milena/doc/examples/undef_global_vars.cc.raw | 1 +
milena/doc/examples/wrongvaluetype.cc.raw | 2 +
milena/doc/img/2dgrid.png | Bin 0 -> 6092 bytes
milena/doc/mainpage.dox | 1 -
milena/doc/mln/convert.dox | 13 +
milena/doc/mln/core/alias/box1d.dox | 25 +
milena/doc/mln/core/alias/box2d.dox | 25 +
milena/doc/mln/core/alias/box2d_h.dox | 25 +
milena/doc/mln/core/alias/box3d.dox | 26 +
milena/doc/mln/core/alias/complex_geometry.dox | 31 +
milena/doc/mln/core/alias/complex_image.dox | 88 ++
milena/doc/mln/core/alias/dpoint1d.dox | 30 +
milena/doc/mln/core/alias/dpoint2d.dox | 27 +
milena/doc/mln/core/alias/dpoint3d.dox | 27 +
milena/doc/mln/core/alias/neighb1d.dox | 16 +
milena/doc/mln/core/alias/neighb2d.dox | 16 +
milena/doc/mln/core/alias/neighb3d.dox | 16 +
milena/doc/mln/core/alias/p_run2d.dox | 18 +
milena/doc/mln/core/alias/p_runs2d.dox | 12 +
milena/doc/mln/core/alias/point1d.dox | 61 ++
milena/doc/mln/core/alias/point2d.dox | 61 ++
milena/doc/mln/core/alias/point2d_h.dox | 63 ++
milena/doc/mln/core/alias/point3d.dox | 62 ++
milena/doc/mln/core/alias/vec2d.dox | 48 +
milena/doc/mln/core/alias/vec3d.dox | 48 +
milena/doc/mln/core/alias/w_window1d_float.dox | 12 +
milena/doc/mln/core/alias/w_window1d_int.dox | 12 +
milena/doc/mln/core/alias/w_window2d_float.dox | 12 +
milena/doc/mln/core/alias/w_window2d_int.dox | 12 +
milena/doc/mln/core/alias/w_window3d_float.dox | 12 +
milena/doc/mln/core/alias/w_window3d_int.dox | 12 +
milena/doc/mln/core/alias/window1d.dox | 12 +
milena/doc/mln/core/alias/window2d.dox | 12 +
milena/doc/mln/core/alias/window3d.dox | 12 +
milena/doc/mln/core/concept/concept.dox | 6 +
milena/doc/mln/io/io.dox | 7 +
milena/doc/mln/labeling/labeling.dox | 6 +
milena/doc/mln/value/hsl.dox | 37 +
milena/doc/mln/value/int_s16.dox | 24 +
milena/doc/mln/value/int_s24.dox | 24 +
milena/doc/mln/value/int_s32.dox | 24 +
milena/doc/mln/value/int_s8.dox | 24 +
milena/doc/mln/value/int_u12.dox | 24 +
milena/doc/mln/value/int_u16.dox | 24 +
milena/doc/mln/value/int_u24.dox | 24 +
milena/doc/mln/value/int_u32.dox | 24 +
milena/doc/mln/value/int_u8.dox | 24 +
milena/doc/mln/value/label_16.dox | 21 +
milena/doc/mln/value/label_32.dox | 21 +
milena/doc/mln/value/label_8.dox | 21 +
milena/doc/mln/value/rgb16.dox | 69 ++
milena/doc/mln/value/rgb8.dox | 69 ++
milena/doc/mln/value/value.dox | 43 +
milena/doc/mln/win/disk2d.dox | 17 +
milena/doc/mln/win/hline2d.dox | 17 +
milena/doc/mln/win/segment1d.dox | 17 +
milena/doc/mln/win/sline3d.dox | 17 +
milena/doc/mln/win/sphere3d.dox | 17 +
milena/doc/mln/win/vline2d.dox | 17 +
milena/doc/ref-guide.tex | 69 +-
milena/headers.mk | 22 +-
milena/mln/accu/compute.hh | 9 +-
milena/mln/accu/image/init.hh | 9 +-
milena/mln/accu/image/set_value.hh | 18 +-
milena/mln/accu/image/take.hh | 18 +-
milena/mln/accu/image/take_as_init.hh | 18 +-
milena/mln/accu/image/take_n_times.hh | 18 +-
milena/mln/accu/image/to_result.hh | 9 +-
milena/mln/accu/image/untake.hh | 18 +-
milena/mln/accu/stat/histo3d_rgb.hh | 13 +-
milena/mln/accu/transform.hh | 12 +-
milena/mln/accu/transform_diagonal.hh | 6 +-
milena/mln/accu/transform_directional.hh | 6 +-
milena/mln/accu/transform_line.hh | 15 +-
milena/mln/accu/transform_snake.hh | 6 +-
milena/mln/accu/transform_stop.hh | 12 +-
milena/mln/all.hh | 2 +-
milena/mln/arith/diff_abs.hh | 3 +-
milena/mln/arith/div.hh | 18 +-
milena/mln/arith/div.spe.hh | 6 +-
milena/mln/arith/min.hh | 16 +-
milena/mln/arith/min.spe.hh | 6 +-
milena/mln/arith/minus.hh | 33 +-
milena/mln/arith/plus.hh | 36 +-
milena/mln/arith/revert.hh | 9 +-
milena/mln/arith/revert.spe.hh | 8 +-
milena/mln/arith/times.hh | 18 +-
milena/mln/arith/times.spe.hh | 6 +-
milena/mln/binarization/binarization.hh | 6 +-
milena/mln/binarization/threshold.hh | 3 +-
milena/mln/border/adjust.hh | 3 +-
milena/mln/border/duplicate.hh | 12 +-
milena/mln/border/equalize.hh | 6 +-
milena/mln/border/fill.hh | 9 +-
milena/mln/border/find.hh | 3 +-
milena/mln/border/get.hh | 9 +-
milena/mln/border/mirror.hh | 15 +-
milena/mln/border/resize.hh | 3 +-
milena/mln/border/resize_equal.hh | 3 +-
milena/mln/canvas/browsing/backdiagonal2d.hh | 10 +-
milena/mln/canvas/browsing/diagonal2d.hh | 3 +-
.../canvas/browsing/dir_struct_elt_incr_update.hh | 3 +-
milena/mln/canvas/browsing/directional.hh | 3 +-
milena/mln/canvas/browsing/fwd.hh | 3 +-
milena/mln/canvas/browsing/hyper_directional.hh | 3 +-
.../canvas/browsing/internal/graph_first_search.hh | 3 +-
milena/mln/canvas/browsing/snake_fwd.hh | 3 +-
milena/mln/canvas/browsing/snake_generic.hh | 3 +-
milena/mln/canvas/browsing/snake_vert.hh | 3 +-
milena/mln/canvas/distance_front.hh | 9 +-
milena/mln/canvas/distance_geodesic.hh | 9 +-
milena/mln/canvas/labeling/blobs.hh | 7 +-
milena/mln/canvas/labeling/generic.hh | 12 +-
milena/mln/canvas/labeling/sorted.hh | 8 +-
milena/mln/canvas/labeling/video.hh | 10 +-
milena/mln/canvas/morpho/attribute_filter.hh | 6 +-
milena/mln/clustering/kmean_rgb.hh | 61 +-
milena/mln/convert/to.hh | 7 +-
milena/mln/convert/to_image.hh | 10 +-
milena/mln/convert/to_qimage.hh | 3 +-
milena/mln/convert/to_qimage_nocopy.hh | 3 +-
milena/mln/core/alias/box1d.hh | 43 +-
milena/mln/core/alias/box2d.hh | 50 +-
milena/mln/core/alias/box3d.hh | 53 +-
milena/mln/core/alias/complex_geometry.hh | 35 +-
milena/mln/core/alias/complex_image.hh | 121 ++-
milena/mln/core/alias/dpoint1d.hh | 39 +-
milena/mln/core/alias/dpoint2d.hh | 42 +-
milena/mln/core/alias/dpoint3d.hh | 42 +-
milena/mln/core/alias/neighb1d.hh | 71 ++-
milena/mln/core/alias/neighb2d.hh | 97 ++-
milena/mln/core/alias/neighb3d.hh | 98 ++-
milena/mln/core/alias/p_run2d.hh | 14 +-
milena/mln/core/alias/p_runs2d.hh | 14 +-
milena/mln/core/alias/point1d.hh | 28 +-
milena/mln/core/alias/point2d.hh | 30 +-
milena/mln/core/alias/point3d.hh | 30 +-
milena/mln/core/alias/vec2d.hh | 26 +-
milena/mln/core/alias/vec3d.hh | 25 +-
milena/mln/core/alias/w_window1d_float.hh | 19 +-
milena/mln/core/alias/w_window1d_int.hh | 19 +-
milena/mln/core/alias/w_window2d_float.hh | 19 +-
milena/mln/core/alias/w_window2d_int.hh | 19 +-
milena/mln/core/alias/w_window3d_float.hh | 19 +-
milena/mln/core/alias/w_window3d_int.hh | 19 +-
milena/mln/core/alias/window1d.hh | 55 +-
milena/mln/core/alias/window2d.hh | 55 +-
milena/mln/core/alias/window3d.hh | 59 +-
milena/mln/core/box_runend_piter.hh | 11 +-
milena/mln/core/box_runstart_piter.hh | 8 +
milena/mln/core/concept/accumulator.hh | 55 +-
milena/mln/core/concept/box.hh | 15 +-
milena/mln/core/concept/browsing.hh | 14 +-
milena/mln/core/concept/delta_point_site.hh | 15 +-
milena/mln/core/concept/dpoint.hh | 10 +-
milena/mln/core/concept/function.hh | 33 +-
milena/mln/core/concept/gdpoint.hh | 23 +-
milena/mln/core/concept/generalized_pixel.hh | 25 +-
milena/mln/core/concept/gpoint.hh | 26 +-
milena/mln/core/concept/graph.hh | 17 +-
milena/mln/core/concept/image.hh | 24 +-
milena/mln/core/concept/iterator.hh | 13 +-
milena/mln/core/concept/literal.hh | 14 +-
milena/mln/core/concept/mesh.hh | 11 +-
milena/mln/core/concept/meta_accumulator.hh | 16 +-
milena/mln/core/concept/meta_function.hh | 20 +-
milena/mln/core/concept/neighborhood.hh | 27 +-
milena/mln/core/concept/object.hh | 19 +-
milena/mln/core/concept/pixel_iterator.hh | 19 +-
milena/mln/core/concept/point.hh | 22 +-
milena/mln/core/concept/point_site.hh | 53 +-
milena/mln/core/concept/proxy.hh | 19 +-
milena/mln/core/concept/pseudo_site.hh | 21 +-
milena/mln/core/concept/regular_grid.hh | 8 +-
milena/mln/core/concept/site.hh | 13 +-
milena/mln/core/concept/site_iterator.hh | 22 +-
milena/mln/core/concept/site_proxy.hh | 23 +-
milena/mln/core/concept/site_set.hh | 21 +-
milena/mln/core/concept/value.hh | 17 +-
milena/mln/core/concept/value_iterator.hh | 20 +-
milena/mln/core/concept/value_set.hh | 19 +-
milena/mln/core/concept/weighted_window.hh | 21 +-
milena/mln/core/concept/window.hh | 28 +-
milena/mln/core/dpoints_pixter.hh | 16 +-
milena/mln/core/dpsites_piter.hh | 14 +-
milena/mln/core/faces_psite.hh | 7 +-
milena/mln/core/image/ch_piter.hh | 6 +-
milena/mln/core/image/complex_image.hh | 8 +-
.../mln/core/image/complex_neighborhood_piter.hh | 6 +-
milena/mln/core/image/complex_window_piter.hh | 6 +-
milena/mln/core/image/dmorph/extended.hh | 10 +-
milena/mln/core/image/dmorph/extension_fun.hh | 11 +-
milena/mln/core/image/dmorph/extension_ima.hh | 10 +-
milena/mln/core/image/dmorph/extension_val.hh | 9 +-
milena/mln/core/image/dmorph/hexa.hh | 9 +-
milena/mln/core/image/dmorph/hexa_piter.hh | 7 +-
milena/mln/core/image/dmorph/image_if.hh | 7 +-
milena/mln/core/image/dmorph/p2p_image.hh | 5 +-
milena/mln/core/image/dmorph/slice_image.hh | 7 +-
milena/mln/core/image/dmorph/sub_image.hh | 11 +-
milena/mln/core/image/dmorph/sub_image_if.hh | 8 +-
milena/mln/core/image/dmorph/transformed_image.hh | 5 +-
milena/mln/core/image/dmorph/unproject_image.hh | 7 +-
milena/mln/core/image/edge_image.hh | 9 +-
milena/mln/core/image/flat_image.hh | 12 +-
milena/mln/core/image/graph_window_if_piter.hh | 13 +-
milena/mln/core/image/graph_window_piter.hh | 10 +-
milena/mln/core/image/image1d.hh | 10 +-
milena/mln/core/image/image2d.hh | 26 +-
milena/mln/core/image/image3d.hh | 14 +-
milena/mln/core/image/imorph/decorated_image.hh | 9 +-
milena/mln/core/image/imorph/interpolated.hh | 7 +-
milena/mln/core/image/imorph/labeled_image.hh | 11 +-
milena/mln/core/image/imorph/lazy_image.hh | 5 +-
milena/mln/core/image/imorph/plain.hh | 5 +-
milena/mln/core/image/imorph/safe.hh | 5 +-
milena/mln/core/image/imorph/tr_image.hh | 5 +-
milena/mln/core/image/vertex_image.hh | 7 +-
milena/mln/core/image/vmorph/cast_image.hh | 7 +-
milena/mln/core/image/vmorph/fun_image.hh | 5 +-
milena/mln/core/image/vmorph/thru_image.hh | 7 +-
milena/mln/core/image/vmorph/violent_cast_image.hh | 5 +-
milena/mln/core/internal/check/image_fastest.hh | 26 +-
milena/mln/core/internal/classical_window_base.hh | 5 +-
milena/mln/core/internal/coord_impl.hh | 40 +-
milena/mln/core/internal/graph_psite_base.hh | 5 +-
milena/mln/core/internal/image_base.hh | 15 +-
milena/mln/core/internal/image_identity.hh | 5 +-
milena/mln/core/internal/image_morpher.hh | 13 +-
milena/mln/core/internal/labeled_image_base.hh | 4 +-
milena/mln/core/internal/neighb_base.hh | 8 +-
milena/mln/core/internal/neighb_niter_base.hh | 8 +-
milena/mln/core/internal/p_complex_piter_base.hh | 5 +-
milena/mln/core/internal/piter_adaptor.hh | 13 +-
milena/mln/core/internal/pseudo_site_base.hh | 3 +-
milena/mln/core/internal/run_image.hh | 5 +-
milena/mln/core/internal/set_of.hh | 7 +-
milena/mln/core/internal/site_iterator_base.hh | 7 +-
.../core/internal/site_relative_iterator_base.hh | 9 +-
milena/mln/core/internal/site_set_base.hh | 5 +-
milena/mln/core/internal/site_set_impl.hh | 3 +-
milena/mln/core/internal/site_set_iterator_base.hh | 12 +-
milena/mln/core/internal/window_base.hh | 12 +-
milena/mln/core/mixed_neighb.hh | 11 +-
milena/mln/core/neighb.hh | 10 +-
milena/mln/core/pixter1d.hh | 8 +-
milena/mln/core/pixter2d.hh | 12 +-
milena/mln/core/pixter3d.hh | 10 +-
milena/mln/core/point.hh | 12 +-
milena/mln/core/routine/duplicate.hh | 3 +-
milena/mln/core/routine/init.hh | 3 +-
milena/mln/core/routine/initialize.hh | 7 +-
milena/mln/core/site_set/box.hh | 3 +-
milena/mln/core/site_set/box_piter.hh | 10 +-
milena/mln/core/site_set/complex_psite.hh | 14 +-
milena/mln/core/site_set/p_array.hh | 25 +-
milena/mln/core/site_set/p_centered.hh | 6 +-
milena/mln/core/site_set/p_complex_piter.hh | 6 +-
milena/mln/core/site_set/p_double.hh | 15 +-
milena/mln/core/site_set/p_edges_psite.hh | 6 +-
milena/mln/core/site_set/p_faces.hh | 4 +-
milena/mln/core/site_set/p_graph_piter.hh | 9 +-
milena/mln/core/site_set/p_if.hh | 5 +-
milena/mln/core/site_set/p_if_piter.hh | 7 +-
milena/mln/core/site_set/p_image.hh | 11 +-
milena/mln/core/site_set/p_key.hh | 10 +-
milena/mln/core/site_set/p_line2d.hh | 3 +-
milena/mln/core/site_set/p_mutable_array_of.hh | 10 +-
milena/mln/core/site_set/p_priority.hh | 8 +-
milena/mln/core/site_set/p_run.hh | 7 +-
milena/mln/core/site_set/p_run_piter.hh | 10 +-
milena/mln/core/site_set/p_set_of.hh | 7 +-
milena/mln/core/site_set/p_transformed.hh | 6 +-
milena/mln/core/site_set/p_transformed_piter.hh | 7 +-
milena/mln/core/site_set/p_vaccess.hh | 6 +-
milena/mln/core/site_set/p_vertices_psite.hh | 6 +-
milena/mln/core/w_window.hh | 11 +-
milena/mln/core/window.hh | 8 +-
milena/mln/data/abs.hh | 6 +-
milena/mln/data/apply.hh | 6 +-
milena/mln/data/apply.spe.hh | 3 +-
milena/mln/data/approx/median.hh | 6 +-
milena/mln/data/compare.hh | 9 +-
milena/mln/data/compute.hh | 3 +-
milena/mln/data/compute_in_window.hh | 23 +-
milena/mln/data/convert.hh | 9 +-
milena/mln/data/fill.hh | 3 +-
milena/mln/data/fill_with_image.hh | 6 +-
milena/mln/data/fill_with_image.spe.hh | 12 +-
milena/mln/data/fill_with_value.hh | 6 +-
milena/mln/data/fill_with_value.spe.hh | 9 +-
milena/mln/data/median.hh | 9 +-
milena/mln/data/memcpy_.hh | 6 +-
milena/mln/data/memset_.hh | 9 +-
milena/mln/data/paste.hh | 6 +-
milena/mln/data/paste.spe.hh | 12 +-
milena/mln/data/paste_without_localization.hh | 15 +-
milena/mln/data/replace.hh | 6 +-
milena/mln/data/saturate.hh | 9 +-
milena/mln/data/sort_offsets.hh | 18 +-
milena/mln/data/split.hh | 3 +-
milena/mln/data/stretch.hh | 12 +-
milena/mln/data/to_enc.hh | 3 +-
milena/mln/data/transform.hh | 12 +-
milena/mln/data/transform.spe.hh | 24 +-
milena/mln/data/transform_inplace.hh | 30 +-
milena/mln/data/update.hh | 9 +-
milena/mln/data/wrap.hh | 3 +-
milena/mln/debug/draw_graph.hh | 26 +-
milena/mln/debug/iota.hh | 3 +-
milena/mln/debug/mosaic.hh | 3 +-
milena/mln/debug/println.hh | 3 +-
milena/mln/debug/put_word.hh | 4 +-
milena/mln/debug/slices_2d.hh | 6 +-
milena/mln/debug/superpose.hh | 3 +-
milena/mln/debug/trace.hh | 218 ++++
milena/mln/debug/z_order.hh | 3 +-
milena/mln/draw/dashed_line.hh | 8 +-
milena/mln/draw/line.hh | 8 +-
milena/mln/essential/routine.hh | 5 +-
milena/mln/extension/adjust.hh | 12 +-
milena/mln/extension/adjust_duplicate.hh | 12 +-
milena/mln/extension/adjust_fill.hh | 12 +-
milena/mln/extension/duplicate.hh | 3 +-
milena/mln/extension/fill.hh | 3 +-
milena/mln/fun/v2b/always_false.hh | 74 ++
milena/mln/fun/v2b/always_true.hh | 74 ++
milena/mln/fun/v2v/round_sat.hh | 4 +-
milena/mln/fun/x2x/composed.hh | 3 +-
milena/mln/geom/chamfer.hh | 3 +-
milena/mln/geom/crop.hh | 3 +-
milena/mln/geom/crop_without_localization.hh | 3 +-
milena/mln/geom/horizontal_symmetry.hh | 3 +-
milena/mln/geom/max_ind.hh | 3 +-
milena/mln/geom/min_ind.hh | 3 +-
milena/mln/geom/ninds.hh | 3 +-
milena/mln/geom/nsites.hh | 3 +-
milena/mln/geom/rotate.hh | 6 +-
milena/mln/geom/seeds2tiling.hh | 6 +-
milena/mln/geom/seeds2tiling_roundness.hh | 6 +-
milena/mln/geom/translate.hh | 3 +-
milena/mln/geom/vertical_symmetry.hh | 3 +-
milena/mln/graph/compute.hh | 3 +-
milena/mln/graph/labeling.hh | 3 +-
milena/mln/graph/to_neighb.hh | 3 +-
milena/mln/graph/to_win.hh | 3 +-
milena/mln/histo/compute.hh | 3 +-
milena/mln/histo/equalize.hh | 3 +-
milena/mln/io/cloud/load.hh | 3 +-
milena/mln/io/cloud/save.hh | 3 +-
milena/mln/io/dicom/get_header.hh | 3 +-
milena/mln/io/dicom/load.hh | 9 +-
milena/mln/io/dump/get_header.hh | 3 +-
milena/mln/io/dump/load.hh | 3 +-
milena/mln/io/dump/save.hh | 3 +-
milena/mln/io/fits/load.hh | 3 +-
milena/mln/io/fld/load.hh | 3 +-
milena/mln/io/fld/save.hh | 3 +-
milena/mln/io/magick/internal/init_magick.hh | 71 ++
milena/mln/io/magick/load.hh | 35 +-
milena/mln/io/magick/save.hh | 40 +-
milena/mln/io/off/load.hh | 9 +-
milena/mln/io/off/save.hh | 12 +-
milena/mln/io/pbm/load.hh | 3 +-
milena/mln/io/pbm/save.hh | 3 +-
milena/mln/io/pbms/load.hh | 3 +-
milena/mln/io/pdf/get_header.hh | 15 +-
milena/mln/io/pdf/load.hh | 106 ++-
milena/mln/io/pfm/load.hh | 3 +-
milena/mln/io/pfm/save.hh | 3 +-
milena/mln/io/pgm/load.hh | 6 +-
milena/mln/io/pgm/save.hh | 3 +-
milena/mln/io/pgms/load.hh | 3 +-
milena/mln/io/plot/load.hh | 3 +-
milena/mln/io/plot/save.hh | 9 +-
milena/mln/io/pnm/load.hh | 6 +-
milena/mln/io/pnm/save.hh | 3 +-
milena/mln/io/pnms/load.hh | 6 +-
milena/mln/io/ppm/load.hh | 6 +-
milena/mln/io/ppms/load.hh | 3 +-
milena/mln/io/raw/get_header.hh | 3 +-
milena/mln/io/raw/load.hh | 3 +-
milena/mln/io/raw/save.hh | 3 +-
milena/mln/io/tiff/load.hh | 3 +-
milena/mln/io/txt/save.hh | 3 +-
milena/mln/labeling/background.hh | 7 +-
milena/mln/labeling/blobs.hh | 3 +-
milena/mln/labeling/blobs_and_compute.hh | 3 +-
milena/mln/labeling/colorize.hh | 50 +-
milena/mln/labeling/compute.hh | 130 ++--
milena/mln/labeling/compute_image.hh | 83 +-
milena/mln/labeling/fill_holes.hh | 3 +-
milena/mln/labeling/flat_zones.hh | 21 +-
milena/mln/labeling/foreground.hh | 11 +-
milena/mln/labeling/mean_values.hh | 20 +-
milena/mln/labeling/n_max.hh | 78 +-
milena/mln/labeling/pack.hh | 40 +-
milena/mln/labeling/regional_maxima.hh | 22 +-
milena/mln/labeling/regional_minima.hh | 22 +-
milena/mln/labeling/relabel.hh | 83 +-
milena/mln/labeling/superpose.hh | 8 +-
milena/mln/labeling/value.hh | 27 +-
milena/mln/labeling/value.spe.hh | 3 +-
milena/mln/labeling/value_and_compute.hh | 25 +-
milena/mln/labeling/wrap.hh | 38 +-
milena/mln/linear/.#ch_convolve.hh | 1 -
milena/mln/linear/convolve.hh | 9 +-
milena/mln/linear/convolve_2x1d.hh | 3 +-
milena/mln/linear/convolve_directional.hh | 3 +-
milena/mln/linear/gaussian_1d.hh | 3 +-
milena/mln/linear/gaussian_directional_2d.hh | 3 +-
milena/mln/linear/lap.hh | 12 +-
milena/mln/linear/log.hh | 39 +-
milena/mln/linear/sobel_2d.hh | 12 +-
milena/mln/logical/and.hh | 6 +-
milena/mln/logical/and_not.hh | 6 +-
milena/mln/logical/not.hh | 6 +-
milena/mln/logical/not.spe.hh | 6 +-
milena/mln/logical/or.hh | 6 +-
milena/mln/logical/xor.hh | 6 +-
milena/mln/make/dual_neighb.hh | 3 +-
milena/mln/make/dummy_p_edges.hh | 3 +-
milena/mln/make/dummy_p_vertices.hh | 3 +-
milena/mln/make/edge_image.hh | 18 +-
milena/mln/make/influence_zone_adjacency_graph.hh | 6 +-
milena/mln/make/p_edges_with_mass_centers.hh | 3 +-
milena/mln/make/p_vertices_with_mass_centers.hh | 3 +-
milena/mln/make/rag_and_labeled_wsl.hh | 6 +-
milena/mln/make/region_adjacency_graph.hh | 10 +-
milena/mln/make/relabelfun.hh | 6 +-
milena/mln/make/vertex_image.hh | 6 +-
milena/mln/make/w_window.hh | 3 +-
milena/mln/morpho/algebraic_filter.hh | 3 +-
milena/mln/morpho/all.hh | 1 -
milena/mln/morpho/approx/dilation.hh | 9 +-
milena/mln/morpho/approx/erosion.hh | 9 +-
milena/mln/morpho/closing/algebraic.hh | 3 +-
milena/mln/morpho/closing/approx/structural.hh | 3 +-
milena/mln/morpho/closing/area.hh | 3 +-
milena/mln/morpho/closing/area_on_vertices.hh | 3 +-
milena/mln/morpho/closing/height.hh | 3 +-
milena/mln/morpho/closing/leveling.hh | 3 +-
milena/mln/morpho/closing/structural.hh | 3 +-
milena/mln/morpho/closing/sum.hh | 3 +-
milena/mln/morpho/closing/volume.hh | 3 +-
milena/mln/morpho/complementation.hh | 6 +-
milena/mln/morpho/contrast.hh | 3 +-
milena/mln/morpho/dilation.hh | 9 +-
milena/mln/morpho/elementary/closing.hh | 3 +-
milena/mln/morpho/elementary/dilation.hh | 3 +-
milena/mln/morpho/elementary/erosion.hh | 3 +-
milena/mln/morpho/elementary/gradient.hh | 12 +-
milena/mln/morpho/elementary/gradient_external.hh | 3 +-
milena/mln/morpho/elementary/gradient_internal.hh | 3 +-
milena/mln/morpho/elementary/laplacian.hh | 3 +-
milena/mln/morpho/elementary/like_ero_fun.hh | 6 +-
milena/mln/morpho/elementary/like_ero_set.hh | 6 +-
milena/mln/morpho/elementary/opening.hh | 3 +-
milena/mln/morpho/elementary/top_hat.hh | 9 +-
milena/mln/morpho/erosion.hh | 9 +-
milena/mln/morpho/essential.hh | 1 -
milena/mln/morpho/general.hh | 9 +-
milena/mln/morpho/general.spe.hh | 21 +-
milena/mln/morpho/gradient.hh | 9 +-
milena/mln/morpho/hit_or_miss.hh | 21 +-
milena/mln/morpho/laplacian.hh | 6 +-
milena/mln/morpho/leveling_filter.hh | 3 +-
milena/mln/morpho/line_gradient.hh | 3 +-
milena/mln/morpho/meyer_wst.hh | 222 ----
milena/mln/morpho/min.hh | 6 +-
milena/mln/morpho/minus.hh | 3 +-
milena/mln/morpho/opening/algebraic.hh | 3 +-
milena/mln/morpho/opening/approx/structural.hh | 3 +-
milena/mln/morpho/opening/area.hh | 3 +-
milena/mln/morpho/opening/area_on_vertices.hh | 3 +-
milena/mln/morpho/opening/height.hh | 3 +-
milena/mln/morpho/opening/leveling.hh | 3 +-
milena/mln/morpho/opening/structural.hh | 3 +-
milena/mln/morpho/opening/volume.hh | 3 +-
milena/mln/morpho/plus.hh | 3 +-
milena/mln/morpho/rank_filter.hh | 12 +-
.../reconstruction/by_dilation/union_find.hh | 11 +-
.../morpho/reconstruction/by_erosion/union_find.hh | 10 +-
milena/mln/morpho/skeleton_constrained.hh | 9 +-
milena/mln/morpho/thick_miss.hh | 3 +-
milena/mln/morpho/thickening.hh | 3 +-
milena/mln/morpho/thin_fit.hh | 3 +-
milena/mln/morpho/thinning.hh | 3 +-
milena/mln/morpho/top_hat.hh | 9 +-
milena/mln/morpho/tree/component_tree.hh | 6 +-
milena/mln/morpho/tree/compute_attribute_image.hh | 6 +-
milena/mln/morpho/tree/compute_parent.hh | 6 +-
milena/mln/morpho/tree/dual_input_tree.hh | 3 +-
milena/mln/morpho/tree/filter/direct.hh | 3 +-
milena/mln/morpho/tree/filter/filter.hh | 3 +-
milena/mln/morpho/tree/filter/max.hh | 3 +-
milena/mln/morpho/tree/filter/min.hh | 3 +-
milena/mln/morpho/tree/filter/subtractive.hh | 3 +-
milena/mln/morpho/tree/impl/dual_hqueue.hh | 3 +-
milena/mln/morpho/tree/impl/dual_union_find.hh | 3 +-
milena/mln/morpho/tree/max.hh | 3 +-
milena/mln/morpho/watershed/flooding.hh | 9 +-
milena/mln/morpho/watershed/superpose.hh | 3 +-
milena/mln/opt/at.hh | 5 +-
milena/mln/registration/all.hh | 49 +
milena/mln/registration/icp.hh | 12 +-
milena/mln/set/card.hh | 9 +-
milena/mln/set/compute.hh | 9 +-
milena/mln/set/compute_with_weights.hh | 15 +-
milena/mln/set/diff.hh | 3 +-
milena/mln/set/get.hh | 3 +-
milena/mln/set/has.hh | 3 +-
milena/mln/set/inter.hh | 3 +-
milena/mln/set/sym_diff.hh | 3 +-
milena/mln/set/uni.hh | 3 +-
milena/mln/set/unique.hh | 3 +-
milena/mln/subsampling/antialiased.hh | 13 +-
milena/mln/test/positive.hh | 3 +-
milena/mln/test/predicate.hh | 9 +-
milena/mln/topo/complex.hh | 44 +-
milena/mln/topo/skeleton/crest.hh | 9 +-
milena/mln/trace/all.hh | 52 -
milena/mln/trace/entering.hh | 89 --
milena/mln/trace/essential.hh | 36 -
milena/mln/trace/exiting.hh | 118 --
milena/mln/trace/quiet.hh | 84 --
milena/mln/trace/resume.hh | 60 -
milena/mln/trace/stop.hh | 63 --
milena/mln/trace/warning.hh | 64 --
milena/mln/trait/ch_value.hh | 66 ++-
milena/mln/trait/concrete.hh | 65 ++-
.../distance_and_closest_point_geodesic.hh | 6 +-
.../distance_and_influence_zone_geodesic.hh | 3 +-
milena/mln/transform/distance_front.hh | 3 +-
milena/mln/transform/distance_geodesic.hh | 3 +-
milena/mln/transform/hough.hh | 3 +-
milena/mln/transform/influence_zone_front.hh | 3 +-
milena/mln/transform/influence_zone_geodesic.hh | 6 +-
.../transform/influence_zone_geodesic_saturated.hh | 3 +-
milena/mln/upscaling/art/scale2x.hh | 3 +-
milena/mln/upscaling/art/scale3x.hh | 3 +-
milena/mln/util/array.hh | 20 +-
milena/mln/util/timer.hh | 15 +-
milena/mln/util/tree_fast_to_image.hh | 6 +-
milena/mln/util/tree_to_fast.hh | 8 +-
milena/mln/util/tree_to_image.hh | 21 +-
milena/mln/value/builtin/symbolics.hh | 6 +-
milena/mln/value/hsl.hh | 24 +-
milena/mln/value/int_s.hh | 9 +-
milena/mln/value/int_s16.hh | 15 +-
milena/mln/value/int_s24.hh | 15 +-
milena/mln/value/int_s32.hh | 15 +-
milena/mln/value/int_s8.hh | 16 +-
milena/mln/value/int_u.hh | 12 +-
milena/mln/value/int_u12.hh | 15 +-
milena/mln/value/int_u16.hh | 15 +-
milena/mln/value/int_u24.hh | 15 +-
milena/mln/value/int_u32.hh | 15 +-
milena/mln/value/int_u8.hh | 15 +-
milena/mln/value/internal/gray_f.hxx | 8 +-
milena/mln/value/label.hh | 15 +-
milena/mln/value/label_16.hh | 15 +-
milena/mln/value/label_32.hh | 9 +-
milena/mln/value/label_8.hh | 15 +-
milena/mln/value/qt/rgb32.hh | 15 +-
milena/mln/value/rgb.hh | 10 +-
milena/mln/value/rgb16.hh | 17 +-
milena/mln/value/rgb8.hh | 17 +-
milena/mln/win/diff.hh | 3 +-
milena/mln/win/disk2d.hh | 19 +-
milena/mln/win/hline2d.hh | 11 +-
milena/mln/win/inter.hh | 3 +-
milena/mln/win/rectangle2d.hh | 13 +-
milena/mln/win/segment1d.hh | 11 +-
milena/mln/win/shift.hh | 3 +-
milena/mln/win/sline3d.hh | 11 +-
milena/mln/win/sphere3d.hh | 18 +-
milena/mln/win/sym.hh | 6 +-
milena/mln/win/vline2d.hh | 11 +-
milena/mln/world/binary_2d/enlarge.hh | 3 +-
milena/mln/world/binary_2d/subsample.hh | 27 +-
milena/mln/world/inter_pixel/compute.hh | 3 +-
.../mln/world/inter_pixel/dim2/make_edge_image.hh | 3 +-
milena/mln/world/inter_pixel/full2image.hh | 3 +-
milena/mln/world/inter_pixel/immerse.hh | 3 +-
milena/mln/world/rgb/invert.hh | 9 +-
milena/mln/world/rgb/invert.spe.hh | 9 +-
milena/tests/accu/site_set/rectangularity.cc | 4 +-
milena/tests/algebra/mat.cc | 19 +-
milena/tests/arith/diff_abs.cc | 2 +-
milena/tests/arith/minus.cc | 2 +-
milena/tests/arith/plus.cc | 4 +-
milena/tests/arith/revert.cc | 2 +-
milena/tests/arith/times.cc | 2 +-
milena/tests/core/image/edge_image.cc | 146 ++--
milena/tests/core/image/line_graph_image.cc | 140 ++--
milena/tests/core/other/var.cc | 8 +-
milena/tests/data.hh.in | 3 +
milena/tests/data/fill_with_image.cc | 4 +-
milena/tests/data/paste.cc | 4 +-
milena/tests/geom/nsites.cc | 2 +-
milena/tests/io/fld/fld1d.cc | 9 +-
milena/tests/io/fld/fld2d.cc | 21 +-
milena/tests/io/fld/fld3d.cc | 9 +-
milena/tests/io/magick/load.cc | 18 +-
milena/tests/io/magick/save.cc | 19 +-
milena/tests/labeling/Makefile.am | 8 +-
milena/tests/labeling/foreground.cc | 34 +-
milena/tests/labeling/foreground.ref.pgm | Bin 0 -> 81654 bytes
milena/tests/labeling/n_max.cc | 5 +-
milena/tests/linear/gaussian.cc | 6 +-
milena/tests/morpho/Makefile.am | 8 +-
.../morpho/artificial_line_graph_image_wst.cc | 19 +-
milena/tests/morpho/closing/algebraic.cc | 2 +-
milena/tests/morpho/elementary/closing.cc | 2 +-
milena/tests/morpho/elementary/dilation.cc | 2 +-
milena/tests/morpho/elementary/erosion.cc | 2 +-
milena/tests/morpho/elementary/opening.cc | 2 +-
milena/tests/morpho/elementary/top_hat.cc | 2 +-
milena/tests/morpho/general.cc | 4 +-
milena/tests/morpho/graph_image_morpho.cc | 2 +-
milena/tests/morpho/graph_image_wst.cc | 15 +-
milena/tests/morpho/lena_line_graph_image_wst1.cc | 18 +-
milena/tests/morpho/lena_line_graph_image_wst2.cc | 19 +-
milena/tests/morpho/line_graph_image_morpho.cc | 49 +-
milena/tests/morpho/line_graph_image_wst.cc | 57 +-
milena/tests/morpho/meyer_wst.cc | 56 -
milena/tests/morpho/meyer_wst_long.cc | 73 --
milena/tests/morpho/opening/algebraic.cc | 2 +-
milena/tests/morpho/top_hat.cc | 2 +-
milena/tests/opt/at.cc | 4 +-
milena/tests/opt/element.cc | 4 +-
milena/tests/opt/value.cc | 5 +-
milena/tests/trait/op/plus.cc | 6 +-
milena/tests/unit_test/Makefile.am | 1 +
milena/tests/unit_test/cond_tests_magickxx | 1 +
milena/tests/unit_test/cond_tests_poppler | 2 +
milena/tests/unit_test/unit-tests.mk | 33 +-
milena/tools/area_flooding.cc | 7 +-
scribo/ChangeLog | 685 ++++++++++++
scribo/common.mk | 8 +-
scribo/demo/viewer/main.cc | 1 -
scribo/demo/xml2doc/main.cc | 28 +-
scribo/doc/Doxyfile.in | 36 +-
scribo/doc/DoxygenLayout.xml | 2 +-
scribo/doc/Makefile.am | 22 +-
scribo/doc/scribo/binarization/binarization.dox | 8 +-
scribo/doc/scribo/binarization/kim.dox | 23 +
scribo/doc/scribo/binarization/otsu.dox | 11 +-
scribo/doc/scribo/binarization/wolf.dox | 6 +
scribo/doc/scribo/filter/component_groups.dox | 2 +-
scribo/doc/scribo/filter/component_links.dox | 2 +-
scribo/doc/scribo/filter/components.dox | 2 +-
scribo/doc/scribo/filter/elements.dox | 2 +-
scribo/doc/scribo/filter/line_links.dox | 4 +-
scribo/doc/scribo/filter/paragraphs.dox | 4 +-
scribo/doc/scribo/layout/layout.dox | 6 +
scribo/doc/scribo/namespaces.dox | 7 +
scribo/doc/scribo/primitive/extract/components.dox | 7 +
scribo/doc/scribo/primitive/extract/extract.dox | 7 +
scribo/doc/scribo/primitive/extract/separators.dox | 8 +-
scribo/headers.mk | 31 +-
scribo/scribo/binarization/all.hh | 6 +
scribo/scribo/binarization/global_threshold.hh | 3 +-
.../scribo/binarization/global_threshold_auto.hh | 5 +-
.../internal/global_max_stddev_functor.hh | 110 ++
.../binarization/internal/local_threshold_core.hh | 33 +-
.../binarization/internal/niblack_formula.hh | 2 +-
.../binarization/internal/niblack_functor.hh | 14 +-
.../binarization/internal/niblack_functor_fast.hh | 12 +
.../internal/niblack_threshold_functor.hh | 18 +-
.../binarization/internal/sauvola_functor.hh | 18 +
.../binarization/internal/sauvola_ms_functor.hh | 18 +-
.../internal/sauvola_threshold_functor.hh | 22 +-
.../scribo/binarization/internal/singh_formula.hh | 13 +-
.../scribo/binarization/internal/singh_functor.hh | 14 +
.../scribo/binarization/internal/wolf_functor.hh | 17 +-
.../binarization/internal/wolf_functor_fast.hh | 15 +
scribo/scribo/binarization/kim.hh | 25 +-
scribo/scribo/binarization/local_threshold.hh | 9 +-
scribo/scribo/binarization/niblack.hh | 3 +-
scribo/scribo/binarization/niblack_fast.hh | 23 +-
scribo/scribo/binarization/niblack_threshold.hh | 17 +-
scribo/scribo/binarization/otsu.hh | 10 +-
scribo/scribo/binarization/otsu_threshold.hh | 15 +-
scribo/scribo/binarization/sauvola.hh | 3 +-
scribo/scribo/binarization/sauvola_ms.hh | 75 +-
scribo/scribo/binarization/sauvola_ms_split.hh | 22 +-
scribo/scribo/binarization/sauvola_threshold.hh | 5 +-
scribo/scribo/binarization/singh.hh | 13 +-
scribo/scribo/binarization/wolf.hh | 60 +-
scribo/scribo/binarization/wolf_fast.hh | 56 +-
scribo/scribo/canvas/integral_browsing.hh | 14 +-
scribo/scribo/convert/from_base64.hh | 9 +-
scribo/scribo/convert/to_base64.hh | 3 +-
scribo/scribo/core/central_sites.hh | 3 +-
scribo/scribo/core/component_info.hh | 17 +-
scribo/scribo/core/component_set.hh | 188 +++-
scribo/scribo/core/concept/serializable.hh | 9 +-
scribo/scribo/core/document.hh | 58 +-
scribo/scribo/core/erase_objects.hh | 3 +-
scribo/scribo/core/init_integral_image.hh | 3 +-
scribo/scribo/core/line_info.hh | 4 +-
scribo/scribo/core/line_set.hh | 19 +-
scribo/scribo/core/object_links.hh | 61 +-
scribo/scribo/core/paragraph_info.hh | 4 +-
scribo/scribo/core/paragraph_set.hh | 7 +
scribo/scribo/core/tag/component.hh | 56 +-
scribo/scribo/debug/alignment_decision_image.hh | 3 +-
scribo/scribo/debug/bboxes_enlarged_image.hh | 3 +-
scribo/scribo/debug/bboxes_image.hh | 9 +-
scribo/scribo/debug/char_space_image.hh | 3 +-
scribo/scribo/debug/decision_image.hh | 6 +-
scribo/scribo/debug/highlight_text_area.hh | 12 +-
scribo/scribo/debug/line_info_image.hh | 3 +-
scribo/scribo/debug/linked_bboxes_image.hh | 9 +-
scribo/scribo/debug/links_decision_image.hh | 3 +-
scribo/scribo/debug/links_image.hh | 8 +-
scribo/scribo/debug/logger.hh | 70 +-
.../scribo/debug/looks_like_a_text_line_image.hh | 3 +-
scribo/scribo/debug/mean_and_base_lines_image.hh | 3 +-
scribo/scribo/debug/save_comp_diff.hh | 3 +-
scribo/scribo/debug/save_label_image.hh | 3 +-
scribo/scribo/debug/save_table_image.hh | 6 +-
scribo/scribo/debug/text_areas_image.hh | 3 +-
scribo/scribo/draw/bounding_box_links.hh | 9 +-
scribo/scribo/draw/bounding_boxes.hh | 6 +-
scribo/scribo/draw/groups_bboxes.hh | 3 +-
scribo/scribo/draw/line_components.hh | 3 +-
scribo/scribo/estim/components_features.hh | 3 +-
scribo/scribo/estim/font_boldness.hh | 12 +-
scribo/scribo/estim/font_color.hh | 9 +-
scribo/scribo/estim/internal/compute_skeleton.hh | 3 +-
scribo/scribo/estim/object_groups_mean_width.hh | 3 +-
scribo/scribo/filter/common/objects_photo.hh | 3 +-
scribo/scribo/filter/images_in_paragraph.hh | 5 +-
scribo/scribo/filter/internal/alignment_angle.hh | 11 +-
scribo/scribo/filter/internal/component_aligned.hh | 3 +-
scribo/scribo/filter/internal/compute.hh | 6 +-
scribo/scribo/filter/object_groups_mean_width.hh | 3 +-
scribo/scribo/filter/object_groups_size_ratio.hh | 3 +-
scribo/scribo/filter/object_groups_small.hh | 3 +-
scribo/scribo/filter/object_groups_with_holes.hh | 7 +-
scribo/scribo/filter/object_links_aligned.hh | 3 +-
scribo/scribo/filter/object_links_bbox_h_ratio.hh | 3 +-
scribo/scribo/filter/object_links_bbox_overlap.hh | 3 +-
scribo/scribo/filter/object_links_bbox_ratio.hh | 3 +-
scribo/scribo/filter/object_links_bbox_w_ratio.hh | 3 +-
.../scribo/filter/object_links_bottom_aligned.hh | 3 +-
.../scribo/filter/object_links_center_aligned.hh | 3 +-
scribo/scribo/filter/object_links_left_aligned.hh | 3 +-
.../filter/object_links_non_aligned_simple.hh | 3 +-
scribo/scribo/filter/object_links_right_aligned.hh | 3 +-
scribo/scribo/filter/object_links_top_aligned.hh | 3 +-
scribo/scribo/filter/objects_h_thick.hh | 6 +-
scribo/scribo/filter/objects_h_thin.hh | 6 +-
scribo/scribo/filter/objects_in_borders.hh | 142 +++
scribo/scribo/filter/objects_large.hh | 6 +-
scribo/scribo/filter/objects_on_border.hh | 3 +-
scribo/scribo/filter/objects_size_ratio.hh | 3 +-
scribo/scribo/filter/objects_small.hh | 6 +-
scribo/scribo/filter/objects_thick.hh | 6 +-
scribo/scribo/filter/objects_thin.hh | 6 +-
scribo/scribo/filter/objects_v_thick.hh | 6 +-
scribo/scribo/filter/objects_v_thin.hh | 6 +-
scribo/scribo/filter/objects_with_holes.hh | 8 +-
scribo/scribo/filter/paragraphs_bbox_overlap.hh | 3 +-
scribo/scribo/filter/paragraphs_in_borders.hh | 53 +-
scribo/scribo/filter/paragraphs_in_image.hh | 3 +-
scribo/scribo/filter/separators_in_borders.hh | 66 +-
scribo/scribo/filter/separators_in_element.hh | 3 +-
scribo/scribo/filter/separators_in_paragraph.hh | 3 +-
scribo/scribo/filter/separators_vert_in_borders.hh | 54 +-
scribo/scribo/io/img/save.hh | 8 +-
scribo/scribo/io/text_boxes/save.hh | 3 +-
scribo/scribo/io/xml/internal/save_image_to_xml.hh | 3 +-
scribo/scribo/io/xml/save.hh | 6 +-
scribo/scribo/layout/xy_cut.hh | 32 +-
scribo/scribo/make/debug_filename.hh | 8 +-
scribo/scribo/make/influence_zone_graph.hh | 3 +-
scribo/scribo/make/text_blocks_image.hh | 3 +-
scribo/scribo/make/text_components_image.hh | 8 +-
scribo/scribo/postprocessing/fill_object_holes.hh | 16 +-
.../postprocessing/images_to_drop_capital.hh | 3 +-
scribo/scribo/preprocessing/crop.hh | 3 +-
.../preprocessing/crop_without_localization.hh | 3 +-
scribo/scribo/preprocessing/denoise.hh | 3 +-
scribo/scribo/preprocessing/denoise_bg.hh | 3 +-
scribo/scribo/preprocessing/denoise_fg.hh | 3 +-
scribo/scribo/preprocessing/deskew.hh | 5 +-
scribo/scribo/preprocessing/deskew_crop.hh | 3 +-
.../scribo/preprocessing/homogeneous_contrast.hh | 3 +-
scribo/scribo/preprocessing/rotate_90.hh | 3 +-
scribo/scribo/preprocessing/split_bg_fg.hh | 12 +-
scribo/scribo/primitive/extract/alignments.hh | 11 +-
scribo/scribo/primitive/extract/canvas.hh | 3 +-
scribo/scribo/primitive/extract/cells.hh | 3 +-
scribo/scribo/primitive/extract/components.hh | 46 +-
.../primitive/extract/horizontal_separators.hh | 3 +-
scribo/scribo/primitive/extract/internal/union.hh | 2 +-
.../scribo/primitive/extract/lines_discontinued.hh | 3 +-
.../primitive/extract/lines_h_discontinued.hh | 3 +-
scribo/scribo/primitive/extract/lines_h_pattern.hh | 3 +-
scribo/scribo/primitive/extract/lines_h_single.hh | 12 +-
scribo/scribo/primitive/extract/lines_h_thick.hh | 3 +-
.../primitive/extract/lines_h_thick_and_single.hh | 3 +-
.../primitive/extract/lines_h_thick_and_thin.hh | 3 +-
scribo/scribo/primitive/extract/lines_pattern.hh | 9 +-
scribo/scribo/primitive/extract/lines_thick.hh | 3 +-
.../primitive/extract/lines_v_discontinued.hh | 3 +-
scribo/scribo/primitive/extract/lines_v_pattern.hh | 3 +-
scribo/scribo/primitive/extract/lines_v_single.hh | 8 +-
scribo/scribo/primitive/extract/lines_v_thick.hh | 3 +-
.../primitive/extract/lines_v_thick_and_single.hh | 3 +-
scribo/scribo/primitive/extract/non_text.hh | 9 +-
scribo/scribo/primitive/extract/non_text_hdoc.hh | 5 +-
scribo/scribo/primitive/extract/non_text_kmean.hh | 5 +-
scribo/scribo/primitive/extract/separators.hh | 3 +-
.../primitive/extract/separators_nonvisible.hh | 3 +-
.../primitive/extract/vertical_separators.hh | 3 +-
scribo/scribo/primitive/group/apply.hh | 6 +-
scribo/scribo/primitive/group/from_double_link.hh | 3 +-
.../scribo/primitive/group/from_double_link_any.hh | 3 +-
scribo/scribo/primitive/group/from_graph.hh | 3 +-
scribo/scribo/primitive/group/from_single_link.hh | 3 +-
scribo/scribo/primitive/identify.hh | 8 +-
.../scribo/primitive/internal/find_graph_link.hh | 3 +-
scribo/scribo/primitive/internal/rd.hh | 6 +-
.../scribo/primitive/internal/update_graph_link.hh | 3 +-
scribo/scribo/primitive/link/compute.hh | 3 +-
scribo/scribo/primitive/link/compute_several.hh | 3 +-
.../primitive/link/internal/compute_anchor.hh | 4 +-
.../primitive/link/internal/find_several_links.hh | 4 +-
.../primitive/link/internal/link_functor_base.hh | 2 +-
scribo/scribo/primitive/link/merge_double_link.hh | 3 +-
.../link/merge_double_link_closest_aligned.hh | 5 +-
scribo/scribo/primitive/link/with_graph.hh | 3 +-
scribo/scribo/primitive/link/with_rag.hh | 3 +-
.../scribo/primitive/link/with_several_graphes.hh | 3 +-
.../primitive/link/with_several_left_links.hh | 3 +-
.../link/with_several_right_closest_links.hh | 3 +-
.../primitive/link/with_several_right_links.hh | 3 +-
.../link/with_several_right_links_overlap.hh | 3 +-
.../scribo/primitive/link/with_single_down_link.hh | 3 +-
.../scribo/primitive/link/with_single_left_link.hh | 3 +-
.../link/with_single_left_link_dmax_ratio.hh | 3 +-
.../with_single_left_link_dmax_ratio_aligned.hh | 14 +-
.../primitive/link/with_single_right_link.hh | 3 +-
.../link/with_single_right_link_bottom.hh | 3 +-
.../link/with_single_right_link_dmax_ratio.hh | 3 +-
.../with_single_right_link_dmax_ratio_aligned.hh | 3 +-
.../primitive/link/with_single_right_link_top.hh | 3 +-
.../scribo/primitive/link/with_single_up_link.hh | 3 +-
scribo/scribo/primitive/merge/components.hh | 3 +-
.../primitive/regroup/from_single_left_link.hh | 3 +-
.../regroup/from_single_left_link_wrt_h_ratio.hh | 3 +-
scribo/scribo/primitive/remove/separators.hh | 3 +-
scribo/scribo/subsampling/bilinear.hh | 7 +-
scribo/scribo/subsampling/integral.hh | 12 +-
scribo/scribo/subsampling/integral_single_image.hh | 12 +-
scribo/scribo/table/align_lines_horizontaly.hh | 3 +-
scribo/scribo/table/align_lines_verticaly.hh | 3 +-
scribo/scribo/table/connect_horizontal_lines.hh | 3 +-
scribo/scribo/table/connect_vertical_lines.hh | 3 +-
scribo/scribo/table/erase.hh | 3 +-
scribo/scribo/table/extract.hh | 3 +-
scribo/scribo/table/internal/align_lines.hh | 3 +-
scribo/scribo/table/internal/connect_lines.hh | 3 +-
scribo/scribo/table/internal/repair_lines.hh | 3 +-
scribo/scribo/table/rebuild.hh | 3 +-
scribo/scribo/table/repair_horizontal_lines.hh | 3 +-
scribo/scribo/table/repair_vertical_lines.hh | 3 +-
scribo/scribo/text/clean.hh | 3 +-
scribo/scribo/text/clean_inplace.hh | 3 +-
scribo/scribo/text/extract_lines.hh | 6 +-
scribo/scribo/text/extract_lines_with_features.hh | 3 +-
scribo/scribo/text/extract_lines_wo_merge.hh | 3 +-
scribo/scribo/text/extract_paragraphs_hdoc.hh | 5 +-
scribo/scribo/text/link_lines.hh | 8 +-
scribo/scribo/text/look_like_text_lines.hh | 6 +-
scribo/scribo/text/merging_hdoc.hh | 112 +--
scribo/scribo/text/paragraphs_closing.hh | 3 +-
scribo/scribo/text/recognition.hh | 12 +-
.../internal/text_in_doc_preprocess_functor.hh | 2 +-
scribo/scribo/toolchain/nepomuk/text_extraction.hh | 3 +-
scribo/scribo/toolchain/text_in_doc_preprocess.hh | 5 +-
scribo/scribo/toolchain/text_in_picture.hh | 3 +-
scribo/scribo/upsampling/bs2x.hh | 3 +-
scribo/scribo/upsampling/eagle.hh | 3 +-
scribo/scribo/util/box_intersection.hh | 3 +-
scribo/scribo/util/box_is_included.hh | 3 +-
scribo/scribo/util/component_precise_outline.hh | 13 +-
scribo/scribo/util/compute_sub_domains.hh | 3 +-
scribo/scribo/util/hex_to_color.hh | 3 +-
scribo/scribo/util/init_integral_image.hh | 12 +-
scribo/src/afp/regroup.hh | 5 +-
scribo/src/binarization/global_threshold.cc | 9 +-
scribo/src/binarization/kim.cc | 7 +-
scribo/src/binarization/niblack.cc | 5 +-
scribo/src/binarization/otsu.cc | 5 +-
.../src/binarization/pgm_global_threshold_auto.cc | 3 +-
.../binarization/pgm_niblack_threshold_image.cc | 3 +-
scribo/src/binarization/sauvola.cc | 9 +-
scribo/src/binarization/sauvola_debug.cc | 3 +-
scribo/src/binarization/sauvola_ms.cc | 8 +-
scribo/src/binarization/sauvola_ms_debug.cc | 12 +-
scribo/src/binarization/sauvola_ms_fg.cc | 8 +-
scribo/src/binarization/sauvola_ms_split.cc | 6 +-
scribo/src/binarization/singh.cc | 8 +-
scribo/src/binarization/wolf.cc | 5 +-
scribo/src/content_in_doc.cc | 5 +-
scribo/src/content_in_hdoc.cc | 5 +-
scribo/src/contest/DAE-2011/content_in_doc_dae.cc | 9 +-
scribo/src/contest/DAE-2011/content_in_hdoc_dae.cc | 9 +-
scribo/src/contest/Makefile.am | 6 +-
scribo/src/contest/hbr-2013/Makefile.am | 33 +
scribo/src/contest/hbr-2013/content_in_hdoc_hbr.cc | 148 +++
.../contest/hdlac-2011/content_in_hdoc_hdlac.cc | 7 +-
scribo/src/contest/hnla-2013/Makefile.am | 33 +
.../src/contest/hnla-2013/content_in_hdoc_hnla.cc | 149 +++
scribo/src/debug/highlight_text_area.cc | 3 +-
scribo/src/debug/show_components_boldness.cc | 5 +-
scribo/src/debug/show_components_color.cc | 6 +-
.../src/debug/show_info_median_inter_characters.cc | 3 +-
scribo/src/debug/show_info_x_height.cc | 3 +-
scribo/src/debug/show_lines_boldness.cc | 3 +-
scribo/src/debug/show_objects_large.cc | 2 +-
scribo/src/debug/show_objects_large_small.cc | 2 +-
scribo/src/debug/show_objects_small.cc | 2 +-
scribo/src/debug/show_objects_thick.cc | 2 +-
scribo/src/debug/show_objects_thin.cc | 2 +-
scribo/src/debug/show_paragraph_blocks.cc | 3 +-
scribo/src/debug/show_separators.cc | 3 +-
scribo/src/debug/show_stoppers.cc | 3 +-
scribo/src/debug/show_text_lines.cc | 3 +-
scribo/src/debug/show_text_lines_wo_seps.cc | 3 +-
scribo/src/filter/objects_large.cc | 3 +-
scribo/src/filter/objects_small.cc | 3 +-
scribo/src/filter/objects_thick.cc | 3 +-
scribo/src/filter/objects_thin.cc | 3 +-
scribo/src/filter/objects_with_holes.cc | 3 +-
scribo/src/filter/objects_with_holes_pgm.cc | 3 +-
scribo/src/misc/negate.cc | 7 +-
scribo/src/misc/superpose.cc | 7 +-
scribo/src/non_text_components.cc | 9 +-
scribo/src/pbm_text_in_doc.cc | 3 +-
scribo/src/postprocessing/fill_object_holes.cc | 3 +-
scribo/src/preprocessing/denoise_bg.cc | 3 +-
scribo/src/preprocessing/denoise_fg.cc | 3 +-
scribo/src/preprocessing/preprocess.cc | 3 +-
scribo/src/preprocessing/rotate.cc | 5 +-
scribo/src/preprocessing/rotate_90.cc | 5 +-
scribo/src/preprocessing/split_bg_fg.cc | 7 +-
scribo/src/preprocessing/subsample.cc | 3 +-
scribo/src/preprocessing/unskew.cc | 7 +-
scribo/src/primitive/extract/alignments.cc | 3 +-
.../src/primitive/extract/discontinued_hlines.cc | 3 +-
scribo/src/primitive/extract/discontinued_lines.cc | 3 +-
.../src/primitive/extract/discontinued_vlines.cc | 3 +-
scribo/src/primitive/extract/lines_pattern.cc | 3 +-
.../src/primitive/extract/separators_nonvisible.cc | 3 +-
scribo/src/primitive/extract/thick_hlines.cc | 3 +-
scribo/src/primitive/extract/thick_vlines.cc | 3 +-
.../src/primitive/find/find_discontinued_lines.cc | 3 +-
scribo/src/primitive/find/find_pattern_lines.cc | 3 +-
scribo/src/primitive/find/find_single_lines.cc | 3 +-
.../primitive/find/find_thick_and_single_lines.cc | 3 +-
scribo/src/primitive/find/find_thick_lines.cc | 3 +-
scribo/src/primitive/remove/separators.cc | 3 +-
scribo/src/table/erase.cc | 3 +-
scribo/src/table/extract.cc | 3 +-
scribo/src/text/cleantxt.cc | 3 +-
scribo/src/text/pbm_lines_recognition.cc | 3 +-
scribo/src/text/pbm_recognition.cc | 3 +-
scribo/src/text_in_doc_preprocess.cc | 6 +-
scribo/src/text_in_picture.cc | 7 +-
scribo/src/text_in_picture_dual.cc | 8 +-
scribo/src/text_recognition_in_picture.cc | 7 +-
scribo/src/util/component_precise_outline.cc | 3 +-
scribo/tests/Makefile.am | 4 +
scribo/tests/binarization/Makefile.am | 7 +-
scribo/tests/binarization/niblack.cc | 16 +-
scribo/tests/binarization/wolf.cc | 16 +-
scribo/tests/primitive/extract/Makefile.am | 3 +-
scribo/tests/unit_test/unit-tests.mk | 2 +
swilena/ChangeLog | 299 +++++
swilena/Makefile.am | 12 +-
swilena/box.ixx | 2 +-
swilena/box2d.i | 7 +-
swilena/box_piter.ixx | 3 +-
swilena/complex.ixx | 330 ++++++
swilena/complex2.i | 111 ++
swilena/concat.ixx | 4 +-
swilena/image2d.ixx | 30 +-
swilena/image2d_int.i | 5 +-
swilena/image2d_int_u8.i | 12 +-
swilena/image2d_point2d.i | 53 +
swilena/image2d_rgb8.i | 63 ++
swilena/int_u.ixx | 24 +-
swilena/int_u32.i | 40 -
swilena/morpho.ixx | 43 +-
swilena/ppm.ixx | 57 +
swilena/python-utils.ixx | 3 +-
swilena/python/Makefile.am | 202 +++-
swilena/python/complex2-misc.py | 99 ++
swilena/python/data.py | 26 -
swilena/python/data.py.in | 26 +
swilena/python/installcheck.mk | 116 ++
swilena/python/ltihooks.py | 60 -
swilena/python/max-tree.py | 57 +
swilena/python/morpho-segm.py | 8 +-
swilena/python/sps-gdb-local.in | 6 +
swilena/python/sps-local.in | 2 +-
swilena/python/swilena.py | 13 +-
swilena/rgb.ixx | 159 +++
swilena/rgb8.i | 40 +
swilena/run.in | 50 +-
1054 files changed, 12025 insertions(+), 5697 deletions(-)
create mode 100644 milena/doc/examples.dox
create mode 100644 milena/doc/examples/multi_files_f1.cc.raw
create mode 100644 milena/doc/examples/multi_files_f2.cc.raw
create mode 100644 milena/doc/examples/multi_files_main.cc.raw
create mode 100644 milena/doc/examples/multiple_def.cc.raw
create mode 100644 milena/doc/examples/typenametemplate.cc.raw
create mode 100644 milena/doc/examples/undef_global_vars.cc.raw
create mode 100644 milena/doc/examples/wrongvaluetype.cc.raw
create mode 100644 milena/doc/img/2dgrid.png
create mode 100644 milena/doc/mln/convert.dox
create mode 100644 milena/doc/mln/core/alias/box1d.dox
create mode 100644 milena/doc/mln/core/alias/box2d.dox
create mode 100644 milena/doc/mln/core/alias/box2d_h.dox
create mode 100644 milena/doc/mln/core/alias/box3d.dox
create mode 100644 milena/doc/mln/core/alias/complex_geometry.dox
create mode 100644 milena/doc/mln/core/alias/complex_image.dox
create mode 100644 milena/doc/mln/core/alias/dpoint1d.dox
create mode 100644 milena/doc/mln/core/alias/dpoint2d.dox
create mode 100644 milena/doc/mln/core/alias/dpoint3d.dox
create mode 100644 milena/doc/mln/core/alias/neighb1d.dox
create mode 100644 milena/doc/mln/core/alias/neighb2d.dox
create mode 100644 milena/doc/mln/core/alias/neighb3d.dox
create mode 100644 milena/doc/mln/core/alias/p_run2d.dox
create mode 100644 milena/doc/mln/core/alias/p_runs2d.dox
create mode 100644 milena/doc/mln/core/alias/point1d.dox
create mode 100644 milena/doc/mln/core/alias/point2d.dox
create mode 100644 milena/doc/mln/core/alias/point2d_h.dox
create mode 100644 milena/doc/mln/core/alias/point3d.dox
create mode 100644 milena/doc/mln/core/alias/vec2d.dox
create mode 100644 milena/doc/mln/core/alias/vec3d.dox
create mode 100644 milena/doc/mln/core/alias/w_window1d_float.dox
create mode 100644 milena/doc/mln/core/alias/w_window1d_int.dox
create mode 100644 milena/doc/mln/core/alias/w_window2d_float.dox
create mode 100644 milena/doc/mln/core/alias/w_window2d_int.dox
create mode 100644 milena/doc/mln/core/alias/w_window3d_float.dox
create mode 100644 milena/doc/mln/core/alias/w_window3d_int.dox
create mode 100644 milena/doc/mln/core/alias/window1d.dox
create mode 100644 milena/doc/mln/core/alias/window2d.dox
create mode 100644 milena/doc/mln/core/alias/window3d.dox
create mode 100644 milena/doc/mln/core/concept/concept.dox
create mode 100644 milena/doc/mln/labeling/labeling.dox
create mode 100644 milena/doc/mln/value/hsl.dox
create mode 100644 milena/doc/mln/value/int_s16.dox
create mode 100644 milena/doc/mln/value/int_s24.dox
create mode 100644 milena/doc/mln/value/int_s32.dox
create mode 100644 milena/doc/mln/value/int_s8.dox
create mode 100644 milena/doc/mln/value/int_u12.dox
create mode 100644 milena/doc/mln/value/int_u16.dox
create mode 100644 milena/doc/mln/value/int_u24.dox
create mode 100644 milena/doc/mln/value/int_u32.dox
create mode 100644 milena/doc/mln/value/int_u8.dox
create mode 100644 milena/doc/mln/value/label_16.dox
create mode 100644 milena/doc/mln/value/label_32.dox
create mode 100644 milena/doc/mln/value/label_8.dox
create mode 100644 milena/doc/mln/value/rgb16.dox
create mode 100644 milena/doc/mln/value/rgb8.dox
create mode 100644 milena/doc/mln/value/value.dox
create mode 100644 milena/doc/mln/win/disk2d.dox
create mode 100644 milena/doc/mln/win/hline2d.dox
create mode 100644 milena/doc/mln/win/segment1d.dox
create mode 100644 milena/doc/mln/win/sline3d.dox
create mode 100644 milena/doc/mln/win/sphere3d.dox
create mode 100644 milena/doc/mln/win/vline2d.dox
create mode 100644 milena/mln/debug/trace.hh
create mode 100755 milena/mln/fun/v2b/always_false.hh
create mode 100755 milena/mln/fun/v2b/always_true.hh
create mode 100644 milena/mln/io/magick/internal/init_magick.hh
delete mode 120000 milena/mln/linear/.#ch_convolve.hh
delete mode 100644 milena/mln/morpho/meyer_wst.hh
create mode 100644 milena/mln/registration/all.hh
delete mode 100644 milena/mln/trace/all.hh
delete mode 100644 milena/mln/trace/entering.hh
delete mode 100644 milena/mln/trace/essential.hh
delete mode 100644 milena/mln/trace/exiting.hh
delete mode 100644 milena/mln/trace/quiet.hh
delete mode 100644 milena/mln/trace/resume.hh
delete mode 100644 milena/mln/trace/stop.hh
delete mode 100644 milena/mln/trace/warning.hh
create mode 100644 milena/tests/labeling/foreground.ref.pgm
delete mode 100644 milena/tests/morpho/meyer_wst.cc
delete mode 100644 milena/tests/morpho/meyer_wst_long.cc
create mode 100644 milena/tests/unit_test/cond_tests_poppler
create mode 100644 scribo/doc/scribo/binarization/kim.dox
create mode 100644 scribo/doc/scribo/binarization/wolf.dox
create mode 100644 scribo/doc/scribo/layout/layout.dox
create mode 100644 scribo/doc/scribo/namespaces.dox
create mode 100644 scribo/doc/scribo/primitive/extract/components.dox
create mode 100644 scribo/doc/scribo/primitive/extract/extract.dox
create mode 100644 scribo/scribo/binarization/internal/global_max_stddev_functor.hh
create mode 100644 scribo/scribo/filter/objects_in_borders.hh
create mode 100644 scribo/src/contest/hbr-2013/Makefile.am
create mode 100644 scribo/src/contest/hbr-2013/content_in_hdoc_hbr.cc
create mode 100644 scribo/src/contest/hnla-2013/Makefile.am
create mode 100644 scribo/src/contest/hnla-2013/content_in_hdoc_hnla.cc
create mode 100644 swilena/complex.ixx
create mode 100644 swilena/complex2.i
create mode 100644 swilena/image2d_point2d.i
create mode 100644 swilena/image2d_rgb8.i
delete mode 100644 swilena/int_u32.i
create mode 100644 swilena/ppm.ixx
create mode 100644 swilena/python/complex2-misc.py
delete mode 100644 swilena/python/data.py
create mode 100644 swilena/python/data.py.in
create mode 100644 swilena/python/installcheck.mk
delete mode 100644 swilena/python/ltihooks.py
create mode 100644 swilena/python/max-tree.py
create mode 100644 swilena/python/sps-gdb-local.in
create mode 100644 swilena/rgb.ixx
create mode 100644 swilena/rgb8.i
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch next has been updated
via efabb3bcb01ae366f463abf4fa14303efce4cda7 (commit)
from 276ad3db3217651981534e7a5908c0b8954d2502 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
efabb3b Remove unstable viewer.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 80 +++++
GScribo/BUGS | 1 -
GScribo/GScribo.pro | 83 -----
GScribo/GScribo.pro.user | 405 -------------------------
GScribo/GScribo.pro.user.1.3 | 283 ------------------
GScribo/PagesWidget/pagesdelegate.cpp | 20 --
GScribo/PagesWidget/pagesdelegate.h | 18 --
GScribo/PagesWidget/pagesmodel.cpp | 55 ----
GScribo/PagesWidget/pagesmodel.h | 43 ---
GScribo/PagesWidget/pageswidget.cpp | 49 ---
GScribo/PagesWidget/pageswidget.h | 55 ----
GScribo/Preferences/generaloptions.cpp | 44 ---
GScribo/Preferences/generaloptions.h | 34 --
GScribo/Preferences/generaloptions.ui | 100 ------
GScribo/Preferences/ocroptions.cpp | 53 ----
GScribo/Preferences/ocroptions.h | 33 --
GScribo/Preferences/ocroptions.ui | 62 ----
GScribo/Preferences/optionwidget.h | 15 -
GScribo/Preferences/preferencesdialog.cpp | 98 ------
GScribo/Preferences/preferencesdialog.h | 42 ---
GScribo/Preferences/preferencesdialog.ui | 121 --------
GScribo/Preferences/preprocessingoptions.cpp | 45 ---
GScribo/Preferences/preprocessingoptions.h | 32 --
GScribo/Preferences/preprocessingoptions.ui | 76 -----
GScribo/Preferences/segmentationoptions.cpp | 33 --
GScribo/Preferences/segmentationoptions.h | 31 --
GScribo/Preferences/segmentationoptions.ui | 52 ----
GScribo/Processing/preprocess.cpp | 11 -
GScribo/Processing/preprocess.h | 26 --
GScribo/Processing/process.cpp | 21 --
GScribo/Processing/process.h | 29 --
GScribo/Processing/progressdialog.cpp | 16 -
GScribo/Processing/progressdialog.h | 22 --
GScribo/Processing/runner.cpp | 183 -----------
GScribo/Processing/runner.h | 58 ----
GScribo/Rendering/abstractregionitem.h | 13 -
GScribo/Rendering/backgroundtexture.h | 12 -
GScribo/Rendering/graphicsview.cpp | 150 ---------
GScribo/Rendering/graphicsview.h | 43 ---
GScribo/Rendering/regionitem.cpp | 59 ----
GScribo/Rendering/regionitem.h | 80 -----
GScribo/Rendering/rootgraphicsitem.h | 30 --
GScribo/Rendering/scene.cpp | 273 -----------------
GScribo/Rendering/scene.h | 118 --------
GScribo/Rendering/selection.cpp | 36 ---
GScribo/Rendering/selection.h | 20 --
GScribo/TODO | 100 ------
GScribo/XmlWidget/attributesmodel.cpp | 69 -----
GScribo/XmlWidget/attributesmodel.h | 48 ---
GScribo/XmlWidget/selectionproxy.h | 47 ---
GScribo/XmlWidget/xmlattributes.cpp | 23 --
GScribo/XmlWidget/xmlattributes.h | 33 --
GScribo/XmlWidget/xmldelegate.h | 30 --
GScribo/XmlWidget/xmlitem.cpp | 43 ---
GScribo/XmlWidget/xmlitem.h | 90 ------
GScribo/XmlWidget/xmlmodel.cpp | 87 ------
GScribo/XmlWidget/xmlmodel.h | 44 ---
GScribo/XmlWidget/xmlview.cpp | 88 ------
GScribo/XmlWidget/xmlview.h | 79 -----
GScribo/XmlWidget/xmlwidget.cpp | 34 --
GScribo/XmlWidget/xmlwidget.h | 54 ----
GScribo/aboutdialog.h | 25 --
GScribo/aboutdialog.ui | 136 ---------
GScribo/configs.h | 134 ---------
GScribo/dir.h | 7 -
GScribo/dockwidget.h | 22 --
GScribo/main.cpp | 23 --
GScribo/mainwindow.cpp | 415 --------------------------
GScribo/mainwindow.h | 120 --------
GScribo/mainwindow.ui | 35 ---
GScribo/region.h | 56 ----
GScribo/regionwidget.cpp | 70 -----
GScribo/regionwidget.h | 40 ---
GScribo/variantpointer.h | 19 --
GScribo/xml.cpp | 206 -------------
GScribo/xml.h | 93 ------
76 files changed, 80 insertions(+), 5353 deletions(-)
delete mode 100644 GScribo/BUGS
delete mode 100644 GScribo/GScribo.pro
delete mode 100644 GScribo/GScribo.pro.user
delete mode 100644 GScribo/GScribo.pro.user.1.3
delete mode 100644 GScribo/PagesWidget/pagesdelegate.cpp
delete mode 100644 GScribo/PagesWidget/pagesdelegate.h
delete mode 100644 GScribo/PagesWidget/pagesmodel.cpp
delete mode 100644 GScribo/PagesWidget/pagesmodel.h
delete mode 100644 GScribo/PagesWidget/pageswidget.cpp
delete mode 100644 GScribo/PagesWidget/pageswidget.h
delete mode 100644 GScribo/Preferences/generaloptions.cpp
delete mode 100644 GScribo/Preferences/generaloptions.h
delete mode 100644 GScribo/Preferences/generaloptions.ui
delete mode 100644 GScribo/Preferences/ocroptions.cpp
delete mode 100644 GScribo/Preferences/ocroptions.h
delete mode 100644 GScribo/Preferences/ocroptions.ui
delete mode 100644 GScribo/Preferences/optionwidget.h
delete mode 100644 GScribo/Preferences/preferencesdialog.cpp
delete mode 100644 GScribo/Preferences/preferencesdialog.h
delete mode 100644 GScribo/Preferences/preferencesdialog.ui
delete mode 100644 GScribo/Preferences/preprocessingoptions.cpp
delete mode 100644 GScribo/Preferences/preprocessingoptions.h
delete mode 100644 GScribo/Preferences/preprocessingoptions.ui
delete mode 100644 GScribo/Preferences/segmentationoptions.cpp
delete mode 100644 GScribo/Preferences/segmentationoptions.h
delete mode 100644 GScribo/Preferences/segmentationoptions.ui
delete mode 100644 GScribo/Processing/preprocess.cpp
delete mode 100644 GScribo/Processing/preprocess.h
delete mode 100644 GScribo/Processing/process.cpp
delete mode 100644 GScribo/Processing/process.h
delete mode 100644 GScribo/Processing/progressdialog.cpp
delete mode 100644 GScribo/Processing/progressdialog.h
delete mode 100644 GScribo/Processing/runner.cpp
delete mode 100644 GScribo/Processing/runner.h
delete mode 100644 GScribo/Rendering/abstractregionitem.h
delete mode 100644 GScribo/Rendering/backgroundtexture.h
delete mode 100644 GScribo/Rendering/graphicsview.cpp
delete mode 100644 GScribo/Rendering/graphicsview.h
delete mode 100644 GScribo/Rendering/regionitem.cpp
delete mode 100644 GScribo/Rendering/regionitem.h
delete mode 100644 GScribo/Rendering/rootgraphicsitem.h
delete mode 100644 GScribo/Rendering/scene.cpp
delete mode 100644 GScribo/Rendering/scene.h
delete mode 100644 GScribo/Rendering/selection.cpp
delete mode 100644 GScribo/Rendering/selection.h
delete mode 100644 GScribo/TODO
delete mode 100644 GScribo/XmlWidget/attributesmodel.cpp
delete mode 100644 GScribo/XmlWidget/attributesmodel.h
delete mode 100644 GScribo/XmlWidget/selectionproxy.h
delete mode 100644 GScribo/XmlWidget/xmlattributes.cpp
delete mode 100644 GScribo/XmlWidget/xmlattributes.h
delete mode 100644 GScribo/XmlWidget/xmldelegate.h
delete mode 100644 GScribo/XmlWidget/xmlitem.cpp
delete mode 100644 GScribo/XmlWidget/xmlitem.h
delete mode 100644 GScribo/XmlWidget/xmlmodel.cpp
delete mode 100644 GScribo/XmlWidget/xmlmodel.h
delete mode 100644 GScribo/XmlWidget/xmlview.cpp
delete mode 100644 GScribo/XmlWidget/xmlview.h
delete mode 100644 GScribo/XmlWidget/xmlwidget.cpp
delete mode 100644 GScribo/XmlWidget/xmlwidget.h
delete mode 100644 GScribo/aboutdialog.h
delete mode 100644 GScribo/aboutdialog.ui
delete mode 100644 GScribo/configs.h
delete mode 100644 GScribo/dir.h
delete mode 100644 GScribo/dockwidget.h
delete mode 100644 GScribo/main.cpp
delete mode 100644 GScribo/mainwindow.cpp
delete mode 100644 GScribo/mainwindow.h
delete mode 100644 GScribo/mainwindow.ui
delete mode 100644 GScribo/region.h
delete mode 100644 GScribo/regionwidget.cpp
delete mode 100644 GScribo/regionwidget.h
delete mode 100644 GScribo/variantpointer.h
delete mode 100644 GScribo/xml.cpp
delete mode 100644 GScribo/xml.h
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Olena, a generic and efficient image processing platform".
The branch exp/all-blobs has been updated
via f8e6233302741208eb78a51e9f0c8655115422fc (commit)
via fe3d6d46aa9357d3db8fdbe118d421faf6b540cd (commit)
from 18a58d33480cce146e8aa2f2f5edb4ccc7b75cea (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
f8e6233 Add support for graylevel images in labeling::blobs.
fe3d6d4 mln/core/internal/pixel_impl.hh: Add change_offset().
-----------------------------------------------------------------------
Summary of changes:
milena/ChangeLog | 22 +++++
milena/mln/canvas/labeling/blobs.hh | 136 ++++++++++++++++++++++++++--
milena/mln/core/internal/pixel_impl.hh | 6 ++
milena/mln/labeling/all_blobs.hh | 127 --------------------------
milena/mln/labeling/blobs.hh | 65 ++++++++++----
milena/mln/labeling/blobs_and_compute.hh | 83 +++++++++++++++--
milena/tests/labeling/Makefile.am | 1 -
milena/tests/labeling/all_blobs.cc | 63 -------------
milena/tests/labeling/blobs.cc | 26 +++++-
milena/tests/labeling/blobs_and_compute.cc | 55 ++++++++---
10 files changed, 339 insertions(+), 245 deletions(-)
delete mode 100644 milena/mln/labeling/all_blobs.hh
delete mode 100644 milena/tests/labeling/all_blobs.cc
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

olena: olena-2.0-555-gdb8fbc5 Add support for graylevel images in labeling::blobs.
by Guillaume Lazzara 18 Apr '13
by Guillaume Lazzara 18 Apr '13
18 Apr '13
* mln/canvas/labeling/blobs.hh: Add a fastest version and make it
support graylevel images.
* mln/labeling/blobs.hh,
* mln/labeling/blobs_and_compute.hh: Add support for graylevel images.
* tests/labeling/blobs.cc,
* tests/labeling/blobs_and_compute.cc: Add a test for graylevel images.
* tests/labeling/Makefile.am: Remove all_blobs target.
* mln/labeling/all_blobs.hh,
* tests/labeling/all_blobs.cc: Remove.
---
milena/ChangeLog | 18 ++++
milena/mln/canvas/labeling/blobs.hh | 136 ++++++++++++++++++++++++++--
milena/mln/labeling/all_blobs.hh | 127 --------------------------
milena/mln/labeling/blobs.hh | 65 ++++++++++----
milena/mln/labeling/blobs_and_compute.hh | 83 +++++++++++++++--
milena/tests/labeling/Makefile.am | 1 -
milena/tests/labeling/all_blobs.cc | 63 -------------
milena/tests/labeling/blobs.cc | 26 +++++-
milena/tests/labeling/blobs_and_compute.cc | 55 ++++++++---
9 files changed, 329 insertions(+), 245 deletions(-)
delete mode 100644 milena/mln/labeling/all_blobs.hh
delete mode 100644 milena/tests/labeling/all_blobs.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 326f6e0..0688513 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,23 @@
2013-04-18 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add support for graylevel images in labeling::blobs.
+
+ * mln/canvas/labeling/blobs.hh: Add a fastest version and make it
+ support graylevel images.
+
+ * mln/labeling/blobs.hh,
+ * mln/labeling/blobs_and_compute.hh: Add support for graylevel images.
+
+ * tests/labeling/blobs.cc,
+ * tests/labeling/blobs_and_compute.cc: Add a test for graylevel images.
+
+ * tests/labeling/Makefile.am: Remove all_blobs target.
+
+ * mln/labeling/all_blobs.hh,
+ * tests/labeling/all_blobs.cc: Remove.
+
+2013-04-18 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/core/internal/pixel_impl.hh: Add change_offset().
2013-04-17 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/mln/canvas/labeling/blobs.hh b/milena/mln/canvas/labeling/blobs.hh
index 4a643ce..f913901 100644
--- a/milena/mln/canvas/labeling/blobs.hh
+++ b/milena/mln/canvas/labeling/blobs.hh
@@ -90,9 +90,15 @@ namespace mln
template <typename I, typename N, typename L, typename F>
mln_ch_value(I, L)
- blobs(const Image<I>& input_, const N& nbh, L& nlabels, F& functor)
+ blobs(const Image<I>& input_, const Neighborhood<N>& nbh_, L& nlabels, F& functor)
{
+ mln_trace("mln::canvas::labeling::impl::generic::blobs");
+
const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(nbh.is_valid());
typedef mln_psite(I) P;
@@ -108,20 +114,24 @@ namespace mln
initialize(output, input);
data::fill(output, zero);
- //extension::fill(input, false);
+ // No initialization needed in border since we look into
+ // the image domain for the neighborhood.
+ //
+ // extension::fill(input, functor.neutral_value()); // <-- functor.neutral_value()
functor.init(); // <-- functor.init()
// Loop.
mln_piter(I) p(input.domain());
for_all(p)
- if (functor.handles(input(p)) && output(p) == zero) // Object point, not labeled yet.
+ if (functor.handles(input(p)) // <-- functor.handles()
+ && output(p) == zero) // Object point, not labeled yet.
{
// Label this point component.
if (nlabels == mln_max(L))
{
- mln_trace_warning("labeling aborted! Too many labels \
-for this label type: nlabels > max(label_type).");
+ mln_trace_warning("labeling aborted! Too many labels "
+ "for this label type: nlabels > max(label_type).");
return output;
}
@@ -157,10 +167,119 @@ for this label type: nlabels > max(label_type).");
} // end of namespace mln::labeling::impl::generic
+ template <typename I, typename N, typename L, typename F>
+ mln_ch_value(I, L)
+ blobs_fastest(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ L& nlabels, F& functor)
+ {
+ mln_trace("mln::canvas::labeling::impl::blobs_fastest");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(nbh.is_valid());
+
+ typedef mln_psite(I) P;
+
+ mln_pixter(const I) cur(input);
+ mln_nixter(const I,N) n(cur, nbh);
+ p_queue_fast<unsigned> qu;
+ const L zero = literal::zero;
+
+ // Initialization.
+ nlabels = literal::zero;
+ typedef mln_ch_value(I, L) out_t;
+ out_t output;
+ initialize(output, input);
+ data::fill(output, zero);
+
+ extension::fill(input, functor.neutral_value()); // <-- functor.neutral_value()
+
+ functor.init(); // <-- functor.init()
+
+ // Loop.
+ mln_pixter(const I) p(input);
+ for_all(p)
+ if (functor.handles(p.val()) // <-- functor.handles()
+ && output.element(p.offset()) == zero) // Object point, not labeled yet.
+ {
+ // Label this point component.
+ if (nlabels == mln_max(L))
+ {
+ mln_trace_warning("labeling aborted! Too many labels "
+ "for this label type: nlabels > max(label_type).");
+
+ return output;
+ }
+ ++nlabels;
+ functor.new_label(nlabels); // <-- functor.new_label()
+ mln_invariant(qu.is_empty());
+ qu.push(p.offset());
+ output.element(p.offset()) = nlabels;
+ functor.process_p_(p.offset()); // <-- functor.process_p_()
+ do
+ {
+ cur.change_offset(qu.front());
+ qu.pop();
+ for_all(n)
+ if (p.val() == n.val() && output.element(n.offset()) == zero)
+ {
+ mln_invariant(! qu.compute_has(n.offset()));
+ qu.push(n.offset());
+ output.element(n) = nlabels;
+ functor.process_n_(n.offset()); // <-- functor.process_n_()
+ }
+ }
+ while (! qu.is_empty());
+ }
+
+ functor.finalize(); // <-- functor.finalize()
+
+ return output;
+ }
+
} // end of namespace mln::canvas::labeling::impl
+ // Dispatch
+
+ namespace internal
+ {
+
+ template <typename I, typename N, typename L, typename F>
+ inline
+ mln_ch_value(I, L)
+ blobs_dispatch(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels, F& functor, mln::trait::image::speed::any)
+ {
+ return impl::generic::blobs(input, nbh, nlabels, functor);
+ }
+
+ template <typename I, typename N, typename L, typename F>
+ inline
+ mln_ch_value(I, L)
+ blobs_dispatch(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels, F& functor, mln::trait::image::speed::fastest)
+ {
+ return impl::blobs_fastest(input, nbh, nlabels, functor);
+ }
+
+ template <typename I, typename N, typename L, typename F>
+ inline
+ mln_ch_value(I, L)
+ blobs_dispatch(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels, F& functor)
+ {
+ typedef mln_trait_image_speed(I) speed;
+ return blobs_dispatch(input, nbh, nlabels, functor, speed());
+ }
+
+ } // end of namespace mln::canvas::labeling::internal
+
+
+
// Facade.
template <typename I, typename N, typename L, typename F>
@@ -169,16 +288,15 @@ for this label type: nlabels > max(label_type).");
blobs(const Image<I>& input_, const Neighborhood<N>& nbh_,
L& nlabels, F& functor)
{
- mln_trace("labeling::blobs");
- // mlc_equal(mln_trait_image_kind(I),
- // mln::trait::image::kind::binary)::check();
+ mln_trace("mln::canvas::labeling::blobs");
+
const I& input = exact(input_);
const N& nbh = exact(nbh_);
mln_precondition(input.is_valid());
// The only implementation is the generic one.
mln_ch_value(I, L)
- output = impl::generic::blobs(input, nbh, nlabels, functor);
+ output = internal::blobs_dispatch(input, nbh, nlabels, functor);
return output;
}
diff --git a/milena/mln/labeling/all_blobs.hh b/milena/mln/labeling/all_blobs.hh
deleted file mode 100644
index 96e5a09..0000000
--- a/milena/mln/labeling/all_blobs.hh
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (C) 2007, 2008, 2009, 2012, 2013 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/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef MLN_LABELING_ALL_BLOBS_HH
-# define MLN_LABELING_ALL_BLOBS_HH
-
-/// \file
-///
-/// Connected component labeling of the homogeneous regions of an
-/// image using a queue-based algorithm.
-///
-/// \todo Handle abort in a nice way...
-
-# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
-
-# include <mln/canvas/labeling/blobs.hh>
-
-
-namespace mln
-{
-
- namespace labeling
- {
-
- /*! \brief Connected component labeling of the homogeneous regions
- * of an image.
-
- \param[in] input The input image.
- \param[in] nbh The connexity of the objects.
- \param[out] nlabels The Number of labels. Its value is set in the
- algorithms.
- \return The label image.
-
- A fast queue is used so that the algorithm is not recursive and
- can handle large objects (blobs).
-
- \ingroup labeling
- */
- template <typename I, typename N, typename L>
- mln_ch_value(I, L)
- all_blobs(const Image<I>& input, const Neighborhood<N>& nbh,
- L& nlabels);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- namespace internal
- {
-
- /*! \brief Functor not computing anything. To be passed to the
- labeling blobs canvas.
- */
- template <typename I, typename L>
- struct label_values_functor
- {
- void init() {}
-
- bool handles(const mln_value(I)&) { return true; }
-
- void new_label(const mln_value(L)&) {}
-
- void process_p(const mln_site(L)&) {}
-
- void process_n(const mln_site(L)&) {}
-
- void finalize() {}
- };
-
- } // end of namespace mln::labeling::internal
-
-
-
- // Facade.
-
- template <typename I, typename N, typename L>
- inline
- mln_ch_value(I, L)
- all_blobs(const Image<I>& input_, const Neighborhood<N>& nbh_,
- L& nlabels)
- {
- mln_trace("labeling::all_blobs");
- const I& input = exact(input_);
- const N& nbh = exact(nbh_);
- mln_precondition(input.is_valid());
-
- typedef mln_ch_value(I,L) out_t;
- internal::label_values_functor<I, out_t> functor;
- out_t
- output = canvas::labeling::blobs(input, nbh, nlabels, functor);
-
- return output;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::labeling
-
-} // end of namespace mln
-
-
-#endif // ! MLN_LABELING_ALL_BLOBS_HH
diff --git a/milena/mln/labeling/blobs.hh b/milena/mln/labeling/blobs.hh
index 81073d1..d3c672d 100644
--- a/milena/mln/labeling/blobs.hh
+++ b/milena/mln/labeling/blobs.hh
@@ -33,8 +33,6 @@
/// image using a queue-based algorithm.
///
/// \todo Handle abort in a nice way...
-///
-/// \todo Add a 2nd version precising the 'value' to label.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -48,27 +46,41 @@ namespace mln
namespace labeling
{
- /*! \brief Connected component labeling of the binary objects of a
- binary image.
+ /*! \brief Connected component labeling of the objects of an
+ * image.
\param[in] input The input image.
\param[in] nbh The connexity of the objects.
\param[out] nlabels The Number of labels. Its value is set in the
algorithms.
- \return The label image.
-
- \pre The input image has to be binary (checked at compile-time).
+ \param[in] background_value The value to be considered as
+ background and not to be labeled.
+ \return A labeled image.
A fast queue is used so that the algorithm is not recursive and
- can handle large binary objects (blobs).
+ can handle large objects (blobs).
\ingroup labeling
*/
template <typename I, typename N, typename L>
mln_ch_value(I, L)
blobs(const Image<I>& input, const Neighborhood<N>& nbh,
- L& nlabels);
+ L& nlabels, const mln_value(I)& background_value);
+
+ /*! \overload
+ \brief Connected component labeling of the objects of an
+ image.
+
+ background_value is set to literal::zero.
+
+ \ingroup labeling
+ */
+ template <typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ blobs(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ L& nlabels);
# ifndef MLN_INCLUDE_ONLY
@@ -83,11 +95,14 @@ namespace mln
template <typename I, typename L>
struct label_value_functor
{
- label_value_functor(const mln_value(I)& value) : value_(value) {}
+ label_value_functor(const mln_value(I)& background_value)
+ : background_value_(background_value) {}
void init() {}
- bool handles(const mln_value(I)& v) { return v == value_; }
+ mln_value(I) neutral_value() const { return this->background_value_; }
+
+ bool handles(const mln_value(I)& v) const { return v != this->background_value_; }
void new_label(const mln_value(L)&) {}
@@ -97,7 +112,15 @@ namespace mln
void finalize() {}
- mln_value(I) value_;
+
+ // Fastest interface
+
+ void process_p_(unsigned) {}
+
+ void process_n_(unsigned) {}
+
+
+ mln_value(I) background_value_;
};
} // end of namespace mln::labeling::internal
@@ -110,23 +133,33 @@ namespace mln
inline
mln_ch_value(I, L)
blobs(const Image<I>& input_, const Neighborhood<N>& nbh_,
- L& nlabels)
+ L& nlabels, const mln_value(I)& background_value)
{
mln_trace("labeling::blobs");
- mlc_equal(mln_trait_image_kind(I),
- mln::trait::image::kind::binary)::check();
+
const I& input = exact(input_);
const N& nbh = exact(nbh_);
mln_precondition(input.is_valid());
typedef mln_ch_value(I,L) out_t;
- internal::label_value_functor<I, out_t> functor(true);
+ internal::label_value_functor<I, out_t> functor(background_value);
out_t
output = canvas::labeling::blobs(input, nbh, nlabels, functor);
return output;
}
+ template <typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ blobs(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels)
+ {
+ return blobs(input, nbh, nlabels,
+ static_cast<mln_value(I)>(literal::zero));
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::labeling
diff --git a/milena/mln/labeling/blobs_and_compute.hh b/milena/mln/labeling/blobs_and_compute.hh
index f7d2f76..2b7b445 100644
--- a/milena/mln/labeling/blobs_and_compute.hh
+++ b/milena/mln/labeling/blobs_and_compute.hh
@@ -35,7 +35,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/labeling/blobs.hh>
+# include <mln/canvas/labeling/blobs.hh>
# include <mln/labeling/compute.hh>
# include <mln/util/couple.hh>
@@ -52,6 +52,8 @@ namespace mln
\param[in] nbh A neighborhood used for labeling.
\param[in,out] nlabels The number of labels found.
\param[in] accu An accumulator to be computed while labeling.
+ \param[in] background_value The value to be considered as
+ background and not to be labeled.
\return The labeled image, computed attributes for each regions
and an array of the accumulators used to compute the
@@ -64,8 +66,21 @@ namespace mln
util::couple<util::array<mln_result(A)>,
util::array<A> > >
blobs_and_compute(const Image<I>& input, const Neighborhood<N>& nbh,
- L& nlabels, const Accumulator<A>& accu);
+ L& nlabels, const Accumulator<A>& accu,
+ const mln_value(I)& background_value);
+ /*! \brief Label an image and compute given accumulators.
+
+ background_value is set to literal::zero.
+
+ \ingroup labeling
+ */
+ template <typename I, typename N, typename L, typename A>
+ util::couple<mln_ch_value(I,L),
+ util::couple<util::array<mln_result(A)>,
+ util::array<A> > >
+ blobs_and_compute(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels, const Accumulator<A>& accu);
# ifndef MLN_INCLUDE_ONLY
@@ -87,8 +102,10 @@ namespace mln
typedef util::couple<util::array<accu_result>,
util::array<A> > result;
- compute_functor(const mln_value(L)& nlabels)
- : nlabels_(nlabels)
+ compute_functor(const mln_value(L)& nlabels, const I& input,
+ const mln_value(I)& background_value)
+ : nlabels_(nlabels), input_(input),
+ background_value_(background_value)
{
}
@@ -100,9 +117,15 @@ namespace mln
}
inline
+ mln_value(I) neutral_value() const
+ {
+ return background_value_;
+ }
+
+ inline
bool handles(const mln_value(I)& v)
{
- return v;
+ return v != background_value_;
}
inline
@@ -131,6 +154,21 @@ namespace mln
}
+ // Fastest interface
+
+ inline
+ void process_p_(const unsigned p)
+ {
+ process__(accu_argument(), p);
+ }
+
+ inline
+ void process_n_(const unsigned n)
+ {
+ process__(accu_argument(), n);
+ }
+
+
private:
inline
void process__(const mln_psite(L)&, const mln_site(L)& p)
@@ -144,6 +182,19 @@ namespace mln
accus_[current_lbl_].take(current_lbl_);
}
+ inline
+ void process__(const mln_psite(L)&, const unsigned p)
+ {
+ accus_[current_lbl_].take(input_.point_at_offset(p));
+ }
+
+ inline
+ void process__(const mln_value(L)&, const unsigned)
+ {
+ accus_[current_lbl_].take(current_lbl_);
+ }
+
+
template <typename V>
inline
void process__(const V&, const mln_site(L)&)
@@ -156,6 +207,8 @@ namespace mln
util::array<A> accus_;
mln_value(L) current_lbl_;
mln_value(L) nlabels_;
+ const I input_;
+ mln_value(I) background_value_;
};
} // end of namespace mln::labeling::internal
@@ -170,18 +223,18 @@ namespace mln
util::couple<util::array<mln_result(A)>,
util::array<A> > >
blobs_and_compute(const Image<I>& input, const Neighborhood<N>& nbh,
- L& nlabels, const Accumulator<A>& accu)
+ L& nlabels, const Accumulator<A>& accu,
+ const mln_value(I)& background_value)
{
mln_trace("labeling::blobs_and_compute");
(void) accu;
- mlc_equal(mln_trait_image_kind(I),
- mln::trait::image::kind::binary)::check();
mln_precondition(exact(input).is_valid());
+ mln_precondition(exact(nbh).is_valid());
typedef mln_ch_value(I,L) out_t;
typedef internal::compute_functor<I,out_t,A> func_t;
- func_t functor(nlabels);
+ func_t functor(nlabels, exact(input), background_value);
out_t
output = canvas::labeling::blobs(input, nbh, nlabels, functor);
@@ -193,6 +246,18 @@ namespace mln
}
+ template <typename I, typename N, typename L, typename A>
+ util::couple<mln_ch_value(I,L),
+ util::couple<util::array<mln_result(A)>,
+ util::array<A> > >
+ blobs_and_compute(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels, const Accumulator<A>& accu)
+ {
+ return blobs_and_compute(input, nbh, nlabels, accu,
+ static_cast<mln_value(I)>(literal::zero));
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/tests/labeling/Makefile.am b/milena/tests/labeling/Makefile.am
index 9aa5416..1cabf25 100644
--- a/milena/tests/labeling/Makefile.am
+++ b/milena/tests/labeling/Makefile.am
@@ -22,7 +22,6 @@ EXTRA_DIST = \
check_PROGRAMS = \
- all_blobs \
background \
blobs \
blobs_and_compute \
diff --git a/milena/tests/labeling/all_blobs.cc b/milena/tests/labeling/all_blobs.cc
deleted file mode 100644
index 646227a..0000000
--- a/milena/tests/labeling/all_blobs.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (C) 2007, 2008, 2009, 2013 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/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/io/pbm/load.hh>
-#include <mln/io/pgm/load.hh>
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/labeling/all_blobs.hh>
-#include <mln/value/int_u8.hh>
-
-#include <mln/labeling/colorize.hh>
-#include <mln/io/ppm/save.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/debug/println.hh>
-
-#include "tests/data.hh"
-
-
-int main()
-{
- using namespace mln;
-
- // Binary image
- {
- image2d<bool> pic;
- io::pbm::load(pic, MLN_IMG_DIR "/picasso.pbm");
- unsigned n;
- labeling::all_blobs(pic, c4(), n);
- mln_assertion(n == 142);
- }
-
- // Gray-level image
- {
- image2d<value::int_u8> pic;
- io::pgm::load(pic, MLN_IMG_DIR "/fly.pgm");
- unsigned n;
- labeling::all_blobs(pic, c4(), n);
- mln_assertion(n == 24);
- }
-}
diff --git a/milena/tests/labeling/blobs.cc b/milena/tests/labeling/blobs.cc
index c3f00bb..9e436b2 100644
--- a/milena/tests/labeling/blobs.cc
+++ b/milena/tests/labeling/blobs.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2013 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -25,8 +26,10 @@
#include <mln/core/image/image2d.hh>
#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/load.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/labeling/blobs.hh>
+#include <mln/value/int_u8.hh>
#include "tests/data.hh"
@@ -35,8 +38,21 @@ int main()
{
using namespace mln;
- image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
- unsigned n;
- labeling::blobs(pic, c4(), n);
- mln_assertion(n == 33);
+ // Binary image
+ {
+ image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
+ unsigned n;
+ labeling::blobs(pic, c4(), n);
+ mln_assertion(n == 33);
+ }
+
+ // Gray-level image
+ {
+ image2d<value::int_u8> pic;
+ io::pgm::load(pic, MLN_IMG_DIR "/fly.pgm");
+ unsigned n;
+ labeling::blobs(pic, c4(), n);
+
+ mln_assertion(n == 24);
+ }
}
diff --git a/milena/tests/labeling/blobs_and_compute.cc b/milena/tests/labeling/blobs_and_compute.cc
index 47abd66..66e15c1 100644
--- a/milena/tests/labeling/blobs_and_compute.cc
+++ b/milena/tests/labeling/blobs_and_compute.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2013 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -26,6 +26,7 @@
#include <mln/core/image/image2d.hh>
#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/load.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/accu/center.hh>
#include <mln/labeling/blobs_and_compute.hh>
@@ -40,22 +41,46 @@ int main()
{
using namespace mln;
- image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
- value::label_8 n;
+ {
+ image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
+ value::label_8 n;
- typedef image2d<value::label_8> L;
- typedef util::array<point2d> arr_t;
- typedef accu::center<point2d,point2d> accu_t;
- typedef util::array<accu_t> accu_arr_t;
- typedef util::couple<L,util::couple<arr_t, accu_arr_t> > res_t;
- res_t result = labeling::blobs_and_compute(pic, c4(), n,
- accu_t());
+ typedef image2d<value::label_8> L;
+ typedef util::array<point2d> arr_t;
+ typedef accu::center<point2d,point2d> accu_t;
+ typedef util::array<accu_t> accu_arr_t;
+ typedef util::couple<L,util::couple<arr_t, accu_arr_t> > res_t;
+ res_t result = labeling::blobs_and_compute(pic, c4(), n,
+ accu_t());
- mln_assertion(result.second().first().size() == 34);
- mln_assertion(result.second().second().size() == 34);
- mln_assertion(result.second().first()[1] == point2d(10,30));
- mln_assertion(result.second().second()[33] == point2d(311,67));
- mln_assertion(n == 33);
+ mln_assertion(result.second().first().size() == 34);
+ mln_assertion(result.second().second().size() == 34);
+ mln_assertion(result.second().first()[1] == point2d(10,30));
+ mln_assertion(result.second().second()[33] == point2d(311,67));
+ mln_assertion(n == 33);
+ }
+
+ {
+ image2d<value::label_8> pic;
+ io::pgm::load(pic, MLN_IMG_DIR "/fly.pgm");
+ value::label_8 n;
+
+
+ typedef image2d<value::label_8> L;
+ typedef util::array<point2d> arr_t;
+ typedef accu::center<point2d,point2d> accu_t;
+ typedef util::array<accu_t> accu_arr_t;
+ typedef util::couple<L,util::couple<arr_t, accu_arr_t> > res_t;
+ res_t result = labeling::blobs_and_compute(pic, c4(), n,
+ accu_t());
+
+ mln_assertion(result.second().first().size() == 25);
+ mln_assertion(result.second().second().size() == 25);
+ mln_assertion(result.second().first()[1] == point2d(0,0));
+ mln_assertion(result.second().second()[24] == point2d(4,4));
+ mln_assertion(n == 24);
+ }
+
}
--
1.7.2.5
1
0

olena-2.0-488-gf8e6233 Add support for graylevel images in labeling::blobs.
by Guillaume Lazzara 18 Apr '13
by Guillaume Lazzara 18 Apr '13
18 Apr '13
* mln/canvas/labeling/blobs.hh: Add a fastest version and make it
support graylevel images.
* mln/labeling/blobs.hh,
* mln/labeling/blobs_and_compute.hh: Add support for graylevel images.
* tests/labeling/blobs.cc,
* tests/labeling/blobs_and_compute.cc: Add a test for graylevel images.
* tests/labeling/Makefile.am: Remove all_blobs target.
* mln/labeling/all_blobs.hh,
* tests/labeling/all_blobs.cc: Remove.
---
milena/ChangeLog | 18 ++++
milena/mln/canvas/labeling/blobs.hh | 136 ++++++++++++++++++++++++++--
milena/mln/labeling/all_blobs.hh | 127 --------------------------
milena/mln/labeling/blobs.hh | 65 ++++++++++----
milena/mln/labeling/blobs_and_compute.hh | 83 +++++++++++++++--
milena/tests/labeling/Makefile.am | 1 -
milena/tests/labeling/all_blobs.cc | 63 -------------
milena/tests/labeling/blobs.cc | 26 +++++-
milena/tests/labeling/blobs_and_compute.cc | 55 ++++++++---
9 files changed, 329 insertions(+), 245 deletions(-)
delete mode 100644 milena/mln/labeling/all_blobs.hh
delete mode 100644 milena/tests/labeling/all_blobs.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4949cad..1f9c705 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,23 @@
2013-04-18 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add support for graylevel images in labeling::blobs.
+
+ * mln/canvas/labeling/blobs.hh: Add a fastest version and make it
+ support graylevel images.
+
+ * mln/labeling/blobs.hh,
+ * mln/labeling/blobs_and_compute.hh: Add support for graylevel images.
+
+ * tests/labeling/blobs.cc,
+ * tests/labeling/blobs_and_compute.cc: Add a test for graylevel images.
+
+ * tests/labeling/Makefile.am: Remove all_blobs target.
+
+ * mln/labeling/all_blobs.hh,
+ * tests/labeling/all_blobs.cc: Remove.
+
+2013-04-18 Guillaume Lazzara <z(a)lrde.epita.fr>
+
* mln/core/internal/pixel_impl.hh: Add change_offset().
2013-04-17 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/milena/mln/canvas/labeling/blobs.hh b/milena/mln/canvas/labeling/blobs.hh
index 4a643ce..f913901 100644
--- a/milena/mln/canvas/labeling/blobs.hh
+++ b/milena/mln/canvas/labeling/blobs.hh
@@ -90,9 +90,15 @@ namespace mln
template <typename I, typename N, typename L, typename F>
mln_ch_value(I, L)
- blobs(const Image<I>& input_, const N& nbh, L& nlabels, F& functor)
+ blobs(const Image<I>& input_, const Neighborhood<N>& nbh_, L& nlabels, F& functor)
{
+ mln_trace("mln::canvas::labeling::impl::generic::blobs");
+
const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(nbh.is_valid());
typedef mln_psite(I) P;
@@ -108,20 +114,24 @@ namespace mln
initialize(output, input);
data::fill(output, zero);
- //extension::fill(input, false);
+ // No initialization needed in border since we look into
+ // the image domain for the neighborhood.
+ //
+ // extension::fill(input, functor.neutral_value()); // <-- functor.neutral_value()
functor.init(); // <-- functor.init()
// Loop.
mln_piter(I) p(input.domain());
for_all(p)
- if (functor.handles(input(p)) && output(p) == zero) // Object point, not labeled yet.
+ if (functor.handles(input(p)) // <-- functor.handles()
+ && output(p) == zero) // Object point, not labeled yet.
{
// Label this point component.
if (nlabels == mln_max(L))
{
- mln_trace_warning("labeling aborted! Too many labels \
-for this label type: nlabels > max(label_type).");
+ mln_trace_warning("labeling aborted! Too many labels "
+ "for this label type: nlabels > max(label_type).");
return output;
}
@@ -157,10 +167,119 @@ for this label type: nlabels > max(label_type).");
} // end of namespace mln::labeling::impl::generic
+ template <typename I, typename N, typename L, typename F>
+ mln_ch_value(I, L)
+ blobs_fastest(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ L& nlabels, F& functor)
+ {
+ mln_trace("mln::canvas::labeling::impl::blobs_fastest");
+
+ const I& input = exact(input_);
+ const N& nbh = exact(nbh_);
+
+ mln_precondition(input.is_valid());
+ mln_precondition(nbh.is_valid());
+
+ typedef mln_psite(I) P;
+
+ mln_pixter(const I) cur(input);
+ mln_nixter(const I,N) n(cur, nbh);
+ p_queue_fast<unsigned> qu;
+ const L zero = literal::zero;
+
+ // Initialization.
+ nlabels = literal::zero;
+ typedef mln_ch_value(I, L) out_t;
+ out_t output;
+ initialize(output, input);
+ data::fill(output, zero);
+
+ extension::fill(input, functor.neutral_value()); // <-- functor.neutral_value()
+
+ functor.init(); // <-- functor.init()
+
+ // Loop.
+ mln_pixter(const I) p(input);
+ for_all(p)
+ if (functor.handles(p.val()) // <-- functor.handles()
+ && output.element(p.offset()) == zero) // Object point, not labeled yet.
+ {
+ // Label this point component.
+ if (nlabels == mln_max(L))
+ {
+ mln_trace_warning("labeling aborted! Too many labels "
+ "for this label type: nlabels > max(label_type).");
+
+ return output;
+ }
+ ++nlabels;
+ functor.new_label(nlabels); // <-- functor.new_label()
+ mln_invariant(qu.is_empty());
+ qu.push(p.offset());
+ output.element(p.offset()) = nlabels;
+ functor.process_p_(p.offset()); // <-- functor.process_p_()
+ do
+ {
+ cur.change_offset(qu.front());
+ qu.pop();
+ for_all(n)
+ if (p.val() == n.val() && output.element(n.offset()) == zero)
+ {
+ mln_invariant(! qu.compute_has(n.offset()));
+ qu.push(n.offset());
+ output.element(n) = nlabels;
+ functor.process_n_(n.offset()); // <-- functor.process_n_()
+ }
+ }
+ while (! qu.is_empty());
+ }
+
+ functor.finalize(); // <-- functor.finalize()
+
+ return output;
+ }
+
} // end of namespace mln::canvas::labeling::impl
+ // Dispatch
+
+ namespace internal
+ {
+
+ template <typename I, typename N, typename L, typename F>
+ inline
+ mln_ch_value(I, L)
+ blobs_dispatch(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels, F& functor, mln::trait::image::speed::any)
+ {
+ return impl::generic::blobs(input, nbh, nlabels, functor);
+ }
+
+ template <typename I, typename N, typename L, typename F>
+ inline
+ mln_ch_value(I, L)
+ blobs_dispatch(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels, F& functor, mln::trait::image::speed::fastest)
+ {
+ return impl::blobs_fastest(input, nbh, nlabels, functor);
+ }
+
+ template <typename I, typename N, typename L, typename F>
+ inline
+ mln_ch_value(I, L)
+ blobs_dispatch(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels, F& functor)
+ {
+ typedef mln_trait_image_speed(I) speed;
+ return blobs_dispatch(input, nbh, nlabels, functor, speed());
+ }
+
+ } // end of namespace mln::canvas::labeling::internal
+
+
+
// Facade.
template <typename I, typename N, typename L, typename F>
@@ -169,16 +288,15 @@ for this label type: nlabels > max(label_type).");
blobs(const Image<I>& input_, const Neighborhood<N>& nbh_,
L& nlabels, F& functor)
{
- mln_trace("labeling::blobs");
- // mlc_equal(mln_trait_image_kind(I),
- // mln::trait::image::kind::binary)::check();
+ mln_trace("mln::canvas::labeling::blobs");
+
const I& input = exact(input_);
const N& nbh = exact(nbh_);
mln_precondition(input.is_valid());
// The only implementation is the generic one.
mln_ch_value(I, L)
- output = impl::generic::blobs(input, nbh, nlabels, functor);
+ output = internal::blobs_dispatch(input, nbh, nlabels, functor);
return output;
}
diff --git a/milena/mln/labeling/all_blobs.hh b/milena/mln/labeling/all_blobs.hh
deleted file mode 100644
index 96e5a09..0000000
--- a/milena/mln/labeling/all_blobs.hh
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (C) 2007, 2008, 2009, 2012, 2013 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/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef MLN_LABELING_ALL_BLOBS_HH
-# define MLN_LABELING_ALL_BLOBS_HH
-
-/// \file
-///
-/// Connected component labeling of the homogeneous regions of an
-/// image using a queue-based algorithm.
-///
-/// \todo Handle abort in a nice way...
-
-# include <mln/core/concept/image.hh>
-# include <mln/core/concept/neighborhood.hh>
-
-# include <mln/canvas/labeling/blobs.hh>
-
-
-namespace mln
-{
-
- namespace labeling
- {
-
- /*! \brief Connected component labeling of the homogeneous regions
- * of an image.
-
- \param[in] input The input image.
- \param[in] nbh The connexity of the objects.
- \param[out] nlabels The Number of labels. Its value is set in the
- algorithms.
- \return The label image.
-
- A fast queue is used so that the algorithm is not recursive and
- can handle large objects (blobs).
-
- \ingroup labeling
- */
- template <typename I, typename N, typename L>
- mln_ch_value(I, L)
- all_blobs(const Image<I>& input, const Neighborhood<N>& nbh,
- L& nlabels);
-
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- namespace internal
- {
-
- /*! \brief Functor not computing anything. To be passed to the
- labeling blobs canvas.
- */
- template <typename I, typename L>
- struct label_values_functor
- {
- void init() {}
-
- bool handles(const mln_value(I)&) { return true; }
-
- void new_label(const mln_value(L)&) {}
-
- void process_p(const mln_site(L)&) {}
-
- void process_n(const mln_site(L)&) {}
-
- void finalize() {}
- };
-
- } // end of namespace mln::labeling::internal
-
-
-
- // Facade.
-
- template <typename I, typename N, typename L>
- inline
- mln_ch_value(I, L)
- all_blobs(const Image<I>& input_, const Neighborhood<N>& nbh_,
- L& nlabels)
- {
- mln_trace("labeling::all_blobs");
- const I& input = exact(input_);
- const N& nbh = exact(nbh_);
- mln_precondition(input.is_valid());
-
- typedef mln_ch_value(I,L) out_t;
- internal::label_values_functor<I, out_t> functor;
- out_t
- output = canvas::labeling::blobs(input, nbh, nlabels, functor);
-
- return output;
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace mln::labeling
-
-} // end of namespace mln
-
-
-#endif // ! MLN_LABELING_ALL_BLOBS_HH
diff --git a/milena/mln/labeling/blobs.hh b/milena/mln/labeling/blobs.hh
index 81073d1..d3c672d 100644
--- a/milena/mln/labeling/blobs.hh
+++ b/milena/mln/labeling/blobs.hh
@@ -33,8 +33,6 @@
/// image using a queue-based algorithm.
///
/// \todo Handle abort in a nice way...
-///
-/// \todo Add a 2nd version precising the 'value' to label.
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
@@ -48,27 +46,41 @@ namespace mln
namespace labeling
{
- /*! \brief Connected component labeling of the binary objects of a
- binary image.
+ /*! \brief Connected component labeling of the objects of an
+ * image.
\param[in] input The input image.
\param[in] nbh The connexity of the objects.
\param[out] nlabels The Number of labels. Its value is set in the
algorithms.
- \return The label image.
-
- \pre The input image has to be binary (checked at compile-time).
+ \param[in] background_value The value to be considered as
+ background and not to be labeled.
+ \return A labeled image.
A fast queue is used so that the algorithm is not recursive and
- can handle large binary objects (blobs).
+ can handle large objects (blobs).
\ingroup labeling
*/
template <typename I, typename N, typename L>
mln_ch_value(I, L)
blobs(const Image<I>& input, const Neighborhood<N>& nbh,
- L& nlabels);
+ L& nlabels, const mln_value(I)& background_value);
+
+ /*! \overload
+ \brief Connected component labeling of the objects of an
+ image.
+
+ background_value is set to literal::zero.
+
+ \ingroup labeling
+ */
+ template <typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ blobs(const Image<I>& input_, const Neighborhood<N>& nbh_,
+ L& nlabels);
# ifndef MLN_INCLUDE_ONLY
@@ -83,11 +95,14 @@ namespace mln
template <typename I, typename L>
struct label_value_functor
{
- label_value_functor(const mln_value(I)& value) : value_(value) {}
+ label_value_functor(const mln_value(I)& background_value)
+ : background_value_(background_value) {}
void init() {}
- bool handles(const mln_value(I)& v) { return v == value_; }
+ mln_value(I) neutral_value() const { return this->background_value_; }
+
+ bool handles(const mln_value(I)& v) const { return v != this->background_value_; }
void new_label(const mln_value(L)&) {}
@@ -97,7 +112,15 @@ namespace mln
void finalize() {}
- mln_value(I) value_;
+
+ // Fastest interface
+
+ void process_p_(unsigned) {}
+
+ void process_n_(unsigned) {}
+
+
+ mln_value(I) background_value_;
};
} // end of namespace mln::labeling::internal
@@ -110,23 +133,33 @@ namespace mln
inline
mln_ch_value(I, L)
blobs(const Image<I>& input_, const Neighborhood<N>& nbh_,
- L& nlabels)
+ L& nlabels, const mln_value(I)& background_value)
{
mln_trace("labeling::blobs");
- mlc_equal(mln_trait_image_kind(I),
- mln::trait::image::kind::binary)::check();
+
const I& input = exact(input_);
const N& nbh = exact(nbh_);
mln_precondition(input.is_valid());
typedef mln_ch_value(I,L) out_t;
- internal::label_value_functor<I, out_t> functor(true);
+ internal::label_value_functor<I, out_t> functor(background_value);
out_t
output = canvas::labeling::blobs(input, nbh, nlabels, functor);
return output;
}
+ template <typename I, typename N, typename L>
+ inline
+ mln_ch_value(I, L)
+ blobs(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels)
+ {
+ return blobs(input, nbh, nlabels,
+ static_cast<mln_value(I)>(literal::zero));
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::labeling
diff --git a/milena/mln/labeling/blobs_and_compute.hh b/milena/mln/labeling/blobs_and_compute.hh
index f7d2f76..2b7b445 100644
--- a/milena/mln/labeling/blobs_and_compute.hh
+++ b/milena/mln/labeling/blobs_and_compute.hh
@@ -35,7 +35,7 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/labeling/blobs.hh>
+# include <mln/canvas/labeling/blobs.hh>
# include <mln/labeling/compute.hh>
# include <mln/util/couple.hh>
@@ -52,6 +52,8 @@ namespace mln
\param[in] nbh A neighborhood used for labeling.
\param[in,out] nlabels The number of labels found.
\param[in] accu An accumulator to be computed while labeling.
+ \param[in] background_value The value to be considered as
+ background and not to be labeled.
\return The labeled image, computed attributes for each regions
and an array of the accumulators used to compute the
@@ -64,8 +66,21 @@ namespace mln
util::couple<util::array<mln_result(A)>,
util::array<A> > >
blobs_and_compute(const Image<I>& input, const Neighborhood<N>& nbh,
- L& nlabels, const Accumulator<A>& accu);
+ L& nlabels, const Accumulator<A>& accu,
+ const mln_value(I)& background_value);
+ /*! \brief Label an image and compute given accumulators.
+
+ background_value is set to literal::zero.
+
+ \ingroup labeling
+ */
+ template <typename I, typename N, typename L, typename A>
+ util::couple<mln_ch_value(I,L),
+ util::couple<util::array<mln_result(A)>,
+ util::array<A> > >
+ blobs_and_compute(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels, const Accumulator<A>& accu);
# ifndef MLN_INCLUDE_ONLY
@@ -87,8 +102,10 @@ namespace mln
typedef util::couple<util::array<accu_result>,
util::array<A> > result;
- compute_functor(const mln_value(L)& nlabels)
- : nlabels_(nlabels)
+ compute_functor(const mln_value(L)& nlabels, const I& input,
+ const mln_value(I)& background_value)
+ : nlabels_(nlabels), input_(input),
+ background_value_(background_value)
{
}
@@ -100,9 +117,15 @@ namespace mln
}
inline
+ mln_value(I) neutral_value() const
+ {
+ return background_value_;
+ }
+
+ inline
bool handles(const mln_value(I)& v)
{
- return v;
+ return v != background_value_;
}
inline
@@ -131,6 +154,21 @@ namespace mln
}
+ // Fastest interface
+
+ inline
+ void process_p_(const unsigned p)
+ {
+ process__(accu_argument(), p);
+ }
+
+ inline
+ void process_n_(const unsigned n)
+ {
+ process__(accu_argument(), n);
+ }
+
+
private:
inline
void process__(const mln_psite(L)&, const mln_site(L)& p)
@@ -144,6 +182,19 @@ namespace mln
accus_[current_lbl_].take(current_lbl_);
}
+ inline
+ void process__(const mln_psite(L)&, const unsigned p)
+ {
+ accus_[current_lbl_].take(input_.point_at_offset(p));
+ }
+
+ inline
+ void process__(const mln_value(L)&, const unsigned)
+ {
+ accus_[current_lbl_].take(current_lbl_);
+ }
+
+
template <typename V>
inline
void process__(const V&, const mln_site(L)&)
@@ -156,6 +207,8 @@ namespace mln
util::array<A> accus_;
mln_value(L) current_lbl_;
mln_value(L) nlabels_;
+ const I input_;
+ mln_value(I) background_value_;
};
} // end of namespace mln::labeling::internal
@@ -170,18 +223,18 @@ namespace mln
util::couple<util::array<mln_result(A)>,
util::array<A> > >
blobs_and_compute(const Image<I>& input, const Neighborhood<N>& nbh,
- L& nlabels, const Accumulator<A>& accu)
+ L& nlabels, const Accumulator<A>& accu,
+ const mln_value(I)& background_value)
{
mln_trace("labeling::blobs_and_compute");
(void) accu;
- mlc_equal(mln_trait_image_kind(I),
- mln::trait::image::kind::binary)::check();
mln_precondition(exact(input).is_valid());
+ mln_precondition(exact(nbh).is_valid());
typedef mln_ch_value(I,L) out_t;
typedef internal::compute_functor<I,out_t,A> func_t;
- func_t functor(nlabels);
+ func_t functor(nlabels, exact(input), background_value);
out_t
output = canvas::labeling::blobs(input, nbh, nlabels, functor);
@@ -193,6 +246,18 @@ namespace mln
}
+ template <typename I, typename N, typename L, typename A>
+ util::couple<mln_ch_value(I,L),
+ util::couple<util::array<mln_result(A)>,
+ util::array<A> > >
+ blobs_and_compute(const Image<I>& input, const Neighborhood<N>& nbh,
+ L& nlabels, const Accumulator<A>& accu)
+ {
+ return blobs_and_compute(input, nbh, nlabels, accu,
+ static_cast<mln_value(I)>(literal::zero));
+ }
+
+
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/tests/labeling/Makefile.am b/milena/tests/labeling/Makefile.am
index 9aa5416..1cabf25 100644
--- a/milena/tests/labeling/Makefile.am
+++ b/milena/tests/labeling/Makefile.am
@@ -22,7 +22,6 @@ EXTRA_DIST = \
check_PROGRAMS = \
- all_blobs \
background \
blobs \
blobs_and_compute \
diff --git a/milena/tests/labeling/all_blobs.cc b/milena/tests/labeling/all_blobs.cc
deleted file mode 100644
index 646227a..0000000
--- a/milena/tests/labeling/all_blobs.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (C) 2007, 2008, 2009, 2013 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/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#include <mln/core/image/image2d.hh>
-#include <mln/io/pbm/load.hh>
-#include <mln/io/pgm/load.hh>
-#include <mln/core/alias/neighb2d.hh>
-#include <mln/labeling/all_blobs.hh>
-#include <mln/value/int_u8.hh>
-
-#include <mln/labeling/colorize.hh>
-#include <mln/io/ppm/save.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/debug/println.hh>
-
-#include "tests/data.hh"
-
-
-int main()
-{
- using namespace mln;
-
- // Binary image
- {
- image2d<bool> pic;
- io::pbm::load(pic, MLN_IMG_DIR "/picasso.pbm");
- unsigned n;
- labeling::all_blobs(pic, c4(), n);
- mln_assertion(n == 142);
- }
-
- // Gray-level image
- {
- image2d<value::int_u8> pic;
- io::pgm::load(pic, MLN_IMG_DIR "/fly.pgm");
- unsigned n;
- labeling::all_blobs(pic, c4(), n);
- mln_assertion(n == 24);
- }
-}
diff --git a/milena/tests/labeling/blobs.cc b/milena/tests/labeling/blobs.cc
index c3f00bb..9e436b2 100644
--- a/milena/tests/labeling/blobs.cc
+++ b/milena/tests/labeling/blobs.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009, 2013 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -25,8 +26,10 @@
#include <mln/core/image/image2d.hh>
#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/load.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/labeling/blobs.hh>
+#include <mln/value/int_u8.hh>
#include "tests/data.hh"
@@ -35,8 +38,21 @@ int main()
{
using namespace mln;
- image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
- unsigned n;
- labeling::blobs(pic, c4(), n);
- mln_assertion(n == 33);
+ // Binary image
+ {
+ image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
+ unsigned n;
+ labeling::blobs(pic, c4(), n);
+ mln_assertion(n == 33);
+ }
+
+ // Gray-level image
+ {
+ image2d<value::int_u8> pic;
+ io::pgm::load(pic, MLN_IMG_DIR "/fly.pgm");
+ unsigned n;
+ labeling::blobs(pic, c4(), n);
+
+ mln_assertion(n == 24);
+ }
}
diff --git a/milena/tests/labeling/blobs_and_compute.cc b/milena/tests/labeling/blobs_and_compute.cc
index 47abd66..66e15c1 100644
--- a/milena/tests/labeling/blobs_and_compute.cc
+++ b/milena/tests/labeling/blobs_and_compute.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009, 2010, 2011 EPITA Research and Development
+// Copyright (C) 2009, 2010, 2011, 2013 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
@@ -26,6 +26,7 @@
#include <mln/core/image/image2d.hh>
#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/load.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/accu/center.hh>
#include <mln/labeling/blobs_and_compute.hh>
@@ -40,22 +41,46 @@ int main()
{
using namespace mln;
- image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
- value::label_8 n;
+ {
+ image2d<bool> pic = io::pbm::load(MLN_IMG_DIR "/picasso.pbm");
+ value::label_8 n;
- typedef image2d<value::label_8> L;
- typedef util::array<point2d> arr_t;
- typedef accu::center<point2d,point2d> accu_t;
- typedef util::array<accu_t> accu_arr_t;
- typedef util::couple<L,util::couple<arr_t, accu_arr_t> > res_t;
- res_t result = labeling::blobs_and_compute(pic, c4(), n,
- accu_t());
+ typedef image2d<value::label_8> L;
+ typedef util::array<point2d> arr_t;
+ typedef accu::center<point2d,point2d> accu_t;
+ typedef util::array<accu_t> accu_arr_t;
+ typedef util::couple<L,util::couple<arr_t, accu_arr_t> > res_t;
+ res_t result = labeling::blobs_and_compute(pic, c4(), n,
+ accu_t());
- mln_assertion(result.second().first().size() == 34);
- mln_assertion(result.second().second().size() == 34);
- mln_assertion(result.second().first()[1] == point2d(10,30));
- mln_assertion(result.second().second()[33] == point2d(311,67));
- mln_assertion(n == 33);
+ mln_assertion(result.second().first().size() == 34);
+ mln_assertion(result.second().second().size() == 34);
+ mln_assertion(result.second().first()[1] == point2d(10,30));
+ mln_assertion(result.second().second()[33] == point2d(311,67));
+ mln_assertion(n == 33);
+ }
+
+ {
+ image2d<value::label_8> pic;
+ io::pgm::load(pic, MLN_IMG_DIR "/fly.pgm");
+ value::label_8 n;
+
+
+ typedef image2d<value::label_8> L;
+ typedef util::array<point2d> arr_t;
+ typedef accu::center<point2d,point2d> accu_t;
+ typedef util::array<accu_t> accu_arr_t;
+ typedef util::couple<L,util::couple<arr_t, accu_arr_t> > res_t;
+ res_t result = labeling::blobs_and_compute(pic, c4(), n,
+ accu_t());
+
+ mln_assertion(result.second().first().size() == 25);
+ mln_assertion(result.second().second().size() == 25);
+ mln_assertion(result.second().first()[1] == point2d(0,0));
+ mln_assertion(result.second().second()[24] == point2d(4,4));
+ mln_assertion(n == 24);
+ }
+
}
--
1.7.2.5
1
0