last-svn-commit-740-g6e9c307 Identify separators among non-text components.

* scribo/core/tag/component.hh: New Separator type. * scribo/primitive/identify.hh: identify non-text components type according criterions. --- scribo/ChangeLog | 9 +++ scribo/scribo/core/tag/component.hh | 6 ++- .../{link/internal/dmax_default.hh => identify.hh} | 58 +++++++++----------- 3 files changed, 40 insertions(+), 33 deletions(-) copy scribo/scribo/primitive/{link/internal/dmax_default.hh => identify.hh} (60%) diff --git a/scribo/ChangeLog b/scribo/ChangeLog index 37d0ea8..2ba7d58 100644 --- a/scribo/ChangeLog +++ b/scribo/ChangeLog @@ -1,5 +1,14 @@ 2011-01-25 Guillaume Lazzara <z@lrde.epita.fr> + Identify separators among non-text components. + + * scribo/core/tag/component.hh: New Separator type. + + * scribo/primitive/identify.hh: identify non-text components + type according criterions. + +2011-01-25 Guillaume Lazzara <z@lrde.epita.fr> + Handle paragraphs correctly in scribo-viewer. * demo/viewer/common.hh, diff --git a/scribo/scribo/core/tag/component.hh b/scribo/scribo/core/tag/component.hh index f2fb059..f773932 100644 --- a/scribo/scribo/core/tag/component.hh +++ b/scribo/scribo/core/tag/component.hh @@ -57,7 +57,8 @@ namespace scribo Character, Separator, Noise, - Punctuation + Punctuation, + Image }; # ifndef MLN_INCLUDE_ONLY @@ -106,6 +107,9 @@ namespace scribo case Punctuation: str = "Punctuation"; break; + case Image: + str = "Image"; + break; } return ostr << str; diff --git a/scribo/scribo/primitive/link/internal/dmax_default.hh b/scribo/scribo/primitive/identify.hh similarity index 60% copy from scribo/scribo/primitive/link/internal/dmax_default.hh copy to scribo/scribo/primitive/identify.hh index b4106a9..7d0c3e6 100644 --- a/scribo/scribo/primitive/link/internal/dmax_default.hh +++ b/scribo/scribo/primitive/identify.hh @@ -1,4 +1,4 @@ -// Copyright (C) 2010 EPITA Research and Development Laboratory (LRDE) +// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE) // // This file is part of Olena. // @@ -23,15 +23,13 @@ // exception does not however invalidate any other reasons why the // executable file might be covered by the GNU General Public License. -#ifndef SCRIBO_PRIMITIVE_LINK_INTERNAL_DMAX_DEFAULT_HH -# define SCRIBO_PRIMITIVE_LINK_INTERNAL_DMAX_DEFAULT_HH +#ifndef SCRIBO_PRIMITIVE_IDENTIFY_HH +# define SCRIBO_PRIMITIVE_IDENTIFY_HH -/// \file -/// -/// Default class for dmax functors. - -# include <scribo/primitive/link/internal/dmax_functor_base.hh> +/*! \brief try to determine the type of a component. +\fixme Add support for more component type (graphic, images, ...) + */ namespace scribo { @@ -39,46 +37,42 @@ namespace scribo namespace primitive { - namespace link + template <typename L> + component_set<L> + identify(const component_set<L> comps) { + trace::entering("scribo::primitive::identify"); - namespace internal - { + mln_assertion(comps.is_valid()); + component_set<L> output = comps.duplicate(); - /// \brief Base class for dmax functors. - class dmax_default : public dmax_functor_base<dmax_default> + for_all_comps(c, comps) + if (comps(c).is_valid()) { - typedef dmax_functor_base<dmax_default> super_; + float + min = comps(c).bbox().height(), + max = comps(c).bbox().width(); - public: - dmax_default(const float& dmax_factor); + if (comps(c).bbox().width() < comps(c).bbox().height()) + std::swap(min, max); - protected: - using super_::dmax_factor_; - }; + if (max/min > 10) + output(c).update_type(component::Separator); + } + trace::exiting("scribo::primitive::identify"); + return output; + } # ifndef MLN_INCLUDE_ONLY - inline - dmax_default::dmax_default(const float& dmax_factor) - : super_(dmax_factor) - { - } - # endif // ! MLN_INCLUDE_ONLY - - } // end of namespace scribo::primitive::link::internal - - } // end of namespace scribo::primitive::link - } // end of namespace scribo::primitive } // end of namespace scribo - -#endif // ! SCRIBO_PRIMITIVE_LINK_INTERNAL_DMAX_DEFAULT_HH +#endif // ! SCRIBO_PRIMITIVE_IDENTIFY_HH -- 1.5.6.5
participants (1)
-
Guillaume Lazzara