-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphics.cpp
More file actions
44 lines (40 loc) · 1.37 KB
/
graphics.cpp
File metadata and controls
44 lines (40 loc) · 1.37 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
40
41
42
43
44
#include "mainwindow.h"
#include "graphics.h"
#include <QGraphicsView>
void MScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent){
cout << "Mouse pressed on scene" << endl;
QGraphicsScene::mousePressEvent(mouseEvent); // allow propagation to items
/*if (!views().isEmpty())
{
cout << "translate 10,10" << endl;
views()[0]->translate(10, 10);
}*/
QGraphicsItem* itemSelected = itemAt(mouseEvent->scenePos(), QTransform());
if (itemSelected)
{
if (itemSelected->isSelected()) cout << "Item selected";
}
if (itemSelected == mouseGrabberItem())
{
cout << " and grabber!";
}
cout << endl;
}
void MScene::mouseMoveEvent(QGraphicsSceneMouseEvent* mouseEvent){
cout << "Mouse moved on scene" << endl;
QGraphicsScene::mouseMoveEvent(mouseEvent); // propagation to items
if (MainWindow::viewMode() == ViewMode::MOVE)
{
// Move the scene
if (!views().isEmpty())
{
QPointF pointTmp = mouseEvent->scenePos() - mouseEvent->lastScenePos();
cout << "Delta: " << pointTmp.x() << " " << pointTmp.y() << endl;
//views()[0]->translate(delta.x(), delta.y()); // FIXME
}
}
}
void MPixmapItem::mousePressEvent(QGraphicsSceneMouseEvent *event){
cout << "Mouse pressed on pixmap" << endl;
QGraphicsPixmapItem::mousePressEvent(event);
}