-
Notifications
You must be signed in to change notification settings - Fork 0
/
score.cpp
69 lines (54 loc) · 2.04 KB
/
score.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
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
#include "score.h"
#include <QDebug>
Score::Score() {
x = -100;
y = 0;
count = 0;
nameBoxLength = 100;
nameBoxWidth = 20;
noOfMeasures = 30;
instruments.resize(0);
}
void Score::addInstrument(QString name) {
Instrument* newInstrument = new Instrument();
newInstrument->name = name;
qreal width = newInstrument->nameBoxWidth;
qreal length = newInstrument->nameBoxLength;
newInstrument->nameText = scene->addText(QString(name));
newInstrument->nameText->setPos(x, y + count * width);
newInstrument->nameBox = scene->addRect(QRectF(x, y + count * width, length, width));
for (int i = 0; i < noOfMeasures; ++i) {
QGraphicsRectItem *measureBox = scene->addRect(QRectF(x + length + i*width, y + count * width, width, width));
measureBox->setToolTip(name + " measure " + QString("%1").arg(i + 1));
newInstrument->measureBoxes.push_back(measureBox);
}
instruments.push_back(newInstrument);
count++;
}
void Score::addTempo() {
tempo = new Tempo();
qreal width = tempo->nameBoxWidth;
qreal length = tempo->nameBoxLength;
tempo->x = x;
tempo->y = y + count * width;
tempo->nameText = scene->addText(tempo->name);
tempo->nameText->setPos(x, y + count * width);
tempo->nameBox = scene->addRect(QRectF(x, y + count * width, length, width));
tempo->nameBox->setBrush(QBrush(tempo->nameColor));
for (int i = 0; i < noOfMeasures; ++i) {
tempo->measureBoxes.push_back(scene->addRect(QRectF(x + length + i*width, y + count * width, width, width)));
}
y += 5;
count++;
}
void Score::addTitle() {
qreal width = nameBoxWidth;
qreal length = nameBoxLength;
scene->addRect(x, y, length + noOfMeasures * width, width);
scene->addText("Measures")->setPos(x, y);
for (int i = 1; i <= noOfMeasures; i += 4) {
scene->addText(QString("%1").arg(i))->setPos(x + length + (i-1)*width, y);
}
y += 5;
count++;
}