本文整理汇总了C++中QRectF::intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::intersects方法的具体用法?C++ QRectF::intersects怎么用?C++ QRectF::intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::intersects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawBackground
void TileScene::drawBackground(QPainter *painter, const QRectF &exposed)
{
// Draws all tiles that intersect the exposed area.
for (int y = 0; y < numTilesV; ++y) {
for (int x = 0; x < numTilesH; ++x) {
QRectF rect = rectForTile(x, y);
if (exposed.intersects(rect))
painter->drawPixmap(rect.topLeft(), tiles[y][x]);
}
}
}
示例2: run
/*!
Run the snap algorithm to with the position of moving rect, to get a snap result.
*/
HsWidgetPositioningOnWidgetMove::Result HsSnapToLines::run(const QRectF &movingRect)
{
HsWidgetPositioningOnWidgetMove::Result result;
if (mSnapEnabled) {
mMovingRect = movingRect;
mHorizontalSnapPosition = 0.0;
mVerticalSnapPosition = 0.0;
mVerticalLine = QLineF();
mMinVerticalEdgesDistance = mSnapForce;
mVerticalDistanceFromSelectedRect = 0.0;
mContainerVerticalEdgeDistance = 0.0;
mHorizontalSnapFound = false;
mHorizontalLine = QLineF();
mMinHorizontalEdgesDistance = mSnapForce;
mHorizontalDistanceFromSelectedRect = 0.0;
mContainerHorizontalEdgeDistance = 0.0;
mVerticalSnapFound = false;
for (int i = 0; i < mInactiveSnapRects.count(); ++i) {
mInactiveSnapRectToCompare = mInactiveSnapRects[i];
mInactiveRectToCompare = mInactiveSnapRectToCompare.rectangle;
if (!movingRect.intersects(mInactiveRectToCompare)) { //Only compare if Inactive Rect and moving rect do not overlap.
// Horizontal - Direction Snapping
compareLeftSideOfMovingRectForSnapping();
compareRightSideOfMovingRectForSnapping();
// Vertical - Direction Snapping
compareTopOfMovingRectForSnapping();
compareBottomOfMovingRectForSnapping();
}
}
if (mHorizontalSnapFound) {
result.hasHorizontalSnap = true;
result.horizontalSnapPosition = mHorizontalSnapPosition;
extendVerticalLine();
result.verticalSnapLine = mVerticalLine;
}
if (mVerticalSnapFound) {
result.hasVerticalSnap = true;
result.verticalSnapPosition = mVerticalSnapPosition;
extendHorizontalLine();
result.horizontalSnapLine = mHorizontalLine;
}
}
return result;
}
示例3: itemVisibleInView
bool AbstractItemContainer::itemVisibleInView(AbstractViewItem* item, const QRectF &viewRect, bool fullyVisible) const
{
if (!item || !m_itemView)
return false;
QRectF itemRectBoundingRect = item->mapToItem(m_itemView, item->boundingRect()).boundingRect();
if (fullyVisible && viewRect.contains(itemRectBoundingRect))
return true;
else if (viewRect.intersects(itemRectBoundingRect))
return true;
return false;
}
示例4: drawForeground
void CanvasView::drawForeground(QPainter *painter, const QRectF& rect)
{
if(_enableoutline && _showoutline && _outlinesize>1 && !_locked) {
const QRectF outline(_prevpoint-QPointF(_outlinesize,_outlinesize),
QSizeF(_dia, _dia));
if(rect.intersects(outline)) {
painter->save();
QPen pen(Qt::white);
pen.setCosmetic(true);
painter->setPen(pen);
painter->setCompositionMode(QPainter::CompositionMode_Difference);
painter->drawEllipse(outline);
painter->restore();
}
}
}
示例5: drawBackground
void QGraphVizPIP::drawBackground(QPainter *painter, const QRectF &rect)
{
if(!rect.intersects(scene()->sceneRect())) {
return;
}
QPen borderPen;
borderPen.setColor(Qt::black);
painter->setPen(borderPen);
QRectF border = QRectF(mapToScene(1.0, 1.0),
mapToScene(width()-2.0, height()-2.0));
painter->drawRect(border);
}
示例6: createSnappableRectangles
/*!
Create the list of rects and flag if their sides are snappable from top or bottom or left or right,
depending on other rects overlapping with the rect.
*/
void HsSnapToLines::createSnappableRectangles(const QList<QRectF> &inactiveRects)
{
mInactiveSnapRects.clear();
int i;
for (i = 0; i<inactiveRects.count(); ++i) {
QRectF rect = inactiveRects[i];
HsSnapRectangle snapRectangle(rect);
int j;
for (j = 0; j<inactiveRects.count(); ++j) {
QRectF rectToCompare = inactiveRects[j];
if (rect != rectToCompare) {
//Check if the rectangles being compared intersect each other
if (rectToCompare.intersects(rect)) {
//As the widgets intersect, check which corner is contained,
//The corner that is contained is not snappable, when the moving widget is in the same position
if (rectToCompare.contains(rect.topLeft())) {
snapRectangle.isLeftSnapableForAbove = false;
snapRectangle.isTopSnapableForLeft = false;
}
if (rectToCompare.contains(rect.topRight())) {
snapRectangle.isRightSnapableForAbove = false;
snapRectangle.isTopSnapableForRight = false;
}
if (rectToCompare.contains(rect.bottomRight())) {
snapRectangle.isRightSnapableForBelow = false;
snapRectangle.isBottomSnapableForRight = false;
}
if (rectToCompare.contains(rect.bottomLeft())) {
snapRectangle.isLeftSnapableForBelow = false;
snapRectangle.isBottomSnapableForLeft = false;
}
}
}
}
if (snapRectangle.isLeftSnapableForAbove || snapRectangle.isLeftSnapableForBelow ||
snapRectangle.isRightSnapableForAbove || snapRectangle.isRightSnapableForBelow ||
snapRectangle.isTopSnapableForLeft || snapRectangle.isTopSnapableForRight ||
snapRectangle.isBottomSnapableForLeft || snapRectangle.isBottomSnapableForRight) {
mInactiveSnapRects.append(snapRectangle);
}
}
}
示例7: intersect
bool intersect(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode,
const QTransform &deviceTransform) const
{
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);
QRectF itemRect = (deviceTransform * transform.inverted()).mapRect(sceneRect);
if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
keep = itemRect.contains(brect) && itemRect != brect;
else
keep = itemRect.intersects(brect);
if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
QPainterPath itemPath;
itemPath.addRect(itemRect);
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 = sceneRect != brect && sceneRect.contains(itemSceneBoundingRect);
else
keep = sceneRect.intersects(itemSceneBoundingRect);
if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
QPainterPath rectPath;
rectPath.addRect(sceneRect);
if (itemd->sceneTransformTranslateOnly)
rectPath.translate(-itemd->sceneTransform.dx(), -itemd->sceneTransform.dy());
else
rectPath = itemd->sceneTransform.inverted().map(rectPath);
keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, rectPath, mode);
}
}
return keep;
}
示例8: mouseReleaseEvent
void Window::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
QGraphicsObject::mouseReleaseEvent(event);
const QGraphicsScene *const currentScene = scene();
if (currentScene) {
QRectF currentSceneRect = currentScene->sceneRect();
QRectF windowRect = sceneBoundingRect();
//防止窗口移出当前scene
if (!currentSceneRect.intersects(windowRect)) {
setPos(m_windowLastPos);
}
else {
m_windowLastPos = pos();
}
}
}
示例9: distinguishRect
void WidgetStyle::distinguishRect(const QRectF& rect)
{
m_deleteGraphicsWgt_.clear();
for(GraphicsWidget* wgt : m_scene->getItemWidget())
{
if(rect.intersects(wgt->boundingRectToScene()))
{
wgt->selectWidget(true);
m_deleteGraphicsWgt_.push_back(wgt);
}
else
{
auto iter = qFind(m_deleteGraphicsWgt_.begin(), m_deleteGraphicsWgt_.end(), wgt);
if(iter != m_deleteGraphicsWgt_.end())
m_deleteGraphicsWgt_.erase(iter);
wgt->selectWidget(false);
}
}
}
示例10: drawForeground
void EditorView::drawForeground(QPainter *painter, const QRectF& rect)
{
if(enableoutline_ && showoutline_ && outlinesize_>1) {
const QRectF outline(prevpoint_-QPointF(outlinesize_,outlinesize_),
QSizeF(dia_, dia_));
if(rect.intersects(outline)) {
//painter->setClipRect(0,0,board_->width(),board_->height()); // default
//painter->setClipRect(outline.adjusted(-7, -7, 7, 7)); // smaller clipping
//painter->setRenderHint(QPainter::Antialiasing, true); // default
QPen pen(background_);
painter->setPen(pen);
painter->drawEllipse(outline);
pen.setColor(foreground_);
pen.setStyle(Qt::DashLine);
painter->setPen(pen);
painter->drawEllipse(outline);
}
}
}
示例11: drawForeground
void PannerView::drawForeground(QPainter * p, const QRectF & rect )
{
if (m_zoomRect.isValid() && rect.intersects(m_zoomRect))
{
p->save();
if (m_zoomRect.width() > 10 && m_zoomRect.height() > 10)
{
p->setPen(Qt::red);
// substract pen width, i.e. draw inside
qreal penWidth = p->pen().widthF();
p->drawRect(m_zoomRect.adjusted(-penWidth, -penWidth, -penWidth, -penWidth));
}
else
{
QBrush brush(Qt::red);
p->fillRect(m_zoomRect, brush);
}
p->restore();
}
}
示例12: intersect_point
static bool intersect_point(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode,
const QTransform &deviceTransform, const void *intersectData)
{
const QPointF scenePoint = *static_cast<const QPointF *>(intersectData);
QRectF brect = item->boundingRect();
_q_adjustRect(&brect);
// ### Add test for this (without making things slower?)
Q_UNUSED(exposeRect);
bool keep = false;
const QGraphicsItemPrivate *itemd = QGraphicsItemPrivate::get(item);
if (itemd->itemIsUntransformable()) {
// Untransformable items; map the scene point to item coordinates.
const QTransform transform = item->deviceTransform(deviceTransform);
QPointF itemPoint = (deviceTransform * transform.inverted()).map(scenePoint);
keep = brect.contains(itemPoint);
if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
QPainterPath pointPath;
pointPath.addRect(QRectF(itemPoint, QSizeF(1, 1)));
keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, pointPath, mode);
}
} else {
Q_ASSERT(!itemd->dirtySceneTransform);
QRectF sceneBoundingRect = itemd->sceneTransformTranslateOnly
? brect.translated(itemd->sceneTransform.dx(),
itemd->sceneTransform.dy())
: itemd->sceneTransform.mapRect(brect);
keep = sceneBoundingRect.intersects(QRectF(scenePoint, QSizeF(1, 1)));
if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
QPointF p = itemd->sceneTransformTranslateOnly
? QPointF(scenePoint.x() - itemd->sceneTransform.dx(),
scenePoint.y() - itemd->sceneTransform.dy())
: itemd->sceneTransform.inverted().map(scenePoint);
keep = item->contains(p);
}
}
return keep;
}
示例13: clipToDocument
void KWCanvasBase::clipToDocument(const KoShape *shape, QPointF &move) const
{
Q_ASSERT(shape);
const QPointF absPos = shape->absolutePosition();
const QPointF destination = absPos + move;
qreal bottomOfPage = 0.0;
KWPage page;
foreach (const KWPage &p, m_document->pageManager()->pages()) {
bottomOfPage += p.height();
if (bottomOfPage >= absPos.y())
page = p;
if (bottomOfPage >= destination.y()) {
page = p;
break;
}
}
if (!page.isValid()) { // shape was not in any page to begin with, can't propose anything sane...
move.setX(0);
move.setY(0);
return;
}
QRectF pageRect(page.rect().adjusted(5, 5, -5, -5));
QPainterPath path(shape->absoluteTransformation(0).map(shape->outline()));
QRectF shapeBounds = path.boundingRect();
shapeBounds.moveTopLeft(shapeBounds.topLeft() + move);
if (!shapeBounds.intersects(pageRect)) {
if (shapeBounds.left() > pageRect.right()) // need to move to the left some
move.setX(move.x() + (pageRect.right() - shapeBounds.left()));
else if (shapeBounds.right() < pageRect.left()) // need to move to the right some
move.setX(move.x() + pageRect.left() - shapeBounds.right());
if (shapeBounds.top() > pageRect.bottom()) // need to move up some
move.setY(move.y() + (pageRect.bottom() - shapeBounds.top()));
else if (shapeBounds.bottom() < pageRect.top()) // need to move down some
move.setY(move.y() + pageRect.top() - shapeBounds.bottom());
}
// Also make sure any anchoring restrictions are adhered to
KWFrameLayout::proposeShapeMove(shape, move, page);
}
示例14: while
void Menu::moveVertically()
{
QList<QGraphicsItem *> items = this->items();
int sizeList = items.size();
QGraphicsItem * focusItem = this->focusItem();
QList<QGraphicsItem *>::const_iterator it = items.begin();
QList<QGraphicsItem *>::const_iterator tmpIt = it;
int index = items.indexOf(focusItem);
++index;
QRectF currentRectF = focusItem->boundingRect();
currentRectF.setHeight(this->getGeometry().height());
currentRectF.setWidth(currentRectF.width());
currentRectF.setX(currentRectF.x());
currentRectF.setY(0);
int i = 0;
bool haveRect = false;
while (i < sizeList && haveRect == false)
{
index = ((index < sizeList) ? index : (index - sizeList));
tmpIt = it;
tmpIt += index;
haveRect = currentRectF.intersects((*tmpIt)->boundingRect());
++index;
++i;
}
if (haveRect == true)
{
(*tmpIt)->setFocus();
}
else
{
index = items.indexOf(focusItem) + 1;
index = ((index < sizeList) ? index : (index - sizeList));
it += index;
(*it)->setFocus();
}
}
示例15: toBackdropGui
GCC_DIAG_UNUSED_PRIVATE_FIELD_ON
#include "Engine/EffectInstance.h"
#include "Engine/Node.h"
#include "Engine/NodeGroup.h"
#include "Engine/Settings.h"
#include "Engine/Utils.h" // convertFromPlainText
#include "Gui/BackdropGui.h"
#include "Gui/Edge.h"
#include "Gui/GuiApplicationManager.h"
#include "Gui/GuiMacros.h"
#include "Gui/NodeGui.h"
#include "Gui/TabWidget.h"
#include "Global/QtCompat.h"
NATRON_NAMESPACE_ENTER
void
NodeGraph::checkForHints(bool shiftdown,
bool controlDown,
const NodeGuiPtr& selectedNode,
const QRectF& visibleSceneR)
{
NodePtr internalNode = selectedNode->getNode();
if (!internalNode) {
return;
}
bool doMergeHints = shiftdown && controlDown;
bool doConnectionHints = controlDown;
//Ignore hints for backdrops
BackdropGuiPtr isBd = toBackdropGui( selectedNode );
if (isBd) {
return;
}
if (!doMergeHints) {
///for nodes already connected don't show hint
if ( ( internalNode->getNInputs() == 0) && internalNode->hasOutputConnected() ) {
doConnectionHints = false;
} else if ( ( internalNode->getNInputs() > 0) && internalNode->hasAllInputsConnected() && internalNode->hasOutputConnected() ) {
doConnectionHints = false;
}
}
if (!doConnectionHints) {
return;
}
QRectF selectedNodeBbox = selectedNode->boundingRectWithEdges(); //selectedNode->mapToParent( selectedNode->boundingRect() ).boundingRect();
double tolerance = 10;
selectedNodeBbox.adjust(-tolerance, -tolerance, tolerance, tolerance);
NodeGuiPtr nodeToShowMergeRect;
NodePtr selectedNodeInternalNode = selectedNode->getNode();
bool selectedNodeIsReader = selectedNodeInternalNode->getEffectInstance()->isReader() || selectedNodeInternalNode->getNInputs() == 0;
Edge* edge = 0;
std::set<NodeGuiPtr> nodesWithinRect;
getNodesWithinViewportRect(visibleWidgetRect(), &nodesWithinRect);
{
for (std::set<NodeGuiPtr>::iterator it = nodesWithinRect.begin(); it != nodesWithinRect.end(); ++it) {
OutputNodesMap outputs;
internalNode->getOutputs(outputs);
OutputNodesMap::const_iterator foundAsOutput = outputs.find((*it)->getNode());
if (foundAsOutput != outputs.end()) {
continue;
}
QRectF nodeBbox = (*it)->boundingRectWithEdges();
if ( ( (*it) != selectedNode ) && (*it)->isVisible() && nodeBbox.intersects(visibleSceneR) ) {
if (doMergeHints) {
//QRectF nodeRect = (*it)->mapToParent((*it)->boundingRect()).boundingRect();
NodePtr internalNode = (*it)->getNode();
if ( !internalNode->isOutputNode() && nodeBbox.intersects(selectedNodeBbox) ) {
bool nHasInput = internalNode->hasInputConnected();
int nMaxInput = internalNode->getNInputs();
bool selectedHasInput = selectedNodeInternalNode->hasInputConnected();
int selectedMaxInput = selectedNodeInternalNode->getNInputs();
double nPAR = internalNode->getEffectInstance()->getAspectRatio(-1);
double selectedPAR = selectedNodeInternalNode->getEffectInstance()->getAspectRatio(-1);
double nFPS = internalNode->getEffectInstance()->getFrameRate();
double selectedFPS = selectedNodeInternalNode->getEffectInstance()->getFrameRate();
bool isValid = true;
if ( (selectedPAR != nPAR) || (std::abs(nFPS - selectedFPS) > 0.01) ) {
if (nHasInput || selectedHasInput) {
isValid = false;
} else if ( !nHasInput && (nMaxInput == 0) && !selectedHasInput && (selectedMaxInput == 0) ) {
isValid = false;
}
}
if (isValid) {
//.........这里部分代码省略.........