本文整理汇总了C++中QWMatrix::rotate方法的典型用法代码示例。如果您正苦于以下问题:C++ QWMatrix::rotate方法的具体用法?C++ QWMatrix::rotate怎么用?C++ QWMatrix::rotate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWMatrix
的用法示例。
在下文中一共展示了QWMatrix::rotate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rotate
void rotate()
{
int i;
const int w = 64;
const int h = 64;
QImage image( w, h, 8, 128 ); // create image
for ( i=0; i<128; i++ ) // build color table
image.setColor( i, qRgb(i,0,0) );
for ( int y=0; y<h; y++ ) { // set image pixels
uchar *p = image.scanLine(y);
for ( int x=0; x<w; x++ )
*p++ = (x+y)%128;
}
QPixmap pm;
pm = image; // convert image to pixmap
pm.optimize( TRUE ); // rotation will be faster
QWidget *d = QApplication::desktop(); // w = desktop widget
for ( i=0; i<=360; i += 2 ) {
QWMatrix m;
m.rotate( i ); // rotate coordinate system
QPixmap rpm = pm.xForm( m ); // rpm = rotated pixmap
d->setBackgroundPixmap( rpm ); // set desktop pixmap
d->update(); // repaint desktop
}
}
示例2: applyTransformations
void ImageLabel::applyTransformations(bool useSmoothScale)
{
pixmap = realpixmap;
if (doRotate)
{
// KDE and QT seem to miss a high quality image rotation
QWMatrix rotMat;
rotMat.rotate(rot_angle);
pixmap = pixmap.xForm(rotMat);
}
if (doScale)
{
if (m_karamba -> useSmoothTransforms() || useSmoothScale)
{
pixmap.convertFromImage(
pixmap.convertToImage().smoothScale(scale_w, scale_h));
}
else
{
double widthFactor = ((double)scale_w) / ((double)pixmap.width());
double heightFactor = ((double)scale_h) / ((double)pixmap.height());
QWMatrix scaleMat;
scaleMat.scale(widthFactor, heightFactor);
pixmap = pixmap.xForm(scaleMat);
}
}
if (imageEffect != 0)
{
pixmap = imageEffect -> apply(pixmap);
}
setWidth(pixmap.width());
setHeight(pixmap.height());
}
示例3: drawColorWheel
void drawColorWheel( QPainter *p )
{
QFont f( "times", 18, QFont::Bold );
p->setFont( f );
p->setPen( Qt::black );
p->setWindow( 0, 0, 500, 500 ); // defines coordinate system
for ( int i=0; i<36; i++ ) { // draws 36 rotated rectangles
QWMatrix matrix;
matrix.translate( 250.0F, 250.0F ); // move to center
matrix.shear( 0.0F, 0.3F ); // twist it
matrix.rotate( (float)i*10 ); // rotate 0,10,20,.. degrees
p->setWorldMatrix( matrix ); // use this world matrix
QColor c;
c.setHsv( i*10, 255, 255 ); // rainbow effect
p->setBrush( c ); // solid fill with color c
p->drawRect( 70, -10, 80, 10 ); // draw the rectangle
QString n;
n.sprintf( "H=%d", i*10 );
p->drawText( 80+70+5, 0, n ); // draw the hue number
}
}
示例4: slotUpdateResizeHandles
void MechanicsItemOverlay::slotUpdateResizeHandles()
{
const PositionInfo absPos = p_mechanicsItem->absolutePosition();
const QRect sizeRect = p_mechanicsItem->sizeRect();
QPointArray pa(9);
pa[0] = sizeRect.topLeft();
pa[2] = sizeRect.topRight();
pa[1] = (pa[0]+pa[2])/2;
pa[4] = sizeRect.bottomRight();
pa[3] = (pa[2]+pa[4])/2;
pa[6] = sizeRect.bottomLeft();
pa[5] = (pa[4]+pa[6])/2;
pa[7] = (pa[6]+pa[0])/2;
pa[8] = QPoint(0,0);
QWMatrix m;
m.rotate(absPos.angle() * DPR);
pa = m.map(pa);
m_tl->move( absPos.x()+pa[0].x(), absPos.y()+pa[0].y() );
m_tm->move( absPos.x()+pa[1].x(), absPos.y()+pa[1].y() );
m_tr->move( absPos.x()+pa[2].x(), absPos.y()+pa[2].y() );
m_mr->move( absPos.x()+pa[3].x(), absPos.y()+pa[3].y() );
m_br->move( absPos.x()+pa[4].x(), absPos.y()+pa[4].y() );
m_bm->move( absPos.x()+pa[5].x(), absPos.y()+pa[5].y() );
m_bl->move( absPos.x()+pa[6].x(), absPos.y()+pa[6].y() );
m_ml->move( absPos.x()+pa[7].x(), absPos.y()+pa[7].y() );
m_mm->move( absPos.x()+pa[8].x(), absPos.y()+pa[8].y() );
}
示例5: drawShape
void ArrowLine::drawShape(QPainter &p)
{
p.setPen(darkGray);
QCanvasLine::drawShape(p);
double angle = computeAngle(startPoint().x(),
startPoint().y(),
endPoint().x(),
endPoint().y());
QPointArray pts(3);
QWMatrix m;
int x, y;
m.rotate(angle);
m.map(-5, -2, &x, &y);
pts.setPoint(0, x, y);
m.map(-5, 2, &x, &y);
pts.setPoint(1, x, y);
m.map(0, 0, &x, &y);
pts.setPoint(2, x, y);
pts.translate(endPoint().x(), endPoint().y());
p.setBrush(QColor(darkGray));
p.drawPolygon(pts);
}
示例6: initPoints
void Node::initPoints() {
// Bounding rectangle, facing right
QPointArray pa(QRect(0, -8, m_length, 16));
QWMatrix m;
m.rotate(m_dir);
pa = m.map(pa);
setPoints(pa);
}
示例7: initPoints
void PinNode::initPoints()
{
int l = - m_length;
// Bounding rectangle, facing right
Q3PointArray pa( QRect( 0, -8, l, 16 ) );
QWMatrix m;
m.rotate( m_dir );
pa = m.map(pa);
setPoints(pa);
}
示例8: setIcon
void KMultiTabBarTab::setIcon(const QPixmap& icon)
{
if ((m_position==KMultiTabBar::Left) || (m_position==KMultiTabBar::Right)) {
QWMatrix rotateMatrix;
if (m_position==KMultiTabBar::Left)
rotateMatrix.rotate(90);
else
rotateMatrix.rotate(-90);
QPixmap pic=icon.xForm(rotateMatrix);
#if 0
if(m_position==KMultiTabBar::Left) {
QWMatrix flipMatrix;
flipMatrix.setMatrix(1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F);
pic=pic.xForm(flipMatrix);
}
#endif
d->pix=pic;
setIconSet(pic);
} else setIconSet(icon);
}
示例9: setTabsPosition
void KMultiTabBarTab::setTabsPosition(KMultiTabBar::KMultiTabBarPosition pos)
{
if ((pos!=m_position) && ((pos==KMultiTabBar::Left) || (pos==KMultiTabBar::Right))) {
if (!d->pix.isNull()) {
QWMatrix temp;// (1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F);
temp.rotate(180);
d->pix=d->pix.xForm(temp);
setIconSet(d->pix);
}
}
setPosition(pos);
// repaint();
}
示例10: paintEvent
void AnalogClock::paintEvent( QPaintEvent * ) // paint clock
{
if ( !isVisible() ) // is is invisible
return;
time = QTime::currentTime(); // save current time
QPointArray pts;
QPainter paint( this );
paint.setBrush( foregroundColor() ); // fill with foreground color
QPoint cp = rect().center(); // widget center point
int d = QMIN(width(),height()); // we want a circular clock
QWMatrix matrix; // setup transformation matrix
matrix.translate( cp.x(), cp.y() ); // origin at widget center
matrix.scale( d/1000.0F, d/1000.0F ); // scale coordinate system
float h_angle = 30*(time.hour()%12-3) + time.minute()/2;
matrix.rotate( h_angle ); // rotate to draw hour hand
paint.setWorldMatrix( matrix );
pts.setPoints( 4, -20,0, 0,-20, 300,0, 0,20 );
paint.drawPolygon( pts ); // draw hour hand
matrix.rotate( -h_angle ); // rotate back to zero
float m_angle = (time.minute()-15)*6;
matrix.rotate( m_angle ); // rotate to draw minute hand
paint.setWorldMatrix( matrix );
pts.setPoints( 4, -10,0, 0,-10, 400,0, 0,10 );
paint.drawPolygon( pts ); // draw minute hand
matrix.rotate( -m_angle ); // rotate back to zero
for ( int i=0; i<12; i++ ) { // draw hour lines
paint.setWorldMatrix( matrix );
paint.drawLine( 450,0, 500,0 );
matrix.rotate( 30 );
}
}
示例11: drawRect
QRect GuiPart::drawRect()
{
QRect dr = rect();
if ( m_angleDegrees%180 != 0 )
{
QWMatrix m;
m.translate( int(x()+(width()/2)), int(y()+(height()/2)) );
if ( (m_angleDegrees%180) != 0 )
m.rotate(-m_angleDegrees);
m.translate( -int(x()+(width()/2)), -int(y()+(height()/2)) );
dr = m.mapRect(dr);
}
return dr;
}
示例12: readPixmapStdout
void FLCodBar::readPixmapStdout() {
if ( writingStdout ) {
qApp->processEvents();
return ;
}
p.loadFromData( proc->readStdout(), "PNG" );
if ( !p.isNull() ) {
QWMatrix m;
m.rotate(( double ) barcode.rotation );
p.xForm( m );
barcode.valid = true;
}
readingStdout = false;
}
示例13: drawPathText
void drawPathText( QPainter *p )
{
QPointArray a( 4 );
a.setPoint( 0, 100,200 );
a.setPoint( 1, 150,75 );
a.setPoint( 2, 250,75 );
a.setPoint( 3, 300,200 );
a = a.quadBezier(); // calculate Bezier curve
p->setPen( lightGray ); // set light gray pen
p->drawPolyline( a ); // draw Bezier point array
p->setFont( QFont("Times",24) ); // set fast font
p->setPen( black ); // set black pen
const char *text = "Troll Tech AS";
int len = strlen(text);
if ( len == 0 )
return;
int ipos = a.size()/len;
int cpos = ipos;
for ( int i=0; i<len; i++ ) { // for each char in text...
QPoint p1 = a.point( cpos-1 );
QPoint p2 = a.point( cpos+1 );
QPoint pt = a.point(cpos);
float dx = (float)(p2.x() - p1.x());
float dy = (float)(p2.y() - p1.y());
float angle = (float)atan(dy/dx); // way too simple
angle *= 180.0F/3.14F;
QWMatrix m; // setup world matrix
m.translate( (float)pt.x(), (float)pt.y() );
m.rotate( angle );
p->setWorldMatrix( m );
p->drawText( 0,0, &text[i], 1 );
cpos += ipos;
}
}
示例14: painter
void ZLQtViewWidget::ZLQtViewWidgetInternal::paintEvent(QPaintEvent*) {
const int w = width();
const int h = height() + myHolder.myApplicationWindow.verticalAdjustment();
switch (myHolder.rotation()) {
default:
((ZLQtPaintContext&)myHolder.view()->context()).setSize(w, h);
break;
case DEGREES90:
case DEGREES270:
((ZLQtPaintContext&)myHolder.view()->context()).setSize(h, w);
break;
}
myHolder.view()->paint();
int angle = 0;
switch (myHolder.rotation()) {
default:
break;
case DEGREES90:
angle = 270;
break;
case DEGREES180:
angle = 180;
break;
case DEGREES270:
angle = 90;
break;
}
const QPixmap &pixmap = ((ZLQtPaintContext&)myHolder.view()->context()).pixmap();
QPainter painter(this);
if (angle == 0) {
painter.drawPixmap(0, 0, pixmap);
} else {
QWMatrix matrix;
matrix.rotate(angle);
painter.drawPixmap(0, 0, pixmap.xForm(matrix));
}
}
示例15: qDrawMotifArrow
// motif arrows look the same whether they are used or not
// is this correct?
static void qDrawMotifArrow( QPainter *p, Qt::ArrowType type, bool down,
int x, int y, int w, int h,
const QColorGroup &g, bool )
{
QPointArray bFill; // fill polygon
QPointArray bTop; // top shadow.
QPointArray bBot; // bottom shadow.
QPointArray bLeft; // left shadow.
#ifndef QT_NO_TRANSFORMATIONS
QWMatrix matrix; // xform matrix
#endif
bool vertical = type == Qt::UpArrow || type == Qt::DownArrow;
bool horizontal = !vertical;
int dim = w < h ? w : h;
int colspec = 0x0000; // color specification array
if ( dim < 2 ) // too small arrow
return;
if ( dim > 3 ) {
if ( dim > 6 )
bFill.resize( dim & 1 ? 3 : 4 );
bTop.resize( (dim/2)*2 );
bBot.resize( dim & 1 ? dim + 1 : dim );
bLeft.resize( dim > 4 ? 4 : 2 );
bLeft.putPoints( 0, 2, 0,0, 0,dim-1 );
if ( dim > 4 )
bLeft.putPoints( 2, 2, 1,2, 1,dim-3 );
bTop.putPoints( 0, 4, 1,0, 1,1, 2,1, 3,1 );
bBot.putPoints( 0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2 );
for( int i=0; i<dim/2-2 ; i++ ) {
bTop.putPoints( i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i );
bBot.putPoints( i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i );
}
if ( dim & 1 ) // odd number size: extra line
bBot.putPoints( dim-1, 2, dim-3,dim/2, dim-1,dim/2 );
if ( dim > 6 ) { // dim>6: must fill interior
bFill.putPoints( 0, 2, 1,dim-3, 1,2 );
if ( dim & 1 ) // if size is an odd number
bFill.setPoint( 2, dim - 3, dim / 2 );
else
bFill.putPoints( 2, 2, dim-4,dim/2-1, dim-4,dim/2 );
}
}
else {
if ( dim == 3 ) { // 3x3 arrow pattern
bLeft.setPoints( 4, 0,0, 0,2, 1,1, 1,1 );
bTop .setPoints( 2, 1,0, 1,0 );
bBot .setPoints( 2, 1,2, 2,1 );
}
else { // 2x2 arrow pattern
bLeft.setPoints( 2, 0,0, 0,1 );
bTop .setPoints( 2, 1,0, 1,0 );
bBot .setPoints( 2, 1,1, 1,1 );
}
}
if ( type == Qt::UpArrow || type == Qt::LeftArrow ) {
#ifndef QT_NO_TRANSFORMATIONS // #### fix me!
matrix.translate( x, y );
if ( vertical ) {
matrix.translate( 0, h - 1 );
matrix.rotate( -90 );
} else {
matrix.translate( w - 1, h - 1 );
matrix.rotate( 180 );
}
#endif
if ( down )
colspec = horizontal ? 0x2334 : 0x2343;
else
colspec = horizontal ? 0x1443 : 0x1434;
}
else if ( type == Qt::DownArrow || type == Qt::RightArrow ) {
#ifndef QT_NO_TRANSFORMATIONS // #### fix me!
matrix.translate( x, y );
if ( vertical ) {
matrix.translate( w-1, 0 );
matrix.rotate( 90 );
}
#endif
if ( down )
colspec = horizontal ? 0x2443 : 0x2434;
else
colspec = horizontal ? 0x1334 : 0x1343;
}
QColor *cols[5];
cols[0] = 0;
cols[1] = (QColor *)&g.button();
cols[2] = (QColor *)&g.mid();
cols[3] = (QColor *)&g.light();
cols[4] = (QColor *)&g.dark();
#define CMID *cols[ (colspec>>12) & 0xf ]
#define CLEFT *cols[ (colspec>>8) & 0xf ]
#define CTOP *cols[ (colspec>>4) & 0xf ]
#define CBOT *cols[ colspec & 0xf ]
//.........这里部分代码省略.........