当前位置: 首页>>代码示例>>C++>>正文


C++ QPolygon::translate方法代码示例

本文整理汇总了C++中QPolygon::translate方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygon::translate方法的具体用法?C++ QPolygon::translate怎么用?C++ QPolygon::translate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QPolygon的用法示例。


在下文中一共展示了QPolygon::translate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: qDrawWinArrow

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
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:55,代码来源:qdrawutil.cpp

示例2: normalizePolygon

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;
}
开发者ID:Broentech,项目名称:sdraw,代码行数:9,代码来源:draw_2D.cpp

示例3: drawRightAngle

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();
}
开发者ID:KDE,项目名称:kig,代码行数:18,代码来源:kigpainter.cpp

示例4: shapeMask

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;
}
开发者ID:nitrau,项目名称:Drawpile,代码行数:18,代码来源:selection.cpp

示例5: imageRecived

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);
}
开发者ID:mmalicki2,项目名称:QOczko,代码行数:19,代码来源:camshift.cpp


注:本文中的QPolygon::translate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。