-
Notifications
You must be signed in to change notification settings - Fork 2
/
disp.cpp
46 lines (37 loc) · 1.04 KB
/
disp.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
#include <QPainter>
#include "disp.h"
#include "ui_disp.h"
Disp::Disp(vrok::VUMeter *meter, QWidget *parent) : QWidget(parent), ui(new Ui::Disp), _meter(meter) {
timer.start(1);
connect(&timer, SIGNAL(timeout()), this, SLOT(draw()));
ui->setupUi(this);
}
void Disp::paintEvent(QPaintEvent *e) {
QPainter painter(this);
QPen pen;
pen.setWidth(10);
double val[2], clip[2];
_meter->GetValues(0, val[0], clip[0]);
_meter->GetValues(1, val[1], clip[1]);
vrok::Clip(val[0], 0.0, 1.0);
vrok::Clip(val[1], 0.0, 1.0);
painter.setPen(pen);
painter.drawLine(0, 20, val[0] * 100, 20);
painter.drawLine(0, 40, val[1] * 100, 40);
QColor color1("red"), color2("red");
color1.setAlpha(clip[0] * 255);
color2.setAlpha(clip[1] * 255);
pen.setColor(color1);
painter.setPen(pen);
painter.drawLine(100, 20, 110, 20);
pen.setColor(color2);
painter.setPen(pen);
painter.drawLine(100, 40, 110, 40);
painter.end();
}
Disp::~Disp() {
delete ui;
}
void Disp::draw() {
repaint();
}