示例#1
0
QwtDial *DataWidget::createDial(int pos)
{
    QwtDial *dial = NULL;
    switch(pos)
    {
        case 0:
        {
            d_ai = new AttitudeIndicator(this);
            dial = d_ai;
            break;
        }
        case 1:
        {
            d_speedo = new SpeedoMeter(this);
            d_speedo->setRange(0.0,8.0);
            d_speedo->setLabel("m/s");
            d_speedo->setOrigin(180);
            d_speedo->setScaleArc(0.0,270.0);
            d_speedo->setScale(-1, 2, 1.0);
            dial = d_speedo;
            break;
        }
        case 2:
        {
            d_speedo = new SpeedoMeter(this);
            d_speedo->setRange(0.0,10.0);
            d_speedo->setLabel("m");
            d_speedo->setOrigin(-90);
            d_speedo->setScaleArc(0.0,360.0);
            d_speedo->setScale(-1, 2, 1);
            dial = d_speedo;
            break;
        }

    }

    if ( dial )
    {
        dial->setReadOnly(true);
        dial->scaleDraw()->setPenWidth(3);
        dial->setLineWidth(4);
        dial->setFrameShadow(QwtDial::Sunken);
    }
    return dial;
}
示例#2
0
void SetWPDlg::on_pb_test2_clicked() {

	QwtDial *p = ui->dial;
	p->setValue(10.0);
	QwtKnob *k = ui->knob;
	k->setValue(10.0);

	QwtPlot *pp = ui->qwtPlot;
    pp->setAxisScale(QwtPlot::xBottom, 0.0, 10.0);
    pp->setAxisScale(QwtPlot::yLeft, -1.0, 1.0);

    pp->setTitle("fsdafdafdafdaadsf");

	QwtPlotCurve *c = new QwtPlotCurve("curve1");
    c->setRenderHint(QwtPlotItem::RenderAntialiased);
    c->setPen(QPen(Qt::red));
    c->setData(new SinusDataT());
    c->attach(pp);
    pp->show();

}
示例#3
0
QwtDial *CockpitGrid::createDial( int pos )
{
    QwtDial *dial = NULL;
    switch( pos )
    {
        case 0:
        {
            d_clock = new QwtAnalogClock( this );
#if 0
            // disable minor ticks
            d_clock->scaleDraw()->setTickLength( QwtScaleDiv::MinorTick, 0 );
#endif

            const QColor knobColor = QColor( Qt::gray ).light( 130 );

            for ( int i = 0; i < QwtAnalogClock::NHands; i++ )
            {
                QColor handColor = QColor( Qt::gray ).light( 150 );
                int width = 8;

                if ( i == QwtAnalogClock::SecondHand )
                {
                    handColor = Qt::gray;
                    width = 5;
                }

                QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle(
                    QwtDialSimpleNeedle::Arrow, true, handColor, knobColor );
                hand->setWidth( width );

                d_clock->setHand( static_cast<QwtAnalogClock::Hand>( i ), hand );
            }

            QTimer *timer = new QTimer( d_clock );
            timer->connect( timer, SIGNAL( timeout() ),
                d_clock, SLOT( setCurrentTime() ) );
            timer->start( 1000 );

            dial = d_clock;
            break;
        }
        case 1:
        {
            d_speedo = new SpeedoMeter( this );
            d_speedo->setScaleStepSize( 20.0 );
            d_speedo->setScale( 0.0, 240.0 );
            d_speedo->scaleDraw()->setPenWidth( 2 );

            QTimer *timer = new QTimer( d_speedo );
            timer->connect( timer, SIGNAL( timeout() ),
                this, SLOT( changeSpeed() ) );
            timer->start( 50 );

            dial = d_speedo;
            break;
        }
        case 2:
        {
            d_ai = new AttitudeIndicator( this );
            d_ai->scaleDraw()->setPenWidth( 3 );

            QTimer *gradientTimer = new QTimer( d_ai );
            gradientTimer->connect( gradientTimer, SIGNAL( timeout() ),
                this, SLOT( changeGradient() ) );
            gradientTimer->start( 100 );

            QTimer *angleTimer = new QTimer( d_ai );
            angleTimer->connect( angleTimer, SIGNAL( timeout() ),
                this, SLOT( changeAngle() ) );
            angleTimer->start( 100 );

            dial = d_ai;
            break;
        }

    }

    if ( dial )
    {
        dial->setReadOnly( true );
        dial->setLineWidth( 4 );
        dial->setFrameShadow( QwtDial::Sunken );
    }
    return dial;
}
void DataWidget::setValue(double value)
{
    switch (_dataDescription->widget)
    {
    case DATA_WIDGET_PLOT:
	{
            QwtPlot *widget = qobject_cast<QwtPlot*> (_internalWidget);
            if (widget != 0)
            {
                _curveData->xData->append(_mainWindow->effectiveRunningTime());
                _curveData->yData->append(value);
#if QWT_VERSION >= 0x060000
                _curve->setRawSamples(_curveData->xData->data(),
                                      _curveData->yData->data(), _curveData->xData->size());
#else
#  warning Old version of qwt being used, data aggregator will not work.
#endif
                widget->replot();
            }
            else
            {
                qDebug() << "Bad data widget cast (DataWidget::setValue()) !";
            }
            break;
	}

    case DATA_WIDGET_LCD:
	{
            QLCDNumber *widget = qobject_cast<QLCDNumber*> (_internalWidget);
            if (widget != 0)
            {
                widget->display(value);
            }
            else
            {
                qDebug() << "Bad data widget cast (DataWidget::setValue()) !";
            }
            break;
	}

    case DATA_WIDGET_LEVEL:
	{
            QwtThermo *widget = qobject_cast<QwtThermo*> (_internalWidget);
            if (widget != 0)
            {
                widget->setValue(value);
            }
            else
            {
                qDebug() << "Bad data widget cast (DataWidget::setValue()) !";
            }
            break;
	}

    case DATA_WIDGET_DIAL:
	{
            QwtDial *widget = qobject_cast<QwtDial*> (_internalWidget);
            if (widget != 0)
            {
                widget->setValue(value);
            }
            else
            {
                qDebug() << "Bad data widget cast (DataWidget::setValue()) !";
            }
            break;
	}

    default:
        ;
    }

    emit valueChanged(value, _dataDescription->id);
}
void DataWidget::createInternalWidget()
{
    qDebug() << "Creating the data widget for data id" << _dataDescription->id;

    switch (_dataDescription->widget)
    {
    case DATA_WIDGET_LCD:
	{
            _internalWidget = new QLCDNumber(this);
            _internalWidget->setMinimumSize(50, 50);
            break;
	}

    case DATA_WIDGET_PLOT:
	{
            _internalWidget = new QwtPlot(this);
            _curve = new QwtPlotCurve(_dataDescription->descriptionString);
            if (_mainWindow->configurationManager()->antialiasing() == true)
            {
                _curve->setRenderHint(QwtPlotItem::RenderAntialiased);
            }
            _curve->attach((QwtPlot*) _internalWidget);
            _curveData = new CurveData;
            _curveData->xData = new QVector<double> ();
            _curveData->yData = new QVector<double> ();
            _internalWidget->setMinimumSize(300, 200);
            break;
	}

    case DATA_WIDGET_LEVEL:
	{
            _internalWidget = new QwtThermo(this);

            QwtThermo *widget = (QwtThermo*) _internalWidget;
            widget->setRange(_dataDescription->valMin, _dataDescription->valMax);
            _internalWidget->setMinimumSize(100, 200);
            break;
	}

    case DATA_WIDGET_LED:
	{
            _internalWidget = new QLedIndicator(this);
            _internalWidget->setMinimumSize(50, 50);
            break;
	}

    case DATA_WIDGET_DIAL:
	{
            _internalWidget = new QwtDial(this);
            _internalWidget->setMinimumSize(250, 250);
            QwtDial *widget = (QwtDial*) _internalWidget;
            widget->setReadOnly(true);
            widget->setWrapping(false);
            widget->setOrigin(135.0);
            widget->setRange(_dataDescription->valMin, _dataDescription->valMax);
            widget->setScaleArc(0.0, 270.0);
            widget->scaleDraw()->setSpacing(8);
            QwtDialSimpleNeedle *needle = new QwtDialSimpleNeedle(
                    QwtDialSimpleNeedle::Arrow, true, Qt::red,
                    QColor(Qt::gray).light(130));
            widget->setNeedle(needle);
            widget->setScaleOptions(QwtDial::ScaleTicks | QwtDial::ScaleLabel);
            widget->setScaleTicks(0, 4, 8);
	}

    default:
        ;
    }

    _internalWidget->setAttribute(Qt::WA_DeleteOnClose);
    layout()->addWidget(_internalWidget);
}