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
November 2010
- 7 participants
- 370 discussions

last-svn-commit-566-ge3767ee Files headers change + base64 data hide in xml tree.
by Arthur Crepin-Leblond 16 Nov '10
by Arthur Crepin-Leblond 16 Nov '10
16 Nov '10
* scribo/demo/viewer/README,
* scribo/demo/viewer/browser_widget.cc,
* scribo/demo/viewer/browser_widget.hh,
* scribo/demo/viewer/common.hh,
* scribo/demo/viewer/help_dialog.cc,
* scribo/demo/viewer/help_dialog.hh,
* scribo/demo/viewer/image_region.cc,
* scribo/demo/viewer/image_region.hh,
* scribo/demo/viewer/image_scene.cc,
* scribo/demo/viewer/image_scene.hh,
* scribo/demo/viewer/image_view.cc,
* scribo/demo/viewer/image_view.hh,
* scribo/demo/viewer/image_widget.cc,
* scribo/demo/viewer/image_widget.hh,
* scribo/demo/viewer/key_widget.cc,
* scribo/demo/viewer/key_widget.hh,
* scribo/demo/viewer/main.cc,
* scribo/demo/viewer/viewer.cc,
* scribo/demo/viewer/viewer.hh,
* scribo/demo/viewer/viewer.hxx,
* scribo/demo/viewer/xml_widget.cc: Change header (add LRDE copyright)
* scribo/demo/viewer/xml_widget.hh: Hide data in base 64 to improve loading speed.
---
scribo/ChangeLog | 28 ++++++++++++++++++++++++++++
scribo/demo/viewer/README | 32 ++++++++++++++++++++------------
scribo/demo/viewer/browser_widget.cc | 27 +++++++++++++++++++--------
scribo/demo/viewer/browser_widget.hh | 27 +++++++++++++++++++--------
scribo/demo/viewer/common.hh | 27 +++++++++++++++++++--------
scribo/demo/viewer/help_dialog.cc | 27 +++++++++++++++++++--------
scribo/demo/viewer/help_dialog.hh | 27 +++++++++++++++++++--------
scribo/demo/viewer/image_region.cc | 27 +++++++++++++++++++--------
scribo/demo/viewer/image_region.hh | 27 +++++++++++++++++++--------
scribo/demo/viewer/image_scene.cc | 27 +++++++++++++++++++--------
scribo/demo/viewer/image_scene.hh | 27 +++++++++++++++++++--------
scribo/demo/viewer/image_view.cc | 27 +++++++++++++++++++--------
scribo/demo/viewer/image_view.hh | 27 +++++++++++++++++++--------
scribo/demo/viewer/image_widget.cc | 27 +++++++++++++++++++--------
scribo/demo/viewer/image_widget.hh | 27 +++++++++++++++++++--------
scribo/demo/viewer/key_widget.cc | 27 +++++++++++++++++++--------
scribo/demo/viewer/key_widget.hh | 27 +++++++++++++++++++--------
scribo/demo/viewer/main.cc | 27 +++++++++++++++++++--------
scribo/demo/viewer/viewer.cc | 4 ++--
scribo/demo/viewer/viewer.hh | 27 +++++++++++++++++++--------
scribo/demo/viewer/viewer.hxx | 27 +++++++++++++++++++--------
scribo/demo/viewer/xml_widget.cc | 34 ++++++++++++++++++++++++++--------
scribo/demo/viewer/xml_widget.hh | 27 +++++++++++++++++++--------
23 files changed, 437 insertions(+), 174 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index da06873..ddd6a10 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,31 @@
+2010-07-21 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+
+ Files headers change + base64 data hide in xml tree.
+
+ * scribo/demo/viewer/README,
+ * scribo/demo/viewer/browser_widget.cc,
+ * scribo/demo/viewer/browser_widget.hh,
+ * scribo/demo/viewer/common.hh,
+ * scribo/demo/viewer/help_dialog.cc,
+ * scribo/demo/viewer/help_dialog.hh,
+ * scribo/demo/viewer/image_region.cc,
+ * scribo/demo/viewer/image_region.hh,
+ * scribo/demo/viewer/image_scene.cc,
+ * scribo/demo/viewer/image_scene.hh,
+ * scribo/demo/viewer/image_view.cc,
+ * scribo/demo/viewer/image_view.hh,
+ * scribo/demo/viewer/image_widget.cc,
+ * scribo/demo/viewer/image_widget.hh,
+ * scribo/demo/viewer/key_widget.cc,
+ * scribo/demo/viewer/key_widget.hh,
+ * scribo/demo/viewer/main.cc,
+ * scribo/demo/viewer/viewer.cc,
+ * scribo/demo/viewer/viewer.hh,
+ * scribo/demo/viewer/viewer.hxx,
+ * scribo/demo/viewer/xml_widget.cc: Change header (add LRDE copyright)
+
+ * scribo/demo/viewer/xml_widget.hh: Hide data in base 64 to improve loading speed.
+
2010-07-20 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
Text selectable in Qt interface.
diff --git a/scribo/demo/viewer/README b/scribo/demo/viewer/README
index 6032a41..fa37cd6 100644
--- a/scribo/demo/viewer/README
+++ b/scribo/demo/viewer/README
@@ -1,15 +1,27 @@
+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.
__________________________________________________________________
@@ -19,9 +31,6 @@ Document Layout Viewer
Purpose:
- Display layout information about image documents.
-Contact:
-d-halluin(a)lrde.epita.fr
-
Usage:
- Get XML layout descriptions (PAGE format, ICDAR2009).
- Put XML and image files in the same directory, with the same name.
@@ -30,4 +39,3 @@ Usage:
Infos:
- Everything is read-only.
-- The DOM Model classes are a slightly modified Qt example.
diff --git a/scribo/demo/viewer/browser_widget.cc b/scribo/demo/viewer/browser_widget.cc
index 43de1e2..b9ccbec 100644
--- a/scribo/demo/viewer/browser_widget.cc
+++ b/scribo/demo/viewer/browser_widget.cc
@@ -1,16 +1,27 @@
+// 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 "browser_widget.hh"
diff --git a/scribo/demo/viewer/browser_widget.hh b/scribo/demo/viewer/browser_widget.hh
index 9266832..964dc47 100644
--- a/scribo/demo/viewer/browser_widget.hh
+++ b/scribo/demo/viewer/browser_widget.hh
@@ -1,16 +1,27 @@
+// 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.
#ifndef BROWSER_WIDGET_HH_
# define BROWSER_WIDGET_HH_
diff --git a/scribo/demo/viewer/common.hh b/scribo/demo/viewer/common.hh
index 346ea51..4dee676 100644
--- a/scribo/demo/viewer/common.hh
+++ b/scribo/demo/viewer/common.hh
@@ -1,16 +1,27 @@
+// 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.
#ifndef COMMON_HH_
# define COMMON_HH_
diff --git a/scribo/demo/viewer/help_dialog.cc b/scribo/demo/viewer/help_dialog.cc
index 3ac5614..932d66f 100644
--- a/scribo/demo/viewer/help_dialog.cc
+++ b/scribo/demo/viewer/help_dialog.cc
@@ -1,16 +1,27 @@
+// 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 "help_dialog.hh"
diff --git a/scribo/demo/viewer/help_dialog.hh b/scribo/demo/viewer/help_dialog.hh
index 114d8f5..2b4adcf 100644
--- a/scribo/demo/viewer/help_dialog.hh
+++ b/scribo/demo/viewer/help_dialog.hh
@@ -1,16 +1,27 @@
+// 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.
#ifndef HELP_DIALOG_HH_
# define HELP_DIALOG_HH_
diff --git a/scribo/demo/viewer/image_region.cc b/scribo/demo/viewer/image_region.cc
index 78b636c..037ed56 100644
--- a/scribo/demo/viewer/image_region.cc
+++ b/scribo/demo/viewer/image_region.cc
@@ -1,16 +1,27 @@
+// 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 "image_region.hh"
diff --git a/scribo/demo/viewer/image_region.hh b/scribo/demo/viewer/image_region.hh
index be1003d..a492b44 100644
--- a/scribo/demo/viewer/image_region.hh
+++ b/scribo/demo/viewer/image_region.hh
@@ -1,16 +1,27 @@
+// 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.
#ifndef IMAGE_REGION_HH_
# define IMAGE_REGION_HH_
diff --git a/scribo/demo/viewer/image_scene.cc b/scribo/demo/viewer/image_scene.cc
index dd9d67e..850647f 100644
--- a/scribo/demo/viewer/image_scene.cc
+++ b/scribo/demo/viewer/image_scene.cc
@@ -1,16 +1,27 @@
+// 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 "image_scene.hh"
#include "image_region.hh"
diff --git a/scribo/demo/viewer/image_scene.hh b/scribo/demo/viewer/image_scene.hh
index 6fb2c1f..4c417b0 100644
--- a/scribo/demo/viewer/image_scene.hh
+++ b/scribo/demo/viewer/image_scene.hh
@@ -1,17 +1,28 @@
+// 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.
#ifndef IMAGE_SCENE_HH_
# define IMAGE_SCENE_HH_
diff --git a/scribo/demo/viewer/image_view.cc b/scribo/demo/viewer/image_view.cc
index 9182c1b..05a85e8 100644
--- a/scribo/demo/viewer/image_view.cc
+++ b/scribo/demo/viewer/image_view.cc
@@ -1,16 +1,27 @@
+// 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 "image_view.hh"
diff --git a/scribo/demo/viewer/image_view.hh b/scribo/demo/viewer/image_view.hh
index 84f722f..ab48a36 100644
--- a/scribo/demo/viewer/image_view.hh
+++ b/scribo/demo/viewer/image_view.hh
@@ -1,16 +1,27 @@
+// 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.
#ifndef IMAGE_VIEW_HH_
# define IMAGE_VIEW_HH_
diff --git a/scribo/demo/viewer/image_widget.cc b/scribo/demo/viewer/image_widget.cc
index b4bee72..3e3f241 100644
--- a/scribo/demo/viewer/image_widget.cc
+++ b/scribo/demo/viewer/image_widget.cc
@@ -1,16 +1,27 @@
+// 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 "image_widget.hh"
#include "image_view.hh"
diff --git a/scribo/demo/viewer/image_widget.hh b/scribo/demo/viewer/image_widget.hh
index 87259b0..a3f51e4 100644
--- a/scribo/demo/viewer/image_widget.hh
+++ b/scribo/demo/viewer/image_widget.hh
@@ -1,16 +1,27 @@
+// 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.
#ifndef IMAGE_WIDGET_HH_
# define IMAGE_WIDGET_HH_
diff --git a/scribo/demo/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc
index 171c811..44839c5 100644
--- a/scribo/demo/viewer/key_widget.cc
+++ b/scribo/demo/viewer/key_widget.cc
@@ -1,16 +1,27 @@
+// 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 "key_widget.hh"
#include "common.hh"
diff --git a/scribo/demo/viewer/key_widget.hh b/scribo/demo/viewer/key_widget.hh
index d7767b0..113835d 100644
--- a/scribo/demo/viewer/key_widget.hh
+++ b/scribo/demo/viewer/key_widget.hh
@@ -1,16 +1,27 @@
+// 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.
#ifndef KEY_WIDGET_HH_
# define KEY_WIDGET_HH_
diff --git a/scribo/demo/viewer/main.cc b/scribo/demo/viewer/main.cc
index 640ea0f..b55ad84 100644
--- a/scribo/demo/viewer/main.cc
+++ b/scribo/demo/viewer/main.cc
@@ -1,16 +1,27 @@
+// 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 <QtGui>
#include <iostream>
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
index f93177e..10c1a43 100644
--- a/scribo/demo/viewer/viewer.cc
+++ b/scribo/demo/viewer/viewer.cc
@@ -185,11 +185,11 @@ Viewer::Viewer(int &argc, char** argv)
win_->setCentralWidget(h_splitter);
QList<int> v_sizes;
- v_sizes << 200 << 300 << 300;
+ v_sizes << 200 << 250 << 350;
v_splitter->setSizes(v_sizes);
QList<int> v_sizes2;
- v_sizes2 << 650 << 150;
+ v_sizes2 << 725 << 175;
v_splitter2->setSizes(v_sizes2);
QList<int> h_sizes;
diff --git a/scribo/demo/viewer/viewer.hh b/scribo/demo/viewer/viewer.hh
index 800bdd5..b1f406d 100644
--- a/scribo/demo/viewer/viewer.hh
+++ b/scribo/demo/viewer/viewer.hh
@@ -1,16 +1,27 @@
+// 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.
#ifndef VIEWER_HH_
# define VIEWER_HH_
diff --git a/scribo/demo/viewer/viewer.hxx b/scribo/demo/viewer/viewer.hxx
index 72ee1f2..b72eaff 100644
--- a/scribo/demo/viewer/viewer.hxx
+++ b/scribo/demo/viewer/viewer.hxx
@@ -1,16 +1,27 @@
+// 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.
#ifndef VIEWER_HXX_
# define VIEWER_HXX_
diff --git a/scribo/demo/viewer/xml_widget.cc b/scribo/demo/viewer/xml_widget.cc
index a4ef2f6..2d10bd7 100644
--- a/scribo/demo/viewer/xml_widget.cc
+++ b/scribo/demo/viewer/xml_widget.cc
@@ -1,16 +1,27 @@
+// 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 "xml_widget.hh"
@@ -128,6 +139,13 @@ void XmlWidget::NFS(QDomNode node, QTreeWidgetItem* item)
{
if (!sibling.toElement().tagName().contains("data"))
NFS(sibling, child);
+ else
+ {
+ QTreeWidgetItem* child_son =
+ new QTreeWidgetItem(QStringList("data = base64-encoded"));
+
+ child->addChild(child_son);
+ }
sibling = sibling.nextSibling();
}
}
diff --git a/scribo/demo/viewer/xml_widget.hh b/scribo/demo/viewer/xml_widget.hh
index c56a736..b80835b 100644
--- a/scribo/demo/viewer/xml_widget.hh
+++ b/scribo/demo/viewer/xml_widget.hh
@@ -1,16 +1,27 @@
+// 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.
#ifndef XML_WIDGET_HH_
# define XML_WIDGET_HH_
--
1.5.6.5
1
0

16 Nov '10
* scribo/demo/viewer/viewer.cc
---
scribo/ChangeLog | 52 +++++++++++++++++++++++------------------
scribo/demo/viewer/viewer.cc | 5 +---
2 files changed, 30 insertions(+), 27 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 0d78dc7..da06873 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.
+ * 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.
- * demo/viewer/Makefile.am
+ * scribo/demo/viewer/Makefile.am
- * demo/viewer/browser_widget.cc: Fix, xmlc extension instead of xmle.
+ * scribo/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.
+ * 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.
- * demo/viewer/viewer.cc,
- * demo/viewer/viewer.hh: Add base 64 cropped pictures support, text viewer
+ * 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

16 Nov '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 | 5 +-
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, 545 insertions(+), 844 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 1c9bdbd..0d78dc7 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 eec19b9..d0f0d6f 100644
--- a/scribo/demo/viewer/Makefile.am
+++ b/scribo/demo/viewer/Makefile.am
@@ -14,6 +14,7 @@
include $(top_srcdir)/build-aux/autotroll.mk
+
bin_PROGRAMS = scribo-viewer
scribo_viewer_SOURCES = $(BUILT_SOURCES) \
viewer.cc \
@@ -40,16 +41,14 @@ 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
+
noinst_HEADERS = viewer.hh \
viewer.hxx \
image_widget.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

last-svn-commit-563-g6d0a92e Base 64 support in Qt interface (xmlc extension)
by Arthur Crepin-Leblond 16 Nov '10
by Arthur Crepin-Leblond 16 Nov '10
16 Nov '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 | 38 +++++++++++------
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, 137 insertions(+), 66 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index f2b8e4a..1c9bdbd 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,29 +1,41 @@
2010-07-16 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+ Base 64 support in Qt interface (xmlc extension)
+
+ * demo/viewer/step_widget.cc
+ * demo/viewer/step_widget.hh
+ * demo/viewer/browser_widget.cc,
+ * demo/viewer/browser_widget.hh: Add .xmlc extension.
+
+ * demo/viewer/image_scene.cc
+ * demo/viewer/viewer.cc,
+ * 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
- XML step.
+ * 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
- disabled/enabled in groups.
+ * 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.
- picture is chosen.
+ * 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.
-
2010-07-16 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
ChangeLog mistake.
- * scribo/ChangeLog: Move 2010-07-08 entry in...
- * scribo/sandbox/ChangeLog:...this.
+ * ChangeLog: Move 2010-07-08 entry in...
+ * sandbox/ChangeLog:...this.
2010-06-30 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
@@ -78,12 +90,12 @@
Small fix in Qt interface.
- * scribo/demo/viewer/viewer.cc,
- * scribo/demo/viewer/image_region.hxx: Disable item click if
+ * demo/viewer/viewer.cc,
+ * demo/viewer/image_region.hxx: Disable item click if
unchecked in item list.
- * scribo/demo/viewer/key_widget.cc,
- * scribo/demo/viewer/key_widget.hh: Add KeyWidget::checkAll.
+ * demo/viewer/key_widget.cc,
+ * demo/viewer/key_widget.hh: Add KeyWidget::checkAll.
2010-08-27 Guillaume Lazzara <z(a)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 Nov '10
* demo/viewer/browser_widget.cc,
* 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
disabled/enabled in groups.
* demo/viewer/step_widget.cc,
* 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/ChangeLog | 20 ++++++
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 +-
9 files changed, 213 insertions(+), 65 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index fb8a48b..f2b8e4a 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,5 +1,25 @@
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
+ XML step.
+
+ * demo/viewer/key_widget.cc,
+ * 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.
+ picture is chosen.
+
+ * demo/viewer/viewer.cc,
+ * demo/viewer/xml_widget.cc: Layout adjustement.
+
+
+2010-07-16 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+
ChangeLog mistake.
* scribo/ChangeLog: Move 2010-07-08 entry in...
diff --git a/scribo/demo/viewer/browser_widget.cc b/scribo/demo/viewer/browser_widget.cc
index d69fea0..bd70648 100644
--- a/scribo/demo/viewer/browser_widget.cc
+++ b/scribo/demo/viewer/browser_widget.cc
@@ -17,16 +17,28 @@
BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
: files_(files),
view_(new QListView()),
- path_(new QLineEdit(""))
+ path_(new QLineEdit("")),
+ first_time_(true)
{
+ QToolButton* next= new QToolButton();
+ QToolButton* prev= new QToolButton();
+ next->setArrowType(Qt::RightArrow);
+ prev->setArrowType(Qt::LeftArrow);
+
QLabel* title = new QLabel(tr("Images"));
title->setAlignment(Qt::AlignHCenter);
QVBoxLayout* layout = new QVBoxLayout;
- layout->addWidget(title);
+ QHBoxLayout *hlayout = new QHBoxLayout;
+
+ hlayout->addWidget(prev);
+ hlayout->addWidget(title);
+ hlayout->addWidget(next);
+ layout->addLayout(hlayout);
layout->addWidget(path_);
layout->addWidget(view_);
+ //setLayout(hlayout);
setLayout(layout);
view_->setModel(files);
@@ -34,19 +46,28 @@ BrowserWidget::BrowserWidget(QDirModel* files, QString dir)
| QDir::Readable | QDir::Drives);
view_->setRootIndex(files->index(QDir::currentPath()));
+
QDir d(dir);
if (d.isReadable())
view_->setRootIndex(files->index(d.absolutePath()));
+
view_->setRowHidden(0, true);
+
path_->setText(files->filePath(view_->rootIndex()));
+
connect(view_, SIGNAL(activated(const QModelIndex&)),
this, SLOT(activate(const QModelIndex&)));
+ connect(next, SIGNAL(released ()),
+ this, SLOT(next()));
+ connect(prev, SIGNAL(released ()),
+ this, SLOT(prev()));
connect(path_, SIGNAL(returnPressed()),
this, SLOT(path_return_pressed()));
QStringList files_filters;
files_filters << "*.png" << "*.jpg"
- << "*.tif" << "*.ppm" << "*.pgm" << "*.pbm";
+ << "*.tif" << "*.ppm" << "*.pgm" << "*.pbm" << "pnm";
+
files->setNameFilters(files_filters);
}
@@ -57,20 +78,43 @@ BrowserWidget::path_return_pressed()
QDir d(path);
if (d.isReadable())
- activate(files_->index(QString(path)));
+ activate(files_->index(QString(path)), false);
}
void
-BrowserWidget::activate(const QModelIndex& index)
+BrowserWidget::activate(const QModelIndex& index, bool b)
{
if (files_->isDir(index))
{
view_->setRootIndex(index);
view_->setRowHidden(0, true);
path_->setText(files_->filePath(view_->rootIndex()));
+ first_time_ = true;
return;
}
- emit activated(files_->filePath(index));
+
+ first_time_ = false;
+
+ emit activated(files_->filePath(index), b);
+}
+
+void
+BrowserWidget::change_pos(bool next)
+{
+ QModelIndex index = view_->currentIndex();
+
+ if(next)
+ index = files_->index(index.row() + 1, index.column(), index.parent());
+ else
+ index = files_->index(index.row() - 1, index.column(), index.parent());
+
+ if (index.isValid())
+ {
+ if (!files_->isDir(index))
+ if (!first_time_)
+ activate(index, true);
+ view_->setCurrentIndex(index);
+ }
}
BrowserWidget::~BrowserWidget()
diff --git a/scribo/demo/viewer/browser_widget.hh b/scribo/demo/viewer/browser_widget.hh
index 23930cd..a0fbe43 100644
--- a/scribo/demo/viewer/browser_widget.hh
+++ b/scribo/demo/viewer/browser_widget.hh
@@ -27,16 +27,20 @@ public:
~BrowserWidget();
public slots:
- void activate(const QModelIndex& index);
+ void activate(const QModelIndex& index, bool b = false);
void path_return_pressed();
+ void next() { change_pos(true); }
+ void prev() { change_pos(false); }
signals:
- void activated(QString filename);
+ void activated(QString filename, bool b);
private:
+ void change_pos(bool next);
QDirModel* files_;
QListView* view_;
QLineEdit* path_;
+ bool first_time_;
};
#endif /* !BROWSER_WIDGET_HH_ */
diff --git a/scribo/demo/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc
index 5e371ab..47203c3 100644
--- a/scribo/demo/viewer/key_widget.cc
+++ b/scribo/demo/viewer/key_widget.cc
@@ -16,82 +16,127 @@
#include "common.hh"
KeyWidget::KeyWidget(const region::KeyMap& key_map)
- : items_(new QListWidget())
+ : items_(new QTreeWidget()),
+ text_(new QTreeWidgetItem(QStringList("Text"))),
+ regions_(new QTreeWidgetItem(QStringList("Regions")))
{
QLabel* title = new QLabel(tr("Key"));
title->setAlignment(Qt::AlignHCenter);
+ items_->addTopLevelItem(text_);
+ items_->addTopLevelItem(regions_);
+ items_->setHeaderHidden(true);
+
+ text_->setCheckState(0, Qt::Checked);
+ regions_->setCheckState(0, Qt::Checked);
+ regions_->setExpanded(true);
+ text_->setExpanded(true);
+
+ for (int i = 0; i < 3; ++i)
+ add_item_(key_map.at(i).first, key_map.at(i).second,
+ i == region::Line ||
+ i == region::Paragraph, text_);
+
+ for (int i = 3; i < key_map.size(); ++i)
+ add_item_(key_map.at(i).first, key_map.at(i).second, false, regions_);
+
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(title);
layout->addWidget(items_);
- for (int i = 0; i < key_map.size(); ++i)
- add_item_(key_map[i].first, key_map[i].second,
- (i == region::Paragraph) ||
- (i == region::Line) );
-
setLayout(layout);
- connect(items_, SIGNAL(itemChanged(QListWidgetItem*)),
- this, SLOT(update(QListWidgetItem*)));
+ connect(items_, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
+ this, SLOT(update(QTreeWidgetItem*)));
+}
+
+void KeyWidget::update_all()
+{
+ for (int i = 0; i < text_->childCount(); ++i)
+ update(text_->child(i));
+
+ for (int i = 0; i < regions_->childCount(); ++i)
+ update(regions_->child(i));
}
-void KeyWidget::checkAll()
+void KeyWidget::setAllCheck(QTreeWidgetItem* parent)
{
- for (int i = 0; i < items_->count(); ++i)
+ for (int i = 0; i < parent->childCount(); ++i)
{
- items_->item(i)->setCheckState(Qt::Checked);
- emit updated(i, true);
+ if (parent->checkState(0) == Qt::Checked)
+ parent->child(i)->setCheckState(0, Qt::Checked);
+ else
+ parent->child(i)->setCheckState(0, Qt::Unchecked);
+ update(parent->child(i));
}
}
-void
+void
KeyWidget::change_mode(bool b)
{
int id_region = region::Paragraph;
int id_line = region::Line;
+
if (b)
{
- items_->item(id_region)->setCheckState(Qt::Checked);
- items_->item(id_region)->setHidden(false);
- items_->item(id_line)->setCheckState(Qt::Checked);
- items_->item(id_line)->setHidden(false);
+ text_->child(id_region)->setCheckState(0, Qt::Checked);
+ text_->child(id_region)->setHidden(false);
+ text_->child(id_line)->setCheckState(0, Qt::Checked);
+ text_->child(id_line)->setHidden(false);
}
else
{
- items_->item(id_region)->setCheckState(Qt::Unchecked);
- items_->item(id_region)->setHidden(true);
- items_->item(id_line)->setCheckState(Qt::Unchecked);
- items_->item(id_line)->setHidden(true);
+ text_->child(id_region)->setCheckState(0, Qt::Unchecked);
+ text_->child(id_region)->setHidden(true);
+ text_->child(id_line)->setCheckState(0, Qt::Unchecked);
+ text_->child(id_line)->setHidden(true);
}
}
void
-KeyWidget::add_item_(QString text, QColor color, bool b)
+KeyWidget::add_item_(QString text, QColor color, bool b, QTreeWidgetItem* parent)
{
- QListWidgetItem* item = new QListWidgetItem(text);
+ QTreeWidgetItem* item = new QTreeWidgetItem(QStringList(text));
QPixmap pixmap(10, 6);
+
pixmap.fill(color);
- item->setIcon(QIcon(pixmap));
- item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
- item->setCheckState(Qt::Checked);
- items_->addItem(item);
- int id = items_->row(item);
- items_->item(id)->setHidden(b);
+ item->setIcon(0, QIcon(pixmap));
+ item->setCheckState(0, Qt::Checked);
+ parent->addChild(item);
+ item->setHidden(b);
}
-bool
+ bool
KeyWidget::isChecked(region::RegionId id)
{
- return items_->item(id)->checkState() == Qt::Checked;
+ QTreeWidgetItem* item = text_->child(id);
+ if (item)
+ return item->checkState(0) == Qt::Checked;
+ else
+ {
+ item = regions_->child(id);
+ if(item)
+ return item->checkState(0) == Qt::Checked;
+ else
+ return false;
+ }
}
void
-KeyWidget::update(QListWidgetItem* item)
+KeyWidget::update(QTreeWidgetItem* item)
{
- int id = items_->row(item);
+ int id;
+ id = text_->indexOfChild(item);
+ if (id == -1)
+ id = regions_->indexOfChild(item) + 3;
+
+ emit updated(id, item->checkState(0) == Qt::Checked);
- emit updated(id, item->checkState() == Qt::Checked);
+ if (item == text_ || item == regions_)
+ {
+ setAllCheck(item);
+ return;
+ }
}
KeyWidget::~KeyWidget()
diff --git a/scribo/demo/viewer/key_widget.hh b/scribo/demo/viewer/key_widget.hh
index 71200c8..d7767b0 100644
--- a/scribo/demo/viewer/key_widget.hh
+++ b/scribo/demo/viewer/key_widget.hh
@@ -27,20 +27,24 @@ public:
KeyWidget(const region::KeyMap& key_map);
~KeyWidget();
- void checkAll();
bool isChecked(region::RegionId id);
+ QTreeWidget* items() { return items_; };
+ void update_all();
signals:
void updated(int key, bool checked);
private slots:
- void update(QListWidgetItem* slot);
void change_mode(bool b);
+ void update(QTreeWidgetItem* item);
+ void setAllCheck(QTreeWidgetItem* parent);
private:
- void add_item_(QString text, QColor color, bool b);
+ void add_item_(QString text, QColor color, bool b, QTreeWidgetItem* parent);
- QListWidget* items_;
+ QTreeWidget* items_;
+ QTreeWidgetItem* text_;
+ QTreeWidgetItem* regions_;
};
#endif /* !KEY_WIDGET_HH_ */
diff --git a/scribo/demo/viewer/step_widget.cc b/scribo/demo/viewer/step_widget.cc
index 7d35543..1020c6a 100644
--- a/scribo/demo/viewer/step_widget.cc
+++ b/scribo/demo/viewer/step_widget.cc
@@ -26,7 +26,8 @@
# include "step_widget.hh"
StepWidget::StepWidget()
- : view_(new QListWidget())
+ : view_(new QListWidget()),
+ step_(QString::Null())
{
QLabel* title = new QLabel(tr("Steps"));
title->setAlignment(Qt::AlignHCenter);
@@ -42,6 +43,9 @@ StepWidget::StepWidget()
connect(view_, SIGNAL(itemActivated(QListWidgetItem*)),
this, SLOT(activate(QListWidgetItem*)));
+
+ connect(this, SIGNAL(activated(QListWidgetItem*)),
+ this, SLOT(activate(QListWidgetItem*)));
}
void StepWidget::activate(QListWidgetItem* item)
@@ -49,18 +53,22 @@ void StepWidget::activate(QListWidgetItem* item)
QString key, value;
StepQMap::iterator iter = map_.find(item->text());
-
+
+ view_->setCurrentItem(item);
if (iter != map_.end())
{
+ step_ = item->text();
key = iter.key();
value = iter.value();
+
+ emit load_xml(value);
}
-
- emit load_xml(value);
+ else
+ qDebug() << "Step not found!";
}
-void StepWidget::fill_steps(QString file)
+void StepWidget::fill_steps(QString file, bool step)
{
view_->clear();
map_.clear();
@@ -69,13 +77,14 @@ void StepWidget::fill_steps(QString file)
emit load_image(file);
int cut = file.lastIndexOf(QChar('/'));
- QString path = file.left(cut+1);
+ QString path = file.left(cut+1);
QString filename = file.mid(cut+1);
-
+
cut = filename.lastIndexOf(QChar('.'));
+
QString file_with_no_ext = filename.left(cut);
// view_->addItem(file_with_no_ext);
-
+
QDir dir(path);
if (dir.isReadable())
@@ -84,7 +93,7 @@ void StepWidget::fill_steps(QString file)
filter << "*.xml";
QStringList xml_list = dir.entryList(filter);
for (int i = 0; i < xml_list.size(); ++i)
- {
+ {
if (xml_list.at(i).startsWith(file_with_no_ext))
{
cut = xml_list.at(i).lastIndexOf(QChar('.'));
@@ -99,6 +108,17 @@ void StepWidget::fill_steps(QString file)
}
}
}
+
+
+ if (step && step_ != QString::Null())
+ {
+ QList<QListWidgetItem*> list = view_->findItems(step_, Qt::MatchContains);
+
+ if (!list.isEmpty())
+ emit activated(list.first());
+ }
+ 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 829f814..928e503 100644
--- a/scribo/demo/viewer/step_widget.hh
+++ b/scribo/demo/viewer/step_widget.hh
@@ -44,14 +44,16 @@ public:
signals:
void load_image(QString);
void load_xml(QString);
+ void activated(QListWidgetItem*);
public slots:
- void fill_steps(QString file);
+ void fill_steps(QString file, bool = false);
void activate(QListWidgetItem* item);
private:
QListWidget* view_;
StepQMap map_;
+ QString step_;
};
#endif /* !STEP_WIDGET_HH_ */
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
index 61a57c1..b3fd6f5 100644
--- a/scribo/demo/viewer/viewer.cc
+++ b/scribo/demo/viewer/viewer.cc
@@ -44,6 +44,7 @@ Viewer::Viewer(int &argc, char** argv)
key_map_[region::Text] = qMakePair(tr("Text Region"), QColor(0, 200, 0));
key_map_[region::Paragraph] = qMakePair(tr("Paragraph"), QColor(0, 0, 255));
key_map_[region::Line] = qMakePair(tr("Text line"), QColor(255, 0, 0));
+
key_map_[region::Image] = qMakePair(tr("Image"), QColor(255, 120, 0));
key_map_[region::Noise] = qMakePair(tr("Noise"), QColor(43, 39, 128));
key_map_[region::Separator] = qMakePair(tr("Separator"), QColor(0, 0, 255));
@@ -70,7 +71,7 @@ Viewer::Viewer(int &argc, char** argv)
// Layout
- win_->resize(1024, 768);
+ win_->resize(1152, 864);
win_->statusBar();
QMenu* file_menu = win_->menuBar()->addMenu(tr("File"));
@@ -157,7 +158,7 @@ Viewer::Viewer(int &argc, char** argv)
win_->setCentralWidget(h_splitter);
QList<int> v_sizes;
- v_sizes << 300 << 200 << 200 << 300;
+ v_sizes << 200 << 200 << 300 << 400;
v_splitter->setSizes(v_sizes);
QList<int> v_sizes2;
@@ -168,8 +169,8 @@ Viewer::Viewer(int &argc, char** argv)
h_sizes << 200 << 700;
h_splitter->setSizes(h_sizes);
- connect(browser_wgt, SIGNAL(activated(QString)),
- step_widget, SLOT(fill_steps(QString)));
+ connect(browser_wgt, SIGNAL(activated(QString, bool)),
+ step_widget, SLOT(fill_steps(QString, bool)));
connect(step_widget, SIGNAL(load_image(QString)),
this, SLOT(load(QString)));
@@ -252,6 +253,11 @@ Viewer::load_xml(QString filename)
void
Viewer::xml_to_layout()
{
+
+ /* /!\ XML parsing is VERY UGLY /!\
+ TO DO: use same parsing as xml_transfrom. */
+
+
// Add layout info to the scene.
if (doc_layout_)
{
@@ -284,6 +290,7 @@ Viewer::xml_to_layout()
doc_layout_->data(point, Qt::UserRole).toMap();
int x = data["x"].toInt();
int y = data["y"].toInt();
+
points << QPoint(x, y);
}
@@ -396,8 +403,8 @@ Viewer::xml_to_layout()
attributes_line, points_line,
outline_action_->isChecked(),
fill_action_->isChecked(),
- precise_action_->isChecked(),
- key_wgt_->isChecked(id_line));
+ precise_action_->isChecked(),
+ key_wgt_->isChecked(id_line));
connect(this, SIGNAL(key_updated(int, bool)),
r_line, SLOT(setDrawIfSameId(int, bool)));
@@ -417,6 +424,7 @@ Viewer::xml_to_layout()
}
emit updated(doc_layout_);
+ key_wgt_->update_all();
}
}
@@ -427,7 +435,7 @@ Viewer::load(QString filename)
scene_->clear();
scene_->update();
image_ = 0;
- xml_file_ = "";
+ // 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.
@@ -482,7 +490,7 @@ Viewer::maybeChangeCacheMode(qreal scale)
void Viewer::useExtended(bool b)
{
extended_mode_ = b;
- key_wgt_->checkAll();
+ key_wgt_->update_all();
if (xml_file_ != QString(""))
load_xml(xml_file_);
diff --git a/scribo/demo/viewer/xml_widget.cc b/scribo/demo/viewer/xml_widget.cc
index fa050ec..36f0406 100644
--- a/scribo/demo/viewer/xml_widget.cc
+++ b/scribo/demo/viewer/xml_widget.cc
@@ -24,6 +24,7 @@ XmlWidget::XmlWidget()
title->setAlignment(Qt::AlignHCenter);
QVBoxLayout* layout = new QVBoxLayout;
+
layout->addWidget(title);
layout->addWidget(view_);
@@ -34,7 +35,7 @@ void
XmlWidget::update(DomModel* model)
{
view_->setModel(model);
- view_->resizeColumnToContents(2);
+ // view_->resizeColumnToContents(2);
}
void
--
1.5.6.5
1
0
* scribo/ChangeLog: Move 2010-07-08 entry in...
* scribo/sandbox/ChangeLog:...this.
---
scribo/ChangeLog | 44 +++----------------------
scribo/sandbox/ChangeLog | 80 ++++++++++++++++++++++++++++++++++------------
2 files changed, 65 insertions(+), 59 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index e58af8d..fb8a48b 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,41 +1,9 @@
-2010-07-08 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
-
- XML transform program.
-
- * sandbox/arthur/xml_to_html/xml_to_html.hh,
- * sandbox/arthur/xml_to_html/xml_to_html.cc,
- * sandbox/arthur/xml_to_html/xml_to_html.pro: Remove.
-
- * sandbox/arthur/xml_to_html/README,
- * sandbox/arthur/xml_to_html/main.cc,
- * sandbox/arthur/xml_to_html/domitem.cc,
- * sandbox/arthur/xml_to_html/domitem.hh,
- * sandbox/arthur/xml_to_html/dommodel.cc,
- * sandbox/arthur/xml_to_html/dommodel.hh: Move to...
-
- * sandbox/arthur/xml_transform/README,
- * sandbox/arthur/xml_transform/main.cc,
- * sandbox/arthur/xml_transform/domitem.cc,
- * sandbox/arthur/xml_transform/domitem.hh,
- * sandbox/arthur/xml_transform/dommodel.cc,
- * sandbox/arthur/xml_transform/dommodel.hh: ...this.
-
- * sandbox/arthur/xml_to_html/patterns/css.css,
- * sandbox/arthur/xml_to_html/patterns/xsl.xsl: Move to...
-
- * sandbox/arthur/xml_transform/templates/html/css.css,
- * sandbox/arthur/xml_transform/templates/html/xsl.xsl: ...this.
-
- * sandbox/arthur/xml_transform/image_crop.cc,
- * sandbox/arthur/xml_transform/loader.cc: New.
-
- * sandbox/arthur/xml_transform/templates/html/html_generator.sh,
- * sandbox/arthur/xml_transform/templates/pdf/line.xsl,
- * sandbox/arthur/xml_transform/templates/pdf/main.xsl,
- * sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl,
- * sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh,
- * sandbox/arthur/xml_transform/templates/pdf/regions.xsl,
- * sandbox/arthur/xml_transform/xml_transform.pro: New.
+2010-07-16 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+
+ ChangeLog mistake.
+
+ * scribo/ChangeLog: Move 2010-07-08 entry in...
+ * scribo/sandbox/ChangeLog:...this.
2010-06-30 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
diff --git a/scribo/sandbox/ChangeLog b/scribo/sandbox/ChangeLog
index 0fb733f..8d7b3e9 100644
--- a/scribo/sandbox/ChangeLog
+++ b/scribo/sandbox/ChangeLog
@@ -2,34 +2,72 @@
XML Tranform.
- * scribo/sandbox/arthur/xml_transform/xml_transform.cc,
- * scribo/sandbox/arthur/xml_transform/xml_transform.hh: Facade.
+ * arthur/xml_transform/xml_transform.cc,
+ * arthur/xml_transform/xml_transform.hh: Facade.
- * scribo/sandbox/arthur/xml_transform/image_crop.cc,
- * scribo/sandbox/arthur/xml_transform/image_crop.hh: Image process.
+ * arthur/xml_transform/image_crop.cc,
+ * arthur/xml_transform/image_crop.hh: Image process.
- * scribo/sandbox/arthur/xml_transform/loader.cc,
- * scribo/sandbox/arthur/xml_transform/loader.hh: XML loader.
+ * arthur/xml_transform/loader.cc,
+ * arthur/xml_transform/loader.hh: XML loader.
- * scribo/sandbox/arthur/xml_transform/main.cc
- * scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
- * scribo/sandbox/arthur/xml_transform/xml_transform.pro
- * scribo/sandbox/arthur/xml_transform/README
+ * arthur/xml_transform/main.cc
+ * arthur/xml_transform/templates/html/xsl.xsl
+ * arthur/xml_transform/xml_transform.pro
+ * arthur/xml_transform/README
- * scribo/sandbox/arthur/xml_transform/common.cc,
- * scribo/sandbox/arthur/xml_transform/common.hh,
- * scribo/sandbox/arthur/xml_transform/templates/html/xsl_base64.xsl,
- * scribo/sandbox/arthur/xml_transform/templates/pdf/main64.xsl,
- * scribo/sandbox/arthur/xml_transform/templates/pdf/regions_base64.xsl: New.
+ * arthur/xml_transform/common.cc,
+ * arthur/xml_transform/common.hh,
+ * arthur/xml_transform/templates/html/xsl_base64.xsl,
+ * arthur/xml_transform/templates/pdf/main64.xsl,
+ * arthur/xml_transform/templates/pdf/regions_base64.xsl: New.
- * scribo/sandbox/arthur/xml_transform/domitem.cc,
- * scribo/sandbox/arthur/xml_transform/domitem.hh,
- * scribo/sandbox/arthur/xml_transform/dommodel.cc,
- * scribo/sandbox/arthur/xml_transform/dommodel.hh: Delete.
+ * arthur/xml_transform/domitem.cc,
+ * arthur/xml_transform/domitem.hh,
+ * arthur/xml_transform/dommodel.cc,
+ * arthur/xml_transform/dommodel.hh: Delete.
- * scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl: Rename as...
- * scribo/sandbox/arthur/xml_transform/templates/pdf/regions_png.xsl:...this.
+ * arthur/xml_transform/templates/pdf/regions.xsl: Rename as...
+ * arthur/xml_transform/templates/pdf/regions_png.xsl:...this.
+2010-07-08 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+
+ XML transform program.
+
+ * arthur/xml_to_html/xml_to_html.hh,
+ * arthur/xml_to_html/xml_to_html.cc,
+ * arthur/xml_to_html/xml_to_html.pro: Remove.
+
+ * arthur/xml_to_html/README,
+ * arthur/xml_to_html/main.cc,
+ * arthur/xml_to_html/domitem.cc,
+ * arthur/xml_to_html/domitem.hh,
+ * arthur/xml_to_html/dommodel.cc,
+ * arthur/xml_to_html/dommodel.hh: Move to...
+
+ * arthur/xml_transform/README,
+ * arthur/xml_transform/main.cc,
+ * arthur/xml_transform/domitem.cc,
+ * arthur/xml_transform/domitem.hh,
+ * arthur/xml_transform/dommodel.cc,
+ * arthur/xml_transform/dommodel.hh: ...this.
+
+ * arthur/xml_to_html/patterns/css.css,
+ * arthur/xml_to_html/patterns/xsl.xsl: Move to...
+
+ * arthur/xml_transform/templates/html/css.css,
+ * arthur/xml_transform/templates/html/xsl.xsl: ...this.
+
+ * arthur/xml_transform/image_crop.cc,
+ * arthur/xml_transform/loader.cc: New.
+
+ * arthur/xml_transform/templates/html/html_generator.sh,
+ * arthur/xml_transform/templates/pdf/line.xsl,
+ * arthur/xml_transform/templates/pdf/main.xsl,
+ * arthur/xml_transform/templates/pdf/main_crop.xsl,
+ * arthur/xml_transform/templates/pdf/pdf_generator.sh,
+ * arthur/xml_transform/templates/pdf/regions.xsl,
+ * arthur/xml_transform/xml_transform.pro: New.
2010-07-05 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
--
1.5.6.5
1
0
* scribo/sandbox/arthur/xml_transform/xml_transform.cc,
* scribo/sandbox/arthur/xml_transform/xml_transform.hh: Facade.
* scribo/sandbox/arthur/xml_transform/image_crop.cc,
* scribo/sandbox/arthur/xml_transform/image_crop.hh: Image process.
* scribo/sandbox/arthur/xml_transform/loader.cc,
* scribo/sandbox/arthur/xml_transform/loader.hh: XML loader.
* scribo/sandbox/arthur/xml_transform/main.cc
* scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
* scribo/sandbox/arthur/xml_transform/xml_transform.pro
* scribo/sandbox/arthur/xml_transform/README
* scribo/sandbox/arthur/xml_transform/common.cc,
* scribo/sandbox/arthur/xml_transform/common.hh,
* scribo/sandbox/arthur/xml_transform/moc_dommodel.cpp,
* scribo/sandbox/arthur/xml_transform/templates/html/xsl_base64.xsl,
* scribo/sandbox/arthur/xml_transform/templates/pdf/main64.xsl,
* scribo/sandbox/arthur/xml_transform/templates/pdf/regions_base64.xsl: New.
* scribo/sandbox/arthur/xml_transform/domitem.cc,
* scribo/sandbox/arthur/xml_transform/domitem.hh,
* scribo/sandbox/arthur/xml_transform/dommodel.cc,
* scribo/sandbox/arthur/xml_transform/dommodel.hh: Delete.
* scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl: Rename as...
* scribo/sandbox/arthur/xml_transform/templates/pdf/regions_png.xsl:...this.
---
scribo/sandbox/ChangeLog | 33 +++
scribo/sandbox/arthur/xml_transform/README | 25 +-
scribo/sandbox/arthur/xml_transform/common.cc | 13 +
scribo/sandbox/arthur/xml_transform/common.hh | 16 +
scribo/sandbox/arthur/xml_transform/domitem.cc | 98 -------
scribo/sandbox/arthur/xml_transform/domitem.hh | 75 -----
scribo/sandbox/arthur/xml_transform/dommodel.cc | 198 -------------
scribo/sandbox/arthur/xml_transform/dommodel.hh | 85 ------
scribo/sandbox/arthur/xml_transform/image_crop.cc | 303 ++++++++++++++------
scribo/sandbox/arthur/xml_transform/image_crop.hh | 19 +-
scribo/sandbox/arthur/xml_transform/loader.cc | 124 +++++----
scribo/sandbox/arthur/xml_transform/loader.hh | 17 +-
scribo/sandbox/arthur/xml_transform/main.cc | 78 +++++-
.../arthur/xml_transform/templates/html/xsl.xsl | 3 +-
.../templates/html/{xsl.xsl => xsl_base64.xsl} | 9 +-
.../templates/pdf/{main.xsl => main64.xsl} | 2 +-
.../pdf/{regions.xsl => regions_base64.xsl} | 6 +-
.../templates/pdf/{regions.xsl => regions_png.xsl} | 0
.../sandbox/arthur/xml_transform/xml_transform.cc | 113 +++++---
.../sandbox/arthur/xml_transform/xml_transform.hh | 20 +-
.../sandbox/arthur/xml_transform/xml_transform.pro | 12 +-
21 files changed, 564 insertions(+), 685 deletions(-)
create mode 100644 scribo/sandbox/arthur/xml_transform/common.cc
create mode 100644 scribo/sandbox/arthur/xml_transform/common.hh
delete mode 100644 scribo/sandbox/arthur/xml_transform/domitem.cc
delete mode 100644 scribo/sandbox/arthur/xml_transform/domitem.hh
delete mode 100644 scribo/sandbox/arthur/xml_transform/dommodel.cc
delete mode 100644 scribo/sandbox/arthur/xml_transform/dommodel.hh
copy scribo/sandbox/arthur/xml_transform/templates/html/{xsl.xsl => xsl_base64.xsl} (97%)
copy scribo/sandbox/arthur/xml_transform/templates/pdf/{main.xsl => main64.xsl} (94%)
copy scribo/sandbox/arthur/xml_transform/templates/pdf/{regions.xsl => regions_base64.xsl} (91%)
rename scribo/sandbox/arthur/xml_transform/templates/pdf/{regions.xsl => regions_png.xsl} (100%)
diff --git a/scribo/sandbox/ChangeLog b/scribo/sandbox/ChangeLog
index d3f537b..0fb733f 100644
--- a/scribo/sandbox/ChangeLog
+++ b/scribo/sandbox/ChangeLog
@@ -1,3 +1,36 @@
+2010-07-15 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
+
+ XML Tranform.
+
+ * scribo/sandbox/arthur/xml_transform/xml_transform.cc,
+ * scribo/sandbox/arthur/xml_transform/xml_transform.hh: Facade.
+
+ * scribo/sandbox/arthur/xml_transform/image_crop.cc,
+ * scribo/sandbox/arthur/xml_transform/image_crop.hh: Image process.
+
+ * scribo/sandbox/arthur/xml_transform/loader.cc,
+ * scribo/sandbox/arthur/xml_transform/loader.hh: XML loader.
+
+ * scribo/sandbox/arthur/xml_transform/main.cc
+ * scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
+ * scribo/sandbox/arthur/xml_transform/xml_transform.pro
+ * scribo/sandbox/arthur/xml_transform/README
+
+ * scribo/sandbox/arthur/xml_transform/common.cc,
+ * scribo/sandbox/arthur/xml_transform/common.hh,
+ * scribo/sandbox/arthur/xml_transform/templates/html/xsl_base64.xsl,
+ * scribo/sandbox/arthur/xml_transform/templates/pdf/main64.xsl,
+ * scribo/sandbox/arthur/xml_transform/templates/pdf/regions_base64.xsl: New.
+
+ * scribo/sandbox/arthur/xml_transform/domitem.cc,
+ * scribo/sandbox/arthur/xml_transform/domitem.hh,
+ * scribo/sandbox/arthur/xml_transform/dommodel.cc,
+ * scribo/sandbox/arthur/xml_transform/dommodel.hh: Delete.
+
+ * scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl: Rename as...
+ * scribo/sandbox/arthur/xml_transform/templates/pdf/regions_png.xsl:...this.
+
+
2010-07-05 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
ICDAR XML to HTML.
diff --git a/scribo/sandbox/arthur/xml_transform/README b/scribo/sandbox/arthur/xml_transform/README
index e0bfbc8..1f358e3 100644
--- a/scribo/sandbox/arthur/xml_transform/README
+++ b/scribo/sandbox/arthur/xml_transform/README
@@ -1,19 +1,24 @@
-xml_transform <option> <xml_file> <ppm_file> <output_dir>
-
-Transforms an ICDAR XML file to different kind of output.
+xml_transform
OPTIONS:
- --html: Produce a HTML output
-
-Once process is finished, open output.xml with your internet browser. If this one supports XSLT, there is no problem to display the result but if it does not support it (like Konqueror or Chrome in local), you should run `sh html_generator.sh` (xsltproc package required) to generate a HTML file readable by all browsers.
+HTML output:
+ --html <xml> <ppm> <out_dir> : HTML output with non-text regions croped into many png files.
+ --html-base64 <xml> <out_dir> : HTML output from a container XML file.
- --pdf: Produce a PDF output, regions will be cropped as follows in the XML file.
- --pdf-no-crop: Produce a PDF output without cropping regions, the entire picture will be displayed.
+PDF output:
+ --pdf <xml> <ppm> <out_dir> : PDF output with non-text regions croped into many png files.
+ --pdf-no-crop <xml> <ppm> <out_dir>: PDF output with the entire picture displayed over the text.
+ --pdf-base64 <xml> <out_dir> : PDF output from a container XML file.
+ --pdf-base64-no-crop <xml> <ppm> <out_dir> : PDF with the entire picture displayed over the text,
+ the picture is loaded from a container XML file.
-PDF is not directly created once the process is finished, to produce it, go to the output_dir and run `sh pdf_generator.sh` (fop >= 0.95 required).
+Base 64 operations:
+ --to-base64 <xml> <ppm> <out_xml> : Produces a container XML file by converting croped pictures into base 64 format.
+ --to-base64-no-crop <xml> <ppm> <out_xml> : Same as to-base64 but only the picture is converted in base 64.
+ --from-base64 <xml> <out_dir> : Decodes a XML container file to produce original image files.
BUILD:
-Chnage the environment variable QMAKE_CXXFLAGS to indicate the correct paths to milena and olena then, just type qmake and make.
\ No newline at end of file
+Chnage the environment variable QMAKE_CXXFLAGS to indicate the correct paths to milena and olena in the .pro file then, just type qmake and make.
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_transform/common.cc b/scribo/sandbox/arthur/xml_transform/common.cc
new file mode 100644
index 0000000..05117b2
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/common.cc
@@ -0,0 +1,13 @@
+# include "common.hh"
+
+QString Common::get_file_name(QString image)
+{
+ QString tmp = image.mid(image.lastIndexOf("/") + 1);
+ tmp.chop(tmp.size() - tmp.lastIndexOf("."));
+ return tmp;
+}
+
+QString Common::get_file_ext(QString image)
+{
+ return image.right(image.size() - image.lastIndexOf("."));
+}
diff --git a/scribo/sandbox/arthur/xml_transform/common.hh b/scribo/sandbox/arthur/xml_transform/common.hh
new file mode 100644
index 0000000..f72218f
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/common.hh
@@ -0,0 +1,16 @@
+#ifndef COMMON_HH
+# define COMMON_HH
+
+# include <QtGui>
+
+class Common : public QObject
+{
+ Q_OBJECT
+public:
+ Common() {}
+ ~Common() {}
+ static QString get_file_name(QString image);
+ static QString get_file_ext(QString image);
+};
+
+#endif // ! COMMON_HH
diff --git a/scribo/sandbox/arthur/xml_transform/domitem.cc b/scribo/sandbox/arthur/xml_transform/domitem.cc
deleted file mode 100644
index 66e989a..0000000
--- a/scribo/sandbox/arthur/xml_transform/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/sandbox/arthur/xml_transform/domitem.hh b/scribo/sandbox/arthur/xml_transform/domitem.hh
deleted file mode 100644
index a5c22cc..0000000
--- a/scribo/sandbox/arthur/xml_transform/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/sandbox/arthur/xml_transform/dommodel.cc b/scribo/sandbox/arthur/xml_transform/dommodel.cc
deleted file mode 100644
index baaf9a7..0000000
--- a/scribo/sandbox/arthur/xml_transform/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/sandbox/arthur/xml_transform/dommodel.hh b/scribo/sandbox/arthur/xml_transform/dommodel.hh
deleted file mode 100644
index 16c5a23..0000000
--- a/scribo/sandbox/arthur/xml_transform/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/sandbox/arthur/xml_transform/image_crop.cc b/scribo/sandbox/arthur/xml_transform/image_crop.cc
index aa17c31..8aafe45 100644
--- a/scribo/sandbox/arthur/xml_transform/image_crop.cc
+++ b/scribo/sandbox/arthur/xml_transform/image_crop.cc
@@ -25,7 +25,7 @@
# include "image_crop.hh"
# include "loader.hh"
-# include "dommodel.hh"
+# include "common.hh"
# include <limits.h>
@@ -36,7 +36,10 @@
#include <mln/io/magick/save.hh>
#include <mln/io/ppm/all.hh>
-ImageCrop::ImageCrop()
+ImageCrop::ImageCrop(QString xml, QString img, QString output) :
+ xml_(xml),
+ image_(img),
+ output_dir_(output)
{
}
@@ -44,95 +47,242 @@ ImageCrop::~ImageCrop()
{
}
-void ImageCrop::save_image(QString image, QString output)
+/* Save PPM image to PNG format in output_dir/img. */
+void ImageCrop::save_image(QString file)
{
using namespace mln;
image2d<value::rgb8> ima;
- io::ppm::load(ima, image.toStdString());
+ io::ppm::load(ima, image_.toStdString());
- io::magick::save(ima, output.toStdString() + "img/image.png");
+ QString filename;
+ if (file == QString::Null())
+ filename = Common::get_file_name(image_);
+ else
+ filename = file;
+
+ std::cout << "Saving " << image_.toStdString() << " to "
+ << output_dir_.toStdString() << "img/"
+ << filename.toStdString() << ".png"
+ << std::endl;
+
+ io::magick::save(ima, output_dir_.toStdString() + "img/" + filename.toStdString() + ".png");
}
-void ImageCrop::crop_regions(QString xml_file, QString image_file, QString output)
+/* Return the image in base 64. */
+QString ImageCrop::img_to_base64()
{
- Loader loader;
+ QFile f(image_);
+ f.open(QIODevice::ReadOnly);
+
+ QByteArray file_content = f.readAll();
- QFile f(image_file);
+ f.close();
- if (!f.exists())
+ return file_content.toBase64();
+}
+
+/* Decode the base 64 string str and save into output_dir_/img/img_name. */
+bool ImageCrop::img_from_base64(QString str, QString img_name, QString mime)
+{
+ QByteArray ba;
+
+ ba = ba.append(str);
+ QByteArray out_ba = QByteArray::fromBase64(ba);
+ QImage ima = QImage::fromData(out_ba);
+
+ return ima.save(output_dir_ + "img/" + img_name + "." + mime);
+}
+
+/* Read all regions of the XML file and save all base 64 data into output_dir/img */
+void ImageCrop::from_base64()
+{
+ 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())
{
- qDebug() << "Image doesn't exist !";
- abort();
+ if (child.toElement().tagName().contains(QRegExp("(image|graphic|chart|separator|table)_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();
+ QString mime = node.firstChildElement("mime").text();
+ img_from_base64(data, id, mime);
+ }
+ }
+ child = child.nextSibling();
+ }
+}
+
+/* Tranfsorm the input XML file associated with images into a single
+ XML output containing datas if images in base 64. */
+void ImageCrop::to_base64(QString out_file, bool no_crop)
+{
+ QFile file(xml_);
+ file.open(QIODevice::ReadOnly);
+ QTextStream stream(&file);
+
+ QFile file2(out_file);
+ file2.open(QIODevice::ReadWrite);
+ QTextStream stream2(&file2);
+
+ QString line = stream.readLine();
+ stream2 << line;
+ line = stream.readLine();
+
+ // HEAD
+ while (!line.contains("<page"))
+ {
+ stream2 << "\n" << line;
+ line = stream.readLine();
+ }
+
+ if (no_crop)
+ {
+ stream2 << "\n" << line;
+
+ stream2 << "\n" << " <image_region id=\"image\">";
+ stream2 << "\n" << " <container>\n";
+ stream2 << " <mime>png</mime>\n";
+
+ QString file_name = Common::get_file_name(image_);
+ save_image();
+ QFile img(output_dir_ + "img/" + file_name + ".png");
+
+ img.open(QIODevice::ReadOnly);
+ stream2 << " <data>\n";
+
+ QByteArray byte = img.readAll();
+ stream2 << byte.toBase64();
+
+ stream2 << " </data>";
+ stream2 << "\n </container>";
+ stream2 << "\n <coords>\n";
+
+ stream2 << " <point x=\"0\" y=\"0\" />\n";
+ stream2 << " <point x=\"0\" y=\"0\" />";
+
+ stream2 << "\n </coords>";
+ stream2 << "\n" << " </image_region>\n";
+ img.close();
+
+ line = stream.readLine();
+
+ while(!line.contains("</pcGts>"))
+ {
+ stream2 << "\n" << line;
+ line = stream.readLine();
+ }
+
+ stream2 << "\n" << line;
}
- DomModel* layout = loader.xml_to_dom(xml_file);
- if (layout)
+ else
{
- QModelIndex pcGts = layout->index(1, 0);
- QModelIndex page = layout->index(1, 0, pcGts);
- QModelIndex region;
- QModelIndex attributes;
- QModelIndex coords;
- QModelIndex point;
- bool regions_found = false;
-
- for (int i = 0; true; ++i)
+ while(!line.contains("</pcGts>"))
{
- region = layout->index(i, 0, page);
- attributes = layout->index(i, 1, page);
+ stream2 << "\n" << line;
+ if (line.contains(QRegExp("<(image|graphic|chart|separator|table)_region")))
+ {
+ stream2 << "\n" << " <container>\n";
+ stream2 << " <mime>png</mime>\n";
+
+ QDomDocument doc;
+ doc.setContent(line);
+
+ QDomElement root = doc.documentElement();
+ QString id = root.attribute("id", "none");
- QString name = layout->data(region, Qt::DisplayRole).toString();
- coords = layout->index(0, 0, region);
+ QFile img(output_dir_ + "img/" + id + ".png");
- bool is_region =
- name == QString("image_region")
- || name == QString("graphic_region")
- || name == QString("separator_region")
- || name == QString("chart_region")
- || name == QString("table_region") ;
+ img.open(QIODevice::ReadOnly);
+ stream2 << " <data>\n";
- if (!region.isValid() || !coords.isValid())
- break;
+ QByteArray byte = img.readAll();
+ stream2 << byte.toBase64();
+
+ stream2 << " </data>";
+ stream2 << "\n </container>";
+ img.close();
+ }
- if (is_region)
+ line = stream.readLine();
+ }
+
+ stream2 << "\n" << line;
+ }
+
+ file2.close();
+ file.close();
+}
+
+bool ImageCrop::crop_regions()
+{
+ Loader loader;
+ QFile f(xml_);
+ f.open(QIODevice::ReadOnly);
+ QDomDocument doc;
+
+ if (doc.setContent(&f))
+ {
+ bool found_regions = false;
+ f.close();
+
+ QDomElement root = doc.documentElement();
+ QDomNode page = root.firstChild();
+
+ while (!page.isNull() && !page.toElement().tagName().contains("page"))
+ page = page.nextSibling();
+
+ if (page.isNull())
+ return false;
+
+ QDomNode region = page.firstChild();
+
+ while (!region.isNull())
+ {
+ if (region.toElement().tagName().contains(QRegExp("(image|graphic|chart|separator|table)_region")))
{
- regions_found = true;
- QMap<QString, QVariant> data =
- layout->data(attributes, Qt::UserRole).toMap();
+ found_regions = true;
- QString id;
- QMap<QString, QVariant>::iterator it = data.find("id");
+ QDomNode coords = region.firstChild();
+ QString id = region.toElement().attribute("id", "none");
- if (it == data.end() || it.key() != "id")
- qDebug() << "WTF_Error : No image region.";
+ qDebug() << region.toElement().tagName();
- while (it != data.end() && it.key() == "id")
- {
- qDebug() << name;
- id = it.value().toString();
- qDebug() << it.key() + " = " + it.value().toString();
- ++it;
- }
+ while (!coords.isNull() && !coords.toElement().tagName().contains("coords"))
+ coords = coords.nextSibling();
+ if (coords.isNull())
+ break;
+
+ QDomNode point = coords.firstChild();
int x_max = 0;
int y_max = 0;
int x_min = INT_MAX;
int y_min = INT_MAX;
- // QVector<QMap<QString, QVariant> > vect;
- for (int j = 0; true; ++j)
+ while (!point.isNull())
{
- // Navigate to the coordinate list
- point = layout->index(j, 1, coords);
- if (!point.isValid())
- break;
-
- QMap<QString, QVariant> data =
- layout->data(point, Qt::UserRole).toMap();
- int x = data["x"].toInt();
- int y = data["y"].toInt();
-
- // vect << data;
+ int x = point.toElement().attribute("x", "none").toInt();
+ int y = point.toElement().attribute("y", "none").toInt();
if (x < x_min)
x_min = x;
@@ -144,41 +294,26 @@ void ImageCrop::crop_regions(QString xml_file, QString image_file, QString outpu
if (y > y_max)
y_max = y;
+ point = point.nextSibling();
}
using namespace mln;
-
box2d box = make::box2d(y_min, x_min, y_max, x_max);
image2d<value::rgb8> ima;
- io::ppm::load(ima, image_file.toStdString());
+ io::ppm::load(ima, image_.toStdString());
ima = scribo::preprocessing::crop(ima, box);
- // image2d<bool> mask = make::box2d(y_min, x_min, y_max, x_max);
- // data::fill(mask, true);
-
- /*for (int a = 1; a < vect.size(); ++a)
- {
- int x = vect[a]["x"].toInt();
- int y = vect[a]["y"].toInt();
-
- data::fill((mask | make::box2d(y, x, y, x)).rw(), false);
- }*/
-
- // io::pbm::save(mask, "output/img/mask_" + id.toStdString());
- io::magick::save(ima, output.toStdString() + "img/" + id.toStdString() + ".png");
-
+ io::magick::save(ima, output_dir_.toStdString() + "img/" + id.toStdString() + ".png");
}
+ region = region.nextSibling();
}
- if (!regions_found)
- qDebug() << "No regions found.";
-
+ return found_regions;
}
else
{
- qDebug() << "Error with XML file.";
+ f.close();
+ return false;
}
-
-
}
diff --git a/scribo/sandbox/arthur/xml_transform/image_crop.hh b/scribo/sandbox/arthur/xml_transform/image_crop.hh
index e4b0a38..9b034cc 100644
--- a/scribo/sandbox/arthur/xml_transform/image_crop.hh
+++ b/scribo/sandbox/arthur/xml_transform/image_crop.hh
@@ -26,7 +26,8 @@
#ifndef IMAGE_CROP_HH
# define IMAGE_CROP_HH
-# include <QtGui>
+#include <QDomDocument>
+# include <QtCore>
class DomModel;
@@ -35,12 +36,22 @@ class ImageCrop : public QObject
Q_OBJECT
public:
- ImageCrop();
+ ImageCrop(QString xml, QString img, QString output);
~ImageCrop();
- void save_image(QString image, QString output);
- void crop_regions(QString xml_file, QString image_file, QString output);
+ void save_image(QString file = QString::Null());
+ bool crop_regions();
+ QString img_to_base64();
+ bool img_from_base64(QString str, QString img_name, QString mime);
+ void to_base64(QString out_file, bool no_crop);
+
+ void from_base64();
+
+private:
+ QString xml_;
+ QString image_;
+ QString output_dir_;
};
#endif /* !IMAGE_CROP_HH */
diff --git a/scribo/sandbox/arthur/xml_transform/loader.cc b/scribo/sandbox/arthur/xml_transform/loader.cc
index 5623928..2b64337 100644
--- a/scribo/sandbox/arthur/xml_transform/loader.cc
+++ b/scribo/sandbox/arthur/xml_transform/loader.cc
@@ -24,8 +24,6 @@
// executable file might be covered by the GNU General Public License.
# include "loader.hh"
-# include "dommodel.hh"
-# include "xml_transform.hh"
Loader::Loader()
{
@@ -35,21 +33,21 @@ Loader::~Loader()
{
}
-DomModel* Loader::xml_to_dom(QString output)
+QDomDocument* Loader::xml_to_dom(QString xml_file)
{
- QString file_path = output;
-
- QFile file(file_path);
+ QFile file(xml_file);
if (file.open(QIODevice::ReadOnly))
{
- QDomDocument document;
- if (document.setContent(&file))
+ QDomDocument* document = new QDomDocument;
+ if (document->setContent(&file))
{
- return new DomModel(document);
+ file.close();
+ return document;
}
}
+ file.close();
return 0;
}
@@ -61,9 +59,7 @@ bool Loader::set_output(QString& output)
output.append("/");
if (!dir.exists())
- {
- return dir.mkpath(".");
- }
+ return dir.mkpath(".");
else
{
QStringList list = dir.entryList(QDir::Writable | QDir::AllDirs);
@@ -72,25 +68,38 @@ bool Loader::set_output(QString& output)
}
-void Loader::add_html_templates(QString output)
+void Loader::add_html_templates(bool base64, QString output)
{
-
QFile gen("templates/html/html_generator.sh");
gen.copy(output + "html_generator.sh");
QFile css("templates/html/css.css");
css.copy(output + "css.css");
- QFile xsl("templates/html/xsl.xsl");
- xsl.copy(output + "xsl.xsl");
-
+ if (base64)
+ {
+ QFile xsl("templates/html/xsl_base64.xsl");
+ xsl.copy(output + "xsl.xsl");
+ }
+ else
+ {
+ QFile xsl("templates/html/xsl.xsl");
+ xsl.copy(output + "xsl.xsl");
+ }
}
-void Loader::add_pdf_templates(bool crop, QString output)
+void Loader::add_pdf_templates(bool crop, bool base64, QString output)
{
-
- QFile regions("templates/pdf/regions.xsl");
- regions.copy(output + "regions.xsl");
+ if (base64)
+ {
+ QFile regions("templates/pdf/regions_base64.xsl");
+ regions.copy(output + "regions.xsl");
+ }
+ else
+ {
+ QFile regions("templates/pdf/regions_png.xsl");
+ regions.copy(output + "regions.xsl");
+ }
QFile gen("templates/pdf/pdf_generator.sh");
gen.copy(output + "pdf_generator.sh");
@@ -104,59 +113,58 @@ void Loader::add_pdf_templates(bool crop, QString output)
}
else
{
- QFile xsl("templates/pdf/main.xsl");
- xsl.copy(output + "main.xsl");
+ if (base64)
+ {
+ QFile xsl("templates/pdf/main.xsl");
+ xsl.copy(output + "main.xsl");
+ }
+ else
+ {
+ QFile xsl("templates/pdf/main64.xsl");
+ xsl.copy(output + "main.xsl");
+ }
}
}
-bool Loader::load_xml(QString xml_file, bool html, QString output)
+bool Loader::xml_output(QString xml_file, bool html, QString output)
{
QFile file(xml_file);
- if (file.exists())
- {
- file.open(QIODevice::ReadOnly);
- set_output(output);
+ file.open(QIODevice::ReadOnly);
- QFile out_file(output + "output.xml");
- out_file.open(QIODevice::ReadWrite);
+ QFile out_file(output + "output.xml");
+ out_file.open(QIODevice::ReadWrite);
- QTextStream stream_in(&file);
- QTextStream stream_out(&out_file);
+ QTextStream stream_in(&file);
+ QTextStream stream_out(&out_file);
- QString line = stream_in.readLine();
+ QString line = stream_in.readLine();
- while(!line.contains("<?xml"))
- line = stream_in.readLine();
+ while(!line.contains("<?xml"))
+ line = stream_in.readLine();
- stream_out << line;
+ stream_out << line;
- if (html)
- stream_out << "\n<?xml-stylesheet type=\"text/xsl\" href=\"xsl.xsl\" ?>";
+ if (html)
+ stream_out << "\n<?xml-stylesheet type=\"text/xsl\" href=\"xsl.xsl\" ?>";
- // /!\ attributes of ICDAR PcGts removed.
- while(!line.contains("<pcGts"))
- line = stream_in.readLine();
+ // /!\ attributes of ICDAR PcGts removed.
+ while(!line.contains("<pcGts"))
+ line = stream_in.readLine();
- line = stream_in.readLine();
- stream_out << "\n<pcGts>";
-
- while (!line.contains("</pcGts>"))
- {
- stream_out << "\n" << line;
- line = stream_in.readLine();
- }
+ line = stream_in.readLine();
+ stream_out << "\n<pcGts>";
+ while (!line.contains("</pcGts>"))
+ {
stream_out << "\n" << line;
+ line = stream_in.readLine();
+ }
- file.close();
- out_file.close();
+ stream_out << "\n" << line;
- return true;
- }
- else
- {
- qDebug() << xml_file + " doesn't exist";
- return false;
- }
+ file.close();
+ out_file.close();
+
+ return true;
}
diff --git a/scribo/sandbox/arthur/xml_transform/loader.hh b/scribo/sandbox/arthur/xml_transform/loader.hh
index 7d24254..fadceed 100644
--- a/scribo/sandbox/arthur/xml_transform/loader.hh
+++ b/scribo/sandbox/arthur/xml_transform/loader.hh
@@ -26,24 +26,23 @@
#ifndef LOADER_HH
# define LOADER_HH
-//# include <QtGui>
-# include "xml_transform.hh"
+# include <QtCore>
+#include <QDomDocument>
-class DomModel;
-
-class Loader
+class Loader : public QObject
{
+ Q_OBJECT
public:
Loader();
~Loader();
// void merge(QString in, QString other, QString output = "output.xml");
- bool load_xml(QString xml_file, bool html, QString output);
- DomModel* xml_to_dom(QString output);
+ bool xml_output(QString xml_file, bool html, QString output);
+ QDomDocument* xml_to_dom(QString xml_file);
bool set_output(QString& output);
- void add_pdf_templates(bool crop, QString output);
- void add_html_templates(QString output);
+ void add_pdf_templates(bool crop, bool base64, QString output);
+ void add_html_templates(bool base64, QString output);
};
#endif /* !LOADER_HH */
diff --git a/scribo/sandbox/arthur/xml_transform/main.cc b/scribo/sandbox/arthur/xml_transform/main.cc
index 9e18cff..e097430 100644
--- a/scribo/sandbox/arthur/xml_transform/main.cc
+++ b/scribo/sandbox/arthur/xml_transform/main.cc
@@ -1,25 +1,89 @@
#include <iostream>
+#include <QDomDocument>
#include "xml_transform.hh"
int main(int argc, char **argv)
{
- std::string man = "xml_transform <option> <xml_file> <ppm_file> <output_dir>\nOPTIONS:\n\t--html: Produce a HTML output\n\t--pdf: Produce a PDF output, regions will be croped as follows in the XML file.\n\t--pdf-no-crop: Produce a PDF output without croping regions, the entire picture will be displayed.";
+ std::string man;
+ man = "xml_transform\n";
+ man += "OPTIONS:\n\n";
+ man += "HTML output:\n";
+ man += "\t--html <xml> <ppm> <out_dir> : HTML output with non-text regions croped into many png files.\n";
+ man += "\t--html-base64 <xml> <out_dir> : HTML output from a container XML file.\n\n";
+ man += "PDF output:\n";
+ man += "\t--pdf <xml> <ppm> <out_dir> : PDF output with non-text regions croped into many png files.\n";
+ man += "\t--pdf-no-crop <xml> <ppm> <out_dir>: PDF output with the entire picture displayed over the text.\n";
+ man += "\t--pdf-base64 <xml> <out_dir> : PDF output from a container XML file.\n";
+ man += "\t--pdf-base64-no-crop <xml> <ppm> <out_dir> : PDF with the entire picture displayed over the text, the picture is loaded from a container XML file.\n\n";
+ man += "Base 64 operations:\n";
+ man += "\t--to-base64 <xml> <ppm> <out_xml> : Produces a container XML file by converting croped pictures into base 64 format.\n";
+ man += "\t--to-base64-no-crop <xml> <ppm> <out_xml> : Same as to-base64 but only the picture is converted in base 64.\n";
+ man += "\t--from-base64 <xml> <out_dir> : Decodes a XML container file to produce original image files.\n";
if (argc > 4)
{
std::string html = "--html";
std::string pdf = "--pdf";
std::string pdf_no_crop = "--pdf-no-crop";
-
- XmlTransform xmlt(argv[4], argv[2]);
+ std::string to_base64 = "--to-base64";
+ std::string to_base64nocrop = "--to-base64-no-crop";
if (html.compare(argv[1]) == 0)
- xmlt.createHTML(argv[3]);
- else if (pdf.compare(argv[1]) == 0)
- xmlt.createPDF(argv[3], true);
+ {
+ XmlTransform xmlt(argv[2], argv[3], argv[4]);
+ xmlt.createHTML(false);
+ }
+ if (pdf.compare(argv[1]) == 0)
+ {
+ XmlTransform xmlt(argv[2], argv[3], argv[4]);
+ xmlt.createPDF(true, false);
+ }
else if (pdf_no_crop.compare(argv[1]) == 0)
- xmlt.createPDF(argv[3], false);
+ {
+ XmlTransform xmlt(argv[2], argv[3], argv[4]);
+ xmlt.createPDF(false, false);
+ }
+ else if (to_base64.compare(argv[1]) == 0)
+ {
+ XmlTransform xmlt(argv[2], argv[3], QString::Null(), argv[4]);
+ xmlt.toBase64(false);
+ }
+ else if (to_base64nocrop.compare(argv[1]) == 0)
+ {
+ XmlTransform xmlt(argv[2], argv[3], QString::Null(), argv[4]);
+ xmlt.toBase64(true);
+ }
+ else
+ std::cout << man << std::endl;
+ }
+ else if (argc > 3)
+ {
+ std::string pdfbase64 = "--pdf-base64";
+ std::string pdfbase64nocrop = "--pdf-base64-no-crop";
+ std::string htmlbase64 = "--html-base64";
+ std::string from_base64 = "--from-base64";
+
+ if (pdfbase64.compare(argv[1]) == 0)
+ {
+ XmlTransform xmlt(argv[2], QString::Null(), argv[3]);
+ xmlt.createPDF(true, true);
+ }
+ else if (pdfbase64nocrop.compare(argv[1]) == 0)
+ {
+ XmlTransform xmlt(argv[2], QString::Null(), argv[3]);
+ xmlt.createPDF(false, true);
+ }
+ else if (htmlbase64.compare(argv[1]) == 0)
+ {
+ XmlTransform xmlt(argv[2], QString::Null(), argv[3]);
+ xmlt.createHTML(true);
+ }
+ else if (from_base64.compare(argv[1]) == 0)
+ {
+ XmlTransform xmlt(argv[2], QString::Null(), argv[3]);
+ xmlt.fromBase64();
+ }
else
std::cout << man << std::endl;
}
diff --git a/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl b/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
index 3d6a1c5..1f29044 100644
--- a/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
+++ b/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
@@ -209,8 +209,7 @@
<xsl:attribute name="height">
<xsl:value-of select="$y2 - $y1" />
</xsl:attribute>
- <xsl:attribute name="src">
- img/<xsl:value-of select="$id"/>.png</xsl:attribute>
+ <xsl:attribute name="src">img/<xsl:value-of select="$id"/>.png</xsl:attribute>
</img>
</div>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl b/scribo/sandbox/arthur/xml_transform/templates/html/xsl_base64.xsl
similarity index 97%
copy from scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
copy to scribo/sandbox/arthur/xml_transform/templates/html/xsl_base64.xsl
index 3d6a1c5..1c25e42 100644
--- a/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
+++ b/scribo/sandbox/arthur/xml_transform/templates/html/xsl_base64.xsl
@@ -174,9 +174,9 @@
<!-- NON-TEXT REGIONS -->
<xsl:if test="name() = 'image_region' or name() = 'separator_region' or name() = 'graphic_region' or name() = 'chart_region' or name() = 'table_region'">
- <!-- id -->
- <xsl:variable name="id">
- <xsl:value-of select="@id" />
+ <!-- data -->
+ <xsl:variable name="data">
+ <xsl:value-of select="container/data" />
</xsl:variable>
<!-- depth -->
@@ -210,7 +210,8 @@
<xsl:value-of select="$y2 - $y1" />
</xsl:attribute>
<xsl:attribute name="src">
- img/<xsl:value-of select="$id"/>.png</xsl:attribute>
+ data:image/png;base64,<xsl:value-of select="$data"/>
+ </xsl:attribute>
</img>
</div>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl b/scribo/sandbox/arthur/xml_transform/templates/pdf/main64.xsl
similarity index 94%
copy from scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl
copy to scribo/sandbox/arthur/xml_transform/templates/pdf/main64.xsl
index 065831e..ecc7443 100644
--- a/scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/main64.xsl
@@ -46,7 +46,7 @@
<fo:block>
<fo:external-graphic>
<xsl:attribute name="src">
- url('img/image.png')
+ data:image/png;base64,<xsl:value-of select="pcGts/page/image_region/container/data" />
</xsl:attribute>
</fo:external-graphic>
</fo:block>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl b/scribo/sandbox/arthur/xml_transform/templates/pdf/regions_base64.xsl
similarity index 91%
copy from scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl
copy to scribo/sandbox/arthur/xml_transform/templates/pdf/regions_base64.xsl
index 65a8c79..add0cba 100644
--- a/scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/regions_base64.xsl
@@ -11,8 +11,8 @@
pcGts/page/separator_region">
<!-- ID of the region, used to display id.png -->
- <xsl:variable name="id">
- <xsl:value-of select="@id" />
+ <xsl:variable name="data">
+ <xsl:value-of select="container/data" />
</xsl:variable>
<!-- Regions coordinates -->
@@ -47,7 +47,7 @@
<fo:block>
<fo:external-graphic>
<xsl:attribute name="src">
- url('img/<xsl:value-of select="$id" />.png')
+ url('data:image/png;base64,<xsl:value-of select="$data" />')
</xsl:attribute>
</fo:external-graphic>
</fo:block>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl b/scribo/sandbox/arthur/xml_transform/templates/pdf/regions_png.xsl
similarity index 100%
rename from scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl
rename to scribo/sandbox/arthur/xml_transform/templates/pdf/regions_png.xsl
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.cc b/scribo/sandbox/arthur/xml_transform/xml_transform.cc
index dd35aff..ebfbed8 100644
--- a/scribo/sandbox/arthur/xml_transform/xml_transform.cc
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.cc
@@ -23,69 +23,114 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
+# include "xml_transform.hh"
# include "image_crop.hh"
# include "loader.hh"
-# include "xml_transform.hh"
+# include "common.hh"
+# include <iostream>
-XmlTransform::XmlTransform(QString output, QString xml_file) :
- output_dir_(output),
- xml_file_(xml_file)
+XmlTransform::XmlTransform(QString xml_file, QString image_file, QString output, QString file) :
+ xml_file_(xml_file),
+ image_(image_file),
+ loader_(new Loader()),
+ file_(file)
{
- Loader loader;
- if (!loader.set_output(output_dir_))
- abort();
+ QFile fi(image_);
+ QFile fx(xml_file_);
+
+ if (file_ != QString::Null())
+ output_dir_ = "/tmp/xml_transform";
+ else
+ output_dir_ = output;
+
+ if (output_dir_ != QString::Null() && !loader_->set_output(output_dir_))
+ {
+ std::cout << "Cant't create " << output_dir_.toStdString() << "dir! Aborting..." << std::endl;
+ abort();
+ }
+ else if (!fi.exists() && image_ != QString::Null())
+ {
+ std::cout << "Image file does not exist ! Aborting..." << std::endl;
+ abort();
+ }
+ else if (!fx.exists())
+ {
+ std::cout << "XML file does not exist ! Aborting..." << std::endl;
+ abort();
+ }
+
+ crop_ = new ImageCrop(xml_file_, image_, output_dir_);
}
XmlTransform::~XmlTransform()
{
}
-void XmlTransform::createPDF (QString img, bool crop)
+void XmlTransform::fromBase64()
{
- Loader loader;
+ QString output = output_dir_;
+ output.append("img");
+
+ if (loader_->set_output(output))
+ crop_->from_base64();
+ else
+ abort();
+}
+void XmlTransform::toBase64(bool crop)
+{
QString output = output_dir_;
output.append("img");
- if (loader.set_output(output))
+ if (loader_->set_output(output))
{
- if (loader.load_xml(xml_file_, false, output_dir_))
- {
+ if (!crop)
+ crop_->crop_regions();
- ImageCrop Crop;
+ crop_->to_base64(file_, crop);
+ }
+ else
+ abort();
+}
- if (crop)
- Crop.crop_regions(xml_file_, img, output_dir_);
- else
- Crop.save_image(img, output_dir_);
+void XmlTransform::createPDF (bool crop, bool base64)
+{
+ if (loader_->xml_output(xml_file_, false, output_dir_))
+ {
+ if (!base64)
+ {
+ QString output = output_dir_;
+ output.append("img");
- loader.add_pdf_templates(crop, output_dir_);
+ if (loader_->set_output(output))
+ {
+ if (crop)
+ crop_->crop_regions();
+ else
+ crop_->save_image("image");
+ }
}
- else
- abort();
+
+ loader_->add_pdf_templates(crop, base64, output_dir_);
}
else
abort();
}
-void XmlTransform::createHTML(QString img)
+void XmlTransform::createHTML(bool base64)
{
- Loader loader;
-
- QString output = output_dir_;
- output.append("img");
-
- if (loader.set_output(output))
+ if (loader_->xml_output(xml_file_, true, output_dir_))
{
- if (loader.load_xml(xml_file_, true, output_dir_))
+ if (!base64)
{
- ImageCrop Crop;
-
- Crop.crop_regions(xml_file_, img, output_dir_);
- loader.add_html_templates(output_dir_);
+ QString output = output_dir_;
+ output.append("img");
+ if (loader_->set_output(output))
+ crop_->crop_regions();
+ else
+ abort();
}
- else
- abort();
+ loader_->add_html_templates(base64, output_dir_);
}
else
abort();
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.hh b/scribo/sandbox/arthur/xml_transform/xml_transform.hh
index 808c108..172bddb 100644
--- a/scribo/sandbox/arthur/xml_transform/xml_transform.hh
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.hh
@@ -26,22 +26,32 @@
#ifndef XML_TRANFORM_HH
# define XML_TRANFORM_HH
-# include <QtGui>
+# include <QtCore>
+
+
+class Loader;
+class ImageCrop;
class XmlTransform : public QObject
{
Q_OBJECT
public:
- XmlTransform(QString output, QString xml_file);
+ XmlTransform(QString xml_file, QString image_file, QString output, QString file = QString::Null());
~XmlTransform();
- void createHTML(QString img);
- void createPDF(QString img, bool crop);
+ void createHTML(bool base64);
+ void createPDF(bool crop, bool base64);
+ void toBase64(bool crop);
+ void fromBase64();
-protected:
+private:
QString output_dir_;
QString xml_file_;
+ QString image_;
+ Loader* loader_;
+ ImageCrop* crop_;
+ QString file_;
};
#endif // !XML_TRANFORM_HH
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.pro b/scribo/sandbox/arthur/xml_transform/xml_transform.pro
index 161a7f4..c038cf6 100644
--- a/scribo/sandbox/arthur/xml_transform/xml_transform.pro
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.pro
@@ -1,5 +1,5 @@
######################################################################
-# Automatically generated by qmake (2.01a) jeu. juil. 8 16:33:27 2010
+# Automatically generated by qmake (2.01a) jeu. juil. 15 13:47:38 2010
######################################################################
TEMPLATE = app
@@ -10,11 +10,7 @@ QMAKE_CXXFLAGS += -I/amd/beyrouth/home/lrde/stage/crepin/git/olena/milena -I/amd
QT += xml
LIBS += `Magick++-config --libs`
+
# Input
-HEADERS += domitem.hh dommodel.hh image_crop.hh loader.hh xml_transform.hh
-SOURCES += domitem.cc \
- dommodel.cc \
- image_crop.cc \
- loader.cc \
- main.cc \
- xml_transform.cc
+HEADERS += common.hh image_crop.hh loader.hh xml_transform.hh
+SOURCES += common.cc image_crop.cc loader.cc main.cc xml_transform.cc
--
1.5.6.5
1
0
* sandbox/arthur/xml_to_html/xml_to_html.hh,
* sandbox/arthur/xml_to_html/xml_to_html.cc,
* sandbox/arthur/xml_to_html/xml_to_html.pro: Remove.
* sandbox/arthur/xml_to_html/README,
* sandbox/arthur/xml_to_html/main.cc,
* sandbox/arthur/xml_to_html/domitem.cc,
* sandbox/arthur/xml_to_html/domitem.hh,
* sandbox/arthur/xml_to_html/dommodel.cc,
* sandbox/arthur/xml_to_html/dommodel.hh: Move to...
* sandbox/arthur/xml_transform/README,
* sandbox/arthur/xml_transform/main.cc,
* sandbox/arthur/xml_transform/domitem.cc,
* sandbox/arthur/xml_transform/domitem.hh,
* sandbox/arthur/xml_transform/dommodel.cc,
* sandbox/arthur/xml_transform/dommodel.hh: ...this.
* sandbox/arthur/xml_to_html/patterns/css.css,
* sandbox/arthur/xml_to_html/patterns/xsl.xsl: Move to...
* sandbox/arthur/xml_transform/templates/html/css.css,
* sandbox/arthur/xml_transform/templates/html/xsl.xsl: ...this.
* sandbox/arthur/xml_transform/image_crop.cc,
* sandbox/arthur/xml_transform/loader.cc: New.
* sandbox/arthur/xml_transform/templates/html/html_generator.sh,
* sandbox/arthur/xml_transform/templates/pdf/line.xsl,
* sandbox/arthur/xml_transform/templates/pdf/main.xsl,
* sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl,
* sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh,
* sandbox/arthur/xml_transform/templates/pdf/regions.xsl,
* sandbox/arthur/xml_transform/xml_transform.pro: New.
---
scribo/ChangeLog | 39 +++
scribo/sandbox/arthur/xml_to_html/README | 25 --
scribo/sandbox/arthur/xml_to_html/main.cc | 58 ----
scribo/sandbox/arthur/xml_to_html/patterns/css.css | 28 --
scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl | 229 ---------------
scribo/sandbox/arthur/xml_to_html/xml_to_html.cc | 292 --------------------
scribo/sandbox/arthur/xml_to_html/xml_to_html.hh | 49 ----
scribo/sandbox/arthur/xml_to_html/xml_to_html.pro | 16 -
scribo/sandbox/arthur/xml_transform/README | 19 ++
.../{xml_to_html => xml_transform}/domitem.cc | 0
.../{xml_to_html => xml_transform}/domitem.hh | 0
.../{xml_to_html => xml_transform}/dommodel.cc | 0
.../{xml_to_html => xml_transform}/dommodel.hh | 0
scribo/sandbox/arthur/xml_transform/image_crop.cc | 184 ++++++++++++
scribo/sandbox/arthur/xml_transform/image_crop.hh | 46 +++
scribo/sandbox/arthur/xml_transform/loader.cc | 162 +++++++++++
scribo/sandbox/arthur/xml_transform/loader.hh | 49 ++++
scribo/sandbox/arthur/xml_transform/main.cc | 30 ++
.../arthur/xml_transform/templates/html/css.css | 31 ++
.../xml_transform/templates/html/html_generator.sh | 3 +
.../arthur/xml_transform/templates/html/xsl.xsl | 224 +++++++++++++++
.../arthur/xml_transform/templates/pdf/line.xsl | 129 +++++++++
.../arthur/xml_transform/templates/pdf/main.xsl | 62 ++++
.../xml_transform/templates/pdf/main_crop.xsl | 42 +++
.../xml_transform/templates/pdf/pdf_generator.sh | 3 +
.../arthur/xml_transform/templates/pdf/regions.xsl | 59 ++++
.../sandbox/arthur/xml_transform/xml_transform.cc | 93 +++++++
.../sandbox/arthur/xml_transform/xml_transform.hh | 48 ++++
.../sandbox/arthur/xml_transform/xml_transform.pro | 20 ++
29 files changed, 1243 insertions(+), 697 deletions(-)
delete mode 100644 scribo/sandbox/arthur/xml_to_html/README
delete mode 100644 scribo/sandbox/arthur/xml_to_html/main.cc
delete mode 100644 scribo/sandbox/arthur/xml_to_html/patterns/css.css
delete mode 100644 scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl
delete mode 100644 scribo/sandbox/arthur/xml_to_html/xml_to_html.cc
delete mode 100644 scribo/sandbox/arthur/xml_to_html/xml_to_html.hh
delete mode 100644 scribo/sandbox/arthur/xml_to_html/xml_to_html.pro
create mode 100644 scribo/sandbox/arthur/xml_transform/README
rename scribo/sandbox/arthur/{xml_to_html => xml_transform}/domitem.cc (100%)
rename scribo/sandbox/arthur/{xml_to_html => xml_transform}/domitem.hh (100%)
rename scribo/sandbox/arthur/{xml_to_html => xml_transform}/dommodel.cc (100%)
rename scribo/sandbox/arthur/{xml_to_html => xml_transform}/dommodel.hh (100%)
create mode 100644 scribo/sandbox/arthur/xml_transform/image_crop.cc
create mode 100644 scribo/sandbox/arthur/xml_transform/image_crop.hh
create mode 100644 scribo/sandbox/arthur/xml_transform/loader.cc
create mode 100644 scribo/sandbox/arthur/xml_transform/loader.hh
create mode 100644 scribo/sandbox/arthur/xml_transform/main.cc
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/html/css.css
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/html/html_generator.sh
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/pdf/line.xsl
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh
create mode 100644 scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl
create mode 100644 scribo/sandbox/arthur/xml_transform/xml_transform.cc
create mode 100644 scribo/sandbox/arthur/xml_transform/xml_transform.hh
create mode 100644 scribo/sandbox/arthur/xml_transform/xml_transform.pro
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index d7be39d..e58af8d 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,42 @@
+2010-07-08 Arthur Crepin-Leblond <crepin(a)ptaouchnok.lrde.epita.fr>
+
+ XML transform program.
+
+ * sandbox/arthur/xml_to_html/xml_to_html.hh,
+ * sandbox/arthur/xml_to_html/xml_to_html.cc,
+ * sandbox/arthur/xml_to_html/xml_to_html.pro: Remove.
+
+ * sandbox/arthur/xml_to_html/README,
+ * sandbox/arthur/xml_to_html/main.cc,
+ * sandbox/arthur/xml_to_html/domitem.cc,
+ * sandbox/arthur/xml_to_html/domitem.hh,
+ * sandbox/arthur/xml_to_html/dommodel.cc,
+ * sandbox/arthur/xml_to_html/dommodel.hh: Move to...
+
+ * sandbox/arthur/xml_transform/README,
+ * sandbox/arthur/xml_transform/main.cc,
+ * sandbox/arthur/xml_transform/domitem.cc,
+ * sandbox/arthur/xml_transform/domitem.hh,
+ * sandbox/arthur/xml_transform/dommodel.cc,
+ * sandbox/arthur/xml_transform/dommodel.hh: ...this.
+
+ * sandbox/arthur/xml_to_html/patterns/css.css,
+ * sandbox/arthur/xml_to_html/patterns/xsl.xsl: Move to...
+
+ * sandbox/arthur/xml_transform/templates/html/css.css,
+ * sandbox/arthur/xml_transform/templates/html/xsl.xsl: ...this.
+
+ * sandbox/arthur/xml_transform/image_crop.cc,
+ * sandbox/arthur/xml_transform/loader.cc: New.
+
+ * sandbox/arthur/xml_transform/templates/html/html_generator.sh,
+ * sandbox/arthur/xml_transform/templates/pdf/line.xsl,
+ * sandbox/arthur/xml_transform/templates/pdf/main.xsl,
+ * sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl,
+ * sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh,
+ * sandbox/arthur/xml_transform/templates/pdf/regions.xsl,
+ * sandbox/arthur/xml_transform/xml_transform.pro: New.
+
2010-06-30 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
Extended XML mode support.
diff --git a/scribo/sandbox/arthur/xml_to_html/README b/scribo/sandbox/arthur/xml_to_html/README
deleted file mode 100644
index f16f472..0000000
--- a/scribo/sandbox/arthur/xml_to_html/README
+++ /dev/null
@@ -1,25 +0,0 @@
-xml_to_html
-
-Produce HTML view from ICDAR (or LRDE extended) XML.
-
-*Compilation:
-
- Just change the paths to olena and milena in xml_to_html.pro
-
-*Usage:
-
- -m, --merge: Merge an XML with an other XML
- args: <xml_file_1> <xml_file_2> [xml_output]
-
-Useful to merge LRDE XML extended mode files with ICDAR XML files to combine both images and recognized text.
-
-
- -c, --create-html: Crop images (if exist) from the ppm file using the XML file and produce an html output.
- args: <xml_file> [ppm_file] [output dir]
-
-If no PPM file is given, the program will only produce an HTML output without images.
-If a PPM file is given, the program will crop image_region, separator_region, graphic_regions, chart_region and table_region to output_dir/img/id.png
-
-*Result:
-
-To view the result run your internet browser on output_dir/output.xml (Does not work with Chrome on local, use a LAMPP server to fix this ;-) ).
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_to_html/main.cc b/scribo/sandbox/arthur/xml_to_html/main.cc
deleted file mode 100644
index 9ec705a..0000000
--- a/scribo/sandbox/arthur/xml_to_html/main.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-#include <iostream>
-#include "xml_to_html.hh"
-
-int main(int argc, char **argv)
-{
-
- std::string man;
- man = "xml_to_html: ...usage\n -m, --merge: Merge an XML with an other XML\n \targs: <xml_file_1> <xml_file_2> [xml_output]\n\n -c, --create-html: Crop images (if exist) from the ppm file using the XML file and produce an html output.\n \targs: <xml_file> [ppm_file] [output dir]\n";
-
- if (argc > 2)
- {
- new QApplication::QApplication(argc, argv, false);
- ImageCrop crop;
-
- std::string merge = "--merge";
- std::string m = "-m";
- std::string scrop = "--create-html";
- std::string c = "-c";
-
- if (argc == 3 && (scrop.compare(argv[1]) == 0 || c.compare(argv[1]) == 0))
- {
- bool b = false;
- b = crop.load_xml(argv[2], QString::Null());
-
- if (b)
- crop.find_image_regions();
- }
- else if (argc > 3)
- {
- if (merge.compare(argv[1]) == 0 || m.compare(argv[1]) == 0)
- {
- if (argc > 4)
- crop.merge(argv[2], argv[3], argv[4]);
- else
- crop.merge(argv[2], argv[3]);
- }
- else if (scrop.compare(argv[1]) == 0 || c.compare(argv[1]) == 0)
- {
- bool b = false;
- if (argc > 4)
- b = crop.load_xml(argv[2], argv[3], argv[4]);
- else
- b = crop.load_xml(argv[2], argv[3]);
-
- if (b)
- crop.find_image_regions();
- }
- else
- std::cout << man;
- }
- else
- std::cout << man;
- }
- else
- std::cout << man;
-
- return 0;
-}
diff --git a/scribo/sandbox/arthur/xml_to_html/patterns/css.css b/scribo/sandbox/arthur/xml_to_html/patterns/css.css
deleted file mode 100644
index 7171754..0000000
--- a/scribo/sandbox/arthur/xml_to_html/patterns/css.css
+++ /dev/null
@@ -1,28 +0,0 @@
-.line
-{
- position:absolute;
- background-color:white;
- z-index:7;
- display:inline;
- white-space:pre;
- letter-spacing:-2px;
- padding:0px;
- margin:0px;
- filter:alpha(opacity=100);
- font-family:"Times New Roman", Times, serif;
-}
-.para
-{
- position:absolute;
- z-index:6;
-}
-.region
-{
- position:absolute;
- z-index:5;
-}
-.image
-{
- position:absolute;
- border:0;
-}
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl b/scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl
deleted file mode 100644
index aa5a078..0000000
--- a/scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl
+++ /dev/null
@@ -1,229 +0,0 @@
-<?xml version="1.0"?>
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
- <xsl:template match="/"> <!-- "/" means the whole document (root) -->
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title>Fooooooo !</title>
- <link rel="stylesheet" type="text/css" href="css.css" />
- </head>
- <body>
-
- <div class="image" style="top:0px;left:0px;">
- <img src="../../ppm/mp00076.png" />
- </div>
-
- <!-- BEGIN IMAGE REGION -->
- <xsl:for-each select="pcGts/page/graphic_region|
- pcGts/page/image_region|
- pcGts/page/chart_region|
- pcGts/page/table_region|
- pcGts/page/separator_region|
- pcGts/page/text_region|
- pcGts/page/text_region/paragraph|
- pcGts/page/text_region/paragraph/line">
-
- <!-- y1 -->
- <xsl:variable name="y1">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@y" order="ascending" data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@y" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- x2 -->
- <xsl:variable name="x2">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@x" order="descending" data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@x" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- y2 -->
- <xsl:variable name="y2">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@y" order="descending" data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@y" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- x1 -->
- <xsl:variable name="x1">
- <xsl:for-each select="coords/point">
- <xsl:sort select="@x" order="ascending" data-type="number"/>
- <xsl:if test="position() = 1">
- <xsl:value-of select="@x" />
- </xsl:if>
- </xsl:for-each>
- </xsl:variable>
-
- <!-- TEXT LINE-->
- <xsl:if test="name() = 'line'">
-
- <xsl:variable name="x_height">
- <xsl:value-of select="../../@x_height" />
- </xsl:variable>
-
- <xsl:variable name="a_height">
- <xsl:value-of select="../../@a_height" />
- </xsl:variable>
-
- <xsl:variable name="colour">
- <xsl:choose>
- <xsl:when test="../../@txt_colour != ''">
- <xsl:value-of select="../../@txt_colour" />
- </xsl:when>
- <xsl:otherwise>
- Black
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="d_height_tmp">
- <xsl:value-of select="../../@d_height" />
- </xsl:variable>
-
- <xsl:variable name="d_height">
- <xsl:choose>
- <xsl:when test="$d_height_tmp < 0">
- <xsl:value-of select="-$d_height_tmp" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$d_height_tmp" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="a">
- <xsl:choose>
- <xsl:when test="($a_height - $x_height) < $d_height">
- <xsl:value-of select="$x_height + $d_height" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$a_height" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="d">
- <xsl:choose>
- <xsl:when test="($a_height - $x_height) > $d_height">
- <xsl:value-of select="-($a_height - $x_height)" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$d_height" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <xsl:variable name="d_f">
- <xsl:choose>
- <xsl:when test="$d < 0">
- <xsl:value-of select="-$d" />
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$d" />
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <div class="line" onmouseover="this.style.opacity=0.2;this.filters.alpha.opacity=20"
- onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100">
- <xsl:attribute name="style">
- opacity:1;
- height:auto;
- font-size:<xsl:value-of select="$a+$d_f" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1 " />px;
- top:<xsl:value-of select="$y1 " />px;
- color:<xsl:value-of select="$colour" />;
- </xsl:attribute>
- <xsl:value-of select="@text"/>
- </div>
- </xsl:if>
- <!-- ENF OF TEXT LINE -->
-
- <!-- TEXT REGION -->
- <xsl:if test="name() = 'text_region'">
- <div class="region">
- <xsl:attribute name="style">
- height:<xsl:value-of select="$y2 - $y1" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1" />px;
- top:<xsl:value-of select="$y1" />px;
- </xsl:attribute>
- </div>
- </xsl:if>
- <!-- ENF OF TEXT REGION -->
-
- <!-- PARAGRAPH -->
- <xsl:if test="name() = 'paragraph'">
- <div class="para">
- <xsl:attribute name="style">
- height:<xsl:value-of select="$y2 - $y1" />px;
- width:<xsl:value-of select="$x2 - $x1" />px;
- left:<xsl:value-of select="$x1" />px;
- top:<xsl:value-of select="$y1" />px;
- </xsl:attribute>
- </div>
- </xsl:if>
- <!-- ENF OF PARAGRAPH -->
-
- <!-- NON-TEXT REGIONS -->
- <xsl:if test="name() = 'image_region' or name() = 'separator_region' or name() = 'graphic_region' or name() = 'chart_region' or name() = 'table_region'">
-
- <!-- id -->
- <xsl:variable name="id">
- <xsl:value-of select="@id" />
- </xsl:variable>
-
- <!-- depth -->
- <xsl:variable name="depth">
- <xsl:choose>
- <xsl:when test="name() = 'separator_region'">
- 1
- </xsl:when>
- <xsl:otherwise>
- 4
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
-
- <div class="image">
- <xsl:attribute name="style">
- top:<xsl:value-of select="$y1" />px;
- left:<xsl:value-of select="$x1" />px;
- width:<xsl:value-of select="$x2 - $x1"/>px;
- height:<xsl:value-of select="$y2 - $y1"/>px;
- z-index:<xsl:value-of select="$depth"/>;
- </xsl:attribute>
- <img>
- <xsl:attribute name="alt">
- <xsl:value-of select="name()" />
- </xsl:attribute>
- <xsl:attribute name="width">
- <xsl:value-of select="$x2 - $x1" />
- </xsl:attribute>
- <xsl:attribute name="height">
- <xsl:value-of select="$y2 - $y1" />
- </xsl:attribute>
- <xsl:attribute name="src">
- img/<xsl:value-of select="$id"/>.png</xsl:attribute>
- </img>
- </div>
-
- </xsl:if>
- <!-- END NON-TEXT REGIONS -->
- </xsl:for-each>
- </body>
- </html>
- </xsl:template>
-
-</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_to_html/xml_to_html.cc b/scribo/sandbox/arthur/xml_to_html/xml_to_html.cc
deleted file mode 100644
index 8267466..0000000
--- a/scribo/sandbox/arthur/xml_to_html/xml_to_html.cc
+++ /dev/null
@@ -1,292 +0,0 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-# include "xml_to_html.hh"
-# include "dommodel.hh"
-# include <limits.h>
-
-#include <scribo/preprocessing/crop.hh>
-#include <mln/value/rgb8.hh>
-#include <mln/core/alias/box2d.hh>
-#include <mln/core/image/image2d.hh>
-#include <mln/io/magick/save.hh>
-#include <mln/io/ppm/all.hh>
-
-ImageCrop::ImageCrop():
- regions_(false)
-{
-}
-
-ImageCrop::~ImageCrop()
-{
-}
-
-void ImageCrop::merge(QString in, QString other, QString output)
-{
- if (in.endsWith(".xml") && other.endsWith(".xml") && output.endsWith(".xml"))
- {
- QFile f_in(in);
- QFile f_other(other);
- QFile f_output(output);
-
- qDebug() << "Merging to " << output << "...";
-
- f_in.open(QIODevice::ReadOnly);
- f_other.open(QIODevice::ReadOnly);
- f_output.open(QIODevice::ReadWrite);
-
- QTextStream stream_in(&f_in);
- QTextStream stream_other(&f_other);
- QTextStream output_stream(&f_output);
-
- QString line = stream_in.readLine();
- output_stream << line;
- line = stream_in.readLine();
-
- while (!line.contains("</page>"))
- {
- output_stream << "\n" << line;
- line = stream_in.readLine();
- }
-
- line = stream_other.readLine();
-
- while (!line.contains("<page"))
- line = stream_other.readLine();
-
- line = stream_other.readLine();
-
- while (!line.contains("</pcGts>"))
- {
- output_stream << "\n" << line;
- line = stream_other.readLine();
- }
-
- output_stream << "\n" << line;
-
- f_in.close();
- f_other.close();
- f_output.close();
- }
- else
- std::cout << "merge : error, only xml files are needed." << std::endl;
-}
-
-bool ImageCrop::load_xml(QString xml_file, QString image_file, QString path)
-{
- if (xml_file.endsWith(".xml") && (image_file.endsWith(".ppm") || image_file == QString::Null()) )
- {
- image_file_ = image_file;
- regions_ = (image_file != QString::Null());
-
- path_ = path;
- if (!path_.endsWith("/"))
- path_.append("/");
-
- QDir dir(path_);
-
- if (!dir.mkpath("img"))
- {
- path_ = "output/";
- dir.mkpath(path_);
- dir.setPath(path_);
- dir.mkpath("img");
- }
-
- if (QFile::exists(xml_file))
- {
- QFile file(xml_file);
- QFile output(path_ + "output.xml");
- QFile xsl("patterns/xsl.xsl");
- QFile css("patterns/css.css");
- xsl.copy(path_ + "xsl.xsl");
- css.copy(path_ + "css.css");
-
- if (QFile::exists(path_ + "output.xml"))
- output.remove();
-
- output.open(QIODevice::ReadWrite);
- file.open(QIODevice::ReadOnly);
-
- QTextStream stream_in(&file);
- QTextStream stream_out(&output);
- stream_in.setCodec("UTF-8");
- stream_out.setCodec("UTF-8");
-
- QString line = stream_in.readLine();
- stream_out << line;
- stream_out << "\n<?xml-stylesheet type=\"text/xsl\" href=\"xsl.xsl\" ?>";
-
- // /!\ attributes of ICDAR PcGts removed.
- line = stream_in.readLine();
- stream_out << "\n<pcGts>";
-
- line = stream_in.readLine();
-
- while (!line.contains("</pcGts>"))
- {
- stream_out << "\n" << line;
- line = stream_in.readLine();
- }
-
- stream_out << "\n" << line;
-
- output.close();
- file.close();
-
- qDebug() << "Output saved to " + path_;
-
- if (file.open(QIODevice::ReadOnly))
- {
- QDomDocument document;
- if (document.setContent(&file))
- {
- layout_ = new DomModel(document, this);
- }
- else
- qDebug() << "Error while loading the XML file, please choose another.";
-
- file.close();
- }
- }
- return true;
- }
- else
- {
- std::cout << "Wrong files format !" << std::endl;
- return false;
- }
-}
-
-void ImageCrop::find_image_regions()
-{
- if (layout_ && regions_)
- {
- QModelIndex pgGts = layout_->index(1, 0);
- QModelIndex page = layout_->index(1, 0, pgGts);
- QModelIndex region;
- QModelIndex attributes;
- QModelIndex coords;
- QModelIndex point;
- bool regions_found = false;
- for (int i = 0; true; ++i)
- {
- region = layout_->index(i, 0, page);
- attributes = layout_->index(i, 1, page);
- QString name = layout_->data(region, Qt::DisplayRole).toString();
- coords = layout_->index(0, 0, region);
-
- bool is_image_region = name == QString("image_region")
- || name == QString("graphic_region")
- || name == QString("separator_region")
- || name == QString("chart_region")
- || name == QString("table_region") ;
-
- if (!region.isValid() || !coords.isValid())
- break;
-
- if (is_image_region)
- {
-
- regions_found = true;
- QMap<QString, QVariant> data =
- layout_->data(attributes, Qt::UserRole).toMap();
-
- QString id;
- QMap<QString, QVariant>::iterator it = data.find("id");
-
- if (it == data.end() || it.key() != "id")
- qDebug() << "No image region.";
-
- while (it != data.end() && it.key() == "id")
- {
- qDebug() << name;
- id = it.value().toString();
- qDebug() << it.key() + " = " + it.value().toString();
- ++it;
- }
-
- int x_max = 0;
- int y_max = 0;
- int x_min = INT_MAX;
- int y_min = INT_MAX;
-
- // QVector<QMap<QString, QVariant> > vect;
- for (int j = 0; true; ++j)
- {
- // Navigate to the coordinate list
- point = layout_->index(j, 1, coords);
- if (!point.isValid())
- break;
-
- QMap<QString, QVariant> data =
- layout_->data(point, Qt::UserRole).toMap();
- int x = data["x"].toInt();
- int y = data["y"].toInt();
-
- // vect << data;
-
- if (x < x_min)
- x_min = x;
- if (x > x_max)
- x_max = x;
-
- if (y < y_min)
- y_min = y;
- if (y > y_max)
- y_max = y;
-
- }
-
- using namespace mln;
-
- box2d box = make::box2d(y_min, x_min, y_max, x_max);
-
- image2d<value::rgb8> ima;
- io::ppm::load(ima, image_file_.toStdString());
- ima = scribo::preprocessing::crop(ima, box);
-
- // image2d<bool> mask = make::box2d(y_min, x_min, y_max, x_max);
- // data::fill(mask, true);
-
- /*for (int a = 1; a < vect.size(); ++a)
- {
- int x = vect[a]["x"].toInt();
- int y = vect[a]["y"].toInt();
-
- data::fill((mask | make::box2d(y, x, y, x)).rw(), false);
- }*/
-
-
- // io::pbm::save(mask, "output/img/mask_" + id.toStdString());
- io::magick::save(ima, path_.toStdString() + "img/" + id.toStdString() + ".png");
-
- }
- }
-
- if (!regions_found)
- qDebug() << "No regions found.";
- }
-}
diff --git a/scribo/sandbox/arthur/xml_to_html/xml_to_html.hh b/scribo/sandbox/arthur/xml_to_html/xml_to_html.hh
deleted file mode 100644
index 27a271e..0000000
--- a/scribo/sandbox/arthur/xml_to_html/xml_to_html.hh
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
-//
-// This file is part of Olena.
-//
-// Olena is free software: you can redistribute it and/or modify it under
-// the terms of the GNU General Public License as published by the Free
-// Software Foundation, version 2 of the License.
-//
-// Olena is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Olena. If not, see <http://www.gnu.org/licenses/>.
-//
-// As a special exception, you may use this file as part of a free
-// software project without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to produce
-// an executable, this file does not by itself cause the resulting
-// executable to be covered by the GNU General Public License. This
-// exception does not however invalidate any other reasons why the
-// executable file might be covered by the GNU General Public License.
-
-#ifndef IMAGE_CROP_HH
-# define IMAGE_CROP_HH
-
-# include <QtGui>
-
-class DomModel;
-
-class ImageCrop : public QObject
-{
- Q_OBJECT
- public:
- ImageCrop();
- ~ImageCrop();
- void merge(QString in, QString other, QString output = "output.xml");
- bool load_xml(QString xml_file, QString image_file = "", QString path = "output");
- void find_image_regions();
- private:
- DomModel* layout_;
- QString image_file_;
- QString path_;
- bool regions_;
-};
-
-#endif /* !IMAGE_CROP_HH */
diff --git a/scribo/sandbox/arthur/xml_to_html/xml_to_html.pro b/scribo/sandbox/arthur/xml_to_html/xml_to_html.pro
deleted file mode 100644
index b43b527..0000000
--- a/scribo/sandbox/arthur/xml_to_html/xml_to_html.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-######################################################################
-# Automatically generated by qmake (2.01a) lun. juil. 5 16:53:31 2010
-######################################################################
-
-TEMPLATE = app
-TARGET =
-DEPENDPATH += .
-INCLUDEPATH += .
-QMAKE_CXXFLAGS += -I/amd/beyrouth/home/lrde/stage/crepin/olena/milena -I/amd/beyrouth/home/lrde/stage/crepin/olena/
-QT += xml
-LIBS += `Magick++-config --libs`
-
-
-# Input
-HEADERS += domitem.hh dommodel.hh xml_to_html.hh
-SOURCES += domitem.cc dommodel.cc main.cc xml_to_html.cc
diff --git a/scribo/sandbox/arthur/xml_transform/README b/scribo/sandbox/arthur/xml_transform/README
new file mode 100644
index 0000000..e0bfbc8
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/README
@@ -0,0 +1,19 @@
+xml_transform <option> <xml_file> <ppm_file> <output_dir>
+
+Transforms an ICDAR XML file to different kind of output.
+
+OPTIONS:
+
+ --html: Produce a HTML output
+
+Once process is finished, open output.xml with your internet browser. If this one supports XSLT, there is no problem to display the result but if it does not support it (like Konqueror or Chrome in local), you should run `sh html_generator.sh` (xsltproc package required) to generate a HTML file readable by all browsers.
+
+ --pdf: Produce a PDF output, regions will be cropped as follows in the XML file.
+ --pdf-no-crop: Produce a PDF output without cropping regions, the entire picture will be displayed.
+
+PDF is not directly created once the process is finished, to produce it, go to the output_dir and run `sh pdf_generator.sh` (fop >= 0.95 required).
+
+
+BUILD:
+
+Chnage the environment variable QMAKE_CXXFLAGS to indicate the correct paths to milena and olena then, just type qmake and make.
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_to_html/domitem.cc b/scribo/sandbox/arthur/xml_transform/domitem.cc
similarity index 100%
rename from scribo/sandbox/arthur/xml_to_html/domitem.cc
rename to scribo/sandbox/arthur/xml_transform/domitem.cc
diff --git a/scribo/sandbox/arthur/xml_to_html/domitem.hh b/scribo/sandbox/arthur/xml_transform/domitem.hh
similarity index 100%
rename from scribo/sandbox/arthur/xml_to_html/domitem.hh
rename to scribo/sandbox/arthur/xml_transform/domitem.hh
diff --git a/scribo/sandbox/arthur/xml_to_html/dommodel.cc b/scribo/sandbox/arthur/xml_transform/dommodel.cc
similarity index 100%
rename from scribo/sandbox/arthur/xml_to_html/dommodel.cc
rename to scribo/sandbox/arthur/xml_transform/dommodel.cc
diff --git a/scribo/sandbox/arthur/xml_to_html/dommodel.hh b/scribo/sandbox/arthur/xml_transform/dommodel.hh
similarity index 100%
rename from scribo/sandbox/arthur/xml_to_html/dommodel.hh
rename to scribo/sandbox/arthur/xml_transform/dommodel.hh
diff --git a/scribo/sandbox/arthur/xml_transform/image_crop.cc b/scribo/sandbox/arthur/xml_transform/image_crop.cc
new file mode 100644
index 0000000..aa17c31
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/image_crop.cc
@@ -0,0 +1,184 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+# include "image_crop.hh"
+# include "loader.hh"
+# include "dommodel.hh"
+
+# include <limits.h>
+
+#include <scribo/preprocessing/crop.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/core/alias/box2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/io/magick/save.hh>
+#include <mln/io/ppm/all.hh>
+
+ImageCrop::ImageCrop()
+{
+}
+
+ImageCrop::~ImageCrop()
+{
+}
+
+void ImageCrop::save_image(QString image, QString output)
+{
+ using namespace mln;
+
+ image2d<value::rgb8> ima;
+ io::ppm::load(ima, image.toStdString());
+
+ io::magick::save(ima, output.toStdString() + "img/image.png");
+}
+
+void ImageCrop::crop_regions(QString xml_file, QString image_file, QString output)
+{
+ Loader loader;
+
+ QFile f(image_file);
+
+ if (!f.exists())
+ {
+ qDebug() << "Image doesn't exist !";
+ abort();
+ }
+ DomModel* layout = loader.xml_to_dom(xml_file);
+ if (layout)
+ {
+ QModelIndex pcGts = layout->index(1, 0);
+ QModelIndex page = layout->index(1, 0, pcGts);
+ QModelIndex region;
+ QModelIndex attributes;
+ QModelIndex coords;
+ QModelIndex point;
+ bool regions_found = false;
+
+ for (int i = 0; true; ++i)
+ {
+ region = layout->index(i, 0, page);
+ attributes = layout->index(i, 1, page);
+
+ QString name = layout->data(region, Qt::DisplayRole).toString();
+ coords = layout->index(0, 0, region);
+
+ bool is_region =
+ name == QString("image_region")
+ || name == QString("graphic_region")
+ || name == QString("separator_region")
+ || name == QString("chart_region")
+ || name == QString("table_region") ;
+
+ if (!region.isValid() || !coords.isValid())
+ break;
+
+ if (is_region)
+ {
+ regions_found = true;
+ QMap<QString, QVariant> data =
+ layout->data(attributes, Qt::UserRole).toMap();
+
+ QString id;
+ QMap<QString, QVariant>::iterator it = data.find("id");
+
+ if (it == data.end() || it.key() != "id")
+ qDebug() << "WTF_Error : No image region.";
+
+ while (it != data.end() && it.key() == "id")
+ {
+ qDebug() << name;
+ id = it.value().toString();
+ qDebug() << it.key() + " = " + it.value().toString();
+ ++it;
+ }
+
+ int x_max = 0;
+ int y_max = 0;
+ int x_min = INT_MAX;
+ int y_min = INT_MAX;
+
+ // QVector<QMap<QString, QVariant> > vect;
+ for (int j = 0; true; ++j)
+ {
+ // Navigate to the coordinate list
+ point = layout->index(j, 1, coords);
+ if (!point.isValid())
+ break;
+
+ QMap<QString, QVariant> data =
+ layout->data(point, Qt::UserRole).toMap();
+ int x = data["x"].toInt();
+ int y = data["y"].toInt();
+
+ // vect << data;
+
+ if (x < x_min)
+ x_min = x;
+ if (x > x_max)
+ x_max = x;
+
+ if (y < y_min)
+ y_min = y;
+ if (y > y_max)
+ y_max = y;
+
+ }
+
+ using namespace mln;
+
+ box2d box = make::box2d(y_min, x_min, y_max, x_max);
+
+ image2d<value::rgb8> ima;
+ io::ppm::load(ima, image_file.toStdString());
+ ima = scribo::preprocessing::crop(ima, box);
+
+ // image2d<bool> mask = make::box2d(y_min, x_min, y_max, x_max);
+ // data::fill(mask, true);
+
+ /*for (int a = 1; a < vect.size(); ++a)
+ {
+ int x = vect[a]["x"].toInt();
+ int y = vect[a]["y"].toInt();
+
+ data::fill((mask | make::box2d(y, x, y, x)).rw(), false);
+ }*/
+
+ // io::pbm::save(mask, "output/img/mask_" + id.toStdString());
+ io::magick::save(ima, output.toStdString() + "img/" + id.toStdString() + ".png");
+
+ }
+ }
+
+ if (!regions_found)
+ qDebug() << "No regions found.";
+
+ }
+ else
+ {
+ qDebug() << "Error with XML file.";
+ }
+
+
+}
diff --git a/scribo/sandbox/arthur/xml_transform/image_crop.hh b/scribo/sandbox/arthur/xml_transform/image_crop.hh
new file mode 100644
index 0000000..e4b0a38
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/image_crop.hh
@@ -0,0 +1,46 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef IMAGE_CROP_HH
+# define IMAGE_CROP_HH
+
+# include <QtGui>
+
+class DomModel;
+
+class ImageCrop : public QObject
+{
+ Q_OBJECT
+ public:
+
+ ImageCrop();
+ ~ImageCrop();
+
+ void save_image(QString image, QString output);
+ void crop_regions(QString xml_file, QString image_file, QString output);
+
+};
+
+#endif /* !IMAGE_CROP_HH */
diff --git a/scribo/sandbox/arthur/xml_transform/loader.cc b/scribo/sandbox/arthur/xml_transform/loader.cc
new file mode 100644
index 0000000..5623928
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/loader.cc
@@ -0,0 +1,162 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+# include "loader.hh"
+# include "dommodel.hh"
+# include "xml_transform.hh"
+
+Loader::Loader()
+{
+}
+
+Loader::~Loader()
+{
+}
+
+DomModel* Loader::xml_to_dom(QString output)
+{
+ QString file_path = output;
+
+ QFile file(file_path);
+
+ if (file.open(QIODevice::ReadOnly))
+ {
+ QDomDocument document;
+ if (document.setContent(&file))
+ {
+ return new DomModel(document);
+ }
+ }
+
+ return 0;
+}
+
+bool Loader::set_output(QString& output)
+{
+ QDir dir(output);
+
+ if (!output.endsWith("/"))
+ output.append("/");
+
+ if (!dir.exists())
+ {
+ return dir.mkpath(".");
+ }
+ else
+ {
+ QStringList list = dir.entryList(QDir::Writable | QDir::AllDirs);
+ return list.size() != 0;
+ }
+}
+
+
+void Loader::add_html_templates(QString output)
+{
+
+ QFile gen("templates/html/html_generator.sh");
+ gen.copy(output + "html_generator.sh");
+
+ QFile css("templates/html/css.css");
+ css.copy(output + "css.css");
+
+ QFile xsl("templates/html/xsl.xsl");
+ xsl.copy(output + "xsl.xsl");
+
+}
+
+void Loader::add_pdf_templates(bool crop, QString output)
+{
+
+ QFile regions("templates/pdf/regions.xsl");
+ regions.copy(output + "regions.xsl");
+
+ QFile gen("templates/pdf/pdf_generator.sh");
+ gen.copy(output + "pdf_generator.sh");
+
+ QFile line("templates/pdf/line.xsl");
+ line.copy(output + "line.xsl");
+ if (crop)
+ {
+ QFile xsl("templates/pdf/main_crop.xsl");
+ xsl.copy(output + "main.xsl");
+ }
+ else
+ {
+ QFile xsl("templates/pdf/main.xsl");
+ xsl.copy(output + "main.xsl");
+ }
+}
+
+bool Loader::load_xml(QString xml_file, bool html, QString output)
+{
+ QFile file(xml_file);
+
+ if (file.exists())
+ {
+ file.open(QIODevice::ReadOnly);
+ set_output(output);
+
+ QFile out_file(output + "output.xml");
+ out_file.open(QIODevice::ReadWrite);
+
+ QTextStream stream_in(&file);
+ QTextStream stream_out(&out_file);
+
+ QString line = stream_in.readLine();
+
+ while(!line.contains("<?xml"))
+ line = stream_in.readLine();
+
+ stream_out << line;
+
+ if (html)
+ stream_out << "\n<?xml-stylesheet type=\"text/xsl\" href=\"xsl.xsl\" ?>";
+
+ // /!\ attributes of ICDAR PcGts removed.
+ while(!line.contains("<pcGts"))
+ line = stream_in.readLine();
+
+ line = stream_in.readLine();
+ stream_out << "\n<pcGts>";
+
+ while (!line.contains("</pcGts>"))
+ {
+ stream_out << "\n" << line;
+ line = stream_in.readLine();
+ }
+
+ stream_out << "\n" << line;
+
+ file.close();
+ out_file.close();
+
+ return true;
+ }
+ else
+ {
+ qDebug() << xml_file + " doesn't exist";
+ return false;
+ }
+}
diff --git a/scribo/sandbox/arthur/xml_transform/loader.hh b/scribo/sandbox/arthur/xml_transform/loader.hh
new file mode 100644
index 0000000..7d24254
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/loader.hh
@@ -0,0 +1,49 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef LOADER_HH
+# define LOADER_HH
+
+//# include <QtGui>
+# include "xml_transform.hh"
+
+class DomModel;
+
+class Loader
+{
+ public:
+
+ Loader();
+ ~Loader();
+
+ // void merge(QString in, QString other, QString output = "output.xml");
+ bool load_xml(QString xml_file, bool html, QString output);
+ DomModel* xml_to_dom(QString output);
+ bool set_output(QString& output);
+ void add_pdf_templates(bool crop, QString output);
+ void add_html_templates(QString output);
+};
+
+#endif /* !LOADER_HH */
diff --git a/scribo/sandbox/arthur/xml_transform/main.cc b/scribo/sandbox/arthur/xml_transform/main.cc
new file mode 100644
index 0000000..9e18cff
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/main.cc
@@ -0,0 +1,30 @@
+#include <iostream>
+#include "xml_transform.hh"
+
+int main(int argc, char **argv)
+{
+
+ std::string man = "xml_transform <option> <xml_file> <ppm_file> <output_dir>\nOPTIONS:\n\t--html: Produce a HTML output\n\t--pdf: Produce a PDF output, regions will be croped as follows in the XML file.\n\t--pdf-no-crop: Produce a PDF output without croping regions, the entire picture will be displayed.";
+
+ if (argc > 4)
+ {
+ std::string html = "--html";
+ std::string pdf = "--pdf";
+ std::string pdf_no_crop = "--pdf-no-crop";
+
+ XmlTransform xmlt(argv[4], argv[2]);
+
+ if (html.compare(argv[1]) == 0)
+ xmlt.createHTML(argv[3]);
+ else if (pdf.compare(argv[1]) == 0)
+ xmlt.createPDF(argv[3], true);
+ else if (pdf_no_crop.compare(argv[1]) == 0)
+ xmlt.createPDF(argv[3], false);
+ else
+ std::cout << man << std::endl;
+ }
+ else
+ std::cout << man << std::endl;
+
+ return 0;
+}
diff --git a/scribo/sandbox/arthur/xml_transform/templates/html/css.css b/scribo/sandbox/arthur/xml_transform/templates/html/css.css
new file mode 100644
index 0000000..0443390
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/html/css.css
@@ -0,0 +1,31 @@
+.line
+{
+ position:absolute;
+ background-color:white;
+ z-index:7;
+ display:inline;
+ white-space:pre;
+
+ /* FIXME */
+ letter-spacing:-2px;
+
+ padding:0px;
+ margin:0px;
+ filter:alpha(opacity=100);
+ font-family:"Times New Roman", Times, serif;
+}
+.para
+{
+ position:absolute;
+ z-index:6;
+}
+.region
+{
+ position:absolute;
+ z-index:5;
+}
+.image
+{
+ position:absolute;
+ border:0;
+}
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_transform/templates/html/html_generator.sh b/scribo/sandbox/arthur/xml_transform/templates/html/html_generator.sh
new file mode 100644
index 0000000..bb24305
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/html/html_generator.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+xsltproc xsl.xsl output.xml > output.html
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl b/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
new file mode 100644
index 0000000..3d6a1c5
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/html/xsl.xsl
@@ -0,0 +1,224 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/"> <!-- "/" means the whole document (root) -->
+ <html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>SCRIBO</title>
+ <link rel="stylesheet" type="text/css" href="css.css" />
+ </head>
+ <body>
+
+ <xsl:for-each select="pcGts/page/graphic_region|
+ pcGts/page/image_region|
+ pcGts/page/chart_region|
+ pcGts/page/table_region|
+ pcGts/page/separator_region|
+ pcGts/page/text_region|
+ pcGts/page/text_region/paragraph|
+ pcGts/page/text_region/paragraph/line">
+
+ <!-- Regions Coordinates -->
+
+ <!-- y1 -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x2 -->
+ <xsl:variable name="x2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="descending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- y2 -->
+ <xsl:variable name="y2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="descending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x1 -->
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- END OF Regions Coordinates -->
+
+ <!-- TEXT LINE-->
+ <xsl:if test="name() = 'line'">
+
+ <xsl:variable name="colour">
+ <xsl:choose>
+ <xsl:when test="../../@txt_colour != ''">
+ <xsl:value-of select="../../@txt_colour" />
+ </xsl:when>
+ <xsl:otherwise>
+ Black
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- x_height -->
+ <xsl:variable name="x_height">
+ <xsl:value-of select="../../@x_height" />
+ </xsl:variable>
+
+ <!-- a_height -->
+ <xsl:variable name="a_height">
+ <xsl:value-of select="../../@a_height" />
+ </xsl:variable>
+
+ <!-- ABS(d_height) -->
+ <xsl:variable name="d_height_abs">
+ <xsl:choose>
+ <xsl:when test="../../@d_height < 0">
+ <xsl:value-of select="-../../@d_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="../../@d_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- a_height computed, i.e>
+ if (A - X < |D|)
+ A = X + |D|
+ -->
+ <xsl:variable name="a">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) < $d_height_abs">
+ <xsl:value-of select="$x_height + $d_height_abs" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$a_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- d_height computed, i.e>
+ if (A - A > |D|)
+ |D| = A - X
+ -->
+ <xsl:variable name="d">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) > $d_height_abs">
+ <xsl:value-of select="$a_height - $x_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$d_height_abs" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <div class="line" onmouseover="this.style.opacity=0.2;this.filters.alpha.opacity=20"
+ onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100">
+ <xsl:attribute name="style">
+ opacity:1;
+ height:auto;
+ font-size:<xsl:value-of select="$a+$d" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1 " />px;
+ top:<xsl:value-of select="$y1 " />px;
+ color:<xsl:value-of select="$colour" />;
+ </xsl:attribute>
+ <xsl:value-of select="@text"/>
+ </div>
+ </xsl:if>
+ <!-- ENF OF TEXT LINE -->
+
+ <!-- TEXT REGION -->
+ <xsl:if test="name() = 'text_region'">
+ <div class="region">
+ <xsl:attribute name="style">
+ height:<xsl:value-of select="$y2 - $y1" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ top:<xsl:value-of select="$y1" />px;
+ </xsl:attribute>
+ </div>
+ </xsl:if>
+ <!-- ENF OF TEXT REGION -->
+
+ <!-- PARAGRAPH -->
+ <xsl:if test="name() = 'paragraph'">
+ <div class="para">
+ <xsl:attribute name="style">
+ height:<xsl:value-of select="$y2 - $y1" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ top:<xsl:value-of select="$y1" />px;
+ </xsl:attribute>
+ </div>
+ </xsl:if>
+ <!-- ENF OF PARAGRAPH -->
+
+ <!-- NON-TEXT REGIONS -->
+ <xsl:if test="name() = 'image_region' or name() = 'separator_region' or name() = 'graphic_region' or name() = 'chart_region' or name() = 'table_region'">
+
+ <!-- id -->
+ <xsl:variable name="id">
+ <xsl:value-of select="@id" />
+ </xsl:variable>
+
+ <!-- depth -->
+ <xsl:variable name="depth">
+ <xsl:choose>
+ <xsl:when test="name() = 'separator_region'">
+ 1
+ </xsl:when>
+ <xsl:otherwise>
+ 4
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <div class="image">
+ <xsl:attribute name="style">
+ top:<xsl:value-of select="$y1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ width:<xsl:value-of select="$x2 - $x1"/>px;
+ height:<xsl:value-of select="$y2 - $y1"/>px;
+ z-index:<xsl:value-of select="$depth"/>;
+ </xsl:attribute>
+ <img>
+ <xsl:attribute name="alt">
+ <xsl:value-of select="name()" />
+ </xsl:attribute>
+ <xsl:attribute name="width">
+ <xsl:value-of select="$x2 - $x1" />
+ </xsl:attribute>
+ <xsl:attribute name="height">
+ <xsl:value-of select="$y2 - $y1" />
+ </xsl:attribute>
+ <xsl:attribute name="src">
+ img/<xsl:value-of select="$id"/>.png</xsl:attribute>
+ </img>
+ </div>
+
+ </xsl:if>
+ <!-- END NON-TEXT REGIONS -->
+ </xsl:for-each>
+ </body>
+ </html>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/line.xsl b/scribo/sandbox/arthur/xml_transform/templates/pdf/line.xsl
new file mode 100644
index 0000000..b143502
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/line.xsl
@@ -0,0 +1,129 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
+
+ <!-- FILE: line.xsl
+ DESCRIPTION: match all pcGts/page/text_region/paragraph/line in order to display the "text" attributes
+ -->
+
+ <xsl:template match="pcGts/page/text_region/paragraph/line">
+
+ <!-- x_height -->
+ <xsl:variable name="x_height">
+ <xsl:value-of select="../../@x_height" />
+ </xsl:variable>
+
+ <!-- a_height -->
+ <xsl:variable name="a_height">
+ <xsl:value-of select="../../@a_height" />
+ </xsl:variable>
+
+
+ <!-- ABS(d_height) -->
+ <xsl:variable name="d_height_abs">
+ <xsl:choose>
+ <xsl:when test="../../@d_height < 0">
+ <xsl:value-of select="-../../@d_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="../../@d_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- a_height computed, i.e>
+ if (A - X < |D|)
+ A = X + |D|
+ -->
+ <xsl:variable name="a">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) < $d_height_abs">
+ <xsl:value-of select="$x_height + $d_height_abs" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$a_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- d_height computed, i.e>
+ if (A - A > |D|)
+ |D| = A - X
+ -->
+ <xsl:variable name="d">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) > $d_height_abs">
+ <xsl:value-of select="$a_height - $x_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$d_height_abs" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <!-- Text lines coordinates -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <!-- END OF lines coordinates -->
+
+ <!-- WTF !?, Necessary to do a lower-case ! -->
+ <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
+ <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
+
+ <!-- Text Colour -->
+ <xsl:variable name="colour">
+ <xsl:choose>
+ <xsl:when test="../../@txt_colour != ''">
+ <xsl:value-of select="translate(../../@txt_colour, $smallcase, $uppercase)" />
+ </xsl:when>
+ <xsl:otherwise>
+ black
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+
+ <fo:block-container position="absolute">
+
+ <xsl:attribute name="left">
+ <xsl:value-of select="$x1" />px
+ </xsl:attribute>
+ <xsl:attribute name="top">
+ <xsl:value-of select="$y1" />px
+ </xsl:attribute>
+
+ <xsl:attribute name="color">
+ <xsl:value-of select="$colour" />
+ </xsl:attribute>
+
+ <!-- if necessary, put letter-spacing="-Npt" ~ -3 <= N <= -1
+ in fo:block-->
+
+ <fo:block font-family="Times">
+
+ <xsl:attribute name="font-size">
+ <xsl:value-of select="$a + $d" />px
+ </xsl:attribute>
+
+ <xsl:value-of select="@text"/>
+ </fo:block>
+
+ </fo:block-container>
+
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl b/scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl
new file mode 100644
index 0000000..065831e
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/main.xsl
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
+
+ <!-- FILE: main.xsl
+ DESCRIPTION: produce pdf output -->
+
+ <xsl:import href="line.xsl"/>
+
+ <xsl:template match="/">
+ <fo:root>
+
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page" margin-left="0cm" margin-right="0cm" margin-bottom="0cm" margin-top="0cm">
+
+ <!-- Output will be sized with image size -->
+ <xsl:attribute name="page-width">
+ <xsl:value-of select="pcGts/page/@image_width" />px
+ </xsl:attribute>
+ <xsl:attribute name="page-height">
+ <xsl:value-of select="pcGts/page/@image_height" />px
+ </xsl:attribute>
+
+ <fo:region-body
+ margin-top="0mm" margin-bottom="0mm"
+ margin-left="0mm" margin-right="0mm"/>
+ <fo:region-after extent="0mm"/>
+
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+
+ <fo:page-sequence master-reference="page">
+
+ <fo:flow flow-name="xsl-region-body">
+
+ <xsl:apply-imports />
+
+ <fo:block-container position="absolute" z-index="-3">
+
+ <xsl:attribute name="left">
+ 0px
+ </xsl:attribute>
+ <xsl:attribute name="top">
+ 0px
+ </xsl:attribute>
+
+ <fo:block>
+ <fo:external-graphic>
+ <xsl:attribute name="src">
+ url('img/image.png')
+ </xsl:attribute>
+ </fo:external-graphic>
+ </fo:block>
+
+ </fo:block-container>
+
+ </fo:flow>
+
+ </fo:page-sequence>
+ </fo:root>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl b/scribo/sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl
new file mode 100644
index 0000000..0dbb673
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/main_crop.xsl
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
+
+ <!-- FILE: main.xsl
+ DESCRIPTION: produce pdf output -->
+
+ <xsl:import href="regions.xsl"/>
+ <xsl:import href="line.xsl"/>
+
+ <xsl:template match="/">
+ <fo:root>
+
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="page" margin-left="0cm" margin-right="0cm" margin-bottom="0cm" margin-top="0cm">
+
+ <!-- Output will be sized with image size -->
+ <xsl:attribute name="page-width">
+ <xsl:value-of select="pcGts/page/@image_width" />px
+ </xsl:attribute>
+ <xsl:attribute name="page-height">
+ <xsl:value-of select="pcGts/page/@image_height" />px
+ </xsl:attribute>
+
+ <fo:region-body
+ margin-top="0mm" margin-bottom="0mm"
+ margin-left="0mm" margin-right="0mm"/>
+ <fo:region-after extent="0mm"/>
+
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+
+ <fo:page-sequence master-reference="page">
+
+ <fo:flow flow-name="xsl-region-body">
+ <xsl:apply-imports />
+ </fo:flow>
+
+ </fo:page-sequence>
+ </fo:root>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh b/scribo/sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh
new file mode 100644
index 0000000..c6339a5
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/pdf_generator.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+fop -xsl main.xsl -xml output.xml -pdf output.pdf
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl b/scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl
new file mode 100644
index 0000000..65a8c79
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/templates/pdf/regions.xsl
@@ -0,0 +1,59 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
+
+ <!-- FILE: regions.xsl
+ DESCRIPTION: Match all regions that are not text to display them -->
+
+ <xsl:template match="pcGts/page/image_region|
+ pcGts/page/graphic_region|
+ pcGts/page/chart_region|
+ pcGts/page/table_region|
+ pcGts/page/separator_region">
+
+ <!-- ID of the region, used to display id.png -->
+ <xsl:variable name="id">
+ <xsl:value-of select="@id" />
+ </xsl:variable>
+
+ <!-- Regions coordinates -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <!-- END OF regions coordinates -->
+
+ <fo:block-container position="absolute">
+
+ <xsl:attribute name="left">
+ <xsl:value-of select="$x1" />px
+ </xsl:attribute>
+ <xsl:attribute name="top">
+ <xsl:value-of select="$y1" />px
+ </xsl:attribute>
+
+ <fo:block>
+ <fo:external-graphic>
+ <xsl:attribute name="src">
+ url('img/<xsl:value-of select="$id" />.png')
+ </xsl:attribute>
+ </fo:external-graphic>
+ </fo:block>
+
+ </fo:block-container>
+
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.cc b/scribo/sandbox/arthur/xml_transform/xml_transform.cc
new file mode 100644
index 0000000..dd35aff
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.cc
@@ -0,0 +1,93 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+# include "image_crop.hh"
+# include "loader.hh"
+# include "xml_transform.hh"
+
+XmlTransform::XmlTransform(QString output, QString xml_file) :
+ output_dir_(output),
+ xml_file_(xml_file)
+{
+ Loader loader;
+ if (!loader.set_output(output_dir_))
+ abort();
+}
+
+XmlTransform::~XmlTransform()
+{
+}
+
+void XmlTransform::createPDF (QString img, bool crop)
+{
+ Loader loader;
+
+ QString output = output_dir_;
+ output.append("img");
+
+ if (loader.set_output(output))
+ {
+ if (loader.load_xml(xml_file_, false, output_dir_))
+ {
+
+ ImageCrop Crop;
+
+ if (crop)
+ Crop.crop_regions(xml_file_, img, output_dir_);
+ else
+ Crop.save_image(img, output_dir_);
+
+ loader.add_pdf_templates(crop, output_dir_);
+ }
+ else
+ abort();
+ }
+ else
+ abort();
+}
+
+void XmlTransform::createHTML(QString img)
+{
+ Loader loader;
+
+ QString output = output_dir_;
+ output.append("img");
+
+ if (loader.set_output(output))
+ {
+ if (loader.load_xml(xml_file_, true, output_dir_))
+ {
+ ImageCrop Crop;
+
+ Crop.crop_regions(xml_file_, img, output_dir_);
+ loader.add_html_templates(output_dir_);
+ }
+ else
+ abort();
+ }
+ else
+ abort();
+}
+
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.hh b/scribo/sandbox/arthur/xml_transform/xml_transform.hh
new file mode 100644
index 0000000..808c108
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.hh
@@ -0,0 +1,48 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+#ifndef XML_TRANFORM_HH
+# define XML_TRANFORM_HH
+
+# include <QtGui>
+
+class XmlTransform : public QObject
+{
+ Q_OBJECT
+ public:
+
+ XmlTransform(QString output, QString xml_file);
+ ~XmlTransform();
+
+ void createHTML(QString img);
+ void createPDF(QString img, bool crop);
+
+protected:
+ QString output_dir_;
+ QString xml_file_;
+};
+
+#endif // !XML_TRANFORM_HH
+
diff --git a/scribo/sandbox/arthur/xml_transform/xml_transform.pro b/scribo/sandbox/arthur/xml_transform/xml_transform.pro
new file mode 100644
index 0000000..161a7f4
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_transform/xml_transform.pro
@@ -0,0 +1,20 @@
+######################################################################
+# Automatically generated by qmake (2.01a) jeu. juil. 8 16:33:27 2010
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+QMAKE_CXXFLAGS += -I/amd/beyrouth/home/lrde/stage/crepin/git/olena/milena -I/amd/beyrouth/home/lrde/stage/crepin/git/olena/
+QT += xml
+LIBS += `Magick++-config --libs`
+
+# Input
+HEADERS += domitem.hh dommodel.hh image_crop.hh loader.hh xml_transform.hh
+SOURCES += domitem.cc \
+ dommodel.cc \
+ image_crop.cc \
+ loader.cc \
+ main.cc \
+ xml_transform.cc
--
1.5.6.5
1
0
* arthur/xml_to_html/domitem.cc,
* arthur/xml_to_html/domitem.hh.,
* arthur/xml_to_html/dommodel.cc,
* arthur/xml_to_html/dommodel.hh: XML parsing.
* arthur/xml_to_html/patterns/css.css,
* arthur/xml_to_html/patterns/xsl.xsl: HTML patterns.
* arthur/xml_to_html/xml_to_html.cc,
* arthur/xml_to_html/xml_to_html.hh: Image cropingd XML merging.
* arthur/xml_to_html/README
* arthur/xml_to_html/xml_to_html.pro
* arthur/xml_to_html/main.cc
---
scribo/sandbox/ChangeLog | 19 ++
scribo/sandbox/arthur/xml_to_html/README | 25 ++
.../arthur/xml_to_html}/domitem.cc | 0
.../arthur/xml_to_html}/domitem.hh | 0
.../arthur/xml_to_html}/dommodel.cc | 0
.../arthur/xml_to_html}/dommodel.hh | 0
scribo/sandbox/arthur/xml_to_html/main.cc | 58 ++++
scribo/sandbox/arthur/xml_to_html/patterns/css.css | 28 ++
scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl | 229 +++++++++++++++
scribo/sandbox/arthur/xml_to_html/xml_to_html.cc | 292 ++++++++++++++++++++
.../arthur/xml_to_html/xml_to_html.hh} | 40 +--
scribo/sandbox/arthur/xml_to_html/xml_to_html.pro | 16 +
12 files changed, 683 insertions(+), 24 deletions(-)
create mode 100644 scribo/sandbox/arthur/xml_to_html/README
copy scribo/{demo/viewer => sandbox/arthur/xml_to_html}/domitem.cc (100%)
copy scribo/{demo/viewer => sandbox/arthur/xml_to_html}/domitem.hh (100%)
copy scribo/{demo/viewer => sandbox/arthur/xml_to_html}/dommodel.cc (100%)
copy scribo/{demo/viewer => sandbox/arthur/xml_to_html}/dommodel.hh (100%)
create mode 100644 scribo/sandbox/arthur/xml_to_html/main.cc
create mode 100644 scribo/sandbox/arthur/xml_to_html/patterns/css.css
create mode 100644 scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl
create mode 100644 scribo/sandbox/arthur/xml_to_html/xml_to_html.cc
copy scribo/{demo/viewer/step_widget.hh => sandbox/arthur/xml_to_html/xml_to_html.hh} (73%)
create mode 100644 scribo/sandbox/arthur/xml_to_html/xml_to_html.pro
diff --git a/scribo/sandbox/ChangeLog b/scribo/sandbox/ChangeLog
index f428dce..d3f537b 100644
--- a/scribo/sandbox/ChangeLog
+++ b/scribo/sandbox/ChangeLog
@@ -1,3 +1,22 @@
+2010-07-05 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
+
+ ICDAR XML to HTML.
+
+ * arthur/xml_to_html/domitem.cc,
+ * arthur/xml_to_html/domitem.hh.,
+ * arthur/xml_to_html/dommodel.cc,
+ * arthur/xml_to_html/dommodel.hh: XML parsing.
+
+ * arthur/xml_to_html/patterns/css.css,
+ * arthur/xml_to_html/patterns/xsl.xsl: HTML patterns.
+
+ * arthur/xml_to_html/xml_to_html.cc,
+ * arthur/xml_to_html/xml_to_html.hh: Image croping and XML merging.
+
+ * arthur/xml_to_html/README
+ * arthur/xml_to_html/xml_to_html.pro
+ * arthur/xml_to_html/main.cc
+
2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr>
Add algorithms to retrieve white spaces.
diff --git a/scribo/sandbox/arthur/xml_to_html/README b/scribo/sandbox/arthur/xml_to_html/README
new file mode 100644
index 0000000..f16f472
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_to_html/README
@@ -0,0 +1,25 @@
+xml_to_html
+
+Produce HTML view from ICDAR (or LRDE extended) XML.
+
+*Compilation:
+
+ Just change the paths to olena and milena in xml_to_html.pro
+
+*Usage:
+
+ -m, --merge: Merge an XML with an other XML
+ args: <xml_file_1> <xml_file_2> [xml_output]
+
+Useful to merge LRDE XML extended mode files with ICDAR XML files to combine both images and recognized text.
+
+
+ -c, --create-html: Crop images (if exist) from the ppm file using the XML file and produce an html output.
+ args: <xml_file> [ppm_file] [output dir]
+
+If no PPM file is given, the program will only produce an HTML output without images.
+If a PPM file is given, the program will crop image_region, separator_region, graphic_regions, chart_region and table_region to output_dir/img/id.png
+
+*Result:
+
+To view the result run your internet browser on output_dir/output.xml (Does not work with Chrome on local, use a LAMPP server to fix this ;-) ).
\ No newline at end of file
diff --git a/scribo/demo/viewer/domitem.cc b/scribo/sandbox/arthur/xml_to_html/domitem.cc
similarity index 100%
copy from scribo/demo/viewer/domitem.cc
copy to scribo/sandbox/arthur/xml_to_html/domitem.cc
diff --git a/scribo/demo/viewer/domitem.hh b/scribo/sandbox/arthur/xml_to_html/domitem.hh
similarity index 100%
copy from scribo/demo/viewer/domitem.hh
copy to scribo/sandbox/arthur/xml_to_html/domitem.hh
diff --git a/scribo/demo/viewer/dommodel.cc b/scribo/sandbox/arthur/xml_to_html/dommodel.cc
similarity index 100%
copy from scribo/demo/viewer/dommodel.cc
copy to scribo/sandbox/arthur/xml_to_html/dommodel.cc
diff --git a/scribo/demo/viewer/dommodel.hh b/scribo/sandbox/arthur/xml_to_html/dommodel.hh
similarity index 100%
copy from scribo/demo/viewer/dommodel.hh
copy to scribo/sandbox/arthur/xml_to_html/dommodel.hh
diff --git a/scribo/sandbox/arthur/xml_to_html/main.cc b/scribo/sandbox/arthur/xml_to_html/main.cc
new file mode 100644
index 0000000..9ec705a
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_to_html/main.cc
@@ -0,0 +1,58 @@
+#include <iostream>
+#include "xml_to_html.hh"
+
+int main(int argc, char **argv)
+{
+
+ std::string man;
+ man = "xml_to_html: ...usage\n -m, --merge: Merge an XML with an other XML\n \targs: <xml_file_1> <xml_file_2> [xml_output]\n\n -c, --create-html: Crop images (if exist) from the ppm file using the XML file and produce an html output.\n \targs: <xml_file> [ppm_file] [output dir]\n";
+
+ if (argc > 2)
+ {
+ new QApplication::QApplication(argc, argv, false);
+ ImageCrop crop;
+
+ std::string merge = "--merge";
+ std::string m = "-m";
+ std::string scrop = "--create-html";
+ std::string c = "-c";
+
+ if (argc == 3 && (scrop.compare(argv[1]) == 0 || c.compare(argv[1]) == 0))
+ {
+ bool b = false;
+ b = crop.load_xml(argv[2], QString::Null());
+
+ if (b)
+ crop.find_image_regions();
+ }
+ else if (argc > 3)
+ {
+ if (merge.compare(argv[1]) == 0 || m.compare(argv[1]) == 0)
+ {
+ if (argc > 4)
+ crop.merge(argv[2], argv[3], argv[4]);
+ else
+ crop.merge(argv[2], argv[3]);
+ }
+ else if (scrop.compare(argv[1]) == 0 || c.compare(argv[1]) == 0)
+ {
+ bool b = false;
+ if (argc > 4)
+ b = crop.load_xml(argv[2], argv[3], argv[4]);
+ else
+ b = crop.load_xml(argv[2], argv[3]);
+
+ if (b)
+ crop.find_image_regions();
+ }
+ else
+ std::cout << man;
+ }
+ else
+ std::cout << man;
+ }
+ else
+ std::cout << man;
+
+ return 0;
+}
diff --git a/scribo/sandbox/arthur/xml_to_html/patterns/css.css b/scribo/sandbox/arthur/xml_to_html/patterns/css.css
new file mode 100644
index 0000000..7171754
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_to_html/patterns/css.css
@@ -0,0 +1,28 @@
+.line
+{
+ position:absolute;
+ background-color:white;
+ z-index:7;
+ display:inline;
+ white-space:pre;
+ letter-spacing:-2px;
+ padding:0px;
+ margin:0px;
+ filter:alpha(opacity=100);
+ font-family:"Times New Roman", Times, serif;
+}
+.para
+{
+ position:absolute;
+ z-index:6;
+}
+.region
+{
+ position:absolute;
+ z-index:5;
+}
+.image
+{
+ position:absolute;
+ border:0;
+}
\ No newline at end of file
diff --git a/scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl b/scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl
new file mode 100644
index 0000000..aa5a078
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_to_html/patterns/xsl.xsl
@@ -0,0 +1,229 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:template match="/"> <!-- "/" means the whole document (root) -->
+ <html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Fooooooo !</title>
+ <link rel="stylesheet" type="text/css" href="css.css" />
+ </head>
+ <body>
+
+ <div class="image" style="top:0px;left:0px;">
+ <img src="../../ppm/mp00076.png" />
+ </div>
+
+ <!-- BEGIN IMAGE REGION -->
+ <xsl:for-each select="pcGts/page/graphic_region|
+ pcGts/page/image_region|
+ pcGts/page/chart_region|
+ pcGts/page/table_region|
+ pcGts/page/separator_region|
+ pcGts/page/text_region|
+ pcGts/page/text_region/paragraph|
+ pcGts/page/text_region/paragraph/line">
+
+ <!-- y1 -->
+ <xsl:variable name="y1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="ascending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x2 -->
+ <xsl:variable name="x2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="descending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- y2 -->
+ <xsl:variable name="y2">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@y" order="descending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@y" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- x1 -->
+ <xsl:variable name="x1">
+ <xsl:for-each select="coords/point">
+ <xsl:sort select="@x" order="ascending" data-type="number"/>
+ <xsl:if test="position() = 1">
+ <xsl:value-of select="@x" />
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+
+ <!-- TEXT LINE-->
+ <xsl:if test="name() = 'line'">
+
+ <xsl:variable name="x_height">
+ <xsl:value-of select="../../@x_height" />
+ </xsl:variable>
+
+ <xsl:variable name="a_height">
+ <xsl:value-of select="../../@a_height" />
+ </xsl:variable>
+
+ <xsl:variable name="colour">
+ <xsl:choose>
+ <xsl:when test="../../@txt_colour != ''">
+ <xsl:value-of select="../../@txt_colour" />
+ </xsl:when>
+ <xsl:otherwise>
+ Black
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="d_height_tmp">
+ <xsl:value-of select="../../@d_height" />
+ </xsl:variable>
+
+ <xsl:variable name="d_height">
+ <xsl:choose>
+ <xsl:when test="$d_height_tmp < 0">
+ <xsl:value-of select="-$d_height_tmp" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$d_height_tmp" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="a">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) < $d_height">
+ <xsl:value-of select="$x_height + $d_height" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$a_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="d">
+ <xsl:choose>
+ <xsl:when test="($a_height - $x_height) > $d_height">
+ <xsl:value-of select="-($a_height - $x_height)" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$d_height" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:variable name="d_f">
+ <xsl:choose>
+ <xsl:when test="$d < 0">
+ <xsl:value-of select="-$d" />
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$d" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <div class="line" onmouseover="this.style.opacity=0.2;this.filters.alpha.opacity=20"
+ onmouseout="this.style.opacity=1;this.filters.alpha.opacity=100">
+ <xsl:attribute name="style">
+ opacity:1;
+ height:auto;
+ font-size:<xsl:value-of select="$a+$d_f" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1 " />px;
+ top:<xsl:value-of select="$y1 " />px;
+ color:<xsl:value-of select="$colour" />;
+ </xsl:attribute>
+ <xsl:value-of select="@text"/>
+ </div>
+ </xsl:if>
+ <!-- ENF OF TEXT LINE -->
+
+ <!-- TEXT REGION -->
+ <xsl:if test="name() = 'text_region'">
+ <div class="region">
+ <xsl:attribute name="style">
+ height:<xsl:value-of select="$y2 - $y1" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ top:<xsl:value-of select="$y1" />px;
+ </xsl:attribute>
+ </div>
+ </xsl:if>
+ <!-- ENF OF TEXT REGION -->
+
+ <!-- PARAGRAPH -->
+ <xsl:if test="name() = 'paragraph'">
+ <div class="para">
+ <xsl:attribute name="style">
+ height:<xsl:value-of select="$y2 - $y1" />px;
+ width:<xsl:value-of select="$x2 - $x1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ top:<xsl:value-of select="$y1" />px;
+ </xsl:attribute>
+ </div>
+ </xsl:if>
+ <!-- ENF OF PARAGRAPH -->
+
+ <!-- NON-TEXT REGIONS -->
+ <xsl:if test="name() = 'image_region' or name() = 'separator_region' or name() = 'graphic_region' or name() = 'chart_region' or name() = 'table_region'">
+
+ <!-- id -->
+ <xsl:variable name="id">
+ <xsl:value-of select="@id" />
+ </xsl:variable>
+
+ <!-- depth -->
+ <xsl:variable name="depth">
+ <xsl:choose>
+ <xsl:when test="name() = 'separator_region'">
+ 1
+ </xsl:when>
+ <xsl:otherwise>
+ 4
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <div class="image">
+ <xsl:attribute name="style">
+ top:<xsl:value-of select="$y1" />px;
+ left:<xsl:value-of select="$x1" />px;
+ width:<xsl:value-of select="$x2 - $x1"/>px;
+ height:<xsl:value-of select="$y2 - $y1"/>px;
+ z-index:<xsl:value-of select="$depth"/>;
+ </xsl:attribute>
+ <img>
+ <xsl:attribute name="alt">
+ <xsl:value-of select="name()" />
+ </xsl:attribute>
+ <xsl:attribute name="width">
+ <xsl:value-of select="$x2 - $x1" />
+ </xsl:attribute>
+ <xsl:attribute name="height">
+ <xsl:value-of select="$y2 - $y1" />
+ </xsl:attribute>
+ <xsl:attribute name="src">
+ img/<xsl:value-of select="$id"/>.png</xsl:attribute>
+ </img>
+ </div>
+
+ </xsl:if>
+ <!-- END NON-TEXT REGIONS -->
+ </xsl:for-each>
+ </body>
+ </html>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/scribo/sandbox/arthur/xml_to_html/xml_to_html.cc b/scribo/sandbox/arthur/xml_to_html/xml_to_html.cc
new file mode 100644
index 0000000..8267466
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_to_html/xml_to_html.cc
@@ -0,0 +1,292 @@
+// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to produce
+// an executable, this file does not by itself cause the resulting
+// executable to be covered by the GNU General Public License. This
+// exception does not however invalidate any other reasons why the
+// executable file might be covered by the GNU General Public License.
+
+# include "xml_to_html.hh"
+# include "dommodel.hh"
+# include <limits.h>
+
+#include <scribo/preprocessing/crop.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/core/alias/box2d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/io/magick/save.hh>
+#include <mln/io/ppm/all.hh>
+
+ImageCrop::ImageCrop():
+ regions_(false)
+{
+}
+
+ImageCrop::~ImageCrop()
+{
+}
+
+void ImageCrop::merge(QString in, QString other, QString output)
+{
+ if (in.endsWith(".xml") && other.endsWith(".xml") && output.endsWith(".xml"))
+ {
+ QFile f_in(in);
+ QFile f_other(other);
+ QFile f_output(output);
+
+ qDebug() << "Merging to " << output << "...";
+
+ f_in.open(QIODevice::ReadOnly);
+ f_other.open(QIODevice::ReadOnly);
+ f_output.open(QIODevice::ReadWrite);
+
+ QTextStream stream_in(&f_in);
+ QTextStream stream_other(&f_other);
+ QTextStream output_stream(&f_output);
+
+ QString line = stream_in.readLine();
+ output_stream << line;
+ line = stream_in.readLine();
+
+ while (!line.contains("</page>"))
+ {
+ output_stream << "\n" << line;
+ line = stream_in.readLine();
+ }
+
+ line = stream_other.readLine();
+
+ while (!line.contains("<page"))
+ line = stream_other.readLine();
+
+ line = stream_other.readLine();
+
+ while (!line.contains("</pcGts>"))
+ {
+ output_stream << "\n" << line;
+ line = stream_other.readLine();
+ }
+
+ output_stream << "\n" << line;
+
+ f_in.close();
+ f_other.close();
+ f_output.close();
+ }
+ else
+ std::cout << "merge : error, only xml files are needed." << std::endl;
+}
+
+bool ImageCrop::load_xml(QString xml_file, QString image_file, QString path)
+{
+ if (xml_file.endsWith(".xml") && (image_file.endsWith(".ppm") || image_file == QString::Null()) )
+ {
+ image_file_ = image_file;
+ regions_ = (image_file != QString::Null());
+
+ path_ = path;
+ if (!path_.endsWith("/"))
+ path_.append("/");
+
+ QDir dir(path_);
+
+ if (!dir.mkpath("img"))
+ {
+ path_ = "output/";
+ dir.mkpath(path_);
+ dir.setPath(path_);
+ dir.mkpath("img");
+ }
+
+ if (QFile::exists(xml_file))
+ {
+ QFile file(xml_file);
+ QFile output(path_ + "output.xml");
+ QFile xsl("patterns/xsl.xsl");
+ QFile css("patterns/css.css");
+ xsl.copy(path_ + "xsl.xsl");
+ css.copy(path_ + "css.css");
+
+ if (QFile::exists(path_ + "output.xml"))
+ output.remove();
+
+ output.open(QIODevice::ReadWrite);
+ file.open(QIODevice::ReadOnly);
+
+ QTextStream stream_in(&file);
+ QTextStream stream_out(&output);
+ stream_in.setCodec("UTF-8");
+ stream_out.setCodec("UTF-8");
+
+ QString line = stream_in.readLine();
+ stream_out << line;
+ stream_out << "\n<?xml-stylesheet type=\"text/xsl\" href=\"xsl.xsl\" ?>";
+
+ // /!\ attributes of ICDAR PcGts removed.
+ line = stream_in.readLine();
+ stream_out << "\n<pcGts>";
+
+ line = stream_in.readLine();
+
+ while (!line.contains("</pcGts>"))
+ {
+ stream_out << "\n" << line;
+ line = stream_in.readLine();
+ }
+
+ stream_out << "\n" << line;
+
+ output.close();
+ file.close();
+
+ qDebug() << "Output saved to " + path_;
+
+ if (file.open(QIODevice::ReadOnly))
+ {
+ QDomDocument document;
+ if (document.setContent(&file))
+ {
+ layout_ = new DomModel(document, this);
+ }
+ else
+ qDebug() << "Error while loading the XML file, please choose another.";
+
+ file.close();
+ }
+ }
+ return true;
+ }
+ else
+ {
+ std::cout << "Wrong files format !" << std::endl;
+ return false;
+ }
+}
+
+void ImageCrop::find_image_regions()
+{
+ if (layout_ && regions_)
+ {
+ QModelIndex pgGts = layout_->index(1, 0);
+ QModelIndex page = layout_->index(1, 0, pgGts);
+ QModelIndex region;
+ QModelIndex attributes;
+ QModelIndex coords;
+ QModelIndex point;
+ bool regions_found = false;
+ for (int i = 0; true; ++i)
+ {
+ region = layout_->index(i, 0, page);
+ attributes = layout_->index(i, 1, page);
+ QString name = layout_->data(region, Qt::DisplayRole).toString();
+ coords = layout_->index(0, 0, region);
+
+ bool is_image_region = name == QString("image_region")
+ || name == QString("graphic_region")
+ || name == QString("separator_region")
+ || name == QString("chart_region")
+ || name == QString("table_region") ;
+
+ if (!region.isValid() || !coords.isValid())
+ break;
+
+ if (is_image_region)
+ {
+
+ regions_found = true;
+ QMap<QString, QVariant> data =
+ layout_->data(attributes, Qt::UserRole).toMap();
+
+ QString id;
+ QMap<QString, QVariant>::iterator it = data.find("id");
+
+ if (it == data.end() || it.key() != "id")
+ qDebug() << "No image region.";
+
+ while (it != data.end() && it.key() == "id")
+ {
+ qDebug() << name;
+ id = it.value().toString();
+ qDebug() << it.key() + " = " + it.value().toString();
+ ++it;
+ }
+
+ int x_max = 0;
+ int y_max = 0;
+ int x_min = INT_MAX;
+ int y_min = INT_MAX;
+
+ // QVector<QMap<QString, QVariant> > vect;
+ for (int j = 0; true; ++j)
+ {
+ // Navigate to the coordinate list
+ point = layout_->index(j, 1, coords);
+ if (!point.isValid())
+ break;
+
+ QMap<QString, QVariant> data =
+ layout_->data(point, Qt::UserRole).toMap();
+ int x = data["x"].toInt();
+ int y = data["y"].toInt();
+
+ // vect << data;
+
+ if (x < x_min)
+ x_min = x;
+ if (x > x_max)
+ x_max = x;
+
+ if (y < y_min)
+ y_min = y;
+ if (y > y_max)
+ y_max = y;
+
+ }
+
+ using namespace mln;
+
+ box2d box = make::box2d(y_min, x_min, y_max, x_max);
+
+ image2d<value::rgb8> ima;
+ io::ppm::load(ima, image_file_.toStdString());
+ ima = scribo::preprocessing::crop(ima, box);
+
+ // image2d<bool> mask = make::box2d(y_min, x_min, y_max, x_max);
+ // data::fill(mask, true);
+
+ /*for (int a = 1; a < vect.size(); ++a)
+ {
+ int x = vect[a]["x"].toInt();
+ int y = vect[a]["y"].toInt();
+
+ data::fill((mask | make::box2d(y, x, y, x)).rw(), false);
+ }*/
+
+
+ // io::pbm::save(mask, "output/img/mask_" + id.toStdString());
+ io::magick::save(ima, path_.toStdString() + "img/" + id.toStdString() + ".png");
+
+ }
+ }
+
+ if (!regions_found)
+ qDebug() << "No regions found.";
+ }
+}
diff --git a/scribo/demo/viewer/step_widget.hh b/scribo/sandbox/arthur/xml_to_html/xml_to_html.hh
similarity index 73%
copy from scribo/demo/viewer/step_widget.hh
copy to scribo/sandbox/arthur/xml_to_html/xml_to_html.hh
index 829f814..27a271e 100644
--- a/scribo/demo/viewer/step_widget.hh
+++ b/scribo/sandbox/arthur/xml_to_html/xml_to_html.hh
@@ -23,35 +23,27 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-
-#ifndef STEP_WIDGET_HH_
-# define STEP_WIDGET_HH_
+#ifndef IMAGE_CROP_HH
+# define IMAGE_CROP_HH
# include <QtGui>
-typedef QMap<QString, QString> StepQMap;
+class DomModel;
-class StepWidget
- : public QWidget
+class ImageCrop : public QObject
{
Q_OBJECT
-
-public:
- StepWidget();
- ~StepWidget();
- void add_element(const QString& element);
-
-signals:
- void load_image(QString);
- void load_xml(QString);
-
-public slots:
- void fill_steps(QString file);
- void activate(QListWidgetItem* item);
-
-private:
- QListWidget* view_;
- StepQMap map_;
+ public:
+ ImageCrop();
+ ~ImageCrop();
+ void merge(QString in, QString other, QString output = "output.xml");
+ bool load_xml(QString xml_file, QString image_file = "", QString path = "output");
+ void find_image_regions();
+ private:
+ DomModel* layout_;
+ QString image_file_;
+ QString path_;
+ bool regions_;
};
-#endif /* !STEP_WIDGET_HH_ */
+#endif /* !IMAGE_CROP_HH */
diff --git a/scribo/sandbox/arthur/xml_to_html/xml_to_html.pro b/scribo/sandbox/arthur/xml_to_html/xml_to_html.pro
new file mode 100644
index 0000000..b43b527
--- /dev/null
+++ b/scribo/sandbox/arthur/xml_to_html/xml_to_html.pro
@@ -0,0 +1,16 @@
+######################################################################
+# Automatically generated by qmake (2.01a) lun. juil. 5 16:53:31 2010
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+QMAKE_CXXFLAGS += -I/amd/beyrouth/home/lrde/stage/crepin/olena/milena -I/amd/beyrouth/home/lrde/stage/crepin/olena/
+QT += xml
+LIBS += `Magick++-config --libs`
+
+
+# Input
+HEADERS += domitem.hh dommodel.hh xml_to_html.hh
+SOURCES += domitem.cc dommodel.cc main.cc xml_to_html.cc
--
1.5.6.5
1
0

16 Nov '10
* scribo/demo/viewer/viewer.cc,
* scribo/demo/viewer/image_region.hxx: Disable item click if unchecked in item list.
* scribo/demo/viewer/key_widget.cc,
* scribo/demo/viewer/key_widget.hh: Add KeyWidget::checkAll.
---
scribo/ChangeLog | 61 +++++++++++++++++++++++++++++++++++
scribo/demo/viewer/image_region.hxx | 1 +
scribo/demo/viewer/key_widget.cc | 9 +++++
scribo/demo/viewer/key_widget.hh | 1 +
scribo/demo/viewer/viewer.cc | 42 ++++++++++++-----------
5 files changed, 94 insertions(+), 20 deletions(-)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 3fc62ec..d7be39d 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,3 +1,64 @@
+2010-06-30 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
+
+ Extended XML mode support.
+
+ * scribo/demo/viewer/Makefile.am
+
+ * 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.
+
+ * demo/viewer/key_widget.cc,
+ * 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/common.hh: Add new RegionId's.
+
+2010-06-30 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
+
+ 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.
+
+
+2010-06-30 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
+
+ Change XML output (replacement of html markups).
+
+ * io/xml/save.hh: Add internal::html_markups_replace.
+
+2010-06-23 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
+
+ Add extensions to ICDAR XML format.
+
+ * io/xml/save_text_lines.hh: Rename as...
+ * io/xml/save.hh: ...this.
+
+ * src/pbm_text_in_doc.cc: Update call to io::xml::save.
+
+2010-07-05 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
+
+ Small fix in Qt interface.
+
+ * scribo/demo/viewer/viewer.cc,
+ * scribo/demo/viewer/image_region.hxx: Disable item click if
+ unchecked in item list.
+
+ * scribo/demo/viewer/key_widget.cc,
+ * scribo/demo/viewer/key_widget.hh: Add KeyWidget::checkAll.
+
+
2010-08-27 Guillaume Lazzara <z(a)lrde.epita.fr>
* src/Makefile.am (CLEANFILES): Fix invalid variable name.
diff --git a/scribo/demo/viewer/image_region.hxx b/scribo/demo/viewer/image_region.hxx
index 50dc93d..efcf493 100644
--- a/scribo/demo/viewer/image_region.hxx
+++ b/scribo/demo/viewer/image_region.hxx
@@ -58,6 +58,7 @@ ImageRegion::setDrawIfSameId(int id, bool draw)
if (id == id_)
{
draw_ = draw;
+ setVisible(draw);
if (scene())
{
scene()->invalidate();
diff --git a/scribo/demo/viewer/key_widget.cc b/scribo/demo/viewer/key_widget.cc
index 93c2cf0..5e371ab 100644
--- a/scribo/demo/viewer/key_widget.cc
+++ b/scribo/demo/viewer/key_widget.cc
@@ -36,6 +36,15 @@ KeyWidget::KeyWidget(const region::KeyMap& key_map)
this, SLOT(update(QListWidgetItem*)));
}
+void KeyWidget::checkAll()
+{
+ for (int i = 0; i < items_->count(); ++i)
+ {
+ items_->item(i)->setCheckState(Qt::Checked);
+ emit updated(i, true);
+ }
+}
+
void
KeyWidget::change_mode(bool b)
{
diff --git a/scribo/demo/viewer/key_widget.hh b/scribo/demo/viewer/key_widget.hh
index e5259e2..71200c8 100644
--- a/scribo/demo/viewer/key_widget.hh
+++ b/scribo/demo/viewer/key_widget.hh
@@ -27,6 +27,7 @@ public:
KeyWidget(const region::KeyMap& key_map);
~KeyWidget();
+ void checkAll();
bool isChecked(region::RegionId id);
signals:
diff --git a/scribo/demo/viewer/viewer.cc b/scribo/demo/viewer/viewer.cc
index 8bafc39..61a57c1 100644
--- a/scribo/demo/viewer/viewer.cc
+++ b/scribo/demo/viewer/viewer.cc
@@ -138,8 +138,8 @@ Viewer::Viewer(int &argc, char** argv)
XmlWidget* xml_wgt = new XmlWidget();
BrowserWidget* browser_wgt =
new BrowserWidget(files_, argc != 2 ? QString() : argv[1]);
- ImageWidget* image_wgt = new ImageWidget(scene_);
key_wgt_ = new KeyWidget(key_map_);
+ ImageWidget* image_wgt = new ImageWidget(scene_);
scene_->setBackgroundBrush(scene_->palette().window());
@@ -212,7 +212,7 @@ Viewer::load_xml(QString filename)
scene_->removeItem(image_);
scene_->clear();
scene_->addItem(image_);
-
+
scene_->update();
if (doc_layout_)
@@ -220,9 +220,9 @@ Viewer::load_xml(QString filename)
doc_layout_->deleteLater();
doc_layout_ = 0;
}
-
+
emit updated(doc_layout_);
-
+
if (QFile::exists(xml_file))
{
QFile file(xml_file);
@@ -267,11 +267,11 @@ Viewer::xml_to_layout()
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)
{
@@ -279,14 +279,14 @@ Viewer::xml_to_layout()
point = doc_layout_->index(j, 1, coords);
if (!point.isValid())
break;
-
+
QMap<QString, QVariant> data =
doc_layout_->data(point, Qt::UserRole).toMap();
int x = data["x"].toInt();
int y = data["y"].toInt();
points << QPoint(x, y);
}
-
+
// Create region
ImageRegion* r = new ImageRegion(id,
key_map_[id].first,
@@ -296,7 +296,7 @@ Viewer::xml_to_layout()
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)),
@@ -305,7 +305,7 @@ Viewer::xml_to_layout()
r, SLOT(setPrecise(bool)));
connect(this, SIGNAL(setFill(bool)),
r, SLOT(setFill(bool)));
-
+
scene_->addItem(r);
// EXTENDED MODE
@@ -325,6 +325,7 @@ Viewer::xml_to_layout()
QModelIndex par_coords = doc_layout_->index(0, 0, paragraph);
QModelIndex point_par;
+
QVector<QPoint> points_par;
for (int m = 0; true; ++m)
{
@@ -332,7 +333,7 @@ Viewer::xml_to_layout()
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();
@@ -349,7 +350,7 @@ Viewer::xml_to_layout()
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)),
@@ -360,7 +361,7 @@ Viewer::xml_to_layout()
r_par, SLOT(setFill(bool)));
scene_->addItem(r_par);
-
+
for (int l = 1; true; ++l)
{
QModelIndex line = doc_layout_->index(l, 0, paragraph);
@@ -370,7 +371,7 @@ Viewer::xml_to_layout()
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;
@@ -380,14 +381,14 @@ Viewer::xml_to_layout()
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,
@@ -397,7 +398,7 @@ Viewer::xml_to_layout()
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)),
@@ -409,12 +410,12 @@ Viewer::xml_to_layout()
scene_->addItem(r_line);
}
- }
+ }
}
// END OF EXTENDED MODE
-
+
}
-
+
emit updated(doc_layout_);
}
}
@@ -481,6 +482,7 @@ Viewer::maybeChangeCacheMode(qreal scale)
void Viewer::useExtended(bool b)
{
extended_mode_ = b;
+ key_wgt_->checkAll();
if (xml_file_ != QString(""))
load_xml(xml_file_);
--
1.5.6.5
1
0