Olena-patches
Threads by month
- ----- 2025 -----
- October
- September
- 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
June 2010
- 9 participants
- 276 discussions
* viewer/image_region.cc,
* viewer/image_region.hxx:
Improve selection highlighting (more readable).
---
viewer/image_region.cc | 41 ++++++++++++++++++++++++++++++++++++++---
viewer/image_region.hxx | 24 ------------------------
2 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/viewer/image_region.cc b/viewer/image_region.cc
index bef30fc..7761065 100644
--- a/viewer/image_region.cc
+++ b/viewer/image_region.cc
@@ -70,11 +70,10 @@ ImageRegion::paint(QPainter* painter,
width = 1;
if (outline_)
- painter->setPen(QPen(QBrush(color_), width));
+ painter->setPen(QPen(QBrush(color_), width, Qt::SolidLine,
+ Qt::SquareCap, Qt::MiterJoin));
else
painter->setPen(QColor(0, 0, 0, 0));
- if (selected_)
- painter->setPen(QPen(QBrush(QColor("red")), width));
QColor brush = color_;
if (fill_)
@@ -84,4 +83,40 @@ ImageRegion::paint(QPainter* painter,
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(2);
+ scene()->invalidate();
+ update();
+ }
+}
+
+void
+ImageRegion::deselect()
+{
+ if (selected_)
+ {
+ selected_ = false;
+ scene()->invalidate();
+ setZValue(1);
+ update();
+ }
}
diff --git a/viewer/image_region.hxx b/viewer/image_region.hxx
index 35634f7..b15615c 100644
--- a/viewer/image_region.hxx
+++ b/viewer/image_region.hxx
@@ -87,28 +87,4 @@ ImageRegion::index() const
return index_;
}
-inline
-void
-ImageRegion::select()
-{
- if (!selected_)
- {
- selected_ = true;
- setZValue(2);
- update();
- }
-}
-
-inline
-void
-ImageRegion::deselect()
-{
- if (selected_)
- {
- selected_ = false;
- setZValue(1);
- update();
- }
-}
-
#endif /* !IMAGE_REGION_HXX_ */
--
1.5.6.5
1
0
* viewer/viewer.cc: Remove debug output.
---
viewer/viewer.cc | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/viewer/viewer.cc b/viewer/viewer.cc
index ce9f850..622a805 100644
--- a/viewer/viewer.cc
+++ b/viewer/viewer.cc
@@ -290,7 +290,6 @@ Viewer::help()
void
Viewer::maybeChangeCacheMode(qreal scale)
{
- qDebug() << scale;
if (image_)
{
if (scale >= 0.7)
--
1.5.6.5
1
0
* viewer/help_dialog.cc:
Update help message.
* viewer/image_view.cc,
* viewer/image_view.hh,
* viewer/image_widget.cc,
* viewer/image_widget.hh,
* viewer/viewer.cc,
* viewer/viewer.hh:
Update colors. Improve cache usage (disabled when zoomed in).
---
viewer/help_dialog.cc | 2 ++
viewer/image_view.cc | 30 ++++++++++++++++++++++++++++++
viewer/image_view.hh | 8 ++++++++
viewer/image_widget.cc | 6 +++++-
viewer/image_widget.hh | 3 +++
viewer/viewer.cc | 38 +++++++++++++++++++++++---------------
viewer/viewer.hh | 5 +++--
7 files changed, 74 insertions(+), 18 deletions(-)
diff --git a/viewer/help_dialog.cc b/viewer/help_dialog.cc
index ebdfdaa..fe59d93 100644
--- a/viewer/help_dialog.cc
+++ b/viewer/help_dialog.cc
@@ -33,6 +33,8 @@ HelpDialog::HelpDialog()
" - If the document layout is present\n"
" (XML file with the same name),\n"
" select regions to display their properties.\n"
+ " - Use the mouse or keyboard to move and zoom\n"
+ " (Arrows, PageUp, PageDown, Home, End).\n"
"\n"
"Contact: d-halluin(a)lrde.epita.fr\n"
"\n"
diff --git a/viewer/image_view.cc b/viewer/image_view.cc
index f017fe9..9182c1b 100644
--- a/viewer/image_view.cc
+++ b/viewer/image_view.cc
@@ -40,9 +40,39 @@ ImageView::wheelEvent(QWheelEvent* event)
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/viewer/image_view.hh b/viewer/image_view.hh
index d2e0058..84f722f 100644
--- a/viewer/image_view.hh
+++ b/viewer/image_view.hh
@@ -27,6 +27,14 @@ public:
~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 /* !IMAGE_VIEW_HH_ */
diff --git a/viewer/image_widget.cc b/viewer/image_widget.cc
index b8ac8c2..b4bee72 100644
--- a/viewer/image_widget.cc
+++ b/viewer/image_widget.cc
@@ -25,11 +25,14 @@ ImageWidget::ImageWidget(QGraphicsScene* scene)
layout->addWidget(title);
layout->addWidget(view_);
- view_->setDragMode (QGraphicsView::ScrollHandDrag);
+ 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);
}
@@ -37,6 +40,7 @@ void
ImageWidget::update()
{
view_->fitInView(view_->sceneRect(), Qt::KeepAspectRatio);
+ view_->scaleUpdate();
}
ImageWidget::~ImageWidget()
diff --git a/viewer/image_widget.hh b/viewer/image_widget.hh
index 25a41a0..87259b0 100644
--- a/viewer/image_widget.hh
+++ b/viewer/image_widget.hh
@@ -31,6 +31,9 @@ public:
public slots:
void update();
+signals:
+ void scaleUpdated(qreal scale);
+
private:
ImageView* view_;
};
diff --git a/viewer/viewer.cc b/viewer/viewer.cc
index 88d0525..ce9f850 100644
--- a/viewer/viewer.cc
+++ b/viewer/viewer.cc
@@ -34,15 +34,15 @@ Viewer::Viewer(int &argc, char** argv)
files_(new QDirModel()),
doc_layout_(0),
key_map_(9),
- alt_cache_(false)
+ no_cache_(false)
{
// Key map
key_map_[region::Text] = qMakePair(tr("Text"), QColor(0, 200, 0));
key_map_[region::Image] = qMakePair(tr("Image"), QColor(255, 120, 0));
- key_map_[region::Noise] = qMakePair(tr("Noise"), QColor(114, 188, 144));
- key_map_[region::Separator] = qMakePair(tr("Separator"), QColor(200, 222, 0));
- key_map_[region::Table] = qMakePair(tr("Table"), QColor(0, 0, 255));
+ key_map_[region::Noise] = qMakePair(tr("Noise"), QColor(43, 39, 128));
+ key_map_[region::Separator] = qMakePair(tr("Separator"), QColor(0, 0, 255));
+ 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));
@@ -96,14 +96,13 @@ Viewer::Viewer(int &argc, char** argv)
connect(fill_action_, SIGNAL(toggled(bool)),
this, SIGNAL(setFill(bool)));
option_menu->addAction(fill_action_);
- QAction* cache_action = new QAction(tr("Alternative cache mode"),
- option_menu);
- cache_action->setStatusTip(tr("Much faster at low zoom, "
- "but unstable at high zoom."));
+ QAction* cache_action = new QAction(tr("Disable cache"), file_menu);
+ cache_action->setStatusTip(tr("Disable the image cache (useful for"
+ " large images)."));
cache_action->setCheckable(true);
cache_action->setChecked(false);
connect(cache_action, SIGNAL(toggled(bool)),
- this, SLOT(setAltCache(bool)));
+ this, SLOT(useCache(bool)));
option_menu->addAction(cache_action);
QMenu* help_menu = win_->menuBar()->addMenu(tr("Help"));
@@ -168,6 +167,8 @@ Viewer::Viewer(int &argc, char** argv)
xml_wgt, SLOT(select(QModelIndex)));
connect(scene_, SIGNAL(deselected(QModelIndex)),
xml_wgt, SLOT(deselect(QModelIndex)));
+ connect(image_wgt, SIGNAL(scaleUpdated(qreal)),
+ this, SLOT(maybeChangeCacheMode(qreal)));
}
void
@@ -182,7 +183,6 @@ Viewer::load(QString filename)
// OpenGL might speed up things a bit.
image_ = new QGraphicsPixmapItem(QPixmap(filename));
image_->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
- image_->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize());
image_->setZValue(0);
scene_->addItem(image_);
@@ -288,14 +288,22 @@ Viewer::help()
}
void
-Viewer::setAltCache(bool b)
+Viewer::maybeChangeCacheMode(qreal scale)
{
- alt_cache_ = b;
+ qDebug() << scale;
if (image_)
{
- if (b)
+ if (scale >= 0.7)
+ image_->setCacheMode(QGraphicsItem::NoCache);
+ else if (!no_cache_)
image_->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- else
- image_->setCacheMode(QGraphicsItem::ItemCoordinateCache);
}
}
+
+void
+Viewer::useCache(bool b)
+{
+ no_cache_ = b;
+ if (b)
+ image_->setCacheMode(QGraphicsItem::NoCache);
+}
diff --git a/viewer/viewer.hh b/viewer/viewer.hh
index 0a76afd..d579847 100644
--- a/viewer/viewer.hh
+++ b/viewer/viewer.hh
@@ -40,7 +40,8 @@ public slots:
void load(QString filename);
void help();
- void setAltCache(bool b);
+ void maybeChangeCacheMode(qreal scale);
+ void useCache(bool b);
signals:
void updated(DomModel* model);
@@ -71,7 +72,7 @@ private:
QMap<QString, int> region_ids_;
region::KeyMap key_map_;
- bool alt_cache_;
+ bool no_cache_;
};
#include "viewer.hxx"
--
1.5.6.5
1
0
* viewer/viewer.cc,
* viewer/browser_widget.cc,
* viewer/browser_widget.hh:
Browse to the directory taken as first parameter.
* viewer/main.cc:
Add usage info.
---
viewer/browser_widget.cc | 5 ++++-
viewer/browser_widget.hh | 2 +-
viewer/main.cc | 13 ++++++++++++-
viewer/viewer.cc | 3 ++-
4 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/viewer/browser_widget.cc b/viewer/browser_widget.cc
index 643cf2f..24f93ca 100644
--- a/viewer/browser_widget.cc
+++ b/viewer/browser_widget.cc
@@ -14,7 +14,7 @@
#include "browser_widget.hh"
-BrowserWidget::BrowserWidget(QDirModel* files)
+BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
: files_(files),
view_(new QListView()),
path_(new QLabel(""))
@@ -34,6 +34,9 @@ BrowserWidget::BrowserWidget(QDirModel* 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&)),
diff --git a/viewer/browser_widget.hh b/viewer/browser_widget.hh
index 954115f..bba438b 100644
--- a/viewer/browser_widget.hh
+++ b/viewer/browser_widget.hh
@@ -23,7 +23,7 @@ class BrowserWidget
Q_OBJECT
public:
- BrowserWidget(QDirModel* files);
+ BrowserWidget(QDirModel* files, QString dir = QString());
~BrowserWidget();
public slots:
diff --git a/viewer/main.cc b/viewer/main.cc
index 3bcc590..640ea0f 100644
--- a/viewer/main.cc
+++ b/viewer/main.cc
@@ -13,14 +13,25 @@
//
#include <QtGui>
+#include <iostream>
+
#include "viewer.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 0;
+ return -1;
return viewer->exec();
}
diff --git a/viewer/viewer.cc b/viewer/viewer.cc
index 3b3b188..88d0525 100644
--- a/viewer/viewer.cc
+++ b/viewer/viewer.cc
@@ -119,7 +119,8 @@ Viewer::Viewer(int &argc, char** argv)
PropertyWidget* property_wgt = new PropertyWidget();
XmlWidget* xml_wgt = new XmlWidget();
- BrowserWidget* browser_wgt = new BrowserWidget(files_);
+ BrowserWidget* browser_wgt =
+ new BrowserWidget(files_, argc != 2 ? QString() : argv[1]);
ImageWidget* image_wgt = new ImageWidget(scene_);
key_wgt_ = new KeyWidget(key_map_);
--
1.5.6.5
1
0
* viewer/Makefile.am,
* viewer/README,
* viewer/browser_widget.cc,
* viewer/browser_widget.hh,
* viewer/common.hh,
* viewer/domitem.cc,
* viewer/domitem.hh,
* viewer/dommodel.cc,
* viewer/dommodel.hh,
* viewer/help_dialog.cc,
* viewer/help_dialog.hh,
* viewer/image_region.cc,
* viewer/image_region.hh,
* viewer/image_region.hxx,
* viewer/image_scene.cc,
* viewer/image_scene.hh,
* viewer/image_view.cc,
* viewer/image_view.hh,
* viewer/image_widget.cc,
* viewer/image_widget.hh,
* viewer/key_widget.cc,
* viewer/key_widget.hh,
* viewer/main.cc,
* viewer/property_widget.cc,
* viewer/property_widget.hh,
* viewer/viewer.cc,
* viewer/viewer.hh,
* viewer/viewer.hxx,
* viewer/xml_widget.cc,
* viewer/xml_widget.hh:
New.
---
viewer/Makefile.am | 67 ++++++++++
viewer/README | 33 +++++
viewer/browser_widget.cc | 63 ++++++++++
viewer/browser_widget.hh | 41 ++++++
viewer/common.hh | 36 ++++++
viewer/domitem.cc | 98 +++++++++++++++
viewer/domitem.hh | 75 +++++++++++
viewer/dommodel.cc | 198 +++++++++++++++++++++++++++++
viewer/dommodel.hh | 85 +++++++++++++
viewer/help_dialog.cc | 53 ++++++++
viewer/help_dialog.hh | 32 +++++
viewer/image_region.cc | 87 +++++++++++++
viewer/image_region.hh | 74 +++++++++++
viewer/image_region.hxx | 114 +++++++++++++++++
viewer/image_scene.cc | 62 +++++++++
viewer/image_scene.hh | 42 +++++++
viewer/image_view.cc | 48 +++++++
viewer/image_view.hh | 32 +++++
viewer/image_widget.cc | 44 +++++++
viewer/image_widget.hh | 38 ++++++
viewer/key_widget.cc | 65 ++++++++++
viewer/key_widget.hh | 44 +++++++
viewer/main.cc | 26 ++++
viewer/property_widget.cc | 73 +++++++++++
viewer/property_widget.hh | 41 ++++++
viewer/viewer.cc | 300 +++++++++++++++++++++++++++++++++++++++++++++
viewer/viewer.hh | 79 ++++++++++++
viewer/viewer.hxx | 31 +++++
viewer/xml_widget.cc | 53 ++++++++
viewer/xml_widget.hh | 41 ++++++
30 files changed, 2075 insertions(+), 0 deletions(-)
create mode 100644 viewer/Makefile.am
create mode 100644 viewer/README
create mode 100644 viewer/browser_widget.cc
create mode 100644 viewer/browser_widget.hh
create mode 100644 viewer/common.hh
create mode 100644 viewer/domitem.cc
create mode 100644 viewer/domitem.hh
create mode 100644 viewer/dommodel.cc
create mode 100644 viewer/dommodel.hh
create mode 100644 viewer/help_dialog.cc
create mode 100644 viewer/help_dialog.hh
create mode 100644 viewer/image_region.cc
create mode 100644 viewer/image_region.hh
create mode 100644 viewer/image_region.hxx
create mode 100644 viewer/image_scene.cc
create mode 100644 viewer/image_scene.hh
create mode 100644 viewer/image_view.cc
create mode 100644 viewer/image_view.hh
create mode 100644 viewer/image_widget.cc
create mode 100644 viewer/image_widget.hh
create mode 100644 viewer/key_widget.cc
create mode 100644 viewer/key_widget.hh
create mode 100644 viewer/main.cc
create mode 100644 viewer/property_widget.cc
create mode 100644 viewer/property_widget.hh
create mode 100644 viewer/viewer.cc
create mode 100644 viewer/viewer.hh
create mode 100644 viewer/viewer.hxx
create mode 100644 viewer/xml_widget.cc
create mode 100644 viewer/xml_widget.hh
diff --git a/viewer/Makefile.am b/viewer/Makefile.am
new file mode 100644
index 0000000..0a6213a
--- /dev/null
+++ b/viewer/Makefile.am
@@ -0,0 +1,67 @@
+##
+## Document layout viewer.
+##
+## Copyright (C) 2009 Florent D'Halluin.
+##
+## This program 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; either version 2
+## of the License, or (at your option) any later version.
+##
+## The complete GNU General Public Licence Notice can be found as the
+## `COPYING' file in the root directory.
+##
+
+include $(top_srcdir)/build-aux/autotroll.mk
+
+bin_PROGRAMS = viewer
+viewer_SOURCES = $(BUILT_SOURCES) \
+ viewer.cc \
+ main.cc \
+ image_widget.cc \
+ xml_widget.cc \
+ key_widget.cc \
+ property_widget.cc \
+ browser_widget.cc \
+ image_scene.cc \
+ image_view.cc \
+ dommodel.cc \
+ domitem.cc \
+ image_region.cc \
+ help_dialog.cc
+
+viewer_CPPFLAGS = $(QT_CPPFLAGS) $(AM_CPPFLAGS) -I$(srcdir)
+viewer_CXXFLAGS = $(QT_CXXFLAGS) $(AM_CXXFLAGS) -O3
+viewer_LDFLAGS = $(QT_LDFLAGS) $(LDFLAGS)
+viewer_LDADD = $(QT_LIBS) $(LDADD)
+
+BUILT_SOURCES = viewer.moc.cc \
+ image_widget.moc.cc \
+ xml_widget.moc.cc \
+ key_widget.moc.cc \
+ property_widget.moc.cc \
+ browser_widget.moc.cc \
+ image_scene.moc.cc \
+ image_view.moc.cc \
+ dommodel.moc.cc \
+ domitem.moc.cc \
+ image_region.moc.cc \
+ help_dialog.moc.cc
+
+include_HEADERS = viewer.hh \
+ viewer.hxx \
+ image_widget.hh \
+ xml_widget.hh \
+ key_widget.hh \
+ property_widget.hh \
+ browser_widget.hh \
+ image_scene.hh \
+ image_view.hh \
+ dommodel.hh \
+ domitem.hh \
+ image_region.hh \
+ image_region.hxx \
+ common.hh \
+ help_dialog.hh
+
+EXTRA_DIST = README
diff --git a/viewer/README b/viewer/README
new file mode 100644
index 0000000..6032a41
--- /dev/null
+++ b/viewer/README
@@ -0,0 +1,33 @@
+
+Document layout viewer.
+
+Copyright (C) 2009 Florent D'Halluin.
+
+This program 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; either version 2
+of the License, or (at your option) any later version.
+
+The complete GNU General Public Licence Notice can be found as the
+`COPYING' file in the root directory.
+
+__________________________________________________________________
+
+
+Document Layout Viewer
+
+Purpose:
+- Display layout information about image documents.
+
+Contact:
+d-halluin(a)lrde.epita.fr
+
+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.
+- The DOM Model classes are a slightly modified Qt example.
diff --git a/viewer/browser_widget.cc b/viewer/browser_widget.cc
new file mode 100644
index 0000000..643cf2f
--- /dev/null
+++ b/viewer/browser_widget.cc
@@ -0,0 +1,63 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include "browser_widget.hh"
+
+BrowserWidget::BrowserWidget(QDirModel* files)
+ : files_(files),
+ view_(new QListView()),
+ path_(new QLabel(""))
+{
+ QLabel* title = new QLabel(tr("Images"));
+ title->setAlignment(Qt::AlignHCenter);
+
+ QVBoxLayout* layout = new QVBoxLayout;
+ layout->addWidget(title);
+ layout->addWidget(path_);
+ layout->addWidget(view_);
+
+ setLayout(layout);
+
+ view_->setModel(files);
+ files->setFilter(QDir::AllDirs | QDir::Files
+ | QDir::Readable | QDir::Drives);
+
+ view_->setRootIndex(files->index(QDir::currentPath()));
+ view_->setRowHidden(0, true);
+ path_->setText(files->filePath(view_->rootIndex()));
+ connect(view_, SIGNAL(activated(const QModelIndex&)),
+ this, SLOT(activate(const QModelIndex&)));
+
+ QStringList files_filters;
+ files_filters << "*.png" << "*.jpg"
+ << "*.tif" << "*.ppm" << "*.pgm";
+ files->setNameFilters(files_filters);
+}
+
+void
+BrowserWidget::activate(const QModelIndex& index)
+{
+ if (files_->isDir(index))
+ {
+ view_->setRootIndex(index);
+ view_->setRowHidden(0, true);
+ path_->setText(files_->filePath(view_->rootIndex()));
+ return;
+ }
+ emit activated(files_->filePath(index));
+}
+
+BrowserWidget::~BrowserWidget()
+{
+}
diff --git a/viewer/browser_widget.hh b/viewer/browser_widget.hh
new file mode 100644
index 0000000..954115f
--- /dev/null
+++ b/viewer/browser_widget.hh
@@ -0,0 +1,41 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef BROWSER_WIDGET_HH_
+# define BROWSER_WIDGET_HH_
+
+# include <QtGui>
+
+class BrowserWidget
+ : public QWidget
+{
+ Q_OBJECT
+
+public:
+ BrowserWidget(QDirModel* files);
+ ~BrowserWidget();
+
+public slots:
+ void activate(const QModelIndex& index);
+
+signals:
+ void activated(QString filename);
+
+private:
+ QDirModel* files_;
+ QListView* view_;
+ QLabel* path_;
+};
+
+#endif /* !BROWSER_WIDGET_HH_ */
diff --git a/viewer/common.hh b/viewer/common.hh
new file mode 100644
index 0000000..ba4f3b1
--- /dev/null
+++ b/viewer/common.hh
@@ -0,0 +1,36 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef COMMON_HH_
+# define COMMON_HH_
+
+namespace region
+{
+ typedef QVector<QPair<QString, QColor> > KeyMap;
+
+ enum RegionId
+ {
+ Text = 0,
+ Image,
+ Noise,
+ Separator,
+ Table,
+ LineDrawing,
+ Graphic,
+ Chart,
+ Maths
+ };
+};
+
+#endif /* !COMMON_HH_ */
diff --git a/viewer/domitem.cc b/viewer/domitem.cc
new file mode 100644
index 0000000..66e989a
--- /dev/null
+++ b/viewer/domitem.cc
@@ -0,0 +1,98 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: Qt Software Information (qt-info(a)nokia.com)
+ **
+ ** This file is part of the example classes of the Qt Toolkit.
+ **
+ ** Commercial Usage
+ ** Licensees holding valid Qt Commercial licenses may use this file in
+ ** accordance with the Qt Commercial License Agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+ ** a written agreement between you and Nokia.
+ **
+ **
+ ** GNU General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU
+ ** General Public License versions 2.0 or 3.0 as published by the Free
+ ** Software Foundation and appearing in the file LICENSE.GPL included in
+ ** the packaging of this file. Please review the following information
+ ** to ensure GNU General Public Licensing requirements will be met:
+ ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+ ** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
+ ** exception, Nokia gives you certain additional rights. These rights
+ ** are described in the Nokia Qt GPL Exception version 1.3, included in
+ ** the file GPL_EXCEPTION.txt in this package.
+ **
+ ** Qt for Windows(R) Licensees
+ ** As a special exception, Nokia, as the sole copyright holder for Qt
+ ** Designer, grants users of the Qt/Eclipse Integration plug-in the
+ ** right for the Qt/Eclipse Integration to link to functionality
+ ** provided by Qt Designer and its related libraries.
+ **
+ ** If you are unsure which license is appropriate for your use, please
+ ** contact the sales department at qt-sales(a)nokia.com.
+ **
+ ****************************************************************************/
+
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include <QtXml>
+
+#include "domitem.hh"
+
+DomItem::DomItem(QDomNode &node, int row, DomItem *parent)
+{
+ domNode = node;
+ // Record the item's location within its parent.
+ rowNumber = row;
+ parentItem = parent;
+}
+
+DomItem::~DomItem()
+{
+ QHash<int,DomItem*>::iterator it;
+ for (it = childItems.begin(); it != childItems.end(); ++it)
+ delete it.value();
+}
+
+QDomNode DomItem::node() const
+{
+ return domNode;
+}
+
+DomItem *DomItem::parent()
+{
+ return parentItem;
+}
+
+DomItem *DomItem::child(int i)
+{
+ if (childItems.contains(i))
+ return childItems[i];
+
+ if (i >= 0 && i < domNode.childNodes().count()) {
+ QDomNode childNode = domNode.childNodes().item(i);
+ DomItem *childItem = new DomItem(childNode, i, this);
+ childItems[i] = childItem;
+ return childItem;
+ }
+ return 0;
+}
+
+int DomItem::row()
+{
+ return rowNumber;
+}
diff --git a/viewer/domitem.hh b/viewer/domitem.hh
new file mode 100644
index 0000000..a5c22cc
--- /dev/null
+++ b/viewer/domitem.hh
@@ -0,0 +1,75 @@
+ /****************************************************************************
+ **
+ ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: Qt Software Information (qt-info(a)nokia.com)
+ **
+ ** This file is part of the example classes of the Qt Toolkit.
+ **
+ ** Commercial Usage
+ ** Licensees holding valid Qt Commercial licenses may use this file in
+ ** accordance with the Qt Commercial License Agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+ ** a written agreement between you and Nokia.
+ **
+ **
+ ** GNU General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU
+ ** General Public License versions 2.0 or 3.0 as published by the Free
+ ** Software Foundation and appearing in the file LICENSE.GPL included in
+ ** the packaging of this file. Please review the following information
+ ** to ensure GNU General Public Licensing requirements will be met:
+ ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+ ** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
+ ** exception, Nokia gives you certain additional rights. These rights
+ ** are described in the Nokia Qt GPL Exception version 1.3, included in
+ ** the file GPL_EXCEPTION.txt in this package.
+ **
+ ** Qt for Windows(R) Licensees
+ ** As a special exception, Nokia, as the sole copyright holder for Qt
+ ** Designer, grants users of the Qt/Eclipse Integration plug-in the
+ ** right for the Qt/Eclipse Integration to link to functionality
+ ** provided by Qt Designer and its related libraries.
+ **
+ ** If you are unsure which license is appropriate for your use, please
+ ** contact the sales department at qt-sales(a)nokia.com.
+ **
+ ****************************************************************************/
+
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef DOMITEM_H
+#define DOMITEM_H
+
+#include <QDomNode>
+#include <QHash>
+
+class DomItem
+{
+public:
+ DomItem(QDomNode &node, int row, DomItem *parent = 0);
+ ~DomItem();
+ DomItem *child(int i);
+ DomItem *parent();
+ QDomNode node() const;
+ int row();
+
+private:
+ QDomNode domNode;
+ QHash<int,DomItem*> childItems;
+ DomItem *parentItem;
+ int rowNumber;
+};
+
+#endif
diff --git a/viewer/dommodel.cc b/viewer/dommodel.cc
new file mode 100644
index 0000000..baaf9a7
--- /dev/null
+++ b/viewer/dommodel.cc
@@ -0,0 +1,198 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: Qt Software Information (qt-info(a)nokia.com)
+ **
+ ** This file is part of the example classes of the Qt Toolkit.
+ **
+ ** Commercial Usage
+ ** Licensees holding valid Qt Commercial licenses may use this file in
+ ** accordance with the Qt Commercial License Agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+ ** a written agreement between you and Nokia.
+ **
+ **
+ ** GNU General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU
+ ** General Public License versions 2.0 or 3.0 as published by the Free
+ ** Software Foundation and appearing in the file LICENSE.GPL included in
+ ** the packaging of this file. Please review the following information
+ ** to ensure GNU General Public Licensing requirements will be met:
+ ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+ ** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
+ ** exception, Nokia gives you certain additional rights. These rights
+ ** are described in the Nokia Qt GPL Exception version 1.3, included in
+ ** the file GPL_EXCEPTION.txt in this package.
+ **
+ ** Qt for Windows(R) Licensees
+ ** As a special exception, Nokia, as the sole copyright holder for Qt
+ ** Designer, grants users of the Qt/Eclipse Integration plug-in the
+ ** right for the Qt/Eclipse Integration to link to functionality
+ ** provided by Qt Designer and its related libraries.
+ **
+ ** If you are unsure which license is appropriate for your use, please
+ ** contact the sales department at qt-sales(a)nokia.com.
+ **
+ ****************************************************************************/
+
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include <QtGui>
+#include <QtXml>
+
+#include "domitem.hh"
+#include "dommodel.hh"
+
+DomModel::DomModel(QDomDocument document, QObject *parent)
+ : QAbstractItemModel(parent), domDocument(document)
+{
+ rootItem = new DomItem(domDocument, 0);
+}
+
+DomModel::~DomModel()
+{
+ delete rootItem;
+}
+
+int DomModel::columnCount(const QModelIndex &/*parent*/) const
+{
+ return 3;
+}
+
+QVariant DomModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ DomItem *item = static_cast<DomItem*>(index.internalPointer());
+ QDomNode node = item->node();
+ QDomNamedNodeMap attributeMap = node.attributes();
+
+ if (role == Qt::DisplayRole)
+ {
+ QStringList attributes;
+
+ switch (index.column())
+ {
+ case 0:
+ return node.nodeName();
+ case 1:
+ for (int i = 0; i < attributeMap.count(); ++i)
+ {
+ QDomNode attribute = attributeMap.item(i);
+ attributes << attribute.nodeName() + "=\""
+ + attribute.nodeValue() + "\"";
+ }
+ return attributes.join(" ");
+ case 2:
+ return node.nodeValue().split("\n").join(" ");
+ default:
+ return QVariant();
+ }
+ }
+ else if (role == Qt::UserRole)
+ {
+ QMap<QString, QVariant> attributes;
+ switch (index.column())
+ {
+ case 1:
+ for (int i = 0; i < attributeMap.count(); ++i)
+ {
+ QDomNode attribute = attributeMap.item(i);
+ attributes[attribute.nodeName()] = attribute.nodeValue();
+ }
+ return attributes;
+ default:
+ return QVariant();
+ }
+ }
+ return QVariant();
+}
+
+Qt::ItemFlags DomModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return 0;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+QVariant DomModel::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("Attributes");
+ case 2:
+ return tr("Value");
+ default:
+ return QVariant();
+ }
+ }
+
+ return QVariant();
+}
+
+QModelIndex DomModel::index(int row, int column, const QModelIndex &parent)
+ const
+{
+ if (!hasIndex(row, column, parent))
+ return QModelIndex();
+
+ DomItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<DomItem*>(parent.internalPointer());
+
+ DomItem *childItem = parentItem->child(row);
+ if (childItem)
+ return createIndex(row, column, childItem);
+ else
+ return QModelIndex();
+}
+
+QModelIndex DomModel::parent(const QModelIndex &child) const
+{
+ if (!child.isValid())
+ return QModelIndex();
+
+ DomItem *childItem = static_cast<DomItem*>(child.internalPointer());
+ DomItem *parentItem = childItem->parent();
+
+ if (!parentItem || parentItem == rootItem)
+ return QModelIndex();
+
+ return createIndex(parentItem->row(), 0, parentItem);
+}
+
+int DomModel::rowCount(const QModelIndex &parent) const
+{
+ if (parent.column() > 0)
+ return 0;
+
+ DomItem *parentItem;
+
+ if (!parent.isValid())
+ parentItem = rootItem;
+ else
+ parentItem = static_cast<DomItem*>(parent.internalPointer());
+
+ return parentItem->node().childNodes().count();
+}
diff --git a/viewer/dommodel.hh b/viewer/dommodel.hh
new file mode 100644
index 0000000..16c5a23
--- /dev/null
+++ b/viewer/dommodel.hh
@@ -0,0 +1,85 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+ ** Contact: Qt Software Information (qt-info(a)nokia.com)
+ **
+ ** This file is part of the example classes of the Qt Toolkit.
+ **
+ ** Commercial Usage
+ ** Licensees holding valid Qt Commercial licenses may use this file in
+ ** accordance with the Qt Commercial License Agreement provided with the
+ ** Software or, alternatively, in accordance with the terms contained in
+ ** a written agreement between you and Nokia.
+ **
+ **
+ ** GNU General Public License Usage
+ ** Alternatively, this file may be used under the terms of the GNU
+ ** General Public License versions 2.0 or 3.0 as published by the Free
+ ** Software Foundation and appearing in the file LICENSE.GPL included in
+ ** the packaging of this file. Please review the following information
+ ** to ensure GNU General Public Licensing requirements will be met:
+ ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+ ** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
+ ** exception, Nokia gives you certain additional rights. These rights
+ ** are described in the Nokia Qt GPL Exception version 1.3, included in
+ ** the file GPL_EXCEPTION.txt in this package.
+ **
+ ** Qt for Windows(R) Licensees
+ ** As a special exception, Nokia, as the sole copyright holder for Qt
+ ** Designer, grants users of the Qt/Eclipse Integration plug-in the
+ ** right for the Qt/Eclipse Integration to link to functionality
+ ** provided by Qt Designer and its related libraries.
+ **
+ ** If you are unsure which license is appropriate for your use, please
+ ** contact the sales department at qt-sales(a)nokia.com.
+ **
+ ****************************************************************************/
+
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef DOMMODEL_H
+#define DOMMODEL_H
+
+#include <QAbstractItemModel>
+#include <QDomDocument>
+#include <QModelIndex>
+#include <QVariant>
+
+class DomItem;
+
+class DomModel : public QAbstractItemModel
+{
+ Q_OBJECT
+
+ public:
+ DomModel(QDomDocument document, QObject *parent = 0);
+ ~DomModel();
+
+ QVariant data(const QModelIndex &index, int role) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex &child) const;
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+private:
+ QDomDocument domDocument;
+ DomItem *rootItem;
+};
+
+#endif
diff --git a/viewer/help_dialog.cc b/viewer/help_dialog.cc
new file mode 100644
index 0000000..ebdfdaa
--- /dev/null
+++ b/viewer/help_dialog.cc
@@ -0,0 +1,53 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include "help_dialog.hh"
+
+HelpDialog::HelpDialog()
+{
+ QPushButton *closeButton = new QPushButton(tr("Close"));
+ connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+
+ QHBoxLayout *buttonsLayout = new QHBoxLayout;
+ buttonsLayout->addStretch(1);
+ buttonsLayout->addWidget(closeButton);
+
+ QVBoxLayout *mainLayout = new QVBoxLayout;
+
+ QString help = tr(
+ "Document layout viewer:\n"
+ "\n"
+ "Usage:\n"
+ " - Choose an image file in the file browser\n"
+ " - If the document layout is present\n"
+ " (XML file with the same name),\n"
+ " select regions to display their properties.\n"
+ "\n"
+ "Contact: d-halluin(a)lrde.epita.fr\n"
+ "\n"
+ "Copyright Florent D'Halluin, 2009.\n");
+
+ QLabel* label = new QLabel(help);
+
+ mainLayout->addWidget(label);
+ mainLayout->addLayout(buttonsLayout);
+
+ setLayout(mainLayout);
+ setWindowTitle(tr("About"));
+}
+
+void HelpDialog::done()
+{
+ emit close();
+}
diff --git a/viewer/help_dialog.hh b/viewer/help_dialog.hh
new file mode 100644
index 0000000..114d8f5
--- /dev/null
+++ b/viewer/help_dialog.hh
@@ -0,0 +1,32 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef HELP_DIALOG_HH_
+# define HELP_DIALOG_HH_
+
+# include <QtGui>
+
+class HelpDialog
+ : public QDialog
+{
+ Q_OBJECT
+
+public:
+ HelpDialog();
+
+public slots:
+ void done();
+};
+
+#endif /* !HELP_DIALOG_HH_ */
diff --git a/viewer/image_region.cc b/viewer/image_region.cc
new file mode 100644
index 0000000..bef30fc
--- /dev/null
+++ b/viewer/image_region.cc
@@ -0,0 +1,87 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include "image_region.hh"
+
+ImageRegion::ImageRegion(region::RegionId id,
+ QString name,
+ QColor color,
+ QModelIndex index,
+ const QVector<QPoint>& points,
+ bool outline,
+ bool fill,
+ bool precise,
+ bool draw)
+ : QGraphicsItem(0),
+ id_(id),
+ name_(name),
+ color_(color),
+ index_(index),
+ shape_(),
+ rect_(),
+ outline_(outline),
+ precise_(precise),
+ fill_(fill),
+ draw_(draw),
+ selected_(false),
+ alpha_(30)
+{
+ setCursor(Qt::ArrowCursor);
+ 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]);
+
+ prepareGeometryChange();
+}
+
+ImageRegion::~ImageRegion()
+{
+}
+
+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));
+ else
+ painter->setPen(QColor(0, 0, 0, 0));
+ if (selected_)
+ painter->setPen(QPen(QBrush(QColor("red")), width));
+
+ QColor brush = color_;
+ if (fill_)
+ brush.setAlpha(alpha_);
+ else
+ brush.setAlpha(0);
+ painter->setBrush(brush);
+
+ painter->drawPath(shape_);
+}
diff --git a/viewer/image_region.hh b/viewer/image_region.hh
new file mode 100644
index 0000000..7f65c02
--- /dev/null
+++ b/viewer/image_region.hh
@@ -0,0 +1,74 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef IMAGE_REGION_HH_
+# define IMAGE_REGION_HH_
+
+# include <QtGui>
+# include "common.hh"
+
+class ImageRegion
+ : public QObject, public QGraphicsItem
+{
+ Q_OBJECT
+
+public:
+ ImageRegion(region::RegionId id,
+ QString name,
+ QColor color,
+ QModelIndex index,
+ const QVector<QPoint>& points,
+ bool outline,
+ bool fill,
+ bool precise,
+ bool draw);
+
+ ~ImageRegion();
+
+ void paint(QPainter* painter,
+ const QStyleOptionGraphicsItem* option,
+ QWidget* widget = 0);
+
+ const QModelIndex& index() const;
+ QRectF boundingRect() const;
+ QPainterPath shape() const;
+
+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_;
+ QModelIndex index_;
+ QPainterPath shape_;
+ QRectF rect_;
+ bool outline_;
+ bool precise_;
+ bool fill_;
+ bool draw_;
+ bool selected_;
+ int alpha_;
+};
+
+#include "image_region.hxx"
+
+#endif /* !IMAGE_REGION_HH_ */
diff --git a/viewer/image_region.hxx b/viewer/image_region.hxx
new file mode 100644
index 0000000..35634f7
--- /dev/null
+++ b/viewer/image_region.hxx
@@ -0,0 +1,114 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef IMAGE_REGION_HXX_
+# define IMAGE_REGION_HXX_
+
+# include "image_region.hh"
+
+inline
+void
+ImageRegion::setOutline(bool outline)
+{
+ outline_ = outline;
+ update();
+}
+
+inline
+void
+ImageRegion::setPrecise(bool precise)
+{
+ precise_ = precise;
+ 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;
+ update();
+}
+
+inline
+void
+ImageRegion::setFillAlpha(int alpha)
+{
+ alpha_ = alpha;
+ update();
+}
+
+inline
+QRectF
+ImageRegion::boundingRect() const
+{
+ return rect_;
+}
+
+inline
+QPainterPath
+ImageRegion::shape() const
+{
+ return shape_;
+}
+
+inline
+const QModelIndex&
+ImageRegion::index() const
+{
+ return index_;
+}
+
+inline
+void
+ImageRegion::select()
+{
+ if (!selected_)
+ {
+ selected_ = true;
+ setZValue(2);
+ update();
+ }
+}
+
+inline
+void
+ImageRegion::deselect()
+{
+ if (selected_)
+ {
+ selected_ = false;
+ setZValue(1);
+ update();
+ }
+}
+
+#endif /* !IMAGE_REGION_HXX_ */
diff --git a/viewer/image_scene.cc b/viewer/image_scene.cc
new file mode 100644
index 0000000..14eac76
--- /dev/null
+++ b/viewer/image_scene.cc
@@ -0,0 +1,62 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include "image_scene.hh"
+#include "image_region.hh"
+
+ImageScene::ImageScene()
+ : selected_(0)
+{
+}
+
+void
+ImageScene::clear()
+{
+ selected_ = 0;
+ QGraphicsScene::clear();
+}
+
+void
+ImageScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
+{
+ QGraphicsScene::mousePressEvent(event);
+ ImageRegion* item = dynamic_cast<ImageRegion*>(itemAt(event->pos()));
+ if (item)
+ {
+ if (item != selected_)
+ {
+ if (selected_)
+ {
+ selected_->deselect();
+ emit deselected(selected_->index());
+ }
+ selected_ = item;
+ item->select();
+ emit selected(item->index());
+ }
+ }
+ else
+ {
+ if (selected_)
+ {
+ selected_->deselect();
+ emit deselected(selected_->index());
+ selected_ = 0;
+ }
+ }
+}
+
+ImageScene::~ImageScene()
+{
+}
diff --git a/viewer/image_scene.hh b/viewer/image_scene.hh
new file mode 100644
index 0000000..eb95462
--- /dev/null
+++ b/viewer/image_scene.hh
@@ -0,0 +1,42 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef IMAGE_SCENE_HH_
+# define IMAGE_SCENE_HH_
+
+# include <QtGui>
+
+class ImageRegion;
+
+class ImageScene
+ : public QGraphicsScene
+{
+ Q_OBJECT
+
+public:
+ ImageScene();
+ ~ImageScene();
+
+ void mousePressEvent(QGraphicsSceneMouseEvent* event);
+ void clear();
+
+signals:
+ void selected(const QModelIndex& index);
+ void deselected(const QModelIndex& index);
+
+private:
+ ImageRegion* selected_;
+};
+
+#endif /* !IMAGE_SCENE_HH_ */
diff --git a/viewer/image_view.cc b/viewer/image_view.cc
new file mode 100644
index 0000000..f017fe9
--- /dev/null
+++ b/viewer/image_view.cc
@@ -0,0 +1,48 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#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);
+ }
+}
+
+ImageView::~ImageView()
+{
+}
diff --git a/viewer/image_view.hh b/viewer/image_view.hh
new file mode 100644
index 0000000..d2e0058
--- /dev/null
+++ b/viewer/image_view.hh
@@ -0,0 +1,32 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef IMAGE_VIEW_HH_
+# define IMAGE_VIEW_HH_
+
+# include <QtGui>
+
+class ImageView
+ : public QGraphicsView
+{
+ Q_OBJECT
+
+public:
+ ImageView(QGraphicsScene* scene);
+ ~ImageView();
+
+ void wheelEvent(QWheelEvent* event);
+};
+
+#endif /* !IMAGE_VIEW_HH_ */
diff --git a/viewer/image_widget.cc b/viewer/image_widget.cc
new file mode 100644
index 0000000..b8ac8c2
--- /dev/null
+++ b/viewer/image_widget.cc
@@ -0,0 +1,44 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include "image_widget.hh"
+#include "image_view.hh"
+
+ImageWidget::ImageWidget(QGraphicsScene* scene)
+ : view_ (new ImageView(scene))
+{
+ 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);
+
+ setLayout(layout);
+}
+
+void
+ImageWidget::update()
+{
+ view_->fitInView(view_->sceneRect(), Qt::KeepAspectRatio);
+}
+
+ImageWidget::~ImageWidget()
+{
+}
diff --git a/viewer/image_widget.hh b/viewer/image_widget.hh
new file mode 100644
index 0000000..25a41a0
--- /dev/null
+++ b/viewer/image_widget.hh
@@ -0,0 +1,38 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef IMAGE_WIDGET_HH_
+# define IMAGE_WIDGET_HH_
+
+# include <QtGui>
+
+class ImageView;
+
+class ImageWidget
+ : public QWidget
+{
+ Q_OBJECT
+
+public:
+ ImageWidget(QGraphicsScene* scene);
+ ~ImageWidget();
+
+public slots:
+ void update();
+
+private:
+ ImageView* view_;
+};
+
+#endif /* !IMAGE_WIDGET_HH_ */
diff --git a/viewer/key_widget.cc b/viewer/key_widget.cc
new file mode 100644
index 0000000..af817b3
--- /dev/null
+++ b/viewer/key_widget.cc
@@ -0,0 +1,65 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include "key_widget.hh"
+#include "common.hh"
+
+KeyWidget::KeyWidget(const region::KeyMap& key_map)
+ : items_(new QListWidget())
+{
+ QLabel* title = new QLabel(tr("Key"));
+ title->setAlignment(Qt::AlignHCenter);
+
+ QVBoxLayout* layout = new QVBoxLayout;
+ layout->addWidget(title);
+ layout->addWidget(items_);
+
+ for (int i = 0; i < key_map.size(); ++i)
+ add_item_(key_map[i].first, key_map[i].second);
+
+ setLayout(layout);
+
+ connect(items_, SIGNAL(itemChanged(QListWidgetItem*)),
+ this, SLOT(update(QListWidgetItem*)));
+}
+
+void
+KeyWidget::add_item_(QString text, QColor color)
+{
+ QListWidgetItem* item = new QListWidgetItem(text);
+ QPixmap pixmap(10, 6);
+ pixmap.fill(color);
+ item->setIcon(QIcon(pixmap));
+ item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
+ item->setCheckState(Qt::Checked);
+ items_->addItem(item);
+}
+
+bool
+KeyWidget::isChecked(region::RegionId id)
+{
+ return items_->item(id)->checkState() == Qt::Checked;
+}
+
+void
+KeyWidget::update(QListWidgetItem* item)
+{
+ int id = items_->row(item);
+
+ emit updated(id, item->checkState() == Qt::Checked);
+}
+
+KeyWidget::~KeyWidget()
+{
+}
diff --git a/viewer/key_widget.hh b/viewer/key_widget.hh
new file mode 100644
index 0000000..2f8a8c6
--- /dev/null
+++ b/viewer/key_widget.hh
@@ -0,0 +1,44 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef KEY_WIDGET_HH_
+# define 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);
+
+signals:
+ void updated(int key, bool checked);
+
+private slots:
+ void update(QListWidgetItem* slot);
+
+private:
+ void add_item_(QString text, QColor color);
+
+ QListWidget* items_;
+};
+
+#endif /* !KEY_WIDGET_HH_ */
diff --git a/viewer/main.cc b/viewer/main.cc
new file mode 100644
index 0000000..3bcc590
--- /dev/null
+++ b/viewer/main.cc
@@ -0,0 +1,26 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include <QtGui>
+#include "viewer.hh"
+
+int main(int argc, char** argv)
+{
+ Viewer* viewer = Viewer::Instance(argc, argv);
+
+ if (!viewer)
+ return 0;
+
+ return viewer->exec();
+}
diff --git a/viewer/property_widget.cc b/viewer/property_widget.cc
new file mode 100644
index 0000000..3d2f4d5
--- /dev/null
+++ b/viewer/property_widget.cc
@@ -0,0 +1,73 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include "property_widget.hh"
+
+#include "dommodel.hh"
+
+PropertyWidget::PropertyWidget()
+ : view_(new QTreeWidget()),
+ model_(0)
+{
+ QLabel* title = new QLabel(tr("Properties"));
+ title->setAlignment(Qt::AlignHCenter);
+
+ QVBoxLayout* layout = new QVBoxLayout;
+ layout->addWidget(title);
+ layout->addWidget(view_);
+
+ view_->setColumnCount(2);
+ view_->setSortingEnabled(true);
+ view_->setRootIsDecorated(false);
+ QStringList header_names;
+ header_names << tr("Name") << tr("Value");
+ view_->setHeaderItem(new QTreeWidgetItem(header_names));
+
+ setLayout(layout);
+}
+
+void
+PropertyWidget::update(DomModel* model)
+{
+ model_ = model;
+}
+
+void
+PropertyWidget::select(const QModelIndex& index)
+{
+ if (!index.isValid())
+ return;
+
+ QMap<QString, QVariant> data =
+ model_->data(index, Qt::UserRole).toMap();
+
+ for (QMap<QString, QVariant>::iterator i = data.begin();
+ i != data.end();
+ ++i)
+ {
+ QStringList values;
+ values << i.key() << i.value().toString();
+ view_->addTopLevelItem(new QTreeWidgetItem(values));
+ }
+}
+
+void
+PropertyWidget::deselect(const QModelIndex&)
+{
+ view_->clear();
+}
+
+PropertyWidget::~PropertyWidget()
+{
+}
diff --git a/viewer/property_widget.hh b/viewer/property_widget.hh
new file mode 100644
index 0000000..fc4c755
--- /dev/null
+++ b/viewer/property_widget.hh
@@ -0,0 +1,41 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef PROPERTY_WIDGET_HH_
+# define PROPERTY_WIDGET_HH_
+
+# include <QtGui>
+
+class DomModel;
+
+class PropertyWidget
+ : public QWidget
+{
+ Q_OBJECT
+
+public:
+ PropertyWidget();
+ ~PropertyWidget();
+
+public slots:
+ void update(DomModel* model);
+ void select(const QModelIndex& index);
+ void deselect(const QModelIndex& index);
+
+private:
+ QTreeWidget* view_;
+ DomModel* model_;
+};
+
+#endif /* !PROPERTY_WIDGET_HH_ */
diff --git a/viewer/viewer.cc b/viewer/viewer.cc
new file mode 100644
index 0000000..3b3b188
--- /dev/null
+++ b/viewer/viewer.cc
@@ -0,0 +1,300 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include "viewer.hh"
+#include "property_widget.hh"
+#include "key_widget.hh"
+#include "browser_widget.hh"
+#include "image_widget.hh"
+#include "xml_widget.hh"
+#include "image_scene.hh"
+#include "image_region.hh"
+#include "help_dialog.hh"
+
+#include "dommodel.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_(9),
+ alt_cache_(false)
+{
+ // Key map
+
+ key_map_[region::Text] = qMakePair(tr("Text"), QColor(0, 200, 0));
+ key_map_[region::Image] = qMakePair(tr("Image"), QColor(255, 120, 0));
+ key_map_[region::Noise] = qMakePair(tr("Noise"), QColor(114, 188, 144));
+ key_map_[region::Separator] = qMakePair(tr("Separator"), QColor(200, 222, 0));
+ key_map_[region::Table] = qMakePair(tr("Table"), QColor(0, 0, 255));
+ 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));
+
+ // Region ids
+
+ region_ids_["text_region"] = region::Text;
+ region_ids_["image_region"] = region::Image;
+ region_ids_["noise_region"] = region::Noise;
+ region_ids_["separator_region"] = region::Separator;
+ region_ids_["table_region"] = region::Table;
+ region_ids_["line_drawing_region"] = region::LineDrawing;
+ region_ids_["graphic_region"] = region::Graphic;
+ region_ids_["chart_region"] = region::Chart;
+ region_ids_["maths_region"] = region::Maths;
+
+ // Layout
+
+ win_->resize(1024, 768);
+ win_->statusBar();
+
+ QMenu* file_menu = win_->menuBar()->addMenu(tr("File"));
+ QAction* quit_action = new QAction(tr("Quit"), file_menu);
+ connect(quit_action, SIGNAL(triggered()),
+ app_, SLOT(quit()));
+ quit_action->setStatusTip(tr("Exit the program."));
+ file_menu->addAction(quit_action);
+
+ QMenu* option_menu = win_->menuBar()->addMenu(tr("Options"));
+ outline_action_ = new QAction(tr("Draw outline"), option_menu);
+ outline_action_->setStatusTip(tr("Draw region outlines."));
+ outline_action_->setCheckable(true);
+ outline_action_->setChecked(true);
+ connect(outline_action_, SIGNAL(toggled(bool)),
+ this, SIGNAL(setOutline(bool)));
+ option_menu->addAction(outline_action_);
+ precise_action_ = new QAction(tr("Precise outline"), option_menu);
+ precise_action_->setStatusTip(tr("1px outline relative to the image "
+ "(1px relative to the view if off)."));
+ precise_action_->setCheckable(true);
+ precise_action_->setChecked(false);
+ connect(precise_action_, SIGNAL(toggled(bool)),
+ this, SIGNAL(setPrecise(bool)));
+ option_menu->addAction(precise_action_);
+ fill_action_ = new QAction(tr("Fill regions"), option_menu);
+ fill_action_->setStatusTip(tr("Color the inside of regions."));
+ fill_action_->setCheckable(true);
+ fill_action_->setChecked(true);
+ connect(fill_action_, SIGNAL(toggled(bool)),
+ this, SIGNAL(setFill(bool)));
+ option_menu->addAction(fill_action_);
+ QAction* cache_action = new QAction(tr("Alternative cache mode"),
+ option_menu);
+ cache_action->setStatusTip(tr("Much faster at low zoom, "
+ "but unstable at high zoom."));
+ cache_action->setCheckable(true);
+ cache_action->setChecked(false);
+ connect(cache_action, SIGNAL(toggled(bool)),
+ this, SLOT(setAltCache(bool)));
+ option_menu->addAction(cache_action);
+
+ QMenu* help_menu = win_->menuBar()->addMenu(tr("Help"));
+ QAction* about_action = new QAction(tr("About"), help_menu);
+ about_action->setStatusTip(tr("About this program."));
+ connect(about_action, SIGNAL(triggered()),
+ this, SLOT(help()));
+ help_menu->addAction(about_action);
+
+ QSplitter* h_splitter = new QSplitter();
+ QSplitter* v_splitter = new QSplitter(Qt::Vertical);
+ QSplitter* v_splitter2 = new QSplitter(Qt::Vertical);
+
+ PropertyWidget* property_wgt = new PropertyWidget();
+ XmlWidget* xml_wgt = new XmlWidget();
+ BrowserWidget* browser_wgt = new BrowserWidget(files_);
+ ImageWidget* image_wgt = new ImageWidget(scene_);
+ key_wgt_ = new KeyWidget(key_map_);
+
+ scene_->setBackgroundBrush(scene_->palette().window());
+
+ v_splitter->addWidget(property_wgt);
+ 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 << 300 << 200 << 500;
+ v_splitter->setSizes(v_sizes);
+
+ QList<int> v_sizes2;
+ v_sizes2 << 500 << 100;
+ v_splitter2->setSizes(v_sizes2);
+
+ QList<int> h_sizes;
+ h_sizes << 200 << 700;
+ h_splitter->setSizes(h_sizes);
+
+ connect(browser_wgt, SIGNAL(activated(QString)),
+ this, SLOT(load(QString)));
+ connect(this, SIGNAL(updated(DomModel*)),
+ property_wgt, SLOT(update(DomModel*)));
+ connect(this, SIGNAL(updated(DomModel*)),
+ xml_wgt, SLOT(update(DomModel*)));
+ connect(this, SIGNAL(updated(DomModel*)),
+ image_wgt, SLOT(update()));
+ connect(key_wgt_, SIGNAL(updated(int, bool)),
+ this, SIGNAL(key_updated(int, bool)));
+ connect(scene_, SIGNAL(selected(QModelIndex)),
+ property_wgt, SLOT(select(QModelIndex)));
+ connect(scene_, SIGNAL(deselected(QModelIndex)),
+ property_wgt, SLOT(deselect(QModelIndex)));
+ connect(scene_, SIGNAL(selected(QModelIndex)),
+ xml_wgt, SLOT(select(QModelIndex)));
+ connect(scene_, SIGNAL(deselected(QModelIndex)),
+ xml_wgt, SLOT(deselect(QModelIndex)));
+}
+
+void
+Viewer::load(QString filename)
+{
+ app_->setOverrideCursor(QCursor(Qt::WaitCursor));
+ scene_->clear();
+ image_ = 0;
+
+ // 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.
+ image_ = new QGraphicsPixmapItem(QPixmap(filename));
+ image_->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
+ image_->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize());
+ image_->setZValue(0);
+ scene_->addItem(image_);
+
+ if (doc_layout_)
+ {
+ doc_layout_->deleteLater();
+ doc_layout_ = 0;
+ }
+
+ // FIXME: Ugly
+ QString xml_file = filename;
+ xml_file.chop(4);
+ xml_file += ".xml";
+
+ if (QFile::exists(xml_file))
+ {
+ QFile file(xml_file);
+ if (file.open(QIODevice::ReadOnly))
+ {
+ QDomDocument document;
+ if (document.setContent(&file))
+ {
+ doc_layout_ = new DomModel(document, this);
+ }
+ file.close();
+ }
+ }
+
+ // Add layout info to the scene.
+ if (doc_layout_)
+ {
+ QModelIndex pgGts = doc_layout_->index(1, 0);
+ QModelIndex page = doc_layout_->index(1, 0, pgGts);
+ QModelIndex region;
+ QModelIndex attributes;
+ QModelIndex coords;
+ QModelIndex point;
+ for (int i = 0; true; ++i)
+ {
+ region = doc_layout_->index(i, 0, page);
+ attributes = doc_layout_->index(i, 1, page);
+ QString name = doc_layout_->data(region, Qt::DisplayRole).toString();
+ region::RegionId id = static_cast<region::RegionId>(region_ids_[name]);
+
+ coords = doc_layout_->index(0, 0, region);
+ if (!region.isValid() || !coords.isValid())
+ break;
+
+ QVector<QPoint> points;
+ for (int j = 0; true; ++j)
+ {
+ // Navigate to the coordinate list
+ point = doc_layout_->index(j, 1, coords);
+ if (!point.isValid())
+ break;
+
+ QMap<QString, QVariant> data =
+ doc_layout_->data(point, Qt::UserRole).toMap();
+ int x = data["x"].toInt();
+ int y = data["y"].toInt();
+ points << QPoint(x, y);
+ }
+
+ // Create region
+ ImageRegion* r = new ImageRegion(id,
+ key_map_[id].first,
+ key_map_[id].second,
+ attributes, 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);
+ }
+ }
+
+ emit updated(doc_layout_);
+
+ app_->restoreOverrideCursor();
+}
+
+int
+Viewer::exec()
+{
+ win_->show();
+ return app_->exec();
+}
+
+void
+Viewer::help()
+{
+ HelpDialog dlg;
+ dlg.exec();
+}
+
+void
+Viewer::setAltCache(bool b)
+{
+ alt_cache_ = b;
+ if (image_)
+ {
+ if (b)
+ image_->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+ else
+ image_->setCacheMode(QGraphicsItem::ItemCoordinateCache);
+ }
+}
diff --git a/viewer/viewer.hh b/viewer/viewer.hh
new file mode 100644
index 0000000..0a76afd
--- /dev/null
+++ b/viewer/viewer.hh
@@ -0,0 +1,79 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef VIEWER_HH_
+# define VIEWER_HH_
+
+# include <QtGui>
+# include "common.hh"
+
+class ImageScene;
+class DomModel;
+class KeyWidget;
+
+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);
+ void help();
+
+ void setAltCache(bool b);
+
+signals:
+ void updated(DomModel* model);
+ void key_updated(int key, bool checked);
+ void setOutline(bool b);
+ void setPrecise(bool b);
+ void setFill(bool b);
+
+private:
+ Viewer(int &argc, char** argv);
+ Viewer();
+
+ QApplication* app_;
+ QMainWindow* win_;
+
+ QGraphicsPixmapItem* image_;
+
+ ImageScene* scene_;
+ QDirModel* files_;
+ DomModel* doc_layout_;
+
+ QAction* outline_action_;
+ QAction* fill_action_;
+ QAction* precise_action_;
+
+ KeyWidget* key_wgt_;
+
+ QMap<QString, int> region_ids_;
+ region::KeyMap key_map_;
+
+ bool alt_cache_;
+};
+
+#include "viewer.hxx"
+
+#endif /* !VIEWER_HH_ */
diff --git a/viewer/viewer.hxx b/viewer/viewer.hxx
new file mode 100644
index 0000000..72ee1f2
--- /dev/null
+++ b/viewer/viewer.hxx
@@ -0,0 +1,31 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef VIEWER_HXX_
+# define VIEWER_HXX_
+
+# include "viewer.hh"
+
+inline Viewer* Viewer::Instance(int &argc, char** argv)
+{
+ static Viewer viewer(argc, argv);
+
+ return &viewer;
+}
+
+inline Viewer::~Viewer()
+{
+}
+
+#endif /* !VIEWER_HXX_ */
diff --git a/viewer/xml_widget.cc b/viewer/xml_widget.cc
new file mode 100644
index 0000000..fa050ec
--- /dev/null
+++ b/viewer/xml_widget.cc
@@ -0,0 +1,53 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#include "xml_widget.hh"
+
+#include "dommodel.hh"
+
+XmlWidget::XmlWidget()
+ : view_(new QTreeView()),
+ model_(0)
+{
+ QLabel* title = new QLabel(tr("XML"));
+ title->setAlignment(Qt::AlignHCenter);
+
+ QVBoxLayout* layout = new QVBoxLayout;
+ layout->addWidget(title);
+ layout->addWidget(view_);
+
+ setLayout(layout);
+}
+
+void
+XmlWidget::update(DomModel* model)
+{
+ view_->setModel(model);
+ view_->resizeColumnToContents(2);
+}
+
+void
+XmlWidget::select(const QModelIndex& index)
+{
+ view_->setCurrentIndex(index);
+}
+
+void
+XmlWidget::deselect(const QModelIndex&)
+{
+}
+
+XmlWidget::~XmlWidget()
+{
+}
diff --git a/viewer/xml_widget.hh b/viewer/xml_widget.hh
new file mode 100644
index 0000000..b3de3fa
--- /dev/null
+++ b/viewer/xml_widget.hh
@@ -0,0 +1,41 @@
+//
+// Document layout viewer.
+//
+// Copyright (C) 2009 Florent D'Halluin.
+//
+// This program 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; either version 2
+// of the License, or (at your option) any later version.
+//
+// The complete GNU General Public Licence Notice can be found as the
+// `COPYING' file in the root directory.
+//
+
+#ifndef XML_WIDGET_HH_
+# define XML_WIDGET_HH_
+
+# include <QtGui>
+
+class DomModel;
+
+class XmlWidget
+ : public QWidget
+{
+ Q_OBJECT
+
+public:
+ XmlWidget();
+ ~XmlWidget();
+
+public slots:
+ void update(DomModel* model);
+ void select(const QModelIndex& index);
+ void deselect(const QModelIndex& index);
+
+private:
+ QTreeView* view_;
+ DomModel* model_;
+};
+
+#endif /* !XML_WIDGET_HH_ */
--
1.5.6.5
1
0

15 Jun '10
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/scribo-z has been updated
via a2d98b12b61ffbd0a4e7addb440888d86d5be8d5 (commit)
via f5d28e908b41e8003fd401989b74b8c995a93192 (commit)
via ab515db441e4825dcfb9601c6ac024c614ce1e45 (commit)
via 6fb53567c35855b2ba1b61b1f9da6aba108a0471 (commit)
via c7c49e9d4611785b6c4086e7098d684fefd690b8 (commit)
via 0c7c2800580a76a371845addb361bd20498c396d (commit)
via 0832aee891ff1c8f78abf0b6f3ce22cda88a258a (commit)
via 6d82d878bff6d80604a7554a348ef8c1d06464ad (commit)
via 999e60c6f834a03d4ad636052aca1a785501f673 (commit)
via d3888a39df55beccc974bf4f556eb50e3b7057cb (commit)
via 06903f8517a4560f544ccb343f011548011fa95f (commit)
via ed6a220ec78c88954f73cee7258595b1a697a242 (commit)
via 7fd561dd32cd4d3a32aa974642da054078513355 (commit)
from 5c627b019540ecc6dbf4cb21630354289adf6f6b (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 -----------------------------------------------------------------
a2d98b1 Small fixes.
f5d28e9 Remove deprecated code.
ab515db configure.ac: Configure scribo/demo.
6fb5356 Add new Makefiles in Scribo demo directories.
c7c49e9 Move ICDAR XML viewer to Scribo directory.
0c7c280 Add support for pbm files in the viewer.
0832aee Update viewer.
6d82d87 Update viewer.
999e60c Update viewer.
d3888a3 Update viewer
06903f8 Update viewer.
ed6a220 Update viewer
7fd561d Add Document Layout Viewer.
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 6 +-
configure.ac | 6 +-
scribo/ChangeLog | 30 +++-
scribo/Makefile.am | 2 +-
scribo/debug/save_linked_bboxes_image.hh | 8 +-
scribo/demo/Makefile.am | 20 ++
scribo/demo/viewer/Makefile.am | 67 +++++++
scribo/demo/viewer/README | 33 ++++
scribo/demo/viewer/browser_widget.cc | 66 +++++++
scribo/demo/viewer/browser_widget.hh | 41 ++++
scribo/demo/viewer/common.hh | 36 ++++
scribo/demo/viewer/domitem.cc | 98 ++++++++++
scribo/demo/viewer/domitem.hh | 75 +++++++
scribo/demo/viewer/dommodel.cc | 198 +++++++++++++++++++
scribo/demo/viewer/dommodel.hh | 85 ++++++++
scribo/demo/viewer/help_dialog.cc | 55 ++++++
scribo/demo/viewer/help_dialog.hh | 32 +++
scribo/demo/viewer/image_region.cc | 124 ++++++++++++
scribo/demo/viewer/image_region.hh | 74 +++++++
scribo/demo/viewer/image_region.hxx | 95 +++++++++
scribo/demo/viewer/image_scene.cc | 62 ++++++
scribo/demo/viewer/image_scene.hh | 42 ++++
scribo/demo/viewer/image_view.cc | 78 ++++++++
scribo/demo/viewer/image_view.hh | 40 ++++
scribo/demo/viewer/image_widget.cc | 48 +++++
scribo/demo/viewer/image_widget.hh | 41 ++++
scribo/demo/viewer/key_widget.cc | 65 +++++++
scribo/demo/viewer/key_widget.hh | 44 +++++
scribo/demo/viewer/main.cc | 37 ++++
scribo/demo/viewer/property_widget.cc | 73 +++++++
scribo/demo/viewer/property_widget.hh | 41 ++++
scribo/demo/viewer/viewer.cc | 308 ++++++++++++++++++++++++++++++
scribo/demo/viewer/viewer.hh | 80 ++++++++
scribo/demo/viewer/viewer.hxx | 31 +++
scribo/demo/viewer/xml_widget.cc | 53 +++++
scribo/demo/viewer/xml_widget.hh | 41 ++++
scribo/src/pbm_text_in_doc.cc | 3 +-
scribo/src/text_in_picture.cc | 4 +-
scribo/text/recognition.hh | 6 +-
scribo/util/all.hh | 46 -----
scribo/util/text.hh | 278 ---------------------------
41 files changed, 2230 insertions(+), 342 deletions(-)
create mode 100644 scribo/demo/Makefile.am
create mode 100644 scribo/demo/viewer/Makefile.am
create mode 100644 scribo/demo/viewer/README
create mode 100644 scribo/demo/viewer/browser_widget.cc
create mode 100644 scribo/demo/viewer/browser_widget.hh
create mode 100644 scribo/demo/viewer/common.hh
create mode 100644 scribo/demo/viewer/domitem.cc
create mode 100644 scribo/demo/viewer/domitem.hh
create mode 100644 scribo/demo/viewer/dommodel.cc
create mode 100644 scribo/demo/viewer/dommodel.hh
create mode 100644 scribo/demo/viewer/help_dialog.cc
create mode 100644 scribo/demo/viewer/help_dialog.hh
create mode 100644 scribo/demo/viewer/image_region.cc
create mode 100644 scribo/demo/viewer/image_region.hh
create mode 100644 scribo/demo/viewer/image_region.hxx
create mode 100644 scribo/demo/viewer/image_scene.cc
create mode 100644 scribo/demo/viewer/image_scene.hh
create mode 100644 scribo/demo/viewer/image_view.cc
create mode 100644 scribo/demo/viewer/image_view.hh
create mode 100644 scribo/demo/viewer/image_widget.cc
create mode 100644 scribo/demo/viewer/image_widget.hh
create mode 100644 scribo/demo/viewer/key_widget.cc
create mode 100644 scribo/demo/viewer/key_widget.hh
create mode 100644 scribo/demo/viewer/main.cc
create mode 100644 scribo/demo/viewer/property_widget.cc
create mode 100644 scribo/demo/viewer/property_widget.hh
create mode 100644 scribo/demo/viewer/viewer.cc
create mode 100644 scribo/demo/viewer/viewer.hh
create mode 100644 scribo/demo/viewer/viewer.hxx
create mode 100644 scribo/demo/viewer/xml_widget.cc
create mode 100644 scribo/demo/viewer/xml_widget.hh
delete mode 100644 scribo/util/all.hh
delete mode 100644 scribo/util/text.hh
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

last-svn-commit-154-gc7c49e9 Move ICDAR XML viewer to Scribo directory.
by Guillaume Lazzara 15 Jun '10
by Guillaume Lazzara 15 Jun '10
15 Jun '10
---
{viewer => scribo/demo/viewer}/Makefile.am | 0
{viewer => scribo/demo/viewer}/README | 0
{viewer => scribo/demo/viewer}/browser_widget.cc | 0
{viewer => scribo/demo/viewer}/browser_widget.hh | 0
{viewer => scribo/demo/viewer}/common.hh | 0
{viewer => scribo/demo/viewer}/domitem.cc | 0
{viewer => scribo/demo/viewer}/domitem.hh | 0
{viewer => scribo/demo/viewer}/dommodel.cc | 0
{viewer => scribo/demo/viewer}/dommodel.hh | 0
{viewer => scribo/demo/viewer}/help_dialog.cc | 0
{viewer => scribo/demo/viewer}/help_dialog.hh | 0
{viewer => scribo/demo/viewer}/image_region.cc | 0
{viewer => scribo/demo/viewer}/image_region.hh | 0
{viewer => scribo/demo/viewer}/image_region.hxx | 0
{viewer => scribo/demo/viewer}/image_scene.cc | 0
{viewer => scribo/demo/viewer}/image_scene.hh | 0
{viewer => scribo/demo/viewer}/image_view.cc | 0
{viewer => scribo/demo/viewer}/image_view.hh | 0
{viewer => scribo/demo/viewer}/image_widget.cc | 0
{viewer => scribo/demo/viewer}/image_widget.hh | 0
{viewer => scribo/demo/viewer}/key_widget.cc | 0
{viewer => scribo/demo/viewer}/key_widget.hh | 0
{viewer => scribo/demo/viewer}/main.cc | 0
{viewer => scribo/demo/viewer}/property_widget.cc | 0
{viewer => scribo/demo/viewer}/property_widget.hh | 0
{viewer => scribo/demo/viewer}/viewer.cc | 0
{viewer => scribo/demo/viewer}/viewer.hh | 0
{viewer => scribo/demo/viewer}/viewer.hxx | 0
{viewer => scribo/demo/viewer}/xml_widget.cc | 0
{viewer => scribo/demo/viewer}/xml_widget.hh | 0
30 files changed, 0 insertions(+), 0 deletions(-)
rename {viewer => scribo/demo/viewer}/Makefile.am (100%)
rename {viewer => scribo/demo/viewer}/README (100%)
rename {viewer => scribo/demo/viewer}/browser_widget.cc (100%)
rename {viewer => scribo/demo/viewer}/browser_widget.hh (100%)
rename {viewer => scribo/demo/viewer}/common.hh (100%)
rename {viewer => scribo/demo/viewer}/domitem.cc (100%)
rename {viewer => scribo/demo/viewer}/domitem.hh (100%)
rename {viewer => scribo/demo/viewer}/dommodel.cc (100%)
rename {viewer => scribo/demo/viewer}/dommodel.hh (100%)
rename {viewer => scribo/demo/viewer}/help_dialog.cc (100%)
rename {viewer => scribo/demo/viewer}/help_dialog.hh (100%)
rename {viewer => scribo/demo/viewer}/image_region.cc (100%)
rename {viewer => scribo/demo/viewer}/image_region.hh (100%)
rename {viewer => scribo/demo/viewer}/image_region.hxx (100%)
rename {viewer => scribo/demo/viewer}/image_scene.cc (100%)
rename {viewer => scribo/demo/viewer}/image_scene.hh (100%)
rename {viewer => scribo/demo/viewer}/image_view.cc (100%)
rename {viewer => scribo/demo/viewer}/image_view.hh (100%)
rename {viewer => scribo/demo/viewer}/image_widget.cc (100%)
rename {viewer => scribo/demo/viewer}/image_widget.hh (100%)
rename {viewer => scribo/demo/viewer}/key_widget.cc (100%)
rename {viewer => scribo/demo/viewer}/key_widget.hh (100%)
rename {viewer => scribo/demo/viewer}/main.cc (100%)
rename {viewer => scribo/demo/viewer}/property_widget.cc (100%)
rename {viewer => scribo/demo/viewer}/property_widget.hh (100%)
rename {viewer => scribo/demo/viewer}/viewer.cc (100%)
rename {viewer => scribo/demo/viewer}/viewer.hh (100%)
rename {viewer => scribo/demo/viewer}/viewer.hxx (100%)
rename {viewer => scribo/demo/viewer}/xml_widget.cc (100%)
rename {viewer => scribo/demo/viewer}/xml_widget.hh (100%)
diff --git a/viewer/Makefile.am b/scribo/demo/viewer/Makefile.am
similarity index 100%
rename from viewer/Makefile.am
rename to scribo/demo/viewer/Makefile.am
diff --git a/viewer/README b/scribo/demo/viewer/README
similarity index 100%
rename from viewer/README
rename to scribo/demo/viewer/README
diff --git a/viewer/browser_widget.cc b/scribo/demo/viewer/browser_widget.cc
similarity index 100%
rename from viewer/browser_widget.cc
rename to scribo/demo/viewer/browser_widget.cc
diff --git a/viewer/browser_widget.hh b/scribo/demo/viewer/browser_widget.hh
similarity index 100%
rename from viewer/browser_widget.hh
rename to scribo/demo/viewer/browser_widget.hh
diff --git a/viewer/common.hh b/scribo/demo/viewer/common.hh
similarity index 100%
rename from viewer/common.hh
rename to scribo/demo/viewer/common.hh
diff --git a/viewer/domitem.cc b/scribo/demo/viewer/domitem.cc
similarity index 100%
rename from viewer/domitem.cc
rename to scribo/demo/viewer/domitem.cc
diff --git a/viewer/domitem.hh b/scribo/demo/viewer/domitem.hh
similarity index 100%
rename from viewer/domitem.hh
rename to scribo/demo/viewer/domitem.hh
diff --git a/viewer/dommodel.cc b/scribo/demo/viewer/dommodel.cc
similarity index 100%
rename from viewer/dommodel.cc
rename to scribo/demo/viewer/dommodel.cc
diff --git a/viewer/dommodel.hh b/scribo/demo/viewer/dommodel.hh
similarity index 100%
rename from viewer/dommodel.hh
rename to scribo/demo/viewer/dommodel.hh
diff --git a/viewer/help_dialog.cc b/scribo/demo/viewer/help_dialog.cc
similarity index 100%
rename from viewer/help_dialog.cc
rename to scribo/demo/viewer/help_dialog.cc
diff --git a/viewer/help_dialog.hh b/scribo/demo/viewer/help_dialog.hh
similarity index 100%
rename from viewer/help_dialog.hh
rename to scribo/demo/viewer/help_dialog.hh
diff --git a/viewer/image_region.cc b/scribo/demo/viewer/image_region.cc
similarity index 100%
rename from viewer/image_region.cc
rename to scribo/demo/viewer/image_region.cc
diff --git a/viewer/image_region.hh b/scribo/demo/viewer/image_region.hh
similarity index 100%
rename from viewer/image_region.hh
rename to scribo/demo/viewer/image_region.hh
diff --git a/viewer/image_region.hxx b/scribo/demo/viewer/image_region.hxx
similarity index 100%
rename from viewer/image_region.hxx
rename to scribo/demo/viewer/image_region.hxx
diff --git a/viewer/image_scene.cc b/scribo/demo/viewer/image_scene.cc
similarity index 100%
rename from viewer/image_scene.cc
rename to scribo/demo/viewer/image_scene.cc
diff --git a/viewer/image_scene.hh b/scribo/demo/viewer/image_scene.hh
similarity index 100%
rename from viewer/image_scene.hh
rename to scribo/demo/viewer/image_scene.hh
diff --git a/viewer/image_view.cc b/scribo/demo/viewer/image_view.cc
similarity index 100%
rename from viewer/image_view.cc
rename to scribo/demo/viewer/image_view.cc
diff --git a/viewer/image_view.hh b/scribo/demo/viewer/image_view.hh
similarity index 100%
rename from viewer/image_view.hh
rename to scribo/demo/viewer/image_view.hh
diff --git a/viewer/image_widget.cc b/scribo/demo/viewer/image_widget.cc
similarity index 100%
rename from viewer/image_widget.cc
rename to scribo/demo/viewer/image_widget.cc
diff --git a/viewer/image_widget.hh b/scribo/demo/viewer/image_widget.hh
similarity index 100%
rename from viewer/image_widget.hh
rename to scribo/demo/viewer/image_widget.hh
diff --git a/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc
similarity index 100%
rename from viewer/key_widget.cc
rename to scribo/demo/viewer/key_widget.cc
diff --git a/viewer/key_widget.hh b/scribo/demo/viewer/key_widget.hh
similarity index 100%
rename from viewer/key_widget.hh
rename to scribo/demo/viewer/key_widget.hh
diff --git a/viewer/main.cc b/scribo/demo/viewer/main.cc
similarity index 100%
rename from viewer/main.cc
rename to scribo/demo/viewer/main.cc
diff --git a/viewer/property_widget.cc b/scribo/demo/viewer/property_widget.cc
similarity index 100%
rename from viewer/property_widget.cc
rename to scribo/demo/viewer/property_widget.cc
diff --git a/viewer/property_widget.hh b/scribo/demo/viewer/property_widget.hh
similarity index 100%
rename from viewer/property_widget.hh
rename to scribo/demo/viewer/property_widget.hh
diff --git a/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
similarity index 100%
rename from viewer/viewer.cc
rename to scribo/demo/viewer/viewer.cc
diff --git a/viewer/viewer.hh b/scribo/demo/viewer/viewer.hh
similarity index 100%
rename from viewer/viewer.hh
rename to scribo/demo/viewer/viewer.hh
diff --git a/viewer/viewer.hxx b/scribo/demo/viewer/viewer.hxx
similarity index 100%
rename from viewer/viewer.hxx
rename to scribo/demo/viewer/viewer.hxx
diff --git a/viewer/xml_widget.cc b/scribo/demo/viewer/xml_widget.cc
similarity index 100%
rename from viewer/xml_widget.cc
rename to scribo/demo/viewer/xml_widget.cc
diff --git a/viewer/xml_widget.hh b/scribo/demo/viewer/xml_widget.hh
similarity index 100%
rename from viewer/xml_widget.hh
rename to scribo/demo/viewer/xml_widget.hh
--
1.5.6.5
1
0
* debug/save_linked_bboxes_image.hh: Fix namespace ambiguity.
* src/pbm_text_in_doc.cc: Fix comment.
* src/text_in_picture: Change few settings.
* text/recognition.hh: Fix invalid default arguments.
---
scribo/ChangeLog | 12 ++++++++++++
scribo/debug/save_linked_bboxes_image.hh | 8 ++++----
scribo/src/pbm_text_in_doc.cc | 3 +--
scribo/src/text_in_picture.cc | 4 ++--
scribo/text/recognition.hh | 6 ++----
5 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index be33d47..2a9a626 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,17 @@
2010-06-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Small fixes.
+
+ * debug/save_linked_bboxes_image.hh: Fix namespace ambiguity.
+
+ * src/pbm_text_in_doc.cc: Fix comment.
+
+ * src/text_in_picture: Change few settings.
+
+ * text/recognition.hh: Fix invalid default arguments.
+
+2010-06-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Remove deprecated code.
* util/all.hh,
diff --git a/scribo/debug/save_linked_bboxes_image.hh b/scribo/debug/save_linked_bboxes_image.hh
index 1e328f8..ef70435 100644
--- a/scribo/debug/save_linked_bboxes_image.hh
+++ b/scribo/debug/save_linked_bboxes_image.hh
@@ -171,7 +171,7 @@ namespace scribo
draw::bounding_boxes(tmp, components, box_value);
draw::bounding_box_links(tmp, array, link_value, anchor);
- io::ppm::save(tmp, filename);
+ mln::io::ppm::save(tmp, filename);
trace::exiting("scribo::debug::save_linked_bboxes_image");
}
@@ -214,7 +214,7 @@ namespace scribo
left_link, right_link,
value);
- io::ppm::save(tmp, filename);
+ mln::io::ppm::save(tmp, filename);
trace::exiting("scribo::debug::save_linked_bboxes_image");
}
@@ -249,7 +249,7 @@ namespace scribo
left_link_value, right_link_value,
validated_link_value);
- io::ppm::save(tmp, filename);
+ mln::io::ppm::save(tmp, filename);
trace::exiting("scribo::debug::save_linked_bboxes_image");
}
@@ -275,7 +275,7 @@ namespace scribo
draw::bounding_boxes(tmp, components, box_value);
draw::bounding_box_links(tmp, components, g, link_value);
- io::ppm::save(tmp, filename);
+ mln::io::ppm::save(tmp, filename);
trace::exiting("scribo::debug::save_linked_bboxes_image");
}
diff --git a/scribo/src/pbm_text_in_doc.cc b/scribo/src/pbm_text_in_doc.cc
index 993bbcb..4c760a0 100644
--- a/scribo/src/pbm_text_in_doc.cc
+++ b/scribo/src/pbm_text_in_doc.cc
@@ -124,9 +124,8 @@ int main(int argc, char* argv[])
// Saving results
scribo::io::xml::save_text_lines(argv[1], lines, "out.xml");
- // Specify shift due to previous crop.
+ // Specify shift due to potential previous crop.
scribo::io::text_boxes::save(lines, argv[2], crop_shift);
-
trace::exiting("main");
}
diff --git a/scribo/src/text_in_picture.cc b/scribo/src/text_in_picture.cc
index c47786c..a7cf8d2 100644
--- a/scribo/src/text_in_picture.cc
+++ b/scribo/src/text_in_picture.cc
@@ -128,11 +128,11 @@ namespace mln
{
config()
{
- sauvola_s = 3u;
+ sauvola_s = 2u; // 3?
sauvola_min_w = 51u;
// Group Filtering
- bbox_h_ratio = 1.50f;
+ bbox_h_ratio = 1.60f;
bbox_overlap = 0.80f;
small_groups = 3;
v_thickness = 8;
diff --git a/scribo/text/recognition.hh b/scribo/text/recognition.hh
index 44533e9..a3ccd50 100644
--- a/scribo/text/recognition.hh
+++ b/scribo/text/recognition.hh
@@ -52,8 +52,6 @@
# include <scribo/core/macros.hh>
-# include <scribo/util/text.hh>
-
# include <scribo/text/clean.hh>
# include <scribo/core/line_set.hh>
@@ -89,7 +87,7 @@ namespace scribo
void
recognition(const Image<I>& line,
const char *language,
- const std::string& output_file = 0);
+ const std::string& output_file = std::string());
@@ -187,7 +185,7 @@ namespace scribo
void
recognition(const Image<I>& line_,
const char *language,
- const std::string& output_file = 0)
+ const std::string& output_file = std::string())
{
trace::entering("scribo::text::recognition");
--
1.5.6.5
1
0
* util/all.hh,
* util/text.hh: Remove.
---
scribo/ChangeLog | 11 ++-
scribo/util/all.hh | 46 ---------
scribo/util/text.hh | 278 ---------------------------------------------------
3 files changed, 9 insertions(+), 326 deletions(-)
delete mode 100644 scribo/util/all.hh
delete mode 100644 scribo/util/text.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index b276525..be33d47 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,12 @@
2010-06-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Remove deprecated code.
+
+ * util/all.hh,
+ * util/text.hh: Remove.
+
+2010-06-15 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Add new Makefiles in Scribo demo directories.
* Makefile.am,
@@ -13,8 +20,8 @@
Add a fast rotation tool.
- * scribo/src/preprocessing/Makefile.am,
- * scribo/src/preprocessing/rotate_90.cc: New.
+ * src/preprocessing/Makefile.am,
+ * src/preprocessing/rotate_90.cc: New.
2010-06-15 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/scribo/util/all.hh b/scribo/util/all.hh
deleted file mode 100644
index 3eef9ff..0000000
--- a/scribo/util/all.hh
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (C) 2009 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 SCRIBO_UTIL_ALL_HH
-# define SCRIBO_UTIL_ALL_HH
-
-/// \file
-///
-/// Include all headers located in scribo/util.
-
-namespace scribo
-{
-
- /// Namespace of useful classes and routines.
- namespace util
- {
-
- } // end of namespace scribo::util
-
-} // end of namespace scribo
-
-# include <scribo/util/text.hh>
-
-#endif // ! SCRIBO_UTIL_ALL_HH
diff --git a/scribo/util/text.hh b/scribo/util/text.hh
deleted file mode 100644
index 3cdd5c1..0000000
--- a/scribo/util/text.hh
+++ /dev/null
@@ -1,278 +0,0 @@
-// Copyright (C) 2009 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 SCRIBO_UTIL_TEXT_HH
-# define SCRIBO_UTIL_TEXT_HH
-
-/// \file
-///
-/// A class representing text bounding boxes and their associated
-/// labeled image.
-
-# include <mln/core/image/image2d.hh>
-# include <mln/core/concept/proxy.hh>
-# include <mln/core/site_set/box.hh>
-# include <mln/accu/center.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/value/label_16.hh>
-# include <mln/util/couple.hh>
-# include <mln/util/array.hh>
-
-namespace scribo
-{
-
- using namespace mln;
-
- namespace util
- {
-
- /// Store text bounding boxes and their associated labeled image.
- template <typename L>
- class text
- {
- public:
- /// The site type in the label image.
- typedef mln_site(L) site;
- /// The bounding box list type.
- typedef mln::util::array<box<site> > boxes_t;
- /// The mass center list type.
- typedef mln::util::array<mln_site(L)::vec> mass_centers_t;
-
- /// Constructors
- /// @{
-
- /// Default.
- text();
-
- /// \param[in] bboxes text line bounding boxes.
- /// \param[in] lbl label image associated to the bounding boxes.
- /// \param[in] nbboxes The number of bounding boxes.
- /// \param[in] mass_centers Mass centers of the components.
- text(const mln::util::array<box<mln_site(L)> >& bboxes,
- const Image<L>& lbl,
- const mln_value(L)& nbboxes,
- const mln::util::array<mln_site(L)::vec>& mass_centers);
-
- /// \param[in] bboxes text line bounding boxes.
- /// \param[in] lbl label image associated to the bounding boxes.
- /// \param[in] nbboxes The number of bounding boxes.
- text(const mln::util::array<box<mln_site(L)> >& bboxes,
- const Image<L>& lbl,
- const mln_value(L)& nbboxes);
- /// @}
-
- /// Return the underlying label image.
- /// @{
- const L& label_image() const;
- L& label_image();
- /// @}
-
- /// Return the number of bounding boxes.
- const mln_value(L)& nbboxes() const;
- /// Return the number of bounding boxes.
- mln_value(L)& nbboxes();
-
- /// Return the bounding boxes.
- const boxes_t& bboxes() const;
- /// Return the bounding boxes.
- boxes_t& bboxes();
-
- /// Return the i-th bounding box.
- const box<mln_site(L)>& bbox(unsigned i) const;
- /// Return the i-th bounding box.
- box<mln_site(L)>& bbox(unsigned i);
-
- /// Return the mass centers.
- /// @{
- const mln::util::array<mln_site(L)::vec>& mass_centers() const;
- mln::util::array<mln_site(L)::vec>& mass_centers();
- /// @}
-
- /// Return the i-th mass centers.
- mln_site(L) mass_center(unsigned i) const;
-
- /// Is this text objet consistant/valid?
- bool is_valid() const;
-
- private:
- void update();
-
- boxes_t bboxes_;
- mass_centers_t mass_centers_;
- L lbl_;
- mln_value(L) nbboxes_;
- };
-
-
-# ifndef MLN_INCLUDE_ONLY
-
-
- template <typename L>
- inline
- text<L>::text()
- {
- }
-
- template <typename L>
- inline
- text<L>::text(const mln::util::array<box<mln_site(L)> >& bboxes,
- const Image<L>& lbl,
- const mln_value(L)& nbboxes,
- const mln::util::array<mln_site(L)::vec>& mass_centers)
- : bboxes_(bboxes), mass_centers_(mass_centers),
- lbl_(exact(lbl)), nbboxes_(nbboxes)
- {
- mln_assertion(bboxes.nelements() == nbboxes.next());
- }
-
- template <typename L>
- inline
- text<L>::text(const mln::util::array<box<mln_site(L)> >& bboxes,
- const Image<L>& lbl,
- const mln_value(L)& nbboxes)
- : bboxes_(bboxes), lbl_(exact(lbl)), nbboxes_(nbboxes)
- {
- mln_assertion(bboxes.nelements() == nbboxes.next());
- update();
- }
-
- template <typename L>
- inline
- const L&
- text<L>::label_image() const
- {
- mln_precondition(lbl_.is_valid());
- return lbl_;
- }
-
- template <typename L>
- inline
- L&
- text<L>::label_image()
- {
-// mln_precondition(lbl_.is_valid());
- return lbl_;
- }
-
- template <typename L>
- inline
- const mln_value(L)&
- text<L>::nbboxes() const
- {
- return nbboxes_;
- }
-
- template <typename L>
- inline
- mln_value(L)&
- text<L>::nbboxes()
- {
- return nbboxes_;
- }
-
- template <typename L>
- inline
- const typename text<L>::boxes_t&
- text<L>::bboxes() const
- {
- mln_precondition(bboxes_.nelements() == nbboxes_.next());
- return bboxes_;
- }
-
- template <typename L>
- inline
- typename text<L>::boxes_t&
- text<L>::bboxes()
- {
- return bboxes_;
- }
-
- template <typename L>
- inline
- const box<mln_site(L)>&
- text<L>::bbox(unsigned i) const
- {
- mln_precondition(bboxes_.nelements() == nbboxes_.next());
- mln_precondition(i < bboxes_.nelements());
- return bboxes_[i];
- }
-
- template <typename L>
- inline
- box<mln_site(L)>&
- text<L>::bbox(unsigned i)
- {
- mln_precondition(bboxes_.nelements() == nbboxes_.next());
- mln_precondition(i < bboxes_.nelements());
- return bboxes_[i];
- }
-
- template <typename L>
- inline
- const mln::util::array<mln_site(L)::vec>&
- text<L>::mass_centers() const
- {
- return mass_centers_;
- }
-
- template <typename L>
- inline
- mln::util::array<mln_site(L)::vec>&
- text<L>::mass_centers()
- {
- return mass_centers_;
- }
-
- template <typename L>
- inline
- mln_site(L)
- text<L>::mass_center(unsigned i) const
- {
- return mass_centers_[i];
- }
-
- template <typename L>
- inline
- bool
- text<L>::is_valid() const
- {
- return lbl_.is_valid() && bboxes_.nelements() == nbboxes_.next();
- }
-
- template <typename L>
- inline
- void
- text<L>::update()
- {
- mass_centers_ = labeling::compute(accu::meta::center(), lbl_, nbboxes_);
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
- } // end of namespace scribo::util
-
-} // end of namespace scribo
-
-#endif // ! SCRIBO_UTIL_TEXT_HH
--
1.5.6.5
1
0

15 Jun '10
---
ChangeLog | 9 +++------
configure.ac | 6 ++++--
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e937542..4bd09b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,10 @@
-2009-11-06 Jérôme Galtier <jerome.galtier(a)lrde.epita.fr>
+2010-06-15 Guillaume Lazzara <z(a)lrde.epita.fr>
- Add support for pbm files in the viewer.
-
- * viewer/browser_widget.cc (BrowserWidget::BrowserWidget): Do not
- filter out pbm files.
+ * configure.ac: Configure scribo/demo.
2010-06-03 Guillaume Lazzara <z(a)lrde.epita.fr>
- * configure.ac: configure several directories in scribo/.
+ * configure.ac: Configure several directories in scribo/.
2010-06-03 Guillaume Lazzara <z(a)lrde.epita.fr>
diff --git a/configure.ac b/configure.ac
index 9b633cd..330a2fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -169,7 +169,7 @@ OLN_WITH_LIB([GDCM], [gdcm-2.0/gdcmReader.h], [gdcmCommon], [gdcm], [GDCM],
OLN_WITH_LIB([TESSERACT], [tesseract/baseapi.h], [tesseract_full], [tesseract], [TESSERACT])
# Qt.
-AT_WITH_QT([], [], [],
+AT_WITH_QT([+xml], [], [],
AC_DEFINE([HAVE_QT], 1, [Define to 1 if we can use Qt]),
AC_DEFINE([HAVE_QT], 0))
AM_CONDITIONAL([HAVE_QT], [test x$QT_PATH != x])
@@ -215,7 +215,9 @@ AM_CONDITIONAL([ENABLE_SCRIBO], [test x$enable_scribo = xyes])
AC_CONFIG_FILES([
scribo/Makefile
- scribo/demo/review/Makefile
+ scribo/demo/Makefile
+ scribo/demo/review/Makefile
+ scribo/demo/viewer/Makefile
scribo/src/Makefile
scribo/src/binarization/Makefile
scribo/src/contest/Makefile
--
1.5.6.5
1
0