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


C++ QTransform类代码示例

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


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

示例1:

void QgsLineStringV2::transform( const QTransform& t )
{
  mCoords = t.map( mCoords );
}
开发者ID:GiordanoPezzola,项目名称:QGIS,代码行数:4,代码来源:qgslinestringv2.cpp

示例2: mapBy

QBezier QBezier::mapBy(const QTransform &transform) const
{
    return QBezier::fromPoints(transform.map(pt1()), transform.map(pt2()), transform.map(pt3()), transform.map(pt4()));
}
开发者ID:KDE,项目名称:android-qt5-qtbase,代码行数:4,代码来源:qbezier.cpp

示例3: applyDeltaMatrix

void TextNode::applyDeltaMatrix(QPointF delta) {
	QTransform t;
	t.fromTranslate(delta.x(), delta.y());
	applyMatrix(t);
}
开发者ID:Jellofishi,项目名称:Desktop,代码行数:5,代码来源:textnode.cpp

示例4: evaluateDataDefinedProperty

bool QgsEllipseSymbolLayerV2::writeDxf( QgsDxfExport& e, double mmMapUnitScaleFactor, const QString& layerName, QgsSymbolV2RenderContext *context, const QgsFeature*, QPointF shift ) const
{
  //width
  double symbolWidth = mSymbolWidth;

  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH ) ) //1. priority: data defined setting on symbol layer le
  {
    context->setOriginalValueVariable( mSymbolWidth );
    symbolWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_WIDTH, *context, mSymbolWidth ).toDouble();
  }
  else if ( context->renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
  {
    symbolWidth = mSize;
  }
  if ( mSymbolWidthUnit == QgsSymbolV2::MM )
  {
    symbolWidth *= mmMapUnitScaleFactor;
  }

  //height
  double symbolHeight = mSymbolHeight;
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT ) ) //1. priority: data defined setting on symbol layer level
  {
    context->setOriginalValueVariable( mSymbolHeight );
    symbolHeight = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_HEIGHT, *context, mSymbolHeight ).toDouble();
  }
  else if ( context->renderHints() & QgsSymbolV2::DataDefinedSizeScale ) //2. priority: is data defined size on symbol level
  {
    symbolHeight = mSize;
  }
  if ( mSymbolHeightUnit == QgsSymbolV2::MM )
  {
    symbolHeight *= mmMapUnitScaleFactor;
  }

  //outline width
  double outlineWidth = mOutlineWidth;

  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH ) )
  {
    context->setOriginalValueVariable( mOutlineWidth );
    outlineWidth = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_WIDTH, *context, mOutlineWidth ).toDouble();
  }
  if ( mOutlineWidthUnit == QgsSymbolV2::MM )
  {
    outlineWidth *= outlineWidth;
  }

  //fill color
  bool ok;
  QColor fc = mColor;
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR ) )
  {
    context->setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mColor ) );
    QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_FILL_COLOR, *context, QVariant(), &ok ).toString();
    if ( ok )
      fc = QgsSymbolLayerV2Utils::decodeColor( colorString );
  }

  //outline color
  QColor oc = mOutlineColor;
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR ) )
  {
    context->setOriginalValueVariable( QgsSymbolLayerV2Utils::encodeColor( mOutlineColor ) );
    QString colorString = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_OUTLINE_COLOR, *context, QVariant(), &ok ).toString();
    if ( ok )
      oc = QgsSymbolLayerV2Utils::decodeColor( colorString );
  }

  //symbol name
  QString symbolName = mSymbolName;
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME ) )
  {
    context->setOriginalValueVariable( mSymbolName );
    symbolName = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_SYMBOL_NAME, *context, mSymbolName ).toString();
  }

  //offset
  double offsetX = 0;
  double offsetY = 0;
  markerOffset( *context, offsetX, offsetY );
  QPointF off( offsetX, offsetY );

  //priority for rotation: 1. data defined symbol level, 2. symbol layer rotation (mAngle)
  double rotation = 0.0;
  if ( hasDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION ) )
  {
    context->setOriginalValueVariable( mAngle );
    rotation = evaluateDataDefinedProperty( QgsSymbolLayerV2::EXPR_ROTATION, *context, mAngle ).toDouble() + mLineAngle;
  }
  else if ( !qgsDoubleNear( mAngle + mLineAngle, 0.0 ) )
  {
    rotation = mAngle + mLineAngle;
  }
  rotation = -rotation; //rotation in Qt is counterclockwise
  if ( rotation )
    off = _rotatedOffset( off, rotation );

  QTransform t;
  t.translate( shift.x() + offsetX, shift.y() + offsetY );
//.........这里部分代码省略.........
开发者ID:asneuvon,项目名称:QGIS,代码行数:101,代码来源:qgsellipsesymbollayerv2.cpp

示例5: D3DXVECTOR3

void CWorld::Create(int width, int height, int textureID, float heightMap, int MPU, bool indoor, const string& bitmap)
{
	m_width = width;
	m_height = height;
	m_MPU = MPU;
	m_inDoor = indoor;

	m_cameraPos = D3DXVECTOR3(MPU * -14, heightMap + MPU * 25, MPU * -14);
	m_cameraAngle.x = 45.0f;
	m_cameraAngle.y = -30.0f;

	_initialize();

	int x, i, y, x2, y2;
	CLandscape* land;
	for (y = 0; y < m_height; y++)
	{
		for (x = 0; x < m_width; x++)
		{
			land = m_lands[y * m_width + x] = new CLandscape(m_device, this, x * MAP_SIZE, y * MAP_SIZE);
			land->GetLayer(textureID);
		}
	}

	QImage image;
	if (!bitmap.isEmpty() && image.load(bitmap))
	{
		QTransform rot;
		rot.rotate(90);
		image = image.transformed(rot);
		for (y = 0; y < m_height; y++)
		{
			for (x = 0; x < m_width; x++)
			{
				land = m_lands[y * m_width + x];
				for (x2 = 0; x2 < (MAP_SIZE + 1); x2++)
				{
					for (y2 = 0; y2 < (MAP_SIZE + 1); y2++)
					{
						land->m_heightMap[x2 *(MAP_SIZE + 1) + y2] = QColor(image.pixel(
							(int)(((float)(x2 + y * MAP_SIZE) / (float)(m_height * MAP_SIZE)) * (float)image.width()),
							(int)(((float)(y2 + x * MAP_SIZE) / (float)(m_width * MAP_SIZE)) * (float)image.height())
							)).redF() * heightMap;
					}
				}
			}
		}
	}
	else
	{
		for (y = 0; y < m_height; y++)
		{
			for (x = 0; x < m_width; x++)
			{
				land = m_lands[y * m_width + x];
				for (i = 0; i < (MAP_SIZE + 1) * (MAP_SIZE + 1); i++)
					land->m_heightMap[i] = heightMap;
			}
		}
	}
}
开发者ID:Aishiro,项目名称:ATools,代码行数:61,代码来源:World.cpp

示例6: transform

void KWidget::setzRotateAngle( qreal angle )
{
    QTransform t = transform();
    setTransform(t.rotate(angle, Qt::ZAxis));
}
开发者ID:kxtry,项目名称:kxmob,代码行数:5,代码来源:kwidget.cpp

示例7: QLineF

void CanvasMode_EditArc::applyValues(double start, double end, double height, double width)
{
	PageItem *currItem = m_doc->m_Selection->itemAt(0);
	QRectF oldR = currItem->getBoundingRect().adjusted(-5, -5, 10, 10);
	PageItem_Arc *item = currItem->asArc();
	QTransform bb;
	bb.scale(height / width, 1.0);
	QLineF inp = QLineF(QPointF(width / 2.0, height / 2.0), QPointF(width, height / 2.0));
	inp.setAngle(start);
	QLineF res = bb.map(inp);
	inp.setAngle(end);
	QLineF ena = bb.map(inp);
	m_startAngle = res.angle();
	m_endAngle = ena.angle();
	double nSweep = m_endAngle - m_startAngle;
	if (nSweep < 0)
		nSweep += 360;
	double oldX = currItem->xPos();
	double oldY = currItem->yPos();
	double newX = oldX + m_centerPoint.x() - (width / 2.0);
	double newY = oldY + m_centerPoint.y() - (height / 2.0);
	item->setXYPos(newX, newY, true);
	FPointArray old = item->PoLine;
	QPainterPath pp;
	pp.moveTo(width / 2.0, height / 2.0);
	pp.arcTo(QRectF(0, 0, width, height), m_startAngle, nSweep);
	pp.closeSubpath();
	currItem->PoLine.fromQPainterPath(pp, true);
	FPoint wh = getMaxClipF(&currItem->PoLine);
	currItem->setWidthHeight(wh.x(),wh.y());
	m_doc->adjustItemSize(currItem);
	currItem->OldB2 = currItem->width();
	currItem->OldH2 = currItem->height();
	if (UndoManager::undoEnabled())
	{
		ScItemState<QPair<FPointArray, FPointArray> > *ss = new ScItemState<QPair<FPointArray, FPointArray> >(Um::EditArc,"",Um::IPolygon);
		ss->set("ARC");
		ss->set("OLD_WIDTH",item->arcWidth);
		ss->set("NEW_WIDTH",width);
		ss->set("OLD_XPOS",oldX);
		ss->set("OLD_YPOS",oldY);
		ss->set("OLD_HEIGHT",item->arcHeight);
		ss->set("NEW_HEIGHT",height);
		ss->set("OLD_START",item->arcStartAngle);
		ss->set("NEW_START",m_startAngle);
		ss->set("OLD_SWEEP",item->arcSweepAngle);
		ss->set("NEW_SWEEP",nSweep);
		ss->setItem(qMakePair(old,item->PoLine));
		ss->set("NEW_XPOS",item->xPos());
		ss->set("NEW_YPOS",item->yPos());
		undoManager->action(currItem,ss);
	}
	item->arcStartAngle = m_startAngle;
	item->arcSweepAngle = nSweep;
	item->arcWidth = width;
	item->arcHeight = height;
	m_startPoint = currItem->PoLine.pointQF(2);
	m_endPoint = currItem->PoLine.pointQF(currItem->PoLine.size() - 4);
	m_centerPoint = currItem->PoLine.pointQF(0);
	m_widthPoint = QPointF(m_centerPoint.x() - item->arcWidth / 2.0, m_centerPoint.y());
	m_heightPoint = QPointF(m_centerPoint.x(), m_centerPoint.y() - item->arcHeight / 2.0);
	m_doc->setRedrawBounding(currItem);
	QRectF newR(currItem->getBoundingRect());
	m_doc->regionsChanged()->update(newR.united(oldR));

//	QTransform itemMatrix = currItem->getTransform();
//	m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
}
开发者ID:nitramr,项目名称:scribus,代码行数:68,代码来源:canvasmode_editarc.cpp

示例8: toLocal

QPointF Body::toLocal( const QPointF& p ) const {
    QTransform transform;
    //transform.translate(-position().x(),-position().y());
    transform.rotateRadians(-angle());
    return transform.map(p-position());
}
开发者ID:andryblack,项目名称:Chipmunk-Sandbox,代码行数:6,代码来源:body.cpp

示例9: resizer_activeness

// --------------------------------------------------------
void TouchWidgetRenderer::drawResizers(
	GLResourceContainer * container,
	const SceneTouchPoint * resizing_point,
	const QPointF & circle_center,
	float circle_radius,
	const QPointF & base_target,
	QList<float> resizer_angles ) const
{
	static Warping<qreal> resizer_activeness(0.0f, 0.2f);
	static bool resizer_active = false;
	static QPointF last_resizer_pos;
	static float touch_angle_target = 0;

	QPointF base_pos = QLineF(circle_center, base_target).unitVector().pointAt(circle_radius);
	float base_angle = QLineF(base_target, circle_center).angleTo(QLineF(0,0,1,0));

	// trigger the warp towards 1 or 0 if the status just changed and evaluate it
	if((resizing_point != NULL) != resizer_active)
	{
		resizer_active = (resizing_point != NULL);
		resizer_activeness.setTarget(resizer_active ? 1.0f : 0.0f);
	}
	float activeness = resizer_activeness.value();

	// update resizer position and angle based on current touch
	if(resizer_active)
	{
		last_resizer_pos = resizing_point->pos();
		touch_angle_target = QLineF(last_resizer_pos, circle_center).angleTo(QLineF(0,0,1,0));;

		touch_angle_target += 60;
		while(touch_angle_target>120) touch_angle_target-=120;
		while(touch_angle_target<-120) touch_angle_target+=120;
		touch_angle_target -= 60;
	}

	// compute resizer size
	const float resizer_diameter = 0.3f * circle_radius * (activeness*0.5+1);
	QSizeF resizer_size(resizer_diameter, resizer_diameter);

	// draw individual angles
	foreach(float resizer_angle, resizer_angles)
	{
		// compute desired angle
		float blended_angle = (touch_angle_target+resizer_angle)*activeness + resizer_angle*(1-activeness);

		// compute resizer handle location
		QTransform transform;
		transform.translate(circle_center.x(), circle_center.y());
		transform.rotate(blended_angle);
		transform.translate(-circle_center.x(), -circle_center.y());
		QPointF resizer_pos = transform.map(base_pos);

		// draw resizer handle
		if(activeness < 1)
		{
			drawTexturedQuad(container->texture("mglass_resizer"), resizer_pos, resizer_size, blended_angle+base_angle+180);
		}
		if(activeness > 0)
		{
			drawTexturedQuad(container->texture("mglass_resizer_active"), resizer_pos, resizer_size, blended_angle+base_angle+180, activeness);
		}
	}
开发者ID:dpkay,项目名称:fingerglass,代码行数:64,代码来源:touchwidgetrenderer.cpp

示例10: fromLocal

QPointF Body::fromLocal( const QPointF& p ) const {
    QTransform transform;
    transform.translate(position().x(),position().y());
    transform.rotateRadians(-angle());
    return transform.map(p);
}
开发者ID:andryblack,项目名称:Chipmunk-Sandbox,代码行数:6,代码来源:body.cpp

示例11: updateGraphicsItemTransform

void BI_FootprintPad::updateGraphicsItemTransform() noexcept {
  QTransform t;
  if (mFootprint.getIsMirrored()) t.scale(qreal(-1), qreal(1));
  t.rotate(-mRotation.toDeg());
  mGraphicsItem->setTransform(t);
}
开发者ID:LibrePCB,项目名称:LibrePCB,代码行数:6,代码来源:bi_footprintpad.cpp

示例12: transform

void QSanSelectableItem::scaleSmoothly(qreal ratio) {
    QTransform trans = transform();
    trans.scale(ratio, ratio);
    setTransform(trans);
}
开发者ID:Jia731,项目名称:QSanguosha-Para-tangjs520,代码行数:5,代码来源:QSanSelectableItem.cpp

示例13: qreal

void KisColorSelector::drawLightStrip(QPainter& painter, const QRect& rect)
{
    bool     isVertical = true;
    qreal    penSize    = qreal(qMin(QWidget::width(), QWidget::height())) / 200.0;
    KisColor color(m_selectedColor);
    
    painter.resetTransform();
    
    if (getNumLightPieces() > 1) {
        painter.setRenderHint(QPainter::Antialiasing, true);
        painter.setPen(QPen(QBrush(Qt::red), penSize));
        
        QTransform matrix;
        matrix.translate(rect.x(), rect.y());
        matrix.scale(rect.width(), rect.height());
        
        for(int i=0; i<getNumLightPieces(); ++i) {
            float  t1    = float(i)   / float(getNumLightPieces());
            float  t2    = float(i+1) / float(getNumLightPieces());
            float  light = 1.0f - (float(i) / float(getNumLightPieces()-1));
            float  diff  = t2 - t1;// + 0.001;
            QRectF r     = isVertical ? QRectF(0.0, t1, 1.0, diff) : QRect(t1, 0.0, diff, 1.0);
            
            color.setX(getLight(light, color.getH(), m_relativeLight));
            
            r = matrix.mapRect(r);
            painter.fillRect(r, color.getQColor());
            
            if (i == m_selectedLightPiece)
                painter.drawRect(r);
        }
    }
    else {
        int size = isVertical ? rect.height() : rect.width();
        painter.setRenderHint(QPainter::Antialiasing, false);
        
        if (isVertical) {
            for(int i=0; i<size; ++i) {
                int   y     = rect.y() + i;
                float light = 1.0f - (float(i) / float(size-1));
                color.setX(getLight(light, color.getH(), m_relativeLight));
                painter.setPen(color.getQColor());
                painter.drawLine(rect.left(), y, rect.right(), y);
            }
        }
        else {
            for(int i=0; i<size; ++i) {
                int   x     = rect.x() + i;
                float light = 1.0f - (float(i) / float(size-1));
                color.setX(getLight(light, color.getH(), m_relativeLight));
                painter.setPen(color.getQColor());
                painter.drawLine(x, rect.top(), x, rect.bottom());
            }
        }
        
        painter.setRenderHint(QPainter::Antialiasing, true);
        painter.setPen(QPen(QBrush(Qt::red), penSize));
        float t = 1.0f - m_light;
        
        if (isVertical) {
            int y = rect.y() + int(size * t);
            painter.drawLine(rect.left(), y, rect.right(), y);
        }
        else {
            int x = rect.x() + int(size * t);
            painter.drawLine(x, rect.top(), x, rect.bottom());
        }
    }
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:69,代码来源:kis_color_selector.cpp

示例14: scaleFromPerspectiveMatrix

qreal KisTransformUtils::scaleFromPerspectiveMatrix(const QTransform &t, const QPointF &basePt) {
    const QRectF testRect(basePt, QSizeF(1.0, 1.0));
    QRectF resultRect = t.mapRect(testRect);

    return 0.5 * (resultRect.width(), resultRect.height());
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:6,代码来源:kis_transform_utils.cpp

示例15: painter

void KMultiTabBarTab::paintEvent(QPaintEvent*) {
	QPainter painter(this);

	QStyleOptionToolButton opt;
	initStyleOption(&opt);

	// Paint bevel..
	if (underMouse() || isChecked()) {
		opt.text.clear();
		opt.icon = QIcon();
		style()->drawComplexControl(QStyle::CC_ToolButton, &opt, &painter, this);
	}

	int hMargin, vMargin;
	computeMargins(&hMargin, &vMargin);

	// We first figure out how much room we have for the text, based on
	// icon size and margin, try to fit in by eliding, and perhaps
	// give up on drawing the text entirely if we're too short on room
	QPixmap icon = iconPixmap();
	int textRoom = 0;
	int iconRoom = 0;

	QString t;
	if (shouldDrawText()) {
		if (isVertical()) {
			iconRoom = icon.height() + 2*vMargin;
			textRoom = height() - iconRoom - vMargin;
		} else {
			iconRoom = icon.width() + 2*hMargin;
			textRoom = width() - iconRoom - hMargin;
		}

		t = painter.fontMetrics().elidedText(text(), Qt::ElideRight, textRoom);

		// See whether anything is left. Qt will return either
		// ... or the ellipsis unicode character, 0x2026
		if (t == QLatin1String("...") || t == QChar(0x2026))
			t.clear();
	}

	// Label time.... Simple case: no text, so just plop down the icon right in the center
	// We only do this when the button never draws the text, to avoid jumps in icon position
	// when resizing
 	if (!shouldDrawText()) {
 		style()->drawItemPixmap(&painter, rect(), Qt::AlignCenter | Qt::AlignVCenter, icon);
 		return;
 	}

	// Now where the icon/text goes depends on text direction and tab position
	QRect iconArea;
	QRect labelArea;

	bool bottomIcon = false;
	bool rtl = layoutDirection() == Qt::RightToLeft;
	if (isVertical()) {
		if (m_position == KMultiTabBar::Left && !rtl)
			bottomIcon = true;
		if (m_position == KMultiTabBar::Right && rtl)
			bottomIcon = true;
	}
	//alignFlags = Qt::AlignLeading | Qt::AlignVCenter;

	if (isVertical()) {
		if (bottomIcon) {
			labelArea = QRect(0, vMargin, width(), textRoom);
			iconArea  = QRect(0, vMargin + textRoom, width(), iconRoom);
		} else {
			labelArea = QRect(0, iconRoom, width(), textRoom);
			iconArea  = QRect(0, 0, width(), iconRoom);
		}
	} else {
		// Pretty simple --- depends only on RTL/LTR
		if (rtl) {
			labelArea = QRect(hMargin, 0, textRoom, height());
			iconArea  = QRect(hMargin + textRoom, 0, iconRoom, height());
		} else {
			labelArea = QRect(iconRoom, 0, textRoom, height());
			iconArea  = QRect(0, 0, iconRoom, height());
		}
	}

	style()->drawItemPixmap(&painter, iconArea, Qt::AlignCenter | Qt::AlignVCenter, icon);

	if (t.isEmpty())
		return;

	QRect labelPaintArea = labelArea;

	if (isVertical()) {
		// If we're vertical, we paint to a simple 0,0 origin rect,
		// and get the transformations to get us in the right place
		labelPaintArea = QRect(0, 0, labelArea.height(), labelArea.width());

		QTransform tr;

		if (bottomIcon) {
			tr.translate(labelArea.x(), labelPaintArea.width() + labelArea.y());
			tr.rotate(-90);
		} else {
//.........这里部分代码省略.........
开发者ID:fluxer,项目名称:kdelibs,代码行数:101,代码来源:kmultitabbar.cpp


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