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


C++ QPainterPath::contains方法代码示例

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


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

示例1: getMode

OnMonitorCornersItem::cornersActions OnMonitorCornersItem::getMode(const QPointF &pos, int *corner)
{
    *corner = -1;
    if (polygon().count() != 4)
        return NoAction;

    QPainterPath mouseArea;
    qreal size = 12;
    if (getView())
        size /= m_view->matrix().m11();
    mouseArea.addRect(pos.x() - size / 2, pos.y() - size / 2, size, size);
    for (int i = 0; i < 4; ++i) {
        if (mouseArea.contains(polygon().at(i))) {
            *corner = i;
            return Corner;
        }
    }
    if (KdenliveSettings::onmonitoreffects_cornersshowcontrols()) {
        if (mouseArea.contains(getCentroid()))
            return Move;

        for (int i = 0; i < 4; ++i) {
            int j = (i + 1) % 4;
            if (mouseArea.contains(QLineF(polygon().at(i), polygon().at(j)).pointAt(.5))) {
                *corner = i;
                return MoveSide;
            }
        }
    }

    return NoAction;
}
开发者ID:JongHong,项目名称:kdenlive,代码行数:32,代码来源:onmonitorcornersitem.cpp

示例2: contains

/**
 * Checks if the given point is inside this closed polygon. If this
 * polyline is not closed (\see setClosed), false is returned.
 */
bool RPolyline::contains(const RVector& point, bool borderIsInside, double tolerance) const {
    if (!isGeometricallyClosed(tolerance)) {
        return false;
    }

    // check if point is on polyline:
    if (isOnShape(point, true, tolerance)) {
        return borderIsInside;
    }

    if (hasArcSegments()) {
        QPainterPath pp = toPainterPath();
        return pp.contains(QPointF(point.x, point.y));
    }

    int nvert = vertices.size();
    int i, j;
    bool c = false;
    for (i=0, j=nvert-1; i<nvert; j=i++) {
        if (((vertices[i].y>point.y) != (vertices[j].y>point.y)) &&
             (point.x < (vertices[j].x-vertices[i].x) * (point.y-vertices[i].y) / (vertices[j].y-vertices[i].y) + vertices[i].x) ) {
            c = !c;
        }
    }
    return c;
}
开发者ID:eric3361229,项目名称:qcad,代码行数:30,代码来源:RPolyline.cpp

示例3: testFindShapedExtremums

void KisGradientPainterTest::testFindShapedExtremums()
{
    QPolygonF selectionPolygon;
    selectionPolygon << QPointF(100, 100);
    selectionPolygon << QPointF(200, 120);
    selectionPolygon << QPointF(170, 140);
    selectionPolygon << QPointF(200, 180);
    selectionPolygon << QPointF(30, 220);

    QPolygonF selectionErasePolygon;
    selectionErasePolygon << QPointF(101, 101);
    selectionErasePolygon << QPointF(190, 120);
    selectionErasePolygon << QPointF(160, 140);
    selectionErasePolygon << QPointF(200, 180);
    selectionErasePolygon << QPointF(30, 220);

    QPainterPath path;
    path.addPolygon(selectionPolygon);
    path.closeSubpath();
    path.addPolygon(selectionErasePolygon);
    path.closeSubpath();

    QPointF center =
        KisPolygonalGradientShapeStrategy::testingCalculatePathCenter(
            4, path, 2.0, true);

    dbgKrita << ppVar(center);

    QVERIFY(path.contains(center));
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:30,代码来源:kis_gradient_painter_test.cpp

示例4: circularPortId

qreal PortHandler::circularPortId(const QPointF &location, const QStringList &types) const
{
	for (int circularPortNumber = 0; circularPortNumber < mCircularPorts.count(); circularPortNumber++) {
		const StatCircular * const circularPort = mCircularPorts.at(circularPortNumber);
		if (!types.contains(circularPort->type())) {
			continue;
		}

		QPainterPathStroker ps;
		ps.setWidth(kvadratik);

		QPainterPath path;
		StatCircular::CircularPort circular = transformPortForNodeSize(circularPort);

		path.addEllipse({circular.x, circular.y}, circular.rx, circular.ry);

		path = ps.createStroke(path);
		if (path.contains(location)) {
			return circularPortNumber + mPointPorts.size() + mLinePorts.size()
				+ (pointByCircularPortAngle(circularPortNumber, location) / 360.0);
		}
	}

	return nonexistentPortId;
}
开发者ID:Antropovi,项目名称:qreal,代码行数:25,代码来源:portHandler.cpp

示例5: linePortId

qreal PortHandler::linePortId(const QPointF &location, const QStringList &types) const
{
	for (int linePortNumber = 0; linePortNumber < mLinePorts.count(); linePortNumber++) {
		const StatLine * const linePort = mLinePorts.at(linePortNumber);
		if (!types.contains(linePort->type())) {
			continue;
		}

		QPainterPathStroker ps;
		ps.setWidth(kvadratik - 5);

		QPainterPath path;
		const QLineF line = transformPortForNodeSize(linePort);
		path.moveTo(line.p1());
		path.lineTo(line.p2());

		path = ps.createStroke(path);
		if (path.contains(location)) {
			return linePortNumber + mPointPorts.size()
				+ qMin(QLineF(line.p1(), location).length() / line.length()
					, mMaximumFractionPartValue);
		}
	}

	return nonexistentPortId;
}
开发者ID:Antropovi,项目名称:qreal,代码行数:26,代码来源:portHandler.cpp

示例6: determinePointsInSelection

void ItemScene::determinePointsInSelection()
{
    QRectF controlRect = this->selectionPathItem->path().controlPointRect();
    QPainterPath path = this->selectionPathItem->path();

    QImage sourceImage = this->imageFileItem->pixmap().toImage();
    QImage extractedImage(controlRect.width(), controlRect.height(), QImage::Format_RGB888);

    for(int yPos = controlRect.topLeft().y(); yPos < controlRect.topLeft().y() + controlRect.height(); yPos++)
    {
        for(int xPos = controlRect.topLeft().x(); xPos < controlRect.topLeft().x() + controlRect.width(); xPos++)
        {
            if(path.contains(QPointF(xPos, yPos)))
            {
                extractedImage.setPixel( xPos - (controlRect.topRight().x() - controlRect.width()), yPos - (controlRect.bottomLeft().y() - controlRect.height()),sourceImage.pixel(xPos, yPos));
            }
            else extractedImage.setPixel( xPos - (controlRect.topRight().x() - controlRect.width()), yPos - (controlRect.bottomLeft().y() - controlRect.height()), QRgb(qRgb(255,255,255)));

        }
    }

    this->imageFileItem->setPixmap(QPixmap::fromImage(extractedImage));
    this->imageFileItem->setPos(this->sceneRect().center().operator -=(QPointF(extractedImage.width()/2, extractedImage.height()/2)));
    this->imageFileItem->update();

    this->removeItem(this->selectionPathItem);

    for(QList<SelectionMarker*>::iterator iterator = this->selectionMarkers->begin(); iterator != this->selectionMarkers->end(); iterator++)
    {
       this->removeItem( (*iterator));
    }
}
开发者ID:ComputationalPhotography,项目名称:local-client,代码行数:32,代码来源:itemscene.cpp

示例7: contains

/**
 * Checks if the given point is inside this closed polygon. If this
 * polyline is not closed (\see setClosed), false is returned.
 */
bool RPolyline::contains(const RVector& point) const {
    if (!closed) {
        return false;
    }

    QPainterPath pp = toPainterPath();
    return pp.contains(QPointF(point.x, point.y));
}
开发者ID:VixMobile,项目名称:qcad,代码行数:12,代码来源:RPolyline.cpp

示例8: getMode

rectActions OnMonitorRectItem::getMode(const QPointF &pos)
{
    // Item mapped coordinates
    QPolygonF pol(rect().normalized());

    QPainterPath top(pol.at(0));
    top.lineTo(pol.at(1));
    QPainterPath bottom(pol.at(2));
    bottom.lineTo(pol.at(3));
    QPainterPath left(pol.at(0));
    left.lineTo(pol.at(3));
    QPainterPath right(pol.at(1));
    right.lineTo(pol.at(2));

    QPainterPath mouseArea;
    qreal xsize = 12;
    qreal ysize = 12;
    if (getView()) {
        xsize /= m_view->matrix().m11();
        ysize /= m_view->matrix().m22();
    }
    mouseArea.addRect(pos.x() - xsize / 2, pos.y() - ysize / 2, xsize, ysize);

    // Check for collisions between the mouse and the borders
    if (mouseArea.contains(pol.at(0)))
        return ResizeTopLeft;
    else if (mouseArea.contains(pol.at(2)))
        return ResizeBottomRight;
    else if (mouseArea.contains(pol.at(1)))
        return ResizeTopRight;
    else if (mouseArea.contains(pol.at(3)))
        return ResizeBottomLeft;
    else if (top.intersects(mouseArea))
        return ResizeTop;
    else if (bottom.intersects(mouseArea))
        return ResizeBottom;
    else if (right.intersects(mouseArea))
        return ResizeRight;
    else if (left.intersects(mouseArea))
        return ResizeLeft;
    else if (rect().normalized().contains(pos))
        return Move;
    else
        return NoAction;
}
开发者ID:JongHong,项目名称:kdenlive,代码行数:45,代码来源:onmonitorrectitem.cpp

示例9: executeNextStep

void BounceEdgeBlock::executeNextStep(ExecutionThread& executionThread) const
{
    Sprite* sprite = executionThread.getSprite();
    if(sprite != NULL)
    {
        SpriteView* s = new SpriteView(sprite);
        QSize screensize = sprite->getProgramModel()->getScreen()->getSize();
        QPainterPath horedges;
        horedges.addRect(-50, 0, screensize.width() + 100, screensize.height());
        QPainterPath veredges;
        veredges.addRect(0, -50, screensize.width(), screensize.height() + 100);
        if (!horedges.contains(s->mapToScene(s->shape())))
            sprite->setRotation(-sprite->getRotation());
        if (!veredges.contains(s->mapToScene(s->shape())))
            sprite->setRotation(-sprite->getRotation() - 180);
    }
    executionThread.endExecution(NULL);
}
开发者ID:BrentChesny,项目名称:EasyBlocks,代码行数:18,代码来源:bounceedgeblock.cpp

示例10: intersect_path

    static bool intersect_path(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode,
                               const QTransform &deviceTransform, const void *intersectData)
    {
        const QPainterPath scenePath = *static_cast<const QPainterPath *>(intersectData);

        QRectF brect = item->boundingRect();
        _q_adjustRect(&brect);

        // ### Add test for this (without making things slower?)
        Q_UNUSED(exposeRect);

        bool keep = true;
        const QGraphicsItemPrivate *itemd = QGraphicsItemPrivate::get(item);
        if (itemd->itemIsUntransformable()) {
            // Untransformable items; map the scene rect to item coordinates.
            const QTransform transform = item->deviceTransform(deviceTransform);
            QPainterPath itemPath = (deviceTransform * transform.inverted()).map(scenePath);
            if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
                keep = itemPath.contains(brect);
            else
                keep = itemPath.intersects(brect);
            if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape))
                keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);
        } else {
            Q_ASSERT(!itemd->dirtySceneTransform);
            const QRectF itemSceneBoundingRect = itemd->sceneTransformTranslateOnly
                                               ? brect.translated(itemd->sceneTransform.dx(),
                                                                  itemd->sceneTransform.dy())
                                               : itemd->sceneTransform.mapRect(brect);
            if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
                keep = scenePath.contains(itemSceneBoundingRect);
            else
                keep = scenePath.intersects(itemSceneBoundingRect);
            if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
                QPainterPath itemPath = itemd->sceneTransformTranslateOnly
                                      ? scenePath.translated(-itemd->sceneTransform.dx(),
                                                             -itemd->sceneTransform.dy())
                                      : itemd->sceneTransform.inverted().map(scenePath);
                keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);
            }
        }
        return keep;
    }
开发者ID:3163504123,项目名称:phantomjs,代码行数:43,代码来源:qgraphicssceneindex.cpp

示例11: itemCollidesWithPath

/*!
    \internal

    Checks if item collides with the path and mode, but also checks that if it
    doesn't collide, maybe its frame rect will.
*/
bool QGraphicsSceneIndexPrivate::itemCollidesWithPath(const QGraphicsItem *item,
                                                      const QPainterPath &path,
                                                      Qt::ItemSelectionMode mode)
{
    if (item->collidesWithPath(path, mode))
        return true;
    if (item->isWidget()) {
        // Check if this is a window, and if its frame rect collides.
        const QGraphicsWidget *widget = static_cast<const QGraphicsWidget *>(item);
        if (widget->isWindow()) {
            QRectF frameRect = widget->windowFrameRect();
            QPainterPath framePath;
            framePath.addRect(frameRect);
            bool intersects = path.intersects(frameRect);
            if (mode == Qt::IntersectsItemShape || mode == Qt::IntersectsItemBoundingRect)
                return intersects || path.contains(frameRect.topLeft())
                    || framePath.contains(path.elementAt(0));
            return !intersects && path.contains(frameRect.topLeft());
        }
    }
    return false;
}
开发者ID:3163504123,项目名称:phantomjs,代码行数:28,代码来源:qgraphicssceneindex.cpp

示例12: mousePressEvent

void GradientRangeEditor::mousePressEvent( QMouseEvent * event )
{
	switch( event->button() )
	{
		case Qt::LeftButton:
		{
			{
				QPainterPath path;
				path.addEllipse( QRectF(
					QPointF( _startPoint.x() * width(), _startPoint.y() * height() ) -
						QPointF( 12, 12 ), QSizeF( 24, 24 ) ) );
				if( path.contains( event->pos() ) )
				{
					movedPoint = startMoved;
					break;
				}
			}

			{
				QPainterPath path;
				path.addEllipse( QRectF(
					QPointF( _endPoint.x() * width(), _endPoint.y() * height() ) -
						QPointF( 12, 12 ), QSizeF( 24, 24 ) ) );
				if( path.contains( event->pos() ) )
				{
					movedPoint = endMoved;
					break;
				}
			}
			break;
		}

		default:
			break;
	}
}
开发者ID:5Y5TEM,项目名称:MultiFusion,代码行数:36,代码来源:GradientRangeEditor.cpp

示例13: stopFromPoint

int GradientStopEditor::stopFromPoint( const QPoint &point )
{
	int countStops = values.size();
	for( int i = 0; i < countStops; i++ )
	{
		QPainterPath path;
		path.addEllipse( QRectF(
			getStopPosition( i ) - QPointF( 6, 6 ),
			QSizeF( 12, 12 ) ) );
		if( path.contains( point ) )
			return i;
	}

	return -1;
}
开发者ID:5Y5TEM,项目名称:MultiFusion,代码行数:15,代码来源:GradientStopsEditor.cpp

示例14: mousePressEvent

void MapEditorWidget::mousePressEvent ( QMouseEvent * event ){
  if(popup){
    return;
  }
  QPointF clickPos = transform.inverted().map(QPointF(event->pos()));
  int index = -1;
  for (int i=0; i<points.size(); ++i) {
    QPainterPath path;
    path.addEllipse(pointBoundingRect(i));
    if (path.contains(event->pos())) {
      index = i;
      break;
    }
  }
  if(plotArea.contains(event->pos()) == false && index == -1){
    return;
  }


  if (event->button() == Qt::LeftButton) {
    if (index == -1) {
      int pos = 0;
      // Insert sort for x or y
      for (int i=0; i<points.size(); ++i){
	if (points.at(i).x() > clickPos.x()) {
	  pos = i;
	  break;
	}
      }
      points.insert(pos, clickPos);
      currentIndex = pos;
      firePointChange();
    } else {
      currentIndex = index;
    }
  } else if (event->button() == Qt::RightButton) {
    if (index >= 0) {
      if(points.size() > 1){
	points.remove(index);
	firePointChange();
      }
    }
  }
}
开发者ID:FXIhub,项目名称:hawk,代码行数:44,代码来源:mapeditordialog.cpp

示例15: closestSegmentIndex

/**
 * Return index of closest segment.
 *
 * @param point The point which is to be tested for closeness.
 *
 * @return Index of the line segment closest to the \a point passed;
 *         -1 if no line segment is closer to passed in \a point.
 */
int AssociationLine::closestSegmentIndex(const QPointF &point, qreal delta) const
{
    QPainterPathStroker stroker;
    stroker.setWidth(delta);

    for(int i = 1; i < m_points.size(); ++i) {
        QLineF segment(m_points[i-1], m_points[i]);

        QPainterPath path;
        path.moveTo(segment.p1());
        path.lineTo(segment.p2());

        path = stroker.createStroke(path);

        if (path.contains(point)) {
            return i-1;
        }
    }
    return -1;
}
开发者ID:behlingc,项目名称:umbrello-behlingc,代码行数:28,代码来源:associationline.cpp


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