本文整理汇总了C++中QPainter::setWorldMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainter::setWorldMatrix方法的具体用法?C++ QPainter::setWorldMatrix怎么用?C++ QPainter::setWorldMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainter
的用法示例。
在下文中一共展示了QPainter::setWorldMatrix方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintEvent
void SLErrorWidget::paintEvent(QPaintEvent *) {
QPainter paint (this);
double ww = QWidget::width();
double wh = QWidget::height()-30;
double scale_x = ww/static_cast<double>(width);
double scale_y = wh/static_cast<double>(height);
scale = (scale_x<scale_y ? scale_x : scale_y);
offset_x = 0.5*(ww-scale*width);
offset_y = 0.5*(wh-scale*height);
if (own_half>0)
paint.setWorldMatrix (QMatrix (scale, 0, 0, scale, offset_x, offset_y));
else
paint.setWorldMatrix (QMatrix (-scale, 0, 0, -scale, ww-offset_x, wh-offset_y));
for (unsigned int i=0; i<width; i++)
for (unsigned int j=0; j<height; j++) {
unsigned int g=error_array[i][j];
paint.setPen (QColor (g,g,g));
paint.fillRect (i,j,2,2, QBrush (QColor (g,g,g), Qt::SolidPattern));
}
paint.setPen (QPen(Qt::blue,2));
paint.drawArc (best_i-1, best_j-1, 3, 3, 0, 5760); // beste Position einzeichnen
if (ci) {
paint.setPen (QPen(Qt::cyan,2));
if (ci->rloc_vis.size()>0) {
Tribots::Vec cur = field2widget (ci->rloc_vis[0].pos);
paint.drawArc (static_cast<int>(cur.x)-1, static_cast<int>(cur.y)-1, 3, 3, 0, 5760); // aktuelle Position zeichnen
paint.setPen (QPen(Qt::magenta,2));
cur = field2widget (optimising_pos);
paint.drawArc (static_cast<int>(cur.x)-1, static_cast<int>(cur.y)-1, 3, 3, 0, 5760); // optimierte Position zeichnen
}
}
}
示例2: show
/*
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: show
/*
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();
}
示例4: paintWheel
void ColorWheel::paintWheel()
{
int h, s, v;
QColor col(ScColorEngine::getDisplayColor(actualColor, currentDoc ));
col.getHsv(&h, &s, &v);
int width = this->width();
int height = this->height();
QPainter p;
p.begin(this);
p.setWindow( 0, 0, width, height);
p.fillRect(0, 0, width, height, Qt::white);
p.setPen(Qt::black);
p.drawRect(0, 0, width, height);
// Half sizes
heightH = height / 2;
widthH = width / 2;
for (int i = 0; i < 360; ++i)
{
QMatrix matrix;
matrix.translate(widthH, heightH);
matrix.rotate((float)i);
p.setWorldMatrix(matrix);
QColor c;
c.setHsv(i, 255, 255);
p.setPen(QPen(c, 7));
p.setBrush(c);
p.drawLine(0, 0, 130, 0);
}
}
示例5: getGradientPixmap
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;
}
示例6: updateCell
void KColorGrid::updateCell( int row, int col, bool erase )
{
//debug("updateCell - before repaint");
QWMatrix matrix;
QPainter p;
p.begin( this );
matrix.translate( (col*cellsize), (row*cellsize) );
p.setWorldMatrix( matrix );
paintCell(&p, row, col);
p.end();
}
示例7: mouseReleaseEvent
void Line::mouseReleaseEvent(QMouseEvent *e)
{
int x,y;
QPainter paint;
QWMatrix m;
KDEBUG(KDEBUG_INFO, 3000, "Line::mouseReleaseEvent() handler called\n");
if (isActive() && drawing && (e->button() == activeButton)) {
emit modified();
x= (e->pos()).x();
y= (e->pos()).y();
// Erase old line
paint.begin(canvas->zoomedPixmap());
if (activeButton == LeftButton)
paint.setPen(leftpen);
else
paint.setPen(rightpen);
paint.setRasterOp(DEFAULT_RASTER_OP);
paint.drawLine(startx, starty, lastx, lasty);
paint.end();
m.scale((float) 100/(canvas->zoom()), (float) 100/(canvas->zoom()));
paint.begin(canvas->pixmap());
if (activeButton == LeftButton)
paint.setPen(leftpen);
else
paint.setPen(rightpen);
paint.setWorldMatrix(m);
paint.setRasterOp(CopyROP);
// Draw new line
paint.drawLine(startx, starty, lastx, lasty);
paint.end();
drawing= FALSE;
canvas->updateZoomed();
canvas->repaint(0);
}
else {
KDEBUG(KDEBUG_WARN, 3000, "Warning event received when inactive (ignoring)\n");
}
}
示例8: mouseReleaseEvent
void AreaSelect::mouseReleaseEvent(QMouseEvent *e)
{
int x,y;
QPainter paint;
QWMatrix m;
KDEBUG(KDEBUG_INFO, 3000, "AreaSelect::mouseReleaseEvent() handler called\n");
if (isActive() && (e->button() == LeftButton)) {
x= (e->pos()).x();
y= (e->pos()).y();
// Erase old line
paint.begin(canvas->zoomedPixmap());
paint.setPen(QPen(green, 0, DashLine));
paint.setRasterOp(DEFAULT_RASTER_OP);
paint.drawRect(startx, starty, lastx-startx, lasty-starty);
paint.end();
m.scale((float) 100/(canvas->zoom()), (float) 100/(canvas->zoom()));
paint.begin(canvas->pixmap());
// paint.setPen(pen);
paint.setWorldMatrix(m);
paint.setRasterOp(CopyROP);
canvas->setSelection(QRect(startx, starty, x-startx, y-starty));
paint.end();
drawing= FALSE;
canvas->updateZoomed();
canvas->repaint(0);
startTimer(TIMER_INTERVALL);
showedSF= false;
}
else {
KDEBUG(KDEBUG_WARN, 3000, "Warning event received when inactive (ignoring)\n");
}
}