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


C++ QLine::p2方法代码示例

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


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

示例1: 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

示例2: setLine

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

示例3: _getNearestIntersectionPoint

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

示例4: _drawLinkLines

// 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

示例5: line

QT_BEGIN_NAMESPACE

/*!
    \class QLine
    \inmodule QtCore
    \ingroup painting

    \brief The QLine class provides a two-dimensional vector using
    integer precision.

    A QLine describes a finite length line (or a line segment) on a
    two-dimensional surface. The start and end points of the line are
    specified using integer point accuracy for coordinates. Use the
    QLineF constructor to retrieve a floating point copy.

    \table
    \row
        \li \inlineimage qline-point.png
        \li \inlineimage qline-coordinates.png
    \endtable

    The positions of the line's start and end points can be retrieved
    using the p1(), x1(), y1(), p2(), x2(), and y2() functions. The
    dx() and dy() functions return the horizontal and vertical
    components of the line. Use isNull() to determine whether the
    QLine represents a valid line or a null line.

    Finally, the line can be translated a given offset using the
    translate() function.

    \sa QLineF, QPolygon, QRect
*/

/*!
    \fn QLine::QLine()

    Constructs a null line.
*/

/*!
    \fn QLine::QLine(const QPoint &p1, const QPoint &p2)

    Constructs a line object that represents the line between \a p1 and
    \a p2.
*/

/*!
    \fn QLine::QLine(int x1, int y1, int x2, int y2)

    Constructs a line object that represents the line between (\a x1, \a y1) and
    (\a x2, \a y2).
*/

/*!
    \fn bool QLine::isNull() const

    Returns true if the line is not set up with valid start and end point;
    otherwise returns false.
*/

/*!
    \fn QPoint QLine::p1() const

    Returns the line's start point.

    \sa x1(), y1(), p2()
*/

/*!
    \fn QPoint QLine::p2() const

    Returns the line's end point.

    \sa x2(), y2(), p1()
*/

/*!
    \fn int QLine::x1() const

    Returns the x-coordinate of the line's start point.

    \sa p1()
*/

/*!
    \fn int QLine::y1() const

    Returns the y-coordinate of the line's start point.

    \sa p1()
*/

/*!
    \fn int QLine::x2() const

    Returns the x-coordinate of the line's end point.

    \sa p2()
*/

//.........这里部分代码省略.........
开发者ID:ghjinlei,项目名称:qt5,代码行数:101,代码来源:qline.cpp

示例6: map

/*!
    \overload

    Creates and returns a QLine object that is a copy of the given \a
    line, mapped into the coordinate system defined by this matrix.
    Note that the transformed coordinates are rounded to the nearest
    integer.
*/
QLine QMatrix::map(const QLine &line) const
{
    return QLine(map(line.p1()), map(line.p2()));
}
开发者ID:12307,项目名称:VLC-for-VS2010,代码行数:12,代码来源:qmatrix.cpp

示例7: QLine

template<> Q_INLINE_TEMPLATE QLine _q_interpolate(const QLine &f, const QLine &t, qreal progress)
{
    return QLine( _q_interpolate(f.p1(), t.p1(), progress), _q_interpolate(f.p2(), t.p2(), progress));
}
开发者ID:12307,项目名称:VLC-for-VS2010,代码行数:4,代码来源:qvariantanimation.cpp

示例8: paintEvent


//.........这里部分代码省略.........
        for(unsigned int j=0; j< currentBuildingView->getFloorViews().size(); j++)
        {
            FloorView* currentFloorView(currentBuildingView->getFloorViews()[j]);

            // take selected pen if view has been selected
            if(selectedFloor == currentFloorView)
                painter.setPen(selectedPen);
            else
                painter.setPen(defaultPen);

            // get floor coordonates
            QRect rect(currentBuildingView->x()+15, currentBuildingView->y()+ 15 + j * 90, 120,75);
            painter.drawRect(rect);

            // add color
            if(isAdmin)
                painter.fillRect(rect, floorAdminColor);
            else
                painter.fillRect(rect, floorColor);

            // add floor name
            painter.drawText(rect, Qt::AlignHCenter,currentFloorView->getName());

            // if all users are null set warning style and add an error in errors
            if(currentFloorView->getFloor()->isUsersNull())
            {
                painter.setFont(warningTextFont);
                painter.setPen(warningTextPen);
                errors.push_back(currentFloorView->getName().toStdString()+" in "+currentBuildingView->getName().toStdString()+ " doesn't have any user.");
            }

            // add floor users
            painter.drawText(rect, Qt::AlignBottom+Qt::AlignCenter, currentFloorView->getUsers());

            // reset pen and font
            painter.setFont(defaultFont);
            painter.setPen(defaultPen);
        }

        //add name
        painter.drawText(*currentBuildingView,Qt::AlignHCenter,currentBuildingView->getName());

        // if all users are null set warning style and add an error in errors
        if(currentBuildingView->getBuilding()->isUsersNull() && !currentBuildingView->getBuildingPanel()->isReadOnly())
        {
            painter.setFont(warningTextFont);
            painter.setPen(warningTextPen);
            errors.push_back(currentBuildingView->getName().toStdString()+" doesn't have any user.");
        }

        // add building users
        painter.drawText(*currentBuildingView, Qt::AlignBottom+Qt::AlignCenter, currentBuildingView->getUsers());

        // reset pen and font
        painter.setFont(defaultFont);
        painter.setPen(defaultPen);
    }

    // foreach b2b view, add it on the board
    for(unsigned int i = 0; i< b2bViews.size(); i++)
    {
        Building_BuildingView *currentB2bView = b2bViews[i];

        //check if the view is selected
        if(currentB2bView == selectedB2bView)
            painter.setPen(selectedPen);
        else
            painter.setPen(defaultPen);

        // get the line to draw
        // if there is an intersection between 2 building don't draw
        if(!currentB2bView->intersect())
        {
            // draw the line
            QLine line = currentB2bView->getLine();
            painter.drawLine(line);

            // find the middle of the line and right the distance
            // get the x average and the y average, offset 4 on y to place text above line
            QPoint mid((line.p2().x()+line.p1().x())/2, (line.p2().y()+line.p1().y())/2-4);

            // if distance == 0 set warning style and add an error
            double distance = currentB2bView->getB2b()->getDistance();
            if(distance == 0)
            {
                painter.setFont(warningTextFont);
                painter.setPen(warningTextPen);
                errors.push_back("Distance between "+ currentB2bView->getBuilding1()->getName().toStdString() +" and "+currentB2bView->getBuilding2()->getName().toStdString()+" can't be null.");
            }

            // draw distance
            painter.drawText(mid, currentB2bView->getDistance());

            // reset pen and style
            painter.setPen(defaultPen);
            painter.setFont(defaultFont);
        }
    }
    painter.end();
}
开发者ID:Feawel,项目名称:CPP_ProjetReseau,代码行数:101,代码来源:requestinterface.cpp

示例9: mousePressEvent

/**
 * @brief RequestInterface::mousePressEvent
 * @param event
 * find the current focus
 */
void RequestInterface::mousePressEvent(QMouseEvent *event)
{
    // reset selected view pointers
    selectedBuildingView = 0;
    selectedB2bView = 0;
    selectedFloor = 0;

    // reset panel to default
    formPanel->setWidget(defaultPanel);

    // check if the user select a building or a floor
    for(unsigned int i = 0 ; i < buildingViews.size();i++)
    {
        BuildingView *currentBuildingView = buildingViews[i];
        //check first floors
        for(unsigned int j =0; j < currentBuildingView->getFloorViews().size(); j++)
        {
            QRect rect(currentBuildingView->x()+15, currentBuildingView->y()+ 15 + j * 90, 120,75);
            if(rect.contains(event->pos()))
            {
                // select the floor and add the panel
                selectedFloor = currentBuildingView->getFloorViews()[j];
                formPanel->setWidget(selectedFloor->getFloorPanel());
                break;
            }
        }

        // if no floor has been selected
        if(selectedFloor==0 && buildingViews[i]->contains(event->pos()))
        {
            // select the building and add the panel
            selectedBuildingView = buildingViews[i];
            formPanel->setWidget(selectedBuildingView->getBuildingPanel());
            break;
        }
    }

    // check if the user select a link b2b if no location has been selected
    if(selectedBuildingView==0 && selectedFloor == 0)
    {
        bool selected = false;
        for(unsigned int i= 0; i< b2bViews.size(); i++)
        {
            // get the line
            QLine line = b2bViews[i]->getLine();
            //event coordonates
            int ex=event->x();
            int ey=event->y();

            // split vertical line and other cases
            // ex = line.p1().x() = line.p2().x() with SELECT_MARGIN of error
            // line.p1().y() < ey < line.p2().y() or line.p2().y() < ey < line.p1().y() with SELECT_MARGIN of error
            if(line.p2().x()==line.p1().x())
            {
                if(line.p1().x()-SELECT_MARGIN <= ex && ex <= line.p1().x()+SELECT_MARGIN && ((line.p1().y()-SELECT_MARGIN <= ey && line.p2().y()+SELECT_MARGIN>= ey) || (line.p2().y()-SELECT_MARGIN <= ey && line.p1().y()+SELECT_MARGIN>= ey)))
                {
                    selected=true;
                }
            }
            else
            {
                // calculate line equation y = la * x + lb
                float la = float(line.p2().y()-line.p1().y())/float(line.p2().x()-line.p1().x());
                float lb = float(line.p1().y()-la*line.p1().x());
                // calculate y coordonate on the line for x=ex
                float ly = la*ex+lb;

                // check if ly and ey are close
                if(ly-SELECT_MARGIN<=ey && ey<=ly+SELECT_MARGIN)
                {
                    selected =true;
                }
            }
            if(selected)
            {
                // select the b2b and add the panel
                selectedB2bView = b2bViews[i];
                formPanel->setWidget(selectedB2bView->getB2bPanel());
                break;
            }
        }
    }

    // update draw
    update();
}
开发者ID:Feawel,项目名称:CPP_ProjetReseau,代码行数:91,代码来源:requestinterface.cpp

示例10: rotateQLine

QLine MathUtils::rotateQLine(QLine &line, qint32 angle)
{
    QLine newLine(MathUtils::rotatePoint(line.p1(), angle).toPoint(),
               MathUtils::rotatePoint(line.p2(), angle).toPoint());
    return newLine;
}
开发者ID:NinjaTrappeur,项目名称:pong-client,代码行数:6,代码来源:mathutils.cpp


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