本文整理汇总了C++中QRectF::bottomRight方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::bottomRight方法的具体用法?C++ QRectF::bottomRight怎么用?C++ QRectF::bottomRight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::bottomRight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shape
QPainterPath OrthogonalRenderer::shape(const MapObject *object) const
{
QPainterPath path;
if (!object->cell().isEmpty()) {
path.addRect(boundingRect(object));
} else {
switch (object->shape()) {
case MapObject::Rectangle: {
const QRectF bounds = object->bounds();
const QRectF rect(tileToPixelCoords(bounds.topLeft()),
tileToPixelCoords(bounds.bottomRight()));
if (rect.isNull()) {
path.addEllipse(rect.topLeft(), 20, 20);
} else {
path.addRoundedRect(rect, 10, 10);
}
break;
}
case MapObject::Polygon:
case MapObject::Polyline: {
const QPointF &pos = object->position();
const QPolygonF polygon = object->polygon().translated(pos);
const QPolygonF screenPolygon = tileToPixelCoords(polygon);
if (object->shape() == MapObject::Polygon) {
path.addPolygon(screenPolygon);
} else {
for (int i = 1; i < screenPolygon.size(); ++i) {
path.addPolygon(lineToPolygon(screenPolygon[i - 1],
screenPolygon[i]));
}
path.setFillRule(Qt::WindingFill);
}
break;
}
case MapObject::Ellipse: {
const QRectF bounds = object->bounds();
const QRectF rect(tileToPixelCoords(bounds.topLeft()),
tileToPixelCoords(bounds.bottomRight()));
if (rect.isNull()) {
path.addEllipse(rect.topLeft(), 20, 20);
} else {
path.addEllipse(rect);
}
break;
}
}
}
return path;
}
示例2: paintOutline
void TiledListView::paintOutline(QPainter *painter,
const QRectF &rectangle)
{
const QRectF rect = rectangle.adjusted(0, 0, -1, -1);
painter->save();
painter->setPen(QPen(palette().dark().color(), 0.5));
painter->drawRect(rect);
painter->setPen(QPen(Qt::black, 0.5));
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
painter->drawLine(rect.bottomRight(), rect.topRight());
painter->restore();
}
示例3: initializeTransform
void UBGraphicsDelegateFrame::initializeTransform()
{
QTransform itemTransform = delegated()->sceneTransform();
QRectF itemRect = delegated()->boundingRect();
QPointF topLeft = itemTransform.map(itemRect.topLeft());
QPointF topRight = itemTransform.map(itemRect.topRight());
QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft());
qreal horizontalFlip = (topLeft.x() > topRight.x()) ? -1 : 1;
mMirrorX = horizontalFlip < 0 ;
if(horizontalFlip < 0) {
// why this is because of the way of calculating the translations that checks which side is the most is the
// nearest instead of checking which one is the left side.
QPointF tmp = topLeft;
topLeft = topRight;
topRight = tmp;
// because of the calculation of the height is done by lenght and not deltaY
bottomLeft = itemTransform.map(itemRect.bottomRight());
}
qreal verticalFlip = (bottomLeft.y() < topLeft.y()) ? -1 : 1;
// not sure that is usefull
mMirrorY = verticalFlip < 0;
if(verticalFlip < 0 && !mMirrorX) {
topLeft = itemTransform.map(itemRect.bottomLeft());
topRight = itemTransform.map(itemRect.bottomRight());
bottomLeft = itemTransform.map(itemRect.topLeft());
}
QLineF topLine(topLeft, topRight);
QLineF leftLine(topLeft, bottomLeft);
qreal width = topLine.length();
qreal height = leftLine.length();
mAngle = topLine.angle();
// the fact the the length is used we loose the horizontalFlip information
// a better way to do this is using DeltaX that preserve the direction information.
mTotalScaleX = (width / itemRect.width()) * horizontalFlip;
mTotalScaleY = height / itemRect.height() * verticalFlip;
QTransform tr;
QPointF center = delegated()->boundingRect().center();
tr.translate(center.x() * mTotalScaleX, center.y() * mTotalScaleY);
tr.rotate(-mAngle);
tr.translate(-center.x() * mTotalScaleX, -center.y() * mTotalScaleY);
tr.scale(mTotalScaleX, mTotalScaleY);
mTotalTranslateX = delegated()->transform().dx() - tr.dx();
mTotalTranslateY = delegated()->transform().dy() - tr.dy();
}
示例4: qwtDrawPanel
static void qwtDrawPanel( QPainter *painter, const QRectF &rect,
const QPalette &pal, double lw )
{
if ( lw > 0.0 )
{
if ( rect.width() == 0.0 )
{
painter->setPen( pal.window().color() );
painter->drawLine( rect.topLeft(), rect.bottomLeft() );
return;
}
if ( rect.height() == 0.0 )
{
painter->setPen( pal.window().color() );
painter->drawLine( rect.topLeft(), rect.topRight() );
return;
}
lw = qMin( lw, rect.height() / 2.0 - 1.0 );
lw = qMin( lw, rect.width() / 2.0 - 1.0 );
const QRectF outerRect = rect.adjusted( 0, 0, 1, 1 );
const QRectF innerRect = outerRect.adjusted( lw, lw, -lw, -lw );
QPolygonF lines[2];
lines[0] += outerRect.bottomLeft();
lines[0] += outerRect.topLeft();
lines[0] += outerRect.topRight();
lines[0] += innerRect.topRight();
lines[0] += innerRect.topLeft();
lines[0] += innerRect.bottomLeft();
lines[1] += outerRect.topRight();
lines[1] += outerRect.bottomRight();
lines[1] += outerRect.bottomLeft();
lines[1] += innerRect.bottomLeft();
lines[1] += innerRect.bottomRight();
lines[1] += innerRect.topRight();
painter->setPen( Qt::NoPen );
painter->setBrush( pal.light() );
painter->drawPolygon( lines[0] );
painter->setBrush( pal.dark() );
painter->drawPolygon( lines[1] );
}
painter->fillRect( rect.adjusted( lw, lw, -lw + 1, -lw + 1 ), pal.window() );
}
示例5: paint
void Node::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *w)
{
Q_UNUSED(w);
Q_UNUSED(option);
QColor color;
if (k->typeNode != Center) {
if (k->action == Rotate) {
color = QColor(255, 102, 0);
color.setAlpha(180);
} else {
color = QColor("green");
color.setAlpha(200);
}
} else {
if (k->generalState == Scale) {
color = QColor(150, 150, 150);
} else {
color = QColor(255, 0, 0);
}
color.setAlpha(150);
}
QRectF square = boundingRect();
painter->setBrush(color);
painter->drawRoundRect(square);
/* SQA: Code for debugging purposes
#ifdef K_DEBUG
painter->setFont(QFont(painter->font().family(), 5));
painter->drawText(square, QString::number(k->typeNode));
#endif
*/
if (k->typeNode == Center) {
painter->save();
color = QColor("white");
color.setAlpha(220);
painter->setPen(color);
QPointF point1 = QPointF(square.topLeft().x() + 2, square.topLeft().y() + 2);
QPointF point2 = QPointF(square.bottomRight().x() - 2, square.bottomRight().y() - 2);
QPointF point3 = QPointF(square.bottomLeft().x() + 2, square.bottomLeft().y() - 2);
QPointF point4 = QPointF(square.topRight().x() - 2, square.topRight().y() + 2);
painter->drawLine(point1, point2);
painter->drawLine(point3, point4);
painter->restore();
}
}
示例6: visibleSceneRect
NATRON_NAMESPACE_ENTER
//using std::cout; using std::endl;
void
NodeGraph::moveNodeToCenterOfVisiblePortion(const NodeGuiPtr &n)
{
QRectF viewPos = visibleSceneRect();
QPointF position;
position.setX( ( viewPos.bottomRight().x() + viewPos.topLeft().x() ) / 2. );
position.setY( ( viewPos.topLeft().y() + viewPos.bottomRight().y() ) / 2. );
position = n->mapFromScene(position);
position = n->mapToParent(position);
n->setPosition( position.x(), position.y() );
}
示例7: r
QLineF
ImageView::edgePosition(int const edge) const
{
QRectF const r(virtualToWidget().mapRect(m_contentRect));
if (edge == TOP) {
return QLineF(r.topLeft(), r.topRight());
} else if (edge == BOTTOM) {
return QLineF(r.bottomLeft(), r.bottomRight());
} else if (edge == LEFT) {
return QLineF(r.topLeft(), r.bottomLeft());
} else {
return QLineF(r.topRight(), r.bottomRight());
}
}
示例8: intersectShapeWithLine
bool DiagramItem::intersectShapeWithLine(const QLineF &line, QPointF *intersectionPoint, QLineF *intersectionLine) const
{
QPolygonF polygon;
if (m_customIcon) {
// TODO use customIcon path as shape
QRectF rect = object()->rect();
rect.translate(object()->pos());
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
} else {
QRectF rect = object()->rect();
rect.translate(object()->pos());
polygon << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft() << rect.topLeft();
}
return GeometryUtilities::intersect(polygon, line, intersectionPoint, intersectionLine);
}
示例9: qwtFillBackground
static void qwtFillBackground( QPainter *painter, QwtPlotCanvas *canvas )
{
QVector<QRectF> rects;
if ( canvas->testAttribute( Qt::WA_StyledBackground ) )
{
QwtStyleSheetRecorder recorder( canvas->size() );
QPainter p( &recorder );
qwtDrawStyledBackground( canvas, &p );
p.end();
if ( recorder.background.brush.isOpaque() )
rects = recorder.clipRects;
else
rects += canvas->rect();
}
else
{
const QRectF r = canvas->rect();
const double radius = canvas->borderRadius();
if ( radius > 0.0 )
{
QSizeF sz( radius, radius );
rects += QRectF( r.topLeft(), sz );
rects += QRectF( r.topRight() - QPointF( radius, 0 ), sz );
rects += QRectF( r.bottomRight() - QPointF( radius, radius ), sz );
rects += QRectF( r.bottomLeft() - QPointF( 0, radius ), sz );
}
}
qwtFillBackground( painter, canvas, rects);
}
示例10:
QgsRectangle::QgsRectangle( QRectF const & qRectF )
{
xmin = qRectF.topLeft().x();
ymin = qRectF.topLeft().y();
xmax = qRectF.bottomRight().x();
ymax = qRectF.bottomRight().y();
}
示例11: focusEditableArea
void QtViewportInteractionEngine::focusEditableArea(const QRectF& caretArea, const QRectF& targetArea)
{
QRectF endArea = itemRectFromCSS(targetArea);
qreal endItemScale = itemScaleFromCSS(innerBoundedCSSScale(2.0));
const QRectF viewportRect = m_viewport->boundingRect();
qreal x;
const qreal borderOffset = 10;
if ((endArea.width() + borderOffset) * endItemScale <= viewportRect.width()) {
// Center the input field in the middle of the view, if it is smaller than
// the view at the scale target.
x = viewportRect.center().x() - endArea.width() * endItemScale / 2.0;
} else {
// Ensure that the caret always has borderOffset contents pixels to the right
// of it, and secondarily (if possible), that the area has borderOffset
// contents pixels to the left of it.
qreal caretOffset = itemCoordFromCSS(caretArea.x()) - endArea.x();
x = qMin(viewportRect.width() - (caretOffset + borderOffset) * endItemScale, borderOffset * endItemScale);
}
const QPointF hotspot = QPointF(endArea.x(), endArea.center().y());
const QPointF viewportHotspot = QPointF(x, /* FIXME: visibleCenter */ viewportRect.center().y());
QPointF endPosition = hotspot * endItemScale - viewportHotspot;
QRectF endPosRange = computePosRangeForItemAtScale(endItemScale);
endPosition = boundPosition(endPosRange.topLeft(), endPosition, endPosRange.bottomRight());
QRectF endVisibleContentRect(endPosition / endItemScale, viewportRect.size() / endItemScale);
animateItemRectVisible(endVisibleContentRect);
}
示例12: updateHandles
void ObjectSelectionTool::updateHandles()
{
if (mMode == Moving || mMode == Rotating)
return;
const QSet<MapObjectItem*> &items = mapScene()->selectedObjectItems();
const bool showHandles = items.size() > 0;
QRectF boundingRect;
if (showHandles) {
QSetIterator<MapObjectItem*> iter(items);
MapObjectItem *item = iter.next();
boundingRect = item->mapToScene(item->boundingRect()).boundingRect();
while (iter.hasNext()) {
item = iter.next();
boundingRect |= item->mapToScene(item->boundingRect()).boundingRect();
}
mCornerHandles[TopLeft]->setPos(boundingRect.topLeft());
mCornerHandles[TopRight]->setPos(boundingRect.topRight());
mCornerHandles[BottomLeft]->setPos(boundingRect.bottomLeft());
mCornerHandles[BottomRight]->setPos(boundingRect.bottomRight());
// TODO: Might be nice to make it configurable
mRotationOrigin = boundingRect.center();
mRotationOriginIndicator->setPos(mRotationOrigin);
}
mSelectionBoundingRect = boundingRect;
setHandlesVisible(showHandles);
mRotationOriginIndicator->setVisible(showHandles);
}
示例13: paint
void KarbonCalligraphyTool::paint(QPainter &painter, const KoViewConverter &converter)
{
if (m_selectedPath) {
painter.save();
painter.setRenderHints(QPainter::Antialiasing, false);
painter.setPen(Qt::red); // TODO make configurable
QRectF rect = m_selectedPath->boundingRect();
QPointF p1 = converter.documentToView(rect.topLeft());
QPointF p2 = converter.documentToView(rect.bottomRight());
painter.drawRect(QRectF(p1, p2));
painter.restore();
}
if (!m_shape) {
return;
}
painter.save();
painter.setTransform(m_shape->absoluteTransformation(&converter) *
painter.transform());
KoShapePaintingContext paintContext; //FIXME
m_shape->paint(painter, converter, paintContext);
painter.restore();
}
示例14: realPointOnRectF
QPointF realPointOnRectF(const QRectF& rect,RectPointName::Enum pointName)
{
switch (pointName)
{
case RectPointName::TopLeft:
return rect.topLeft();
case RectPointName::TopRight:
return rect.topRight();
case RectPointName::BottomLeft:
return rect.bottomLeft();
case RectPointName::BottomRight:
return rect.bottomRight();
default:
case RectPointName::Center:
return rect.center();
case RectPointName::TopCenter:
return QPointF(rect.center().x(),rect.top());
case RectPointName::RightCenter:
return QPointF(rect.right(),rect.center().y());
case RectPointName::BottomCenter:
return QPointF(rect.center().x(),rect.bottom());
case RectPointName::LeftCenter:
return QPointF(rect.left(),rect.center().y());
}
return QPointF(); //keep compilers happy
}
示例15: paintSamplesArrow
void DesignerGUIUtils::paintSamplesArrow(QPainter* painter) {
QPen pen(Qt::darkGray);
pen.setWidthF(2);
painter->setPen(pen);
painter->setRenderHint(QPainter::SmoothPixmapTransform);
QFont f = painter->font();
painter->resetTransform();
f.setFamily("Times New Roman");
f.setPointSizeF(20);
f.setItalic(true);
painter->setFont(f);
QRectF approx(50,50, 400, 400);
QString txt = QObject::tr("Select a sample to start");
QRectF res = painter->boundingRect(approx, Qt::AlignLeft | Qt::AlignTop, txt);
res.adjust(-5,-3,15,3);
QPainterPath p(QPointF(5, res.center().y()));
p.lineTo(res.topLeft());
p.lineTo(res.topRight());
p.lineTo(res.bottomRight());
p.lineTo(res.bottomLeft());
p.closeSubpath();
QColor yc = QColor(255,255,160);//QColor(Qt::yellow).lighter();yc.setAlpha(127);
painter->fillPath(p, QBrush(yc));
painter->drawPath(p);
painter->setPen(Qt::black);
painter->drawText(approx, Qt::AlignLeft | Qt::AlignTop, txt);
}