LRE
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
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
List overview
Download
Olena-patches
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
olena-patches@lrde.epita.fr
9625 discussions
Start a n
N
ew thread
olena-2.0-191-g4ddbf89 Add a new structure for compressed tree.
by Guillaume Lazzara
* mln/util/tree_of_shapes.hh: Remove methods related to compressed tree. * mln/util/ztree_of_shapes.hh: New. --- milena/ChangeLog | 9 + milena/mln/util/tree_of_shapes.hh | 44 +- milena/mln/util/ztree_of_shapes.hh | 788 ++++++++++++++++++++++++++++++++++++ 3 files changed, 818 insertions(+), 23 deletions(-) create mode 100644 milena/mln/util/ztree_of_shapes.hh diff --git a/milena/ChangeLog b/milena/ChangeLog index 8d00301..521a626 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,14 @@ 2013-02-11 Guillaume Lazzara <z(a)lrde.epita.fr> + Add a new structure for compressed tree. + + * mln/util/tree_of_shapes.hh: Remove methods related to compressed + tree. + + * mln/util/ztree_of_shapes.hh: New. + +2013-02-11 Guillaume Lazzara <z(a)lrde.epita.fr> + Small fixes. * mln/util/map.hh: Fix prototype of element(). diff --git a/milena/mln/util/tree_of_shapes.hh b/milena/mln/util/tree_of_shapes.hh index 9bf978f..1444fb1 100644 --- a/milena/mln/util/tree_of_shapes.hh +++ b/milena/mln/util/tree_of_shapes.hh @@ -30,6 +30,10 @@ #ifndef MLN_UTIL_TREE_OF_SHAPES_HH # define MLN_UTIL_TREE_OF_SHAPES_HH +# include <vector> +# include <mln/value/rgb8.hh> +# include <mln/util/map.hh> +# include <mln/core/alias/box2d.hh> namespace mln { @@ -37,41 +41,30 @@ namespace mln namespace util { - enum Tags { None, Spurious, Noise }; - template <typename I> struct tree_of_shapes { typedef mln_site(I) P; typedef mln_value(I) V; typedef mln_equiv(V) EV; + typedef mln_ch_value(I,P) parent_t; I Fb; // Default canonicalization. std::vector<P> R; - mln_ch_value(I,P) parent; - - // 0-canonicalization. - std::vector<P> R0; - mln_ch_value(I,P) parent0; - // Attributes/tags for 0-representants. - std::vector<Tags> tag; - - // 01-canonicalization. - std::vector<P> R01; - mln_ch_value(I,P) parent01; - + parent_t parent; V level(const P& p) const; bool level_changes_at(unsigned i) const; + bool is_root(const P& p) const; + bool is_not_root(const P& p) const; + bool is_representative(const P& p) const; + bool is_not_representative(const P& p) const; bool is_0_representative(const P& p) const; - - bool is_01_representative(const P& p) const; - }; @@ -104,6 +97,13 @@ namespace mln template <typename I> bool + tree_of_shapes<I>::is_not_root(const P& p) const + { + return ! is_root(p); + } + + template <typename I> + bool tree_of_shapes<I>::is_representative(const P& p) const { return is_root(p) || Fb(parent(p)) != Fb(p); @@ -111,18 +111,16 @@ namespace mln template <typename I> bool - tree_of_shapes<I>::is_0_representative(const P& p) const + tree_of_shapes<I>::is_not_representative(const P& p) const { - return is_representative(p) && (Fb(p) == V(0)); + return ! is_not_representative(p); } template <typename I> bool - tree_of_shapes<I>::is_01_representative(const P& p) const + tree_of_shapes<I>::is_0_representative(const P& p) const { - return is_root(p) - || (Fb(p) == V(0) && Fb(parent(p)) != V(0)) - || (Fb(p) != V(0) && Fb(parent(p)) == V(0)); + return (is_root(p) || Fb(parent(p)) != Fb(p)) && (Fb(p) == V(0)); } diff --git a/milena/mln/util/ztree_of_shapes.hh b/milena/mln/util/ztree_of_shapes.hh new file mode 100644 index 0000000..641f0fc --- /dev/null +++ b/milena/mln/util/ztree_of_shapes.hh @@ -0,0 +1,788 @@ +// Copyright (C) 2012 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. + +/// \file +/// +/// \brief Tree of shapes data structure. + +#ifndef MLN_UTIL_ZTREE_OF_SHAPES_HH +# define MLN_UTIL_ZTREE_OF_SHAPES_HH + +# include <vector> +# include <mln/value/rgb8.hh> +# include <mln/util/map.hh> +# include <mln/core/image/image2d.hh> +# include <mln/util/tree_of_shapes.hh> +# include <mln/data/transform.hh> +# include <mln/border/resize.hh> + +# include <mln/debug/println.hh> +# include <mln/util/object_id.hh> + +namespace mln +{ + + // Type used to refer to a pixel in one of the ztree images. + struct face_id {}; + typedef unsigned face_id_t; + + + namespace util + { + enum Hole { Not_hole, Is_hole, Contains_hole }; + enum Tags { None = 0, Spurious, Noise, Object, Background }; + + struct attrib_t + { + attrib_t() + { + reset(); + } + + void reset() + { + tag = None; + own_area = 0; + area = 0; + nchild = 0; + color = literal::black; + is_leaf = true; + own_area_ratio = 0; + rectangularity = 0; + elongation = 0; + d_color_q = 0; + d_color_gp = 0; + dlap = 0; + max_abs_lap = 0; + hole = Not_hole; + bg_score = 0; + fg_score = 0; + is_valid = false; + } + + // It is stored on any representatives. + Tags tag; + + // Corresponds to the number of pixels of the same level as the + // related representative. + // It is stored on any representatives. + unsigned own_area; + + // Corresponds to the number of pixels of all the sub-shapes and + // at the same level. + // It is stored on any representatives. + unsigned area; + + // The bounding box. + // It is stored on 0-representatives ONLY. + box2d bbox; + + // The mean color of the shape. It relies only on values from + // 2-faces owned by this shape. + // It is stored on any representatives. + value::rgb8 color; + + // // The weighted mean color of the shape. It relies only on + // // values from 2-faces owned by this shape. It is stored on any + // // representatives. + // value::rgb8 wcolor; + + // The number of children in the tree. + // It is stored on any representatives. + unsigned nchild; + + // Is it a representative of a leaf ?. + // It is stored on any representatives. + bool is_leaf; + + // The ratio own_area / area. + // It is stored on 0-representatives ONLY. + float own_area_ratio; + + // It is stored on 0-representatives ONLY. + float rectangularity; + + // It is stored on 0-representatives ONLY. + float elongation; + + // The maximum color distance between the non-0-representative + // children and the non-0-representative parent colors. + // It is stored on 0-representatives ONLY. + // + // @ + // | + // o gp + // | + // @ + // | + // o + // @ --> d_color_gp = max(d_color_gp, l1::distance(p.color, gp.color)) + // | + // o p + unsigned d_color_q; + + // The maximum color distance between the non-0-representative + // children and the non-0-representative grandparent colors. + // It is stored on 0-representatives ONLY. + // + // @ + // | + // o gp + // | + // @ + // | + // o + // @ --> d_color_gp = max(d_color_gp, l1::distance(p.color, gp.color)) + // | + // o p + unsigned d_color_gp; + + // Maximum distance between the non-0-representative children + // and the non-0-representative parent laplacian values. + // It is stored on 0-representatives ONLY. + unsigned dlap; + + // Maximum absolute value in laplacian image for the current + // shape. + // It is stored on any representatives. + unsigned max_abs_lap; + + // Set whether this shape contains a hole or is a hole. + // It is stored on any representatives. + Hole hole; + + // The higher is this score, the higher is the probability that + // this shape is a background. It is based on the hypothesis + // that interesting objects are leaves (excepted holes). This + // score take into account the number of holes and leaves + // included in that shape. + // It is stored on non-0-representatives ONLY. + unsigned bg_score; + + // The higher is this score, the higher is the probability that + // this shape is foreground. + // It is stored on non-0-representatives ONLY. + unsigned fg_score; + + bool is_valid; + }; + + bool operator==(const attrib_t& l, const attrib_t& r) + { + return l.tag == r.tag + && l.own_area == r.own_area + && l.area == r.area + && l.bbox == r.bbox + && l.color == r.color + && l.nchild == r.nchild + && l.is_leaf == r.is_leaf + && l.own_area_ratio == r.own_area_ratio + && l.rectangularity == r.rectangularity + && l.elongation == r.elongation + && l.d_color_q == r.d_color_q + && l.d_color_gp == r.d_color_gp + && l.dlap == r.dlap + && l.max_abs_lap == r.max_abs_lap + && l.hole == r.hole + && l.bg_score == r.bg_score + && l.fg_score == r.fg_score + && l.is_valid == r.is_valid; + } + + bool operator!=(const attrib_t& l, const attrib_t& r) + { + return ! (l == r); + } + + template <typename I> + class ztree_of_shapes + { + public: + typedef mln_site(I) P; + typedef mln_value(I) V; + typedef mln_equiv(V) EV; + typedef mln_ch_value(I,face_id_t) parent_t; // FIXME: could be + // replaced by an + // array (direct + // access from + // face_id_t). + typedef I Fb_t; + + // all pixels, from root to leaf + std::vector<face_id_t> R; + // 0-representatives only, from root to leaf + std::vector<face_id_t> R0; + // representative only, from root to leaf + std::vector<face_id_t> R01; + + ztree_of_shapes(); + ztree_of_shapes(const util::tree_of_shapes<I>& tree, + const I& lap_k1); + + V level(const P& p) const; + + bool is_root(const P& p) const; + bool is_root(const face_id_t& pi) const; + + bool is_representative(const P& p) const; + bool is_representative(const face_id_t& pi) const; + + bool is_0_representative(const P& p) const; + bool is_0_representative(const face_id_t& p) const; + + bool is_non_0_representative(const P& p) const; + bool is_non_0_representative(const face_id_t& p) const; + + bool is_compressed() const; + bool is_valid() const; + + + const face_id_t& parent(const face_id_t& pi) const; + P parentp(const P& pi) const; + + const V& Fb(const face_id_t& pi) const; + const V& Fb(const P& pi) const; + const V& lap(const face_id_t& pi) const; + const V& lap(const P& pi) const; + + const box2d& parent_domain() const; + const parent_t& parent_image() const; + parent_t& parent_image_(); + + const box2d& Fb_domain() const; + const I& Fb_image() const; + I& Fb_image_(); + + I& lap_image(); + const I& lap_image() const; + + void trim(const util::array<face_id_t>& f, + const std::vector<face_id_t>& R0, + const std::vector<face_id_t>& R01, + const util::array<bool>& is_removed); + + // Debug + bool is_01_canonicalized() const; + + face_id_t offset_of(const point2d& p) const; + point2d face_at(const face_id_t& pi) const; + + unsigned nfaces() const; + + private: + + Fb_t Fb_; + // compressed parent image. + parent_t parent_; + I lap_k1_; + + void compress_tree(); + bool compressed_; + }; + + +# ifndef MLN_INCLUDE_ONLY + + namespace internal + { + + template <typename V> + bool have_same_sign(const V& v1, const V& v2) + { + // FIXME: Remove when Fb is flat. + mln_precondition(v1.is_degenerated() && v2.is_degenerated()); + if (!v1.is_degenerated() || !v2.is_degenerated()) + { + std::cout << "OUUUUPPPSSS" << std::endl; + abort(); + } + + return (v1.first() == 0 && v2.first() == 0) || (v1.first() > 0 && v2.first() > 0) || (v1.first() < 0 && v2.first() < 0); + } + + + template <typename I, typename P> + bool + is_01_representative_in_parent01(util::ztree_of_shapes<I>& t, const P& p) + { + typedef mln_value(I) V; + return t.is_root(p) + || (t.Fb(p) == V(0) && t.Fb(t.parent(p)) != V(0)) + || (t.Fb(p) != V(0) && t.Fb(t.parent(p)) == V(0)); + } + + template <typename I> + struct point_to_offset_t : Function_v2v<point_to_offset_t<I> > + { + typedef face_id_t result; + typedef point2d argument; + + point_to_offset_t(const I& Fb) : Fb_(Fb) {} + + result operator()(const argument& v) const + { + return face_id_t(Fb_.offset_of_point(v)); + } + + I Fb_; + }; + + } + + template <typename I> + ztree_of_shapes<I>::ztree_of_shapes() + : compressed_(false) + { + } + + template <typename I> + ztree_of_shapes<I>::ztree_of_shapes(const util::tree_of_shapes<I>& tree, + const I& lap_k1) + { + lap_k1_ = duplicate(lap_k1); + border::resize(lap_k1_, 1); + + // Make sure that underlying images have same border (site + // offsets are therefore equivalent). + Fb_ = duplicate(tree.Fb); + border::resize(Fb_, 1); + + internal::point_to_offset_t<I> point_to_offset(Fb_); + parent_ = data::transform(tree.parent, point_to_offset); + border::resize(parent_, 1); + + // Check image sizes. + mln_assertion(Fb_.domain() == tree.parent.domain()); + mln_assertion(Fb_.border() == parent_.border()); + mln_assertion(Fb_.domain() == parent_.domain()); + +# ifndef RELEASE + if (Fb_.domain() != tree.parent.domain() + || Fb_.border() != parent_.border() + || Fb_.domain() != parent_.domain()) + abort(); + + //Check + { + mln_piter(image2d<face_id_t>) p(parent_domain()); + for_all(p) + if (parent(offset_of(p)) >= nfaces()) + { + std::cout << "Invalid parent id!" << std::endl; + abort(); + } + } + + + // debug::println(Fb_); + // debug::println(parent_); +# endif // ! RELEASE + + for (int i = 0; i < tree.R.size(); ++i) + R.push_back(offset_of(tree.R[i])); + + // Initialize R0, 0-representative faces and R01 representative + // pixels in compressed tree. + for (unsigned i = 0; i < R.size(); ++i) + { + face_id_t pi = R[i]; + if (is_representative(pi)) + { + R01.push_back(pi); + if (is_0_representative(pi)) + R0.push_back(pi); + } + } + + compress_tree(); + } + + template <typename I> + face_id_t + ztree_of_shapes<I>::offset_of(const point2d& p) const + { + return Fb_.offset_of_point(p); + } + + template <typename I> + point2d + ztree_of_shapes<I>::face_at(const face_id_t& pi) const + { + return Fb_.point_at_offset(pi); + } + + template <typename I> + unsigned + ztree_of_shapes<I>::nfaces() const + { + return Fb_.nelements(); + } + + template <typename I> + typename ztree_of_shapes<I>::V + ztree_of_shapes<I>::level(const P& p) const + { + return Fb(p); + } + + template <typename I> + bool + ztree_of_shapes<I>::is_root(const face_id_t& pi) const + { + return parent(pi) == pi; + } + + template <typename I> + bool + ztree_of_shapes<I>::is_root(const P& p) const + { + return is_root(offset_of(p)); + } + + template <typename I> + bool + ztree_of_shapes<I>::is_0_representative(const P& p) const + { + return is_0_representative(offset_of(p)); + } + + template <typename I> + bool + ztree_of_shapes<I>::is_0_representative(const face_id_t& pi) const + { + return (is_root(pi) || Fb(parent(pi)) != Fb(pi)) && (Fb(pi) == V(0)); + } + + template <typename I> + bool + ztree_of_shapes<I>::is_non_0_representative(const P& p) const + { + return is_non_0_representative(offset_of(p)); + } + + template <typename I> + bool + ztree_of_shapes<I>::is_non_0_representative(const face_id_t& pi) const + { + return is_representative(pi) && ! is_0_representative(pi); + } + + template <typename I> + bool + ztree_of_shapes<I>::is_representative(const P& p) const + { + return is_representative(offset_of(p)); + } + + template <typename I> + bool + ztree_of_shapes<I>::is_representative(const face_id_t& pi) const + { + return is_root(pi) + || (Fb(pi) == V(0) && Fb(parent(pi)) != V(0)) + || (Fb(pi) != V(0) && Fb(parent(pi)) == V(0)); + } + + template <typename I> + bool + ztree_of_shapes<I>::is_valid() const + { + return is_compressed(); + } + + template <typename I> + bool + ztree_of_shapes<I>::is_compressed() const + { + mln_precondition(is_01_canonicalized()); + +# ifndef RELEASE + // Precondition + if (!is_01_canonicalized()) + abort(); +# endif // ! RELEASE + + return compressed_; + } + + + template <typename I> + const face_id_t& + ztree_of_shapes<I>::parent(const face_id_t& pi) const + { + return parent_.element(pi); + } + + template <typename I> + typename ztree_of_shapes<I>::P + ztree_of_shapes<I>::parentp(const P& p) const + { + return face_at(parent(offset_of(p))); + } + + template <typename I> + const typename ztree_of_shapes<I>::V& + ztree_of_shapes<I>::Fb(const face_id_t& pi) const + { + return Fb_.element(pi); + } + + template <typename I> + const typename ztree_of_shapes<I>::V& + ztree_of_shapes<I>::Fb(const P& p) const + { + return Fb(offset_of(p)); + } + + template <typename I> + const typename ztree_of_shapes<I>::V& + ztree_of_shapes<I>::lap(const face_id_t& pi) const + { + return lap_k1_.element(pi); + } + + template <typename I> + const typename ztree_of_shapes<I>::V& + ztree_of_shapes<I>::lap(const P& p) const + { + return lap(offset_of(p)); + } + + template <typename I> + const box2d& + ztree_of_shapes<I>::parent_domain() const + { + return parent_.domain(); + } + + template <typename I> + const typename ztree_of_shapes<I>::parent_t& + ztree_of_shapes<I>::parent_image() const + { + return parent_; + } + + template <typename I> + typename ztree_of_shapes<I>::parent_t& + ztree_of_shapes<I>::parent_image_() + { + return parent_; + } + + template <typename I> + const box2d& + ztree_of_shapes<I>::Fb_domain() const + { + return Fb_.domain(); + } + + template <typename I> + const I& + ztree_of_shapes<I>::Fb_image() const + { + return Fb_; + } + + template <typename I> + I& + ztree_of_shapes<I>::Fb_image_() + { + return Fb_; + } + + template <typename I> + I& + ztree_of_shapes<I>::lap_image() + { + return lap_k1_; + } + + template <typename I> + const I& + ztree_of_shapes<I>::lap_image() const + { + return lap_k1_; + } + + template <typename I> + void + ztree_of_shapes<I>::compress_tree() + { + typedef mln_site(I) P; + + unsigned N = parent_.nsites(); + + // // DEBUG + // { + // image2d<bool> imap0(parent.domain()); + // data::fill(imap0, false); + // for (unsigned i = 0; i < R0.size(); ++i) + // imap0(R0[i]) = true; + + // io::magick::save(imap0, "debug_imap0.pbm"); + // std::cout << "0-node count: " << R0.size() << std::endl; + // } + // { + // image2d<value::rgb8> imap01(parent.domain()); + // data::fill(imap01, literal::black); + // for (unsigned i = 0; i < R01.size(); ++i) + // if (is_0_zrepresentative(t, R01[i])) + // imap01(R01[i]) = literal::blue; + // else + // imap01(R01[i]) = literal::red; + + // io::magick::save(imap01, "debug_imap01.ppm"); + // std::cout << "representative count: " << R01.size() << std::endl; + // } + + + // Canonicalization + typedef mln_value(I) V; + for (unsigned i = 0; i < N; ++i) + { + face_id_t p = R[i]; // p goes from root to leaves + face_id_t q = parent(p); + if (! is_representative(q)) + parent_.element(p) = parent(q); + } + + compressed_ = true; + +# ifndef RELEASE + // Check + for (unsigned i = 0; i < N; ++i) + { + face_id_t p = R[i]; // p goes from root to leaves + face_id_t q = parent(p); + if (! is_representative(q)) + { + std::cerr << "OOOOOOOOOOOO" << std::endl; + std::abort(); + } + } + + + // Check + unsigned j = 0; + for (unsigned i = 0; i < N; ++i) + if (internal::is_01_representative_in_parent01(*this, R[i])) + if (R01[j++] != R[i]) + { + std::cout << "Oups 2" << std::endl; + std::abort(); + } +# endif // ! RELEASE + + } + + + + template <typename I> + bool + ztree_of_shapes<I>::is_01_canonicalized() const + { + mln_precondition(parent.is_valid()); + + // Check if parent relationship is ok. + mln_piter(image2d<point2d>) p(parent_domain()); + for_all(p) + { + face_id_t pi = offset_of(p); + if (! is_representative(parent(pi))) + { + std::cout << "Parent " << parent(pi) + << " is not 01-representative!" << std::endl; +# ifndef RELEASE + std::abort(); +# endif // ! RELEASE + return false; + } + + if (is_representative(pi)) + { + if (! is_root(pi)) + if (internal::have_same_sign(Fb(pi), Fb(parent(pi)))) + { + std::cout << "A repr and its parent have same sign!" << std::endl; +# ifndef RELEASE + std::abort(); +# endif // ! RELEASE + return false; + } + } + else // p is not a repr + if (! internal::have_same_sign(Fb(pi), Fb(parent(pi)))) + { + std::cout << "a regular p and its repr have not the same sign!" << std::endl; +# ifndef RELEASE + std::abort(); +# endif // ! RELEASE + return false; + } + } + return true; + } + + template <typename I> + void + ztree_of_shapes<I>::trim(const util::array<face_id_t>& f, + const std::vector<face_id_t>& R0_, + const std::vector<face_id_t>& R01_, + const util::array<bool>& is_removed) + { + // We may merge shapes and faces having a different sign value + // in Fb. It would break the tree properties for recognizing + // representative among all other faces. To fix this issue, we + // update Fb so that all faces have the same value as their + // parent. + // + // Warning: we must update Fb before parent_ in order to + // preserve the validity of is_representative() which is based + // on the difference of levels between a pixel and its parent to + // decide whether it is a representative or not. Faces parts of + // 0-representative nodes may not be updated if this order of + // updates is not preserved. + for (int i = R.size() - 1; i >= 0; --i) // leaves to root + { + face_id_t p = R[i]; + if (! is_representative(p) || is_removed(p)) + Fb_.element(p) = Fb(f(parent(p))); + } + + // Adjust parent data. + parent_ = data::transform(parent_, f); + + // Update representative arrays. + R0 = R0_; + R01 = R01_; + } + +# endif // ! MLN_INCLUDE_ONLY + + } // end of namespace mln::util + +} // end of namespace mln + +#endif // ! MLN_UTIL_ZTREE_OF_SHAPES_HH -- 1.7.2.5
11Â years, 11Â months
1
0
0
0
olena-2.0-190-gfd858dc Small fixes.
by Guillaume Lazzara
* mln/util/map.hh: Fix prototype of element(). * mln/util/set.hh: Add a missing include. --- milena/ChangeLog | 8 ++++++++ milena/mln/util/map.hh | 8 ++++---- milena/mln/util/set.hh | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index b2a096f..8d00301 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,11 @@ +2013-02-11 Guillaume Lazzara <z(a)lrde.epita.fr> + + Small fixes. + + * mln/util/map.hh: Fix prototype of element(). + + * mln/util/set.hh: Add a missing include. + 2013-01-04 Guillaume Lazzara <z(a)lrde.epita.fr> * mln/util/tree_of_shapes.hh: Extend structure for storing new diff --git a/milena/mln/util/map.hh b/milena/mln/util/map.hh index 680d3e4..1cc8309 100644 --- a/milena/mln/util/map.hh +++ b/milena/mln/util/map.hh @@ -205,7 +205,7 @@ namespace mln void invalidate(); /// Give the element the iterator designates. - const std::pair<K,V>& element() const; + subj_t element() const; // As a Proxy. subj_t subj_(); @@ -256,7 +256,7 @@ namespace mln void invalidate(); /// Give the element the iterator designates. - const std::pair<K,V>& element() const; + subj_t element() const; // As a Proxy. subj_t subj_(); @@ -496,7 +496,7 @@ namespace mln template <typename K, typename V> inline - const std::pair<K,V>& + typename map_fwd_iter<K,V>::subj_t map_fwd_iter<K,V>::element() const { mln_precondition(is_valid()); @@ -579,7 +579,7 @@ namespace mln template <typename K, typename V> inline - const std::pair<K,V>& + typename map_bkd_iter<K,V>::subj_t map_bkd_iter<K,V>::element() const { mln_precondition(is_valid()); diff --git a/milena/mln/util/set.hh b/milena/mln/util/set.hh index d9e91e2..6d8608c 100644 --- a/milena/mln/util/set.hh +++ b/milena/mln/util/set.hh @@ -41,6 +41,7 @@ # include <algorithm> # include <iostream> +# include <mln/core/concept/object.hh> # include <mln/core/concept/proxy.hh> # include <mln/util/ord.hh> -- 1.7.2.5
11Â years, 11Â months
1
0
0
0
5fd931b Get chain segmentation and good pages viewer (add selection and remove).
by Antoine Froger
--- GScribo/GScribo.pro | 8 +- GScribo/GScribo.pro.user | 62 +++++----- GScribo/PagesViewer/listmodel.cpp | 21 +++- GScribo/PagesViewer/listmodel.h | 6 +- GScribo/PagesViewer/pageswidget.cpp | 33 +++++- GScribo/PagesViewer/pageswidget.h | 9 +- GScribo/Processing/progressdialog.cpp | 2 +- GScribo/Processing/runner.cpp | 28 ++-- GScribo/Processing/runner.h | 4 +- GScribo/Rendering/scene.cpp | 9 +- GScribo/Rendering/scene.h | 7 +- GScribo/Rendering/selection.h | 2 +- GScribo/main.cpp | 6 +- GScribo/mainwindow.cpp | 151 +++++++++++++++++++++++ GScribo/mainwindow.h | 60 +++++++++ GScribo/xml.cpp | 2 +- GScribo/xml.h | 24 +++- XmlTree/XmlTree.pro | 14 ++ XmlTree/XmlTree.pro.user | 160 +++++++++++++++++++++++++ {Test => XmlTree}/main.cpp | 4 +- NotePad/notepad.cpp => XmlTree/mainwindow.cpp | 12 +- XmlTree/mainwindow.h | 27 ++++ XmlTree/mainwindow.ui | 24 ++++ XmlTree/xml.cpp | 24 ++++ XmlTree/xml.h | 23 ++++ XmlTree/xmlwidget.cpp | 5 + XmlTree/xmlwidget.h | 14 ++ 27 files changed, 655 insertions(+), 86 deletions(-) create mode 100644 GScribo/mainwindow.cpp create mode 100644 GScribo/mainwindow.h create mode 100644 XmlTree/XmlTree.pro create mode 100644 XmlTree/XmlTree.pro.user copy {Test => XmlTree}/main.cpp (76%) copy NotePad/notepad.cpp => XmlTree/mainwindow.cpp (59%) create mode 100644 XmlTree/mainwindow.h create mode 100644 XmlTree/mainwindow.ui create mode 100644 XmlTree/xml.cpp create mode 100644 XmlTree/xml.h create mode 100644 XmlTree/xmlwidget.cpp create mode 100644 XmlTree/xmlwidget.h diff --git a/GScribo/GScribo.pro b/GScribo/GScribo.pro index 9ca65f6..4175a7f 100644 --- a/GScribo/GScribo.pro +++ b/GScribo/GScribo.pro @@ -28,7 +28,9 @@ SOURCES += main.cpp \ Rendering/polygonitem.cpp \ Processing/progressdialog.cpp \ Processing/process.cpp \ - Processing/preprocess.cpp + Processing/preprocess.cpp \ + Processing/runner.cpp \ + xml.cpp HEADERS += mainwindow.h \ configs.h \ region.h \ @@ -46,7 +48,9 @@ HEADERS += mainwindow.h \ Processing/preprocess.h \ Processing/progressdialog.h \ Processing/process.h \ - dir.h + dir.h \ + Processing/runner.h \ + xml.h FORMS += mainwindow.ui \ Preferences/preferencesdialog.ui \ Preferences/ocroptions.ui \ diff --git a/GScribo/GScribo.pro.user b/GScribo/GScribo.pro.user index e3df61a..2415250 100644 --- a/GScribo/GScribo.pro.user +++ b/GScribo/GScribo.pro.user @@ -58,6 +58,7 @@ <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <value key="QtVersionId" type="int">2</value> <value key="ToolChain" type="int">0</value> + <value key="addQDumper" type=""></value> <value key="buildConfiguration" type="int">2</value> </valuemap> </data> @@ -66,36 +67,35 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Rm9H5yDUD5,guid=00a0d6b325751c50c00c26e2006a9203</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-P80XV4IXzt,guid=a5409515b0d4b55f3087c5ac006be134</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kTB4J7</value> - <value type="QString">GNOME_KEYRING_PID=27564</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-hNSqJb</value> + <value type="QString">GNOME_KEYRING_PID=26128</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> - <value type="QString">LANGUAGE=</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt/GScribo/Preferences</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=27639</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-qeVjd27573/agent.27573</value> + <value type="QString">SSH_AGENT_PID=26203</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-JCcKD26137/agent.26137</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm9DVURW</value> + <value type="QString">WINDOWID=16777252</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmDXEURW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359032006.901905-2088645706</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359117815.965216-788943747</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -119,36 +119,35 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Rm9H5yDUD5,guid=00a0d6b325751c50c00c26e2006a9203</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-P80XV4IXzt,guid=a5409515b0d4b55f3087c5ac006be134</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kTB4J7</value> - <value type="QString">GNOME_KEYRING_PID=27564</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-hNSqJb</value> + <value type="QString">GNOME_KEYRING_PID=26128</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> - <value type="QString">LANGUAGE=</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt/GScribo/Preferences</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=27639</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-qeVjd27573/agent.27573</value> + <value type="QString">SSH_AGENT_PID=26203</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-JCcKD26137/agent.26137</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm9DVURW</value> + <value type="QString">WINDOWID=16777252</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmDXEURW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359032006.901905-2088645706</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359117815.965216-788943747</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -169,35 +168,36 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Rm9H5yDUD5,guid=00a0d6b325751c50c00c26e2006a9203</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-E725PGjN72,guid=03a3a01426a1915469d93b2f006b9a87</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kTB4J7</value> - <value type="QString">GNOME_KEYRING_PID=27564</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-qpwUT9</value> + <value type="QString">GNOME_KEYRING_PID=23170</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> + <value type="QString">LANGUAGE=</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt/GScribo/Preferences</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=27639</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-qeVjd27573/agent.27573</value> + <value type="QString">SSH_AGENT_PID=23245</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-CQzeO23179/agent.23179</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm9DVURW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm87KZRW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359032006.901905-2088645706</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359099722.931858-1143452610</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> diff --git a/GScribo/PagesViewer/listmodel.cpp b/GScribo/PagesViewer/listmodel.cpp index 6fd60db..9748e76 100644 --- a/GScribo/PagesViewer/listmodel.cpp +++ b/GScribo/PagesViewer/listmodel.cpp @@ -5,6 +5,11 @@ ListModel::ListModel(QObject *parent): { } +QStringList ListModel::filenames() const +{ + return paths; +} + int ListModel::rowCount(const QModelIndex&) const { return pixmaps.size(); @@ -24,7 +29,7 @@ QVariant ListModel::data(const QModelIndex& index, int role) const // Store the path of the pixmap in an other custom place. if(role == Qt::UserRole+1) - return filenames.value(index.row()); + return paths.value(index.row()); return QVariant(); } @@ -36,7 +41,19 @@ void ListModel::addPixmap(const QString& filename, const QPixmap& pixmap) beginInsertRows(QModelIndex(), row, row); pixmaps.insert(row, pixmap); - filenames.insert(row, filename); + paths.insert(row, filename); endInsertRows(); } + +void ListModel::removePixmap(const QModelIndex &parent) +{ + int row = parent.row(); + + beginRemoveRows(parent, row, row); + + pixmaps.removeAt(row); + paths.removeAt(row); + + endRemoveRows(); +} diff --git a/GScribo/PagesViewer/listmodel.h b/GScribo/PagesViewer/listmodel.h index 2f0350e..328d3ca 100644 --- a/GScribo/PagesViewer/listmodel.h +++ b/GScribo/PagesViewer/listmodel.h @@ -12,13 +12,17 @@ class ListModel: public: explicit ListModel(QObject *parent = 0); + QStringList filenames() const; int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role = Qt::DecorationRole) const; void addPixmap(const QString& filename, const QPixmap& pixmap); private: QList<QPixmap> pixmaps; - QList<QString> filenames; + QStringList paths; + + public slots: + void removePixmap(const QModelIndex &parent); }; #endif // LISTMODEL_H diff --git a/GScribo/PagesViewer/pageswidget.cpp b/GScribo/PagesViewer/pageswidget.cpp index 712f5eb..3f975b4 100644 --- a/GScribo/PagesViewer/pageswidget.cpp +++ b/GScribo/PagesViewer/pageswidget.cpp @@ -4,6 +4,8 @@ PagesWidget::PagesWidget(QWidget *parent): QListView(parent) { setUniformItemSizes(true); + setSelectionMode(QAbstractItemView::ExtendedSelection); + setSelectionRectVisible(false); setViewMode(QListView::IconMode); setIconSize(QSize(200, 200)); setFlow(QListView::TopToBottom); @@ -12,15 +14,15 @@ PagesWidget::PagesWidget(QWidget *parent): setWrapping(false); setModel(&model); - connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(getSelection(QModelIndex))); + connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(getPixmap(QModelIndex))); } -void PagesWidget::addPixmap(const QString& filename, const QPixmap &pixmap) +QStringList PagesWidget::filenames() const { - model.addPixmap(filename, pixmap); + return model.filenames(); } -void PagesWidget::getSelection(const QModelIndex &index) +void PagesWidget::getPixmap(const QModelIndex &index) { // Get the pixmap and the path of the icon to send it to the scene and draw it. QPixmap pixmap = index.data(Qt::UserRole).value<QPixmap>(); @@ -28,3 +30,26 @@ void PagesWidget::getSelection(const QModelIndex &index) emit selectionClicked(filename, pixmap); } + +void PagesWidget::addPixmap(const QString& filename, const QPixmap &pixmap) +{ + model.addPixmap(filename, pixmap); +} + +void PagesWidget::removeSelection() +{ + QModelIndexList indexes = selectedIndexes(); + + if(indexes.count() > 0) + { + // We have to sort the list because after the first removal, the second row index may not be the good one. + qSort(indexes.begin(), indexes.end()); + + // From the highest row value to the smallest to be sure to remove the good index. + for(int i = indexes.count()-1; i > -1; i--) + model.removePixmap(indexes[i]); + + getPixmap(model.index(indexes[0].row())); + clearSelection(); + } +} diff --git a/GScribo/PagesViewer/pageswidget.h b/GScribo/PagesViewer/pageswidget.h index ae17a4a..07d32ac 100644 --- a/GScribo/PagesViewer/pageswidget.h +++ b/GScribo/PagesViewer/pageswidget.h @@ -1,11 +1,8 @@ #ifndef PAGESWIDGET_H #define PAGESWIDGET_H -#include <QPushButton> -#include <QScrollBar> #include <QListView> -#include <QPainter> -#include <QWidget> +#include <QShortcut> #include "listmodel.h" @@ -17,12 +14,14 @@ class PagesWidget: public: explicit PagesWidget(QWidget *parent = 0); void addPixmap(const QString& filename, const QPixmap& pixmap); + QStringList filenames() const; private: ListModel model; public slots: - void getSelection(const QModelIndex &index); + void getPixmap(const QModelIndex &index); + void removeSelection(); signals: void clicked(const QModelIndex &index); diff --git a/GScribo/Processing/progressdialog.cpp b/GScribo/Processing/progressdialog.cpp index 386aaa6..c4ae96f 100644 --- a/GScribo/Processing/progressdialog.cpp +++ b/GScribo/Processing/progressdialog.cpp @@ -17,6 +17,6 @@ void ProgressDialog::run() void ProgressDialog::reset() { setValue(0); - setLabelText(""); + setLabelText("Initilization"); show(); } diff --git a/GScribo/Processing/runner.cpp b/GScribo/Processing/runner.cpp index ebde288..5024acd 100644 --- a/GScribo/Processing/runner.cpp +++ b/GScribo/Processing/runner.cpp @@ -29,9 +29,12 @@ void Runner::run() case Demat: { image2d<value::rgb8> ima; - io::magick::load(ima, args_.at(0).toUtf8().constData()); - image2d<bool> bin_ima = preprocess(ima); - process(ima, bin_ima); + for(int i = 0; i < args_.count(); i++) + { + io::magick::load(ima, args_.at(i).toUtf8().constData()); + image2d<bool> bin_ima = preprocess(ima); + process(ima, bin_ima, i); + } emit finished(); } break; @@ -48,10 +51,10 @@ void Runner::stop() } // Demat related stuff -void Runner::start_demat(const QString& filename) +void Runner::start_demat(const QStringList& filenames) { args_.clear(); - args_ << filename; + args_ = filenames; mode_ = Demat; QThread::start(); } @@ -86,11 +89,11 @@ image2d<bool> Runner::preprocess(const image2d<value::rgb8>& ima) void Runner::process(const image2d<value::rgb8>& original_ima, - const image2d<bool>& processed_ima) + const image2d<bool>& processed_ima, int arg) { emit new_step("Page segmentation"); - Process f(args_.at(0).toUtf8().constData()); + Process f(args_.at(arg).toUtf8().constData()); connect(&f, SIGNAL(progress()), this, SIGNAL(progress())); connect(&f, SIGNAL(newProgressLabel(QString)), @@ -112,7 +115,7 @@ void Runner::process(const image2d<value::rgb8>& original_ima, f.save_doc_as_xml = true; - QFileInfo file(args_.at(0)); + QFileInfo file(args_.at(arg)); QString output_dir = QDir::tempPath(); if (conf->generalSaveXmlEnabled()) { @@ -134,8 +137,6 @@ void Runner::process(const image2d<value::rgb8>& original_ima, emit xml_saved(filename); } - - // Export related stuff void Runner::start_export(const QString& imgfile, const QString& xmlfile, const QString& outfile) @@ -147,10 +148,9 @@ void Runner::start_export(const QString& imgfile, QThread::start(); } - void Runner::export_as() { - emit new_step("Exporting document..."); + emit new_step("Exporting document"); emit new_progress_max_value(2); // Checking output format @@ -169,14 +169,14 @@ void Runner::export_as() int rvalue = 0; if (f.suffix() == "pdf") { - emit new_step("Exporting as PDF..."); + emit new_step("Exporting as PDF"); rvalue = system(QString("%1/scribo-xml2doc --pdf %2 %3 %4") .arg(pathto_xml2doc).arg(args_.at(1)).arg(args_.at(0)) .arg(args_.at(2)).toAscii().constData()); } else if (f.suffix() == "html" || f.suffix() == "htm") { - emit new_step("Exporting as HTML..."); + emit new_step("Exporting as HTML"); rvalue = system(QString("%1/scribo-xml2doc --html %2 %3 %4") .arg(pathto_xml2doc).arg(args_.at(1)).arg(args_.at(0)) .arg(args_.at(2)).toAscii().constData()); diff --git a/GScribo/Processing/runner.h b/GScribo/Processing/runner.h index 51969e3..721086a 100644 --- a/GScribo/Processing/runner.h +++ b/GScribo/Processing/runner.h @@ -30,12 +30,12 @@ class Runner : public: explicit Runner(QObject *parent = 0); - void start_demat(const QString& filename); + void start_demat(const QStringList& filenames); void start_export(const QString& imgfile, const QString& xmlfile, const QString& outfile); private: image2d<bool> preprocess(const image2d<value::rgb8>& ima); - void process(const image2d<value::rgb8>& original_ima, const image2d<bool>& processed_ima); + void process(const image2d<value::rgb8>& original_ima, const image2d<bool>& processed_ima, int arg); void export_as(); virtual void run(); template <typename V> unsigned find_best_scale(const mln::image2d<V>& ima); diff --git a/GScribo/Rendering/scene.cpp b/GScribo/Rendering/scene.cpp index 5035b28..695a4f1 100644 --- a/GScribo/Rendering/scene.cpp +++ b/GScribo/Rendering/scene.cpp @@ -28,6 +28,11 @@ void Scene::init() addItem(&selection); } +QString Scene::backgroundPath() const +{ + return path; +} + void Scene::removeItems() { QList<QGraphicsItem *> itemsList = items(); @@ -91,9 +96,9 @@ void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) void Scene::setBackground(const QString& filename, const QPixmap& pixmap) { - if(backgroundPath != filename) + if(path != filename) { - backgroundPath = filename; + path = filename; setSceneRect(pixmap.rect()); setBackgroundBrush(QBrush(pixmap)); diff --git a/GScribo/Rendering/scene.h b/GScribo/Rendering/scene.h index c4a627a..6aa7668 100644 --- a/GScribo/Rendering/scene.h +++ b/GScribo/Rendering/scene.h @@ -1,9 +1,9 @@ #ifndef SCENE_H #define SCENE_H -#include <QFileDialog> -#include <QGraphicsScene> #include <QGraphicsSceneMouseEvent> +#include <QGraphicsScene> +#include <QFileDialog> #include "selection.h" #include "polygonitem.h" @@ -17,6 +17,7 @@ class Scene : explicit Scene(QObject *parent = 0); explicit Scene(const QRectF &sceneRect, QObject *parent = 0); explicit Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent = 0); + QString backgroundPath() const; void removeItems(); protected: @@ -27,7 +28,7 @@ class Scene : private: void init(); - QString backgroundPath; + QString path; Selection selection; QPointF pressPos; bool isPressing; diff --git a/GScribo/Rendering/selection.h b/GScribo/Rendering/selection.h index 4864e15..ace8f01 100644 --- a/GScribo/Rendering/selection.h +++ b/GScribo/Rendering/selection.h @@ -2,8 +2,8 @@ #define SELECTION_H #include <QGraphicsRectItem> -#include <QPen> #include <climits> +#include <QPen> class Selection : public QGraphicsRectItem diff --git a/GScribo/main.cpp b/GScribo/main.cpp index b8f57bd..bd76409 100644 --- a/GScribo/main.cpp +++ b/GScribo/main.cpp @@ -1,10 +1,12 @@ +#undef MLN_WO_GLOBAL_VARS + +#include <scribo/make/debug_filename.hh> #include <mln/labeling/colorize.hh> -#include <mln/math/pi.hh> #include <mln/io/magick/load.hh> #include <mln/literal/colors.hh> #include <mln/debug/filename.hh> -#include <scribo/make/debug_filename.hh> #include <QtGui/QApplication> +#include <mln/math/pi.hh> #include "mainwindow.h" diff --git a/GScribo/mainwindow.cpp b/GScribo/mainwindow.cpp new file mode 100644 index 0000000..4b2a4d3 --- /dev/null +++ b/GScribo/mainwindow.cpp @@ -0,0 +1,151 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + setWindowTitle(tr("GScribo")); + //progressDialog.setParent(this); + + initGraphicsRegion(); + initTextRegion(); + initPageWidget(); + initToolBar(); + initMenuBar(); + + connectWidgets(); + connectShortcuts(); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::initGraphicsRegion() +{ + // Cache backgroud to speed up its repaint. + graphicsView.setCacheMode(QGraphicsView::CacheBackground); + graphicsView.setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); + graphicsView.setScene(&scene); + + setCentralWidget(&graphicsView); +} + +void MainWindow::initPageWidget() +{ + dockPages.setWindowTitle(tr("Pages")); + dockPages.setFeatures(QDockWidget::DockWidgetClosable); + dockPages.setMaximumWidth(190); + dockPages.setMinimumWidth(190); + dockPages.setWidget(&pagesWidget); + + addDockWidget(Qt::LeftDockWidgetArea, &dockPages); +} + +void MainWindow::initTextRegion() +{ + dockText.setWindowTitle(tr("Text")); + dockText.setAllowedAreas(Qt::AllDockWidgetAreas); + dockText.setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + dockText.setWidget(&textEdit); + + addDockWidget(Qt::RightDockWidgetArea, &dockText); + dockText.hide(); +} + +void MainWindow::initToolBar() +{ + QAction *open = ui->mainToolBar->addAction(tr("Open")); + connect(open, SIGNAL(triggered()), this, SLOT(onOpen())); + + QAction *segment = ui->mainToolBar->addAction(tr("Segment")); + connect(segment, SIGNAL(triggered()), this, SLOT(onSegment())); + + QAction *del = ui->mainToolBar->addAction(tr("Delete")); + connect(del, SIGNAL(triggered()), &pagesWidget, SLOT(removeSelection())); +} + +void MainWindow::initMenuBar() +{ + QAction *preferences = ui->menuBar->addAction(tr("Preferences")); + connect(preferences, SIGNAL(triggered()), SLOT(onPreferences())); +} + +void MainWindow::onOpen() +{ + QStringList paths = QFileDialog::getOpenFileNames(this, "Open Image(s)", QDir::homePath(), "Images (*.png *.jpg *.ppm *.bmp)"); + + if(paths.count() > 0) + { + QString path = paths[0]; + QPixmap pixmap(path); + + scene.setBackground(path, pixmap); + pagesWidget.addPixmap(path, pixmap); + + // If more than one file, we store it in the page widget. + for(int i = 1; i < paths.count(); i++) + { + path = paths[i]; + pixmap.load(path); + pagesWidget.addPixmap(path, pixmap); + } + } +} + +void MainWindow::onSegment() +{ + if(scene.backgroundPath() != "") + { + QStringList filenames; + + if(!pagesWidget.isVisible()) + filenames << scene.backgroundPath(); + + else + filenames = pagesWidget.filenames(); + + progressDialog.reset(); + runner.start_demat(filenames); + } +} + +void MainWindow::onPreferences() +{ + PreferencesDialog *preferenceDialog = new PreferencesDialog(this); + preferenceDialog->show(); +} + +void MainWindow::connectWidgets() +{ + // If double click on a picture of the page widget -> draw it on background scene. + connect(&pagesWidget, SIGNAL(selectionClicked(QString,QPixmap)), &scene, SLOT(setBackground(QString,QPixmap))); + + connect(&runner, SIGNAL(progress()), &progressDialog, SLOT(run())); + connect(&runner, SIGNAL(new_progress_max_value(int)), &progressDialog, SLOT(setMaximum(int))); + connect(&runner, SIGNAL(new_progress_label(QString)), &progressDialog, SLOT(setLabelText(QString))); + connect(&runner, SIGNAL(finished()), &progressDialog, SLOT(close())); +} + +void MainWindow::connectShortcuts() +{ + QShortcut *del = new QShortcut(Qt::Key_Delete, &pagesWidget); + connect(del, SIGNAL(activated()), &pagesWidget, SLOT(removeSelection())); +} + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) + { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/GScribo/mainwindow.h b/GScribo/mainwindow.h new file mode 100644 index 0000000..708a4f6 --- /dev/null +++ b/GScribo/mainwindow.h @@ -0,0 +1,60 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QGraphicsView> +#include <QPlainTextEdit> +#include <QMainWindow> +#include <QHBoxLayout> +#include <QDockWidget> +#include <QFileDialog> +#include <QGroupBox> + +#include "Preferences/preferencesdialog.h" +#include "Processing/progressdialog.h" +#include "PagesViewer/pageswidget.h" +#include "Processing/runner.h" +#include "Rendering/scene.h" + +namespace Ui +{ + class MainWindow; +} + +class MainWindow: + public QMainWindow +{ + Q_OBJECT + + public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + + protected: + void changeEvent(QEvent *e); + + private: + void initGraphicsRegion(); + void initTextRegion(); + void initToolBar(); + void initPageWidget(); + void initMenuBar(); + void connectWidgets(); + void connectShortcuts(); + + Ui::MainWindow *ui; + QDockWidget dockText; + QDockWidget dockPages; + QGraphicsView graphicsView; + Scene scene; + QPlainTextEdit textEdit; + PagesWidget pagesWidget; + Runner runner; + ProgressDialog progressDialog; + + private slots: + void onOpen(); + void onSegment(); + void onPreferences(); +}; + +#endif // MAINWINDOW_H diff --git a/GScribo/xml.cpp b/GScribo/xml.cpp index 67c5451..c213728 100644 --- a/GScribo/xml.cpp +++ b/GScribo/xml.cpp @@ -1,5 +1,4 @@ #include "xml.h" -#include "region.h" static const GraphicRegion::Data itemsData[] = { @@ -16,6 +15,7 @@ static const GraphicRegion::Data itemsData[] = Xml::Xml() { + } void Xml::graphicsRegion(const QDomElement& element, const GraphicRegion::Data& data, Scene *scene) diff --git a/GScribo/xml.h b/GScribo/xml.h index c694a95..840f73a 100644 --- a/GScribo/xml.h +++ b/GScribo/xml.h @@ -1,16 +1,24 @@ #ifndef XML_H #define XML_H -#include <QString> #include <QGraphicsItem> #include <QDomElement> -#include <QFile> -#include <climits> #include <QTextEdit> +#include <climits> +#include <QString> +#include <QFile> + #include "polygonitem.h" #include "region.h" +#include "region.h" #include "scene.h" +struct Node +{ + QDomElement root; + QDomElement +}; + class Xml: QObject { @@ -19,10 +27,12 @@ class Xml: static void parseItems(const QString &filename, Scene *scene); private: - static void graphicsRegion(const QDomElement& element, const GraphicRegion::Data& data, Scene *scene); - static void graphicsTypoRegion(const QDomElement& element, const QPoint& xPos, Scene *scene); - static void graphicsLineRegion(const QDomElement& element, Scene *scene); - static void graphicsTextRegion(const QDomElement& element, Scene *scene); + void graphicsRegion(const QDomElement& element, const GraphicRegion::Data& data, Scene *scene); + void graphicsTypoRegion(const QDomElement& element, const QPoint& xPos, Scene *scene); + void graphicsLineRegion(const QDomElement& element, Scene *scene); + void graphicsTextRegion(const QDomElement& element, Scene *scene); + + QDomElement root; }; #endif // XML_H diff --git a/XmlTree/XmlTree.pro b/XmlTree/XmlTree.pro new file mode 100644 index 0000000..c3fcab9 --- /dev/null +++ b/XmlTree/XmlTree.pro @@ -0,0 +1,14 @@ +# ------------------------------------------------- +# Project created by QtCreator 2013-01-25T17:20:25 +# ------------------------------------------------- +QT += xml +TARGET = XmlTree +TEMPLATE = app +SOURCES += main.cpp \ + mainwindow.cpp \ + xmlwidget.cpp \ + xml.cpp +HEADERS += mainwindow.h \ + xmlwidget.h \ + xml.h +FORMS += mainwindow.ui diff --git a/XmlTree/XmlTree.pro.user b/XmlTree/XmlTree.pro.user new file mode 100644 index 0000000..eef8a12 --- /dev/null +++ b/XmlTree/XmlTree.pro.user @@ -0,0 +1,160 @@ +<!DOCTYPE QtCreatorProject> +<qtcreator> + <data> + <variable>RunConfiguration0-BaseEnvironmentBase</variable> + <value type="int">2</value> + </data> + <data> + <variable>RunConfiguration0-CommandLineArguments</variable> + <valuelist type="QVariantList"/> + </data> + <data> + <variable>RunConfiguration0-ProFile</variable> + <value type="QString">XmlTree.pro</value> + </data> + <data> + <variable>RunConfiguration0-RunConfiguration.name</variable> + <value type="QString">XmlTree</value> + </data> + <data> + <variable>RunConfiguration0-UseDyldImageSuffix</variable> + <value type="bool">false</value> + </data> + <data> + <variable>RunConfiguration0-UseTerminal</variable> + <value type="bool">false</value> + </data> + <data> + <variable>RunConfiguration0-UserEnvironmentChanges</variable> + <valuelist type="QVariantList"/> + </data> + <data> + <variable>RunConfiguration0-UserSetName</variable> + <value type="bool">false</value> + </data> + <data> + <variable>RunConfiguration0-UserSetWorkingDirectory</variable> + <value type="bool">false</value> + </data> + <data> + <variable>RunConfiguration0-UserWorkingDirectory</variable> + <value type="QString"></value> + </data> + <data> + <variable>RunConfiguration0-type</variable> + <value type="QString">Qt4ProjectManager.Qt4RunConfiguration</value> + </data> + <data> + <variable>activeRunConfiguration</variable> + <value type="int">0</value> + </data> + <data> + <variable>activebuildconfiguration</variable> + <value type="QString">Debug</value> + </data> + <data> + <variable>buildConfiguration-Debug</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> + <value key="QtVersionId" type="int">0</value> + <value key="ToolChain" type="int">0</value> + <value key="buildConfiguration" type="int">2</value> + </valuemap> + </data> + <data> + <variable>buildConfiguration-Release</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> + <value key="QtVersionId" type="int">0</value> + <value key="buildConfiguration" type="int">0</value> + </valuemap> + </data> + <data> + <variable>buildconfiguration-Debug-buildstep0</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> + </valuemap> + </data> + <data> + <variable>buildconfiguration-Debug-buildstep1</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> + </valuemap> + </data> + <data> + <variable>buildconfiguration-Debug-cleanstep0</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> + <value key="cleanConfig" type="bool">true</value> + <valuelist key="makeargs" type="QVariantList"> + <value type="QString">clean</value> + </valuelist> + </valuemap> + </data> + <data> + <variable>buildconfiguration-Release-buildstep0</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> + </valuemap> + </data> + <data> + <variable>buildconfiguration-Release-buildstep1</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> + </valuemap> + </data> + <data> + <variable>buildconfiguration-Release-cleanstep0</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> + </valuemap> + </data> + <data> + <variable>buildconfigurations</variable> + <valuelist type="QVariantList"> + <value type="QString">Debug</value> + <value type="QString">Release</value> + </valuelist> + </data> + <data> + <variable>buildstep0</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value> + <value key="mkspec" type="QString"></value> + </valuemap> + </data> + <data> + <variable>buildstep1</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value> + </valuemap> + </data> + <data> + <variable>buildsteps</variable> + <valuelist type="QVariantList"> + <value type="QString">trolltech.qt4projectmanager.qmake</value> + <value type="QString">trolltech.qt4projectmanager.make</value> + </valuelist> + </data> + <data> + <variable>cleanstep0</variable> + <valuemap type="QVariantMap"> + <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value> + <value key="clean" type="bool">true</value> + </valuemap> + </data> + <data> + <variable>cleansteps</variable> + <valuelist type="QVariantList"> + <value type="QString">trolltech.qt4projectmanager.make</value> + </valuelist> + </data> + <data> + <variable>defaultFileEncoding</variable> + <value type="QByteArray">System</value> + </data> + <data> + <variable>project</variable> + <valuemap type="QVariantMap"/> + </data> +</qtcreator> diff --git a/Test/main.cpp b/XmlTree/main.cpp similarity index 76% copy from Test/main.cpp copy to XmlTree/main.cpp index 9f16ac8..6e7efd9 100644 --- a/Test/main.cpp +++ b/XmlTree/main.cpp @@ -1,10 +1,10 @@ #include <QtGui/QApplication> -#include "test.h" +#include "mainwindow.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); - Test w; + MainWindow w; w.show(); return a.exec(); } diff --git a/NotePad/notepad.cpp b/XmlTree/mainwindow.cpp similarity index 59% copy from NotePad/notepad.cpp copy to XmlTree/mainwindow.cpp index 57fc04f..7a8cf0a 100644 --- a/NotePad/notepad.cpp +++ b/XmlTree/mainwindow.cpp @@ -1,19 +1,19 @@ -#include "notepad.h" -#include "ui_notepad.h" +#include "mainwindow.h" +#include "ui_mainwindow.h" -NotePad::NotePad(QWidget *parent) : +MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), - ui(new Ui::NotePad) + ui(new Ui::MainWindow) { ui->setupUi(this); } -NotePad::~NotePad() +MainWindow::~MainWindow() { delete ui; } -void NotePad::changeEvent(QEvent *e) +void MainWindow::changeEvent(QEvent *e) { QMainWindow::changeEvent(e); switch (e->type()) diff --git a/XmlTree/mainwindow.h b/XmlTree/mainwindow.h new file mode 100644 index 0000000..fb82901 --- /dev/null +++ b/XmlTree/mainwindow.h @@ -0,0 +1,27 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : + public QMainWindow +{ + Q_OBJECT + + public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + + protected: + void changeEvent(QEvent *e); + + private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/XmlTree/mainwindow.ui b/XmlTree/mainwindow.ui new file mode 100644 index 0000000..97c03be --- /dev/null +++ b/XmlTree/mainwindow.ui @@ -0,0 +1,24 @@ +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>600</width> + <height>400</height> + </rect> + </property> + <property name="windowTitle" > + <string>MainWindow</string> + </property> + <widget class="QMenuBar" name="menuBar" /> + <widget class="QToolBar" name="mainToolBar" /> + <widget class="QWidget" name="centralWidget" /> + <widget class="QStatusBar" name="statusBar" /> + </widget> + <layoutDefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> diff --git a/XmlTree/xml.cpp b/XmlTree/xml.cpp new file mode 100644 index 0000000..febcd69 --- /dev/null +++ b/XmlTree/xml.cpp @@ -0,0 +1,24 @@ +#include "xml.h" + +Xml::Xml() +{ +} + +Xml::Xml(const QString &filename) +{ + load(filename); +} + +void Xml::load(const QString &filename) +{ + QFile xmlFile(filename); + xmlFile.open(QIODevice::ReadOnly); + + QDomDocument xml; + xml.setContent(&xmlFile); + + xmlFile.close(); + + QDomElement root = xml.documentElement(); + tItems.setText(0, QStringList(root.tagName())); +} diff --git a/XmlTree/xml.h b/XmlTree/xml.h new file mode 100644 index 0000000..1353c62 --- /dev/null +++ b/XmlTree/xml.h @@ -0,0 +1,23 @@ +#ifndef XML_H +#define XML_H + +#include <QTreeWidgetItem> +#include <QGraphicsItem> +#include <QDomElement> +#include <QFile> + +class Xml +{ + public: + Xml(); + explicit Xml(const QString& filename); + void load(const QString& filename); + QList<QGraphicsItem *> graphicsItems() const; + QTreeWidgetItem * treeItem() const; + + private: + QList<QGraphicsItem *> gItems; + QTreeWidgetItem tItems; +}; + +#endif // XML_H diff --git a/XmlTree/xmlwidget.cpp b/XmlTree/xmlwidget.cpp new file mode 100644 index 0000000..e9d7a60 --- /dev/null +++ b/XmlTree/xmlwidget.cpp @@ -0,0 +1,5 @@ +#include "xmlwidget.h" + +XmlWidget::XmlWidget() +{ +} diff --git a/XmlTree/xmlwidget.h b/XmlTree/xmlwidget.h new file mode 100644 index 0000000..906c1d0 --- /dev/null +++ b/XmlTree/xmlwidget.h @@ -0,0 +1,14 @@ +#ifndef XMLWIDGET_H +#define XMLWIDGET_H + +#include <QDomElement> +#include <QWidget> + +class XmlWidget : + public QWidget +{ + public: + explicit XmlWidget(const QString& filename); +}; + +#endif // XMLWIDGET_H -- 1.7.2.5
11Â years, 11Â months
1
0
0
0
b16ebc4 Finish pages viewer (just one little problem) and add config dialog.
by Antoine Froger
--- GScribo/GScribo.pro | 52 ++++-- GScribo/GScribo.pro.user | 113 +++++++----- GScribo/{ => PagesViewer}/listmodel.cpp | 14 ++- GScribo/{ => PagesViewer}/listmodel.h | 3 +- GScribo/PagesViewer/pageswidget.cpp | 30 ++++ GScribo/{ => PagesViewer}/pageswidget.h | 13 +- GScribo/Preferences/generaloptions.ui | 100 +++++++++++ GScribo/Preferences/ocroptions.ui | 62 +++++++ GScribo/Preferences/optionwidget.cpp | 14 ++ GScribo/Preferences/optionwidget.h | 15 ++ GScribo/Preferences/preferencesdialog.ui | 121 +++++++++++++ GScribo/Preferences/preprocessingoptions.ui | 76 ++++++++ GScribo/Preferences/segmentationoptions.ui | 52 ++++++ GScribo/{ => Processing}/preprocess.cpp | 0 GScribo/{ => Processing}/preprocess.h | 4 +- GScribo/{ => Processing}/process.cpp | 0 GScribo/{ => Processing}/process.h | 4 +- GScribo/{ => Processing}/progressdialog.cpp | 0 GScribo/{ => Processing}/progressdialog.h | 0 GScribo/{ => Processing}/runner.cpp | 8 - GScribo/{ => Processing}/runner.h | 15 +- GScribo/Rendering/polygonitem.cpp | 76 ++++++++ GScribo/{ => Rendering}/polygonitem.h | 9 +- GScribo/Rendering/scene.cpp | 101 +++++++++++ GScribo/{ => Rendering}/scene.h | 7 +- GScribo/{ => Rendering}/selection.cpp | 3 + GScribo/{ => Rendering}/selection.h | 0 {XmlParser => GScribo}/configs.cpp | 34 ++++- GScribo/{config.h => configs.h} | 3 + GScribo/dir.h | 2 +- GScribo/icon.cpp | 26 --- GScribo/icon.h | 21 --- GScribo/mainwindow.ui | 8 +- GScribo/pageswidget.cpp | 19 -- GScribo/polygonitem.cpp | 75 -------- {XmlParser => GScribo}/region.h | 0 GScribo/scene.cpp | 82 --------- GScribo/ui_mainwindow.h | 73 -------- MVC/MVC.pro | 13 -- MVC/MVC.pro.user | 251 --------------------------- MVC/itemdelegate.cpp | 19 -- MVC/itemdelegate.h | 17 -- MVC/listmodel.cpp | 32 ---- MVC/listmodel.h | 24 --- MVC/main.cpp | 11 -- MVC/mainwindow.cpp | 40 ----- MVC/mainwindow.h | 30 ---- MVC/mainwindow.ui | 24 --- MVC/ui_mainwindow.h | 70 -------- XmlParser/XmlParser.pro.user | 38 ++-- gmvc/gmodel.cpp | 162 ----------------- gmvc/gmodel.h | 34 ---- gmvc/gmvc.pro | 13 -- gmvc/gmvc.pro.user | 251 --------------------------- gmvc/main.cpp | 11 -- gmvc/mainwindow.cpp | 51 ------ gmvc/mainwindow.h | 28 --- gmvc/mainwindow.ui | 24 --- gmvc/model.cpp | 37 ---- gmvc/model.h | 20 -- 60 files changed, 860 insertions(+), 1575 deletions(-) rename GScribo/{ => PagesViewer}/listmodel.cpp (62%) rename GScribo/{ => PagesViewer}/listmodel.h (80%) create mode 100644 GScribo/PagesViewer/pageswidget.cpp rename GScribo/{ => PagesViewer}/pageswidget.h (67%) create mode 100644 GScribo/Preferences/generaloptions.ui create mode 100644 GScribo/Preferences/ocroptions.ui create mode 100644 GScribo/Preferences/optionwidget.cpp create mode 100644 GScribo/Preferences/optionwidget.h create mode 100644 GScribo/Preferences/preferencesdialog.ui create mode 100644 GScribo/Preferences/preprocessingoptions.ui create mode 100644 GScribo/Preferences/segmentationoptions.ui rename GScribo/{ => Processing}/preprocess.cpp (100%) rename GScribo/{ => Processing}/preprocess.h (100%) rename GScribo/{ => Processing}/process.cpp (100%) rename GScribo/{ => Processing}/process.h (100%) rename GScribo/{ => Processing}/progressdialog.cpp (100%) rename GScribo/{ => Processing}/progressdialog.h (100%) rename GScribo/{ => Processing}/runner.cpp (95%) rename GScribo/{ => Processing}/runner.h (99%) create mode 100644 GScribo/Rendering/polygonitem.cpp rename GScribo/{ => Rendering}/polygonitem.h (80%) create mode 100644 GScribo/Rendering/scene.cpp rename GScribo/{ => Rendering}/scene.h (85%) rename GScribo/{ => Rendering}/selection.cpp (94%) rename GScribo/{ => Rendering}/selection.h (100%) rename {XmlParser => GScribo}/configs.cpp (95%) rename GScribo/{config.h => configs.h} (93%) delete mode 100644 GScribo/icon.cpp delete mode 100644 GScribo/icon.h delete mode 100644 GScribo/pageswidget.cpp delete mode 100644 GScribo/polygonitem.cpp copy {XmlParser => GScribo}/region.h (100%) delete mode 100644 GScribo/scene.cpp delete mode 100644 GScribo/ui_mainwindow.h delete mode 100644 MVC/MVC.pro delete mode 100644 MVC/MVC.pro.user delete mode 100644 MVC/itemdelegate.cpp delete mode 100644 MVC/itemdelegate.h delete mode 100644 MVC/listmodel.cpp delete mode 100644 MVC/listmodel.h delete mode 100644 MVC/main.cpp delete mode 100644 MVC/mainwindow.cpp delete mode 100644 MVC/mainwindow.h delete mode 100644 MVC/mainwindow.ui delete mode 100644 MVC/ui_mainwindow.h delete mode 100644 gmvc/gmodel.cpp delete mode 100644 gmvc/gmodel.h delete mode 100644 gmvc/gmvc.pro delete mode 100644 gmvc/gmvc.pro.user delete mode 100644 gmvc/main.cpp delete mode 100644 gmvc/mainwindow.cpp delete mode 100644 gmvc/mainwindow.h delete mode 100644 gmvc/mainwindow.ui delete mode 100644 gmvc/model.cpp delete mode 100644 gmvc/model.h diff --git a/GScribo/GScribo.pro b/GScribo/GScribo.pro index 57041dc..9ca65f6 100644 --- a/GScribo/GScribo.pro +++ b/GScribo/GScribo.pro @@ -1,8 +1,7 @@ # ------------------------------------------------- # Project created by QtCreator 2013-01-21T09:20:54 # ------------------------------------------------- -QT += opengl \ - xml +QT += xml INCLUDEPATH += /lrde/home/stage/froger_a/olena/milena/ \ /lrde/home/stage/froger_a/olena/scribo/ \ /lrde/home/stage/froger_a/olena/_build/scribo/demo/ @@ -15,15 +14,42 @@ TARGET = GScribo TEMPLATE = app SOURCES += main.cpp \ mainwindow.cpp \ - scene.cpp \ - selection.cpp \ - pageswidget.cpp \ - listmodel.cpp \ - icon.cpp + configs.cpp \ + Rendering/scene.cpp \ + Rendering/selection.cpp \ + PagesViewer/pageswidget.cpp \ + PagesViewer/listmodel.cpp \ + Preferences/segmentationoptions.cpp \ + Preferences/preprocessingoptions.cpp \ + Preferences/ocroptions.cpp \ + Preferences/generaloptions.cpp \ + Preferences/optionwidget.cpp \ + Preferences/preferencesdialog.cpp \ + Rendering/polygonitem.cpp \ + Processing/progressdialog.cpp \ + Processing/process.cpp \ + Processing/preprocess.cpp HEADERS += mainwindow.h \ - scene.h \ - selection.h \ - pageswidget.h \ - listmodel.h \ - icon.h -FORMS += mainwindow.ui + configs.h \ + region.h \ + Rendering/scene.h \ + Rendering/selection.h \ + PagesViewer/pageswidget.h \ + PagesViewer/listmodel.h \ + Preferences/segmentationoptions.h \ + Preferences/preprocessingoptions.h \ + Preferences/ocroptions.h \ + Preferences/generaloptions.h \ + Preferences/optionwidget.h \ + Preferences/preferencesdialog.h \ + Rendering/polygonitem.h \ + Processing/preprocess.h \ + Processing/progressdialog.h \ + Processing/process.h \ + dir.h +FORMS += mainwindow.ui \ + Preferences/preferencesdialog.ui \ + Preferences/ocroptions.ui \ + Preferences/segmentationoptions.ui \ + Preferences/generaloptions.ui \ + Preferences/preprocessingoptions.ui diff --git a/GScribo/GScribo.pro.user b/GScribo/GScribo.pro.user index 13a97a6..e3df61a 100644 --- a/GScribo/GScribo.pro.user +++ b/GScribo/GScribo.pro.user @@ -56,55 +56,46 @@ <variable>buildConfiguration-Debug</variable> <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> - <value key="QtVersionId" type="int">0</value> + <value key="QtVersionId" type="int">2</value> <value key="ToolChain" type="int">0</value> - <value key="addQDumper" type=""></value> <value key="buildConfiguration" type="int">2</value> </valuemap> </data> <data> - <variable>buildConfiguration-Release</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - <value key="QtVersionId" type="int">0</value> - <value key="addQDumper" type=""></value> - <value key="buildConfiguration" type="int">0</value> - </valuemap> - </data> - <data> <variable>buildconfiguration-Debug-buildstep0</variable> <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0VAN4sEd5T,guid=75a5318e040070f8fcb70ccf006944fa</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Rm9H5yDUD5,guid=00a0d6b325751c50c00c26e2006a9203</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nVYZaO</value> - <value type="QString">GNOME_KEYRING_PID=27939</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kTB4J7</value> + <value type="QString">GNOME_KEYRING_PID=27564</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> + <value type="QString">LANGUAGE=</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt/GScribo/Preferences</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=28014</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-yzfMR27948/agent.27948</value> + <value type="QString">SSH_AGENT_PID=27639</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-qeVjd27573/agent.27573</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmBDX0QW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm9DVURW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358946750.592912-119709926</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359032006.901905-2088645706</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -128,35 +119,36 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0VAN4sEd5T,guid=75a5318e040070f8fcb70ccf006944fa</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Rm9H5yDUD5,guid=00a0d6b325751c50c00c26e2006a9203</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nVYZaO</value> - <value type="QString">GNOME_KEYRING_PID=27939</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kTB4J7</value> + <value type="QString">GNOME_KEYRING_PID=27564</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> + <value type="QString">LANGUAGE=</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt/GScribo/Preferences</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=28014</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-yzfMR27948/agent.27948</value> + <value type="QString">SSH_AGENT_PID=27639</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-qeVjd27573/agent.27573</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmBDX0QW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm9DVURW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358946750.592912-119709926</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359032006.901905-2088645706</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -176,6 +168,50 @@ <variable>buildconfiguration-Debug-cleanstep0</variable> <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> + <valuelist key="abstractProcess.Environment" type="QVariantList"> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Rm9H5yDUD5,guid=00a0d6b325751c50c00c26e2006a9203</value> + <value type="QString">DESKTOP_SESSION=fluxbox</value> + <value type="QString">DISPLAY=:0.0</value> + <value type="QString">GDMSESSION=fluxbox</value> + <value type="QString">GDM_LANG=fr_FR.UTF-8</value> + <value type="QString">GDM_XSERVER_LOCATION=local</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kTB4J7</value> + <value type="QString">GNOME_KEYRING_PID=27564</value> + <value type="QString">GTK_MODULES=canberra-gtk-module</value> + <value type="QString">HOME=/lrde/home/stage/froger_a</value> + <value type="QString">LANG=fr_FR.UTF-8</value> + <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> + <value type="QString">LOGNAME=froger_a</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt/GScribo/Preferences</value> + <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> + <value type="QString">QTDIR=/usr/share/qt4</value> + <value type="QString">SHELL=/bin/bash</value> + <value type="QString">SHLVL=2</value> + <value type="QString">SSH_AGENT_PID=27639</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-qeVjd27573/agent.27573</value> + <value type="QString">TERM=xterm</value> + <value type="QString">USER=froger_a</value> + <value type="QString">USERNAME=froger_a</value> + <value type="QString">WINDOWID=10485796</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm9DVURW</value> + <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359032006.901905-2088645706</value> + <value type="QString">XPSERVERLIST=:64 </value> + <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> + <value type="QString">XTERM_SHELL=/bin/bash</value> + <value type="QString">XTERM_VERSION=XTerm(261)</value> + <value type="QString">_=/usr/bin/qtcreator</value> + </valuelist> + <value key="abstractProcess.IgnoreReturnValue" type="bool">true</value> + <valuelist key="abstractProcess.arguments" type="QVariantList"> + <value type="QString">clean</value> + <value type="QString">-w</value> + </valuelist> + <value key="abstractProcess.command" type="QString">/usr/bin/make</value> + <value key="abstractProcess.enabled" type="bool">true</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo</value> <value key="cleanConfig" type="bool">true</value> <valuelist key="makeargs" type="QVariantList"> <value type="QString">clean</value> @@ -183,28 +219,9 @@ </valuemap> </data> <data> - <variable>buildconfiguration-Release-buildstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Release-buildstep1</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Release-cleanstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - </valuemap> - </data> - <data> <variable>buildconfigurations</variable> <valuelist type="QVariantList"> <value type="QString">Debug</value> - <value type="QString">Release</value> </valuelist> </data> <data> diff --git a/GScribo/listmodel.cpp b/GScribo/PagesViewer/listmodel.cpp similarity index 62% rename from GScribo/listmodel.cpp rename to GScribo/PagesViewer/listmodel.cpp index de0087a..6fd60db 100644 --- a/GScribo/listmodel.cpp +++ b/GScribo/PagesViewer/listmodel.cpp @@ -18,13 +18,25 @@ QVariant ListModel::data(const QModelIndex& index, int role) const if(role == Qt::DecorationRole) return QIcon(pixmaps.value(index.row()).scaled(QSize(200, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + // Store the original pixmap in a custom place. + if(role == Qt::UserRole) + return pixmaps.value(index.row()); + + // Store the path of the pixmap in an other custom place. + if(role == Qt::UserRole+1) + return filenames.value(index.row()); + return QVariant(); } -void ListModel::addPixmap(const QPixmap& pixmap) +void ListModel::addPixmap(const QString& filename, const QPixmap& pixmap) { int row = pixmaps.size(); + beginInsertRows(QModelIndex(), row, row); + pixmaps.insert(row, pixmap); + filenames.insert(row, filename); + endInsertRows(); } diff --git a/GScribo/listmodel.h b/GScribo/PagesViewer/listmodel.h similarity index 80% rename from GScribo/listmodel.h rename to GScribo/PagesViewer/listmodel.h index 03469b5..2f0350e 100644 --- a/GScribo/listmodel.h +++ b/GScribo/PagesViewer/listmodel.h @@ -14,10 +14,11 @@ class ListModel: explicit ListModel(QObject *parent = 0); int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role = Qt::DecorationRole) const; - void addPixmap(const QPixmap& pixmap); + void addPixmap(const QString& filename, const QPixmap& pixmap); private: QList<QPixmap> pixmaps; + QList<QString> filenames; }; #endif // LISTMODEL_H diff --git a/GScribo/PagesViewer/pageswidget.cpp b/GScribo/PagesViewer/pageswidget.cpp new file mode 100644 index 0000000..712f5eb --- /dev/null +++ b/GScribo/PagesViewer/pageswidget.cpp @@ -0,0 +1,30 @@ +#include "pageswidget.h" + +PagesWidget::PagesWidget(QWidget *parent): + QListView(parent) +{ + setUniformItemSizes(true); + setViewMode(QListView::IconMode); + setIconSize(QSize(200, 200)); + setFlow(QListView::TopToBottom); + setMovement(QListView::Static); + setSpacing(10); + setWrapping(false); + setModel(&model); + + connect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(getSelection(QModelIndex))); +} + +void PagesWidget::addPixmap(const QString& filename, const QPixmap &pixmap) +{ + model.addPixmap(filename, pixmap); +} + +void PagesWidget::getSelection(const QModelIndex &index) +{ + // Get the pixmap and the path of the icon to send it to the scene and draw it. + QPixmap pixmap = index.data(Qt::UserRole).value<QPixmap>(); + QString filename = index.data(Qt::UserRole+1).toString(); + + emit selectionClicked(filename, pixmap); +} diff --git a/GScribo/pageswidget.h b/GScribo/PagesViewer/pageswidget.h similarity index 67% rename from GScribo/pageswidget.h rename to GScribo/PagesViewer/pageswidget.h index fade0d6..ae17a4a 100644 --- a/GScribo/pageswidget.h +++ b/GScribo/PagesViewer/pageswidget.h @@ -1,11 +1,11 @@ #ifndef PAGESWIDGET_H #define PAGESWIDGET_H -#include <QWidget> -#include <QListView> -#include <QPainter> #include <QPushButton> #include <QScrollBar> +#include <QListView> +#include <QPainter> +#include <QWidget> #include "listmodel.h" @@ -20,6 +20,13 @@ class PagesWidget: private: ListModel model; + + public slots: + void getSelection(const QModelIndex &index); + + signals: + void clicked(const QModelIndex &index); + void selectionClicked(const QString& filename, const QPixmap& pixmap); }; #endif // PAGESWIDGET_H diff --git a/GScribo/Preferences/generaloptions.ui b/GScribo/Preferences/generaloptions.ui new file mode 100644 index 0000000..5839c27 --- /dev/null +++ b/GScribo/Preferences/generaloptions.ui @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>GeneralOptions</class> + <widget class="QWidget" name="GeneralOptions"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QGroupBox" name="saveXml"> + <property name="title"> + <string>Save segmentation results</string> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QRadioButton" name="sameDir"> + <property name="text"> + <string>In the same directory as the input image</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QRadioButton" name="customDir"> + <property name="text"> + <string>In the following directory</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Maximum</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QLineEdit" name="customDirValue"/> + </item> + <item> + <widget class="QPushButton" name="customDirBrowseBtn"> + <property name="text"> + <string>Browse</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/GScribo/Preferences/ocroptions.ui b/GScribo/Preferences/ocroptions.ui new file mode 100644 index 0000000..d001c64 --- /dev/null +++ b/GScribo/Preferences/ocroptions.ui @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>OcrOptions</class> + <widget class="QWidget" name="OcrOptions"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>366</width> + <height>112</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="enable_ocr"> + <property name="title"> + <string>Enable OCR</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + <property name="flat"> + <bool>true</bool> + </property> + <property name="checkable"> + <bool>true</bool> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="1" column="1"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Language</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="ocr_language"/> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/GScribo/Preferences/optionwidget.cpp b/GScribo/Preferences/optionwidget.cpp new file mode 100644 index 0000000..75ee55d --- /dev/null +++ b/GScribo/Preferences/optionwidget.cpp @@ -0,0 +1,14 @@ +#include "optionwidget.h" + +OptionWidget::OptionWidget(QWidget * parent) : + QWidget(parent) +{ +} + +void OptionWidget::saveConfig() +{ +} + +void OptionWidget::loadConfig() +{ +} diff --git a/GScribo/Preferences/optionwidget.h b/GScribo/Preferences/optionwidget.h new file mode 100644 index 0000000..ecdb650 --- /dev/null +++ b/GScribo/Preferences/optionwidget.h @@ -0,0 +1,15 @@ +#ifndef OPTIONWIDGET_H +#define OPTIONWIDGET_H + +#include <QWidget> + +struct OptionWidget : + public QWidget +{ + explicit OptionWidget(QWidget * parent); + + virtual void loadConfig(); + virtual void saveConfig(); +}; + +#endif // OPTIONWIDGET_H diff --git a/GScribo/Preferences/preferencesdialog.ui b/GScribo/Preferences/preferencesdialog.ui new file mode 100644 index 0000000..1d40563 --- /dev/null +++ b/GScribo/Preferences/preferencesdialog.ui @@ -0,0 +1,121 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreferencesDialog</class> + <widget class="QDialog" name="PreferencesDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>668</width> + <height>418</height> + </rect> + </property> + <property name="windowTitle"> + <string>Preferences</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'DejaVu Sans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">Preferences</span></p></body></html></string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QListWidget" name="optionList"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>200</width> + <height>16777215</height> + </size> + </property> + <property name="baseSize"> + <size> + <width>100</width> + <height>0</height> + </size> + </property> + </widget> + </item> + <item> + <widget class="QWidget" name="widget" native="true"/> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>PreferencesDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>PreferencesDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/GScribo/Preferences/preprocessingoptions.ui b/GScribo/Preferences/preprocessingoptions.ui new file mode 100644 index 0000000..962cf49 --- /dev/null +++ b/GScribo/Preferences/preprocessingoptions.ui @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PreprocessingOptions</class> + <widget class="QWidget" name="PreprocessingOptions"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>466</width> + <height>198</height> + </rect> + </property> + <property name="windowTitle"> + <string>Configure toolchain</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Binarization method:</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="bin_algoCbox"/> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QCheckBox" name="subsampleCb"> + <property name="text"> + <string>Run on subsampled image</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="remove_bgCb"> + <property name="text"> + <string>Remove background (slow)</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QCheckBox" name="deskewCb"> + <property name="text"> + <string>Deskew</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QCheckBox" name="remove_noiseCb"> + <property name="text"> + <string>Remove noise</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>48</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/GScribo/Preferences/segmentationoptions.ui b/GScribo/Preferences/segmentationoptions.ui new file mode 100644 index 0000000..485e448 --- /dev/null +++ b/GScribo/Preferences/segmentationoptions.ui @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>SegmentationOptions</class> + <widget class="QWidget" name="SegmentationOptions"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Find separators</string> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="find_sepsCbox"> + <property name="editable"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>258</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/GScribo/preprocess.cpp b/GScribo/Processing/preprocess.cpp similarity index 100% rename from GScribo/preprocess.cpp rename to GScribo/Processing/preprocess.cpp diff --git a/GScribo/preprocess.h b/GScribo/Processing/preprocess.h similarity index 100% rename from GScribo/preprocess.h rename to GScribo/Processing/preprocess.h index 0ca01d3..d65357f 100644 --- a/GScribo/preprocess.h +++ b/GScribo/Processing/preprocess.h @@ -1,10 +1,10 @@ #ifndef PREPROCESS_H #define PREPROCESS_H -#include <QObject> +#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh> #include <mln/core/image/image2d.hh> #include <mln/value/rgb8.hh> -#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh> +#include <QObject> using namespace scribo::toolchain::internal; diff --git a/GScribo/process.cpp b/GScribo/Processing/process.cpp similarity index 100% rename from GScribo/process.cpp rename to GScribo/Processing/process.cpp diff --git a/GScribo/process.h b/GScribo/Processing/process.h similarity index 100% rename from GScribo/process.h rename to GScribo/Processing/process.h index 2759d00..579a988 100644 --- a/GScribo/process.h +++ b/GScribo/Processing/process.h @@ -1,9 +1,9 @@ #ifndef PROCESS_H #define PROCESS_H -#include <QObject> -#include <mln/core/image/image2d.hh> #include <scribo/toolchain/internal/content_in_doc_functor.hh> +#include <mln/core/image/image2d.hh> +#include <QObject> using namespace scribo::toolchain::internal; diff --git a/GScribo/progressdialog.cpp b/GScribo/Processing/progressdialog.cpp similarity index 100% rename from GScribo/progressdialog.cpp rename to GScribo/Processing/progressdialog.cpp diff --git a/GScribo/progressdialog.h b/GScribo/Processing/progressdialog.h similarity index 100% rename from GScribo/progressdialog.h rename to GScribo/Processing/progressdialog.h diff --git a/GScribo/runner.cpp b/GScribo/Processing/runner.cpp similarity index 95% rename from GScribo/runner.cpp rename to GScribo/Processing/runner.cpp index 8dfd8b0..ebde288 100644 --- a/GScribo/runner.cpp +++ b/GScribo/Processing/runner.cpp @@ -12,8 +12,6 @@ static QString get_pathto(const QString& file, const QString localdirsuffix = QS if (f.exists()) return SCRIBO_PREFIX_BINDIR; - //qDebug() << "FATAL ERROR: Can't locate file: " + file; - return ""; } @@ -42,7 +40,6 @@ void Runner::run() export_as(); break; } - //qDebug() << "Done."; } void Runner::stop() @@ -84,7 +81,6 @@ image2d<bool> Runner::preprocess(const image2d<value::rgb8>& ima) // Perform preprocessing. f(ima); - //qDebug() << "Preprocess Done."; return f.output; } @@ -124,8 +120,6 @@ void Runner::process(const image2d<value::rgb8>& original_ima, output_dir = file.absolutePath(); else if (conf->generalSaveXmlCustomDir()) output_dir = conf->generalSaveXmlCustomDirPath(); - //else - //qDebug() << "runner::progress - Invalid xml saving option!"; QDir dir(output_dir); if (!dir.exists() && !dir.mkpath(output_dir)) @@ -138,13 +132,11 @@ void Runner::process(const image2d<value::rgb8>& original_ima, // Perform text detection. f(original_ima, processed_ima); emit xml_saved(filename); - //qDebug() << "Process Done."; } // Export related stuff - void Runner::start_export(const QString& imgfile, const QString& xmlfile, const QString& outfile) { diff --git a/GScribo/runner.h b/GScribo/Processing/runner.h similarity index 99% rename from GScribo/runner.h rename to GScribo/Processing/runner.h index 56a07df..51969e3 100644 --- a/GScribo/runner.h +++ b/GScribo/Processing/runner.h @@ -1,18 +1,19 @@ #ifndef RUNNER_H #define RUNNER_H -#include <QThread> +#include <mln/core/image/image2d.hh> +#include <mln/io/magick/load.hh> +#include <mln/value/rgb8.hh> #include <QStringList> #include <QMessageBox> +#include <QThread> #include <QFile> -#include <mln/core/image/image2d.hh> -#include <mln/value/rgb8.hh> -#include <mln/io/magick/load.hh> -#include "dir.h" -#include "region.h" -#include "process.h" + #include "preprocess.h" +#include "process.h" #include "configs.h" +#include "region.h" +#include "dir.h" using namespace mln; diff --git a/GScribo/Rendering/polygonitem.cpp b/GScribo/Rendering/polygonitem.cpp new file mode 100644 index 0000000..6bdcd3e --- /dev/null +++ b/GScribo/Rendering/polygonitem.cpp @@ -0,0 +1,76 @@ +#include "polygonitem.h" + +PolygonItem::PolygonItem(QGraphicsItem *parent, QGraphicsScene *scene) + : QGraphicsPolygonItem(parent, scene) +{ + init(); +} + +PolygonItem::PolygonItem(const QPolygonF &polygon, QGraphicsItem *parent, QGraphicsScene *scene): + QGraphicsPolygonItem(polygon, parent, scene) +{ + init(); +} + +void PolygonItem::init() +{ + selectedPen.setStyle(Qt::SolidLine); + unselectedPen.setStyle(Qt::SolidLine); + + selectedPen.setWidthF(2); + unselectedPen.setWidth(0); + + selectedPen.setCapStyle(Qt::SquareCap); + unselectedPen.setCapStyle(Qt::SquareCap); + + selectedBrush.setStyle(Qt::SolidPattern); + unselectedBrush.setStyle(Qt::SolidPattern); +} + +void PolygonItem::setColor(const QColor &color) +{ + selectedPen.setColor(QColor::fromRgb(color.red(), color.green(), color.blue(), 200)); + unselectedPen.setColor(color); + + selectedBrush.setColor(color); + unselectedBrush.setColor(QColor::fromRgb(color.red(), color.green(), color.blue(), 30)); + + setPen(selectedPen); + setBrush(selectedBrush); +} + +QColor PolygonItem::color() const +{ + return selectedBrush.color(); +} + +void PolygonItem::repaint(const QRectF& rect, bool clic) +{ + bool sel; + + // For optimization, do first an intersection by bounding rectangle beetween items and selection and then an intersection by shape. + if(clic) + sel = (boundingRect().width() == 0 || boundingRect().height() == 0 || boundingRect().contains(rect.bottomRight())) && shape().contains(rect.bottomRight()); + else + sel = (boundingRect().width() == 0 || boundingRect().height() == 0 || boundingRect().intersects(rect)) && shape().intersects(rect); + + // Change items brush and pen if it's selectionned or not. + if(sel) + { + if(pen() != selectedPen) + { + setPen(selectedPen); + setBrush(selectedBrush); + update(rect); + } + } + else + { + if(pen() != unselectedPen) + { + setPen(unselectedPen); + setBrush(unselectedBrush); + update(rect); + } + } +} diff --git a/GScribo/polygonitem.h b/GScribo/Rendering/polygonitem.h similarity index 80% rename from GScribo/polygonitem.h rename to GScribo/Rendering/polygonitem.h index 50abf61..893bde3 100644 --- a/GScribo/polygonitem.h +++ b/GScribo/Rendering/polygonitem.h @@ -13,17 +13,16 @@ class PolygonItem : public: explicit PolygonItem(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0); explicit PolygonItem(const QPolygonF& path, QGraphicsItem *parent = 0, QGraphicsScene *scene = 0); - ~PolygonItem(); void setColor(const QColor& color); QColor color() const; private: void init(); - QPen *selectedPen; - QPen *unselectedPen; - QBrush *selectedBrush; - QBrush *unselectedBrush; + QPen selectedPen; + QPen unselectedPen; + QBrush selectedBrush; + QBrush unselectedBrush; public slots: void repaint(const QRectF& rect, bool clic); diff --git a/GScribo/Rendering/scene.cpp b/GScribo/Rendering/scene.cpp new file mode 100644 index 0000000..5035b28 --- /dev/null +++ b/GScribo/Rendering/scene.cpp @@ -0,0 +1,101 @@ +#include "scene.h" + +Scene::Scene(QObject *parent): + QGraphicsScene(parent) +{ + init(); +} + +Scene::Scene(const QRectF &sceneRect, QObject *parent): + QGraphicsScene(sceneRect, parent) +{ + init(); +} + +Scene::Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent): + QGraphicsScene(x, y, width, height, parent) +{ + init(); +} + +void Scene::init() +{ + isPressing = false; + clic = false; + + // Disable the scene size adaptation to items rect with a non null rect. + setSceneRect(0, 0, 0, 1); + addItem(&selection); +} + +void Scene::removeItems() +{ + QList<QGraphicsItem *> itemsList = items(); + QGraphicsItem *i; + + // Remove all items on the scene expect the selection. + foreach(i, itemsList) + { + if(i != &selection) + delete i; + } +} + +void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + if(event->button() == Qt::LeftButton && !isPressing) + { + isPressing = true; + clic = true; + + pressPos = event->scenePos(); + selection.show(); + } +} + +void Scene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + if(isPressing) + { + clic = false; + + // Adapt if the selection rectangle has a negative size. + if(pressPos.x() < event->scenePos().x()) + selection.setRect(pressPos.x(), 0, event->scenePos().x()-pressPos.x(), 0); + else + selection.setRect(event->scenePos().x(), 0, pressPos.x()-event->scenePos().x(), 0); + + if(pressPos.y() < event->scenePos().y()) + selection.setRect(selection.rect().x(), pressPos.y(), selection.rect().width(), event->scenePos().y()-pressPos.y()); + else + selection.setRect(selection.rect().x(), event->scenePos().y(), selection.rect().width(), pressPos.y()-event->scenePos().y()); + } +} + +void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) +{ + if(event->button() == Qt::LeftButton) + { + isPressing = false; + + // If no selection, store the click position in the selection rectangle. + if(clic) + selection.setRect(QRectF(QPointF(0, 0), event->scenePos())); + + emit repaintItem(selection.rect(), clic); + + selection.setRect(0, 0, 0, 0); + selection.hide(); + } +} + +void Scene::setBackground(const QString& filename, const QPixmap& pixmap) +{ + if(backgroundPath != filename) + { + backgroundPath = filename; + + setSceneRect(pixmap.rect()); + setBackgroundBrush(QBrush(pixmap)); + } +} diff --git a/GScribo/scene.h b/GScribo/Rendering/scene.h similarity index 85% rename from GScribo/scene.h rename to GScribo/Rendering/scene.h index 86ca8c7..c4a627a 100644 --- a/GScribo/scene.h +++ b/GScribo/Rendering/scene.h @@ -17,7 +17,6 @@ class Scene : explicit Scene(QObject *parent = 0); explicit Scene(const QRectF &sceneRect, QObject *parent = 0); explicit Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent = 0); - ~Scene(); void removeItems(); protected: @@ -28,11 +27,15 @@ class Scene : private: void init(); - Selection *selection; + QString backgroundPath; + Selection selection; QPointF pressPos; bool isPressing; bool clic; + public slots: + void setBackground(const QString& filename, const QPixmap& pixmap); + signals: void repaintItem(const QRectF& rect, bool clic); }; diff --git a/GScribo/selection.cpp b/GScribo/Rendering/selection.cpp similarity index 94% rename from GScribo/selection.cpp rename to GScribo/Rendering/selection.cpp index 6020312..438e92e 100644 --- a/GScribo/selection.cpp +++ b/GScribo/Rendering/selection.cpp @@ -20,12 +20,15 @@ Selection::Selection(qreal x, qreal y, qreal width, qreal height, QGraphicsScene void Selection::init() { + // Always drawn on top of the scene. setZValue(INT_MAX); + QPen pen; pen.setStyle(Qt::DashLine); pen.setCapStyle(Qt::SquareCap); pen.setCosmetic(true); setPen(pen); + QBrush brush; brush.setStyle(Qt::Dense4Pattern); brush.setColor(QColor::fromRgb(80, 200, 10, 100)); diff --git a/GScribo/selection.h b/GScribo/Rendering/selection.h similarity index 100% rename from GScribo/selection.h rename to GScribo/Rendering/selection.h diff --git a/XmlParser/configs.cpp b/GScribo/configs.cpp similarity index 95% rename from XmlParser/configs.cpp rename to GScribo/configs.cpp index 59df3db..e003442 100644 --- a/XmlParser/configs.cpp +++ b/GScribo/configs.cpp @@ -1,6 +1,4 @@ -#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh> #include "configs.h" -#include "region.h" Configs::Configs() : QSettings("Olena-Scribo", "viewer") @@ -13,6 +11,7 @@ Configs * Configs::getInstance() return conf; } +// Preprocessing configs. bool Configs::preprocessingSubsample() { return value("preprocessing/subsample", false).toBool(); @@ -23,6 +22,8 @@ void Configs::setPreprocessingSubsample(bool b) setValue("preprocessing/subsample", b); } + + bool Configs::preprocessingRemoveBg() { return value("preprocessing/remove_bg", false).toBool(); @@ -33,6 +34,8 @@ void Configs::setPreprocessingRemoveBg(bool b) setValue("preprocessing/remove_bg", b); } + + bool Configs::preprocessingDeskew() { return value("preprocessing/deskew", false).toBool(); @@ -43,6 +46,8 @@ void Configs::setPreprocessingDeskew(bool b) setValue("preprocessing/deskew", b); } + + bool Configs::preprocessingRemoveNoise() { return value("preprocessing/remove_noise", true).toBool(); @@ -53,6 +58,8 @@ void Configs::setPreprocessingRemoveNoise(bool b) setValue("preprocessing/remove_noise", b); } + + int Configs::preprocessingBinAlgo() { return value("preprocessing/bin_algo", scribo::toolchain::internal::SauvolaMs).toInt(); @@ -63,6 +70,11 @@ void Configs::setPreprocessingBinAlgo(int algo) setValue("preprocessing/bin_algo", algo); } + + + + +// Segmentation configs. int Configs::segmentationFindSeps() { return value("segmentation/find_seps", Separator::Both).toInt(); @@ -73,6 +85,11 @@ void Configs::setSegmentationFindSeps(int seps) setValue("segmentation/find_seps", seps); } + + + + +// OCR configs. bool Configs::ocrEnabled() { return value("ocr/enabled", true).toBool(); @@ -83,6 +100,8 @@ void Configs::setOcrEnabled(bool b) setValue("ocr/enabled", b); } + + QString Configs::ocrLanguage() { return value("ocr/language", 0).toString(); @@ -93,6 +112,11 @@ void Configs::setOcrLanguage(const QString &lang) setValue("ocr/language", lang); } + + + + +// OCR configs. bool Configs::generalSaveXmlEnabled() { return value("general/save_xml/enabled", true).toBool(); @@ -103,6 +127,8 @@ void Configs::setGeneralSaveXmlEnabled(bool b) setValue("general/save_xml/enabled", b); } + + bool Configs::generalSaveXmlSameDir() { return value("general/save_xml/same_dir", true).toBool(); @@ -113,6 +139,8 @@ void Configs::setGeneralSaveXmlSameDir(bool b) setValue("general/save_xml/same_dir", b); } + + bool Configs::generalSaveXmlCustomDir() { return value("general/save_xml/custom_dir", false).toBool(); @@ -123,6 +151,8 @@ void Configs::setGeneralSaveXmlCustomDir(bool b) setValue("general/save_xml/custom_dir", b); } + + QString Configs::generalSaveXmlCustomDirPath() { return value("general/save_xml/custom_dir_path", QDir::tempPath()).toString(); diff --git a/GScribo/config.h b/GScribo/configs.h similarity index 93% rename from GScribo/config.h rename to GScribo/configs.h index 6677527..aff4889 100644 --- a/GScribo/config.h +++ b/GScribo/configs.h @@ -1,9 +1,12 @@ #ifndef CONFIGS_H #define CONFIGS_H +#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh> #include <QSettings> #include <QDir> +#include "region.h" + class Configs : public QSettings { diff --git a/GScribo/dir.h b/GScribo/dir.h index cb951f1..a6c036b 100644 --- a/GScribo/dir.h +++ b/GScribo/dir.h @@ -1,7 +1,7 @@ #ifndef DIR_H #define DIR_H -#define SCRIBO_PREFIX_BINDIR "/usr/local/bin" #define SCRIBO_LOCAL_DEMODIR "/lrde/home/stage/froger_a/olena/_build/scribo/demo" +#define SCRIBO_PREFIX_BINDIR "/usr/local/bin" #endif // DIR_H diff --git a/GScribo/icon.cpp b/GScribo/icon.cpp deleted file mode 100644 index 5aca60f..0000000 --- a/GScribo/icon.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "icon.h" - -Icon::Icon(const QPixmap &pixmap) : - QIcon(pixmap) -{ -} - -QString Icon::path() const -{ - return filename; -} - -QPixmap * Icon::pixmap() -{ - return pix; -} - -void Icon::setPath(QString path) -{ - filename = path; -} - -void Icon::setPixmap(QPixmap *pixmap) -{ - pix = pixmap; -} diff --git a/GScribo/icon.h b/GScribo/icon.h deleted file mode 100644 index ebedbe7..0000000 --- a/GScribo/icon.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef ICON_H -#define ICON_H - -#include <QIcon> - -class Icon : - QIcon -{ - public: - explicit Icon(const QPixmap& pixmap); - QString path() const; - QPixmap * pixmap(); - void setPath(QString path); - void setPixmap(QPixmap *pixmap); - - private: - QString filename; - QPixmap *pix; -}; - -#endif // ICON_H diff --git a/GScribo/mainwindow.ui b/GScribo/mainwindow.ui index 3a174ec..0d91002 100644 --- a/GScribo/mainwindow.ui +++ b/GScribo/mainwindow.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>671</width> - <height>436</height> + <width>800</width> + <height>600</height> </rect> </property> <property name="windowTitle"> @@ -23,8 +23,8 @@ <rect> <x>0</x> <y>0</y> - <width>671</width> - <height>23</height> + <width>800</width> + <height>21</height> </rect> </property> </widget> diff --git a/GScribo/pageswidget.cpp b/GScribo/pageswidget.cpp deleted file mode 100644 index 1652062..0000000 --- a/GScribo/pageswidget.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "pageswidget.h" - -PagesWidget::PagesWidget(QWidget *parent): - QListView(parent) -{ - setUniformItemSizes(true); - setViewMode(QListView::IconMode); - setIconSize(QSize(200, 200)); - setFlow(QListView::TopToBottom); - setMovement(QListView::Static); - setSpacing(10); - setWrapping(false); - setModel(&model); -} - -void PagesWidget::addPixmap(const QString& filename, const QPixmap &pixmap) -{ - model.addPixmap(pixmap); -} diff --git a/GScribo/polygonitem.cpp b/GScribo/polygonitem.cpp deleted file mode 100644 index 2c20dbf..0000000 --- a/GScribo/polygonitem.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#include "polygonitem.h" - -PolygonItem::PolygonItem(QGraphicsItem *parent, QGraphicsScene *scene) - : QGraphicsPolygonItem(parent, scene) -{ - init(); -} - -PolygonItem::PolygonItem(const QPolygonF &polygon, QGraphicsItem *parent, QGraphicsScene *scene): - QGraphicsPolygonItem(polygon, parent, scene) -{ - init(); -} - -PolygonItem::~PolygonItem() -{ - delete selectedPen; - delete unselectedPen; - delete selectedBrush; - delete unselectedBrush; -} - -void PolygonItem::init() -{ - selectedPen = new QPen(Qt::SolidLine); - unselectedPen = new QPen(Qt::SolidLine); - selectedPen->setWidthF(2); - unselectedPen->setWidth(0); - selectedPen->setCapStyle(Qt::SquareCap); - unselectedPen->setCapStyle(Qt::SquareCap); - selectedBrush = new QBrush(Qt::SolidPattern); - unselectedBrush = new QBrush(Qt::SolidPattern); -} - -void PolygonItem::setColor(const QColor &color) -{ - selectedPen->setColor(QColor::fromRgb(color.red(), color.green(), color.blue(), 200)); - unselectedPen->setColor(color); - selectedBrush->setColor(color); - unselectedBrush->setColor(QColor::fromRgb(color.red(), color.green(), color.blue(), 30)); - setPen(*selectedPen); - setBrush(*selectedBrush); -} - -QColor PolygonItem::color() const -{ - return selectedBrush->color(); -} - -void PolygonItem::repaint(const QRectF& rect, bool clic) -{ - bool sel; - if(clic) - sel = (boundingRect().width() == 0 || boundingRect().height() == 0 || boundingRect().contains(rect.bottomRight())) && shape().contains(rect.bottomRight()); - else - sel = (boundingRect().width() == 0 || boundingRect().height() == 0 || boundingRect().intersects(rect)) && shape().intersects(rect); - if(sel) - { - if(pen() != *selectedPen) - { - setPen(*selectedPen); - setBrush(*selectedBrush); - update(rect); - } - } - else - { - if(pen() != *unselectedPen) - { - setPen(*unselectedPen); - setBrush(*unselectedBrush); - update(rect); - } - } -} diff --git a/XmlParser/region.h b/GScribo/region.h similarity index 100% copy from XmlParser/region.h copy to GScribo/region.h diff --git a/GScribo/scene.cpp b/GScribo/scene.cpp deleted file mode 100644 index ee2007a..0000000 --- a/GScribo/scene.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "scene.h" - -Scene::Scene(QObject *parent): - QGraphicsScene(parent) -{ - init(); -} - -Scene::Scene(const QRectF &sceneRect, QObject *parent): - QGraphicsScene(sceneRect, parent) -{ - init(); -} - -Scene::Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent): - QGraphicsScene(x, y, width, height, parent) -{ - init(); -} - -Scene::~Scene() -{ - delete selection; -} - -void Scene::init() -{ - isPressing = false; - clic = false; - selection = new Selection(this); -} - -void Scene::removeItems() -{ - QList<QGraphicsItem *> itemsList = items(); - QGraphicsItem *i; - foreach(i, itemsList) - { - if(i != selection) - delete i; - } -} - -void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ - if(event->button() == Qt::LeftButton && !isPressing) - { - isPressing = true; - clic = true; - pressPos = event->scenePos(); - selection->show(); - } -} - -void Scene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -{ - if(isPressing) - { - clic = false; - if(pressPos.x() < event->scenePos().x()) - selection->setRect(pressPos.x(), 0, event->scenePos().x()-pressPos.x(), 0); - else - selection->setRect(event->scenePos().x(), 0, pressPos.x()-event->scenePos().x(), 0); - if(pressPos.y() < event->scenePos().y()) - selection->setRect(selection->rect().x(), pressPos.y(), selection->rect().width(), event->scenePos().y()-pressPos.y()); - else - selection->setRect(selection->rect().x(), event->scenePos().y(), selection->rect().width(), pressPos.y()-event->scenePos().y()); - } -} - -void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -{ - if(event->button() == Qt::LeftButton) - { - isPressing = false; - if(clic) - selection->setRect(QRectF(QPointF(0, 0), event->scenePos())); - emit repaintItem(selection->rect(), clic); - selection->setRect(0, 0, 0, 0); - selection->hide(); - } -} diff --git a/GScribo/ui_mainwindow.h b/GScribo/ui_mainwindow.h deleted file mode 100644 index 7ba54a5..0000000 --- a/GScribo/ui_mainwindow.h +++ /dev/null @@ -1,73 +0,0 @@ -/******************************************************************************** -** Form generated from reading UI file 'mainwindow.ui' -** -** Created: Wed Jan 23 15:39:30 2013 -** by: Qt User Interface Compiler version 4.6.3 -** -** WARNING! All changes made in this file will be lost when recompiling UI file! -********************************************************************************/ - -#ifndef UI_MAINWINDOW_H -#define UI_MAINWINDOW_H - -#include <QtCore/QVariant> -#include <QtGui/QAction> -#include <QtGui/QApplication> -#include <QtGui/QButtonGroup> -#include <QtGui/QHeaderView> -#include <QtGui/QMainWindow> -#include <QtGui/QMenuBar> -#include <QtGui/QStatusBar> -#include <QtGui/QToolBar> -#include <QtGui/QWidget> - -QT_BEGIN_NAMESPACE - -class Ui_MainWindow -{ -public: - QWidget *centralWidget; - QMenuBar *menuBar; - QToolBar *mainToolBar; - QStatusBar *statusBar; - - void setupUi(QMainWindow *MainWindow) - { - if (MainWindow->objectName().isEmpty()) - MainWindow->setObjectName(QString::fromUtf8("MainWindow")); - MainWindow->resize(671, 436); - centralWidget = new QWidget(MainWindow); - centralWidget->setObjectName(QString::fromUtf8("centralWidget")); - centralWidget->setEnabled(true); - MainWindow->setCentralWidget(centralWidget); - menuBar = new QMenuBar(MainWindow); - menuBar->setObjectName(QString::fromUtf8("menuBar")); - menuBar->setGeometry(QRect(0, 0, 671, 23)); - MainWindow->setMenuBar(menuBar); - mainToolBar = new QToolBar(MainWindow); - mainToolBar->setObjectName(QString::fromUtf8("mainToolBar")); - mainToolBar->setFloatable(false); - MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar); - statusBar = new QStatusBar(MainWindow); - statusBar->setObjectName(QString::fromUtf8("statusBar")); - MainWindow->setStatusBar(statusBar); - - retranslateUi(MainWindow); - - QMetaObject::connectSlotsByName(MainWindow); - } // setupUi - - void retranslateUi(QMainWindow *MainWindow) - { - MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8)); - } // retranslateUi - -}; - -namespace Ui { - class MainWindow: public Ui_MainWindow {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_MAINWINDOW_H diff --git a/MVC/MVC.pro b/MVC/MVC.pro deleted file mode 100644 index 1a4d48c..0000000 --- a/MVC/MVC.pro +++ /dev/null @@ -1,13 +0,0 @@ -# ------------------------------------------------- -# Project created by QtCreator 2013-01-22T16:00:23 -# ------------------------------------------------- -TARGET = MVC -TEMPLATE = app -SOURCES += main.cpp \ - mainwindow.cpp \ - itemdelegate.cpp \ - listmodel.cpp -HEADERS += mainwindow.h \ - listmodel.h \ - itemdelegate.h -FORMS += mainwindow.ui diff --git a/MVC/MVC.pro.user b/MVC/MVC.pro.user deleted file mode 100644 index 1c6e9ba..0000000 --- a/MVC/MVC.pro.user +++ /dev/null @@ -1,251 +0,0 @@ -<!DOCTYPE QtCreatorProject> -<qtcreator> - <data> - <variable>RunConfiguration0-BaseEnvironmentBase</variable> - <value type="int">2</value> - </data> - <data> - <variable>RunConfiguration0-CommandLineArguments</variable> - <valuelist type="QVariantList"/> - </data> - <data> - <variable>RunConfiguration0-ProFile</variable> - <value type="QString">MVC.pro</value> - </data> - <data> - <variable>RunConfiguration0-RunConfiguration.name</variable> - <value type="QString">MVC</value> - </data> - <data> - <variable>RunConfiguration0-UseDyldImageSuffix</variable> - <value type="bool">false</value> - </data> - <data> - <variable>RunConfiguration0-UseTerminal</variable> - <value type="bool">false</value> - </data> - <data> - <variable>RunConfiguration0-UserEnvironmentChanges</variable> - <valuelist type="QVariantList"/> - </data> - <data> - <variable>RunConfiguration0-UserSetName</variable> - <value type="bool">false</value> - </data> - <data> - <variable>RunConfiguration0-UserSetWorkingDirectory</variable> - <value type="bool">false</value> - </data> - <data> - <variable>RunConfiguration0-UserWorkingDirectory</variable> - <value type="QString"></value> - </data> - <data> - <variable>RunConfiguration0-type</variable> - <value type="QString">Qt4ProjectManager.Qt4RunConfiguration</value> - </data> - <data> - <variable>activeRunConfiguration</variable> - <value type="int">0</value> - </data> - <data> - <variable>activebuildconfiguration</variable> - <value type="QString">Debug</value> - </data> - <data> - <variable>buildConfiguration-Debug</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> - <value key="QtVersionId" type="int">0</value> - <value key="ToolChain" type="int">0</value> - <value key="addQDumper" type=""></value> - <value key="buildConfiguration" type="int">2</value> - </valuemap> - </data> - <data> - <variable>buildConfiguration-Release</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - <value key="QtVersionId" type="int">0</value> - <value key="addQDumper" type=""></value> - <value key="buildConfiguration" type="int">0</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Debug-buildstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> - <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-iL4mXwl7ak,guid=7e9603aab929b1f1fce663d30068f708</value> - <value type="QString">DESKTOP_SESSION=fluxbox</value> - <value type="QString">DISPLAY=:0.0</value> - <value type="QString">GDMSESSION=fluxbox</value> - <value type="QString">GDM_LANG=fr_FR.UTF-8</value> - <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kN7FtK</value> - <value type="QString">GNOME_KEYRING_PID=25582</value> - <value type="QString">GTK_MODULES=canberra-gtk-module</value> - <value type="QString">HOME=/lrde/home/stage/froger_a</value> - <value type="QString">LANG=fr_FR.UTF-8</value> - <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> - <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> - <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/MVC</value> - <value type="QString">QTDIR=/usr/share/qt4</value> - <value type="QString">SHELL=/bin/bash</value> - <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=25657</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-RiFAp25591/agent.25591</value> - <value type="QString">TERM=xterm</value> - <value type="QString">USER=froger_a</value> - <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmJKU1QW</value> - <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358926796.562496-56304996</value> - <value type="QString">XPSERVERLIST=:64 </value> - <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> - <value type="QString">XTERM_SHELL=/bin/bash</value> - <value type="QString">XTERM_VERSION=XTerm(261)</value> - <value type="QString">_=/usr/bin/qtcreator</value> - </valuelist> - <valuelist key="abstractProcess.arguments" type="QVariantList"> - <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/MVC/MVC.pro</value> - <value type="QString">-spec</value> - <value type="QString">linux-g++</value> - <value type="QString">-r</value> - <value type="QString">CONFIG+=debug</value> - </valuelist> - <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value> - <value key="abstractProcess.enabled" type="bool">false</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/MVC</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Debug-buildstep1</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> - <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-iL4mXwl7ak,guid=7e9603aab929b1f1fce663d30068f708</value> - <value type="QString">DESKTOP_SESSION=fluxbox</value> - <value type="QString">DISPLAY=:0.0</value> - <value type="QString">GDMSESSION=fluxbox</value> - <value type="QString">GDM_LANG=fr_FR.UTF-8</value> - <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kN7FtK</value> - <value type="QString">GNOME_KEYRING_PID=25582</value> - <value type="QString">GTK_MODULES=canberra-gtk-module</value> - <value type="QString">HOME=/lrde/home/stage/froger_a</value> - <value type="QString">LANG=fr_FR.UTF-8</value> - <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> - <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> - <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/MVC</value> - <value type="QString">QTDIR=/usr/share/qt4</value> - <value type="QString">SHELL=/bin/bash</value> - <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=25657</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-RiFAp25591/agent.25591</value> - <value type="QString">TERM=xterm</value> - <value type="QString">USER=froger_a</value> - <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmJKU1QW</value> - <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358926796.562496-56304996</value> - <value type="QString">XPSERVERLIST=:64 </value> - <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> - <value type="QString">XTERM_SHELL=/bin/bash</value> - <value type="QString">XTERM_VERSION=XTerm(261)</value> - <value type="QString">_=/usr/bin/qtcreator</value> - </valuelist> - <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value> - <valuelist key="abstractProcess.arguments" type="QVariantList"> - <value type="QString">-w</value> - </valuelist> - <value key="abstractProcess.command" type="QString">/usr/bin/make</value> - <value key="abstractProcess.enabled" type="bool">true</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/MVC</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Debug-cleanstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> - <value key="cleanConfig" type="bool">true</value> - <valuelist key="makeargs" type="QVariantList"> - <value type="QString">clean</value> - </valuelist> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Release-buildstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Release-buildstep1</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Release-cleanstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - </valuemap> - </data> - <data> - <variable>buildconfigurations</variable> - <valuelist type="QVariantList"> - <value type="QString">Debug</value> - <value type="QString">Release</value> - </valuelist> - </data> - <data> - <variable>buildstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value> - <value key="mkspec" type="QString"></value> - </valuemap> - </data> - <data> - <variable>buildstep1</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value> - </valuemap> - </data> - <data> - <variable>buildsteps</variable> - <valuelist type="QVariantList"> - <value type="QString">trolltech.qt4projectmanager.qmake</value> - <value type="QString">trolltech.qt4projectmanager.make</value> - </valuelist> - </data> - <data> - <variable>cleanstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value> - <value key="clean" type="bool">true</value> - </valuemap> - </data> - <data> - <variable>cleansteps</variable> - <valuelist type="QVariantList"> - <value type="QString">trolltech.qt4projectmanager.make</value> - </valuelist> - </data> - <data> - <variable>defaultFileEncoding</variable> - <value type="QByteArray">System</value> - </data> - <data> - <variable>project</variable> - <valuemap type="QVariantMap"/> - </data> -</qtcreator> diff --git a/MVC/itemdelegate.cpp b/MVC/itemdelegate.cpp deleted file mode 100644 index 5f67a91..0000000 --- a/MVC/itemdelegate.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "itemdelegate.h" - -ItemDelegate::ItemDelegate(QWidget *parent): - QAbstractItemDelegate(parent) -{ -} - -void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - QString path = index.data(Qt::DecorationRole).toString(); - QPixmap pixmap(path); - - painter->drawPixmap(0, index.row() * 210, 200, 200, pixmap); -} - -QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const -{ - return QSize(200, 400); -} diff --git a/MVC/itemdelegate.h b/MVC/itemdelegate.h deleted file mode 100644 index 1c653d5..0000000 --- a/MVC/itemdelegate.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ITEMDELEGATE_H -#define ITEMDELEGATE_H - -#include <QItemDelegate> -#include <QLabel> -#include <QPainter> - -class ItemDelegate: - public QAbstractItemDelegate -{ - public: - explicit ItemDelegate(QWidget *parent = 0); - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; -}; - -#endif // ITEMDELEGATE_H diff --git a/MVC/listmodel.cpp b/MVC/listmodel.cpp deleted file mode 100644 index 709853e..0000000 --- a/MVC/listmodel.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "listmodel.h" - -ListModel::ListModel(QStringList list, QObject *parent): - QAbstractListModel(parent) -{ - this->list = list; -} - -ListModel::~ListModel() -{ -} - -int ListModel::rowCount(const QModelIndex &/*parent*/) const -{ - return list.count(); -} - -QVariant ListModel::data(const QModelIndex &index, int role) const -{ - if(index.isValid() && index.row() < list.size() && role == Qt::DecorationRole) - return list.at(index.row()); - else - return QVariant(); -} - -QVariant ListModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if(role != Qt::DecorationRole && orientation == Qt::Horizontal) - return QVariant(); - else - return QString("Row %1").arg(section); -} diff --git a/MVC/listmodel.h b/MVC/listmodel.h deleted file mode 100644 index 35ae99c..0000000 --- a/MVC/listmodel.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef LISTMODEL_H -#define LISTMODEL_H - -#include <QAbstractListModel> -#include <QLabel> -#include <QList> - -class ListModel: - public QAbstractListModel -{ - Q_OBJECT - - public: - explicit ListModel(QStringList list, QObject *parent = 0); - ~ListModel(); - int rowCount(const QModelIndex &parent = QModelIndex()) const; - QVariant data(const QModelIndex &index, int role = Qt::DecorationRole) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DecorationRole) const; - - private: - QStringList list; -}; - -#endif // LISTMODEL_H diff --git a/MVC/main.cpp b/MVC/main.cpp deleted file mode 100644 index ab61e7c..0000000 --- a/MVC/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include <QtGui/QApplication> -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication::setGraphicsSystem("raster"); - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/MVC/mainwindow.cpp b/MVC/mainwindow.cpp deleted file mode 100644 index 72bf823..0000000 --- a/MVC/mainwindow.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - QStringList list; - list << "/lrde/home/stage/froger_a/ppm/mp00032c.ppm" << "/lrde/home/stage/froger_a/ppm/mp00042.ppm" << "/lrde/home/stage/froger_a/ppm/mp00076.ppm"; - - QAbstractItemModel *model = new ListModel(list); - - ItemDelegate *delegate = new ItemDelegate(); - - QListView *view = new QListView; - view->setModel(model); - view->setItemDelegate(delegate); - setCentralWidget(view); - view->show(); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::changeEvent(QEvent *e) -{ - QMainWindow::changeEvent(e); - switch (e->type()) - { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} diff --git a/MVC/mainwindow.h b/MVC/mainwindow.h deleted file mode 100644 index 8bf225d..0000000 --- a/MVC/mainwindow.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include <QMainWindow> -#include <QListView> - -#include "itemdelegate.h" -#include "listmodel.h" - -namespace Ui -{ - class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - - public: - MainWindow(QWidget *parent = 0); - ~MainWindow(); - - protected: - void changeEvent(QEvent *e); - - private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/MVC/mainwindow.ui b/MVC/mainwindow.ui deleted file mode 100644 index 97c03be..0000000 --- a/MVC/mainwindow.ui +++ /dev/null @@ -1,24 +0,0 @@ -<ui version="4.0"> - <class>MainWindow</class> - <widget class="QMainWindow" name="MainWindow" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>600</width> - <height>400</height> - </rect> - </property> - <property name="windowTitle" > - <string>MainWindow</string> - </property> - <widget class="QMenuBar" name="menuBar" /> - <widget class="QToolBar" name="mainToolBar" /> - <widget class="QWidget" name="centralWidget" /> - <widget class="QStatusBar" name="statusBar" /> - </widget> - <layoutDefault spacing="6" margin="11" /> - <pixmapfunction></pixmapfunction> - <resources/> - <connections/> -</ui> diff --git a/MVC/ui_mainwindow.h b/MVC/ui_mainwindow.h deleted file mode 100644 index 48f2cce..0000000 --- a/MVC/ui_mainwindow.h +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************** -** Form generated from reading UI file 'mainwindow.ui' -** -** Created: Wed Jan 23 08:52:24 2013 -** by: Qt User Interface Compiler version 4.6.3 -** -** WARNING! All changes made in this file will be lost when recompiling UI file! -********************************************************************************/ - -#ifndef UI_MAINWINDOW_H -#define UI_MAINWINDOW_H - -#include <QtCore/QVariant> -#include <QtGui/QAction> -#include <QtGui/QApplication> -#include <QtGui/QButtonGroup> -#include <QtGui/QHeaderView> -#include <QtGui/QMainWindow> -#include <QtGui/QMenuBar> -#include <QtGui/QStatusBar> -#include <QtGui/QToolBar> -#include <QtGui/QWidget> - -QT_BEGIN_NAMESPACE - -class Ui_MainWindow -{ -public: - QMenuBar *menuBar; - QToolBar *mainToolBar; - QWidget *centralWidget; - QStatusBar *statusBar; - - void setupUi(QMainWindow *MainWindow) - { - if (MainWindow->objectName().isEmpty()) - MainWindow->setObjectName(QString::fromUtf8("MainWindow")); - MainWindow->resize(600, 400); - menuBar = new QMenuBar(MainWindow); - menuBar->setObjectName(QString::fromUtf8("menuBar")); - MainWindow->setMenuBar(menuBar); - mainToolBar = new QToolBar(MainWindow); - mainToolBar->setObjectName(QString::fromUtf8("mainToolBar")); - MainWindow->addToolBar(mainToolBar); - centralWidget = new QWidget(MainWindow); - centralWidget->setObjectName(QString::fromUtf8("centralWidget")); - MainWindow->setCentralWidget(centralWidget); - statusBar = new QStatusBar(MainWindow); - statusBar->setObjectName(QString::fromUtf8("statusBar")); - MainWindow->setStatusBar(statusBar); - - retranslateUi(MainWindow); - - QMetaObject::connectSlotsByName(MainWindow); - } // setupUi - - void retranslateUi(QMainWindow *MainWindow) - { - MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8)); - } // retranslateUi - -}; - -namespace Ui { - class MainWindow: public Ui_MainWindow {}; -} // namespace Ui - -QT_END_NAMESPACE - -#endif // UI_MAINWINDOW_H diff --git a/XmlParser/XmlParser.pro.user b/XmlParser/XmlParser.pro.user index 4041e71..d21de52 100644 --- a/XmlParser/XmlParser.pro.user +++ b/XmlParser/XmlParser.pro.user @@ -188,17 +188,18 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-dwXmVzGpRA,guid=2e4bb3ce70c39fa5e5288771006655e3</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Rm9H5yDUD5,guid=00a0d6b325751c50c00c26e2006a9203</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-9aAGCJ</value> - <value type="QString">GNOME_KEYRING_PID=19876</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kTB4J7</value> + <value type="QString">GNOME_KEYRING_PID=27564</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> + <value type="QString">LANGUAGE=</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> @@ -207,16 +208,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=19951</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-kVrax19885/agent.19885</value> + <value type="QString">SSH_AGENT_PID=27639</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-qeVjd27573/agent.27573</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm0ICXQW</value> + <value type="QString">WINDOWID=12582948</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm9DVURW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358754471.558659-246518931</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359032006.901905-2088645706</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -239,17 +240,18 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-dwXmVzGpRA,guid=2e4bb3ce70c39fa5e5288771006655e3</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Rm9H5yDUD5,guid=00a0d6b325751c50c00c26e2006a9203</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-9aAGCJ</value> - <value type="QString">GNOME_KEYRING_PID=19876</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kTB4J7</value> + <value type="QString">GNOME_KEYRING_PID=27564</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> + <value type="QString">LANGUAGE=</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> @@ -258,16 +260,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=19951</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-kVrax19885/agent.19885</value> + <value type="QString">SSH_AGENT_PID=27639</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-qeVjd27573/agent.27573</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm0ICXQW</value> + <value type="QString">WINDOWID=12582948</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm9DVURW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358754471.558659-246518931</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1359032006.901905-2088645706</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> diff --git a/gmvc/gmodel.cpp b/gmvc/gmodel.cpp deleted file mode 100644 index 38a2aa3..0000000 --- a/gmvc/gmodel.cpp +++ /dev/null @@ -1,162 +0,0 @@ -#include "gmodel.h" - -gModel::gModel(QObject *parent) : - QAbstractListModel(parent) -{ -} - -QVariant gModel::data(const QModelIndex &index, int role) const - { - if (!index.isValid()) - return QVariant(); - - if (role == Qt::DecorationRole) - return QIcon(pixmaps.value(index.row()).scaled(60, 60, - Qt::KeepAspectRatio, Qt::SmoothTransformation)); - /*else if (role == Qt::UserRole) - return pixmaps.value(index.row()); - else if (role == Qt::UserRole + 1) - return locations.value(index.row());*/ - - return QVariant(); - } - - void gModel::addPiece(const QPixmap &pixmap, const QPoint &location) - { - /*int row; - if (int(2.0*qrand()/(RAND_MAX+1.0)) == 1) - row = 0; - else - row = pixmaps.size();*/ - int row = pixmaps.size(); - - beginInsertRows(QModelIndex(), row, row); - pixmaps.insert(row, pixmap); - //locations.insert(row, location); - endInsertRows(); - } - - /*Qt::ItemFlags gModel::flags(const QModelIndex &index) const - { - if (index.isValid()) - return (Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled); - - return Qt::ItemIsDropEnabled; - }*/ - - /*bool gModel::removeRows(int row, int count, const QModelIndex &parent) - { - if (parent.isValid()) - return false; - - if (row >= pixmaps.size() || row + count <= 0) - return false; - - int beginRow = qMax(0, row); - int endRow = qMin(row + count - 1, pixmaps.size() - 1); - - beginRemoveRows(parent, beginRow, endRow); - - while (beginRow <= endRow) { - pixmaps.removeAt(beginRow); - locations.removeAt(beginRow); - ++beginRow; - } - - endRemoveRows(); - return true; - }*/ - - /*QStringList gModel::mimeTypes() const - { - QStringList types; - types << "image/x-puzzle-piece"; - return types; - }*/ - - /*QMimeData *gModel::mimeData(const QModelIndexList &indexes) const - { - QMimeData *mimeData = new QMimeData(); - QByteArray encodedData; - - QDataStream stream(&encodedData, QIODevice::WriteOnly); - - foreach (QModelIndex index, indexes) { - if (index.isValid()) { - QPixmap pixmap = qVariantValue<QPixmap>(data(index, Qt::UserRole)); - QPoint location = data(index, Qt::UserRole+1).toPoint(); - stream << pixmap << location; - } - } - - mimeData->setData("image/x-puzzle-piece", encodedData); - return mimeData; - }*/ - - /*bool gModel::dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) - { - if (!data->hasFormat("image/x-puzzle-piece")) - return false; - - if (action == Qt::IgnoreAction) - return true; - - if (column > 0) - return false; - - int endRow; - - if (!parent.isValid()) { - if (row < 0) - endRow = pixmaps.size(); - else - endRow = qMin(row, pixmaps.size()); - } else - endRow = parent.row(); - - QByteArray encodedData = data->data("image/x-puzzle-piece"); - QDataStream stream(&encodedData, QIODevice::ReadOnly); - - while (!stream.atEnd()) { - QPixmap pixmap; - QPoint location; - stream >> pixmap >> location; - - beginInsertRows(QModelIndex(), endRow, endRow); - pixmaps.insert(endRow, pixmap); - locations.insert(endRow, location); - endInsertRows(); - - ++endRow; - } - - return true; - }*/ - - int gModel::rowCount(const QModelIndex &parent) const - { - if (parent.isValid()) - return 0; - else - return pixmaps.size(); - } - - /*Qt::DropActions gModel::supportedDropActions() const - { - return Qt::CopyAction | Qt::MoveAction; - }*/ - -/* void gModel::addPieces(const QPixmap& pixmap) - { - beginRemoveRows(QModelIndex(), 0, 24); - pixmaps.clear(); - locations.clear(); - endRemoveRows(); - for (int y = 0; y < 5; ++y) { - for (int x = 0; x < 5; ++x) { - QPixmap pieceImage = pixmap.copy(x*80, y*80, 80, 80); - addPiece(pieceImage, QPoint(x, y)); - } - } - }*/ diff --git a/gmvc/gmodel.h b/gmvc/gmodel.h deleted file mode 100644 index 3e5a787..0000000 --- a/gmvc/gmodel.h +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef GMODEL_H -#define GMODEL_H - -#include <QAbstractListModel> -#include <QPixmap> -#include <QIcon> -#include <QMimeData> - -class gModel : - public QAbstractListModel -{ - public: - gModel(QObject *parent = 0); - - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - //Qt::ItemFlags flags(const QModelIndex &index) const; - //bool removeRows(int row, int count, const QModelIndex &parent); - - //bool dropMimeData(const QMimeData *data, Qt::DropAction action, - // int row, int column, const QModelIndex &parent); - //QMimeData *mimeData(const QModelIndexList &indexes) const; - //QStringList mimeTypes() const; - int rowCount(const QModelIndex &parent) const; - //Qt::DropActions supportedDropActions() const; - - void addPiece(const QPixmap &pixmap, const QPoint &location); - //void addPieces(const QPixmap& pixmap); - - private: - QList<QPoint> locations; - QList<QPixmap> pixmaps; -}; - -#endif // GMODEL_H diff --git a/gmvc/gmvc.pro b/gmvc/gmvc.pro deleted file mode 100644 index 81e49e5..0000000 --- a/gmvc/gmvc.pro +++ /dev/null @@ -1,13 +0,0 @@ -# ------------------------------------------------- -# Project created by QtCreator 2013-01-23T09:31:00 -# ------------------------------------------------- -TARGET = gmvc -TEMPLATE = app -SOURCES += main.cpp \ - mainwindow.cpp \ - model.cpp \ - gmodel.cpp -HEADERS += mainwindow.h \ - model.h \ - gmodel.h -FORMS += mainwindow.ui diff --git a/gmvc/gmvc.pro.user b/gmvc/gmvc.pro.user deleted file mode 100644 index 4a75b91..0000000 --- a/gmvc/gmvc.pro.user +++ /dev/null @@ -1,251 +0,0 @@ -<!DOCTYPE QtCreatorProject> -<qtcreator> - <data> - <variable>RunConfiguration0-BaseEnvironmentBase</variable> - <value type="int">2</value> - </data> - <data> - <variable>RunConfiguration0-CommandLineArguments</variable> - <valuelist type="QVariantList"/> - </data> - <data> - <variable>RunConfiguration0-ProFile</variable> - <value type="QString">gmvc.pro</value> - </data> - <data> - <variable>RunConfiguration0-RunConfiguration.name</variable> - <value type="QString">gmvc</value> - </data> - <data> - <variable>RunConfiguration0-UseDyldImageSuffix</variable> - <value type="bool">false</value> - </data> - <data> - <variable>RunConfiguration0-UseTerminal</variable> - <value type="bool">false</value> - </data> - <data> - <variable>RunConfiguration0-UserEnvironmentChanges</variable> - <valuelist type="QVariantList"/> - </data> - <data> - <variable>RunConfiguration0-UserSetName</variable> - <value type="bool">false</value> - </data> - <data> - <variable>RunConfiguration0-UserSetWorkingDirectory</variable> - <value type="bool">false</value> - </data> - <data> - <variable>RunConfiguration0-UserWorkingDirectory</variable> - <value type="QString"></value> - </data> - <data> - <variable>RunConfiguration0-type</variable> - <value type="QString">Qt4ProjectManager.Qt4RunConfiguration</value> - </data> - <data> - <variable>activeRunConfiguration</variable> - <value type="int">0</value> - </data> - <data> - <variable>activebuildconfiguration</variable> - <value type="QString">Debug</value> - </data> - <data> - <variable>buildConfiguration-Debug</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> - <value key="QtVersionId" type="int">0</value> - <value key="ToolChain" type="int">0</value> - <value key="addQDumper" type=""></value> - <value key="buildConfiguration" type="int">2</value> - </valuemap> - </data> - <data> - <variable>buildConfiguration-Release</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - <value key="QtVersionId" type="int">0</value> - <value key="addQDumper" type=""></value> - <value key="buildConfiguration" type="int">0</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Debug-buildstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> - <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0VAN4sEd5T,guid=75a5318e040070f8fcb70ccf006944fa</value> - <value type="QString">DESKTOP_SESSION=fluxbox</value> - <value type="QString">DISPLAY=:0.0</value> - <value type="QString">GDMSESSION=fluxbox</value> - <value type="QString">GDM_LANG=fr_FR.UTF-8</value> - <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nVYZaO</value> - <value type="QString">GNOME_KEYRING_PID=27939</value> - <value type="QString">GTK_MODULES=canberra-gtk-module</value> - <value type="QString">HOME=/lrde/home/stage/froger_a</value> - <value type="QString">LANG=fr_FR.UTF-8</value> - <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> - <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> - <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/gmvc</value> - <value type="QString">QTDIR=/usr/share/qt4</value> - <value type="QString">SHELL=/bin/bash</value> - <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=28014</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-yzfMR27948/agent.27948</value> - <value type="QString">TERM=xterm</value> - <value type="QString">USER=froger_a</value> - <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmBDX0QW</value> - <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358946750.592912-119709926</value> - <value type="QString">XPSERVERLIST=:64 </value> - <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> - <value type="QString">XTERM_SHELL=/bin/bash</value> - <value type="QString">XTERM_VERSION=XTerm(261)</value> - <value type="QString">_=/usr/bin/qtcreator</value> - </valuelist> - <valuelist key="abstractProcess.arguments" type="QVariantList"> - <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/gmvc/gmvc.pro</value> - <value type="QString">-spec</value> - <value type="QString">linux-g++</value> - <value type="QString">-r</value> - <value type="QString">CONFIG+=debug</value> - </valuelist> - <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value> - <value key="abstractProcess.enabled" type="bool">false</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/gmvc</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Debug-buildstep1</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> - <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0VAN4sEd5T,guid=75a5318e040070f8fcb70ccf006944fa</value> - <value type="QString">DESKTOP_SESSION=fluxbox</value> - <value type="QString">DISPLAY=:0.0</value> - <value type="QString">GDMSESSION=fluxbox</value> - <value type="QString">GDM_LANG=fr_FR.UTF-8</value> - <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nVYZaO</value> - <value type="QString">GNOME_KEYRING_PID=27939</value> - <value type="QString">GTK_MODULES=canberra-gtk-module</value> - <value type="QString">HOME=/lrde/home/stage/froger_a</value> - <value type="QString">LANG=fr_FR.UTF-8</value> - <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> - <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> - <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/gmvc</value> - <value type="QString">QTDIR=/usr/share/qt4</value> - <value type="QString">SHELL=/bin/bash</value> - <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=28014</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-yzfMR27948/agent.27948</value> - <value type="QString">TERM=xterm</value> - <value type="QString">USER=froger_a</value> - <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmBDX0QW</value> - <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358946750.592912-119709926</value> - <value type="QString">XPSERVERLIST=:64 </value> - <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> - <value type="QString">XTERM_SHELL=/bin/bash</value> - <value type="QString">XTERM_VERSION=XTerm(261)</value> - <value type="QString">_=/usr/bin/qtcreator</value> - </valuelist> - <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value> - <valuelist key="abstractProcess.arguments" type="QVariantList"> - <value type="QString">-w</value> - </valuelist> - <value key="abstractProcess.command" type="QString">/usr/bin/make</value> - <value key="abstractProcess.enabled" type="bool">true</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/gmvc</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Debug-cleanstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> - <value key="cleanConfig" type="bool">true</value> - <valuelist key="makeargs" type="QVariantList"> - <value type="QString">clean</value> - </valuelist> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Release-buildstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Release-buildstep1</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - </valuemap> - </data> - <data> - <variable>buildconfiguration-Release-cleanstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> - </valuemap> - </data> - <data> - <variable>buildconfigurations</variable> - <valuelist type="QVariantList"> - <value type="QString">Debug</value> - <value type="QString">Release</value> - </valuelist> - </data> - <data> - <variable>buildstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value> - <value key="mkspec" type="QString"></value> - </valuemap> - </data> - <data> - <variable>buildstep1</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value> - </valuemap> - </data> - <data> - <variable>buildsteps</variable> - <valuelist type="QVariantList"> - <value type="QString">trolltech.qt4projectmanager.qmake</value> - <value type="QString">trolltech.qt4projectmanager.make</value> - </valuelist> - </data> - <data> - <variable>cleanstep0</variable> - <valuemap type="QVariantMap"> - <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString"></value> - <value key="clean" type="bool">true</value> - </valuemap> - </data> - <data> - <variable>cleansteps</variable> - <valuelist type="QVariantList"> - <value type="QString">trolltech.qt4projectmanager.make</value> - </valuelist> - </data> - <data> - <variable>defaultFileEncoding</variable> - <value type="QByteArray">System</value> - </data> - <data> - <variable>project</variable> - <valuemap type="QVariantMap"/> - </data> -</qtcreator> diff --git a/gmvc/main.cpp b/gmvc/main.cpp deleted file mode 100644 index ab61e7c..0000000 --- a/gmvc/main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include <QtGui/QApplication> -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication::setGraphicsSystem("raster"); - QApplication a(argc, argv); - MainWindow w; - w.show(); - return a.exec(); -} diff --git a/gmvc/mainwindow.cpp b/gmvc/mainwindow.cpp deleted file mode 100644 index d046226..0000000 --- a/gmvc/mainwindow.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - QListView *view = new QListView(); - view->setViewMode(QListView::IconMode); - view->setIconSize(QSize(100, 100)); - view->setMovement(QListView::Static); - view->setFlow(QListView::TopToBottom); - //view->setGridSize(QSize(300, 100)); - view->setSpacing(9); - - QList<QPixmap> pixmaps; - QStringList paths; - paths << "/lrde/home/stage/froger_a/ppm/mp00032c.ppm" << "/lrde/home/stage/froger_a/ppm/mp00042.ppm" << "/lrde/home/stage/froger_a/ppm/mp00076.ppm"; - QString path; - Model *model = new Model(this); - foreach(path, paths) - { - QPixmap pixmap(path); - model->addPixmap(pixmap); - } - - view->setModel(model); - //setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - - setCentralWidget(view); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::changeEvent(QEvent *e) -{ - QMainWindow::changeEvent(e); - switch (e->type()) - { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} diff --git a/gmvc/mainwindow.h b/gmvc/mainwindow.h deleted file mode 100644 index 822c275..0000000 --- a/gmvc/mainwindow.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include <QMainWindow> -#include <QHBoxLayout> -#include <QListView> - -#include "gmodel.h" -#include "model.h" - -namespace Ui { - class MainWindow; -} - -class MainWindow : public QMainWindow { - Q_OBJECT -public: - MainWindow(QWidget *parent = 0); - ~MainWindow(); - -protected: - void changeEvent(QEvent *e); - -private: - Ui::MainWindow *ui; -}; - -#endif // MAINWINDOW_H diff --git a/gmvc/mainwindow.ui b/gmvc/mainwindow.ui deleted file mode 100644 index 97c03be..0000000 --- a/gmvc/mainwindow.ui +++ /dev/null @@ -1,24 +0,0 @@ -<ui version="4.0"> - <class>MainWindow</class> - <widget class="QMainWindow" name="MainWindow" > - <property name="geometry" > - <rect> - <x>0</x> - <y>0</y> - <width>600</width> - <height>400</height> - </rect> - </property> - <property name="windowTitle" > - <string>MainWindow</string> - </property> - <widget class="QMenuBar" name="menuBar" /> - <widget class="QToolBar" name="mainToolBar" /> - <widget class="QWidget" name="centralWidget" /> - <widget class="QStatusBar" name="statusBar" /> - </widget> - <layoutDefault spacing="6" margin="11" /> - <pixmapfunction></pixmapfunction> - <resources/> - <connections/> -</ui> diff --git a/gmvc/model.cpp b/gmvc/model.cpp deleted file mode 100644 index eb20cf8..0000000 --- a/gmvc/model.cpp +++ /dev/null @@ -1,37 +0,0 @@ -#include "model.h" - -Model::Model(QObject *parent) : - QAbstractListModel(parent) -{ - this->pixmaps = pixmaps; -} - -int Model::rowCount(const QModelIndex& parent) const -{ - if (parent.isValid()) - return 0; - else - return pixmaps.size();; -} - -QVariant Model::data(const QModelIndex& index, int role) const -{ - if(!index.isValid()) - return QVariant(); - - if(role == Qt::DecorationRole) - return QIcon(pixmaps.value(index.row()).scaled(300, 300, Qt::KeepAspectRatio, Qt::SmoothTransformation)); - - if(role == Qt::UserRole) - return pixmaps.value(index.row()); - - return QVariant(); -} - -void Model::addPixmap(const QPixmap& pixmap) -{ - int row = pixmaps.size(); - beginInsertRows(QModelIndex(), row, row); - pixmaps.insert(row, pixmap); - endInsertRows(); -} diff --git a/gmvc/model.h b/gmvc/model.h deleted file mode 100644 index f2247f4..0000000 --- a/gmvc/model.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef MODEL_H -#define MODEL_H - -#include <QAbstractListModel> -#include <QIcon> - -class Model : - public QAbstractListModel -{ - public: - explicit Model(QObject *parent = 0); - QVariant data(const QModelIndex &index, int role) const; - int rowCount(const QModelIndex &parent) const; - void addPixmap(const QPixmap& pixmap); - - private: - QList<QPixmap> pixmaps; -}; - -#endif // MODEL_H -- 1.7.2.5
11Â years, 11Â months
1
0
0
0
e7ece12 Try to implement good model/ view for training.
by Antoine Froger
--- GScribo/GScribo.pro | 8 +- GScribo/GScribo.pro.user | 36 ++++---- GScribo/icon.cpp | 26 +++++ GScribo/icon.h | 21 ++++ GScribo/itemdelegate.cpp | 26 ----- GScribo/itemdelegate.h | 17 ---- GScribo/listmodel.cpp | 50 +++------- GScribo/listmodel.h | 11 +-- GScribo/mainwindow.cpp | 97 ------------------- GScribo/mainwindow.h | 52 ---------- GScribo/pageswidget.cpp | 30 ++---- GScribo/pageswidget.h | 19 ++--- GScribo/ui_mainwindow.h | 73 ++++++++++++++ MVC/MVC.pro.user | 32 +++--- MVC/itemdelegate.cpp | 4 +- MVC/ui_mainwindow.h | 70 ++++++++++++++ gmvc/gmodel.cpp | 162 ++++++++++++++++++++++++++++++++ gmvc/gmodel.h | 34 +++++++ MVC/MVC.pro => gmvc/gmvc.pro | 12 +- MVC/MVC.pro.user => gmvc/gmvc.pro.user | 46 +++++----- {MVC => gmvc}/main.cpp | 0 gmvc/mainwindow.cpp | 51 ++++++++++ gmvc/mainwindow.h | 28 ++++++ {MVC => gmvc}/mainwindow.ui | 0 gmvc/model.cpp | 37 +++++++ gmvc/model.h | 20 ++++ 26 files changed, 627 insertions(+), 335 deletions(-) create mode 100644 GScribo/icon.cpp create mode 100644 GScribo/icon.h delete mode 100644 GScribo/itemdelegate.cpp delete mode 100644 GScribo/itemdelegate.h delete mode 100644 GScribo/mainwindow.cpp delete mode 100644 GScribo/mainwindow.h create mode 100644 GScribo/ui_mainwindow.h create mode 100644 MVC/ui_mainwindow.h create mode 100644 gmvc/gmodel.cpp create mode 100644 gmvc/gmodel.h copy MVC/MVC.pro => gmvc/gmvc.pro (59%) copy MVC/MVC.pro.user => gmvc/gmvc.pro.user (87%) copy {MVC => gmvc}/main.cpp (100%) create mode 100644 gmvc/mainwindow.cpp create mode 100644 gmvc/mainwindow.h copy {MVC => gmvc}/mainwindow.ui (100%) create mode 100644 gmvc/model.cpp create mode 100644 gmvc/model.h diff --git a/GScribo/GScribo.pro b/GScribo/GScribo.pro index 7930307..57041dc 100644 --- a/GScribo/GScribo.pro +++ b/GScribo/GScribo.pro @@ -18,12 +18,12 @@ SOURCES += main.cpp \ scene.cpp \ selection.cpp \ pageswidget.cpp \ - itemdelegate.cpp \ - listmodel.cpp + listmodel.cpp \ + icon.cpp HEADERS += mainwindow.h \ scene.h \ selection.h \ pageswidget.h \ - itemdelegate.h \ - listmodel.h + listmodel.h \ + icon.h FORMS += mainwindow.ui diff --git a/GScribo/GScribo.pro.user b/GScribo/GScribo.pro.user index 92e91c7..13a97a6 100644 --- a/GScribo/GScribo.pro.user +++ b/GScribo/GScribo.pro.user @@ -76,14 +76,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-sncykruQ0C,guid=e454b1a02a95fc6454d7a56d0067ee2b</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0VAN4sEd5T,guid=75a5318e040070f8fcb70ccf006944fa</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-8ccgXN</value> - <value type="QString">GNOME_KEYRING_PID=30769</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nVYZaO</value> + <value type="QString">GNOME_KEYRING_PID=27939</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -95,16 +95,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=30844</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gtQAz30778/agent.30778</value> + <value type="QString">SSH_AGENT_PID=28014</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-yzfMR27948/agent.27948</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=12582948</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm3KFZQW</value> + <value type="QString">WINDOWID=10485796</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmBDX0QW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358858991.561353-1070905078</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358946750.592912-119709926</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -128,14 +128,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-sncykruQ0C,guid=e454b1a02a95fc6454d7a56d0067ee2b</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0VAN4sEd5T,guid=75a5318e040070f8fcb70ccf006944fa</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-8ccgXN</value> - <value type="QString">GNOME_KEYRING_PID=30769</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nVYZaO</value> + <value type="QString">GNOME_KEYRING_PID=27939</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -147,16 +147,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=30844</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gtQAz30778/agent.30778</value> + <value type="QString">SSH_AGENT_PID=28014</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-yzfMR27948/agent.27948</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=12582948</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm3KFZQW</value> + <value type="QString">WINDOWID=10485796</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmBDX0QW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358858991.561353-1070905078</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358946750.592912-119709926</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> diff --git a/GScribo/icon.cpp b/GScribo/icon.cpp new file mode 100644 index 0000000..5aca60f --- /dev/null +++ b/GScribo/icon.cpp @@ -0,0 +1,26 @@ +#include "icon.h" + +Icon::Icon(const QPixmap &pixmap) : + QIcon(pixmap) +{ +} + +QString Icon::path() const +{ + return filename; +} + +QPixmap * Icon::pixmap() +{ + return pix; +} + +void Icon::setPath(QString path) +{ + filename = path; +} + +void Icon::setPixmap(QPixmap *pixmap) +{ + pix = pixmap; +} diff --git a/GScribo/icon.h b/GScribo/icon.h new file mode 100644 index 0000000..ebedbe7 --- /dev/null +++ b/GScribo/icon.h @@ -0,0 +1,21 @@ +#ifndef ICON_H +#define ICON_H + +#include <QIcon> + +class Icon : + QIcon +{ + public: + explicit Icon(const QPixmap& pixmap); + QString path() const; + QPixmap * pixmap(); + void setPath(QString path); + void setPixmap(QPixmap *pixmap); + + private: + QString filename; + QPixmap *pix; +}; + +#endif // ICON_H diff --git a/GScribo/itemdelegate.cpp b/GScribo/itemdelegate.cpp deleted file mode 100644 index 60f8cd3..0000000 --- a/GScribo/itemdelegate.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "itemdelegate.h" - -ItemDelegate::ItemDelegate(QWidget *parent): - QItemDelegate(parent) -{ -} - -QWidget * ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem&, const QModelIndex&) const -{ - QLabel *label = new QLabel(parent); - label->setMinimumSize(100, 100); - - return label; -} - -void ItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const -{ - QLabel *label = static_cast<QLabel *>(editor); - QPixmap pixmap = index.model()->data(index, Qt::DecorationRole).value<QPixmap>(); - label->setPixmap(pixmap); -} - -void ItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const -{ - editor->setGeometry(option.rect); -} diff --git a/GScribo/itemdelegate.h b/GScribo/itemdelegate.h deleted file mode 100644 index 1864ccf..0000000 --- a/GScribo/itemdelegate.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef ITEMDELEGATE_H -#define ITEMDELEGATE_H - -#include <QItemDelegate> -#include <QLabel> - -class ItemDelegate: - public QItemDelegate -{ - public: - explicit ItemDelegate(QWidget *parent = 0); - QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem& option, const QModelIndex& index) const; - void setEditorData(QWidget *editor, const QModelIndex &index) const; - void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; -}; - -#endif // ITEMDELEGATE_H diff --git a/GScribo/listmodel.cpp b/GScribo/listmodel.cpp index 4bbe802..de0087a 100644 --- a/GScribo/listmodel.cpp +++ b/GScribo/listmodel.cpp @@ -1,52 +1,30 @@ #include "listmodel.h" -ListModel::ListModel(QStringList stringList, QObject *parent): +ListModel::ListModel(QObject *parent): QAbstractListModel(parent) { - this->stringList = stringList; } -ListModel::~ListModel() +int ListModel::rowCount(const QModelIndex&) const { + return pixmaps.size(); } -int ListModel::rowCount(const QModelIndex &/*parent*/) const +QVariant ListModel::data(const QModelIndex& index, int role) const { - return stringList.count(); -} - -QVariant ListModel::data(const QModelIndex &index, int role) const -{ - if(index.isValid() && stringList.size() < index.row() && (role == Qt::DisplayRole || role == Qt::EditRole)) - return stringList.at(index.row()); - else + if(!index.isValid()) return QVariant(); -} -QVariant ListModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if(role == Qt::DisplayRole && orientation == Qt::Horizontal) - return QVariant(); - else - return QString("Row %1").arg(section); -} + if(role == Qt::DecorationRole) + return QIcon(pixmaps.value(index.row()).scaled(QSize(200, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation)); -/*Qt::ItemFlags ListModel::flags(const QModelIndex &index) const -{ - if(!index.isValid()) - return Qt::ItemIsEnabled; - else - return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; + return QVariant(); } -bool ListModel::setData(const QModelIndex &index, const QVariant &value, int role) +void ListModel::addPixmap(const QPixmap& pixmap) { - if(index.isValid() && role == Qt::DisplayRole) - { - stringList.replace(index.row(), value.toString()); - emit dataChanged(index, index); - return true; - } - else - return false; -}*/ + int row = pixmaps.size(); + beginInsertRows(QModelIndex(), row, row); + pixmaps.insert(row, pixmap); + endInsertRows(); +} diff --git a/GScribo/listmodel.h b/GScribo/listmodel.h index c7f061f..03469b5 100644 --- a/GScribo/listmodel.h +++ b/GScribo/listmodel.h @@ -2,7 +2,7 @@ #define LISTMODEL_H #include <QAbstractListModel> -#include <QLabel> +#include <QIcon> #include <QList> class ListModel: @@ -11,16 +11,13 @@ class ListModel: Q_OBJECT public: - explicit ListModel(QStringList stringList, QObject *parent = 0); - ~ListModel(); + explicit ListModel(QObject *parent = 0); int rowCount(const QModelIndex &parent) const; QVariant data(const QModelIndex &index, int role = Qt::DecorationRole) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DecorationRole) const; - /*Qt::ItemFlags flags(const QModelIndex &index) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DecorationRole);*/ + void addPixmap(const QPixmap& pixmap); private: - QStringList stringList; + QList<QPixmap> pixmaps; }; #endif // LISTMODEL_H diff --git a/GScribo/mainwindow.cpp b/GScribo/mainwindow.cpp deleted file mode 100644 index 4b68fbe..0000000 --- a/GScribo/mainwindow.cpp +++ /dev/null @@ -1,97 +0,0 @@ -#include "mainwindow.h" -#include "ui_mainwindow.h" - -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - - initGraphicsRegion(); - initTextRegion(); - initTablePage(); - initToolBar(); -} - -MainWindow::~MainWindow() -{ - delete dockText; - delete dockPages; - delete scene; - delete graphicsView; - delete textEdit; - delete ui; -} - -void MainWindow::initGraphicsRegion() -{ - graphicsView = new QGraphicsView; - // Cache backgroud to speed up its repaint. - graphicsView->setCacheMode(QGraphicsView::CacheBackground); - graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); - - scene = new Scene(); - // Disable scroll bar extend with a non-null rectangle. - scene->setSceneRect(0, 0, 0, 1); - graphicsView->setScene(scene); - - setCentralWidget(graphicsView); -} - -void MainWindow::initTablePage() -{ - dockPages = new QDockWidget(tr("Pages")); - dockPages->setAllowedAreas(Qt::AllDockWidgetAreas); - dockPages->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable); - - pagesWidget = new PagesWidget; - dockPages->setWidget(pagesWidget); - - addDockWidget(Qt::LeftDockWidgetArea, dockPages); -} - -void MainWindow::initTextRegion() -{ - dockText = new QDockWidget(tr("Previsualization")); - dockText->setAllowedAreas(Qt::AllDockWidgetAreas); - dockText->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); - - textEdit = new QPlainTextEdit; - dockText->setWidget(textEdit); - - addDockWidget(Qt::RightDockWidgetArea, dockText); - //dockText->hide(); -} - -void MainWindow::initToolBar() -{ - QAction *open = ui->mainToolBar->addAction(tr("Open")); - connect(open, SIGNAL(triggered()), this, SLOT(onOpen())); -} - -void MainWindow::onOpen() -{ - QString path = QFileDialog::getOpenFileName(this); - if(path != "") - { - QPixmap pixmap(path); - - scene->setSceneRect(pixmap.rect()); - scene->setBackgroundBrush(QBrush(pixmap)); - - pagesWidget->addPicture(path, pixmap); - } -} - -void MainWindow::changeEvent(QEvent *e) -{ - QMainWindow::changeEvent(e); - switch (e->type()) - { - case QEvent::LanguageChange: - ui->retranslateUi(this); - break; - default: - break; - } -} diff --git a/GScribo/mainwindow.h b/GScribo/mainwindow.h deleted file mode 100644 index b5355f1..0000000 --- a/GScribo/mainwindow.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include <QMainWindow> -#include <QHBoxLayout> -#include <QDockWidget> -#include <QGraphicsView> -#include <QGLWidget> -#include <QPlainTextEdit> -#include <QGroupBox> -#include <QFileDialog> - -#include "scene.h" -#include "pageswidget.h" - -namespace Ui -{ - class MainWindow; -} - -class MainWindow: - public QMainWindow -{ - Q_OBJECT - - public: - MainWindow(QWidget *parent = 0); - ~MainWindow(); - - protected: - void changeEvent(QEvent *e); - - private: - void initGraphicsRegion(); - void initTextRegion(); - void initToolBar(); - void initTablePage(); - - Ui::MainWindow *ui; - QDockWidget *dockText; - QDockWidget *dockPages; - Scene *scene; - QGraphicsView *graphicsView; - QPlainTextEdit *textEdit; - PagesWidget *pagesWidget; - QString imagePath; - - private slots: - void onOpen(); -}; - -#endif // MAINWINDOW_H diff --git a/GScribo/pageswidget.cpp b/GScribo/pageswidget.cpp index ed34d84..1652062 100644 --- a/GScribo/pageswidget.cpp +++ b/GScribo/pageswidget.cpp @@ -1,27 +1,19 @@ #include "pageswidget.h" PagesWidget::PagesWidget(QWidget *parent): - QWidget(parent) + QListView(parent) { - QStringList l; - l << "/lrde/home/stage/froger_a/ppm/mp00032c.ppm" << "/lrde/home/stage/froger_a/ppm/mp00042.ppm" << "/lrde/home/stage/froger_a/ppm/mp00076.ppm"; - filenames = new QStringList; - model = new ListModel(l); - listView = new QListView(this); - listView->setItemDelegate(new ItemDelegate()); - listView->setModel(model); - listView->update(model->index(0, 0)); - listView->show(); + setUniformItemSizes(true); + setViewMode(QListView::IconMode); + setIconSize(QSize(200, 200)); + setFlow(QListView::TopToBottom); + setMovement(QListView::Static); + setSpacing(10); + setWrapping(false); + setModel(&model); } -PagesWidget::~PagesWidget() +void PagesWidget::addPixmap(const QString& filename, const QPixmap &pixmap) { - delete filenames; - delete listView; -} - -void PagesWidget::addPicture(const QString& filename, const QPixmap& pixmap) -{ - *filenames << filename; - + model.addPixmap(pixmap); } diff --git a/GScribo/pageswidget.h b/GScribo/pageswidget.h index 805deff..fade0d6 100644 --- a/GScribo/pageswidget.h +++ b/GScribo/pageswidget.h @@ -2,29 +2,24 @@ #define PAGESWIDGET_H #include <QWidget> -#include <QScrollArea> -#include <QVBoxLayout> -#include <QListWidget> -#include <QStandardItemModel> -#include <QLabel> +#include <QListView> +#include <QPainter> +#include <QPushButton> +#include <QScrollBar> -#include "itemdelegate.h" #include "listmodel.h" class PagesWidget: - public QWidget + public QListView { Q_OBJECT public: explicit PagesWidget(QWidget *parent = 0); - ~PagesWidget(); - void addPicture(const QString& filename, const QPixmap& pixmap); + void addPixmap(const QString& filename, const QPixmap& pixmap); private: - QListView *listView; - ListModel *model; - QStringList *filenames; + ListModel model; }; #endif // PAGESWIDGET_H diff --git a/GScribo/ui_mainwindow.h b/GScribo/ui_mainwindow.h new file mode 100644 index 0000000..7ba54a5 --- /dev/null +++ b/GScribo/ui_mainwindow.h @@ -0,0 +1,73 @@ +/******************************************************************************** +** Form generated from reading UI file 'mainwindow.ui' +** +** Created: Wed Jan 23 15:39:30 2013 +** by: Qt User Interface Compiler version 4.6.3 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_MAINWINDOW_H +#define UI_MAINWINDOW_H + +#include <QtCore/QVariant> +#include <QtGui/QAction> +#include <QtGui/QApplication> +#include <QtGui/QButtonGroup> +#include <QtGui/QHeaderView> +#include <QtGui/QMainWindow> +#include <QtGui/QMenuBar> +#include <QtGui/QStatusBar> +#include <QtGui/QToolBar> +#include <QtGui/QWidget> + +QT_BEGIN_NAMESPACE + +class Ui_MainWindow +{ +public: + QWidget *centralWidget; + QMenuBar *menuBar; + QToolBar *mainToolBar; + QStatusBar *statusBar; + + void setupUi(QMainWindow *MainWindow) + { + if (MainWindow->objectName().isEmpty()) + MainWindow->setObjectName(QString::fromUtf8("MainWindow")); + MainWindow->resize(671, 436); + centralWidget = new QWidget(MainWindow); + centralWidget->setObjectName(QString::fromUtf8("centralWidget")); + centralWidget->setEnabled(true); + MainWindow->setCentralWidget(centralWidget); + menuBar = new QMenuBar(MainWindow); + menuBar->setObjectName(QString::fromUtf8("menuBar")); + menuBar->setGeometry(QRect(0, 0, 671, 23)); + MainWindow->setMenuBar(menuBar); + mainToolBar = new QToolBar(MainWindow); + mainToolBar->setObjectName(QString::fromUtf8("mainToolBar")); + mainToolBar->setFloatable(false); + MainWindow->addToolBar(Qt::TopToolBarArea, mainToolBar); + statusBar = new QStatusBar(MainWindow); + statusBar->setObjectName(QString::fromUtf8("statusBar")); + MainWindow->setStatusBar(statusBar); + + retranslateUi(MainWindow); + + QMetaObject::connectSlotsByName(MainWindow); + } // setupUi + + void retranslateUi(QMainWindow *MainWindow) + { + MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8)); + } // retranslateUi + +}; + +namespace Ui { + class MainWindow: public Ui_MainWindow {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_MAINWINDOW_H diff --git a/MVC/MVC.pro.user b/MVC/MVC.pro.user index c8ef164..1c6e9ba 100644 --- a/MVC/MVC.pro.user +++ b/MVC/MVC.pro.user @@ -76,14 +76,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-sncykruQ0C,guid=e454b1a02a95fc6454d7a56d0067ee2b</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-iL4mXwl7ak,guid=7e9603aab929b1f1fce663d30068f708</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-8ccgXN</value> - <value type="QString">GNOME_KEYRING_PID=30769</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kN7FtK</value> + <value type="QString">GNOME_KEYRING_PID=25582</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -95,16 +95,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=30844</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gtQAz30778/agent.30778</value> + <value type="QString">SSH_AGENT_PID=25657</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-RiFAp25591/agent.25591</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm3KFZQW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmJKU1QW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358858991.561353-1070905078</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358926796.562496-56304996</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -128,14 +128,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-sncykruQ0C,guid=e454b1a02a95fc6454d7a56d0067ee2b</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-iL4mXwl7ak,guid=7e9603aab929b1f1fce663d30068f708</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-8ccgXN</value> - <value type="QString">GNOME_KEYRING_PID=30769</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-kN7FtK</value> + <value type="QString">GNOME_KEYRING_PID=25582</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -147,16 +147,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=30844</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gtQAz30778/agent.30778</value> + <value type="QString">SSH_AGENT_PID=25657</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-RiFAp25591/agent.25591</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm3KFZQW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmJKU1QW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358858991.561353-1070905078</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358926796.562496-56304996</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> diff --git a/MVC/itemdelegate.cpp b/MVC/itemdelegate.cpp index c241e1e..5f67a91 100644 --- a/MVC/itemdelegate.cpp +++ b/MVC/itemdelegate.cpp @@ -7,7 +7,7 @@ ItemDelegate::ItemDelegate(QWidget *parent): void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { - QString path = index.model()->data(index, Qt::DecorationRole).toString(); + QString path = index.data(Qt::DecorationRole).toString(); QPixmap pixmap(path); painter->drawPixmap(0, index.row() * 210, 200, 200, pixmap); @@ -15,5 +15,5 @@ void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { - return QSize(200, 200); + return QSize(200, 400); } diff --git a/MVC/ui_mainwindow.h b/MVC/ui_mainwindow.h new file mode 100644 index 0000000..48f2cce --- /dev/null +++ b/MVC/ui_mainwindow.h @@ -0,0 +1,70 @@ +/******************************************************************************** +** Form generated from reading UI file 'mainwindow.ui' +** +** Created: Wed Jan 23 08:52:24 2013 +** by: Qt User Interface Compiler version 4.6.3 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_MAINWINDOW_H +#define UI_MAINWINDOW_H + +#include <QtCore/QVariant> +#include <QtGui/QAction> +#include <QtGui/QApplication> +#include <QtGui/QButtonGroup> +#include <QtGui/QHeaderView> +#include <QtGui/QMainWindow> +#include <QtGui/QMenuBar> +#include <QtGui/QStatusBar> +#include <QtGui/QToolBar> +#include <QtGui/QWidget> + +QT_BEGIN_NAMESPACE + +class Ui_MainWindow +{ +public: + QMenuBar *menuBar; + QToolBar *mainToolBar; + QWidget *centralWidget; + QStatusBar *statusBar; + + void setupUi(QMainWindow *MainWindow) + { + if (MainWindow->objectName().isEmpty()) + MainWindow->setObjectName(QString::fromUtf8("MainWindow")); + MainWindow->resize(600, 400); + menuBar = new QMenuBar(MainWindow); + menuBar->setObjectName(QString::fromUtf8("menuBar")); + MainWindow->setMenuBar(menuBar); + mainToolBar = new QToolBar(MainWindow); + mainToolBar->setObjectName(QString::fromUtf8("mainToolBar")); + MainWindow->addToolBar(mainToolBar); + centralWidget = new QWidget(MainWindow); + centralWidget->setObjectName(QString::fromUtf8("centralWidget")); + MainWindow->setCentralWidget(centralWidget); + statusBar = new QStatusBar(MainWindow); + statusBar->setObjectName(QString::fromUtf8("statusBar")); + MainWindow->setStatusBar(statusBar); + + retranslateUi(MainWindow); + + QMetaObject::connectSlotsByName(MainWindow); + } // setupUi + + void retranslateUi(QMainWindow *MainWindow) + { + MainWindow->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8)); + } // retranslateUi + +}; + +namespace Ui { + class MainWindow: public Ui_MainWindow {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_MAINWINDOW_H diff --git a/gmvc/gmodel.cpp b/gmvc/gmodel.cpp new file mode 100644 index 0000000..38a2aa3 --- /dev/null +++ b/gmvc/gmodel.cpp @@ -0,0 +1,162 @@ +#include "gmodel.h" + +gModel::gModel(QObject *parent) : + QAbstractListModel(parent) +{ +} + +QVariant gModel::data(const QModelIndex &index, int role) const + { + if (!index.isValid()) + return QVariant(); + + if (role == Qt::DecorationRole) + return QIcon(pixmaps.value(index.row()).scaled(60, 60, + Qt::KeepAspectRatio, Qt::SmoothTransformation)); + /*else if (role == Qt::UserRole) + return pixmaps.value(index.row()); + else if (role == Qt::UserRole + 1) + return locations.value(index.row());*/ + + return QVariant(); + } + + void gModel::addPiece(const QPixmap &pixmap, const QPoint &location) + { + /*int row; + if (int(2.0*qrand()/(RAND_MAX+1.0)) == 1) + row = 0; + else + row = pixmaps.size();*/ + int row = pixmaps.size(); + + beginInsertRows(QModelIndex(), row, row); + pixmaps.insert(row, pixmap); + //locations.insert(row, location); + endInsertRows(); + } + + /*Qt::ItemFlags gModel::flags(const QModelIndex &index) const + { + if (index.isValid()) + return (Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled); + + return Qt::ItemIsDropEnabled; + }*/ + + /*bool gModel::removeRows(int row, int count, const QModelIndex &parent) + { + if (parent.isValid()) + return false; + + if (row >= pixmaps.size() || row + count <= 0) + return false; + + int beginRow = qMax(0, row); + int endRow = qMin(row + count - 1, pixmaps.size() - 1); + + beginRemoveRows(parent, beginRow, endRow); + + while (beginRow <= endRow) { + pixmaps.removeAt(beginRow); + locations.removeAt(beginRow); + ++beginRow; + } + + endRemoveRows(); + return true; + }*/ + + /*QStringList gModel::mimeTypes() const + { + QStringList types; + types << "image/x-puzzle-piece"; + return types; + }*/ + + /*QMimeData *gModel::mimeData(const QModelIndexList &indexes) const + { + QMimeData *mimeData = new QMimeData(); + QByteArray encodedData; + + QDataStream stream(&encodedData, QIODevice::WriteOnly); + + foreach (QModelIndex index, indexes) { + if (index.isValid()) { + QPixmap pixmap = qVariantValue<QPixmap>(data(index, Qt::UserRole)); + QPoint location = data(index, Qt::UserRole+1).toPoint(); + stream << pixmap << location; + } + } + + mimeData->setData("image/x-puzzle-piece", encodedData); + return mimeData; + }*/ + + /*bool gModel::dropMimeData(const QMimeData *data, Qt::DropAction action, + int row, int column, const QModelIndex &parent) + { + if (!data->hasFormat("image/x-puzzle-piece")) + return false; + + if (action == Qt::IgnoreAction) + return true; + + if (column > 0) + return false; + + int endRow; + + if (!parent.isValid()) { + if (row < 0) + endRow = pixmaps.size(); + else + endRow = qMin(row, pixmaps.size()); + } else + endRow = parent.row(); + + QByteArray encodedData = data->data("image/x-puzzle-piece"); + QDataStream stream(&encodedData, QIODevice::ReadOnly); + + while (!stream.atEnd()) { + QPixmap pixmap; + QPoint location; + stream >> pixmap >> location; + + beginInsertRows(QModelIndex(), endRow, endRow); + pixmaps.insert(endRow, pixmap); + locations.insert(endRow, location); + endInsertRows(); + + ++endRow; + } + + return true; + }*/ + + int gModel::rowCount(const QModelIndex &parent) const + { + if (parent.isValid()) + return 0; + else + return pixmaps.size(); + } + + /*Qt::DropActions gModel::supportedDropActions() const + { + return Qt::CopyAction | Qt::MoveAction; + }*/ + +/* void gModel::addPieces(const QPixmap& pixmap) + { + beginRemoveRows(QModelIndex(), 0, 24); + pixmaps.clear(); + locations.clear(); + endRemoveRows(); + for (int y = 0; y < 5; ++y) { + for (int x = 0; x < 5; ++x) { + QPixmap pieceImage = pixmap.copy(x*80, y*80, 80, 80); + addPiece(pieceImage, QPoint(x, y)); + } + } + }*/ diff --git a/gmvc/gmodel.h b/gmvc/gmodel.h new file mode 100644 index 0000000..3e5a787 --- /dev/null +++ b/gmvc/gmodel.h @@ -0,0 +1,34 @@ +#ifndef GMODEL_H +#define GMODEL_H + +#include <QAbstractListModel> +#include <QPixmap> +#include <QIcon> +#include <QMimeData> + +class gModel : + public QAbstractListModel +{ + public: + gModel(QObject *parent = 0); + + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + //Qt::ItemFlags flags(const QModelIndex &index) const; + //bool removeRows(int row, int count, const QModelIndex &parent); + + //bool dropMimeData(const QMimeData *data, Qt::DropAction action, + // int row, int column, const QModelIndex &parent); + //QMimeData *mimeData(const QModelIndexList &indexes) const; + //QStringList mimeTypes() const; + int rowCount(const QModelIndex &parent) const; + //Qt::DropActions supportedDropActions() const; + + void addPiece(const QPixmap &pixmap, const QPoint &location); + //void addPieces(const QPixmap& pixmap); + + private: + QList<QPoint> locations; + QList<QPixmap> pixmaps; +}; + +#endif // GMODEL_H diff --git a/MVC/MVC.pro b/gmvc/gmvc.pro similarity index 59% copy from MVC/MVC.pro copy to gmvc/gmvc.pro index 1a4d48c..81e49e5 100644 --- a/MVC/MVC.pro +++ b/gmvc/gmvc.pro @@ -1,13 +1,13 @@ # ------------------------------------------------- -# Project created by QtCreator 2013-01-22T16:00:23 +# Project created by QtCreator 2013-01-23T09:31:00 # ------------------------------------------------- -TARGET = MVC +TARGET = gmvc TEMPLATE = app SOURCES += main.cpp \ mainwindow.cpp \ - itemdelegate.cpp \ - listmodel.cpp + model.cpp \ + gmodel.cpp HEADERS += mainwindow.h \ - listmodel.h \ - itemdelegate.h + model.h \ + gmodel.h FORMS += mainwindow.ui diff --git a/MVC/MVC.pro.user b/gmvc/gmvc.pro.user similarity index 87% copy from MVC/MVC.pro.user copy to gmvc/gmvc.pro.user index c8ef164..4a75b91 100644 --- a/MVC/MVC.pro.user +++ b/gmvc/gmvc.pro.user @@ -10,11 +10,11 @@ </data> <data> <variable>RunConfiguration0-ProFile</variable> - <value type="QString">MVC.pro</value> + <value type="QString">gmvc.pro</value> </data> <data> <variable>RunConfiguration0-RunConfiguration.name</variable> - <value type="QString">MVC</value> + <value type="QString">gmvc</value> </data> <data> <variable>RunConfiguration0-UseDyldImageSuffix</variable> @@ -76,14 +76,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-sncykruQ0C,guid=e454b1a02a95fc6454d7a56d0067ee2b</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0VAN4sEd5T,guid=75a5318e040070f8fcb70ccf006944fa</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-8ccgXN</value> - <value type="QString">GNOME_KEYRING_PID=30769</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nVYZaO</value> + <value type="QString">GNOME_KEYRING_PID=27939</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -91,20 +91,20 @@ <value type="QString">LOGNAME=froger_a</value> <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/MVC</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/gmvc</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=30844</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gtQAz30778/agent.30778</value> + <value type="QString">SSH_AGENT_PID=28014</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-yzfMR27948/agent.27948</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm3KFZQW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmBDX0QW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358858991.561353-1070905078</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358946750.592912-119709926</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -112,7 +112,7 @@ <value type="QString">_=/usr/bin/qtcreator</value> </valuelist> <valuelist key="abstractProcess.arguments" type="QVariantList"> - <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/MVC/MVC.pro</value> + <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/gmvc/gmvc.pro</value> <value type="QString">-spec</value> <value type="QString">linux-g++</value> <value type="QString">-r</value> @@ -120,7 +120,7 @@ </valuelist> <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value> <value key="abstractProcess.enabled" type="bool">false</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/MVC</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/gmvc</value> </valuemap> </data> <data> @@ -128,14 +128,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-sncykruQ0C,guid=e454b1a02a95fc6454d7a56d0067ee2b</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-0VAN4sEd5T,guid=75a5318e040070f8fcb70ccf006944fa</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-8ccgXN</value> - <value type="QString">GNOME_KEYRING_PID=30769</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nVYZaO</value> + <value type="QString">GNOME_KEYRING_PID=27939</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -143,20 +143,20 @@ <value type="QString">LOGNAME=froger_a</value> <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/MVC</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/gmvc</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=30844</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gtQAz30778/agent.30778</value> + <value type="QString">SSH_AGENT_PID=28014</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-yzfMR27948/agent.27948</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm3KFZQW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmBDX0QW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358858991.561353-1070905078</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358946750.592912-119709926</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -169,7 +169,7 @@ </valuelist> <value key="abstractProcess.command" type="QString">/usr/bin/make</value> <value key="abstractProcess.enabled" type="bool">true</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/MVC</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/gmvc</value> </valuemap> </data> <data> diff --git a/MVC/main.cpp b/gmvc/main.cpp similarity index 100% copy from MVC/main.cpp copy to gmvc/main.cpp diff --git a/gmvc/mainwindow.cpp b/gmvc/mainwindow.cpp new file mode 100644 index 0000000..d046226 --- /dev/null +++ b/gmvc/mainwindow.cpp @@ -0,0 +1,51 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + QListView *view = new QListView(); + view->setViewMode(QListView::IconMode); + view->setIconSize(QSize(100, 100)); + view->setMovement(QListView::Static); + view->setFlow(QListView::TopToBottom); + //view->setGridSize(QSize(300, 100)); + view->setSpacing(9); + + QList<QPixmap> pixmaps; + QStringList paths; + paths << "/lrde/home/stage/froger_a/ppm/mp00032c.ppm" << "/lrde/home/stage/froger_a/ppm/mp00042.ppm" << "/lrde/home/stage/froger_a/ppm/mp00076.ppm"; + QString path; + Model *model = new Model(this); + foreach(path, paths) + { + QPixmap pixmap(path); + model->addPixmap(pixmap); + } + + view->setModel(model); + //setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + + setCentralWidget(view); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) + { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/gmvc/mainwindow.h b/gmvc/mainwindow.h new file mode 100644 index 0000000..822c275 --- /dev/null +++ b/gmvc/mainwindow.h @@ -0,0 +1,28 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> +#include <QHBoxLayout> +#include <QListView> + +#include "gmodel.h" +#include "model.h" + +namespace Ui { + class MainWindow; +} + +class MainWindow : public QMainWindow { + Q_OBJECT +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + +protected: + void changeEvent(QEvent *e); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/MVC/mainwindow.ui b/gmvc/mainwindow.ui similarity index 100% copy from MVC/mainwindow.ui copy to gmvc/mainwindow.ui diff --git a/gmvc/model.cpp b/gmvc/model.cpp new file mode 100644 index 0000000..eb20cf8 --- /dev/null +++ b/gmvc/model.cpp @@ -0,0 +1,37 @@ +#include "model.h" + +Model::Model(QObject *parent) : + QAbstractListModel(parent) +{ + this->pixmaps = pixmaps; +} + +int Model::rowCount(const QModelIndex& parent) const +{ + if (parent.isValid()) + return 0; + else + return pixmaps.size();; +} + +QVariant Model::data(const QModelIndex& index, int role) const +{ + if(!index.isValid()) + return QVariant(); + + if(role == Qt::DecorationRole) + return QIcon(pixmaps.value(index.row()).scaled(300, 300, Qt::KeepAspectRatio, Qt::SmoothTransformation)); + + if(role == Qt::UserRole) + return pixmaps.value(index.row()); + + return QVariant(); +} + +void Model::addPixmap(const QPixmap& pixmap) +{ + int row = pixmaps.size(); + beginInsertRows(QModelIndex(), row, row); + pixmaps.insert(row, pixmap); + endInsertRows(); +} diff --git a/gmvc/model.h b/gmvc/model.h new file mode 100644 index 0000000..f2247f4 --- /dev/null +++ b/gmvc/model.h @@ -0,0 +1,20 @@ +#ifndef MODEL_H +#define MODEL_H + +#include <QAbstractListModel> +#include <QIcon> + +class Model : + public QAbstractListModel +{ + public: + explicit Model(QObject *parent = 0); + QVariant data(const QModelIndex &index, int role) const; + int rowCount(const QModelIndex &parent) const; + void addPixmap(const QPixmap& pixmap); + + private: + QList<QPixmap> pixmaps; +}; + +#endif // MODEL_H -- 1.7.2.5
11Â years, 11Â months
1
0
0
0
42b527a Add listview implementation tentative. With custiom delegate item and custom model.
by Antoine Froger
--- GScribo/GScribo.pro | 8 ++- GScribo/GScribo.pro.user | 40 ++++++++-------- GScribo/itemdelegate.cpp | 26 ++++++++++ GScribo/itemdelegate.h | 17 ++++++ GScribo/listmodel.cpp | 52 ++++++++++++++++++++ GScribo/listmodel.h | 26 ++++++++++ GScribo/mainwindow.cpp | 2 +- GScribo/mainwindow.h | 3 +- GScribo/pageswidget.cpp | 23 ++++----- GScribo/pageswidget.h | 9 ++- MVC/MVC.pro | 13 +++++ TestInterface/GScribo.pro.user => MVC/MVC.pro.user | 46 +++++++++--------- MVC/itemdelegate.cpp | 19 +++++++ MVC/itemdelegate.h | 17 ++++++ MVC/listmodel.cpp | 32 ++++++++++++ MVC/listmodel.h | 24 +++++++++ {NotePad => MVC}/main.cpp | 6 +- MVC/mainwindow.cpp | 40 +++++++++++++++ MVC/mainwindow.h | 30 +++++++++++ MVC/mainwindow.ui | 24 +++++++++ 20 files changed, 391 insertions(+), 66 deletions(-) create mode 100644 GScribo/itemdelegate.cpp create mode 100644 GScribo/itemdelegate.h create mode 100644 GScribo/listmodel.cpp create mode 100644 GScribo/listmodel.h create mode 100644 MVC/MVC.pro copy TestInterface/GScribo.pro.user => MVC/MVC.pro.user (87%) create mode 100644 MVC/itemdelegate.cpp create mode 100644 MVC/itemdelegate.h create mode 100644 MVC/listmodel.cpp create mode 100644 MVC/listmodel.h copy {NotePad => MVC}/main.cpp (60%) create mode 100644 MVC/mainwindow.cpp create mode 100644 MVC/mainwindow.h create mode 100644 MVC/mainwindow.ui diff --git a/GScribo/GScribo.pro b/GScribo/GScribo.pro index ad4abe0..7930307 100644 --- a/GScribo/GScribo.pro +++ b/GScribo/GScribo.pro @@ -17,9 +17,13 @@ SOURCES += main.cpp \ mainwindow.cpp \ scene.cpp \ selection.cpp \ - pageswidget.cpp + pageswidget.cpp \ + itemdelegate.cpp \ + listmodel.cpp HEADERS += mainwindow.h \ scene.h \ selection.h \ - pageswidget.h + pageswidget.h \ + itemdelegate.h \ + listmodel.h FORMS += mainwindow.ui diff --git a/GScribo/GScribo.pro.user b/GScribo/GScribo.pro.user index 6f863ff..92e91c7 100644 --- a/GScribo/GScribo.pro.user +++ b/GScribo/GScribo.pro.user @@ -76,35 +76,35 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Si71aPButo,guid=4a5769b30d2b16bfbff191ee00669e72</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-sncykruQ0C,guid=e454b1a02a95fc6454d7a56d0067ee2b</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-xqG91k</value> - <value type="QString">GNOME_KEYRING_PID=24747</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-8ccgXN</value> + <value type="QString">GNOME_KEYRING_PID=30769</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=24822</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-ViaPN24756/agent.24756</value> + <value type="QString">SSH_AGENT_PID=30844</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gtQAz30778/agent.30778</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmDMHCRW</value> + <value type="QString">WINDOWID=12582948</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm3KFZQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358773046.159332-2135577617</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358858991.561353-1070905078</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -128,35 +128,35 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Si71aPButo,guid=4a5769b30d2b16bfbff191ee00669e72</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-sncykruQ0C,guid=e454b1a02a95fc6454d7a56d0067ee2b</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-xqG91k</value> - <value type="QString">GNOME_KEYRING_PID=24747</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-8ccgXN</value> + <value type="QString">GNOME_KEYRING_PID=30769</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=24822</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-ViaPN24756/agent.24756</value> + <value type="QString">SSH_AGENT_PID=30844</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gtQAz30778/agent.30778</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmDMHCRW</value> + <value type="QString">WINDOWID=12582948</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm3KFZQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358773046.159332-2135577617</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358858991.561353-1070905078</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> diff --git a/GScribo/itemdelegate.cpp b/GScribo/itemdelegate.cpp new file mode 100644 index 0000000..60f8cd3 --- /dev/null +++ b/GScribo/itemdelegate.cpp @@ -0,0 +1,26 @@ +#include "itemdelegate.h" + +ItemDelegate::ItemDelegate(QWidget *parent): + QItemDelegate(parent) +{ +} + +QWidget * ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem&, const QModelIndex&) const +{ + QLabel *label = new QLabel(parent); + label->setMinimumSize(100, 100); + + return label; +} + +void ItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const +{ + QLabel *label = static_cast<QLabel *>(editor); + QPixmap pixmap = index.model()->data(index, Qt::DecorationRole).value<QPixmap>(); + label->setPixmap(pixmap); +} + +void ItemDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &/*index*/) const +{ + editor->setGeometry(option.rect); +} diff --git a/GScribo/itemdelegate.h b/GScribo/itemdelegate.h new file mode 100644 index 0000000..1864ccf --- /dev/null +++ b/GScribo/itemdelegate.h @@ -0,0 +1,17 @@ +#ifndef ITEMDELEGATE_H +#define ITEMDELEGATE_H + +#include <QItemDelegate> +#include <QLabel> + +class ItemDelegate: + public QItemDelegate +{ + public: + explicit ItemDelegate(QWidget *parent = 0); + QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem& option, const QModelIndex& index) const; + void setEditorData(QWidget *editor, const QModelIndex &index) const; + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; +}; + +#endif // ITEMDELEGATE_H diff --git a/GScribo/listmodel.cpp b/GScribo/listmodel.cpp new file mode 100644 index 0000000..4bbe802 --- /dev/null +++ b/GScribo/listmodel.cpp @@ -0,0 +1,52 @@ +#include "listmodel.h" + +ListModel::ListModel(QStringList stringList, QObject *parent): + QAbstractListModel(parent) +{ + this->stringList = stringList; +} + +ListModel::~ListModel() +{ +} + +int ListModel::rowCount(const QModelIndex &/*parent*/) const +{ + return stringList.count(); +} + +QVariant ListModel::data(const QModelIndex &index, int role) const +{ + if(index.isValid() && stringList.size() < index.row() && (role == Qt::DisplayRole || role == Qt::EditRole)) + return stringList.at(index.row()); + else + return QVariant(); +} + +QVariant ListModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(role == Qt::DisplayRole && orientation == Qt::Horizontal) + return QVariant(); + else + return QString("Row %1").arg(section); +} + +/*Qt::ItemFlags ListModel::flags(const QModelIndex &index) const +{ + if(!index.isValid()) + return Qt::ItemIsEnabled; + else + return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; +} + +bool ListModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if(index.isValid() && role == Qt::DisplayRole) + { + stringList.replace(index.row(), value.toString()); + emit dataChanged(index, index); + return true; + } + else + return false; +}*/ diff --git a/GScribo/listmodel.h b/GScribo/listmodel.h new file mode 100644 index 0000000..c7f061f --- /dev/null +++ b/GScribo/listmodel.h @@ -0,0 +1,26 @@ +#ifndef LISTMODEL_H +#define LISTMODEL_H + +#include <QAbstractListModel> +#include <QLabel> +#include <QList> + +class ListModel: + public QAbstractListModel +{ + Q_OBJECT + + public: + explicit ListModel(QStringList stringList, QObject *parent = 0); + ~ListModel(); + int rowCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role = Qt::DecorationRole) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DecorationRole) const; + /*Qt::ItemFlags flags(const QModelIndex &index) const; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::DecorationRole);*/ + + private: + QStringList stringList; +}; + +#endif // LISTMODEL_H diff --git a/GScribo/mainwindow.cpp b/GScribo/mainwindow.cpp index 4ef2aa1..4b68fbe 100644 --- a/GScribo/mainwindow.cpp +++ b/GScribo/mainwindow.cpp @@ -60,7 +60,7 @@ void MainWindow::initTextRegion() dockText->setWidget(textEdit); addDockWidget(Qt::RightDockWidgetArea, dockText); - dockText->hide(); + //dockText->hide(); } void MainWindow::initToolBar() diff --git a/GScribo/mainwindow.h b/GScribo/mainwindow.h index aa80b72..b5355f1 100644 --- a/GScribo/mainwindow.h +++ b/GScribo/mainwindow.h @@ -18,7 +18,8 @@ namespace Ui class MainWindow; } -class MainWindow : public QMainWindow +class MainWindow: + public QMainWindow { Q_OBJECT diff --git a/GScribo/pageswidget.cpp b/GScribo/pageswidget.cpp index 2f23d9d..ed34d84 100644 --- a/GScribo/pageswidget.cpp +++ b/GScribo/pageswidget.cpp @@ -3,28 +3,25 @@ PagesWidget::PagesWidget(QWidget *parent): QWidget(parent) { + QStringList l; + l << "/lrde/home/stage/froger_a/ppm/mp00032c.ppm" << "/lrde/home/stage/froger_a/ppm/mp00042.ppm" << "/lrde/home/stage/froger_a/ppm/mp00076.ppm"; filenames = new QStringList; - scrollArea = new QScrollArea(this); - scrollArea->setGeometry(0, 0, 1000, 1000); - layout = new QHBoxLayout; - QWidget *widget = new QWidget; - widget->setLayout(layout); - scrollArea->setWidget(widget); + model = new ListModel(l); + listView = new QListView(this); + listView->setItemDelegate(new ItemDelegate()); + listView->setModel(model); + listView->update(model->index(0, 0)); + listView->show(); } PagesWidget::~PagesWidget() { delete filenames; - delete layout; - delete scrollArea; + delete listView; } void PagesWidget::addPicture(const QString& filename, const QPixmap& pixmap) { *filenames << filename; - QPixmap pix = pixmap.scaled(100, 100, Qt::IgnoreAspectRatio); - QLabel *label = new QLabel(this); - label->setPixmap(pix); - layout->addWidget(label, 0, Qt::AlignHCenter | Qt::AlignTop); - scrollArea->update(scrollArea->geometry()); + } diff --git a/GScribo/pageswidget.h b/GScribo/pageswidget.h index 3747d20..805deff 100644 --- a/GScribo/pageswidget.h +++ b/GScribo/pageswidget.h @@ -5,8 +5,12 @@ #include <QScrollArea> #include <QVBoxLayout> #include <QListWidget> +#include <QStandardItemModel> #include <QLabel> +#include "itemdelegate.h" +#include "listmodel.h" + class PagesWidget: public QWidget { @@ -14,13 +18,12 @@ class PagesWidget: public: explicit PagesWidget(QWidget *parent = 0); - explicit PagesWidget(QWidgetPrivate &d, QWidget *parent = 0); ~PagesWidget(); void addPicture(const QString& filename, const QPixmap& pixmap); private: - QScrollArea *scrollArea; - QHBoxLayout *layout; + QListView *listView; + ListModel *model; QStringList *filenames; }; diff --git a/MVC/MVC.pro b/MVC/MVC.pro new file mode 100644 index 0000000..1a4d48c --- /dev/null +++ b/MVC/MVC.pro @@ -0,0 +1,13 @@ +# ------------------------------------------------- +# Project created by QtCreator 2013-01-22T16:00:23 +# ------------------------------------------------- +TARGET = MVC +TEMPLATE = app +SOURCES += main.cpp \ + mainwindow.cpp \ + itemdelegate.cpp \ + listmodel.cpp +HEADERS += mainwindow.h \ + listmodel.h \ + itemdelegate.h +FORMS += mainwindow.ui diff --git a/TestInterface/GScribo.pro.user b/MVC/MVC.pro.user similarity index 87% copy from TestInterface/GScribo.pro.user copy to MVC/MVC.pro.user index 4b00d43..c8ef164 100644 --- a/TestInterface/GScribo.pro.user +++ b/MVC/MVC.pro.user @@ -10,11 +10,11 @@ </data> <data> <variable>RunConfiguration0-ProFile</variable> - <value type="QString">GScribo.pro</value> + <value type="QString">MVC.pro</value> </data> <data> <variable>RunConfiguration0-RunConfiguration.name</variable> - <value type="QString">GScribo</value> + <value type="QString">MVC</value> </data> <data> <variable>RunConfiguration0-UseDyldImageSuffix</variable> @@ -76,14 +76,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-dwXmVzGpRA,guid=2e4bb3ce70c39fa5e5288771006655e3</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-sncykruQ0C,guid=e454b1a02a95fc6454d7a56d0067ee2b</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-9aAGCJ</value> - <value type="QString">GNOME_KEYRING_PID=19876</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-8ccgXN</value> + <value type="QString">GNOME_KEYRING_PID=30769</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -91,20 +91,20 @@ <value type="QString">LOGNAME=froger_a</value> <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/MVC</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=19951</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-kVrax19885/agent.19885</value> + <value type="QString">SSH_AGENT_PID=30844</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gtQAz30778/agent.30778</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm0ICXQW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm3KFZQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358754471.558659-246518931</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358858991.561353-1070905078</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -112,7 +112,7 @@ <value type="QString">_=/usr/bin/qtcreator</value> </valuelist> <valuelist key="abstractProcess.arguments" type="QVariantList"> - <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo/GScribo.pro</value> + <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/MVC/MVC.pro</value> <value type="QString">-spec</value> <value type="QString">linux-g++</value> <value type="QString">-r</value> @@ -120,7 +120,7 @@ </valuelist> <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value> <value key="abstractProcess.enabled" type="bool">false</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/MVC</value> </valuemap> </data> <data> @@ -128,14 +128,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-dwXmVzGpRA,guid=2e4bb3ce70c39fa5e5288771006655e3</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-sncykruQ0C,guid=e454b1a02a95fc6454d7a56d0067ee2b</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-9aAGCJ</value> - <value type="QString">GNOME_KEYRING_PID=19876</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-8ccgXN</value> + <value type="QString">GNOME_KEYRING_PID=30769</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -143,20 +143,20 @@ <value type="QString">LOGNAME=froger_a</value> <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/MVC</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=19951</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-kVrax19885/agent.19885</value> + <value type="QString">SSH_AGENT_PID=30844</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-gtQAz30778/agent.30778</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm0ICXQW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm3KFZQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358754471.558659-246518931</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358858991.561353-1070905078</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -169,7 +169,7 @@ </valuelist> <value key="abstractProcess.command" type="QString">/usr/bin/make</value> <value key="abstractProcess.enabled" type="bool">true</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/MVC</value> </valuemap> </data> <data> diff --git a/MVC/itemdelegate.cpp b/MVC/itemdelegate.cpp new file mode 100644 index 0000000..c241e1e --- /dev/null +++ b/MVC/itemdelegate.cpp @@ -0,0 +1,19 @@ +#include "itemdelegate.h" + +ItemDelegate::ItemDelegate(QWidget *parent): + QAbstractItemDelegate(parent) +{ +} + +void ItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + QString path = index.model()->data(index, Qt::DecorationRole).toString(); + QPixmap pixmap(path); + + painter->drawPixmap(0, index.row() * 210, 200, 200, pixmap); +} + +QSize ItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const +{ + return QSize(200, 200); +} diff --git a/MVC/itemdelegate.h b/MVC/itemdelegate.h new file mode 100644 index 0000000..1c653d5 --- /dev/null +++ b/MVC/itemdelegate.h @@ -0,0 +1,17 @@ +#ifndef ITEMDELEGATE_H +#define ITEMDELEGATE_H + +#include <QItemDelegate> +#include <QLabel> +#include <QPainter> + +class ItemDelegate: + public QAbstractItemDelegate +{ + public: + explicit ItemDelegate(QWidget *parent = 0); + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const; +}; + +#endif // ITEMDELEGATE_H diff --git a/MVC/listmodel.cpp b/MVC/listmodel.cpp new file mode 100644 index 0000000..709853e --- /dev/null +++ b/MVC/listmodel.cpp @@ -0,0 +1,32 @@ +#include "listmodel.h" + +ListModel::ListModel(QStringList list, QObject *parent): + QAbstractListModel(parent) +{ + this->list = list; +} + +ListModel::~ListModel() +{ +} + +int ListModel::rowCount(const QModelIndex &/*parent*/) const +{ + return list.count(); +} + +QVariant ListModel::data(const QModelIndex &index, int role) const +{ + if(index.isValid() && index.row() < list.size() && role == Qt::DecorationRole) + return list.at(index.row()); + else + return QVariant(); +} + +QVariant ListModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(role != Qt::DecorationRole && orientation == Qt::Horizontal) + return QVariant(); + else + return QString("Row %1").arg(section); +} diff --git a/MVC/listmodel.h b/MVC/listmodel.h new file mode 100644 index 0000000..35ae99c --- /dev/null +++ b/MVC/listmodel.h @@ -0,0 +1,24 @@ +#ifndef LISTMODEL_H +#define LISTMODEL_H + +#include <QAbstractListModel> +#include <QLabel> +#include <QList> + +class ListModel: + public QAbstractListModel +{ + Q_OBJECT + + public: + explicit ListModel(QStringList list, QObject *parent = 0); + ~ListModel(); + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role = Qt::DecorationRole) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DecorationRole) const; + + private: + QStringList list; +}; + +#endif // LISTMODEL_H diff --git a/NotePad/main.cpp b/MVC/main.cpp similarity index 60% copy from NotePad/main.cpp copy to MVC/main.cpp index 137c3a4..ab61e7c 100644 --- a/NotePad/main.cpp +++ b/MVC/main.cpp @@ -1,11 +1,11 @@ #include <QtGui/QApplication> -#include "notepad.h" +#include "mainwindow.h" int main(int argc, char *argv[]) { + QApplication::setGraphicsSystem("raster"); QApplication a(argc, argv); - NotePad w; + MainWindow w; w.show(); - return a.exec(); } diff --git a/MVC/mainwindow.cpp b/MVC/mainwindow.cpp new file mode 100644 index 0000000..72bf823 --- /dev/null +++ b/MVC/mainwindow.cpp @@ -0,0 +1,40 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + QStringList list; + list << "/lrde/home/stage/froger_a/ppm/mp00032c.ppm" << "/lrde/home/stage/froger_a/ppm/mp00042.ppm" << "/lrde/home/stage/froger_a/ppm/mp00076.ppm"; + + QAbstractItemModel *model = new ListModel(list); + + ItemDelegate *delegate = new ItemDelegate(); + + QListView *view = new QListView; + view->setModel(model); + view->setItemDelegate(delegate); + setCentralWidget(view); + view->show(); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) + { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/MVC/mainwindow.h b/MVC/mainwindow.h new file mode 100644 index 0000000..8bf225d --- /dev/null +++ b/MVC/mainwindow.h @@ -0,0 +1,30 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> +#include <QListView> + +#include "itemdelegate.h" +#include "listmodel.h" + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + + public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + + protected: + void changeEvent(QEvent *e); + + private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/MVC/mainwindow.ui b/MVC/mainwindow.ui new file mode 100644 index 0000000..97c03be --- /dev/null +++ b/MVC/mainwindow.ui @@ -0,0 +1,24 @@ +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>600</width> + <height>400</height> + </rect> + </property> + <property name="windowTitle" > + <string>MainWindow</string> + </property> + <widget class="QMenuBar" name="menuBar" /> + <widget class="QToolBar" name="mainToolBar" /> + <widget class="QWidget" name="centralWidget" /> + <widget class="QStatusBar" name="statusBar" /> + </widget> + <layoutDefault spacing="6" margin="11" /> + <pixmapfunction></pixmapfunction> + <resources/> + <connections/> +</ui> -- 1.7.2.5
11Â years, 11Â months
1
0
0
0
347fbf7 Add scribo interface and tests. Block on scroll layout.
by Antoine Froger
--- XmlParser/XmlParser.pro => GScribo/GScribo.pro | 29 ++----- .../GScribo.pro.user | 50 +++++----- XmlParser/configs.h => GScribo/config.h | 0 {XmlParser => GScribo}/dir.h | 0 {XmlParser => GScribo}/main.cpp | 7 +- GScribo/mainwindow.cpp | 97 ++++++++++++++++++++ GScribo/mainwindow.h | 51 ++++++++++ Test/test.ui => GScribo/mainwindow.ui | 38 +++----- GScribo/pageswidget.cpp | 30 ++++++ GScribo/pageswidget.h | 27 ++++++ {XmlParser => GScribo}/polygonitem.cpp | 0 {XmlParser => GScribo}/polygonitem.h | 0 {XmlParser => GScribo}/preprocess.cpp | 0 {XmlParser => GScribo}/preprocess.h | 0 {XmlParser => GScribo}/process.cpp | 0 {XmlParser => GScribo}/process.h | 0 {XmlParser => GScribo}/progressdialog.cpp | 0 {XmlParser => GScribo}/progressdialog.h | 0 {XmlParser => GScribo}/runner.cpp | 0 {XmlParser => GScribo}/runner.h | 0 {XmlParser => GScribo}/scene.cpp | 12 +-- {XmlParser => GScribo}/scene.h | 8 +- {XmlParser => GScribo}/selection.cpp | 4 +- {XmlParser => GScribo}/selection.h | 1 - {XmlParser => GScribo}/xml.cpp | 0 {XmlParser => GScribo}/xml.h | 0 .../XmlParser.pro => TestInterface/GScribo.pro | 31 ++----- .../GScribo.pro.user | 46 +++++----- XmlParser/configs.h => TestInterface/config.h | 0 {XmlParser => TestInterface}/dir.h | 0 {XmlParser => TestInterface}/main.cpp | 9 +- TestInterface/mainwindow.cpp | 75 +++++++++++++++ TestInterface/mainwindow.h | 40 ++++++++ Test/test.ui => TestInterface/mainwindow.ui | 35 ++----- {XmlParser => TestInterface}/polygonitem.cpp | 0 {XmlParser => TestInterface}/polygonitem.h | 0 {XmlParser => TestInterface}/preprocess.cpp | 0 {XmlParser => TestInterface}/preprocess.h | 0 {XmlParser => TestInterface}/process.cpp | 0 {XmlParser => TestInterface}/process.h | 0 {XmlParser => TestInterface}/progressdialog.cpp | 0 {XmlParser => TestInterface}/progressdialog.h | 0 {XmlParser => TestInterface}/runner.cpp | 0 {XmlParser => TestInterface}/runner.h | 0 {XmlParser => TestInterface}/scene.cpp | 10 +-- {XmlParser => TestInterface}/scene.h | 5 +- {XmlParser => TestInterface}/selection.cpp | 2 +- {XmlParser => TestInterface}/selection.h | 1 - {XmlParser => TestInterface}/xml.cpp | 0 {XmlParser => TestInterface}/xml.h | 0 XmlParser/XmlParser.pro | 3 +- XmlParser/XmlParser.pro.user | 36 ++++---- XmlParser/main.cpp | 5 + XmlParser/mainwindow.cpp | 1 + XmlParser/mainwindow.h | 1 + XmlParser/scene.cpp | 2 + 56 files changed, 460 insertions(+), 196 deletions(-) copy XmlParser/XmlParser.pro => GScribo/GScribo.pro (59%) copy XmlParser/XmlParser.pro.user.1.3 => GScribo/GScribo.pro.user (85%) copy XmlParser/configs.h => GScribo/config.h (100%) copy {XmlParser => GScribo}/dir.h (100%) copy {XmlParser => GScribo}/main.cpp (72%) create mode 100644 GScribo/mainwindow.cpp create mode 100644 GScribo/mainwindow.h copy Test/test.ui => GScribo/mainwindow.ui (60%) create mode 100644 GScribo/pageswidget.cpp create mode 100644 GScribo/pageswidget.h copy {XmlParser => GScribo}/polygonitem.cpp (100%) copy {XmlParser => GScribo}/polygonitem.h (100%) copy {XmlParser => GScribo}/preprocess.cpp (100%) copy {XmlParser => GScribo}/preprocess.h (100%) copy {XmlParser => GScribo}/process.cpp (100%) copy {XmlParser => GScribo}/process.h (100%) copy {XmlParser => GScribo}/progressdialog.cpp (100%) copy {XmlParser => GScribo}/progressdialog.h (100%) copy {XmlParser => GScribo}/runner.cpp (100%) copy {XmlParser => GScribo}/runner.h (100%) copy {XmlParser => GScribo}/scene.cpp (86%) copy {XmlParser => GScribo}/scene.h (86%) copy {XmlParser => GScribo}/selection.cpp (88%) copy {XmlParser => GScribo}/selection.h (99%) copy {XmlParser => GScribo}/xml.cpp (100%) copy {XmlParser => GScribo}/xml.h (100%) copy XmlParser/XmlParser.pro => TestInterface/GScribo.pro (55%) copy XmlParser/XmlParser.pro.user.1.3 => TestInterface/GScribo.pro.user (86%) copy XmlParser/configs.h => TestInterface/config.h (100%) copy {XmlParser => TestInterface}/dir.h (100%) copy {XmlParser => TestInterface}/main.cpp (70%) create mode 100644 TestInterface/mainwindow.cpp create mode 100644 TestInterface/mainwindow.h copy Test/test.ui => TestInterface/mainwindow.ui (60%) copy {XmlParser => TestInterface}/polygonitem.cpp (100%) copy {XmlParser => TestInterface}/polygonitem.h (100%) copy {XmlParser => TestInterface}/preprocess.cpp (100%) copy {XmlParser => TestInterface}/preprocess.h (100%) copy {XmlParser => TestInterface}/process.cpp (100%) copy {XmlParser => TestInterface}/process.h (100%) copy {XmlParser => TestInterface}/progressdialog.cpp (100%) copy {XmlParser => TestInterface}/progressdialog.h (100%) copy {XmlParser => TestInterface}/runner.cpp (100%) copy {XmlParser => TestInterface}/runner.h (100%) copy {XmlParser => TestInterface}/scene.cpp (86%) copy {XmlParser => TestInterface}/scene.h (86%) copy {XmlParser => TestInterface}/selection.cpp (96%) copy {XmlParser => TestInterface}/selection.h (99%) copy {XmlParser => TestInterface}/xml.cpp (100%) copy {XmlParser => TestInterface}/xml.h (100%) diff --git a/XmlParser/XmlParser.pro b/GScribo/GScribo.pro similarity index 59% copy from XmlParser/XmlParser.pro copy to GScribo/GScribo.pro index 597fc47..ad4abe0 100644 --- a/XmlParser/XmlParser.pro +++ b/GScribo/GScribo.pro @@ -1,9 +1,8 @@ # ------------------------------------------------- -# Project created by QtCreator 2013-01-11T14:21:43 +# Project created by QtCreator 2013-01-21T09:20:54 # ------------------------------------------------- -QT += xml -TARGET = XmlParser -TEMPLATE = app +QT += opengl \ + xml INCLUDEPATH += /lrde/home/stage/froger_a/olena/milena/ \ /lrde/home/stage/froger_a/olena/scribo/ \ /lrde/home/stage/froger_a/olena/_build/scribo/demo/ @@ -12,29 +11,15 @@ QMAKE_CXXFLAGS += -DNDEBUG \ LIBS += -I/usr/include/graphicsImage \ -lGraphicsMagick++ \ -ltesseract_full +TARGET = GScribo +TEMPLATE = app SOURCES += main.cpp \ mainwindow.cpp \ - xml.cpp \ scene.cpp \ selection.cpp \ - polygonitem.cpp \ - runner.cpp \ - toolbar.cpp \ - process.cpp \ - preprocess.cpp \ - configs.cpp \ - progressdialog.cpp + pageswidget.cpp HEADERS += mainwindow.h \ - region.h \ - xml.h \ scene.h \ selection.h \ - polygonitem.h \ - runner.h \ - toolbar.h \ - process.h \ - preprocess.h \ - configs.h \ - dir.h \ - progressdialog.h + pageswidget.h FORMS += mainwindow.ui diff --git a/XmlParser/XmlParser.pro.user.1.3 b/GScribo/GScribo.pro.user similarity index 85% copy from XmlParser/XmlParser.pro.user.1.3 copy to GScribo/GScribo.pro.user index 29f9b56..6f863ff 100644 --- a/XmlParser/XmlParser.pro.user.1.3 +++ b/GScribo/GScribo.pro.user @@ -10,11 +10,11 @@ </data> <data> <variable>RunConfiguration0-ProFile</variable> - <value type="QString">XmlParser.pro</value> + <value type="QString">GScribo.pro</value> </data> <data> <variable>RunConfiguration0-RunConfiguration.name</variable> - <value type="QString">XmlParser</value> + <value type="QString">GScribo</value> </data> <data> <variable>RunConfiguration0-UseDyldImageSuffix</variable> @@ -76,35 +76,35 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-YjhocK9Z3d,guid=e9e5f2da71aeced554355e6f00596ece</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Si71aPButo,guid=4a5769b30d2b16bfbff191ee00669e72</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-INUHb2</value> - <value type="QString">GNOME_KEYRING_PID=27655</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-xqG91k</value> + <value type="QString">GNOME_KEYRING_PID=24747</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=27730</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-aIvoE27664/agent.27664</value> + <value type="QString">SSH_AGENT_PID=24822</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-ViaPN24756/agent.24756</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmJEZ7QW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmDMHCRW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1357908881.805303-96205090</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358773046.159332-2135577617</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -112,7 +112,7 @@ <value type="QString">_=/usr/bin/qtcreator</value> </valuelist> <valuelist key="abstractProcess.arguments" type="QVariantList"> - <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser/XmlParser.pro</value> + <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo/GScribo.pro</value> <value type="QString">-spec</value> <value type="QString">linux-g++</value> <value type="QString">-r</value> @@ -120,7 +120,7 @@ </valuelist> <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value> <value key="abstractProcess.enabled" type="bool">false</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo</value> </valuemap> </data> <data> @@ -128,35 +128,35 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-YjhocK9Z3d,guid=e9e5f2da71aeced554355e6f00596ece</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-Si71aPButo,guid=4a5769b30d2b16bfbff191ee00669e72</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-INUHb2</value> - <value type="QString">GNOME_KEYRING_PID=27655</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-xqG91k</value> + <value type="QString">GNOME_KEYRING_PID=24747</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=27730</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-aIvoE27664/agent.27664</value> + <value type="QString">SSH_AGENT_PID=24822</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-ViaPN24756/agent.24756</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmJEZ7QW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmDMHCRW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1357908881.805303-96205090</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358773046.159332-2135577617</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -169,7 +169,7 @@ </valuelist> <value key="abstractProcess.command" type="QString">/usr/bin/make</value> <value key="abstractProcess.enabled" type="bool">true</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo</value> </valuemap> </data> <data> diff --git a/XmlParser/configs.h b/GScribo/config.h similarity index 100% copy from XmlParser/configs.h copy to GScribo/config.h diff --git a/XmlParser/dir.h b/GScribo/dir.h similarity index 100% copy from XmlParser/dir.h copy to GScribo/dir.h diff --git a/XmlParser/main.cpp b/GScribo/main.cpp similarity index 72% copy from XmlParser/main.cpp copy to GScribo/main.cpp index aecf5cd..b8f57bd 100644 --- a/XmlParser/main.cpp +++ b/GScribo/main.cpp @@ -1,5 +1,3 @@ -#undef MLN_WO_GLOBAL_VARS - #include <mln/labeling/colorize.hh> #include <mln/math/pi.hh> #include <mln/io/magick/load.hh> @@ -7,11 +5,14 @@ #include <mln/debug/filename.hh> #include <scribo/make/debug_filename.hh> #include <QtGui/QApplication> + #include "mainwindow.h" -int main(int argc, char **argv) +int main(int argc, char *argv[]) { Magick::InitializeMagick(*argv); + //On Linux, we NEED to use the raster graphics system. + //Linux don't really support X11 graphics system (the default one). QApplication::setGraphicsSystem("raster"); QApplication a(argc, argv); MainWindow w; diff --git a/GScribo/mainwindow.cpp b/GScribo/mainwindow.cpp new file mode 100644 index 0000000..4ef2aa1 --- /dev/null +++ b/GScribo/mainwindow.cpp @@ -0,0 +1,97 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + initGraphicsRegion(); + initTextRegion(); + initTablePage(); + initToolBar(); +} + +MainWindow::~MainWindow() +{ + delete dockText; + delete dockPages; + delete scene; + delete graphicsView; + delete textEdit; + delete ui; +} + +void MainWindow::initGraphicsRegion() +{ + graphicsView = new QGraphicsView; + // Cache backgroud to speed up its repaint. + graphicsView->setCacheMode(QGraphicsView::CacheBackground); + graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); + + scene = new Scene(); + // Disable scroll bar extend with a non-null rectangle. + scene->setSceneRect(0, 0, 0, 1); + graphicsView->setScene(scene); + + setCentralWidget(graphicsView); +} + +void MainWindow::initTablePage() +{ + dockPages = new QDockWidget(tr("Pages")); + dockPages->setAllowedAreas(Qt::AllDockWidgetAreas); + dockPages->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable); + + pagesWidget = new PagesWidget; + dockPages->setWidget(pagesWidget); + + addDockWidget(Qt::LeftDockWidgetArea, dockPages); +} + +void MainWindow::initTextRegion() +{ + dockText = new QDockWidget(tr("Previsualization")); + dockText->setAllowedAreas(Qt::AllDockWidgetAreas); + dockText->setFeatures(QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetMovable); + + textEdit = new QPlainTextEdit; + dockText->setWidget(textEdit); + + addDockWidget(Qt::RightDockWidgetArea, dockText); + dockText->hide(); +} + +void MainWindow::initToolBar() +{ + QAction *open = ui->mainToolBar->addAction(tr("Open")); + connect(open, SIGNAL(triggered()), this, SLOT(onOpen())); +} + +void MainWindow::onOpen() +{ + QString path = QFileDialog::getOpenFileName(this); + if(path != "") + { + QPixmap pixmap(path); + + scene->setSceneRect(pixmap.rect()); + scene->setBackgroundBrush(QBrush(pixmap)); + + pagesWidget->addPicture(path, pixmap); + } +} + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) + { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/GScribo/mainwindow.h b/GScribo/mainwindow.h new file mode 100644 index 0000000..aa80b72 --- /dev/null +++ b/GScribo/mainwindow.h @@ -0,0 +1,51 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> +#include <QHBoxLayout> +#include <QDockWidget> +#include <QGraphicsView> +#include <QGLWidget> +#include <QPlainTextEdit> +#include <QGroupBox> +#include <QFileDialog> + +#include "scene.h" +#include "pageswidget.h" + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + + public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + + protected: + void changeEvent(QEvent *e); + + private: + void initGraphicsRegion(); + void initTextRegion(); + void initToolBar(); + void initTablePage(); + + Ui::MainWindow *ui; + QDockWidget *dockText; + QDockWidget *dockPages; + Scene *scene; + QGraphicsView *graphicsView; + QPlainTextEdit *textEdit; + PagesWidget *pagesWidget; + QString imagePath; + + private slots: + void onOpen(); +}; + +#endif // MAINWINDOW_H diff --git a/Test/test.ui b/GScribo/mainwindow.ui similarity index 60% copy from Test/test.ui copy to GScribo/mainwindow.ui index 5fb0299..3a174ec 100644 --- a/Test/test.ui +++ b/GScribo/mainwindow.ui @@ -1,57 +1,45 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>Test</class> - <widget class="QMainWindow" name="Test"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>919</width> - <height>562</height> + <width>671</width> + <height>436</height> </rect> </property> <property name="windowTitle"> - <string>Test</string> + <string>MainWindow</string> </property> <widget class="QWidget" name="centralWidget"> - <widget class="QLabel" name="label"> - <property name="geometry"> - <rect> - <x>250</x> - <y>130</y> - <width>341</width> - <height>181</height> - </rect> - </property> - <property name="text"> - <string/> - </property> - </widget> + <property name="enabled"> + <bool>true</bool> + </property> </widget> <widget class="QMenuBar" name="menuBar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>919</width> + <width>671</width> <height>23</height> </rect> </property> </widget> <widget class="QToolBar" name="mainToolBar"> + <property name="floatable"> + <bool>false</bool> + </property> <attribute name="toolBarArea"> <enum>TopToolBarArea</enum> </attribute> <attribute name="toolBarBreak"> - <bool>true</bool> + <bool>false</bool> </attribute> </widget> <widget class="QStatusBar" name="statusBar"/> - <action name="actionLoad"> - <property name="text"> - <string>Load</string> - </property> - </action> </widget> <layoutdefault spacing="6" margin="11"/> <resources/> diff --git a/GScribo/pageswidget.cpp b/GScribo/pageswidget.cpp new file mode 100644 index 0000000..2f23d9d --- /dev/null +++ b/GScribo/pageswidget.cpp @@ -0,0 +1,30 @@ +#include "pageswidget.h" + +PagesWidget::PagesWidget(QWidget *parent): + QWidget(parent) +{ + filenames = new QStringList; + scrollArea = new QScrollArea(this); + scrollArea->setGeometry(0, 0, 1000, 1000); + layout = new QHBoxLayout; + QWidget *widget = new QWidget; + widget->setLayout(layout); + scrollArea->setWidget(widget); +} + +PagesWidget::~PagesWidget() +{ + delete filenames; + delete layout; + delete scrollArea; +} + +void PagesWidget::addPicture(const QString& filename, const QPixmap& pixmap) +{ + *filenames << filename; + QPixmap pix = pixmap.scaled(100, 100, Qt::IgnoreAspectRatio); + QLabel *label = new QLabel(this); + label->setPixmap(pix); + layout->addWidget(label, 0, Qt::AlignHCenter | Qt::AlignTop); + scrollArea->update(scrollArea->geometry()); +} diff --git a/GScribo/pageswidget.h b/GScribo/pageswidget.h new file mode 100644 index 0000000..3747d20 --- /dev/null +++ b/GScribo/pageswidget.h @@ -0,0 +1,27 @@ +#ifndef PAGESWIDGET_H +#define PAGESWIDGET_H + +#include <QWidget> +#include <QScrollArea> +#include <QVBoxLayout> +#include <QListWidget> +#include <QLabel> + +class PagesWidget: + public QWidget +{ + Q_OBJECT + + public: + explicit PagesWidget(QWidget *parent = 0); + explicit PagesWidget(QWidgetPrivate &d, QWidget *parent = 0); + ~PagesWidget(); + void addPicture(const QString& filename, const QPixmap& pixmap); + + private: + QScrollArea *scrollArea; + QHBoxLayout *layout; + QStringList *filenames; +}; + +#endif // PAGESWIDGET_H diff --git a/XmlParser/polygonitem.cpp b/GScribo/polygonitem.cpp similarity index 100% copy from XmlParser/polygonitem.cpp copy to GScribo/polygonitem.cpp diff --git a/XmlParser/polygonitem.h b/GScribo/polygonitem.h similarity index 100% copy from XmlParser/polygonitem.h copy to GScribo/polygonitem.h diff --git a/XmlParser/preprocess.cpp b/GScribo/preprocess.cpp similarity index 100% copy from XmlParser/preprocess.cpp copy to GScribo/preprocess.cpp diff --git a/XmlParser/preprocess.h b/GScribo/preprocess.h similarity index 100% copy from XmlParser/preprocess.h copy to GScribo/preprocess.h diff --git a/XmlParser/process.cpp b/GScribo/process.cpp similarity index 100% copy from XmlParser/process.cpp copy to GScribo/process.cpp diff --git a/XmlParser/process.h b/GScribo/process.h similarity index 100% copy from XmlParser/process.h copy to GScribo/process.h diff --git a/XmlParser/progressdialog.cpp b/GScribo/progressdialog.cpp similarity index 100% copy from XmlParser/progressdialog.cpp copy to GScribo/progressdialog.cpp diff --git a/XmlParser/progressdialog.h b/GScribo/progressdialog.h similarity index 100% copy from XmlParser/progressdialog.h copy to GScribo/progressdialog.h diff --git a/XmlParser/runner.cpp b/GScribo/runner.cpp similarity index 100% copy from XmlParser/runner.cpp copy to GScribo/runner.cpp diff --git a/XmlParser/runner.h b/GScribo/runner.h similarity index 100% copy from XmlParser/runner.h copy to GScribo/runner.h diff --git a/XmlParser/scene.cpp b/GScribo/scene.cpp similarity index 86% copy from XmlParser/scene.cpp copy to GScribo/scene.cpp index 612d2bd..ee2007a 100644 --- a/XmlParser/scene.cpp +++ b/GScribo/scene.cpp @@ -28,7 +28,7 @@ void Scene::init() isPressing = false; clic = false; selection = new Selection(this); -} +} void Scene::removeItems() { @@ -48,6 +48,7 @@ void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) isPressing = true; clic = true; pressPos = event->scenePos(); + selection->show(); } } @@ -74,13 +75,8 @@ void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) isPressing = false; if(clic) selection->setRect(QRectF(QPointF(0, 0), event->scenePos())); - emit repaintItems(selection->rect(), clic); + emit repaintItem(selection->rect(), clic); selection->setRect(0, 0, 0, 0); + selection->hide(); } } - -QString Scene::debug(QRect &rect) -{ - return "Position : " + QString::number(rect.x()) + ", " + QString::number(rect.y()) + "\n" + - "Size : " + QString::number(rect.width()) + ", " + QString::number(rect.height()); -} diff --git a/XmlParser/scene.h b/GScribo/scene.h similarity index 86% copy from XmlParser/scene.h copy to GScribo/scene.h index b7294c6..86ca8c7 100644 --- a/XmlParser/scene.h +++ b/GScribo/scene.h @@ -1,8 +1,10 @@ #ifndef SCENE_H #define SCENE_H +#include <QFileDialog> #include <QGraphicsScene> #include <QGraphicsSceneMouseEvent> + #include "selection.h" #include "polygonitem.h" @@ -25,7 +27,6 @@ class Scene : private: void init(); - QString debug(QRect &rect); Selection *selection; QPointF pressPos; @@ -33,8 +34,7 @@ class Scene : bool clic; signals: - void repaintItems(const QRectF& rect, bool clic); - void sendString(QString& string); -}; + void repaintItem(const QRectF& rect, bool clic); + }; #endif // SCENE_H diff --git a/XmlParser/selection.cpp b/GScribo/selection.cpp similarity index 88% copy from XmlParser/selection.cpp copy to GScribo/selection.cpp index 51e3fe5..6020312 100644 --- a/XmlParser/selection.cpp +++ b/GScribo/selection.cpp @@ -24,10 +24,10 @@ void Selection::init() QPen pen; pen.setStyle(Qt::DashLine); pen.setCapStyle(Qt::SquareCap); - pen.setWidth(1); + pen.setCosmetic(true); setPen(pen); QBrush brush; brush.setStyle(Qt::Dense4Pattern); - brush.setColor(QColor::fromRgb(100, 200, 60, 100)); + brush.setColor(QColor::fromRgb(80, 200, 10, 100)); setBrush(brush); } diff --git a/XmlParser/selection.h b/GScribo/selection.h similarity index 99% copy from XmlParser/selection.h copy to GScribo/selection.h index dad1038..4864e15 100644 --- a/XmlParser/selection.h +++ b/GScribo/selection.h @@ -5,7 +5,6 @@ #include <QPen> #include <climits> - class Selection : public QGraphicsRectItem { diff --git a/XmlParser/xml.cpp b/GScribo/xml.cpp similarity index 100% copy from XmlParser/xml.cpp copy to GScribo/xml.cpp diff --git a/XmlParser/xml.h b/GScribo/xml.h similarity index 100% copy from XmlParser/xml.h copy to GScribo/xml.h diff --git a/XmlParser/XmlParser.pro b/TestInterface/GScribo.pro similarity index 55% copy from XmlParser/XmlParser.pro copy to TestInterface/GScribo.pro index 597fc47..db83ffa 100644 --- a/XmlParser/XmlParser.pro +++ b/TestInterface/GScribo.pro @@ -1,9 +1,8 @@ # ------------------------------------------------- -# Project created by QtCreator 2013-01-11T14:21:43 +# Project created by QtCreator 2013-01-21T09:20:54 # ------------------------------------------------- -QT += xml -TARGET = XmlParser -TEMPLATE = app +QT += opengl \ + xml INCLUDEPATH += /lrde/home/stage/froger_a/olena/milena/ \ /lrde/home/stage/froger_a/olena/scribo/ \ /lrde/home/stage/froger_a/olena/_build/scribo/demo/ @@ -12,29 +11,13 @@ QMAKE_CXXFLAGS += -DNDEBUG \ LIBS += -I/usr/include/graphicsImage \ -lGraphicsMagick++ \ -ltesseract_full +TARGET = GScribo +TEMPLATE = app SOURCES += main.cpp \ mainwindow.cpp \ - xml.cpp \ scene.cpp \ - selection.cpp \ - polygonitem.cpp \ - runner.cpp \ - toolbar.cpp \ - process.cpp \ - preprocess.cpp \ - configs.cpp \ - progressdialog.cpp + selection.cpp HEADERS += mainwindow.h \ - region.h \ - xml.h \ scene.h \ - selection.h \ - polygonitem.h \ - runner.h \ - toolbar.h \ - process.h \ - preprocess.h \ - configs.h \ - dir.h \ - progressdialog.h + selection.h FORMS += mainwindow.ui diff --git a/XmlParser/XmlParser.pro.user.1.3 b/TestInterface/GScribo.pro.user similarity index 86% copy from XmlParser/XmlParser.pro.user.1.3 copy to TestInterface/GScribo.pro.user index 29f9b56..4b00d43 100644 --- a/XmlParser/XmlParser.pro.user.1.3 +++ b/TestInterface/GScribo.pro.user @@ -10,11 +10,11 @@ </data> <data> <variable>RunConfiguration0-ProFile</variable> - <value type="QString">XmlParser.pro</value> + <value type="QString">GScribo.pro</value> </data> <data> <variable>RunConfiguration0-RunConfiguration.name</variable> - <value type="QString">XmlParser</value> + <value type="QString">GScribo</value> </data> <data> <variable>RunConfiguration0-UseDyldImageSuffix</variable> @@ -76,14 +76,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-YjhocK9Z3d,guid=e9e5f2da71aeced554355e6f00596ece</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-dwXmVzGpRA,guid=2e4bb3ce70c39fa5e5288771006655e3</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-INUHb2</value> - <value type="QString">GNOME_KEYRING_PID=27655</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-9aAGCJ</value> + <value type="QString">GNOME_KEYRING_PID=19876</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -91,20 +91,20 @@ <value type="QString">LOGNAME=froger_a</value> <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=27730</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-aIvoE27664/agent.27664</value> + <value type="QString">SSH_AGENT_PID=19951</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-kVrax19885/agent.19885</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmJEZ7QW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm0ICXQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1357908881.805303-96205090</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358754471.558659-246518931</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -112,7 +112,7 @@ <value type="QString">_=/usr/bin/qtcreator</value> </valuelist> <valuelist key="abstractProcess.arguments" type="QVariantList"> - <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser/XmlParser.pro</value> + <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo/GScribo.pro</value> <value type="QString">-spec</value> <value type="QString">linux-g++</value> <value type="QString">-r</value> @@ -120,7 +120,7 @@ </valuelist> <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value> <value key="abstractProcess.enabled" type="bool">false</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo</value> </valuemap> </data> <data> @@ -128,14 +128,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-YjhocK9Z3d,guid=e9e5f2da71aeced554355e6f00596ece</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-dwXmVzGpRA,guid=2e4bb3ce70c39fa5e5288771006655e3</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-INUHb2</value> - <value type="QString">GNOME_KEYRING_PID=27655</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-9aAGCJ</value> + <value type="QString">GNOME_KEYRING_PID=19876</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -143,20 +143,20 @@ <value type="QString">LOGNAME=froger_a</value> <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> - <value type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/GScribo</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=27730</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-aIvoE27664/agent.27664</value> + <value type="QString">SSH_AGENT_PID=19951</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-kVrax19885/agent.19885</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmJEZ7QW</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm0ICXQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1357908881.805303-96205090</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358754471.558659-246518931</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -169,7 +169,7 @@ </valuelist> <value key="abstractProcess.command" type="QString">/usr/bin/make</value> <value key="abstractProcess.enabled" type="bool">true</value> - <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/GScribo</value> </valuemap> </data> <data> diff --git a/XmlParser/configs.h b/TestInterface/config.h similarity index 100% copy from XmlParser/configs.h copy to TestInterface/config.h diff --git a/XmlParser/dir.h b/TestInterface/dir.h similarity index 100% copy from XmlParser/dir.h copy to TestInterface/dir.h diff --git a/XmlParser/main.cpp b/TestInterface/main.cpp similarity index 70% copy from XmlParser/main.cpp copy to TestInterface/main.cpp index aecf5cd..4636dff 100644 --- a/XmlParser/main.cpp +++ b/TestInterface/main.cpp @@ -1,5 +1,3 @@ -#undef MLN_WO_GLOBAL_VARS - #include <mln/labeling/colorize.hh> #include <mln/math/pi.hh> #include <mln/io/magick/load.hh> @@ -7,11 +5,16 @@ #include <mln/debug/filename.hh> #include <scribo/make/debug_filename.hh> #include <QtGui/QApplication> + #include "mainwindow.h" -int main(int argc, char **argv) +int main(int argc, char *argv[]) { Magick::InitializeMagick(*argv); + /* + On Linux, we NEED to use the raster graphics system. + Linux don't really support X11 graphics system (the default one). + */ QApplication::setGraphicsSystem("raster"); QApplication a(argc, argv); MainWindow w; diff --git a/TestInterface/mainwindow.cpp b/TestInterface/mainwindow.cpp new file mode 100644 index 0000000..89634e3 --- /dev/null +++ b/TestInterface/mainwindow.cpp @@ -0,0 +1,75 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); + + + /* Central window to adjust all widgets's size inside it. */ + QWidget *window = new QWidget(); + QHBoxLayout *mainLayout = new QHBoxLayout(window); + mainLayout->setSpacing(8); + setCentralWidget(window); + // + + initGraphicsRegion(window, mainLayout); + initTextRegion(window, mainLayout); +} + +MainWindow::~MainWindow() +{ + delete scene; + delete graphicsView; + delete textEdit; + delete ui; +} + +void MainWindow::initGraphicsRegion(QWidget *parent, QLayout *layout) +{ + QGroupBox *graphicsBox = new QGroupBox(tr("Image"), parent); + graphicsBox->setFlat(true); + graphicsBox->setAlignment(Qt::AlignHCenter); + + graphicsView = new QGraphicsView(); + // Cache backgroud to speed up its repaint. + graphicsView->setCacheMode(QGraphicsView::CacheBackground); + graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); + + scene = new Scene(); + // Disable scroll bar extend with a non-null rectangle. + scene->setSceneRect(0, 0, 0, 1); + graphicsView->setScene(scene); + + QHBoxLayout *graphicsLayout = new QHBoxLayout(graphicsBox); + graphicsLayout->addWidget(graphicsView); + layout->addWidget(graphicsBox); +} + +void MainWindow::initTextRegion(QWidget *parent, QLayout *layout) +{ + QGroupBox *textBox = new QGroupBox(tr("Previsualization"), parent); + textBox->setFlat(true); + textBox->setAlignment(Qt::AlignHCenter); + + textEdit = new QPlainTextEdit(textBox); + + QHBoxLayout *textLayout = new QHBoxLayout(textBox); + textLayout->addWidget(textEdit); + layout->addWidget(textBox); +} + +void MainWindow::changeEvent(QEvent *e) +{ + QMainWindow::changeEvent(e); + switch (e->type()) + { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/TestInterface/mainwindow.h b/TestInterface/mainwindow.h new file mode 100644 index 0000000..b4728ad --- /dev/null +++ b/TestInterface/mainwindow.h @@ -0,0 +1,40 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include <QMainWindow> +#include <QHBoxLayout> +#include <QDockWidget> +#include <QGraphicsView> +#include <QGLWidget> +#include <QPlainTextEdit> +#include <QGroupBox> + +#include "scene.h" + +namespace Ui +{ + class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + + public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); + + protected: + void changeEvent(QEvent *e); + + private: + void initGraphicsRegion(QWidget *parent, QLayout *layout); + void initTextRegion(QWidget *parent, QLayout *layout); + + Ui::MainWindow *ui; + Scene *scene; + QGraphicsView *graphicsView; + QPlainTextEdit *textEdit; +}; + +#endif // MAINWINDOW_H diff --git a/Test/test.ui b/TestInterface/mainwindow.ui similarity index 60% copy from Test/test.ui copy to TestInterface/mainwindow.ui index 5fb0299..0c25302 100644 --- a/Test/test.ui +++ b/TestInterface/mainwindow.ui @@ -1,39 +1,29 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>Test</class> - <widget class="QMainWindow" name="Test"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>919</width> - <height>562</height> + <width>600</width> + <height>400</height> </rect> </property> <property name="windowTitle"> - <string>Test</string> + <string>MainWindow</string> </property> <widget class="QWidget" name="centralWidget"> - <widget class="QLabel" name="label"> - <property name="geometry"> - <rect> - <x>250</x> - <y>130</y> - <width>341</width> - <height>181</height> - </rect> - </property> - <property name="text"> - <string/> - </property> - </widget> + <property name="enabled"> + <bool>true</bool> + </property> </widget> <widget class="QMenuBar" name="menuBar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>919</width> + <width>600</width> <height>23</height> </rect> </property> @@ -43,15 +33,10 @@ <enum>TopToolBarArea</enum> </attribute> <attribute name="toolBarBreak"> - <bool>true</bool> + <bool>false</bool> </attribute> </widget> <widget class="QStatusBar" name="statusBar"/> - <action name="actionLoad"> - <property name="text"> - <string>Load</string> - </property> - </action> </widget> <layoutdefault spacing="6" margin="11"/> <resources/> diff --git a/XmlParser/polygonitem.cpp b/TestInterface/polygonitem.cpp similarity index 100% copy from XmlParser/polygonitem.cpp copy to TestInterface/polygonitem.cpp diff --git a/XmlParser/polygonitem.h b/TestInterface/polygonitem.h similarity index 100% copy from XmlParser/polygonitem.h copy to TestInterface/polygonitem.h diff --git a/XmlParser/preprocess.cpp b/TestInterface/preprocess.cpp similarity index 100% copy from XmlParser/preprocess.cpp copy to TestInterface/preprocess.cpp diff --git a/XmlParser/preprocess.h b/TestInterface/preprocess.h similarity index 100% copy from XmlParser/preprocess.h copy to TestInterface/preprocess.h diff --git a/XmlParser/process.cpp b/TestInterface/process.cpp similarity index 100% copy from XmlParser/process.cpp copy to TestInterface/process.cpp diff --git a/XmlParser/process.h b/TestInterface/process.h similarity index 100% copy from XmlParser/process.h copy to TestInterface/process.h diff --git a/XmlParser/progressdialog.cpp b/TestInterface/progressdialog.cpp similarity index 100% copy from XmlParser/progressdialog.cpp copy to TestInterface/progressdialog.cpp diff --git a/XmlParser/progressdialog.h b/TestInterface/progressdialog.h similarity index 100% copy from XmlParser/progressdialog.h copy to TestInterface/progressdialog.h diff --git a/XmlParser/runner.cpp b/TestInterface/runner.cpp similarity index 100% copy from XmlParser/runner.cpp copy to TestInterface/runner.cpp diff --git a/XmlParser/runner.h b/TestInterface/runner.h similarity index 100% copy from XmlParser/runner.h copy to TestInterface/runner.h diff --git a/XmlParser/scene.cpp b/TestInterface/scene.cpp similarity index 86% copy from XmlParser/scene.cpp copy to TestInterface/scene.cpp index 612d2bd..d65b85a 100644 --- a/XmlParser/scene.cpp +++ b/TestInterface/scene.cpp @@ -48,6 +48,7 @@ void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) isPressing = true; clic = true; pressPos = event->scenePos(); + selection->show(); } } @@ -74,13 +75,8 @@ void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) isPressing = false; if(clic) selection->setRect(QRectF(QPointF(0, 0), event->scenePos())); - emit repaintItems(selection->rect(), clic); + emit repaintItem(selection->rect(), clic); selection->setRect(0, 0, 0, 0); + selection->hide(); } } - -QString Scene::debug(QRect &rect) -{ - return "Position : " + QString::number(rect.x()) + ", " + QString::number(rect.y()) + "\n" + - "Size : " + QString::number(rect.width()) + ", " + QString::number(rect.height()); -} diff --git a/XmlParser/scene.h b/TestInterface/scene.h similarity index 86% copy from XmlParser/scene.h copy to TestInterface/scene.h index b7294c6..0560cbd 100644 --- a/XmlParser/scene.h +++ b/TestInterface/scene.h @@ -3,6 +3,7 @@ #include <QGraphicsScene> #include <QGraphicsSceneMouseEvent> + #include "selection.h" #include "polygonitem.h" @@ -25,7 +26,6 @@ class Scene : private: void init(); - QString debug(QRect &rect); Selection *selection; QPointF pressPos; @@ -33,8 +33,7 @@ class Scene : bool clic; signals: - void repaintItems(const QRectF& rect, bool clic); - void sendString(QString& string); + void repaintItem(const QRectF& rect, bool clic); }; #endif // SCENE_H diff --git a/XmlParser/selection.cpp b/TestInterface/selection.cpp similarity index 96% copy from XmlParser/selection.cpp copy to TestInterface/selection.cpp index 51e3fe5..1f696ce 100644 --- a/XmlParser/selection.cpp +++ b/TestInterface/selection.cpp @@ -24,7 +24,7 @@ void Selection::init() QPen pen; pen.setStyle(Qt::DashLine); pen.setCapStyle(Qt::SquareCap); - pen.setWidth(1); + pen.setCosmetic(true); setPen(pen); QBrush brush; brush.setStyle(Qt::Dense4Pattern); diff --git a/XmlParser/selection.h b/TestInterface/selection.h similarity index 99% copy from XmlParser/selection.h copy to TestInterface/selection.h index dad1038..4864e15 100644 --- a/XmlParser/selection.h +++ b/TestInterface/selection.h @@ -5,7 +5,6 @@ #include <QPen> #include <climits> - class Selection : public QGraphicsRectItem { diff --git a/XmlParser/xml.cpp b/TestInterface/xml.cpp similarity index 100% copy from XmlParser/xml.cpp copy to TestInterface/xml.cpp diff --git a/XmlParser/xml.h b/TestInterface/xml.h similarity index 100% copy from XmlParser/xml.h copy to TestInterface/xml.h diff --git a/XmlParser/XmlParser.pro b/XmlParser/XmlParser.pro index 597fc47..e673c8e 100644 --- a/XmlParser/XmlParser.pro +++ b/XmlParser/XmlParser.pro @@ -1,7 +1,8 @@ # ------------------------------------------------- # Project created by QtCreator 2013-01-11T14:21:43 # ------------------------------------------------- -QT += xml +QT += xml \ + opengl TARGET = XmlParser TEMPLATE = app INCLUDEPATH += /lrde/home/stage/froger_a/olena/milena/ \ diff --git a/XmlParser/XmlParser.pro.user b/XmlParser/XmlParser.pro.user index 9eea455..4041e71 100644 --- a/XmlParser/XmlParser.pro.user +++ b/XmlParser/XmlParser.pro.user @@ -188,14 +188,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-E5D7SPzCvM,guid=d599357c9b4b11459397a7040062a9e9</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-dwXmVzGpRA,guid=2e4bb3ce70c39fa5e5288771006655e3</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-IhfkdE</value> - <value type="QString">GNOME_KEYRING_PID=8615</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-9aAGCJ</value> + <value type="QString">GNOME_KEYRING_PID=19876</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -207,16 +207,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=8690</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-znXRds8624/agent.8624</value> + <value type="QString">SSH_AGENT_PID=19951</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-kVrax19885/agent.19885</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=16777252</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmLS4BRW</value> + <value type="QString">WINDOWID=10485796</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm0ICXQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358513837.420735-2094239602</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358754471.558659-246518931</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -239,14 +239,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-E5D7SPzCvM,guid=d599357c9b4b11459397a7040062a9e9</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-dwXmVzGpRA,guid=2e4bb3ce70c39fa5e5288771006655e3</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-IhfkdE</value> - <value type="QString">GNOME_KEYRING_PID=8615</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-9aAGCJ</value> + <value type="QString">GNOME_KEYRING_PID=19876</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -258,16 +258,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=8690</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-znXRds8624/agent.8624</value> + <value type="QString">SSH_AGENT_PID=19951</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-kVrax19885/agent.19885</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=16777252</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmLS4BRW</value> + <value type="QString">WINDOWID=10485796</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm0ICXQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358513837.420735-2094239602</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358754471.558659-246518931</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> diff --git a/XmlParser/main.cpp b/XmlParser/main.cpp index aecf5cd..f9678ac 100644 --- a/XmlParser/main.cpp +++ b/XmlParser/main.cpp @@ -12,6 +12,11 @@ int main(int argc, char **argv) { Magick::InitializeMagick(*argv); + /******************************************************************* + On Linux, we NEED to use the raster graphics system. + Linux don't really support X11 graphics system (the default one). + VERY IMPORTANT. + ********************************************************************/ QApplication::setGraphicsSystem("raster"); QApplication a(argc, argv); MainWindow w; diff --git a/XmlParser/mainwindow.cpp b/XmlParser/mainwindow.cpp index a9415cf..323b74a 100644 --- a/XmlParser/mainwindow.cpp +++ b/XmlParser/mainwindow.cpp @@ -10,6 +10,7 @@ MainWindow::MainWindow(QWidget *parent): QVBoxLayout *gBLayout = new QVBoxLayout; gBLayout->addWidget(ui->graphicsView); ui->groupBox->setLayout(gBLayout); + // Cache the background for repaint optimization. ui->graphicsView->setCacheMode(QGraphicsView::CacheBackground); scene = new Scene(ui->graphicsView); scene->setSceneRect(ui->graphicsView->geometry()); diff --git a/XmlParser/mainwindow.h b/XmlParser/mainwindow.h index e8e899a..f6c7fb5 100644 --- a/XmlParser/mainwindow.h +++ b/XmlParser/mainwindow.h @@ -6,6 +6,7 @@ #include <QVBoxLayout> #include <QFileDialog> #include <QProgressDialog> +#include <QGLWidget> #include "scene.h" #include "toolbar.h" #include "xml.h" diff --git a/XmlParser/scene.cpp b/XmlParser/scene.cpp index 612d2bd..1d8aaf6 100644 --- a/XmlParser/scene.cpp +++ b/XmlParser/scene.cpp @@ -48,6 +48,7 @@ void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) isPressing = true; clic = true; pressPos = event->scenePos(); + selection->show(); } } @@ -76,6 +77,7 @@ void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) selection->setRect(QRectF(QPointF(0, 0), event->scenePos())); emit repaintItems(selection->rect(), clic); selection->setRect(0, 0, 0, 0); + selection->hide(); } } -- 1.7.2.5
11Â years, 11Â months
1
0
0
0
8837bd5 Optimisation, runner works well, add destructors and delete fine.
by Antoine Froger
--- XmlParser/XmlParser.pro | 4 +- XmlParser/XmlParser.pro.user | 135 +++++++++++++++++++++++++++++++++++------- XmlParser/demodir.h | 7 -- XmlParser/main.cpp | 1 + XmlParser/mainwindow.cpp | 24 ++++---- XmlParser/mainwindow.h | 4 +- XmlParser/polygonitem.cpp | 23 ++++---- XmlParser/polygonitem.h | 1 + XmlParser/region.h | 16 +++--- XmlParser/runner.cpp | 8 ++- XmlParser/runner.h | 4 +- XmlParser/scene.cpp | 21 ++++++- XmlParser/scene.h | 2 + XmlParser/toolbar.cpp | 7 ++ XmlParser/toolbar.h | 2 +- XmlParser/xml.cpp | 72 +++++----------------- 16 files changed, 204 insertions(+), 127 deletions(-) delete mode 100644 XmlParser/demodir.h diff --git a/XmlParser/XmlParser.pro b/XmlParser/XmlParser.pro index e65b72a..597fc47 100644 --- a/XmlParser/XmlParser.pro +++ b/XmlParser/XmlParser.pro @@ -5,7 +5,8 @@ QT += xml TARGET = XmlParser TEMPLATE = app INCLUDEPATH += /lrde/home/stage/froger_a/olena/milena/ \ - /lrde/home/stage/froger_a/olena/scribo/ + /lrde/home/stage/froger_a/olena/scribo/ \ + /lrde/home/stage/froger_a/olena/_build/scribo/demo/ QMAKE_CXXFLAGS += -DNDEBUG \ -DMLN_WO_GLOBAL_VARS LIBS += -I/usr/include/graphicsImage \ @@ -31,7 +32,6 @@ HEADERS += mainwindow.h \ polygonitem.h \ runner.h \ toolbar.h \ - demodir.h \ process.h \ preprocess.h \ configs.h \ diff --git a/XmlParser/XmlParser.pro.user b/XmlParser/XmlParser.pro.user index 0b03fae..9eea455 100644 --- a/XmlParser/XmlParser.pro.user +++ b/XmlParser/XmlParser.pro.user @@ -50,7 +50,7 @@ </data> <data> <variable>activebuildconfiguration</variable> - <value type="QString">Debug</value> + <value type="QString">Release</value> </data> <data> <variable>buildConfiguration-Debug</variable> @@ -67,6 +67,7 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> <value key="QtVersionId" type="int">0</value> + <value key="ToolChain" type="int">0</value> <value key="addQDumper" type=""></value> <value key="buildConfiguration" type="int">0</value> </valuemap> @@ -76,35 +77,35 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-jXUCLOmOZn,guid=4585eaa0c02f09d20a77bf8f006153a8</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-TRVg8AHdB1,guid=cba5ba91aecc3f6dfc36295700626000</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-aTERin</value> - <value type="QString">GNOME_KEYRING_PID=8076</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nw18hR</value> + <value type="QString">GNOME_KEYRING_PID=3747</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=8151</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-wrZmtE8085/agent.8085</value> + <value type="QString">SSH_AGENT_PID=3822</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-SkEKXK3756/agent.3756</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm4ATXQW</value> + <value type="QString">WINDOWID=12582948</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmQ2DSQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358426220.205793-1492047644</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358494916.667367-1101742900</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -128,35 +129,35 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-jXUCLOmOZn,guid=4585eaa0c02f09d20a77bf8f006153a8</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-TRVg8AHdB1,guid=cba5ba91aecc3f6dfc36295700626000</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-aTERin</value> - <value type="QString">GNOME_KEYRING_PID=8076</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-nw18hR</value> + <value type="QString">GNOME_KEYRING_PID=3747</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> <value type="QString">LOGNAME=froger_a</value> - <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a</value> <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> <value type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value> <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=8151</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-wrZmtE8085/agent.8085</value> + <value type="QString">SSH_AGENT_PID=3822</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-SkEKXK3756/agent.3756</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm4ATXQW</value> + <value type="QString">WINDOWID=12582948</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmQ2DSQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358426220.205793-1492047644</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358494916.667367-1101742900</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -186,18 +187,110 @@ <variable>buildconfiguration-Release-buildstep0</variable> <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> + <valuelist key="abstractProcess.Environment" type="QVariantList"> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-E5D7SPzCvM,guid=d599357c9b4b11459397a7040062a9e9</value> + <value type="QString">DESKTOP_SESSION=fluxbox</value> + <value type="QString">DISPLAY=:0.0</value> + <value type="QString">GDMSESSION=fluxbox</value> + <value type="QString">GDM_LANG=fr_FR.UTF-8</value> + <value type="QString">GDM_XSERVER_LOCATION=local</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-IhfkdE</value> + <value type="QString">GNOME_KEYRING_PID=8615</value> + <value type="QString">GTK_MODULES=canberra-gtk-module</value> + <value type="QString">HOME=/lrde/home/stage/froger_a</value> + <value type="QString">LANG=fr_FR.UTF-8</value> + <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> + <value type="QString">LOGNAME=froger_a</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> + <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value> + <value type="QString">QTDIR=/usr/share/qt4</value> + <value type="QString">SHELL=/bin/bash</value> + <value type="QString">SHLVL=2</value> + <value type="QString">SSH_AGENT_PID=8690</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-znXRds8624/agent.8624</value> + <value type="QString">TERM=xterm</value> + <value type="QString">USER=froger_a</value> + <value type="QString">USERNAME=froger_a</value> + <value type="QString">WINDOWID=16777252</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmLS4BRW</value> + <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358513837.420735-2094239602</value> + <value type="QString">XPSERVERLIST=:64 </value> + <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> + <value type="QString">XTERM_SHELL=/bin/bash</value> + <value type="QString">XTERM_VERSION=XTerm(261)</value> + <value type="QString">_=/usr/bin/qtcreator</value> + </valuelist> + <valuelist key="abstractProcess.arguments" type="QVariantList"> + <value type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser/XmlParser.pro</value> + <value type="QString">-spec</value> + <value type="QString">linux-g++</value> + <value type="QString">-r</value> + </valuelist> + <value key="abstractProcess.command" type="QString">/usr/bin/qmake-qt4</value> + <value key="abstractProcess.enabled" type="bool">false</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser</value> </valuemap> </data> <data> <variable>buildconfiguration-Release-buildstep1</variable> <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> + <valuelist key="abstractProcess.Environment" type="QVariantList"> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-E5D7SPzCvM,guid=d599357c9b4b11459397a7040062a9e9</value> + <value type="QString">DESKTOP_SESSION=fluxbox</value> + <value type="QString">DISPLAY=:0.0</value> + <value type="QString">GDMSESSION=fluxbox</value> + <value type="QString">GDM_LANG=fr_FR.UTF-8</value> + <value type="QString">GDM_XSERVER_LOCATION=local</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-IhfkdE</value> + <value type="QString">GNOME_KEYRING_PID=8615</value> + <value type="QString">GTK_MODULES=canberra-gtk-module</value> + <value type="QString">HOME=/lrde/home/stage/froger_a</value> + <value type="QString">LANG=fr_FR.UTF-8</value> + <value type="QString">LD_LIBRARY_PATH=/usr/lib/qtcreator</value> + <value type="QString">LOGNAME=froger_a</value> + <value type="QString">OLDPWD=/lrde/home/stage/froger_a/qt</value> + <value type="QString">PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games</value> + <value type="QString">PWD=/lrde/home/stage/froger_a/qt/XmlParser</value> + <value type="QString">QTDIR=/usr/share/qt4</value> + <value type="QString">SHELL=/bin/bash</value> + <value type="QString">SHLVL=2</value> + <value type="QString">SSH_AGENT_PID=8690</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-znXRds8624/agent.8624</value> + <value type="QString">TERM=xterm</value> + <value type="QString">USER=froger_a</value> + <value type="QString">USERNAME=froger_a</value> + <value type="QString">WINDOWID=16777252</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdmLS4BRW</value> + <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358513837.420735-2094239602</value> + <value type="QString">XPSERVERLIST=:64 </value> + <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> + <value type="QString">XTERM_SHELL=/bin/bash</value> + <value type="QString">XTERM_VERSION=XTerm(261)</value> + <value type="QString">_=/usr/bin/qtcreator</value> + </valuelist> + <value key="abstractProcess.IgnoreReturnValue" type="bool">false</value> + <valuelist key="abstractProcess.arguments" type="QVariantList"> + <value type="QString">-w</value> + </valuelist> + <value key="abstractProcess.command" type="QString">/usr/bin/make</value> + <value key="abstractProcess.enabled" type="bool">true</value> + <value key="abstractProcess.workingDirectory" type="QString">/amd/nfs/volume1/home/stage/froger_a/qt/XmlParser</value> </valuemap> </data> <data> <variable>buildconfiguration-Release-cleanstep0</variable> <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Release</value> + <value key="cleanConfig" type="bool">true</value> + <valuelist key="makeargs" type="QVariantList"> + <value type="QString">clean</value> + </valuelist> </valuemap> </data> <data> diff --git a/XmlParser/demodir.h b/XmlParser/demodir.h deleted file mode 100644 index 4182ace..0000000 --- a/XmlParser/demodir.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef DEMODIR_H -#define DEMODIR_H - -# define SCRIBO_PREFIX_BINDIR "/usr/local/bin" -# define SCRIBO_LOCAL_DEMODIR "/lrde/home/stage/froger_a/olena/_build/scribo/demo" - -#endif // DEMODIR_H diff --git a/XmlParser/main.cpp b/XmlParser/main.cpp index 53ec79f..aecf5cd 100644 --- a/XmlParser/main.cpp +++ b/XmlParser/main.cpp @@ -12,6 +12,7 @@ int main(int argc, char **argv) { Magick::InitializeMagick(*argv); + QApplication::setGraphicsSystem("raster"); QApplication a(argc, argv); MainWindow w; w.show(); diff --git a/XmlParser/mainwindow.cpp b/XmlParser/mainwindow.cpp index eb461fc..a9415cf 100644 --- a/XmlParser/mainwindow.cpp +++ b/XmlParser/mainwindow.cpp @@ -10,6 +10,7 @@ MainWindow::MainWindow(QWidget *parent): QVBoxLayout *gBLayout = new QVBoxLayout; gBLayout->addWidget(ui->graphicsView); ui->groupBox->setLayout(gBLayout); + ui->graphicsView->setCacheMode(QGraphicsView::CacheBackground); scene = new Scene(ui->graphicsView); scene->setSceneRect(ui->graphicsView->geometry()); ui->graphicsView->setScene(scene); @@ -18,16 +19,19 @@ MainWindow::MainWindow(QWidget *parent): toolBar->setGeometry(0, ui->menuBar->height(), ui->menuBar->width(), 30); connect(toolBar->openAction(), SIGNAL(triggered()), this, SLOT(on_actionOpen_triggered())); connect(toolBar->quitAction(), SIGNAL(triggered()), this, SLOT(close())); - connect(toolBar->segmentAction(), SIGNAL(triggered()), this, SLOT(onSegmentation())); + connect(toolBar->segmentAction(), SIGNAL(triggered()), this, SLOT(onBeginSegmentation())); progressDialog = new ProgressDialog(this); - connect(&runner, SIGNAL(finished(QString*)), this, SLOT(onEndSegmentation(QString*))); + connect(&runner, SIGNAL(finished()), progressDialog, SLOT(close())); connect(&runner, SIGNAL(new_progress_max_value(int)), progressDialog, SLOT(setMaximum(int))); connect(&runner, SIGNAL(new_progress_label(QString)), progressDialog, SLOT(setLabelText(QString))); + connect(&runner, SIGNAL(xml_saved(QString)), this, SLOT(onXmlSaved(QString))); connect(&runner, SIGNAL(progress()), progressDialog, SLOT(run())); } MainWindow::~MainWindow() { + delete scene; + delete progressDialog; delete ui; } @@ -49,17 +53,14 @@ void MainWindow::on_actionOpen_triggered() imagePath = QFileDialog::getOpenFileName(this); if(imagePath != "") { + scene->removeItems(); QPixmap pixmap(imagePath); - QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap); - pixmapItem->setFlag(QGraphicsItem::ItemNegativeZStacksBehindParent, true); - pixmapItem->setZValue(-1); - pixmapItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); - ui->graphicsView->scene()->setSceneRect(pixmap.rect()); - ui->graphicsView->scene()->addItem(pixmapItem); + scene->setSceneRect(pixmap.rect()); + scene->setBackgroundBrush(QBrush(pixmap)); } } -void MainWindow::onSegmentation() +void MainWindow::onBeginSegmentation() { if(imagePath != "") { @@ -68,10 +69,9 @@ void MainWindow::onSegmentation() } } -void MainWindow::onEndSegmentation(QString *filename) +void MainWindow::onXmlSaved(const QString& filename) { - progressDialog->close(); - Xml::parseItems(*filename, scene); + Xml::parseItems(filename, scene); } /*void MainWindow::on_action(QString& string) diff --git a/XmlParser/mainwindow.h b/XmlParser/mainwindow.h index 6deccc7..e8e899a 100644 --- a/XmlParser/mainwindow.h +++ b/XmlParser/mainwindow.h @@ -39,8 +39,8 @@ class MainWindow : private slots: void on_actionOpen_triggered(); - void onSegmentation(); - void onEndSegmentation(QString *filename); + void onBeginSegmentation(); + void onXmlSaved(const QString& filename); //void on_action(QString& string); }; diff --git a/XmlParser/polygonitem.cpp b/XmlParser/polygonitem.cpp index 5ab3e7e..2c20dbf 100644 --- a/XmlParser/polygonitem.cpp +++ b/XmlParser/polygonitem.cpp @@ -1,7 +1,7 @@ #include "polygonitem.h" -PolygonItem::PolygonItem(QGraphicsItem *parent, QGraphicsScene *scene): - QGraphicsPolygonItem(parent, scene) +PolygonItem::PolygonItem(QGraphicsItem *parent, QGraphicsScene *scene) + : QGraphicsPolygonItem(parent, scene) { init(); } @@ -12,23 +12,24 @@ PolygonItem::PolygonItem(const QPolygonF &polygon, QGraphicsItem *parent, QGraph init(); } +PolygonItem::~PolygonItem() +{ + delete selectedPen; + delete unselectedPen; + delete selectedBrush; + delete unselectedBrush; +} + void PolygonItem::init() { - setCacheMode(QGraphicsItem::ItemCoordinateCache); - setFlags(QGraphicsItem::ItemClipsToShape); selectedPen = new QPen(Qt::SolidLine); unselectedPen = new QPen(Qt::SolidLine); - selectedPen->setWidthF(3); + selectedPen->setWidthF(2); unselectedPen->setWidth(0); selectedPen->setCapStyle(Qt::SquareCap); unselectedPen->setCapStyle(Qt::SquareCap); selectedBrush = new QBrush(Qt::SolidPattern); unselectedBrush = new QBrush(Qt::SolidPattern); - QRectF bRect(boundingRect()); - if(bRect.width() < 1) - bRect.setWidth(1); - if(bRect.height() < 1) - bRect.setHeight(1); } void PolygonItem::setColor(const QColor &color) @@ -46,7 +47,7 @@ QColor PolygonItem::color() const return selectedBrush->color(); } -void PolygonItem::repaint(const QRectF &rect, bool clic) +void PolygonItem::repaint(const QRectF& rect, bool clic) { bool sel; if(clic) diff --git a/XmlParser/polygonitem.h b/XmlParser/polygonitem.h index c46fcb4..50abf61 100644 --- a/XmlParser/polygonitem.h +++ b/XmlParser/polygonitem.h @@ -13,6 +13,7 @@ class PolygonItem : public: explicit PolygonItem(QGraphicsItem *parent = 0, QGraphicsScene *scene = 0); explicit PolygonItem(const QPolygonF& path, QGraphicsItem *parent = 0, QGraphicsScene *scene = 0); + ~PolygonItem(); void setColor(const QColor& color); QColor color() const; diff --git a/XmlParser/region.h b/XmlParser/region.h index 0741177..e0c456e 100644 --- a/XmlParser/region.h +++ b/XmlParser/region.h @@ -5,14 +5,6 @@ namespace GraphicRegion { - struct Data - { - QColor color; - QString name; - int region; - int zValue; - }; - enum Id { Text, @@ -30,6 +22,14 @@ namespace GraphicRegion Chart, Maths }; + + struct Data + { + QColor color; + QString name; + int region; + int zValue; + }; } namespace Separator diff --git a/XmlParser/runner.cpp b/XmlParser/runner.cpp index 7ad62fa2..8dfd8b0 100644 --- a/XmlParser/runner.cpp +++ b/XmlParser/runner.cpp @@ -33,7 +33,8 @@ void Runner::run() image2d<value::rgb8> ima; io::magick::load(ima, args_.at(0).toUtf8().constData()); image2d<bool> bin_ima = preprocess(ima); - emit finished(&process(ima, bin_ima)); + process(ima, bin_ima); + emit finished(); } break; @@ -130,12 +131,13 @@ void Runner::process(const image2d<value::rgb8>& original_ima, if (!dir.exists() && !dir.mkpath(output_dir)) output_dir = QDir::tempPath(); } - f.output_file = (output_dir + "/" + file.baseName() + "_gui.xml").toUtf8().constData(); + QString filename = (output_dir + "/" + file.baseName() + "_gui.xml"); + f.output_file = filename.toUtf8().constData(); emit new_progress_max_value(f.nsteps()); // Perform text detection. f(original_ima, processed_ima); - return f.output_file; + emit xml_saved(filename); //qDebug() << "Process Done."; } diff --git a/XmlParser/runner.h b/XmlParser/runner.h index 0e506b7..56a07df 100644 --- a/XmlParser/runner.h +++ b/XmlParser/runner.h @@ -34,7 +34,7 @@ class Runner : private: image2d<bool> preprocess(const image2d<value::rgb8>& ima); - QString process(const image2d<value::rgb8>& original_ima, const image2d<bool>& processed_ima); + void process(const image2d<value::rgb8>& original_ima, const image2d<bool>& processed_ima); void export_as(); virtual void run(); template <typename V> unsigned find_best_scale(const mln::image2d<V>& ima); @@ -51,7 +51,7 @@ class Runner : void new_progress_label(const QString& msg); void xml_saved(const QString& filename); void progress(); - void finished(QString *filename = 0); + void finished(); }; #endif // RUNNER_H diff --git a/XmlParser/scene.cpp b/XmlParser/scene.cpp index 79cc213..612d2bd 100644 --- a/XmlParser/scene.cpp +++ b/XmlParser/scene.cpp @@ -18,6 +18,11 @@ Scene::Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent): init(); } +Scene::~Scene() +{ + delete selection; +} + void Scene::init() { isPressing = false; @@ -25,6 +30,17 @@ void Scene::init() selection = new Selection(this); } +void Scene::removeItems() +{ + QList<QGraphicsItem *> itemsList = items(); + QGraphicsItem *i; + foreach(i, itemsList) + { + if(i != selection) + delete i; + } +} + void Scene::mousePressEvent(QGraphicsSceneMouseEvent *event) { if(event->button() == Qt::LeftButton && !isPressing) @@ -57,9 +73,8 @@ void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { isPressing = false; if(clic) - emit repaintItems(QRectF(QPointF(0, 0), event->scenePos()), true); - else - emit repaintItems(selection->rect(), false); + selection->setRect(QRectF(QPointF(0, 0), event->scenePos())); + emit repaintItems(selection->rect(), clic); selection->setRect(0, 0, 0, 0); } } diff --git a/XmlParser/scene.h b/XmlParser/scene.h index 47e0cf2..b7294c6 100644 --- a/XmlParser/scene.h +++ b/XmlParser/scene.h @@ -15,6 +15,8 @@ class Scene : explicit Scene(QObject *parent = 0); explicit Scene(const QRectF &sceneRect, QObject *parent = 0); explicit Scene(qreal x, qreal y, qreal width, qreal height, QObject *parent = 0); + ~Scene(); + void removeItems(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/XmlParser/toolbar.cpp b/XmlParser/toolbar.cpp index 746f5ee..7742310 100644 --- a/XmlParser/toolbar.cpp +++ b/XmlParser/toolbar.cpp @@ -12,6 +12,13 @@ ToolBar::ToolBar(QWidget *parent): quit = addAction(tr("Quit")); } +ToolBar::~ToolBar() +{ + delete open; + delete segment; + delete quit; +} + QAction * ToolBar::openAction() const { return open; diff --git a/XmlParser/toolbar.h b/XmlParser/toolbar.h index 25609af..e7a3b77 100644 --- a/XmlParser/toolbar.h +++ b/XmlParser/toolbar.h @@ -3,13 +3,13 @@ #include <QToolBar> #include <QAction> -#include "mainwindow.h" class ToolBar : public QToolBar { public: explicit ToolBar(QWidget *parent); + ~ToolBar(); QAction * openAction() const; QAction * segmentAction() const; QAction * quitAction() const; diff --git a/XmlParser/xml.cpp b/XmlParser/xml.cpp index 4b20005..67c5451 100644 --- a/XmlParser/xml.cpp +++ b/XmlParser/xml.cpp @@ -1,6 +1,19 @@ #include "xml.h" #include "region.h" +static const GraphicRegion::Data itemsData[] = +{ + {QColor::fromRgb(0, 0, 255, 60), "VerticalSeparatorRegion", (int)GraphicRegion::VerticalSeparator, 2}, + {QColor::fromRgb(0, 0, 255, 60), "HorizontalSeparatorRegion", (int)GraphicRegion::HorizontalSeparator, 2}, + {QColor::fromRgb(0, 0, 128, 60), "WhitespaceSeparatorRegion", (int)GraphicRegion::WhiteSpaceSeparator, 2}, + {QColor::fromRgb(255, 120, 0, 60), "ImageRegion", (int)GraphicRegion::Image, 1}, + {QColor::fromRgb(43, 39, 128, 60), "NoiseRegion", (int)GraphicRegion::Noise, 2}, + {QColor::fromRgb(220, 246, 0, 60), "TableRegion", (int)GraphicRegion::Table, 2}, + {QColor::fromRgb(170, 0, 255, 60), "MathsRegion", (int)GraphicRegion::Maths, 3}, + {QColor::fromRgb(255, 0, 144, 60), "GraphicRegion", (int)GraphicRegion::Graphic, 2}, + {QColor::fromRgb(0, 204, 255, 60), "ChartRegion", (int)GraphicRegion::Chart, 2} +}; + Xml::Xml() { } @@ -29,10 +42,12 @@ void Xml::graphicsTypoRegion(const QDomElement& element, const QPoint& xPos, Sce { int yPos = element.attribute("baseline", "null").toInt(); QGraphicsLineItem *baselineRegion = new QGraphicsLineItem(QLine(QPoint(xPos.x(), yPos), QPoint(xPos.y(), yPos)), 0, scene); + baselineRegion->setCacheMode(QGraphicsItem::DeviceCoordinateCache); baselineRegion->setData(0, QVariant::fromValue((int)GraphicRegion::Baseline)); baselineRegion->setZValue(3); yPos = element.attribute("meanline", "null").toInt(); QGraphicsLineItem *meanlineRegion = new QGraphicsLineItem(QLine(QPoint(xPos.x(), yPos), QPoint(xPos.y(), yPos)), 0, scene); + meanlineRegion->setCacheMode(QGraphicsItem::DeviceCoordinateCache); meanlineRegion->setData(0, QVariant::fromValue((int)GraphicRegion::Meanline)); meanlineRegion->setZValue(3); } @@ -95,61 +110,8 @@ void Xml::parseItems(const QString &filename, Scene *scene) QDomDocument xml; xml.setContent(&xmlFile); xmlFile.close(); - QVector<QGraphicsItem *> items; QDomElement element = xml.documentElement().firstChild().nextSiblingElement("Page").firstChild().toElement(); graphicsTextRegion(element, scene); - GraphicRegion::Data verticalData; - verticalData.color = QColor::fromRgb(0, 0, 255, 80); - verticalData.name = "VerticalSeparatorRegion"; - verticalData.region = (int)GraphicRegion::VerticalSeparator; - verticalData.zValue = 2; - graphicsRegion(element.nextSiblingElement(verticalData.name), verticalData, scene); - GraphicRegion::Data horizontalData; - horizontalData.color = QColor::fromRgb(0, 0, 255, 80); - horizontalData.name = "HorizontalSeparatorRegion"; - horizontalData.region = (int)GraphicRegion::HorizontalSeparator; - horizontalData.zValue = 2; - graphicsRegion(element.nextSiblingElement(horizontalData.name), horizontalData, scene); - GraphicRegion::Data spaceData; - spaceData.color = QColor::fromRgb(0, 0, 128, 80); - spaceData.name = "WhitespaceSeparatorRegion"; - spaceData.region = (int)GraphicRegion::WhiteSpaceSeparator; - spaceData.zValue = 2; - graphicsRegion(element.nextSiblingElement(spaceData.name), spaceData, scene); - GraphicRegion::Data imageData; - imageData.color = QColor::fromRgb(255, 120, 0, 80); - imageData.name = "ImageRegion"; - imageData.region = (int)GraphicRegion::Image; - imageData.zValue = 1; - graphicsRegion(element.nextSiblingElement(imageData.name), imageData, scene); - GraphicRegion::Data noiseData; - noiseData.color = QColor::fromRgb(43, 39, 128, 80); - noiseData.name = "NoiseRegion"; - noiseData.region = (int)GraphicRegion::Noise; - noiseData.zValue = 2; - graphicsRegion(element.nextSiblingElement(noiseData.name), noiseData, scene); - GraphicRegion::Data tableData; - tableData.color = QColor::fromRgb(220, 246, 0, 80); - tableData.name = "TableRegion"; - tableData.region = (int)GraphicRegion::Table; - tableData.zValue = 2; - graphicsRegion(element.nextSiblingElement(tableData.name), tableData, scene); - GraphicRegion::Data mathsData; - mathsData.color = QColor::fromRgb(170, 0, 255, 80); - mathsData.name = "MathsRegion"; - mathsData.region = (int)GraphicRegion::Maths; - mathsData.zValue = 3; - graphicsRegion(element.nextSiblingElement(mathsData.name), mathsData, scene); - GraphicRegion::Data graphicData; - graphicData.color = QColor::fromRgb(255, 0, 144, 80); - graphicData.name = "GraphicRegion"; - graphicData.region = (int)GraphicRegion::Graphic; - graphicData.zValue = 2; - graphicsRegion(element.nextSiblingElement(graphicData.name), graphicData, scene); - GraphicRegion::Data chartData; - chartData.color = QColor::fromRgb(0, 204, 255, 80); - chartData.name = "ChartRegion"; - chartData.region = (int)GraphicRegion::Chart; - chartData.zValue = 2; - graphicsRegion(element.nextSiblingElement(chartData.name), chartData, scene); + for(int i = 0; i < 9; i++) + graphicsRegion(element.nextSiblingElement(itemsData[i].name), itemsData[i], scene); } -- 1.7.2.5
11Â years, 11Â months
1
0
0
0
01f77f1 Add runner and all segmentation tasks.
by Antoine Froger
--- Test2/test2.h | 2 +- XmlParser/XmlParser.pro | 22 ++++- XmlParser/XmlParser.pro.user | 36 ++++---- XmlParser/configs.cpp | 134 +++++++++++++++++++++++++++++ XmlParser/configs.h | 39 +++++++++ XmlParser/demodir.h | 7 ++ XmlParser/dir.h | 7 ++ XmlParser/main.cpp | 11 ++- XmlParser/mainwindow.cpp | 52 +++++++++--- XmlParser/mainwindow.h | 11 ++- XmlParser/mainwindow.ui | 8 +- XmlParser/polygonitem.h | 3 +- XmlParser/preprocess.cpp | 11 +++ XmlParser/preprocess.h | 26 ++++++ XmlParser/process.cpp | 21 +++++ XmlParser/process.h | 29 ++++++ XmlParser/progressdialog.cpp | 22 +++++ XmlParser/progressdialog.h | 19 ++++ XmlParser/region.h | 12 +++- XmlParser/runner.cpp | 193 +++++++++++++++++++++++++++++++++++++++++- XmlParser/runner.h | 34 +++++++- XmlParser/scene.h | 8 +- XmlParser/toolbar.cpp | 22 ++++- XmlParser/toolbar.h | 14 +++- XmlParser/xml.cpp | 20 ++-- 25 files changed, 697 insertions(+), 66 deletions(-) create mode 100644 XmlParser/configs.cpp create mode 100644 XmlParser/configs.h create mode 100644 XmlParser/demodir.h create mode 100644 XmlParser/dir.h create mode 100644 XmlParser/preprocess.cpp create mode 100644 XmlParser/preprocess.h create mode 100644 XmlParser/process.cpp create mode 100644 XmlParser/process.h create mode 100644 XmlParser/progressdialog.cpp create mode 100644 XmlParser/progressdialog.h diff --git a/Test2/test2.h b/Test2/test2.h index 9007d2d..02c2534 100644 --- a/Test2/test2.h +++ b/Test2/test2.h @@ -11,7 +11,7 @@ namespace Ui { - class Test2; + class Test2 } class Test2 : public QMainWindow { diff --git a/XmlParser/XmlParser.pro b/XmlParser/XmlParser.pro index 812902d..e65b72a 100644 --- a/XmlParser/XmlParser.pro +++ b/XmlParser/XmlParser.pro @@ -4,7 +4,13 @@ QT += xml TARGET = XmlParser TEMPLATE = app -INCLUDEPATH += /lrde/home/stage/froger_a/olena/milena/ +INCLUDEPATH += /lrde/home/stage/froger_a/olena/milena/ \ + /lrde/home/stage/froger_a/olena/scribo/ +QMAKE_CXXFLAGS += -DNDEBUG \ + -DMLN_WO_GLOBAL_VARS +LIBS += -I/usr/include/graphicsImage \ + -lGraphicsMagick++ \ + -ltesseract_full SOURCES += main.cpp \ mainwindow.cpp \ xml.cpp \ @@ -12,7 +18,11 @@ SOURCES += main.cpp \ selection.cpp \ polygonitem.cpp \ runner.cpp \ - toolbar.cpp + toolbar.cpp \ + process.cpp \ + preprocess.cpp \ + configs.cpp \ + progressdialog.cpp HEADERS += mainwindow.h \ region.h \ xml.h \ @@ -20,5 +30,11 @@ HEADERS += mainwindow.h \ selection.h \ polygonitem.h \ runner.h \ - toolbar.h + toolbar.h \ + demodir.h \ + process.h \ + preprocess.h \ + configs.h \ + dir.h \ + progressdialog.h FORMS += mainwindow.ui diff --git a/XmlParser/XmlParser.pro.user b/XmlParser/XmlParser.pro.user index bd2e795..0b03fae 100644 --- a/XmlParser/XmlParser.pro.user +++ b/XmlParser/XmlParser.pro.user @@ -76,14 +76,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-1aju09G1Pe,guid=69ec02ba8a70eadde9e5182600601b23</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-jXUCLOmOZn,guid=4585eaa0c02f09d20a77bf8f006153a8</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-792wyb</value> - <value type="QString">GNOME_KEYRING_PID=10096</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-aTERin</value> + <value type="QString">GNOME_KEYRING_PID=8076</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -95,16 +95,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=10171</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-VVXGf10105/agent.10105</value> + <value type="QString">SSH_AGENT_PID=8151</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-wrZmtE8085/agent.8085</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=16777252</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm1TO0QW</value> + <value type="QString">WINDOWID=10485796</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm4ATXQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358346215.20665-174033780</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358426220.205793-1492047644</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -128,14 +128,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-1aju09G1Pe,guid=69ec02ba8a70eadde9e5182600601b23</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-jXUCLOmOZn,guid=4585eaa0c02f09d20a77bf8f006153a8</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-792wyb</value> - <value type="QString">GNOME_KEYRING_PID=10096</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-aTERin</value> + <value type="QString">GNOME_KEYRING_PID=8076</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -147,16 +147,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=10171</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-VVXGf10105/agent.10105</value> + <value type="QString">SSH_AGENT_PID=8151</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-wrZmtE8085/agent.8085</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=16777252</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdm1TO0QW</value> + <value type="QString">WINDOWID=10485796</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm4ATXQW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358346215.20665-174033780</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358426220.205793-1492047644</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> diff --git a/XmlParser/configs.cpp b/XmlParser/configs.cpp new file mode 100644 index 0000000..59df3db --- /dev/null +++ b/XmlParser/configs.cpp @@ -0,0 +1,134 @@ +#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh> +#include "configs.h" +#include "region.h" + +Configs::Configs() + : QSettings("Olena-Scribo", "viewer") +{ +} + +Configs * Configs::getInstance() +{ + static Configs * conf = new Configs(); + return conf; +} + +bool Configs::preprocessingSubsample() +{ + return value("preprocessing/subsample", false).toBool(); +} + +void Configs::setPreprocessingSubsample(bool b) +{ + setValue("preprocessing/subsample", b); +} + +bool Configs::preprocessingRemoveBg() +{ + return value("preprocessing/remove_bg", false).toBool(); +} + +void Configs::setPreprocessingRemoveBg(bool b) +{ + setValue("preprocessing/remove_bg", b); +} + +bool Configs::preprocessingDeskew() +{ + return value("preprocessing/deskew", false).toBool(); +} + +void Configs::setPreprocessingDeskew(bool b) +{ + setValue("preprocessing/deskew", b); +} + +bool Configs::preprocessingRemoveNoise() +{ + return value("preprocessing/remove_noise", true).toBool(); +} + +void Configs::setPreprocessingRemoveNoise(bool b) +{ + setValue("preprocessing/remove_noise", b); +} + +int Configs::preprocessingBinAlgo() +{ + return value("preprocessing/bin_algo", scribo::toolchain::internal::SauvolaMs).toInt(); +} + +void Configs::setPreprocessingBinAlgo(int algo) +{ + setValue("preprocessing/bin_algo", algo); +} + +int Configs::segmentationFindSeps() +{ + return value("segmentation/find_seps", Separator::Both).toInt(); +} + +void Configs::setSegmentationFindSeps(int seps) +{ + setValue("segmentation/find_seps", seps); +} + +bool Configs::ocrEnabled() +{ + return value("ocr/enabled", true).toBool(); +} + +void Configs::setOcrEnabled(bool b) +{ + setValue("ocr/enabled", b); +} + +QString Configs::ocrLanguage() +{ + return value("ocr/language", 0).toString(); +} + +void Configs::setOcrLanguage(const QString &lang) +{ + setValue("ocr/language", lang); +} + +bool Configs::generalSaveXmlEnabled() +{ + return value("general/save_xml/enabled", true).toBool(); +} + +void Configs::setGeneralSaveXmlEnabled(bool b) +{ + setValue("general/save_xml/enabled", b); +} + +bool Configs::generalSaveXmlSameDir() +{ + return value("general/save_xml/same_dir", true).toBool(); +} + +void Configs::setGeneralSaveXmlSameDir(bool b) +{ + setValue("general/save_xml/same_dir", b); +} + +bool Configs::generalSaveXmlCustomDir() +{ + return value("general/save_xml/custom_dir", false).toBool(); +} + +void Configs::setGeneralSaveXmlCustomDir(bool b) +{ + setValue("general/save_xml/custom_dir", b); +} + +QString Configs::generalSaveXmlCustomDirPath() +{ + return value("general/save_xml/custom_dir_path", QDir::tempPath()).toString(); +} + +void Configs::setGeneralSaveXmlCustomDirPath(const QString &path) +{ + setValue("general/save_xml/custom_dir_path", path); +} diff --git a/XmlParser/configs.h b/XmlParser/configs.h new file mode 100644 index 0000000..6677527 --- /dev/null +++ b/XmlParser/configs.h @@ -0,0 +1,39 @@ +#ifndef CONFIGS_H +#define CONFIGS_H + +#include <QSettings> +#include <QDir> + +class Configs : + public QSettings +{ + public: + Configs(); + static Configs * getInstance(); + bool preprocessingSubsample(); + void setPreprocessingSubsample(bool b); + bool preprocessingRemoveBg(); + void setPreprocessingRemoveBg(bool b); + bool preprocessingDeskew(); + void setPreprocessingDeskew(bool b); + bool preprocessingRemoveNoise(); + void setPreprocessingRemoveNoise(bool b); + int preprocessingBinAlgo(); + void setPreprocessingBinAlgo(int algo); + int segmentationFindSeps(); + void setSegmentationFindSeps(int seps); + bool ocrEnabled(); + void setOcrEnabled(bool b); + QString ocrLanguage(); + void setOcrLanguage(const QString& lang); + bool generalSaveXmlEnabled(); + void setGeneralSaveXmlEnabled(bool b); + bool generalSaveXmlSameDir(); + void setGeneralSaveXmlSameDir(bool b); + bool generalSaveXmlCustomDir(); + void setGeneralSaveXmlCustomDir(bool b); + QString generalSaveXmlCustomDirPath(); + void setGeneralSaveXmlCustomDirPath(const QString& path); +}; + +#endif // CONFIGS_H diff --git a/XmlParser/demodir.h b/XmlParser/demodir.h new file mode 100644 index 0000000..4182ace --- /dev/null +++ b/XmlParser/demodir.h @@ -0,0 +1,7 @@ +#ifndef DEMODIR_H +#define DEMODIR_H + +# define SCRIBO_PREFIX_BINDIR "/usr/local/bin" +# define SCRIBO_LOCAL_DEMODIR "/lrde/home/stage/froger_a/olena/_build/scribo/demo" + +#endif // DEMODIR_H diff --git a/XmlParser/dir.h b/XmlParser/dir.h new file mode 100644 index 0000000..cb951f1 --- /dev/null +++ b/XmlParser/dir.h @@ -0,0 +1,7 @@ +#ifndef DIR_H +#define DIR_H + +#define SCRIBO_PREFIX_BINDIR "/usr/local/bin" +#define SCRIBO_LOCAL_DEMODIR "/lrde/home/stage/froger_a/olena/_build/scribo/demo" + +#endif // DIR_H diff --git a/XmlParser/main.cpp b/XmlParser/main.cpp index 6e7efd9..53ec79f 100644 --- a/XmlParser/main.cpp +++ b/XmlParser/main.cpp @@ -1,8 +1,17 @@ +#undef MLN_WO_GLOBAL_VARS + +#include <mln/labeling/colorize.hh> +#include <mln/math/pi.hh> +#include <mln/io/magick/load.hh> +#include <mln/literal/colors.hh> +#include <mln/debug/filename.hh> +#include <scribo/make/debug_filename.hh> #include <QtGui/QApplication> #include "mainwindow.h" -int main(int argc, char *argv[]) +int main(int argc, char **argv) { + Magick::InitializeMagick(*argv); QApplication a(argc, argv); MainWindow w; w.show(); diff --git a/XmlParser/mainwindow.cpp b/XmlParser/mainwindow.cpp index 6ad5237..eb461fc 100644 --- a/XmlParser/mainwindow.cpp +++ b/XmlParser/mainwindow.cpp @@ -1,22 +1,29 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -MainWindow::MainWindow(QWidget *parent) : +MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(ui->groupBox); - layout->addWidget(ui->textEdit); - setLayout(layout); + imagePath = QString::null; QVBoxLayout *gBLayout = new QVBoxLayout; gBLayout->addWidget(ui->graphicsView); ui->groupBox->setLayout(gBLayout); - Scene *scene = new Scene(ui->graphicsView); + scene = new Scene(ui->graphicsView); scene->setSceneRect(ui->graphicsView->geometry()); ui->graphicsView->setScene(scene); Xml::parseItems("/tmp/mp00082c_gui.xml", scene); + ToolBar *toolBar = new ToolBar(this); + toolBar->setGeometry(0, ui->menuBar->height(), ui->menuBar->width(), 30); + connect(toolBar->openAction(), SIGNAL(triggered()), this, SLOT(on_actionOpen_triggered())); + connect(toolBar->quitAction(), SIGNAL(triggered()), this, SLOT(close())); + connect(toolBar->segmentAction(), SIGNAL(triggered()), this, SLOT(onSegmentation())); + progressDialog = new ProgressDialog(this); + connect(&runner, SIGNAL(finished(QString*)), this, SLOT(onEndSegmentation(QString*))); + connect(&runner, SIGNAL(new_progress_max_value(int)), progressDialog, SLOT(setMaximum(int))); + connect(&runner, SIGNAL(new_progress_label(QString)), progressDialog, SLOT(setLabelText(QString))); + connect(&runner, SIGNAL(progress()), progressDialog, SLOT(run())); } MainWindow::~MainWindow() @@ -39,13 +46,32 @@ void MainWindow::changeEvent(QEvent *e) void MainWindow::on_actionOpen_triggered() { - QPixmap pixmap(QFileDialog::getOpenFileName(this)); - QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap); - pixmapItem->setFlag(QGraphicsItem::ItemNegativeZStacksBehindParent, true); - pixmapItem->setZValue(-1); - pixmapItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); - ui->graphicsView->scene()->setSceneRect(pixmap.rect()); - ui->graphicsView->scene()->addItem(pixmapItem); + imagePath = QFileDialog::getOpenFileName(this); + if(imagePath != "") + { + QPixmap pixmap(imagePath); + QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap); + pixmapItem->setFlag(QGraphicsItem::ItemNegativeZStacksBehindParent, true); + pixmapItem->setZValue(-1); + pixmapItem->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + ui->graphicsView->scene()->setSceneRect(pixmap.rect()); + ui->graphicsView->scene()->addItem(pixmapItem); + } +} + +void MainWindow::onSegmentation() +{ + if(imagePath != "") + { + progressDialog->reset(); + runner.start_demat(imagePath); + } +} + +void MainWindow::onEndSegmentation(QString *filename) +{ + progressDialog->close(); + Xml::parseItems(*filename, scene); } /*void MainWindow::on_action(QString& string) diff --git a/XmlParser/mainwindow.h b/XmlParser/mainwindow.h index 47103a3..6deccc7 100644 --- a/XmlParser/mainwindow.h +++ b/XmlParser/mainwindow.h @@ -5,9 +5,13 @@ #include <QGraphicsView> #include <QVBoxLayout> #include <QFileDialog> +#include <QProgressDialog> #include "scene.h" +#include "toolbar.h" #include "xml.h" #include "polygonitem.h" +#include "runner.h" +#include "progressdialog.h" namespace Ui { @@ -28,11 +32,16 @@ class MainWindow : private: Ui::MainWindow *ui; + Scene * scene; + ProgressDialog *progressDialog; + QString imagePath; + Runner runner; private slots: void on_actionOpen_triggered(); + void onSegmentation(); + void onEndSegmentation(QString *filename); //void on_action(QString& string); }; #endif // MAINWINDOW_H - diff --git a/XmlParser/mainwindow.ui b/XmlParser/mainwindow.ui index 3340356..8e57fa3 100644 --- a/XmlParser/mainwindow.ui +++ b/XmlParser/mainwindow.ui @@ -20,8 +20,8 @@ <widget class="QTextEdit" name="textEdit"> <property name="geometry"> <rect> - <x>110</x> - <y>650</y> + <x>120</x> + <y>670</y> <width>811</width> <height>75</height> </rect> @@ -30,8 +30,8 @@ <widget class="QGroupBox" name="groupBox"> <property name="geometry"> <rect> - <x>40</x> - <y>10</y> + <x>30</x> + <y>50</y> <width>971</width> <height>591</height> </rect> diff --git a/XmlParser/polygonitem.h b/XmlParser/polygonitem.h index 70ad085..c46fcb4 100644 --- a/XmlParser/polygonitem.h +++ b/XmlParser/polygonitem.h @@ -5,7 +5,8 @@ #include <QPen> class PolygonItem : - public QObject, public QGraphicsPolygonItem + public QObject, + public QGraphicsPolygonItem { Q_OBJECT diff --git a/XmlParser/preprocess.cpp b/XmlParser/preprocess.cpp new file mode 100644 index 0000000..f012d88 --- /dev/null +++ b/XmlParser/preprocess.cpp @@ -0,0 +1,11 @@ +#include "preprocess.h" + +void Preprocess::on_progress() +{ + emit progress(); +} + +void Preprocess::on_new_progress_label(const char *label) +{ + emit newProgressLabel(QString(label)); +} diff --git a/XmlParser/preprocess.h b/XmlParser/preprocess.h new file mode 100644 index 0000000..0ca01d3 --- /dev/null +++ b/XmlParser/preprocess.h @@ -0,0 +1,26 @@ +#ifndef PREPROCESS_H +#define PREPROCESS_H + +#include <QObject> +#include <mln/core/image/image2d.hh> +#include <mln/value/rgb8.hh> +#include <scribo/toolchain/internal/text_in_doc_preprocess_functor.hh> + +using namespace scribo::toolchain::internal; + +class Preprocess : + public QObject, + public text_in_doc_preprocess_functor<mln::image2d<mln::value::rgb8> > +{ + Q_OBJECT + + public: + virtual void on_progress(); + virtual void on_new_progress_label(const char *label); + + signals: + void newProgressLabel(const QString& label); + void progress(); +}; + +#endif // PREPROCESS_H diff --git a/XmlParser/process.cpp b/XmlParser/process.cpp new file mode 100644 index 0000000..bd37480 --- /dev/null +++ b/XmlParser/process.cpp @@ -0,0 +1,21 @@ +#include "process.h" + +Process::Process(const char *doc_filename) + : superT(doc_filename) +{ +} + +void Process::on_progress() +{ + emit progress(); +} + +void Process::on_new_progress_label(const char *label) +{ + emit newProgressLabel(QString(label)); +} + +void Process::on_xml_saved() +{ + emit xmlSaved(QString(output_file.c_str())); +} diff --git a/XmlParser/process.h b/XmlParser/process.h new file mode 100644 index 0000000..2759d00 --- /dev/null +++ b/XmlParser/process.h @@ -0,0 +1,29 @@ +#ifndef PROCESS_H +#define PROCESS_H + +#include <QObject> +#include <mln/core/image/image2d.hh> +#include <scribo/toolchain/internal/content_in_doc_functor.hh> + +using namespace scribo::toolchain::internal; + +struct Process : + public QObject, + public content_in_doc_functor<mln::image2d<bool> > +{ + Q_OBJECT + typedef content_in_doc_functor<mln::image2d<bool> > superT; + + public : + explicit Process(const char *docFilename); + virtual void on_progress(); + virtual void on_new_progress_label(const char *label); + virtual void on_xml_saved(); + + signals: + void newProgressLabel(const QString& label); + void progress(); + void xmlSaved(const QString& filename); +}; + +#endif // PROCESS_H diff --git a/XmlParser/progressdialog.cpp b/XmlParser/progressdialog.cpp new file mode 100644 index 0000000..386aaa6 --- /dev/null +++ b/XmlParser/progressdialog.cpp @@ -0,0 +1,22 @@ +#include "progressdialog.h" + +ProgressDialog::ProgressDialog(QWidget *parent, Qt::WindowFlags flags): + QProgressDialog(parent, flags) +{ + setModal(true); + setAutoClose(false); + setCancelButton(0); + hide(); +} + +void ProgressDialog::run() +{ + setValue(value()+1); +} + +void ProgressDialog::reset() +{ + setValue(0); + setLabelText(""); + show(); +} diff --git a/XmlParser/progressdialog.h b/XmlParser/progressdialog.h new file mode 100644 index 0000000..d1d1a20 --- /dev/null +++ b/XmlParser/progressdialog.h @@ -0,0 +1,19 @@ +#ifndef PROGRESSDIALOG_H +#define PROGRESSDIALOG_H + +#include <QProgressDialog> + +class ProgressDialog : + public QProgressDialog +{ + Q_OBJECT + + public: + explicit ProgressDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0); + void reset(); + + public slots: + void run(); +}; + +#endif // PROGRESSDIALOG_H diff --git a/XmlParser/region.h b/XmlParser/region.h index 21d67d8..0741177 100644 --- a/XmlParser/region.h +++ b/XmlParser/region.h @@ -15,7 +15,7 @@ namespace GraphicRegion enum Id { - Text = 0, + Text, Line, Baseline, Meanline, @@ -32,4 +32,14 @@ namespace GraphicRegion }; } +namespace Separator +{ + enum FindSeparator + { + Lines, + Whitespaces, + Both + }; +} + #endif // REGION_H diff --git a/XmlParser/runner.cpp b/XmlParser/runner.cpp index 3f91319..7ad62fa2 100644 --- a/XmlParser/runner.cpp +++ b/XmlParser/runner.cpp @@ -1,6 +1,195 @@ #include "runner.h" -Runner::Runner(QObject *parent): - QThread(parent) +using namespace mln; +using namespace scribo::toolchain::internal; + +static QString get_pathto(const QString& file, const QString localdirsuffix = QString()) +{ + QFile f(SCRIBO_LOCAL_DEMODIR "/" + localdirsuffix + "/" + file); + if (f.exists()) + return SCRIBO_LOCAL_DEMODIR "/" + localdirsuffix; + f.setFileName(SCRIBO_PREFIX_BINDIR "/" + file); + if (f.exists()) + return SCRIBO_PREFIX_BINDIR; + + //qDebug() << "FATAL ERROR: Can't locate file: " + file; + + return ""; +} + +Runner::Runner(QObject *parent) + : QThread(parent) +{ + moveToThread(this); +} + +void Runner::run() +{ + switch(mode_) + { + default: + case Demat: + { + image2d<value::rgb8> ima; + io::magick::load(ima, args_.at(0).toUtf8().constData()); + image2d<bool> bin_ima = preprocess(ima); + emit finished(&process(ima, bin_ima)); + } + break; + + case Export: + export_as(); + break; + } + //qDebug() << "Done."; +} + +void Runner::stop() +{ + terminate(); +} + +// Demat related stuff +void Runner::start_demat(const QString& filename) +{ + args_.clear(); + args_ << filename; + mode_ = Demat; + QThread::start(); +} + + +image2d<bool> Runner::preprocess(const image2d<value::rgb8>& ima) +{ + emit new_step("Preprocessing"); + Preprocess f; + + // Load config. + Configs * const conf = Configs::getInstance(); + + connect(&f, SIGNAL(progress()), this, SIGNAL(progress())); + connect(&f, SIGNAL(newProgressLabel(QString)), + this, SIGNAL(new_progress_label(const QString&))); + + f.enable_subsample = conf->preprocessingSubsample(); + f.enable_fg_extraction = conf->preprocessingRemoveBg(); + f.enable_deskew = conf->preprocessingDeskew(); + f.enable_denoising = conf->preprocessingRemoveNoise(); + + f.binarization_algo = static_cast<Binarization_Algo>(conf->preprocessingBinAlgo()); + + emit new_progress_max_value(f.nsteps()); + + // Perform preprocessing. + f(ima); + + //qDebug() << "Preprocess Done."; + return f.output; +} + + +void Runner::process(const image2d<value::rgb8>& original_ima, + const image2d<bool>& processed_ima) +{ + emit new_step("Page segmentation"); + + Process f(args_.at(0).toUtf8().constData()); + + connect(&f, SIGNAL(progress()), this, SIGNAL(progress())); + connect(&f, SIGNAL(newProgressLabel(QString)), + this, SIGNAL(new_progress_label(QString))); + connect(&f, SIGNAL(xmlSaved(QString)), + this, SIGNAL(xml_saved(const QString&))); + + // Load config. + Configs * const conf = Configs::getInstance(); + + Separator::FindSeparator find_seps = static_cast<Separator::FindSeparator>(conf->segmentationFindSeps()); + f.enable_line_seps = (find_seps == Separator::Lines + || find_seps == Separator::Both); + f.enable_whitespace_seps = (find_seps == Separator::Whitespaces + || find_seps == Separator::Both); + f.enable_ocr = conf->ocrEnabled(); + f.ocr_language = conf->ocrLanguage().toAscii().data(); + f.xml_format = scribo::io::xml::PageExtended; + + + f.save_doc_as_xml = true; + QFileInfo file(args_.at(0)); + QString output_dir = QDir::tempPath(); + if (conf->generalSaveXmlEnabled()) + { + if (conf->generalSaveXmlSameDir()) + output_dir = file.absolutePath(); + else if (conf->generalSaveXmlCustomDir()) + output_dir = conf->generalSaveXmlCustomDirPath(); + //else + //qDebug() << "runner::progress - Invalid xml saving option!"; + + QDir dir(output_dir); + if (!dir.exists() && !dir.mkpath(output_dir)) + output_dir = QDir::tempPath(); + } + f.output_file = (output_dir + "/" + file.baseName() + "_gui.xml").toUtf8().constData(); + emit new_progress_max_value(f.nsteps()); + + // Perform text detection. + f(original_ima, processed_ima); + return f.output_file; + //qDebug() << "Process Done."; +} + + + +// Export related stuff + +void Runner::start_export(const QString& imgfile, + const QString& xmlfile, const QString& outfile) +{ + args_.clear(); + args_ << imgfile << xmlfile << outfile; + mode_ = Export; + + QThread::start(); +} + + +void Runner::export_as() { + emit new_step("Exporting document..."); + emit new_progress_max_value(2); + + // Checking output format + QFileInfo f(args_.at(2)); + + QString pathto_xml2doc = get_pathto("scribo-xml2doc", "xml2doc"); + + if (pathto_xml2doc.isEmpty()) + { + QMessageBox::critical(0, "Fatal error", "Cannot export! Cannot find scribo-xml2doc program!"); + return; + } + + emit progress(); + + int rvalue = 0; + if (f.suffix() == "pdf") + { + emit new_step("Exporting as PDF..."); + rvalue = system(QString("%1/scribo-xml2doc --pdf %2 %3 %4") + .arg(pathto_xml2doc).arg(args_.at(1)).arg(args_.at(0)) + .arg(args_.at(2)).toAscii().constData()); + } + else if (f.suffix() == "html" || f.suffix() == "htm") + { + emit new_step("Exporting as HTML..."); + rvalue = system(QString("%1/scribo-xml2doc --html %2 %3 %4") + .arg(pathto_xml2doc).arg(args_.at(1)).arg(args_.at(0)) + .arg(args_.at(2)).toAscii().constData()); + } + else + QMessageBox::critical(0, "Fatal error", "Cannot export! Invalid output format!"); + + if (rvalue != 0) + QMessageBox::critical(0, "Fatal error", "Cannot export! Return value is not 0!"); } diff --git a/XmlParser/runner.h b/XmlParser/runner.h index 2f303f0..0e506b7 100644 --- a/XmlParser/runner.h +++ b/XmlParser/runner.h @@ -3,9 +3,18 @@ #include <QThread> #include <QStringList> +#include <QMessageBox> +#include <QFile> #include <mln/core/image/image2d.hh> #include <mln/value/rgb8.hh> #include <mln/io/magick/load.hh> +#include "dir.h" +#include "region.h" +#include "process.h" +#include "preprocess.h" +#include "configs.h" + +using namespace mln; enum RunMode { @@ -16,10 +25,33 @@ enum RunMode class Runner : public QThread { - //Q_OBJECT + Q_OBJECT public: explicit Runner(QObject *parent = 0); + void start_demat(const QString& filename); + void start_export(const QString& imgfile, const QString& xmlfile, const QString& outfile); + + private: + image2d<bool> preprocess(const image2d<value::rgb8>& ima); + QString process(const image2d<value::rgb8>& original_ima, const image2d<bool>& processed_ima); + void export_as(); + virtual void run(); + template <typename V> unsigned find_best_scale(const mln::image2d<V>& ima); + + QStringList args_; + RunMode mode_; + + public slots: + void stop(); + + signals: + void new_step(const QString& step_name); + void new_progress_max_value(int i); + void new_progress_label(const QString& msg); + void xml_saved(const QString& filename); + void progress(); + void finished(QString *filename = 0); }; #endif // RUNNER_H diff --git a/XmlParser/scene.h b/XmlParser/scene.h index efeac73..47e0cf2 100644 --- a/XmlParser/scene.h +++ b/XmlParser/scene.h @@ -21,10 +21,6 @@ class Scene : void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); void mouseMoveEvent(QGraphicsSceneMouseEvent *event); - signals: - void repaintItems(const QRectF& rect, bool clic); - void sendString(QString& string); - private: void init(); QString debug(QRect &rect); @@ -33,6 +29,10 @@ class Scene : QPointF pressPos; bool isPressing; bool clic; + + signals: + void repaintItems(const QRectF& rect, bool clic); + void sendString(QString& string); }; #endif // SCENE_H diff --git a/XmlParser/toolbar.cpp b/XmlParser/toolbar.cpp index 4b098a5..746f5ee 100644 --- a/XmlParser/toolbar.cpp +++ b/XmlParser/toolbar.cpp @@ -3,12 +3,26 @@ ToolBar::ToolBar(QWidget *parent): QToolBar("ToolBar", parent) { - init(); + setAutoFillBackground(true); + setFloatable(false); + setMovable(false); + open = addAction(tr("Open")); + segment = addAction(tr("Segment")); + addSeparator(); + quit = addAction(tr("Quit")); } -void ToolBar::init() +QAction * ToolBar::openAction() const { - addAction(tr("Open")); - addAction(tr("Segment")); + return open; +} +QAction * ToolBar::segmentAction() const +{ + return segment; +} + +QAction * ToolBar::quitAction() const +{ + return quit; } diff --git a/XmlParser/toolbar.h b/XmlParser/toolbar.h index 91aa338..25609af 100644 --- a/XmlParser/toolbar.h +++ b/XmlParser/toolbar.h @@ -2,16 +2,26 @@ #define TOOLBAR_H #include <QToolBar> +#include <QAction> +#include "mainwindow.h" class ToolBar : public QToolBar { public: - explicit ToolBar(QWidget *parent = 0); - explicit ToolBar(const QString& title, QWidget *parent = 0); + explicit ToolBar(QWidget *parent); + QAction * openAction() const; + QAction * segmentAction() const; + QAction * quitAction() const; private: void init(); + + QAction *open; + QAction *segment; + QAction *quit; + + }; #endif // TOOLBAR_H diff --git a/XmlParser/xml.cpp b/XmlParser/xml.cpp index 40bf193..4b20005 100644 --- a/XmlParser/xml.cpp +++ b/XmlParser/xml.cpp @@ -97,59 +97,59 @@ void Xml::parseItems(const QString &filename, Scene *scene) xmlFile.close(); QVector<QGraphicsItem *> items; QDomElement element = xml.documentElement().firstChild().nextSiblingElement("Page").firstChild().toElement(); - graphicsTextRegion(element, scene); // TextRegion + LineRegion + Baseline + Meanline + graphicsTextRegion(element, scene); GraphicRegion::Data verticalData; verticalData.color = QColor::fromRgb(0, 0, 255, 80); verticalData.name = "VerticalSeparatorRegion"; verticalData.region = (int)GraphicRegion::VerticalSeparator; verticalData.zValue = 2; - graphicsRegion(element.nextSiblingElement(verticalData.name), verticalData, scene); // VerticalRegion + graphicsRegion(element.nextSiblingElement(verticalData.name), verticalData, scene); GraphicRegion::Data horizontalData; horizontalData.color = QColor::fromRgb(0, 0, 255, 80); horizontalData.name = "HorizontalSeparatorRegion"; horizontalData.region = (int)GraphicRegion::HorizontalSeparator; horizontalData.zValue = 2; - graphicsRegion(element.nextSiblingElement(horizontalData.name), horizontalData, scene); // HorizontalRegion + graphicsRegion(element.nextSiblingElement(horizontalData.name), horizontalData, scene); GraphicRegion::Data spaceData; spaceData.color = QColor::fromRgb(0, 0, 128, 80); spaceData.name = "WhitespaceSeparatorRegion"; spaceData.region = (int)GraphicRegion::WhiteSpaceSeparator; spaceData.zValue = 2; - graphicsRegion(element.nextSiblingElement(spaceData.name), spaceData, scene); // WhitespaceRegion + graphicsRegion(element.nextSiblingElement(spaceData.name), spaceData, scene); GraphicRegion::Data imageData; imageData.color = QColor::fromRgb(255, 120, 0, 80); imageData.name = "ImageRegion"; imageData.region = (int)GraphicRegion::Image; imageData.zValue = 1; - graphicsRegion(element.nextSiblingElement(imageData.name), imageData, scene); // ImageRegion + graphicsRegion(element.nextSiblingElement(imageData.name), imageData, scene); GraphicRegion::Data noiseData; noiseData.color = QColor::fromRgb(43, 39, 128, 80); noiseData.name = "NoiseRegion"; noiseData.region = (int)GraphicRegion::Noise; noiseData.zValue = 2; - graphicsRegion(element.nextSiblingElement(noiseData.name), noiseData, scene); // NoiseRegion + graphicsRegion(element.nextSiblingElement(noiseData.name), noiseData, scene); GraphicRegion::Data tableData; tableData.color = QColor::fromRgb(220, 246, 0, 80); tableData.name = "TableRegion"; tableData.region = (int)GraphicRegion::Table; tableData.zValue = 2; - graphicsRegion(element.nextSiblingElement(tableData.name), tableData, scene); // TableRegion + graphicsRegion(element.nextSiblingElement(tableData.name), tableData, scene); GraphicRegion::Data mathsData; mathsData.color = QColor::fromRgb(170, 0, 255, 80); mathsData.name = "MathsRegion"; mathsData.region = (int)GraphicRegion::Maths; mathsData.zValue = 3; - graphicsRegion(element.nextSiblingElement(mathsData.name), mathsData, scene); // MathsRegion + graphicsRegion(element.nextSiblingElement(mathsData.name), mathsData, scene); GraphicRegion::Data graphicData; graphicData.color = QColor::fromRgb(255, 0, 144, 80); graphicData.name = "GraphicRegion"; graphicData.region = (int)GraphicRegion::Graphic; graphicData.zValue = 2; - graphicsRegion(element.nextSiblingElement(graphicData.name), graphicData, scene); // GraphicRegion + graphicsRegion(element.nextSiblingElement(graphicData.name), graphicData, scene); GraphicRegion::Data chartData; chartData.color = QColor::fromRgb(0, 204, 255, 80); chartData.name = "ChartRegion"; chartData.region = (int)GraphicRegion::Chart; chartData.zValue = 2; - graphicsRegion(element.nextSiblingElement(chartData.name), chartData, scene); // ChartRegion + graphicsRegion(element.nextSiblingElement(chartData.name), chartData, scene); } -- 1.7.2.5
11Â years, 11Â months
1
0
0
0
e456b2c Try to add segmentation tasks.
by Antoine Froger
--- XmlParser/XmlParser | Bin 1161618 -> 0 bytes XmlParser/XmlParser.pro | 9 +++++++-- XmlParser/XmlParser.pro.user | 36 ++++++++++++++++++------------------ XmlParser/mainwindow.cpp | 10 ++++++++-- XmlParser/mainwindow.h | 1 + XmlParser/mainwindow.ui | 16 +++++----------- XmlParser/runner.cpp | 6 ++++++ XmlParser/runner.h | 25 +++++++++++++++++++++++++ XmlParser/toolbar.cpp | 14 ++++++++++++++ XmlParser/toolbar.h | 17 +++++++++++++++++ 10 files changed, 101 insertions(+), 33 deletions(-) delete mode 100755 XmlParser/XmlParser create mode 100644 XmlParser/runner.cpp create mode 100644 XmlParser/runner.h create mode 100644 XmlParser/toolbar.cpp create mode 100644 XmlParser/toolbar.h diff --git a/XmlParser/XmlParser b/XmlParser/XmlParser deleted file mode 100755 index 083bcef..0000000 Binary files a/XmlParser/XmlParser and /dev/null differ diff --git a/XmlParser/XmlParser.pro b/XmlParser/XmlParser.pro index 1b9bca8..812902d 100644 --- a/XmlParser/XmlParser.pro +++ b/XmlParser/XmlParser.pro @@ -4,16 +4,21 @@ QT += xml TARGET = XmlParser TEMPLATE = app +INCLUDEPATH += /lrde/home/stage/froger_a/olena/milena/ SOURCES += main.cpp \ mainwindow.cpp \ xml.cpp \ scene.cpp \ selection.cpp \ - polygonitem.cpp + polygonitem.cpp \ + runner.cpp \ + toolbar.cpp HEADERS += mainwindow.h \ region.h \ xml.h \ scene.h \ selection.h \ - polygonitem.h + polygonitem.h \ + runner.h \ + toolbar.h FORMS += mainwindow.ui diff --git a/XmlParser/XmlParser.pro.user b/XmlParser/XmlParser.pro.user index 8b1714e..bd2e795 100644 --- a/XmlParser/XmlParser.pro.user +++ b/XmlParser/XmlParser.pro.user @@ -76,14 +76,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-cEQxLJuvtW,guid=fcd36bb11605fca6a463651e005eb9dd</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-1aju09G1Pe,guid=69ec02ba8a70eadde9e5182600601b23</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-r2voTB</value> - <value type="QString">GNOME_KEYRING_PID=13274</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-792wyb</value> + <value type="QString">GNOME_KEYRING_PID=10096</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -95,16 +95,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=13349</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-vxZwL13283/agent.13283</value> + <value type="QString">SSH_AGENT_PID=10171</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-VVXGf10105/agent.10105</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmSQLVQW</value> + <value type="QString">WINDOWID=16777252</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm1TO0QW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358255777.408983-704756310</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358346215.20665-174033780</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> @@ -128,14 +128,14 @@ <valuemap type="QVariantMap"> <value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">Debug</value> <valuelist key="abstractProcess.Environment" type="QVariantList"> - <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-cEQxLJuvtW,guid=fcd36bb11605fca6a463651e005eb9dd</value> + <value type="QString">DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-1aju09G1Pe,guid=69ec02ba8a70eadde9e5182600601b23</value> <value type="QString">DESKTOP_SESSION=fluxbox</value> <value type="QString">DISPLAY=:0.0</value> <value type="QString">GDMSESSION=fluxbox</value> <value type="QString">GDM_LANG=fr_FR.UTF-8</value> <value type="QString">GDM_XSERVER_LOCATION=local</value> - <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-r2voTB</value> - <value type="QString">GNOME_KEYRING_PID=13274</value> + <value type="QString">GNOME_KEYRING_CONTROL=/tmp/keyring-792wyb</value> + <value type="QString">GNOME_KEYRING_PID=10096</value> <value type="QString">GTK_MODULES=canberra-gtk-module</value> <value type="QString">HOME=/lrde/home/stage/froger_a</value> <value type="QString">LANG=fr_FR.UTF-8</value> @@ -147,16 +147,16 @@ <value type="QString">QTDIR=/usr/share/qt4</value> <value type="QString">SHELL=/bin/bash</value> <value type="QString">SHLVL=2</value> - <value type="QString">SSH_AGENT_PID=13349</value> - <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-vxZwL13283/agent.13283</value> + <value type="QString">SSH_AGENT_PID=10171</value> + <value type="QString">SSH_AUTH_SOCK=/tmp/ssh-VVXGf10105/agent.10105</value> <value type="QString">TERM=xterm</value> <value type="QString">USER=froger_a</value> <value type="QString">USERNAME=froger_a</value> - <value type="QString">WINDOWID=10485796</value> - <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> - <value type="QString">XAUTHORITY=/tmp/.gdmSQLVQW</value> + <value type="QString">WINDOWID=16777252</value> + <value type="QString">WINDOWPATH=7:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8:8</value> + <value type="QString">XAUTHORITY=/tmp/.gdm1TO0QW</value> <value type="QString">XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/usr/share/gdm/</value> - <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358255777.408983-704756310</value> + <value type="QString">XDG_SESSION_COOKIE=b24883b9b4dbfb80ea83575b00000a11-1358346215.20665-174033780</value> <value type="QString">XPSERVERLIST=:64 </value> <value type="QString">XTERM_LOCALE=fr_FR.UTF-8</value> <value type="QString">XTERM_SHELL=/bin/bash</value> diff --git a/XmlParser/mainwindow.cpp b/XmlParser/mainwindow.cpp index 2bf9df8..6ad5237 100644 --- a/XmlParser/mainwindow.cpp +++ b/XmlParser/mainwindow.cpp @@ -6,9 +6,15 @@ MainWindow::MainWindow(QWidget *parent) : ui(new Ui::MainWindow) { ui->setupUi(this); - ui->graphicsView->setGeometry(0, 0, ui->groupBox->width(), ui->groupBox->height()); + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(ui->groupBox); + layout->addWidget(ui->textEdit); + setLayout(layout); + QVBoxLayout *gBLayout = new QVBoxLayout; + gBLayout->addWidget(ui->graphicsView); + ui->groupBox->setLayout(gBLayout); Scene *scene = new Scene(ui->graphicsView); - scene->setSceneRect(/*ui->graphicsView->geometry()*/0, 0, 1000, 1000); + scene->setSceneRect(ui->graphicsView->geometry()); ui->graphicsView->setScene(scene); Xml::parseItems("/tmp/mp00082c_gui.xml", scene); } diff --git a/XmlParser/mainwindow.h b/XmlParser/mainwindow.h index 26cc6f0..47103a3 100644 --- a/XmlParser/mainwindow.h +++ b/XmlParser/mainwindow.h @@ -3,6 +3,7 @@ #include <QMainWindow> #include <QGraphicsView> +#include <QVBoxLayout> #include <QFileDialog> #include "scene.h" #include "xml.h" diff --git a/XmlParser/mainwindow.ui b/XmlParser/mainwindow.ui index 80ee3b4..3340356 100644 --- a/XmlParser/mainwindow.ui +++ b/XmlParser/mainwindow.ui @@ -13,6 +13,9 @@ <property name="windowTitle"> <string>MainWindow</string> </property> + <property name="dockNestingEnabled"> + <bool>false</bool> + </property> <widget class="QWidget" name="centralWidget"> <widget class="QTextEdit" name="textEdit"> <property name="geometry"> @@ -27,7 +30,7 @@ <widget class="QGroupBox" name="groupBox"> <property name="geometry"> <rect> - <x>30</x> + <x>40</x> <y>10</y> <width>971</width> <height>591</height> @@ -54,7 +57,7 @@ <x>0</x> <y>0</y> <width>1035</width> - <height>25</height> + <height>23</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -65,15 +68,6 @@ </widget> <addaction name="menuFile"/> </widget> - <widget class="QToolBar" name="mainToolBar"> - <attribute name="toolBarArea"> - <enum>TopToolBarArea</enum> - </attribute> - <attribute name="toolBarBreak"> - <bool>false</bool> - </attribute> - </widget> - <widget class="QStatusBar" name="statusBar"/> <action name="actionOpen"> <property name="text"> <string>Open</string> diff --git a/XmlParser/runner.cpp b/XmlParser/runner.cpp new file mode 100644 index 0000000..3f91319 --- /dev/null +++ b/XmlParser/runner.cpp @@ -0,0 +1,6 @@ +#include "runner.h" + +Runner::Runner(QObject *parent): + QThread(parent) +{ +} diff --git a/XmlParser/runner.h b/XmlParser/runner.h new file mode 100644 index 0000000..2f303f0 --- /dev/null +++ b/XmlParser/runner.h @@ -0,0 +1,25 @@ +#ifndef RUNNER_H +#define RUNNER_H + +#include <QThread> +#include <QStringList> +#include <mln/core/image/image2d.hh> +#include <mln/value/rgb8.hh> +#include <mln/io/magick/load.hh> + +enum RunMode +{ + Demat, + Export +}; + +class Runner : + public QThread +{ + //Q_OBJECT + + public: + explicit Runner(QObject *parent = 0); +}; + +#endif // RUNNER_H diff --git a/XmlParser/toolbar.cpp b/XmlParser/toolbar.cpp new file mode 100644 index 0000000..4b098a5 --- /dev/null +++ b/XmlParser/toolbar.cpp @@ -0,0 +1,14 @@ +#include "toolbar.h" + +ToolBar::ToolBar(QWidget *parent): + QToolBar("ToolBar", parent) +{ + init(); +} + +void ToolBar::init() +{ + addAction(tr("Open")); + addAction(tr("Segment")); + +} diff --git a/XmlParser/toolbar.h b/XmlParser/toolbar.h new file mode 100644 index 0000000..91aa338 --- /dev/null +++ b/XmlParser/toolbar.h @@ -0,0 +1,17 @@ +#ifndef TOOLBAR_H +#define TOOLBAR_H + +#include <QToolBar> + +class ToolBar : + public QToolBar +{ + public: + explicit ToolBar(QWidget *parent = 0); + explicit ToolBar(const QString& title, QWidget *parent = 0); + + private: + void init(); +}; + +#endif // TOOLBAR_H -- 1.7.2.5
11Â years, 11Â months
1
0
0
0
← Newer
1
...
146
147
148
149
150
151
152
...
963
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
Results per page:
10
25
50
100
200