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


C++ QLine类代码示例

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


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

示例1: extractBlackGuide

QLine extractBlackGuide(QImage input,QPoint start,bool hor) {
    QLine line;
    QPoint step(1,0);
    if (!hor) {
        // vertical movement
        step = QPoint(0,1);
    }

    QPoint pt = start;

    while (pt.x() < input.width() && pt.y() < input.height()) {
        if (input.pixel(pt) == 0xFF000000) {
            line.setP1(pt);
            break;
        }
        pt += step;
    }

    while (pt.x() < input.width() && pt.y() < input.height()) {
        if (input.pixel(pt) != 0xFF000000) {
            line.setP2(pt);
            break;
        }
        pt += step;
    }

    return line;
}
开发者ID:Wellingtonjunior,项目名称:quickandroid,代码行数:28,代码来源:main.cpp

示例2: initRollChar

void qAttitudeIndicator::initRollChar()
{
    QLine line;
    line.setLine(-size/32,14*size/32,0,15*size/32);
    target.append(line);
    line.setLine(0,15*size/32,size/32,14*size/32);
    target.append(line);
    line.setLine(size/32,14*size/32,-size/32,14*size/32);
    target.append(line);
}
开发者ID:dgrat,项目名称:rpicopter,代码行数:10,代码来源:attitudeindicator.cpp

示例3: cos

QHash<QString, QLine> Controller::coordinateAxes(Length length){
    QLine x;
    QLine y;
    QLine z;

    int size = length;

    //z
    z.setP1(QPoint(0, size));
    z.setP2(QPoint(0, -size));

    //x
    x.setP1(QPoint( -size, 0));
    x.setP2(QPoint(size, 0));


    //z
    y.setP1(QPoint(size * cos(_alpha * M_PI/180), -size * sin(_alpha * M_PI/180)));
    y.setP2(QPoint(-size * cos(_alpha * M_PI/180), size * sin(_alpha * M_PI/180)));

    QHash<QString, QLine> axes = {
                                {"X", x},
                                {"Y", y},
                                {"Z", z}
                            };
    return axes;
}
开发者ID:NickolayStorm,项目名称:usatu-learning,代码行数:27,代码来源:controller.cpp

示例4: QPen

void map_widget::drawRobotPose(QPainter *painter , QPaintEvent *event)
{
    QPoint Robot_Pose = this->convertToActFrame( sensor_connection->act_pose.x_pos,
                                                 sensor_connection->act_pose.y_pos,
                                                 event );

    painter->setPen( QPen( Qt::red, 5, Qt::SolidLine, Qt::RoundCap) );
    painter->drawPoint( Robot_Pose );

    // Draw the orientatian;
    // Berechne Steigung
    const double lenght_of_orientation_line = 2.0;

    double theta = sensor_connection->act_pose.theta;
    while( theta >= (2* M_PI) )
    {
        theta -= (2* M_PI);
    }

    double skew_y = tan( theta );
    double skew_x = 1.0;

    if( theta == 0.5 * M_PI )
    {
        skew_y = 1.0;
        skew_x = 0.0;
    }

    else if( theta == (3.0*M_PI)/2.0 )
    {
        skew_y = -1.0;
        skew_x = 0.0;
    }

    else if( theta >= 0.5 * M_PI && theta < (3.0*M_PI)/2.0)
    {
        skew_y *= -1.0;
        skew_x *= -1.0;
    }

    double distance = sqrt( (skew_x*skew_x) + (skew_y*skew_y) );
    skew_x = (skew_x * lenght_of_orientation_line) / distance;
    skew_y = (skew_y * lenght_of_orientation_line) / distance;

    skew_x *= ((double) event->rect().width() / (double) this->visible_rect.width() );
    skew_y *= ((double) event->rect().height() / (double) this->visible_rect.height() );

    QLine line;
    line.setP1( Robot_Pose );
    line.setP2( QPoint(Robot_Pose.x() + skew_x, Robot_Pose.y() - skew_y) );

    painter->setPen( QPen( Qt::red, 3, Qt::SolidLine, Qt::RoundCap) );
    painter->drawLine( line );
}
开发者ID:TWes,项目名称:Robot01,代码行数:54,代码来源:map_widget.cpp

示例5: initTargetChar

void qAttitudeIndicator::initTargetChar()
{
    QLine line;
    line.setLine(-size/4,0,-size/16,0);
    target.append(line);
    line.setLine(-size/16,0,0,-size/32);
    target.append(line);
    line.setLine(0,-size/32,size/16,0);
    target.append(line);
    line.setLine(size/16,0,size/4,0);
    target.append(line);
}
开发者ID:dgrat,项目名称:rpicopter,代码行数:12,代码来源:attitudeindicator.cpp

示例6: eASSERT

// Draw connection lines between linking
// operators (to visualize dependencies).
void eGuiOpPage::_drawLinkLines(QPainter *painter)
{
    eASSERT(painter != eNULL);

    static const QPoint arrowPts[3] =
    {
        QPoint(0,            0),
        QPoint(-ARROW_SIZE,  ARROW_SIZE),
        QPoint(-ARROW_SIZE, -ARROW_SIZE)
    };

    painter->save();
    painter->setRenderHint(QPainter::HighQualityAntialiasing, true);
    painter->setPen(QColor(80, 90, 100));
    painter->setBrush(QBrush(QColor(120, 130, 140), Qt::SolidPattern));

    for (eU32 i=0; i<m_opPage->getOperatorCount(); i++)
    {
        const eIOperator *op = m_opPage->getOperatorByIndex(i);
        eASSERT(op != eNULL);

        for (eU32 j=0; j<op->getLinkingCount(); j++)
        {
            const eID linkingId = op->getLinkingOperator(j);
            const eIOperator *linkingOp = eDemoData::findOperator(linkingId);

            // Lies linking operator on same page?
            if (linkingOp && linkingOp->getOwnerPage() == m_opPage)
            {
                // Yes, so draw line between them.
                const QRect opRect = _getOperatorRect(op);
                const QRect linkingRect = _getOperatorRect(linkingOp);

                // Calculate nearest intersection point and
                // angle to rotate arrow.
                const QPoint nip = _getNearestIntersectionPoint(opRect, QLine(linkingRect.center(), opRect.center()));
                const QLine line(nip, linkingRect.center());
                const QPoint p = line.p1()-line.p2();
                const eF32 angle = eRadToDeg(eATan2(p.y(), p.x()));

                painter->drawLine(line);
                painter->save();
                painter->translate(line.p1().x(), line.p1().y());
                painter->rotate(angle);
                painter->drawConvexPolygon(arrowPts, 3);
                painter->restore();
            }
        }
    }

    painter->restore();
}
开发者ID:DX94,项目名称:Enigma-Studio-3,代码行数:54,代码来源:guioppage.cpp

示例7: line

    void line(const QLine& line, Callback&& func)
    {
        // Sign of delta x/y
        int sx = line.dx() > 0 ? 1 : -1;
        int sy = line.dy() > 0 ? 1 : -1;
        // Value that determines whether to move on X or Y
        int error = 0;
        // Absolute value of delta x/y
        int deltaerry = line.dy() * sy;
        int deltaerrx = line.dx() * sx;

        QPoint point = line.p1();

        while ( point != line.p2() )
        {
            func(point);

            error += deltaerry;
            while ( error >= deltaerrx / 2 && point.y() != line.y2() )
            {
                func(point);
                point.setY(point.y() + sy);
                error -= deltaerrx;
            }

            if ( point.x() != line.x2() )
                point.setX(point.x() + sx);
        }

        func(point);
    }
开发者ID:mbasaglia,项目名称:PixelCayman,代码行数:31,代码来源:draw.hpp

示例8: addPlacementLine

void WidgetArea::addPlacementLine(int val, bool vertical, bool& changed)
{
    QLine l;
    if(vertical)
        l.setLine(val, -PLACEMENT_SHOW, val, height()+PLACEMENT_SHOW);
    else
        l.setLine(-PLACEMENT_SHOW, val, width()+PLACEMENT_SHOW, val);

    if(m_placementLines.contains(l))
        return;

    m_placementLines.push_back(l);
    changed = true;
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例9: sendLine

QString PackageManager::sendLine(QDataStream &stream, QLine line, QPen pen, QString old)
{
	// "order:line:x1:y1:x2:y3:color:size"
	QString packet = "order:line:";
	packet += QString::number(line.x1()) + ":";
	packet += QString::number(line.y1()) + ":";
	packet += QString::number(line.x2()) + ":";
	packet += QString::number(line.y2()) + ":";
	packet += pen.color().name() += ":";
	packet += QString::number(pen.width());
	
	if (packet != old)
		stream << packet;
	return packet;
}
开发者ID:kbollini,项目名称:dessin-realite-augmentee,代码行数:15,代码来源:packagemanager.cpp

示例10: settings

QIcon ConfigTabAppearance::createThemeIcon(const QString &fileName)
{
    QSettings settings(fileName, QSettings::IniFormat);
    Theme theme(settings);

    QPixmap pix(16, 16);
    pix.fill(Qt::black);

    QPainter p(&pix);

    QRect rect(1, 1, 14, 5);
    p.setPen(Qt::NoPen);
    p.setBrush( theme.color("sel_bg") );
    p.drawRect(rect);

    rect.translate(0, 5);
    p.setBrush( theme.color("bg") );
    p.drawRect(rect);

    rect.translate(0, 5);
    p.setBrush( theme.color("alt_bg") );
    p.drawRect(rect);

    QLine line;

    line = QLine(2, 3, 14, 3);
    QPen pen;
    p.setOpacity(0.6);

    pen.setColor( theme.color("sel_fg") );
    pen.setDashPattern(QVector<qreal>() << 2 << 1 << 1 << 1 << 3 << 1 << 2 << 10);
    p.setPen(pen);
    p.drawLine(line);

    line.translate(0, 5);
    pen.setColor( theme.color("fg") );
    pen.setDashPattern(QVector<qreal>() << 2 << 1 << 4 << 10);
    p.setPen(pen);
    p.drawLine(line);

    line.translate(0, 5);
    pen.setDashPattern(QVector<qreal>() << 3 << 1 << 2 << 1);
    p.setPen(pen);
    p.drawLine(line);

    return pix;
}
开发者ID:m4r71n,项目名称:CopyQ,代码行数:47,代码来源:configtabappearance.cpp

示例11: prepareGeometryChanged

void FwLinePrimitive::setLine(const QLine& line)
{
    if(line != this->line())
    {
        prepareGeometryChanged();
        setPos(line.p1());

        m_p2 = line.p2() - line.p1();

        if(line.y1() == line.y2())
        {
            m_orientation = Fw::O_Horizontal;
            m_lenght = m_p2.x() - pos().x();

        }
        else if(line.x1() == line.x2())
        {
            m_orientation = Fw::O_Vertical;
            m_lenght = m_p2.y() - pos().y();
        }
        else
        {
            m_orientation = Fw::O_Diagonal;
            m_lenght = qRound(QLineF(line).length());
        }
        update();
    }
}
开发者ID:govorilka,项目名称:fireworks,代码行数:28,代码来源:fwlineprimitive.cpp

示例12: QLineF

QPoint eGuiOpPage::_getNearestIntersectionPoint(const QRect &r, const QLine &line) const
{
    // First, calculate intersections with all four
    // rectangle sides.
    const QLineF lines[4] =
    {
        QLineF(r.topLeft(),     r.topRight()),
        QLineF(r.topRight(),    r.bottomRight()),
        QLineF(r.bottomRight(), r.bottomLeft()),
        QLineF(r.bottomLeft(),  r.topLeft())
    };

    QVector<QPoint> ips;
    QPointF ip;

    for (eInt i=0; i<4; i++)
    {
        if (lines[i].intersect(line, &ip) == QLineF::BoundedIntersection)
        {
            ips.append(ip.toPoint());
        }
    }

    eASSERT(ips.size() != eNULL);

    // Second, find nearest intersection point.
    QPoint nip = ips[0];
    eU32 minDist = (nip-line.p2()).manhattanLength();

    for (eInt i=1; i<ips.size(); i++)
    {
        eU32 dist = (ips[i]-line.p2()).manhattanLength();

        if (dist < minDist)
        {
            minDist = dist;
            nip = ips[i];
        }
    }

    return nip;
}
开发者ID:DX94,项目名称:Enigma-Studio-3,代码行数:42,代码来源:guioppage.cpp

示例13: qwtMaskRegion

static inline QRegion qwtMaskRegion( const QLine &l, int penWidth )
{
    const int pw = qMax( penWidth, 1 );
    const int pw2 = penWidth / 2;

    QRegion region;

    if ( l.x1() == l.x2() )
    {
        region += QRect( l.x1() - pw2, l.y1(),
            pw, l.y2() ).normalized();
    }
    else if ( l.y1() == l.y2() )
    {
        region += QRect( l.x1(), l.y1() - pw2,
            l.x2(), pw ).normalized();
    }

    return region;
}
开发者ID:NREL,项目名称:OpenStudio,代码行数:20,代码来源:qwt_picker.cpp

示例14: pointDistToLine_

double PlotIterPath::pointDistToLine_(const QPoint &p, const QLine &l)
{
  // Project the point on the line.
  double lx = l.x2() - l.x1();
  double ly = l.y2() - l.y1();
  double ll = sqrt(lx*lx + ly*ly);
  
  double vx = p.x() - l.x1();
  double vy = p.y() - l.y1();
  
  double prPar = (vx*lx + vy*ly) / ll;
  double prPerp = (vx*ly - vy*lx) / ll;
  
  // The point is on the "left" side of the line.
  if(prPar < 0)
    return sqrt(vx*vx + vy*vy);
  // The point is on the "right" side of the line.
  else if(prPar > ll)
    return sqrt(vx*vx + vy*vy);
  else
    return fabs(prPerp);
}
开发者ID:chivalry123,项目名称:otkpp,代码行数:22,代码来源:plotiterpath.cpp

示例15: get_line_cross_point

QPoint Rotater::get_line_cross_point(QLine base_line, QLine rotate_line)
{
    qreal k = (qreal)rotate_line.dy() / rotate_line.dx();
    int x(0), y(0);

    if (base_line.dy() == 0)
    {
        x = (base_line.y1() - rotate_line.y1()) / k + rotate_line.x1();
        y = base_line.y1();
    }
    else if (base_line.dx() == 0)
    {
        y = (base_line.x1() - rotate_line.x1()) * k + rotate_line.y1();
        x = base_line.x1();
    }

//    qDebug() << "k dx dy" << k << rotate_line.dx() << rotate_line.dy();
//    qDebug() << "rotate_line x1 y1" << rotate_line.x1() << rotate_line.y1();
//    qDebug() << "rotate_line x2 y2" << rotate_line.x2() << rotate_line.y2();

    QPoint p(x, y);
    return p;
}
开发者ID:chenx77,项目名称:MyCodeLab,代码行数:23,代码来源:rotater.cpp


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