void CurveWidget::mouseMoveEvent(QMouseEvent *mouseEvent) { if (leftPressed || rightPressed) { drawRubberBand(mousePressBeginPoint, mousePressEndPoint, DASH_SIZE, RUBBER_BAND_COLOR); mousePressEndPoint = mouseEvent->pos(); updatePlot(); } }
void Select2DTool::draw() const { if (!display_box_) return; GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); // draw the selection box drawRubberBand(viewport); // highlight all the points in the rubberband highlightPoints(viewport); }
void RemapImage::paintEvent(QPaintEvent *event) { QPainter p(this); p.drawImage(m_simgX, m_simgY, m_imageScaled); drawRubberBand(&p); if (m_pickPoint) drawRawValue(&p); if (m_lowresImage) { p.setPen(QPen(QColor(250, 150, 50), 1)); p.setBrush(Qt::transparent); p.drawRect(rect().adjusted(2,2,-2,-2)); p.setPen(QPen(QColor(200, 50, 0), 1)); p.setBrush(Qt::transparent); p.drawRect(rect().adjusted(4,4,-4,-4)); } else if (m_level > 0) { p.setPen(QPen(QColor(250-50*m_level, 150, 50), 1)); p.setBrush(Qt::transparent); p.drawRect(rect().adjusted(2,2,-2,-2)); p.setPen(QPen(QColor(250-40*m_level, 50, 0), 1)); p.setBrush(Qt::transparent); p.drawRect(rect().adjusted(4,4,-4,-4)); } if (hasFocus()) { p.setPen(QPen(QColor(0, 250, 100), 2)); p.setBrush(Qt::transparent); p.drawRect(rect()); } QString txt; if (m_level == 0) txt = QString("No subsampling"); else txt = QString("Subsampling(%1)").arg(qPow(2, m_level)); QFont pfont = QFont("Helvetica", 14); p.setFont(pfont); p.setPen(Qt::transparent); p.setBrush(QColor(0, 0, 0, 100)); p.drawRect(m_offsetX-3, m_offsetY, 180, 25); p.setPen(Qt::white); p.drawText(m_offsetX, m_offsetY+20, txt); }
static void rubberMotion(int x,int y) { pScene sc; pPersp p; sc = cv.scene[currentScene()]; p = sc->persp; glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_XOR); /* draw frame */ drawRubberBand(rxi,ryi,rx1,ry1); rx2 = x; ry2 = sc->par.ys-y; drawRubberBand(rxi,ryi,rx2,ry2); glFlush(); glLogicOp(GL_COPY); glDisable(GL_COLOR_LOGIC_OP); /* keep old coords */ rx1 = rx2; ry1 = ry2; }
void OccView::onMouseMove( const int theFlags, const QPoint thePoint ) { // Draw the rubber band. if (theFlags & Qt::LeftButton) { drawRubberBand(myXmin, myYmin, thePoint.x(), thePoint.y()); dragEvent(thePoint.x(), thePoint.y()); } // Ctrl for multi selection. if (theFlags & Qt::ControlModifier) { multiMoveEvent(thePoint.x(), thePoint.y()); } else { moveEvent(thePoint.x(), thePoint.y()); } // Middle button. if (theFlags & Qt::MidButton) { switch (myCurrentMode) { case CurAction3d_DynamicRotation: myView->Rotation(thePoint.x(), thePoint.y()); break; case CurAction3d_DynamicZooming: myView->Zoom(myXmin, myYmin, thePoint.x(), thePoint.y()); break; case CurAction3d_DynamicPanning: myView->Pan(thePoint.x() - myXmax, myYmax - thePoint.y()); myXmax = thePoint.x(); myYmax = thePoint.y(); break; default: break; } } }
/*! \reimp */ void QtSash::mousePressEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) { // const QRect& rect = this->geometry(); // QPoint p1(this->mapToGlobal(rect.topLeft())); // QPoint p2(this->mapToGlobal(rect.bottomRight())); // startRect = QRect(p1, p2); startRect = this->geometry(); lastX = startRect.x(); lastY = startRect.y(); GuiTk::SelectionEvent::Pointer event(new GuiTk::SelectionEvent(this)); event->x = lastX; event->y = lastY; event->width = startRect.width(); event->height = startRect.height(); if (!smooth) { event->detail = Constants::DRAG; } selectionEvents.selected(event); if (event->doit) { dragging = true; lastX = event->x; lastY = event->y; //parent.update (true, (style & SWT.SMOOTH) == 0); drawRubberBand(lastX, lastY, startRect.width(), startRect.height()); if (smooth) { this->setGeometry(lastX, lastY, startRect.width(), startRect.height()); // widget could be disposed at this point } } } }
void CurveWidget::updatePlot() { if (leftPressed || rightPressed) { drawRubberBand(mousePressBeginPoint, mousePressEndPoint, DASH_SIZE, RUBBER_BAND_COLOR); } else { buffer.fill(Qt::white); drawAxis(); curve.draw(getViewPort(), scale, thickness, antiAliasing); QRgb oldColor = setColor(qRgb(0, 0, 0)); drawRect(QPoint(), QPoint(buffer.width() - 1, buffer.height() - 1)); setColor(oldColor); } const int FIELD_WIDTH = 2; emit thicknessChanged(QString("%1").arg(QString::number(thickness), FIELD_WIDTH)); emit scaleChanged(QString("%1 : %2"). arg(QString::number(scale > 1 ? scale : 1.)). arg(QString::number(scale > 1 ? 1. : 1 / scale))); update(); }
/*! \reimp */ void QtSash::mouseMoveEvent(QMouseEvent *e) { if (!dragging && !(e->buttons() & Qt::LeftButton)) return; QPoint eventPoint(e->globalX(), e->globalY()); eventPoint = this->parentWidget()->mapFromGlobal(eventPoint); int eventX = eventPoint.x(); int eventY = eventPoint.y(); // int eventX = e->globalX(); // int eventY = e->globalY(); //int x = OS.GTK_WIDGET_X (handle); //int y = OS.GTK_WIDGET_Y (handle); int width = this->geometry().width(); int height = this->geometry().height(); //int parentBorder = 0; //int parentWidth = OS.GTK_WIDGET_WIDTH (parent.handle); //int parentHeight = OS.GTK_WIDGET_HEIGHT (parent.handle); int newX = lastX; int newY = lastY; if ((orientation & Qt::Vertical) != 0) { //newX = std::min(std::max (0, eventX + x - startX - parentBorder), parentWidth - width); newX = eventX; } else { // newY = Math.min (Math.max (0, eventY + y - startY - parentBorder), parentHeight - height); newY = eventY; } if (newX == lastX && newY == lastY) return; drawRubberBand(lastX, lastY, width, height); GuiTk::SelectionEvent::Pointer event(new GuiTk::SelectionEvent(this)); event->x = newX; event->y = newY; event->width = width; event->height = height; if (!smooth) { event->detail = Constants::DRAG; } selectionEvents.selected(event); if (event->doit) { lastX = event->x; lastY = event->y; } //parent.update (true, (style & SWT.SMOOTH) == 0); drawRubberBand(lastX, lastY, width, height); if (smooth) { setGeometry(lastX, lastY, width, height); // widget could be disposed at this point } }