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


C++ NodeElement::contentsRect方法代码示例

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


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

示例1: drawGuides

void SceneGridHandler::drawGuides()
{
	const int drift = 5;  // A dirft for scene not to resize from guide lines.
	const QPointF nodeScenePos = mNode->scenePos();
	const QRectF contentsRect = mNode->contentsRect();
	const QRectF sceneRect = mNode->scene()->sceneRect().adjusted(drift, drift, -drift, -drift);

	deleteGuides();

	QList<QGraphicsItem *> list = getAdjancedNodes();

	qreal myX1 = nodeScenePos.x() + contentsRect.x();
	qreal myY1 = nodeScenePos.y() + contentsRect.y();
	qreal myX2 = myX1 + contentsRect.width();
	qreal myY2 = myY1 + contentsRect.height();

	for (QGraphicsItem *graphicsItem : list) {
		NodeElement *item = dynamic_cast<NodeElement *>(graphicsItem);
		if (item == nullptr || item->parentItem() != nullptr || item == mNode) {
			continue;
		}

		const QPointF point = item->scenePos();
		const QRectF contents = item->contentsRect();

		const qreal pointX1 = point.x() + contents.x() - spacing;
		const qreal pointY1  = point.y() + contents.y() - spacing;
		const qreal pointX2 = pointX1  + contents.width() + 2 * spacing;
		const qreal pointY2  = pointY1 + contents.height() + 2 * spacing;

		if (pointX1 != myX1 || pointY1 != myY1) {
			const qreal deltaY1 = qAbs(pointY1 - myY1);
			const qreal deltaY2 = qAbs(pointY2 - myY2);
			const qreal deltaX1 = qAbs(pointX1 - myX1);
			const qreal deltaX2 = qAbs(pointX2 - myX2);

			buildLineY(deltaY1, pointY1, 0, myY1, myY2, sceneRect);
			buildLineY(deltaY2, pointY2, contentsRect.height(), myY1, myY2, sceneRect);

			buildLineX(deltaX1, pointX1, 0, myX1, myX2, sceneRect);
			buildLineX(deltaX2, pointX2, contentsRect.width(), myX1, myX2, sceneRect);

			buildLineY(qAbs(pointY1 - myY2), pointY1, contentsRect.height(), myY1, myY2, sceneRect);
			buildLineX(qAbs(pointX1 - myX2), pointX1, contentsRect.width(), myX1, myX2, sceneRect);

			buildLineY(qAbs(pointY2 - myY1), pointY2, 0, myY1, myY2, sceneRect);
			buildLineX(qAbs(pointX2 - myX1), pointX2, 0, myX1, myX2, sceneRect);
		}
	}
}
开发者ID:Antropovi,项目名称:qreal,代码行数:50,代码来源:sceneGridHandler.cpp

示例2: drawGuides

void SceneGridHandler::drawGuides()
{
	QPointF const nodeScenePos = mNode->scenePos();
	QRectF const contentsRect = mNode->contentsRect();
	QRectF const sceneRect = mNode->scene()->sceneRect();

	delUnusedLines();

	QList<QGraphicsItem *> list = getAdjancedNodes();

	qreal myX1 = nodeScenePos.x() + contentsRect.x();
	qreal myY1 = nodeScenePos.y() + contentsRect.y();
	qreal myX2 = myX1 + contentsRect.width();
	qreal myY2 = myY1 + contentsRect.height();

	foreach (QGraphicsItem *graphicsItem, list) {
		NodeElement *item = dynamic_cast<NodeElement *>(graphicsItem);
		if (item == NULL || item->parentItem() != NULL || item == mNode) {
			continue;
		}

		QPointF const point = item->scenePos();
		QRectF const contents = item->contentsRect();

		qreal const pointX1 = point.x() + contents.x() - spacing;
		qreal const pointY1  = point.y() + contents.y() - spacing;
		qreal const pointX2 = pointX1  + contents.width() + 2 * spacing;
		qreal const pointY2  = pointY1 + contents.height() + 2 * spacing;

		if (pointX1 != myX1 || pointY1 != myY1) {
			qreal const deltaY1 = qAbs(pointY1 - myY1);
			qreal const deltaY2 = qAbs(pointY2 - myY2);
			qreal const deltaX1 = qAbs(pointX1 - myX1);
			qreal const deltaX2 = qAbs(pointX2 - myX2);

			buildLineY(deltaY1, pointY1, 0, myY1, myY2, sceneRect);
			buildLineY(deltaY2, pointY2, contentsRect.height(), myY1, myY2, sceneRect);

			buildLineX(deltaX1, pointX1, 0, myX1, myX2, sceneRect);
			buildLineX(deltaX2, pointX2, contentsRect.width(), myX1, myX2, sceneRect);

			buildLineY(qAbs(pointY1 - myY2), pointY1, contentsRect.height(), myY1, myY2, sceneRect);
			buildLineX(qAbs(pointX1 - myX2), pointX1, contentsRect.width(), myX1, myX2, sceneRect);

			buildLineY(qAbs(pointY2 - myY1), pointY2, 0, myY1, myY2, sceneRect);
			buildLineX(qAbs(pointX2 - myX1), pointX2, 0, myX1, myX2, sceneRect);
		}
	}
开发者ID:BogdanKl,项目名称:qreal,代码行数:48,代码来源:sceneGridHandler.cpp


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