//======================================================================================== void MouseSelectionEditor::initProxies(GlMainWidget *glMainWidget) { GlGraphInputData *inputData = glMainWidget->getScene()->getGlGraphComposite()->getInputData(); _graph = inputData->getGraph(); _layout = inputData->getElementLayout(); _selection = inputData->getElementSelected(); _rotation = inputData->getElementRotation(); _sizes = inputData->getElementSize(); }
//===================================================================== 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; }