Ejemplo n.º 1
0
/*!
  \brief draw the scale
*/
void QwtScaleWidget::draw( QPainter *painter ) const
{
    d_data->scaleDraw->draw( painter, palette() );

    if ( d_data->colorBar.isEnabled && d_data->colorBar.width > 0 &&
        d_data->colorBar.interval.isValid() )
    {
        drawColorBar( painter, colorBarRect( contentsRect() ) );
    }

    QRect r = contentsRect();
    if ( d_data->scaleDraw->orientation() == Qt::Horizontal )
    {
        r.setLeft( r.left() + d_data->borderDist[0] );
        r.setWidth( r.width() - d_data->borderDist[1] );
    }
    else
    {
        r.setTop( r.top() + d_data->borderDist[0] );
        r.setHeight( r.height() - d_data->borderDist[1] );
    }

    if ( !d_data->title.isEmpty() )
        drawTitle( painter, d_data->scaleDraw->alignment(), r );
}
Ejemplo n.º 2
0
void caCircularGauge::paintEvent(QPaintEvent *)
{
    QPainter	painter(this);
    int size = qMin(height(), width());

    /* see http://doc.trolltech.com/4.4/coordsys.html#window-viewport-conversion for a analogous example */
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setViewport((int)((width()-size)*.5),(int)((height()-size)*.5),size,size);
    painter.setWindow(-50,-50,100,100);

    drawColorBar(&painter);

    if (isEnabled())
        drawNeedle(&painter);

    if (m_valueDisplayed)
        drawValue(&painter);

    if (!isEnabled())
    {
        QColor c = palette().color(QPalette::Background);
        c.setAlpha(200);
        painter.fillRect(painter.window(), c);
    }
    if (m_scaleEnabled)
    {
        drawScale(&painter);
        drawLabels(&painter);
    }
}
/*!
  \brief draw the scale
*/
void QwtScaleWidget::draw(QPainter *painter) const
{
    painter->save();

    QPen scalePen = painter->pen();
    scalePen.setWidth(d_data->penWidth);
    painter->setPen(scalePen);
    
#if QT_VERSION < 0x040000
    d_data->scaleDraw->draw(painter, colorGroup());
#else
    d_data->scaleDraw->draw(painter, palette());
#endif
    painter->restore();

    if ( d_data->colorBar.isEnabled && d_data->colorBar.width > 0 &&
        d_data->colorBar.interval.isValid() )
    {
        drawColorBar(painter, colorBarRect(rect()));
    }

    QRect r = rect();
    if ( d_data->scaleDraw->orientation() == Qt::Horizontal )
    {
        r.setLeft(r.left() + d_data->borderDist[0]);
        r.setWidth(r.width() - d_data->borderDist[1]);
    }
    else
    {
        r.setTop(r.top() + d_data->borderDist[0]);
        r.setHeight(r.height() - d_data->borderDist[1]);
    }

    if ( !d_data->title.isEmpty() )
    {
        QRect tr = r;
        switch(d_data->scaleDraw->alignment())
        {
            case QwtScaleDraw::LeftScale:
                tr.setRight( r.right() - d_data->titleOffset );
                break;

            case QwtScaleDraw::RightScale:
                tr.setLeft( r.left() + d_data->titleOffset );
                break;

            case QwtScaleDraw::BottomScale:
                tr.setTop( r.top() + d_data->titleOffset );
                break;

            case QwtScaleDraw::TopScale:
            default:
                tr.setBottom( r.bottom() - d_data->titleOffset );
                break;
        }

        drawTitle(painter, d_data->scaleDraw->alignment(), tr);
    }
}
Ejemplo n.º 4
0
void Shape::updateRto(float minR, float maxR)
{
    maxTimeRatio = maxR;
    minTimeRatio = minR;
    //qDebug() << maxTimeRatio;
//    update();
    drawColorBar();
}
Ejemplo n.º 5
0
void FileManager::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
	BarBase::paint( painter, option, widget );
	painter->save();
	//*********************************************************
	drawDropArea( painter );
	drawFileArea( painter );
	drawVisArea( painter );
	renderItem( painter );
	drawControl( painter );
	drawViews( painter );
	drawColorBar( painter );
	//*********************************************************
	painter->restore();
	//*********************************************************
	return;
}
Ejemplo n.º 6
0
void caLinearGauge::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    int size, w, h;
    QFontMetrics fm(painter.font());

    h = fm.height()+2;
    w = fm.width(labels[longestLabelIndex])+2;

    if (m_orientation == Qt::Horizontal) {
        size = qMin((int)(width()*totalSize/100.0), height());
    } else {
        size = qMin((int)(height()*totalSize/100.0), width());
    }

    painter.setRenderHint(QPainter::Antialiasing);

    if (m_orientation == Qt::Horizontal) {
        painter.setViewport((int)((width()-size*100.0/totalSize)*.5),(int)((height()-size)*.5), (int)(size*100.0/totalSize), size);
        painter.setWindow((int)(-w*.5), 0, 100+w, totalSize+2); /* border */
    } else {
        painter.setViewport((int)((width()-size)*.5),(int)((height()-size*100.0/totalSize)*.5), size, (int)(size*100.0/totalSize));
        painter.setWindow(-2, (int)(-h*.5), totalSize+2, 100+h); /* border */
    }
    painter.setViewport(0,0, width(), height()); // A.Mezger I do not like above behaviour when resizing

    drawColorBar(&painter);
    if (m_scaleEnabled)
    {
        drawScale(&painter);
        drawLabels(&painter);
    }
    if (isEnabled() && (m_fillMode == ALL))
        drawMarker(&painter, true);

    if (!isEnabled())
    {
        QColor c = palette().color(QPalette::Background);
        c.setAlpha(200);
        painter.fillRect(painter.window(), c);
    }
}
Ejemplo n.º 7
0
void ColorBar::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    drawColorBar(&painter, rect());
}