bool PixelOrientedViewNavigator::eventFilter(QObject *widget, QEvent *e) { if(e->type() != QEvent::MouseButtonDblClick && e->type() != QEvent::MouseMove) return false; GlMainWidget *glWidget = (GlMainWidget *) widget; if (!glWidget->hasMouseTracking()) { glWidget->setMouseTracking(true); } if (!pixelView->smallMultiplesViewSet() && !pixelView->interactorsEnabled()) { pixelView->toggleInteractors(true); } if (pixelView->getOverviews().size() == 0) { return false; } if (e->type() == QEvent::MouseMove && pixelView->smallMultiplesViewSet()) { QMouseEvent *me = (QMouseEvent *) e; int x = glWidget->width() - me->x(); int y = me->y(); Coord screenCoords(x, y, 0); Coord sceneCoords = glWidget->getScene()->getGraphCamera().viewportTo3DWorld(glWidget->screenToViewport(screenCoords)); PixelOrientedOverview *overviewUnderPointer = getOverviewUnderPointer(sceneCoords); if (overviewUnderPointer != NULL && overviewUnderPointer != selectedOverview) { selectedOverview = overviewUnderPointer; } return true; } else if (e->type() == QEvent::MouseButtonDblClick) { if (selectedOverview != NULL && !selectedOverview->overviewGenerated()) { pixelView->generatePixelOverview(selectedOverview, glWidget); glWidget->draw(); } else if (selectedOverview != NULL && pixelView->smallMultiplesViewSet()) { QtGlSceneZoomAndPanAnimator zoomAndPanAnimator(glWidget, selectedOverview->getBoundingBox()); zoomAndPanAnimator.animateZoomAndPan(); pixelView->switchFromSmallMultiplesToDetailView(selectedOverview); selectedOverview = NULL; } else if (!pixelView->smallMultiplesViewSet() && pixelView->getOverviews().size() > 1) { pixelView->switchFromDetailViewToSmallMultiples(); QtGlSceneZoomAndPanAnimator zoomAndPanAnimator(glWidget, pixelView->getSmallMultiplesViewBoundingBox()); zoomAndPanAnimator.animateZoomAndPan(); pixelView->centerView(); } return true; } return false; }
bool ScatterPlot2DViewNavigator::eventFilter(QObject *widget, QEvent *e) { if (glWidget == nullptr) { glWidget = static_cast<GlMainWidget *>(widget); } if (glWidget != nullptr) { if (!glWidget->hasMouseTracking()) { glWidget->setMouseTracking(true); } if (!scatterPlot2dView->matrixViewSet() && !scatterPlot2dView->interactorsEnabled()) { scatterPlot2dView->toggleInteractors(true); } if (e->type() == QEvent::MouseMove && scatterPlot2dView->matrixViewSet()) { QMouseEvent *me = static_cast<QMouseEvent *>(e); int x = glWidget->width() - me->x(); int y = me->y(); Coord screenCoords(x, y, 0.0f); Coord sceneCoords(glWidget->getScene()->getGraphCamera().viewportTo3DWorld( glWidget->screenToViewport(screenCoords))); selectedScatterPlotOverview = getOverviewUnderPointer(sceneCoords); return true; } else if (e->type() == QEvent::MouseButtonDblClick) { if (selectedScatterPlotOverview != nullptr && !selectedScatterPlotOverview->overviewGenerated()) { scatterPlot2dView->generateScatterPlot(selectedScatterPlotOverview, glWidget); glWidget->draw(); } else if (selectedScatterPlotOverview != nullptr && scatterPlot2dView->matrixViewSet()) { QtGlSceneZoomAndPanAnimator zoomAndPanAnimator( glWidget, selectedScatterPlotOverview->getBoundingBox()); zoomAndPanAnimator.animateZoomAndPan(); scatterPlot2dView->switchFromMatrixToDetailView(selectedScatterPlotOverview, true); selectedScatterPlotOverview = nullptr; } else if (!scatterPlot2dView->matrixViewSet()) { scatterPlot2dView->switchFromDetailViewToMatrixView(); QtGlSceneZoomAndPanAnimator zoomAndPanAnimator(glWidget, scatterPlot2dView->getMatrixBoundingBox()); zoomAndPanAnimator.animateZoomAndPan(); } return true; } } return false; }