PixelOrientedOverview::PixelOrientedOverview(TulipGraphDimension *data, PixelOrientedMediator *pixelOrientedMediator, Coord blCornerPos, const std::string &dimName, const Color &backgroundColor, const Color &textColor) : data(data), pixelOrientedMediator(pixelOrientedMediator), blCornerPos(blCornerPos), dimName(dimName), frame(nullptr), frame2(nullptr), overviewGen(false), backgroundColor(backgroundColor), textColor(textColor) { if (this->dimName.empty()) { this->dimName = data->getDimensionName(); } overviewId = overviewCpt++; textureName = dimName + " texture " + getStringFromNumber(overviewId); unsigned int width = pixelOrientedMediator->getImageWidth(); unsigned int height = pixelOrientedMediator->getImageHeight(); unsigned int labelHeight = height / 4; Graph *graph = data->getTulipGraph(); pixelLayout = new LayoutProperty(graph); pixelSize = new SizeProperty(graph); graphComposite = new GlGraphComposite(graph); setGraphView(graphComposite); GlGraphInputData *glGraphInputData = graphComposite->getInputData(); glGraphInputData->setElementLayout(pixelLayout); glGraphInputData->setElementSize(pixelSize); frame = new GlRect(Coord(blCornerPos.getX() - 3, blCornerPos.getY() + height + 3), Coord(blCornerPos.getX() + width + 3, blCornerPos.getY() - 3), Color(0, 0, 0), Color(0, 0, 0), false, true); addGlEntity(frame, dimName + "frame"); frame2 = new GlRect(Coord(blCornerPos.getX() - 4, blCornerPos.getY() + height + 4), Coord(blCornerPos.getX() + width + 4, blCornerPos.getY() - 4), Color(0, 0, 0), Color(0, 0, 0), false, true); addGlEntity(frame2, dimName + "frame 2"); backgroundRect = new GlRect(Coord(blCornerPos.getX(), blCornerPos.getY() + height), Coord(blCornerPos.getX() + width, blCornerPos.getY()), Color(255, 255, 255), Color(255, 255, 255), true, false); addGlEntity(backgroundRect, "background rect"); clickLabel = new GlLabel(Coord(blCornerPos.getX() + width / 2, blCornerPos.getY() + height / 2), Size(width, height / 4), Color(0, 0, 0)); clickLabel->setText("Double Click to generate overview"); addGlEntity(clickLabel, "label"); computeBoundingBox(); overviewLabel = new GlLabel(Coord(blCornerPos.getX() + width / 2, blCornerPos.getY() - labelHeight / 2), Size(width, labelHeight), textColor); overviewLabel->setText(dimName); addGlEntity(overviewLabel, "overview label"); }
//======================================================================================== 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; }