Ground-Truthing GUI  1.0
rectanglewindow.h
1 
25 #ifndef RECTANGLEWINDOW
26 #define RECTANGLEWINDOW
27 
28 #include <QtextEdit>
29 #include <QLineEdit>
30 #include <QVBoxLayout>
31 #include <QPushButton>
32 #include <QObject>
33 #include <QLabel>
34 
35 #include <QWidget>
36 #include "rectangledraw.h"
37 #include <QDebug>
38 #include "filewriter.h"
39 #include "addiconpicture.h"
40 #include "filereader.h"
41 
42 class RectangleWindow:public QWidget {
43 
44  Q_OBJECT
45 
46 private:
47 
48  // The rectangle associated to the dialog window
49  RectangleDraw *rectangle;
50 
51  // Create the annotation space
52  QTextEdit* textEdit;
53 
54  // Create the space where the user can insert the word number
55  QLineEdit *lineEdit_word;
56 
57  // Create the space where the user can insert the line number
58  QLineEdit *lineEdit_line;
59 
60  // Create a vertical layout
61  QVBoxLayout* layout;
62 
63  // Create a horizontal layout containing the rectangle id
64  QHBoxLayout *id_layout;
65 
66  // Create a horizontal layout containing the line insertion
67  QHBoxLayout *line_layout;
68 
69  // Create a horizontal layout containing the word insertion
70  QHBoxLayout *word_layout;
71 
72  // Create a horizontal layout containg the annotation insertion
73  QHBoxLayout *annotation_layout;
74 
75  // Create a horizontal layout containing the push button
76  QHBoxLayout *push_layout;
77 
78  // Create a push button
79  QPushButton* push;
80 
81  // Create the label which is going to display the rectangle id
82  QLabel *id_label_show;
83 
84  // Create the label displaying the text "Id:"
85  QLabel *id_text;
86 
87  // Create the label displaying the text "Line:"
88  QLabel *line_label;
89 
90  // Create the label displaying the text "Word:"
91  QLabel *word_label;
92 
93  // Create the lable displaying the text "Annotation:"
94  QLabel *annotation_label;
95 
96  // The icon picture
97  AddIconPicture *icon;
98 
99  // The scene
100  QGraphicsScene *scene;
101 
102  QString str;
103 
104  // The file writer
105  FileWriter *filewriter;
106 
107 
108 public:
109 
115  RectangleWindow(RectangleDraw* rectangle_1,FileWriter *filewriter_1,QGraphicsScene *scene_1):rectangle(rectangle_1),
116  filewriter(filewriter_1),scene(scene_1)
117  {
118  textEdit=new QTextEdit();
119  textEdit->setMaximumSize(100,50);
120  textEdit->setText(rectangle->getAnnotation());
121  lineEdit_word=new QLineEdit();
122  lineEdit_line=new QLineEdit();
123  lineEdit_word->setMaximumSize(100,20);
124  lineEdit_word->setText(rectangle->getWordNumber());
125 
126  lineEdit_line->setMaximumSize(100,20);
127  lineEdit_line->setText(rectangle->getLineNumber());
128 
129  line_label=new QLabel(this);
130  line_label->setText("Line Number:");
131  word_label=new QLabel(this);
132  word_label->setText("Word Number:");
133 
134  id_label_show=new QLabel(this);
135  id_label_show->setAlignment(Qt::AlignLeft);
136  id_text=new QLabel(this);
137  id_text->setText("Id:");
138 
139  annotation_label=new QLabel();
140  annotation_label->setText("Comments:");
141 
142  push=new QPushButton();
143  push->setText("Add Note");
144 
145  layout=new QVBoxLayout(this);
146  id_layout=new QHBoxLayout();
147  line_layout=new QHBoxLayout();
148  word_layout=new QHBoxLayout();
149  annotation_layout=new QHBoxLayout();
150  push_layout=new QHBoxLayout();
151 
152  id_label_show->setNum(rectangle->getId());
153 
154  id_layout->addWidget(id_text);
155  id_layout->addWidget(id_label_show);
156  line_layout->addWidget(line_label);
157  line_layout->addWidget(lineEdit_line);
158  word_layout->addWidget(word_label);
159  word_layout->addWidget(lineEdit_word);
160  annotation_layout->addWidget(annotation_label);
161  annotation_layout->addWidget(textEdit);
162  push_layout->addWidget(push);
163 
164  layout->addLayout(id_layout);
165  layout->addLayout(line_layout);
166  layout->addLayout(word_layout);
167  layout->addLayout(annotation_layout);
168  layout->addLayout(push_layout);
169 
170  this->setWindowTitle("Rectangle "+QString::number(rectangle->getId()));
171  this->show();
172 
173  QObject::connect(textEdit,SIGNAL(textChanged()),this,SLOT(textChangedSlot()));
174  QObject::connect(lineEdit_word,SIGNAL(textChanged(QString)),this,SLOT(wordChangedSlot(QString)));
175  QObject::connect(lineEdit_line,SIGNAL(textChanged(QString)),this,SLOT(lineChangedSlot(QString)));
176  QObject::connect(push,SIGNAL(clicked()),this, SLOT(quit()));
177  }
178 
179 private slots:
180 
184  void quit();
185 
189  void textChangedSlot();
190 
194  void wordChangedSlot(QString word);
195 
199  void lineChangedSlot(QString line);
200 };
201 
202 #endif // RECTANGLEWINDOW
203 
virtual QString getWordNumber() const
Returns the word number inserted by the user.
Definition: rectangledraw.cpp:51
RectangleWindow(RectangleDraw *rectangle_1, FileWriter *filewriter_1, QGraphicsScene *scene_1)
The constructor of the RectangleWindow class.
Definition: rectanglewindow.h:115
virtual QString getLineNumber() const
Returns the line number inserted by the user.
Definition: rectangledraw.cpp:26
Adds an icon at the top-left corner of a rectangle.
Definition: addiconpicture.h:34
virtual int getId() const
Returns the rectangle ID.
Definition: rectangledraw.cpp:5
Write in a text file.
Definition: filewriter.h:28
The annotation window.
Definition: rectanglewindow.h:42
Describes a rectangle drawn by the user.
Definition: rectangledraw.h:34
virtual QString getAnnotation() const
Returns the comment inserted by the user.
Definition: rectangledraw.cpp:36