WordTree
|
00001 /* 00002 * header file for WTVisualizedTree class 00003 * written by: christian moellinger <ch.moellinger@gmail.com> 00004 * 03/2011 - 06/2011 Project "InfoVis: Word Tree" 00005 */ 00006 00007 #ifndef WTVISUALIZEDTREE_H 00008 #define WTVISUALIZEDTREE_H 00009 00010 #include <QVector> 00011 #include <QMap> 00012 #include <QString> 00013 00014 /*! This class represents a visualized tree. 00015 A visualized tree is an object which stores all the necessary information 00016 to draw the tree (words and lines together with their positions) 00017 */ 00018 class WTVisualizedTree 00019 { 00020 public: 00021 /*! \name Public types */ 00022 //@{ 00023 /// a struct which holds all necessary info about a word 00024 struct TVisualizedWordInfo 00025 { 00026 double dLeft; 00027 double dTop; 00028 int iWidth; 00029 int iHeight; 00030 int iFontSize; 00031 00032 QString sWord; 00033 QString sPhrase; 00034 00035 bool bIsFirstElement; 00036 }; 00037 00038 /// a struct which holds all necessary info about a connection line 00039 struct TVisualizedLineInfo 00040 { 00041 double dX1, dY1; 00042 double dX2, dY2; 00043 00044 /// the code of the word where the line begins 00045 long long int lStartWord; 00046 00047 /// the code of the word where the line ends 00048 long long int lEndWord; 00049 }; 00050 //@} 00051 00052 /*! \name Construction / Destruction */ 00053 //@{ 00054 /// Constructor 00055 WTVisualizedTree(QString sSearchPhrase); 00056 //@} 00057 00058 00059 /*! \name Public methods */ 00060 //@{ 00061 /// this method adds a word to the visualized tree 00062 void AddRenderedWord(QVector<long long int> vWordIds, 00063 QString sWord, 00064 QString sPhrase, 00065 double dLeft, 00066 double dTop, 00067 int iWidth, 00068 int iHeight, 00069 int iFontSize); 00070 00071 /// this method adds a connection line to the visualized tree 00072 void AddRenderedLine(double dX1, 00073 double dY1, 00074 double dX2, 00075 double dY2, 00076 long long int lStartChar, 00077 long long int lEndChar); 00078 //@} 00079 00080 00081 /*! \name Public attributes */ 00082 //@{ 00083 /// this method returns the connection lines 00084 QVector<TVisualizedLineInfo> GetRenderedLines() { return m_vRenderedLines; }; 00085 00086 /// this method returns a info map with the word code as keys, 00087 /// for each existing word in the tree the word info is returned 00088 /// (even if some words of the input file are rendered as the same 00089 /// word in the tree, that's why the words are accessed by its code) 00090 QMap<long long int, TVisualizedWordInfo> *GetInfoMap() { return &m_mInfoMap; }; 00091 00092 /// writes the word under the mouse click to sResult and "true" as return value if there 00093 /// is any, else it returns false 00094 bool GetWordUnderMouseClick(int iX, int iY, QString &sResult); 00095 00096 /// writes the phrase under the mouse click to sResult and "true" as return value if there 00097 /// is any, else it returns false 00098 bool GetPhraseUnderMouseClick(int iX, int iY, QString &sResult); 00099 00100 /// returns the phrase which was used to generate this tree 00101 QString GetSearchPhrase() { return m_sSearchPhrase; }; 00102 //@} 00103 00104 private: 00105 /*! \name Private member variables */ 00106 //@{ 00107 QMap<long long int, TVisualizedWordInfo> m_mInfoMap; 00108 QVector<TVisualizedLineInfo> m_vRenderedLines; 00109 QString m_sSearchPhrase; 00110 //@} 00111 00112 }; 00113 00114 #endif // WTVISUALIZEDTREE_H