-
Notifications
You must be signed in to change notification settings - Fork 1
/
position.cpp
39 lines (33 loc) · 917 Bytes
/
position.cpp
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
/*!
* \file position.cpp
* \author Simon Coakley
* \date 2012
* \copyright Copyright (c) 2012 University of Sheffield
* \brief Implementation of position
*/
#include "./position.h"
Position::Position() {
positionVariable = "";
op = "";
opVariable = "";
opValue = 0.0;
useOp = true;
useVariable = true;
}
void Position::paint(QPainter *painter, const QRect &rect,
const QPalette &/*palette*/, EditMode /*mode*/) const {
painter->save();
painter->setRenderHint(QPainter::Antialiasing, true);
QString text;
if (useVariable) {
text = positionVariable;
if (opValue != 0.0) {
if (opValue > 0.0) text.append("+");
text.append(QString("%1").arg(opValue));
}
} else {
text.append(QString("%1").arg(opValue));
}
painter->drawText(rect, Qt::AlignCenter, text);
painter->restore();
}