-
Notifications
You must be signed in to change notification settings - Fork 0
/
SignalerGraphicsView.cpp
77 lines (67 loc) · 2.14 KB
/
SignalerGraphicsView.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
70
71
72
73
74
75
76
77
#include "SignalerGraphicsView.h"
#include "CreateHandler.h"
#include "DeleteHandler.h"
#include "ResizeHandler.h"
#include "ZoomHandler.h"
sgv::SignalerGraphicsView::SignalerGraphicsView(QWidget* a_parent)
: QGraphicsView(a_parent)
, m_create_handler( new sgv::CreateHandler(*this) )
, m_delete_handler( new sgv::DeleteHandler(*this) )
, m_resize_handler( new sgv::ResizeHandler(*this) )
, m_zoom_handler ( new sgv::ZoomHandler (*this) )
{
// For proper mouse move handling
setMouseTracking(true);
}
void sgv::SignalerGraphicsView::setResizeAreaSize(int a_size)
{
Q_ASSERT(a_size >= 1);
m_resize_handler->setAreaSize(a_size);
}
void sgv::SignalerGraphicsView::setMinimumItemWidth(int a_width)
{
Q_ASSERT(a_width >= 1);
m_resize_handler->setMinimumWidth(a_width);
}
void sgv::SignalerGraphicsView::setMinimumItemHeight(int a_height)
{
Q_ASSERT(a_height >= 1);
m_resize_handler->setMinimumHeight(a_height);
}
void sgv::SignalerGraphicsView::setResizeModes(sgv::ResizeMode a_mode)
{
m_resize_handler->setModes(a_mode);
}
void sgv::SignalerGraphicsView::mousePressEvent(QMouseEvent* a_event)
{
m_create_handler->mousePressEvent(a_event);
m_delete_handler->mousePressEvent(a_event);
m_resize_handler->mousePressEvent(a_event);
if (!m_resize_handler->isResizing())
// Prevent default handling (moving, selecting)
QGraphicsView::mousePressEvent(a_event);
}
void sgv::SignalerGraphicsView::mouseMoveEvent(QMouseEvent* a_event)
{
m_resize_handler->mouseMoveEvent(a_event);
m_delete_handler->mouseMoveEvent(a_event);
QGraphicsView ::mouseMoveEvent(a_event);
}
void sgv::SignalerGraphicsView::mouseReleaseEvent(QMouseEvent* a_event)
{
m_create_handler->mouseReleaseEvent(a_event);
m_delete_handler->mouseReleaseEvent(a_event);
m_resize_handler->mouseReleaseEvent(a_event);
QGraphicsView::mouseReleaseEvent(a_event);
}
void sgv::SignalerGraphicsView::wheelEvent(QWheelEvent* a_event)
{
m_zoom_handler->wheelEvent(a_event);
QGraphicsView::wheelEvent(a_event);
}
QPointF sgv::SignalerGraphicsView::scenePosition(const QMouseEvent* a_event)
{
QPoint local_pos = a_event->localPos().toPoint();
QPointF scene_pos = mapToScene(local_pos);
return scene_pos;
}