本文整理汇总了C++中QWMatrix类的典型用法代码示例。如果您正苦于以下问题:C++ QWMatrix类的具体用法?C++ QWMatrix怎么用?C++ QWMatrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QWMatrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pa
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() );
}
示例2: getX
/*
void KColorGrid::show()
{
//updateScrollBars();
QWidget::show();
}
*/
void KColorGrid::paintEvent(QPaintEvent *e)
{
//kdDebug(4640) << "KColorGrid::paintEvent" << endl;
//updateScrollBars();
//QWidget::paintEvent(e);
const QRect urect = e->rect();
//kdDebug(4640) << "Update rect = ( " << //urect.left() << ", " << urect.top() << ", " << urect.width() << ", " << urect.height() << " )" << endl;
int firstcol = getX(urect.x())-1;
int firstrow = getY(urect.y())-1;
int lastcol = getX(urect.right())+1;
int lastrow = getY(urect.bottom())+1;
QWMatrix matrix;
QPixmap pm(urect.width(),urect.height());
pm.fill(paletteBackgroundColor());
QPainter p;
p.begin( &pm );
firstrow = (firstrow < 0) ? 0 : firstrow;
firstcol = (firstcol < 0) ? 0 : firstcol;
lastrow = (lastrow >= rows) ? rows : lastrow;
lastcol = (lastcol >= cols) ? cols : lastcol;
//kdDebug(4640) << urect.x() << " x " << urect.y() << " - row: " << urect.width() << " x " << urect.height() << endl;
//kdDebug(4640) << "col: " << firstcol << " -> " << lastcol << " - row: " << firstrow << " -> " << lastrow << endl;
/*
if(this->isA("KDrawGrid"))
kdDebug(4640) << "KDrawGrid\n firstcol: " << firstcol << "\n lastcol: " << lastcol << "\n firstrow: " << firstrow << "\n lastrow: " << lastrow << endl;
*/
for(int i = firstrow; i < lastrow; i++)
{
//if(this->isA("KDrawGrid"))
// kdDebug(4640) << "Updating row " << i << endl;
for(int j = firstcol; j < lastcol; j++)
{
matrix.translate( (j*cellsize)-urect.x(), (i*cellsize)-urect.y() );
p.setWorldMatrix( matrix );
//p.setClipRect(j*cellsize, i*cellsize, cellsize, cellsize);
paintCell(&p, i, j);
//p.setClipping(FALSE);
matrix.reset();
p.setWorldMatrix( matrix );
}
//kapp->processEvents();
}
matrix.translate(-urect.x(),-urect.y());
p.setWorldMatrix( matrix );
paintForeground(&p,e);
p.end();
bitBlt(this,urect.topLeft(),&pm,QRect(0,0,pm.width(),pm.height()));
}
示例3: pm
bool Board::loadTiles(float scale) {
int i, j, x, y;
// delete old tiles
for(i = 0; i < 45; i++)
if(pm_tile[i] != 0) {
delete pm_tile[i];
pm_tile[i] = 0;
}
QPixmap pm((PICDIR + "/kshisen.xpm").data());
if(pm.width() == 0 || pm.height() == 0) {
KMsgBox::message(0, klocale->translate("Shisen-Sho"),
klocale->translate("Cannot load pixmaps!"));
exit(1);
}
if(pm.width() == 0 || pm.height() == 0)
return FALSE;
x = pm.width() / 9;
y = pm.height() / 5;
for(i = 0; i < 9; i++)
for(j = 0; j < 5; j++) {
pm_tile[i + j*9] = new QPixmap(x,y);
bitBlt(pm_tile[i + j*9], 0, 0, &pm, x * i, y * j, x, y, CopyROP);
if(scale != 1.0) {
QWMatrix wm;
wm.scale(scale, scale);
*pm_tile[i + j*9] = pm_tile[i + j*9]->xForm(wm);
}
}
return TRUE;
}
示例4: insertSA
void ClsQSAList::insertSA(QPixmap qpm, string, vector <vector<double> > v, bool bReplace) {
// cout << "ClsQSAList::insertSA(QPixmap qpm, string, vector <vector<double> > v)" << endl;
double fFactor = (double)iListViewVisibleWidth / (double) qpm.width();
QWMatrix m;
m.scale(fFactor, fFactor );
QPixmap pmS = qpm.xForm( m );
ClsListBoxSA* clsListBoxSA = new ClsListBoxSA(qlbox, pmS);
clsListBoxSA->setMatrix(v);
if(bReplace){
int iCurrent = qlbox->currentItem();
if(iCurrent>=0) {
qlbox->removeItem(iCurrent);
}
qlbox->insertItem(clsListBoxSA, iCurrent);
} else {
qlbox->insertItem(clsListBoxSA);
}
qlbox->setCurrentItem(clsListBoxSA);
qlbox->clearSelection ();
qlbox->setSelected(clsListBoxSA, true);
}
示例5: type
void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) {
MimeType type( info->absFilePath() );
if (!compliesMime( type.id() ) )
return;
QPixmap pix = type.pixmap();
QString dir, name;
bool locked;
if ( pix.isNull() ) {
QWMatrix matrix;
QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
matrix.scale( .4, .4 );
pix = pixer.xForm( matrix );
}
dir = info->dirPath( true );
locked = false;
if ( symlink )
name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
else {
name = info->fileName();
if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) {
locked = true;
pix = Resource::loadPixmap("locked");
}
}
(void)new OFileSelectorItem( m_view, pix, name,
info->lastModified().toString(), QString::number( info->size() ),
dir, locked );
}
示例6: 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
}
}
示例7: computeAngle
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);
}
示例8: 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());
}
示例9: 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
}
}
示例10:
void k9MenuEditor::resizeEvent ( QResizeEvent * e ) {
QWMatrix m;
double scalex=(e->size().width()-4.0)/720.0;
double scaley=(e->size().height()-4.0)/576.0;
m.scale(QMIN(scalex,scaley),QMIN(scalex,scaley));
this->setWorldMatrix(m);
}
示例11: QPainter
QPixmap ClsBaseQStateArrayView::getGradientPixmap(int iImgWidth, int iImgHeight, int _iColorMode ) {
#ifdef DEBUG_CLSBASEQSTATEARRAYVIEW
cout << "ClsBaseQStateArrayView::getGradientPixmap(int iImgWidth, int iImgHeight)" << endl;
#endif
// int iColorMode = ClsBaseQStateArrayView::GRAY;
// int iColorMode = ClsBaseQStateArrayView::BLUE2RED;
// int iColorMode = ClsBaseQStateArrayView::HSV;
QPixmap pmGradient;
QPainter* paintGradient = new QPainter();
QWMatrix mxRot;
int iDiag = (int)(sqrt(double(iImgWidth * iImgWidth + iImgHeight * iImgHeight))/2.);
pmGradient.resize(2 * iDiag, 2 * iDiag);
paintGradient->begin(&pmGradient);
paintGradient->setWindow( 0, 0, 2 * iDiag, 2 * iDiag );
int iNrSices = 50;
for ( int i=0; i<iNrSices; i++ ) {
paintGradient->setWorldMatrix( mxRot );
QColor c;
if(_iColorMode == ClsBaseQStateArrayView::GRAY){
c.setRgb( i* 255 / iNrSices, i* 255 / iNrSices, i* 255 / iNrSices );
}
else if(_iColorMode == ClsBaseQStateArrayView::BLUE2RED){
if(i<iNrSices/2){
/* BLUE */
c.setRgb(0, 0, 255 - i * 510/iNrSices);
}
else {
/* RED */
c.setRgb( (i - iNrSices/2) * 255/(iNrSices/2), 0,0);
}
}
else {
c.setHsv( i* 360 / iNrSices, 255, 255 );
}
paintGradient->setBrush( c );
paintGradient->setPen( c );
//zzz QPointArray a;
QPolygon a;
a.setPoints( 4,
0, 0,
iDiag * 2 / iNrSices, 0,
iDiag * 2 / iNrSices, iDiag * 2,
0, iDiag * 2 );
paintGradient->drawPolygon( a );
mxRot.translate( (double)iDiag * 2.0 / (double)iNrSices, 0.0 );
}
paintGradient->end();
return pmGradient;
}
示例12: pa
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);
}
示例13: updateWorldMatrix
void CVBEditor::updateWorldMatrix() {
double z = p_itemView->zoomLevel();
QRect r = m_pCanvas->rect();
// QWMatrix m( z, 0.0, 0.0, z, -r.left(), -r.top() );
// QWMatrix m( z, 0.0, 0.0, z, 0.0, 0.0 );
QWMatrix m;
m.scale(z, z);
m.translate(-r.left(), -r.top());
setWorldMatrix(m);
}
示例14: zoomOut
void ClsQDiagramView::zoomOut() {
#ifdef DEBUG_CLSQDIAGRAMVIEW
cout << "ClsQDiagramView::zoomOut()" << endl;
#endif
QWMatrix m = clsQDiagramCanvasView->worldMatrix();
m.scale( 0.9, 0.9 );
clsQDiagramCanvasView->setWorldMatrix( m );
#ifdef USEPANNER
clsqcanvaspanner->canvasResized();
#endif
};
示例15: getX
/*
void KColorGrid::show()
{
//updateScrollBars();
QWidget::show();
}
*/
void KColorGrid::paintEvent(QPaintEvent *e)
{
//debug("KColorGrid::paintEvent");
//updateScrollBars();
//QWidget::paintEvent(e);
const QRect urect = e->rect();
//debug("Update rect = ( %i, %i, %i, %i )",
//urect.left(),urect.top(), urect.width(), urect.height() );
int firstcol = getX(urect.x())-1;
int firstrow = getY(urect.y())-1;
int lastcol = getX(urect.right())+1;
int lastrow = getY(urect.bottom())+1;
QWMatrix matrix;
QPainter p;
p.begin( this );
firstrow = (firstrow < 0) ? 0 : firstrow;
firstcol = (firstcol < 0) ? 0 : firstcol;
lastrow = (lastrow >= rows) ? rows : lastrow;
lastcol = (lastcol >= cols) ? cols : lastcol;
//debug("%d x %d - row: %d x %d", urect.x(), urect.y(), urect.width(), urect.height());
//debug("col: %d -> %d - row: %d -> %d", firstcol, lastcol, firstrow, lastrow);
/*
if(this->isA("KDrawGrid"))
debug("KDrawGrid\n firstcol: %d\n lastcol: %d\n firstrow: %d\n lastrow: %d",
firstcol, lastcol, firstrow, lastrow);
*/
for(int i = firstrow; i < lastrow; i++)
{
//if(this->isA("KDrawGrid"))
// debug("Updating row %d", i);
for(int j = firstcol; j < lastcol; j++)
{
matrix.translate( (j*cellsize), (i*cellsize) );
p.setWorldMatrix( matrix );
//p.setClipRect(j*cellsize, i*cellsize, cellsize, cellsize);
paintCell(&p, i, j);
//p.setClipping(FALSE);
matrix.reset();
p.setWorldMatrix( matrix );
}
//kapp->processEvents();
}
p.end();
}