Пример #1
0
static void qDrawWinArrow(QPainter *p, Qt::ArrowType type, bool down,
                           int x, int y, int w, int h,
                           const QPalette &pal, bool enabled)
{
    QPolygon a;                                // arrow polygon
    switch (type) {
    case Qt::UpArrow:
        a.setPoints(7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2);
        break;
    case Qt::DownArrow:
        a.setPoints(7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2);
        break;
    case Qt::LeftArrow:
        a.setPoints(7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0);
        break;
    case Qt::RightArrow:
        a.setPoints(7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0);
        break;
    default:
        break;
    }
    if (a.isEmpty())
        return;

    if (down) {
        x++;
        y++;
    }

    QPen savePen = p->pen();                        // save current pen
    if (down)
        p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
    p->fillRect(x, y, w, h, pal.brush(QPalette::Button));
    if (down)
        p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
    if (enabled) {
        a.translate(x+w/2, y+h/2);
        p->setPen(pal.foreground().color());
        p->drawLine(a.at(0), a.at(1));
        p->drawLine(a.at(2), a.at(2));
        p->drawPoint(a[6]);
    } else {
        a.translate(x+w/2+1, y+h/2+1);
        p->setPen(pal.light().color());
        p->drawLine(a.at(0), a.at(1));
        p->drawLine(a.at(2), a.at(2));
        p->drawPoint(a[6]);
        a.translate(-1, -1);
        p->setPen(pal.mid().color());
        p->drawLine(a.at(0), a.at(1));
        p->drawLine(a.at(2), a.at(2));
        p->drawPoint(a[6]);
    }
    p->setPen(savePen);                        // restore pen
}
Пример #2
0
QPolygon sdraw::normalizePolygon(const QPolygon &polygon, int offset)
{
   QPolygon ret = polygon;
   QRect boundingRect = ret.boundingRect();
   QPoint transPt(-boundingRect.topLeft().x() + offset,
      -boundingRect.topLeft().y() + offset);
   ret.translate(transPt);
   return ret;
}
Пример #3
0
void KigPainter::drawRightAngle( const Coordinate& point, double startangle, int diagonal )
{
    const int startangleDegrees = static_cast<int>( Goniometry::convert( startangle, Goniometry::Rad, Goniometry::Deg ) );
    QPolygon rightAnglePolygon;
    QMatrix rotationMatrix;
    int halfSide = diagonal * sin( M_PI / 4 );
    const QPoint screenPoint = toScreen( point );

    rightAnglePolygon << QPoint( halfSide, 0 ) << QPoint( halfSide, -halfSide ) << QPoint( 0, -halfSide );

    rotationMatrix.rotate( -startangleDegrees );
    rightAnglePolygon = rotationMatrix.map( rightAnglePolygon );
    rightAnglePolygon.translate( screenPoint );

    mP.drawPolyline( rightAnglePolygon );

    setWholeWinOverlay();
}
Пример #4
0
QImage Selection::shapeMask(const QColor &color, QPoint *offset) const
{
    const QRect b = boundingRect();
    QPolygon p = m_shape.toPolygon();
    p.translate(-b.topLeft());

    QImage mask(b.size(), QImage::Format_ARGB32);
    mask.fill(0);
    QPainter painter(&mask);
    painter.setPen(Qt::NoPen);
    painter.setBrush(color);
    painter.drawPolygon(p);

    if(offset)
        *offset = b.topLeft();

    return mask;
}
Пример #5
0
void CamShift::imageRecived(const cv::Mat& image)
{
    cv::Rect l_rect = (m_rect.height > 0) ? m_rect : cv::Rect(0, 0, image.cols, image.rows);

    cv::RotatedRect rrect =  cv::CamShift(image, l_rect, m_criteria);

    emit detectedHotPoint(QPoint(rrect.center.x, rrect.center.y));

    const QRect rect(-rrect.size.height/2, -rrect.size.width/2, rrect.size.height, rrect.size.width);
    QTransform transform;
    transform.rotate(rrect.angle, Qt::ZAxis);
    QVector<QPolygon> ret;
    QPolygon polygon = transform.map(QPolygon(rect, true));
    polygon.translate(rrect.center.x , rrect.center.y);
    ret.append(polygon);


    emit detected(ret);
}