void PlotSectorHistogram::updateIntervals( const SectorHistogram &histogram)
{
	_datasCurveIntervals->clear();
	QVector<QwtIntervalSample> curveHistogramIntervalsDatas;
	const int nbIntervals = histogram.nbIntervals();
	if ( nbIntervals > 0 )
	{
		QVector< Interval<uint> >::ConstIterator begin = histogram.intervals().begin();
		const QVector< Interval<uint> >::ConstIterator end = histogram.intervals().end();
		const uint nbSectors = PieChartSingleton::getInstance()->nbSectors();
		uint min, max, i;
		qDebug() << "Intervalles d'angles' :";
		while ( begin != end )
		{
			const Interval<uint> &currentInterval = *begin++;
			min = currentInterval.min();
			max = currentInterval.max();
			if ( currentInterval.isValid() )
			{
				_datasCurveIntervals->append(QwtPointPolar( PieChartSingleton::getInstance()->sector(min).minAngle(), 0. ));
				for ( i=min ; i<=max ; ++i )
				{
					const PiePart &currentSector = PieChartSingleton::getInstance()->sector(i);
					_datasCurveIntervals->append(QwtPointPolar(currentSector.minAngle(),histogram[i]));
					_datasCurveIntervals->append(QwtPointPolar(currentSector.maxAngle(), histogram[i]));
					curveHistogramIntervalsDatas.append(QwtIntervalSample( histogram[i],currentSector.minAngle(),currentSector.maxAngle()));
				}
				_datasCurveIntervals->append(QwtPointPolar( PieChartSingleton::getInstance()->sector(max).maxAngle(), 0. ));
			}
			else
			{
				_datasCurveIntervals->append(QwtPointPolar( PieChartSingleton::getInstance()->sector(min).minAngle(), 0. ));
				for ( i=min ; i<nbSectors ; ++i )
				{
					const PiePart &currentSector = PieChartSingleton::getInstance()->sector(i);
					_datasCurveIntervals->append(QwtPointPolar(currentSector.minAngle(), histogram[i]));
					_datasCurveIntervals->append(QwtPointPolar(currentSector.maxAngle(), histogram[i]));
					curveHistogramIntervalsDatas.append(QwtIntervalSample( histogram[i],currentSector.minAngle(),currentSector.maxAngle()));
				}
				for ( i=0 ; i<=max ; ++i )
				{
					const PiePart &currentSector = PieChartSingleton::getInstance()->sector(i);
					_datasCurveIntervals->append(QwtPointPolar(currentSector.minAngle(), histogram[i]));
					_datasCurveIntervals->append(QwtPointPolar(currentSector.maxAngle(), histogram[i]));
					curveHistogramIntervalsDatas.append(QwtIntervalSample( histogram[i],currentSector.minAngle(),currentSector.maxAngle()));
				}
				_datasCurveIntervals->append(QwtPointPolar( PieChartSingleton::getInstance()->sector(max).maxAngle(), 0. ));
			}
			qDebug() << "  [ " << min << ", " << max << " ] => [" << PieChartSingleton::getInstance()->sector(min).minAngle()*RAD_TO_DEG_FACT << ", " << PieChartSingleton::getInstance()->sector(max).maxAngle()*RAD_TO_DEG_FACT << "] avec largeur = " << (max>min?max-min:360-min+max);
		}
	}
	_histogramIntervals.setSamples(curveHistogramIntervalsDatas);
}
Esempio n. 2
0
/*!
   \brief Calculate the bounding rect of the plot area

   The plot area depends on the zoom parameters.

   \param canvasRect Rectangle of the canvas
   \return Rectangle for displaying 100% of the plot
*/
QRectF QwtPolarPlot::plotRect( const QRectF &canvasRect ) const
{
    const QwtScaleDiv *sd = scaleDiv( QwtPolar::Radius );
    const QwtScaleEngine *se = scaleEngine( QwtPolar::Radius );

    const int margin = plotMarginHint();
    const QRectF cr = canvasRect;
    const int radius = qMin( cr.width(), cr.height() ) / 2 - margin;

    QwtScaleMap map;
    map.setTransformation( se->transformation() );
    map.setPaintInterval( 0.0, radius / d_data->zoomFactor );
    map.setScaleInterval( sd->lowerBound(), sd->upperBound() );

    double v = map.s1();
    if ( map.s1() <= map.s2() )
        v += d_data->zoomPos.radius();
    else
        v -= d_data->zoomPos.radius();
    v = map.transform( v );

    const QPointF off =
        QwtPointPolar( d_data->zoomPos.azimuth(), v ).toPoint();

    QPointF center( cr.center().x(), cr.top() + margin + radius );
    center -= QPointF( off.x(), -off.y() );

    QRectF rect( 0, 0, 2 * map.p2(), 2 * map.p2() );
    rect.moveCenter( center );

    return rect;
}
Esempio n. 3
0
/*!
   Unzoom the plot
   \sa zoom()
*/
void QwtPolarPlot::unzoom()
{
    if ( d_data->zoomFactor != 1.0 || d_data->zoomPos.isValid() )
    {
        d_data->zoomFactor = 1.0;
        d_data->zoomPos = QwtPointPolar();
        autoRefresh();
    }
}
Esempio n. 4
0
    virtual QwtPointPolar sample( size_t i ) const
    {
        const double stepA = d_azimuthInterval.width() / (d_size-1);
        const double a = d_azimuthInterval.minValue() + i * stepA;          //uhol

        const double stepR = d_radialInterval.width() / d_size;             //velkost
        const double r = d_radialInterval.minValue() + i * stepR;

        return QwtPointPolar( a, r );
    }
Esempio n. 5
0
/*!
   Normalize radius and azimuth

   When the radius is < 0.0 it is set to 0.0. The azimuth is
   a value >= 0.0 and < 2 * M_PI.
*/
QwtPointPolar QwtPointPolar::normalized() const
{
    const double radius = qMax( d_radius, 0.0 );

    double azimuth = d_azimuth;
    if ( azimuth < -2.0 * M_PI || azimuth >= 2 * M_PI )
        azimuth = ::fmod( d_azimuth, 2 * M_PI );

    if ( azimuth < 0.0 )
        azimuth += 2 * M_PI;

    return QwtPointPolar( azimuth, radius );
}
Esempio n. 6
0
    virtual QwtPointPolar sample( size_t i ) const
    {
        //const double stepA = 4 * d_azimuthInterval.width() / d_size;
        //qDebug() << d_azimuthInterval.minValue();
        //qDebug() << d_size;
        //const double a = d_azimuthInterval.minValue() + i * stepA;
        const double a = d_angle;

        const double stepR = 2*d_radialInterval.width() / d_size;
        const double r = d_radialInterval.minValue() + i * stepR;

        return QwtPointPolar( a, r );
        //return QwtPointPolar();
    }
Esempio n. 7
0
void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation &info )
{
  QVector<QPointF> data;

  // set validity flag and status from GPS data
  // based on GGA, GSA and RMC sentences - the logic does not require all
  bool validFlag = false; // true if GPS indicates position fix
  FixStatus fixStatus = NoData;

  // no fix if any of the three report bad; default values are invalid values and won't be changed if the corresponding NMEA msg is not received
  if ( info.status == 'V' || info.fixType == NMEA_FIX_BAD || info.quality == 0 ) // some sources say that 'V' indicates position fix, but is below acceptable quality
  {
    fixStatus = NoFix;
  }
  else if ( info.fixType == NMEA_FIX_2D ) // 2D indication (from GGA)
  {
    fixStatus = Fix2D;
    validFlag = true;
  }
  else if ( info.status == 'A' || info.fixType == NMEA_FIX_3D || info.quality > 0 ) // good
  {
    fixStatus = Fix3D;
    validFlag = true;
  }
  else  // unknown status (not likely)
  {
  }

  // set visual status indicator -- do only on change of state
  if ( fixStatus != mLastFixStatus )
  {
    setStatusIndicator( fixStatus );
  }

  if ( mStackedWidget->currentIndex() == 1 && info.satInfoComplete ) //signal
  {
    mpPlot->setAxisScale( QwtPlot::xBottom, 0, info.satellitesInView.size() );
  } //signal
#ifdef WITH_QWTPOLAR
  if ( mStackedWidget->currentIndex() == 2 && info.satInfoComplete ) //satellites
  {
    while ( !mMarkerList.isEmpty() )
    {
      delete mMarkerList.takeFirst();
    }
  } //satellites
#endif
  if ( mStackedWidget->currentIndex() == 4 ) //debug
  {
    mGPSPlainTextEdit->clear();
  } //debug

  for ( int i = 0; i < info.satellitesInView.size(); ++i ) //satellite processing loop
  {
    QgsSatelliteInfo currentInfo = info.satellitesInView.at( i );

    if ( mStackedWidget->currentIndex() == 1 && info.satInfoComplete ) //signal
    {
      data << QPointF( i, 0 );
      data << QPointF( i, currentInfo.signal );
      data << QPointF( i + 1, currentInfo.signal );
      data << QPointF( i + 1, 0 );
    } //signal

    if ( mStackedWidget->currentIndex() == 2 && info.satInfoComplete ) //satellites
    {
      QColor bg( Qt::white ); // moved several items outside of the following if block to minimize loop time
      bg.setAlpha( 200 );
      QColor myColor;

      // Add a marker to the polar plot
      if ( currentInfo.id > 0 )       // don't show satellite if id=0 (no satellite indication)
      {
#ifdef WITH_QWTPOLAR
        QwtPolarMarker *mypMarker = new QwtPolarMarker();
#if (QWT_POLAR_VERSION<0x010000)
        mypMarker->setPosition( QwtPolarPoint( currentInfo.azimuth, currentInfo.elevation ) );
#else
        mypMarker->setPosition( QwtPointPolar( currentInfo.azimuth, currentInfo.elevation ) );
#endif
#endif
        if ( currentInfo.signal < 30 ) //weak signal
        {
          myColor = Qt::red;
        }
        else
        {
          myColor = Qt::black; //strong signal
        }
#ifdef WITH_QWTPOLAR
        QBrush symbolBrush( Qt::black );
        QSize markerSize( 9, 9 );
        QBrush textBgBrush( bg );
#if (QWT_POLAR_VERSION<0x010000)
        mypMarker->setSymbol( QwtSymbol( QwtSymbol::Ellipse,
                                         symbolBrush, QPen( myColor ), markerSize ) );
#else
        mypMarker->setSymbol( new QwtSymbol( QwtSymbol::Ellipse,
                                             symbolBrush, QPen( myColor ), markerSize ) );
#endif

        mypMarker->setLabelAlignment( Qt::AlignHCenter | Qt::AlignTop );
        QwtText text( QString::number( currentInfo.id ) );
        text.setColor( myColor );
        text.setBackgroundBrush( textBgBrush );
        mypMarker->setLabel( text );
        mypMarker->attach( mpSatellitesWidget );
        mMarkerList << mypMarker;
#endif
      } // currentInfo.id > 0
    } //satellites
  } //satellite processing loop

  if ( mStackedWidget->currentIndex() == 1 && info.satInfoComplete ) //signal
  {
    mpCurve->setSamples( data );
    mpPlot->replot();
  } //signal
#ifdef WITH_QWTPOLAR
  if ( mStackedWidget->currentIndex() == 2 && info.satInfoComplete ) //satellites
  {
    mpSatellitesWidget->replot();
  } //satellites
#endif
  if ( validFlag )
  {
    validFlag = info.longitude >= -180.0 && info.longitude <= 180.0 && info.latitude >= -90.0 && info.latitude <= 90.0;
  }

  QgsPointXY myNewCenter;
  if ( validFlag )
  {
    myNewCenter = QgsPointXY( info.longitude, info.latitude );
  }
  else
  {
    myNewCenter = mLastGpsPosition;
  }

  if ( mStackedWidget->currentIndex() == 0 ) //position
  {
    mTxtLatitude->setText( QString::number( info.latitude, 'f', 8 ) );
    mTxtLongitude->setText( QString::number( info.longitude, 'f', 8 ) );
    mTxtAltitude->setText( tr( "%1 m" ).arg( info.elevation, 0, 'f', 1 ) ); // don't know of any GPS receivers that output better than 0.1 m precision
    if ( mDateTimeFormat.isEmpty() )
    {
      mTxtDateTime->setText( info.utcDateTime.toString( Qt::TextDate ) );  // default format
    }
    else
    {
      mTxtDateTime->setText( info.utcDateTime.toString( mDateTimeFormat ) );  //user specified format string for testing the millisecond part of time
    }
    mTxtSpeed->setText( tr( "%1 km/h" ).arg( info.speed, 0, 'f', 1 ) );
    mTxtDirection->setText( QString::number( info.direction, 'f', 1 ) + QStringLiteral( "°" ) );
    mTxtHdop->setText( QString::number( info.hdop, 'f', 1 ) );
    mTxtVdop->setText( QString::number( info.vdop, 'f', 1 ) );
    mTxtPdop->setText( QString::number( info.pdop, 'f', 1 ) );
    mTxtHacc->setText( QString::number( info.hacc, 'f', 1 ) + "m" );
    mTxtVacc->setText( QString::number( info.vacc, 'f', 1 ) + "m" );
    mTxtFixMode->setText( info.fixMode == 'A' ? tr( "Automatic" ) : info.fixMode == 'M' ? tr( "Manual" ) : QLatin1String( "" ) ); // A=automatic 2d/3d, M=manual; allowing for anything else
    mTxtFixType->setText( info.fixType == 3 ? tr( "3D" ) : info.fixType == 2 ? tr( "2D" ) : info.fixType == 1 ? tr( "No fix" ) : QString::number( info.fixType ) ); // 1=no fix, 2=2D, 3=3D; allowing for anything else
    mTxtQuality->setText( info.quality == 2 ? tr( "Differential" ) : info.quality == 1 ? tr( "Non-differential" ) : info.quality == 0 ? tr( "No position" ) : info.quality > 2 ? QString::number( info.quality ) : QLatin1String( "" ) ); // allowing for anything else
    mTxtSatellitesUsed->setText( QString::number( info.satellitesUsed ) );
    mTxtStatus->setText( info.status == 'A' ? tr( "Valid" ) : info.status == 'V' ? tr( "Invalid" ) : QLatin1String( "" ) );
  } //position

  // Avoid refreshing / panning if we haven't moved
  if ( mLastGpsPosition != myNewCenter )
  {
    mLastGpsPosition = myNewCenter;

    // Pan based on user specified behavior
    if ( radRecenterMap->isChecked() || radRecenterWhenNeeded->isChecked() )
    {
      QgsCoordinateReferenceSystem mypSRS = mpCanvas->mapSettings().destinationCrs();
      QgsCoordinateTransform myTransform( mWgs84CRS, mypSRS ); // use existing WGS84 CRS

      QgsPointXY myPoint = myTransform.transform( myNewCenter );
      //keep the extent the same just center the map canvas in the display so our feature is in the middle
      QgsRectangle myRect( myPoint, myPoint );  // empty rect can be used to set new extent that is centered on the point used to construct the rect

      // testing if position is outside some proportion of the map extent
      // this is a user setting - useful range: 5% to 100% (0.05 to 1.0)
      QgsRectangle myExtentLimit( mpCanvas->extent() );
      myExtentLimit.scale( mSpinMapExtentMultiplier->value() * 0.01 );

      // only change the extents if the point is beyond the current extents to minimize repaints
      if ( radRecenterMap->isChecked() ||
           ( radRecenterWhenNeeded->isChecked() && !myExtentLimit.contains( myPoint ) ) )
      {
        mpCanvas->setExtent( myRect );
        mpCanvas->refresh();
      }
    } //otherwise never recenter automatically

    if ( mCbxAutoAddVertices->isChecked() )
    {
      addVertex();
    }
  } // mLastGpsPosition != myNewCenter

  // new marker position after recentering
  if ( mGroupShowMarker->isChecked() ) // show marker
  {
    if ( validFlag ) // update cursor position if valid position
    {
      // initially, cursor isn't drawn until first valid fix; remains visible until GPS disconnect
      if ( ! mpMapMarker )
      {
        mpMapMarker = new QgsGpsMarker( mpCanvas );
      }
      mpMapMarker->setSize( mSliderMarkerSize->value() );
      mpMapMarker->setCenter( myNewCenter );
    }
  }
  else
  {
    if ( mpMapMarker )
    {
      delete mpMapMarker;
      mpMapMarker = nullptr;
    }
  } // show marker
}
Esempio n. 8
0
void Phase::drawPhase()
{
    ui->qwtPolarPlot->detachItems(QwtPolarItem::Rtti_PolarItem, false);
    d_grid->attach(ui->qwtPolarPlot);

    double H = ui->HdoubleSpinBox->value();
    double f0 = ui->f0LineEdit->text().toDouble();
    //double fm = ui->fmLineEdit->text().toDouble();
    double df0 = ui->df0LineEdit->text().toDouble();

    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)));
    d_curve->attach(ui->qwtPolarPlot);
    qDebug() << "angle F0 = " << angleF0;

    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) + "°"));
    c_curve->attach(ui->qwtPolarPlot);
    qDebug() << "angle Fm = " << 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) + "°"));
    e_curve->attach(ui->qwtPolarPlot);

    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);

    a_curve->setData(new SpiralData( radial1Interval, azimuth1Interval, 10000, angleF0 ));
    a_curve->attach(ui->qwtPolarPlot);

    f_curve->setData(new SpiralData( radial2Interval, azimuth2Interval, 400, angleF0 ));
    f_curve->attach(ui->qwtPolarPlot);
    g_curve->setData(new SpiralData2( radial3Interval, azimuth3Interval, 1000, angleF0 ));
    g_curve->attach(ui->qwtPolarPlot);
    qDebug() << angleF0;

    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 );
    marker1->setPosition(QwtPointPolar(angleF0+angleFm, radial2Interval.maxValue()));
    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->setPosition(QwtPointPolar(angleF0, radial2Interval.minValue()));
    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->setPosition(QwtPointPolar(angleF0-angleFm, radial3Interval.maxValue()-0.15));
    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->setPosition(QwtPointPolar(angleF0, radial3Interval.minValue()-0.15));
    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->setPosition(QwtPointPolar(angleF0, radial1Interval.maxValue()));
    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->setPosition(QwtPointPolar(angleF0, radial1Interval.minValue()));
    marker33->attach(ui->qwtPolarPlot);

    ui->qwtPolarPlot->replot();
}
Esempio n. 9
0
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 );
}
Esempio n. 10
0
// ----------------------------------- Инициализация полярного графика ----------------------------------- //
void Dialog_EditAnt::initPolarGraph(Antenna dan)
{
    dan.AzimutHorizontal[360]=360;
    dan.AzimutVertical[360]=360;
    dan.RadHorizontal[360]=dan.RadHorizontal[0];
    dan.RadVertical[360]=dan.RadVertical[0];

    ui->PlotPolar->detachItems(0,1);

    QColor qcHorizDN = "#ff0000";
    QColor qcVertDN = "#00ff00";

    double marker3db[361];
    for (int i=0; i<=360; i++)
        marker3db[i]=-3;

    gridPolar = new QwtPolarGrid();                            // создаем сетку

    for (int sc=0; sc < QwtPolar::ScaleCount; sc++)     // для всех шкал
    {
        gridPolar->showMinorGrid(sc);            // разрешаем отображение линий сетки, соответствующих вспомогательным делениям шкалы
        gridPolar->setMajorGridPen(sc,QPen(Qt::lightGray));                  // основных делений
        gridPolar->setMinorGridPen(sc,QPen(Qt::lightGray,0,Qt::DotLine));    // и вспомогательных
    }

    // markers
    QwtPolarMarker *marker = new QwtPolarMarker();
    marker->setPosition( QwtPointPolar( 269.5, -3 ) );
    marker->setSymbol( new QwtSymbol( QwtSymbol::HLine, QBrush( Qt::transparent ), QPen( Qt::green ), QSize( 0, 0 ) ) );
    marker->setLabelAlignment( Qt::AlignLeft | Qt::AlignTop );
    QwtText text( "-3" );
    text.setColor( Qt::black );
    QColor bg( Qt::white );
    bg.setAlpha( 200 );
    text.setBackgroundBrush( QBrush( bg ) );
    marker->setLabel( text );
    marker->attach( ui->PlotPolar );

    gridPolar->showAxis(QwtPolar::AxisRight,false);       // запрещаем отображать радиальную шкалу справа
    gridPolar->showAxis(QwtPolar::AxisTop,true);          // разрешаем отображать радиальную шкалу сверху

    gridPolar->attach(ui->PlotPolar);                                 // связываем созданную сетку с графиком

    ui->PlotPolar->setScale(QwtPolar::Radius,-GraphScale,0,1);        // радиальной шкалы
    ui->PlotPolar->setScale(QwtPolar::Azimuth,360,0,30);              // и азимутальной

    CurvPolarVert = new QwtPolarCurve(QString("Vertical"));           // создаем первую кривую с наименованием "DNA 1"
    CurvPolarVert->setPen(QPen(qcVertDN,2));                          // назначаем толщину 2 и цвет прорисовки - темно-зеленый

    CurvPolarHoriz = new QwtPolarCurve(QString("Horizontal"));        // создаем вторую кривую с наименованием "DNA 2"
    CurvPolarHoriz->setPen(QPen(qcHorizDN,2));                        // назначаем цвет прорисовки - красный

    CurvPolar3db = new QwtPolarCurve(QString("Marker3db"));           // создаем вторую кривую с наименованием "DNA 2"
    CurvPolar3db->setPen(QPen(Qt::red,0));                            // назначаем цвет прорисовки - красный
    CurvPolar3db->setPen(QPen(Qt::DashDotLine));
    CurvPolar3db->setStyle(QwtPolarCurve::Lines);
    CurvPolar3db->setData(new QData(dan.AzimutHorizontal,marker3db,N1));       // передаем кривым подготовленные данные
    CurvPolar3db->attach(ui->PlotPolar);

    CurvPolarVert->setData(new QData(dan.AzimutVertical,dan.RadVertical,N1));     // передаем кривым подготовленные данные
    CurvPolarHoriz->setData(new QData(dan.AzimutHorizontal,dan.RadHorizontal,N1));  // передаем кривым подготовленные данные

    CurvPolarHoriz->attach(ui->PlotPolar);
    CurvPolarVert->attach(ui->PlotPolar);

    ui->PlotPolar->replot();
}
Esempio n. 11
0
File: Plot.cpp Progetto: BulSV/Radar
Plot::Plot(QWidget *parent)
    : QwtPolarPlot(parent)
    , m_azimuthChange(new QTimer(this))
    , m_currTime(new QTime)
    , m_nextAzimuthData(new QTimer(this))
    , m_isStarted(false)
    , m_showIDs(true)
    , m_tracksStorage(new MarksTracksStorage(this))
      /*, m_picker(new QwtPolarPicker(QwtPicker::CrossRubberBand,
                                    QwtPicker::ActiveOnly,
                                    this->canvas()))*/
    , m_isIDMoving(false)
    , m_currMovingCurveID(0)
    , m_wrongMarksSound(new QSound(":/Resources/WrongMarksReceived.wav", this))
    , m_rightMarksSound(new QSound(":/Resources/RadarShort.wav", this))
    , m_offSounds(false)
    , m_markIndex(0)
    , m_upToIndex(0)
    , m_isIndexMarkFirstAppearance(true)
    , m_pauseAzimuth(0.0)
    , m_isPaused(false)
{
    m_tracksStorage->setStorageSize(40);

    /*m_picker->setStateMachine(new QwtPickerDragPointMachine);
    m_picker->setMousePattern(QwtPicker::MouseSelect1, Qt::LeftButton);
    m_picker->setRubberBandPen(QColor("#00FF00"));
    m_picker->setTrackerPen(QColor(Qt::white));
    m_picker->setTrackerFont(QFont("Verdana", 10));*/

    setAutoReplot( false );
    setPlotBackground( QColor("#0B0B3B") );
    canvas()->setStyleSheet("background: #0B0B3B");
    // Maked plot squared
    this->zoom(QwtPointPolar(0, 0), ZOOMDEFAULTFACTOR);

    // setting start point at 12 o'clock
    setAzimuthOrigin(M_PI/2);

    // scales
    setScale(QwtPolar::Azimuth, 360, 0, 30);
    setScaleMaxMinor(QwtPolar::Azimuth, 30);
    setScaleMaxMajor(QwtPolar::Azimuth, 30);

    setScale(QwtPolar::Radius, 0.0, 400.0 / ZOOMDEFAULTFACTOR, 50.0);
    setScaleMaxMinor(QwtPolar::Radius, qCeil(400.0 / (50.0 * ZOOMDEFAULTFACTOR)));
    setScaleMaxMajor(QwtPolar::Radius, qCeil(400.0 / (50.0 * ZOOMDEFAULTFACTOR)));

    // grids
    m_grid = new QwtPolarGrid();
    m_grid->setPen(QPen(Qt::gray));
    for(int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++)
    {
        m_grid->showGrid(scaleId);
    }
    m_grid->setAxisPen(QwtPolar::AxisAzimuth, QPen(Qt::gray));
    m_grid->setAzimuthScaleDraw(new AzimuthScaleDraw());
    m_grid->showAxis(QwtPolar::AxisAzimuth, true);
    m_grid->showAxis(QwtPolar::AxisLeft, false);
    m_grid->showAxis(QwtPolar::AxisRight, true);
    m_grid->showAxis(QwtPolar::AxisTop, false);
    m_grid->showAxis(QwtPolar::AxisBottom, false);
    m_grid->showGrid(QwtPolar::Azimuth, true);
    m_grid->showGrid(QwtPolar::Radius, true);
    m_grid->attach(this);

    setMinimumSize(defaultPlotSize);

    m_currAzimuth = 0;
    QVector<double> azimuth;
    QVector<double> radius;
    azimuth.fill(m_currAzimuth, 2);
    radius.append(0);
    radius.append(maxBeamRadius);
    m_beamCurve = new QwtPolarCurve;
    m_beamCurve->setPen(QPen(QBrush(Qt::green), beamPenWidth));
    m_beamData = new Data(azimuth, radius, beamId);

    m_beamCurve->setData(m_beamData);
    m_beamCurve->attach(this);

    // Blind Zone Curve
    radius.clear();
    azimuth.clear();
    radius.fill(5, 33);
    for(double i = 0; i <= 360; i += 11.25) {
        azimuth.append(i);
    }
    QwtPolarCurve *blindZoneCurve = new QwtPolarCurveJamming;
    blindZoneCurve->setPen(QPen(QBrush(Qt::yellow), 0));
    Data *blindZoneData = new Data(azimuth, radius, 0x10000);
    blindZoneCurve->setData(blindZoneData);
    blindZoneCurve->attach(this);

    m_cycleTime = Cicle10;
    m_azimuthChange->setInterval(cicleInterval);

    m_nextAzimuthData->setInterval(packetsInterval);

    connect(m_azimuthChange, SIGNAL(timeout()), this, SLOT(azimuthChanged()));
    connect(m_nextAzimuthData, SIGNAL(timeout()), this, SLOT(nextAzimuthData()));
//    connect(m_picker, SIGNAL(moved(QwtPointPolar)), this, SLOT(moveMarkID(QwtPointPolar)));
//    connect(m_picker, SIGNAL(appended(QwtPointPolar)), this, SLOT(selectMarkID(QwtPointPolar)));
//    connect(m_picker, SIGNAL(activated(bool)), this, SLOT(stopMoving(bool)));
}