コード例 #1
0
ファイル: FishEyeInteractor.cpp プロジェクト: tulip5/tulip
void FishEyeInteractorComponent::viewChanged(View *view) {
  if (view == nullptr) {
    return;
  }

  GlMainView *glView = static_cast<GlMainView *>(view);
  GlMainWidget *glWidget = glView->getGlMainWidget();

  if (!glWidget->hasMouseTracking()) {
    glWidget->setMouseTracking(true);
  }

  if (configWidget->getFishEyeRadius() == 0.) {
    configWidget->setFishEyeRadius(glWidget->getScene()->getGraphCamera().getSceneRadius() / 4.);
    configWidget->setFishEyeHeight(4.);
  }
}
コード例 #2
0
void MouseMagnifyingGlassInteractorComponent::viewChanged(View *view) {
  if (view == NULL) {
    glWidget = NULL;
    return;
  }

  GlMainView *glView = dynamic_cast<GlMainView *>(view);
  glWidget = glView->getGlMainWidget();
  radius = glWidget->screenToViewport(glWidget->width()) / 4;
  camera = &glWidget->getScene()->getLayer("Main")->getCamera();

  if (!glWidget->hasMouseTracking()) {
    glWidget->setMouseTracking(true);
  }

  ostringstream oss;
  oss << "magnifyingglass" << reinterpret_cast<uintptr_t>(glWidget);
  textureName = oss.str();
}
コード例 #3
0
ファイル: interactor_plugin.cpp プロジェクト: tulip5/tulip
  /*
  Most important function of an interactor component
  When an event arrive on your interactor : this function is call
  You have to process it and return true. If the event do nothing in your interactor : this function
  return false;
  */
  bool eventFilter(QObject *, QEvent *e) {

    /*
    If you have clicked on a node/edge, information widget is visible.
    And if you use the wheel of the mouse we hide the information widget
    */
    if (_informationWidgetItem->isVisible() && e->type() == QEvent::Wheel) {
      _informationWidgetItem->setVisible(false);
      return false;
    }

    /*
    Check if the event is a mouse event
    */
    QMouseEvent *qMouseEv = dynamic_cast<QMouseEvent *>(e);

    if (qMouseEv != nullptr) {
      GlMainView *glMainView = static_cast<GlMainView *>(view());

      /*
      Check if event is a left mouse button press
      */
      if (e->type() == QEvent::MouseButtonPress && qMouseEv->button() == Qt::LeftButton) {

        /*
        If you have clicked on a node/edge, information widget is visible.
        And if you reclick : hide it
        */
        if (_informationWidgetItem->isVisible()) {
          _informationWidgetItem->setVisible(false);
        } else {

          /*
          Select entities under the mouse cursor
          The result of selection is stored in SelectedEntity
          And pickNodesEdges return true if you click on node or edge
          */
          SelectedEntity selectedEntity;

          if (glMainView->getGlMainWidget()->pickNodesEdges(qMouseEv->x(), qMouseEv->y(),
                                                            selectedEntity)) {

            /*
            Change text of the information label with
            - If you click on a node : "Click on node id : nodeId"
            - If you click on an edge : "Click on edge id : edgeId"
            */
            QString text("Click on ");

            if (selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED)
              text += "node ";
            else
              text += "edge ";

            text += " id : " + QString::number(selectedEntity.getComplexEntityId());

            /*
            - Update QLabel with new text
            - Auto resize QLabel
            - Set position of the label at mouse position
            - Display it
            */
            _informationLabel->setText(text);
            _informationLabel->adjustSize();
            _informationWidgetItem->setPos(qMouseEv->pos());
            _informationWidgetItem->setVisible(true);

            /*
            Here we just add a small smooth animation on the label pop
            */
            QPropertyAnimation *animation =
                new QPropertyAnimation(_informationWidgetItem, "opacity");
            animation->setDuration(100);
            animation->setStartValue(0.);
            animation->setEndValue(0.99);
            animation->start();

            /*
            We have treated the event so we return true
            */
            return true;
          }
        }
      }
    }

    /*
    We don't have treated the event se we return false
    */
    return false;
  }