本文整理汇总了C++中QRectF::translated方法的典型用法代码示例。如果您正苦于以下问题:C++ QRectF::translated方法的具体用法?C++ QRectF::translated怎么用?C++ QRectF::translated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRectF
的用法示例。
在下文中一共展示了QRectF::translated方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
QPainterPath
Shapes::stick(const QRectF &bound, Style style)
{
_S(6)
QPainterPath path;
switch (style)
{
case Square:
path.addRect(bound.adjusted(s6, s6, -s6, -s6));
break;
case LasseKongo:
{
_S(4);
const float d = 3*s4;
QRectF rect = bound.adjusted(0,0,-d,-d);
path.addRect(rect);
path.addRect(rect.translated(d,0));
path.addRect(rect.translated(0,d));
path.addRect(rect.translated(d,d));
break;
}
default:
case Round:
case TheRob:
path.addEllipse(bound.adjusted(s6, s6, -s6, -s6));
break;
}
return path;
}
示例2: drawText
void GraphicsDImgView::drawText(QPainter* p, const QRectF& rect, const QString& text)
{
p->save();
p->setRenderHint(QPainter::Antialiasing, true);
p->setBackgroundMode(Qt::TransparentMode);
// increase width by 5 and height by 2
QRectF textRect = rect.adjusted(0, 0, 5, 2);
// Draw background
p->setPen(Qt::black);
QColor semiTransBg = palette().color(QPalette::Window);
semiTransBg.setAlpha(190);
p->setBrush(semiTransBg);
//p->translate(0.5, 0.5);
p->drawRoundRect(textRect, 10.0, 10.0);
// Draw shadow and text
p->setPen(palette().color(QPalette::Window).dark(115));
p->drawText(textRect.translated(3, 1), text);
p->setPen(palette().color(QPalette::WindowText));
p->drawText(textRect.translated(2, 0), text);
p->restore();
}
示例3: paint
void WeatherWallpaper::paint(QPainter * painter, const QRectF & exposedRect)
{
// Check if geometry changed
if (m_size != boundingRect().size().toSize()) {
calculateGeometry();
if (!m_size.isEmpty() && !m_img.isEmpty()) { // We have previous image
renderWallpaper();
return;
}
}
if (m_pixmap.isNull()) {
painter->fillRect(exposedRect, QBrush(m_color));
return;
}
if (painter->worldMatrix() == QMatrix()) {
// draw the background untransformed when possible;(saves lots of per-pixel-math)
painter->resetTransform();
}
// blit the background (saves all the per-pixel-products that blending does)
painter->setCompositionMode(QPainter::CompositionMode_Source);
// for pixmaps we draw only the exposed part (untransformed since the
// bitmapBackground already has the size of the viewport)
painter->drawPixmap(exposedRect, m_pixmap, exposedRect.translated(-boundingRect().topLeft()));
if (!m_oldFadedPixmap.isNull()) {
// Put old faded image on top.
painter->setCompositionMode(QPainter::CompositionMode_SourceAtop);
painter->drawPixmap(exposedRect, m_oldFadedPixmap,
exposedRect.translated(-boundingRect().topLeft()));
}
}
示例4: resize
void ResizeCommand::resize(NodeElement * const element, const QRectF &geometry)
{
if (element && geometryOf(element) != geometry) {
ResizeHandler handler(element);
handler.resize(geometry.translated(-geometry.topLeft()), geometry.topLeft(), false);
}
}
示例5: rotatedRect
QRectF rotatedRect( const QRectF& oldRect, qreal angleInt, const QPointF& center )
{
const QRect rect( oldRect.translated( center ).toRect() );
const qreal angle = PI * angleInt / 180.0;
const qreal cosAngle = cos( angle );
const qreal sinAngle = sin( angle );
QMatrix rotationMatrix(cosAngle, sinAngle, -sinAngle, cosAngle, 0, 0);
QPolygon rotPts;
rotPts << rotationMatrix.map(rect.topLeft()) //QPoint(0,0)
<< rotationMatrix.map(rect.topRight())
<< rotationMatrix.map(rect.bottomRight())
<< rotationMatrix.map(rect.bottomLeft());
//<< rotatedPoint(rect.topRight(), angleInt, center).toPoint()
//<< rotatedPoint(rect.bottomRight(), angleInt, center).toPoint()
//<< rotatedPoint(rect.bottomLeft(), angleInt, center).toPoint();
return rotPts.boundingRect();
/*
const QPointF topLeft( rotatedPoint( oldRect.topLeft(), angle, center ) );
const QPointF topRight( rotatedPoint( oldRect.topRight(), angle, center ) );
const QPointF bottomLeft( rotatedPoint( oldRect.bottomLeft(), angle, center ) );
const QPointF bottomRight( rotatedPoint( oldRect.bottomRight(), angle, center ) );
const qreal x = qMin( qMin( topLeft.x(), topRight.x() ), qMin( bottomLeft.x(), topLeft.x() ) );
const qreal y = qMin( qMin( topLeft.y(), topRight.y() ), qMin( bottomLeft.y(), topLeft.y() ) );
const qreal width = qMax( qMax( topLeft.x(), topRight.x() ), qMax( bottomLeft.x(), topLeft.x() ) ) - x;
const qreal height = qMax( qMax( topLeft.y(), topRight.y() ), qMax( bottomLeft.y(), topLeft.y() ) ) - y;
return QRectF( x, y, width, height );
*/
}
示例6: calculateTextRect
QRectF PheromoneItem::calculateTextRect(const QString &str, const QFont &font, const QRectF &referencia)
{
// QFont font("arial", 7);
QFontMetricsF txtMetrics(font);
QRectF tmpRect = txtMetrics.boundingRect(str);
return tmpRect.translated(-tmpRect.width()/2, referencia.y() - tmpRect.height());
}
示例7: printColorSensor
QImage TwoDModelEngineApi::printColorSensor(PortInfo const &port) const
{
if (mModel.robotModel().configuration().type(port).isNull()) {
return QImage();
}
QPair<QPointF, qreal> const neededPosDir = countPositionAndDirection(port);
QPointF const position = neededPosDir.first;
qreal const width = sensorWidth / 2.0;
QRectF const scanningRect = QRectF(position.x() - width, position.y() - width, 2 * width, 2 * width);
QImage image(scanningRect.size().toSize(), QImage::Format_RGB32);
QPainter painter(&image);
QBrush brush(Qt::SolidPattern);
brush.setColor(Qt::white);
painter.setBrush(brush);
painter.setPen(QPen(Qt::white));
painter.drawRect(scanningRect.translated(-scanningRect.topLeft()));
bool const wasSelected = mView.sensorItem(port)->isSelected();
mView.setSensorVisible(port, false);
mView.scene()->render(&painter, QRectF(), scanningRect);
mView.setSensorVisible(port, true);
mView.sensorItem(port)->setSelected(wasSelected);
return image;
}
示例8: boundingRectFor
QRectF ShadowEffect::boundingRectFor(const QRectF &rect) const
{
qreal padding = m_blurRadius * 2;
return rect.united(
rect.translated(m_xOffset, m_yOffset)
.adjusted(-padding, -padding, padding, padding)
);
}
示例9: paint
void EditorMagnifierItem::paint(QPainter * painter,
const QStyleOptionGraphicsItem *option,
QWidget * widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
if ( !scene() )
return;
QRectF rect = getRect();
EditorScene *scn = qobject_cast<EditorScene *>( scene() );
if (rect.isValid() && m_valid && scn)
{
updateMask();
painter->save(); // because clipping is active !!
QPainterPath clipPath;
clipPath.addEllipse(getRect().center(), getRect().width() / 2,getRect().width() / 2);
painter->setClipPath(clipPath);
painter->setClipping(true);
// TODO add extracted image to a cache !!!
QRectF extractRect( rect.translated( pos() - scn->getUnderlayOffset() ) );
int extractWidth = extractRect.width() / m_magnifyingFactor;
extractRect.adjust(extractWidth,extractWidth,-extractWidth,-extractWidth);
QRectF bgRect = scn->getUnderlayImage().rect();
QRectF croppedRect = extractRect.intersected(bgRect);
if ( !croppedRect.isNull() )
{
QImage background = scn->getUnderlayImage().copy( croppedRect.toRect() );
QImage mag = background.scaled(rect.size().toSize(),Qt::KeepAspectRatio,Qt::SmoothTransformation);
painter->drawImage(rect,mag);
}
painter->drawPixmap(rect.topLeft(), m_imgMask);
painter->restore();
}
// draw a box if selected
if( isSelected() )
{
painter->save();
QPen pen;
pen.setCosmetic(true);
pen.setColor(Qt::black);
pen.setWidth(1);
pen.setStyle(Qt::DotLine);
painter->setPen(pen);
painter->drawRect(rect);
painter->restore();
}
}
示例10: CenterRectSlaveFromMaster
QRectF CenterRectSlaveFromMaster( const QRectF Master ,
QRectF Slave )
{
QRectF SlaveOnline = Slave.translated(Master.center());
const qreal wi = Slave.width() / 2;
const qreal hi = Slave.height() / 2;
SlaveOnline.translate( 0 - wi , 0 - hi );
return SlaveOnline;
}
示例11: contentsRect
QRectF CDiagramTextNode::contentsRect() const
{
QRectF r;
r = CDiagramNode::contentsRect();
if (m_coordMode != CDiagramItem::CenterAsOrigin)
r = r.translated( -r.topLeft() );
return r;
}
示例12: paint
void ChannelGraphItem::paint(QPainter* painter, QColor color)
{
QRectF rect = boundingRect();
QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
gradient.setColorAt(0, QColor(255, 255, 255));
gradient.setColorAt(1, color);
painter->setBrush(gradient);
painter->drawRoundedRect(rect, margin, margin);
painter->drawText(rect.translated(1, -1), Qt::AlignCenter, name);
}
示例13: paintOutlineRect
QRectF KisExperimentPaintOpSettings::paintOutlineRect(const QPointF& pos, KisImageWSP image, OutlineMode _mode) const
{
if (_mode != CursorIsOutline) return QRectF();
qreal width = getInt(EXPERIMENT_START_SIZE); /* scale();*/
qreal height = getInt(EXPERIMENT_START_SIZE); /* scale();*/
width += 10;
height += 10;
QRectF rc = QRectF(0, 0, width, height);
return image->pixelToDocument(rc.translated(- QPoint(width * 0.5, height * 0.5))).translated(pos);
}
示例14:
void D2ModelScene::centerOnRobot()
{
for (QGraphicsView * const view : views()) {
QRectF const viewPortRect = view->mapToScene(view->viewport()->rect()).boundingRect();
if (!viewPortRect.contains(mRobot->sceneBoundingRect().toRect())) {
QRectF const requiredViewPort = viewPortRect.translated(mRobot->scenePos() - viewPortRect.center());
setSceneRect(itemsBoundingRect().united(requiredViewPort));
view->centerOn(mRobot);
}
}
}
示例15: setGeometry
void NodeElement::setGeometry(const QRectF &geom)
{
prepareGeometryChange();
setPos(geom.topLeft());
if (geom.isValid()) {
mContents = geom.translated(-geom.topLeft());
}
mTransform.reset();
mTransform.scale(mContents.width(), mContents.height());
adjustLinks();
}