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 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;
}