WordTree
Data Structures
WTVisualizedTree Class Reference

#include <WTVisualizedTree.h>

Data Structures

struct  TVisualizedLineInfo
 a struct which holds all necessary info about a connection line More...
struct  TVisualizedWordInfo
 a struct which holds all necessary info about a word More...

Public Member Functions

Construction / Destruction
 WTVisualizedTree (QString sSearchPhrase)
 Constructor.
Public methods
void AddRenderedWord (QVector< long long int > vWordIds, QString sWord, QString sPhrase, double dLeft, double dTop, int iWidth, int iHeight, int iFontSize)
 this method adds a word to the visualized tree
void AddRenderedLine (double dX1, double dY1, double dX2, double dY2, long long int lStartChar, long long int lEndChar)
 this method adds a connection line to the visualized tree
Public attributes
QVector< TVisualizedLineInfoGetRenderedLines ()
 this method returns the connection lines
QMap< long long int,
TVisualizedWordInfo > * 
GetInfoMap ()
bool GetWordUnderMouseClick (int iX, int iY, QString &sResult)
bool GetPhraseUnderMouseClick (int iX, int iY, QString &sResult)
QString GetSearchPhrase ()
 returns the phrase which was used to generate this tree

Detailed Description

This class represents a visualized tree. A visualized tree is an object which stores all the necessary information to draw the tree (words and lines together with their positions)


Member Function Documentation

QMap<long long int, TVisualizedWordInfo>* WTVisualizedTree::GetInfoMap ( ) [inline]

this method returns a info map with the word code as keys, for each existing word in the tree the word info is returned (even if some words of the input file are rendered as the same word in the tree, that's why the words are accessed by its code)

{ return &m_mInfoMap; };
bool WTVisualizedTree::GetPhraseUnderMouseClick ( int  iX,
int  iY,
QString &  sResult 
)

writes the phrase under the mouse click to sResult and "true" as return value if there is any, else it returns false

{
    for (QMap<long long int, TVisualizedWordInfo>::iterator iter=m_mInfoMap.begin(); iter != m_mInfoMap.end(); iter++)
    {
        if (iter.value().dLeft < iX && (iter.value().dLeft + iter.value().iWidth > iX) &&
                iter.value().dTop < iY && (iter.value().dTop + iter.value().iHeight > iY))
        {
            sResult = iter.value().sPhrase;

            // this is a hack to remove the wrong space before commas
            for (int i=1; i < sResult.length(); i++)
            {
                if (sResult.at(i) == ',' && sResult.at(i-1) == ' ')
                    sResult = sResult.remove(i - 1, 1);
            }
            return true;
        }
    }

    return false;
}
bool WTVisualizedTree::GetWordUnderMouseClick ( int  iX,
int  iY,
QString &  sResult 
)

writes the word under the mouse click to sResult and "true" as return value if there is any, else it returns false

{
    for (QMap<long long int, TVisualizedWordInfo>::iterator iter=m_mInfoMap.begin(); iter != m_mInfoMap.end(); iter++)
    {
        if (iter.value().dLeft < iX && (iter.value().dLeft + iter.value().iWidth > iX) &&
                iter.value().dTop < iY && (iter.value().dTop + iter.value().iHeight > iY))
        {
            sResult = iter.value().sWord.trimmed();
            return true;
        }
    }

    return false;
}

The documentation for this class was generated from the following files:
 All Data Structures Functions Variables