-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWTVisualizedTree.h
More file actions
117 lines (95 loc) · 3.11 KB
/
WTVisualizedTree.h
File metadata and controls
117 lines (95 loc) · 3.11 KB
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
/*
* header file for WTVisualizedTree class
* Original by: christian moellinger <ch.moellinger@gmail.com>
* Modified by: Chung-Yeon Lee <cylee@bi.snu.ac.kr> and Beom-Jin Lee <bjlee@bi.snu.ac.kr>
* 03/2011 - 06/2011 Project "InfoVis: Word Tree"
* 11/2013 - 12/2013 Project "InfoVis: Word Tree ++"
*/
#ifndef WTVISUALIZEDTREE_H
#define WTVISUALIZEDTREE_H
#include <QVector>
#include <QMap>
#include <QString>
/*! 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)
*/
class WTVisualizedTree
{
public:
/*! \name Public types */
//@{
/// a struct which holds all necessary info about a word
struct TVisualizedWordInfo
{
double dLeft;
double dTop;
int iWidth;
int iHeight;
int iFontSize;
QString sWord;
QString sPhrase;
bool bIsFirstElement;
};
/// a struct which holds all necessary info about a connection line
struct TVisualizedLineInfo
{
double dX1, dY1;
double dX2, dY2;
/// the code of the word where the line begins
long long int lStartWord;
/// the code of the word where the line ends
long long int lEndWord;
};
//@}
/*! \name Construction / Destruction */
//@{
/// Constructor
WTVisualizedTree(QString sSearchPhrase);
//@}
/*! \name Public methods */
//@{
/// this method adds a word to the visualized tree
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 connection line to the visualized tree
void AddRenderedLine(double dX1,
double dY1,
double dX2,
double dY2,
long long int lStartChar,
long long int lEndChar);
//@}
/*! \name Public attributes */
//@{
/// this method returns the connection lines
QVector<TVisualizedLineInfo> GetRenderedLines() { return m_vRenderedLines; };
/// 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)
QMap<long long int, TVisualizedWordInfo> *GetInfoMap() { return &m_mInfoMap; };
/// writes the word under the mouse click to sResult and "true" as return value if there
/// is any, else it returns false
bool GetWordUnderMouseClick(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
bool GetPhraseUnderMouseClick(int iX, int iY, QString &sResult);
/// returns the phrase which was used to generate this tree
QString GetSearchPhrase() { return m_sSearchPhrase; };
//@}
QString m_sSearchPhrase;
private:
/*! \name Private member variables */
//@{
QMap<long long int, TVisualizedWordInfo> m_mInfoMap;
QVector<TVisualizedLineInfo> m_vRenderedLines;
//@}
};
#endif // WTVISUALIZEDTREE_H