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


C++ QPainter::transform方法代码示例

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


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

示例1: height

    void Na2DViewer::transformPainterToCurrentCamera(QPainter& painter)
{
    // adjust painter coordinate system to place image correctly
    float scale = defaultScale * cameraModel.scale();
    // origin at pixel center, not corner
    qreal w2 = (pixmap.width() - 1.0) / 2.0;
    qreal h2 = (pixmap.height() - 1.0) / 2.0;
    qreal tx = w2 + flip_X * (cameraModel.focus().x() - w2) + 0.5;
    qreal ty = h2 + flip_Y * (cameraModel.focus().y() - h2) + 0.5;
    painter.translate(width()/2.0 - tx * scale, height()/2.0 - ty * scale);
    painter.scale(scale, scale);

    // I want to convert screen coordinates to image coordinates;
    // The QPainter object knows this transformation.
    // This nomenclature for the transforms, e.g. X_view_img , comes from the
    // advanced dynamics community at Stanford, specifically the disciples of Thomas Kane.
    X_view_img = painter.transform();
    X_img_view = painter.transform().inverted();
}
开发者ID:Vaa3D,项目名称:v3d_external,代码行数:19,代码来源:Na2DViewer.cpp

示例2: paintEllipse

void PaintMethods::paintEllipse(const DebugDrawing::Ellipse& element, QPainter& painter)
{
  setBrush(element.fillStyle, element.fillColor, painter);
  setPen(element, painter);

  if(element.rotation != 0.0f)
  {
    QTransform trans(painter.transform());
    QTransform transBack(painter.transform());
    trans.translate(qreal(element.x), qreal(element.y));
    trans.rotateRadians(qreal(element.rotation));
    painter.setTransform(trans);
    painter.drawEllipse(-element.radiusX, -element.radiusY, 2 * element.radiusX, 2 * element.radiusY);
    painter.setTransform(transBack);
  }
  else
  {
    painter.drawEllipse(element.x - element.radiusX, element.y - element.radiusY, 2 * element.radiusX, 2 * element.radiusY);
  }
}
开发者ID:BADBDY23,项目名称:BHumanCodeRelease,代码行数:20,代码来源:PaintMethods.cpp

示例3: paintRectangle

void PaintMethods::paintRectangle(const DebugDrawing::Rectangle& element, QPainter& painter)
{
  setBrush(element.fillStyle, element.fillColor, painter);
  setPen(element, painter);

  const QRect dRect(element.topLX, element.topLY, element.w, element.h);

  if(element.rotation != 0.0f)
  {
    const QPoint center = dRect.center();
    QTransform trans(painter.transform());
    QTransform transBack(painter.transform());
    trans.translate(center.x(), center.y());
    trans.rotateRadians(qreal(element.rotation));
    painter.setTransform(trans);
    painter.drawRect(element.topLX - center.x(), element.topLY - center.y(), dRect.width(), dRect.height());
    painter.setTransform(transBack);
  }
  else
  {
    painter.drawRect(dRect);
  }
}
开发者ID:BADBDY23,项目名称:BHumanCodeRelease,代码行数:23,代码来源:PaintMethods.cpp

示例4: paint

void KoShapeShadow::paint(KoShape *shape, QPainter &painter, const KoViewConverter &converter)
{
    if (! d->visible)
        return;

    // So the approach we are taking here is to draw into a buffer image the size of boundingRect
    // We offset by the shadow offset at the time we draw into the buffer
    // Then we filter the image and draw it at the position of the bounding rect on canvas

    //the boundingRect of the shape or the KoSelection boundingRect of the group
    QRectF shadowRect = shape->boundingRect();
    QRectF zoomedClipRegion = converter.documentToView(shadowRect);

    // Init the buffer image
    QImage sourceGraphic(zoomedClipRegion.size().toSize(), QImage::Format_ARGB32_Premultiplied);
    sourceGraphic.fill(qRgba(0,0,0,0));
    // Init the buffer painter
    QPainter imagePainter(&sourceGraphic);
    imagePainter.setPen(Qt::NoPen);
    imagePainter.setBrush(Qt::NoBrush);
    imagePainter.setRenderHint(QPainter::Antialiasing, painter.testRenderHint(QPainter::Antialiasing));
    // Since our imagebuffer and the canvas don't align we need to offset our drawings
    imagePainter.translate(-1.0f*converter.documentToView(shadowRect.topLeft()));

    // Handle the shadow offset
    imagePainter.translate(converter.documentToView(offset()));

    KoShapeGroup *group = dynamic_cast<KoShapeGroup*>(shape);
    if (group) {
        d->paintGroupShadow(group, imagePainter, converter);
    } else {
        //apply shape's transformation
        imagePainter.setTransform(shape->absoluteTransformation(&converter), true);

        d->paintShadow(shape, imagePainter, converter);
    }
    imagePainter.end();

    // Blur the shadow (well the entire buffer)
    d->blurShadow(sourceGraphic, converter.documentToViewX(d->blur), d->color);

    // Paint the result
    painter.save();
    // The painter is initialized for us with canvas transform 'plus' shape transform
    // we are only interested in the canvas transform so 'subtract' the shape transform part
    painter.setTransform(shape->absoluteTransformation(&converter).inverted() * painter.transform());
    painter.drawImage(zoomedClipRegion.topLeft(), sourceGraphic);
    painter.restore();
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:49,代码来源:KoShapeShadow.cpp

示例5: paintText

void PaintMethods::paintText(const DebugDrawing::Text& element, QPainter& painter)
{
  QFont font("Arial", element.fontSize, QFont::Normal);
  pen.setColor(QColor(element.penColor.r, element.penColor.g, element.penColor.b, element.penColor.a));
  painter.setPen(pen);
  painter.setFont(font);

  QTransform trans(painter.transform());
  QTransform newTrans;
  newTrans.translate(trans.dx(), trans.dy());
  newTrans.scale(std::abs(trans.m11()), std::abs(trans.m22()));
  painter.setTransform(newTrans);
  painter.drawText(QPoint(element.x * (int)sgn(trans.m11()), element.y * (int)sgn(trans.m22())), QObject::tr((const char*)(&element + 1)));
  painter.setTransform(trans);
}
开发者ID:BADBDY23,项目名称:BHumanCodeRelease,代码行数:15,代码来源:PaintMethods.cpp

示例6: paintPath

void KoCreatePathTool::paintPath(KoPathShape& pathShape, QPainter &painter, const KoViewConverter &converter)
{
    Q_D(KoCreatePathTool);
    painter.setTransform(pathShape.absoluteTransformation(&converter) * painter.transform());
    painter.save();

    KoShapePaintingContext paintContext; //FIXME
    pathShape.paint(painter, converter, paintContext);
    painter.restore();
    if (pathShape.stroke()) {
        painter.save();
        pathShape.stroke()->paint(d->shape, painter, converter);
        painter.restore();
    }
}
开发者ID:KDE,项目名称:calligra,代码行数:15,代码来源:KoCreatePathTool.cpp

示例7: drawResized

void AdvancedImageWidget::drawResized(QPainter &painter)
{
    //qDebug("AdvancedImageWidget::drawResized():called");
    if (mImage.isNull())
    {
        qDebug("AdvancedImageWidget::drawResized():image is null");

        painter.drawText(0,0, this->width(), this->height(), Qt::AlignHCenter | Qt::AlignVCenter, QString("NO ACTIVE IMAGE"));
        return;
    }

    if (mUi->rotationComboBox->currentIndex() == 0)
    {
        painter.drawImage(mOutputRect, *mImage, mInputRect);
        return;
    }

//    qDebug() << "Input"  << mInputRect;
//    qDebug() << "Output" << mOutputRect;


    Matrix33 matrix = currentTransformMatrix();
//    cout << "Transfrom Matrix:\n" << matrix << std::endl << std::flush;
    QTransform transform = Core2Qt::QTransformFromMatrix(matrix);
//    qDebug() << "QTransfrom" << transform;



    QTransform old = painter.transform();
    painter.setTransform(transform, false);

    painter.drawImage(mOutputRect.topLeft(), *mImage, mImage->rect());

#if 0
    painter.setPen(Qt::red);
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            painter.drawPoint(i * 64, j * 48);
        }
    }
#endif

    painter.setTransform(old);

}
开发者ID:Aldrog,项目名称:corecvs,代码行数:47,代码来源:advancedImageWidget.cpp

示例8: paint

void KoPathToolSelection::paint(QPainter &painter, const KoViewConverter &converter)
{
    int handleRadius = m_tool->canvas()->shapeController()->resourceManager()->handleRadius();

    PathShapePointMap::iterator it(m_shapePointMap.begin());
    for (; it != m_shapePointMap.end(); ++it) {
        painter.save();

        painter.setTransform(it.key()->absoluteTransformation(&converter) * painter.transform());
        KoShape::applyConversion(painter, converter);

        foreach(KoPathPoint *p, it.value())
            p->paint(painter, handleRadius, KoPathPoint::All);

        painter.restore();
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:17,代码来源:KoPathToolSelection.cpp

示例9: paint

void RightToLeftPaintingStrategy::paint(KoShape *shape, QPainter &painter,
                                        const KoViewConverter &converter, bool forPrint)
{
    painter.save();
    const double width = d->canvas->canvasWidget()->width();
//    const double offsetX = d->canvas->canvasController()->canvasOffsetX();
    painter.translate(/*-2 * offsetX*/ + width, 0);
//     painter.scale(-1, 1);

    painter.setTransform(shape->absoluteTransformation(&converter) * painter.transform());

    if (shapeManager()) {
        shapeManager()->paintShape(shape, painter, converter, forPrint);
    }

    painter.restore();  // for the matrix
}
开发者ID:KDE,项目名称:calligra-history,代码行数:17,代码来源:RightToLeftPaintingStrategy.cpp

示例10: drawTextEx

static void drawTextEx(QPainter &p, const QRectF &r, int fl,
    const QString &s, bool mirrorX = 0, bool mirrorY = 0)
{
    QTransform t = p.transform();
    qreal hw = 0.5*r.width(), hh = 0.5*r.height();
    p.setTransform(QTransform(mirrorX ? -1:1, 0, 0, mirrorY ? -1:1, r.x() + hw, r.y() + hh), 1);
    if(mirrorX)
    {
        if(fl&Qt::AlignLeft) fl &= ~Qt::AlignLeft, fl |= Qt::AlignRight;
        else if(fl&Qt::AlignRight) fl &= ~Qt::AlignRight, fl |= Qt::AlignLeft;
    }
    if(mirrorY)
    {
        if(fl&Qt::AlignTop) fl &= ~Qt::AlignTop, fl |= Qt::AlignBottom;
        else if(fl&Qt::AlignBottom) fl &= ~Qt::AlignBottom, fl |= Qt::AlignTop;
    }
    p.drawText(QRect(-hw, -hh, r.width(), r.height()), fl, s);
    p.setTransform(t);
}
开发者ID:obrpasha,项目名称:votlis_krizh_gaz_nas,代码行数:19,代码来源:graph.cpp

示例11: paint

void KPrShapeManagerAnimationStrategy::paint( KoShape * shape, QPainter &painter, const KoViewConverter &converter, bool forPrint )
{
    if ( ! dynamic_cast<KPrPlaceholderShape *>( shape ) && m_strategy->page()->displayShape( shape ) ) {
        if ( m_animationCache->value(shape, "visibility", true).toBool() ) {
            painter.save();
            QTransform animationTransform = m_animationCache->value(shape, "transform", QTransform()).value<QTransform>();;
            QTransform transform(painter.transform() * shape->absoluteTransformation(&converter));
            if (animationTransform.isScaling()) {
                transform = animationTransform * transform;
            } else {
                transform = transform * animationTransform;
            }

            painter.setTransform(transform);
            // paint shape
            shapeManager()->paintShape( shape, painter, converter, forPrint );
            painter.restore();  // for the transform
        }
    }
}
开发者ID:KDE,项目名称:calligra-history,代码行数:20,代码来源:KPrShapeManagerAnimationStrategy.cpp

示例12: c

void Shape2D::draw(QPainter& painter) const
{
  painter.setPen(m_color);
  this->drawShape(painter);
  if (m_editing)
  {
    QColor c(255,255,255,100);
    painter.setPen(c);
    painter.setCompositionMode(QPainter::CompositionMode_Plus);
    painter.drawRect(m_boundingRect.toQRectF());
    for(size_t i = 0; i < getNControlPoints(); ++i)
    {
      QPointF p = painter.transform().map(getControlPoint(i));
      QRectF r(p - QPointF(sizeCP,sizeCP),p + QPointF(sizeCP,sizeCP));
      painter.save();
      painter.resetTransform();
      painter.fillRect(r,c);
      painter.restore();
    }
  }
}
开发者ID:trnielsen,项目名称:mantid,代码行数:21,代码来源:Shape2D.cpp

示例13: beginTransparencyLayer

void GraphicsContext::beginTransparencyLayer(float opacity)
{
    if (paintingDisabled())
        return;

    int x, y, w, h;
    x = y = 0;
    QPainter *p = m_data->p();
    const QPaintDevice *device = p->device();
    w = device->width();
    h = device->height();

    QRectF clip = p->clipPath().boundingRect();
    QRectF deviceClip = p->transform().mapRect(clip);
    x = int(qBound(qreal(0), deviceClip.x(), (qreal)w));
    y = int(qBound(qreal(0), deviceClip.y(), (qreal)h));
    w = int(qBound(qreal(0), deviceClip.width(), (qreal)w) + 2);
    h = int(qBound(qreal(0), deviceClip.height(), (qreal)h) + 2);

    TransparencyLayer * layer = new TransparencyLayer(m_data->p(), QRect(x, y, w, h));

    layer->opacity = opacity;
    m_data->layers.push(layer);
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:24,代码来源:GraphicsContextQt.cpp

示例14: printProfileDives

void PrintLayout::printProfileDives(int divesPerRow, int divesPerColumn)
{
	int i, row = 0, col = 0, printed = 0, total = estimateTotalDives();
	struct dive *dive;
	if (!total)
		return;

	// setup a painter
	QPainter painter;
	painter.begin(printer);
	painter.setRenderHint(QPainter::Antialiasing);
	painter.setRenderHint(QPainter::SmoothPixmapTransform);
	painter.scale(scaleX, scaleY);

	// setup the profile widget
	ProfileGraphicsView *profile = MainWindow::instance()->graphics();
	const int profileFrameStyle = profile->frameStyle();
	profile->setFrameStyle(QFrame::NoFrame);
	profile->clear();
	profile->setPrintMode(true, !printOptions->color_selected);
	QSize originalSize = profile->size();
	// swap rows/col for landscape
	if (printer->orientation() == QPrinter::Landscape) {
		int swap = divesPerColumn;
		divesPerColumn = divesPerRow;
		divesPerRow = swap;
	}
	// padding in pixels between two dives. no padding if only one dive per page.
	const int padDef = 20;
	const int padW = (divesPerColumn < 2) ? 0 : padDef;
	const int padH = (divesPerRow < 2) ? 0 : padDef;
	// estimate dimensions for a single dive
	const int scaledW = ESTIMATE_DIVE_DIM(scaledPageW, divesPerColumn, padW);
	const int scaledH = ESTIMATE_DIVE_DIM(scaledPageH, divesPerRow, padH);
	// padding in pixels between profile and table
	const int padPT = 5;
	// create a model and table
	ProfilePrintModel model;
	QTableView *table = createProfileTable(&model, scaledW);
	// profilePrintTableMaxH updates after the table is created
	const int tableH = profilePrintTableMaxH;
	// resize the profile widget
	profile->resize(scaledW, scaledH - tableH - padPT);
	// offset table or profile on top
	int yOffsetProfile = 0, yOffsetTable = 0;
	if (printOptions->notes_up)
		yOffsetProfile = tableH + padPT;
	else
		yOffsetTable = scaledH - tableH;

	// plot the dives at specific rows and columns on the page
	for_each_dive(i, dive) {
		if (!dive->selected && printOptions->print_selected)
			continue;
		if (col == divesPerColumn) {
			col = 0;
			row++;
			if (row == divesPerRow) {
				row = 0;
				printer->newPage();
			}
		}
		QTransform origTransform = painter.transform();

		// draw a profile
		painter.translate((scaledW + padW) * col, (scaledH + padH) * row + yOffsetProfile);
		profile->plot(dive, true);
		profile->render(&painter, QRect(0, 0, scaledW, scaledH - tableH - padPT));
		painter.setTransform(origTransform);

		// draw a table
		painter.translate((scaledW + padW) * col, (scaledH + padH) * row + yOffsetTable);
		model.setDive(dive);
		table->render(&painter);
		painter.setTransform(origTransform);
		col++;
		printed++;
		emit signalProgress((printed * 100) / total);
	}

	// cleanup
	painter.end();
	delete table;
	profile->setFrameStyle(profileFrameStyle);
	profile->setPrintMode(false);
	profile->resize(originalSize);
	profile->clear();
	profile->plot(current_dive, true);
}
开发者ID:uddhavpgautam,项目名称:subsurface,代码行数:89,代码来源:printlayout.cpp

示例15: drawGrid

void TransferFunctionEditor::drawGrid(QPainter & painter, int w, int h)
{
  QColor c(128, 128, 128, 128);

  QPen pen(c);
  pen.setWidth(1);

  QBrush brush(c);

  painter.setPen(pen);
  painter.setBrush(brush);

  // vykreslenie samotnej mriezky
  painter.setRenderHint(QPainter::Antialiasing, false);
  painter.setRenderHint(QPainter::HighQualityAntialiasing, false);

  const int vert_step = 20;
  const int horz_step = 10;

  // horizontalne ciary mriezky
  for (int i = INNER_PADDING_BOTTOM; i < h - INNER_PADDING_TOP; i += horz_step)
  {
    painter.drawLine(INNER_PADDING_LEFT, h - i, w - INNER_PADDING_RIGHT, h - i);
  }

  // vertikalne ciary mriezky
  for (int i = INNER_PADDING_LEFT; i < w - INNER_PADDING_RIGHT; i += vert_step)
  {
    painter.drawLine(i, INNER_PADDING_TOP, i, h - INNER_PADDING_BOTTOM);
  }

  painter.setRenderHint(QPainter::Antialiasing, true);
  painter.setRenderHint(QPainter::HighQualityAntialiasing, true);

  pen.setWidth(2);
  painter.setPen(pen);

  // vykreslenie horizontalnej osi
  const QPointF triangle_horz[3] = {
    QPointF(w - INNER_PADDING_RIGHT + EXTRA_INNNER_PADDING_RIGHT,                   h - INNER_PADDING_BOTTOM - 2.5f),
    QPointF(w - INNER_PADDING_RIGHT + EXTRA_INNNER_PADDING_RIGHT + AXIS_ARROW_SIZE, h - INNER_PADDING_BOTTOM + 0.0f),
    QPointF(w - INNER_PADDING_RIGHT + EXTRA_INNNER_PADDING_RIGHT,                   h - INNER_PADDING_BOTTOM + 2.5f)
  };

  painter.drawLine(INNER_PADDING_LEFT, h - INNER_PADDING_BOTTOM, w - INNER_PADDING_RIGHT + EXTRA_INNNER_PADDING_RIGHT, h - INNER_PADDING_BOTTOM);
  painter.drawPolygon(triangle_horz, 3);

  // vykreslenie vertikalnej osi
  const QPointF triangle_vert[3] = {
    //                       x      y
    QPointF(INNER_PADDING_LEFT - 2.5f, INNER_PADDING_TOP - EXTRA_INNNER_PADDING_TOP), // lavy bod
    QPointF(INNER_PADDING_LEFT + 2.5f, INNER_PADDING_TOP - EXTRA_INNNER_PADDING_TOP), // pravy bod
    QPointF(INNER_PADDING_LEFT + 0.0f, INNER_PADDING_TOP - EXTRA_INNNER_PADDING_TOP - AXIS_ARROW_SIZE)  // stredny bod
  };

  painter.drawLine(INNER_PADDING_LEFT, h - INNER_PADDING_BOTTOM, INNER_PADDING_LEFT, INNER_PADDING_TOP - EXTRA_INNNER_PADDING_TOP);
  painter.drawPolygon(triangle_vert, 3);

  // vykreslenie horizontalneho popisku
  painter.drawStaticText(w - INNER_PADDING_RIGHT - 40, h - INNER_PADDING_BOTTOM + 2, QStaticText("intensity"));

  // vykreslenie vertikalneho popisku
  {
    QTransform old_t = painter.transform();
    QTransform t;
    t.translate(0, INNER_PADDING_TOP + 30);
    t.rotate(-90);
    painter.setTransform(t);
    painter.drawStaticText(0, 0, QStaticText("opacity"));
    painter.setTransform(old_t);
  }
}
开发者ID:jcxz,项目名称:PGP,代码行数:72,代码来源:transfer_function_editor.cpp


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