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


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

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


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

示例1: eventFilter

bool MouseRotXRotY::eventFilter(QObject *widget, QEvent *e) {
  if (e->type() == QEvent::MouseButtonPress) {
    x = ((QMouseEvent *) e)->x();
    y = ((QMouseEvent *) e)->y();
    return true;
  }

  if (e->type() == QEvent::MouseMove) {
    QMouseEvent *qMouseEv = (QMouseEvent *) e;
    GlMainWidget *glMainWidget = (GlMainWidget *) widget;
    int deltaX,deltaY;
    deltaX=qMouseEv->x()-x;
    deltaY=qMouseEv->y()-y;

    if (abs(deltaX)>abs(deltaY))
      deltaY=0;
    else
      deltaX=0;

    if (deltaY!=0) glMainWidget->getScene()->rotateScene(deltaY,0,0);

    if (deltaX!=0) glMainWidget->getScene()->rotateScene(0,deltaX,0);

    x=qMouseEv->x();
    y=qMouseEv->y();
    glMainWidget->draw();
    return true;
  }

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

示例2: addLink

void MouseEdgeBuilder::addLink(QObject *widget, const node source, const node target) {
    GlMainWidget *glMainWidget = static_cast<GlMainWidget *>(widget);
    Graph * g = glMainWidget->getScene()->getGlGraphComposite()->getInputData()->getGraph();

    LayoutProperty* mLayout = glMainWidget->getScene()->getGlGraphComposite()->getInputData()->getElementLayout();
    edge newEdge = g->addEdge(source, target);
    mLayout->setEdgeValue(newEdge, bends());
    _bends.clear();
}
开发者ID:mneumann,项目名称:tulip,代码行数:9,代码来源:MouseEdgeBuilder.cpp

示例3: main

int main(int argc, char **argv) {

  // A QApplication must always be declared at the beginning of the main function if you intend to
  // use the tulip-gui library
  // This must be done before calling tlp::initTulipSoftware()
  QApplication app(argc, argv);

  // Initialize the library and load all plugins
  tlp::initTulipSoftware();

  Graph *g = nullptr;
  if (QApplication::arguments().size() == 2) {
    // Load the file passed as first argument into a graph.
    // This method will select the default Tulip algorithm plugin (TLP)
    QString filename = QApplication::arguments()[1];
    if (!((filename.endsWith(".tlp")) || (filename.endsWith(".tlp.gz")))) {
      cout << "File " << QStringToTlpString(filename)
           << " not compatible. Use a tlp file or a tlp.gz file" << endl;
      exit(EXIT_FAILURE);
    }
    g = tlp::loadGraph(QStringToTlpString(filename));
  } else {
    // If no arguments were given to the command, create a complete tree of depth 5
    // and degree 2 for demo purpose
    g = createCompleteTree(5, 2);
    // Set some visual properties in order to visualize the tree
    setTreeVisualProperties(g);
  }

  // Creates the main widget that will display our graph
  GlMainWidget *mainWidget = new GlMainWidget(nullptr);

  // Adds a layer to the scene
  GlLayer *mainLayer = mainWidget->getScene()->createLayer("Main");

  // Adds the graph to this layer
  mainLayer->addGraph(g, "graph");

  // Sets some rendering parameters on the graph to visualize
  setGraphRenderingParameters(mainWidget->getScene()->getGlGraphComposite());

  // Display the widget
  mainWidget->show();

  // Flush event loop in order to let paint events pass through in order for the scene to be
  // initialized.
  QApplication::processEvents();

  // Center the camera and draw the graph
  mainWidget->centerScene();
  mainWidget->draw();

  // Adds Zoom and pan navigation to the widget
  mainWidget->installEventFilter(new MouseNKeysNavigator);
  return app.exec();
}
开发者ID:tulip5,项目名称:tulip,代码行数:56,代码来源:graph_display.cpp

示例4: 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

示例5: eventFilter

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;
}
开发者ID:mneumann,项目名称:tulip,代码行数:56,代码来源:PixelOrientedViewNavigator.cpp

示例6: main

int main(int argc, char **argv) {
  /*
  A QApplication must always be declared at the beginning of the main function in order for Tulip to work.
  This must be done before calling tlp::initTulipSoftware()
  */
  QApplication app(argc, argv);
  /*
  Initialize the library, load plugins and set application runtime pathes accordingly to the host
  operating system
  This method should always be called if you intend to use plugins in your application.
  */
  tlp::initTulipSoftware();
  /*
  Load the file passed as first argument into a graph.
  This method will select the default Tulip algorithm plugin (TLP)
  */
  // Graph* g = tlp::loadGraph(argv[1]);
  Graph *g = newGraph();

  TulipProject *_project = TulipProject::openProject(QString::fromLatin1(argv[1]));

  // std::cout << QString::fromLatin1(argv[1]) << std::endl;

  if (_project->exists("/data/graphs/0/graph.tlp")) {
    std::cout << "pouet pouet" << std::endl;
    DataSet data;

    data.set<std::string>("file::filename",
                          QStringToTlpString(_project->toAbsolutePath("/data/graphs/0/graph.tlp")));

    g = tlp::importGraph("TLP Import", data);
    std::cout << g << std::endl;
  }

  // Creates the main widget that will display our graph
  GlMainWidget *mainWidget = new GlMainWidget();
  // Adds a layer to the scene
  GlLayer *mainLayer = mainWidget->getScene()->createLayer("Main");
  // Adds the graph to this layer
  mainLayer->addGraph(g, "graph");

  // Display the widget
  mainWidget->show();
  // Flush event loop in order to let paint events pass through in order for the scene to be
  // initialized.
  QApplication::processEvents();
  // Center the camera and draw the graph
  mainWidget->centerScene();
  mainWidget->draw();
  // Adds Zoom and pan navigation to the widget
  mainWidget->installEventFilter(new MouseNKeysNavigator);
  return app.exec();
}
开发者ID:tulip5,项目名称:tulip,代码行数:53,代码来源:tutorial106.cpp

示例7: eventFilter

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;
}
开发者ID:mneumann,项目名称:tulip,代码行数:50,代码来源:ParallelCoordsAxisBoxPlot.cpp

示例8: eventFilter

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;

}
开发者ID:mneumann,项目名称:tulip,代码行数:50,代码来源:FishEyeInteractor.cpp

示例9: main

int main(int argc, char **argv) {
  /*
  A QApplication must always be declared at the beginning of the main function in order for Tulip to work.
  This must be done before calling tlp::initTulipSoftware()
  */
  QApplication app(argc, argv);
  /*
  Initialize the library, load plugins and set application runtime pathes accordingly to the host
  operating system
  This method should always be called if you intend to use plugins in your application.
  */
  tlp::initTulipSoftware();

  // Creates the main widget that will display our graph
  GlMainWidget *mainWidget = new GlMainWidget();
  // Adds a layer to the scene
  GlLayer *mainLayer = mainWidget->getScene()->createLayer("Main");

  Coord center1(-1, -1, -1);
  Coord center2(1, 1, 1);
  Size size(1, 1, 1);
  Color whiteOpaque(255, 255, 255, 255);
  Color blackOpaque(0, 0, 0, 255);

  GlBox *node1 = new GlBox(center1, size, whiteOpaque, blackOpaque);
  GlBox *node2 = new GlBox(center2, size, whiteOpaque, blackOpaque);

  mainLayer->addGlEntity(node1, "Gl Tutorial 1: Node 1");
  mainLayer->addGlEntity(node2, "Gl Tutorial 1: Node 2");

  Coord centerBox(0, 0, 0);
  Size sizeBox(3.001, 3.001, 3.001);
  Color purpleTrans(155, 0, 155, 50);
  GlBox *box = new GlBox(centerBox, sizeBox, purpleTrans, blackOpaque);
  mainLayer->addGlEntity(box, "Gl Tutorial 2: Box");

  // Display the widget
  mainWidget->show();
  // Flush event loop in order to let paint events pass through in order for the scene to be
  // initialized.
  QApplication::processEvents();
  // Center the camera and draw the graph
  mainWidget->centerScene();
  mainWidget->draw();
  // Adds Zoom and pan navigation to the widget
  mainWidget->installEventFilter(new MouseNKeysNavigator);
  return app.exec();
}
开发者ID:tulip5,项目名称:tulip,代码行数:48,代码来源:tutorial102.cpp

示例10: viewChanged

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.);
  }
}
开发者ID:tulip5,项目名称:tulip,代码行数:17,代码来源:FishEyeInteractor.cpp

示例11: eventFilter

//========================================================================================
bool MouseEdgeBendEditor::eventFilter(QObject *widget, QEvent *e) {

  QMouseEvent * qMouseEv = (QMouseEvent *) e;

  if(qMouseEv == NULL)
    return false;

  // Double click to create a new control point
  if(e->type() == QEvent::MouseButtonDblClick &&  qMouseEv->button() == Qt::LeftButton && haveSelection(glMainWidget)) {
    _operation = NEW_OP;
    mMouseCreate(qMouseEv->x(), qMouseEv->y(), glMainWidget);
    return true;
  }

  if (e->type() == QEvent::MouseButtonPress) {
    if(!glMainWidget)
      glMainWidget = (GlMainWidget *) widget;

    initProxies(glMainWidget);
    bool hasSelection = haveSelection(glMainWidget);

    editPosition[0] = qMouseEv->x();
    editPosition[1] = qMouseEv->y();
    editPosition[2] = 0;

    switch(qMouseEv->buttons()) {
    case Qt::LeftButton : {

      if (!hasSelection) {
        // event occurs outside the selection rectangle
        // so from now we delegate the job to a MouseEdgeSelector object
        // which should intercept the event
        _operation = NONE_OP;
      }
      else {

        bool entityIsSelected = glMainWidget->pickGlEntities((int)editPosition[0] - 3, (int)editPosition[1] - 3, 6, 6, select, layer);

        if(!entityIsSelected) {
          // We have click outside an entity
          _operation = NONE_OP;
        }
        else {
          selectedEntity=circleString->findKey(select[0].getSimpleEntity());

          if (qMouseEv->modifiers() &
#if defined(__APPLE__)
              Qt::AltModifier
#else
              Qt::ControlModifier
#endif
             ) {
            _operation = DELETE_OP;
            mMouseDelete();
          }
          else {
            _graph->push();
            _operation = TRANSLATE_OP;
            glMainWidget->setCursor(QCursor(Qt::SizeAllCursor));
            mode = COORD;
          }

          return true;
        }
      }

      break;
    }

    default: {
      return false;
    }
    }

    glMainWidget->redraw();
  }

  if (e->type() == QEvent::MouseButtonRelease &&
      qMouseEv->button() == Qt::LeftButton &&
      _operation != NONE_OP) {
    GlMainWidget *glMainWidget = (GlMainWidget *) widget;

    if(selectedEntity=="targetTriangle") {
      SelectedEntity selectedEntity;

      if (glMainWidget->pickNodesEdges(qMouseEv->x(), qMouseEv->y(), selectedEntity) && selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED) {
        glMainWidget->getScene()->getGlGraphComposite()->getGraph()->setEnds(mEdge,glMainWidget->getScene()->getGlGraphComposite()->getGraph()->ends(mEdge).first,node(selectedEntity.getComplexEntityId()));
      }
    }
    else if(selectedEntity=="sourceCircle") {
      SelectedEntity selectedEntity;

      if (glMainWidget->pickNodesEdges(qMouseEv->x(), qMouseEv->y(), selectedEntity) && selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED) {
        glMainWidget->getScene()->getGlGraphComposite()->getGraph()->setEnds(mEdge,node(selectedEntity.getComplexEntityId()),glMainWidget->getScene()->getGlGraphComposite()->getGraph()->ends(mEdge).second);
      }
    }

    selectedEntity="";

//.........这里部分代码省略.........
开发者ID:vadivelselvaraj,项目名称:TulipGLImprovement,代码行数:101,代码来源:MouseEdgeBendEditor.cpp

示例12: eventFilter

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;
  }
//.........这里部分代码省略.........
开发者ID:vadivelselvaraj,项目名称:TulipGLImprovement,代码行数:101,代码来源:GoogleMapsViewInteractors.cpp

示例13: eventFilter

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;
}
开发者ID:mneumann,项目名称:tulip,代码行数:96,代码来源:MouseEdgeBuilder.cpp

示例14: eventFilter

//=====================================================================
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();
//.........这里部分代码省略.........
开发者ID:mneumann,项目名称:tulip,代码行数:101,代码来源:MouseBoxZoomer.cpp


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