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; }
QwtDial *CockpitGrid::createDial(int pos) { QwtDial *dial = NULL; switch(pos) { case 0: { d_clock = new QwtAnalogClock(this); 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((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->setRange(0.0, 240.0); d_speedo->setScale(-1, 2, 20); 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); 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->scaleDraw()->setPenWidth(3); dial->setLineWidth(4); dial->setFrameShadow(QwtDial::Sunken); } return dial; }
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); }