QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWidget * parent, Qt::WindowFlags f ) : QWidget( parent, f ) , mNmea( 0 ) , mpCanvas( thepCanvas ) { setupUi( this ); mpLastLayer = 0; mLastGpsPosition = QgsPoint( 0.0, 0.0 ); mpMapMarker = 0; mpRubberBand = 0; populateDevices(); QWidget * mpHistogramWidget = mStackedWidget->widget( 1 ); #if (!WITH_QWTPOLAR) mBtnSatellites->setVisible( false ); #endif // // Set up the graph for signal strength // mpPlot = new QwtPlot( mpHistogramWidget ); mpPlot->setAutoReplot( false ); // plot on demand //mpPlot->setTitle(QObject::tr("Signal Status")); //mpPlot->insertLegend(new QwtLegend(), QwtPlot::BottomLegend); // Set axis titles //mpPlot->setAxisTitle(QwtPlot::xBottom, QObject::tr("Satellite")); //mpPlot->setAxisTitle(QwtPlot::yLeft, QObject::tr("Value")); mpPlot->setAxisScale( QwtPlot::xBottom, 0, 20 ); mpPlot->setAxisScale( QwtPlot::yLeft, 0, 100 ); // max is 50dB SNR, I believe - SLM // add a grid //QwtPlotGrid * mypGrid = new QwtPlotGrid(); //mypGrid->attach( mpPlot ); //display satellites first mpCurve = new QwtPlotCurve(); mpCurve->setRenderHint( QwtPlotItem::RenderAntialiased ); mpCurve->setPen( QPen( Qt::blue ) ); mpCurve->setBrush( QBrush( Qt::blue ) ); mpPlot->enableAxis( QwtPlot::yLeft, false ); mpPlot->enableAxis( QwtPlot::xBottom, false ); mpCurve->attach( mpPlot ); //ensure all children get removed mpPlot->setAutoDelete( true ); QVBoxLayout *mpHistogramLayout = new QVBoxLayout( mpHistogramWidget ); mpHistogramLayout->setContentsMargins( 0, 0, 0, 0 ); mpHistogramLayout->addWidget( mpPlot ); mpHistogramWidget->setLayout( mpHistogramLayout ); // // Set up the polar graph for satellite pos // #if (WITH_QWTPOLAR) QWidget * mpPolarWidget = mStackedWidget->widget( 2 ); mpSatellitesWidget = new QwtPolarPlot( /*QwtText( tr( "Satellite View" ), QwtText::PlainText ),*/ mpPolarWidget ); // possible title for graph removed for now as it is too large in small windows mpSatellitesWidget->setAutoReplot( false ); // plot on demand (after all data has been handled) mpSatellitesWidget->setPlotBackground( Qt::white ); // scales mpSatellitesWidget->setScale( QwtPolar::ScaleAzimuth, 360, //min - reverse the min/max values to get compass orientation - increasing clockwise 0, //max 90 //interval - just show cardinal and intermediate (NE, N, NW, etc.) compass points (in degrees) ); mpSatellitesWidget->setAzimuthOrigin( M_PI_2 ); // to get compass orientation - need to rotate 90 deg. ccw; this is in Radians (not indicated in QwtPolarPlot docs) // mpSatellitesWidget->setScaleMaxMinor( QwtPolar::ScaleRadius, 2 ); // seems unnecessary mpSatellitesWidget->setScale( QwtPolar::ScaleRadius, 90, //min - reverse the min/max to get 0 at edge, 90 at center 0, //max 45 //interval ); // grids, axes QwtPolarGrid * mypSatellitesGrid = new QwtPolarGrid(); mypSatellitesGrid->setGridAttribute( QwtPolarGrid::AutoScaling, false ); // This fixes the issue of autoscaling on the Radius grid. It is ON by default AND is separate from the scaleData.doAutoScale in QwtPolarPlot::setScale(), etc. THIS IS VERY TRICKY! mypSatellitesGrid->setPen( QPen( Qt::black ) ); QPen minorPen( Qt::gray ); // moved outside of for loop; NOTE setting the minor pen isn't necessary if the minor grids aren't shown for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ ) { //mypSatellitesGrid->showGrid( scaleId ); //mypSatellitesGrid->showMinorGrid(scaleId); mypSatellitesGrid->setMinorGridPen( scaleId, minorPen ); } // mypSatellitesGrid->setAxisPen( QwtPolar::AxisAzimuth, QPen( Qt::black ) ); mypSatellitesGrid->showAxis( QwtPolar::AxisAzimuth, true ); mypSatellitesGrid->showAxis( QwtPolar::AxisLeft, false ); //alt axis mypSatellitesGrid->showAxis( QwtPolar::AxisRight, false );//alt axis mypSatellitesGrid->showAxis( QwtPolar::AxisTop, false );//alt axis mypSatellitesGrid->showAxis( QwtPolar::AxisBottom, false );//alt axis mypSatellitesGrid->showGrid( QwtPolar::ScaleAzimuth, false ); // hide the grid; just show ticks at edge mypSatellitesGrid->showGrid( QwtPolar::ScaleRadius, true ); // mypSatellitesGrid->showMinorGrid( QwtPolar::ScaleAzimuth, true ); mypSatellitesGrid->showMinorGrid( QwtPolar::ScaleRadius, true ); // for 22.5, 67.5 degree circles mypSatellitesGrid->attach( mpSatellitesWidget ); //QwtLegend *legend = new QwtLegend; //mpSatellitesWidget->insertLegend(legend, QwtPolarPlot::BottomLegend); QVBoxLayout *mpPolarLayout = new QVBoxLayout( mpPolarWidget ); mpPolarLayout->setContentsMargins( 0, 0, 0, 0 ); mpPolarLayout->addWidget( mpSatellitesWidget ); mpPolarWidget->setLayout( mpPolarLayout ); // replot on command mpSatellitesWidget->replot(); #endif mpPlot->replot(); // Restore state QSettings mySettings; mGroupShowMarker->setChecked( mySettings.value( "/gps/showMarker", "true" ).toBool() ); mSliderMarkerSize->setValue( mySettings.value( "/gps/markerSize", "12" ).toInt() ); mSpinTrackWidth->setValue( mySettings.value( "/gps/trackWidth", "2" ).toInt() ); mTrackColor = mySettings.value( "/gps/trackColor", QColor( Qt::red ) ).value<QColor>(); QString myPortMode = mySettings.value( "/gps/portMode", "scanPorts" ).toString(); mSpinMapExtentMultiplier->setValue( mySettings.value( "/gps/mapExtentMultiplier", "50" ).toInt() ); mDateTimeFormat = mySettings.value( "/gps/dateTimeFormat", "" ).toString(); // zero-length string signifies default format mGpsdHost->setText( mySettings.value( "/gps/gpsdHost", "localhost" ).toString() ); mGpsdPort->setText( mySettings.value( "/gps/gpsdPort", 2947 ).toString() ); mGpsdDevice->setText( mySettings.value( "/gps/gpsdDevice" ).toString() ); //port mode if ( myPortMode == "scanPorts" ) { mRadAutodetect->setChecked( true ); } else if ( myPortMode == "internalGPS" ) { mRadInternal->setChecked( true ); } else if ( myPortMode == "explicitPort" ) { mRadUserPath->setChecked( true ); } else if ( myPortMode == "gpsd" ) { mRadGpsd->setChecked( true ); } //disable the internal port method if build is without QtLocation #ifndef HAVE_QT_MOBILITY_LOCATION mRadInternal->setDisabled( true ); mRadAutodetect->setChecked( true ); #endif //auto digitising behaviour mCbxAutoAddVertices->setChecked( mySettings.value( "/gps/autoAddVertices", "false" ).toBool() ); mCbxAutoCommit->setChecked( mySettings.value( "/gps/autoCommit", "false" ).toBool() ); //pan mode QString myPanMode = mySettings.value( "/gps/panMode", "recenterWhenNeeded" ).toString(); if ( myPanMode == "none" ) { radNeverRecenter->setChecked( true ); } else if ( myPanMode == "recenterAlways" ) { radRecenterMap->setChecked( true ); } else { radRecenterWhenNeeded->setChecked( true ); } mWgs84CRS.createFromOgcWmsCrs( "EPSG:4326" ); mBtnDebug->setVisible( mySettings.value( "/gps/showDebug", "false" ).toBool() ); // use a registry setting to control - power users/devs could set it // status = unknown setStatusIndicator( NoData ); //SLM - added functionality mLogFile = 0; connect( QgisApp::instance()->layerTreeView(), SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( updateCloseFeatureButton( QgsMapLayer* ) ) ); mStackedWidget->setCurrentIndex( 3 ); // force to Options mBtnPosition->setFocus( Qt::TabFocusReason ); }
Phase::Phase(QWidget *parent) : QWidget(parent), ui(new Ui::Phase) { ui->setupUi(this); ui->HdoubleSpinBox->setDecimals(6); ui->HdoubleSpinBox->setValue(0.2644); connect(ui->HdoubleSpinBox, SIGNAL(valueChanged(double)), this, SLOT(drawPhase())); connect(ui->execute, SIGNAL(clicked()), this, SLOT(drawPhase())); ui->f0LineEdit->setText(QString::number(4.4e9)); ui->fmLineEdit->setText(QString::number(150)); ui->df0LineEdit->setText(QString::number(50e6)); double f0 = ui->f0LineEdit->text().toDouble(); double fm = ui->fmLineEdit->text().toDouble(); double df0 = ui->df0LineEdit->text().toDouble(); ui->qwtPolarPlot->setPlotBackground( Qt::white ); // markers QwtPolarMarker *marker1 = new QwtPolarMarker(); marker1->setSymbol( new QwtSymbol( QwtSymbol::Triangle, QBrush( Qt::red ), QPen( Qt::white ), QSize( 8, 8 ) ) ); marker1->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop ); //QwtText text( "Marker" ); //text.setColor( Qt::black ); //QColor bg( Qt::white ); //bg.setAlpha( 200 ); //text.setBackgroundBrush( QBrush( bg ) ); //marker->setLabel( text ); marker1->attach(ui->qwtPolarPlot); QwtPolarMarker *marker11= new QwtPolarMarker(); marker11->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::red ), QPen( Qt::white ), QSize( 7, 7 ) ) ); marker11->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop ); marker11->attach(ui->qwtPolarPlot); QwtPolarMarker *marker2= new QwtPolarMarker(); marker2->setSymbol( new QwtSymbol( QwtSymbol::Triangle, QBrush( Qt::darkGreen ), QPen( Qt::white ), QSize( 8, 8 ) ) ); marker2->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop ); marker2->attach(ui->qwtPolarPlot); QwtPolarMarker *marker22= new QwtPolarMarker(); marker22->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::darkGreen ), QPen( Qt::white ), QSize( 7, 7 ) ) ); marker22->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop ); marker22->attach(ui->qwtPolarPlot); QwtPolarMarker *marker3= new QwtPolarMarker(); marker3->setSymbol( new QwtSymbol( QwtSymbol::Triangle, QBrush( Qt::darkBlue ), QPen( Qt::white ), QSize( 8, 8 ) ) ); marker3->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop ); marker3->attach(ui->qwtPolarPlot); QwtPolarMarker *marker33= new QwtPolarMarker(); marker33->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::darkBlue ), QPen( Qt::white ), QSize( 7, 7 ) ) ); marker33->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop ); marker33->attach(ui->qwtPolarPlot); d_curve = new QwtPolarCurve(); c_curve = new QwtPolarCurve(); e_curve = new QwtPolarCurve(); double H = ui->HdoubleSpinBox->value(); double angleF0 = countPhase0(H,f0); d_curve->setData( new PhaseData( radialInterval, azimuthInterval, numPoints, angleF0 ) ); d_curve->setTitle(QString("fi0 = %1° (%2)").arg(QString::number(angleF0- floor(angleF0/360)*360)).arg(floor(angleF0/360))); double angleFm = countPhaseM(H,f0,df0); c_curve->setData( new PhaseData( radialInterval, azimuthInterval, numPoints, angleF0 + angleFm ) ); c_curve->setTitle(QString("+fim = %1° (%2)").arg(QString::number((angleF0- floor(angleF0/360)*360) + angleFm)).arg("fi0+" + QString::number(angleFm) + "°")); e_curve->setData( new PhaseData( radialInterval, azimuthInterval, numPoints, angleF0 - angleFm ) ); e_curve->setTitle(QString("-fim = %1° (%2)").arg(QString::number((angleF0- floor(angleF0/360)*360) - angleFm)).arg("fi0-" + QString::number(angleFm) + "°")); const QwtInterval azimuth2Interval(angleF0, angleF0+angleFm); const QwtInterval azimuth3Interval(angleF0-angleFm, angleF0); double F1 = (angleF0 - floor(angleF0/360)*360)+(qRound(H)*360); const QwtInterval azimuth1Interval(0, F1); f_curve = new QwtPolarCurve(); f_curve->setData(new SpiralData( radial2Interval, azimuth2Interval, 400, angleF0 ) ); f_curve->attach(ui->qwtPolarPlot); g_curve = new QwtPolarCurve(); g_curve->setData(new SpiralData2( radial3Interval, azimuth3Interval, 400, angleF0 ) ); g_curve->attach(ui->qwtPolarPlot); a_curve = new QwtPolarCurve(); a_curve->setData(new SpiralData( radial1Interval, azimuth1Interval, 800, angleF0 ) ); a_curve->attach(ui->qwtPolarPlot); marker1->setPosition(QwtPointPolar(angleF0+angleFm, radial2Interval.maxValue())); marker11->setPosition(QwtPointPolar(angleF0, radial2Interval.minValue())); marker2->setPosition(QwtPointPolar(angleF0-angleFm, radial3Interval.maxValue()-0.15)); marker22->setPosition(QwtPointPolar(angleF0, radial3Interval.minValue()-0.15)); marker3->setPosition(QwtPointPolar(angleF0, radial1Interval.maxValue())); marker33->setPosition(QwtPointPolar(angleF0, radial1Interval.minValue())); QPen spiral3Pen(Qt::darkBlue); spiral3Pen.setWidth(2); a_curve->setPen(spiral3Pen); QPen curve1Pen(Qt::darkBlue); curve1Pen.setWidth(3); d_curve->setPen(curve1Pen); QPen curve2Pen(Qt::red); curve2Pen.setWidth(3); curve2Pen.setStyle(Qt::DashDotLine); c_curve->setPen(curve2Pen); QPen curve3Pen(Qt::darkGreen); curve3Pen.setWidth(3); curve3Pen.setStyle(Qt::DashDotLine); QPen spiral1Pen(Qt::red); spiral1Pen.setWidth(2); f_curve->setPen(spiral1Pen); QPen spiral2Pen(Qt::darkGreen); spiral2Pen.setWidth(2); g_curve->setPen(spiral2Pen); e_curve->setPen(curve3Pen); d_curve->attach(ui->qwtPolarPlot); c_curve->attach(ui->qwtPolarPlot); e_curve->attach(ui->qwtPolarPlot); d_grid = new QwtPolarGrid(); d_grid->setPen( QPen( Qt::black ) ); QPen minorPen( Qt::gray ); minorPen.setStyle( Qt::DotLine ); d_grid->setMinorGridPen( minorPen ); d_grid->showGrid(true); d_grid->showMinorGrid(true); d_grid->setAxisPen( QwtPolar::AxisAzimuth, QPen( Qt::black ) ); d_grid->showAxis( QwtPolar::AxisAzimuth, true ); d_grid->showAxis( QwtPolar::AxisLeft, true ); d_grid->showAxis( QwtPolar::AxisRight, true ); d_grid->showAxis( QwtPolar::AxisTop, true ); d_grid->showAxis( QwtPolar::AxisBottom, true ); d_grid->showGrid( QwtPolar::Azimuth, true ); d_grid->showGrid( QwtPolar::Radius, true ); d_grid->attach(ui->qwtPolarPlot); QwtLegend *legend = new QwtLegend; ui->qwtPolarPlot->insertLegend( legend, QwtPolarPlot::BottomLegend ); }