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


C++ QCPGraph::setData方法代码示例

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


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

示例1: updateCurve

void OdroidReader::updateCurve(int row, int col) {
	if (col != 0) return;

	bool enable = ui->sensors->item(row,col)->checkState() == Qt::Checked;
	if (enable && graphs.at(row) == nullptr) {
		if (origcols.count() == 0) {
			ui->sensors->item(row,col)->setCheckState(Qt::Unchecked);
			return;
		}
		QColor color = origcols.takeFirst();
		QCPGraph* graph = ui->globalPlot->addGraph();
		DataSeries* series =  data[rowMap[row]];
		graph->setName(series->descriptor->name());
		graph->setProperty("unit",series->descriptor->unit());
		graph->setPen(color);
		graph->setData(series->getTimestamps(), series->getValues());
		connect(series,&DataSeries::newValue,[graph,this](double time, double value) {
			graph->addData(time,value);
			ui->globalPlot->rescaleAxes();
			ui->globalPlot->yAxis->scaleRange(1.2,ui->globalPlot->yAxis->range().center());
			ui->globalPlot->replot();
		});
		graphs[row] = graph;
		ui->sensors->item(row,col)->setBackgroundColor(color);
	} else if (!enable && graphs.at(row) != nullptr){
		disconnect(data.at(rowMap[row]),SIGNAL(newValue(double,double)),0,0);
		origcols.push_front(graphs.at(row)->pen().color());
		ui->globalPlot->removeGraph(graphs.at(row));
		graphs[row] = nullptr;
		ui->sensors->item(row,col)->setBackgroundColor(Qt::white);
	}
开发者ID:TUD-OS,项目名称:OdroidReader,代码行数:31,代码来源:odroidreader.cpp

示例2: addBaseLine

void ScatterWidget::addBaseLine(const PointD &p1, const PointD &p2, string legend)
{
    QCPGraph *graph = NULL;
    int nG = ui->scatter->graphCount();
    for(int j=0; j<nG; j++)
    {
        if(ui->scatter->graph(j)->name() == QString::fromStdString(legend))
        {
            graph = ui->scatter->graph(j);
            break;
        }
    }

    if(!graph)
    {
        graph = ui->scatter->addGraph();
        // ----------------------- Scatter Configuration ---------------------------
        graph->setName(QString::fromStdString(legend));
        QColor color_ = colorManager.getNewDifferentColor();
        graph->setPen(QPen(color_));
    }
    QVector<double> keys, vals;
    keys << p1.x << p2.x;
    vals << p1.y << p2.y;
    graph->setData(keys, vals);
}
开发者ID:amiryanj,项目名称:smart-debug,代码行数:26,代码来源:scatterwidget.cpp

示例3: createGraph

static void createGraph(QCustomPlot *plot, QVector<double> &steps, QVector<double> &data, const Qt::GlobalColor &color, const Qt::PenStyle &style, const int width)
{
	QCPGraph *graph = plot->addGraph();
	QPen pen(color);
	pen.setStyle(style);
	pen.setWidth(width);
	graph->setPen(pen);
	graph->setData(steps, data);
}
开发者ID:ArthurMarz,项目名称:DynamicAudioNormalizer,代码行数:9,代码来源:Main.cpp

示例4: on_listView_clicked

void MainWindow::on_listView_clicked(const QModelIndex &index)
{
    //QModelIndex a = ui->listView->selectedIndexes().back();
    QVariant selected = dataModel->compNameList->data(index,Qt::DisplayRole);
    dataModel->dataViewComp = selected.toString();
    QVector<double> dataViewPrice = dataModel->priceBuff.value(selected.toString());
    QVector<double> xval;
    QVector<double> baseVal;
    if(dataViewPrice.empty()) return;
    double min = dataViewPrice[0];
    for(auto &i : dataViewPrice) min = std::fmin(min,i);
    for(int i = 0; i<dataViewPrice.size(); i++){
        xval<<i;
        baseVal<<min;
    }
    QCustomPlot* p = ui->qcpDataView;;
    p->clearGraphs();

    QCPGraph* timeline = new QCPGraph(p->xAxis,p->yAxis);
    timeline->addData(xval,dataViewPrice);
    QCPGraph* base = new QCPGraph(p->xAxis,p->yAxis);
    base->setData(xval,baseVal);

    p->addPlottable(timeline);
    p->addPlottable(base);

    timeline->setChannelFillGraph(base);
    timeline->setPen(QPen(QColor(0,0,0,0)));
    timeline->setBrush(QColor(0,0,255,100));

    //QVector<double> ticks;
    QVector<QString> labels;

    int L = this->dataModel->dateBuff.values()[0].size()-1;
    int len = 6;
    float step = (float)L/(float)len;
    for(int i = 0; i<= len; i++){
        labels<<this->dataModel->dateBuff.values()[0][i*step].toString("MM/yy");
    }

    p->xAxis->setTickVectorLabels(labels);
    p->xAxis->setAutoTicks(true);
    p->xAxis->setAutoTickLabels(false);

    p->xAxis->setTickLabelRotation(-60);
    //p->xAxis->setSubTickCount(0);
    //p->xAxis->setTickLength(0, len-1);

    p->xAxis->grid()->setVisible(true);
    //p->xAxis->setRange(0, len-2);
    //p->xAxis->setTickVector(ticks);

    p->rescaleAxes();
    p->replot();
}
开发者ID:kaiyuzhao,项目名称:ModelAnalytics,代码行数:55,代码来源:mainwindow.cpp

示例5: createWaveFormPic

void Record::createWaveFormPic(Ffmpeg_t *ffmpeg, QString recortPath) {

    std::pair<std::vector<double>, std::vector<double> > dataWaveForm = ffmpeg->getSamplesForWaveformPlotting(recortPath + "/" + m_Name);
    QCustomPlot Plotter;
    Plotter.setBackground(QBrush(Qt::transparent) );
    Plotter.xAxis->setVisible(false);
    Plotter.yAxis->setVisible(false);
    Plotter.axisRect()->setAutoMargins(QCP::msNone);
    Plotter.axisRect()->setMargins(QMargins(0, 5, 0, 5));
    QCPGraph *Waveform = Plotter.addGraph();
    Waveform->setPen(QPen(Qt::green) );

    if (!Waveform)
    {
        qDebug("addGraph failed\n");
    }

    QVector<double> Amplitudes(QVector<double>::fromStdVector(dataWaveForm.first) );
    QVector<double> Time;

    double CurrentTime = 0;
    auto TimeSlotCount = Amplitudes.size();

    for (int64_t i = 1; i < TimeSlotCount; i++)
    {
        Time.append(CurrentTime);
        CurrentTime += 0.5;
    }

    Waveform->setData(Time, Amplitudes);
    Plotter.xAxis->setRange(0, Time.back() );
    Plotter.yAxis->setRange(SHRT_MIN, SHRT_MAX);

    QByteArray ByteArray;
    QBuffer Buffer(&ByteArray);
    Buffer.open(QBuffer::WriteOnly);
    uint32_t time = m_EndTime - m_StartTime;
    for (int i = 1; i < 10000; i*=10) {
        Plotter.toPixmap(time/(i), this->height()).save(&Buffer, "PNG", 0);
        //Plotter.saveJpg(recortPath + "/plot" + QString::number(m_Id) + QString::number(i) + ".jpg", time/(i), this->height());

        QPixmap Pixmap;
        Pixmap.loadFromData(ByteArray, "PNG");
        v_PixWaves.append(Pixmap);

        ByteArray.clear();
        Buffer.reset();
    }
    Buffer.close();
    qDebug() << m_WavePic->margin();
    // místo 2 podle toho jaký zoom
    m_WavePic->setPixmap(v_PixWaves[2]);

}
开发者ID:PetrosW,项目名称:pDub,代码行数:54,代码来源:record.cpp

示例6: updateDetails

void DataExplorer::updateDetails() {
	//qDebug() << "SELECT!";
    ui->runPlot->clearPlottables();
	QVector<QString> labels;
	QVector<double> ticks;
	int colid = 0;
	switch (ui->detailType->currentIndex()) {
	  case 0:
		ui->runPlot->xAxis->setAutoTicks(true);
		ui->runPlot->xAxis->setAutoTickLabels(true);
		for (QCPAbstractPlottable *p : ui->selectEnvironment->selectedPlottables()) {
			int unitid = p->property("UID").toInt();
			int envid = p->property("EID").toInt();
			DataSeries v = exp->runs.keys().at(envid)->run(unitid,ui->runNo->value(),exp);
			QCPGraph *g = ui->runPlot->addGraph();
			g->setName(v.descriptor->name()+" @ "+exp->runs.keys().at(envid)->label);
			g->setProperty("Unit",v.descriptor->unit());
			g->setPen(origcols[colid++%origcols.size()]);
			g->setData(v.getTimestamps(),v.getValues());
		}
		break;
	  case 1:
		for (QCPAbstractPlottable *p : ui->selectEnvironment->selectedPlottables()) {
			int unitid = p->property("UID").toInt();
			int envid = p->property("EID").toInt();
			StatisticalSet vals = exp->runs.keys().at(envid)->integral(unitid,exp);
			QCPStatisticalBox* b = new QCPStatisticalBox(ui->runPlot->xAxis,ui->runPlot->yAxis);
			b->setData(colid,vals.min(),vals.quantile(0.25),vals.median(),vals.quantile(0.75),vals.max());
			b->setProperty("StdDev",vals.getStdDev());
			b->setProperty("avg",vals.avg());
			b->setProperty("avgTime",vals.avgTime());
			qWarning() << exp->data.at(unitid)->descriptor->name() <<  exp->runs.keys().at(envid)->label << vals.avg() << vals.avgTime() << vals.getStdDev();
			ui->runPlot->addPlottable(b);
			labels.append(QString("%1 @ %2").arg(exp->data.at(unitid)->descriptor->name(),exp->runs.keys().at(envid)->label));
			ticks.append(colid++);
			ui->runPlot->xAxis->setAutoTicks(false);
			ui->runPlot->xAxis->setAutoTickLabels(false);
			ui->runPlot->xAxis->setSubTickCount(0);
			ui->runPlot->xAxis->setTickLength(0, 4);
			ui->runPlot->xAxis->setTickLabelRotation(90);
			ui->runPlot->xAxis->setTickVector(ticks);
			ui->runPlot->xAxis->setTickVectorLabels(labels);
		}
		break;
	  case 2: break;
	}
    ui->runPlot->rescaleAxes();
    if (ui->axisFromZero->isChecked())
        ui->runPlot->yAxis->setRangeLower(0);
    ui->runPlot->replot();
}
开发者ID:TUD-OS,项目名称:OdroidReader,代码行数:51,代码来源:dataexplorer.cpp

示例7: addBodePlot

void BodeWidget::addBodePlot(BodeData *data, const QString& name){
    QCPGraph* dbGraph = dbPlot->addGraph();
    QCPGraph* paGraph = paPlot->addGraph();

    dbGraph->setData(data->at(0), data->at(1));
    paGraph->setData(data->at(0), data->at(2));

    dbGraph->setName(name);
    paGraph->setName(name);


    dbGraph->setPen(QPen(QColor::fromHsv(hue, 255, 255, 192)));
    paGraph->setPen(QPen(QColor::fromHsv(hue, 255, 255, 192)));

    paGraph->setVisible(false);

    dbGraph->rescaleAxes();
    paGraph->rescaleAxes();

    hue += 17;
    hue %= 360;

    this->paGraphMap[dbGraph] = paGraph;
}
开发者ID:Bakhazard,项目名称:plc-gnosis,代码行数:24,代码来源:bodewidget.cpp

示例8: setupItemTracerTest_MyTest_addGrap

void MainWindow::setupItemTracerTest_MyTest_addGrap(QCustomPlot *customPlot, QCPAxisRect* pAxisRect)
{


	QCPGraph *graph = customPlot->addGraph(pAxisRect->axis(QCPAxis::atBottom), pAxisRect->axis(QCPAxis::atLeft));
	int n = 200;
	QVector<double> x(n), y(n);
	for (int nIndex=0; nIndex<n; ++nIndex)
	{
		//x[i] = 0.5+i/(double)n*4;
		unsigned int nTimeNow = 0;
		double xValue = 0.5 + nIndex/(double)n*4;
		nTimeNow = QDateTime::currentDateTime().toTime_t() + nIndex;
		x[nIndex] = nTimeNow;
		//y[nIndex] = qSin(x[nIndex])+1.5;//
		y[nIndex] = qSin(xValue)+1.5;//
	}
	graph->setData(x, y);
}
开发者ID:shenglonglinapple,项目名称:slin_code,代码行数:19,代码来源:mainwindow.cpp

示例9: ConvertProfile

void ConvertProfile(TProfile* prof, QCPGraph &graph){
  //how we put the profile histogram in Qt.
  //passing the graph to alter is just easier :)
  QVector<double> xvals,yvals,xerrs, yerrs;
  int nbins = prof->GetNbinsX();
  //get the values
  for(int i=0; i<nbins;++i){
    xvals.push_back(prof->GetBinCenter(i+1));
    yvals.push_back(prof->GetBinContent(i+1));
    xerrs.push_back(prof->GetBinWidth(i+1)/2.);
    yerrs.push_back(prof->GetBinError(i+1));
  }
  
  graph.setData(xvals, yvals);
  graph.setDataValueError(xvals, yvals, yerrs);//symmetric errors, only in y.
  graph.setScatterStyle(QCPScatterStyle(QCPScatterStyle::ssCircle, QPen(Qt::black, 1.5), QBrush(Qt::white), 9));
  graph.setPen(QPen(QColor(120, 120, 120), 2));
  graph.setLineStyle(QCPGraph::LineStyle::lsNone);
  return;
}
开发者ID:adamdddave,项目名称:The40Thieves,代码行数:20,代码来源:RootHelpers.cpp

示例10: setupAdaptiveSamplingTest

void MainWindow::setupAdaptiveSamplingTest(QCustomPlot *customPlot)
{
	qsrand(1);
	QCPGraph *g = customPlot->addGraph();
	int n = 200000;
	QVector<double> x, y;
	x << -6;
	y << 2;
	for (int i=0; i<n/2; ++i)
	{
		x << i/(double)(n/2-1)*4-5;
		if (qrand()%(n/25) == 0)
			y << qrand()/(double)RAND_MAX*7; // generate outliers (must be preserved in adaptive-sampling-algorithm)
		else
			y << qCos(qrand()/(double)RAND_MAX*2*M_PI)*qSqrt(-2*qLn(qrand()/(double)RAND_MAX)) + 5*qSin(x[i]);
	}
	x << 0.5;
	y << 2;
	for (int i=0; i<n/2; ++i)
	{
		x << i/(double)(n/2-1)*4+1;
		if (qrand()%(n/25) == 0)
			y << qrand()/(double)RAND_MAX*7; // generate outliers (must be preserved in adaptive-sampling-algorithm)
		else
			y << qCos(qrand()/(double)RAND_MAX*2*M_PI)*qSqrt(-2*qLn(qrand()/(double)RAND_MAX)) + qSin(5*x[i]);
	}
	x << 6;
	y << -1;
	g->setData(x, y);
	//g->setScatterStyle(QCPScatterStyle::ssPlus);
	//g->setLineStyle(QCPGraph::lsNone);
	g->setAdaptiveSampling(true);

	customPlot->setPlottingHint(QCP::phFastPolylines, true);
	customPlot->rescaleAxes();
	customPlot->xAxis->scaleRange(1, customPlot->xAxis->range().center());
	customPlot->yAxis->scaleRange(1, customPlot->yAxis->range().center());
}
开发者ID:shenglonglinapple,项目名称:slin_code,代码行数:38,代码来源:mainwindow.cpp

示例11: updatePlot


//.........这里部分代码省略.........
            graph->setScatterStyle(QCP::ssDisc);
            graph->setScatterSize(10);

            Group group = *groupIterator;

            QColor color = group.getColor();
            mapGroupGraph[group] = graph;
            color.setAlphaF(0.3);
            pen.setColor(color);
            graph->setPen(pen);
        }
    }

    //int numberOfTrip = selectedTrips->size();
    map<Group,pair<QVector<double>,QVector<double> > > mapGroupData;
    if(buildGlobalPlot){
        int numberOfTrips = selectedTrips->size();
        //QVector<double> x(numberOfTrips), y(numberOfTrips);
        QVector<double> x, y;
        mapGroupData[QColor(0,0,0)] = make_pair(x,y);
    }
    else{
        QVector<double> x, y;
        for(groupIterator = groups.begin() ; groupIterator != groups.end() ; ++groupIterator){
            Group group = *groupIterator;

            mapGroupData[group.getColor()] = make_pair(x,y);

        }
    }

    // add graphs with different scatter styles:
    KdTrip::TripSet::iterator it = selectedTrips->begin();
    for (; it != selectedTrips->end(); ++it) {
        const KdTrip::Trip * trip = *it;
        QPointF coords = getCoords(trip);

        if(buildGlobalPlot){
            pair<QVector<double>,QVector<double> > &data =
                    mapGroupData[QColor(0,0,0)];
            QVector<double> &x = data.first;
            QVector<double> &y = data.second;
            x << coords.x();
            y << coords.y();
        }
        else{
            for(groupIterator = groups.begin() ; groupIterator != groups.end() ; ++groupIterator){
                Group currentGroup = *groupIterator;

                assert(mapGroupToNodes.count(currentGroup) > 0 && mapGroupToEdges.count(currentGroup) > 0);

                if(tripSatisfiesConstraints(trip, mapGroupToNodes[currentGroup],mapGroupToEdges[currentGroup])){
                    pair<QVector<double>,QVector<double> > &data =
                            mapGroupData[currentGroup.getColor()];
                    QVector<double> &x = data.first;
                    QVector<double> &y = data.second;
                    x << coords.x();
                    y << coords.y();
                    continue; // make sure the point is only added once
                }
            }
        }
    }

    if(buildGlobalPlot){
        pair<QVector<double>,QVector<double> > &data =
                mapGroupData[QColor(0,0,0)];
        QVector<double> &x = data.first;
        QVector<double> &y = data.second;
        QCPGraph* graph = mapGroupGraph[QColor(0,0,0)];
        graph->setData(x, y);
        graph->rescaleAxes(true);
    }
    else{
        for(groupIterator = groups.begin() ; groupIterator != groups.end() ; ++groupIterator){
            Group currentGroup = *groupIterator;
            pair<QVector<double>,QVector<double> > &data =
                    mapGroupData[currentGroup.getColor()];
            QVector<double> &x = data.first;
            QVector<double> &y = data.second;
            QCPGraph* graph = mapGroupGraph[currentGroup.getColor()];
            graph->setData(x, y);
            graph->rescaleAxes(true);
        }
    }

    //
    int numGraphs = ui->customPlot->graphCount();
    for(int i = 0 ; i < numGraphs ; ++i){
        ui->customPlot->graph(i)->rescaleAxes(false,true);
    }
    //ui->customPlot->yAxis->scaleRange(1.1, ui->customPlot->yAxis->range().center());
    ui->customPlot->setRangeDrag(Qt::Horizontal|Qt::Vertical);
    ui->customPlot->setRangeZoom(Qt::Horizontal|Qt::Vertical);
    ui->customPlot->setInteractions(QCustomPlot::iRangeDrag | QCustomPlot::iRangeZoom | QCustomPlot::iSelectAxes |
                                    QCustomPlot::iSelectLegend | QCustomPlot::iSelectPlottables | QCustomPlot::iSelectTitle);

    //
    ui->customPlot->replot();
}
开发者ID:Rambo2015,项目名称:TaxiVis,代码行数:101,代码来源:scatterplotwidget.cpp

示例12: mkSensorModel

void Dialog::mkSensorModel()
{
	QCPGraph * gr;
	QPen pn;

	double simTime = 60.0;
	double simStepTime = 0.1;

	double tempStart = 25.0;
	double tempCurrent = tempStart;
	double tempSet = 35.0;
	double tempDeltaPrev = 0.0;

	int normalFixDeep = 5;

	int steps = simTime / simStepTime;

	QVector<double> xTime(steps), yTemp(steps), yTempSet(steps);
	QVector<double> normalValues(normalFixDeep);
	normalValues.fill(0);

	QVector<double> tempLabels;
	for (int x=10; x<=50; x+=5) tempLabels.push_back(x);

	QVector<double> timeLabels;
	for (int x=0; x<=simTime; x+=5) timeLabels.push_back(x);

	for (int x=0; x<steps; x++)
	{
		// Calc new temp value
		double tempApply = 0.0; // No change
		double tempDelta = std::abs(tempCurrent - tempSet);
		double stepDir = (tempCurrent < tempSet) ? 1.0 : -1.0;
		if (0.1 < tempDelta)
		{
			if (tempDelta > 10)
			{
				tempApply = 0.19 * 1.0;
			} else {
				tempApply = 0.2 * (1.0 * (tempDelta/10.0) );
			}

			// if (tempApply < 0.01) tempApply = 0.01;

			// qDebug() << tempApply;

			tempApply = tempApply * stepDir;

			// Calc normalzied value
			double lastSum = 0;
			for (int x=0; x<normalFixDeep; x++) lastSum += normalValues[x];
			tempApply = (lastSum + tempApply) / ((double)normalFixDeep + 1.0);

			tempDeltaPrev = tempApply;
			tempCurrent = tempCurrent + tempApply;
			qDebug() << tempCurrent;
		}

		normalValues.push_back(tempApply);
		normalValues.pop_front();

		xTime[x] = (double)x * simStepTime;

		if (10.0 == xTime[x]) tempSet = 40.0;
		if (40.0 == xTime[x]) tempSet = 30.0;

		yTempSet[x] = tempSet;
		yTemp[x] = tempCurrent;
	}

	gr = ui->plot->addGraph();
	gr->setData(xTime, yTemp);
	pn.setColor(Qt::red);
	pn.setWidth(3);
	gr->setPen(pn);
	gr->setName("Реальное значение");

	gr = ui->plot->addGraph();
	gr->setData(xTime, yTempSet);
	pn.setColor(0x008080);
	pn.setWidth(1);
	pn.setStyle(Qt::DashLine);
	gr->setPen(pn);
	gr->setName("Конечное значение");




	ui->plot->xAxis->setLabel("Время, сек");
	ui->plot->xAxis->setRange(0, simTime);
	ui->plot->xAxis->setAutoTicks(false);
	ui->plot->xAxis->setTickVector(timeLabels);

	ui->plot->yAxis->setLabel("Температура, °C");
	ui->plot->yAxis->setRange(20, 50);
	ui->plot->yAxis->setAutoTicks(false);
	ui->plot->yAxis->setTickVector(tempLabels);

	ui->plot->legend->setVisible(true);

//.........这里部分代码省略.........
开发者ID:petrows,项目名称:boiler-autotemp,代码行数:101,代码来源:dialog.cpp

示例13: mkGraph

void Dialog::mkGraph()
{
	QCPGraph * gr;
	QPen pn;

	QVector<double> timeLabels, tempLabels, drosselLabels;
	for (int x=0; x<mdl.simTime; x+=10) timeLabels.push_back(x);
	for (int x=0; x<=80; x+=5) tempLabels.push_back(x);
	for (int x=0; x<=120; x+=10) drosselLabels.push_back(x);

	gr = ui->plot->addGraph();
	gr->setData(mdl.xTime, mdl.yTempOutput);
	pn.setColor(Qt::red);
	pn.setWidth(3);
	gr->setPen(pn);
	gr->setName("Реальное значение, °C");

	gr = ui->plot->addGraph();
	gr->setData(mdl.xTime, mdl.yTempSet);
	pn.setColor(0x0000FF);
	pn.setWidth(2);
	pn.setStyle(Qt::DotLine);
	gr->setPen(pn);
	gr->setName("Конечное значение, °C");

	gr = ui->plot->addGraph();
	gr->setData(mdl.xTime, mdl.yTempCurrent);
	pn.setColor(0x808000);
	pn.setWidth(2);
	pn.setStyle(Qt::SolidLine);
	gr->setPen(pn);
	gr->setName("Желаемая температура, °C");

	gr = ui->plot->addGraph(0, ui->plot->yAxis2);
	gr->setData(mdl.xTime, mdl.yServoPos);
	pn.setColor(0x006600);
	pn.setWidth(2);
	pn.setStyle(Qt::DotLine);
	gr->setPen(pn);
	gr->setName("Дроссель, %");

	gr = ui->plot->addGraph(0, ui->plot->yAxis2);
	gr->setData(mdl.xTime, mdl.yPressure);
	pn.setColor(0x800080);
	pn.setWidth(2);
	pn.setStyle(Qt::SolidLine);
	gr->setPen(pn);
	gr->setName("Сила нагрева, %");

	ui->plot->xAxis->setLabel("Время, сек");
	ui->plot->xAxis->setRange(0, mdl.simTime);
	ui->plot->xAxis->setAutoTicks(false);
	ui->plot->xAxis->setTickVector(timeLabels);
	//ui->plot->xAxis->setAutoTickCount(15);
	ui->plot->xAxis->setSubTickCount(10);

	ui->plot->yAxis->setLabel("Температура, °C");
	ui->plot->yAxis->setRange(20, 80);
	ui->plot->yAxis->setAutoTicks(false);
	ui->plot->yAxis->setTickVector(tempLabels);
	ui->plot->yAxis->setSubTickCount(5);

	ui->plot->yAxis2->setLabel("Параметры, %");
	ui->plot->yAxis2->setRange(0, 150);
	ui->plot->yAxis2->setVisible(true);
	ui->plot->yAxis2->setAutoTicks(false);
	ui->plot->yAxis2->setTickVector(drosselLabels);

	ui->plot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignLeft|Qt::AlignTop);
	ui->plot->legend->setVisible(true);

	mdl.reset();
	mdl.tempCurrent = 40;
	mdl.pressureCoef = 1.0;
	repaintGraph("ideal");
/*
	mdl.reset();
	mdl.simTime = 180;
	mdl.tempCurrent = 35;
	mdl.pressureCoef = 1.2;
	mdl.paramsChanged.push_back(ParamChange(20.0, 0, 40));
	repaintGraph("hotrun");

	mdl.reset();
	mdl.tempCurrent = 35;
	mdl.pressureCoef = 1.2;
	mdl.paramsChanged.push_back(ParamChange(20.0, 0, 30));
	repaintGraph("hotrun-low");
// return;

	mdl.reset();
	mdl.tempCurrent = 45;
	mdl.pressureCoef = 0.5;
	mdl.paramsChanged.push_back(ParamChange(20.0, 0, 40));
	mdl.paramsChanged.push_back(ParamChange(30.0, 1.2, 0));
	repaintGraph("plow-hi");

	mdl.reset();
	mdl.tempCurrent = 45;
	mdl.pressureCoef = 0.5;
//.........这里部分代码省略.........
开发者ID:petrows,项目名称:boiler-autotemp,代码行数:101,代码来源:dialog.cpp

示例14: mkSensor

void Dialog::mkSensor()
{

    QCPGraph * gr;
    QPen pn;





    int steps = (20) + 1;
    double stepTemp = 0.47;

    QVector<double> xLabels;
    QVector<double> yLabels;
    QVector<double> xD(steps), yD(steps),yDlin(steps);

    for (int x=0; x<steps; x++)
    {
        //xD[x] = 30.0 + (stepTemp * (double)x) + 0.5 * ((double)(100 - qrand()%200) / 100.0);
        xD[x] = 30.0 + x;
        yD[x] = 158 + floor( ((double)x / 0.47) + 1.5 * ((double)(100 - qrand()%200) / 100.0) );
        yDlin[x] = 158.0 + ((double)x / 0.47);
        //if (((int)yD[x])%50 == 0) yLabels.push_back(yD[x]);
        //if (((int)xD[x])%10 == 0) xLabels.push_back(xD[x]);
    }

    for (int x=150; x<=210; x+=10)
    {
        yLabels.push_back(x);
    }

    for (int x=30; x<=50; x+=1)
    {
        xLabels.push_back(x);
    }

    qDebug() << yD;
    qDebug() << xD;

    gr = ui->plot->addGraph();
    gr->setData(xD, yD);
    pn.setColor(Qt::red);
    pn.setWidth(3);
    gr->setPen(pn);

    gr = ui->plot->addGraph();
    gr->setData(xD, yDlin);
    pn.setColor(0x008080);
    pn.setWidth(1);
    pn.setStyle(Qt::DashLine);
    gr->setPen(pn);

    ui->plot->xAxis->setLabel("Температура, °C");
    ui->plot->xAxis->setRange(30, 50);
    ui->plot->xAxis->setAutoTicks(false);
    ui->plot->xAxis->setTickVector(xLabels);
    ui->plot->yAxis->setLabel("Сигнал АЦП");
    ui->plot->yAxis->setRange(145, 215);
    ui->plot->yAxis->setAutoTicks(false);
    ui->plot->yAxis->setTickVector(yLabels);

    ui->plot->replot();
	ui->plot->savePdf("graph-sensor.pdf", false, 800, 400);
}
开发者ID:petrows,项目名称:boiler-autotemp,代码行数:65,代码来源:dialog.cpp

示例15: updatePlot

void LiftDragPlot::updatePlot()
{
    clearPlottables();
    clearItems();

    xAxis->setLabel(tr("Drag Coefficient"));
    yAxis->setLabel(tr("Lift Coefficient"));

    double lower = mMainWindow->rangeLower();
    double upper = mMainWindow->rangeUpper();

    QVector< double > t, x, y;

    double xMin, xMax;
    double yMin, yMax;

    int start = mMainWindow->findIndexBelowT(lower) + 1;
    int end   = mMainWindow->findIndexAboveT(upper);

    double s10 = 0, s01 = 0, s20 = 0, s11 = 0;
    double s21 = 0, s30 = 0, s40 = 0;

    bool first = true;
    for (int i = start; i < end; ++i)
    {
        const DataPoint &dp = mMainWindow->dataPoint(i);

        t.append(dp.t);
        x.append(dp.drag);
        y.append(dp.lift);

        if (first)
        {
            xMax = x.back();
            yMax = y.back();

            first = false;
        }
        else
        {
            if (x.back() > xMax) xMax = x.back();
            if (y.back() > yMax) yMax = y.back();
        }

        s10 += dp.lift;
        s01 += dp.drag;
        s20 += dp.lift * dp.lift;
        s11 += dp.lift * dp.drag;
        s21 += dp.lift * dp.lift * dp.drag;
        s30 += dp.lift * dp.lift * dp.lift;
        s40 += dp.lift * dp.lift * dp.lift * dp.lift;
    }

    QCPCurve *curve = new QCPCurve(xAxis, yAxis);
    curve->setData(t, x, y);
    curve->setPen(QPen(Qt::lightGray, mMainWindow->lineThickness()));
    curve->setLineStyle(QCPCurve::lsNone);
    curve->setScatterStyle(QCPScatterStyle::ssDisc);
    addPlottable(curve);

    setViewRange(xMax, yMax);

    // Update plot limits
    xMin = xAxis->range().lower;
    xMax = xAxis->range().upper;

    yMin = yAxis->range().lower;
    yMax = yAxis->range().upper;

    if (mMainWindow->markActive())
    {
        int i1 = mMainWindow->findIndexBelowT(mMainWindow->markEnd()) + 1;
        int i2 = mMainWindow->findIndexAboveT(mMainWindow->markEnd()) - 1;

        const DataPoint &dp1 = mMainWindow->dataPoint(i1);
        const DataPoint &dp2 = mMainWindow->dataPoint(i2);

        QVector< double > xMark, yMark;

        if (mMainWindow->markEnd() - dp1.t < dp2.t - mMainWindow->markEnd())
        {
            xMark.append(dp1.drag);
            yMark.append(dp1.lift);
        }
        else
        {
            xMark.append(dp2.drag);
            yMark.append(dp2.lift);
        }

        QCPGraph *graph = addGraph();
        graph->setData(xMark, yMark);
        graph->setPen(QPen(Qt::black, mMainWindow->lineThickness()));
        graph->setLineStyle(QCPGraph::lsNone);
        graph->setScatterStyle(QCPScatterStyle::ssDisc);
    }

    // x = ay^2 + c
    const double m = 1 / mMainWindow->maxLD();
    const double c = mMainWindow->minDrag();
//.........这里部分代码省略.........
开发者ID:FloKas,项目名称:flysight-viewer-qt,代码行数:101,代码来源:liftdragplot.cpp


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