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


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

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


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

示例1: adjustedPoints

void
Zoomer::drawRubberBand( QPainter *painter ) const
{
    if ( !isActive() || rubberBand() == NoRubberBand || rubberBandPen().style() == Qt::NoPen )
		return;

	const QPolygon pa = adjustedPoints( pickedPoints() );
    if ( pa.count() < 1 )
        return;

    const QRectF& rc = pickArea().boundingRect(); // view rect
    const QPoint p2 = pa[int( pa.count() - 1 )];

    QwtPainter::drawLine( painter, p2.x(), rc.top(), p2.x(), rc.bottom() );  // vertical @ 2nd point (automaticall drawn by picker)
    QwtPainter::drawLine( painter, rc.left(), p2.y(), rc.right(), p2.y() );  // horizontal @ 2nd point

	if ( pa.count() >= 2 ) {
        const QPoint p1 = pa[0];
        const QRect rect = QRect( p1, p2 ).normalized();
        
        if ( autoYScale_ || rect.height() < minY ) { // select horizontal (indicate by 2 vertical lines)
            QwtPainter::drawLine( painter, p1.x(), rc.top(), p1.x(), rc.bottom() );  // vertical @ 1st point
        } else if ( rect.width() < minX ) {
            QwtPainter::drawLine( painter, rc.left(), p1.y(), rc.right(), p1.y() );  // horizontal @ 1st point
        } else {
            QwtPainter::drawLine( painter, p1.x(), rc.top(), p1.x(), rc.bottom() );  // vertical @ 1st point
            QwtPainter::drawLine( painter, rc.left(), p1.y(), rc.right(), p1.y() );  // horizontal @ 1st point
        }
    }
}
开发者ID:hermixy,项目名称:qtplatz,代码行数:30,代码来源:zoomer.cpp

示例2: QRect

//virtual
bool
Zoomer::accept( QPolygon &pa ) const
{
    if ( pa.count() < 2 )
        return false;
  
    QRect rect = QRect( pa[0], pa[int( pa.count() ) - 1] );
    rect = rect.normalized();
  
    if ( rect.width() < 2 && rect.height() < 2 )
        return false;
    pa.resize( 2 );

    const QRectF& rc = pickArea().boundingRect(); // view rect
    if ( rect.width() < minX ) {
        // make a virtical line
        pa[ 0 ] = QPoint( rc.left(), rect.top() );
        pa[ 1 ] = QPoint( rc.right(), rect.bottom() );
        return true;
    } else if ( rect.height() < minY ) {
        // make a horizontal line
        pa[ 0 ] = QPoint( rect.left(), rc.top() );
        pa[ 1 ] = QPoint( rect.right(), rc.bottom() );
    } else {
        pa[ 0 ] = rect.topLeft();
        pa[ 1 ] = rect.bottomRight();
    }
    return true;
}
开发者ID:hermixy,项目名称:qtplatz,代码行数:30,代码来源:zoomer.cpp

示例3: end

bool QwtPlotPicker::end( bool ok )
{
    ok = QwtPicker::end( ok );
    if ( !ok )
        return false;

    QwtPlot *plot = QwtPlotPicker::plot();
    if ( !plot )
        return false;

    const QPolygon pa = selection();
    if ( pa.count() == 0 )
        return false;

    QwtPickerMachine::SelectionType selectionType =
        QwtPickerMachine::NoSelection;

    if ( stateMachine() )
        selectionType = stateMachine()->selectionType();

    switch ( selectionType )
    {
        case QwtPickerMachine::PointSelection:
        {
            const QPointF pos = invTransform( pa[0] );
            Q_EMIT selected( pos );
            break;
        }
        case QwtPickerMachine::RectSelection:
        {
            if ( pa.count() >= 2 )
            {
                const QPoint p1 = pa[0];
                const QPoint p2 = pa[int( pa.count() - 1 )];

                const QRect rect = QRect( p1, p2 ).normalized();
                Q_EMIT selected( invTransform( rect ) );
            }
            break;
        }
        case QwtPickerMachine::PolygonSelection:
        {
            QVector<QPointF> dpa( pa.count() );
            for ( int i = 0; i < int( pa.count() ); i++ )
                dpa[i] = invTransform( pa[i] );

            Q_EMIT selected( dpa );
        }
        default:
            break;
    }

    return true;
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:54,代码来源:qwt_plot_picker.cpp

示例4:

// Returns whether there is only 1 distinct point in <points>.
static bool Only1PixelInPointArray (const QPolygon &points)
{
    if (points.count () == 0)
        return false;

    for (int i = 1; i < (int) points.count (); i++)
    {
        if (points [i] != points [0])
            return false;
    }

    return true;
}
开发者ID:KDE,项目名称:kolourpaint,代码行数:14,代码来源:kpPixmapFX_DrawShapes.cpp

示例5:

QDebug operator<<(QDebug dbg, const QPolygon &a)
{
    dbg.nospace() << "QPolygon(";
    for (int i = 0; i < a.count(); ++i)
        dbg.nospace() << a.at(i);
    dbg.nospace() << ')';
    return dbg.space();
}
开发者ID:cedrus,项目名称:qt,代码行数:8,代码来源:qpolygon.cpp

示例6: drawPolygon

// public static
void kpPixmapFX::drawPolygon (QImage *image,
        const QPolygon &points,
        const kpColor &fcolor, int penWidth,
        const kpColor &bcolor,
        bool isFinal,
        const kpColor &fStippleColor)
{
    QPainter p(image);

    ::QPainterSetPenWithStipple (&p,
        fcolor, penWidth,
        fStippleColor);

    if (bcolor.isValid ())
        p.setBrush (QBrush (bcolor.toQColor()));
    // HACK: seems to be needed if set_Pen_(Qt::color0) else fills with Qt::color0.
    else
        p.setBrush (Qt::NoBrush);

    // Qt bug: single point doesn't show up depending on penWidth.
    if (Only1PixelInPointArray (points))
    {
    #if DEBUG_KP_PIXMAP_FX
        qCDebug(kpLogPixmapfx) << "\tinvoking single point hack";
    #endif
        p.drawPoint(points [0]);
        return;
    }

    // TODO: why aren't the ends rounded?
    p.drawPolygon(points, Qt::OddEvenFill);

    if ( isFinal )
      return;

    if ( points.count() <= 2 )
      return;

    p.setCompositionMode(QPainter::RasterOp_SourceXorDestination);
    p.setPen(QPen(Qt::white));
    p.drawLine(points[0], points[points.count() - 1]);
}
开发者ID:KDE,项目名称:kolourpaint,代码行数:43,代码来源:kpPixmapFX_DrawShapes.cpp

示例7: qWarning

QDebug operator<<(QDebug dbg, const QPolygon &a)
{
#ifndef Q_BROKEN_DEBUG_STREAM
    dbg.nospace() << "QPolygon(";
    for (int i = 0; i < a.count(); ++i)
        dbg.nospace() << a.at(i);
    dbg.nospace() << ')';
    return dbg.space();
#else
    qWarning("This compiler doesn't support streaming QPolygon to QDebug");
    return dbg;
    Q_UNUSED(a);
#endif
}
开发者ID:fluxer,项目名称:katie,代码行数:14,代码来源:qpolygon.cpp

示例8: DrawLineShape

static void DrawLineShape (kpImage *image,
        const QPolygon &points,
        const kpColor &fcolor, int penWidth,
        const kpColor &bcolor,
        bool isFinal)
{
    Q_ASSERT (points.count () == 2);

    kpToolPolyline::DrawShape (image,
        points,
        fcolor, penWidth,
        bcolor,
        isFinal);
}
开发者ID:KDE,项目名称:kolourpaint,代码行数:14,代码来源:kpToolLine.cpp

示例9: accept

bool QwtCustomPlotZoomer::accept(QPolygon& p) const
{
	if ( p.count() < 2 )
		return false;

	// Reject zooms which are too small
	if (abs(p[0].x() - p[1].x()) < 10)
		return false;

	// Set the zoom rect to be top to bottm, irrespective of what the user selects in y axis
	p[0].setY(0);
	p[1].setY(canvas()->size().height());
	return true;
}
开发者ID:McWare,项目名称:cycling-data-view,代码行数:14,代码来源:plotwindow.cpp

示例10: accept

bool QwtPlotZoomer::accept( QPolygon &pa ) const
{
    if ( pa.count() < 2 )
        return false;

    QRect rect = QRect( pa[0], pa[int( pa.count() ) - 1] );
    rect = rect.normalized();

    const int minSize = 2;
    if ( rect.width() < minSize && rect.height() < minSize )
        return false;

    const int minZoomSize = 11;

    const QPoint center = rect.center();
    rect.setSize( rect.size().expandedTo( QSize( minZoomSize, minZoomSize ) ) );
    rect.moveCenter( center );

    pa.resize( 2 );
    pa[0] = rect.topLeft();
    pa[1] = rect.bottomRight();

    return true;
}
开发者ID:mirams,项目名称:opencor,代码行数:24,代码来源:qwt_plot_zoomer.cpp

示例11: Actor

Bot::Bot(const QPolygon &path, Map *map, Scene *scene)
	: Actor("resources/guard.spb", scene),
	  m_map(map),
	  m_currentLine(0),
	  m_positionInLine(0),
	  m_movingForward(true),
//	  m_directionSwitchDelay(0),
	  m_visionCone(this, map, scene)
{
	for(int i = 0; i < path.count() - 1; i++)
		m_path.append(QLineF(path.at(i), path.at(i + 1)));

//	m_alarmSound.setSource(QUrl::fromLocalFile("resources/sound/alarm.wav"));
//	m_alarmSound.setVolume(0.5);
//	m_alarmSound.setLoopCount(3);
}
开发者ID:MemoryLeek,项目名称:ld27,代码行数:16,代码来源:Bot.cpp

示例12: clipEdge

void GraphPolygonClipper::clipEdge(Edge edge, 
    const QPolygon &pa, QPolygon &cpa) const
{
    if ( pa.count() == 0 )
    {
        cpa.resize(0);
        return;
    }

    unsigned int count = 0;

    QPoint p1 = pa.point(0);
    if ( insideEdge(p1, edge) )
        addPoint(cpa, count++, p1);

    const uint nPoints = pa.size();
    for ( uint i = 1; i < nPoints; i++ )
    {
        const QPoint p2 = pa.point(i);
        if ( insideEdge(p2, edge) )
        {
            if ( insideEdge(p1, edge) )
                addPoint(cpa, count++, p2);
            else
            {
                addPoint(cpa, count++, intersectEdge(p1, p2, edge));
                addPoint(cpa, count++, p2);
            }
        }
        else
        {
            if ( insideEdge(p1, edge) )
                addPoint(cpa, count++, intersectEdge(p1, p2, edge));
        }
        p1 = p2;
    }
    cpa.resize(count);
}
开发者ID:ongbe,项目名称:xchart,代码行数:38,代码来源:graph_clipper.cpp

示例13: drawRubberBand

void QwtCustomPlotZoomer::drawRubberBand(QPainter* painter) const
{
	if ( rubberBand() < UserRubberBand )
		QwtPlotPicker::drawRubberBand( painter );
	else
	{
		if ( !isActive() || rubberBandPen().style() == Qt::NoPen )
			return;

		QPolygon p = selection();

		if ( p.count() < 2 )
			return;

		const QPoint& pt1 = p[0];
		const QPoint& pt2 = p[1];

		const int end = canvas()->size().height();
		painter->drawLine(pt1.x(), 0, pt1.x(), end);
		painter->drawLine(pt2.x(), 0, pt2.x(), end);
		painter->fillRect(QRect(pt1.x(), 0, pt2.x() - pt1.x(), end), QBrush(QColor("black"), Qt::Dense7Pattern));
	}
}
开发者ID:McWare,项目名称:cycling-data-view,代码行数:23,代码来源:plotwindow.cpp

示例14: drawRubberBand

void QwtPicker::drawRubberBand( QPainter *painter ) const
{
    if ( !isActive() || rubberBand() == NoRubberBand ||
        rubberBandPen().style() == Qt::NoPen )
    {
        return;
    }

    const QPolygon pa = adjustedPoints( d_data->pickedPoints );

    QwtPickerMachine::SelectionType selectionType =
        QwtPickerMachine::NoSelection;

    if ( d_data->stateMachine )
        selectionType = d_data->stateMachine->selectionType();

    switch ( selectionType )
    {
        case QwtPickerMachine::NoSelection:
        case QwtPickerMachine::PointSelection:
        {
            if ( pa.count() < 1 )
                return;

            const QPoint pos = pa[0];

            const QRect pRect = pickArea().boundingRect().toRect();
            switch ( rubberBand() )
            {
                case VLineRubberBand:
                {
                    QwtPainter::drawLine( painter, pos.x(),
                        pRect.top(), pos.x(), pRect.bottom() );
                    break;
                }
                case HLineRubberBand:
                {
                    QwtPainter::drawLine( painter, pRect.left(),
                        pos.y(), pRect.right(), pos.y() );
                    break;
                }
                case CrossRubberBand:
                {
                    QwtPainter::drawLine( painter, pos.x(),
                        pRect.top(), pos.x(), pRect.bottom() );
                    QwtPainter::drawLine( painter, pRect.left(),
                        pos.y(), pRect.right(), pos.y() );
                    break;
                }
                default:
                    break;
            }
            break;
        }
        case QwtPickerMachine::RectSelection:
        {
            if ( pa.count() < 2 )
                return;

            const QRect rect = QRect( pa.first(), pa.last() ).normalized();
            switch ( rubberBand() )
            {
                case EllipseRubberBand:
                {
                    QwtPainter::drawEllipse( painter, rect );
                    break;
                }
                case RectRubberBand:
                {
                    QwtPainter::drawRect( painter, rect );
                    break;
                }
                default:
                    break;
            }
            break;
        }
        case QwtPickerMachine::PolygonSelection:
        {
            if ( rubberBand() == PolygonRubberBand )
                painter->drawPolyline( pa );
            break;
        }
        default:
            break;
    }
}
开发者ID:NREL,项目名称:OpenStudio,代码行数:87,代码来源:qwt_picker.cpp

示例15: mouseMoveEvent

void Storage::mouseMoveEvent(QMouseEvent *anEvent)
{
    QPoint pos = anEvent->pos() / scale_;
    if (anEvent->pos().x() < 0)
        pos.setX(0);

    if (width() < anEvent->pos().x())
        pos.setX(width() - 1);

    if (anEvent->pos().y() < 0)
        pos.setY(0);


    if (height() < anEvent->pos().y())
        pos.setY(height() - 1);

    /* изменяем прямоугольник  */
    if ((anEvent->buttons() & Qt::LeftButton) &&
        BoundingBoxTool == tool_ &&
        NewSelection == state_ &&
        Qt::NoModifier == keyboard_modifier_)
    {
        triggerBoundBox(pos, prev_cursor_pos_, rect);
    }

    /* изменяем эллипс  */
    if ((anEvent->buttons() & Qt::LeftButton) &&
        EllipseTool == tool_ &&
        NewSelection == state_ &&
        Qt::NoModifier == keyboard_modifier_)
    {
        triggerEllipse(pos, prev_cursor_pos_, ell);
    }

    /* изменяем стрелу  */
    if ((anEvent->buttons() & Qt::LeftButton) &&
        ArrowTool == tool_ &&
        NewSelection == state_ &&
        Qt::NoModifier == keyboard_modifier_)
    {
        triggerArrow(pos, prev_cursor_pos_, arrow);
    }

    /* перемещаем последнюю точку(курсор) многоугольника до создания(точка зафиксирется кликом) новой */
    if (PolygonTool == tool_ &&
        NewSelection == state_ &&
        (anEvent->buttons() & Qt::LeftButton))
    {
        QPolygon tmp = poly.getCoordinates();
        tmp.setPoint(tmp.count() - 1, pos);
        poly.setCoordinates(tmp);
        repaint_needed_ = 1;
    }

//    if (-1 != focused_selection_ &&
//        !(anEvent->buttons() & Qt::LeftButton)) {
//        checkForPoints(&pos);
//    }
//here now 2
    /* изменяем многоульник */
//    if (-1 != hovered_point_.figureID &&
//        !list_polygon_->isEmpty() &&
//        PolyFigure == hovered_point_.figure &&
//        (anEvent->buttons() & Qt::LeftButton) &&
//        hovered_point_.figureID == focused_selection_)
//    {
//        polygon_.poly.clear();
//        polygon_.label_ID_ = *label_ID_/*focused_label_ID_selection_*/;
//        Polygon *poly = list_polygon_->at(hovered_point_.figureID);

//        poly->poly.setPoint(hovered_point_.pointID, pos);

//        for(int i=0;i< list_polygon_->at(hovered_point_.figureID)->poly.count();++i)
//        {
//            if(i!=hovered_point_.pointID)
//                polygon_.poly  << list_polygon_->at(hovered_point_.figureID)->poly.point(i);
//            else
//                polygon_.poly << pos;
//        }
//        qDebug() << "polygon_.poly =" << polygon_.poly;

//        repaint_needed_ = 1;
//    }

    /* изменяем прямоульник */
//    if (-1 != hovered_point_.figureID &&
//        !list_bounding_box_->isEmpty() &&
//        RectFigure == hovered_point_.figure &&
//        (anEvent->buttons() & Qt::LeftButton))
//    {
//        bounding_box_.label_ID_ = *label_ID_/*focused_label_ID_selection_*/;

//        bounding_box_.rect.setTopLeft(list_bounding_box_->at(hovered_point_.figureID)->rect.topLeft());
//        bounding_box_.rect.setTopRight(list_bounding_box_->at(hovered_point_.figureID)->rect.topRight());
//        bounding_box_.rect.setBottomRight(list_bounding_box_->at(hovered_point_.figureID)->rect.bottomRight());
//        bounding_box_.rect.setBottomLeft(list_bounding_box_->at(hovered_point_.figureID)->rect.bottomLeft());
//        BoundingBox *rect = list_bounding_box_->at(hovered_point_.figureID);
//        if (0 == hovered_point_.pointID)
//        {
//            rect->rect.setTopLeft(pos);
//.........这里部分代码省略.........
开发者ID:RISK46kaf,项目名称:Practise,代码行数:101,代码来源:storage.cpp


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