23 #include <QGraphicsScene>
24 #include <QGraphicsSceneMouseEvent>
36 setCursor(QCursor(Qt::OpenHandCursor));
48 this->
topLeft->setCursor(QCursor(Qt::SizeFDiagCursor));
49 this->
bottomRight->setCursor(QCursor(Qt::SizeFDiagCursor));
50 this->
topRight->setCursor(QCursor(Qt::SizeBDiagCursor));
51 this->
bottomLeft->setCursor(QCursor(Qt::SizeBDiagCursor));
52 this->
leftCenter->setCursor(QCursor(Qt::SizeHorCursor));
53 this->
rightCenter->setCursor(QCursor(Qt::SizeHorCursor));
54 this->
topCenter->setCursor(QCursor(Qt::SizeVerCursor));
55 this->
bottomCenter->setCursor(QCursor(Qt::SizeVerCursor));
78 setCursor(QCursor(Qt::CrossCursor));
125 if (event->button() == Qt::LeftButton) {
127 setCursor(QCursor(Qt::ClosedHandCursor));
134 QPointF delta =
event->scenePos() -
event->lastScenePos();
135 moveBy(delta.x(), delta.y());
137 prepareGeometryChange();
138 QPointF size =
event->scenePos() - scenePos();
139 mainRect->setRect(0, 0, size.x(), size.y());
153 if (event->button() == Qt::LeftButton) {
154 setCursor(QCursor(Qt::OpenHandCursor));
156 QPointF delta = (
event->scenePos() -
startPos);
165 setPos(normalized.x(), normalized.y());
189 if (event->button() == Qt::LeftButton)
198 QPointF delta =
event->scenePos() -
event->lastScenePos();
199 delta.rx() *= qAbs(x);
200 delta.ry() *= qAbs(y);
203 bool increaseX = ((x < 0) == (delta.x() < 0));
204 bool increaseY = ((y < 0) == (delta.y() < 0));
206 if ((delta.x() < 0 && increaseX) || (delta.x() >= 0 && !increaseX)) {
207 moveBy(delta.x(), 0);
211 if ((delta.y() < 0 && increaseY) || (delta.y() >= 0 && !increaseY)) {
212 moveBy(0, delta.y());
229 if (event->button() == Qt::LeftButton)
236 return QPoint(-1, -1);
239 return QPoint(0, -1);
242 return QPoint(1, -1);
254 return QPoint(-1, 1);
257 return QPoint(-1, 0);
277 handle->setPen(QPen(Qt::blue));
278 handle->setBrush(Qt::NoBrush);
280 scene->addItem(handle);
283 handle->installSceneEventFilter(
this);
299 QGraphicsSceneMouseEvent* mouseEvent =
static_cast<QGraphicsSceneMouseEvent*
>(event);
301 switch (event->type()) {
302 case QEvent::GraphicsSceneMousePress:
304 case QEvent::GraphicsSceneMouseMove:
306 case QEvent::GraphicsSceneMouseRelease:
308 case QEvent::GraphicsSceneMouseDoubleClick:
317 QGraphicsSceneMouseEvent* mouseEvent =
static_cast<QGraphicsSceneMouseEvent*
>(event);
320 if (multiplier.isNull())
323 switch (event->type()) {
324 case QEvent::GraphicsSceneMousePress:
326 case QEvent::GraphicsSceneMouseMove:
328 case QEvent::GraphicsSceneMouseRelease: