void myGauge1::drawGraph(QPainter* painter) { qreal increment=(qreal)180/100; painter->save(); painter->setPen(Qt::NoPen); QRadialGradient graphGradient(m_center,m_colorPieRadius,m_center); graphGradient.setColorAt(0.0,QColor(180,180,180)); graphGradient.setColorAt(0.7,QColor(150,150,150)); graphGradient.setColorAt(0.85,QColor(180,180,180)); graphGradient.setColorAt(1.0,QColor(150,150,150)); painter->setBrush(graphGradient); painter->drawPie(m_pieRect,0,180*16-m_currentValue*increment*16); painter->restore(); }
void CIndicator::drawGraph(QPainter *painter) { painter->save(); painter->setPen(QPen(Qt::transparent,INDICATOR_PEN_WIDTH)); QLinearGradient graphGradient(m_rectTopLeft,QPointF(m_rectTopLeft.x(),m_rectBottomRight.y())); graphGradient.setColorAt(0.0,forecolor); painter->setBrush(graphGradient); qreal dY=(qreal)(m_rectTopLeft.y()-m_rectBottomRight.y())/100; qreal yValue=dY*m_currValue; QPointF topLeftPot(m_rectTopLeft.x()+INDICATOR_PEN_WIDTH,m_rectBottomRight.y()+yValue); QPointF bottomRightPot(m_rectBottomRight.x()-INDICATOR_PEN_WIDTH,m_rectBottomRight.y()); QRectF graphRect(topLeftPot,bottomRightPot); painter->drawRect(graphRect); QString strCurrValue; strCurrValue=tr("%1").arg((m_currValue)); if(m_currValue<10) { lcd[0]->setValue(0); lcd[1]->setValue(0); lcd[2]->setValue(m_currValue); } else if(m_currValue < 100 && m_currValue >= 10) { lcd[0]->setValue(0); lcd[1]->setValue(strCurrValue.at(0).digitValue()); lcd[2]->setValue(strCurrValue.at(1).digitValue()); } else { lcd[0]->setValue(1); lcd[1]->setValue(0); lcd[2]->setValue(0); } painter->restore(); }
void CThermoMeterItem::drawGraph(QPainter *painter) { painter->save(); qreal bucketHeight=m_bucketRect.height(); qreal increment=(qreal)bucketHeight/100; QPointF bottomRightPot(m_bucketRect.bottomRight()); qreal currentY=m_currentValue*increment; QPointF topLeftPot(m_bucketRect.topLeft().x(),m_bucketRect.bottomLeft().y()-currentY); QRectF graphRect(topLeftPot,bottomRightPot); painter->setPen(Qt::NoPen); QLinearGradient graphGradient(graphRect.topLeft(),graphRect.topRight()); painter->setOpacity(0.7); graphGradient.setColorAt(0.0,this->graphcolor); painter->setBrush(graphGradient); painter->drawRect(graphRect); painter->restore(); }