本文整理汇总了C++中QTransform::scale方法的典型用法代码示例。如果您正苦于以下问题:C++ QTransform::scale方法的具体用法?C++ QTransform::scale怎么用?C++ QTransform::scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTransform
的用法示例。
在下文中一共展示了QTransform::scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawPixmapWithScreenScaleFactor
void StyleHelper::drawPixmapWithScreenScaleFactor(QPainter* p, const QRect& rcOrign, const QPixmap& pix)
{
if (pix.isNull())
return;
#ifdef Q_OS_MAC
float factor = qt_mac_get_scalefactor(0);
QRect rcTarget(rcOrign);
rcTarget.setWidth(rcTarget.width() * factor);
rcTarget.setHeight(rcTarget.height() * factor);
QTransform transRect;
transRect.scale(factor, factor);
QPoint leftTop = transRect.map(rcOrign.topLeft());
rcTarget.moveTopLeft(leftTop);
//
float rFactor = 1 / factor;
QTransform transPainter;
transPainter.scale(rFactor, rFactor);
//
p->save();
p->setWorldTransform(transPainter);
p->drawPixmap(rcTarget, pix);
p->restore();
#else
p->drawPixmap(rcOrign, pix);
#endif
}
示例2: createTransform
QTransform QgsTransformEffect::createTransform( const QgsRenderContext &context ) const
{
QTransform t;
if ( !source() )
return t;
int width = source()->boundingRect().width();
int height = source()->boundingRect().height();
int top = source()->boundingRect().top();
int left = source()->boundingRect().left();
//remember that the below operations are effectively performed in the opposite order
//so, first the reflection applies, then scale, shear, rotate and lastly translation
double translateX = context.convertToPainterUnits( mTranslateX, mTranslateUnit, mTranslateMapUnitScale );
double translateY = context.convertToPainterUnits( mTranslateY, mTranslateUnit, mTranslateMapUnitScale );
t.translate( translateX + left + width / 2.0,
translateY + top + height / 2.0 );
t.rotate( mRotation );
t.shear( mShearX, mShearY );
t.scale( mScaleX, mScaleY );
if ( mReflectX || mReflectY )
{
t.scale( mReflectX ? -1 : 1, mReflectY ? -1 : 1 );
}
t.translate( -left - width / 2.0,
-top - height / 2.0 );
return t;
}
示例3: getPuzzlePieceShape
QPainterPath ShapeProcessor::getPuzzlePieceShape(int status)
{
_p->shapeRequests++;
if (!_p->shapeCache.contains(status))
{
foreach (int s, _p->shapeCache.keys())
{
MatchMode m = match(s, status);
if (m == NoMatch)
continue;
// Found a shape which matches, but needs transforming
QTransform tr;
if (m == HorizontalFlipMatch)
tr = tr.scale(-1.0, 1.0).translate(-_p->unit.width() - _p->tabFull * 2, 0);
else if (m == VerticalFlipMatch)
tr = tr.scale(1.0, -1.0).translate(0, - _p->unit.height() - _p->tabFull * 2);
else if (m == HorizontalAndVerticalFlipMatch)
tr = tr.scale(-1.0, -1.0).translate(-_p->unit.width() - _p->tabFull * 2, - _p->unit.height() - _p->tabFull * 2);
_p->shapeCacheHits++;
return _p->shapeCache[status] = tr.map(_p->shapeCache[s]);
}
// No match in the cache, need to generate a new shape
return _p->shapeCache[status] =
createPuzzleShape(
_p->unit,
status, _p->tabFull, _p->tabSize, _p->tabOffset, _p->tabTolerance, _p->tabSize, _p->tabOffset);
}
示例4: SetDegree
void Animator::SetDegree(const double& dg){
Degree=dg;
double ScaleGrade;
while(Degree>360.0) Degree-=360.0;
while(Degree<0) Degree+=360.0;
if(tipoAnimazione==RotateIn){
QTransform transform;
ScaleGrade=-((Degree/360.0)-1.0);
transform.scale(ScaleGrade,ScaleGrade);
transform.shear(0, (Degree/180.0)*((double)WidImage->height())/((double)WidImage->width()));
Immagine->setTransform(transform);
if(baseParent==0)
setGeometry(Posizione.x()+(QApplication::desktop()->width()*(1-ScaleGrade)),Posizione.y(),WidImage->width()*ScaleGrade,WidImage->height());
else
setGeometry(Posizione.x()+(baseParent->width()*(1-ScaleGrade)),Posizione.y(),WidImage->width()*ScaleGrade,WidImage->height());
}
if(tipoAnimazione==RotateOut){
QTransform transform;
ScaleGrade=Degree/360.0;
transform.scale(ScaleGrade,ScaleGrade);
transform.shear(0, ((Degree/180.0)-2.0)*((double)WidImage->height())/((double)WidImage->width()));
Immagine->setTransform(transform);
setGeometry(
Posizione.x()*ScaleGrade,
Posizione.y()-(WidImage->height())*(ScaleGrade-1.0),
WidImage->width()*ScaleGrade,
WidImage->height()+(WidImage->height())*(ScaleGrade-1.0));
}
}
示例5: tileCollisionObjectsTransform
QTransform MapObjectItem::tileCollisionObjectsTransform(const Tile &tile) const
{
const Tileset *tileset = tile.tileset();
QTransform tileTransform;
tileTransform.scale(mObject->width() / tile.width(),
mObject->height() / tile.height());
if (mMapDocument->map()->orientation() == Map::Isometric)
tileTransform.translate(-tile.width() / 2, 0.0);
tileTransform.translate(tileset->tileOffset().x(), tileset->tileOffset().y());
if (mObject->cell().flippedVertically()) {
tileTransform.scale(1, -1);
tileTransform.translate(0, tile.height());
}
if (mObject->cell().flippedHorizontally()) {
tileTransform.scale(-1, 1);
tileTransform.translate(-tile.width(), 0);
}
if (tileset->orientation() == Tileset::Isometric)
tileTransform.translate(0.0, -tile.tileset()->gridSize().height());
else
tileTransform.translate(0.0, -tile.height());
return tileTransform;
}
示例6: createPixmap
QPixmap ExifPixmap::createPixmap(QString path)
{
ExifData *exifData = exif_data_new_from_file(path.toStdString().c_str());
int orientation = 0;
if(exifData) {
ExifByteOrder byteOrder = exif_data_get_byte_order(exifData);
ExifEntry *exifEntry = exif_data_get_entry(exifData, EXIF_TAG_ORIENTATION);
if(exifEntry) {
orientation = exif_get_short(exifEntry->data, byteOrder);
}
exif_data_free(exifData);
}
QPixmap pic(path);
/*
0th Row 0th Column
1 top left side
2 top right side
3 bottom right side
4 bottom left side
5 left side top
6 right side top
7 right side bottom
8 left side bottom
*/
QTransform t;
switch(orientation) { // TODO : test flips
case 1:
break;
case 2:
t.scale(-1,1);
break;
case 3:
t.rotate(180);
break;
case 4:
t.rotate(180);
t.scale(-1,1);
break;
case 5:
t.rotate(90);
t.scale(-1,1);
break;
case 6:
t.rotate(90);
break;
case 7:
t.rotate(-90);
t.scale(-1,1);
break;
case 8:
t.rotate(-90);
break;
default:
break;
}
return pic.transformed(t);
}
示例7: updateLength
void TscoreTie::updateLength() {
QTransform t;
if (firstNote()->staff() == secondNote()->staff())
t.scale((secondNote()->x() - firstNote()->x() - firstNote()->width() * 0.8) / m_tieItem->boundingRect().width(),
firstNote()->note()->rtm.stemDown() ? -1.0 : 1.0);
else
t.scale(1.0, firstNote()->note()->rtm.stemDown() ? -1.0 : 1.0);
m_tieItem->setTransform(t);
m_tieItem->setPos(firstNote()->width(), firstNote()->notePos() + (firstNote()->note()->rtm.stemDown() ? 3.7 : - 1.8));
}
示例8: brushOutline
QPainterPath KisDuplicateOpSettings::brushOutline(const QPointF& pos, KisPaintOpSettings::OutlineMode mode, qreal scale, qreal rotation) const
{
QPainterPath path;
path = KisBrushBasedPaintOpSettings::brushOutline(QPointF(0.0,0.0),KisPaintOpSettings::CursorIsOutline, scale, rotation);
QPainterPath copy(path);
QRectF rect2 = copy.boundingRect();
if (m_isOffsetNotUptodate) {
copy.translate(m_position - pos);
} else {
copy.translate(-m_offset);
}
path.addPath(copy);
QTransform m;
m.scale(0.5,0.5);
rect2 = m.mapRect(rect2);
path.moveTo(rect2.topLeft());
path.lineTo(rect2.bottomRight());
path.moveTo(rect2.topRight());
path.lineTo(rect2.bottomLeft());
if (mode == CursorIsOutline){
return path.translated(pos);
} else {
// workaround?
//copy.addEllipse(QRectF(0,0,1,1));
return copy.translated(pos);
}
}
示例9: drawGlyphOutline
void ScreenPainter::drawGlyphOutline(const GlyphLayout gl, bool fill)
{
if (fill)
drawGlyph(gl);
m_painter->save();
bool fr = m_painter->fillRule();
m_painter->setFillRule(false);
setupState(false);
m_painter->translate(0, -(fontSize() * gl.scaleV));
FPointArray outline = font().glyphOutline(gl.glyph);
double scaleHv = gl.scaleH * fontSize() / 10.0;
double scaleVv = gl.scaleV * fontSize() / 10.0;
QTransform trans;
trans.scale(scaleHv, scaleVv);
outline.map(trans);
m_painter->setupPolygon(&outline, true);
if (outline.size() > 3)
{
m_painter->setLineWidth(strokeWidth());
m_painter->strokePath();
}
m_painter->setFillRule(fr);
m_painter->restore();
}
示例10: update
void poligono::on_pushButton_6_clicked()
{
QTransform reflect;
reflect.scale(-1,1);
transforms.push_back(reflect);
update();
}
示例11: drawText
// draw text
void ScenePainter::drawText(const char * const *strs, double *x, double *y,
int n, Qt::Alignment flags, double rot, double hcex,
double vcex)
{
if (indexMode()) {
QVector<QRectF> rects = textExtents(strs, n, flags);
for (int i = 0; i < n; i++) {
QString qstr = QString::fromLocal8Bit(strs[i]);
QPointF center = rects[i].center();
double xi = x[i] + center.x();
double yi = y[i] + center.y();
drawPoints(&xi, &yi, 1);
}
return;
}
// FIXME: alignment is ignored -- translate to HTML?
QTransform posTform = transform();
QTransform textTform;
textTform.rotate(-rot);
textTform.scale(hcex, vcex);
for (int i = 0; i < n; i++) {
QString qstr = QString::fromLocal8Bit(strs[i]);
QGraphicsItem *item = STORE_INDEX(_scene->addText(qstr, _scene->font()));
item->setFlag(QGraphicsItem::ItemIgnoresTransformations);
item->setPos(posTform.map(QPointF(x[i], y[i])));
item->setTransform(textTform);
}
}
示例12: paintEvent
void Heading_Widget::paintEvent(QPaintEvent * event)
{
(void)event;
QPainter painter(this);
painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
float xScale = (float)this->width() / (float)backImage.width();
float yScale = (float)this->height() / (float)backImage.height();
painter.scale(xScale, yScale);
painter.drawPixmap(0, 0, backImage);
QTransform trans;
trans.translate( width()/2, height()/2);
trans.scale(xScale,yScale);
trans.rotate( -headingAngle );
trans.translate( -137, -137 );
painter.setTransform(trans);
painter.drawPixmap(0, 0, headingRing);
painter.resetTransform();
painter.scale(xScale, yScale);
painter.drawPixmap(70, 40, airplaneImage);
}
示例13: add
void KisShapeSelectionModel::add(KoShape *child)
{
if (!m_shapeSelection) return;
if (m_shapeMap.contains(child))
return;
child->setStroke(0);
child->setBackground( QSharedPointer<KoShapeBackground>(0));
m_shapeMap.insert(child, child->boundingRect());
m_shapeSelection->shapeManager()->addShape(child);
QRect updateRect = child->boundingRect().toAlignedRect();
if (m_image.isValid()) {
QTransform matrix;
matrix.scale(m_image->xRes(), m_image->yRes());
updateRect = matrix.mapRect(updateRect);
}
if (m_shapeMap.count() == 1) {
// The shape is the first one, so the shape selection just got created
// Pixel selection provides no longer the datamanager of the selection
// so update the whole selection
requestUpdate(QRect());
} else {
requestUpdate(updateRect);
}
}
示例14: mapSourceToTarget
void QSvgTinyDocument::mapSourceToTarget(QPainter *p, const QRectF &targetRect, const QRectF &sourceRect)
{
QRectF target = targetRect;
if (target.isNull()) {
QPaintDevice *dev = p->device();
QRectF deviceRect(0, 0, dev->width(), dev->height());
if (deviceRect.isNull()) {
if (sourceRect.isNull())
target = QRectF(QPointF(0, 0), size());
else
target = QRectF(QPointF(0, 0), sourceRect.size());
} else {
target = deviceRect;
}
}
QRectF source = sourceRect;
if (source.isNull())
source = viewBox();
if (source != target && !source.isNull()) {
QTransform transform;
transform.scale(target.width() / source.width(),
target.height() / source.height());
QRectF c2 = transform.mapRect(source);
p->translate(target.x() - c2.x(),
target.y() - c2.y());
p->scale(target.width() / source.width(),
target.height() / source.height());
}
}
示例15: connect
MainWindow::MainWindow(QWidget* parent) {
ui.setupUi(this);
ui.graphicsView->setScene(&_scene);
_mapid.load("./MapID.mat");
cout << _mapid.n_cols << "," << _mapid.n_rows << endl;
connect(ui.slider, SIGNAL(valueChanged(int)), SLOT(selectValue(int)));
connect(ui.clearGraphButton, SIGNAL(pressed()), SLOT(clearGraphs()));
connect(ui.loadSeries, SIGNAL(pressed()), SLOT(loadSeries()));
_mapItem = new QFloatImageItem();
_mapItem->setImage(_imageBuffer.memptr(), _imageBuffer.n_rows, _imageBuffer.n_cols);
_mapItem->setRange(ui.minValue->value(), ui.maxValue->value());
_mapItem->setInteraction(this);
_scene.addItem(_mapItem);
_traceItem = _scene.addPath(_tracePath);
_traceItem->setPen(QPen(Qt::black));
QTransform matrix;
matrix.scale(5, 5);
ui.graphicsView->setTransform(matrix);
ui.customPlot->setInteraction(QCustomPlot::iSelectLegend, true);
ui.customPlot->setInteraction(QCustomPlot::iSelectPlottables, true);
connect(ui.customPlot, SIGNAL(selectionChangedByUser()), SLOT(graphSelected()));
_plotMarker = new QGraphicsEllipseItem(_mapItem);
_plotMarker->setVisible(false);
}