Ejemplo n.º 1
0
void ClosableImage::mousePressEvent(QMouseEvent *ev)
{
    if (m_loading || ev->button() != Qt::LeftButton || !m_pixmap.isNull())
        return;

    if ((!m_image.isNull() || !m_imagePath.isEmpty()) && closeRect().contains(ev->pos())) {
        if (!confirmDeleteImage())
            return;
        m_pixmap = QPixmap::grabWidget(this);
        Helper::instance()->setDevicePixelRatio(m_pixmap, Helper::instance()->devicePixelRatio(this));
        m_anim = new QPropertyAnimation(this);
        m_anim->setEasingCurve(QEasingCurve::InQuad);
        m_anim->setTargetObject(this);
        m_anim->setStartValue(0);
        m_anim->setEndValue(width()/2);
        m_anim->setPropertyName("mySize");
        m_anim->setDuration(400);
        m_anim->start(QPropertyAnimation::DeleteWhenStopped);
        connect(m_anim, SIGNAL(finished()), this, SIGNAL(sigClose()));
        connect(m_anim, SIGNAL(finished()), this, SLOT(closed()), Qt::QueuedConnection);
    } else if ((!m_image.isNull() || !m_imagePath.isEmpty()) && m_showZoomAndResolution && zoomRect().contains(ev->pos())) {
        if (!m_image.isNull()) {
            ImagePreviewDialog::instance()->setImage(QPixmap::fromImage(QImage::fromData(m_image)));
            ImagePreviewDialog::instance()->exec();
        } else if (!m_imagePath.isEmpty()) {
            ImagePreviewDialog::instance()->setImage(QPixmap::fromImage(QImage(m_imagePath)));
            ImagePreviewDialog::instance()->exec();
        }
    } else if (m_clickable && imgRect().contains(ev->pos())) {
        emit clicked();
    }
}
Ejemplo n.º 2
0
void mouse(int button, int state, int x, int y) {
	if (initialized == false){
		if ((button == GLUT_LEFT_BUTTON) && (state == GLUT_DOWN)) {
			userAnnotations.push_back(Point2f(x, y));
		} 
		else if ((button == GLUT_LEFT_BUTTON) && (state == GLUT_UP)) {
			userPitchPoints.push_back(Point2f(x, y));
			cout<<userAnnotations.size()<<" point pair(s) entered."<<endl;
		}
	} 
	else{
		if ( button == GLUT_LEFT_BUTTON && state == GLUT_DOWN ){
			//cout<<x<<"--"<<y<<endl;

			Mat topToCurrTrans;
			invert(keyToTopTrans * currToKeyTrans, topToCurrTrans);

			vector<Point2f> augmentedPoint;
			perspectiveTransform(vector<Point2f>(1, Point2f((float) x, (float) y)),
				augmentedPoint, topToCurrTrans);

			playerAnnotation = augmentedPoint[0];
			//vector<KeyPoint> filteredPoints;

			Mat binaryImage;
			threshold(grayFrame, binaryImage, thres, 255,THRESH_BINARY);

			prevRect = closeRect(binaryImage, playerAnnotation, x_range, y_range);
			Mat watch = rawFrame;
			rectangle(rawFrame, prevRect[0], prevRect[1], Scalar(255, 255, 0));
			rectangle(rawFrame, Point(playerAnnotation.x - x_range,playerAnnotation.y - y_range), Point(playerAnnotation.x+x_range,playerAnnotation.y+y_range), Scalar(255, 0, 255));
		}
	}
}
Ejemplo n.º 3
0
void ClosableImage::mouseMoveEvent(QMouseEvent *ev)
{
    if (!m_loading) {
        if ((!m_image.isNull() || !m_imagePath.isEmpty()) && closeRect().contains(ev->pos())) {
            setCursor(Qt::PointingHandCursor);
            setToolTip(tr("Delete Image"));
            return;
        }

        if ((!m_image.isNull() || !m_imagePath.isEmpty()) && m_showZoomAndResolution && zoomRect().contains(ev->pos())) {
            setCursor(Qt::PointingHandCursor);
            setToolTip(tr("Zoom Image"));
            return;
        }

        if (m_showCapture && captureRect().contains(ev->pos())) {
            setCursor(Qt::PointingHandCursor);
            setToolTip(tr("Capture random screenshot"));
            return;
        }

        if (m_clickable && imgRect().contains(ev->pos())) {
            setCursor(Qt::PointingHandCursor);
            setToolTip(tr("Select another image"));
            return;
        }
    }
    setCursor(Qt::ArrowCursor);
    setToolTip("");
}
Ejemplo n.º 4
0
void TPanelTitleBar::paintEvent(QPaintEvent *)
{
	QPainter painter(this);
	QRect rect = this->rect();

	QColor titleColor;
	QColor brushColor;

	TPanel *dw = qobject_cast<TPanel *>(parentWidget());
	Q_ASSERT(dw != 0);
	if (!dw->isFloating()) {
		if (dw->widgetInThisPanelIsFocused()) {
			brushColor = QColor(64, 64, 64);
			titleColor = QColor(Qt::white);
		} else {
			brushColor = QColor(100, 100, 100);
			titleColor = QColor(192, 192, 192);
		}
	} else if (isActiveWindow()) {
		brushColor = QColor(96, 96, 96);
		titleColor = QColor(Qt::white);
	} else {
		brushColor = QColor(128, 128, 128);
		titleColor = QColor(192, 192, 192);
	}
	painter.setBrush(brushColor);
	painter.setPen(Qt::black);
	painter.drawRect(rect.adjusted(0, 0, -1, -1));

	painter.setPen(titleColor);
	painter.drawLine(rect.topLeft(), rect.bottomLeft());
	painter.drawLine(rect.topLeft(), rect.topRight());

	if (dw->getOrientation() == TDockWidget::vertical) {
		QString titleText =
			painter.fontMetrics().elidedText(
				dw->windowTitle(), Qt::ElideRight, rect.width() - 50);

		painter.setBrush(Qt::NoBrush);
		painter.setPen(titleColor);
		painter.drawText(QPointF(10, 15), titleText);
	}

	if (dw->isFloating()) {
		const static QPixmap closeButtonPixmap(":/Resources/close_pane.png");
		const static QPixmap closeButtonPixmapOver(":/Resources/close_pane_rollover.png");

		QRect closeRect(rect.right() - 17, rect.top() + 1, 16, 16);

		if (m_closeButtonHighlighted)
			painter.drawPixmap(closeRect, closeButtonPixmapOver);
		else
			painter.drawPixmap(closeRect, closeButtonPixmap);
	}

	painter.end();
}
void ContentWindowGraphicsItem::drawCloseButton_( QPainter* painter )
{
    float buttonWidth, buttonHeight;
    getButtonDimensions(buttonWidth, buttonHeight);

    QRectF closeRect(coordinates_.x() + coordinates_.width() - buttonWidth, coordinates_.y(), buttonWidth, buttonHeight);
    QPen pen;
    pen.setColor(QColor(255,0,0));
    painter->setPen(pen);
    painter->drawRect(closeRect);
    painter->drawLine(QPointF(coordinates_.x() + coordinates_.width() - buttonWidth, coordinates_.y()),
                      QPointF(coordinates_.x() + coordinates_.width(), coordinates_.y() + buttonHeight));
    painter->drawLine(QPointF(coordinates_.x() + coordinates_.width(), coordinates_.y()),
                      QPointF(coordinates_.x() + coordinates_.width() - buttonWidth, coordinates_.y() + buttonHeight));
}
Ejemplo n.º 6
0
QRectF UBGraphicsCompass::closeButtonRect() const
{
    QPixmap closePixmap(":/images/closeTool.svg");

    QSizeF closeRectSize(
        closePixmap.width() * mAntiScaleRatio,
        closePixmap.height() * mAntiScaleRatio);

    QPointF closeRectTopLeft(
        sNeedleLength + sNeedleBaseLength + 4,
        (rect().height() - closeRectSize.height()) / 2);

    QRectF closeRect(closeRectTopLeft, closeRectSize);
    closeRect.translate(rect().topLeft());

    return closeRect;
}
Ejemplo n.º 7
0
void TPanelTitleBar::paintEvent(QPaintEvent *) {
  QPainter painter(this);
  QRect rect = this->rect();

  bool isPanelActive;

  TPanel *dw = qobject_cast<TPanel *>(parentWidget());
  Q_ASSERT(dw != 0);
  // docked panel
  if (!dw->isFloating()) {
    isPanelActive = dw->widgetInThisPanelIsFocused();
    qDrawBorderPixmap(&painter, rect, QMargins(3, 3, 3, 3),
                      (isPanelActive) ? m_activeBorderPm : m_borderPm);
  }
  // floating panel
  else {
    isPanelActive = isActiveWindow();
    qDrawBorderPixmap(
        &painter, rect, QMargins(3, 3, 3, 3),
        (isPanelActive) ? m_floatActiveBorderPm : m_floatBorderPm);
  }

  if (dw->getOrientation() == TDockWidget::vertical) {
    QString titleText = painter.fontMetrics().elidedText(
        dw->windowTitle(), Qt::ElideRight, rect.width() - 50);

    painter.setBrush(Qt::NoBrush);
    painter.setPen(isPanelActive ? m_activeTitleColor : m_titleColor);
    painter.drawText(QPointF(10, 15), titleText);
  }

  if (dw->isFloating()) {
    const static QPixmap closeButtonPixmap(":/Resources/close_pane.png");
    const static QPixmap closeButtonPixmapOver(
        ":/Resources/close_pane_rollover.png");

    QRect closeRect(rect.right() - 17, rect.top() + 1, 16, 16);

    if (m_closeButtonHighlighted)
      painter.drawPixmap(closeRect, closeButtonPixmapOver);
    else
      painter.drawPixmap(closeRect, closeButtonPixmap);
  }

  painter.end();
}
Ejemplo n.º 8
0
void CMainDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	POINT p(point);
	ScreenToClient(&p);
	if (p.y <= 100 && p.y >= 18)
	{
		int buttonth = p.x/100;
		switch(buttonth)
		{
		case 0:
			PostMessage(WM_HOME);
			break;
		case 1:
			PostMessage(WM_CAMERA);
			break;
		case 2:
			PostMessage(WM_UPDOWNDLG);
			break;
		case 3:
			PostMessage(WM_FRIENDGROUP);
			break;
		case 4:
			PostMessage(WM_VIDEO_LIST);
			break;
		}
	}
	CRect closeRect(775,0,800,25);
	CRect mimimazeRect(750,0,775,25);
	if (closeRect.PtInRect(p))
	{
		SendMessage(WM_CLOSE);
	}
	else if (mimimazeRect.PtInRect(p))
	{
		SendMessage(WM_SYSCOMMAND,SC_MINIMIZE,0);
	}
	CRect linkRect(550,30,760,80);
	if (linkRect.PtInRect(p))
	{
		ShellExecute(NULL,L"open",L"http://121.199.24.119/templates/index.html",NULL,NULL,SW_SHOWNORMAL);
	}
	
	CDialogEx::OnNcLButtonDown(nHitTest, point);
}
Ejemplo n.º 9
0
void ClosableImage::mousePressEvent(QMouseEvent *ev)
{
    if (ev->button() != Qt::LeftButton)
        return;
    QRect closeRect(width()-25, 0, 24, 24);
    QRect zoomRect(0, height()-16, 16, 16);
    if (closeRect.contains(ev->pos()) && m_pixmap.isNull()) {
        m_pixmap = QPixmap::grabWidget(this);
        QPropertyAnimation *anim = new QPropertyAnimation(this);
        anim->setEasingCurve(QEasingCurve::InQuad);
        anim->setTargetObject(this);
        anim->setStartValue(0);
        anim->setEndValue(width()/2);
        anim->setPropertyName("mySize");
        anim->setDuration(400);
        anim->start(QPropertyAnimation::DeleteWhenStopped);
        connect(anim, SIGNAL(finished()), this, SIGNAL(sigClose()));
    } else if (m_showZoomAndResolution && zoomRect.contains(ev->pos()) && m_pixmap.isNull()) {
        emit sigZoom(m_image);
    }
}
void ContentWindowGraphicsItem::paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
{
    QGraphicsRectItem::paint(painter, option, widget);

    boost::shared_ptr<ContentWindowManager> contentWindowManager = getContentWindowManager();

    if(contentWindowManager != NULL)
    {
        // default pen
        QPen pen;

        // button dimensions
        float buttonWidth, buttonHeight;
        getButtonDimensions(buttonWidth, buttonHeight);

        // draw close button
        QRectF closeRect(rect().x() + rect().width() - buttonWidth, rect().y(), buttonWidth, buttonHeight);
        pen.setColor(QColor(255,0,0));
        painter->setPen(pen);
        painter->drawRect(closeRect);
        painter->drawLine(QPointF(rect().x() + rect().width() - buttonWidth, rect().y()), QPointF(rect().x() + rect().width(), rect().y() + buttonHeight));
        painter->drawLine(QPointF(rect().x() + rect().width(), rect().y()), QPointF(rect().x() + rect().width() - buttonWidth, rect().y() + buttonHeight));

        // resize indicator
        QRectF resizeRect(rect().x() + rect().width() - buttonWidth, rect().y() + rect().height() - buttonHeight, buttonWidth, buttonHeight);
        pen.setColor(QColor(128,128,128));
        painter->setPen(pen);
        painter->drawRect(resizeRect);
        painter->drawLine(QPointF(rect().x() + rect().width(), rect().y() + rect().height() - buttonHeight), QPointF(rect().x() + rect().width() - buttonWidth, rect().y() + rect().height()));

        // text label

        // set the font
        float fontSize = 24.;

        QFont font;
        font.setPixelSize(fontSize);
        painter->setFont(font);

        // color the text black
        pen.setColor(QColor(0,0,0));
        painter->setPen(pen);

        // scale the text size down to the height of the graphics view
        // and, calculate the bounding rectangle for the text based on this scale
        // the dimensions of the view need to be corrected for the tiled display aspect ratio
        // recall the tiled display UI is only part of the graphics view since we show it at the correct aspect ratio
        float viewWidth = (float)scene()->views()[0]->width();
        float viewHeight = (float)scene()->views()[0]->height();

        float tiledDisplayAspect = (float)g_configuration->getTotalWidth() / (float)g_configuration->getTotalHeight();

        if(viewWidth / viewHeight > tiledDisplayAspect)
        {
            viewWidth = viewHeight * tiledDisplayAspect;
        }
        else if(viewWidth / viewHeight <= tiledDisplayAspect)
        {
            viewHeight = viewWidth / tiledDisplayAspect;
        }

        float verticalTextScale = 1. / viewHeight;
        float horizontalTextScale = viewHeight / viewWidth * verticalTextScale;

        painter->scale(horizontalTextScale, verticalTextScale);

        QRectF textBoundingRect = QRectF(rect().x() / horizontalTextScale, rect().y() / verticalTextScale, rect().width() / horizontalTextScale, rect().height() / verticalTextScale);

        // get the label and render it
        QString label(contentWindowManager->getContent()->getURI().c_str());
        QString labelSection = label.section("/", -1, -1).prepend(" ");
        painter->drawText(textBoundingRect, Qt::AlignLeft | Qt::AlignTop, labelSection);

        // draw window info at smaller scale
        verticalTextScale *= 0.5;
        horizontalTextScale *= 0.5;

        painter->scale(0.5, 0.5);

        textBoundingRect = QRectF(rect().x() / horizontalTextScale, rect().y() / verticalTextScale, rect().width() / horizontalTextScale, rect().height() / verticalTextScale);

        QString coordinatesLabel = QString(" (") + QString::number(x_, 'f', 2) + QString(" ,") + QString::number(y_, 'f', 2) + QString(", ") + QString::number(w_, 'f', 2) + QString(", ") + QString::number(h_, 'f', 2) + QString(")\n");
        QString zoomCenterLabel = QString(" zoom = ") + QString::number(zoom_, 'f', 2) + QString(" @ (") + QString::number(centerX_, 'f', 2) + QString(", ") + QString::number(centerY_, 'f', 2) + QString(")");
        QString interactionLabel = QString(" x: ") +
                                   QString::number(interactionState_.mouseX_, 'f', 2) +
                                   QString(" y: ") + QString::number(interactionState_.mouseY_, 'f', 2) +
                                   QString(" mouseLeft: ") + QString::number((int) interactionState_.mouseLeft_, 'b', 1) +
                                   QString(" mouseMiddle: ") + QString::number((int) interactionState_.mouseMiddle_, 'b', 1) +
                                   QString(" mouseRight: ") + QString::number((int) interactionState_.mouseRight_, 'b', 1);

        QString windowInfoLabel = coordinatesLabel + zoomCenterLabel + interactionLabel;
        painter->drawText(textBoundingRect, Qt::AlignLeft | Qt::AlignBottom, windowInfoLabel);
    }
}