-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWTBackend.h
More file actions
133 lines (111 loc) · 3.53 KB
/
WTBackend.h
File metadata and controls
133 lines (111 loc) · 3.53 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
* header file for WTBackend 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 WTBACKEND_H
#define WTBACKEND_H
#include <QObject>
#include <QSharedPointer>
#include <QStringList>
#include <QVector>
#include <QMap>
class WTVisualizedTree;
class WTBackend : public QObject
{
Q_OBJECT
public:
/*! \name Public types */
//@{
//int filterCheck = 0;
/// a coded phrase, which stores the whole phrase,
/// a list of all words, and for each word an unique code
struct TCodedPhrase
{
QStringList m_lsWords;
QVector<long long int> m_vCodesForWords;
};
struct Initial_vis_data_set
{
QStringList Words;
long long int counter_val;
};
//@}
//@{
QString initWord;
QList< QList<QByteArray> > Total_SplittedPhrase;
//@}
/*! \name Constructor / Destructor */
//@{
/// Constructor
explicit WTBackend(QObject *parent = 0);
//@}
/*! \name Public methods */
//@{
/// This method creates a word tree, which can be visualized with WTTreeVisualizer
QSharedPointer<WTVisualizedTree> CreateWordTree(QString sSearchPhrase);
//@}
public slots:
/*! \name Public slots */
//@{
/// this method loads a given file
void LoadFile(QString sFilename, bool filtered);
//@}
private:
/*! \name Private types */
//@{
/// this class represents a node in the word tree
class TItlNode
{
public:
/*! \name Public attributes */
//@{
/// returns the word list
QStringList GetWordList() { return m_lsWords; }
/// returns the number of children
int NumChildren() const { return m_vChildren.size(); }
/// returns a vector with the children
QVector<QSharedPointer<TItlNode> > GetChildren() { return m_vChildren; }
//@}
/*! \name Public methods */
//@{
/// adds a new child
void AddChild(QSharedPointer<TItlNode> spNode) { m_vChildren.push_back(spNode); }
//@}
/*! \name Public variables, should be moved to private */
//@{
QStringList m_lsWords;
QString m_sPhrase;
QMap<int, QVector<long long int> > m_mCodesForWords;
//@}
private:
/*! \name Private member variables */
//@{
QVector<QSharedPointer<TItlNode> > m_vChildren;
//@}
};
//@}
/*! \name Internal methods */
//@{
/// this method creates a word list of the given phrase
QStringList ItlCreateWordList(QString sPhrase);
/// this method recursively draws a given node in the given visualized tree object
void ItlDrawNode(int iStartX,
int iStartY,
int &rUsedHeight,
QSharedPointer<WTBackend::TItlNode> spRootNode,
QSharedPointer<WTVisualizedTree> spVisualizedTree);
/// this method generates a phrase tree, that means a data structure with connected nodes
QSharedPointer<WTBackend::TItlNode> ItlCreatePhraseTree(QVector<TCodedPhrase> lPhrases);
/// this medhod recursively generates a node from the given phrases
QSharedPointer<TItlNode> ItlCreateNode(QVector<TCodedPhrase> lCodedPhrases, int iPosition);
//@}
/*! \name Internal member variables */
//@{
/// the coded phrases of the currently loaded file
QVector<TCodedPhrase> m_vCodedPhrases;
//@}
};
#endif // WTBACKEND_H