{
if(mReset)
{
mReset = false;
pixmap = & pixmap1;
}
else
{
if(mStatus == true)
{
pixmap = & pixmap2;
}
else if(mStatus == false )
{
if( mFinalTorque <= mTorque)
{
pixmap = & pixmap3;
}
else
{
pixmap = & pixmap4;
}
}
}
return *pixmap;
}
{
struct timeval tv1,tv2;
gettimeofday(&tv1, NULL);
myPaintEvent(pe);
gettimeofday(&tv2, NULL);
qDebug() << "Meter::paintEvent: " << (tv2.tv_sec-tv1.tv_sec)*1000000+(tv2.tv_usec-tv1.tv_usec) << "us";
}
{
QColor needleColor
(255,
230,
0);
paintNeedle.setBackgroundMode (Qt::TransparentMode);
paintNeedle.drawPixmap(mPixmapXCoord, mPixmapYCoord, setBitmap());
paintNeedle.translate(mVectorTranslationX, mVectorTranslationY);
paintNeedle.setPen(Qt::NoPen);
paintNeedle.setBrush(needleColor);
paintNeedle.save();
paintNeedle.rotate(mFinalPoint);
paintNeedle.drawConvexPolygon(needle, 3);
paintNeedle.restore();
paintNeedle.setPen(needleColor);
QRect rect
(mEllipseX, mEllipseY, mEllipseWidht, mEllipseHeight
);
paintNeedle.drawEllipse(rect);
}
QPixmap Meter::setBitmap()
{
QPixmap* pixmap;
if(mReset)
{
mReset = false;
pixmap = & pixmap1;
}
else
{
if(mStatus == true)
{
pixmap = & pixmap2;
}
else if(mStatus == false )
{
if( mFinalTorque <= mTorque)
{
pixmap = & pixmap3;
}
else
{
pixmap = & pixmap4;
}
}
}
return *pixmap;
}
void Meter::paintEvent(QPaintEvent* pe)
{
struct timeval tv1,tv2;
gettimeofday(&tv1, NULL);
myPaintEvent(pe);
gettimeofday(&tv2, NULL);
qDebug() << "Meter::paintEvent: " << (tv2.tv_sec-tv1.tv_sec)*1000000+(tv2.tv_usec-tv1.tv_usec) << "us";
}
void Meter::myPaintEvent(QPaintEvent*)
{
QPainter paintNeedle(this);
QColor needleColor(255, 230, 0);
paintNeedle.setBackgroundMode (Qt::TransparentMode);
paintNeedle.drawPixmap(mPixmapXCoord, mPixmapYCoord, setBitmap());
paintNeedle.translate(mVectorTranslationX, mVectorTranslationY);
paintNeedle.setPen(Qt::NoPen);
paintNeedle.setBrush(needleColor);
paintNeedle.save();
paintNeedle.rotate(mFinalPoint);
paintNeedle.drawConvexPolygon(needle, 3);
paintNeedle.restore();
paintNeedle.setPen(needleColor);
QRect rect(mEllipseX, mEllipseY, mEllipseWidht, mEllipseHeight);
paintNeedle.drawEllipse(rect);
}
To copy to clipboard, switch view to plain text mode
Bookmarks