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


C++ QwtLegend::setItemMode方法代码示例

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


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

示例1: setupPlot

void MainWindow::setupPlot()
{
    plotTimer.setInterval(1000/settingsDialog->rate);
    connect(&plotTimer, SIGNAL(timeout()), this, SLOT(plotUpdate()));
    plotTimer.start();

    if (!ui->plot->legend()) {
        QwtLegend* legend = new QwtLegend;
        legend->setItemMode(QwtLegend::CheckableItem);
        ui->plot->insertLegend(legend, QwtPlot::RightLegend);
    }

    ui->plot->setAxisTitle(QwtPlot::xBottom, "seconds");
    ui->plot->setCanvasBackground(Qt::white);

    QColor gridColor;
    gridColor.setNamedColor("grey");
    QPen gridPen(gridColor);
    gridPen.setStyle(Qt::DotLine);
    QwtPlotGrid* grid = new QwtPlotGrid;
    grid->setMajPen(gridPen);
    grid->attach(ui->plot);

    connect(ui->plot, SIGNAL(legendChecked(QwtPlotItem*,bool)), this, SLOT(showCurve(QwtPlotItem*,bool)));
}
开发者ID:OwenBrotherwood,项目名称:vag-blocks,代码行数:25,代码来源:mainwindow.cpp

示例2: init

void GenericHistogramView::init()
{
  this->setMouseTracking(true); //Switch on mouse tracking (no need to press button)

  _qwtPlot->setTitle("Histogram");
  
  _qwtPlot->setCanvasBackground(QColor(Qt::gray));
  _qwtPlot->plotLayout()->setAlignCanvasToScales(true);

  _qwtPlot->setAxisTitle(QwtPlot::yLeft, "Number of specimen");
  _qwtPlot->setAxisTitle(QwtPlot::xBottom, "Pixel value");

	QwtLegend* legend = new QwtLegend();
  legend->setItemMode(QwtLegend::CheckableItem);
  _qwtPlot->insertLegend(legend, QwtPlot::RightLegend);

  populate();
  
  _qwtPlot->canvas()->setMouseTracking(true);
  
  if(_horizontal)
  _principalPicker = new HistogramPicker(QwtPlotPicker::HLineRubberBand, QwtPicker::AlwaysOn, _qwtPlot->canvas());
  else
  _principalPicker = new HistogramPicker(QwtPlotPicker::VLineRubberBand, QwtPicker::AlwaysOn, _qwtPlot->canvas());
  _principalPicker->setStateMachine(new QwtPickerDragPointMachine());
  _principalPicker->setTrackerPen(QColor(Qt::white));
  _principalPicker->setRubberBandPen(QColor(Qt::yellow));
  
  _leftPicker = new HistogramPicker(_qwtPlot->canvas());
  _leftPicker->setStateMachine(new QwtPickerDragPointMachine());
  
  _rightPicker = new HistogramPicker(_qwtPlot->canvas());
  _rightPicker->setStateMachine(new QwtPickerDragPointMachine());
  _rightPicker->setRubberBand(QwtPlotPicker::VLineRubberBand);
  _rightPicker->setRubberBandPen(QColor(Qt::yellow));
	_rightPicker->setMousePattern(QwtPicker::MouseSelect1, Qt::RightButton);

  connect(_qwtPlot, SIGNAL(legendChecked(QwtPlotItem*, bool)), this, SLOT(showItem(QwtPlotItem*, bool)));
  connect(_rightPicker, SIGNAL(selected(const QPointF&)), this, SLOT(rightClick(const QPointF&)));
  connect(_leftPicker, SIGNAL(selected(const QPointF&)), this, SLOT(leftClick(const QPointF&)));
  connect(_principalPicker, SIGNAL(moved(const QPointF&)), this, SLOT(move(const QPointF&)));

  _qwtPlot->replot(); // creating the legend items

  QwtPlotItemList items = _qwtPlot->itemList(QwtPlotItem::Rtti_PlotHistogram);
  for(int i = 0; i < items.size(); i++)
  {
      QwtLegendItem* legendItem = qobject_cast<QwtLegendItem*>(legend->find(items[i]));
      if(legendItem)
    legendItem->setChecked(true);

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

  _qwtPlot->setAutoReplot(true);
}
开发者ID:detiq-t,项目名称:detiq-t_old,代码行数:56,代码来源:GenericHistogramView.cpp

示例3: QwtPlot

CopasiPlot::CopasiPlot(const CPlotSpecification* plotspec, QWidget* parent):
  QwtPlot(parent),
  mCurves(0),
  mCurveMap(),
  mDataBefore(0),
  mDataDuring(0),
  mDataAfter(0),
  mHaveBefore(false),
  mHaveDuring(false),
  mHaveAfter(false),
  mpPlotSpecification(NULL),
  mNextPlotTime(),
  mIgnoreUpdate(false),
  mpZoomer(NULL),
  mReplotFinished(false)
{
  QwtLegend *legend = new QwtLegend;
  legend->setItemMode(QwtLegend::CheckableItem);

  // whole legend can not be displayed at bottom on DARWIN
  // maybe a Qwt bug ?!?
#ifdef Darwin
  insertLegend(legend, QwtPlot::TopLegend);
#else
  insertLegend(legend, QwtPlot::BottomLegend);
#endif

  // Set up the zoom facility
  mpZoomer = new ScrollZoomer(canvas());
  mpZoomer->setRubberBandPen(QColor(Qt::black));
  mpZoomer->setTrackerPen(QColor(Qt::black));
  mpZoomer->setTrackerMode(QwtPicker::AlwaysOn);
  mpZoomer->setTrackerFont(this->font());

  // white background better for printing...
  setCanvasBackground(Qt::white);

  //  setTitle(FROM_UTF8(plotspec->getTitle()));
  setCanvasLineWidth(0);

  canvas()->setPaintAttribute(QwtPlotCanvas::PaintPacked, true);

  connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)),
          SLOT(showCurve(QwtPlotItem *, bool)));

  // Size the vectors to be able to store information for all activities.
  mData.resize(ActivitySize);
  mObjectValues.resize(ActivitySize);
  mObjectInteger.resize(ActivitySize);
  mDataSize.resize(ActivitySize);
  mDataIndex.clear();

  // Initialize from the plot specification
  initFromSpec(plotspec);
  connect(this, SIGNAL(replotSignal()), this, SLOT(replot()));
}
开发者ID:bmoreau,项目名称:COPASI,代码行数:56,代码来源:CopasiPlot.cpp

示例4: QwtPlot

MavPlot::MavPlot(QWidget *parent) : QwtPlot(parent), _havePrintColors(false) {
    setAutoReplot(false);
    setTitle("MAV System Data Plot");
    setCanvasBackground(QColor(Qt::darkGray));

    // legend
    QwtLegend *legend = new QwtLegend;
    insertLegend(legend, QwtPlot::BottomLegend);
    #if (QWT_VERSION < QWT_VERSION_CHECK(6,1,0))
        legend->setItemMode(QwtLegend::ClickableItem);
        connect(this, SIGNAL(legendClicked(QwtPlotItem*)), SLOT(legendClicked(QwtPlotItem*)));
    #else
        legend->setDefaultItemMode(QwtLegendData::Clickable);        
        connect(legend, SIGNAL(clicked(const QVariant&, int)), SLOT(legendClickedNew(const QVariant&, int)));
    #endif    

    // grid
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin(true);
    #if (QWT_VERSION < QWT_VERSION_CHECK(6,1,0))
        grid->setMajPen(QPen(Qt::gray, 0, Qt::DotLine));
        grid->setMinPen(QPen(QColor(0x8, 0x8, 0x8), 0 , Qt::DotLine));
    #else
        grid->setMajorPen(QPen(Qt::gray, 0, Qt::DotLine));
        grid->setMinorPen(QPen(QColor(0x8, 0x8, 0x8), 0 , Qt::DotLine));
    #endif
    grid->attach(this);

    // axes
    //enableAxis(QwtPlot::yRight);
    setAxisTitle(QwtPlot::xBottom, "time");
    setAxisScaleDraw(QwtPlot::xBottom, new HumanReadableTime()); // no need to de-alloc or store, plot does it

    // A-B markers
    for (int i=0; i<2; i++) {
        _user_markers[i].setLineStyle(QwtPlotMarker::VLine);
        _user_markers[i].setLabelAlignment(Qt::AlignRight | Qt::AlignBottom);
        _user_markers[i].setLinePen(QPen(QColor(255, 140, 0), 0, Qt::SolidLine));
        _user_markers_visible[i] = false;
    }
    _user_markers[0].setLabel(QwtText("A"));
    _user_markers[1].setLabel(QwtText("B"));

    // data marker
    _data_marker.setLineStyle(QwtPlotMarker::VLine);
    _data_marker.setLinePen(QPen(QColor(255, 160, 47), 2, Qt::SolidLine));
    _data_marker.setLabel(QwtText("data"));
    _data_marker.setLabelAlignment(Qt::AlignTop | Qt::AlignRight);
    _data_marker_visible = false;
    _data_marker.setZ(9999); // higher value -> paint on top of everything else

    setAutoReplot(true);
}
开发者ID:mbeckersys,项目名称:MavLogAnalyzer,代码行数:53,代码来源:mavplot.cpp

示例5: QwtScaleDraw

PlotWidget::PlotWidget(QWidget *parent) :
    QwtPlot(parent),
    ui(new Ui::PlotWidget)
{
    ui->setupUi(this);

    // Setup plot stuff
    setAutoReplot(false);
    canvas()->setBorderRadius( 10 );

    plotLayout()->setAlignCanvasToScales(true);

    QwtLegend *legend = new QwtLegend;
    legend->setItemMode(QwtLegend::CheckableItem);
    insertLegend(legend, QwtPlot::RightLegend);

    setAxisTitle(QwtPlot::xBottom, " Time [s]");
    setAxisScaleDraw(QwtPlot::xBottom,
                     new QwtScaleDraw());
    setAxisAutoScale(QwtPlot::xBottom, false);
    setAxisScale(QwtPlot::xBottom, 0, Market::EXPERIMENT_RUNNING_TIME);
    setAxisLabelRotation(QwtPlot::xBottom, -50.0);
    setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);

    setAxisTitle(QwtPlot::yLeft, " Price [$]");
    setAxisScaleDraw(QwtPlot::yLeft,
                     new QwtScaleDraw());
    setAxisScale(QwtPlot::yLeft, 0, MAX_PRICE_PLOT);
    setAxisLabelRotation(QwtPlot::yLeft, -50.0);
    setAxisLabelAlignment(QwtPlot::yLeft, Qt::AlignLeft | Qt::AlignBottom);

    // Setup the data
    asset1Data = new CircularBuffer((Market::EXPERIMENT_RUNNING_TIME)/2 + 4); // Running time, /2 for data every 2 seconds, + a safety buffer
    asset2Data = new CircularBuffer((Market::EXPERIMENT_RUNNING_TIME)/2 + 4);
    timeData = new CircularBuffer((Market::EXPERIMENT_RUNNING_TIME)/2 + 4);

    asset1Curve = new QwtPlotCurve("Asset 1");
    asset1Curve->setPen(QPen(Qt::red));
    asset1Curve->attach(this);

    asset2Curve = new QwtPlotCurve("Asset 2");
    asset2Curve->setPen(QPen(Qt::blue));
    asset2Curve->attach(this);
}
开发者ID:dwattttt,项目名称:marketsim,代码行数:44,代码来源:plotwidget.cpp

示例6: percentColor

	BatteryHistoryDialog::BatteryHistoryDialog (int histSize, QWidget *parent)
	: QDialog (parent)
	, Percent_ (new QwtPlotCurve (tr ("Percentage")))
	, Energy_ (new QwtPlotCurve (tr ("Energy rate")))
	{
		Ui_.setupUi (this);

		Ui_.PercentPlot_->setAxisAutoScale (QwtPlot::xBottom, false);
		Ui_.PercentPlot_->setAxisAutoScale (QwtPlot::yLeft, false);
		Ui_.PercentPlot_->setAxisScale (QwtPlot::xBottom, 0, histSize);
		Ui_.PercentPlot_->setAxisScale (QwtPlot::yLeft, 0, 100);
		Ui_.PercentPlot_->enableAxis (QwtPlot::yRight);
		Ui_.PercentPlot_->setAxisTitle (QwtPlot::yLeft, tr ("Percent"));
		Ui_.PercentPlot_->setAxisTitle (QwtPlot::yRight, tr ("Energy rate, W"));

		QColor percentColor (Qt::blue);
		Percent_->setPen (QPen (percentColor));
		percentColor.setAlpha (20);
		Percent_->setBrush (percentColor);

		Percent_->setRenderHint (QwtPlotItem::RenderAntialiased);
		Percent_->attach (Ui_.PercentPlot_);

		QColor energyColor (Qt::red);
		Energy_->setPen (QPen (energyColor));
		energyColor.setAlpha (20);
		Energy_->setBrush (energyColor);

		Energy_->setRenderHint (QwtPlotItem::RenderAntialiased);
		Energy_->setYAxis (QwtPlot::yRight);
		Energy_->attach (Ui_.PercentPlot_);

		QwtLegend *legend = new QwtLegend;
		legend->setItemMode (QwtLegend::ClickableItem);
		Ui_.PercentPlot_->insertLegend (legend, QwtPlot::BottomLegend);
	}
开发者ID:Akon32,项目名称:leechcraft,代码行数:36,代码来源:batteryhistorydialog.cpp

示例7: QDialog

//---------------------------------------------------------------------------
JrkPlotDialog::JrkPlotDialog(jrk_variables *indata, jrk_pid_variables *pid_indata, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::JrkPlotDialog)
{
    int i;

    ui->setupUi(this);
    setLayout(ui->mainLayout);

    interval(200);
    history(10);
    setSamples();

    data_ptr = indata;
    pid_data_ptr = pid_indata;

    timeData = (double *) malloc(SAMPLES * sizeof(double));
    reset();

    ui->jrkPlot->setAutoReplot(false);
    ui->jrkPlot->canvas()->setBorderRadius(0);
    ui->jrkPlot->plotLayout()->setAlignCanvasToScales(true);
    ui->jrkPlot->setCanvasBackground(Qt::white);

    QwtLegend *legend = new QwtLegend;
    legend->setItemMode(QwtLegend::CheckableItem);
    ui->jrkPlot->insertLegend(legend, QwtPlot::RightLegend);

    ui->jrkPlot->setAxisTitle(QwtPlot::xBottom, "Seconds");
    ui->jrkPlot->setAxisScale(QwtPlot::xBottom, timeData[0], timeData[SAMPLES - 1]);

//    ui->jrkPlot->setAxisLabelRotation( QwtPlot::xBottom, -50.0 );
    ui->jrkPlot->setAxisLabelAlignment( QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom );
    QwtScaleWidget *scaleWidget = ui->jrkPlot->axisWidget(QwtPlot::xBottom);
    i = QFontMetrics(scaleWidget->font()).height();
    scaleWidget->setMinBorderDist(0, i / 2);

    ui->jrkPlot->setAxisTitle(QwtPlot::yLeft, "%");
    ui->jrkPlot->setAxisScale(QwtPlot::yLeft, -100, 100);

    // picker, panner, zoomer
    plot_picker = new QwtPlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
                                    QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn,
                                    ui->jrkPlot->canvas());
#if 0
    plot_picker->setStateMachine(new QwtPickerDragPointMachine());
    plot_picker->setRubberBandPen(QColor(Qt::black));
    plot_picker->setRubberBand(QwtPicker::CrossRubberBand );
#endif
    plot_picker->setTrackerPen(QColor(Qt::black));

    // panning with the left mouse button
    plot_panner = new QwtPlotPanner(ui->jrkPlot->canvas());
    plot_panner->setUpdatesEnabled(true);

    // zoom in/out with the wheel
    plot_zoomer = new QwtPlotMagnifier(ui->jrkPlot->canvas());

    // grid
    QwtPlotGrid *grid = new QwtPlotGrid;
    grid->enableXMin( true );
    grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
    grid->setMinPen(QPen(Qt::black, 0, Qt::DotLine));
    grid->attach(ui->jrkPlot);

    // curves, scale is in %
    createCurve("Input",                Qt::gray,           false,  4095);
    createCurve("Target",               Qt::blue,           false,  4095);
    createCurve("Feedback",             Qt::darkBlue,       false,  4095);
    createCurve("Scaled feedback",      Qt::magenta,        false,  4095);
    createCurve("Error",                Qt::red,            true,   4095);
    createCurve("Integral",             Qt::darkGreen,      false,  1000);
    createCurve("Derivative",           Qt::yellow,         false,  1000);
    createCurve("Duty cycle target",    Qt::darkCyan,       false,  0600);
    createCurve("Duty cycle",           Qt::darkRed,        false,  0600);
    createCurve("Current",              Qt::black,          true,   0050);

    plot_timer = new QTimer(this);
    plot_timer->setInterval(INTERVAL);

    connect(plot_timer, SIGNAL(timeout()), this, SLOT(onUpdateGraph()));
    connect(ui->jrkPlot, SIGNAL(legendChecked(QwtPlotItem *, bool)),
            SLOT(showCurve(QwtPlotItem *, bool)));

#if 0
    connect(plot_picker, SIGNAL(moved(const QPoint &)),
            SLOT(picker_moved(const QPoint &)));
    connect(plot_picker, SIGNAL(selected(const QPolygon &)),
            SLOT(picker_selected(const QPolygon &)));
#endif

    connect(this, SIGNAL(finished(int)), this, SLOT(onFinished(int)));

//    plot_timer->start();
}
开发者ID:poes-weather,项目名称:Sensor-Benchmark,代码行数:96,代码来源:jrkplotdialog.cpp

示例8: QwtPlotPanner

AmpPlot::AmpPlot(QwtPlot *plot)
{

//TODO
//    _picker = new QwtPicker(canvas());
//    _picker->setStateMachine(new QwtPickerDragRectMachine());
//    _picker->setTrackerMode(QwtPicker::ActiveOnly);
//    _picker->setRubberBand(QwtPicker::RectRubberBand);

    _plot = plot;

    _panner = new QwtPlotPanner(_plot->canvas()); //Panning with the mouse
    _panner->setOrientations(Qt::Horizontal);
    //connect(_panner, SIGNAL(moved(int,int)), this, SLOT(pannerMoved(int,int)));

    _magnifier = new QwtPlotMagnifier(_plot->canvas()); //Zooming with the wheel

    _plot->canvas()->setBorderRadius(5);
    _plot->setCanvasBackground(Qt::white);
    _plot->plotLayout()->setAlignCanvasToScales(true);

    QwtLegend *legend = new QwtLegend;
    _plot->insertLegend(legend,QwtPlot::RightLegend);
    legend->setItemMode(QwtLegend::CheckableItem);
    connect(_plot,SIGNAL(legendChecked(QwtPlotItem*,bool)),SLOT(showCurve(QwtPlotItem*,bool)));

    _xMax = DEFAULT_X_MAX;
    _yMax = DEFAULT_Y_MAX;

    _plot->setAxisTitle(QwtPlot::xBottom, "ms");
    _plot->setAxisScale(QwtPlot::xBottom,0,_xMax);

    QwtScaleWidget *scaleWidget = _plot->axisWidget(QwtPlot::xBottom);
    const int fmh = QFontMetrics(scaleWidget->font()).height();
    scaleWidget->setMinBorderDist(0, fmh*2);

    _plot->setAxisTitle(QwtPlot::yLeft,"mA");
    _plot->setAxisAutoScale(QwtPlot::yLeft, true);

    _dataCurve = new QwtPlotCurve("mA");
    _dataCurve->attach(_plot);
    _dataCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    _dataCurve->setVisible(_plot);

    _meanCurve = new QwtPlotCurve("avg mean");
    _meanCurve->attach(_plot);
    _meanCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    _meanCurve->setPen(QPen(Qt::red));

    _maxCurve = new QwtPlotCurve("max");
    _maxCurve->attach(_plot);
    _maxCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    _maxCurve->setPen(QPen(Qt::darkMagenta));

    _currentMeanCurve = new QwtPlotCurve("mean");
    _currentMeanCurve->attach(_plot);
    _currentMeanCurve->setRenderHint(QwtPlotItem::RenderAntialiased);
    _currentMeanCurve->setPen(QPen(Qt::blue));

    showCurve(_dataCurve, true);
    showCurve(_meanCurve, false);
    showCurve(_maxCurve, false);
    showCurve(_currentMeanCurve, true);

    _time = new QTime();
    _time->start();

    _meanData.append(0.0);
    _meanTime.append(0.0);
    _meanData.append(0.0);
    _meanTime.append(0.0);

    _maxData.append(0.0);
    _maxTime.append(0.0);
    _maxData.append(0.0);
    _maxTime.append(0.0);

    _pauseTime = 0;


    _dataSource = NULL;

    _loadedCurve = NULL;
}
开发者ID:RazZziel,项目名称:ampMeter,代码行数:84,代码来源:ampplot.cpp

示例9: TimeScaleDraw

CpuPlot::CpuPlot(QWidget *parent):
    QwtPlot(parent),
    dataCount(0)
{
    setAutoReplot(false);

    plotLayout()->setAlignCanvasToScales(true);

    QwtLegend *legend = new QwtLegend;
    legend->setItemMode(QwtLegend::CheckableItem);
    insertLegend(legend, QwtPlot::RightLegend);

    setAxisTitle(QwtPlot::xBottom, " System Uptime [h:m:s]");
    setAxisScaleDraw(QwtPlot::xBottom,
                     new TimeScaleDraw(cpuStat.upTime()));
    setAxisScale(QwtPlot::xBottom, 0, HISTORY);
    setAxisLabelRotation(QwtPlot::xBottom, -50.0);
    setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);

    /*
     In situations, when there is a label at the most right position of the
     scale, additional space is needed to display the overlapping part
     of the label would be taken by reducing the width of scale and canvas.
     To avoid this "jumping canvas" effect, we add a permanent margin.
     We don't need to do the same for the left border, because there
     is enough space for the overlapping label below the left scale.
     */

    QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom);
    const int fmh = QFontMetrics(scaleWidget->font()).height();
    scaleWidget->setMinBorderDist(0, fmh / 2);

    setAxisTitle(QwtPlot::yLeft, "Cpu Usage [%]");
    setAxisScale(QwtPlot::yLeft, 0, 100);

    Background *bg = new Background();
    bg->attach(this);

    CpuPieMarker *pie = new CpuPieMarker();
    pie->attach(this);

    CpuCurve *curve;

    curve = new CpuCurve("System");
    curve->setColor(Qt::red);
    curve->attach(this);
    data[System].curve = curve;

    curve = new CpuCurve("User");
    curve->setColor(Qt::blue);
    curve->setZ(curve->z() - 1);
    curve->attach(this);
    data[User].curve = curve;

    curve = new CpuCurve("Total");
    curve->setColor(Qt::black);
    curve->setZ(curve->z() - 2);
    curve->attach(this);
    data[Total].curve = curve;

    curve = new CpuCurve("Idle");
    curve->setColor(Qt::darkCyan);
    curve->setZ(curve->z() - 3);
    curve->attach(this);
    data[Idle].curve = curve;

    showCurve(data[System].curve, true);
    showCurve(data[User].curve, true);
    showCurve(data[Total].curve, false);
    showCurve(data[Idle].curve, false);

    for ( int i = 0; i < HISTORY; i++ )
        timeData[HISTORY - 1 - i] = i;

    (void)startTimer(1000); // 1 second

    connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)),
            SLOT(showCurve(QwtPlotItem *, bool)));
}
开发者ID:PrincetonPAVE,项目名称:old_igvc,代码行数:79,代码来源:cpuplot.cpp

示例10: TimeScaleDraw

QwtGrapher::QwtGrapher(QWidget* parent):
    QwtPlot(parent) {
    m_values = new TwoDArray<double>(3,100);
    plotLayout()->setAlignCanvasToScales(true);
    QwtLegend *legend = new QwtLegend;
    legend->setItemMode(QwtLegend::CheckableItem);
    insertLegend(legend, QwtPlot::RightLegend);

    setAxisTitle(QwtPlot::xBottom, " FitnessCases");
    /*setAxisScaleDraw(QwtPlot::xBottom,
     new TimeScaleDraw(cpuStat.upTime()));
     setAxisScale(QwtPlot::xBottom, 0, HISTORY);
     setAxisLabelRotation(QwtPlot::xBottom, -50.0);
     setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
     */
    /*
     In situations, when there is a label at the most right position of the
     scale, additional space is needed to display the overlapping part
     of the label would be taken by reducing the width of scale and canvas.
     To avoid this "jumping canvas" effect, we add a permanent margin.
     We don't need to do the same for the left border, because there
     is enough space for the overlapping label below the left scale.
     */

    QwtScaleWidget *scaleWidget = axisWidget(QwtPlot::xBottom);
    const int fmh = QFontMetrics(scaleWidget->font()).height();
    scaleWidget->setMinBorderDist(0, fmh / 2);

    setAxisTitle(QwtPlot::yLeft, "Ouput") ;
    //setAxisScale(QwtPlot::yLeft, 0, 100);

    // Background *bg = new Background();
    //bg->attach(this);

    /*CpuPieMarker *pie = new CpuPieMarker();
     pie->attach(this);
     */
    QwtPlotCurve *curve;

    curve = new QwtPlotCurve("Best");
    curve->setPen(QColor(Qt::green));
    curve->attach(this);
    m_curves[0] = curve;

    curve = new QwtPlotCurve("Average");
    curve->setPen(QColor(Qt::blue));
    curve->setZ(curve->z() - 1);
    curve->attach(this);
    m_curves[1] = curve;

    curve = new QwtPlotCurve("Worst");
    curve->setPen(QColor(Qt::black));
    curve->setZ(curve->z() - 2);
    curve->attach(this);
    m_curves[2] = curve;

    showCurve(m_curves[0], true);
    showCurve(m_curves[1], true);
    showCurve(m_curves[2], true);

    connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)),
            SLOT(showCurve(QwtPlotItem *, bool)));
}
开发者ID:jesloper,项目名称:CGP,代码行数:63,代码来源:QwtGrapher.cpp


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