-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdisplay.cpp
More file actions
39 lines (33 loc) · 1.26 KB
/
Copy pathdisplay.cpp
File metadata and controls
39 lines (33 loc) · 1.26 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
#include "display.h"
#include <QDebug>
#include <QGraphicsPixmapItem>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsView>
#include <QPixmap>
void mousePixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
// qDebug() << "Click: " << event->scenePos();
if (event->button() == Qt::LeftButton) {
emit m_displ->leftClick(event->scenePos().x(), event->scenePos().y());
}
if (event->button() == Qt::RightButton) {
emit m_displ->rightClick(event->scenePos().x(), event->scenePos().y());
}
QGraphicsItem::mousePressEvent(event);
}
Display::Display(QWidget *parent) : QGraphicsView(parent) {
m_scene = new QGraphicsScene(this);
m_item = new mousePixmapItem(this);
m_scene->addItem(m_item);
setScene(m_scene);
}
void Display::clean() { m_item->setPixmap(QPixmap()); }
void Display::loadARGB32(uint32_t *data, uint32_t width, uint32_t height) {
m_item->setPixmap(QPixmap::fromImage(
QImage((uchar *)data, width, height, QImage::Format_ARGB32)));
}
void Display::loadARGB32Scaled(uint32_t *data, uint32_t width, uint32_t height,
uint32_t scale) {
m_item->setPixmap(QPixmap::fromImage(
QImage((uchar *)data, width, height, QImage::Format_ARGB32)
.scaled(width * scale, height * scale)));
}