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 ParallelCoordsAxisBoxPlot::eventFilter(QObject *widget, QEvent *e) { GlMainWidget *glWidget = dynamic_cast<GlMainWidget *>(widget); if(!glWidget) return false; initOrUpdateBoxPlots(); if (e->type() == QEvent::MouseMove) { QMouseEvent *me = (QMouseEvent *) e; int x = glWidget->width() - me->x(); int y = me->y(); Coord screenCoords(x, y, 0.0f); Coord sceneCoords(glWidget->getScene()->getLayer("Main")->getCamera().viewportTo3DWorld(glWidget->screenToViewport(screenCoords))); selectedAxis = parallelView->getAxisUnderPointer(me->x(), me->y()); if (selectedAxis != NULL && dynamic_cast<QuantitativeParallelAxis *>(selectedAxis)) { if (axisBoxPlotMap.find(static_cast<QuantitativeParallelAxis *>(selectedAxis)) != axisBoxPlotMap.end()) if (parallelView->getLayoutType() == ParallelCoordinatesDrawing::CIRCULAR) { rotateVector(sceneCoords, -(selectedAxis->getRotationAngle()), Z_ROT); } axisBoxPlotMap[static_cast<QuantitativeParallelAxis *>(selectedAxis)]->setHighlightRangeIfAny(sceneCoords); } parallelView->refresh(); return true; } if (e->type() == QEvent::MouseButtonPress) { return false; } if (e->type() == QEvent::MouseButtonRelease) { if (selectedAxis != NULL && dynamic_cast<QuantitativeParallelAxis *>(selectedAxis)) { Observable::holdObservers(); if (axisBoxPlotMap.find(static_cast<QuantitativeParallelAxis *>(selectedAxis)) != axisBoxPlotMap.end()) parallelView->highlightDataInAxisBoxPlotRange(static_cast<QuantitativeParallelAxis *>(selectedAxis)); Observable::unholdObservers(); selectedAxis = NULL; parallelView->refresh(); return true; } } return false; }
bool FishEyeInteractorComponent::eventFilter(QObject *obj, QEvent *e) { GlMainWidget *glWidget = (GlMainWidget*)obj; Camera *camera=&glWidget->getScene()->getGraphCamera(); activateFishEye = false; if (e->type() == QEvent::MouseMove || e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease) { activateFishEye = true; QMouseEvent *me = (QMouseEvent *) e; float x = glWidget->width() - me->x(); float y = me->y(); Coord screenCoords(x, y, 0); fisheyeCenter = camera->viewportTo3DWorld(glWidget->screenToViewport(screenCoords)); glWidget->redraw(); return true; } else if (e->type() == QEvent::Wheel) { activateFishEye = true; QWheelEvent *wheelEvent = (QWheelEvent *) e; int numDegrees = wheelEvent->delta() / 8; int numSteps = numDegrees / 15; if (wheelEvent->orientation() == Qt::Vertical && (wheelEvent->modifiers() == Qt::ControlModifier)) { activateFishEye = true; configWidget->setFishEyeRadius(configWidget->getFishEyeRadius() + configWidget->getFishEyeRadiusIncrementStep() * numSteps); glWidget->redraw(); return true; } else if (wheelEvent->orientation() == Qt::Vertical && (wheelEvent->modifiers() == Qt::ShiftModifier)) { activateFishEye = true; float newHeight = configWidget->getFishEyeHeight() + configWidget->getFishEyeHeightIncrementStep() * numSteps; if (newHeight < 0) { newHeight = 0; } configWidget->setFishEyeHeight(newHeight); glWidget->redraw(); return true; } return false; } return false; }
bool GoogleMapViewNavigator::eventFilter(QObject *widget, QEvent *e) { GoogleMapsView *googleMapsView=static_cast<GoogleMapsView*>(view()); if(googleMapsView->viewType()==GoogleMapsView::GoogleRoadMap || googleMapsView->viewType()==GoogleMapsView::GoogleSatellite || googleMapsView->viewType()==GoogleMapsView::GoogleTerrain || googleMapsView->viewType()==GoogleMapsView::GoogleHybrid) { QMouseEvent *qMouseEv = dynamic_cast<QMouseEvent *>(e); QWheelEvent *qWheelEv = dynamic_cast<QWheelEvent *>(e); if(qMouseEv || qWheelEv) { GoogleMapsView* googleMapsView=static_cast<GoogleMapsView*>(view()); QApplication::sendEvent(googleMapsView->getGoogleMap(), e); } return false; } else if (googleMapsView->viewType()==GoogleMapsView::Globe) { if (e->type() == QEvent::Wheel && (((QWheelEvent *) e)->orientation() == Qt::Vertical)) { #define WHEEL_DELTA 120 GlMainWidget *g = (GlMainWidget *) widget; g->getScene()->zoomXY(((QWheelEvent *) e)->delta() / WHEEL_DELTA, g->width()/2., g->height()/2.); view()->draw(); return true; } if (e->type() == QEvent::MouseButtonPress && !inRotation) { if(((QMouseEvent*)e)->button()==Qt::LeftButton) { x = ((QMouseEvent *) e)->x(); y = ((QMouseEvent *) e)->y(); inRotation=true; return true; } } if(e->type() == QEvent::MouseButtonRelease) { if(((QMouseEvent*)e)->button()==Qt::LeftButton) { inRotation=false; return true; } } if (e->type() == QEvent::MouseMove && inRotation) { GlMainWidget *g = (GlMainWidget *) widget; Camera &camera=g->getScene()->getGraphCamera(); Coord c1=camera.getEyes()-camera.getCenter(); Coord c2=camera.getEyes()-camera.getCenter()+camera.getUp(); trans(c1,c2,-0.005*(((QMouseEvent *) e)->y()-y),-0.005*(((QMouseEvent *) e)->x()-x)); camera.setCenter(Coord(0,0,0)); camera.setEyes(c1); camera.setUp(c2-camera.getEyes()); x = ((QMouseEvent *) e)->x(); y = ((QMouseEvent *) e)->y(); view()->draw(); return true; } if (e->type() == QEvent::KeyPress) { GlMainWidget *g = (GlMainWidget *) widget; float angle1=0; float angle2=0; switch(((QKeyEvent *) e)->key()) { case Qt::Key_Left: angle2=-0.05f; break; case Qt::Key_Right: angle2=0.05f; break; case Qt::Key_Up: angle1=0.05f; break; case Qt::Key_Down: angle1=-0.05f; break; } Camera &camera=g->getScene()->getGraphCamera(); Coord c1=camera.getEyes()-camera.getCenter(); Coord c2=camera.getEyes()-camera.getCenter()+camera.getUp(); trans(c1,c2,angle1,angle2); camera.setCenter(Coord(0,0,0)); camera.setEyes(c1); camera.setUp(c2-camera.getEyes()); view()->draw(); return true; } return false; } else { return MouseNKeysNavigator::eventFilter(widget, e); } }
bool MouseEdgeBuilder::eventFilter(QObject *widget, QEvent *e) { GlMainWidget *glMainWidget = static_cast<GlMainWidget *>(widget); if (e->type() == QEvent::MouseButtonPress) { QMouseEvent * qMouseEv = static_cast<QMouseEvent *>(e); SelectedEntity selectedEntity; GlGraphInputData *inputData=glMainWidget->getScene()->getGlGraphComposite()->getInputData(); Graph * _graph = inputData->getGraph(); LayoutProperty* mLayout = inputData->getElementLayout(); if (qMouseEv->buttons()==Qt::LeftButton) { if (!_started) { bool result=glMainWidget->pickNodesEdges(qMouseEv->x(), qMouseEv->y(), selectedEntity); if (result && (selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED)) { _started=true; initObserver(_graph); _source=node(selectedEntity.getComplexEntityId()); _curPos=_startPos=mLayout->getNodeValue(_source); return true; } return false; } else { bool result = glMainWidget->pickNodesEdges(qMouseEv->x(),qMouseEv->y(),selectedEntity); if (result && (selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED)) { Observable::holdObservers(); _started=false; clearObserver(); // allow to undo _graph->push(); addLink(widget,_source,node(selectedEntity.getComplexEntityId())); Observable::unholdObservers(); } else { Coord point(glMainWidget->width() - qMouseEv->x(), qMouseEv->y(), 0); _bends.push_back(glMainWidget->getScene()->getGraphCamera().viewportTo3DWorld(glMainWidget->screenToViewport(point))); glMainWidget->redraw(); } } return true; } if (qMouseEv->buttons()==Qt::MidButton) { _bends.clear(); _started=false; _source=node(); clearObserver(); glMainWidget->draw(); return true; } } if (e->type() == QEvent::MouseMove) { QMouseEvent * qMouseEv = static_cast<QMouseEvent *>(e); if (!_started) { SelectedEntity selectedEntity; bool hoveringOverNode = glMainWidget->pickNodesEdges(qMouseEv->x(), qMouseEv->y(), selectedEntity) && selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED; if (!hoveringOverNode) { glMainWidget->setCursor(QCursor(Qt::ArrowCursor)); return false; } else { glMainWidget->setCursor(QCursor(Qt::CrossCursor)); } } else { SelectedEntity selectedEntity; if(glMainWidget->pickNodesEdges(qMouseEv->x(), qMouseEv->y(), selectedEntity) && selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED) { glMainWidget->setCursor(QCursor(Qt::CrossCursor)); } else { glMainWidget->setCursor(QCursor(Qt::ArrowCursor)); } Coord point(glMainWidget->width() - qMouseEv->x(), qMouseEv->y(), 0); point = glMainWidget->getScene()->getGraphCamera().viewportTo3DWorld(glMainWidget->screenToViewport(point)); _curPos.set(point[0], point[1], point[2]); glMainWidget->redraw(); } return true; } return false; }
//===================================================================== bool MouseBoxZoomer::eventFilter(QObject *widget, QEvent *e) { GlMainWidget *glw = static_cast<GlMainWidget *>(widget); GlGraphInputData *inputData = glw->getScene()->getGlGraphComposite()->getInputData(); if (e->type() == QEvent::MouseButtonPress) { QMouseEvent * qMouseEv = static_cast<QMouseEvent *>(e); if (qMouseEv->buttons() == mButton && (kModifier == Qt::NoModifier || qMouseEv->modifiers() & kModifier)) { if (!started) { x = qMouseEv->x(); y = glw->height() - qMouseEv->y(); w = 0; h = 0; started = true; graph = inputData->getGraph(); } else { if (inputData->getGraph() != graph) { graph = NULL; started = false; } } return true; } if (qMouseEv->buttons()==Qt::MidButton) { started = false; glw->redraw(); return true; } return false; } if (e->type() == QEvent::MouseMove) { QMouseEvent * qMouseEv = static_cast<QMouseEvent *>(e); if ((qMouseEv->buttons() & mButton) && (kModifier == Qt::NoModifier || qMouseEv->modifiers() & kModifier)) { if (inputData->getGraph() != graph) { graph = NULL; started = false; } if (started) { if ((qMouseEv->x() > 0) && (qMouseEv->x() < glw->width())) w = qMouseEv->x() - x; if ((qMouseEv->y() > 0) && (qMouseEv->y() < glw->height())) h = y - (glw->height() - qMouseEv->y()); glw->redraw(); return true; } } } if (e->type() == QEvent::MouseButtonDblClick) { GlBoundingBoxSceneVisitor bbVisitor(inputData); glw->getScene()->getLayer("Main")->acceptVisitor(&bbVisitor); QtGlSceneZoomAndPanAnimator zoomAnPan(glw, bbVisitor.getBoundingBox()); zoomAnPan.animateZoomAndPan(); return true; } if (e->type() == QEvent::MouseButtonRelease) { QMouseEvent * qMouseEv = static_cast<QMouseEvent *>(e); if ((qMouseEv->button() == mButton && (kModifier == Qt::NoModifier || qMouseEv->modifiers() & kModifier))) { if (inputData->getGraph() != graph) { graph = NULL; started = false; } if (started) { started = false; if(!(w==0 && h==0)) { int width = glw->width(); int height = glw->height(); Coord bbMin(width-x, height - y+h); Coord bbMax(width-(x+w), height - y); if (abs(bbMax[0] - bbMin[0]) > 1 && abs(bbMax[1] - bbMin[1]) > 1) { BoundingBox sceneBB; sceneBB.expand(glw->getScene()->getGraphCamera().viewportTo3DWorld(glw->screenToViewport(bbMin))); sceneBB.expand(glw->getScene()->getGraphCamera().viewportTo3DWorld(glw->screenToViewport(bbMax))); QtGlSceneZoomAndPanAnimator zoomAnPan(glw, sceneBB); zoomAnPan.animateZoomAndPan(); } } } return true; } } return false; }