コード例 #1
0
ファイル: scopeplot.cpp プロジェクト: cureton/qsstv
void scopePlot::setCurveOn(int i,bool b)
{
  QwtPlotItemList items = plW->itemList( QwtPlotItem::Rtti_PlotCurve);
  if(i>=items.size()) return;
  const QVariant itemInfo = plW->itemToInfo( items[i] );
  QwtLegendLabel *legendLabel =qobject_cast<QwtLegendLabel *>( legend->legendWidget( itemInfo ) );
  if (legendLabel )
    {
      legendLabel->setChecked(b);
    }

  items[i]->setVisible( b );

}
コード例 #2
0
ファイル: tvplot.cpp プロジェクト: 0vermind/NeoLoader
TVPlot::TVPlot( QWidget *parent ):
    QwtPlot( parent )
{
    setTitle( "Watching TV during a weekend" );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setPalette( Qt::gray );
    canvas->setBorderRadius( 10 );
    setCanvas( canvas );

    plotLayout()->setAlignCanvasToScales( true );

    setAxisTitle( QwtPlot::yLeft, "Number of People" );
    setAxisTitle( QwtPlot::xBottom, "Number of Hours" );

    QwtLegend *legend = new QwtLegend;
    legend->setDefaultItemMode( QwtLegendData::Checkable );
    insertLegend( legend, QwtPlot::RightLegend );

    populate();

    connect( legend, SIGNAL( checked( const QVariant &, bool, int ) ),
        SLOT( showItem( const QVariant &, bool ) ) );

    replot(); // creating the legend items

    QwtPlotItemList items = itemList( QwtPlotItem::Rtti_PlotHistogram );
    for ( int i = 0; i < items.size(); i++ )
    {
        if ( i == 0 )
        {
            const QVariant itemInfo = itemToInfo( items[i] );

            QwtLegendLabel *legendLabel =
                qobject_cast<QwtLegendLabel *>( legend->legendWidget( itemInfo ) );
            if ( legendLabel )
                legendLabel->setChecked( true );

            items[i]->setVisible( true );
        }
        else
        {
            items[i]->setVisible( false );
        }
    }

    setAutoReplot( true );
}
コード例 #3
0
ファイル: cpuplot.cpp プロジェクト: CarnationTL/cpuplotIntg
void CpuPlot::showCurve( QwtPlotItem *item, bool on ) {
    item->setVisible( on );

    QwtLegend *lgd = qobject_cast<QwtLegend *>( legend() );

    QList<QWidget *> legendWidgets =
        lgd->legendWidgets( itemToInfo( item ) );

    if ( legendWidgets.size() == 1 ) {
        QwtLegendLabel *legendLabel =
            qobject_cast<QwtLegendLabel *>( legendWidgets[0] );

        if ( legendLabel )
            legendLabel->setChecked( on );
    }

    replot();
}
コード例 #4
0
ファイル: scopeplot.cpp プロジェクト: cureton/qsstv
void scopePlot::init(QString title)
{
  
  setup=true;
  setCentralWidget(wd);
  connect(ui.offsetWheel, SIGNAL(valueChanged(double)),SLOT(slotOffsetChanged(double )));
  connect(ui.rangeWheel, SIGNAL(valueChanged(double)), SLOT(slotRangeChanged(double )));
  connect(ui.samplesPushButton, SIGNAL(clicked()), this, SLOT(slotSamplesButtton()));
  plW=ui.plotWindow;
  plW->setTitle(title);
  plW->setCanvasBackground(Qt::darkBlue);
  curve1->attach(plW);
  curve2->attach(plW);
  curve3->attach(plW);
  curve4->attach(plW);
  plW->setAxisTitle(QwtPlot::xBottom,xAxisTitle);
  plW->setAxisScale(QwtPlot::xBottom, 0, 100);
  plW->setAxisTitle(QwtPlot::yLeft, "Values");
  plW->setAxisScale(QwtPlot::yLeft, -1.5, 1.5);

  QwtPlotGrid *grid = new QwtPlotGrid;
  grid->enableXMin(true);
  grid->setMajorPen(QPen(Qt::white, 0, Qt::DotLine));
  grid->setMinorPen(QPen(Qt::gray, 0 , Qt::DotLine));
  grid->attach(plW);
  QwtText m1("M1");
  m1.setColor(QColor(Qt::white));
  marker1=new QwtPlotMarker();
  marker1->setValue(0.0, 0.0);
  marker1->setLabel(m1);
  marker1->setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
  marker1->setLinePen(QPen(QColor(200,150,0), 0, Qt::DashDotLine));
  marker1->setSymbol( new QwtSymbol(QwtSymbol::Diamond,QColor(Qt::green), QColor(Qt::green), QSize(7,7)));
  //	marker1->hide();
  marker1->attach(plW);



  QwtText m2("M2");
  m2.setColor(QColor(Qt::white));
  marker2=new QwtPlotMarker();
  marker2->setValue(0.0, 0.0);
  marker2->setLabel(m2);
  marker2->setLabelAlignment(Qt::AlignLeft | Qt::AlignTop);
  marker2->setLinePen(QPen(QColor(200,150,0), 0, Qt::DashDotLine));
  marker2->setSymbol( new QwtSymbol(QwtSymbol::Diamond,QColor(Qt::yellow), QColor(Qt::yellow), QSize(7,7)));
  //	marker2->hide();
  marker2->attach(plW);



  legend = new QwtLegend;
  legend->setFrameStyle(QFrame::Box|QFrame::Sunken);
  legend->setDefaultItemMode(QwtLegendData::Checkable);
  QPalette pal(legend->palette());
  pal.setColor(QPalette::Window,Qt::darkBlue);
  pal.setColor(QPalette::WindowText,Qt::white);
  pal.setColor(QPalette::Text,Qt::black);
  legend->setPalette(pal);
  plW->insertLegend(legend, QwtPlot::BottomLegend);

  picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, plW->canvas());
  picker->setStateMachine(new QwtPickerDragPointMachine());
  picker->setRubberBandPen(QColor(Qt::green));
  picker->setRubberBand(QwtPicker::CrossRubberBand);
  picker->setTrackerPen(QColor(Qt::white));
  picker->setEnabled(true);
  plW->replot();

  QwtPlotItemList items = plW->itemList( QwtPlotItem::Rtti_PlotCurve);
  for ( int i = 0; i < items.size(); i++ )
    {
      const QVariant itemInfo = plW->itemToInfo( items[i] );

      QwtLegendLabel *legendLabel =qobject_cast<QwtLegendLabel *>( legend->legendWidget( itemInfo ) );
      if (legendLabel )
        {
          legendLabel->setChecked( true );
        }

      items[i]->setVisible( true );
    }
  connect(picker, SIGNAL(moved(const QPointF  &)),SLOT(pickerMoved(const QPointF &)));
  connect(picker, SIGNAL(selected(const QPointF  &)), SLOT(pickerSelected(const QPointF  &)));
  connect(legend, SIGNAL(checked(const QVariant &, bool ,int)),SLOT(legendClicked(const QVariant &,bool)));
  connect(ui.nextButton, SIGNAL(clicked()),SLOT(slotNext()));
  connect(ui.previousButton, SIGNAL(clicked()),SLOT(slotPrevious()));
  plW->setAxisTitle(QwtPlot::xBottom,xAxisTitle);
  xOffset=0;
}