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

21 Jul '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 83e8345d5d31ad0d20dcfda0b5e2852b6c613130 (commit)
from acf89baab8b2cadc93ba0ff845d7c83c27049172 (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 -----------------------------------------------------------------
83e8345 Text selectable in Qt interface.
-----------------------------------------------------------------------
Summary of changes:
scribo/ChangeLog | 56 +++++++++++++++++++++++------------------
scribo/demo/viewer/viewer.cc | 5 +---
2 files changed, 32 insertions(+), 29 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
2
1

20 Jul '10
* scribo/demo/viewer/viewer.cc
---
scribo/ChangeLog | 56 +++++++++++++++++++++++------------------
scribo/demo/viewer/viewer.cc | 5 +---
2 files changed, 32 insertions(+), 29 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index b318aba..527a0a6 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,34 +1,40 @@
2010-07-20 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+ Text selectable in Qt interface.
+
+ * scribo/demo/viewer/viewer.cc
+
+2010-07-20 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+
Some changes in XML interface.
- * demo/viewer/property_widget.cc,
- * demo/viewer/property_widget.hh,
- * demo/viewer/domitem.cc,
- * demo/viewer/domitem.hh,
- * demo/viewer/dommodel.cc,
- * demo/viewer/dommodel.hh: Delete.
-
- * demo/viewer/Makefile.am
-
- * demo/viewer/browser_widget.cc: Fix, xmlc extension instead of xmle.
-
- * demo/viewer/key_widget.cc,
- * demo/viewer/step_widget.cc,
- * demo/viewer/step_widget.hh,
- * demo/viewer/image_scene.cc,
- * demo/viewer/image_scene.hh,
- * demo/viewer/help_dialog.cc,
- * demo/viewer/image_region.cc,
- * demo/viewer/image_region.hh,
- * demo/viewer/image_region.hxx: Small changes.
-
- * demo/viewer/viewer.cc,
- * demo/viewer/viewer.hh: Add base 64 cropped pictures support, text viewer
+ * scribo/demo/viewer/property_widget.cc,
+ * scribo/demo/viewer/property_widget.hh,
+ * scribo/demo/viewer/domitem.cc,
+ * scribo/demo/viewer/domitem.hh,
+ * scribo/demo/viewer/dommodel.cc,
+ * scribo/demo/viewer/dommodel.hh: Delete.
+
+ * scribo/demo/viewer/Makefile.am
+
+ * scribo/demo/viewer/browser_widget.cc: Fix, xmlc extension instead of xmle.
+
+ * scribo/demo/viewer/key_widget.cc,
+ * scribo/demo/viewer/step_widget.cc,
+ * scribo/demo/viewer/step_widget.hh,
+ * scribo/demo/viewer/image_scene.cc,
+ * scribo/demo/viewer/image_scene.hh,
+ * scribo/demo/viewer/help_dialog.cc,
+ * scribo/demo/viewer/image_region.cc,
+ * scribo/demo/viewer/image_region.hh,
+ * scribo/demo/viewer/image_region.hxx: Small changes.
+
+ * scribo/demo/viewer/viewer.cc,
+ * scribo/demo/viewer/viewer.hh: Add base 64 cropped pictures support, text viewer
and change XML parsing.
- * demo/viewer/xml_widget.cc,
- * demo/viewer/xml_widget.hh: Change widget, tree and attributes are together.
+ * scribo/demo/viewer/xml_widget.cc,
+ * scribo/demo/viewer/xml_widget.hh: Change widget, tree and attributes are together.
2010-07-16 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
index 090bb1b..f93177e 100644
--- a/scribo/demo/viewer/viewer.cc
+++ b/scribo/demo/viewer/viewer.cc
@@ -275,6 +275,7 @@ Viewer::add_text(QDomNode line, QDomNode region)
font.setPixelSize(a_height + d_height);
QGraphicsTextItem* text_item = scene_->addText(text, font);
text_item->setPos(x_min, y_min);
+ text_item->setTextInteractionFlags(Qt::TextSelectableByMouse);
text_vector_ << text_item;
if (!text_)
scene_->removeItem(text_item);
@@ -619,7 +620,6 @@ Viewer::useText(bool b)
scene_->addItem(text_vector_[i]);
}
- emit updated();
scene_->update();
}
@@ -644,9 +644,6 @@ Viewer::useImage(bool b)
scene_->addItem(image_vector_[i]);
}
-
-
- emit updated();
scene_->update();
}
--
1.5.6.5
1
0

20 Jul '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 acf89baab8b2cadc93ba0ff845d7c83c27049172 (commit)
from cfa008d41e46c8c145d9eb01cb9719a4fa018861 (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 -----------------------------------------------------------------
acf89ba Some changes in XML interface.
-----------------------------------------------------------------------
Summary of changes:
scribo/ChangeLog | 33 ++
scribo/demo/viewer/Makefile.am | 9 -
scribo/demo/viewer/browser_widget.cc | 2 +-
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 | 6 +-
scribo/demo/viewer/image_region.cc | 6 +-
scribo/demo/viewer/image_region.hh | 9 +-
scribo/demo/viewer/image_region.hxx | 7 -
scribo/demo/viewer/image_scene.cc | 20 +-
scribo/demo/viewer/image_scene.hh | 4 +-
scribo/demo/viewer/key_widget.cc | 2 +-
scribo/demo/viewer/property_widget.cc | 73 -----
scribo/demo/viewer/property_widget.hh | 41 ---
scribo/demo/viewer/step_widget.cc | 4 +-
scribo/demo/viewer/step_widget.hh | 1 +
scribo/demo/viewer/viewer.cc | 547 +++++++++++++++++++--------------
scribo/demo/viewer/viewer.hh | 15 +-
scribo/demo/viewer/xml_widget.cc | 143 ++++++++-
scribo/demo/viewer/xml_widget.hh | 15 +-
22 files changed, 543 insertions(+), 850 deletions(-)
delete mode 100644 scribo/demo/viewer/domitem.cc
delete mode 100644 scribo/demo/viewer/domitem.hh
delete mode 100644 scribo/demo/viewer/dommodel.cc
delete mode 100644 scribo/demo/viewer/dommodel.hh
delete mode 100644 scribo/demo/viewer/property_widget.cc
delete mode 100644 scribo/demo/viewer/property_widget.hh
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

20 Jul '10
* demo/viewer/property_widget.cc,
* demo/viewer/property_widget.hh,
* demo/viewer/domitem.cc,
* demo/viewer/domitem.hh,
* demo/viewer/dommodel.cc,
* demo/viewer/dommodel.hh: Delete.
* demo/viewer/Makefile.am
* demo/viewer/browser_widget.cc: Fix, xmlc extension instead of xmle.
* demo/viewer/key_widget.cc,
* demo/viewer/step_widget.cc,
* demo/viewer/step_widget.hh,
* demo/viewer/image_scene.cc,
* demo/viewer/image_scene.hh,
* demo/viewer/help_dialog.cc,
* demo/viewer/image_region.cc,
* demo/viewer/image_region.hh,
* demo/viewer/image_region.hxx: Small changes.
* demo/viewer/viewer.cc,
* demo/viewer/viewer.hh: Add base 64 cropped pictures support, text viewer
and change XML parsing.
* demo/viewer/xml_widget.cc,
* demo/viewer/xml_widget.hh: Change widget, tree and attributes are together.
---
scribo/ChangeLog | 33 ++
scribo/demo/viewer/Makefile.am | 9 -
scribo/demo/viewer/browser_widget.cc | 2 +-
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 | 6 +-
scribo/demo/viewer/image_region.cc | 6 +-
scribo/demo/viewer/image_region.hh | 9 +-
scribo/demo/viewer/image_region.hxx | 7 -
scribo/demo/viewer/image_scene.cc | 20 +-
scribo/demo/viewer/image_scene.hh | 4 +-
scribo/demo/viewer/key_widget.cc | 2 +-
scribo/demo/viewer/property_widget.cc | 73 -----
scribo/demo/viewer/property_widget.hh | 41 ---
scribo/demo/viewer/step_widget.cc | 4 +-
scribo/demo/viewer/step_widget.hh | 1 +
scribo/demo/viewer/viewer.cc | 547 +++++++++++++++++++--------------
scribo/demo/viewer/viewer.hh | 15 +-
scribo/demo/viewer/xml_widget.cc | 143 ++++++++-
scribo/demo/viewer/xml_widget.hh | 15 +-
22 files changed, 543 insertions(+), 850 deletions(-)
delete mode 100644 scribo/demo/viewer/domitem.cc
delete mode 100644 scribo/demo/viewer/domitem.hh
delete mode 100644 scribo/demo/viewer/dommodel.cc
delete mode 100644 scribo/demo/viewer/dommodel.hh
delete mode 100644 scribo/demo/viewer/property_widget.cc
delete mode 100644 scribo/demo/viewer/property_widget.hh
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 77c6680..b318aba 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,36 @@
+2010-07-20 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+
+ Some changes in XML interface.
+
+ * demo/viewer/property_widget.cc,
+ * demo/viewer/property_widget.hh,
+ * demo/viewer/domitem.cc,
+ * demo/viewer/domitem.hh,
+ * demo/viewer/dommodel.cc,
+ * demo/viewer/dommodel.hh: Delete.
+
+ * demo/viewer/Makefile.am
+
+ * demo/viewer/browser_widget.cc: Fix, xmlc extension instead of xmle.
+
+ * demo/viewer/key_widget.cc,
+ * demo/viewer/step_widget.cc,
+ * demo/viewer/step_widget.hh,
+ * demo/viewer/image_scene.cc,
+ * demo/viewer/image_scene.hh,
+ * demo/viewer/help_dialog.cc,
+ * demo/viewer/image_region.cc,
+ * demo/viewer/image_region.hh,
+ * demo/viewer/image_region.hxx: Small changes.
+
+ * demo/viewer/viewer.cc,
+ * demo/viewer/viewer.hh: Add base 64 cropped pictures support, text viewer
+ and change XML parsing.
+
+ * demo/viewer/xml_widget.cc,
+ * demo/viewer/xml_widget.hh: Change widget, tree and attributes are together.
+
+
2010-07-16 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
Base 64 support in Qt interface (xmlc extension)
diff --git a/scribo/demo/viewer/Makefile.am b/scribo/demo/viewer/Makefile.am
index a0112c6..9ef923a 100644
--- a/scribo/demo/viewer/Makefile.am
+++ b/scribo/demo/viewer/Makefile.am
@@ -21,12 +21,9 @@ viewer_SOURCES = $(BUILT_SOURCES) \
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 \
step_widget.cc
@@ -40,12 +37,9 @@ 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 \
step_widget.moc.cc
@@ -55,12 +49,9 @@ include_HEADERS = viewer.hh \
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 \
diff --git a/scribo/demo/viewer/browser_widget.cc b/scribo/demo/viewer/browser_widget.cc
index 220a719..43de1e2 100644
--- a/scribo/demo/viewer/browser_widget.cc
+++ b/scribo/demo/viewer/browser_widget.cc
@@ -68,7 +68,7 @@ BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
files_filters << "*.png" << "*.jpg"
<< "*.tif" << "*.ppm"
<< "*.pgm" << "*.pbm"
- << "*.pnm" << "*.xmle";
+ << "*.pnm" << "*.xmlc";
files->setNameFilters(files_filters);
}
diff --git a/scribo/demo/viewer/domitem.cc b/scribo/demo/viewer/domitem.cc
deleted file mode 100644
index 66e989a..0000000
--- a/scribo/demo/viewer/domitem.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
- **
- ** 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/scribo/demo/viewer/domitem.hh b/scribo/demo/viewer/domitem.hh
deleted file mode 100644
index a5c22cc..0000000
--- a/scribo/demo/viewer/domitem.hh
+++ /dev/null
@@ -1,75 +0,0 @@
- /****************************************************************************
- **
- ** 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/scribo/demo/viewer/dommodel.cc b/scribo/demo/viewer/dommodel.cc
deleted file mode 100644
index baaf9a7..0000000
--- a/scribo/demo/viewer/dommodel.cc
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
- **
- ** 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/scribo/demo/viewer/dommodel.hh b/scribo/demo/viewer/dommodel.hh
deleted file mode 100644
index 16c5a23..0000000
--- a/scribo/demo/viewer/dommodel.hh
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
- **
- ** 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/scribo/demo/viewer/help_dialog.cc b/scribo/demo/viewer/help_dialog.cc
index fe59d93..3ac5614 100644
--- a/scribo/demo/viewer/help_dialog.cc
+++ b/scribo/demo/viewer/help_dialog.cc
@@ -35,10 +35,8 @@ HelpDialog::HelpDialog()
" 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"
- "Copyright Florent D'Halluin, 2009.\n");
+ "\n");
+
QLabel* label = new QLabel(help);
diff --git a/scribo/demo/viewer/image_region.cc b/scribo/demo/viewer/image_region.cc
index 04e3c9b..78b636c 100644
--- a/scribo/demo/viewer/image_region.cc
+++ b/scribo/demo/viewer/image_region.cc
@@ -17,7 +17,7 @@
ImageRegion::ImageRegion(region::RegionId id,
QString name,
QColor color,
- QModelIndex index,
+ QString attr_id,
const QVector<QPoint>& points,
bool outline,
bool fill,
@@ -27,7 +27,7 @@ ImageRegion::ImageRegion(region::RegionId id,
id_(id),
name_(name),
color_(color),
- index_(index),
+ attr_id_(attr_id),
shape_(),
rect_(),
outline_(outline),
@@ -65,7 +65,7 @@ ImageRegion::~ImageRegion()
region::RegionId ImageRegion::id()
{
return id_;
-}
+}
void
ImageRegion::paint(QPainter* painter,
diff --git a/scribo/demo/viewer/image_region.hh b/scribo/demo/viewer/image_region.hh
index 38aecb4..be1003d 100644
--- a/scribo/demo/viewer/image_region.hh
+++ b/scribo/demo/viewer/image_region.hh
@@ -27,7 +27,7 @@ public:
ImageRegion(region::RegionId id,
QString name,
QColor color,
- QModelIndex index,
+ QString attr_id,
const QVector<QPoint>& points,
bool outline,
bool fill,
@@ -36,15 +36,16 @@ public:
~ImageRegion();
- region::RegionId id();
+ region::RegionId id();
void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option,
QWidget* widget = 0);
- const QModelIndex& index() const;
QRectF boundingRect() const;
QPainterPath shape() const;
QString name() { return name_; }
+ QRectF rect() { return rect_; }
+ QString attr_id() { return attr_id_; }
public slots:
void setOutline(bool outline);
@@ -60,7 +61,7 @@ private:
region::RegionId id_;
QString name_;
QColor color_;
- QModelIndex index_;
+ QString attr_id_;
QPainterPath shape_;
QRectF rect_;
bool outline_;
diff --git a/scribo/demo/viewer/image_region.hxx b/scribo/demo/viewer/image_region.hxx
index efcf493..0d23426 100644
--- a/scribo/demo/viewer/image_region.hxx
+++ b/scribo/demo/viewer/image_region.hxx
@@ -91,11 +91,4 @@ ImageRegion::shape() const
return shape_;
}
-inline
-const QModelIndex&
-ImageRegion::index() const
-{
- return index_;
-}
-
#endif /* !IMAGE_REGION_HXX_ */
diff --git a/scribo/demo/viewer/image_scene.cc b/scribo/demo/viewer/image_scene.cc
index 62b4b46..dd9d67e 100644
--- a/scribo/demo/viewer/image_scene.cc
+++ b/scribo/demo/viewer/image_scene.cc
@@ -31,7 +31,17 @@ void
ImageScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
QGraphicsScene::mousePressEvent(event);
- QList<QGraphicsItem *> items_list = items(event->pos()); // includes both ImageRegions and the picture.
+ QList<QGraphicsItem *> items_list = items(event->scenePos()); // includes both ImageRegions and the picture.
+
+ if (items_list.isEmpty())
+ {
+ if (selected_)
+ {
+ selected_->deselect();
+ emit deselected();
+ selected_ = 0;
+ }
+ }
// Selection is under the mouse click (at event->pos()).
bool selection_is_clicked = items_list.contains(selected_);
@@ -55,20 +65,20 @@ ImageScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
else
{
selected_->deselect();
- emit deselected(selected_->index());
+ emit deselected();
selected_ = 0;
}
}
else
{
selected_->deselect();
- emit deselected(selected_->index());
+ emit deselected();
selected_ = 0;
}
}
selected_ = item;
item->select();
- emit selected(item->index());
+ emit selected(item->attr_id(), item->name());
return;
}
}
@@ -78,7 +88,7 @@ ImageScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
&& (items_list.size() == 1) )// no ImageRegion, only the picture
{
selected_->deselect();
- emit deselected(selected_->index());
+ emit deselected();
selected_ = 0;
}
}
diff --git a/scribo/demo/viewer/image_scene.hh b/scribo/demo/viewer/image_scene.hh
index 64ab590..6fb2c1f 100644
--- a/scribo/demo/viewer/image_scene.hh
+++ b/scribo/demo/viewer/image_scene.hh
@@ -33,8 +33,8 @@ public:
void clear();
signals:
- void selected(const QModelIndex& index);
- void deselected(const QModelIndex& index);
+ void selected(QString, QString);
+ void deselected();
private:
ImageRegion* selected_;
diff --git a/scribo/demo/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc
index 47203c3..171c811 100644
--- a/scribo/demo/viewer/key_widget.cc
+++ b/scribo/demo/viewer/key_widget.cc
@@ -128,7 +128,7 @@ KeyWidget::update(QTreeWidgetItem* item)
int id;
id = text_->indexOfChild(item);
if (id == -1)
- id = regions_->indexOfChild(item) + 3;
+ id = regions_->indexOfChild(item) + 4;
emit updated(id, item->checkState(0) == Qt::Checked);
diff --git a/scribo/demo/viewer/property_widget.cc b/scribo/demo/viewer/property_widget.cc
deleted file mode 100644
index 3d2f4d5..0000000
--- a/scribo/demo/viewer/property_widget.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-//
-// 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/scribo/demo/viewer/property_widget.hh b/scribo/demo/viewer/property_widget.hh
deleted file mode 100644
index fc4c755..0000000
--- a/scribo/demo/viewer/property_widget.hh
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// 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/scribo/demo/viewer/step_widget.cc b/scribo/demo/viewer/step_widget.cc
index 207796d..010b270 100644
--- a/scribo/demo/viewer/step_widget.cc
+++ b/scribo/demo/viewer/step_widget.cc
@@ -75,11 +75,13 @@ void StepWidget::fill_steps(QString file, bool step, bool container)
if (container)
{
- emit load_image(file, true);
+ emit change_base(true);
+ // emit load_image(file, true);
emit load_xml(file);
}
else
{
+ emit change_base(false);
// image is loaded once
emit load_image(file, false);
diff --git a/scribo/demo/viewer/step_widget.hh b/scribo/demo/viewer/step_widget.hh
index 32602b0..c5d77df 100644
--- a/scribo/demo/viewer/step_widget.hh
+++ b/scribo/demo/viewer/step_widget.hh
@@ -45,6 +45,7 @@ signals:
void load_image(QString, bool);
void load_xml(QString);
void activated(QListWidgetItem*);
+ void change_base(bool);
public slots:
void fill_steps(QString file, bool step = false, bool container = false);
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
index e5ec717..090bb1b 100644
--- a/scribo/demo/viewer/viewer.cc
+++ b/scribo/demo/viewer/viewer.cc
@@ -1,19 +1,29 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
//
-// Document layout viewer.
+// This file is part of Olena.
//
-// Copyright (C) 2009 Florent D'Halluin.
+// 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.
//
-// 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.
+// 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.
//
-// The complete GNU General Public Licence Notice can be found as the
-// `COPYING' file in the root directory.
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
#include "viewer.hh"
-#include "property_widget.hh"
#include "key_widget.hh"
#include "browser_widget.hh"
#include "image_widget.hh"
@@ -22,8 +32,7 @@
#include "image_scene.hh"
#include "image_region.hh"
#include "help_dialog.hh"
-
-#include "dommodel.hh"
+#include <limits.h>
#include "common.hh"
@@ -37,7 +46,10 @@ Viewer::Viewer(int &argc, char** argv)
key_map_(11),
no_cache_(false),
extended_mode_(false),
- xml_file_(QString(""))
+ xml_file_(QString::Null()),
+ base64_(false),
+ text_(true),
+ use_image_(true)
{
// Key map
@@ -123,6 +135,23 @@ Viewer::Viewer(int &argc, char** argv)
this, SLOT(useExtended(bool)));
option_menu->addAction(extended_action);
+ QAction* show_image_action = new QAction(tr("Show pictures"), file_menu);
+ //show_image_action->setStatusTip(tr(""));
+
+ show_image_action->setCheckable(true);
+ show_image_action->setChecked(true);
+ connect(show_image_action, SIGNAL(toggled(bool)),
+ this, SLOT(useImage(bool)));
+ option_menu->addAction(show_image_action);
+
+ QAction* show_text_action = new QAction(tr("Show text"), file_menu);
+ show_text_action->setStatusTip(tr("Show detected text inside boxes."));
+ show_text_action->setCheckable(true);
+ show_text_action->setChecked(true);
+ connect(show_text_action, SIGNAL(toggled(bool)),
+ this, SLOT(useText(bool)));
+ option_menu->addAction(show_text_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."));
@@ -135,7 +164,6 @@ Viewer::Viewer(int &argc, char** argv)
QSplitter* v_splitter2 = new QSplitter(Qt::Vertical);
StepWidget* step_widget = new StepWidget();
- PropertyWidget* property_wgt = new PropertyWidget();
XmlWidget* xml_wgt = new XmlWidget();
BrowserWidget* browser_wgt =
new BrowserWidget(files_, argc != 2 ? QString() : argv[1]);
@@ -144,7 +172,6 @@ Viewer::Viewer(int &argc, char** argv)
scene_->setBackgroundBrush(scene_->palette().window());
- v_splitter->addWidget(property_wgt);
v_splitter->addWidget(step_widget);
v_splitter->addWidget(key_wgt_);
v_splitter->addWidget(browser_wgt);
@@ -158,280 +185,302 @@ Viewer::Viewer(int &argc, char** argv)
win_->setCentralWidget(h_splitter);
QList<int> v_sizes;
- v_sizes << 200 << 200 << 300 << 400;
+ v_sizes << 200 << 300 << 300;
v_splitter->setSizes(v_sizes);
QList<int> v_sizes2;
- v_sizes2 << 500 << 100;
+ v_sizes2 << 650 << 150;
v_splitter2->setSizes(v_sizes2);
QList<int> h_sizes;
- h_sizes << 200 << 700;
+ h_sizes << 200 << 900;
h_splitter->setSizes(h_sizes);
connect(browser_wgt, SIGNAL(activated(QString, bool, bool)),
step_widget, SLOT(fill_steps(QString, bool, bool)));
+ connect(step_widget, SIGNAL(change_base(bool)),
+ this, SLOT(change_base(bool)));
connect(step_widget, SIGNAL(load_image(QString, bool)),
this, SLOT(load(QString, bool)));
connect(step_widget, SIGNAL(load_xml(QString)),
this, SLOT(load_xml(QString)));
- connect(this, SIGNAL(updated(DomModel*)),
- property_wgt, SLOT(update(DomModel*)));
connect(this, SIGNAL(mode_changed(bool)),
key_wgt_, SLOT(change_mode(bool)));
- connect(this, SIGNAL(updated(DomModel*)),
- xml_wgt, SLOT(update(DomModel*)));
- connect(this, SIGNAL(updated(DomModel*)),
+ connect(this, SIGNAL(updated()),
image_wgt, SLOT(update()));
+ connect(this, SIGNAL(fill_xml(QString)),
+ xml_wgt, SLOT(fill_widget(QString)));
connect(key_wgt_, SIGNAL(updated(int, bool)),
this, SIGNAL(key_updated(int, bool)));
- connect(scene_, SIGNAL(selected(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)));
+ connect(scene_, SIGNAL(selected(QString, QString)),
+ xml_wgt, SLOT(select(QString, QString)));
+ connect(scene_, SIGNAL(deselected()),
+ xml_wgt, SLOT(deselect()));
connect(image_wgt, SIGNAL(scaleUpdated(qreal)),
this, SLOT(maybeChangeCacheMode(qreal)));
}
+
void
-Viewer::load_xml(QString filename)
+Viewer::add_text(QDomNode line, QDomNode region)
{
- QString xml_file = filename;
- xml_file_ = filename;
- app_->setOverrideCursor(QCursor(Qt::WaitCursor));
+ int a_height = region.toElement().attribute("a_height", "0").toInt();
+ int d_height = region.toElement().attribute("d_height", "0").toInt();
+ int x_height = region.toElement().attribute("x_height", "0").toInt();
- scene_->removeItem(image_);
- scene_->clear();
- scene_->addItem(image_);
+ if (d_height < 0)
+ d_height = -d_height;
- scene_->update();
+ if ( (a_height - x_height) < (d_height))
+ a_height = x_height + d_height;
+
+ if ( (a_height - x_height) > (d_height))
+ d_height = a_height - x_height;
+
+ QDomNode coords = region.firstChild();
+
+ while (!coords.isNull() && !coords.toElement().tagName().contains("coords"))
+ coords = coords.nextSibling();
+
+ if (coords.isNull())
+ return;
+
+ QDomNode point = coords.firstChild();
- if (doc_layout_)
+ int x_min = INT_MAX;
+ int y_min = INT_MAX;
+
+ while (!point.isNull())
{
- doc_layout_->deleteLater();
- doc_layout_ = 0;
+ int x = point.toElement().attribute("x", "0").toInt();
+ int y = point.toElement().attribute("y", "0").toInt();
+
+ if (x < x_min)
+ x_min = x;
+
+ if (y < y_min)
+ y_min = y;
+
+ point = point.nextSibling();
}
- emit updated(doc_layout_);
+ QString text = line.toElement().attribute("text", "none");
+ QFont font("Times");
+ font.setPixelSize(a_height + d_height);
+ QGraphicsTextItem* text_item = scene_->addText(text, font);
+ text_item->setPos(x_min, y_min);
+ text_vector_ << text_item;
+ if (!text_)
+ scene_->removeItem(text_item);
- if (QFile::exists(xml_file))
- {
- QFile file(xml_file);
- if (file.open(QIODevice::ReadOnly))
+}
+
+void
+Viewer::add_region(QDomNode father, QString attr_id)
+{
+ QDomNode coords = father.firstChild();
+ QString name = father.toElement().tagName();
+ region::RegionId id = static_cast<region::RegionId>(region_ids_[name]);
+
+ while (!coords.isNull() && !coords.toElement().tagName().contains("coords"))
+ coords = coords.nextSibling();
+
+ if (coords.isNull())
+ return;
+
+ QDomNode point = coords.firstChild();
+ QVector<QPoint> points;
+
+ while (!point.isNull())
{
- QDomDocument document;
- if (document.setContent(&file))
- {
- doc_layout_ = new DomModel(document, this);
- }
- else
- {
- app_->restoreOverrideCursor();
- QMessageBox msgBox;
- msgBox.setText("Error while loading the XML file, please choose another.");
- msgBox.exec();
- }
- file.close();
- }
- }
+ int x = point.toElement().attribute("x", "0").toInt();
+ int y = point.toElement().attribute("y", "0").toInt();
- xml_to_layout();
+ points << QPoint(x, y);
+ point = point.nextSibling();
+ }
- app_->restoreOverrideCursor();
+ ImageRegion* r = new ImageRegion(id,
+ key_map_[id].first,
+ key_map_[id].second,
+ attr_id, points,
+ outline_action_->isChecked(),
+ fill_action_->isChecked(),
+ precise_action_->isChecked(),
+ key_wgt_->isChecked(id));
+
+ connect(this, SIGNAL(key_updated(int, bool)),
+ r, SLOT(setDrawIfSameId(int, bool)));
+ connect(this, SIGNAL(setOutline(bool)),
+ r, SLOT(setOutline(bool)));
+ connect(this, SIGNAL(setPrecise(bool)),
+ r, SLOT(setPrecise(bool)));
+ connect(this, SIGNAL(setFill(bool)),
+ r, SLOT(setFill(bool)));
+
+ scene_->addItem(r);
}
void
-Viewer::xml_to_layout()
+Viewer::load_xml(QString filename)
{
+ text_vector_.clear();
+ image_vector_.clear();
- /* /!\ XML parsing is VERY UGLY /!\
- TO DO: use same parsing as xml_transfrom. */
+ app_->setOverrideCursor(QCursor(Qt::WaitCursor));
+ emit fill_xml(filename);
+
+ if (image_ && image_->scene() && image_->scene() == scene_)
+ scene_->removeItem(image_);
+
+ scene_->clear();
+ if (!base64_ && use_image_)
+ scene_->addItem(image_);
- // Add layout info to the scene.
- if (doc_layout_)
+ scene_->update();
+
+ xml_file_ = filename;
+ QFile f_in(xml_file_);
+ f_in.open(QIODevice::ReadOnly);
+
+ QDomDocument doc;
+ doc.setContent(&f_in);
+ f_in.close();
+
+ QDomElement root = doc.documentElement();
+ QDomNode page = root.firstChild();
+
+ while (!page.isNull() && !page.toElement().tagName().contains("page"))
+ page = page.nextSibling();
+
+ if (page.isNull())
+ return;
+
+ int width = page.toElement().attribute("image_width", "none").toInt();
+ int height = page.toElement().attribute("image_height", "none").toInt();
+
+ scene_->setSceneRect(0, 0, width, height);
+
+ QDomNode region = page.firstChild();
+
+ while (!region.isNull())
{
- 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)
+ if (region.toElement().tagName().contains(QRegExp("(image|graphic|chart|separator|table|text)_region")))
+ {
+ QString attr_id = region.toElement().attribute("id", "none");
+ add_region(region, attr_id);
+
+ if ( base64_ &&
+ region.toElement().tagName().contains(QRegExp("(image|graphic|chart|separator|table)_region")))
{
- // Navigate to the coordinate list
- point = doc_layout_->index(j, 1, coords);
- if (!point.isValid())
- break;
+ QDomNode container = region.firstChild();
- QMap<QString, QVariant> data =
- doc_layout_->data(point, Qt::UserRole).toMap();
- int x = data["x"].toInt();
- int y = data["y"].toInt();
+ while (!container.isNull() && !container.toElement().tagName().contains("container"))
+ container = container.nextSibling();
- points << QPoint(x, y);
- }
+ QDomNode coords = region.firstChild();
- // 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);
-
- // EXTENDED MODE
- if (extended_mode_)
- {
- for (int k = 1; true; ++k)
+ while (!coords.isNull() && !coords.toElement().tagName().contains("coords"))
+ coords = coords.nextSibling();
+
+ if (!container.isNull() && !coords.isNull())
{
- QModelIndex paragraph = doc_layout_->index(k, 0, region);
- QModelIndex attributes_par = doc_layout_->index(k, 1, region);
- if (!paragraph.isValid())
- break;
+ QDomNode child = container.firstChild();
- QString name_par = doc_layout_->data(paragraph, Qt::DisplayRole).toString();
- region::RegionId id_par = static_cast<region::RegionId>(region_ids_[name_par]);
+ while (!child.isNull() && !child.toElement().tagName().contains("data"))
+ child = child.nextSibling();
- QDebug(&name_par) << name_par;
+ QPixmap pix;
+ QString data = child.toElement().text();
+ QByteArray ba;
+ ba = ba.append(data);
+ QByteArray out_ba = QByteArray::fromBase64(ba);
+ pix.loadFromData(out_ba);
- QModelIndex par_coords = doc_layout_->index(0, 0, paragraph);
- QModelIndex point_par;
+ QGraphicsPixmapItem* image = new QGraphicsPixmapItem(pix);
- QVector<QPoint> points_par;
- for (int m = 0; true; ++m)
+ QDomNode point = coords.firstChild();
+
+ int x_min = INT_MAX;
+ int y_min = INT_MAX;
+
+ while (!point.isNull())
{
- // Navigate to the coordinate list
- point_par = doc_layout_->index(m, 1, par_coords);
- if (!point_par.isValid())
- break;
-
- QMap<QString, QVariant> data_par =
- doc_layout_->data(point_par, Qt::UserRole).toMap();
- int x = data_par["x"].toInt();
- int y = data_par["y"].toInt();
- points_par << QPoint(x, y);
+ int x = point.toElement().attribute("x", "0").toInt();
+ int y = point.toElement().attribute("y", "0").toInt();
+
+ if (x < x_min)
+ x_min = x;
+
+ if (y < y_min)
+ y_min = y;
+
+ point = point.nextSibling();
}
- // Create region
- ImageRegion* r_par = new ImageRegion(id_par,
- key_map_[id_par].first,
- key_map_[id_par].second,
- attributes_par, points_par,
- outline_action_->isChecked(),
- fill_action_->isChecked(),
- precise_action_->isChecked(),
- key_wgt_->isChecked(id_par));
-
- connect(this, SIGNAL(key_updated(int, bool)),
- r_par, SLOT(setDrawIfSameId(int, bool)));
- connect(this, SIGNAL(setOutline(bool)),
- r_par, SLOT(setOutline(bool)));
- connect(this, SIGNAL(setPrecise(bool)),
- r_par, SLOT(setPrecise(bool)));
- connect(this, SIGNAL(setFill(bool)),
- r_par, SLOT(setFill(bool)));
-
- scene_->addItem(r_par);
-
- for (int l = 1; true; ++l)
+ image->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
+ image->setZValue(0);
+ image->setOffset(x_min, y_min);
+ if (use_image_)
+ scene_->addItem(image);
+ image_vector_ << image;
+
+ if (no_cache_)
+ image->setCacheMode(QGraphicsItem::NoCache);
+ else
+ image->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+
+ child = child.nextSibling();
+ }
+ }
+
+ if (extended_mode_ &&
+ region.toElement().tagName().contains("text_region"))
+ {
+ QDomNode para = region.firstChild();
+ while (!para.isNull() && !para.toElement().tagName().contains("paragraph"))
+ para = para.nextSibling();
+
+ if (!para.isNull())
+ {
+ add_region(para, attr_id);
+
+ QDomNode line = para.firstChild();
+ while (!line.isNull() && !line.toElement().tagName().contains("line"))
+ line = line.nextSibling();
+
+ if (!line.isNull())
{
- QModelIndex line = doc_layout_->index(l, 0, paragraph);
- QModelIndex attributes_line = doc_layout_->index(l, 1, paragraph);
- if (!line.isValid())
- break;
-
- QString name_line = doc_layout_->data(line, Qt::DisplayRole).toString();
- region::RegionId id_line = static_cast<region::RegionId>(region_ids_[name_line]);
-
- QModelIndex line_coords = doc_layout_->index(0, 0, line);
- QModelIndex point_line;
- QVector<QPoint> points_line;
- for (int n = 0; true; ++n)
- {
- // Navigate to the coordinate list
- point_line = doc_layout_->index(n, 1, line_coords);
- if (!point_line.isValid())
- break;
-
- QMap<QString, QVariant> data_line =
- doc_layout_->data(point_line, Qt::UserRole).toMap();
- int x = data_line["x"].toInt();
- int y = data_line["y"].toInt();
- points_line << QPoint(x, y);
- }
-
- // Create region
- ImageRegion* r_line = new ImageRegion(id_line,
- key_map_[id_line].first,
- key_map_[id_line].second,
- attributes_line, points_line,
- outline_action_->isChecked(),
- fill_action_->isChecked(),
- precise_action_->isChecked(),
- key_wgt_->isChecked(id_line));
-
- connect(this, SIGNAL(key_updated(int, bool)),
- r_line, SLOT(setDrawIfSameId(int, bool)));
- connect(this, SIGNAL(setOutline(bool)),
- r_line, SLOT(setOutline(bool)));
- connect(this, SIGNAL(setPrecise(bool)),
- r_line, SLOT(setPrecise(bool)));
- connect(this, SIGNAL(setFill(bool)),
- r_line, SLOT(setFill(bool)));
-
- scene_->addItem(r_line);
+ add_region(line, attr_id);
+ add_text(line, region);
}
}
}
- // END OF EXTENDED MODE
- }
+ }
- emit updated(doc_layout_);
- key_wgt_->update_all();
+ region = region.nextSibling();
}
+
+ emit updated();
+ scene_->update();
+ key_wgt_->update_all();
+
+ app_->restoreOverrideCursor();
}
void
Viewer::load(QString filename, bool b)
{
app_->setOverrideCursor(QCursor(Qt::WaitCursor));
+
scene_->clear();
scene_->update();
image_ = 0;
@@ -443,24 +492,21 @@ Viewer::load(QString filename, bool b)
image_ = new QGraphicsPixmapItem(load_base64(filename));
else
image_ = new QGraphicsPixmapItem(QPixmap(filename));
+
image_->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
image_->setZValue(0);
- scene_->addItem(image_);
+ if (use_image_)
+ scene_->addItem(image_);
if (no_cache_)
image_->setCacheMode(QGraphicsItem::NoCache);
else
image_->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
- if (doc_layout_)
- {
- doc_layout_->deleteLater();
- doc_layout_ = 0;
- }
-
app_->restoreOverrideCursor();
+ emit updated();
- emit updated(doc_layout_);
+ app_->restoreOverrideCursor();
}
int
@@ -493,10 +539,11 @@ void Viewer::useExtended(bool b)
{
extended_mode_ = b;
key_wgt_->update_all();
- if (xml_file_ != QString(""))
+
+ if (xml_file_ != QString::Null())
load_xml(xml_file_);
- emit mode_changed (b);
+ emit mode_changed(b);
}
void
@@ -557,4 +604,54 @@ QPixmap Viewer::load_base64(QString xml)
return pix;
}
-// LocalWords: hh
+void
+Viewer::useText(bool b)
+{
+ text_ = b;
+ if (!b)
+ {
+ for (int i = 0; i < text_vector_.size(); ++i)
+ scene_->removeItem(text_vector_[i]);
+ }
+ else
+ {
+ for (int i = 0; i < text_vector_.size(); ++i)
+ scene_->addItem(text_vector_[i]);
+ }
+
+ emit updated();
+ scene_->update();
+}
+
+void
+Viewer::useImage(bool b)
+{
+ use_image_ = b;
+ if (!b)
+ {
+ if (image_ && image_->scene() && image_->scene() == scene_)
+ scene_->removeItem(image_);
+
+ for (int i = 0; i < image_vector_.size(); ++i)
+ scene_->removeItem(image_vector_[i]);
+ }
+ else
+ {
+ if (image_ && image_->scene() == 0)
+ scene_->addItem(image_);
+
+ for (int i = 0; i < image_vector_.size(); ++i)
+ scene_->addItem(image_vector_[i]);
+ }
+
+
+
+ emit updated();
+ scene_->update();
+}
+
+void
+Viewer::change_base(bool b)
+{
+ base64_ = b;
+}
diff --git a/scribo/demo/viewer/viewer.hh b/scribo/demo/viewer/viewer.hh
index 7093da8..800bdd5 100644
--- a/scribo/demo/viewer/viewer.hh
+++ b/scribo/demo/viewer/viewer.hh
@@ -17,6 +17,7 @@
# include <QtGui>
# include "common.hh"
+# include <QDomNode>
class ImageScene;
class DomModel;
@@ -44,15 +45,18 @@ public slots:
void maybeChangeCacheMode(qreal scale);
void useCache(bool b);
void useExtended(bool b);
+ void useText(bool b);
+ void useImage(bool b);
+ void change_base(bool b);
signals:
- void updated(DomModel* model);
- void loaded(DomModel* model);
+ void updated();
void key_updated(int key, bool checked);
void setOutline(bool b);
void setPrecise(bool b);
void setFill(bool b);
void mode_changed(bool b);
+ void fill_xml(QString);
private:
Viewer(int &argc, char** argv);
@@ -60,6 +64,8 @@ private:
void xml_to_layout();
QPixmap load_base64(QString xml);
+ void add_region(QDomNode father, QString attr_id);
+ void add_text(QDomNode line, QDomNode region);
QApplication* app_;
QMainWindow* win_;
@@ -82,6 +88,11 @@ private:
bool no_cache_;
bool extended_mode_;
QString xml_file_;
+ bool base64_;
+ bool text_;
+ bool use_image_;
+ QVector<QGraphicsTextItem *> text_vector_;
+ QVector<QGraphicsPixmapItem*> image_vector_;
};
#include "viewer.hxx"
diff --git a/scribo/demo/viewer/xml_widget.cc b/scribo/demo/viewer/xml_widget.cc
index 36f0406..a4ef2f6 100644
--- a/scribo/demo/viewer/xml_widget.cc
+++ b/scribo/demo/viewer/xml_widget.cc
@@ -14,39 +14,160 @@
#include "xml_widget.hh"
-#include "dommodel.hh"
-
XmlWidget::XmlWidget()
- : view_(new QTreeView()),
- model_(0)
+ : tree_(new QTreeWidget()),
+ property_(new QTreeWidget())
{
QLabel* title = new QLabel(tr("XML"));
title->setAlignment(Qt::AlignHCenter);
+ tree_->setHeaderHidden(true);
+
QVBoxLayout* layout = new QVBoxLayout;
+ QHBoxLayout *hlayout = new QHBoxLayout;
+
+ QStringList header_names;
+ header_names << tr("Name") << tr("Value");
+ property_->setHeaderItem(new QTreeWidgetItem(header_names));
+
+ hlayout->addWidget(tree_);
+ hlayout->addWidget(property_);
layout->addWidget(title);
- layout->addWidget(view_);
+ layout->addLayout(hlayout);
setLayout(layout);
+
+ connect(tree_, SIGNAL(itemDoubleClicked (QTreeWidgetItem*, int)),
+ this, SLOT(check_item (QTreeWidgetItem*) ) );
}
void
-XmlWidget::update(DomModel* model)
+XmlWidget::select(QString id, QString name)
{
- view_->setModel(model);
- // view_->resizeColumnToContents(2);
+ QDomNode n = node_map_[item_map_[id]];
+
+ if (name.contains("Paragraph"))
+ {
+ n = n.firstChild();
+ while (!n.isNull() && !n.toElement().tagName().contains("paragraph"))
+ n = n.nextSibling();
+ }
+
+ if (name.contains("Text line"))
+ {
+ n = n.firstChild();
+ while (!n.isNull() && !n.toElement().tagName().contains("paragraph"))
+ n = n.nextSibling();
+
+ if (!n.isNull())
+ {
+ n = n.firstChild();
+ while (!n.isNull() && !n.toElement().tagName().contains("line"))
+ n = n.nextSibling();
+ }
+ }
+
+ if (!n.isNull())
+ {
+ QTreeWidgetItem* item = node_map_.key(n);
+
+ tree_->setCurrentItem(item, 0);
+ item->setExpanded(true);
+ check_item(item);
+ }
}
void
-XmlWidget::select(const QModelIndex& index)
+XmlWidget::check_item (QTreeWidgetItem* item)
{
- view_->setCurrentIndex(index);
+ QDomNode node = node_map_[item];
+
+ if (node.hasAttributes())
+ {
+ property_->clear();
+ QDomNamedNodeMap attributes = node.toElement().attributes();
+
+ for (int i = 0; i < attributes.count(); ++i)
+ {
+ QStringList values;
+ values << attributes.item(i).toAttr().name() << attributes.item(i).toAttr().value();
+ property_->addTopLevelItem(new QTreeWidgetItem(values));
+ }
+ }
+
+ property_->resizeColumnToContents(0);
+}
+
+void XmlWidget::NFS(QDomNode node, QTreeWidgetItem* item)
+{
+ if (!node.isNull())
+ {
+ QString append;
+ if (node.toElement().tagName().contains("point"))
+ {
+ QString x = node.toElement().attribute("x", "0");
+ QString y = node.toElement().attribute("y", "0");
+ append.append(" = (" + x + ", " + y + ")");
+ }
+
+ QTreeWidgetItem* child =
+ new QTreeWidgetItem(QStringList(node.toElement().tagName() + node.nodeValue() + append));
+
+ if (node.hasAttributes())
+ {
+ QString id = node.toElement().attribute("id", "none");
+ item_map_[id] = child;
+ }
+
+ node_map_[child] = node;
+ item->addChild(child);
+
+ QDomNode sibling = node.firstChild();
+ while (!sibling.isNull())
+ {
+ if (!sibling.toElement().tagName().contains("data"))
+ NFS(sibling, child);
+ sibling = sibling.nextSibling();
+ }
+ }
+}
+
+void XmlWidget::fill_widget(QString xml)
+{
+ node_map_.clear();
+ item_map_.clear();
+
+ tree_->clear();
+ property_->clear();
+ QFile f_in(xml);
+ f_in.open(QIODevice::ReadOnly);
+
+ QDomDocument doc;
+ doc.setContent(&f_in);
+ f_in.close();
+
+ int i = 0;
+
+ QDomElement root = doc.documentElement();
+ QTreeWidgetItem* root_item=
+ new QTreeWidgetItem(QStringList(root.tagName()));
+
+ tree_->addTopLevelItem(root_item);
+ root = root.firstChild().toElement();
+
+ while (!root.isNull())
+ {
+ ++i;
+ NFS(root, root_item);
+ root = root.nextSibling().toElement();
+ }
}
void
-XmlWidget::deselect(const QModelIndex&)
+XmlWidget::deselect()
{
+ property_->clear();
}
XmlWidget::~XmlWidget()
diff --git a/scribo/demo/viewer/xml_widget.hh b/scribo/demo/viewer/xml_widget.hh
index b3de3fa..c56a736 100644
--- a/scribo/demo/viewer/xml_widget.hh
+++ b/scribo/demo/viewer/xml_widget.hh
@@ -16,6 +16,7 @@
# define XML_WIDGET_HH_
# include <QtGui>
+# include <QDomNode>
class DomModel;
@@ -29,13 +30,17 @@ public:
~XmlWidget();
public slots:
- void update(DomModel* model);
- void select(const QModelIndex& index);
- void deselect(const QModelIndex& index);
+ void select(QString id, QString name);
+ void deselect();
+ void fill_widget(QString xml);
+ void check_item (QTreeWidgetItem* item);
private:
- QTreeView* view_;
- DomModel* model_;
+ void NFS(QDomNode node, QTreeWidgetItem* item);
+ QTreeWidget* tree_;
+ QTreeWidget* property_;
+ QMap<QString, QTreeWidgetItem*> item_map_;
+ QMap<QTreeWidgetItem*, QDomNode> node_map_;
};
#endif /* !XML_WIDGET_HH_ */
--
1.5.6.5
1
0

19 Jul '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 fix-magick++-wrappers has been created
at 15a057175710227bdea5a9702dcbf5bd64704a9d (commit)
- Log -----------------------------------------------------------------
15a0571 Fix and improve the Magick++ I/O API wrapper.
-----------------------------------------------------------------------
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

last-svn-commit-179-g15a0571 Fix and improve the Magick++ I/O API wrapper.
by Roland Levillain 19 Jul '10
by Roland Levillain 19 Jul '10
19 Jul '10
* mln/io/magick/load.hh
(io::magick::do_it): Enclose these helpers...
(io::magick::impl::do_it): ...in a sub-namespace.
(io::magick::load): Ensure a Magick++'s Quantum is an 8-bit value.
Use a pixel view (Magick::Pixels) to access to pixel values.
No longer pass the input filename to the `do_it' helper.
Simplify the code.
Improve the documentation.
Aesthetic changes.
* mln/io/magick/save.hh
(io::magick::get_color): Enclose these helpers...
(io::magick::impl::get_color): ...in a sub-namespace.
Properly use Magick::Color.
Properly pass the width and the height of the image.
Use a pixel view (Magick::Pixels) to access to pixel values.
Simplify the code.
Aesthetic changes.
* tests/io/magick/load.cc,
* tests/io/magick/save.cc:
Properly initialize Magick++.
Exercice more cases.
* tests/io/magick/Makefile.am (MOSTLYCLEANFILES):
Update the list of files created by tests.
---
milena/ChangeLog | 28 ++++++
milena/mln/io/magick/load.hh | 184 ++++++++++++++++++++----------------
milena/mln/io/magick/save.hh | 140 +++++++++++++++++-----------
milena/tests/io/magick/Makefile.am | 8 +-
milena/tests/io/magick/load.cc | 72 ++++++++++++--
milena/tests/io/magick/save.cc | 86 ++++++++++++++---
6 files changed, 354 insertions(+), 164 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 214b7e6..b4e98cd 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,31 @@
+2010-07-19 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Fix and improve the Magick++ I/O API wrapper.
+
+ * mln/io/magick/load.hh
+ (io::magick::do_it): Enclose these helpers...
+ (io::magick::impl::do_it): ...in a sub-namespace.
+ (io::magick::load): Ensure a Magick++'s Quantum is an 8-bit value.
+ Use a pixel view (Magick::Pixels) to access to pixel values.
+ No longer pass the input filename to the `do_it' helper.
+ Simplify the code.
+ Improve the documentation.
+ Aesthetic changes.
+ * mln/io/magick/save.hh
+ (io::magick::get_color): Enclose these helpers...
+ (io::magick::impl::get_color): ...in a sub-namespace.
+ Properly use Magick::Color.
+ Properly pass the width and the height of the image.
+ Use a pixel view (Magick::Pixels) to access to pixel values.
+ Simplify the code.
+ Aesthetic changes.
+ * tests/io/magick/load.cc,
+ * tests/io/magick/save.cc:
+ Properly initialize Magick++.
+ Exercice more cases.
+ * tests/io/magick/Makefile.am (MOSTLYCLEANFILES):
+ Update the list of files created by tests.
+
2010-04-26 Roland Levillain <roland(a)lrde.epita.fr>
Clean Milena's tests' outputs during `make mostlyclean'.
diff --git a/milena/mln/io/magick/load.hh b/milena/mln/io/magick/load.hh
index 11d17bd..662e67c 100644
--- a/milena/mln/io/magick/load.hh
+++ b/milena/mln/io/magick/load.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -28,13 +28,21 @@
/// \file
///
-/// Define a function which loads an image of kind magick with
-/// given path.
+/// \brief Image intput routines based on Magick++.
+///
+/// Do not forget to call Magick::InitializeMagick(*argv)
+/// <em>before</em> using any of these functions, as advised by the
+/// GraphicsMagick documentation
+/// (http://www.graphicsmagick.org/Magick++/Image.html)
+
+# include <cstdlib>
+
+# include <Magick++.h>
# include <mln/core/image/image2d.hh>
+
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
-# include <Magick++.h>
namespace mln
@@ -46,66 +54,83 @@ namespace mln
namespace magick
{
- /*! Load a magick image in a Milena image.
- *
- * \param[out] ima A reference to the image which will receive
- * data.
- * \param[in] filename The source.
- */
+ /** Load data from a file into a Milena image using Magick++.
+
+ \param[out] ima The image data are loaded into.
+ \param[in] filename The name of the input file. */
template <typename I>
void load(Image<I>& ima, const std::string& filename);
- /*! Load a magick image in a tiled image.
- *
- * \param[out] ima A reference to the image which will receive
- * data.
- * \param[in] filename The source.
- */
- /*template <typename T>
- void load(Image<tiled2d<T> >& ima, const std::string& filename);*/
+
+ // FIXME: Unfinished?
+#if 0
+ /** Load data from a file into a Milena tiled image using
+ Magick++.
+
+ \param[out] ima The image data are loaded into.
+ \param[in] filename The name of the input file. */
+ template <typename T>
+ void load(Image<tiled2d<T> >& ima, const std::string& filename);
+#endif
# ifndef MLN_INCLUDE_ONLY
- inline
- bool do_it(const value::rgb8& in, bool& out, const std::string& filename)
+ namespace impl
{
- if (in.red() == 255u && in.green() == 255u && in.blue() == 255u)
+
+ inline
+ bool
+ do_it(const value::rgb8& in, bool& out)
{
- out = true;
+ if (in.red() != in.green() || in.green() != in.blue())
+ {
+ std::cerr <<
+ "error: attempt to load what looks like a color\n"
+ "(mln::value::rgb8) image into a Boolean (bool) image" <<
+ std::endl;
+ return false;
+ }
+ if (in.red() != 0 &&
+ in.red() != mln_max(value::rgb8::red_t))
+ {
+ std::cerr <<
+ "error: attempt to load what looks like a grayscale\n"
+ "(mln::value::int_u8) image into a Boolean (bool) image" <<
+ std::endl;
+ return false;
+ }
+
+ out = (in.red() != 0);
return true;
}
- if (in.red() == 0u && in.green() == 0u && in.blue() == 0u)
+
+ inline
+ bool
+ do_it(const value::rgb8& in, value::int_u8& out)
{
- out = false;
+ if (in.red() != in.green() || in.green() != in.blue())
+ {
+ std::cerr <<
+ "error: attempt to load what looks like a color\n"
+ "(mln::value::rgb8) image into a grayscale\n"
+ "(mln::int_u8 values) image" << std::endl;
+ return false;
+ }
+
+ out = in.red();
return true;
}
- if (in.red() == in.green() && in.green() == in.blue())
- std::cerr << "error: trying to load '" << filename << "' which is a grayscale image into a bool image" << std::endl;
- else
- std::cerr << "error: trying to load '" << filename << "' which is a truecolor image into a bool image" << std::endl;
- return false;
- }
- inline
- bool do_it(const value::rgb8& in, value::int_u8& out, const std::string& filename)
- {
- if (in.red() == in.green() && in.green() == in.blue())
+ inline
+ bool
+ do_it(const value::rgb8& in, value::rgb8& out)
{
- out = in.red();
+ out = in;
return true;
}
- std::cerr << "error: trying to load '" << filename << "' which is a truecolor image into a grayscale image" << std::endl;
- return false;
- }
- inline
- bool do_it(const value::rgb8& in, value::rgb8& out, const std::string& filename)
- {
- (void) filename;
- out = in;
- return true;
- }
+ } // end of namespace mln::io::magick::impl
template <typename I>
@@ -114,58 +139,51 @@ namespace mln
{
trace::entering("mln::io::magick::load");
+ // Ensure a Magick++'s Quantum is an 8-bit value.
+ mln::metal::equal<Magick::Quantum, unsigned char>::check();
+
I& ima = exact(ima_);
- //std::ifstream file(filename.c_str());
- //if (! file)
- //{
- // std::cerr << "error: cannot open file '" << filename << "'!";
- // abort();
- //}
-
- Magick::Image im_file(filename);
- im_file.modifyImage();
- im_file.type(Magick::TrueColorType);
- int columns = im_file.columns();
- int rows = im_file.rows();
- /*std::cout << "width: " <<columns << std::endl;
- std::cout << "height: " <<rows << std::endl;
- std::cout << "depth: " <<im_file.depth() << std::endl;
- std::cout << "format: " <<im_file.format() << std::endl;
- std::cout << "magick: " <<im_file.magick() << std::endl;*/
-
- const Magick::PixelPacket *pixel_cache = im_file.getConstPixels(0, 0, columns, rows);
-
- algebra::vec<mln_site_(I)::dim, unsigned int> vmin;
- algebra::vec<mln_site_(I)::dim, unsigned int> vmax;
- vmin[0] = 0;
- vmin[1] = 0;
- vmax[0] = rows - 1;
- vmax[1] = columns - 1;
- mln_site(I) pmin(vmin);
- mln_site(I) pmax(vmax);
+ // FIXME: Handle Magick++'s exceptions (see either
+ // ImageMagick++'s or GraphicsMagick++'s documentation).
+ Magick::Image magick_ima(filename);
+ magick_ima.read(filename);
+ magick_ima.type(Magick::TrueColorType);
+ int nrows = magick_ima.rows();
+ int ncols = magick_ima.columns();
+ mln_site(I) pmin(0, 0);
+ mln_site(I) pmax(nrows - 1, ncols - 1);
mln_concrete(I) result(box<mln_site(I)>(pmin, pmax));
initialize(ima, result);
+
+ Magick::Pixels view(magick_ima);
+ // Note that `ncols' is passed before `nrows'.
+ Magick::PixelPacket* pixels = view.get(0, 0, ima.ncols(), ima.nrows());
mln_piter(I) p(ima.domain());
for_all(p)
{
- const Magick::PixelPacket *pixel = pixel_cache + (int) p.to_site().to_vec()[0] * columns
- + (int) p.to_site().to_vec()[1];
- // FIXME: Quantum = 16bits but rgb is 8bits
- value::rgb8 pix(pixel->red % 256, pixel->green % 256, pixel->blue % 256);
+ value::rgb8 c(pixels->red, pixels->green, pixels->blue);
mln_value(I) res;
- if (!do_it(pix, res, filename))
- abort();
+ if (!impl::do_it(c, res))
+ {
+ std::cerr << "while trying to load `" << filename << "'"
+ << std::endl;
+ abort();
+ }
ima(p) = res;
+ ++pixels;
}
trace::exiting("mln::io::magick::load");
}
- /*template<typename T>
+ // FIXME: Unfinished?
+#if 0
+ template<typename T>
inline
- void load(Image<tiled2d<T> >& ima_, const std::string& filename)
+ void
+ load(Image<tiled2d<T> >& ima_, const std::string& filename)
{
trace::entering("mln::io::magick::load");
@@ -175,8 +193,8 @@ namespace mln
ima = result;
trace::exiting("mln::io::magick::load");
- }*/
-
+ }
+#endif
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/mln/io/magick/save.hh b/milena/mln/io/magick/save.hh
index 0af7d21..d524564 100644
--- a/milena/mln/io/magick/save.hh
+++ b/milena/mln/io/magick/save.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -28,16 +28,23 @@
/// \file
///
-/// Define a function which saves an image of kind magick with
-/// given path.
+/// \brief Image output routines based on Magick++.
///
-/// \todo At the moment it works; is it a miracle?
+/// Do not forget to call Magick::InitializeMagick(*argv)
+/// <em>before</em> using any of these functions, as advised by the
+/// GraphicsMagick documentation
+/// (http://www.graphicsmagick.org/Magick++/Image.html)
+
+# include <cstdlib>
+
+# include <Magick++.h>
-# include <mln/core/image/image2d.hh>
# include <mln/metal/equal.hh>
+
+# include <mln/core/image/image2d.hh>
+
# include <mln/value/int_u8.hh>
# include <mln/value/rgb8.hh>
-# include <Magick++.h>
namespace mln
@@ -49,84 +56,106 @@ namespace mln
namespace magick
{
- /*! Save a Milena image in a magick image.
- *
- * \param[out] ima A reference to the image to save.
- * \param[in] filename The output.
- */
+ /** Save a Milena image into a file using Magick++.
+
+ \param[out] ima The image to save.
+ \param[in] filename The name of the output file. */
template <typename I>
- void save(const Image<I>& ima,
- const std::string& filename);
+ void
+ save(const Image<I>& ima, const std::string& filename);
- /*! Save a Milena tiled image in a magick image.
- *
- * \param[out] ima A reference to the image to save.
- * \param[in] filename The output.
- */
- /*template <typename T>
- void save(Image< tiled2d<T> >& ima,
- const std::string& filename);*/
+
+ // FIXME: Unfinished?
+#if 0
+ /** Save a Milena tiled image into a file using Magick++.
+
+ \param[out] ima The image to save.
+ \param[in] filename The name of the output file. */
+ template <typename T>
+ void
+ save(const Image< tiled2d<T> >& ima, const std::string& filename);
+#endif
# ifndef MLN_INCLUDE_ONLY
- inline
- Magick::Color get_color(bool value)
+ namespace impl
{
- return Magick::ColorMono(value);
- }
- inline
- Magick::Color get_color(const value::int_u8& value)
- {
- return Magick::ColorGray(256 - value);
- }
+ inline
+ Magick::Color get_color(bool value)
+ {
+ return Magick::ColorMono(value);
+ }
+
+ inline
+ Magick::Color get_color(const value::int_u8& value)
+ {
+ // Ensure a Magick++'s Quantum is an 8-bit value.
+ mln::metal::equal<Magick::Quantum, unsigned char>::check();
+ return Magick::Color(value, value, value);
+ }
+
+ inline
+ Magick::Color get_color(const value::rgb8& value)
+ {
+ // Ensure a Magick++'s Quantum is an 8-bit value.
+ mln::metal::equal<Magick::Quantum, unsigned char>::check();
+ return Magick::Color(value.red(), value.green(), value.blue());
+ }
+
+ } // end of namespace mln::io::magick::impl
- inline
- Magick::Color get_color(const value::rgb8& value)
- {
- return Magick::ColorRGB(256 - value.red(),
- 256 - value.green(),
- 256 - value.blue());
- }
template <typename I>
inline
- void save(const Image<I>& ima_, const std::string& filename)
+ void
+ save(const Image<I>& ima_, const std::string& filename)
{
trace::entering("mln::io::magick::save");
mln_precondition(mln_site_(I)::dim == 2);
- const I& ima = exact(ima_);
+ // Turn this into a static check?
if (!(mln::metal::equal<mln_value(I), bool>::value ||
mln::metal::equal<mln_value(I), value::int_u8>::value ||
mln::metal::equal<mln_value(I), value::rgb8>::value))
{
- std::cerr << "error: trying to save an unsupported format" << std::endl;
- std::cerr << "supported formats: binary, 8bits grayscale (int_u8), 8bits truecolor (rgb8)" << std::endl;
+ std::cerr <<
+ "error: trying to save an unsupported format\n"
+ "supported formats are:\n"
+ " binary (bool)\n"
+ " 8-bit grayscale (mln::value::int_u8)\n"
+ " 3x8-bit truecolor (rgb8)" << std::endl;
abort();
}
- Magick::Image im_file;
- im_file.size(Magick::Geometry(ima.nrows(), ima.ncols()));
+ const I& ima = exact(ima_);
- Magick::PixelPacket* pixel_cache = im_file.getPixels(0, 0, ima.nrows(), ima.ncols());
- Magick::PixelPacket* pixel;
+ Magick::Image magick_ima;
+ // In the construction of a Geometry object, the width (i.e.
+ // `ncols') comes first, then the height (i.e. `nrows')
+ // follows.
+ magick_ima.size(Magick::Geometry(ima.ncols(), ima.nrows()));
+
+ Magick::Pixels view(magick_ima);
+ // As above, `ncols' is passed before `nrows'.
+ Magick::PixelPacket* pixels = view.get(0, 0, ima.ncols(), ima.nrows());
mln_piter(I) p(ima.domain());
for_all(p)
- {
- pixel = pixel_cache + (int) p.to_site().to_vec()[0] * ima.ncols()
- + (int) p.to_site().to_vec()[1];
- *pixel = get_color(ima(p));
- }
- im_file.syncPixels();
- im_file.write(filename);
+ *pixels++ = impl::get_color(ima(p));
+
+ view.sync();
+ magick_ima.write(filename);
trace::exiting("mln::io::magick::save");
}
- /*template <typename T>
- void save(Image< tiled2d<T> >& ima_, const std::string& filename)
+
+ // FIXME: Unfinished?
+#if 0
+ template <typename T>
+ void
+ save(const Image< tiled2d<T> >& ima_, const std::string& filename)
{
trace::entering("mln::io::magick::save");
@@ -135,7 +164,8 @@ namespace mln
ima.buffer().write(filename);
trace::exiting("mln::io::magick::save");
- }*/
+ }
+#endif
# endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/tests/io/magick/Makefile.am b/milena/tests/io/magick/Makefile.am
index f2d5f48..c04147f 100644
--- a/milena/tests/io/magick/Makefile.am
+++ b/milena/tests/io/magick/Makefile.am
@@ -29,5 +29,9 @@ save_SOURCES = save.cc
TESTS = $(check_PROGRAMS)
MOSTLYCLEANFILES = \
- save-tiny.ppm \
- save-tiny.png
+ save-tiny-temp.pbm \
+ save-tiny-temp.pgm \
+ save-tiny-temp.png \
+ save-tiny.pbm \
+ save-tiny.pgm \
+ save-tiny.ppm
diff --git a/milena/tests/io/magick/load.cc b/milena/tests/io/magick/load.cc
index ce6db10..1525545 100644
--- a/milena/tests/io/magick/load.cc
+++ b/milena/tests/io/magick/load.cc
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009, 2010 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -23,26 +23,78 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#include <mln/core/image/image2d.hh>
+#include <mln/io/magick/load.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/ppm/load.hh>
#include <mln/data/compare.hh>
-#include <mln/io/magick/load.hh>
-#include <mln/io/ppm/load.hh>
+#include <mln/core/image/image2d.hh>
#include <mln/value/rgb8.hh>
#include "tests/data.hh"
-int main()
+
+int main(int /* argc */, char* argv[])
{
using namespace mln;
- image2d<value::rgb8> lena_ppm;
- io::ppm::load(lena_ppm, MLN_IMG_DIR "/tiny.ppm");
+ /* From http://www.graphicsmagick.org/Magick++/Image.html:
+
+ The InitializeMagick() function MUST be invoked before
+ constructing any Magick++ objects. This used to be optional,
+ but now it is absolutely required. This function initalizes
+ semaphores and configuration information necessary for the
+ software to work correctly. Failing to invoke
+ InitializeMagick() is likely to lead to a program crash or
+ thrown assertion. If the program resides in the same directory
+ as the GraphicsMagick files, then argv[0] may be passed as an
+ argument so that GraphicsMagick knows where its files reside,
+ otherwise NULL may be passed and GraphicsMagick will try to use
+ other means (if necessary). */
+ Magick::InitializeMagick(*argv);
+
+ // Compare Milena's built-in PBM loaded and Magick++'s support for PBM.
+ {
+ typedef image2d<bool> I;
+ I mln_lena;
+ io::pbm::load(mln_lena, MLN_IMG_DIR "/tiny.pbm");
+ I magick_lena;
+ io::magick::load(magick_lena, MLN_IMG_DIR "/tiny.pbm");
+ mln_assertion(mln_lena == magick_lena);
+ }
+
+ // Compare Milena's built-in PGM loaded and Magick++'s support for PGM.
+ {
+ typedef image2d<value::int_u8> I;
+ I mln_lena;
+ io::pgm::load(mln_lena, MLN_IMG_DIR "/tiny.pgm");
+ I magick_lena;
+ io::magick::load(magick_lena, MLN_IMG_DIR "/tiny.pgm");
+ mln_assertion(mln_lena == magick_lena);
+ }
+
+ // Compare Milena's built-in PPM loaded and Magick++'s support for PPM.
+ {
+ typedef image2d<value::rgb8> I;
+ I mln_lena;
+ io::ppm::load(mln_lena, MLN_IMG_DIR "/tiny.ppm");
+ I magick_lena;
+ io::magick::load(magick_lena, MLN_IMG_DIR "/tiny.ppm");
+ mln_assertion(mln_lena == magick_lena);
+ }
- image2d<value::rgb8> lena_png;
- io::magick::load(lena_png, MLN_TESTS_IMG_DIR "/tiny.png");
- mln_assertion(lena_png == lena_ppm);
+ // Check Magick++'s support for PNG.
+ {
+ typedef image2d<value::rgb8> I;
+ I lena_ppm;
+ io::ppm::load(lena_ppm, MLN_IMG_DIR "/tiny.ppm");
+ I lena_png;
+ io::magick::load(lena_png, MLN_TESTS_IMG_DIR "/tiny.png");
+ mln_assertion(lena_ppm == lena_png);
+ }
}
diff --git a/milena/tests/io/magick/save.cc b/milena/tests/io/magick/save.cc
index a4efd12..9f5eae7 100644
--- a/milena/tests/io/magick/save.cc
+++ b/milena/tests/io/magick/save.cc
@@ -24,34 +24,92 @@
// executable file might be covered by the GNU General Public License.
#include <mln/core/image/image2d.hh>
+
+#include <mln/data/compare.hh>
+
#include <mln/io/magick/load.hh>
#include <mln/io/magick/save.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
#include <mln/io/ppm/load.hh>
#include <mln/io/ppm/save.hh>
-#include <mln/data/compare.hh>
+
#include "tests/data.hh"
-#include <mln/io/magick/load.hh>
+using namespace mln;
-int main()
-{
- using namespace mln;
+template <typename T>
+image2d<T>
+test(const image2d<T>& lena_mln, const std::string& temp_filename)
+{
point2d p(0,0);
- image2d<value::rgb8> lena_mln;
- io::ppm::load(lena_mln, MLN_IMG_DIR "/tiny.ppm");
- value::rgb8 c = lena_mln(p);
+ T c = lena_mln(p);
- io::magick::save(lena_mln, "save-tiny.png");
+ io::magick::save(lena_mln, temp_filename);
+ image2d<T> lena_im;
+ io::magick::load(lena_im, temp_filename);
- image2d<value::rgb8> lena_im;
- io::magick::load(lena_im, "save-tiny.png");
mln_assertion(lena_im(p) == c);
-
- io::ppm::save(lena_im, "save-tiny.ppm");
-
mln_assertion(lena_im.domain() == lena_mln.domain());
mln_assertion(lena_im == lena_mln);
+
+ return lena_im;
+}
+
+
+int main(int /* argc */, char* argv[])
+{
+ using namespace mln;
+
+ /* From http://www.graphicsmagick.org/Magick++/Image.html:
+
+ The InitializeMagick() function MUST be invoked before
+ constructing any Magick++ objects. This used to be optional,
+ but now it is absolutely required. This function initalizes
+ semaphores and configuration information necessary for the
+ software to work correctly. Failing to invoke
+ InitializeMagick() is likely to lead to a program crash or
+ thrown assertion. If the program resides in the same directory
+ as the GraphicsMagick files, then argv[0] may be passed as an
+ argument so that GraphicsMagick knows where its files reside,
+ otherwise NULL may be passed and GraphicsMagick will try to use
+ other means (if necessary). */
+ Magick::InitializeMagick(*argv);
+
+ point2d p(0,0);
+
+ // Grayscale values (PBM -> PBM -> PBM).
+ {
+ typedef image2d<bool> I;
+ I lena_mln;
+ io::pbm::load(lena_mln, MLN_IMG_DIR "/tiny.pbm");
+ I lena_im = ::test(lena_mln, "save-tiny-temp.pbm");
+ io::pbm::save(lena_im, "save-tiny.pbm");
+ }
+
+ // Grayscale values (PGM -> PGM -> PGM).
+ {
+ typedef image2d<value::int_u8> I;
+ I lena_mln;
+ io::pgm::load(lena_mln, MLN_IMG_DIR "/tiny.pgm");
+ I lena_im = ::test(lena_mln, "save-tiny-temp.pgm");
+ io::pgm::save(lena_im, "save-tiny.pgm");
+ }
+
+ // Color values (PPM -> PNG -> PPM).
+ {
+ typedef image2d<value::rgb8> I;
+ I lena_mln;
+ io::ppm::load(lena_mln, MLN_IMG_DIR "/tiny.ppm");
+ I lena_im = ::test(lena_mln, "save-tiny-temp.png");
+ io::ppm::save(lena_im, "save-tiny.ppm");
+ }
}
--
1.5.6.5
1
0
#234: Add more I/O routines for graph and complexes
-------------------------+--------------------------------------------------
Reporter: levill_r | Owner: Olena Team
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: Milena | Version: 1.0
Keywords: |
-------------------------+--------------------------------------------------
We need routines to read input from/write output to these file formats :
!GraphViz's (`.dot`, `.neato`, etc.):: Nothing has been done so far,
except some ad hoc outputs in
source:milena/apps/papers/levillain.09.ismm/graph.cc).
VTK's:: Roland has started to support the VTK legacy format, since it is
easy to produce ; the other, newer format is XML-based.
OFF file format:: Milena already provides some read/write support for
this format, but there is still some work to do (see the FIXMEs in
source:milena/mln/io/off).
TikZ/PGF "format":: TikZ (and/or PGF) outputs would be useful to draw
figures for LaTeX documents like papers, documentation, manuals, etc. (I'm
unsure about inputs).
--
Ticket URL: <https://trac.lrde.org/olena/ticket/234>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
1
1

16 Jul '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 cfa008d41e46c8c145d9eb01cb9719a4fa018861 (commit)
from fc5c165e1e2b4713f25529e1a1f12e16514c771e (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 -----------------------------------------------------------------
cfa008d Base 64 support in Qt interface (xmlc extension)
-----------------------------------------------------------------------
Summary of changes:
scribo/ChangeLog | 47 +++++++++++++-------
scribo/demo/viewer/browser_widget.cc | 9 +++-
scribo/demo/viewer/browser_widget.hh | 2 +-
scribo/demo/viewer/image_scene.cc | 10 ++--
scribo/demo/viewer/step_widget.cc | 77 ++++++++++++++++++---------------
scribo/demo/viewer/step_widget.hh | 4 +-
scribo/demo/viewer/viewer.cc | 60 +++++++++++++++++++++++---
scribo/demo/viewer/viewer.hh | 3 +-
8 files changed, 142 insertions(+), 70 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0

last-svn-commit-237-gcfa008d Base 64 support in Qt interface (xmlc extension)
by Arthur Crepin-Leblond 16 Jul '10
by Arthur Crepin-Leblond 16 Jul '10
16 Jul '10
* scribo/demo/viewer/step_widget.cc
* scribo/demo/viewer/step_widget.hh
* scribo/demo/viewer/browser_widget.cc,
* scribo/demo/viewer/browser_widget.hh: Add .xmlc extension.
* scribo/demo/viewer/image_scene.cc
* scribo/demo/viewer/viewer.cc,
* scribo/demo/viewer/viewer.hh: base 64 loading.
---
scribo/ChangeLog | 47 +++++++++++++-------
scribo/demo/viewer/browser_widget.cc | 9 +++-
scribo/demo/viewer/browser_widget.hh | 2 +-
scribo/demo/viewer/image_scene.cc | 10 ++--
scribo/demo/viewer/step_widget.cc | 77 ++++++++++++++++++---------------
scribo/demo/viewer/step_widget.hh | 4 +-
scribo/demo/viewer/viewer.cc | 60 +++++++++++++++++++++++---
scribo/demo/viewer/viewer.hh | 3 +-
8 files changed, 142 insertions(+), 70 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index dbc16e3..77c6680 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,21 +1,34 @@
2010-07-16 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+ Base 64 support in Qt interface (xmlc extension)
+
+ * scribo/demo/viewer/step_widget.cc
+ * scribo/demo/viewer/step_widget.hh
+ * scribo/demo/viewer/browser_widget.cc,
+ * scribo/demo/viewer/browser_widget.hh: Add .xmlc extension.
+
+ * scribo/demo/viewer/image_scene.cc
+ * scribo/demo/viewer/viewer.cc,
+ * scribo/demo/viewer/viewer.hh: base 64 loading.
+
+2010-07-16 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+
Two new features in Qt interface.
- * demo/viewer/browser_widget.cc,
- * demo/viewer/browser_widget.hh: Add arrows to change image and keep
+ * scribo/demo/viewer/browser_widget.cc,
+ * scribo/demo/viewer/browser_widget.hh: Add arrows to change image and keep
XML step.
- * demo/viewer/key_widget.cc,
- * demo/viewer/key_widget.hh: Change ListWidget to TreeWidget, Items can be
+ * scribo/demo/viewer/key_widget.cc,
+ * scribo/demo/viewer/key_widget.hh: Change ListWidget to TreeWidget, Items can be
disabled/enabled in groups.
- * demo/viewer/step_widget.cc,
- * demo/viewer/step_widget.hh: Small changes to keep the step when next/prev.
+ * scribo/demo/viewer/step_widget.cc,
+ * scribo/demo/viewer/step_widget.hh: Small changes to keep the step when next/prev.
picture is chosen.
- * demo/viewer/viewer.cc,
- * demo/viewer/xml_widget.cc: Layout adjustement.
+ * scribo/demo/viewer/viewer.cc,
+ * scribo/demo/viewer/xml_widget.cc: Layout adjustement.
2010-07-16 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
@@ -42,18 +55,18 @@
* scribo/demo/viewer/Makefile.am
- * demo/viewer/image_region.cc,
+ * scribo/demo/viewer/image_region.cc,
* viewer/image_region.hh,
* viewer/image_region.hxx: Change regions depths to have a hierarchy.
- * demo/viewer/image_scene.cc,
- * demo/viewer/image_scene.hh: Change mouse click behaviour.
+ * scribo/demo/viewer/image_scene.cc,
+ * scribo/demo/viewer/image_scene.hh: Change mouse click behaviour.
- * demo/viewer/key_widget.cc,
- * demo/viewer/key_widget.hh: Add new items (text line and paragraph)
+ * scribo/demo/viewer/key_widget.cc,
+ * scribo/demo/viewer/key_widget.hh: Add new items (text line and paragraph)
- * demo/viewer/viewer.cc,
- * demo/viewer/viewer.hh: Chnage XML parsing to support extended format.
+ * scribo/demo/viewer/viewer.cc,
+ * scribo/demo/viewer/viewer.hh: Chnage XML parsing to support extended format.
* scribo/demo/viewer/common.hh: Add new RegionId's.
@@ -61,8 +74,8 @@
New features in Qt interface.
- * demo/viewer/browser_widget.hh: Improve picture browser.
- * demo/viewer/step_widget.cc: Add a "step chooser" to load several XML files related to one picture.
+ * scribo/demo/viewer/browser_widget.hh: Improve picture browser.
+ * scribo/demo/viewer/step_widget.cc: Add a "step chooser" to load several XML files related to one picture.
2010-06-30 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
diff --git a/scribo/demo/viewer/browser_widget.cc b/scribo/demo/viewer/browser_widget.cc
index bd70648..220a719 100644
--- a/scribo/demo/viewer/browser_widget.cc
+++ b/scribo/demo/viewer/browser_widget.cc
@@ -66,7 +66,9 @@ BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
QStringList files_filters;
files_filters << "*.png" << "*.jpg"
- << "*.tif" << "*.ppm" << "*.pgm" << "*.pbm" << "pnm";
+ << "*.tif" << "*.ppm"
+ << "*.pgm" << "*.pbm"
+ << "*.pnm" << "*.xmle";
files->setNameFilters(files_filters);
}
@@ -95,7 +97,10 @@ BrowserWidget::activate(const QModelIndex& index, bool b)
first_time_ = false;
- emit activated(files_->filePath(index), b);
+ if (files_->filePath(index).endsWith(".xmlc"))
+ emit activated(files_->filePath(index), b, true);
+ else
+ emit activated(files_->filePath(index), b, false);
}
void
diff --git a/scribo/demo/viewer/browser_widget.hh b/scribo/demo/viewer/browser_widget.hh
index a0fbe43..9266832 100644
--- a/scribo/demo/viewer/browser_widget.hh
+++ b/scribo/demo/viewer/browser_widget.hh
@@ -33,7 +33,7 @@ public slots:
void prev() { change_pos(false); }
signals:
- void activated(QString filename, bool b);
+ void activated(QString filename, bool b, bool x);
private:
void change_pos(bool next);
diff --git a/scribo/demo/viewer/image_scene.cc b/scribo/demo/viewer/image_scene.cc
index bbc75c3..62b4b46 100644
--- a/scribo/demo/viewer/image_scene.cc
+++ b/scribo/demo/viewer/image_scene.cc
@@ -40,7 +40,7 @@ ImageScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
ImageRegion* item = dynamic_cast<ImageRegion*>(elt);
if (item)
- {
+ {
if (item != selected_)
{
if (selected_)
@@ -49,7 +49,7 @@ ImageScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
int item_area = item->boundingRect().size().height() * item->boundingRect().size().width();
int selected_area = selected_->boundingRect().size().height() * selected_->boundingRect().size().width();
-
+
if (selected_area < item_area && selection_is_clicked)
return;
else
@@ -66,15 +66,15 @@ ImageScene::mousePressEvent(QGraphicsSceneMouseEvent* event)
selected_ = 0;
}
}
- selected_ = item;
+ selected_ = item;
item->select();
emit selected(item->index());
- return;
+ return;
}
}
else
{
- if ( (selected_)
+ if ( (selected_)
&& (items_list.size() == 1) )// no ImageRegion, only the picture
{
selected_->deselect();
diff --git a/scribo/demo/viewer/step_widget.cc b/scribo/demo/viewer/step_widget.cc
index 1020c6a..207796d 100644
--- a/scribo/demo/viewer/step_widget.cc
+++ b/scribo/demo/viewer/step_widget.cc
@@ -68,57 +68,64 @@ void StepWidget::activate(QListWidgetItem* item)
}
-void StepWidget::fill_steps(QString file, bool step)
+void StepWidget::fill_steps(QString file, bool step, bool container)
{
view_->clear();
map_.clear();
- // image is loaded once
- emit load_image(file);
+ if (container)
+ {
+ emit load_image(file, true);
+ emit load_xml(file);
+ }
+ else
+ {
+ // image is loaded once
+ emit load_image(file, false);
- int cut = file.lastIndexOf(QChar('/'));
- QString path = file.left(cut+1);
- QString filename = file.mid(cut+1);
+ int cut = file.lastIndexOf(QChar('/'));
+ QString path = file.left(cut+1);
+ QString filename = file.mid(cut+1);
- cut = filename.lastIndexOf(QChar('.'));
+ cut = filename.lastIndexOf(QChar('.'));
- QString file_with_no_ext = filename.left(cut);
- // view_->addItem(file_with_no_ext);
+ QString file_with_no_ext = filename.left(cut);
+ // view_->addItem(file_with_no_ext);
- QDir dir(path);
+ QDir dir(path);
- if (dir.isReadable())
- {
- QStringList filter;
- filter << "*.xml";
- QStringList xml_list = dir.entryList(filter);
- for (int i = 0; i < xml_list.size(); ++i)
+ if (dir.isReadable())
{
- if (xml_list.at(i).startsWith(file_with_no_ext))
+ QStringList filter;
+ filter << "*.xml";
+ QStringList xml_list = dir.entryList(filter);
+ for (int i = 0; i < xml_list.size(); ++i)
{
- cut = xml_list.at(i).lastIndexOf(QChar('.'));
- QString key = xml_list.at(i).left(cut);
- key.replace(file_with_no_ext + QString("_"), QString(""));
- key.replace(QRegExp("^step([0-9])"), "Step \\1");
- key.replace(QRegExp("^Step ([0-9])_"), "Step \\1 : ");
- key.replace("_", " ");
- QString value = path;
- map_.insertMulti(key, value.append(xml_list.at(i)));
- view_->addItem(key);
+ if (xml_list.at(i).startsWith(file_with_no_ext))
+ {
+ cut = xml_list.at(i).lastIndexOf(QChar('.'));
+ QString key = xml_list.at(i).left(cut);
+ key.replace(file_with_no_ext + QString("_"), QString(""));
+ key.replace(QRegExp("^step([0-9])"), "Step \\1");
+ key.replace(QRegExp("^Step ([0-9])_"), "Step \\1 : ");
+ key.replace("_", " ");
+ QString value = path;
+ map_.insertMulti(key, value.append(xml_list.at(i)));
+ view_->addItem(key);
+ }
}
}
- }
+ if ( (step && step_ != QString::Null()))
+ {
+ QList<QListWidgetItem*> list = view_->findItems(step_, Qt::MatchContains);
- if (step && step_ != QString::Null())
- {
- QList<QListWidgetItem*> list = view_->findItems(step_, Qt::MatchContains);
-
- if (!list.isEmpty())
- emit activated(list.first());
+ if (!list.isEmpty())
+ emit activated(list.first());
+ }
+ else
+ step_ = QString::Null();
}
- else
- step_ = QString::Null();
}
void StepWidget::add_element(const QString& element)
diff --git a/scribo/demo/viewer/step_widget.hh b/scribo/demo/viewer/step_widget.hh
index 928e503..32602b0 100644
--- a/scribo/demo/viewer/step_widget.hh
+++ b/scribo/demo/viewer/step_widget.hh
@@ -42,12 +42,12 @@ public:
void add_element(const QString& element);
signals:
- void load_image(QString);
+ void load_image(QString, bool);
void load_xml(QString);
void activated(QListWidgetItem*);
public slots:
- void fill_steps(QString file, bool = false);
+ void fill_steps(QString file, bool step = false, bool container = false);
void activate(QListWidgetItem* item);
private:
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
index b3fd6f5..e5ec717 100644
--- a/scribo/demo/viewer/viewer.cc
+++ b/scribo/demo/viewer/viewer.cc
@@ -169,11 +169,11 @@ Viewer::Viewer(int &argc, char** argv)
h_sizes << 200 << 700;
h_splitter->setSizes(h_sizes);
- connect(browser_wgt, SIGNAL(activated(QString, bool)),
- step_widget, SLOT(fill_steps(QString, bool)));
+ connect(browser_wgt, SIGNAL(activated(QString, bool, bool)),
+ step_widget, SLOT(fill_steps(QString, bool, bool)));
- connect(step_widget, SIGNAL(load_image(QString)),
- this, SLOT(load(QString)));
+ connect(step_widget, SIGNAL(load_image(QString, bool)),
+ this, SLOT(load(QString, bool)));
connect(step_widget, SIGNAL(load_xml(QString)),
this, SLOT(load_xml(QString)));
@@ -429,18 +429,20 @@ Viewer::xml_to_layout()
}
void
-Viewer::load(QString filename)
+Viewer::load(QString filename, bool b)
{
app_->setOverrideCursor(QCursor(Qt::WaitCursor));
scene_->clear();
scene_->update();
image_ = 0;
- // xml_file_ = "";
// 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));
+ if (b)
+ image_ = new QGraphicsPixmapItem(load_base64(filename));
+ else
+ image_ = new QGraphicsPixmapItem(QPixmap(filename));
image_->setShapeMode(QGraphicsPixmapItem::BoundingRectShape);
image_->setZValue(0);
scene_->addItem(image_);
@@ -511,4 +513,48 @@ Viewer::useCache(bool b)
image_->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
}
+QPixmap Viewer::load_base64(QString xml)
+{
+ QPixmap pix;
+ QFile f_in(xml);
+ f_in.open(QIODevice::ReadOnly);
+
+ QDomDocument doc;
+ doc.setContent(&f_in);
+ f_in.close();
+
+ QDomElement root = doc.documentElement();
+ QDomNode child = root.firstChild();
+
+ while (!child.isNull() && !child.toElement().tagName().contains("page"))
+ child = child.nextSibling();
+
+ child = child.firstChild();
+ while (!child.isNull())
+ {
+ if (child.toElement().tagName().contains(QRegExp("image_region")))
+ {
+ QDomNode node = child.firstChild();
+ QString id = child.toElement().attribute("id", "none");
+
+ while (!node.isNull() && !node.toElement().tagName().contains("container"))
+ node = node.nextSibling();
+
+ if (!node.isNull())
+ {
+ QString data = node.firstChildElement("data").text();
+ QByteArray ba;
+ ba = ba.append(data);
+ QByteArray out_ba = QByteArray::fromBase64(ba);
+ pix.loadFromData(out_ba);
+
+ return pix;
+ }
+ }
+ child = child.nextSibling();
+ }
+
+ return pix;
+}
+
// LocalWords: hh
diff --git a/scribo/demo/viewer/viewer.hh b/scribo/demo/viewer/viewer.hh
index d13ef91..7093da8 100644
--- a/scribo/demo/viewer/viewer.hh
+++ b/scribo/demo/viewer/viewer.hh
@@ -38,7 +38,7 @@ public:
public slots:
// Load the file as an image, load the layout if xml with the same
// name is found.
- void load(QString filename);
+ void load(QString filename, bool b);
void help();
void load_xml(QString filename);
void maybeChangeCacheMode(qreal scale);
@@ -59,6 +59,7 @@ private:
Viewer();
void xml_to_layout();
+ QPixmap load_base64(QString xml);
QApplication* app_;
QMainWindow* win_;
--
1.5.6.5
1
0

16 Jul '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 fc5c165e1e2b4713f25529e1a1f12e16514c771e (commit)
via 7bebf5b174b861b8cd7f181bb51bce2d2e771f4c (commit)
from 1454557f814a8f278ec51d567340bf7732895825 (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 -----------------------------------------------------------------
fc5c165 Two new features in Qt interface.
7bebf5b ChangeLog mistake.
-----------------------------------------------------------------------
Summary of changes:
scribo/ChangeLog | 64 ++++++++-----------
scribo/demo/viewer/browser_widget.cc | 56 +++++++++++++++--
scribo/demo/viewer/browser_widget.hh | 8 ++-
scribo/demo/viewer/key_widget.cc | 113 +++++++++++++++++++++++----------
scribo/demo/viewer/key_widget.hh | 12 +++-
scribo/demo/viewer/step_widget.cc | 38 +++++++++---
scribo/demo/viewer/step_widget.hh | 4 +-
scribo/demo/viewer/viewer.cc | 24 +++++---
scribo/demo/viewer/xml_widget.cc | 3 +-
scribo/sandbox/ChangeLog | 80 ++++++++++++++++++------
10 files changed, 278 insertions(+), 124 deletions(-)
hooks/post-receive
--
Olena, a generic and efficient image processing platform
1
0