Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

CTextLine.h

Go to the documentation of this file.
00001 /* Copyright (C) 2004 Catherine Proulx
00002 
00003    This library is free software; you can redistribute it and/or
00004    modify it under the terms of the GNU Lesser General Public
00005    License as published by the Free Software Foundation; either
00006    version 2.1 of the License, or (at your option) any later version.
00007    
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Lesser General Public License for more details.
00012    
00013    You should have received a copy of the GNU Lesser General Public
00014    License along with this library; if not, write to the Free Software
00015    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 */
00017 
00018 #ifndef _CTEXTLINE_
00019 #define _CTEXTLINE_
00020 
00021 #include <list>
00022 #include "Object.h"
00023 #include "CSymbol.h"
00024 
00025 namespace RobotFlow {
00026 
00027 bool IsBefore(void*, void*);
00028 
00029 ///////////////////////////////////////////////////////////////////////////////
00030 // CTextLine.
00031 //
00032 //  A CTextLine is an object describing a line of text. In contains a list of CRect
00033 //  describing the letters.
00034 //
00035 ///////////////////////////////////////////////////////////////////////////////
00036 
00037 class CTextLine : public FD::Object {
00038     
00039    public:
00040 
00041    CTextLine();
00042 
00043    // Ctor with a initializing CRect to set the line parameters
00044    CTextLine(CSymbol & firstLetter, double verticalTolerance, double horizontalTolerance);
00045 
00046    // Dtor Destructor
00047    virtual ~CTextLine();
00048 
00049    // Sorting the letters from left to right
00050    void Sort();
00051 
00052    // Insert a new letter in line
00053    void Insert(CSymbol &);
00054 
00055    // Checks if letter is part of current line according to its y coordinates
00056    bool Contains(CSymbol &);
00057 
00058    // Get the std::string corresponding to the sorted line
00059    void GetString(std::string & resultString);
00060 
00061    // Get the string corresponding to the sorted line
00062    void GetString_v2(std::string & resultString, std::list<std::vector<std::vector<float> > >&vect_list);
00063 
00064    // Print Object
00065    void printOn(std::ostream &out = std::cout) const;
00066 
00067    // Get the line vertical position (centerY of first character)
00068    int GetVerticalPosition() { return (mMinY + mMaxY)/2; }
00069 
00070    std::list<CSymbol*>& getSymbols(){return mLetterList;}
00071 
00072  private:
00073 
00074   // Determines whether there's a space between two characters
00075   bool SpacePresentBetween(const CSymbol&, const CSymbol&);
00076 
00077   // Minimum and minimum vertical center value for a letter to be considered
00078   // part of the line (upper bound and lower bounds)
00079   int mMinY;
00080   int mMaxY;
00081 
00082   // Maximum and minimum heights for a letter to be considered part of the line
00083   int mMinHeight;
00084   int mMaxHeight;
00085 
00086   // Average width of characters: used for deciding what is a space
00087   int mAverageWidth;
00088 
00089   // Tolerance on the regularity of the line
00090   // (even character height and vertical alignement)
00091   double mVerticalTolerance;
00092 
00093   // Tolerance on the spacing between characters
00094   double mHorizontalTolerance;
00095 
00096 
00097   ///The list of cells
00098   std::list<CSymbol*> mLetterList;
00099  
00100 };
00101 
00102 }//namespace RobotFlow
00103 #endif

Generated on Wed Oct 5 14:36:12 2005 for RobotFlow by  doxygen 1.4.4