30 #include <QGraphicsView>
31 #include <QWheelEvent>
39 using namespace YACS::HMI;
41 GraphicsView::GraphicsView(
QWidget *parent)
48 setTransformationAnchor(QGraphicsView::AnchorViewCenter);
57 DEBTRACE(
"GraphicsView::onViewFitAll");
66 DEBTRACE(
"GraphicsView::onViewFitArea");
67 Scene* myScene =
dynamic_cast<Scene*
>(scene());
74 DEBTRACE(
"GraphicsView::onViewZoom");
75 Scene* myScene =
dynamic_cast<Scene*
>(scene());
84 Scene* myScene =
dynamic_cast<Scene*
>(scene());
88 setTransformationAnchor(QGraphicsView::NoAnchor);
93 DEBTRACE(
"GraphicsView::onViewGlobalPan");
98 DEBTRACE(
"GraphicsView::onViewReset");
111 QPointF point = mapToScene(event->pos());
113 item->
popupMenu(
this, event->globalPos());
120 QPointF point = mapToScene(event->pos());
122 item->
popupMenu(
this, event->globalPos());
130 WrapGraphicsView::mouseMoveEvent(e);
131 if (e->buttons()==Qt::LeftButton)
133 QPoint current = e->pos();
136 qreal currentX = e->globalX();
137 qreal currentY = e->globalY();
145 double deltax = delta/900.;
146 double zoom = exp(deltax);
161 _rect = scene()->addRect(QGraphicsView::mapToScene(QRect(
_prevPos, current)).boundingRect());
162 _rect->setZValue(100000);
163 _rect->setParentItem(0);
167 _rect->setRect(QGraphicsView::mapToScene(QRect(
_prevPos, current)).boundingRect());
176 DEBTRACE(
"GraphicsView::mousePressEvent");
179 DEBTRACE(
"Switch context before selection");
182 WrapGraphicsView::mousePressEvent(e);
203 setDragMode(QGraphicsView::NoDrag);
204 setTransformationAnchor(QGraphicsView::AnchorViewCenter);
208 QPoint current = e->pos();
209 fitInView(QGraphicsView::mapToScene(QRect(
_prevPos, current)).boundingRect(), Qt::KeepAspectRatio);
214 QTransform q = transform();
215 DEBTRACE(q.m11()<<
" "<<q.m12()<<
" "<<q.m21()<<
" "<<q.m22()<<
" "<<q.dx()<<
" "<<q.dy());
216 WrapGraphicsView::mouseReleaseEvent(e);
221 DEBTRACE(
"GraphicsView::wheelEvent " << e->delta());
222 double zoom = exp(0.1*e->delta()/120);
224 setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
240 QRectF rect = item->mapToScene(item->
boundingRect().toRect()).boundingRect();
241 fitInView(rect.toRect(), Qt::KeepAspectRatio);