void TOSMWidget::wheelEvent(QWheelEvent *e) { // qDebug() << "delta " << e->delta(); double delta = e->delta(), scale = 1, step = 0.9; if (delta > 0) { while (delta > 0) { delta -= 120; scale *= step; } } else { while(delta < 0) { delta += 120; scale /= step; } } QPointF clickPoint((double)e->pos().x() / width() * Rect.width() + Rect.left(), (double)(height() - e->pos().y()) / height() * Rect.height() + Rect.top()); QPointF newSizes(Rect.width() * scale, Rect.height() * scale); Rect = QRectF(clickPoint.x() - newSizes.x() * ((double)e->pos().x() / width()), clickPoint.y() - newSizes.y() * ((double)(height() - e->pos().y()) / height()), newSizes.x(), newSizes.y()); update(); }
/////////////////////////////////////////////////////////////////////////////////// // onMouseLocation() // Description: On click listener to display the location of the point // clicked. This callback can be set with the following function if // you have need to debug (x,y) locations of an image. // setMouseCallback("Original", onMouseLocation, static_cast<void*>(&m_pPanel)); /////////////////////////////////////////////////////////////////////////////////// static void onMouseLocation(int event, int x, int y, int f, void *ptr) { if (event == EVENT_LBUTTONDOWN) { Panel *pPanel = static_cast<Panel*>(ptr); Point clickPoint(x, y); ShowMessage("Click Location: (" + to_string(clickPoint.x) + "," + to_string(clickPoint.y) + ")"); } }
///////////////////////////////////////////////////////////////////////////////// // onMouseColor() // Description: On click listener to display the HSV value of the point clicked. // This callback can be set with the following function if you have need to // debug HSV colors of an image: // setMouseCallback(windowTitle, onMouseColor, static_cast<void*>(&m_pPanel)); ///////////////////////////////////////////////////////////////////////////////// static void onMouseColor(int event, int x, int y, int f, void *ptr) { if (event == EVENT_LBUTTONDOWN) { Panel *pPanel = static_cast<Panel*>(ptr); Point clickPoint(x, y); pPanel->ColorAtPoint(clickPoint); } }
void PickerRep::pickLandmarkSlot(vtkObject* renderWindowInteractor) { vtkRenderWindowInteractorPtr iren = vtkRenderWindowInteractor::SafeDownCast(renderWindowInteractor); if (iren == NULL) return; int pickedPoint[2]; //<x,y> iren->GetEventPosition(pickedPoint); //mouse positions are measured in pixels vtkRendererPtr renderer = this->getRenderer(); if (renderer == NULL) return; Vector3D clickPoint(pickedPoint[0], pickedPoint[1], 0); this->pickLandmark(clickPoint, renderer); }
void QuadWarp :: mousePressed(ofMouseEventArgs &e) { if(!visible) return; ofVec3f clickPoint(e.x, e.y); for(int i = 0; i < dstPoints.size(); i++) { if(dstPoints[i].distance(clickPoint) < pointRadius) { curPointIndex = i; ofVec3f &curPoint = dstPoints[i]; clickOffset = curPoint - clickPoint; dragStartPoint = clickPoint; break; } } };