void PSV_CircularIndicatorItem::drawColorPie(int zValue)
{
    double colorCircleRadius = m_colorCircleRadiusRatio * m_outerRadius;
    QPointF topLeftPot(m_rect.center().x()-colorCircleRadius, m_rect.center().y()-colorCircleRadius);
    QPointF bottomRightPot(m_rect.center().x()+colorCircleRadius, m_rect.center().y()+colorCircleRadius);
    QRectF colorCircleRect=QRectF(topLeftPot, bottomRightPot);


    QMapIterator<double,QColor> iter(m_levelInfos);

    int startAngle = 225 * 16;
    double dValue = m_max -m_min;
    if(qAbs(dValue) < PSV_ZEOR)
    {
        dValue = 100;
        m_max = 100;
        m_min = 0;
    }
    int spanAngle = 0;
    int topAngle = 0;
    while(iter.hasNext())
    {
        iter.next();
        spanAngle = (int)(16 * 270 * iter.key()) - topAngle;
        topAngle += spanAngle;
        QGraphicsEllipseItem* item = new QGraphicsEllipseItem(this);
        item->setRect(colorCircleRect);
        item->setStartAngle(startAngle - spanAngle);
        item->setSpanAngle(spanAngle);
        item->setPen(QPen(Qt::NoPen));
        item->setBrush(QBrush(iter.value()));
        item->setZValue(zValue);
        startAngle = startAngle - spanAngle;
    }
}
Exemplo n.º 2
0
void Gui::createLaserDistanceObjects()
{
	// set colors
	colorHelpLine = Qt::gray;
	colorHelpLineText = Qt::gray;


	//--------------------------------------------------------------
	// create the FRONT laser line distances with text
	//--------------------------------------------------------------
	laserDistanceLineListFront = new QList <QGraphicsEllipseItem*>();
	laserDistanceTextFront = new QList <QGraphicsSimpleTextItem*>();

	// create and add twelve semi circles and text
	for (int i=0; i<LASERDISTANCECIRCLES; i++)
	{
		// create semi circles
		// position doesn't matter, because of moving circles in setLaserDistancePosition()! So we just take 0,0 here.
		QGraphicsEllipseItem *semiCircle = new QGraphicsEllipseItem(0, 0, LASERDISTANCEFIRSTCIRCLE + (i*LASERDISTANCEDISTANCE), LASERDISTANCEFIRSTCIRCLE + (i*LASERDISTANCEDISTANCE));

		// create an (empty) text
		QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem();

		// set the start angle of the circle
		semiCircle->setStartAngle(180*16);
		// set the span angle of the circle
		semiCircle->setSpanAngle(180*16);

		// set semiCircle color
		semiCircle->setPen(QPen(colorHelpLine));

		// set text color
		text->setBrush(QBrush(colorHelpLine));

		// setting to the highest layer level
		semiCircle->setZValue(4);
		text->setZValue(4);

		// add semiCircle to QList
		laserDistanceLineListFront->append(semiCircle);
		laserDistanceTextFront->append(text);

		// add semiCircle to scene
		scene->addItem(semiCircle);

		// add text to scene
		scene->addItem(text);
	}


	//--------------------------------------------------------------
	// create the REAR laser line distances with text
	//--------------------------------------------------------------
	laserDistanceLineListRear = new QList <QGraphicsEllipseItem*>();
	laserDistanceTextRear = new QList <QGraphicsSimpleTextItem*>();

	// create and add twelve semi circles and text
	for (int i=0; i<LASERDISTANCECIRCLES; i++)
	{
		// create semi circles
		// position doesn't matter, because of moving circles in setLaserDistancePosition()! So we just take 0,0 here.
		QGraphicsEllipseItem *semiCircle = new QGraphicsEllipseItem(0, 0, LASERDISTANCEFIRSTCIRCLE + (i*LASERDISTANCEDISTANCE), LASERDISTANCEFIRSTCIRCLE + (i*LASERDISTANCEDISTANCE));

		// create an (empty) text
		QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem();

		// set the start angle of the circle
		semiCircle->setStartAngle(0);
		// set the span angle of the circle
		semiCircle->setSpanAngle(180*16);

		// set semiCircle color
		semiCircle->setPen(QPen(colorHelpLine));

		// set text color
		text->setBrush(QBrush(colorHelpLine));

		// setting to the highest layer level
		semiCircle->setZValue(4);
		text->setZValue(4);

		// add semiCircle to QList
		laserDistanceLineListRear->append(semiCircle);
		laserDistanceTextRear->append(text);

		// add semiCircle to scene
		scene->addItem(semiCircle);

		// add text to scene
		scene->addItem(text);
	}
}