当前位置: 首页>>代码示例>>C++>>正文


C++ GlMainWidget::doSelect方法代码示例

本文整理汇总了C++中GlMainWidget::doSelect方法的典型用法代码示例。如果您正苦于以下问题:C++ GlMainWidget::doSelect方法的具体用法?C++ GlMainWidget::doSelect怎么用?C++ GlMainWidget::doSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GlMainWidget的用法示例。


在下文中一共展示了GlMainWidget::doSelect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: eventFilter

//===============================================================
bool MouseElementDeleter::eventFilter(QObject *widget, QEvent *e) {
  QMouseEvent *qMouseEv = (QMouseEvent *) e;

  if(qMouseEv != NULL) {
    node tmpNode;
    edge tmpEdge;
    ElementType type;
    GlMainWidget *glMainWidget = (GlMainWidget *) widget;

    if(e->type() == QEvent::MouseMove) {
      if (glMainWidget->doSelect(qMouseEv->x(), qMouseEv->y(), type, tmpNode, tmpEdge)) {
        glMainWidget->setCursor(QCursor(QPixmap(":/i_del.png")));
      }
      else {
        glMainWidget->setCursor(Qt::ArrowCursor);
      }

      return false;
    }
    else if (e->type() == QEvent::MouseButtonPress && qMouseEv->button()==Qt::LeftButton) {
      if (glMainWidget->doSelect(qMouseEv->x(), qMouseEv->y(), type, tmpNode, tmpEdge)) {
        Observable::holdObservers();
        Graph* graph = glMainWidget->getGraph();
        // allow to undo
        graph->push();

        switch(type) {
        case NODE:
          graph->delNode(tmpNode);
          break;

        case EDGE:
          graph->delEdge(tmpEdge);
          break;
        }

        glMainWidget->redraw();
        Observable::unholdObservers();
        return true;
      }
    }
  }

  return false;
}
开发者ID:kdbanman,项目名称:browseRDF,代码行数:46,代码来源:MouseInteractors.cpp

示例2: eventFilter

// Event filter of the interactor component (main function of the interactor component)
bool InteractorPluginComponent::eventFilter(QObject *widget, QEvent *e) {

  if (e->type() == QEvent::MouseButtonRelease) {
    QMouseEvent * qMouseEv = (QMouseEvent *) e;
    GlMainWidget *glMainWidget = (GlMainWidget *) widget;

    if (qMouseEv->button()== Qt::LeftButton) {
      // Enter here if we have released the left button of the mouse

      // doSelect function return node/edge under the mouse
      node tmpNode;
      edge tmpEdge;
      ElementType type;
      bool result = glMainWidget->doSelect(qMouseEv->x(), qMouseEv->y(), type, tmpNode, tmpEdge);

      if (result) {
        // Enter here if we have node/edge under the mouse

        // Store selection property
        Graph *graph=glMainWidget->getScene()->getGlGraphComposite()->getInputData()->getGraph();
        string selectionPropertyName=glMainWidget->getScene()->getGlGraphComposite()->getInputData()->getElementSelectedPropName();
        BooleanProperty* selection=graph->getProperty<BooleanProperty>(selectionPropertyName);

        // Before do any think on the graph, we push the current state of the graph (this activate the undo/redo system)
        graph->push();

        // Deselect all nodes/edges
        selection->setAllNodeValue(false);
        selection->setAllEdgeValue(false);

        switch(type) {
        case NODE:
          // Set selection at true for selected node
          selection->setNodeValue(tmpNode, true);
          break;

        case EDGE:
          // Set selection at false for selected edge
          selection->setEdgeValue(tmpEdge, true);
          break;
        }

        // We have treated the event so we return true
        // (this event will not be passed to others interactorComponent)
        return true;
      }
    }
  }

  // We don't have treated the event so we return false
  // (this event will be passed to others interactorComponent)
  return false;
}
开发者ID:kdbanman,项目名称:browseRDF,代码行数:54,代码来源:InteractorPluginExample.cpp


注:本文中的GlMainWidget::doSelect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。