本文整理汇总了C++中QTransform::rotateRadians方法的典型用法代码示例。如果您正苦于以下问题:C++ QTransform::rotateRadians方法的具体用法?C++ QTransform::rotateRadians怎么用?C++ QTransform::rotateRadians使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTransform
的用法示例。
在下文中一共展示了QTransform::rotateRadians方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rysuj_mape
void Plansza::rysuj_mape(QPainter& painter, QRect rect) {
double margines = sqrt(pow(this->czolg.rozmiar.width(), 2) + pow(this->czolg.rozmiar.height(), 2));
if(this->czolg.pozycja.x() < this->widok.x() + margines)
this->widok.setX(this->czolg.pozycja.x() - margines);
else if(this->czolg.pozycja.x() > this->widok.x() + rect.width() - margines)
this->widok.setX(this->czolg.pozycja.x() - rect.width() + margines);
if(this->czolg.pozycja.y() < this->widok.y() + margines)
this->widok.setY(this->czolg.pozycja.y() - margines);
else if(this->czolg.pozycja.y() > this->widok.y() + rect.height() - margines)
this->widok.setY(this->czolg.pozycja.y() - rect.height() + margines);
int start;
painter.setPen(0x004040);
if(this->widok.x() > 0)
start = this->widok.x() % 50 > 0 ? 50 - this->widok.x() % 50 : 0;
else
start = -this->widok.x() % 50;
for(int i = 0; start + i * 50 < rect.width(); i++)
painter.drawLine(rect.topLeft() + QPoint(start + i * 50, 0), rect.topLeft() + QPoint(start + i * 50, rect.height() - 1));
if(this->widok.y() > 0)
start = this->widok.y() % 50 > 0 ? 50 - this->widok.y() % 50 : 0;
else
start = -this->widok.y() % 50;
for(int i = 0; start + i * 50 < rect.height(); i++)
painter.drawLine(rect.topLeft() + QPoint(0, start + i * 50), rect.topLeft() + QPoint(rect.width() - 1, start + i * 50));
painter.setPen(0xFF0000);
for(int i = 0; i < this->ilosc_odcinkow; i++)
painter.drawLine(this->odcinki[i].translated(rect.topLeft() - this->widok));
QTransform t;
t.rotateRadians(M_PI_2 - this->czolg.kierunek);
QPixmap korpus = this->czolg.korpus.transformed(t);
painter.drawPixmap(rect.topLeft() + this->czolg.pozycja - this->widok - QPoint(korpus.width() / 2, korpus.height() / 2), korpus);
t.rotateRadians(-this->czolg.kierunek_wiezy);
QPixmap wieza = this->czolg.wieza.transformed(t);
QPointF przesuniecie_osi_wiezy_dla_korpusu(this->czolg.przesuniecie_osi_wiezy_dla_korpusu * -cos(this->czolg.kierunek), this->czolg.przesuniecie_osi_wiezy_dla_korpusu * sin(this->czolg.kierunek));
QPointF przesuniecie_osi_wiezy_dla_wiezy(this->czolg.przesuniecie_osi_wiezy_dla_wiezy * cos(this->czolg.kierunek + this->czolg.kierunek_wiezy), this->czolg.przesuniecie_osi_wiezy_dla_wiezy * -sin(this->czolg.kierunek + this->czolg.kierunek_wiezy));
painter.drawPixmap(rect.topLeft() - this->widok + this->czolg.pozycja + przesuniecie_osi_wiezy_dla_korpusu + przesuniecie_osi_wiezy_dla_wiezy - QPoint(wieza.width() / 2, wieza.height() / 2), wieza);
if(this->strzal) {
this->pociski << Pocisk(this->czolg.pozycja + przesuniecie_osi_wiezy_dla_korpusu + przesuniecie_osi_wiezy_dla_wiezy + QPointF(this->czolg.wieza.height() * cos(this->czolg.kierunek + this->czolg.kierunek_wiezy) / 2, this->czolg.wieza.height() * -sin(this->czolg.kierunek + this->czolg.kierunek_wiezy) / 2), QVector2D(cos(this->czolg.kierunek + this->czolg.kierunek_wiezy), -sin(this->czolg.kierunek + this->czolg.kierunek_wiezy)), 500);
this->strzal = false;
}
painter.setBrush(QColor(Qt::white));
for(int i = 0; i < this->pociski.size(); i++) {
this->pociski[i].pozycja += this->pociski[i].kierunek.toPointF() * this->pociski[i].predkosc * 0.02;
painter.drawEllipse(rect.topLeft() - this->widok + this->pociski[i].pozycja.toPoint(), 3, 3);
}
if(this->o.width() > 0) {
painter.setPen(0x000080);
painter.setBrush(QBrush(QColor(0, 0, 255, 32)));
this->o.moveTopLeft(this->o.topLeft() + rect.topLeft() - this->widok);
painter.drawEllipse(this->o);
}
}
示例2: brushOutline
QPainterPath KisLiquifyPaintop::brushOutline(const KisLiquifyProperties &props,
const KisPaintInformation &info)
{
const qreal diameter = props.size();
const qreal reverseCoeff = props.reverseDirection() ? -1.0 : 1.0;
QPainterPath outline;
outline.addEllipse(-0.5 * diameter, -0.5 * diameter,
diameter, diameter);
switch (props.mode()) {
case KisLiquifyProperties::MOVE:
case KisLiquifyProperties::SCALE:
break;
case KisLiquifyProperties::ROTATE: {
QPainterPath p;
p.lineTo(-3.0, 4.0);
p.moveTo(0.0, 0.0);
p.lineTo(-3.0, -4.0);
QTransform S;
if (diameter < 15.0) {
const qreal scale = diameter / 15.0;
S = QTransform::fromScale(scale, scale);
}
QTransform R;
R.rotateRadians(-reverseCoeff * 0.5 * M_PI);
QTransform T = QTransform::fromTranslate(0.5 * diameter, 0.0);
p = (S * R * T).map(p);
outline.addPath(p);
break;
}
case KisLiquifyProperties::OFFSET: {
qreal normalAngle = info.drawingAngle() + reverseCoeff * 0.5 * M_PI;
QPainterPath p = KisAlgebra2D::smallArrow();
const qreal offset = qMax(0.8 * diameter, 15.0);
QTransform R;
R.rotateRadians(normalAngle);
QTransform T = QTransform::fromTranslate(offset, 0.0);
p = (T * R).map(p);
outline.addPath(p);
break;
}
case KisLiquifyProperties::UNDO:
break;
case KisLiquifyProperties::N_MODES:
qFatal("Not supported mode");
}
return outline;
}
示例3: addChild
void AbstractGroupPrivate::addChild(QGraphicsWidget *child)
{
QPointF newPos = q->mapFromItem(child->parentItem(), child->pos());
if (groupType == AbstractGroup::ConstrainedGroup) {
child->setTransform(QTransform());
} else {
QTransform t(child->itemTransform(q));
if (t.m11() != 0) {
qreal angle = (t.m12() > 0 ? acos(t.m11()) : -acos(t.m11()));
QTransform at;
QSizeF size(child->size());
at.translate(size.width() / 2, size.height() / 2);
at.rotateRadians(angle);
at.translate(-size.width() / 2, -size.height() / 2);
child->setTransform(at);
newPos -= QPointF(at.dx(), at.dy());
}
}
child->setParentItem(q);
child->setProperty("group", QVariant::fromValue(q));
child->setPos(newPos);
if (groupType == AbstractGroup::FreeGroup) {
q->connect(child, SIGNAL(geometryChanged()), q, SLOT(onChildGeometryChanged()));
}
}
示例4: testSafeTransformSingleVanishingPoint
void KisTransformMaskTest::testSafeTransformSingleVanishingPoint()
{
// rotation around 0X has a single vanishing point for 0Y axis
QTransform transform(1, 0, 0,
-0.870208, -0.414416, -0.000955222,
132.386, 1082.91, 1.99439);
QTransform R; R.rotateRadians(M_PI / 4.0);
//transform *= R;
QRectF testRect(1536, 1024, 512, 512);
KisSafeTransform t2(transform, QRect(0, 0, 2048, 2048), testRect.toRect());
QPolygonF fwdPoly = t2.mapForward(testRect);
QRectF fwdRect = t2.mapRectForward(testRect);
QPolygonF bwdPoly = t2.mapBackward(fwdPoly);
QRectF bwdRect = t2.mapRectBackward(fwdRect);
/**
* A special weird rect that crosses the vanishing point,
* which is (911.001, 433.84) in this case
*/
QRectF fwdNastyRect(800, 100, 400, 600);
//QRectF fwdNastyRect(100, 400, 1000, 800);
QRectF bwdNastyRect = t2.mapRectBackward(fwdNastyRect);
/*
dbgKrita << ppVar(testRect);
dbgKrita << ppVar(fwdPoly);
dbgKrita << ppVar(fwdRect);
dbgKrita << ppVar(bwdPoly);
dbgKrita << ppVar(bwdRect);
dbgKrita << ppVar(bwdNastyRect);
*/
QPolygon ref;
ref.clear();
ref << QPoint(765,648);
ref << QPoint(1269, 648);
ref << QPoint(1601, 847);
ref << QPoint(629, 847);
ref << QPoint(765, 648);
QCOMPARE(fwdPoly.toPolygon(), ref);
QCOMPARE(fwdRect.toRect(), QRect(629,648,971,199));
ref.clear();
ref << QPoint(1536,1024);
ref << QPoint(2048,1024);
ref << QPoint(2048,1536);
ref << QPoint(1536,1536);
ref << QPoint(1536,1024);
QCOMPARE(bwdPoly.toPolygon(), ref);
QCOMPARE(bwdRect.toRect(), QRect(1398,1024,650,512));
QCOMPARE(bwdNastyRect.toRect(), QRect(1463,0,585,1232));
}
示例5: layout
void HairpinSegment::layout()
{
QTransform t;
qreal _spatium = spatium();
qreal h1 = score()->styleS(ST_hairpinHeight).val() * _spatium * .5;
qreal h2 = score()->styleS(ST_hairpinContHeight).val() * _spatium * .5;
rypos() = 0.0;
qreal len;
qreal x = pos2().x();
if (x < _spatium) // minimum size of hairpin
x = _spatium;
qreal y = pos2().y();
len = sqrt(x * x + y * y);
t.rotateRadians(asin(y/len));
if (hairpin()->hairpinType() == 0) {
// crescendo
switch (spannerSegmentType()) {
case SEGMENT_SINGLE:
case SEGMENT_BEGIN:
l1.setLine(.0, .0, len, h1);
l2.setLine(.0, .0, len, - h1);
break;
case SEGMENT_MIDDLE:
case SEGMENT_END:
l1.setLine(.0, h2, len, h1);
l2.setLine(.0, -h2, len, - h1);
break;
}
}
else {
// decrescendo
switch(spannerSegmentType()) {
case SEGMENT_SINGLE:
case SEGMENT_END:
l1.setLine(.0, h1, len, 0.0);
l2.setLine(.0, -h1, len, 0.0);
break;
case SEGMENT_BEGIN:
case SEGMENT_MIDDLE:
l1.setLine(.0, h1, len, + h2);
l2.setLine(.0, -h1, len, - h2);
break;
}
}
l1 = t.map(l1);
l2 = t.map(l2);
QRectF r = QRectF(l1.p1(), l1.p2()).normalized() | QRectF(l2.p1(), l2.p2()).normalized();
qreal w = point(score()->styleS(ST_hairpinWidth));
setbbox(r.adjusted(-w*.5, -w*.5, w, w));
if (parent())
rypos() += score()->styleS(ST_hairpinY).val() * _spatium;
adjustReadPos();
}
示例6: paintRectangle
void SprayBrush::paintRectangle(KisPainter* painter, qreal x, qreal y, qreal width, qreal height, qreal angle)
{
QPainterPath path;
path.addRect(QRectF(-0.5 * width, -0.5 * height, width, height));
QTransform t;
t.translate(x, y);
t.rotateRadians(angle);
path = t.map(path);
painter->fillPainterPath(path);
}
示例7: paintEllipse
void SprayBrush::paintEllipse(KisPainter* painter, qreal x, qreal y, qreal a, qreal b, qreal angle)
{
QPainterPath path;
path.addEllipse(QPointF(), a, b);
QTransform t;
t.translate(x, y);
t.rotateRadians(angle);
path = t.map(path);
painter->fillPainterPath(path);
}
示例8: DrawShip
void TWorldDisplay::DrawShip(QPainter& painter, const NSpace::TShip& ship) {
int x = ship.X * World->Scale + World->OffsetX;
int y = ship.Y * World->Scale + World->OffsetY;
QColor shipColor = GetQColor(World->IdToPlayer[ship.PlayerID]->Color);
QImage shipImage = GraphicManager.GetShip(World->Scale, shipColor);
QTransform transform;
transform.rotateRadians(float(ship.Angle) / 100.0 + M_PI_2);
shipImage = shipImage.transformed(transform);
painter.drawImage(x - shipImage.width() / 2, y - shipImage.height() / 2, shipImage);
}
示例9:
void
dmz::QtPluginCanvasObject::ObjectStruct::update () {
if (item) {
QTransform trans;
trans.translate (posX, posY);
trans.rotateRadians (heading);
if (scaleX && scaleY) { trans.scale (scaleX, scaleY); }
item->setTransform (trans);
}
}
示例10: Tekstura
Pocisk::Pocisk(const SpecyfikacjaPocisku* specyfikacja, bool pociskGracza, QPointF punktStartowy, QVector2D wektorKierunku, float dystansCalkowity):
Obiekt(punktStartowy),
specyfikacja(specyfikacja),
status(true),
pociskGracza(pociskGracza),
punktStartowy(punktStartowy),
wektorKierunku(wektorKierunku),
dystansCalkowity(dystansCalkowity),
dystansAktualny(0.0),
czasMilisekundy(0){
QTransform transformacja;
transformacja.rotateRadians(M_PI_2 + atan2(this->wektorKierunku.y(), this->wektorKierunku.x()));
this->tekstura = new Tekstura(this->specyfikacja->tekstura.teksturaOryginalna.transformed(transformacja));
}
示例11: brushOutline
QPainterPath KisPaintOpSettings::brushOutline(const QPointF& pos, OutlineMode mode, qreal scale, qreal rotation) const
{
QPainterPath path;
if (mode == CursorIsOutline){
QRectF rc(-5,-5, 10, 10);
path.moveTo(rc.topLeft());
path.lineTo(rc.bottomRight());
path.moveTo(rc.topRight());
path.lineTo(rc.bottomLeft());
QTransform m;
m.reset(); m.scale(scale,scale); m.rotateRadians(rotation);
path = m.map(path);
path.translate(pos);
}
return path;
}
示例12: getTransform
void DkRotatingRect::getTransform(QTransform& tForm, QPointF& size) const {
if (rect.size() < 4)
return;
// default upper left corner is 0
DkVector xV = DkVector(rect[3] - rect[0]).round();
DkVector yV = DkVector(rect[1] - rect[0]).round();
QPointF ul = QPointF(qRound(rect[0].x()), qRound(rect[0].y()));
size = QPointF(xV.norm(), yV.norm());
qDebug() << xV.toQPointF();
qDebug() << "size: " << size;
double angle = xV.angle();
angle = DkMath::normAngleRad(angle, -CV_PI, CV_PI);
if (std::abs(angle) > DBL_EPSILON)
qDebug() << "angle is > eps...";
// switch width/height for /\ and \/ quadrants
if (std::abs(angle) > CV_PI*0.25 && std::abs(angle) < CV_PI*0.75) {
float x = (float)size.x();
size.setX(size.y());
size.setY(x);
}
// invariance -> user does not want to make a difference between an upside down rect
if (angle > CV_PI*0.25 && angle < CV_PI*0.75) {
angle -= CV_PI*0.5;
ul = rect[1];
}
else if (angle > -CV_PI*0.75 && angle < -CV_PI*0.25) {
angle += CV_PI*0.5;
ul = rect[3];
}
else if (angle >= CV_PI*0.75 || angle <= -CV_PI*0.75) {
angle += CV_PI;
ul = rect[2];
}
tForm.rotateRadians(-angle);
tForm.translate(qRound(-ul.x()), qRound(-ul.y())); // round guarantees that pixels are not interpolated
}
示例13: rotate
void Selection::rotate(float angle)
{
if(qAbs(angle) < 0.0001)
return;
const QPointF origin = m_shape.boundingRect().center();
QTransform t;
t.translate(origin.x(), origin.y());
t.rotateRadians(angle);
for(int i=0; i<m_shape.size(); ++i) {
QPointF p = m_shape[i] - origin;
m_shape[i] = t.map(p);
}
emit shapeChanged(m_shape);
}
示例14: render
// ============================================================================
// Renders AA battery
void AntiAirBattery::render ( QPainter& painter, const QRectF& rect, const RenderingOptions& options )
{
Machine::render( painter, rect, options );
QTransform t = _bodyMain->transform();
// get angle
double currentAngle = _sysOperator->currentAngle();
double lastSign = _lastDisplayedAngle > 0 ? 1 : -1;
// limit angle to min/max
if ( fabs( currentAngle ) < _sysOperator->minAngle() )
{
currentAngle = _sysOperator->minAngle() * lastSign; // don't change sign while outside range
}
if ( fabs( currentAngle ) > _sysOperator->maxAngle() )
{
currentAngle = _sysOperator->maxAngle() * lastSign;
}
// check if sign changed
if ( ( lastSign * currentAngle) < 0 )
{
double x = _bodyMain->position().x;
_bodyMain->flip( QPointF( x, 1 ), QPointF( x, -1 ) ); // flip around vertical axis
}
_lastDisplayedAngle = currentAngle;
double sign = currentAngle > 0 ? 1 : -1;
// calculate screen angle
double screenAngle = M_PI/2 - currentAngle;
painter.save();
QImage barrel = TextureProvider::loadTexture("installations/flak1-barrel.png").image(Texture::Normal);
QPointF textureAxis = QPointF( 13, 8 ); // axis in texture coords
double scale = 0.05; // TODO this has to go with texture somehow
t.rotateRadians( screenAngle );
t.scale( scale * sign, -scale * sign );
t.translate( -textureAxis.x(), -textureAxis.y() );
painter.setTransform( t, true );
painter.drawImage( 0, 0, barrel );
painter.restore();
}
示例15: repos
void LinkBox::repos()
{
int x1m = m1->x();
int y1m = m1->y();
int x2m = m2->x();
int y2m = m2->y();
float dx = float(x2m - x1m);
float dy = float(y2m - y1m);
float dd = sqrt(dx * dx + dy * dy);
float xx = x1m + dx / 2;
float yy = y1m + dy / 2;
float rad;
if (dx != 0) {
rad = atan(dy / dx);
} else {
rad = atan(dy / 0.00001);
}
if (dx < 0) {
if (dx > 0) {
rad += 3.14;
} else {
rad -= 3.14;
}
}
QTransform *transform = new QTransform();
transform->translate(xx, yy);
transform->rotateRadians(rad);
setTransform(*transform);
QPainterPath *path = new QPainterPath();
path->moveTo(10, 0);
path->lineTo(dd / 2, 0);
path->moveTo(-5, 0);
path->lineTo(-dd / 2, 0);
path->addPath(basePath);
setPath(*path);
}