MCPcopy Create free account
hub / github.com/Linloir/GraphBuilder / wheelEvent

Method wheelEvent

graph_view.cpp:149–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149void MyGraphicsView::wheelEvent(QWheelEvent *event){
150 QPointF cursorPoint = event->position();
151 QPointF scenePos = this->mapToScene(QPoint(cursorPoint.x(), cursorPoint.y()));
152
153 qreal viewWidth = this->viewport()->width();
154 qreal viewHeight = this->viewport()->height();
155
156 qreal hScale = cursorPoint.x() / viewWidth;
157 qreal vScale = cursorPoint.y() / viewHeight;
158
159 qreal scaleFactor = this->transform().m11();
160 int wheelDeltaValue = event->angleDelta().y();
161 if (wheelDeltaValue > 0)
162 {
163 if(scaleFactor > 2) return;
164 this->scale(1.1, 1.1);
165 }
166 else
167 {
168 if(scaleFactor < 0.5) return;
169 this->scale(1.0 / 1.1, 1.0 / 1.1);
170 }
171 QPointF viewPoint = this->transform().map(scenePos);
172 horizontalScrollBar()->setValue(int(viewPoint.x() - viewWidth * hScale));
173 verticalScrollBar()->setValue(int(viewPoint.y() - viewHeight * vScale));
174}
175
176void MyGraphicsView::changeCursor(){
177

Callers

nothing calls this directly

Calls 1

setValueMethod · 0.80

Tested by

no test coverage detected