当前位置: 首页>>代码示例>>C++>>正文


C++ QwtPlotGrid类代码示例

本文整理汇总了C++中QwtPlotGrid的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotGrid类的具体用法?C++ QwtPlotGrid怎么用?C++ QwtPlotGrid使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QwtPlotGrid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QwtPlot

BrainPlot::BrainPlot(QWidget *parent, int nChannels, int Length, int Amplitude):
    QwtPlot( parent ),
    d_curves( nChannels ),
    d_zeros( nChannels )
{
    /*Set some attributes*/
    minusExpectedAmplitude = -Amplitude;
    plotLength = Length;
    this->nChannels = nChannels;

    /*Start sample counter*/
    sample = 0;

    /*Painter*/
    d_directPainter = new QwtPlotDirectPainter( this );
    if ( QwtPainter::isX11GraphicsSystem() )
    {
#if QT_VERSION < 0x050000
        canvas()->setAttribute( Qt::WA_PaintOutsidePaintEvent, true );
#endif
        canvas()->setAttribute( Qt::WA_PaintOnScreen, true );
    }

    /*Activates the legend for channel tracking*/
    QwtLegend *legend = new QwtLegend;
    legend->setDefaultItemMode( QwtLegendData::ReadOnly);
    insertLegend( legend, QwtPlot::LeftLegend );

    /*Instantiate the reference lines and the data curves for each channel*/
    int Hfactor = 360/(nChannels+1);//different colors for each curve
    char name[15];

    for(int c = 0; c < nChannels; c++) {
        /*Curve*/
        sprintf(name, "Channel %d", c+1);
        d_curves[c] = new QwtPlotCurve( name);
        d_curves[c]->setData( new CurveData(plotLength,
                                            minusExpectedAmplitude*(2*c+1)) );
        d_curves[c]->setPen( QColor::fromHsv ( Hfactor*c, 255, 255));
        d_curves[c]->setStyle( QwtPlotCurve::Lines );
        d_curves[c]->setSymbol( new QwtSymbol( QwtSymbol::NoSymbol));
        d_curves[c]->attach( this );

        /*Reference line*/
        d_zeros[c] = new QwtPlotCurve;
        d_zeros[c]->setData( new CurveData() );
        d_zeros[c]->setPen( QColor::fromHsv ( Hfactor*c, 255, 140));
        d_zeros[c]->setStyle( QwtPlotCurve::Lines );
        d_zeros[c]->setSymbol( new QwtSymbol( QwtSymbol::NoSymbol));
        d_zeros[c]->setItemAttribute(QwtPlotItem::Legend, false);
        d_zeros[c]->attach( this );

        /*Draw reference lines*/
        CurveData *data = static_cast<CurveData *>( d_zeros[c]->data() );
        data->append(QPointF(0, minusExpectedAmplitude*(2*c+1)));
        data->append(QPointF(plotLength, minusExpectedAmplitude*(2*c+1)));
        d_directPainter->drawSeries( d_zeros[c], 0, 1);
    }

    /*Sweeping line*/
    d_sweep = new QwtPlotCurve;
    d_sweep->setData( new CurveData() );
    d_sweep->setPen( Qt::black, plotLength/100, Qt::SolidLine);
    d_sweep->setStyle( QwtPlotCurve::Lines );
    d_sweep->setSymbol( new QwtSymbol( QwtSymbol::NoSymbol));
    d_sweep->setItemAttribute(QwtPlotItem::Legend, false);
    d_sweep->attach( this );

    CurveData *data = static_cast<CurveData *>( d_sweep->data() );
    data->append(QPointF(0, plotLength));
    data->append(QPointF(0, 2*nChannels*minusExpectedAmplitude));

    /*Axis*/
    setAxisScale( xBottom, 0, plotLength );
    setAxisScale( yLeft, 2*nChannels*minusExpectedAmplitude, 0 );

    enableAxis(xBottom, false);
    enableAxis(yLeft, false);

    /*Frame*/
    setFrameStyle( QFrame::NoFrame );
    setLineWidth( 0 );

    /*Canvas*/
    plotLayout()->setAlignCanvasToScales( true );
    plotLayout()->setCanvasMargin(100, QwtPlot::xBottom);
    plotLayout()->setCanvasMargin(100, QwtPlot::xTop);
    setCanvasBackground( Qt::black );

    /*Grid*/
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->setMajorPen( Qt::gray, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0, Qt::DotLine );
    grid->enableYMin(true);
    grid->attach( this );

    /*Optimizaion for real-time data collecting*/
    setAutoReplot( false );

    /*Show*/
//.........这里部分代码省略.........
开发者ID:cogitoergobum,项目名称:eeg,代码行数:101,代码来源:brainplot.cpp

示例2: Variog_multiplot

Variog_multiplot::
Variog_multiplot( const std::vector<Discrete_function>& df_vec,
                  const QStringList& titles,
                  QWidget *parent, const char *name )
       : QwtPlot(parent)
{
  if (name)
    setObjectName(name);
  
  //this->setWindowFlags( Qt::SubWindow|Qt::MSWindowsFixedSizeDialogHint);

  //------------
  // configure the plotting area

  //use a light gray for the grid
  QwtPlotGrid * grid = new QwtPlotGrid();
  grid->enableX(true);
  grid->setPen( QPen( QColor(150,150,150), 0, Qt::DotLine ) );
  grid->attach(this);
    
  // configure the plot axis
  this->axisScaleEngine(QwtPlot::xBottom)->setReference(0);
  this->axisScaleEngine(QwtPlot::yLeft)->setReference(0);
  this->axisScaleEngine(QwtPlot::xBottom)->setMargins(0,0.5);
  this->axisScaleEngine(QwtPlot::yLeft)->setMargins(0,0.5);
  this->axisScaleEngine(QwtPlot::xBottom)->setAttributes(QwtScaleEngine::Floating |
							QwtScaleEngine::IncludeReference);
  this->axisScaleEngine(QwtPlot::yLeft)->setAttributes(QwtScaleEngine::Floating |
							QwtScaleEngine::IncludeReference);


  QFont axis_font =  this->axisFont( QwtPlot::xBottom );
  axis_font.setPointSize( 7 );

  QwtText title("distance");
  title.setFont(axis_font);
  this->setAxisTitle( QwtPlot::xBottom,title);


  //-------------
  this->setWindowTitle( "All Plots" );

  typedef enum QwtSymbol::Style QwtStyleEnum;
  typedef enum Qt::PenStyle QtPenStyleEnum;

  unsigned int dot_styles[8] = { QwtSymbol::Ellipse,
                                  QwtSymbol::Rect,
                                  QwtSymbol::Diamond,
                                  QwtSymbol::DTriangle,
                                  QwtSymbol::UTriangle,
                                  QwtSymbol::RTriangle,
                                  QwtSymbol::Cross,
                                  QwtSymbol::XCross };
  unsigned int line_styles[5] = {Qt::SolidLine, 
                                 Qt::DashLine, 
                                 Qt::DotLine,
                                 Qt::DashDotLine, 
                                 Qt::DashDotDotLine };
  /*
  if( !title.isEmpty() ) {
    QFont title_font;
    title_font.setPointSize( 8 );
    this->setTitle( title );
    this->setTitleFont( title_font );
    this->setCaption( title );
  }
  */
  const float ymargin = 1.05;
  const float xmargin = 1.06;

  float ymax = -9e99;
  float ymin = 9e99;
  float xmax = -9e99;
  for( unsigned int plot_id = 0; plot_id < df_vec.size() ; plot_id++ ) {
    std::vector<double> x_vals = df_vec[plot_id].x_values();
    std::vector<double> y_vals = df_vec[plot_id].y_values();

    double* x = new double[x_vals.size()];
    double* y = new double[x_vals.size()];

    int actual_size = 0;
    for( int i=0 ; i < x_vals.size() ; i++ ) {
      if( GsTL::equals( x_vals[i], df_vec[plot_id].no_data_value(), 0.001 ) ||
          GsTL::equals( y_vals[i], df_vec[plot_id].no_data_value(), 0.001 ) ) continue;

      x[actual_size] = x_vals[i];
      y[actual_size] = y_vals[i];

      actual_size++;
    }
    if( actual_size > 0 ) {
      float current_ymax = *(std::max_element( y, y+actual_size ));
      float current_ymin = *(std::min_element( y, y+actual_size ));
      float current_xmax = *(std::max_element( x, x+actual_size ));

      ymax = std::max(ymax, current_ymax );
      ymin = std::min(ymin, current_ymin );

      xmax = std::max(xmax, current_xmax );
    }
//.........这里部分代码省略.........
开发者ID:DMachuca,项目名称:ar2tech-SGeMS-public,代码行数:101,代码来源:variog_multiplot.cpp

示例3: QwtPlot

Plot::Plot( QWidget *parent ):
    QwtPlot( parent)
{
    setPalette( Qt::black );

    // we want to have the axis scales like a frame around the
    // canvas
    plotLayout()->setAlignCanvasToScales( true );
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
        axisWidget( axis )->setMargin( 0 );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setAutoFillBackground( false );
    canvas->setFrameStyle( QFrame::NoFrame );
    setCanvas( canvas );

    setAxisScale( QwtPlot::yLeft, 0.0, 10.0 );

    // a title
    QwtText title( "Picker Demo" );
    title.setColor( Qt::white );
    title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop );

    QFont font;
    font.setBold( true );
    title.setFont( font );

    QwtPlotTextLabel *titleItem = new QwtPlotTextLabel();
    titleItem->setText( title );
    titleItem->attach( this );

#if 1
    // section

    //QColor c( "PaleVioletRed" );

    QwtPlotZoneItem* zone = new QwtPlotZoneItem();
    zone->setPen( Qt::darkGray );
    zone->setBrush( QColor( "#834358" ) );
    zone->setOrientation( Qt::Horizontal );
    zone->setInterval( 3.8, 5.7 );
    zone->attach( this );

#else
    // grid

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setMajorPen( Qt::white, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );
#endif

    // curves

    QPolygonF points1;
    points1 << QPointF( 0.2, 4.4 ) << QPointF( 1.2, 3.0 )
            << QPointF( 2.7, 4.5 ) << QPointF( 3.5, 6.8 )
            << QPointF( 4.7, 7.9 ) << QPointF( 5.8, 7.1 );

    insertCurve( "Curve 1", "DarkOrange", points1 );

    QPolygonF points2;
    points2 << QPointF( 0.4, 8.7 ) << QPointF( 1.4, 7.8 )
            << QPointF( 2.3, 5.5 ) << QPointF( 3.3, 4.1 )
            << QPointF( 4.4, 5.2 ) << QPointF( 5.6, 5.7 );

    insertCurve( "Curve 2", "DodgerBlue", points2 );

    CurveTracker* tracker = new CurveTracker( this->canvas() );

    // for the demo we want the tracker to be active without
    // having to click on the canvas
    tracker->setStateMachine( new QwtPickerTrackerMachine() );
    tracker->setRubberBandPen( QPen( "MediumOrchid" ) );
}
开发者ID:rickeywang,项目名称:AFM-CLIENT-LIB,代码行数:75,代码来源:plot.cpp

示例4: QwtPlotGrid

void QgsHistogramWidget::drawHistogram()
{
  // clear plot
  mpPlot->detachItems();

  //ensure all children get removed
  mpPlot->setAutoDelete( true );
  // Set axis titles
  if ( !mXAxisTitle.isEmpty() )
    mpPlot->setAxisTitle( QwtPlot::xBottom, mXAxisTitle );
  if ( !mYAxisTitle.isEmpty() )
    mpPlot->setAxisTitle( QwtPlot::yLeft, mYAxisTitle );
  mpPlot->setAxisFont( QwtPlot::xBottom, this->font() );
  mpPlot->setAxisFont( QwtPlot::yLeft, this->font() );
  QFont titleFont = this->font();
  titleFont.setBold( true );
  QwtText xAxisText = mpPlot->axisTitle( QwtPlot::xBottom );
  xAxisText.setFont( titleFont );
  mpPlot->setAxisTitle( QwtPlot::xBottom, xAxisText );
  QwtText yAxisText = mpPlot->axisTitle( QwtPlot::yLeft );
  yAxisText.setFont( titleFont );
  mpPlot->setAxisTitle( QwtPlot::yLeft, yAxisText );
  mpPlot->setAxisAutoScale( QwtPlot::yLeft );
  mpPlot->setAxisAutoScale( QwtPlot::xBottom );

  // add a grid
  QwtPlotGrid *grid = new QwtPlotGrid();
  grid->enableX( false );
  grid->setPen( mGridPen );
  grid->attach( mpPlot );

  // make colors list
  mHistoColors.clear();
  Q_FOREACH ( const QgsRendererRange &range, mRanges )
  {
    mHistoColors << ( range.symbol() ? range.symbol()->color() : Qt::black );
  }

  //draw histogram
  QwtPlotHistogram *plotHistogram = nullptr;
  plotHistogram = createPlotHistogram( !mRanges.isEmpty() ? mRanges.at( 0 ).label() : QString(),
                                       !mRanges.isEmpty() ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
                                       !mRanges.isEmpty() ? Qt::NoPen : mPen );
  QVector<QwtIntervalSample> dataHisto;

  int bins = mBinsSpinBox->value();
  QList<double> edges = mHistogram.binEdges( bins );
  QList<int> counts = mHistogram.counts( bins );

  int rangeIndex = 0;
  int lastValue = 0;

  for ( int bin = 0; bin < bins; ++bin )
  {
    int binValue = counts.at( bin );

    //current bin crosses two graduated ranges, so we split between
    //two histogram items
    if ( rangeIndex < mRanges.count() - 1 && edges.at( bin ) > mRanges.at( rangeIndex ).upperValue() )
    {
      rangeIndex++;
      plotHistogram->setSamples( dataHisto );
      plotHistogram->attach( mpPlot );
      plotHistogram = createPlotHistogram( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
      dataHisto.clear();
      dataHisto << QwtIntervalSample( lastValue, mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) );
    }

    double upperEdge = !mRanges.isEmpty() ? qMin( edges.at( bin + 1 ), mRanges.at( rangeIndex ).upperValue() )
                       : edges.at( bin + 1 );

    dataHisto << QwtIntervalSample( binValue, edges.at( bin ), upperEdge );

    lastValue = binValue;
  }

  plotHistogram->setSamples( dataHisto );
  plotHistogram->attach( mpPlot );

  mRangeMarkers.clear();
  Q_FOREACH ( const QgsRendererRange &range, mRanges )
  {
    QwtPlotMarker *rangeMarker = new QwtPlotMarker();
    rangeMarker->attach( mpPlot );
    rangeMarker->setLineStyle( QwtPlotMarker::VLine );
    rangeMarker->setXValue( range.upperValue() );
    rangeMarker->setLabel( QString::number( range.upperValue() ) );
    rangeMarker->setLabelOrientation( Qt::Vertical );
    rangeMarker->setLabelAlignment( Qt::AlignLeft | Qt::AlignTop );
    rangeMarker->show();
    mRangeMarkers << rangeMarker;
  }
开发者ID:ndavid,项目名称:QGIS,代码行数:92,代码来源:qgshistogramwidget.cpp

示例5: QMainWindow

GraphikSV::GraphikSV(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::GraphikSV)
{
    ui->setupUi(this);
QString b1,b2,b3,b4,b5,b6;
qDebug()<<IDD;

      QSqlQuery queryQ;
      QString e1111 = (QString("SELECT \"Button1\", \"Button2\", \"Button3\", \"Button4\", \"Button5\","
                                 " \"Button6\" FROM \"ResultTest\" where \"StudentId\" = '%1' AND \"Hand\" = '%2'").arg(IDD).arg(1));

      queryQ.exec(e1111);

      while (queryQ.next()) {
          b1=queryQ.value(0).toString();
          b2=queryQ.value(1).toString();
          b3=queryQ.value(2).toString();
          b4=queryQ.value(3).toString();
          b5=queryQ.value(4).toString();
          b6=queryQ.value(5).toString();


      }



    ui->Qwt_Widget->detachItems(QwtPlotItem::Rtti_PlotItem,true);
    ui->Qwt_Widget->setTitle( "График результатов по ведущей руке" );
    ui->Qwt_Widget->setCanvasBackground( Qt::white );

    // Параметры осей координат
    ui->Qwt_Widget->setAxisTitle(QwtPlot::yLeft, "Количество кликов");
    ui->Qwt_Widget->setAxisTitle(QwtPlot::xBottom, "Время, сек");
    QwtPlotPicker *d_picker =
                new QwtPlotPicker(
                    QwtPlot::xBottom, QwtPlot::yLeft, // ассоциация с осями
        QwtPlotPicker::CrossRubberBand, // стиль перпендикулярных линий
        QwtPicker::ActiveOnly, // включение/выключение
        ui->Qwt_Widget->canvas() ); // ассоциация с полем

        // Цвет перпендикулярных линий
        d_picker->setRubberBandPen( QColor( Qt::red ) );

        // цвет координат положения указателя
        d_picker->setTrackerPen( QColor( Qt::black ) );

        // непосредственное включение вышеописанных функций
        d_picker->setStateMachine( new QwtPickerDragPointMachine() );

    ui->Qwt_Widget->setAxisScale(QwtPlot::xBottom, 5, 30, 5);
    ui->Qwt_Widget->setAxisScale(QwtPlot::yLeft, 0, 48, 8);


       QwtPlotGrid *grid = new QwtPlotGrid();
       grid->setMajorPen(QPen( Qt::gray, 2 )); // цвет линий и толщина
       grid->attach( ui->Qwt_Widget );


           curve = new QwtPlotCurve();
           curve->setPen( Qt::green, 6 ); // цвет и толщина кривой

           // Маркеры кривой
           // #include <qwt_symbol.h>
           QwtSymbol *symbol = new QwtSymbol( QwtSymbol::Ellipse,
               QBrush( Qt::yellow ), QPen( Qt::red, 2 ), QSize( 8, 8 ) );
           curve->setSymbol( symbol );

           // Добавить точки на ранее созданную кривую
           // Значения точек записываются в массив, затем считываются
           // из этого массива


             points << QPointF(5, b1.toInt())<<QPointF(10, b2.toInt())<<QPointF(15, b3.toInt())<<QPointF(20, b4.toInt())<<QPointF(25, b5.toInt())<<QPointF(30, b6.toInt());




          // for (int i = 0; i < 5; i++) {
         //      points << QPointF( 1.0 * i, 1.0 * i); // произвольное заполнение
         //  }

           curve->setSamples( points ); // ассоциировать набор точек с кривой

           curve->attach( ui->Qwt_Widget ); // отобразить кривую на графике



 points.clear();

}
开发者ID:vikkylix,项目名称:Tapping-test,代码行数:91,代码来源:graphiksv.cpp

示例6: setAutoReplot

Plot::Plot(QWidget *parent):QwtPlot( parent )
{    setAutoReplot( false );

     setTitle( "FFT" );

     QwtPlotCanvas *canvas = new QwtPlotCanvas();
     canvas->setBorderRadius( 10 );

     setCanvas( canvas );
     setCanvasBackground( QColor( "MidnightBlue" ) );

     // legend
     QwtLegend *legend = new QwtLegend;
     insertLegend( legend, QwtPlot::BottomLegend );

     // grid
     QwtPlotGrid *grid = new QwtPlotGrid;
     grid->enableXMin( true );
     grid->setMajorPen( Qt::white, 0, Qt::DotLine );
     grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
     grid->attach( this );

     // axes
     //enableAxis( QwtPlot::yRight );
     setAxisTitle( QwtPlot::xBottom, "Frequency [kHz]" );
     setAxisTitle( QwtPlot::yLeft, "Amplitude " );
     //setAxisTitle( QwtPlot::yRight, "Phase [deg]" );




     setAxisMaxMajor( QwtPlot::xBottom, 6 );
     setAxisMaxMinor( QwtPlot::xBottom, 9 );


      //setAxisScale(QwtPlot::xBottom,0.01,100);

     //setAxisScaleEngine( QwtPlot::xBottom, ScaleEngine_Lin_X );


     // setAxisScaleEngine(QwtPlot::xBottom, new QwtLogScaleEngine );

     // curves


     d_curve1 = new QwtPlotCurve( "Amplitude Ch1" );
     d_curve1->setRenderHint( QwtPlotItem::RenderAntialiased );
     d_curve1->setPen( Qt::red );
     d_curve1->setLegendAttribute( QwtPlotCurve::LegendShowLine );
     d_curve1->setYAxis( QwtPlot::yLeft );
     d_curve1->attach( this );




     m_Channel2=true;

      if(m_Channel2){
         d_curve2 = new QwtPlotCurve( "Amplitude Ch2 " );
         d_curve2->setRenderHint( QwtPlotItem::RenderAntialiased );
         d_curve2->setPen( Qt::magenta );
         d_curve2->setLegendAttribute( QwtPlotCurve::LegendShowLine );
         d_curve2->setYAxis( QwtPlot::yLeft );
         d_curve2->attach( this );
      }

      d_average = new QwtPlotCurve( "Average Ch1" );
      d_average->setRenderHint( QwtPlotItem::RenderAntialiased );
      d_average->setPen( Qt::white );
      d_average->setLegendAttribute( QwtPlotCurve::LegendShowLine );
      d_average->setYAxis( QwtPlot::yLeft );
      d_average->attach( this );


     // marker
     d_marker1 = new QwtPlotMarker();
     d_marker1->setValue( 0.0, 0.0 );
     d_marker1->setLineStyle( QwtPlotMarker::VLine );
     d_marker1->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
     d_marker1->setLinePen(  Qt::green, 0, Qt::DashDotLine );
     d_marker1->attach( this );

      if(m_Channel2){
        /*  d_marker2 = new QwtPlotMarker();
          d_marker2->setValue( 0.0, 0.0 );
          d_marker2->setLineStyle( QwtPlotMarker::VLine );
          d_marker2->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
          d_marker2->setLinePen(  Qt::gray, 0, Qt::DashDotLine );
          d_marker2->attach( this );*/

          /*
         d_marker2 = new QwtPlotMarker();
         d_marker2->setLineStyle( QwtPlotMarker::HLine );
         d_marker2->setLabelAlignment( Qt::AlignRight | Qt::AlignBottom );
         d_marker2->setLinePen( QColor( 200, 150, 0 ), 0, Qt::DashDotLine );
         d_marker2->setSymbol( new QwtSymbol( QwtSymbol::Diamond,
            QColor( Qt::yellow ), QColor( Qt::green ), QSize( 8, 8 ) ) );
         d_marker2->attach( this );*/
      }

//.........这里部分代码省略.........
开发者ID:digibird1,项目名称:DigitalScope,代码行数:101,代码来源:plot.cpp

示例7: QwtPlot

//---------------------------------------------------------------------------
Plot::Plot( size_t streamPos, size_t Type, size_t Group, QWidget *parent ) :
    QwtPlot( parent ),
    m_streamPos( streamPos ),
    m_type( Type ),
    m_group( Group )
{
    setAutoReplot( false );

    QwtPlotCanvas* canvas = dynamic_cast<QwtPlotCanvas*>( this->canvas() );
    if ( canvas )
    {
        canvas->setFrameStyle( QFrame::Plain | QFrame::Panel );
        canvas->setLineWidth( 1 );
#if 1
        canvas->setPalette( QColor("Cornsilk") );
#endif
    }

    setAxisMaxMajor( QwtPlot::yLeft, 0 );
    setAxisMaxMinor( QwtPlot::yLeft, 0 );
    setAxisScaleDraw( QwtPlot::yLeft, new PlotScaleDrawY() );

    enableAxis( QwtPlot::xBottom, false );

    // something invalid
    setAxisScale( QwtPlot::xBottom, -1, 0 );
    setAxisScale( QwtPlot::yLeft, -1, 0 );

    // Plot grid
    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->enableXMin( true );
    grid->enableYMin( true );
    grid->setMajorPen( Qt::darkGray, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );

    m_cursor = new PlotCursor( canvas );
    m_cursor->setPosition( 0 );

    // curves

    for( unsigned j = 0; j < PerStreamType[m_type].PerGroup[m_group].Count; ++j )
    {
        QwtPlotCurve* curve = new QwtPlotCurve( PerStreamType[m_type].PerItem[PerStreamType[m_type].PerGroup[m_group].Start + j].Name );

        curve->setPen( curveColor( j ) );
        curve->setRenderHint( QwtPlotItem::RenderAntialiased );
        curve->setZ( curve->z() - j ); //Invert data order (e.g. MAX before MIN)
        curve->attach( this );

        m_curves += curve;
    }

    // visual helpers
    if ( m_type == Type_Video )
    switch (m_group)
    {
        case Group_Y :
                        Plot_AddHLine( this,  16,  61,  89, 171);
                        Plot_AddHLine( this, 235, 220,  20,  60);
                        break;
        case Group_U :
        case Group_V :
                        Plot_AddHLine( this,  16,  61,  89, 171);
                        Plot_AddHLine( this, 240, 220,  20,  60);
                        break;
        case Group_Sat :
                        Plot_AddHLine( this,  88, 255,   0, 255);
                        Plot_AddHLine( this, 118, 220,  20,  60);
                        break;
        default      :  ;  
    }

    PlotPicker* picker = new PlotPicker( canvas, &PerStreamType[m_type], m_group, &m_curves );
    connect( picker, SIGNAL( moved( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );
    connect( picker, SIGNAL( selected( const QPointF& ) ), SLOT( onPickerMoved( const QPointF& ) ) );

    connect( axisWidget( QwtPlot::xBottom ), SIGNAL( scaleDivChanged() ), SLOT( onXScaleChanged() ) );

    // legend
    m_legend = new PlotLegend();
    
    connect( this, SIGNAL( legendDataChanged( const QVariant &, const QList<QwtLegendData> & ) ),
         m_legend, SLOT( updateLegend( const QVariant &, const QList<QwtLegendData> & ) ) );

    updateLegend();
}
开发者ID:hsoerensen,项目名称:qctools,代码行数:88,代码来源:Plot.cpp

示例8: QwtPlot

Plot::Plot(QWidget *parent):
    QwtPlot(parent),
    d_paintedPoints(0),
    d_interval(0.0, 10.0),
    d_timerId(-1)
{
    d_directPainter = new QwtPlotDirectPainter();

    setAutoReplot(false);

    // The backing store is important, when working with widget
    // overlays ( f.e rubberbands for zooming ).
    // Here we don't have them and the internal
    // backing store of QWidget is good enough.

    canvas()->setPaintAttribute(QwtPlotCanvas::BackingStore, false);


#if defined(Q_WS_X11)
    // Even if not recommended by TrollTech, Qt::WA_PaintOutsidePaintEvent
    // works on X11. This has a nice effect on the performance.

    canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);

    // Disabling the backing store of Qt improves the performance
    // for the direct painter even more, but the canvas becomes
    // a native window of the window system, receiving paint events
    // for resize and expose operations. Those might be expensive
    // when there are many points and the backing store of
    // the canvas is disabled. So in this application
    // we better don't both backing stores.

    if ( canvas()->testPaintAttribute( QwtPlotCanvas::BackingStore ) )
    {
        canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
        canvas()->setAttribute(Qt::WA_NoSystemBackground, true);
    }

#endif

    initGradient();

    plotLayout()->setAlignCanvasToScales(true);

    setAxisTitle(QwtPlot::xBottom, "Time [s]");
    setAxisScale(QwtPlot::xBottom, d_interval.minValue(), d_interval.maxValue());
    setAxisScale(QwtPlot::yLeft, -200.0, 200.0);

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setPen(QPen(Qt::gray, 0.0, Qt::DotLine));
    grid->enableX(true);
    grid->enableXMin(true);
    grid->enableY(true);
    grid->enableYMin(false);
    grid->attach(this);

    d_origin = new QwtPlotMarker();
    d_origin->setLineStyle(QwtPlotMarker::Cross);
    d_origin->setValue(d_interval.minValue() + d_interval.width() / 2.0, 0.0);
    d_origin->setLinePen(QPen(Qt::gray, 0.0, Qt::DashLine));
    d_origin->attach(this);

    d_curve = new QwtPlotCurve();
    d_curve->setStyle(QwtPlotCurve::Lines);
    d_curve->setPen(QPen(Qt::green));
#if 1
    d_curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
#endif
#if 1
    d_curve->setPaintAttribute(QwtPlotCurve::ClipPolygons, false);
#endif
    d_curve->setData(new CurveData());
    d_curve->attach(this);
}
开发者ID:BryanF1947,项目名称:GoldenCheetah,代码行数:74,代码来源:plot.cpp

示例9: setupUi

chooseCyclesForm::chooseCyclesForm(model* mainModelGiven, bool showAlreadyPrecalcedCycles){

	// open log file
	log.open("chooseCyclesForm.log");
	log << "constructor call" << std::endl;
	FFTSignal = NULL;
	justDeletedMaker = NULL;


	// attach ui form
	setupUi(this);


	mainModel = mainModelGiven;
	peakSignal = mainModel->givePeakSignal();
	// ask to evaluate peak signal
	//askMainModelToEvaluate();
	// and take it
	//peakSignal = mainModel->givePeakSignal();




	// peak signal plot
	qwtPlot_peakSignal->setAutoReplot(false);

	qwtPlot_peakSignal->setCanvasBackground(QColor(Qt::darkBlue));
	qwtPlot_peakSignal->setTitle("peak signal");
	qwtPlot_peakSignal->setAxisTitle(QwtPlot::xBottom, "FFT cycles");
	qwtPlot_peakSignal->setAxisTitle(QwtPlot::yLeft, "Amplitude");

	QwtLegend *legend = new QwtLegend;
    qwtPlot_peakSignal->insertLegend(legend, QwtPlot::BottomLegend);

	QwtPlotGrid *grid = new QwtPlotGrid;
	grid->enableXMin(true);
	grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
	grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
	grid->attach(qwtPlot_peakSignal);

	peakSignalCurve1 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	peakSignalCurve1->setPen(QPen(Qt::cyan));
	peakSignalCurve1->attach(qwtPlot_peakSignal);

	peakSignalCurve2 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	peakSignalCurve2->setPen(QPen(Qt::yellow));
	peakSignalCurve2->attach(qwtPlot_peakSignal);

	showPeakSignal1(0);
	showPeakSignal2(0);

	qwtPlot_peakSignal->setAutoReplot(true);
	// end of peak signal plot




	//FFTSignal
	qwtPlot_FFTCycle->setAutoReplot(false);

	qwtPlot_FFTCycle->setCanvasBackground(QColor(Qt::darkBlue));
	qwtPlot_FFTCycle->setTitle("FFT signal");
	qwtPlot_FFTCycle->setAxisTitle(QwtPlot::xBottom, "FFT beans");
	qwtPlot_FFTCycle->setAxisTitle(QwtPlot::yLeft, "Amplitude");
	
	/*
	qwtPlot_FFTCycle->setAxisTitle(QwtPlot::xTop, "FFT beans");
	QwtInterval interval = qwtPlot_FFTCycle->axisInterval(QwtPlot::xBottom);
	double left = interval.minValue();
	double right = interval.maxValue();
	qwtPlot_FFTCycle->setAxisScale(QwtPlot::xTop, left, right);
	*/

	QwtLegend *legendFFTSignal = new QwtLegend;
    qwtPlot_FFTCycle->insertLegend(legendFFTSignal, QwtPlot::BottomLegend);

	QwtPlotGrid *gridFFTSignal = new QwtPlotGrid;
	gridFFTSignal->enableXMin(true);
	gridFFTSignal->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
	gridFFTSignal->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
	gridFFTSignal->attach(qwtPlot_FFTCycle);

	FFTSignalCurve1 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	FFTSignalCurve1->setPen(QPen(Qt::cyan));
	FFTSignalCurve1->attach(qwtPlot_FFTCycle);

	FFTSignalCurve2 = new QwtPlotCurve("Gidrophone 0 peakSignal");
	FFTSignalCurve2->setPen(QPen(Qt::yellow));
	FFTSignalCurve2->attach(qwtPlot_FFTCycle);

	qwtPlot_FFTCycle->setAutoReplot(true);
	// end of FFT signal plot



	// zoomer and picker and smth else
	// recreare zoomer each time we get new data in the plot
	reCreateZoomer();
	reCreateZoomer2nd();
	// end of zoomer and picker and smth else
//.........这里部分代码省略.........
开发者ID:duckens,项目名称:projects,代码行数:101,代码来源:chooseCyclesForm.cpp

示例10: QwtPlot

Plot::Plot(QWidget *parent):
    QwtPlot(parent),
    d_paintedPoints0(0),
    d_paintedPoints1(0),
    d_interval(0.0, 25.0),
    d_timerId(-1)
{
    d_directPainter0 = new QwtPlotDirectPainter();

    setAutoReplot(false);

    canvas()->setPaintAttribute(QwtPlotCanvas::BackingStore, false);


#if defined(Q_WS_X11)
    
    canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);

    if ( canvas()->testPaintAttribute( QwtPlotCanvas::BackingStore ) )
    {
        canvas()->setAttribute(Qt::WA_PaintOnScreen, true);
        canvas()->setAttribute(Qt::WA_NoSystemBackground, true);
    }

#endif

    initGradient();

    plotLayout()->setAlignCanvasToScales(true);

    setAxisTitle(QwtPlot::xBottom, "Time [s]");
    setAxisScale(QwtPlot::xBottom, d_interval.minValue(), d_interval.maxValue()); 
    setAxisScale(QwtPlot::yLeft, 0, 10.0);

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setPen(QPen(Qt::green, 0.0, Qt::DotLine));
    grid->enableX(true);
    grid->enableXMin(true);
    grid->enableY(true);
    grid->enableYMin(false);
    grid->attach(this);

    d_origin = new QwtPlotMarker();
    d_origin->setLineStyle(QwtPlotMarker::Cross);
    d_origin->setValue(d_interval.minValue() + d_interval.width() / 2.0, 0.0);
    d_origin->setLinePen(QPen(Qt::red, 0.0, Qt::DashLine));
    d_origin->attach(this);

    d_curve0 = new QwtPlotCurve();
    d_curve0->setStyle(QwtPlotCurve::Lines);
    d_curve0->setPen(QPen(Qt::green,3));
#if 1
    d_curve0->setRenderHint(QwtPlotItem::RenderAntialiased, true);
#endif
#if 1
    d_curve0->setPaintAttribute(QwtPlotCurve::ClipPolygons, false);
#endif
    d_curve0->setData(new CurveData());
    d_curve0->attach(this);

    d_curve1 = new QwtPlotCurve();
    d_curve1->setStyle(QwtPlotCurve::Lines);
    d_curve1->setPen(QPen(Qt::red,3));
#if 1
    d_curve1->setRenderHint(QwtPlotItem::RenderAntialiased, true);
#endif
#if 1
    d_curve1->setPaintAttribute(QwtPlotCurve::ClipPolygons, false);
#endif
    d_curve1->setData(new CurveData());
    d_curve1->attach(this);
}
开发者ID:d2mitry,项目名称:d2m_reno,代码行数:72,代码来源:plot.cpp

示例11: QDialog

ProcessDialog::ProcessDialog (QWidget *parent) : QDialog (parent)
{
	setupUi (this);
	writeThread = new DThread;
	saver = new DSaver;
	aCurve = new DCurve;
	config = new DConfig;
	fprintf (stderr, "Objects initialized.\n");	
	zone_length = config->measure_num;
	zone_length_spin->setValue (zone_length);
	start_x = 0;
//	zone_length = 50;
//	start_x = 0;
//	end_x = zone_length;
	// ############## STANDART WIDGETS INITIALIZATION ############
	
	//zone_length_spin->setValue (static_cast<int>(aCurve->zone_length));
//	zone_length_spin->setValue (50);
//	QString scale_temp = QString::number (aCurve->maxX/zone_length, 'g', 4);
//	scale_value_label->setText (scale_temp); 
	saver->set_file_name ("default.dat");
	running = false;
	indicator_label->setText ("<font color=red> <b> NOT RUNNING </b> </font>");
	tabWidget->setTabText (0, "Diagram");
	tabWidget->setTabText (1, "Scheme");

	/*	Connections	*/
	connect (aCurve, SIGNAL ( pack_accepted () ), plot, SLOT ( replot() ));
	connect (aCurve, SIGNAL ( pack_accepted () ), this, SLOT (graph_next_frame()) );
	connect (writeThread, SIGNAL ( text_data (DPack *) ), this, SLOT ( process_pack (DPack *) ));
	connect (writeThread, SIGNAL ( chart_data (DPack *) ), aCurve, SLOT ( accept_data_pack (DPack *) ));
	connect (writeThread, SIGNAL ( save_data (DPack *) ), saver, SLOT (accept_data_pack (DPack *) ));
	connect (writeThread, SIGNAL ( done()), this, SLOT ( done()));
	connect (this, SIGNAL (rejected()), writeThread, SLOT (stop_thread()));
	// test routine
//	connect (this, SIGNAL (test_data_pack (DPack *)), this, SLOT ( process_pack (DPack *) ));
//	connect (this, SIGNAL (test_data_pack (DPack *)), aCurve, SLOT ( accept_data_pack (DPack *) ));
//	connect (this, SIGNAL (test_data_pack (DPack *)), saver, SLOT ( accept_data_pack (DPack *) ));
	/*	Properties	*/
	connect (channel1_box, SIGNAL (clicked()), this, SLOT (channel1_box_clicked()));
	connect (channel2_box, SIGNAL (clicked()), this, SLOT (channel2_box_clicked()));
	connect (channel3_box, SIGNAL (clicked()), this, SLOT (channel3_box_clicked()));
	connect (channel4_box, SIGNAL (clicked()), this, SLOT (channel4_box_clicked()));
	connect (channel5_box, SIGNAL (clicked()), this, SLOT (channel5_box_clicked()));
	connect (channel6_box, SIGNAL (clicked()), this, SLOT (channel6_box_clicked()));
	connect (zone_length_spin, SIGNAL (valueChanged (int)), this, SLOT (graph_update (int)));
	connect (this, SIGNAL (closed()), this, SLOT (renew()));
	
	fprintf (stderr, "Connections established,\n");
	// ###################  QwtPlot initialization ########################
       	for (int a = 0; a < 6; a ++)
	{
		QPen pen = QPen (config->colors[a]);
		pen.setWidth(2);
		aCurve->channel_curve[a]->setPen (pen);
        	aCurve->channel_curve[a]->attach (plot);
	}

        aCurve->setMaxX (config->measure_num); 
        aCurve->setStepX (config->chart_mod);
	fprintf (stderr, "ProcessDialog: stepx = config->chart_mod = %d.\n", config->chart_mod);

	QwtPlotGrid *grid = new QwtPlotGrid;
	
	grid->setMajPen (QPen (Qt::gray, 0, Qt::DotLine));
	grid->attach (plot);
	
	plot->setTitle ("Graphics diagram");
	plot->setCanvasBackground (Qt::white);
	plot->setAxisTitle (0,"Signal, V");
	plot->setAxisTitle (2,"Measure, num");
//	plot->setAxisScale (2, start_x, end_x, zone_length/10);		
	plot->setAxisScale (2, 0, config->measure_num, config->measure_num/10);
	//graph_update(zone_length);
	
	// ##################### TABLE INITIALIZATION #####################

	row = -1;
	display_table->setColumnCount (6);
	display_table->setRowCount(config->measure_num); 	
	for (int i = 0; i < 6; i++)
	{
		display_table->setColumnWidth (i, 40);
	}

	// ########### CHANNEL GROUP ######################

	QString temp = tr("<font color='%1'>%2</font>");
	QString text = "Ch1";
	channel1_label->setText (temp.arg (config->colors[0].name(), text));
	
	temp = tr("<font color='%1'>%2</font>");
	text = "Ch2";
	channel2_label->setText (temp.arg (config->colors[1].name(), text));
	
	temp = tr("<font color='%1'>%2</font>");
	text = "Ch3";
	channel3_label->setText (temp.arg (config->colors[2].name(), text));

	temp = tr("<font color='%1'>%2</font>");
//.........这里部分代码省略.........
开发者ID:infernal666knight,项目名称:opendaq,代码行数:101,代码来源:processdialog.cpp

示例12: QDialog

QmitkHistogramWidget::QmitkHistogramWidget(QWidget * parent, bool showreport)
  : QDialog(parent)
  , m_Plot(NULL)
  , m_Textedit(NULL)
  , m_Marker(NULL)
  , m_Picker(NULL)
  , m_Zoomer(NULL)
  , m_Histogram(NULL)
{
  QBoxLayout *layout = new QVBoxLayout(this);

  //***histogram***

  QGroupBox *hgroupbox = new QGroupBox("", this);

  hgroupbox->setMinimumSize(900, 400);

  m_Plot = new QwtPlot(hgroupbox);
  m_Plot->setCanvasBackground(QColor(Qt::white));
  m_Plot->setTitle("Histogram");
  QwtText text = m_Plot->titleLabel()->text();
  text.setFont(QFont("Helvetica", 12, QFont::Normal));

  QwtPlotGrid *grid = new QwtPlotGrid;
  grid->enableXMin(true);
  grid->enableYMin(true);
  grid->setMajorPen(QPen(Qt::black, 0, Qt::DotLine));
  grid->setMinorPen(QPen(Qt::gray, 0 , Qt::DotLine));
  grid->attach(m_Plot);

  layout->addWidget(hgroupbox);

  layout->setSpacing(20);

  if (showreport == true)
  {
    //***report***
    QGroupBox *rgroupbox = new QGroupBox("", this);

    rgroupbox->setMinimumSize(900, 400);

    QLabel *label = new QLabel("Gray  Value  Analysis", rgroupbox);
    label->setAlignment(Qt::AlignHCenter);
    label->setFont(QFont("Helvetica", 14, QFont::Bold));

    m_Textedit = new QTextEdit(rgroupbox);
    m_Textedit->setFont(QFont("Helvetica", 12, QFont::Normal));
    m_Textedit->setReadOnly(true);

    layout->addWidget(rgroupbox);
  }

  m_Picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                               QwtPlotPicker::NoRubberBand, QwtPicker::AlwaysOn,
                               m_Plot->canvas());
  // the m_PickerMachine pointer is managed by the m_Picker instance
  m_Picker->setStateMachine(new QwtPickerClickPointMachine());

  connect(m_Picker, SIGNAL(selected(const QwtDoublePoint &)),
    SLOT(OnSelect(const QwtDoublePoint &)));
}
开发者ID:GHfangxin,项目名称:MITK,代码行数:61,代码来源:QmitkHistogramWidget.cpp

示例13: QwtPlot

EcgCh::EcgCh(QWidget *parent) :
    QwtPlot(parent)
{
     setMinimumHeight(10);
     setMinimumWidth(10);
     QwtPlotGrid *grid = new QwtPlotGrid;
     grid->enableXMin(true);
     grid->setMajPen(QPen(Qt::white, 0, Qt::DotLine));
     grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
     grid->attach(this);
     setAxisTitle(QwtPlot::xBottom, "Czas [mm:ss.ms]");
     setAxisTitle(QwtPlot::yLeft, "Amplituda [mV]");

     signalCurve = new QwtPlotCurve("signal");
     signalCurve->setYAxis(QwtPlot::yLeft);
     signalCurve->attach(this);
     peaksCurve = new QwtPlotCurve("r-peaks");
     peaksCurve->setYAxis(QwtPlot::yLeft);
     peaksCurve->setStyle(QwtPlotCurve::NoCurve);
     peaksCurve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QColor(Qt::red), QColor(Qt::red), QSize(6, 6)));
     peaksCurve->setPen(QPen(Qt::red, 5));
     peaksCurve->attach(this);

     qrsOnSetCurve = new QwtPlotCurve("qrsOnSet");
     qrsOnSetCurve->setYAxis(QwtPlot::yLeft);
     qrsOnSetCurve->setStyle(QwtPlotCurve::NoCurve);
     qrsOnSetCurve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QColor(0,255,0), QColor(0,255,0), QSize(6, 6)));
     qrsOnSetCurve->attach(this);

     qrsEndSetCurve = new QwtPlotCurve("qrsEndSet");
     qrsEndSetCurve->setYAxis(QwtPlot::yLeft);
     qrsEndSetCurve->setStyle(QwtPlotCurve::NoCurve);
     qrsEndSetCurve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QColor(0,150,0), QColor(0,150,0), QSize(6, 6)));
     qrsEndSetCurve->attach(this);

     pOnSetCurve = new QwtPlotCurve("pOnSet");
     pOnSetCurve->setYAxis(QwtPlot::yLeft);
     pOnSetCurve->setStyle(QwtPlotCurve::NoCurve);
     pOnSetCurve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QColor(0,0,255), QColor(0,0,255), QSize(6, 6)));
     pOnSetCurve->attach(this);

     pEndSetCurve = new QwtPlotCurve("pEndSet");
     pEndSetCurve->setYAxis(QwtPlot::yLeft);
     pEndSetCurve->setStyle(QwtPlotCurve::NoCurve);
     pEndSetCurve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QColor(0,94,185), QColor(0,94,185), QSize(6, 6)));
     pEndSetCurve->attach(this);

     tEndSetCurve = new QwtPlotCurve("tEndSet");
     tEndSetCurve->setYAxis(QwtPlot::yLeft);
     tEndSetCurve->setStyle(QwtPlotCurve::NoCurve);
     tEndSetCurve->setSymbol(new QwtSymbol(QwtSymbol::Ellipse,QColor(116,11,11), QColor(116,11,11), QSize(6, 6)));
     tEndSetCurve->attach(this);

     vCurve = new QwtPlotCurve("V");
     vCurve->setYAxis(QwtPlot::yLeft);
     vCurve->setStyle(QwtPlotCurve::NoCurve);
     vCurve->setSymbol(new QwtSymbol(QwtSymbol::Triangle,QColor(Qt::red), QColor(Qt::red), QSize(6, 6)));
     vCurve->attach(this);
     vCurve->setVisible(false);

     svCurve = new QwtPlotCurve("SV");
     svCurve->setYAxis(QwtPlot::yLeft);
     svCurve->setStyle(QwtPlotCurve::NoCurve);
     svCurve->setSymbol(new QwtSymbol(QwtSymbol::Star1,QColor(Qt::red), QColor(Qt::red), QSize(6, 6)));
     svCurve->attach(this);
     svCurve->setVisible(false);

     setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw(360.0));

     replot();
}
开发者ID:Basildcruz,项目名称:ECG-analyzer,代码行数:71,代码来源:ecgch.cpp

示例14: switch

void QwtPlotPrintFilter::reset(QwtPlotItem *item) const
{
    if ( d_data->cache == 0 )
        return;

    const PrivateData::Cache &cache = *d_data->cache;

    switch(item->rtti())
    {
        case QwtPlotItem::Rtti_PlotGrid:
        {
            QwtPlotGrid *grid = (QwtPlotGrid *)item;

            QPen pen = grid->majPen();
            pen.setColor(cache.gridColors[0]);
            grid->setMajPen(pen);

            pen = grid->minPen();
            pen.setColor(cache.gridColors[1]);
            grid->setMinPen(pen);

            break;
        }
        case QwtPlotItem::Rtti_PlotCurve:
        {
            QwtPlotCurve *c = (QwtPlotCurve *)item;

            QwtSymbol symbol = c->symbol();

            if ( cache.curveSymbolPenColors.contains(c) )
            {
                symbol.setPen(cache.curveSymbolPenColors[c]);
            }

            if ( cache.curveSymbolBrushColors.contains(c) )
            {
                QBrush brush = symbol.brush();
                brush.setColor(cache.curveSymbolBrushColors[c]);
                symbol.setBrush(brush);
            }
            c->setSymbol(symbol);

            if ( cache.curveColors.contains(c) )
            {
                QPen pen = c->pen();
                pen.setColor(cache.curveColors[c]);
                c->setPen(pen);
            }

            break;
        }
        case QwtPlotItem::Rtti_PlotMarker:
        {
            QwtPlotMarker *m = (QwtPlotMarker *)item;

            if ( cache.markerFonts.contains(m) )
            {
                QwtText label = m->label();
                label.setFont(cache.markerFonts[m]);
                m->setLabel(label);
            }

            if ( cache.markerLabelColors.contains(m) )
            {
                QwtText label = m->label();
                label.setColor(cache.markerLabelColors[m]);
                m->setLabel(label);
            }

            if ( cache.markerLineColors.contains(m) )
            {
                QPen pen = m->linePen();
                pen.setColor(cache.markerLineColors[m]);
                m->setLinePen(pen);
            }
            
            QwtSymbol symbol = m->symbol();

            if ( cache.markerSymbolPenColors.contains(m) )
            {
                QPen pen = symbol.pen();
                pen.setColor(cache.markerSymbolPenColors[m]);
                symbol.setPen(pen);
            }

            if ( cache.markerSymbolBrushColors.contains(m) )
            {
                QBrush brush = symbol.brush();
                brush.setColor(cache.markerSymbolBrushColors[m]);
                symbol.setBrush(brush);
            }

            m->setSymbol(symbol);

            break;
        }
        default:
            break;
    }
}
开发者ID:BijanZarif,项目名称:coolfluid3,代码行数:100,代码来源:qwt_plot_printfilter.cpp

示例15: qSort

void QgsHistogramWidget::drawHistogram()
{
  if ( !mVectorLayer || mSourceFieldExp.isEmpty() )
    return;

  QApplication::setOverrideCursor( Qt::WaitCursor );

  if ( mValues.empty() )
  {
    bool ok;
    mValues = mVectorLayer->getDoubleValues( mSourceFieldExp, ok );

    if ( ! ok )
    {
      QApplication::restoreOverrideCursor();
      return;
    }
    qSort( mValues.begin(), mValues.end() );
    mHistogram.setValues( mValues );
    mBinsSpinBox->blockSignals( true );
    mBinsSpinBox->setValue( qMax( mHistogram.optimalNumberBins(), 30 ) );
    mBinsSpinBox->blockSignals( false );

    mStats.setStatistics( QgsStatisticalSummary::StDev );
    mStats.calculate( mValues );
  }

  // clear plot
  mpPlot->detachItems();

  //ensure all children get removed
  mpPlot->setAutoDelete( true );
  // Set axis titles
  mpPlot->setAxisTitle( QwtPlot::xBottom, QObject::tr( "Value" ) );
  mpPlot->setAxisTitle( QwtPlot::yLeft, QObject::tr( "Count" ) );
  mpPlot->setAxisAutoScale( QwtPlot::yLeft );
  mpPlot->setAxisAutoScale( QwtPlot::xBottom );

  // add a grid
  QwtPlotGrid * grid = new QwtPlotGrid();
  grid->enableX( false );
  grid->setPen( mGridPen );
  grid->attach( mpPlot );

  // make colors list
  mHistoColors.clear();
  foreach ( QgsRendererRangeV2 range, mRanges )
  {
    mHistoColors << ( range.symbol() ? range.symbol()->color() : Qt::black );
  }

  //draw histogram
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
  QwtPlotHistogram * plotHistogram = 0;
  plotHistogram = createPlotHistogram( mRanges.count() > 0 ? mRanges.at( 0 ).label() : QString(),
                                       mRanges.count() > 0 ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
                                       mRanges.count() > 0 ? Qt::NoPen : mPen );
#else
  HistogramItem *plotHistogramItem = 0;
  plotHistogramItem = createHistoItem( mRanges.count() > 0 ? mRanges.at( 0 ).label() : QString(),
                                       mRanges.count() > 0 ? QBrush( mHistoColors.at( 0 ) ) : mBrush,
                                       mRanges.count() > 0 ? Qt::NoPen : mPen );
#endif

#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
  QVector<QwtIntervalSample> dataHisto;
#else

  // we safely assume that QT>=4.0 (min version is 4.7), therefore QwtArray is a QVector, so don't set size here
  QwtArray<QwtDoubleInterval> intervalsHisto;
  QwtArray<double> valuesHisto;

#endif

  int bins = mBinsSpinBox->value();
  QList<double> edges = mHistogram.binEdges( bins );
  QList<int> counts = mHistogram.counts( bins );

  int rangeIndex = 0;
  int lastValue = 0;

  for ( int bin = 0; bin < bins; ++bin )
  {
    int binValue = counts.at( bin );

    //current bin crosses two graduated ranges, so we split between
    //two histogram items
    if ( rangeIndex < mRanges.count() - 1 && edges.at( bin ) > mRanges.at( rangeIndex ).upperValue() )
    {
      rangeIndex++;
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
      plotHistogram->setSamples( dataHisto );
      plotHistogram->attach( mpPlot );
      plotHistogram = createPlotHistogram( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
      dataHisto.clear();
      dataHisto << QwtIntervalSample( lastValue, mRanges.at( rangeIndex - 1 ).upperValue(), edges.at( bin ) );
#else
      plotHistogramItem->setData( QwtIntervalData( intervalsHisto, valuesHisto ) );
      plotHistogramItem->attach( mpPlot );
      plotHistogramItem = createHistoItem( mRanges.at( rangeIndex ).label(), mHistoColors.at( rangeIndex ) );
//.........这里部分代码省略.........
开发者ID:Br1ndavoine,项目名称:QGIS,代码行数:101,代码来源:qgshistogramwidget.cpp


注:本文中的QwtPlotGrid类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。